From 754b30dd5c7f326cf31415913c64853492d8dc12 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 22 May 2023 15:46:42 +0100 Subject: [PATCH] add features property to automation defintions --- .../automation/AutomationBuilder/FlowChart/FlowItem.svelte | 2 +- packages/server/src/automations/steps/bash.ts | 3 ++- packages/server/src/automations/steps/collect.ts | 3 ++- packages/server/src/automations/steps/createRow.ts | 3 ++- packages/server/src/automations/steps/delay.ts | 2 +- packages/server/src/automations/steps/deleteRow.ts | 3 ++- packages/server/src/automations/steps/discord.ts | 3 ++- packages/server/src/automations/steps/executeQuery.ts | 3 ++- packages/server/src/automations/steps/executeScript.ts | 3 ++- packages/server/src/automations/steps/filter.ts | 2 +- packages/server/src/automations/steps/loop.ts | 3 +-- packages/server/src/automations/steps/make.ts | 3 ++- packages/server/src/automations/steps/outgoingWebhook.ts | 3 ++- packages/server/src/automations/steps/queryRows.ts | 3 ++- packages/server/src/automations/steps/sendSmtpEmail.ts | 3 ++- packages/server/src/automations/steps/serverLog.ts | 3 ++- packages/server/src/automations/steps/slack.ts | 3 ++- packages/server/src/automations/steps/updateRow.ts | 3 ++- packages/server/src/automations/steps/zapier.ts | 3 ++- packages/types/src/documents/app/automation.ts | 6 +++++- 20 files changed, 39 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 9ff57a764b..ce3756b6ae 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -187,7 +187,7 @@ {#if !isTrigger}
- {#if block?.canLoop} + {#if block?.features.includes("LOOPING")} addLooping()} icon="Reuse"> Add Looping diff --git a/packages/server/src/automations/steps/bash.ts b/packages/server/src/automations/steps/bash.ts index de1f43a907..36e89f17de 100644 --- a/packages/server/src/automations/steps/bash.ts +++ b/packages/server/src/automations/steps/bash.ts @@ -5,6 +5,7 @@ import environment from "../../environment" import { AutomationActionStepId, AutomationCustomIOType, + AutomationFeature, AutomationIOType, AutomationStepInput, AutomationStepSchema, @@ -18,7 +19,7 @@ export const definition: AutomationStepSchema = { description: "Run a bash script", type: AutomationStepType.ACTION, internal: true, - canLoop: true, + features: [AutomationFeature.LOOPING], 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 1083c2a216..512dfc0dff 100644 --- a/packages/server/src/automations/steps/collect.ts +++ b/packages/server/src/automations/steps/collect.ts @@ -4,6 +4,7 @@ import { AutomationStepInput, AutomationStepType, AutomationIOType, + AutomationFeature, } from "@budibase/types" export const definition: AutomationStepSchema = { @@ -14,7 +15,7 @@ export const definition: AutomationStepSchema = { "Collects specified data so it can be provided to the design section", type: AutomationStepType.ACTION, internal: true, - canLoop: false, + features: [], stepId: AutomationActionStepId.COLLECT, inputs: { text: "", diff --git a/packages/server/src/automations/steps/createRow.ts b/packages/server/src/automations/steps/createRow.ts index 027012338b..5886c95be5 100644 --- a/packages/server/src/automations/steps/createRow.ts +++ b/packages/server/src/automations/steps/createRow.ts @@ -4,6 +4,7 @@ import { buildCtx } from "./utils" import { AutomationActionStepId, AutomationCustomIOType, + AutomationFeature, AutomationIOType, AutomationStepInput, AutomationStepSchema, @@ -17,7 +18,7 @@ export const definition: AutomationStepSchema = { description: "Add a row to your database", type: AutomationStepType.ACTION, internal: true, - canLoop: true, + features: [AutomationFeature.LOOPING], 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 736e392821..abddd73196 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, - canLoop: false, + features: [], inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/deleteRow.ts b/packages/server/src/automations/steps/deleteRow.ts index 6b830a3eab..5ba52cfe99 100644 --- a/packages/server/src/automations/steps/deleteRow.ts +++ b/packages/server/src/automations/steps/deleteRow.ts @@ -8,6 +8,7 @@ import { AutomationStepType, AutomationIOType, AutomationCustomIOType, + AutomationFeature, } from "@budibase/types" export const definition: AutomationStepSchema = { @@ -18,7 +19,7 @@ export const definition: AutomationStepSchema = { type: AutomationStepType.ACTION, stepId: AutomationActionStepId.DELETE_ROW, internal: true, - canLoop: true, + features: [AutomationFeature.LOOPING], inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/discord.ts b/packages/server/src/automations/steps/discord.ts index 165f1a6d04..e495fe0241 100644 --- a/packages/server/src/automations/steps/discord.ts +++ b/packages/server/src/automations/steps/discord.ts @@ -6,6 +6,7 @@ import { AutomationStepInput, AutomationStepType, AutomationIOType, + AutomationFeature, } from "@budibase/types" const DEFAULT_USERNAME = "Budibase Automate" @@ -19,7 +20,7 @@ export const definition: AutomationStepSchema = { stepId: AutomationActionStepId.discord, type: AutomationStepType.ACTION, internal: false, - canLoop: true, + features: [AutomationFeature.LOOPING], inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/executeQuery.ts b/packages/server/src/automations/steps/executeQuery.ts index b63d894f5c..50893c7758 100644 --- a/packages/server/src/automations/steps/executeQuery.ts +++ b/packages/server/src/automations/steps/executeQuery.ts @@ -4,6 +4,7 @@ import * as automationUtils from "../automationUtils" import { AutomationActionStepId, AutomationCustomIOType, + AutomationFeature, AutomationIOType, AutomationStepInput, AutomationStepSchema, @@ -18,7 +19,7 @@ export const definition: AutomationStepSchema = { type: AutomationStepType.ACTION, stepId: AutomationActionStepId.EXECUTE_QUERY, internal: true, - canLoop: true, + features: [AutomationFeature.LOOPING], inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/executeScript.ts b/packages/server/src/automations/steps/executeScript.ts index d0bb500cf1..5bfc6dee36 100644 --- a/packages/server/src/automations/steps/executeScript.ts +++ b/packages/server/src/automations/steps/executeScript.ts @@ -4,6 +4,7 @@ import * as automationUtils from "../automationUtils" import { AutomationActionStepId, AutomationCustomIOType, + AutomationFeature, AutomationIOType, AutomationStepInput, AutomationStepSchema, @@ -19,7 +20,7 @@ export const definition: AutomationStepSchema = { internal: true, stepId: AutomationActionStepId.EXECUTE_SCRIPT, inputs: {}, - canLoop: true, + features: [AutomationFeature.LOOPING], schema: { inputs: { properties: { diff --git a/packages/server/src/automations/steps/filter.ts b/packages/server/src/automations/steps/filter.ts index f457492fc3..b96cfc0f07 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, - canLoop: false, + 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 f646492ee7..729a0b5c01 100644 --- a/packages/server/src/automations/steps/loop.ts +++ b/packages/server/src/automations/steps/loop.ts @@ -13,8 +13,7 @@ export const definition: AutomationStepSchema = { description: "Loop", stepId: AutomationActionStepId.LOOP, internal: true, - canLoop: false, - + features: [], inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/make.ts b/packages/server/src/automations/steps/make.ts index dc4c75d27b..c8e0ac8a91 100644 --- a/packages/server/src/automations/steps/make.ts +++ b/packages/server/src/automations/steps/make.ts @@ -6,6 +6,7 @@ import { AutomationStepInput, AutomationStepType, AutomationIOType, + AutomationFeature, } from "@budibase/types" export const definition: AutomationStepSchema = { @@ -18,7 +19,7 @@ export const definition: AutomationStepSchema = { stepId: AutomationActionStepId.integromat, type: AutomationStepType.ACTION, internal: false, - canLoop: true, + features: [AutomationFeature.LOOPING], inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/outgoingWebhook.ts b/packages/server/src/automations/steps/outgoingWebhook.ts index acdf60d869..96fd279320 100644 --- a/packages/server/src/automations/steps/outgoingWebhook.ts +++ b/packages/server/src/automations/steps/outgoingWebhook.ts @@ -4,6 +4,7 @@ import * as automationUtils from "../automationUtils" import { AutomationActionStepId, AutomationCustomIOType, + AutomationFeature, AutomationIOType, AutomationStepInput, AutomationStepSchema, @@ -32,7 +33,7 @@ export const definition: AutomationStepSchema = { description: "Send a request of specified method to a URL", type: AutomationStepType.ACTION, internal: true, - canLoop: true, + features: [AutomationFeature.LOOPING], 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 f3ab298e55..c50170a733 100644 --- a/packages/server/src/automations/steps/queryRows.ts +++ b/packages/server/src/automations/steps/queryRows.ts @@ -6,6 +6,7 @@ import * as automationUtils from "../automationUtils" import { AutomationActionStepId, AutomationCustomIOType, + AutomationFeature, AutomationIOType, AutomationStepInput, AutomationStepSchema, @@ -42,7 +43,7 @@ export const definition: AutomationStepSchema = { type: AutomationStepType.ACTION, stepId: AutomationActionStepId.QUERY_ROWS, internal: true, - canLoop: true, + features: [AutomationFeature.LOOPING], inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/sendSmtpEmail.ts b/packages/server/src/automations/steps/sendSmtpEmail.ts index fc88ee721b..c2614c3e3c 100644 --- a/packages/server/src/automations/steps/sendSmtpEmail.ts +++ b/packages/server/src/automations/steps/sendSmtpEmail.ts @@ -6,6 +6,7 @@ import { AutomationStepInput, AutomationStepType, AutomationIOType, + AutomationFeature, } from "@budibase/types" export const definition: AutomationStepSchema = { @@ -15,7 +16,7 @@ export const definition: AutomationStepSchema = { name: "Send Email (SMTP)", type: AutomationStepType.ACTION, internal: true, - canLoop: true, + features: [AutomationFeature.LOOPING], 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 241d71a220..67535c8ded 100644 --- a/packages/server/src/automations/steps/serverLog.ts +++ b/packages/server/src/automations/steps/serverLog.ts @@ -4,6 +4,7 @@ import { AutomationStepInput, AutomationStepType, AutomationIOType, + AutomationFeature, } from "@budibase/types" /** @@ -19,7 +20,7 @@ export const definition: AutomationStepSchema = { description: "Logs the given text to the server (using console.log)", type: AutomationStepType.ACTION, internal: true, - canLoop: true, + features: [AutomationFeature.LOOPING], 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 ec08f60e5a..769d81e2a3 100644 --- a/packages/server/src/automations/steps/slack.ts +++ b/packages/server/src/automations/steps/slack.ts @@ -6,6 +6,7 @@ import { AutomationStepInput, AutomationStepType, AutomationIOType, + AutomationFeature, } from "@budibase/types" export const definition: AutomationStepSchema = { @@ -16,7 +17,7 @@ export const definition: AutomationStepSchema = { stepId: AutomationActionStepId.slack, type: AutomationStepType.ACTION, internal: false, - canLoop: true, + features: [AutomationFeature.LOOPING], inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/updateRow.ts b/packages/server/src/automations/steps/updateRow.ts index 4b3457961b..c05b121106 100644 --- a/packages/server/src/automations/steps/updateRow.ts +++ b/packages/server/src/automations/steps/updateRow.ts @@ -4,6 +4,7 @@ import { buildCtx } from "./utils" import { AutomationActionStepId, AutomationCustomIOType, + AutomationFeature, AutomationIOType, AutomationStepInput, AutomationStepSchema, @@ -17,7 +18,7 @@ export const definition: AutomationStepSchema = { description: "Update a row in your database", type: AutomationStepType.ACTION, internal: true, - canLoop: true, + features: [AutomationFeature.LOOPING], 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 85f056e6dd..dcd96f0f48 100644 --- a/packages/server/src/automations/steps/zapier.ts +++ b/packages/server/src/automations/steps/zapier.ts @@ -6,6 +6,7 @@ import { AutomationStepInput, AutomationStepType, AutomationIOType, + AutomationFeature, } from "@budibase/types" export const definition: AutomationStepSchema = { @@ -13,7 +14,7 @@ export const definition: AutomationStepSchema = { stepId: AutomationActionStepId.zapier, type: AutomationStepType.ACTION, internal: false, - canLoop: true, + features: [AutomationFeature.LOOPING], 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 70cefbb0d9..84c9072d0f 100644 --- a/packages/types/src/documents/app/automation.ts +++ b/packages/types/src/documents/app/automation.ts @@ -123,7 +123,11 @@ export interface AutomationStepSchema { outputs: InputOutputBlock } custom?: boolean - canLoop?: boolean + features?: AutomationFeature[] +} + +export enum AutomationFeature { + LOOPING = "LOOPING", } export interface AutomationStep extends AutomationStepSchema {