From 395cf4a667aa01319e668c41f151ffbd5781bbe5 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Thu, 11 May 2023 17:49:33 +0100 Subject: [PATCH] Add JSON payload support for Make and Zapier (#10529) * Rename Integromat to Make. Update logo. * Add JSON type for automations * Support deprecated values in JSON * Fix json query editor width bug * Push body to schema if missing * Support JSON body * Add JSON payload support for Zapier * Update packages/server/src/automations/steps/make.ts Co-authored-by: Martin McKeaveney * July -> November * Add unit tests --------- Co-authored-by: Martin McKeaveney --- .../SetupPanel/AutomationBlockSetup.svelte | 76 ++++++++++++++++++- .../components/integration/QueryEditor.svelte | 6 +- packages/server/src/automations/steps/make.ts | 19 ++++- .../server/src/automations/steps/zapier.ts | 19 ++++- .../server/src/automations/tests/make.spec.ts | 54 +++++++++++++ .../src/automations/tests/zapier.spec.js | 27 ------- .../src/automations/tests/zapier.spec.ts | 56 ++++++++++++++ .../types/src/documents/app/automation.ts | 1 + 8 files changed, 227 insertions(+), 31 deletions(-) create mode 100644 packages/server/src/automations/tests/make.spec.ts delete mode 100644 packages/server/src/automations/tests/zapier.spec.js create mode 100644 packages/server/src/automations/tests/zapier.spec.ts diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 70cb56c77d..35c9c6ad6d 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -61,11 +61,63 @@ $: isTrigger = block?.type === "TRIGGER" $: isUpdateRow = stepId === ActionStepID.UPDATE_ROW + /** + * TODO - Remove after November 2023 + * ******************************* + * Code added to provide backwards compatibility between Values 1,2,3,4,5 + * and the new JSON body. + */ + let deprecatedSchemaProperties + $: { + if (block?.stepId === "integromat" || block?.stepId === "zapier") { + deprecatedSchemaProperties = schemaProperties.filter( + prop => !prop[0].startsWith("value") + ) + if (!deprecatedSchemaProperties.map(entry => entry[0]).includes("body")) { + deprecatedSchemaProperties.push([ + "body", + { + title: "Payload", + type: "json", + }, + ]) + } + } else { + deprecatedSchemaProperties = schemaProperties + } + } + /****************************************************/ + const getInputData = (testData, blockInputs) => { let newInputData = testData || blockInputs if (block.event === "app:trigger" && !newInputData?.fields) { newInputData = cloneDeep(blockInputs) } + + /** + * TODO - Remove after November 2023 + * ******************************* + * Code added to provide backwards compatibility between Values 1,2,3,4,5 + * and the new JSON body. + */ + if ( + (block?.stepId === "integromat" || block?.stepId === "zapier") && + !newInputData?.body?.value + ) { + let deprecatedValues = { + ...newInputData, + } + delete deprecatedValues.url + delete deprecatedValues.body + newInputData = { + url: newInputData.url, + body: { + value: JSON.stringify(deprecatedValues), + }, + } + } + /**********************************/ + inputData = newInputData setDefaultEnumValues() } @@ -239,7 +291,7 @@
- {#each schemaProperties as [key, value]} + {#each deprecatedSchemaProperties as [key, value]}
{#if key !== "fields"}