@budibase/server 0.9.138 → 0.9.140-alpha.2
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/discord.c14881e9.svg +10 -0
- package/builder/assets/{index.b18ab99b.js → index.1d1fa051.js} +35 -35
- package/builder/assets/{index.121692c9.css → index.79907e5c.css} +5 -5
- package/builder/assets/integromat.42212f11.png +0 -0
- package/builder/assets/slack.1e1f7cfb.svg +33 -0
- package/builder/assets/{vendor.7177f366.js → vendor.d39b3c1e.js} +2 -2
- package/builder/assets/zapier.3fbd8f5c.png +0 -0
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2138 -2091
- package/coverage/coverage-final.json +120 -106
- 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 +84 -84
- package/coverage/lcov-report/api/controllers/auth.js.html +6 -6
- package/coverage/lcov-report/api/controllers/automation.js.html +182 -356
- 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 +12 -12
- 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 +47 -32
- package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- package/coverage/lcov-report/api/controllers/metadata.js.html +218 -0
- package/coverage/lcov-report/api/controllers/permission.js.html +14 -14
- package/coverage/lcov-report/api/controllers/query.js.html +17 -23
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +15 -15
- package/coverage/lcov-report/api/controllers/row/index.html +29 -44
- package/coverage/lcov-report/api/controllers/row/index.js.html +48 -45
- package/coverage/lcov-report/api/controllers/row/internal.js.html +159 -126
- package/coverage/lcov-report/api/controllers/row/utils.js.html +17 -17
- package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
- package/coverage/lcov-report/api/controllers/script.js.html +5 -5
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +40 -40
- package/coverage/lcov-report/api/controllers/table/utils.js.html +48 -48
- package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
- package/coverage/lcov-report/api/controllers/user.js.html +14 -11
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +3 -3
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +9 -9
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +6 -6
- package/coverage/lcov-report/api/controllers/webhook.js.html +14 -14
- 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 -16
- 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 +57 -117
- package/coverage/lcov-report/automations/automationUtils.js.html +7 -7
- package/coverage/lcov-report/automations/bullboard.js.html +49 -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 +37 -16
- package/coverage/lcov-report/automations/steps/createRow.js.html +15 -15
- package/coverage/lcov-report/automations/steps/delay.js.html +48 -9
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +14 -14
- package/coverage/lcov-report/automations/steps/discord.js.html +329 -0
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +22 -34
- package/coverage/lcov-report/automations/steps/executeScript.js.html +21 -33
- package/coverage/lcov-report/automations/steps/filter.js.html +28 -25
- package/coverage/lcov-report/automations/steps/index.html +140 -65
- package/coverage/lcov-report/automations/steps/integromat.js.html +341 -0
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +44 -38
- package/coverage/lcov-report/automations/steps/queryRows.js.html +437 -0
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +13 -13
- package/coverage/lcov-report/automations/steps/serverLog.js.html +23 -11
- package/coverage/lcov-report/automations/steps/{sendgridEmail.js.html → slack.js.html} +58 -88
- package/coverage/lcov-report/automations/steps/updateRow.js.html +12 -12
- 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 +67 -838
- 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 +32 -17
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/index.html +19 -19
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +79 -79
- package/coverage/lcov-report/db/linkedRows/index.html +18 -18
- package/coverage/lcov-report/db/linkedRows/index.js.html +107 -149
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +43 -43
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +127 -76
- 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 +6 -6
- package/coverage/lcov-report/events/utils.js.html +3 -3
- package/coverage/lcov-report/index.html +116 -101
- 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 +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +33 -33
- package/coverage/lcov-report/utilities/index.html +28 -28
- package/coverage/lcov-report/utilities/index.js.html +178 -25
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +18 -18
- 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 +10 -10
- package/coverage/lcov-report/utilities/security.js.html +9 -9
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +52 -52
- package/coverage/lcov.info +3255 -3218
- package/dist/api/controllers/automation.js +60 -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/ExternalRequest.js +1 -1
- package/dist/api/controllers/row/index.js +1 -0
- package/dist/api/controllers/row/internal.js +33 -23
- package/dist/api/controllers/static/index.js +1 -28
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +4 -1
- package/dist/api/controllers/user.js +1 -1
- 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/static.js +0 -1
- package/dist/api/routes/tests/utilities/TestFunctions.js +13 -0
- package/dist/app.js +1 -1
- package/dist/automations/actions.js +29 -46
- package/dist/automations/bullboard.js +11 -2
- package/dist/automations/index.js +11 -48
- package/dist/automations/steps/bash.js +12 -6
- package/dist/automations/steps/createRow.js +5 -5
- package/dist/automations/steps/delay.js +16 -3
- package/dist/automations/steps/deleteRow.js +5 -5
- package/dist/automations/steps/discord.js +91 -0
- package/dist/automations/steps/executeQuery.js +12 -15
- package/dist/automations/steps/executeScript.js +12 -15
- package/dist/automations/steps/filter.js +19 -18
- package/dist/automations/steps/integromat.js +94 -0
- package/dist/automations/steps/outgoingWebhook.js +19 -20
- package/dist/automations/steps/queryRows.js +129 -0
- package/dist/automations/steps/sendSmtpEmail.js +4 -4
- package/dist/automations/steps/serverLog.js +7 -3
- package/dist/automations/steps/slack.js +73 -0
- package/dist/automations/steps/updateRow.js +4 -4
- 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 -285
- package/dist/automations/utils.js +143 -0
- package/dist/constants/index.js +4 -0
- package/dist/db/linkedRows/index.js +20 -34
- package/dist/db/utils.js +14 -1
- package/dist/environment.js +2 -1
- package/dist/integrations/mysql.js +14 -2
- package/dist/middleware/appInfo.js +17 -0
- package/dist/middleware/usageQuota.js +1 -1
- package/dist/package.json +12 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/appDirectoryTemplate/package.json +1 -1
- package/dist/utilities/fileSystem/clientLibrary.js +2 -2
- package/dist/utilities/fileSystem/index.js +2 -27
- 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 +13 -12
- package/scripts/jestSetup.js +1 -0
- package/scripts/selfhost.js +8 -0
- package/src/api/controllers/automation.js +87 -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/ExternalRequest.ts +1 -1
- package/src/api/controllers/row/index.js +1 -0
- package/src/api/controllers/row/internal.js +34 -23
- package/src/api/controllers/static/index.js +1 -39
- package/src/api/controllers/static/templates/BudibaseApp.svelte +4 -1
- package/src/api/controllers/user.js +1 -0
- 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/static.js +0 -1
- 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 +29 -49
- package/src/automations/bullboard.js +13 -2
- package/src/automations/index.js +11 -45
- package/src/automations/steps/bash.js +13 -6
- package/src/automations/steps/createRow.js +5 -5
- package/src/automations/steps/delay.js +16 -3
- package/src/automations/steps/deleteRow.js +5 -5
- package/src/automations/steps/discord.js +83 -0
- package/src/automations/steps/executeQuery.js +12 -16
- package/src/automations/steps/executeScript.js +12 -16
- package/src/automations/steps/filter.js +19 -18
- package/src/automations/steps/integromat.js +87 -0
- package/src/automations/steps/outgoingWebhook.js +20 -18
- package/src/automations/steps/queryRows.js +119 -0
- package/src/automations/steps/sendSmtpEmail.js +4 -4
- package/src/automations/steps/serverLog.js +7 -3
- package/src/automations/steps/slack.js +64 -0
- package/src/automations/steps/updateRow.js +4 -4
- package/src/automations/steps/utils.js +36 -0
- package/src/automations/steps/zapier.js +84 -0
- package/src/automations/tests/automation.spec.js +4 -67
- package/src/automations/tests/delay.spec.js +2 -2
- package/src/automations/tests/filter.spec.js +14 -14
- package/src/automations/tests/queryRows.spec.js +51 -0
- 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 -290
- package/src/automations/utils.js +159 -0
- package/src/constants/index.js +5 -0
- package/src/db/linkedRows/index.js +21 -35
- package/src/db/tests/linkTests.spec.js +0 -12
- package/src/db/utils.js +17 -0
- package/src/environment.js +2 -1
- package/src/integrations/mysql.ts +15 -2
- package/src/middleware/appInfo.js +19 -0
- package/src/middleware/usageQuota.js +1 -1
- package/src/utilities/appDirectoryTemplate/package.json +1 -1
- package/src/utilities/fileSystem/clientLibrary.js +2 -2
- package/src/utilities/fileSystem/index.js +2 -36
- package/src/utilities/index.js +51 -0
- package/src/utilities/redis.js +18 -1
- package/src/utilities/rowProcessor/index.js +16 -4
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +0 -1244
- 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
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
const fetch = require("node-fetch");
|
|
12
|
+
const { getFetchResponse } = require("./utils");
|
|
13
|
+
exports.definition = {
|
|
14
|
+
name: "Zapier Webhook",
|
|
15
|
+
stepId: "zapier",
|
|
16
|
+
type: "ACTION",
|
|
17
|
+
internal: false,
|
|
18
|
+
description: "Trigger a Zapier Zap via webhooks",
|
|
19
|
+
tagline: "Trigger a Zapier Zap",
|
|
20
|
+
icon: "ri-flashlight-line",
|
|
21
|
+
schema: {
|
|
22
|
+
inputs: {
|
|
23
|
+
properties: {
|
|
24
|
+
url: {
|
|
25
|
+
type: "string",
|
|
26
|
+
title: "Webhook URL",
|
|
27
|
+
},
|
|
28
|
+
value1: {
|
|
29
|
+
type: "string",
|
|
30
|
+
title: "Payload Value 1",
|
|
31
|
+
},
|
|
32
|
+
value2: {
|
|
33
|
+
type: "string",
|
|
34
|
+
title: "Payload Value 2",
|
|
35
|
+
},
|
|
36
|
+
value3: {
|
|
37
|
+
type: "string",
|
|
38
|
+
title: "Payload Value 3",
|
|
39
|
+
},
|
|
40
|
+
value4: {
|
|
41
|
+
type: "string",
|
|
42
|
+
title: "Payload Value 4",
|
|
43
|
+
},
|
|
44
|
+
value5: {
|
|
45
|
+
type: "string",
|
|
46
|
+
title: "Payload Value 5",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
required: ["url"],
|
|
50
|
+
},
|
|
51
|
+
outputs: {
|
|
52
|
+
properties: {
|
|
53
|
+
httpStatus: {
|
|
54
|
+
type: "number",
|
|
55
|
+
description: "The HTTP status code of the request",
|
|
56
|
+
},
|
|
57
|
+
response: {
|
|
58
|
+
type: "string",
|
|
59
|
+
description: "The response from Zapier",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
exports.run = function ({ inputs }) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const { url, value1, value2, value3, value4, value5 } = inputs;
|
|
68
|
+
// send the platform to make sure zaps always work, even
|
|
69
|
+
// if no values supplied
|
|
70
|
+
const response = yield fetch(url, {
|
|
71
|
+
method: "post",
|
|
72
|
+
body: JSON.stringify({
|
|
73
|
+
platform: "budibase",
|
|
74
|
+
value1,
|
|
75
|
+
value2,
|
|
76
|
+
value3,
|
|
77
|
+
value4,
|
|
78
|
+
value5,
|
|
79
|
+
}),
|
|
80
|
+
headers: {
|
|
81
|
+
"Content-Type": "application/json",
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
const { status, message } = yield getFetchResponse(response);
|
|
85
|
+
return {
|
|
86
|
+
success: status === 200,
|
|
87
|
+
httpStatus: status,
|
|
88
|
+
response: message,
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
};
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const TestConfig = require("../../../tests/utilities/TestConfiguration");
|
|
12
12
|
const actions = require("../../actions");
|
|
13
|
-
const logic = require("../../logic");
|
|
14
13
|
const emitter = require("../../../events/index");
|
|
15
14
|
const env = require("../../../environment");
|
|
16
15
|
let config;
|
|
@@ -41,15 +40,7 @@ exports.runInProd = (fn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
41
40
|
});
|
|
42
41
|
exports.runStep = function runStep(stepId, inputs) {
|
|
43
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
let step;
|
|
45
|
-
if (Object.values(exports.actions)
|
|
46
|
-
.map(action => action.stepId)
|
|
47
|
-
.includes(stepId)) {
|
|
48
|
-
step = yield actions.getAction(stepId);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
step = logic.getLogic(stepId);
|
|
52
|
-
}
|
|
43
|
+
let step = yield actions.getAction(stepId);
|
|
53
44
|
expect(step).toBeDefined();
|
|
54
45
|
return step({
|
|
55
46
|
inputs,
|
|
@@ -61,5 +52,4 @@ exports.runStep = function runStep(stepId, inputs) {
|
|
|
61
52
|
});
|
|
62
53
|
};
|
|
63
54
|
exports.apiKey = "test";
|
|
64
|
-
exports.actions = actions.
|
|
65
|
-
exports.logic = logic.BUILTIN_DEFINITIONS;
|
|
55
|
+
exports.actions = actions.ACTION_DEFINITIONS;
|
|
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const actions = require("./actions");
|
|
12
|
-
const logic = require("./logic");
|
|
13
12
|
const automationUtils = require("./automationUtils");
|
|
14
13
|
const AutomationEmitter = require("../events/AutomationEmitter");
|
|
15
14
|
const { processObject } = require("@budibase/string-templates");
|
|
@@ -17,7 +16,7 @@ const { DEFAULT_TENANT_ID } = require("@budibase/auth").constants;
|
|
|
17
16
|
const CouchDB = require("../db");
|
|
18
17
|
const { DocumentTypes } = require("../db/utils");
|
|
19
18
|
const { doInTenant } = require("@budibase/auth/tenancy");
|
|
20
|
-
const FILTER_STEP_ID =
|
|
19
|
+
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId;
|
|
21
20
|
/**
|
|
22
21
|
* The automation orchestrator is a class responsible for executing automations.
|
|
23
22
|
* It handles the context of the automation and makes sure each step gets the correct
|
|
@@ -38,16 +37,15 @@ class Orchestrator {
|
|
|
38
37
|
// create an emitter which has the chain count for this automation run in it, so it can block
|
|
39
38
|
// excessive chaining if required
|
|
40
39
|
this._emitter = new AutomationEmitter(this._chainCount + 1);
|
|
40
|
+
this.executionOutput = { trigger: {}, steps: [] };
|
|
41
|
+
// setup the execution output
|
|
42
|
+
const triggerStepId = automation.definition.trigger.stepId;
|
|
43
|
+
const triggerId = automation.definition.trigger.id;
|
|
44
|
+
this.updateExecutionOutput(triggerId, triggerStepId, null, triggerOutput);
|
|
41
45
|
}
|
|
42
|
-
getStepFunctionality(
|
|
46
|
+
getStepFunctionality(stepId) {
|
|
43
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
let step =
|
|
45
|
-
if (type === "ACTION") {
|
|
46
|
-
step = yield actions.getAction(stepId);
|
|
47
|
-
}
|
|
48
|
-
else if (type === "LOGIC") {
|
|
49
|
-
step = logic.getLogic(stepId);
|
|
50
|
-
}
|
|
48
|
+
let step = yield actions.getAction(stepId);
|
|
51
49
|
if (step == null) {
|
|
52
50
|
throw `Cannot find automation step by name ${stepId}`;
|
|
53
51
|
}
|
|
@@ -65,12 +63,20 @@ class Orchestrator {
|
|
|
65
63
|
return this._app;
|
|
66
64
|
});
|
|
67
65
|
}
|
|
66
|
+
updateExecutionOutput(id, stepId, inputs, outputs) {
|
|
67
|
+
const stepObj = { id, stepId, inputs, outputs };
|
|
68
|
+
// first entry is always the trigger (constructor)
|
|
69
|
+
if (this.executionOutput.steps.length === 0) {
|
|
70
|
+
this.executionOutput.trigger = stepObj;
|
|
71
|
+
}
|
|
72
|
+
this.executionOutput.steps.push(stepObj);
|
|
73
|
+
}
|
|
68
74
|
execute() {
|
|
69
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
76
|
let automation = this._automation;
|
|
71
77
|
const app = yield this.getApp();
|
|
72
78
|
for (let step of automation.definition.steps) {
|
|
73
|
-
let stepFn = yield this.getStepFunctionality(step.
|
|
79
|
+
let stepFn = yield this.getStepFunctionality(step.stepId);
|
|
74
80
|
step.inputs = yield processObject(step.inputs, this._context);
|
|
75
81
|
step.inputs = automationUtils.cleanInputValues(step.inputs, step.schema.inputs);
|
|
76
82
|
// appId is always passed
|
|
@@ -89,26 +95,18 @@ class Orchestrator {
|
|
|
89
95
|
break;
|
|
90
96
|
}
|
|
91
97
|
this._context.steps.push(outputs);
|
|
98
|
+
this.updateExecutionOutput(step.id, step.stepId, step.inputs, outputs);
|
|
92
99
|
}
|
|
93
100
|
catch (err) {
|
|
94
101
|
console.error(`Automation error - ${step.stepId} - ${err}`);
|
|
102
|
+
return err;
|
|
95
103
|
}
|
|
96
104
|
}
|
|
105
|
+
return this.executionOutput;
|
|
97
106
|
});
|
|
98
107
|
}
|
|
99
108
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const automationOrchestrator = new Orchestrator(job.data.automation, job.data.event);
|
|
104
|
-
yield automationOrchestrator.execute();
|
|
105
|
-
if (cb) {
|
|
106
|
-
cb();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
catch (err) {
|
|
110
|
-
if (cb) {
|
|
111
|
-
cb(err);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
109
|
+
module.exports = (job) => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
const automationOrchestrator = new Orchestrator(job.data.automation, job.data.event);
|
|
111
|
+
return automationOrchestrator.execute();
|
|
114
112
|
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.definition = {
|
|
3
|
+
name: "App Action",
|
|
4
|
+
event: "app:trigger",
|
|
5
|
+
icon: "Apps",
|
|
6
|
+
tagline: "Automation fired from the frontend",
|
|
7
|
+
description: "Trigger an automation from an action inside your app",
|
|
8
|
+
stepId: "APP",
|
|
9
|
+
inputs: {},
|
|
10
|
+
schema: {
|
|
11
|
+
inputs: {
|
|
12
|
+
properties: {
|
|
13
|
+
fields: {
|
|
14
|
+
type: "object",
|
|
15
|
+
customType: "triggerSchema",
|
|
16
|
+
title: "Fields",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
required: [],
|
|
20
|
+
},
|
|
21
|
+
outputs: {
|
|
22
|
+
properties: {
|
|
23
|
+
fields: {
|
|
24
|
+
type: "object",
|
|
25
|
+
description: "Fields submitted from the app frontend",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ["fields"],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
type: "TRIGGER",
|
|
32
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.definition = {
|
|
3
|
+
name: "Cron Trigger",
|
|
4
|
+
event: "cron:trigger",
|
|
5
|
+
icon: "Clock",
|
|
6
|
+
tagline: "Cron Trigger (<b>{{inputs.cron}}</b>)",
|
|
7
|
+
description: "Triggers automation on a cron schedule.",
|
|
8
|
+
stepId: "CRON",
|
|
9
|
+
inputs: {},
|
|
10
|
+
schema: {
|
|
11
|
+
inputs: {
|
|
12
|
+
properties: {
|
|
13
|
+
cron: {
|
|
14
|
+
type: "string",
|
|
15
|
+
customType: "cron",
|
|
16
|
+
title: "Expression",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
required: ["cron"],
|
|
20
|
+
},
|
|
21
|
+
outputs: {
|
|
22
|
+
properties: {
|
|
23
|
+
timestamp: {
|
|
24
|
+
type: "number",
|
|
25
|
+
description: "Timestamp the cron was executed",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ["timestamp"],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
type: "TRIGGER",
|
|
32
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const app = require("./app");
|
|
3
|
+
const cron = require("./cron");
|
|
4
|
+
const rowDeleted = require("./rowDeleted");
|
|
5
|
+
const rowSaved = require("./rowSaved");
|
|
6
|
+
const rowUpdated = require("./rowUpdated");
|
|
7
|
+
const webhook = require("./webhook");
|
|
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,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.definition = {
|
|
3
|
+
name: "Row Deleted",
|
|
4
|
+
event: "row:delete",
|
|
5
|
+
icon: "TableRowRemoveCenter",
|
|
6
|
+
tagline: "Row is deleted from {{inputs.enriched.table.name}}",
|
|
7
|
+
description: "Fired when a row is deleted from your database",
|
|
8
|
+
stepId: "ROW_DELETED",
|
|
9
|
+
inputs: {},
|
|
10
|
+
schema: {
|
|
11
|
+
inputs: {
|
|
12
|
+
properties: {
|
|
13
|
+
tableId: {
|
|
14
|
+
type: "string",
|
|
15
|
+
customType: "table",
|
|
16
|
+
title: "Table",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
required: ["tableId"],
|
|
20
|
+
},
|
|
21
|
+
outputs: {
|
|
22
|
+
properties: {
|
|
23
|
+
row: {
|
|
24
|
+
type: "object",
|
|
25
|
+
customType: "row",
|
|
26
|
+
description: "The row that was deleted",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
required: ["row"],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
type: "TRIGGER",
|
|
33
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.definition = {
|
|
3
|
+
name: "Row Created",
|
|
4
|
+
event: "row:save",
|
|
5
|
+
icon: "TableRowAddBottom",
|
|
6
|
+
tagline: "Row is added to {{inputs.enriched.table.name}}",
|
|
7
|
+
description: "Fired when a row is added to your database",
|
|
8
|
+
stepId: "ROW_SAVED",
|
|
9
|
+
inputs: {},
|
|
10
|
+
schema: {
|
|
11
|
+
inputs: {
|
|
12
|
+
properties: {
|
|
13
|
+
tableId: {
|
|
14
|
+
type: "string",
|
|
15
|
+
customType: "table",
|
|
16
|
+
title: "Table",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
required: ["tableId"],
|
|
20
|
+
},
|
|
21
|
+
outputs: {
|
|
22
|
+
properties: {
|
|
23
|
+
row: {
|
|
24
|
+
type: "object",
|
|
25
|
+
customType: "row",
|
|
26
|
+
description: "The new row that was created",
|
|
27
|
+
},
|
|
28
|
+
id: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "Row ID - can be used for updating",
|
|
31
|
+
},
|
|
32
|
+
revision: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Revision of row",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
required: ["row", "id"],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
type: "TRIGGER",
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.definition = {
|
|
3
|
+
name: "Row Updated",
|
|
4
|
+
event: "row:update",
|
|
5
|
+
icon: "Refresh",
|
|
6
|
+
tagline: "Row is updated in {{inputs.enriched.table.name}}",
|
|
7
|
+
description: "Fired when a row is updated in your database",
|
|
8
|
+
stepId: "ROW_UPDATED",
|
|
9
|
+
inputs: {},
|
|
10
|
+
schema: {
|
|
11
|
+
inputs: {
|
|
12
|
+
properties: {
|
|
13
|
+
tableId: {
|
|
14
|
+
type: "string",
|
|
15
|
+
customType: "table",
|
|
16
|
+
title: "Table",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
required: ["tableId"],
|
|
20
|
+
},
|
|
21
|
+
outputs: {
|
|
22
|
+
properties: {
|
|
23
|
+
row: {
|
|
24
|
+
type: "object",
|
|
25
|
+
customType: "row",
|
|
26
|
+
description: "The row that was updated",
|
|
27
|
+
},
|
|
28
|
+
id: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "Row ID - can be used for updating",
|
|
31
|
+
},
|
|
32
|
+
revision: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Revision of row",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
required: ["row", "id"],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
type: "TRIGGER",
|
|
41
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.definition = {
|
|
3
|
+
name: "Webhook",
|
|
4
|
+
event: "web:trigger",
|
|
5
|
+
icon: "Send",
|
|
6
|
+
tagline: "Webhook endpoint is hit",
|
|
7
|
+
description: "Trigger an automation when a HTTP POST webhook is hit",
|
|
8
|
+
stepId: "WEBHOOK",
|
|
9
|
+
inputs: {},
|
|
10
|
+
schema: {
|
|
11
|
+
inputs: {
|
|
12
|
+
properties: {
|
|
13
|
+
schemaUrl: {
|
|
14
|
+
type: "string",
|
|
15
|
+
customType: "webhookUrl",
|
|
16
|
+
title: "Schema URL",
|
|
17
|
+
},
|
|
18
|
+
triggerUrl: {
|
|
19
|
+
type: "string",
|
|
20
|
+
customType: "webhookUrl",
|
|
21
|
+
title: "Trigger URL",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
required: ["schemaUrl", "triggerUrl"],
|
|
25
|
+
},
|
|
26
|
+
outputs: {
|
|
27
|
+
properties: {
|
|
28
|
+
body: {
|
|
29
|
+
type: "object",
|
|
30
|
+
description: "Body of the request which hit the webhook",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
required: ["body"],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
type: "TRIGGER",
|
|
37
|
+
};
|