@budibase/server 0.9.125-alpha.4 → 0.9.125-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builder/assets/{index.dc48c234.js → index.a6e64238.js} +1 -1
- package/builder/index.html +1 -1
- package/coverage/clover.xml +1659 -1493
- package/coverage/coverage-final.json +101 -87
- package/coverage/lcov-report/api/controllers/analytics.js.html +3 -3
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/application.js.html +39 -39
- package/coverage/lcov-report/api/controllers/auth.js.html +6 -6
- package/coverage/lcov-report/api/controllers/automation.js.html +151 -361
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +15 -15
- package/coverage/lcov-report/api/controllers/hosting.js.html +8 -8
- package/coverage/lcov-report/api/controllers/index.html +39 -24
- package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +218 -0
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query.js.html +6 -12
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +20 -20
- package/coverage/lcov-report/api/controllers/row/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/row/internal.js.html +95 -62
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +10 -10
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +24 -24
- package/coverage/lcov-report/api/controllers/table/utils.js.html +32 -32
- package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +23 -23
- package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/application.js.html +8 -8
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +41 -26
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +13 -13
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +11 -11
- package/coverage/lcov-report/api/routes/hosting.js.html +8 -8
- package/coverage/lcov-report/api/routes/index.html +24 -9
- package/coverage/lcov-report/api/routes/index.js.html +36 -30
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +194 -0
- package/coverage/lcov-report/api/routes/permission.js.html +12 -12
- package/coverage/lcov-report/api/routes/query.js.html +13 -13
- package/coverage/lcov-report/api/routes/role.js.html +12 -12
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +10 -10
- package/coverage/lcov-report/api/routes/screen.js.html +11 -11
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +13 -13
- package/coverage/lcov-report/api/routes/table.js.html +12 -12
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +9 -9
- package/coverage/lcov-report/api/routes/view.js.html +11 -11
- package/coverage/lcov-report/api/routes/webhook.js.html +11 -11
- package/coverage/lcov-report/automations/actions.js.html +38 -107
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +46 -16
- package/coverage/lcov-report/automations/index.html +67 -67
- package/coverage/lcov-report/automations/index.js.html +26 -128
- package/coverage/lcov-report/automations/steps/bash.js.html +33 -12
- package/coverage/lcov-report/automations/steps/createRow.js.html +8 -8
- package/coverage/lcov-report/automations/steps/delay.js.html +45 -6
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +8 -8
- package/coverage/lcov-report/automations/steps/discord.js.html +329 -0
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +19 -31
- package/coverage/lcov-report/automations/steps/executeScript.js.html +18 -30
- package/coverage/lcov-report/automations/steps/filter.js.html +22 -19
- package/coverage/lcov-report/automations/steps/index.html +125 -65
- package/coverage/lcov-report/automations/steps/integromat.js.html +341 -0
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +26 -32
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +9 -9
- package/coverage/lcov-report/automations/steps/serverLog.js.html +20 -8
- package/coverage/lcov-report/automations/steps/{sendgridEmail.js.html → slack.js.html} +57 -87
- package/coverage/lcov-report/automations/steps/updateRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/utils.js.html +188 -0
- package/coverage/lcov-report/automations/steps/zapier.js.html +332 -0
- package/coverage/lcov-report/automations/thread.js.html +79 -76
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +173 -0
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +173 -0
- package/coverage/lcov-report/automations/triggerInfo/index.html +201 -0
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +125 -0
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +176 -0
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +200 -0
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +200 -0
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +188 -0
- package/coverage/lcov-report/automations/triggers.js.html +54 -819
- package/coverage/lcov-report/automations/utils.js.html +557 -0
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +19 -4
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +2 -2
- package/coverage/lcov-report/db/client.js.html +1 -1
- package/coverage/lcov-report/db/index.html +19 -19
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +73 -73
- package/coverage/lcov-report/db/linkedRows/index.html +17 -17
- package/coverage/lcov-report/db/linkedRows/index.js.html +79 -115
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +31 -31
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +79 -28
- package/coverage/lcov-report/events/AutomationEmitter.js.html +7 -7
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +2 -2
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +115 -100
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/{automations/logic.js.html → middleware/appInfo.js.html} +35 -38
- package/coverage/lcov-report/middleware/authorized.js.html +16 -16
- package/coverage/lcov-report/middleware/builder.js.html +15 -15
- package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
- package/coverage/lcov-report/middleware/index.html +23 -8
- package/coverage/lcov-report/middleware/joi-validator.js.html +6 -6
- package/coverage/lcov-report/middleware/resourceId.js.html +28 -28
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +8 -8
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +21 -21
- package/coverage/lcov-report/utilities/index.html +18 -18
- package/coverage/lcov-report/utilities/index.js.html +167 -14
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +12 -12
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +14 -14
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +87 -51
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +8 -8
- package/coverage/lcov-report/utilities/security.js.html +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +2641 -2357
- package/dist/api/controllers/automation.js +49 -127
- package/dist/api/controllers/deploy/index.js +17 -1
- package/dist/api/controllers/metadata.js +49 -0
- package/dist/api/controllers/query.js +0 -2
- package/dist/api/controllers/row/internal.js +33 -23
- package/dist/api/routes/automation.js +4 -5
- package/dist/api/routes/index.js +2 -0
- package/dist/api/routes/metadata.js +13 -0
- package/dist/api/routes/tests/utilities/TestFunctions.js +13 -0
- package/dist/app.js +1 -1
- package/dist/automations/actions.js +26 -46
- package/dist/automations/bullboard.js +10 -2
- package/dist/automations/index.js +11 -48
- package/dist/automations/steps/bash.js +11 -5
- package/dist/automations/steps/createRow.js +4 -4
- package/dist/automations/steps/delay.js +15 -2
- package/dist/automations/steps/deleteRow.js +4 -4
- package/dist/automations/steps/discord.js +91 -0
- package/dist/automations/steps/executeQuery.js +11 -14
- package/dist/automations/steps/executeScript.js +11 -14
- package/dist/automations/steps/filter.js +18 -17
- package/dist/automations/steps/integromat.js +94 -0
- package/dist/automations/steps/outgoingWebhook.js +12 -16
- package/dist/automations/steps/sendSmtpEmail.js +3 -3
- package/dist/automations/steps/serverLog.js +6 -2
- package/dist/automations/steps/slack.js +73 -0
- package/dist/automations/steps/updateRow.js +3 -3
- package/dist/automations/steps/utils.js +46 -0
- package/dist/automations/steps/zapier.js +91 -0
- package/dist/automations/tests/utilities/index.js +2 -12
- package/dist/automations/thread.js +23 -25
- package/dist/automations/triggerInfo/app.js +32 -0
- package/dist/automations/triggerInfo/cron.js +32 -0
- package/dist/automations/triggerInfo/index.js +15 -0
- package/dist/automations/triggerInfo/rowDeleted.js +33 -0
- package/dist/automations/triggerInfo/rowSaved.js +41 -0
- package/dist/automations/triggerInfo/rowUpdated.js +41 -0
- package/dist/automations/triggerInfo/webhook.js +37 -0
- package/dist/automations/triggers.js +27 -284
- package/dist/automations/utils.js +143 -0
- package/dist/constants/index.js +4 -0
- package/dist/db/linkedRows/index.js +14 -26
- package/dist/db/utils.js +14 -1
- package/dist/environment.js +1 -0
- package/dist/middleware/appInfo.js +17 -0
- package/dist/middleware/usageQuota.js +1 -1
- package/dist/package.json +4 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +0 -26
- package/dist/utilities/index.js +54 -0
- package/dist/utilities/redis.js +16 -1
- package/dist/utilities/rowProcessor/index.js +7 -4
- package/package.json +5 -6
- package/src/api/controllers/automation.js +75 -145
- package/src/api/controllers/deploy/index.js +23 -1
- package/src/api/controllers/metadata.js +46 -0
- package/src/api/controllers/query.js +0 -2
- package/src/api/controllers/row/internal.js +34 -23
- package/src/api/routes/automation.js +16 -11
- package/src/api/routes/index.js +2 -0
- package/src/api/routes/metadata.js +38 -0
- package/src/api/routes/tests/automation.spec.js +4 -26
- package/src/api/routes/tests/metadata.spec.js +65 -0
- package/src/api/routes/tests/utilities/TestFunctions.js +14 -0
- package/src/app.ts +1 -1
- package/src/automations/actions.js +26 -49
- package/src/automations/bullboard.js +12 -2
- package/src/automations/index.js +11 -45
- package/src/automations/steps/bash.js +12 -5
- package/src/automations/steps/createRow.js +4 -4
- package/src/automations/steps/delay.js +15 -2
- package/src/automations/steps/deleteRow.js +4 -4
- package/src/automations/steps/discord.js +83 -0
- package/src/automations/steps/executeQuery.js +11 -15
- package/src/automations/steps/executeScript.js +11 -15
- package/src/automations/steps/filter.js +18 -17
- package/src/automations/steps/integromat.js +87 -0
- package/src/automations/steps/outgoingWebhook.js +12 -14
- package/src/automations/steps/sendSmtpEmail.js +3 -3
- package/src/automations/steps/serverLog.js +6 -2
- package/src/automations/steps/slack.js +64 -0
- package/src/automations/steps/updateRow.js +3 -3
- package/src/automations/steps/utils.js +36 -0
- package/src/automations/steps/zapier.js +84 -0
- package/src/automations/tests/automation.spec.js +3 -66
- package/src/automations/tests/delay.spec.js +1 -1
- package/src/automations/tests/filter.spec.js +13 -13
- package/src/automations/tests/utilities/index.js +2 -13
- package/src/automations/thread.js +27 -26
- package/src/automations/triggerInfo/app.js +31 -0
- package/src/automations/triggerInfo/cron.js +31 -0
- package/src/automations/triggerInfo/index.js +15 -0
- package/src/automations/triggerInfo/rowDeleted.js +32 -0
- package/src/automations/triggerInfo/rowSaved.js +40 -0
- package/src/automations/triggerInfo/rowUpdated.js +40 -0
- package/src/automations/triggerInfo/webhook.js +36 -0
- package/src/automations/triggers.js +33 -288
- package/src/automations/utils.js +159 -0
- package/src/constants/index.js +5 -0
- package/src/db/linkedRows/index.js +15 -27
- package/src/db/tests/linkTests.spec.js +0 -12
- package/src/db/utils.js +17 -0
- package/src/environment.js +1 -0
- package/src/middleware/appInfo.js +19 -0
- package/src/middleware/usageQuota.js +1 -1
- package/src/utilities/fileSystem/index.js +0 -30
- package/src/utilities/index.js +51 -0
- package/src/utilities/redis.js +18 -1
- package/src/utilities/rowProcessor/index.js +16 -4
- package/dist/automations/logic.js +0 -17
- package/dist/automations/steps/sendgridEmail.js +0 -85
- package/src/automations/logic.js +0 -20
- package/src/automations/steps/sendgridEmail.js +0 -74
- package/src/automations/tests/sendEmail.spec.js +0 -36
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
jest.mock("../../utilities/usageQuota")
|
|
2
2
|
jest.mock("../thread")
|
|
3
3
|
jest.spyOn(global.console, "error")
|
|
4
|
-
jest.mock("worker-farm", () => {
|
|
5
|
-
return () => {
|
|
6
|
-
const value = jest
|
|
7
|
-
.fn()
|
|
8
|
-
.mockReturnValueOnce(undefined)
|
|
9
|
-
.mockReturnValueOnce("Error")
|
|
10
|
-
return (input, callback) => {
|
|
11
|
-
workerJob = input
|
|
12
|
-
if (callback) {
|
|
13
|
-
callback(value())
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
4
|
|
|
19
5
|
require("../../environment")
|
|
20
6
|
const automation = require("../index")
|
|
21
7
|
const usageQuota = require("../../utilities/usageQuota")
|
|
22
8
|
const thread = require("../thread")
|
|
23
9
|
const triggers = require("../triggers")
|
|
24
|
-
const { basicAutomation
|
|
10
|
+
const { basicAutomation } = require("../../tests/utilities/structures")
|
|
25
11
|
const { wait } = require("../../utilities")
|
|
26
12
|
const { makePartial } = require("../../tests/utilities")
|
|
27
13
|
const { cleanInputValues } = require("../automationUtils")
|
|
28
14
|
const setup = require("./utilities")
|
|
29
15
|
|
|
30
|
-
let workerJob
|
|
31
|
-
|
|
32
16
|
usageQuota.getAPIKey.mockReturnValue({ apiKey: "test" })
|
|
33
17
|
|
|
34
18
|
describe("Run through some parts of the automations system", () => {
|
|
@@ -44,59 +28,12 @@ describe("Run through some parts of the automations system", () => {
|
|
|
44
28
|
it("should be able to init in builder", async () => {
|
|
45
29
|
await triggers.externalTrigger(basicAutomation(), { a: 1 })
|
|
46
30
|
await wait(100)
|
|
47
|
-
expect(workerJob).toBeUndefined()
|
|
48
31
|
expect(thread).toHaveBeenCalled()
|
|
49
32
|
})
|
|
50
33
|
|
|
51
34
|
it("should be able to init in prod", async () => {
|
|
52
|
-
await
|
|
53
|
-
|
|
54
|
-
await wait(100)
|
|
55
|
-
// haven't added a mock implementation so getAPIKey of usageQuota just returns undefined
|
|
56
|
-
expect(usageQuota.update).toHaveBeenCalledWith("test", "automationRuns", 1)
|
|
57
|
-
expect(workerJob).toBeDefined()
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it("try error scenario", async () => {
|
|
62
|
-
await setup.runInProd(async () => {
|
|
63
|
-
// the second call will throw an error
|
|
64
|
-
await triggers.externalTrigger(basicAutomation(), { a: 1 })
|
|
65
|
-
await wait(100)
|
|
66
|
-
expect(console.error).toHaveBeenCalled()
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it("should be able to check triggering row filling", async () => {
|
|
71
|
-
const automation = basicAutomation()
|
|
72
|
-
let table = basicTable()
|
|
73
|
-
table.schema.boolean = {
|
|
74
|
-
type: "boolean",
|
|
75
|
-
constraints: {
|
|
76
|
-
type: "boolean",
|
|
77
|
-
},
|
|
78
|
-
}
|
|
79
|
-
table.schema.number = {
|
|
80
|
-
type: "number",
|
|
81
|
-
constraints: {
|
|
82
|
-
type: "number",
|
|
83
|
-
},
|
|
84
|
-
}
|
|
85
|
-
table.schema.datetime = {
|
|
86
|
-
type: "datetime",
|
|
87
|
-
constraints: {
|
|
88
|
-
type: "datetime",
|
|
89
|
-
},
|
|
90
|
-
}
|
|
91
|
-
table = await config.createTable(table)
|
|
92
|
-
automation.definition.trigger.inputs.tableId = table._id
|
|
93
|
-
const params = await triggers.fillRowOutput(automation, { appId: config.getAppId() })
|
|
94
|
-
expect(params.row).toBeDefined()
|
|
95
|
-
const date = new Date(params.row.datetime)
|
|
96
|
-
expect(typeof params.row.name).toBe("string")
|
|
97
|
-
expect(typeof params.row.boolean).toBe("boolean")
|
|
98
|
-
expect(typeof params.row.number).toBe("number")
|
|
99
|
-
expect(date.getFullYear()).toBe(1970)
|
|
35
|
+
await triggers.externalTrigger(basicAutomation(), { a: 1 })
|
|
36
|
+
await wait(100)
|
|
100
37
|
})
|
|
101
38
|
|
|
102
39
|
it("should check coercion", async () => {
|
|
@@ -4,7 +4,7 @@ describe("test the delay logic", () => {
|
|
|
4
4
|
it("should be able to run the delay", async () => {
|
|
5
5
|
const time = 100
|
|
6
6
|
const before = Date.now()
|
|
7
|
-
await setup.runStep(setup.
|
|
7
|
+
await setup.runStep(setup.actions.DELAY.stepId, { time: time })
|
|
8
8
|
const now = Date.now()
|
|
9
9
|
// divide by two just so that test will always pass as long as there was some sort of delay
|
|
10
10
|
expect(now - before).toBeGreaterThanOrEqual(time / 2)
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
const setup = require("./utilities")
|
|
2
|
-
const {
|
|
2
|
+
const { FilterConditions } = require("../steps/filter")
|
|
3
3
|
|
|
4
4
|
describe("test the filter logic", () => {
|
|
5
5
|
async function checkFilter(field, condition, value, pass = true) {
|
|
6
|
-
let res = await setup.runStep(setup.
|
|
6
|
+
let res = await setup.runStep(setup.actions.FILTER.stepId,
|
|
7
7
|
{ field, condition, value }
|
|
8
8
|
)
|
|
9
9
|
expect(res.success).toEqual(pass)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
it("should be able test equality", async () => {
|
|
13
|
-
await checkFilter("hello",
|
|
14
|
-
await checkFilter("hello",
|
|
13
|
+
await checkFilter("hello", FilterConditions.EQUAL, "hello", true)
|
|
14
|
+
await checkFilter("hello", FilterConditions.EQUAL, "no", false)
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
it("should be able to test greater than", async () => {
|
|
18
|
-
await checkFilter(10,
|
|
19
|
-
await checkFilter(10,
|
|
18
|
+
await checkFilter(10, FilterConditions.GREATER_THAN, 5, true)
|
|
19
|
+
await checkFilter(10, FilterConditions.GREATER_THAN, 15, false)
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
it("should be able to test less than", async () => {
|
|
23
|
-
await checkFilter(5,
|
|
24
|
-
await checkFilter(15,
|
|
23
|
+
await checkFilter(5, FilterConditions.LESS_THAN, 10, true)
|
|
24
|
+
await checkFilter(15, FilterConditions.LESS_THAN, 10, false)
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
it("should be able to in-equality", async () => {
|
|
28
|
-
await checkFilter("hello",
|
|
29
|
-
await checkFilter(10,
|
|
28
|
+
await checkFilter("hello", FilterConditions.NOT_EQUAL, "no", true)
|
|
29
|
+
await checkFilter(10, FilterConditions.NOT_EQUAL, 10, false)
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
it("check number coercion", async () => {
|
|
33
|
-
await checkFilter("10",
|
|
33
|
+
await checkFilter("10", FilterConditions.GREATER_THAN, "5", true)
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
it("check date coercion", async () => {
|
|
37
37
|
await checkFilter(
|
|
38
38
|
(new Date()).toISOString(),
|
|
39
|
-
|
|
39
|
+
FilterConditions.GREATER_THAN,
|
|
40
40
|
(new Date(-10000)).toISOString(),
|
|
41
41
|
true
|
|
42
42
|
)
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
it("check objects always false", async () => {
|
|
46
|
-
await checkFilter({},
|
|
46
|
+
await checkFilter({}, FilterConditions.EQUAL, {}, false)
|
|
47
47
|
})
|
|
48
48
|
})
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const TestConfig = require("../../../tests/utilities/TestConfiguration")
|
|
2
2
|
const actions = require("../../actions")
|
|
3
|
-
const logic = require("../../logic")
|
|
4
3
|
const emitter = require("../../../events/index")
|
|
5
4
|
const env = require("../../../environment")
|
|
6
5
|
|
|
@@ -34,16 +33,7 @@ exports.runInProd = async fn => {
|
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
exports.runStep = async function runStep(stepId, inputs) {
|
|
37
|
-
let step
|
|
38
|
-
if (
|
|
39
|
-
Object.values(exports.actions)
|
|
40
|
-
.map(action => action.stepId)
|
|
41
|
-
.includes(stepId)
|
|
42
|
-
) {
|
|
43
|
-
step = await actions.getAction(stepId)
|
|
44
|
-
} else {
|
|
45
|
-
step = logic.getLogic(stepId)
|
|
46
|
-
}
|
|
36
|
+
let step = await actions.getAction(stepId)
|
|
47
37
|
expect(step).toBeDefined()
|
|
48
38
|
return step({
|
|
49
39
|
inputs,
|
|
@@ -56,5 +46,4 @@ exports.runStep = async function runStep(stepId, inputs) {
|
|
|
56
46
|
|
|
57
47
|
exports.apiKey = "test"
|
|
58
48
|
|
|
59
|
-
exports.actions = actions.
|
|
60
|
-
exports.logic = logic.BUILTIN_DEFINITIONS
|
|
49
|
+
exports.actions = actions.ACTION_DEFINITIONS
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const actions = require("./actions")
|
|
2
|
-
const logic = require("./logic")
|
|
3
2
|
const automationUtils = require("./automationUtils")
|
|
4
3
|
const AutomationEmitter = require("../events/AutomationEmitter")
|
|
5
4
|
const { processObject } = require("@budibase/string-templates")
|
|
@@ -8,7 +7,7 @@ const CouchDB = require("../db")
|
|
|
8
7
|
const { DocumentTypes } = require("../db/utils")
|
|
9
8
|
const { doInTenant } = require("@budibase/auth/tenancy")
|
|
10
9
|
|
|
11
|
-
const FILTER_STEP_ID =
|
|
10
|
+
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* The automation orchestrator is a class responsible for executing automations.
|
|
@@ -30,15 +29,15 @@ class Orchestrator {
|
|
|
30
29
|
// create an emitter which has the chain count for this automation run in it, so it can block
|
|
31
30
|
// excessive chaining if required
|
|
32
31
|
this._emitter = new AutomationEmitter(this._chainCount + 1)
|
|
32
|
+
this.executionOutput = { trigger: {}, steps: [] }
|
|
33
|
+
// setup the execution output
|
|
34
|
+
const triggerStepId = automation.definition.trigger.stepId
|
|
35
|
+
const triggerId = automation.definition.trigger.id
|
|
36
|
+
this.updateExecutionOutput(triggerId, triggerStepId, null, triggerOutput)
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
async getStepFunctionality(
|
|
36
|
-
let step =
|
|
37
|
-
if (type === "ACTION") {
|
|
38
|
-
step = await actions.getAction(stepId)
|
|
39
|
-
} else if (type === "LOGIC") {
|
|
40
|
-
step = logic.getLogic(stepId)
|
|
41
|
-
}
|
|
39
|
+
async getStepFunctionality(stepId) {
|
|
40
|
+
let step = await actions.getAction(stepId)
|
|
42
41
|
if (step == null) {
|
|
43
42
|
throw `Cannot find automation step by name ${stepId}`
|
|
44
43
|
}
|
|
@@ -55,11 +54,20 @@ class Orchestrator {
|
|
|
55
54
|
return this._app
|
|
56
55
|
}
|
|
57
56
|
|
|
57
|
+
updateExecutionOutput(id, stepId, inputs, outputs) {
|
|
58
|
+
const stepObj = { id, stepId, inputs, outputs }
|
|
59
|
+
// first entry is always the trigger (constructor)
|
|
60
|
+
if (this.executionOutput.steps.length === 0) {
|
|
61
|
+
this.executionOutput.trigger = stepObj
|
|
62
|
+
}
|
|
63
|
+
this.executionOutput.steps.push(stepObj)
|
|
64
|
+
}
|
|
65
|
+
|
|
58
66
|
async execute() {
|
|
59
67
|
let automation = this._automation
|
|
60
68
|
const app = await this.getApp()
|
|
61
69
|
for (let step of automation.definition.steps) {
|
|
62
|
-
let stepFn = await this.getStepFunctionality(step.
|
|
70
|
+
let stepFn = await this.getStepFunctionality(step.stepId)
|
|
63
71
|
step.inputs = await processObject(step.inputs, this._context)
|
|
64
72
|
step.inputs = automationUtils.cleanInputValues(
|
|
65
73
|
step.inputs,
|
|
@@ -81,27 +89,20 @@ class Orchestrator {
|
|
|
81
89
|
break
|
|
82
90
|
}
|
|
83
91
|
this._context.steps.push(outputs)
|
|
92
|
+
this.updateExecutionOutput(step.id, step.stepId, step.inputs, outputs)
|
|
84
93
|
} catch (err) {
|
|
85
94
|
console.error(`Automation error - ${step.stepId} - ${err}`)
|
|
95
|
+
return err
|
|
86
96
|
}
|
|
87
97
|
}
|
|
98
|
+
return this.executionOutput
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
)
|
|
98
|
-
await automationOrchestrator.execute()
|
|
99
|
-
if (cb) {
|
|
100
|
-
cb()
|
|
101
|
-
}
|
|
102
|
-
} catch (err) {
|
|
103
|
-
if (cb) {
|
|
104
|
-
cb(err)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
102
|
+
module.exports = async job => {
|
|
103
|
+
const automationOrchestrator = new Orchestrator(
|
|
104
|
+
job.data.automation,
|
|
105
|
+
job.data.event
|
|
106
|
+
)
|
|
107
|
+
return automationOrchestrator.execute()
|
|
107
108
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
exports.definition = {
|
|
2
|
+
name: "App Action",
|
|
3
|
+
event: "app:trigger",
|
|
4
|
+
icon: "ri-window-fill",
|
|
5
|
+
tagline: "Automation fired from the frontend",
|
|
6
|
+
description: "Trigger an automation from an action inside your app",
|
|
7
|
+
stepId: "APP",
|
|
8
|
+
inputs: {},
|
|
9
|
+
schema: {
|
|
10
|
+
inputs: {
|
|
11
|
+
properties: {
|
|
12
|
+
fields: {
|
|
13
|
+
type: "object",
|
|
14
|
+
customType: "triggerSchema",
|
|
15
|
+
title: "Fields",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
required: [],
|
|
19
|
+
},
|
|
20
|
+
outputs: {
|
|
21
|
+
properties: {
|
|
22
|
+
fields: {
|
|
23
|
+
type: "object",
|
|
24
|
+
description: "Fields submitted from the app frontend",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: ["fields"],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
type: "TRIGGER",
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
exports.definition = {
|
|
2
|
+
name: "Cron Trigger",
|
|
3
|
+
event: "cron:trigger",
|
|
4
|
+
icon: "ri-timer-line",
|
|
5
|
+
tagline: "Cron Trigger (<b>{{inputs.cron}}</b>)",
|
|
6
|
+
description: "Triggers automation on a cron schedule.",
|
|
7
|
+
stepId: "CRON",
|
|
8
|
+
inputs: {},
|
|
9
|
+
schema: {
|
|
10
|
+
inputs: {
|
|
11
|
+
properties: {
|
|
12
|
+
cron: {
|
|
13
|
+
type: "string",
|
|
14
|
+
customType: "cron",
|
|
15
|
+
title: "Expression",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
required: ["cron"],
|
|
19
|
+
},
|
|
20
|
+
outputs: {
|
|
21
|
+
properties: {
|
|
22
|
+
timestamp: {
|
|
23
|
+
type: "number",
|
|
24
|
+
description: "Timestamp the cron was executed",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: ["timestamp"],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
type: "TRIGGER",
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const app = require("./app")
|
|
2
|
+
const cron = require("./cron")
|
|
3
|
+
const rowDeleted = require("./rowDeleted")
|
|
4
|
+
const rowSaved = require("./rowSaved")
|
|
5
|
+
const rowUpdated = require("./rowUpdated")
|
|
6
|
+
const webhook = require("./webhook")
|
|
7
|
+
|
|
8
|
+
exports.definitions = {
|
|
9
|
+
ROW_SAVED: rowSaved.definition,
|
|
10
|
+
ROW_UPDATED: rowUpdated.definition,
|
|
11
|
+
ROW_DELETED: rowDeleted.definition,
|
|
12
|
+
WEBHOOK: webhook.definition,
|
|
13
|
+
APP: app.definition,
|
|
14
|
+
CRON: cron.definition,
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
exports.definition = {
|
|
2
|
+
name: "Row Deleted",
|
|
3
|
+
event: "row:delete",
|
|
4
|
+
icon: "ri-delete-bin-line",
|
|
5
|
+
tagline: "Row is deleted from {{inputs.enriched.table.name}}",
|
|
6
|
+
description: "Fired when a row is deleted from your database",
|
|
7
|
+
stepId: "ROW_DELETED",
|
|
8
|
+
inputs: {},
|
|
9
|
+
schema: {
|
|
10
|
+
inputs: {
|
|
11
|
+
properties: {
|
|
12
|
+
tableId: {
|
|
13
|
+
type: "string",
|
|
14
|
+
customType: "table",
|
|
15
|
+
title: "Table",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
required: ["tableId"],
|
|
19
|
+
},
|
|
20
|
+
outputs: {
|
|
21
|
+
properties: {
|
|
22
|
+
row: {
|
|
23
|
+
type: "object",
|
|
24
|
+
customType: "row",
|
|
25
|
+
description: "The row that was deleted",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ["row"],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
type: "TRIGGER",
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
exports.definition = {
|
|
2
|
+
name: "Row Created",
|
|
3
|
+
event: "row:save",
|
|
4
|
+
icon: "ri-save-line",
|
|
5
|
+
tagline: "Row is added to {{inputs.enriched.table.name}}",
|
|
6
|
+
description: "Fired when a row is added to your database",
|
|
7
|
+
stepId: "ROW_SAVED",
|
|
8
|
+
inputs: {},
|
|
9
|
+
schema: {
|
|
10
|
+
inputs: {
|
|
11
|
+
properties: {
|
|
12
|
+
tableId: {
|
|
13
|
+
type: "string",
|
|
14
|
+
customType: "table",
|
|
15
|
+
title: "Table",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
required: ["tableId"],
|
|
19
|
+
},
|
|
20
|
+
outputs: {
|
|
21
|
+
properties: {
|
|
22
|
+
row: {
|
|
23
|
+
type: "object",
|
|
24
|
+
customType: "row",
|
|
25
|
+
description: "The new row that was created",
|
|
26
|
+
},
|
|
27
|
+
id: {
|
|
28
|
+
type: "string",
|
|
29
|
+
description: "Row ID - can be used for updating",
|
|
30
|
+
},
|
|
31
|
+
revision: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "Revision of row",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
required: ["row", "id"],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
type: "TRIGGER",
|
|
40
|
+
}
|