@budibase/server 1.0.115 → 1.0.118
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.dae9f8cf.js → index.b1f26359.js} +2 -2
- package/builder/index.html +1 -1
- package/coverage/clover.xml +1113 -1125
- package/coverage/coverage-final.json +85 -86
- 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 +126 -120
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
- 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 +23 -14
- package/coverage/lcov-report/api/controllers/index.html +17 -17
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- 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 +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.js.html +19 -19
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +19 -19
- package/coverage/lcov-report/api/controllers/row/index.html +10 -10
- package/coverage/lcov-report/api/controllers/row/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/row/internal.js.html +37 -34
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +10 -10
- package/coverage/lcov-report/api/controllers/row/utils.js.html +12 -12
- package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +9 -9
- package/coverage/lcov-report/api/controllers/table/external.js.html +12 -12
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/table/internal.js.html +13 -13
- package/coverage/lcov-report/api/controllers/table/utils.js.html +30 -30
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +19 -19
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/view/utils.js.html +12 -12
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +17 -17
- 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/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/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/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/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 +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +5 -5
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +7 -7
- package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +18 -18
- package/coverage/lcov-report/automations/utils.js.html +43 -40
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +27 -27
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/inMemoryView.js.html +52 -49
- package/coverage/lcov-report/db/index.html +21 -36
- package/coverage/lcov-report/db/index.js.html +49 -10
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +7 -7
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +18 -18
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +13 -13
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +13 -13
- 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 +5 -5
- package/coverage/lcov-report/events/utils.js.html +3 -3
- package/coverage/lcov-report/index.html +46 -46
- 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 +15 -12
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +4 -4
- 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/usageQuota.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 +10 -10
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +1 -1
- package/coverage/lcov-report/threads/utils.js.html +19 -22
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +15 -15
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +26 -26
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +8 -8
- 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 +18 -18
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +4 -4
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +13 -13
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +8 -8
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +38 -26
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +28 -28
- package/coverage/lcov.info +1392 -1404
- package/dist/api/controllers/application.js +4 -1
- package/dist/api/controllers/deploy/index.js +5 -1
- package/dist/api/controllers/dev.js +9 -5
- package/dist/api/controllers/row/ExternalRequest.js +18 -7
- package/dist/api/controllers/row/internal.js +2 -1
- package/dist/api/controllers/webhook.js +2 -2
- package/dist/api/routes/tests/utilities/TestFunctions.js +1 -4
- package/dist/app.js +5 -2
- package/dist/automations/utils.js +6 -5
- package/dist/db/inMemoryView.js +33 -31
- package/dist/db/index.js +13 -2
- package/dist/integrations/couchdb.js +19 -25
- package/dist/integrations/mysql.js +13 -0
- package/dist/middleware/builder.js +10 -9
- package/dist/migrations/index.js +1 -5
- package/dist/package.json +5 -5
- package/dist/tests/utilities/TestConfiguration.js +66 -59
- package/dist/threads/utils.js +2 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +27 -26
- package/dist/utilities/usageQuota/rows.js +16 -16
- package/package.json +6 -6
- package/scripts/exportAppTemplate.js +10 -8
- package/src/api/controllers/application.js +3 -1
- package/src/api/controllers/deploy/index.js +4 -4
- package/src/api/controllers/dev.js +9 -6
- package/src/api/controllers/query/import/tests/index.spec.js +7 -11
- package/src/api/controllers/row/ExternalRequest.ts +25 -7
- package/src/api/controllers/row/internal.js +2 -1
- package/src/api/controllers/webhook.js +2 -2
- package/src/api/routes/tests/row.spec.js +15 -11
- package/src/api/routes/tests/table.spec.js +3 -2
- package/src/api/routes/tests/utilities/TestFunctions.js +1 -5
- package/src/app.ts +2 -2
- package/src/automations/tests/deleteRow.spec.js +1 -1
- package/src/automations/utils.js +6 -5
- package/src/db/inMemoryView.js +37 -36
- package/src/db/index.js +15 -2
- package/src/db/tests/linkTests.spec.js +8 -7
- package/src/integrations/couchdb.ts +28 -24
- package/src/integrations/mysql.ts +17 -1
- package/src/integrations/tests/airtable.spec.js +3 -1
- package/src/integrations/tests/couchdb.spec.js +4 -1
- package/src/middleware/builder.js +10 -9
- package/src/middleware/tests/authorized.spec.js +0 -1
- package/src/middleware/tests/usageQuota.spec.js +6 -20
- package/src/migrations/functions/tests/appUrls.spec.js +8 -11
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +13 -10
- package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +25 -21
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +26 -24
- package/src/migrations/index.ts +1 -2
- package/src/module.d.ts +8 -0
- package/src/tests/utilities/TestConfiguration.js +62 -55
- package/src/threads/utils.js +2 -3
- package/src/utilities/fileSystem/index.js +30 -30
- package/src/utilities/usageQuota/rows.js +22 -18
- package/coverage/lcov-report/db/client.js.html +0 -173
- package/dist/db/client.js +0 -25
- package/scripts/replicateApp.js +0 -50
- package/src/db/client.js +0 -31
|
@@ -92,7 +92,7 @@ function createInstance(template) {
|
|
|
92
92
|
const tenantId = isMultiTenant() ? getTenantId() : null;
|
|
93
93
|
const baseAppId = generateAppID(tenantId);
|
|
94
94
|
const appId = generateDevAppID(baseAppId);
|
|
95
|
-
updateAppId(appId);
|
|
95
|
+
yield updateAppId(appId);
|
|
96
96
|
const db = getAppDB();
|
|
97
97
|
yield db.put({
|
|
98
98
|
_id: "_design/database",
|
|
@@ -347,6 +347,9 @@ exports.sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
347
347
|
catch (err) {
|
|
348
348
|
error = err;
|
|
349
349
|
}
|
|
350
|
+
finally {
|
|
351
|
+
yield replication.close();
|
|
352
|
+
}
|
|
350
353
|
// sync the users
|
|
351
354
|
yield syncGlobalUsers();
|
|
352
355
|
if (error) {
|
|
@@ -81,11 +81,12 @@ function initDeployedApp(prodAppId) {
|
|
|
81
81
|
}
|
|
82
82
|
function deployApp(deployment) {
|
|
83
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
let replication;
|
|
84
85
|
try {
|
|
85
86
|
const appId = getAppId();
|
|
86
87
|
const devAppId = getDevelopmentAppID(appId);
|
|
87
88
|
const productionAppId = getProdAppID(appId);
|
|
88
|
-
|
|
89
|
+
replication = new Replication({
|
|
89
90
|
source: devAppId,
|
|
90
91
|
target: productionAppId,
|
|
91
92
|
});
|
|
@@ -109,6 +110,9 @@ function deployApp(deployment) {
|
|
|
109
110
|
yield storeDeploymentHistory(deployment);
|
|
110
111
|
throw Object.assign(Object.assign({}, err), { message: `Deployment Failed: ${err.message}` });
|
|
111
112
|
}
|
|
113
|
+
finally {
|
|
114
|
+
yield replication.close();
|
|
115
|
+
}
|
|
112
116
|
});
|
|
113
117
|
}
|
|
114
118
|
exports.fetchDeployments = function (ctx) {
|
|
@@ -81,8 +81,9 @@ exports.revert = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
81
81
|
try {
|
|
82
82
|
const db = getProdAppDB({ skip_setup: true });
|
|
83
83
|
const info = yield db.info();
|
|
84
|
-
if (info.error)
|
|
84
|
+
if (info.error) {
|
|
85
85
|
throw info.error;
|
|
86
|
+
}
|
|
86
87
|
const deploymentDoc = yield db.get(DocumentTypes.DEPLOYMENTS);
|
|
87
88
|
if (!deploymentDoc.history ||
|
|
88
89
|
Object.keys(deploymentDoc.history).length === 0) {
|
|
@@ -92,11 +93,11 @@ exports.revert = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
92
93
|
catch (err) {
|
|
93
94
|
return ctx.throw(400, "App has not yet been deployed");
|
|
94
95
|
}
|
|
96
|
+
const replication = new Replication({
|
|
97
|
+
source: productionAppId,
|
|
98
|
+
target: appId,
|
|
99
|
+
});
|
|
95
100
|
try {
|
|
96
|
-
const replication = new Replication({
|
|
97
|
-
source: productionAppId,
|
|
98
|
-
target: appId,
|
|
99
|
-
});
|
|
100
101
|
yield replication.rollback();
|
|
101
102
|
// update appID in reverted app to be dev version again
|
|
102
103
|
const db = getAppDB();
|
|
@@ -112,6 +113,9 @@ exports.revert = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
112
113
|
catch (err) {
|
|
113
114
|
ctx.throw(400, `Unable to revert. ${err}`);
|
|
114
115
|
}
|
|
116
|
+
finally {
|
|
117
|
+
yield replication.close();
|
|
118
|
+
}
|
|
115
119
|
});
|
|
116
120
|
exports.getBudibaseVersion = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
121
|
ctx.body = {
|
|
@@ -274,6 +274,23 @@ var External;
|
|
|
274
274
|
// after the fact
|
|
275
275
|
return { row: newRow, manyRelationships };
|
|
276
276
|
}
|
|
277
|
+
squashRelationshipColumns(table, row, relationships) {
|
|
278
|
+
for (let relationship of relationships) {
|
|
279
|
+
const linkedTable = this.tables[relationship.tableName];
|
|
280
|
+
if (!linkedTable) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const display = linkedTable.primaryDisplay;
|
|
284
|
+
for (let key of Object.keys(row[relationship.column])) {
|
|
285
|
+
const related = row[relationship.column][key];
|
|
286
|
+
row[relationship.column][key] = {
|
|
287
|
+
primaryDisplay: display ? related[display] : undefined,
|
|
288
|
+
_id: related._id,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return row;
|
|
293
|
+
}
|
|
277
294
|
/**
|
|
278
295
|
* This iterates through the returned rows and works out what elements of the rows
|
|
279
296
|
* actually match up to another row (based on primary keys) - this is pretty specific
|
|
@@ -300,12 +317,6 @@ var External;
|
|
|
300
317
|
if (!linked._id) {
|
|
301
318
|
continue;
|
|
302
319
|
}
|
|
303
|
-
// if not returning full docs then get the minimal links out
|
|
304
|
-
const display = linkedTable.primaryDisplay;
|
|
305
|
-
linked = {
|
|
306
|
-
primaryDisplay: display ? linked[display] : undefined,
|
|
307
|
-
_id: linked._id,
|
|
308
|
-
};
|
|
309
320
|
columns[relationship.column] = linked;
|
|
310
321
|
}
|
|
311
322
|
for (let [column, related] of Object.entries(columns)) {
|
|
@@ -344,7 +355,7 @@ var External;
|
|
|
344
355
|
// do this at end once its been added to the final rows
|
|
345
356
|
finalRows = this.updateRelationshipColumns(table, row, finalRows, relationships);
|
|
346
357
|
}
|
|
347
|
-
return utils_4.processFormulas(table, Object.values(finalRows));
|
|
358
|
+
return utils_4.processFormulas(table, Object.values(finalRows)).map((row) => this.squashRelationshipColumns(table, row, relationships));
|
|
348
359
|
}
|
|
349
360
|
/**
|
|
350
361
|
* Gets the list of relationship JSON structures based on the columns in the table,
|
|
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
const linkRows = require("../../../db/linkedRows");
|
|
23
23
|
const { generateRowID, getRowParams, getTableIDFromRowID, DocumentTypes, InternalTables, } = require("../../../db/utils");
|
|
24
|
+
const { dangerousGetDB } = require("@budibase/backend-core/db");
|
|
24
25
|
const userController = require("../user");
|
|
25
26
|
const { inputProcessing, outputProcessing, cleanupAttachments, } = require("../../../utilities/rowProcessor");
|
|
26
27
|
const { FieldTypes } = require("../../../constants");
|
|
@@ -233,7 +234,7 @@ exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
233
234
|
return outputProcessing(table, rows);
|
|
234
235
|
});
|
|
235
236
|
exports.find = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
236
|
-
const db =
|
|
237
|
+
const db = dangerousGetDB(ctx.appId);
|
|
237
238
|
const table = yield db.get(ctx.params.tableId);
|
|
238
239
|
let row = yield findRow(ctx, ctx.params.tableId, ctx.params.rowId);
|
|
239
240
|
row = yield outputProcessing(table, row);
|
|
@@ -55,7 +55,7 @@ exports.destroy = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
55
55
|
ctx.body = yield db.remove(ctx.params.id, ctx.params.rev);
|
|
56
56
|
});
|
|
57
57
|
exports.buildSchema = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
-
updateAppId(ctx.params.instance);
|
|
58
|
+
yield updateAppId(ctx.params.instance);
|
|
59
59
|
const db = getAppDB();
|
|
60
60
|
const webhook = yield db.get(ctx.params.id);
|
|
61
61
|
webhook.bodySchema = toJsonSchema(ctx.request.body);
|
|
@@ -80,7 +80,7 @@ exports.buildSchema = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
80
80
|
});
|
|
81
81
|
exports.trigger = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
82
|
const prodAppId = getProdAppID(ctx.params.instance);
|
|
83
|
-
updateAppId(prodAppId);
|
|
83
|
+
yield updateAppId(prodAppId);
|
|
84
84
|
try {
|
|
85
85
|
const db = getAppDB();
|
|
86
86
|
const webhook = yield db.get(ctx.params.id);
|
|
@@ -13,7 +13,7 @@ const appController = require("../../../controllers/application");
|
|
|
13
13
|
const { AppStatus } = require("../../../../db/utils");
|
|
14
14
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
15
15
|
const { TENANT_ID } = require("../../../../tests/utilities/structures");
|
|
16
|
-
const {
|
|
16
|
+
const { doInAppContext } = require("@budibase/backend-core/context");
|
|
17
17
|
const env = require("../../../../environment");
|
|
18
18
|
function Request(appId, params) {
|
|
19
19
|
this.appId = appId;
|
|
@@ -101,9 +101,6 @@ exports.checkPermissionsEndpoint = ({ config, method, url, body, passRole, failR
|
|
|
101
101
|
.set(failHeader)
|
|
102
102
|
.expect(403);
|
|
103
103
|
});
|
|
104
|
-
exports.getDB = () => {
|
|
105
|
-
return getAppDB();
|
|
106
|
-
};
|
|
107
104
|
exports.testAutomation = (config, automation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
105
|
return runRequest(automation.appId, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
106
|
return yield config.request
|
package/dist/app.js
CHANGED
|
@@ -27,10 +27,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
27
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
30
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
34
|
const env = __importStar(require("./environment"));
|
|
32
|
-
const
|
|
33
|
-
|
|
35
|
+
const db_1 = __importDefault(require("./db"));
|
|
36
|
+
db_1.default.init();
|
|
34
37
|
const Koa = require("koa");
|
|
35
38
|
const destroyable = require("server-destroy");
|
|
36
39
|
const koaBody = require("koa-body");
|
|
@@ -11,13 +11,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
const { Thread, ThreadType } = require("../threads");
|
|
12
12
|
const { definitions } = require("./triggerInfo");
|
|
13
13
|
const webhooks = require("../api/controllers/webhook");
|
|
14
|
-
const CouchDB = require("../db");
|
|
15
14
|
const { queue } = require("./bullboard");
|
|
16
15
|
const newid = require("../db/newid");
|
|
17
16
|
const { updateEntityMetadata } = require("../utilities");
|
|
18
17
|
const { MetadataTypes, WebhookType } = require("../constants");
|
|
19
18
|
const { getProdAppID } = require("@budibase/backend-core/db");
|
|
20
19
|
const { cloneDeep } = require("lodash/fp");
|
|
20
|
+
const { doWithDB } = require("@budibase/backend-core/db");
|
|
21
21
|
const { getAppDB, getAppId } = require("@budibase/backend-core/context");
|
|
22
22
|
const WH_STEP_ID = definitions.WEBHOOK.stepId;
|
|
23
23
|
const CRON_STEP_ID = definitions.CRON.stepId;
|
|
@@ -94,10 +94,11 @@ exports.enableCronTrigger = (appId, automation) => __awaiter(void 0, void 0, voi
|
|
|
94
94
|
// can't use getAppDB here as this is likely to be called from dev app,
|
|
95
95
|
// but this call could be for dev app or prod app, need to just use what
|
|
96
96
|
// was passed in
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
yield doWithDB(appId, (db) => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
+
const response = yield db.put(automation);
|
|
99
|
+
automation._id = response.id;
|
|
100
|
+
automation._rev = response.rev;
|
|
101
|
+
}));
|
|
101
102
|
}
|
|
102
103
|
return automation;
|
|
103
104
|
});
|
package/dist/db/inMemoryView.js
CHANGED
|
@@ -8,44 +8,46 @@ 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 PouchDB = require("pouchdb");
|
|
12
|
-
const memory = require("pouchdb-adapter-memory");
|
|
13
11
|
const newid = require("./newid");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
12
|
+
// bypass the main application db config
|
|
13
|
+
// use in memory pouchdb directly
|
|
14
|
+
const { getPouch, closeDB } = require("@budibase/backend-core/db");
|
|
15
|
+
const Pouch = getPouch({ inMemory: true });
|
|
19
16
|
exports.runView = (view, calculation, group, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
17
|
// use a different ID each time for the DB, make sure they
|
|
21
18
|
// are always unique for each query, don't want overlap
|
|
22
19
|
// which could cause 409s
|
|
23
20
|
const db = new Pouch(newid());
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const response = yield db.query(queryFns, {
|
|
36
|
-
include_docs: !calculation,
|
|
37
|
-
group: !!group,
|
|
38
|
-
});
|
|
39
|
-
// need to fix the revs to be totally accurate
|
|
40
|
-
for (let row of response.rows) {
|
|
41
|
-
if (!row._rev || !row._id) {
|
|
42
|
-
continue;
|
|
21
|
+
try {
|
|
22
|
+
// write all the docs to the in memory Pouch (remove revs)
|
|
23
|
+
yield db.bulkDocs(data.map(row => (Object.assign(Object.assign({}, row), { _rev: undefined }))));
|
|
24
|
+
let fn = (doc, emit) => emit(doc._id);
|
|
25
|
+
eval("fn = " + view.map.replace("function (doc)", "function (doc, emit)"));
|
|
26
|
+
const queryFns = {
|
|
27
|
+
meta: view.meta,
|
|
28
|
+
map: fn,
|
|
29
|
+
};
|
|
30
|
+
if (view.reduce) {
|
|
31
|
+
queryFns.reduce = view.reduce;
|
|
43
32
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
const response = yield db.query(queryFns, {
|
|
34
|
+
include_docs: !calculation,
|
|
35
|
+
group: !!group,
|
|
36
|
+
});
|
|
37
|
+
// need to fix the revs to be totally accurate
|
|
38
|
+
for (let row of response.rows) {
|
|
39
|
+
if (!row._rev || !row._id) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const found = data.find(possible => possible._id === row._id);
|
|
43
|
+
if (found) {
|
|
44
|
+
row._rev = found._rev;
|
|
45
|
+
}
|
|
47
46
|
}
|
|
47
|
+
return response;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
yield db.destroy();
|
|
51
|
+
yield closeDB(db);
|
|
48
52
|
}
|
|
49
|
-
yield db.destroy();
|
|
50
|
-
return response;
|
|
51
53
|
});
|
package/dist/db/index.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
3
|
-
|
|
2
|
+
const core = require("@budibase/backend-core");
|
|
3
|
+
const env = require("../environment");
|
|
4
|
+
exports.init = () => {
|
|
5
|
+
const dbConfig = {
|
|
6
|
+
replication: true,
|
|
7
|
+
find: true,
|
|
8
|
+
};
|
|
9
|
+
if (env.isTest()) {
|
|
10
|
+
dbConfig.inMemory = true;
|
|
11
|
+
dbConfig.allDbs = true;
|
|
12
|
+
}
|
|
13
|
+
core.init({ db: dbConfig });
|
|
14
|
+
};
|
|
@@ -54,49 +54,43 @@ var CouchDBModule;
|
|
|
54
54
|
this.config = config;
|
|
55
55
|
this.client = new PouchDB(`${config.url}/${config.database}`);
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
query(command, errorMsg, query) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
59
|
try {
|
|
60
|
-
|
|
60
|
+
const response = yield this.client[command](query.id || query.json);
|
|
61
|
+
yield this.client.close();
|
|
62
|
+
return response;
|
|
61
63
|
}
|
|
62
64
|
catch (err) {
|
|
63
|
-
console.error(
|
|
65
|
+
console.error(errorMsg, err);
|
|
64
66
|
throw err;
|
|
65
67
|
}
|
|
66
68
|
});
|
|
67
69
|
}
|
|
70
|
+
create(query) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
return this.query("post", "Error writing to couchDB", query);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
68
75
|
read(query) {
|
|
69
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
catch (err) {
|
|
75
|
-
console.error("Error querying couchDB", err);
|
|
76
|
-
throw err;
|
|
77
|
-
}
|
|
77
|
+
const result = yield this.query("allDocs", "Error querying couchDB", {
|
|
78
|
+
json: Object.assign({ include_docs: true }, query.json),
|
|
79
|
+
});
|
|
80
|
+
return result.rows.map((row) => row.doc);
|
|
78
81
|
});
|
|
79
82
|
}
|
|
80
83
|
update(query) {
|
|
81
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
|
|
83
|
-
return this.client.put(query.json);
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
console.error("Error updating couchDB document", err);
|
|
87
|
-
throw err;
|
|
88
|
-
}
|
|
85
|
+
return this.query("put", "Error updating couchDB document", query);
|
|
89
86
|
});
|
|
90
87
|
}
|
|
91
88
|
delete(query) {
|
|
92
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
console.error("Error deleting couchDB document", err);
|
|
98
|
-
throw err;
|
|
99
|
-
}
|
|
90
|
+
const doc = yield this.query("get", "Cannot find doc to be deleted", query);
|
|
91
|
+
return this.query("remove", "Error deleting couchDB document", {
|
|
92
|
+
json: doc,
|
|
93
|
+
});
|
|
100
94
|
});
|
|
101
95
|
}
|
|
102
96
|
}
|
|
@@ -54,6 +54,11 @@ var MySQLModule;
|
|
|
54
54
|
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
55
55
|
required: false,
|
|
56
56
|
},
|
|
57
|
+
rejectUnauthorized: {
|
|
58
|
+
type: datasource_1.DatasourceFieldTypes.BOOLEAN,
|
|
59
|
+
default: true,
|
|
60
|
+
required: false,
|
|
61
|
+
},
|
|
57
62
|
},
|
|
58
63
|
query: {
|
|
59
64
|
create: {
|
|
@@ -98,6 +103,14 @@ var MySQLModule;
|
|
|
98
103
|
if (config.ssl && Object.keys(config.ssl).length === 0) {
|
|
99
104
|
delete config.ssl;
|
|
100
105
|
}
|
|
106
|
+
// make sure this defaults to true
|
|
107
|
+
if (config.rejectUnauthorized != null &&
|
|
108
|
+
!config.rejectUnauthorized &&
|
|
109
|
+
config.ssl) {
|
|
110
|
+
config.ssl.rejectUnauthorized = config.rejectUnauthorized;
|
|
111
|
+
}
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
delete config.rejectUnauthorized;
|
|
101
114
|
this.config = config;
|
|
102
115
|
}
|
|
103
116
|
getBindingIdentifier() {
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const { APP_DEV_PREFIX } = require("../db/utils");
|
|
12
12
|
const { doesUserHaveLock, updateLock, checkDebounce, setDebounce, } = require("../utilities/redis");
|
|
13
|
-
const {
|
|
13
|
+
const { doWithDB } = require("@budibase/backend-core/db");
|
|
14
14
|
const { DocumentTypes } = require("../db/utils");
|
|
15
15
|
const { PermissionTypes } = require("@budibase/backend-core/permissions");
|
|
16
16
|
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
@@ -49,14 +49,15 @@ function updateAppUpdatedAt(ctx) {
|
|
|
49
49
|
if (ctx.method === "GET" || (yield checkDebounce(appId))) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
yield doWithDB(appId, (db) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const metadata = yield db.get(DocumentTypes.APP_METADATA);
|
|
54
|
+
metadata.updatedAt = new Date().toISOString();
|
|
55
|
+
const response = yield db.put(metadata);
|
|
56
|
+
metadata._rev = response.rev;
|
|
57
|
+
yield appCache.invalidateAppMetadata(appId, metadata);
|
|
58
|
+
// set a new debounce record with a short TTL
|
|
59
|
+
yield setDebounce(appId, DEBOUNCE_TIME_SEC);
|
|
60
|
+
}));
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
module.exports = (ctx, permType) => __awaiter(void 0, void 0, void 0, function* () {
|
package/dist/migrations/index.js
CHANGED
|
@@ -27,12 +27,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
27
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
31
|
exports.migrate = exports.MIGRATIONS = void 0;
|
|
35
|
-
const db_1 = __importDefault(require("../db"));
|
|
36
32
|
const { MIGRATION_TYPES, runMigrations, } = require("@budibase/backend-core/migrations");
|
|
37
33
|
// migration functions
|
|
38
34
|
const userEmailViewCasing = __importStar(require("./functions/userEmailViewCasing"));
|
|
@@ -57,6 +53,6 @@ exports.MIGRATIONS = [
|
|
|
57
53
|
},
|
|
58
54
|
];
|
|
59
55
|
const migrate = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
-
yield runMigrations(
|
|
56
|
+
yield runMigrations(exports.MIGRATIONS, options);
|
|
61
57
|
});
|
|
62
58
|
exports.migrate = migrate;
|
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.
|
|
4
|
+
"version": "1.0.117",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"license": "GPL-3.0",
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
71
|
-
"@budibase/backend-core": "^1.0.
|
|
72
|
-
"@budibase/client": "^1.0.
|
|
73
|
-
"@budibase/string-templates": "^1.0.
|
|
71
|
+
"@budibase/backend-core": "^1.0.117",
|
|
72
|
+
"@budibase/client": "^1.0.117",
|
|
73
|
+
"@budibase/string-templates": "^1.0.117",
|
|
74
74
|
"@bull-board/api": "^3.7.0",
|
|
75
75
|
"@bull-board/koa": "^3.7.0",
|
|
76
76
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"pg": "8.5.1",
|
|
118
118
|
"pino-pretty": "4.0.0",
|
|
119
119
|
"posthog-node": "^1.1.4",
|
|
120
|
-
"pouchdb": "7.
|
|
120
|
+
"pouchdb": "7.3.0",
|
|
121
121
|
"pouchdb-adapter-memory": "^7.2.1",
|
|
122
122
|
"pouchdb-all-dbs": "1.0.2",
|
|
123
123
|
"pouchdb-find": "^7.2.2",
|