@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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const sendgridEmail = require("./steps/sendgridEmail")
|
|
2
1
|
const sendSmtpEmail = require("./steps/sendSmtpEmail")
|
|
3
2
|
const createRow = require("./steps/createRow")
|
|
4
3
|
const updateRow = require("./steps/updateRow")
|
|
@@ -8,15 +7,15 @@ const bash = require("./steps/bash")
|
|
|
8
7
|
const executeQuery = require("./steps/executeQuery")
|
|
9
8
|
const outgoingWebhook = require("./steps/outgoingWebhook")
|
|
10
9
|
const serverLog = require("./steps/serverLog")
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const discord = require("./steps/discord")
|
|
11
|
+
const slack = require("./steps/slack")
|
|
12
|
+
const zapier = require("./steps/zapier")
|
|
13
|
+
const integromat = require("./steps/integromat")
|
|
14
|
+
let filter = require("./steps/filter")
|
|
15
|
+
let delay = require("./steps/delay")
|
|
16
|
+
let queryRow = require("./steps/queryRows")
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
SEND_EMAIL: sendgridEmail.run,
|
|
18
|
+
const ACTION_IMPLS = {
|
|
20
19
|
SEND_EMAIL_SMTP: sendSmtpEmail.run,
|
|
21
20
|
CREATE_ROW: createRow.run,
|
|
22
21
|
UPDATE_ROW: updateRow.run,
|
|
@@ -26,9 +25,16 @@ const BUILTIN_ACTIONS = {
|
|
|
26
25
|
EXECUTE_BASH: bash.run,
|
|
27
26
|
EXECUTE_QUERY: executeQuery.run,
|
|
28
27
|
SERVER_LOG: serverLog.run,
|
|
28
|
+
DELAY: delay.run,
|
|
29
|
+
FILTER: filter.run,
|
|
30
|
+
QUERY_ROWS: queryRow.run,
|
|
31
|
+
// these used to be lowercase step IDs, maintain for backwards compat
|
|
32
|
+
discord: discord.run,
|
|
33
|
+
slack: slack.run,
|
|
34
|
+
zapier: zapier.run,
|
|
35
|
+
integromat: integromat.run,
|
|
29
36
|
}
|
|
30
|
-
const
|
|
31
|
-
SEND_EMAIL: sendgridEmail.definition,
|
|
37
|
+
const ACTION_DEFINITIONS = {
|
|
32
38
|
SEND_EMAIL_SMTP: sendSmtpEmail.definition,
|
|
33
39
|
CREATE_ROW: createRow.definition,
|
|
34
40
|
UPDATE_ROW: updateRow.definition,
|
|
@@ -38,47 +44,21 @@ const BUILTIN_DEFINITIONS = {
|
|
|
38
44
|
EXECUTE_QUERY: executeQuery.definition,
|
|
39
45
|
EXECUTE_BASH: bash.definition,
|
|
40
46
|
SERVER_LOG: serverLog.definition,
|
|
47
|
+
DELAY: delay.definition,
|
|
48
|
+
FILTER: filter.definition,
|
|
49
|
+
QUERY_ROWS: queryRow.definition,
|
|
50
|
+
// these used to be lowercase step IDs, maintain for backwards compat
|
|
51
|
+
discord: discord.definition,
|
|
52
|
+
slack: slack.definition,
|
|
53
|
+
zapier: zapier.definition,
|
|
54
|
+
integromat: integromat.definition,
|
|
41
55
|
}
|
|
42
56
|
|
|
43
|
-
let MANIFEST = null
|
|
44
|
-
|
|
45
57
|
/* istanbul ignore next */
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/* istanbul ignore next */
|
|
51
|
-
module.exports.getAction = async function (actionName) {
|
|
52
|
-
if (BUILTIN_ACTIONS[actionName] != null) {
|
|
53
|
-
return BUILTIN_ACTIONS[actionName]
|
|
54
|
-
}
|
|
55
|
-
// worker pools means that a worker may not have manifest
|
|
56
|
-
if (env.isProd() && MANIFEST == null) {
|
|
57
|
-
MANIFEST = await module.exports.init()
|
|
58
|
-
}
|
|
59
|
-
// env setup to get async packages
|
|
60
|
-
if (!MANIFEST || !MANIFEST.packages || !MANIFEST.packages[actionName]) {
|
|
61
|
-
return null
|
|
62
|
-
}
|
|
63
|
-
const pkg = MANIFEST.packages[actionName]
|
|
64
|
-
const bundleName = buildBundleName(pkg.stepId, pkg.version)
|
|
65
|
-
return getExternalAutomationStep(pkg.stepId, pkg.version, bundleName)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
module.exports.init = async function () {
|
|
69
|
-
try {
|
|
70
|
-
MANIFEST = await automationInit()
|
|
71
|
-
module.exports.DEFINITIONS =
|
|
72
|
-
MANIFEST && MANIFEST.packages
|
|
73
|
-
? Object.assign(MANIFEST.packages, BUILTIN_DEFINITIONS)
|
|
74
|
-
: BUILTIN_DEFINITIONS
|
|
75
|
-
} catch (err) {
|
|
76
|
-
console.error(err)
|
|
77
|
-
Sentry.captureException(err)
|
|
58
|
+
exports.getAction = async function (actionName) {
|
|
59
|
+
if (ACTION_IMPLS[actionName] != null) {
|
|
60
|
+
return ACTION_IMPLS[actionName]
|
|
78
61
|
}
|
|
79
|
-
return MANIFEST
|
|
80
62
|
}
|
|
81
63
|
|
|
82
|
-
|
|
83
|
-
module.exports.DEFINITIONS = BUILTIN_DEFINITIONS
|
|
84
|
-
module.exports.BUILTIN_DEFINITIONS = BUILTIN_DEFINITIONS
|
|
64
|
+
exports.ACTION_DEFINITIONS = ACTION_DEFINITIONS
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
const { createBullBoard } = require("bull-board")
|
|
2
2
|
const { BullAdapter } = require("bull-board/bullAdapter")
|
|
3
|
-
const { getQueues } = require("./triggers")
|
|
4
3
|
const express = require("express")
|
|
4
|
+
const env = require("../environment")
|
|
5
|
+
const Queue = env.isTest()
|
|
6
|
+
? require("../utilities/queue/inMemoryQueue")
|
|
7
|
+
: require("bull")
|
|
8
|
+
const { JobQueues } = require("../constants")
|
|
9
|
+
const { utils } = require("@budibase/auth/redis")
|
|
10
|
+
const { opts, redisProtocolUrl } = utils.getRedisOptions()
|
|
11
|
+
|
|
12
|
+
const redisConfig = redisProtocolUrl || { redis: opts }
|
|
13
|
+
let automationQueue = new Queue(JobQueues.AUTOMATIONS, redisConfig)
|
|
5
14
|
|
|
6
15
|
exports.pathPrefix = "/bulladmin"
|
|
7
16
|
|
|
8
17
|
exports.init = () => {
|
|
9
18
|
const expressApp = express()
|
|
10
19
|
// Set up queues for bull board admin
|
|
11
|
-
const queues =
|
|
20
|
+
const queues = [automationQueue]
|
|
12
21
|
const adapters = []
|
|
13
22
|
for (let queue of queues) {
|
|
14
23
|
adapters.push(new BullAdapter(queue))
|
|
@@ -18,3 +27,5 @@ exports.init = () => {
|
|
|
18
27
|
expressApp.use(exports.pathPrefix, router)
|
|
19
28
|
return expressApp
|
|
20
29
|
}
|
|
30
|
+
|
|
31
|
+
exports.queue = automationQueue
|
package/src/automations/index.js
CHANGED
|
@@ -1,51 +1,17 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const env = require("../environment")
|
|
4
|
-
const workerFarm = require("worker-farm")
|
|
5
|
-
const singleThread = require("./thread")
|
|
6
|
-
const { getAPIKey, update, Properties } = require("../utilities/usageQuota")
|
|
7
|
-
|
|
8
|
-
let workers = workerFarm(require.resolve("./thread"))
|
|
9
|
-
|
|
10
|
-
function runWorker(job) {
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
workers(job, err => {
|
|
13
|
-
if (err) {
|
|
14
|
-
reject(err)
|
|
15
|
-
} else {
|
|
16
|
-
resolve()
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function updateQuota(automation) {
|
|
23
|
-
const appId = automation.appId
|
|
24
|
-
const apiObj = await getAPIKey(appId)
|
|
25
|
-
// this will fail, causing automation to escape if limits reached
|
|
26
|
-
await update(apiObj.apiKey, Properties.AUTOMATION, 1)
|
|
27
|
-
return apiObj.apiKey
|
|
28
|
-
}
|
|
1
|
+
const { processEvent } = require("./utils")
|
|
2
|
+
const { queue } = require("./bullboard")
|
|
29
3
|
|
|
30
4
|
/**
|
|
31
5
|
* This module is built purely to kick off the worker farm and manage the inputs/outputs
|
|
32
6
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (env.USE_QUOTAS) {
|
|
38
|
-
job.data.automation.apiKey = await updateQuota(job.data.automation)
|
|
39
|
-
}
|
|
40
|
-
if (env.isProd()) {
|
|
41
|
-
await runWorker(job)
|
|
42
|
-
} else {
|
|
43
|
-
await singleThread(job)
|
|
44
|
-
}
|
|
45
|
-
} catch (err) {
|
|
46
|
-
console.error(
|
|
47
|
-
`${job.data.automation.appId} automation ${job.data.automation._id} was unable to run - ${err}`
|
|
48
|
-
)
|
|
49
|
-
}
|
|
7
|
+
exports.init = function () {
|
|
8
|
+
// this promise will not complete
|
|
9
|
+
return queue.process(async job => {
|
|
10
|
+
await processEvent(job)
|
|
50
11
|
})
|
|
51
12
|
}
|
|
13
|
+
|
|
14
|
+
exports.getQueues = () => {
|
|
15
|
+
return [queue]
|
|
16
|
+
}
|
|
17
|
+
exports.queue = queue
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
const { execSync } = require("child_process")
|
|
2
2
|
const { processStringSync } = require("@budibase/string-templates")
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
exports.definition = {
|
|
5
5
|
name: "Bash Scripting",
|
|
6
6
|
tagline: "Execute a bash command",
|
|
7
|
-
icon: "
|
|
7
|
+
icon: "JourneyEvent",
|
|
8
8
|
description: "Run a bash script",
|
|
9
9
|
type: "ACTION",
|
|
10
|
+
internal: true,
|
|
10
11
|
stepId: "EXECUTE_BASH",
|
|
11
12
|
inputs: {},
|
|
12
13
|
schema: {
|
|
@@ -24,7 +25,11 @@ module.exports.definition = {
|
|
|
24
25
|
properties: {
|
|
25
26
|
stdout: {
|
|
26
27
|
type: "string",
|
|
27
|
-
description: "Standard output of your bash command or script
|
|
28
|
+
description: "Standard output of your bash command or script",
|
|
29
|
+
},
|
|
30
|
+
success: {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
description: "Whether the command was successful",
|
|
28
33
|
},
|
|
29
34
|
},
|
|
30
35
|
},
|
|
@@ -32,7 +37,7 @@ module.exports.definition = {
|
|
|
32
37
|
},
|
|
33
38
|
}
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
exports.run = async function ({ inputs, context }) {
|
|
36
41
|
if (inputs.code == null) {
|
|
37
42
|
return {
|
|
38
43
|
stdout: "Budibase bash automation failed: Invalid inputs",
|
|
@@ -42,18 +47,20 @@ module.exports.run = async function ({ inputs, context }) {
|
|
|
42
47
|
try {
|
|
43
48
|
const command = processStringSync(inputs.code, context)
|
|
44
49
|
|
|
45
|
-
let stdout
|
|
50
|
+
let stdout,
|
|
51
|
+
success = true
|
|
46
52
|
try {
|
|
47
53
|
stdout = execSync(command, { timeout: 500 }).toString()
|
|
48
54
|
} catch (err) {
|
|
49
55
|
stdout = err.message
|
|
56
|
+
success = false
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
return {
|
|
53
60
|
stdout,
|
|
61
|
+
success,
|
|
54
62
|
}
|
|
55
63
|
} catch (err) {
|
|
56
|
-
console.error(err)
|
|
57
64
|
return {
|
|
58
65
|
success: false,
|
|
59
66
|
response: err,
|
|
@@ -3,12 +3,13 @@ const automationUtils = require("../automationUtils")
|
|
|
3
3
|
const env = require("../../environment")
|
|
4
4
|
const usage = require("../../utilities/usageQuota")
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
exports.definition = {
|
|
7
7
|
name: "Create Row",
|
|
8
8
|
tagline: "Create a {{inputs.enriched.table.name}} row",
|
|
9
|
-
icon: "
|
|
9
|
+
icon: "TableRowAddBottom",
|
|
10
10
|
description: "Add a row to your database",
|
|
11
11
|
type: "ACTION",
|
|
12
|
+
internal: true,
|
|
12
13
|
stepId: "CREATE_ROW",
|
|
13
14
|
inputs: {},
|
|
14
15
|
schema: {
|
|
@@ -42,7 +43,7 @@ module.exports.definition = {
|
|
|
42
43
|
},
|
|
43
44
|
success: {
|
|
44
45
|
type: "boolean",
|
|
45
|
-
description: "Whether the
|
|
46
|
+
description: "Whether the row creation was successful",
|
|
46
47
|
},
|
|
47
48
|
id: {
|
|
48
49
|
type: "string",
|
|
@@ -58,7 +59,7 @@ module.exports.definition = {
|
|
|
58
59
|
},
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
exports.run = async function ({ inputs, appId, apiKey, emitter }) {
|
|
62
63
|
if (inputs.row == null || inputs.row.tableId == null) {
|
|
63
64
|
return {
|
|
64
65
|
success: false,
|
|
@@ -97,7 +98,6 @@ module.exports.run = async function ({ inputs, appId, apiKey, emitter }) {
|
|
|
97
98
|
success: ctx.status === 200,
|
|
98
99
|
}
|
|
99
100
|
} catch (err) {
|
|
100
|
-
console.error(err)
|
|
101
101
|
return {
|
|
102
102
|
success: false,
|
|
103
103
|
response: err,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
let { wait } = require("../../utilities")
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
exports.definition = {
|
|
4
4
|
name: "Delay",
|
|
5
|
-
icon: "
|
|
5
|
+
icon: "Clock",
|
|
6
6
|
tagline: "Delay for {{inputs.time}} milliseconds",
|
|
7
7
|
description: "Delay the automation until an amount of time has passed",
|
|
8
8
|
stepId: "DELAY",
|
|
9
|
+
internal: true,
|
|
9
10
|
inputs: {},
|
|
10
11
|
schema: {
|
|
11
12
|
inputs: {
|
|
@@ -17,10 +18,22 @@ module.exports.definition = {
|
|
|
17
18
|
},
|
|
18
19
|
required: ["time"],
|
|
19
20
|
},
|
|
21
|
+
outputs: {
|
|
22
|
+
properties: {
|
|
23
|
+
success: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
description: "Whether the delay was successful",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ["success"],
|
|
29
|
+
},
|
|
20
30
|
},
|
|
21
31
|
type: "LOGIC",
|
|
22
32
|
}
|
|
23
33
|
|
|
24
|
-
|
|
34
|
+
exports.run = async function delay({ inputs }) {
|
|
25
35
|
await wait(inputs.time)
|
|
36
|
+
return {
|
|
37
|
+
success: true,
|
|
38
|
+
}
|
|
26
39
|
}
|
|
@@ -2,13 +2,14 @@ const rowController = require("../../api/controllers/row")
|
|
|
2
2
|
const env = require("../../environment")
|
|
3
3
|
const usage = require("../../utilities/usageQuota")
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
exports.definition = {
|
|
6
6
|
description: "Delete a row from your database",
|
|
7
|
-
icon: "
|
|
7
|
+
icon: "TableRowRemoveCenter",
|
|
8
8
|
name: "Delete Row",
|
|
9
9
|
tagline: "Delete a {{inputs.enriched.table.name}} row",
|
|
10
10
|
type: "ACTION",
|
|
11
11
|
stepId: "DELETE_ROW",
|
|
12
|
+
internal: true,
|
|
12
13
|
inputs: {},
|
|
13
14
|
schema: {
|
|
14
15
|
inputs: {
|
|
@@ -42,7 +43,7 @@ module.exports.definition = {
|
|
|
42
43
|
},
|
|
43
44
|
success: {
|
|
44
45
|
type: "boolean",
|
|
45
|
-
description: "Whether the
|
|
46
|
+
description: "Whether the deletion was successful",
|
|
46
47
|
},
|
|
47
48
|
},
|
|
48
49
|
required: ["row", "success"],
|
|
@@ -50,7 +51,7 @@ module.exports.definition = {
|
|
|
50
51
|
},
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
exports.run = async function ({ inputs, appId, apiKey, emitter }) {
|
|
54
55
|
if (inputs.id == null || inputs.revision == null) {
|
|
55
56
|
return {
|
|
56
57
|
success: false,
|
|
@@ -84,7 +85,6 @@ module.exports.run = async function ({ inputs, appId, apiKey, emitter }) {
|
|
|
84
85
|
success: ctx.status === 200,
|
|
85
86
|
}
|
|
86
87
|
} catch (err) {
|
|
87
|
-
console.error(err)
|
|
88
88
|
return {
|
|
89
89
|
success: false,
|
|
90
90
|
response: err,
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const fetch = require("node-fetch")
|
|
2
|
+
const { getFetchResponse } = require("./utils")
|
|
3
|
+
|
|
4
|
+
const DEFAULT_USERNAME = "Budibase Automate"
|
|
5
|
+
const DEFAULT_AVATAR_URL = "https://i.imgur.com/a1cmTKM.png"
|
|
6
|
+
|
|
7
|
+
exports.definition = {
|
|
8
|
+
name: "Discord Message",
|
|
9
|
+
tagline: "Send a message to a Discord server",
|
|
10
|
+
description: "Send a message to a Discord server",
|
|
11
|
+
icon: "ri-discord-line",
|
|
12
|
+
stepId: "discord",
|
|
13
|
+
type: "ACTION",
|
|
14
|
+
internal: false,
|
|
15
|
+
inputs: {},
|
|
16
|
+
schema: {
|
|
17
|
+
inputs: {
|
|
18
|
+
properties: {
|
|
19
|
+
url: {
|
|
20
|
+
type: "string",
|
|
21
|
+
title: "Discord Webhook URL",
|
|
22
|
+
},
|
|
23
|
+
username: {
|
|
24
|
+
type: "string",
|
|
25
|
+
title: "Bot Name",
|
|
26
|
+
},
|
|
27
|
+
avatar_url: {
|
|
28
|
+
type: "string",
|
|
29
|
+
title: "Bot Avatar URL",
|
|
30
|
+
},
|
|
31
|
+
content: {
|
|
32
|
+
type: "string",
|
|
33
|
+
title: "Message",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
required: ["url", "content"],
|
|
37
|
+
},
|
|
38
|
+
outputs: {
|
|
39
|
+
properties: {
|
|
40
|
+
httpStatus: {
|
|
41
|
+
type: "number",
|
|
42
|
+
description: "The HTTP status code of the request",
|
|
43
|
+
},
|
|
44
|
+
response: {
|
|
45
|
+
type: "string",
|
|
46
|
+
description: "The response from the Discord Webhook",
|
|
47
|
+
},
|
|
48
|
+
success: {
|
|
49
|
+
type: "boolean",
|
|
50
|
+
description: "Whether the message sent successfully",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
exports.run = async function ({ inputs }) {
|
|
58
|
+
let { url, username, avatar_url, content } = inputs
|
|
59
|
+
if (!username) {
|
|
60
|
+
username = DEFAULT_USERNAME
|
|
61
|
+
}
|
|
62
|
+
if (!avatar_url) {
|
|
63
|
+
avatar_url = DEFAULT_AVATAR_URL
|
|
64
|
+
}
|
|
65
|
+
const response = await fetch(url, {
|
|
66
|
+
method: "post",
|
|
67
|
+
body: JSON.stringify({
|
|
68
|
+
username,
|
|
69
|
+
avatar_url,
|
|
70
|
+
content,
|
|
71
|
+
}),
|
|
72
|
+
headers: {
|
|
73
|
+
"Content-Type": "application/json",
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const { status, message } = await getFetchResponse(response)
|
|
78
|
+
return {
|
|
79
|
+
httpStatus: status,
|
|
80
|
+
success: status === 200,
|
|
81
|
+
response: message,
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
const queryController = require("../../api/controllers/query")
|
|
2
|
+
const { buildCtx } = require("./utils")
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
exports.definition = {
|
|
4
5
|
name: "External Data Connector",
|
|
5
6
|
tagline: "Execute Data Connector",
|
|
6
|
-
icon: "
|
|
7
|
+
icon: "Data",
|
|
7
8
|
description: "Execute a query in an external data connector",
|
|
8
9
|
type: "ACTION",
|
|
9
10
|
stepId: "EXECUTE_QUERY",
|
|
11
|
+
internal: true,
|
|
10
12
|
inputs: {},
|
|
11
13
|
schema: {
|
|
12
14
|
inputs: {
|
|
@@ -42,7 +44,7 @@ module.exports.definition = {
|
|
|
42
44
|
},
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
exports.run = async function ({ inputs, appId, emitter }) {
|
|
46
48
|
if (inputs.query == null) {
|
|
47
49
|
return {
|
|
48
50
|
success: false,
|
|
@@ -54,28 +56,22 @@ module.exports.run = async function ({ inputs, appId, emitter }) {
|
|
|
54
56
|
|
|
55
57
|
const { queryId, ...rest } = inputs.query
|
|
56
58
|
|
|
57
|
-
const ctx = {
|
|
59
|
+
const ctx = buildCtx(appId, emitter, {
|
|
60
|
+
body: {
|
|
61
|
+
parameters: rest,
|
|
62
|
+
},
|
|
58
63
|
params: {
|
|
59
64
|
queryId,
|
|
60
65
|
},
|
|
61
|
-
|
|
62
|
-
body: {
|
|
63
|
-
parameters: rest,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
appId,
|
|
67
|
-
eventEmitter: emitter,
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
await queryController.execute(ctx)
|
|
66
|
+
})
|
|
71
67
|
|
|
72
68
|
try {
|
|
69
|
+
await queryController.execute(ctx)
|
|
73
70
|
return {
|
|
74
71
|
response: ctx.body,
|
|
75
|
-
success:
|
|
72
|
+
success: true,
|
|
76
73
|
}
|
|
77
74
|
} catch (err) {
|
|
78
|
-
console.error(err)
|
|
79
75
|
return {
|
|
80
76
|
success: false,
|
|
81
77
|
response: err,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
const scriptController = require("../../api/controllers/script")
|
|
2
|
+
const { buildCtx } = require("./utils")
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
exports.definition = {
|
|
4
5
|
name: "JS Scripting",
|
|
5
6
|
tagline: "Execute JavaScript Code",
|
|
6
|
-
icon: "
|
|
7
|
+
icon: "Code",
|
|
7
8
|
description: "Run a piece of JavaScript code in your automation",
|
|
8
9
|
type: "ACTION",
|
|
10
|
+
internal: true,
|
|
9
11
|
stepId: "EXECUTE_SCRIPT",
|
|
10
12
|
inputs: {},
|
|
11
13
|
schema: {
|
|
@@ -23,8 +25,7 @@ module.exports.definition = {
|
|
|
23
25
|
properties: {
|
|
24
26
|
value: {
|
|
25
27
|
type: "string",
|
|
26
|
-
description:
|
|
27
|
-
"The result of the last statement of the executed script.",
|
|
28
|
+
description: "The result of the return statement",
|
|
28
29
|
},
|
|
29
30
|
success: {
|
|
30
31
|
type: "boolean",
|
|
@@ -36,7 +37,7 @@ module.exports.definition = {
|
|
|
36
37
|
},
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
exports.run = async function ({ inputs, appId, context, emitter }) {
|
|
40
41
|
if (inputs.code == null) {
|
|
41
42
|
return {
|
|
42
43
|
success: false,
|
|
@@ -46,25 +47,20 @@ module.exports.run = async function ({ inputs, appId, context, emitter }) {
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
const ctx = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
context,
|
|
54
|
-
},
|
|
50
|
+
const ctx = buildCtx(appId, emitter, {
|
|
51
|
+
body: {
|
|
52
|
+
script: inputs.code,
|
|
53
|
+
context,
|
|
55
54
|
},
|
|
56
|
-
|
|
57
|
-
eventEmitter: emitter,
|
|
58
|
-
}
|
|
55
|
+
})
|
|
59
56
|
|
|
60
57
|
try {
|
|
61
58
|
await scriptController.execute(ctx)
|
|
62
59
|
return {
|
|
63
|
-
success:
|
|
60
|
+
success: true,
|
|
64
61
|
value: ctx.body,
|
|
65
62
|
}
|
|
66
63
|
} catch (err) {
|
|
67
|
-
console.error(err)
|
|
68
64
|
return {
|
|
69
65
|
success: false,
|
|
70
66
|
response: err,
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
const
|
|
1
|
+
const FilterConditions = {
|
|
2
2
|
EQUAL: "EQUAL",
|
|
3
3
|
NOT_EQUAL: "NOT_EQUAL",
|
|
4
4
|
GREATER_THAN: "GREATER_THAN",
|
|
5
5
|
LESS_THAN: "LESS_THAN",
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
8
|
+
const PrettyFilterConditions = {
|
|
9
|
+
[FilterConditions.EQUAL]: "Equals",
|
|
10
|
+
[FilterConditions.NOT_EQUAL]: "Not equals",
|
|
11
|
+
[FilterConditions.GREATER_THAN]: "Greater than",
|
|
12
|
+
[FilterConditions.LESS_THAN]: "Less than",
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
exports.FilterConditions = FilterConditions
|
|
16
|
+
exports.PrettyFilterConditions = PrettyFilterConditions
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
exports.definition = {
|
|
19
19
|
name: "Filter",
|
|
20
20
|
tagline: "{{inputs.field}} {{inputs.condition}} {{inputs.value}}",
|
|
21
|
-
icon: "
|
|
21
|
+
icon: "Branch2",
|
|
22
22
|
description: "Filter any automations which do not meet certain conditions",
|
|
23
23
|
type: "LOGIC",
|
|
24
|
+
internal: true,
|
|
24
25
|
stepId: "FILTER",
|
|
25
26
|
inputs: {
|
|
26
|
-
condition:
|
|
27
|
+
condition: FilterConditions.EQUALS,
|
|
27
28
|
},
|
|
28
29
|
schema: {
|
|
29
30
|
inputs: {
|
|
@@ -35,8 +36,8 @@ module.exports.definition = {
|
|
|
35
36
|
condition: {
|
|
36
37
|
type: "string",
|
|
37
38
|
title: "Condition",
|
|
38
|
-
enum: Object.values(
|
|
39
|
-
pretty: Object.values(
|
|
39
|
+
enum: Object.values(FilterConditions),
|
|
40
|
+
pretty: Object.values(PrettyFilterConditions),
|
|
40
41
|
},
|
|
41
42
|
value: {
|
|
42
43
|
type: "string",
|
|
@@ -57,7 +58,7 @@ module.exports.definition = {
|
|
|
57
58
|
},
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
exports.run = async function filter({ inputs }) {
|
|
61
62
|
let { field, condition, value } = inputs
|
|
62
63
|
// coerce types so that we can use them
|
|
63
64
|
if (!isNaN(value) && !isNaN(field)) {
|
|
@@ -70,16 +71,16 @@ module.exports.run = async function filter({ inputs }) {
|
|
|
70
71
|
let success = false
|
|
71
72
|
if (typeof field !== "object" && typeof value !== "object") {
|
|
72
73
|
switch (condition) {
|
|
73
|
-
case
|
|
74
|
+
case FilterConditions.EQUAL:
|
|
74
75
|
success = field === value
|
|
75
76
|
break
|
|
76
|
-
case
|
|
77
|
+
case FilterConditions.NOT_EQUAL:
|
|
77
78
|
success = field !== value
|
|
78
79
|
break
|
|
79
|
-
case
|
|
80
|
+
case FilterConditions.GREATER_THAN:
|
|
80
81
|
success = field > value
|
|
81
82
|
break
|
|
82
|
-
case
|
|
83
|
+
case FilterConditions.LESS_THAN:
|
|
83
84
|
success = field < value
|
|
84
85
|
break
|
|
85
86
|
}
|