@budibase/server 0.9.167-alpha.0 → 0.9.167-alpha.12
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.32c8bc7d.js → index.bb938864.js} +34 -34
- package/builder/assets/{index.18ad7651.css → index.bcacf476.css} +2 -2
- package/builder/assets/{vendor.60887453.js → vendor.a3855e3d.js} +1 -1
- package/builder/index.html +3 -3
- package/coverage/clover.xml +416 -369
- package/coverage/coverage-final.json +17 -16
- 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 +41 -17
- package/coverage/lcov-report/api/controllers/hosting.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +43 -43
- 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 +20 -20
- package/coverage/lcov-report/api/controllers/table/index.js.html +17 -8
- package/coverage/lcov-report/api/controllers/table/utils.js.html +8 -38
- package/coverage/lcov-report/api/controllers/templates.js.html +49 -13
- 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 +26 -11
- package/coverage/lcov-report/api/routes/hosting.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +9 -9
- 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 +5 -2
- 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 +53 -53
- 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 +2 -2
- 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 +2 -2
- 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 +14 -14
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +38 -8
- 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 +700 -608
- package/dist/api/controllers/dev.js +17 -11
- package/dist/api/controllers/query.js +26 -8
- package/dist/api/controllers/script.js +4 -16
- package/dist/api/controllers/table/index.js +3 -0
- package/dist/api/controllers/table/utils.js +2 -10
- package/dist/api/controllers/templates.js +18 -3
- package/dist/api/routes/dev.js +8 -4
- package/dist/api/routes/query.js +3 -1
- package/dist/automations/actions.js +9 -3
- package/dist/automations/thread.js +14 -3
- package/dist/constants/index.js +1 -0
- package/dist/integrations/base/sql.js +4 -4
- package/dist/middleware/currentapp.js +1 -1
- package/dist/package.json +5 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/global.js +1 -1
- package/dist/utilities/rowProcessor/index.js +8 -0
- package/dist/utilities/scriptRunner.js +19 -0
- package/package.json +6 -5
- package/src/api/controllers/dev.js +16 -8
- package/src/api/controllers/query.js +46 -11
- package/src/api/controllers/script.js +4 -19
- package/src/api/controllers/table/index.js +3 -0
- package/src/api/controllers/table/utils.js +2 -12
- package/src/api/controllers/templates.js +17 -5
- package/src/api/routes/dev.js +9 -4
- package/src/api/routes/query.js +3 -1
- package/src/automations/actions.js +10 -3
- package/src/automations/thread.js +17 -3
- package/src/constants/index.js +1 -0
- package/src/integrations/base/sql.ts +5 -3
- package/src/integrations/tests/mongo.spec.js +10 -6
- package/src/middleware/currentapp.js +1 -1
- package/src/middleware/tests/currentapp.spec.js +3 -3
- package/src/utilities/global.js +1 -1
- package/src/utilities/rowProcessor/index.js +10 -0
- package/src/utilities/scriptRunner.js +21 -0
|
@@ -16,11 +16,11 @@ const { request } = require("../../utilities/workerRequests");
|
|
|
16
16
|
const { clearLock } = require("../../utilities/redis");
|
|
17
17
|
const { Replication } = require("@budibase/auth").db;
|
|
18
18
|
const { DocumentTypes } = require("../../db/utils");
|
|
19
|
-
function redirect(ctx, method) {
|
|
19
|
+
function redirect(ctx, method, path = "global") {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
const { devPath } = ctx.params;
|
|
22
22
|
const queryString = ctx.originalUrl.split("?")[1] || "";
|
|
23
|
-
const response = yield fetch(checkSlashesInUrl(`${env.WORKER_URL}/api
|
|
23
|
+
const response = yield fetch(checkSlashesInUrl(`${env.WORKER_URL}/api/${path}/${devPath}?${queryString}`), request(ctx, {
|
|
24
24
|
method,
|
|
25
25
|
body: ctx.request.body,
|
|
26
26
|
}, true));
|
|
@@ -45,15 +45,21 @@ function redirect(ctx, method) {
|
|
|
45
45
|
ctx.cookies;
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
exports.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
48
|
+
exports.buildRedirectGet = path => {
|
|
49
|
+
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
yield redirect(ctx, "GET", path);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.buildRedirectPost = path => {
|
|
54
|
+
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
yield redirect(ctx, "POST", path);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
exports.buildRedirectDelete = path => {
|
|
59
|
+
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
yield redirect(ctx, "DELETE", path);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
57
63
|
exports.clearLock = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
64
|
const { appId } = ctx.params;
|
|
59
65
|
try {
|
|
@@ -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) {
|
|
@@ -81,6 +81,9 @@ exports.save = function (ctx) {
|
|
|
81
81
|
for (let propKey of Object.keys(tableToSave.schema)) {
|
|
82
82
|
let column = tableToSave.schema[propKey];
|
|
83
83
|
let oldColumn = oldTable.schema[propKey];
|
|
84
|
+
if (oldColumn && oldColumn.type === "internal") {
|
|
85
|
+
oldColumn.type = "auto";
|
|
86
|
+
}
|
|
84
87
|
if (oldColumn && oldColumn.type !== column.type) {
|
|
85
88
|
ctx.throw(400, "Cannot change the type of a column");
|
|
86
89
|
}
|
|
@@ -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
|
}
|
|
@@ -15,9 +15,24 @@ const DEFAULT_TEMPLATES_BUCKET = "prod-budi-templates.s3-eu-west-1.amazonaws.com
|
|
|
15
15
|
exports.fetch = function (ctx) {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
const { type = "app" } = ctx.query;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
let response, error = false;
|
|
19
|
+
try {
|
|
20
|
+
response = yield fetch(`https://${DEFAULT_TEMPLATES_BUCKET}/manifest.json`);
|
|
21
|
+
if (response.status !== 200) {
|
|
22
|
+
error = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
error = true;
|
|
27
|
+
}
|
|
28
|
+
// if there is an error, simply return no templates
|
|
29
|
+
if (!error && response) {
|
|
30
|
+
const json = yield response.json();
|
|
31
|
+
ctx.body = Object.values(json.templates[type]);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
ctx.body = [];
|
|
35
|
+
}
|
|
21
36
|
});
|
|
22
37
|
};
|
|
23
38
|
// can't currently test this, have to ignore from coverage
|
package/dist/api/routes/dev.js
CHANGED
|
@@ -5,11 +5,15 @@ const env = require("../../environment");
|
|
|
5
5
|
const authorized = require("../../middleware/authorized");
|
|
6
6
|
const { BUILDER } = require("@budibase/auth/permissions");
|
|
7
7
|
const router = Router();
|
|
8
|
-
|
|
8
|
+
function redirectPath(path) {
|
|
9
9
|
router
|
|
10
|
-
.get(
|
|
11
|
-
.post(
|
|
12
|
-
.delete(
|
|
10
|
+
.get(`/api/${path}/:devPath(.*)`, controller.buildRedirectGet(path))
|
|
11
|
+
.post(`/api/${path}/:devPath(.*)`, controller.buildRedirectPost(path))
|
|
12
|
+
.delete(`/api/${path}/:devPath(.*)`, controller.buildRedirectDelete(path));
|
|
13
|
+
}
|
|
14
|
+
if (env.isDev() || env.isTest()) {
|
|
15
|
+
redirectPath("global");
|
|
16
|
+
redirectPath("system");
|
|
13
17
|
}
|
|
14
18
|
router
|
|
15
19
|
.get("/api/dev/version", authorized(BUILDER), controller.getBudibaseVersion)
|
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/constants/index.js
CHANGED
|
@@ -80,7 +80,7 @@ function addFilters(tableName, query, filters) {
|
|
|
80
80
|
}
|
|
81
81
|
return query;
|
|
82
82
|
}
|
|
83
|
-
function addRelationships(query, fromTable, relationships) {
|
|
83
|
+
function addRelationships(knex, query, fields, fromTable, relationships) {
|
|
84
84
|
if (!relationships) {
|
|
85
85
|
return query;
|
|
86
86
|
}
|
|
@@ -88,7 +88,7 @@ function addRelationships(query, fromTable, relationships) {
|
|
|
88
88
|
const from = relationship.from, to = relationship.to, toTable = relationship.tableName;
|
|
89
89
|
if (!relationship.through) {
|
|
90
90
|
// @ts-ignore
|
|
91
|
-
query = query.leftJoin(toTable, `${fromTable}.${from}`, `${
|
|
91
|
+
query = query.leftJoin(toTable, `${fromTable}.${from}`, `${toTable}.${to}`);
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
94
|
const throughTable = relationship.through;
|
|
@@ -100,7 +100,7 @@ function addRelationships(query, fromTable, relationships) {
|
|
|
100
100
|
.leftJoin(toTable, `${toTable}.${toPrimary}`, `${throughTable}.${to}`);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
return query;
|
|
103
|
+
return query.limit(BASE_LIMIT);
|
|
104
104
|
}
|
|
105
105
|
function buildCreate(knex, json, opts) {
|
|
106
106
|
const { endpoint, body } = json;
|
|
@@ -165,7 +165,7 @@ function buildRead(knex, json, limit) {
|
|
|
165
165
|
[tableName]: query,
|
|
166
166
|
}).select(selectStatement);
|
|
167
167
|
// handle joins
|
|
168
|
-
return addRelationships(preQuery, tableName, relationships);
|
|
168
|
+
return addRelationships(knex, preQuery, selectStatement, tableName, relationships);
|
|
169
169
|
}
|
|
170
170
|
function buildUpdate(knex, json, opts) {
|
|
171
171
|
const { endpoint, body, filters } = json;
|
|
@@ -53,7 +53,7 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
53
53
|
const globalUser = yield getCachedSelf(ctx, requestAppId);
|
|
54
54
|
appId = requestAppId;
|
|
55
55
|
// retrieving global user gets the right role
|
|
56
|
-
roleId = globalUser.roleId ||
|
|
56
|
+
roleId = globalUser.roleId || roleId;
|
|
57
57
|
}
|
|
58
58
|
// nothing more to do
|
|
59
59
|
if (!appId) {
|
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.
|
|
4
|
+
"version": "0.9.167-alpha.11",
|
|
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.
|
|
72
|
-
"@budibase/client": "^0.9.
|
|
73
|
-
"@budibase/string-templates": "^0.9.
|
|
71
|
+
"@budibase/auth": "^0.9.167-alpha.11",
|
|
72
|
+
"@budibase/client": "^0.9.167-alpha.11",
|
|
73
|
+
"@budibase/string-templates": "^0.9.167-alpha.11",
|
|
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
|
},
|