From 5a73b028278390e114ec98dbeada8303dad0df18 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Fri, 26 May 2023 11:02:47 +0100 Subject: [PATCH] update feature array to be an object --- .../AutomationBuilder/FlowChart/FlowItem.svelte | 8 ++++++-- packages/builder/src/constants/backend/automations.js | 4 ++++ packages/server/src/automations/steps/bash.ts | 4 +++- packages/server/src/automations/steps/collect.ts | 2 +- packages/server/src/automations/steps/createRow.ts | 4 +++- packages/server/src/automations/steps/delay.ts | 2 +- packages/server/src/automations/steps/deleteRow.ts | 4 +++- packages/server/src/automations/steps/discord.ts | 4 +++- packages/server/src/automations/steps/executeQuery.ts | 4 +++- packages/server/src/automations/steps/executeScript.ts | 4 +++- packages/server/src/automations/steps/filter.ts | 2 +- packages/server/src/automations/steps/loop.ts | 2 +- packages/server/src/automations/steps/make.ts | 4 +++- packages/server/src/automations/steps/openai.ts | 1 + packages/server/src/automations/steps/outgoingWebhook.ts | 4 +++- packages/server/src/automations/steps/queryRows.ts | 4 +++- packages/server/src/automations/steps/sendSmtpEmail.ts | 4 +++- packages/server/src/automations/steps/serverLog.ts | 4 +++- packages/server/src/automations/steps/slack.ts | 4 +++- packages/server/src/automations/steps/updateRow.ts | 4 +++- packages/server/src/automations/steps/zapier.ts | 4 +++- packages/types/src/documents/app/automation.ts | 2 +- 22 files changed, 58 insertions(+), 21 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index 88516b99b4..092138170f 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -17,7 +17,11 @@ import ActionModal from "./ActionModal.svelte" import FlowItemHeader from "./FlowItemHeader.svelte" import RoleSelect from "components/design/settings/controls/RoleSelect.svelte" - import { ActionStepID, TriggerStepID } from "constants/backend/automations" + import { + ActionStepID, + TriggerStepID, + Features, + } from "constants/backend/automations" import { permissions } from "stores/backend" export let block @@ -187,7 +191,7 @@ {#if !isTrigger}
- {#if block?.features?.includes("LOOPING")} + {#if block?.features?.[Features.LOOPING] || !block.features} addLooping()} icon="Reuse"> Add Looping diff --git a/packages/builder/src/constants/backend/automations.js b/packages/builder/src/constants/backend/automations.js index 6c58ed8620..f89a126d3c 100644 --- a/packages/builder/src/constants/backend/automations.js +++ b/packages/builder/src/constants/backend/automations.js @@ -27,3 +27,7 @@ export const ActionStepID = { zapier: "zapier", integromat: "integromat", } + +export const Features = { + LOOPING: "LOOPING", +} diff --git a/packages/server/src/automations/steps/bash.ts b/packages/server/src/automations/steps/bash.ts index 36e89f17de..61d446f12c 100644 --- a/packages/server/src/automations/steps/bash.ts +++ b/packages/server/src/automations/steps/bash.ts @@ -19,7 +19,9 @@ export const definition: AutomationStepSchema = { description: "Run a bash script", type: AutomationStepType.ACTION, internal: true, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, stepId: AutomationActionStepId.EXECUTE_BASH, inputs: {}, schema: { diff --git a/packages/server/src/automations/steps/collect.ts b/packages/server/src/automations/steps/collect.ts index 1107c68c32..ef1fe64772 100644 --- a/packages/server/src/automations/steps/collect.ts +++ b/packages/server/src/automations/steps/collect.ts @@ -15,7 +15,7 @@ export const definition: AutomationStepSchema = { "Collects specified data so it can be provided to the design section", type: AutomationStepType.ACTION, internal: true, - features: [], + features: {}, stepId: AutomationActionStepId.COLLECT, inputs: {}, schema: { diff --git a/packages/server/src/automations/steps/createRow.ts b/packages/server/src/automations/steps/createRow.ts index 5886c95be5..d11baab5c6 100644 --- a/packages/server/src/automations/steps/createRow.ts +++ b/packages/server/src/automations/steps/createRow.ts @@ -18,7 +18,9 @@ export const definition: AutomationStepSchema = { description: "Add a row to your database", type: AutomationStepType.ACTION, internal: true, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, stepId: AutomationActionStepId.CREATE_ROW, inputs: {}, schema: { diff --git a/packages/server/src/automations/steps/delay.ts b/packages/server/src/automations/steps/delay.ts index abddd73196..4e04539998 100644 --- a/packages/server/src/automations/steps/delay.ts +++ b/packages/server/src/automations/steps/delay.ts @@ -14,7 +14,7 @@ export const definition: AutomationStepSchema = { description: "Delay the automation until an amount of time has passed", stepId: AutomationActionStepId.DELAY, internal: true, - features: [], + features: {}, inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/deleteRow.ts b/packages/server/src/automations/steps/deleteRow.ts index 5ba52cfe99..c8b6585cae 100644 --- a/packages/server/src/automations/steps/deleteRow.ts +++ b/packages/server/src/automations/steps/deleteRow.ts @@ -19,7 +19,9 @@ export const definition: AutomationStepSchema = { type: AutomationStepType.ACTION, stepId: AutomationActionStepId.DELETE_ROW, internal: true, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/discord.ts b/packages/server/src/automations/steps/discord.ts index e495fe0241..c80e4ba66f 100644 --- a/packages/server/src/automations/steps/discord.ts +++ b/packages/server/src/automations/steps/discord.ts @@ -20,7 +20,9 @@ export const definition: AutomationStepSchema = { stepId: AutomationActionStepId.discord, type: AutomationStepType.ACTION, internal: false, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/executeQuery.ts b/packages/server/src/automations/steps/executeQuery.ts index 50893c7758..a9517b01a0 100644 --- a/packages/server/src/automations/steps/executeQuery.ts +++ b/packages/server/src/automations/steps/executeQuery.ts @@ -19,7 +19,9 @@ export const definition: AutomationStepSchema = { type: AutomationStepType.ACTION, stepId: AutomationActionStepId.EXECUTE_QUERY, internal: true, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/executeScript.ts b/packages/server/src/automations/steps/executeScript.ts index 5bfc6dee36..7ce6c1d0f4 100644 --- a/packages/server/src/automations/steps/executeScript.ts +++ b/packages/server/src/automations/steps/executeScript.ts @@ -20,7 +20,9 @@ export const definition: AutomationStepSchema = { internal: true, stepId: AutomationActionStepId.EXECUTE_SCRIPT, inputs: {}, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, schema: { inputs: { properties: { diff --git a/packages/server/src/automations/steps/filter.ts b/packages/server/src/automations/steps/filter.ts index b96cfc0f07..3b000f8f29 100644 --- a/packages/server/src/automations/steps/filter.ts +++ b/packages/server/src/automations/steps/filter.ts @@ -28,7 +28,7 @@ export const definition: AutomationStepSchema = { "Conditionally halt automations which do not meet certain conditions", type: AutomationStepType.LOGIC, internal: true, - features: [], + features: {}, stepId: AutomationActionStepId.FILTER, inputs: { condition: FilterConditions.EQUAL, diff --git a/packages/server/src/automations/steps/loop.ts b/packages/server/src/automations/steps/loop.ts index 729a0b5c01..cdf494c288 100644 --- a/packages/server/src/automations/steps/loop.ts +++ b/packages/server/src/automations/steps/loop.ts @@ -13,7 +13,7 @@ export const definition: AutomationStepSchema = { description: "Loop", stepId: AutomationActionStepId.LOOP, internal: true, - features: [], + features: {}, inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/make.ts b/packages/server/src/automations/steps/make.ts index c8e0ac8a91..e90648d573 100644 --- a/packages/server/src/automations/steps/make.ts +++ b/packages/server/src/automations/steps/make.ts @@ -19,7 +19,9 @@ export const definition: AutomationStepSchema = { stepId: AutomationActionStepId.integromat, type: AutomationStepType.ACTION, internal: false, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/openai.ts b/packages/server/src/automations/steps/openai.ts index 88d3fb8b85..8ae211579e 100644 --- a/packages/server/src/automations/steps/openai.ts +++ b/packages/server/src/automations/steps/openai.ts @@ -22,6 +22,7 @@ export const definition: AutomationStepSchema = { description: "Interact with the OpenAI ChatGPT API.", type: AutomationStepType.ACTION, internal: true, + features: {}, stepId: AutomationActionStepId.OPENAI, inputs: { prompt: "", diff --git a/packages/server/src/automations/steps/outgoingWebhook.ts b/packages/server/src/automations/steps/outgoingWebhook.ts index 96fd279320..269c8c7157 100644 --- a/packages/server/src/automations/steps/outgoingWebhook.ts +++ b/packages/server/src/automations/steps/outgoingWebhook.ts @@ -33,7 +33,9 @@ export const definition: AutomationStepSchema = { description: "Send a request of specified method to a URL", type: AutomationStepType.ACTION, internal: true, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, stepId: AutomationActionStepId.OUTGOING_WEBHOOK, inputs: { requestMethod: "POST", diff --git a/packages/server/src/automations/steps/queryRows.ts b/packages/server/src/automations/steps/queryRows.ts index c50170a733..28da430858 100644 --- a/packages/server/src/automations/steps/queryRows.ts +++ b/packages/server/src/automations/steps/queryRows.ts @@ -43,7 +43,9 @@ export const definition: AutomationStepSchema = { type: AutomationStepType.ACTION, stepId: AutomationActionStepId.QUERY_ROWS, internal: true, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/sendSmtpEmail.ts b/packages/server/src/automations/steps/sendSmtpEmail.ts index c2614c3e3c..448c374ce8 100644 --- a/packages/server/src/automations/steps/sendSmtpEmail.ts +++ b/packages/server/src/automations/steps/sendSmtpEmail.ts @@ -16,7 +16,9 @@ export const definition: AutomationStepSchema = { name: "Send Email (SMTP)", type: AutomationStepType.ACTION, internal: true, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, stepId: AutomationActionStepId.SEND_EMAIL_SMTP, inputs: {}, schema: { diff --git a/packages/server/src/automations/steps/serverLog.ts b/packages/server/src/automations/steps/serverLog.ts index 67535c8ded..eb75ca1f3b 100644 --- a/packages/server/src/automations/steps/serverLog.ts +++ b/packages/server/src/automations/steps/serverLog.ts @@ -20,7 +20,9 @@ export const definition: AutomationStepSchema = { description: "Logs the given text to the server (using console.log)", type: AutomationStepType.ACTION, internal: true, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, stepId: AutomationActionStepId.SERVER_LOG, inputs: { text: "", diff --git a/packages/server/src/automations/steps/slack.ts b/packages/server/src/automations/steps/slack.ts index 769d81e2a3..79544bf001 100644 --- a/packages/server/src/automations/steps/slack.ts +++ b/packages/server/src/automations/steps/slack.ts @@ -17,7 +17,9 @@ export const definition: AutomationStepSchema = { stepId: AutomationActionStepId.slack, type: AutomationStepType.ACTION, internal: false, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/updateRow.ts b/packages/server/src/automations/steps/updateRow.ts index c05b121106..5ed4e19f61 100644 --- a/packages/server/src/automations/steps/updateRow.ts +++ b/packages/server/src/automations/steps/updateRow.ts @@ -18,7 +18,9 @@ export const definition: AutomationStepSchema = { description: "Update a row in your database", type: AutomationStepType.ACTION, internal: true, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, stepId: AutomationActionStepId.UPDATE_ROW, inputs: {}, schema: { diff --git a/packages/server/src/automations/steps/zapier.ts b/packages/server/src/automations/steps/zapier.ts index dcd96f0f48..d69ac39ba7 100644 --- a/packages/server/src/automations/steps/zapier.ts +++ b/packages/server/src/automations/steps/zapier.ts @@ -14,7 +14,9 @@ export const definition: AutomationStepSchema = { stepId: AutomationActionStepId.zapier, type: AutomationStepType.ACTION, internal: false, - features: [AutomationFeature.LOOPING], + features: { + [AutomationFeature.LOOPING]: true, + }, description: "Trigger a Zapier Zap via webhooks", tagline: "Trigger a Zapier Zap", icon: "ri-flashlight-line", diff --git a/packages/types/src/documents/app/automation.ts b/packages/types/src/documents/app/automation.ts index 3e361806ae..193a5a414a 100644 --- a/packages/types/src/documents/app/automation.ts +++ b/packages/types/src/documents/app/automation.ts @@ -124,7 +124,7 @@ export interface AutomationStepSchema { outputs: InputOutputBlock } custom?: boolean - features?: AutomationFeature[] + features?: Partial> } export enum AutomationFeature {