@budibase/server 0.9.125-alpha.4 → 0.9.125-alpha.8
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.cf133375.js} +2 -2
- package/builder/assets/{vendor.4af73c18.js → vendor.d8e1ee7b.js} +1 -1
- package/builder/index.html +2 -2
- 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/integrations/mysql.js +1 -1
- package/dist/middleware/appInfo.js +17 -0
- package/dist/middleware/usageQuota.js +1 -1
- package/dist/package.json +7 -6
- 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 +8 -7
- package/scripts/selfhost.js +8 -0
- 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/integrations/mysql.ts +1 -1
- 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
|
@@ -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
|
+
const DEFAULT_USERNAME = "Budibase Automate";
|
|
14
|
+
const DEFAULT_AVATAR_URL = "https://i.imgur.com/a1cmTKM.png";
|
|
15
|
+
exports.definition = {
|
|
16
|
+
name: "Discord Message",
|
|
17
|
+
tagline: "Send a message to a Discord server",
|
|
18
|
+
description: "Send a message to a Discord server",
|
|
19
|
+
icon: "ri-discord-line",
|
|
20
|
+
stepId: "discord",
|
|
21
|
+
type: "ACTION",
|
|
22
|
+
internal: false,
|
|
23
|
+
inputs: {},
|
|
24
|
+
schema: {
|
|
25
|
+
inputs: {
|
|
26
|
+
properties: {
|
|
27
|
+
url: {
|
|
28
|
+
type: "string",
|
|
29
|
+
title: "Discord Webhook URL",
|
|
30
|
+
},
|
|
31
|
+
username: {
|
|
32
|
+
type: "string",
|
|
33
|
+
title: "Bot Name",
|
|
34
|
+
},
|
|
35
|
+
avatar_url: {
|
|
36
|
+
type: "string",
|
|
37
|
+
title: "Bot Avatar URL",
|
|
38
|
+
},
|
|
39
|
+
content: {
|
|
40
|
+
type: "string",
|
|
41
|
+
title: "Message",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: ["url", "content"],
|
|
45
|
+
},
|
|
46
|
+
outputs: {
|
|
47
|
+
properties: {
|
|
48
|
+
httpStatus: {
|
|
49
|
+
type: "number",
|
|
50
|
+
description: "The HTTP status code of the request",
|
|
51
|
+
},
|
|
52
|
+
response: {
|
|
53
|
+
type: "string",
|
|
54
|
+
description: "The response from the Discord Webhook",
|
|
55
|
+
},
|
|
56
|
+
success: {
|
|
57
|
+
type: "boolean",
|
|
58
|
+
description: "Whether the message sent successfully",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
exports.run = function ({ inputs }) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
let { url, username, avatar_url, content } = inputs;
|
|
67
|
+
if (!username) {
|
|
68
|
+
username = DEFAULT_USERNAME;
|
|
69
|
+
}
|
|
70
|
+
if (!avatar_url) {
|
|
71
|
+
avatar_url = DEFAULT_AVATAR_URL;
|
|
72
|
+
}
|
|
73
|
+
const response = yield fetch(url, {
|
|
74
|
+
method: "post",
|
|
75
|
+
body: JSON.stringify({
|
|
76
|
+
username,
|
|
77
|
+
avatar_url,
|
|
78
|
+
content,
|
|
79
|
+
}),
|
|
80
|
+
headers: {
|
|
81
|
+
"Content-Type": "application/json",
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
const { status, message } = yield getFetchResponse(response);
|
|
85
|
+
return {
|
|
86
|
+
httpStatus: status,
|
|
87
|
+
success: status === 200,
|
|
88
|
+
response: message,
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
};
|
|
@@ -20,13 +20,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
const queryController = require("../../api/controllers/query");
|
|
23
|
-
|
|
23
|
+
const { buildCtx } = require("./utils");
|
|
24
|
+
exports.definition = {
|
|
24
25
|
name: "External Data Connector",
|
|
25
26
|
tagline: "Execute Data Connector",
|
|
26
27
|
icon: "ri-database-2-line",
|
|
27
28
|
description: "Execute a query in an external data connector",
|
|
28
29
|
type: "ACTION",
|
|
29
30
|
stepId: "EXECUTE_QUERY",
|
|
31
|
+
internal: true,
|
|
30
32
|
inputs: {},
|
|
31
33
|
schema: {
|
|
32
34
|
inputs: {
|
|
@@ -61,7 +63,7 @@ module.exports.definition = {
|
|
|
61
63
|
required: ["response", "success"],
|
|
62
64
|
},
|
|
63
65
|
};
|
|
64
|
-
|
|
66
|
+
exports.run = function ({ inputs, appId, emitter }) {
|
|
65
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
68
|
if (inputs.query == null) {
|
|
67
69
|
return {
|
|
@@ -72,27 +74,22 @@ module.exports.run = function ({ inputs, appId, emitter }) {
|
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
76
|
const _a = inputs.query, { queryId } = _a, rest = __rest(_a, ["queryId"]);
|
|
75
|
-
const ctx = {
|
|
77
|
+
const ctx = buildCtx(appId, emitter, {
|
|
78
|
+
body: {
|
|
79
|
+
parameters: rest,
|
|
80
|
+
},
|
|
76
81
|
params: {
|
|
77
82
|
queryId,
|
|
78
83
|
},
|
|
79
|
-
|
|
80
|
-
body: {
|
|
81
|
-
parameters: rest,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
appId,
|
|
85
|
-
eventEmitter: emitter,
|
|
86
|
-
};
|
|
87
|
-
yield queryController.execute(ctx);
|
|
84
|
+
});
|
|
88
85
|
try {
|
|
86
|
+
yield queryController.execute(ctx);
|
|
89
87
|
return {
|
|
90
88
|
response: ctx.body,
|
|
91
|
-
success:
|
|
89
|
+
success: true,
|
|
92
90
|
};
|
|
93
91
|
}
|
|
94
92
|
catch (err) {
|
|
95
|
-
console.error(err);
|
|
96
93
|
return {
|
|
97
94
|
success: false,
|
|
98
95
|
response: err,
|
|
@@ -9,12 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const scriptController = require("../../api/controllers/script");
|
|
12
|
-
|
|
12
|
+
const { buildCtx } = require("./utils");
|
|
13
|
+
exports.definition = {
|
|
13
14
|
name: "JS Scripting",
|
|
14
15
|
tagline: "Execute JavaScript Code",
|
|
15
16
|
icon: "ri-terminal-box-line",
|
|
16
17
|
description: "Run a piece of JavaScript code in your automation",
|
|
17
18
|
type: "ACTION",
|
|
19
|
+
internal: true,
|
|
18
20
|
stepId: "EXECUTE_SCRIPT",
|
|
19
21
|
inputs: {},
|
|
20
22
|
schema: {
|
|
@@ -32,7 +34,7 @@ module.exports.definition = {
|
|
|
32
34
|
properties: {
|
|
33
35
|
value: {
|
|
34
36
|
type: "string",
|
|
35
|
-
description: "The result of the
|
|
37
|
+
description: "The result of the return statement",
|
|
36
38
|
},
|
|
37
39
|
success: {
|
|
38
40
|
type: "boolean",
|
|
@@ -43,7 +45,7 @@ module.exports.definition = {
|
|
|
43
45
|
required: ["success"],
|
|
44
46
|
},
|
|
45
47
|
};
|
|
46
|
-
|
|
48
|
+
exports.run = function ({ inputs, appId, context, emitter }) {
|
|
47
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
50
|
if (inputs.code == null) {
|
|
49
51
|
return {
|
|
@@ -53,25 +55,20 @@ module.exports.run = function ({ inputs, appId, context, emitter }) {
|
|
|
53
55
|
},
|
|
54
56
|
};
|
|
55
57
|
}
|
|
56
|
-
const ctx = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
context,
|
|
61
|
-
},
|
|
58
|
+
const ctx = buildCtx(appId, emitter, {
|
|
59
|
+
body: {
|
|
60
|
+
script: inputs.code,
|
|
61
|
+
context,
|
|
62
62
|
},
|
|
63
|
-
|
|
64
|
-
eventEmitter: emitter,
|
|
65
|
-
};
|
|
63
|
+
});
|
|
66
64
|
try {
|
|
67
65
|
yield scriptController.execute(ctx);
|
|
68
66
|
return {
|
|
69
|
-
success:
|
|
67
|
+
success: true,
|
|
70
68
|
value: ctx.body,
|
|
71
69
|
};
|
|
72
70
|
}
|
|
73
71
|
catch (err) {
|
|
74
|
-
console.error(err);
|
|
75
72
|
return {
|
|
76
73
|
success: false,
|
|
77
74
|
response: err,
|
|
@@ -8,29 +8,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const
|
|
11
|
+
const FilterConditions = {
|
|
12
12
|
EQUAL: "EQUAL",
|
|
13
13
|
NOT_EQUAL: "NOT_EQUAL",
|
|
14
14
|
GREATER_THAN: "GREATER_THAN",
|
|
15
15
|
LESS_THAN: "LESS_THAN",
|
|
16
16
|
};
|
|
17
|
-
const
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
17
|
+
const PrettyFilterConditions = {
|
|
18
|
+
[FilterConditions.EQUAL]: "Equals",
|
|
19
|
+
[FilterConditions.NOT_EQUAL]: "Not equals",
|
|
20
|
+
[FilterConditions.GREATER_THAN]: "Greater than",
|
|
21
|
+
[FilterConditions.LESS_THAN]: "Less than",
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
exports.FilterConditions = FilterConditions;
|
|
24
|
+
exports.PrettyFilterConditions = PrettyFilterConditions;
|
|
25
|
+
exports.definition = {
|
|
26
26
|
name: "Filter",
|
|
27
27
|
tagline: "{{inputs.field}} {{inputs.condition}} {{inputs.value}}",
|
|
28
28
|
icon: "ri-git-branch-line",
|
|
29
29
|
description: "Filter any automations which do not meet certain conditions",
|
|
30
30
|
type: "LOGIC",
|
|
31
|
+
internal: true,
|
|
31
32
|
stepId: "FILTER",
|
|
32
33
|
inputs: {
|
|
33
|
-
condition:
|
|
34
|
+
condition: FilterConditions.EQUALS,
|
|
34
35
|
},
|
|
35
36
|
schema: {
|
|
36
37
|
inputs: {
|
|
@@ -42,8 +43,8 @@ module.exports.definition = {
|
|
|
42
43
|
condition: {
|
|
43
44
|
type: "string",
|
|
44
45
|
title: "Condition",
|
|
45
|
-
enum: Object.values(
|
|
46
|
-
pretty: Object.values(
|
|
46
|
+
enum: Object.values(FilterConditions),
|
|
47
|
+
pretty: Object.values(PrettyFilterConditions),
|
|
47
48
|
},
|
|
48
49
|
value: {
|
|
49
50
|
type: "string",
|
|
@@ -63,7 +64,7 @@ module.exports.definition = {
|
|
|
63
64
|
},
|
|
64
65
|
},
|
|
65
66
|
};
|
|
66
|
-
|
|
67
|
+
exports.run = function filter({ inputs }) {
|
|
67
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
69
|
let { field, condition, value } = inputs;
|
|
69
70
|
// coerce types so that we can use them
|
|
@@ -78,16 +79,16 @@ module.exports.run = function filter({ inputs }) {
|
|
|
78
79
|
let success = false;
|
|
79
80
|
if (typeof field !== "object" && typeof value !== "object") {
|
|
80
81
|
switch (condition) {
|
|
81
|
-
case
|
|
82
|
+
case FilterConditions.EQUAL:
|
|
82
83
|
success = field === value;
|
|
83
84
|
break;
|
|
84
|
-
case
|
|
85
|
+
case FilterConditions.NOT_EQUAL:
|
|
85
86
|
success = field !== value;
|
|
86
87
|
break;
|
|
87
|
-
case
|
|
88
|
+
case FilterConditions.GREATER_THAN:
|
|
88
89
|
success = field > value;
|
|
89
90
|
break;
|
|
90
|
-
case
|
|
91
|
+
case FilterConditions.LESS_THAN:
|
|
91
92
|
success = field < value;
|
|
92
93
|
break;
|
|
93
94
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
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: "Integromat Integration",
|
|
15
|
+
tagline: "Trigger an Integromat scenario",
|
|
16
|
+
description: "Performs a webhook call to Integromat and gets the response (if configured)",
|
|
17
|
+
icon: "ri-shut-down-line",
|
|
18
|
+
stepId: "integromat",
|
|
19
|
+
type: "ACTION",
|
|
20
|
+
internal: false,
|
|
21
|
+
inputs: {},
|
|
22
|
+
schema: {
|
|
23
|
+
inputs: {
|
|
24
|
+
properties: {
|
|
25
|
+
url: {
|
|
26
|
+
type: "string",
|
|
27
|
+
title: "Webhook URL",
|
|
28
|
+
},
|
|
29
|
+
value1: {
|
|
30
|
+
type: "string",
|
|
31
|
+
title: "Input Value 1",
|
|
32
|
+
},
|
|
33
|
+
value2: {
|
|
34
|
+
type: "string",
|
|
35
|
+
title: "Input Value 2",
|
|
36
|
+
},
|
|
37
|
+
value3: {
|
|
38
|
+
type: "string",
|
|
39
|
+
title: "Input Value 3",
|
|
40
|
+
},
|
|
41
|
+
value4: {
|
|
42
|
+
type: "string",
|
|
43
|
+
title: "Input Value 4",
|
|
44
|
+
},
|
|
45
|
+
value5: {
|
|
46
|
+
type: "string",
|
|
47
|
+
title: "Input Value 5",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
required: ["url", "value1", "value2", "value3", "value4", "value5"],
|
|
51
|
+
},
|
|
52
|
+
outputs: {
|
|
53
|
+
properties: {
|
|
54
|
+
success: {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
description: "Whether call was successful",
|
|
57
|
+
},
|
|
58
|
+
httpStatus: {
|
|
59
|
+
type: "number",
|
|
60
|
+
description: "The HTTP status code returned",
|
|
61
|
+
},
|
|
62
|
+
response: {
|
|
63
|
+
type: "object",
|
|
64
|
+
description: "The webhook response - this can have properties",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
required: ["success", "response"],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
exports.run = function ({ inputs }) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const { url, value1, value2, value3, value4, value5 } = inputs;
|
|
74
|
+
const response = yield fetch(url, {
|
|
75
|
+
method: "post",
|
|
76
|
+
body: JSON.stringify({
|
|
77
|
+
value1,
|
|
78
|
+
value2,
|
|
79
|
+
value3,
|
|
80
|
+
value4,
|
|
81
|
+
value5,
|
|
82
|
+
}),
|
|
83
|
+
headers: {
|
|
84
|
+
"Content-Type": "application/json",
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
const { status, message } = yield getFetchResponse(response);
|
|
88
|
+
return {
|
|
89
|
+
httpStatus: status,
|
|
90
|
+
success: status === 200,
|
|
91
|
+
response: message,
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
};
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const fetch = require("node-fetch");
|
|
12
|
+
const { getFetchResponse } = require("./utils");
|
|
12
13
|
const RequestType = {
|
|
13
14
|
POST: "POST",
|
|
14
15
|
GET: "GET",
|
|
@@ -22,12 +23,13 @@ const BODY_REQUESTS = [RequestType.POST, RequestType.PUT, RequestType.PATCH];
|
|
|
22
23
|
* is complex and maybe better to be opinionated here.
|
|
23
24
|
* GET/DELETE requests cannot handle body elements so they will not be sent if configured.
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
+
exports.definition = {
|
|
26
27
|
name: "Outgoing webhook",
|
|
27
28
|
tagline: "Send a {{inputs.requestMethod}} request",
|
|
28
29
|
icon: "ri-send-plane-line",
|
|
29
30
|
description: "Send a request of specified method to a URL",
|
|
30
31
|
type: "ACTION",
|
|
32
|
+
internal: true,
|
|
31
33
|
stepId: "OUTGOING_WEBHOOK",
|
|
32
34
|
inputs: {
|
|
33
35
|
requestMethod: "POST",
|
|
@@ -66,6 +68,10 @@ module.exports.definition = {
|
|
|
66
68
|
type: "object",
|
|
67
69
|
description: "The response from the webhook",
|
|
68
70
|
},
|
|
71
|
+
httpStatus: {
|
|
72
|
+
type: "number",
|
|
73
|
+
description: "The HTTP status code returned",
|
|
74
|
+
},
|
|
69
75
|
success: {
|
|
70
76
|
type: "boolean",
|
|
71
77
|
description: "Whether the action was successful",
|
|
@@ -75,7 +81,7 @@ module.exports.definition = {
|
|
|
75
81
|
},
|
|
76
82
|
},
|
|
77
83
|
};
|
|
78
|
-
|
|
84
|
+
exports.run = function ({ inputs }) {
|
|
79
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
86
|
let { requestMethod, url, requestBody, headers } = inputs;
|
|
81
87
|
if (!url.startsWith("http")) {
|
|
@@ -110,21 +116,11 @@ module.exports.run = function ({ inputs }) {
|
|
|
110
116
|
JSON.parse(request.body);
|
|
111
117
|
}
|
|
112
118
|
const response = yield fetch(url, request);
|
|
113
|
-
const
|
|
114
|
-
const success = response.status === 200;
|
|
115
|
-
let resp;
|
|
116
|
-
if (!success) {
|
|
117
|
-
resp = response.statusText;
|
|
118
|
-
}
|
|
119
|
-
else if (contentType && contentType.indexOf("application/json") !== -1) {
|
|
120
|
-
resp = yield response.json();
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
resp = yield response.text();
|
|
124
|
-
}
|
|
119
|
+
const { status, message } = yield getFetchResponse(response);
|
|
125
120
|
return {
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
httpStatus: status,
|
|
122
|
+
response: message,
|
|
123
|
+
success: status === 200,
|
|
128
124
|
};
|
|
129
125
|
}
|
|
130
126
|
catch (err) {
|