diff --git a/src/__tests__/api/_test-utils/_action-instances.ts b/src/__tests__/api/_test-utils/_action-instances.ts index 37523920d..cfcf84c3b 100644 --- a/src/__tests__/api/_test-utils/_action-instances.ts +++ b/src/__tests__/api/_test-utils/_action-instances.ts @@ -1,24 +1,24 @@ import { createConfigDomainPersistenceService } from "backend/lib/config-persistence"; -import { ActionIntegrationKeys, IActionInstance } from "shared/types/actions"; +import { ActionIntegrations, IActionInstance } from "shared/types/actions"; import { DataEventActions } from "shared/types/data"; const TEST_ACTION_INSTANCES: IActionInstance[] = [ { instanceId: "instance-id-1", - integrationKey: ActionIntegrationKeys.SMTP, + integration: ActionIntegrations.SMTP, entity: "base-model", - implementationKey: "SEND_MESSAGE", - formAction: DataEventActions.Create, + action: "SEND_MESSAGE", + trigger: DataEventActions.Create, configuration: { foo: "bar", }, }, { instanceId: "instance-id-2", - integrationKey: ActionIntegrationKeys.HTTP, + integration: ActionIntegrations.HTTP, entity: "secondary-model", - implementationKey: "POST", - formAction: DataEventActions.Delete, + action: "POST", + trigger: DataEventActions.Delete, configuration: { bar: "foo", }, diff --git a/src/__tests__/api/_test-utils/_activated-integrations.ts b/src/__tests__/api/_test-utils/_activated-integrations.ts index baba21ce1..91f6facb8 100644 --- a/src/__tests__/api/_test-utils/_activated-integrations.ts +++ b/src/__tests__/api/_test-utils/_activated-integrations.ts @@ -1,20 +1,20 @@ import { createKeyValueDomainPersistenceService } from "backend/lib/key-value"; -import { ActionIntegrationKeys } from "shared/types/actions"; +import { ActionIntegrations } from "shared/types/actions"; -const TEST_ACTIVATED_ACTIONS: ActionIntegrationKeys[] = [ - ActionIntegrationKeys.SMTP, - ActionIntegrationKeys.SLACK, +const TEST_ACTIVATED_ACTIONS: ActionIntegrations[] = [ + ActionIntegrations.SMTP, + ActionIntegrations.SLACK, ]; export const setupActivatedIntegrationsTestData = async ( - testActivatedActions: ActionIntegrationKeys[] = TEST_ACTIVATED_ACTIONS + testActivatedIntegrations: ActionIntegrations[] = TEST_ACTIVATED_ACTIONS ) => { const activatedIntegrationsPersistenceService = - createKeyValueDomainPersistenceService( + createKeyValueDomainPersistenceService( "activated-integrations" ); await activatedIntegrationsPersistenceService.persistItem( - testActivatedActions + testActivatedIntegrations ); }; diff --git a/src/__tests__/api/dashboards/[dashboardId]/index.spec.ts b/src/__tests__/api/dashboards/[dashboardId]/index.spec.ts index a66d415f7..8d2a1fd02 100644 --- a/src/__tests__/api/dashboards/[dashboardId]/index.spec.ts +++ b/src/__tests__/api/dashboards/[dashboardId]/index.spec.ts @@ -211,7 +211,7 @@ describe("/api/dashboards/[dashboardId]/index generation", () => { "color": "red", "entity": "base-model", "icon": "ShoppingCart", - "id": "2", + "id": "1", "script": "const actual = await $.query(\`select count(*) as \`count\` from \`base-model\`\`); const relative = await $.query(\`select count(*) as \`count\` from \`base-model\` where \`createdAt\` < '$.RELATIVE_TIME'\`); @@ -224,7 +224,7 @@ describe("/api/dashboards/[dashboardId]/index generation", () => { "color": "orange", "entity": "secondary-model", "icon": "Activity", - "id": "1", + "id": "2", "script": "return await $.query(\`select count(*) as \`count\` from \`secondary-model\`\`)", "title": "Secondary Model", }, diff --git a/src/__tests__/api/integrations/actions/[key]/credentials.spec.ts b/src/__tests__/api/integrations/actions/[key]/credentials.spec.ts index 31594d2e8..648d64ccb 100644 --- a/src/__tests__/api/integrations/actions/[key]/credentials.spec.ts +++ b/src/__tests__/api/integrations/actions/[key]/credentials.spec.ts @@ -4,7 +4,7 @@ import { setupAllTestData, setupCredentialsTestData, } from "__tests__/api/_test-utils"; -import { ActionIntegrationKeys } from "shared/types/actions"; +import { ActionIntegrations } from "shared/types/actions"; describe("/api/integrations/actions/[key]/credentials", () => { beforeAll(async () => { @@ -27,7 +27,7 @@ describe("/api/integrations/actions/[key]/credentials", () => { const { req, res } = createAuthenticatedMocks({ method: "POST", query: { - key: ActionIntegrationKeys.SMTP, + key: ActionIntegrations.SMTP, }, body: { _password: "invalid password", @@ -51,7 +51,7 @@ describe("/api/integrations/actions/[key]/credentials", () => { const { req, res } = createAuthenticatedMocks({ method: "POST", query: { - key: ActionIntegrationKeys.SMTP, + key: ActionIntegrations.SMTP, }, body: { _password: "password", @@ -73,7 +73,7 @@ describe("/api/integrations/actions/[key]/credentials", () => { const { req, res } = createAuthenticatedMocks({ method: "POST", query: { - key: ActionIntegrationKeys.HTTP, + key: ActionIntegrations.HTTP, }, body: { _password: "password", diff --git a/src/__tests__/api/integrations/actions/[key]/index.spec.ts b/src/__tests__/api/integrations/actions/[key]/index.spec.ts index 414f7a18f..62fa8ed7d 100644 --- a/src/__tests__/api/integrations/actions/[key]/index.spec.ts +++ b/src/__tests__/api/integrations/actions/[key]/index.spec.ts @@ -8,7 +8,7 @@ import { setupAllTestData, } from "__tests__/api/_test-utils"; import { setupActionInstanceTestData } from "__tests__/api/_test-utils/_action-instances"; -import { ActionIntegrationKeys } from "shared/types/actions"; +import { ActionIntegrations } from "shared/types/actions"; import { DataEventActions } from "shared/types/data"; jest.mock("nanoid", () => ({ @@ -22,20 +22,20 @@ describe("/api/integrations/actions/[key]/index", () => { await setupActionInstanceTestData([ { instanceId: "instance-id-1", - integrationKey: ActionIntegrationKeys.HTTP, + integration: ActionIntegrations.HTTP, entity: "base-model", - implementationKey: "SEND_MESSAGE", - formAction: DataEventActions.Create, + action: "SEND_MESSAGE", + trigger: DataEventActions.Create, configuration: { foo: "bar", }, }, { instanceId: "instance-id-2", - integrationKey: ActionIntegrationKeys.SLACK, + integration: ActionIntegrations.SLACK, entity: "secondary-model", - implementationKey: "POST", - formAction: DataEventActions.Delete, + action: "POST", + trigger: DataEventActions.Delete, configuration: { bar: "foo", }, diff --git a/src/__tests__/api/integrations/actions/instances/[key].spec.ts b/src/__tests__/api/integrations/actions/instances/[key].spec.ts index 6d517e519..d6408b72f 100644 --- a/src/__tests__/api/integrations/actions/instances/[key].spec.ts +++ b/src/__tests__/api/integrations/actions/instances/[key].spec.ts @@ -1,5 +1,5 @@ import handler from "pages/api/integrations/actions/instances/[key]"; -import { ActionIntegrationKeys, IActionInstance } from "shared/types/actions"; +import { ActionIntegrations, IActionInstance } from "shared/types/actions"; import { createAuthenticatedMocks, setupAllTestData, @@ -10,40 +10,40 @@ import { DataEventActions } from "shared/types/data"; const TEST_ACTION_INSTANCES: IActionInstance[] = [ { instanceId: "instance-id-1", - integrationKey: ActionIntegrationKeys.SMTP, + integration: ActionIntegrations.SMTP, entity: "base-model", - implementationKey: "SEND_MESSAGE", - formAction: DataEventActions.Create, + action: "SEND_MESSAGE", + trigger: DataEventActions.Create, configuration: { foo: "bar", }, }, { instanceId: "instance-id-2", - integrationKey: ActionIntegrationKeys.SMTP, + integration: ActionIntegrations.SMTP, entity: "base-model", - implementationKey: "SEND_MESSAGE", - formAction: DataEventActions.Delete, + action: "SEND_MESSAGE", + trigger: DataEventActions.Delete, configuration: { foo1: "bar1", }, }, { instanceId: "instance-id-3", - integrationKey: ActionIntegrationKeys.SMTP, + integration: ActionIntegrations.SMTP, entity: "base-model", - implementationKey: "SEND_MESSAGE", - formAction: DataEventActions.Update, + action: "SEND_MESSAGE", + trigger: DataEventActions.Update, configuration: { foo2: "bar2", }, }, { instanceId: "instance-id-4", - integrationKey: ActionIntegrationKeys.HTTP, + integration: ActionIntegrations.HTTP, entity: "secondary-model", - implementationKey: "POST", - formAction: DataEventActions.Delete, + action: "POST", + trigger: DataEventActions.Delete, configuration: { bar: "foo", }, @@ -69,34 +69,34 @@ describe("/api/integrations/actions/instances/[key]", () => { expect(res._getJSONData()).toMatchInlineSnapshot(` [ { + "action": "SEND_MESSAGE", "configuration": { "foo": "bar", }, "entity": "base-model", - "formAction": "create", - "implementationKey": "SEND_MESSAGE", "instanceId": "instance-id-1", - "integrationKey": "smtp", + "integration": "smtp", + "trigger": "create", }, { + "action": "SEND_MESSAGE", "configuration": { "foo1": "bar1", }, "entity": "base-model", - "formAction": "delete", - "implementationKey": "SEND_MESSAGE", "instanceId": "instance-id-2", - "integrationKey": "smtp", + "integration": "smtp", + "trigger": "delete", }, { + "action": "SEND_MESSAGE", "configuration": { "foo2": "bar2", }, "entity": "base-model", - "formAction": "update", - "implementationKey": "SEND_MESSAGE", "instanceId": "instance-id-3", - "integrationKey": "smtp", + "integration": "smtp", + "trigger": "update", }, ] `); @@ -132,10 +132,10 @@ describe("/api/integrations/actions/instances/[key]", () => { key: "instance-id-2", }, body: { - integrationKey: "slack", + integration: "slack", entity: "base-model", - implementationKey: "SEND_MESSAGE_UPDATED", - formAction: "update", + action: "SEND_MESSAGE_UPDATED", + trigger: "update", configuration: { you: "are", awe: "some", @@ -158,25 +158,25 @@ describe("/api/integrations/actions/instances/[key]", () => { expect(getRes._getJSONData()).toMatchInlineSnapshot(` [ { + "action": "SEND_MESSAGE", "configuration": { "foo": "bar", }, "entity": "base-model", - "formAction": "create", - "implementationKey": "SEND_MESSAGE", "instanceId": "instance-id-1", - "integrationKey": "smtp", + "integration": "smtp", + "trigger": "create", }, { + "action": "SEND_MESSAGE_UPDATED", "configuration": { "awe": "some", "you": "are", }, "entity": "base-model", - "formAction": "update", - "implementationKey": "SEND_MESSAGE_UPDATED", "instanceId": "instance-id-2", - "integrationKey": "slack", + "integration": "slack", + "trigger": "update", }, ] `); diff --git a/src/__tests__/api/integrations/actions/instances/index.spec.ts b/src/__tests__/api/integrations/actions/instances/index.spec.ts index b86c52d21..762eb345b 100644 --- a/src/__tests__/api/integrations/actions/instances/index.spec.ts +++ b/src/__tests__/api/integrations/actions/instances/index.spec.ts @@ -22,9 +22,9 @@ describe("/api/integrations/actions/instances/index", () => { method: "POST", body: { entity: "test-entity", - integrationKey: "smtp", - implementationKey: "SEND_MESSAGE", - formAction: "update", + integration: "smtp", + action: "SEND_MESSAGE", + trigger: "update", configuration: { to: "me", subject: "something important", @@ -43,9 +43,9 @@ describe("/api/integrations/actions/instances/index", () => { method: "POST", body: { entity: "test-entity", - integrationKey: "http", - implementationKey: "PUT", - formAction: "create", + integration: "http", + action: "PUT", + trigger: "create", configuration: { url: "/some-where", body: '{"me": "you"}', @@ -63,10 +63,10 @@ describe("/api/integrations/actions/instances/index", () => { const { req, res } = createAuthenticatedMocks({ method: "POST", body: { - integrationKey: "postmark", + integration: "postmark", entity: "test-entity-2", - implementationKey: "GET", - formAction: "update", + action: "GET", + trigger: "update", configuration: { bad: '{"request": "hello"}', }, @@ -100,28 +100,28 @@ describe("/api/integrations/actions/instances/index", () => { expect(res._getJSONData()).toMatchInlineSnapshot(` [ { + "action": "SEND_MESSAGE", "configuration": { "body": "You are awesome", "subject": "something important", "to": "me", }, "entity": "test-entity", - "formAction": "update", - "implementationKey": "SEND_MESSAGE", "instanceId": "nano-id-1", - "integrationKey": "smtp", + "integration": "smtp", + "trigger": "update", }, { + "action": "PUT", "configuration": { "body": "{"me": "you"}", "headers": "{"me": "you"}", "url": "/some-where", }, "entity": "test-entity", - "formAction": "create", - "implementationKey": "PUT", "instanceId": "nano-id-2", - "integrationKey": "http", + "integration": "http", + "trigger": "create", }, ] `); diff --git a/src/backend/actions/__tests__/run-action.spec.ts b/src/backend/actions/__tests__/run-action.spec.ts index cc234dc63..9a3bec206 100644 --- a/src/backend/actions/__tests__/run-action.spec.ts +++ b/src/backend/actions/__tests__/run-action.spec.ts @@ -11,7 +11,7 @@ import { setupActionInstanceTestData } from "__tests__/api/_test-utils/_action-i import { setupIntegrationsConstantsTestData } from "__tests__/api/_test-utils/_integrations-constants"; import { createTransport } from "nodemailer"; import { DataEventActions } from "shared/types/data"; -import { ActionIntegrationKeys } from "shared/types/actions"; +import { ActionIntegrations } from "shared/types/actions"; jest.mock("nodemailer", () => ({ createTransport: jest.fn(), @@ -63,10 +63,10 @@ describe("Run Action", () => { await setupActionInstanceTestData([ { instanceId: "instance-id-1", - integrationKey: ActionIntegrationKeys.SMTP, + integration: ActionIntegrations.SMTP, entity: "tests", - implementationKey: "SEND_MAIL", - formAction: DataEventActions.Create, + action: "SEND_MAIL", + trigger: DataEventActions.Create, configuration: { to: "{{ data.id }}@dashpress.io", subject: "CREATE TEST", @@ -79,10 +79,10 @@ describe("Run Action", () => { }, { instanceId: "instance-id-5", - integrationKey: ActionIntegrationKeys.HTTP, + integration: ActionIntegrations.HTTP, entity: "tests", - implementationKey: "POST", - formAction: DataEventActions.Create, + action: "POST", + trigger: DataEventActions.Create, configuration: { url: "http://CREATE.TEST", headers: `{ @@ -94,10 +94,10 @@ describe("Run Action", () => { }, { instanceId: "instance-id-2", - integrationKey: ActionIntegrationKeys.SLACK, + integration: ActionIntegrations.SLACK, entity: "tests", - implementationKey: "SEND_MESSAGE", - formAction: DataEventActions.Update, + action: "SEND_MESSAGE", + trigger: DataEventActions.Update, configuration: { channel: "UPDATE TEST", message: @@ -106,10 +106,10 @@ describe("Run Action", () => { }, { instanceId: "instance-id-3", - integrationKey: ActionIntegrationKeys.SLACK, + integration: ActionIntegrations.SLACK, entity: "DO_NOT_CALL_ME_CAUSE_INVALID_ENTITY", - implementationKey: "SEND_MESSAGE", - formAction: DataEventActions.Update, + action: "SEND_MESSAGE", + trigger: DataEventActions.Update, configuration: { channel: "UPDATE TEST", message: @@ -118,10 +118,10 @@ describe("Run Action", () => { }, { instanceId: "instance-id-4", - integrationKey: ActionIntegrationKeys.HTTP, + integration: ActionIntegrations.HTTP, entity: "tests", - implementationKey: "POST", - formAction: DataEventActions.Delete, + action: "POST", + trigger: DataEventActions.Delete, configuration: { url: "http://DELETE.TEST", headers: `{ diff --git a/src/backend/actions/actions.service.ts b/src/backend/actions/actions.service.ts index 5cc47a7e8..a1159e9a4 100644 --- a/src/backend/actions/actions.service.ts +++ b/src/backend/actions/actions.service.ts @@ -1,12 +1,7 @@ import { - appConstantsApiService, credentialsApiService, CredentialsApiService, } from "backend/integrations-configurations"; -import { - IntegrationsConfigurationApiService, - INTEGRATION_CONFIG_GROUP_DEMILITER, -} from "backend/integrations-configurations/services/_base"; import { createConfigDomainPersistenceService, AbstractConfigDataPersistenceService, @@ -20,7 +15,7 @@ import { IIntegrationsList, IActionInstance, IIntegrationImplementationList, - ActionIntegrationKeys, + ActionIntegrations, } from "shared/types/actions"; import { IAccountProfile } from "shared/types/user"; import { compileTemplateString } from "shared/lib/strings/templates"; @@ -30,16 +25,16 @@ import { createKeyValueDomainPersistenceService, KeyValueStoreApiService, } from "backend/lib/key-value"; +import { getAppCredentialsAndConstants } from "backend/integrations-configurations/utils"; import { ACTION_INTEGRATIONS } from "./integrations"; export class ActionsApiService implements IApplicationService { constructor( private readonly _activatedIntegrationsPersistenceService: KeyValueStoreApiService< - ActionIntegrationKeys[] + ActionIntegrations[] >, private readonly _actionInstancesPersistenceService: AbstractConfigDataPersistenceService, - private readonly _credentialsApiService: CredentialsApiService, - private readonly _appConstantsApiService: IntegrationsConfigurationApiService + private readonly _credentialsApiService: CredentialsApiService ) {} async bootstrap() { @@ -48,13 +43,13 @@ export class ActionsApiService implements IApplicationService { async runAction( entity: string, - dataEvent: DataEventActions, + dataEventAction: DataEventActions, getData: () => Promise>, accountProfile: IAccountProfile ) { const instances = await this.listEntityActionInstances(entity); const actionsToRun = instances.filter( - (action) => action.formAction === dataEvent + (action) => action.trigger === dataEventAction ); if (actionsToRun.length === 0) { @@ -63,37 +58,19 @@ export class ActionsApiService implements IApplicationService { const data = await getData(); - for (const action of actionsToRun) { - const { configuration, implementationKey, integrationKey } = action; + const { appConstants, credentials } = await getAppCredentialsAndConstants(); + + for (const actionToRun of actionsToRun) { + const { configuration, action, integration } = actionToRun; const actionConfiguration = await this.getIntegrationCredentials( - integrationKey + integration ); - const connection = await ACTION_INTEGRATIONS[integrationKey].connect( + const connection = await ACTION_INTEGRATIONS[integration].connect( actionConfiguration ); - const appConstants = Object.fromEntries( - (await this._appConstantsApiService.list()).map(({ key, value }) => [ - key, - value, - ]) - ); - - const credentials = Object.fromEntries( - await Promise.all( - (await this._credentialsApiService.list()) - .filter( - ({ key }) => !key.includes(INTEGRATION_CONFIG_GROUP_DEMILITER) - ) - .map(async ({ key, value }) => [ - key, - await this._credentialsApiService.processDataAfterFetch(value), - ]) - ) - ); - const compiledConfiguration = Object.fromEntries( Object.entries(configuration || {}).map(([key, value]) => [ key, @@ -106,30 +83,30 @@ export class ActionsApiService implements IApplicationService { ]) ); - await ACTION_INTEGRATIONS[integrationKey].performsImplementation[ - implementationKey - ].do(connection, compiledConfiguration); + await ACTION_INTEGRATIONS[integration].performsImplementation[action].do( + connection, + compiledConfiguration + ); } } async instantiateAction(action: Omit) { const instanceId = nanoid(); - const activatedActions = await this.listActivatedActions(); + const activatedIntegrations = await this.listActivatedIntegrations(); - const integrationKey = activatedActions.find( - (activateIntegrationKey) => - activateIntegrationKey === action.integrationKey + const integration = activatedIntegrations.find( + (activatedIntegration) => activatedIntegration === action.integration ); - if (!integrationKey) { + if (!integration) { throw new BadRequestError( - `The integration for '${action.integrationKey}' has not yet been activated` + `The integration for '${action.integration}' has not yet been activated` ); } await this._actionInstancesPersistenceService.createItem(instanceId, { ...action, - integrationKey, + integration, instanceId, }); } @@ -159,17 +136,17 @@ export class ActionsApiService implements IApplicationService { ([key, { title, description, configurationSchema }]) => ({ description, title, - key: key as ActionIntegrationKeys, + key: key as ActionIntegrations, configurationSchema, }) ); } listIntegrationImplementations( - integrationKey: ActionIntegrationKeys + integration: ActionIntegrations ): IIntegrationImplementationList[] { return Object.entries( - ACTION_INTEGRATIONS[integrationKey].performsImplementation + ACTION_INTEGRATIONS[integration].performsImplementation ).map(([key, { configurationSchema, label }]) => ({ label, key, @@ -177,90 +154,84 @@ export class ActionsApiService implements IApplicationService { })); } - async listActivatedActions(): Promise { + async listActivatedIntegrations(): Promise { const activatedIntegrations = (await this._activatedIntegrationsPersistenceService.getItem()) || []; - return [...activatedIntegrations, ActionIntegrationKeys.HTTP]; + return [...activatedIntegrations, ActionIntegrations.HTTP]; } async activateAction( - integrationKey: ActionIntegrationKeys, + integration: ActionIntegrations, configuration: Record ): Promise { validateSchemaRequestBody( - ACTION_INTEGRATIONS[integrationKey].configurationSchema, + ACTION_INTEGRATIONS[integration].configurationSchema, configuration ); - const credentialsGroupKey = this.makeCredentialsGroupKey(integrationKey); + const credentialsGroupKey = this.makeCredentialsGroupKey(integration); const activatedIntegrations = (await this._activatedIntegrationsPersistenceService.getItem()) || []; await this._activatedIntegrationsPersistenceService.persistItem([ ...activatedIntegrations, - integrationKey, + integration, ]); await this._credentialsApiService.upsertGroup( { key: credentialsGroupKey, fields: Object.keys( - ACTION_INTEGRATIONS[integrationKey].configurationSchema + ACTION_INTEGRATIONS[integration].configurationSchema ), }, configuration ); } - private makeCredentialsGroupKey(integrationKey: ActionIntegrationKeys) { - return sluggify(`ACTION__${integrationKey}`).toUpperCase(); + private makeCredentialsGroupKey(integration: ActionIntegrations) { + return sluggify(`ACTION__${integration}`).toUpperCase(); } async getIntegrationCredentials( - integrationKey: ActionIntegrationKeys + integration: ActionIntegrations ): Promise> { - if (integrationKey === ActionIntegrationKeys.HTTP) { + if (integration === ActionIntegrations.HTTP) { return {}; } return await this._credentialsApiService.useGroupValue({ - key: this.makeCredentialsGroupKey(integrationKey), - fields: Object.keys( - ACTION_INTEGRATIONS[integrationKey].configurationSchema - ), + key: this.makeCredentialsGroupKey(integration), + fields: Object.keys(ACTION_INTEGRATIONS[integration].configurationSchema), }); } async updateIntegrationConfig( - integrationKey: ActionIntegrationKeys, + integration: ActionIntegrations, configuration: Record ): Promise { validateSchemaRequestBody( - ACTION_INTEGRATIONS[integrationKey].configurationSchema, + ACTION_INTEGRATIONS[integration].configurationSchema, configuration ); await this._credentialsApiService.upsertGroup( { - key: this.makeCredentialsGroupKey(integrationKey), + key: this.makeCredentialsGroupKey(integration), fields: Object.keys( - ACTION_INTEGRATIONS[integrationKey].configurationSchema + ACTION_INTEGRATIONS[integration].configurationSchema ), }, configuration ); } - async deactivateIntegration( - integrationKey: ActionIntegrationKeys - ): Promise { + async deactivateIntegration(integration: ActionIntegrations): Promise { await this._credentialsApiService.deleteGroup({ - key: this.makeCredentialsGroupKey(integrationKey), - fields: Object.keys( - ACTION_INTEGRATIONS[integrationKey].configurationSchema - ), + key: this.makeCredentialsGroupKey(integration), + fields: Object.keys(ACTION_INTEGRATIONS[integration].configurationSchema), }); const activatedIntegrations = @@ -268,7 +239,7 @@ export class ActionsApiService implements IApplicationService { await this._activatedIntegrationsPersistenceService.persistItem( activatedIntegrations.filter( - (activatedIntegrationKey) => activatedIntegrationKey !== integrationKey + (activatedIntegration) => activatedIntegration !== integration ) ); @@ -276,7 +247,7 @@ export class ActionsApiService implements IApplicationService { await this._actionInstancesPersistenceService.getAllItems(); for (const instance of instances) { - if (instance.integrationKey === integrationKey) { + if (instance.integration === integration) { await this._actionInstancesPersistenceService.removeItem( instance.instanceId ); @@ -286,7 +257,7 @@ export class ActionsApiService implements IApplicationService { } const activatedIntegrationsPersistenceService = - createKeyValueDomainPersistenceService( + createKeyValueDomainPersistenceService( "activated-integrations" ); @@ -296,6 +267,5 @@ const actionInstancesPersistenceService = export const actionsApiService = new ActionsApiService( activatedIntegrationsPersistenceService, actionInstancesPersistenceService, - credentialsApiService, - appConstantsApiService + credentialsApiService ); diff --git a/src/backend/actions/integrations/index.ts b/src/backend/actions/integrations/index.ts index 430a79483..4a7f478e4 100644 --- a/src/backend/actions/integrations/index.ts +++ b/src/backend/actions/integrations/index.ts @@ -1,5 +1,5 @@ import { - ActionIntegrationKeys, + ActionIntegrations, IActionIntegrationsImplemention, } from "shared/types/actions"; import { HTTP_ACTION_INTEGRATION } from "./http"; @@ -12,15 +12,15 @@ import { SMTP_ACTION_INTEGRATION } from "./smtp"; import { TWILIO_ACTION_INTEGRATION } from "./twilio"; export const ACTION_INTEGRATIONS: Record< - ActionIntegrationKeys, + ActionIntegrations, IActionIntegrationsImplemention > = { - [ActionIntegrationKeys.HTTP]: HTTP_ACTION_INTEGRATION, - [ActionIntegrationKeys.SMTP]: SMTP_ACTION_INTEGRATION, - [ActionIntegrationKeys.SLACK]: SLACK_ACTION_INTEGRATION, - [ActionIntegrationKeys.SENDGRID]: SEND_GRID_ACTION_INTEGRATION, - [ActionIntegrationKeys.MAILGUN]: MAIL_GUN_ACTION_INTEGRATION, - [ActionIntegrationKeys.TWILIO]: TWILIO_ACTION_INTEGRATION, - [ActionIntegrationKeys.POSTMARK]: POST_MARK_ACTION_INTEGRATION, - [ActionIntegrationKeys.SEND_IN_BLUE]: SENDINBLUE_ACTION_INTEGRATION, + [ActionIntegrations.HTTP]: HTTP_ACTION_INTEGRATION, + [ActionIntegrations.SMTP]: SMTP_ACTION_INTEGRATION, + [ActionIntegrations.SLACK]: SLACK_ACTION_INTEGRATION, + [ActionIntegrations.SENDGRID]: SEND_GRID_ACTION_INTEGRATION, + [ActionIntegrations.MAILGUN]: MAIL_GUN_ACTION_INTEGRATION, + [ActionIntegrations.TWILIO]: TWILIO_ACTION_INTEGRATION, + [ActionIntegrations.POSTMARK]: POST_MARK_ACTION_INTEGRATION, + [ActionIntegrations.SEND_IN_BLUE]: SENDINBLUE_ACTION_INTEGRATION, }; diff --git a/src/backend/integrations-configurations/utils.ts b/src/backend/integrations-configurations/utils.ts new file mode 100644 index 000000000..51ed59454 --- /dev/null +++ b/src/backend/integrations-configurations/utils.ts @@ -0,0 +1,25 @@ +import { INTEGRATION_CONFIG_GROUP_DEMILITER } from "./services/_base"; +import { credentialsApiService } from "./services/credentials.service"; +import { appConstantsApiService } from "./services/env-variable.service"; + +export const getAppCredentialsAndConstants = async () => { + const appConstants = Object.fromEntries( + (await appConstantsApiService.list()).map(({ key, value }) => [key, value]) + ); + + const credentials: Record = Object.fromEntries( + await Promise.all( + (await credentialsApiService.list()) + .filter(({ key }) => !key.includes(INTEGRATION_CONFIG_GROUP_DEMILITER)) + .map(async ({ key, value }) => [ + key, + await credentialsApiService.processDataAfterFetch(value), + ]) + ) + ); + + return { + appConstants, + credentials, + }; +}; diff --git a/src/backend/lib/request/validations/implementations/__tests__/query-filters.spec.ts b/src/backend/lib/request/validations/implementations/__tests__/query-filters.spec.ts index b83ba1c8f..e33a86e99 100644 --- a/src/backend/lib/request/validations/implementations/__tests__/query-filters.spec.ts +++ b/src/backend/lib/request/validations/implementations/__tests__/query-filters.spec.ts @@ -12,8 +12,8 @@ const handler = requestHandler({ }); describe("Request Validations => queryFilterValidationImpl", () => { - beforeAll(() => { - setupAllTestData(["schema"]); + beforeAll(async () => { + await setupAllTestData(["credentials", "schema"]); }); it("should return correct filters", async () => { diff --git a/src/backend/storage/integrations/index.ts b/src/backend/storage/integrations/index.ts index 56f68c67d..f5b786989 100644 --- a/src/backend/storage/integrations/index.ts +++ b/src/backend/storage/integrations/index.ts @@ -2,13 +2,13 @@ import { IStorageIntegrationsImplemention } from "../types"; import { AWS_STORAGE_INTEGRATION } from "./aws"; import { CLOUDINARY_STORAGE_INTEGRATION } from "./cloudinary"; import { GOOGLE_STORAGE_INTEGRATION } from "./google"; -import { StorageIntegrationKeys } from "./types"; +import { StorageIntegrations } from "./types"; export const STORAGE_INTEGRATIONS: Record< - StorageIntegrationKeys, + StorageIntegrations, IStorageIntegrationsImplemention > = { - [StorageIntegrationKeys.S3]: AWS_STORAGE_INTEGRATION, - [StorageIntegrationKeys.CLOUDINARY]: CLOUDINARY_STORAGE_INTEGRATION, - [StorageIntegrationKeys.GOOGLE]: GOOGLE_STORAGE_INTEGRATION, + [StorageIntegrations.S3]: AWS_STORAGE_INTEGRATION, + [StorageIntegrations.CLOUDINARY]: CLOUDINARY_STORAGE_INTEGRATION, + [StorageIntegrations.GOOGLE]: GOOGLE_STORAGE_INTEGRATION, }; diff --git a/src/backend/storage/integrations/types.ts b/src/backend/storage/integrations/types.ts index 94f19581e..0f988e09e 100644 --- a/src/backend/storage/integrations/types.ts +++ b/src/backend/storage/integrations/types.ts @@ -1,4 +1,4 @@ -export enum StorageIntegrationKeys { +export enum StorageIntegrations { S3 = "s3", CLOUDINARY = "cloudinary", GOOGLE = "google", diff --git a/src/backend/storage/storage.service.ts b/src/backend/storage/storage.service.ts index 1149fef0b..5d4213327 100644 --- a/src/backend/storage/storage.service.ts +++ b/src/backend/storage/storage.service.ts @@ -11,7 +11,7 @@ import { IApplicationService } from "backend/types"; import { sluggify } from "shared/lib/strings"; import { IStorageIntegration } from "shared/types/actions"; import { STORAGE_INTEGRATIONS } from "./integrations"; -import { StorageIntegrationKeys } from "./integrations/types"; +import { StorageIntegrations } from "./integrations/types"; export class StorageApiService implements IApplicationService { constructor( @@ -25,7 +25,7 @@ export class StorageApiService implements IApplicationService { return Object.entries(STORAGE_INTEGRATIONS).map( ([key, { title, integrationConfigurationSchema }]) => ({ title, - key: key as StorageIntegrationKeys, + key: key as StorageIntegrations, configurationSchema: integrationConfigurationSchema, }) ); diff --git a/src/frontend/views/entity/Actions/Base.tsx b/src/frontend/views/entity/Actions/Base.tsx index cc096e498..fb1f089ba 100644 --- a/src/frontend/views/entity/Actions/Base.tsx +++ b/src/frontend/views/entity/Actions/Base.tsx @@ -5,8 +5,8 @@ import { } from "frontend/components/FEPaginationTable"; import { ViewStateMachine } from "frontend/components/ViewStateMachine"; import { - useActionIntegrationsList, - useActiveActionList, + useIntegrationsList, + useActiveIntegrations, } from "frontend/views/integrations/actions/actions.store"; import { useCallback, useState } from "react"; import { IActionInstance } from "shared/types/actions"; @@ -30,8 +30,8 @@ import { ActionForm } from "./Form"; const NEW_ACTION_ITEM = "__new_action_item__"; export function BaseActionInstances({ entity }: { entity: string }) { - const activeActionList = useActiveActionList(); - const integrationsList = useActionIntegrationsList(); + const activeIntegration = useActiveIntegrations(); + const integrationsList = useIntegrationsList(); const dataEndpoint = LIST_ACTION_INSTANCES(entity); @@ -73,7 +73,7 @@ export function BaseActionInstances({ entity }: { entity: string }) { const columns: IFETableColumn[] = [ { Header: "Integration", - accessor: "integrationKey", + accessor: "integration", filter: { _type: "string", bag: undefined, @@ -85,7 +85,7 @@ export function BaseActionInstances({ entity }: { entity: string }) { }, { Header: "Trigger", - accessor: "formAction", + accessor: "trigger", filter: { _type: "string", bag: undefined, @@ -97,7 +97,7 @@ export function BaseActionInstances({ entity }: { entity: string }) { }, { Header: "Action", - accessor: "implementationKey", + accessor: "action", filter: { _type: "string", bag: undefined, @@ -118,8 +118,8 @@ export function BaseActionInstances({ entity }: { entity: string }) { return ( <> } > @@ -169,7 +169,7 @@ export function BaseActionInstances({ entity }: { entity: string }) { currentInstanceId === NEW_ACTION_ITEM ? "create" : "update" } integrationsList={integrationsList.data} - activatedIntegrations={activeActionList.data} + activatedIntegrations={activeIntegration.data} /> diff --git a/src/frontend/views/entity/Actions/Form.tsx b/src/frontend/views/entity/Actions/Form.tsx index c72ee0e83..75876e946 100644 --- a/src/frontend/views/entity/Actions/Form.tsx +++ b/src/frontend/views/entity/Actions/Form.tsx @@ -3,7 +3,7 @@ import { SchemaForm } from "frontend/components/SchemaForm"; import { useState } from "react"; import { IAppliedSchemaFormConfig } from "shared/form-schemas/types"; import { - ActionIntegrationKeys, + ActionIntegrations, IActionInstance, IIntegrationsList, } from "shared/types/actions"; @@ -17,7 +17,7 @@ interface IProps { initialValues?: Partial; formAction: "create" | "update"; integrationsList: IIntegrationsList[]; - activatedIntegrations: ActionIntegrationKeys[]; + activatedIntegrations: ActionIntegrations[]; entity: string; } @@ -34,25 +34,23 @@ export function ActionForm({ const integrationsListMap = Object.fromEntries( integrationsList.map((action) => [action.key, action]) ); - const activatedOptions = activatedIntegrations.map((integrationKey) => ({ - label: integrationsListMap[integrationKey].title, - value: integrationKey, + const activatedOptions = activatedIntegrations.map((integration) => ({ + label: integrationsListMap[integration].title, + value: integration, })); const [formValues, setFormValues] = useState>({}); const implementations = useIntegrationImplementationsList( - formValues.integrationKey + formValues.integration ); - const currentActionTitle = - integrationsListMap[formValues.integrationKey]?.title; + const currentActionTitle = integrationsListMap[formValues.integration]?.title; const selectedImplementation = Object.fromEntries( Object.entries( - implementations.data.find( - ({ key }) => key === formValues.implementationKey - )?.configurationSchema || {} + implementations.data.find(({ key }) => key === formValues.action) + ?.configurationSchema || {} ).map(([key, value]) => [ `${CONFIGURATION_FORM_PREFIX}${key}`, { ...value, label: `${currentActionTitle}: ${userFriendlyCase(key)}` }, @@ -60,7 +58,7 @@ export function ActionForm({ ); const fields: IAppliedSchemaFormConfig = { - formAction: { + trigger: { label: "Trigger", type: "selection", selections: [ @@ -83,16 +81,16 @@ export function ActionForm({ }, ], }, - integrationKey: { + integration: { label: "Integration", selections: activatedOptions, type: "selection", validations: [{ validationType: "required" }], formState: ($) => ({ - disabled: $.action === "update" || !$.formValues.formAction, + disabled: $.action === "update" || !$.formValues.trigger, }), }, - implementationKey: { + action: { label: "Action", type: "selection", validations: [{ validationType: "required" }], @@ -101,7 +99,7 @@ export function ActionForm({ value: key, })), formState: ($) => ({ - disabled: !$.formValues.formAction, + disabled: !$.formValues.trigger, }), }, ...selectedImplementation, diff --git a/src/frontend/views/entity/Actions/instances.store.ts b/src/frontend/views/entity/Actions/instances.store.ts index a86ab7c36..c617eafa2 100644 --- a/src/frontend/views/entity/Actions/instances.store.ts +++ b/src/frontend/views/entity/Actions/instances.store.ts @@ -18,12 +18,12 @@ export const LIST_ACTION_INSTANCES = (entity: string) => { return `${BASE_ACTIONS_ENDPOINT}/instances/${entity}`; }; -export const useIntegrationImplementationsList = (integrationKey: string) => +export const useIntegrationImplementationsList = (integration: string) => useApi( - `${BASE_ACTIONS_ENDPOINT}/${integrationKey}/implementations`, + `${BASE_ACTIONS_ENDPOINT}/${integration}/implementations`, { errorMessage: CRUD_CONFIG_NOT_FOUND("Integration Implementations"), - enabled: !!integrationKey, + enabled: !!integration, defaultData: [], } ); diff --git a/src/frontend/views/integrations/_Base.tsx b/src/frontend/views/integrations/_Base.tsx index cc388c393..c29d4369e 100644 --- a/src/frontend/views/integrations/_Base.tsx +++ b/src/frontend/views/integrations/_Base.tsx @@ -11,8 +11,8 @@ import { AppLayout } from "frontend/_layouts/app"; import { NAVIGATION_LINKS } from "frontend/lib/routing/links"; import { IListMangerItemProps } from "frontend/design-system/components/ListManager/ListManagerItem"; import { - useActionIntegrationsList, - useActiveActionList, + useIntegrationsList, + useActiveIntegrations, } from "./actions/actions.store"; import { ACTION_INTEGRATIONS_CRUD_CONFIG } from "./actions/constants"; import { STORAGE_INTEGRATIONS_CRUD_CONFIG } from "./storage/constants"; @@ -24,8 +24,8 @@ interface IProps { export function BaseActionsLayout({ children }: IProps) { const currentKey = useRouteParam("key"); - const actionIntegrationsList = useActionIntegrationsList(); - const activeActionList = useActiveActionList(); + const integrationsList = useIntegrationsList(); + const activeIntegrations = useActiveIntegrations(); const router = useRouter(); @@ -35,11 +35,11 @@ export function BaseActionsLayout({ children }: IProps) { { - const isActive = activeActionList.data.includes(menuItem.key); + const isActive = activeIntegrations.data.includes(menuItem.key); const props: IListMangerItemProps = { label: menuItem.title, IconComponent: isActive ? Zap : ZapOff, diff --git a/src/frontend/views/integrations/actions/View/Configure.tsx b/src/frontend/views/integrations/actions/View/Configure.tsx index d1046202c..4cac8b9d6 100644 --- a/src/frontend/views/integrations/actions/View/Configure.tsx +++ b/src/frontend/views/integrations/actions/View/Configure.tsx @@ -7,7 +7,7 @@ import { Stack } from "frontend/design-system/primitives/Stack"; import { Spacer } from "frontend/design-system/primitives/Spacer"; import { useActivationConfiguration, - useUpdateActivatedActionMutation, + useUpdateActivatedIntegrationMutation, } from "../actions.store"; import { ACTION_INTEGRATIONS_CRUD_CONFIG } from "../constants"; import { PasswordMessage, PasswordToReveal } from "../../Password"; @@ -18,8 +18,8 @@ interface IProps { } export function Configure({ activationId, integrationDetail }: IProps) { - const updateActivatedActionMutation = - useUpdateActivatedActionMutation(activationId); + const updateActivatedIntegrationMutation = + useUpdateActivatedIntegrationMutation(activationId); const activationConfiguration = useActivationConfiguration(activationId); useEffect(() => { @@ -52,7 +52,7 @@ export function Configure({ activationId, integrationDetail }: IProps) { @@ -52,7 +52,7 @@ export function Deactivate({ integrationDetail, activationId }: IProps) { ], }, }} - onSubmit={() => deactivateActionMutation.mutateAsync(activationId)} + onSubmit={() => deactivateIntegrationMutation.mutateAsync(activationId)} buttonText={(isSubmitting) => isSubmitting ? `Deactivating ${integrationDetail.title}` diff --git a/src/frontend/views/integrations/actions/View/index.tsx b/src/frontend/views/integrations/actions/View/index.tsx index 2a9afbcea..6b76ae7a6 100644 --- a/src/frontend/views/integrations/actions/View/index.tsx +++ b/src/frontend/views/integrations/actions/View/index.tsx @@ -1,23 +1,23 @@ import { SchemaForm } from "frontend/components/SchemaForm"; -import { ActionIntegrationKeys, IIntegrationsList } from "shared/types/actions"; +import { ActionIntegrations, IIntegrationsList } from "shared/types/actions"; import { Typo } from "frontend/design-system/primitives/Typo"; import { Spacer } from "frontend/design-system/primitives/Spacer"; import { Tabs } from "frontend/design-system/components/Tabs"; -import { useActivateActionMutation } from "../actions.store"; +import { useActivateIntegrationMutation } from "../actions.store"; import { Deactivate } from "./Deactivate"; import { Configure } from "./Configure"; import { PasswordMessage } from "../../Password"; interface IProps { integrationDetail?: IIntegrationsList; - activeAction?: ActionIntegrationKeys; + activeAction?: ActionIntegrations; } export function ActionSettingsView({ integrationDetail, activeAction, }: IProps) { - const activateActionMutation = useActivateActionMutation( + const activateIntegrationMutation = useActivateIntegrationMutation( integrationDetail?.key ); @@ -32,7 +32,7 @@ export function ActionSettingsView({ diff --git a/src/frontend/views/integrations/actions/actions.store.ts b/src/frontend/views/integrations/actions/actions.store.ts index dd5dd4380..65f6521cb 100644 --- a/src/frontend/views/integrations/actions/actions.store.ts +++ b/src/frontend/views/integrations/actions/actions.store.ts @@ -1,5 +1,5 @@ import { useMutation } from "react-query"; -import { IIntegrationsList, ActionIntegrationKeys } from "shared/types/actions"; +import { IIntegrationsList, ActionIntegrations } from "shared/types/actions"; import { CRUD_CONFIG_NOT_FOUND } from "frontend/lib/crud-config"; import { reduceStringToNumber } from "shared/lib/strings"; import { makeActionRequest } from "frontend/lib/data/makeRequest"; @@ -14,14 +14,14 @@ const ACTIVATION_CONFIG = (activationId: string) => { return `/api/integrations/actions/${activationId}/credentials`; }; -export const useActionIntegrationsList = () => +export const useIntegrationsList = () => useApi("/api/integrations/actions/list", { errorMessage: ACTION_INTEGRATIONS_CRUD_CONFIG.TEXT_LANG.NOT_FOUND, defaultData: [], }); -export const useActiveActionList = () => - useApi(ACTIVE_ACTIONS_INTEGRATIONS_ENDPOINT, { +export const useActiveIntegrations = () => + useApi(ACTIVE_ACTIONS_INTEGRATIONS_ENDPOINT, { errorMessage: CRUD_CONFIG_NOT_FOUND("Activated Integrations"), defaultData: [], }); @@ -41,13 +41,13 @@ export const useActivationConfiguration = (activationId: string) => { enabled: !!activationId && !!rootPassword && - activationId !== ActionIntegrationKeys.HTTP, + activationId !== ActionIntegrations.HTTP, defaultData: undefined, } ); }; -export function useDeactivateActionMutation() { +export function useDeactivateIntegrationMutation() { const apiMutateOptions = useWaitForResponseMutationOptions< Record >({ @@ -66,7 +66,7 @@ export function useDeactivateActionMutation() { ); } -export function useActivateActionMutation(integrationKey: string) { +export function useActivateIntegrationMutation(integration: string) { const apiMutateOptions = useWaitForResponseMutationOptions< Record >({ @@ -79,14 +79,14 @@ export function useActivateActionMutation(integrationKey: string) { async (configuration: Record) => await makeActionRequest( "POST", - `/api/integrations/actions/${integrationKey}`, + `/api/integrations/actions/${integration}`, configuration ), apiMutateOptions ); } -export function useUpdateActivatedActionMutation(activationId: string) { +export function useUpdateActivatedIntegrationMutation(activationId: string) { const apiMutateOptions = useWaitForResponseMutationOptions< Record >({ diff --git a/src/frontend/views/integrations/actions/index.tsx b/src/frontend/views/integrations/actions/index.tsx index 9e4e46450..d2df23511 100644 --- a/src/frontend/views/integrations/actions/index.tsx +++ b/src/frontend/views/integrations/actions/index.tsx @@ -11,10 +11,7 @@ import { } from "frontend/design-system/components/Skeleton/Form"; import { SectionBox } from "frontend/design-system/components/Section/SectionBox"; import { BaseActionsLayout } from "../_Base"; -import { - useActionIntegrationsList, - useActiveActionList, -} from "./actions.store"; +import { useIntegrationsList, useActiveIntegrations } from "./actions.store"; import { ACTIONS_VIEW_KEY } from "../constants"; import { ActionSettingsView } from "./View"; import { ACTION_INTEGRATIONS_CRUD_CONFIG } from "./constants"; @@ -25,15 +22,15 @@ export function ActionsIntegrations() { const currentKey = useRouteParam("key"); const [isDocOpen, setIsDocOpen] = useState(false); - const integrationsList = useActionIntegrationsList(); - const activeActionsList = useActiveActionList(); + const integrationsList = useIntegrationsList(); + const activeActionsList = useActiveIntegrations(); const integrationDetail = integrationsList.data.find( ({ key }) => key === currentKey ); const activeAction = activeActionsList.data.find( - (integrationKey) => integrationKey === currentKey + (integration) => integration === currentKey ); useSetPageDetails({ diff --git a/src/pages/api/integrations/actions/active.ts b/src/pages/api/integrations/actions/active.ts index 7496e3731..fc5efbce9 100644 --- a/src/pages/api/integrations/actions/active.ts +++ b/src/pages/api/integrations/actions/active.ts @@ -3,6 +3,6 @@ import { actionsApiService } from "backend/actions/actions.service"; export default requestHandler({ GET: async () => { - return await actionsApiService.listActivatedActions(); + return await actionsApiService.listActivatedIntegrations(); }, }); diff --git a/src/shared/constants/menu.ts b/src/shared/constants/menu.ts index 01c12f3c8..e08ef749b 100644 --- a/src/shared/constants/menu.ts +++ b/src/shared/constants/menu.ts @@ -1,4 +1,4 @@ -import { ActionIntegrationKeys } from "shared/types/actions"; +import { ActionIntegrations } from "shared/types/actions"; import { SystemLinks } from "shared/types/menu"; import { NAVIGATION_LINKS } from "frontend/lib/routing/links"; import { META_USER_PERMISSIONS, USER_PERMISSIONS } from "./user"; @@ -27,7 +27,7 @@ export const SYSTEM_LINKS_CONFIG_MAP: Record< permission: USER_PERMISSIONS.CAN_MANAGE_USERS, }, [SystemLinks.Integrations]: { - link: NAVIGATION_LINKS.INTEGRATIONS.ACTIONS(ActionIntegrationKeys.HTTP), + link: NAVIGATION_LINKS.INTEGRATIONS.ACTIONS(ActionIntegrations.HTTP), permission: USER_PERMISSIONS.CAN_MANAGE_APP_CREDENTIALS, }, }; diff --git a/src/shared/types/actions.ts b/src/shared/types/actions.ts index 90bc6b276..4fa51146e 100644 --- a/src/shared/types/actions.ts +++ b/src/shared/types/actions.ts @@ -1,7 +1,7 @@ import { IAppliedSchemaFormConfig } from "shared/form-schemas/types"; import { DataEventActions } from "./data"; -export enum ActionIntegrationKeys { +export enum ActionIntegrations { HTTP = "http", SMTP = "smtp", SLACK = "slack", @@ -14,10 +14,10 @@ export enum ActionIntegrationKeys { export type IActionInstance = { instanceId: string; - integrationKey: ActionIntegrationKeys; + integration: ActionIntegrations; entity: string; - implementationKey: string; - formAction: DataEventActions; + action: string; + trigger: DataEventActions; configuration: Record; }; @@ -41,7 +41,7 @@ export interface IStorageIntegration { configurationSchema: IAppliedSchemaFormConfig; } -export type IIntegrationsList = { key: ActionIntegrationKeys } & Pick< +export type IIntegrationsList = { key: ActionIntegrations } & Pick< IActionIntegrationsImplemention, "title" | "description" | "configurationSchema" >;