@budibase/server 1.0.219-alpha.8 → 1.0.220-alpha.0
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.7e1f2be1.js → index.530f60fc.js} +153 -152
- package/builder/index.html +1 -1
- package/coverage/clover.xml +283 -262
- package/coverage/coverage-final.json +5 -5
- 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 +1 -1
- 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 +15 -15
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +78 -24
- 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 +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/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 +5 -2
- 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 +2 -2
- 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 +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 +30 -30
- 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 +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/publicApi.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/utils.js.html +1 -1
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +14 -14
- package/coverage/lcov-report/threads/query.js.html +40 -25
- package/coverage/lcov-report/threads/utils.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 +16 -16
- 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 +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 +57 -9
- package/coverage/lcov.info +501 -462
- package/dist/api/controllers/public/applications.js +1 -1
- package/dist/api/controllers/public/utils.js +8 -1
- package/dist/api/controllers/query/index.js +7 -4
- package/dist/api/controllers/row/internalSearch.js +26 -10
- package/dist/api/routes/public/rows.js +7 -2
- package/dist/api/routes/utils/validators.js +1 -0
- package/dist/app.js +20 -0
- package/dist/automations/steps/executeQuery.js +1 -1
- package/dist/environment.js +2 -0
- package/dist/integrations/base/sql.js +4 -2
- package/dist/package.json +6 -6
- package/dist/threads/query.js +20 -13
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +8 -0
- package/package.json +7 -7
- package/scripts/dev/manage.js +2 -0
- package/specs/openapi.json +9 -5
- package/specs/openapi.yaml +10 -4
- package/src/api/controllers/public/applications.ts +2 -2
- package/src/api/controllers/public/utils.ts +8 -1
- package/src/api/controllers/query/index.ts +13 -5
- package/src/api/controllers/row/internalSearch.js +27 -9
- package/src/api/routes/public/rows.ts +7 -2
- package/src/api/routes/tests/query.spec.js +0 -1
- package/src/api/routes/utils/validators.js +1 -0
- package/src/app.ts +30 -1
- package/src/automations/steps/executeQuery.js +1 -1
- package/src/definitions/openapi.ts +471 -469
- package/src/environment.js +2 -0
- package/src/integrations/base/sql.ts +6 -2
- package/src/threads/query.js +20 -15
- package/src/utilities/workerRequests.js +16 -0
|
@@ -84,7 +84,7 @@ function read(ctx, next) {
|
|
|
84
84
|
exports.read = read;
|
|
85
85
|
function update(ctx, next) {
|
|
86
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
ctx.request.body = fixAppID(ctx.request.body, ctx.params);
|
|
87
|
+
ctx.request.body = yield (0, utils_1.addRev)(fixAppID(ctx.request.body, ctx.params));
|
|
88
88
|
updateAppId(ctx.params.appId);
|
|
89
89
|
yield controller.update(ctx);
|
|
90
90
|
yield setResponseApp(ctx);
|
|
@@ -12,14 +12,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.search = exports.addRev = void 0;
|
|
13
13
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
14
14
|
const utils_1 = require("../../../integrations/utils");
|
|
15
|
+
const utils_2 = require("../../../db/utils");
|
|
15
16
|
function addRev(body, tableId) {
|
|
16
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
18
|
if (!body._id || (tableId && (0, utils_1.isExternalTable)(tableId))) {
|
|
18
19
|
return body;
|
|
19
20
|
}
|
|
21
|
+
let id = body._id;
|
|
22
|
+
if (body._id.startsWith(utils_2.APP_PREFIX)) {
|
|
23
|
+
id = utils_2.DocumentTypes.APP_METADATA;
|
|
24
|
+
}
|
|
20
25
|
const db = getAppDB();
|
|
21
|
-
const dbDoc = yield db.get(
|
|
26
|
+
const dbDoc = yield db.get(id);
|
|
22
27
|
body._rev = dbDoc._rev;
|
|
28
|
+
// update ID in case it is an app ID
|
|
29
|
+
body._id = id;
|
|
23
30
|
return body;
|
|
24
31
|
});
|
|
25
32
|
}
|
|
@@ -164,12 +164,15 @@ function preview(ctx) {
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
exports.preview = preview;
|
|
167
|
-
function execute(ctx, opts = { rowsOnly: false }) {
|
|
167
|
+
function execute(ctx, opts = { rowsOnly: false, isAutomation: false }) {
|
|
168
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
169
|
const db = (0, context_1.getAppDB)();
|
|
170
170
|
const query = yield db.get(ctx.params.queryId);
|
|
171
171
|
const datasource = yield db.get(query.datasourceId);
|
|
172
|
-
|
|
172
|
+
let authConfigCtx = {};
|
|
173
|
+
if (!opts.isAutomation) {
|
|
174
|
+
authConfigCtx = getAuthConfig(ctx);
|
|
175
|
+
}
|
|
173
176
|
const enrichedParameters = ctx.request.body.parameters || {};
|
|
174
177
|
// make sure parameters are fully enriched with defaults
|
|
175
178
|
if (query && query.parameters) {
|
|
@@ -214,9 +217,9 @@ function executeV1(ctx) {
|
|
|
214
217
|
});
|
|
215
218
|
}
|
|
216
219
|
exports.executeV1 = executeV1;
|
|
217
|
-
function executeV2(ctx) {
|
|
220
|
+
function executeV2(ctx, { isAutomation } = {}) {
|
|
218
221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
219
|
-
return execute(ctx, { rowsOnly: false });
|
|
222
|
+
return execute(ctx, { rowsOnly: false, isAutomation });
|
|
220
223
|
});
|
|
221
224
|
}
|
|
222
225
|
exports.executeV2 = executeV2;
|
|
@@ -18,7 +18,7 @@ const { getAppId } = require("@budibase/backend-core/context");
|
|
|
18
18
|
*/
|
|
19
19
|
class QueryBuilder {
|
|
20
20
|
constructor(base) {
|
|
21
|
-
this.query = Object.assign({ string: {}, fuzzy: {}, range: {}, equal: {}, notEqual: {}, empty: {}, notEmpty: {}, oneOf: {} }, base);
|
|
21
|
+
this.query = Object.assign({ allOr: false, string: {}, fuzzy: {}, range: {}, equal: {}, notEqual: {}, empty: {}, notEmpty: {}, oneOf: {} }, base);
|
|
22
22
|
this.limit = 50;
|
|
23
23
|
this.sortOrder = "ascending";
|
|
24
24
|
this.sortType = "string";
|
|
@@ -127,8 +127,21 @@ class QueryBuilder {
|
|
|
127
127
|
}
|
|
128
128
|
buildSearchQuery() {
|
|
129
129
|
const builder = this;
|
|
130
|
-
let
|
|
130
|
+
let allOr = this.query && this.query.allOr;
|
|
131
|
+
let query = allOr ? "" : "*:*";
|
|
131
132
|
const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true };
|
|
133
|
+
let tableId;
|
|
134
|
+
if (this.query.equal.tableId) {
|
|
135
|
+
tableId = this.query.equal.tableId;
|
|
136
|
+
delete this.query.equal.tableId;
|
|
137
|
+
}
|
|
138
|
+
const equal = (key, value) => {
|
|
139
|
+
// 0 evaluates to false, which means we would return all rows if we don't check it
|
|
140
|
+
if (!value && value !== 0) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
144
|
+
};
|
|
132
145
|
function build(structure, queryFn) {
|
|
133
146
|
for (let [key, value] of Object.entries(structure)) {
|
|
134
147
|
key = builder.preprocess(key.replace(/ /g, "_"), {
|
|
@@ -138,7 +151,10 @@ class QueryBuilder {
|
|
|
138
151
|
if (expression == null) {
|
|
139
152
|
continue;
|
|
140
153
|
}
|
|
141
|
-
query
|
|
154
|
+
if (query.length > 0) {
|
|
155
|
+
query += ` ${allOr ? "OR" : "AND"} `;
|
|
156
|
+
}
|
|
157
|
+
query += expression;
|
|
142
158
|
}
|
|
143
159
|
}
|
|
144
160
|
// Construct the actual lucene search query string from JSON structure
|
|
@@ -183,13 +199,7 @@ class QueryBuilder {
|
|
|
183
199
|
});
|
|
184
200
|
}
|
|
185
201
|
if (this.query.equal) {
|
|
186
|
-
build(this.query.equal,
|
|
187
|
-
// 0 evaluates to false, which means we would return all rows if we don't check it
|
|
188
|
-
if (!value && value !== 0) {
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
192
|
-
});
|
|
202
|
+
build(this.query.equal, equal);
|
|
193
203
|
}
|
|
194
204
|
if (this.query.notEqual) {
|
|
195
205
|
build(this.query.notEqual, (key, value) => {
|
|
@@ -222,6 +232,12 @@ class QueryBuilder {
|
|
|
222
232
|
return `${key}:(${orStatement})`;
|
|
223
233
|
});
|
|
224
234
|
}
|
|
235
|
+
// make sure table ID is always added as an AND
|
|
236
|
+
if (tableId) {
|
|
237
|
+
query = `(${query})`;
|
|
238
|
+
allOr = false;
|
|
239
|
+
build({ tableId }, equal);
|
|
240
|
+
}
|
|
225
241
|
return query;
|
|
226
242
|
}
|
|
227
243
|
buildSearchBody() {
|
|
@@ -144,6 +144,11 @@ read.push(new Endpoint_1.default("get", "/tables/:tableId/rows/:rowId", rows_1.d
|
|
|
144
144
|
* query:
|
|
145
145
|
* type: object
|
|
146
146
|
* properties:
|
|
147
|
+
* allOr:
|
|
148
|
+
* type: boolean
|
|
149
|
+
* description: Specifies that a row should be returned if it satisfies
|
|
150
|
+
* any of the specified options, rather than requiring it to fulfill all
|
|
151
|
+
* the search parameters. This defaults to false, meaning AND logic will be used.
|
|
147
152
|
* string:
|
|
148
153
|
* type: object
|
|
149
154
|
* example:
|
|
@@ -161,9 +166,9 @@ read.push(new Endpoint_1.default("get", "/tables/:tableId/rows/:rowId", rows_1.d
|
|
|
161
166
|
* range:
|
|
162
167
|
* type: object
|
|
163
168
|
* description: Searches within a range, the format of this must be
|
|
164
|
-
*
|
|
169
|
+
* in the format of an object with a "low" and "high" property.
|
|
165
170
|
* example:
|
|
166
|
-
* columnName1:
|
|
171
|
+
* columnName1: { low: 10, high: 20 }
|
|
167
172
|
* equal:
|
|
168
173
|
* type: object
|
|
169
174
|
* description: Searches for rows that have a column value that is
|
package/dist/app.js
CHANGED
|
@@ -54,6 +54,7 @@ const { Thread } = require("./threads");
|
|
|
54
54
|
const redis_1 = __importDefault(require("./utilities/redis"));
|
|
55
55
|
const migrations = __importStar(require("./migrations"));
|
|
56
56
|
const backend_core_1 = require("@budibase/backend-core");
|
|
57
|
+
const workerRequests_1 = require("./utilities/workerRequests");
|
|
57
58
|
const app = new Koa();
|
|
58
59
|
// set up top level koa middleware
|
|
59
60
|
app.use(koaBody({
|
|
@@ -112,6 +113,7 @@ server.on("close", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
112
113
|
}
|
|
113
114
|
}));
|
|
114
115
|
module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
+
var _a;
|
|
115
117
|
console.log(`Budibase running on ${JSON.stringify(server.address())}`);
|
|
116
118
|
env._set("PORT", server.address().port);
|
|
117
119
|
eventEmitter.emitPort(env.PORT);
|
|
@@ -128,6 +130,24 @@ module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, vo
|
|
|
128
130
|
shutdown();
|
|
129
131
|
}
|
|
130
132
|
}
|
|
133
|
+
// check and create admin user if required
|
|
134
|
+
if (env.SELF_HOSTED &&
|
|
135
|
+
!env.MULTI_TENANCY &&
|
|
136
|
+
env.BB_ADMIN_USER_EMAIL &&
|
|
137
|
+
env.BB_ADMIN_USER_PASSWORD) {
|
|
138
|
+
const checklist = yield (0, workerRequests_1.getChecklist)();
|
|
139
|
+
if (!((_a = checklist === null || checklist === void 0 ? void 0 : checklist.adminUser) === null || _a === void 0 ? void 0 : _a.checked)) {
|
|
140
|
+
try {
|
|
141
|
+
const tenantId = backend_core_1.tenancy.getTenantId();
|
|
142
|
+
yield (0, workerRequests_1.createAdminUser)(env.BB_ADMIN_USER_EMAIL, env.BB_ADMIN_USER_PASSWORD, tenantId);
|
|
143
|
+
console.log("Admin account automatically created for", env.BB_ADMIN_USER_EMAIL);
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
logAlert("Error creating initial admin user. Exiting.", e);
|
|
147
|
+
shutdown();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
131
151
|
// check for version updates
|
|
132
152
|
yield backend_core_1.installation.checkInstallVersion();
|
|
133
153
|
// done last - this will never complete
|
|
@@ -88,7 +88,7 @@ exports.run = function ({ inputs, appId, emitter }) {
|
|
|
88
88
|
},
|
|
89
89
|
});
|
|
90
90
|
try {
|
|
91
|
-
yield queryController.executeV2(ctx);
|
|
91
|
+
yield queryController.executeV2(ctx, { isAutomation: true });
|
|
92
92
|
const _b = ctx.body, { data } = _b, rest = __rest(_b, ["data"]);
|
|
93
93
|
return {
|
|
94
94
|
response: data,
|
package/dist/environment.js
CHANGED
|
@@ -62,6 +62,8 @@ module.exports = {
|
|
|
62
62
|
DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT,
|
|
63
63
|
QUERY_THREAD_TIMEOUT: parseIntSafe(process.env.QUERY_THREAD_TIMEOUT),
|
|
64
64
|
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
|
65
|
+
BB_ADMIN_USER_EMAIL: process.env.BB_ADMIN_USER_EMAIL,
|
|
66
|
+
BB_ADMIN_USER_PASSWORD: process.env.BB_ADMIN_USER_PASSWORD,
|
|
65
67
|
// flags
|
|
66
68
|
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
|
|
67
69
|
DISABLE_THREADING: process.env.DISABLE_THREADING,
|
|
@@ -97,8 +97,10 @@ function generateSelectStatement(json, knex) {
|
|
|
97
97
|
const fieldNames = field.split(/\./g);
|
|
98
98
|
const tableName = fieldNames[0];
|
|
99
99
|
const columnName = fieldNames[1];
|
|
100
|
-
if (columnName &&
|
|
101
|
-
|
|
100
|
+
if (columnName &&
|
|
101
|
+
(schema === null || schema === void 0 ? void 0 : schema[columnName]) &&
|
|
102
|
+
knex.client.config.client === utils_1.SqlClients.POSTGRES) {
|
|
103
|
+
const externalType = schema[columnName].externalType;
|
|
102
104
|
if (externalType === null || externalType === void 0 ? void 0 : externalType.includes("money")) {
|
|
103
105
|
return knex.raw(`"${tableName}"."${columnName}"::money::numeric as "${field}"`);
|
|
104
106
|
}
|
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.219
|
|
4
|
+
"version": "1.0.219",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -77,11 +77,10 @@
|
|
|
77
77
|
"license": "GPL-3.0",
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
80
|
-
"@budibase/backend-core": "^1.0.219
|
|
81
|
-
"@budibase/client": "^1.0.219
|
|
82
|
-
"@budibase/pro": "1.0.219
|
|
83
|
-
"@budibase/string-templates": "^1.0.219
|
|
84
|
-
"@budibase/types": "^1.0.219-alpha.7",
|
|
80
|
+
"@budibase/backend-core": "^1.0.219",
|
|
81
|
+
"@budibase/client": "^1.0.219",
|
|
82
|
+
"@budibase/pro": "1.0.219",
|
|
83
|
+
"@budibase/string-templates": "^1.0.219",
|
|
85
84
|
"@bull-board/api": "3.7.0",
|
|
86
85
|
"@bull-board/koa": "3.9.4",
|
|
87
86
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -152,6 +151,7 @@
|
|
|
152
151
|
"@babel/core": "7.17.4",
|
|
153
152
|
"@babel/preset-env": "7.16.11",
|
|
154
153
|
"@budibase/standard-components": "^0.9.139",
|
|
154
|
+
"@budibase/types": "^1.0.219",
|
|
155
155
|
"@jest/test-sequencer": "24.9.0",
|
|
156
156
|
"@types/apidoc": "0.50.0",
|
|
157
157
|
"@types/bson": "4.2.0",
|
package/dist/threads/query.js
CHANGED
|
@@ -17,6 +17,7 @@ const { doInAppContext, getAppDB } = require("@budibase/backend-core/context");
|
|
|
17
17
|
const { refreshOAuthToken, updateUserOAuth, } = require("@budibase/backend-core/auth");
|
|
18
18
|
const { user: userCache } = require("@budibase/backend-core/cache");
|
|
19
19
|
const { getGlobalIDFromUserMetadataID } = require("../db/utils");
|
|
20
|
+
const { cloneDeep } = require("lodash/fp");
|
|
20
21
|
const { isSQL } = require("../integrations/utils");
|
|
21
22
|
const { enrichQueryFields, interpolateSQL, } = require("../integrations/queries/sql");
|
|
22
23
|
class QueryRunner {
|
|
@@ -43,16 +44,19 @@ class QueryRunner {
|
|
|
43
44
|
var _a;
|
|
44
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
46
|
let { datasource, fields, queryVerb, transformer } = this;
|
|
46
|
-
|
|
47
|
+
let datasourceClone = cloneDeep(datasource);
|
|
48
|
+
let fieldsClone = cloneDeep(fields);
|
|
49
|
+
const Integration = integrations[datasourceClone.source];
|
|
47
50
|
if (!Integration) {
|
|
48
51
|
throw "Integration type does not exist.";
|
|
49
52
|
}
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
if (datasourceClone.config.authConfigs) {
|
|
54
|
+
datasourceClone.config.authConfigs =
|
|
55
|
+
datasourceClone.config.authConfigs.map(config => {
|
|
56
|
+
return enrichQueryFields(config, this.ctx);
|
|
57
|
+
});
|
|
54
58
|
}
|
|
55
|
-
const integration = new Integration(
|
|
59
|
+
const integration = new Integration(datasourceClone.config);
|
|
56
60
|
// pre-query, make sure datasource variables are added to parameters
|
|
57
61
|
const parameters = yield this.addDatasourceVariables();
|
|
58
62
|
// Enrich the parameters with the addition context items.
|
|
@@ -60,16 +64,16 @@ class QueryRunner {
|
|
|
60
64
|
const enrichedParameters = enrichQueryFields(parameters, this.ctx);
|
|
61
65
|
const enrichedContext = Object.assign(Object.assign({}, enrichedParameters), this.ctx);
|
|
62
66
|
// Parse global headers
|
|
63
|
-
if (
|
|
64
|
-
|
|
67
|
+
if (datasourceClone.config.defaultHeaders) {
|
|
68
|
+
datasourceClone.config.defaultHeaders = enrichQueryFields(datasourceClone.config.defaultHeaders, enrichedContext);
|
|
65
69
|
}
|
|
66
70
|
let query;
|
|
67
71
|
// handle SQL injections by interpolating the variables
|
|
68
|
-
if (isSQL(
|
|
69
|
-
query = interpolateSQL(
|
|
72
|
+
if (isSQL(datasourceClone)) {
|
|
73
|
+
query = interpolateSQL(fieldsClone, enrichedParameters, integration);
|
|
70
74
|
}
|
|
71
75
|
else {
|
|
72
|
-
query = enrichQueryFields(
|
|
76
|
+
query = enrichQueryFields(fieldsClone, enrichedContext);
|
|
73
77
|
}
|
|
74
78
|
// Add pagination values for REST queries
|
|
75
79
|
if (this.pagination) {
|
|
@@ -100,7 +104,9 @@ class QueryRunner {
|
|
|
100
104
|
// Attempt to refresh the access token from the provider
|
|
101
105
|
this.hasRefreshedOAuth = true;
|
|
102
106
|
}
|
|
103
|
-
|
|
107
|
+
else {
|
|
108
|
+
this.hasRerun = true;
|
|
109
|
+
}
|
|
104
110
|
yield threadUtils.invalidateDynamicVariables(this.cachedVariables);
|
|
105
111
|
return this.execute();
|
|
106
112
|
}
|
|
@@ -156,7 +162,8 @@ class QueryRunner {
|
|
|
156
162
|
else {
|
|
157
163
|
// In this event the user may have oAuth issues that
|
|
158
164
|
// could require re-authenticating with their provider.
|
|
159
|
-
|
|
165
|
+
let errorMessage = resp.err.data ? resp.err.data : resp.err.toString();
|
|
166
|
+
throw new Error("OAuth2 access token could not be refreshed: " + errorMessage);
|
|
160
167
|
}
|
|
161
168
|
return resp;
|
|
162
169
|
});
|