@budibase/server 0.9.167-alpha.4 → 0.9.167-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.60f832ce.js → index.553837db.js} +34 -34
- package/builder/assets/{index.18ad7651.css → index.c4a1fb7f.css} +1 -1
- package/builder/assets/{vendor.60887453.js → vendor.278a305c.js} +1 -1
- package/builder/index.html +3 -3
- package/coverage/clover.xml +273 -245
- package/coverage/coverage-final.json +9 -8
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/hosting.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +26 -26
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query.js.html +129 -24
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +12 -57
- package/coverage/lcov-report/api/controllers/table/index.html +10 -10
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/utils.js.html +8 -38
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- 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/utils.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 +1 -1
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/application.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/hosting.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +9 -3
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/row.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +31 -10
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +19 -19
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/thread.js.html +54 -12
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/automations/utils.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/client.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +12 -12
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +9 -9
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +1 -1
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +37 -37
- 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/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/authorized.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +22 -7
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +143 -0
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- 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 +450 -402
- package/dist/api/controllers/query.js +26 -8
- package/dist/api/controllers/script.js +4 -16
- package/dist/api/controllers/table/utils.js +2 -10
- package/dist/api/routes/query.js +3 -1
- package/dist/automations/actions.js +9 -3
- package/dist/automations/thread.js +14 -3
- package/dist/package.json +5 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/scriptRunner.js +19 -0
- package/package.json +6 -5
- package/src/api/controllers/query.js +46 -11
- package/src/api/controllers/script.js +4 -19
- package/src/api/controllers/table/utils.js +2 -12
- package/src/api/routes/query.js +3 -1
- package/src/automations/actions.js +10 -3
- package/src/automations/thread.js +17 -3
- package/src/integrations/tests/mongo.spec.js +10 -6
- package/src/utilities/scriptRunner.js +21 -0
|
@@ -14,6 +14,7 @@ const { generateQueryID, getQueryParams } = require("../../db/utils");
|
|
|
14
14
|
const { integrations } = require("../../integrations");
|
|
15
15
|
const { BaseQueryVerbs } = require("../../constants");
|
|
16
16
|
const env = require("../../environment");
|
|
17
|
+
const ScriptRunner = require("../../utilities/scriptRunner");
|
|
17
18
|
// simple function to append "readable" to all read queries
|
|
18
19
|
function enrichQueries(input) {
|
|
19
20
|
const wasArray = Array.isArray(input);
|
|
@@ -35,11 +36,29 @@ function formatResponse(resp) {
|
|
|
35
36
|
resp = { response: resp };
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
if (!Array.isArray(resp)) {
|
|
39
|
-
resp = [resp];
|
|
40
|
-
}
|
|
41
39
|
return resp;
|
|
42
40
|
}
|
|
41
|
+
function runAndTransform(integration, queryVerb, enrichedQuery, transformer) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
let rows = formatResponse(yield integration[queryVerb](enrichedQuery));
|
|
44
|
+
// transform as required
|
|
45
|
+
if (transformer) {
|
|
46
|
+
const runner = new ScriptRunner(transformer, { data: rows });
|
|
47
|
+
rows = runner.execute();
|
|
48
|
+
}
|
|
49
|
+
// needs to an array for next step
|
|
50
|
+
if (!Array.isArray(rows)) {
|
|
51
|
+
rows = [rows];
|
|
52
|
+
}
|
|
53
|
+
// map into JSON if just raw primitive here
|
|
54
|
+
if (rows.find(row => typeof row !== "object")) {
|
|
55
|
+
rows = rows.map(value => ({ value }));
|
|
56
|
+
}
|
|
57
|
+
// get all the potential fields in the schema
|
|
58
|
+
let keys = rows.flatMap(Object.keys);
|
|
59
|
+
return { rows, keys };
|
|
60
|
+
});
|
|
61
|
+
}
|
|
43
62
|
exports.fetch = function (ctx) {
|
|
44
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
64
|
const db = new CouchDB(ctx.appId);
|
|
@@ -119,12 +138,10 @@ exports.preview = function (ctx) {
|
|
|
119
138
|
if (!Integration) {
|
|
120
139
|
ctx.throw(400, "Integration type does not exist.");
|
|
121
140
|
}
|
|
122
|
-
const { fields, parameters, queryVerb } = ctx.request.body;
|
|
141
|
+
const { fields, parameters, queryVerb, transformer } = ctx.request.body;
|
|
123
142
|
const enrichedQuery = yield enrichQueryFields(fields, parameters);
|
|
124
143
|
const integration = new Integration(datasource.config);
|
|
125
|
-
const rows =
|
|
126
|
-
// get all the potential fields in the schema
|
|
127
|
-
const keys = rows.flatMap(Object.keys);
|
|
144
|
+
const { rows, keys } = yield runAndTransform(integration, queryVerb, enrichedQuery, transformer);
|
|
128
145
|
ctx.body = {
|
|
129
146
|
rows,
|
|
130
147
|
schemaFields: [...new Set(keys)],
|
|
@@ -147,7 +164,8 @@ exports.execute = function (ctx) {
|
|
|
147
164
|
const enrichedQuery = yield enrichQueryFields(query.fields, ctx.request.body.parameters);
|
|
148
165
|
const integration = new Integration(datasource.config);
|
|
149
166
|
// call the relevant CRUD method on the integration class
|
|
150
|
-
|
|
167
|
+
const { rows } = yield runAndTransform(integration, query.queryVerb, enrichedQuery, query.transformer);
|
|
168
|
+
ctx.body = rows;
|
|
151
169
|
// cleanup
|
|
152
170
|
if (integration.end) {
|
|
153
171
|
integration.end();
|
|
@@ -8,24 +8,12 @@ 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
|
|
12
|
-
const vm = require("vm");
|
|
13
|
-
class ScriptExecutor {
|
|
14
|
-
constructor(body) {
|
|
15
|
-
const code = `let fn = () => {\n${body.script}\n}; out = fn();`;
|
|
16
|
-
this.script = new vm.Script(code);
|
|
17
|
-
this.context = vm.createContext(body.context);
|
|
18
|
-
this.context.fetch = fetch;
|
|
19
|
-
}
|
|
20
|
-
execute() {
|
|
21
|
-
this.script.runInContext(this.context);
|
|
22
|
-
return this.context.out;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
11
|
+
const ScriptRunner = require("../../utilities/scriptRunner");
|
|
25
12
|
exports.execute = function (ctx) {
|
|
26
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const
|
|
28
|
-
|
|
14
|
+
const { script, context } = ctx.request.body;
|
|
15
|
+
const runner = new ScriptRunner(script, context);
|
|
16
|
+
ctx.body = runner.execute();
|
|
29
17
|
});
|
|
30
18
|
};
|
|
31
19
|
exports.save = function (ctx) {
|
|
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const CouchDB = require("../../../db");
|
|
12
|
-
const linkRows = require("../../../db/linkedRows");
|
|
13
12
|
const csvParser = require("../../../utilities/csvParser");
|
|
14
13
|
const { getRowParams, generateRowID, InternalTables, } = require("../../../db/utils");
|
|
15
14
|
const { isEqual } = require("lodash/fp");
|
|
@@ -86,16 +85,9 @@ exports.handleDataImport = (appId, user, table, dataImport) => __awaiter(void 0,
|
|
|
86
85
|
];
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
|
-
|
|
90
|
-
finalData.push(linkRows.updateLinks({
|
|
91
|
-
appId,
|
|
92
|
-
eventType: linkRows.EventType.ROW_SAVE,
|
|
93
|
-
row,
|
|
94
|
-
tableId: row.tableId,
|
|
95
|
-
table,
|
|
96
|
-
}));
|
|
88
|
+
finalData.push(row);
|
|
97
89
|
}
|
|
98
|
-
yield db.bulkDocs(
|
|
90
|
+
yield db.bulkDocs(finalData);
|
|
99
91
|
let response = yield db.put(table);
|
|
100
92
|
table._rev = response._rev;
|
|
101
93
|
}
|
package/dist/api/routes/query.js
CHANGED
|
@@ -22,7 +22,8 @@ function generateQueryValidation() {
|
|
|
22
22
|
})),
|
|
23
23
|
queryVerb: Joi.string().allow().required(),
|
|
24
24
|
extra: Joi.object().optional(),
|
|
25
|
-
schema: Joi.object({}).required().unknown(true)
|
|
25
|
+
schema: Joi.object({}).required().unknown(true),
|
|
26
|
+
transformer: Joi.string().optional(),
|
|
26
27
|
}));
|
|
27
28
|
}
|
|
28
29
|
function generateQueryPreviewValidation() {
|
|
@@ -32,6 +33,7 @@ function generateQueryPreviewValidation() {
|
|
|
32
33
|
queryVerb: Joi.string().allow().required(),
|
|
33
34
|
extra: Joi.object().optional(),
|
|
34
35
|
datasourceId: Joi.string().required(),
|
|
36
|
+
transformer: Joi.string().optional(),
|
|
35
37
|
parameters: Joi.object({}).required().unknown(true)
|
|
36
38
|
}));
|
|
37
39
|
}
|
|
@@ -13,7 +13,6 @@ const createRow = require("./steps/createRow");
|
|
|
13
13
|
const updateRow = require("./steps/updateRow");
|
|
14
14
|
const deleteRow = require("./steps/deleteRow");
|
|
15
15
|
const executeScript = require("./steps/executeScript");
|
|
16
|
-
const bash = require("./steps/bash");
|
|
17
16
|
const executeQuery = require("./steps/executeQuery");
|
|
18
17
|
const outgoingWebhook = require("./steps/outgoingWebhook");
|
|
19
18
|
const serverLog = require("./steps/serverLog");
|
|
@@ -24,6 +23,7 @@ const integromat = require("./steps/integromat");
|
|
|
24
23
|
let filter = require("./steps/filter");
|
|
25
24
|
let delay = require("./steps/delay");
|
|
26
25
|
let queryRow = require("./steps/queryRows");
|
|
26
|
+
const env = require("../environment");
|
|
27
27
|
const ACTION_IMPLS = {
|
|
28
28
|
SEND_EMAIL_SMTP: sendSmtpEmail.run,
|
|
29
29
|
CREATE_ROW: createRow.run,
|
|
@@ -31,7 +31,6 @@ const ACTION_IMPLS = {
|
|
|
31
31
|
DELETE_ROW: deleteRow.run,
|
|
32
32
|
OUTGOING_WEBHOOK: outgoingWebhook.run,
|
|
33
33
|
EXECUTE_SCRIPT: executeScript.run,
|
|
34
|
-
EXECUTE_BASH: bash.run,
|
|
35
34
|
EXECUTE_QUERY: executeQuery.run,
|
|
36
35
|
SERVER_LOG: serverLog.run,
|
|
37
36
|
DELAY: delay.run,
|
|
@@ -51,7 +50,6 @@ const ACTION_DEFINITIONS = {
|
|
|
51
50
|
OUTGOING_WEBHOOK: outgoingWebhook.definition,
|
|
52
51
|
EXECUTE_SCRIPT: executeScript.definition,
|
|
53
52
|
EXECUTE_QUERY: executeQuery.definition,
|
|
54
|
-
EXECUTE_BASH: bash.definition,
|
|
55
53
|
SERVER_LOG: serverLog.definition,
|
|
56
54
|
DELAY: delay.definition,
|
|
57
55
|
FILTER: filter.definition,
|
|
@@ -62,6 +60,14 @@ const ACTION_DEFINITIONS = {
|
|
|
62
60
|
zapier: zapier.definition,
|
|
63
61
|
integromat: integromat.definition,
|
|
64
62
|
};
|
|
63
|
+
// don't add the bash script/definitions unless in self host
|
|
64
|
+
// the fact this isn't included in any definitions means it cannot be
|
|
65
|
+
// ran at all
|
|
66
|
+
if (env.SELF_HOSTED) {
|
|
67
|
+
const bash = require("./steps/bash");
|
|
68
|
+
ACTION_IMPLS["EXECUTE_BASH"] = bash.run;
|
|
69
|
+
ACTION_DEFINITIONS["EXECUTE_BASH"] = bash.definition;
|
|
70
|
+
}
|
|
65
71
|
/* istanbul ignore next */
|
|
66
72
|
exports.getAction = function (actionName) {
|
|
67
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -19,6 +19,7 @@ const { doInTenant } = require("@budibase/auth/tenancy");
|
|
|
19
19
|
const env = require("../environment");
|
|
20
20
|
const usage = require("../utilities/usageQuota");
|
|
21
21
|
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId;
|
|
22
|
+
const STOPPED_STATUS = { success: false, status: "STOPPED" };
|
|
22
23
|
/**
|
|
23
24
|
* The automation orchestrator is a class responsible for executing automations.
|
|
24
25
|
* It handles the context of the automation and makes sure each step gets the correct
|
|
@@ -77,7 +78,13 @@ class Orchestrator {
|
|
|
77
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
79
|
let automation = this._automation;
|
|
79
80
|
const app = yield this.getApp();
|
|
81
|
+
let stopped = false;
|
|
80
82
|
for (let step of automation.definition.steps) {
|
|
83
|
+
// execution stopped, record state for that
|
|
84
|
+
if (stopped) {
|
|
85
|
+
this.updateExecutionOutput(step.id, step.stepId, {}, STOPPED_STATUS);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
81
88
|
let stepFn = yield this.getStepFunctionality(step.stepId);
|
|
82
89
|
step.inputs = yield processObject(step.inputs, this._context);
|
|
83
90
|
step.inputs = automationUtils.cleanInputValues(step.inputs, step.schema.inputs);
|
|
@@ -92,10 +99,14 @@ class Orchestrator {
|
|
|
92
99
|
context: this._context,
|
|
93
100
|
});
|
|
94
101
|
});
|
|
102
|
+
this._context.steps.push(outputs);
|
|
103
|
+
// if filter causes us to stop execution don't break the loop, set a var
|
|
104
|
+
// so that we can finish iterating through the steps and record that it stopped
|
|
95
105
|
if (step.stepId === FILTER_STEP_ID && !outputs.success) {
|
|
96
|
-
|
|
106
|
+
stopped = true;
|
|
107
|
+
this.updateExecutionOutput(step.id, step.stepId, step.inputs, Object.assign(Object.assign({}, outputs), STOPPED_STATUS));
|
|
108
|
+
continue;
|
|
97
109
|
}
|
|
98
|
-
this._context.steps.push(outputs);
|
|
99
110
|
this.updateExecutionOutput(step.id, step.stepId, step.inputs, outputs);
|
|
100
111
|
}
|
|
101
112
|
catch (err) {
|
|
@@ -105,7 +116,7 @@ class Orchestrator {
|
|
|
105
116
|
}
|
|
106
117
|
// Increment quota for automation runs
|
|
107
118
|
if (!env.SELF_HOSTED && !isDevAppID(this._appId)) {
|
|
108
|
-
usage.update(usage.Properties.AUTOMATION, 1);
|
|
119
|
+
yield usage.update(usage.Properties.AUTOMATION, 1);
|
|
109
120
|
}
|
|
110
121
|
return this.executionOutput;
|
|
111
122
|
});
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "0.9.167-alpha.
|
|
4
|
+
"version": "0.9.167-alpha.7",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"author": "Budibase",
|
|
69
69
|
"license": "AGPL-3.0-or-later",
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@budibase/auth": "^0.9.167-alpha.
|
|
72
|
-
"@budibase/client": "^0.9.167-alpha.
|
|
73
|
-
"@budibase/string-templates": "^0.9.167-alpha.
|
|
71
|
+
"@budibase/auth": "^0.9.167-alpha.7",
|
|
72
|
+
"@budibase/client": "^0.9.167-alpha.7",
|
|
73
|
+
"@budibase/string-templates": "^0.9.167-alpha.7",
|
|
74
74
|
"@elastic/elasticsearch": "7.10.0",
|
|
75
75
|
"@koa/router": "8.0.0",
|
|
76
76
|
"@sendgrid/mail": "7.1.1",
|
|
@@ -119,6 +119,7 @@
|
|
|
119
119
|
"to-json-schema": "0.2.5",
|
|
120
120
|
"uuid": "3.3.2",
|
|
121
121
|
"validate.js": "0.13.1",
|
|
122
|
+
"vm2": "^3.9.3",
|
|
122
123
|
"yargs": "13.2.4",
|
|
123
124
|
"zlib": "1.0.5"
|
|
124
125
|
},
|