refactor: compute reconnectionSteps out of auth steps
This commit is contained in:
@@ -133,96 +133,6 @@ export default {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
reconnectionSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'resetConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'consumerKey',
|
|
||||||
value: '{fields.consumerKey}'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerSecret',
|
|
||||||
value: '{fields.consumerSecret}'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'botToken',
|
|
||||||
value: '{fields.botToken}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createAuthData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'openWithPopup' as const,
|
|
||||||
name: 'openAuthPopup',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'url',
|
|
||||||
value: '{createAuthData.url}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'oauthVerifier',
|
|
||||||
value: '{openAuthPopup.code}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
createAuthData,
|
createAuthData,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
|
@@ -117,92 +117,6 @@ export default {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
reconnectionSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'resetConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'consumerKey',
|
|
||||||
value: '{fields.consumerKey}'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerSecret',
|
|
||||||
value: '{fields.consumerSecret}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createAuthData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'openWithPopup' as const,
|
|
||||||
name: 'openAuthPopup',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'url',
|
|
||||||
value: '{createAuthData.url}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'oauthVerifier',
|
|
||||||
value: '{openAuthPopup.oauth_verifier}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
createAuthData,
|
createAuthData,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
|
@@ -117,92 +117,6 @@ export default {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
reconnectionSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'resetConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'consumerKey',
|
|
||||||
value: '{fields.consumerKey}'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerSecret',
|
|
||||||
value: '{fields.consumerSecret}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createAuthData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'openWithPopup' as const,
|
|
||||||
name: 'openAuthPopup',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'url',
|
|
||||||
value: '{createAuthData.url}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'oauthVerifier',
|
|
||||||
value: '{openAuthPopup.code}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
createAuthData,
|
createAuthData,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
|
@@ -119,96 +119,6 @@ export default {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
reconnectionSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'resetConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'consumerKey',
|
|
||||||
value: '{fields.consumerKey}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerSecret',
|
|
||||||
value: '{fields.consumerSecret}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createAuthData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'openWithPopup' as const,
|
|
||||||
name: 'openAuthPopup',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'url',
|
|
||||||
value: '{createAuthData.url}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'code',
|
|
||||||
value: '{openAuthPopup.code}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'state',
|
|
||||||
value: '{openAuthPopup.state}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
createAuthData,
|
createAuthData,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
|
@@ -138,68 +138,6 @@ export default {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
reconnectionSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'resetConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'host',
|
|
||||||
value: '{fields.host}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'username',
|
|
||||||
value: '{fields.username}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'password',
|
|
||||||
value: '{fields.password}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'useTLS',
|
|
||||||
value: '{fields.useTls}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'port',
|
|
||||||
value: '{fields.port}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'fromEmail',
|
|
||||||
value: '{fields.fromEmail}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
isStillVerified,
|
isStillVerified,
|
||||||
};
|
};
|
||||||
|
@@ -63,52 +63,6 @@ export default {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
reconnectionSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'resetConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'accountSid',
|
|
||||||
value: '{fields.accountSid}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'authToken',
|
|
||||||
value: '{fields.authToken}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
isStillVerified,
|
isStillVerified,
|
||||||
|
@@ -115,92 +115,6 @@ export default {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
reconnectionSteps: [
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'resetConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'consumerKey',
|
|
||||||
value: '{fields.consumerKey}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'consumerSecret',
|
|
||||||
value: '{fields.consumerSecret}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'createAuthData',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'openWithPopup' as const,
|
|
||||||
name: 'openAuthPopup',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'url',
|
|
||||||
value: '{createAuthData.url}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'updateConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'formattedData',
|
|
||||||
value: null,
|
|
||||||
properties: [
|
|
||||||
{
|
|
||||||
name: 'oauthVerifier',
|
|
||||||
value: '{openAuthPopup.oauth_verifier}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'mutation' as const,
|
|
||||||
name: 'verifyConnection',
|
|
||||||
arguments: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
value: '{connection.id}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
createAuthData,
|
createAuthData,
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
|
@@ -126,7 +126,6 @@ type Auth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AuthenticationStep {
|
type AuthenticationStep {
|
||||||
step: Int
|
|
||||||
type: String
|
type: String
|
||||||
name: String
|
name: String
|
||||||
arguments: [AuthenticationStepArgument]
|
arguments: [AuthenticationStepArgument]
|
||||||
@@ -316,7 +315,6 @@ input PreviousStepInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ReconnectionStep {
|
type ReconnectionStep {
|
||||||
step: Int
|
|
||||||
type: String
|
type: String
|
||||||
name: String
|
name: String
|
||||||
arguments: [ReconnectionStepArgument]
|
arguments: [ReconnectionStepArgument]
|
||||||
|
81
packages/backend/src/helpers/add-reconnection-steps.ts
Normal file
81
packages/backend/src/helpers/add-reconnection-steps.ts
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import { IApp, IAuthenticationStep, IAuthenticationStepField } from '@automatisch/types';
|
||||||
|
import cloneDeep from 'lodash/cloneDeep';
|
||||||
|
|
||||||
|
const connectionIdArgument = {
|
||||||
|
name: 'id',
|
||||||
|
value: '{connection.id}',
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetConnectionStep = {
|
||||||
|
type: 'mutation' as const,
|
||||||
|
name: 'resetConnection',
|
||||||
|
arguments: [
|
||||||
|
connectionIdArgument,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
function replaceCreateConnection(string: string) {
|
||||||
|
return string.replace(
|
||||||
|
'{createConnection.id}',
|
||||||
|
'{connection.id}'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeAppKeyArgument(args: IAuthenticationStepField[]) {
|
||||||
|
return args.filter((argument) => argument.name !== 'key');
|
||||||
|
}
|
||||||
|
|
||||||
|
function addConnectionId(step: IAuthenticationStep) {
|
||||||
|
step.arguments = step.arguments.map((argument) => {
|
||||||
|
if (typeof argument.value === 'string') {
|
||||||
|
argument.value = replaceCreateConnection(argument.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argument.properties) {
|
||||||
|
argument.properties = argument.properties.map((property) => {
|
||||||
|
return {
|
||||||
|
name: property.name,
|
||||||
|
value: replaceCreateConnection(property.value),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return argument;
|
||||||
|
});
|
||||||
|
|
||||||
|
return step;
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceCreateConnectionsWithUpdate(steps: IAuthenticationStep[]) {
|
||||||
|
const updatedSteps = cloneDeep(steps);
|
||||||
|
return updatedSteps.map((step) => {
|
||||||
|
const updatedStep = addConnectionId(step);
|
||||||
|
|
||||||
|
if (step.name === 'createConnection') {
|
||||||
|
updatedStep.name = 'updateConnection';
|
||||||
|
updatedStep.arguments = removeAppKeyArgument(updatedStep.arguments);
|
||||||
|
updatedStep.arguments.unshift(connectionIdArgument);
|
||||||
|
|
||||||
|
return updatedStep;
|
||||||
|
}
|
||||||
|
|
||||||
|
return step;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function addReconnectionSteps(app: IApp): IApp {
|
||||||
|
const hasReconnectionSteps = app.auth.reconnectionSteps;
|
||||||
|
|
||||||
|
if (hasReconnectionSteps) return app;
|
||||||
|
|
||||||
|
const updatedSteps = replaceCreateConnectionsWithUpdate(app.auth.authenticationSteps);
|
||||||
|
|
||||||
|
app.auth.reconnectionSteps = [
|
||||||
|
resetConnectionStep,
|
||||||
|
...updatedSteps,
|
||||||
|
]
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default addReconnectionSteps;
|
@@ -6,6 +6,7 @@ import {
|
|||||||
ITrigger,
|
ITrigger,
|
||||||
} from '@automatisch/types';
|
} from '@automatisch/types';
|
||||||
import { omit, cloneDeep } from 'lodash';
|
import { omit, cloneDeep } from 'lodash';
|
||||||
|
import addReconnectionSteps from './add-reconnection-steps';
|
||||||
|
|
||||||
async function getDefaultExport(path: string) {
|
async function getDefaultExport(path: string) {
|
||||||
return (await import(path)).default;
|
return (await import(path)).default;
|
||||||
@@ -16,7 +17,11 @@ function stripFunctions<C>(data: C): C {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getApp = async (appKey: string, stripFuncs = true) => {
|
const getApp = async (appKey: string, stripFuncs = true) => {
|
||||||
const appData: IApp = cloneDeep(await getDefaultExport(`../apps/${appKey}`));
|
let appData: IApp = cloneDeep(await getDefaultExport(`../apps/${appKey}`));
|
||||||
|
|
||||||
|
if (appData.auth) {
|
||||||
|
appData = addReconnectionSteps(appData);
|
||||||
|
}
|
||||||
|
|
||||||
appData.triggers = appData?.triggers?.map((trigger: IRawTrigger) => {
|
appData.triggers = appData?.triggers?.map((trigger: IRawTrigger) => {
|
||||||
return addStaticSubsteps('trigger', appData, trigger);
|
return addStaticSubsteps('trigger', appData, trigger);
|
||||||
|
3
packages/types/index.d.ts
vendored
3
packages/types/index.d.ts
vendored
@@ -143,7 +143,6 @@ export interface IAuthenticationStepField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IAuthenticationStep {
|
export interface IAuthenticationStep {
|
||||||
step: number;
|
|
||||||
type: 'mutation' | 'openWithPopup';
|
type: 'mutation' | 'openWithPopup';
|
||||||
name: string;
|
name: string;
|
||||||
arguments: IAuthenticationStepField[];
|
arguments: IAuthenticationStepField[];
|
||||||
@@ -183,7 +182,7 @@ export interface IAuth {
|
|||||||
isStillVerified($: IGlobalVariable): Promise<boolean>;
|
isStillVerified($: IGlobalVariable): Promise<boolean>;
|
||||||
fields: IField[];
|
fields: IField[];
|
||||||
authenticationSteps: IAuthenticationStep[];
|
authenticationSteps: IAuthenticationStep[];
|
||||||
reconnectionSteps: IAuthenticationStep[];
|
reconnectionSteps?: IAuthenticationStep[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IService {
|
export interface IService {
|
||||||
|
@@ -87,7 +87,7 @@ function AppConnectionRow(props: AppConnectionRowProps): React.ReactElement {
|
|||||||
alignItems="flex-start"
|
alignItems="flex-start"
|
||||||
spacing={1}
|
spacing={1}
|
||||||
>
|
>
|
||||||
<Typography variant="h6">
|
<Typography variant="h6" sx={{ textAlign: 'left' }}>
|
||||||
{formattedData?.screenName}
|
{formattedData?.screenName}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
|
@@ -27,7 +27,6 @@ export const GET_APP = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
authenticationSteps {
|
authenticationSteps {
|
||||||
step
|
|
||||||
type
|
type
|
||||||
name
|
name
|
||||||
arguments {
|
arguments {
|
||||||
@@ -41,7 +40,6 @@ export const GET_APP = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
reconnectionSteps {
|
reconnectionSteps {
|
||||||
step
|
|
||||||
type
|
type
|
||||||
name
|
name
|
||||||
arguments {
|
arguments {
|
||||||
|
@@ -24,7 +24,6 @@ export const GET_APPS = gql`
|
|||||||
clickToCopy
|
clickToCopy
|
||||||
}
|
}
|
||||||
authenticationSteps {
|
authenticationSteps {
|
||||||
step
|
|
||||||
type
|
type
|
||||||
name
|
name
|
||||||
arguments {
|
arguments {
|
||||||
@@ -38,7 +37,6 @@ export const GET_APPS = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
reconnectionSteps {
|
reconnectionSteps {
|
||||||
step
|
|
||||||
type
|
type
|
||||||
name
|
name
|
||||||
arguments {
|
arguments {
|
||||||
|
Reference in New Issue
Block a user