+
@@ -183,6 +186,7 @@
}
div :global(.CodeMirror) {
+ width: var(--code-mirror-width) !important;
height: var(--code-mirror-height) !important;
border-radius: var(--border-radius-s);
font-family: var(--font-mono);
diff --git a/packages/server/src/automations/steps/make.ts b/packages/server/src/automations/steps/make.ts
index 324193c2a4..54e7175b79 100644
--- a/packages/server/src/automations/steps/make.ts
+++ b/packages/server/src/automations/steps/make.ts
@@ -26,6 +26,10 @@ export const definition: AutomationStepSchema = {
type: AutomationIOType.STRING,
title: "Webhook URL",
},
+ body: {
+ type: AutomationIOType.JSON,
+ title: "Payload",
+ },
value1: {
type: AutomationIOType.STRING,
title: "Input Value 1",
@@ -70,7 +74,19 @@ export const definition: AutomationStepSchema = {
}
export async function run({ inputs }: AutomationStepInput) {
- const { url, value1, value2, value3, value4, value5 } = inputs
+ //TODO - Remove deprecated values 1,2,3,4,5 after November 2023
+ const { url, value1, value2, value3, value4, value5, body } = inputs
+
+ let payload = {}
+ try {
+ payload = body?.value ? JSON.parse(body?.value) : {}
+ } catch (err) {
+ return {
+ httpStatus: 400,
+ response: "Invalid payload JSON",
+ success: false,
+ }
+ }
if (!url?.trim()?.length) {
return {
@@ -89,6 +105,7 @@ export async function run({ inputs }: AutomationStepInput) {
value3,
value4,
value5,
+ ...payload,
}),
headers: {
"Content-Type": "application/json",
diff --git a/packages/server/src/automations/steps/zapier.ts b/packages/server/src/automations/steps/zapier.ts
index 75a21deaae..006f9ce99b 100644
--- a/packages/server/src/automations/steps/zapier.ts
+++ b/packages/server/src/automations/steps/zapier.ts
@@ -24,6 +24,10 @@ export const definition: AutomationStepSchema = {
type: AutomationIOType.STRING,
title: "Webhook URL",
},
+ body: {
+ type: AutomationIOType.JSON,
+ title: "Payload",
+ },
value1: {
type: AutomationIOType.STRING,
title: "Payload Value 1",
@@ -63,7 +67,19 @@ export const definition: AutomationStepSchema = {
}
export async function run({ inputs }: AutomationStepInput) {
- const { url, value1, value2, value3, value4, value5 } = inputs
+ //TODO - Remove deprecated values 1,2,3,4,5 after November 2023
+ const { url, value1, value2, value3, value4, value5, body } = inputs
+
+ let payload = {}
+ try {
+ payload = body?.value ? JSON.parse(body?.value) : {}
+ } catch (err) {
+ return {
+ httpStatus: 400,
+ response: "Invalid payload JSON",
+ success: false,
+ }
+ }
if (!url?.trim()?.length) {
return {
@@ -85,6 +101,7 @@ export async function run({ inputs }: AutomationStepInput) {
value3,
value4,
value5,
+ ...payload,
}),
headers: {
"Content-Type": "application/json",
diff --git a/packages/server/src/automations/tests/make.spec.ts b/packages/server/src/automations/tests/make.spec.ts
new file mode 100644
index 0000000000..ddf7dc3f44
--- /dev/null
+++ b/packages/server/src/automations/tests/make.spec.ts
@@ -0,0 +1,54 @@
+import { getConfig, afterAll, runStep, actions } from "./utilities"
+
+describe("test the outgoing webhook action", () => {
+ let config = getConfig()
+
+ beforeAll(async () => {
+ await config.init()
+ })
+
+ afterAll()
+
+ it("should be able to run the action", async () => {
+ const res = await runStep(actions.integromat.stepId, {
+ value1: "test",
+ url: "http://www.test.com",
+ })
+ expect(res.response.url).toEqual("http://www.test.com")
+ expect(res.response.method).toEqual("post")
+ expect(res.success).toEqual(true)
+ })
+
+ it("should add the payload props when a JSON string is provided", async () => {
+ const payload = `{"value1":1,"value2":2,"value3":3,"value4":4,"value5":5,"name":"Adam","age":9}`
+ const res = await runStep(actions.integromat.stepId, {
+ value1: "ONE",
+ value2: "TWO",
+ value3: "THREE",
+ value4: "FOUR",
+ value5: "FIVE",
+ body: {
+ value: payload,
+ },
+ url: "http://www.test.com",
+ })
+ expect(res.response.url).toEqual("http://www.test.com")
+ expect(res.response.method).toEqual("post")
+ expect(res.response.body).toEqual(payload)
+ expect(res.success).toEqual(true)
+ })
+
+ it("should return a 400 if the JSON payload string is malformed", async () => {
+ const payload = `{ value1 1 }`
+ const res = await runStep(actions.integromat.stepId, {
+ value1: "ONE",
+ body: {
+ value: payload,
+ },
+ url: "http://www.test.com",
+ })
+ expect(res.httpStatus).toEqual(400)
+ expect(res.response).toEqual("Invalid payload JSON")
+ expect(res.success).toEqual(false)
+ })
+})
diff --git a/packages/server/src/automations/tests/zapier.spec.js b/packages/server/src/automations/tests/zapier.spec.js
deleted file mode 100644
index 9d94a4c17f..0000000000
--- a/packages/server/src/automations/tests/zapier.spec.js
+++ /dev/null
@@ -1,27 +0,0 @@
-const setup = require("./utilities")
-const fetch = require("node-fetch")
-
-jest.mock("node-fetch")
-
-describe("test the outgoing webhook action", () => {
- let inputs
- let config = setup.getConfig()
-
- beforeAll(async () => {
- await config.init()
- inputs = {
- value1: "test",
- url: "http://www.test.com",
- }
- })
-
- afterAll(setup.afterAll)
-
- it("should be able to run the action", async () => {
- const res = await setup.runStep(setup.actions.zapier.stepId, inputs)
- expect(res.response.url).toEqual("http://www.test.com")
- expect(res.response.method).toEqual("post")
- expect(res.success).toEqual(true)
- })
-
-})
diff --git a/packages/server/src/automations/tests/zapier.spec.ts b/packages/server/src/automations/tests/zapier.spec.ts
new file mode 100644
index 0000000000..a86185ccad
--- /dev/null
+++ b/packages/server/src/automations/tests/zapier.spec.ts
@@ -0,0 +1,56 @@
+import { getConfig, afterAll, runStep, actions } from "./utilities"
+
+describe("test the outgoing webhook action", () => {
+ let config = getConfig()
+
+ beforeAll(async () => {
+ await config.init()
+ })
+
+ afterAll()
+
+ it("should be able to run the action", async () => {
+ const res = await runStep(actions.zapier.stepId, {
+ value1: "test",
+ url: "http://www.test.com",
+ })
+ expect(res.response.url).toEqual("http://www.test.com")
+ expect(res.response.method).toEqual("post")
+ expect(res.success).toEqual(true)
+ })
+
+ it("should add the payload props when a JSON string is provided", async () => {
+ const payload = `{ "value1": 1, "value2": 2, "value3": 3, "value4": 4, "value5": 5, "name": "Adam", "age": 9 }`
+ const res = await runStep(actions.zapier.stepId, {
+ value1: "ONE",
+ value2: "TWO",
+ value3: "THREE",
+ value4: "FOUR",
+ value5: "FIVE",
+ body: {
+ value: payload,
+ },
+ url: "http://www.test.com",
+ })
+ expect(res.response.url).toEqual("http://www.test.com")
+ expect(res.response.method).toEqual("post")
+ expect(res.response.body).toEqual(
+ `{"platform":"budibase","value1":1,"value2":2,"value3":3,"value4":4,"value5":5,"name":"Adam","age":9}`
+ )
+ expect(res.success).toEqual(true)
+ })
+
+ it("should return a 400 if the JSON payload string is malformed", async () => {
+ const payload = `{ value1 1 }`
+ const res = await runStep(actions.zapier.stepId, {
+ value1: "ONE",
+ body: {
+ value: payload,
+ },
+ url: "http://www.test.com",
+ })
+ expect(res.httpStatus).toEqual(400)
+ expect(res.response).toEqual("Invalid payload JSON")
+ expect(res.success).toEqual(false)
+ })
+})
diff --git a/packages/types/src/documents/app/automation.ts b/packages/types/src/documents/app/automation.ts
index 110a2c0642..2cd365888a 100644
--- a/packages/types/src/documents/app/automation.ts
+++ b/packages/types/src/documents/app/automation.ts
@@ -7,6 +7,7 @@ export enum AutomationIOType {
BOOLEAN = "boolean",
NUMBER = "number",
ARRAY = "array",
+ JSON = "json",
}
export enum AutomationCustomIOType {