@budibase/server 1.0.212-alpha.13 → 1.0.212-alpha.14
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/__mocks__/node-fetch.ts +9 -0
- package/builder/assets/index.1f366fcc.js +977 -0
- package/builder/assets/{index.92958011.css → index.7786f497.css} +1 -1
- package/builder/assets/{vendor.b4361801.js → vendor.001dcf8c.js} +2 -2
- package/builder/index.html +3 -3
- package/coverage/clover.xml +217 -209
- package/coverage/coverage-final.json +14 -14
- package/coverage/lcov-report/api/controllers/apikeys.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 +16 -16
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- 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/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- 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/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.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 +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- 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 +5 -5
- 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/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/index.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/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- 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/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.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/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.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 +1 -1
- 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 +1 -1
- 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/delay.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/loop.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/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/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/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 +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +12 -12
- 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 +18 -18
- 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/builder.js.html +12 -12
- package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +10 -10
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +19 -19
- package/coverage/lcov-report/threads/query.js.html +143 -68
- package/coverage/lcov-report/threads/utils.js.html +4 -4
- 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 +14 -14
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +9 -9
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- 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 +1 -1
- 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/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.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 +395 -381
- package/dist/api/controllers/query/index.js +6 -0
- package/dist/integrations/queries/sql.js +3 -0
- package/dist/integrations/rest.js +1 -1
- package/dist/package.json +6 -6
- package/dist/tests/utilities/TestConfiguration.js +19 -6
- package/dist/threads/query.js +18 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/api/controllers/query/index.ts +6 -0
- package/src/api/routes/tests/query.spec.js +166 -0
- package/src/integrations/queries/sql.ts +3 -1
- package/src/integrations/rest.ts +1 -1
- package/src/integrations/tests/rest.spec.js +16 -1
- package/src/migrations/tests/index.spec.ts +18 -2
- package/src/tests/utilities/TestConfiguration.js +22 -3
- package/src/threads/query.js +28 -3
- package/builder/assets/index.8653aa05.js +0 -977
|
@@ -128,6 +128,9 @@ function preview(ctx) {
|
|
|
128
128
|
parameters,
|
|
129
129
|
transformer,
|
|
130
130
|
queryId,
|
|
131
|
+
ctx: {
|
|
132
|
+
user: ctx.user,
|
|
133
|
+
},
|
|
131
134
|
});
|
|
132
135
|
const { rows, keys, info, extra } = yield pro_1.quotas.addQuery(runFn);
|
|
133
136
|
yield backend_core_1.events.query.previewed(datasource, query);
|
|
@@ -169,6 +172,9 @@ function execute(ctx, opts = { rowsOnly: false }) {
|
|
|
169
172
|
parameters: enrichedParameters,
|
|
170
173
|
transformer: query.transformer,
|
|
171
174
|
queryId: ctx.params.queryId,
|
|
175
|
+
ctx: {
|
|
176
|
+
user: ctx.user,
|
|
177
|
+
},
|
|
172
178
|
});
|
|
173
179
|
const { rows, pagination, extra } = yield pro_1.quotas.addQuery(runFn);
|
|
174
180
|
if (opts && opts.rowsOnly) {
|
|
@@ -5,6 +5,9 @@ const string_templates_1 = require("@budibase/string-templates");
|
|
|
5
5
|
const CONST_CHAR_REGEX = new RegExp("'[^']*'", "g");
|
|
6
6
|
function enrichQueryFields(fields, parameters = {}) {
|
|
7
7
|
const enrichedQuery = Array.isArray(fields) ? [] : {};
|
|
8
|
+
if (!fields || !parameters) {
|
|
9
|
+
return enrichedQuery;
|
|
10
|
+
}
|
|
8
11
|
// enrich the fields with dynamic parameters
|
|
9
12
|
for (let key of Object.keys(fields)) {
|
|
10
13
|
if (fields[key] == null) {
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.212-alpha.
|
|
4
|
+
"version": "1.0.212-alpha.13",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"license": "GPL-3.0",
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
80
|
-
"@budibase/backend-core": "^1.0.212-alpha.
|
|
81
|
-
"@budibase/client": "^1.0.212-alpha.
|
|
82
|
-
"@budibase/pro": "1.0.212-alpha.
|
|
83
|
-
"@budibase/string-templates": "^1.0.212-alpha.
|
|
84
|
-
"@budibase/types": "^1.0.212-alpha.
|
|
80
|
+
"@budibase/backend-core": "^1.0.212-alpha.13",
|
|
81
|
+
"@budibase/client": "^1.0.212-alpha.13",
|
|
82
|
+
"@budibase/pro": "1.0.212-alpha.13",
|
|
83
|
+
"@budibase/string-templates": "^1.0.212-alpha.13",
|
|
84
|
+
"@budibase/types": "^1.0.212-alpha.13",
|
|
85
85
|
"@bull-board/api": "3.7.0",
|
|
86
86
|
"@bull-board/koa": "3.9.4",
|
|
87
87
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -26,6 +26,8 @@ const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db");
|
|
|
26
26
|
const { encrypt } = require("@budibase/backend-core/encryption");
|
|
27
27
|
const GLOBAL_USER_ID = "us_uuid1";
|
|
28
28
|
const EMAIL = "babs@babs.com";
|
|
29
|
+
const FIRSTNAME = "Barbara";
|
|
30
|
+
const LASTNAME = "Barbington";
|
|
29
31
|
const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306";
|
|
30
32
|
class TestConfiguration {
|
|
31
33
|
constructor(openServer = true) {
|
|
@@ -51,6 +53,14 @@ class TestConfiguration {
|
|
|
51
53
|
getProdAppId() {
|
|
52
54
|
return this.prodAppId;
|
|
53
55
|
}
|
|
56
|
+
getUserDetails() {
|
|
57
|
+
return {
|
|
58
|
+
globalId: GLOBAL_USER_ID,
|
|
59
|
+
email: EMAIL,
|
|
60
|
+
firstName: FIRSTNAME,
|
|
61
|
+
lastName: LASTNAME,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
54
64
|
doInContext(appId, task) {
|
|
55
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
66
|
if (!appId) {
|
|
@@ -109,7 +119,7 @@ class TestConfiguration {
|
|
|
109
119
|
});
|
|
110
120
|
}
|
|
111
121
|
// USER / AUTH
|
|
112
|
-
globalUser({ id = GLOBAL_USER_ID, builder = true, admin = false, email = EMAIL, roles, } = {}) {
|
|
122
|
+
globalUser({ id = GLOBAL_USER_ID, firstName = FIRSTNAME, lastName = LASTNAME, builder = true, admin = false, email = EMAIL, roles, } = {}) {
|
|
113
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
124
|
return doWithGlobalDB(TENANT_ID, (db) => __awaiter(this, void 0, void 0, function* () {
|
|
115
125
|
let existing;
|
|
@@ -119,7 +129,8 @@ class TestConfiguration {
|
|
|
119
129
|
catch (err) {
|
|
120
130
|
existing = { email };
|
|
121
131
|
}
|
|
122
|
-
const user = Object.assign(Object.assign({ _id: id }, existing), { roles: roles || {}, tenantId: TENANT_ID
|
|
132
|
+
const user = Object.assign(Object.assign({ _id: id }, existing), { roles: roles || {}, tenantId: TENANT_ID, firstName,
|
|
133
|
+
lastName });
|
|
123
134
|
yield createASession(id, {
|
|
124
135
|
sessionId: "sessionid",
|
|
125
136
|
tenantId: TENANT_ID,
|
|
@@ -142,11 +153,13 @@ class TestConfiguration {
|
|
|
142
153
|
}));
|
|
143
154
|
});
|
|
144
155
|
}
|
|
145
|
-
createUser(id = null, email = EMAIL, builder = true, admin = false, roles = {}) {
|
|
156
|
+
createUser(id = null, firstName = FIRSTNAME, lastName = LASTNAME, email = EMAIL, builder = true, admin = false, roles = {}) {
|
|
146
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
158
|
const globalId = !id ? `us_${Math.random()}` : `us_${id}`;
|
|
148
159
|
const resp = yield this.globalUser({
|
|
149
160
|
id: globalId,
|
|
161
|
+
firstName,
|
|
162
|
+
lastName,
|
|
150
163
|
email,
|
|
151
164
|
builder,
|
|
152
165
|
admin,
|
|
@@ -466,15 +479,15 @@ class TestConfiguration {
|
|
|
466
479
|
});
|
|
467
480
|
}
|
|
468
481
|
// QUERY
|
|
469
|
-
previewQuery(request, config, datasource, fields) {
|
|
482
|
+
previewQuery(request, config, datasource, fields, params, verb) {
|
|
470
483
|
return __awaiter(this, void 0, void 0, function* () {
|
|
471
484
|
return request
|
|
472
485
|
.post(`/api/queries/preview`)
|
|
473
486
|
.send({
|
|
474
487
|
datasourceId: datasource._id,
|
|
475
|
-
parameters: {},
|
|
488
|
+
parameters: params || {},
|
|
476
489
|
fields,
|
|
477
|
-
queryVerb: "read",
|
|
490
|
+
queryVerb: verb || "read",
|
|
478
491
|
name: datasource.name,
|
|
479
492
|
})
|
|
480
493
|
.set(config.defaultHeaders())
|
package/dist/threads/query.js
CHANGED
|
@@ -27,6 +27,8 @@ class QueryRunner {
|
|
|
27
27
|
this.queryId = input.queryId;
|
|
28
28
|
this.noRecursiveQuery = flags.noRecursiveQuery;
|
|
29
29
|
this.cachedVariables = [];
|
|
30
|
+
// Additional context items for enrichment
|
|
31
|
+
this.ctx = input.ctx;
|
|
30
32
|
// allows the response from a query to be stored throughout this
|
|
31
33
|
// execution so that if it needs to be re-used for another variable
|
|
32
34
|
// it can be
|
|
@@ -40,16 +42,29 @@ class QueryRunner {
|
|
|
40
42
|
if (!Integration) {
|
|
41
43
|
throw "Integration type does not exist.";
|
|
42
44
|
}
|
|
45
|
+
if (datasource.config.authConfigs) {
|
|
46
|
+
datasource.config.authConfigs = datasource.config.authConfigs.map(config => {
|
|
47
|
+
return enrichQueryFields(config, this.ctx);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
43
50
|
const integration = new Integration(datasource.config);
|
|
44
51
|
// pre-query, make sure datasource variables are added to parameters
|
|
45
52
|
const parameters = yield this.addDatasourceVariables();
|
|
53
|
+
// Enrich the parameters with the addition context items.
|
|
54
|
+
// 'user' is now a reserved variable key in mapping parameters
|
|
55
|
+
const enrichedParameters = enrichQueryFields(parameters, this.ctx);
|
|
56
|
+
const enrichedContext = Object.assign(Object.assign({}, enrichedParameters), this.ctx);
|
|
57
|
+
// Parse global headers
|
|
58
|
+
if (datasource.config.defaultHeaders) {
|
|
59
|
+
datasource.config.defaultHeaders = enrichQueryFields(datasource.config.defaultHeaders, enrichedContext);
|
|
60
|
+
}
|
|
46
61
|
let query;
|
|
47
62
|
// handle SQL injections by interpolating the variables
|
|
48
63
|
if (isSQL(datasource)) {
|
|
49
|
-
query = interpolateSQL(fields,
|
|
64
|
+
query = interpolateSQL(fields, enrichedParameters, integration);
|
|
50
65
|
}
|
|
51
66
|
else {
|
|
52
|
-
query = enrichQueryFields(fields,
|
|
67
|
+
query = enrichQueryFields(fields, enrichedContext);
|
|
53
68
|
}
|
|
54
69
|
// Add pagination values for REST queries
|
|
55
70
|
if (this.pagination) {
|
|
@@ -67,7 +82,7 @@ class QueryRunner {
|
|
|
67
82
|
if (transformer) {
|
|
68
83
|
const runner = new ScriptRunner(transformer, {
|
|
69
84
|
data: rows,
|
|
70
|
-
params:
|
|
85
|
+
params: enrichedParameters,
|
|
71
86
|
});
|
|
72
87
|
rows = runner.execute();
|
|
73
88
|
}
|