@budibase/server 2.0.32 → 2.0.34-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/__mocks__/mongodb.ts +1 -1
- package/builder/assets/backups-default.8c011f1b.png +0 -0
- package/builder/assets/{index.dfa4073c.css → index.b15ffe95.css} +2 -2
- package/builder/assets/{index.f8c02de7.js → index.d09d1931.js} +340 -332
- package/builder/index.html +2 -2
- package/coverage/clover.xml +634 -689
- package/coverage/coverage-final.json +34 -36
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +74 -62
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +2 -2
- package/coverage/lcov-report/api/controllers/index.html +17 -32
- 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 +12 -12
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +15 -15
- package/coverage/lcov-report/api/controllers/row/utils.js.html +13 -13
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +12 -9
- package/coverage/lcov-report/api/controllers/table/external.js.html +10 -10
- package/coverage/lcov-report/api/controllers/table/index.html +16 -16
- package/coverage/lcov-report/api/controllers/table/index.js.html +5 -5
- 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 +3 -3
- 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 +7 -7
- 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/automation.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 +5 -20
- 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 +6 -6
- package/coverage/lcov-report/automations/bullboard.js.html +17 -92
- package/coverage/lcov-report/automations/index.html +18 -18
- package/coverage/lcov-report/automations/index.js.html +9 -9
- 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 +3 -3
- 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 +26 -26
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +10 -16
- 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 +19 -19
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +11 -11
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +11 -11
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +3 -3
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +37 -316
- 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 +2 -2
- package/coverage/lcov-report/events/utils.js.html +9 -9
- package/coverage/lcov-report/index.html +77 -77
- 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 +11 -11
- package/coverage/lcov-report/middleware/currentapp.js.html +34 -34
- 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 +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/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +11 -8
- package/coverage/lcov-report/utilities/global.js.html +16 -16
- package/coverage/lcov-report/utilities/index.html +15 -15
- package/coverage/lcov-report/utilities/index.js.html +7 -7
- package/coverage/lcov-report/utilities/plugins.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +52 -52
- package/coverage/lcov-report/utilities/queue/index.html +21 -21
- 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 +54 -39
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +14 -14
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +23 -11
- 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 +1141 -1246
- package/dist/api/controllers/application.js +4 -7
- package/dist/api/controllers/backup.js +19 -13
- package/dist/api/controllers/cloud.js +38 -35
- package/dist/api/controllers/deploy/index.js +11 -2
- package/dist/api/controllers/dev.js +1 -1
- package/dist/api/controllers/query/index.js +7 -2
- package/dist/api/controllers/row/index.js +30 -10
- package/dist/api/controllers/static/index.js +2 -2
- package/dist/api/controllers/static/templates/preview.hbs +10 -0
- package/dist/api/controllers/table/bulkFormula.js +4 -3
- package/dist/api/controllers/table/external.js +5 -4
- package/dist/api/controllers/table/index.js +4 -4
- package/dist/api/controllers/table/internal.js +10 -3
- package/dist/api/controllers/table/utils.js +7 -49
- package/dist/api/controllers/view/index.js +2 -2
- package/dist/api/routes/backup.js +34 -7
- package/dist/api/routes/index.js +9 -4
- package/dist/app.js +14 -0
- package/dist/automations/automationUtils.js +2 -2
- package/dist/automations/bullboard.js +5 -33
- package/dist/automations/index.js +4 -4
- package/dist/automations/steps/updateRow.js +2 -2
- package/dist/automations/triggers.js +4 -4
- package/dist/automations/utils.js +18 -12
- package/dist/constants/index.js +4 -5
- package/dist/db/utils.js +10 -75
- package/dist/index.js +1 -0
- package/dist/integrations/arangodb.js +2 -0
- package/dist/integrations/base/sqlTable.js +1 -0
- package/dist/integrations/mongodb.js +300 -11
- package/dist/integrations/rest.js +38 -5
- package/dist/migrations/functions/backfill/app/tables.js +5 -8
- package/dist/migrations/functions/{quotas1.js → syncQuotas.js} +3 -7
- package/dist/migrations/functions/usageQuotas/syncApps.js +0 -1
- package/dist/migrations/functions/{pluginCount.js → usageQuotas/syncPlugins.js} +1 -3
- package/dist/migrations/functions/usageQuotas/syncRows.js +9 -5
- package/dist/migrations/index.js +9 -38
- package/dist/package.json +14 -14
- package/dist/sdk/app/backups/constants.js +5 -0
- package/dist/sdk/app/backups/exports.js +172 -0
- package/dist/sdk/app/backups/imports.js +162 -0
- package/dist/sdk/app/backups/index.js +29 -0
- package/dist/sdk/app/backups/statistics.js +73 -0
- package/dist/sdk/app/tables/index.js +61 -0
- package/dist/sdk/index.js +15 -0
- package/dist/tests/utilities/TestConfiguration.js +4 -2
- package/dist/threads/automation.js +12 -17
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/csvParser.js +1 -0
- package/dist/utilities/fileSystem/index.js +3 -95
- package/dist/utilities/fileSystem/utilities.js +2 -1
- package/dist/utilities/rowProcessor/index.js +5 -0
- package/dist/utilities/usageQuota/rows.js +6 -4
- package/package.json +15 -15
- package/specs/openapi.json +3 -0
- package/specs/openapi.yaml +3 -0
- package/src/api/controllers/application.ts +5 -12
- package/src/api/controllers/{backup.js → backup.ts} +7 -7
- package/src/api/controllers/cloud.js +44 -40
- package/src/api/controllers/deploy/index.ts +20 -8
- package/src/api/controllers/dev.js +1 -1
- package/src/api/controllers/query/index.ts +8 -2
- package/src/api/controllers/row/index.ts +36 -13
- package/src/api/controllers/static/index.ts +2 -2
- package/src/api/controllers/static/templates/preview.hbs +10 -0
- package/src/api/controllers/table/bulkFormula.js +4 -3
- package/src/api/controllers/table/external.js +4 -4
- package/src/api/controllers/table/index.js +4 -4
- package/src/api/controllers/table/internal.ts +8 -9
- package/src/api/controllers/table/utils.ts +4 -53
- package/src/api/controllers/view/index.js +2 -2
- package/src/api/routes/backup.ts +10 -0
- package/src/api/routes/index.ts +11 -5
- package/src/api/routes/tests/backup.spec.js +1 -1
- package/src/api/routes/tests/{deployment.spec.js → deployment.spec.ts} +4 -4
- package/src/api/routes/tests/row.spec.js +22 -27
- package/src/app.ts +15 -0
- package/src/automations/automationUtils.js +2 -2
- package/src/automations/bullboard.js +8 -33
- package/src/automations/index.js +4 -4
- package/src/automations/steps/updateRow.js +2 -2
- package/src/automations/tests/automation.spec.js +1 -6
- package/src/automations/triggers.js +4 -4
- package/src/automations/utils.ts +18 -12
- package/src/constants/index.js +4 -6
- package/src/db/utils.js +17 -110
- package/src/definitions/automations.ts +0 -12
- package/src/definitions/datasource.ts +1 -0
- package/src/index.ts +1 -0
- package/src/integrations/arangodb.ts +2 -0
- package/src/integrations/base/sqlTable.ts +1 -0
- package/src/integrations/mongodb.ts +290 -27
- package/src/integrations/rest.ts +17 -5
- package/src/integrations/tests/mongo.spec.ts +19 -19
- package/src/integrations/tests/rest.spec.ts +38 -22
- package/src/migrations/functions/backfill/app/tables.ts +7 -13
- package/src/migrations/functions/backfill/global.ts +1 -1
- package/src/migrations/functions/{quotas1.ts → syncQuotas.ts} +3 -8
- package/src/migrations/functions/tests/{quotas1.spec.js → syncQuotas.spec.js} +5 -2
- package/src/migrations/functions/usageQuotas/syncApps.ts +0 -1
- package/src/migrations/functions/usageQuotas/syncPlugins.ts +10 -0
- package/src/migrations/functions/usageQuotas/syncRows.ts +15 -6
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +9 -1
- package/src/migrations/index.ts +20 -45
- package/src/migrations/tests/index.spec.ts +0 -1
- package/src/sdk/app/backups/constants.ts +2 -0
- package/src/sdk/app/backups/exports.ts +171 -0
- package/src/sdk/app/backups/imports.ts +169 -0
- package/src/sdk/app/backups/index.ts +9 -0
- package/src/sdk/app/backups/statistics.ts +78 -0
- package/src/sdk/app/tables/index.ts +61 -0
- package/src/sdk/index.ts +13 -0
- package/src/tests/utilities/TestConfiguration.js +5 -2
- package/src/threads/automation.ts +20 -27
- package/src/utilities/csvParser.js +1 -0
- package/src/utilities/fileSystem/index.js +2 -119
- package/src/utilities/fileSystem/utilities.js +2 -0
- package/src/utilities/rowProcessor/index.js +5 -0
- package/src/utilities/usageQuota/rows.js +7 -3
- package/coverage/lcov-report/api/controllers/backup.js.html +0 -142
- package/coverage/lcov-report/api/routes/backup.js.html +0 -115
- package/dist/automations/listeners.js +0 -102
- package/src/api/routes/backup.js +0 -10
- package/src/automations/listeners.ts +0 -78
- package/src/migrations/functions/pluginCount.ts +0 -12
|
@@ -12,15 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.TableSaveFunctions = exports.hasTypeChanged = exports.areSwitchableTypes = exports.foreignKeyStructure = exports.generateJunctionTableName = exports.generateForeignKey = exports.checkForViewUpdates = exports.
|
|
15
|
+
exports.TableSaveFunctions = exports.hasTypeChanged = exports.areSwitchableTypes = exports.foreignKeyStructure = exports.generateJunctionTableName = exports.generateForeignKey = exports.checkForViewUpdates = exports.checkStaticTables = exports.handleSearchIndexes = exports.handleDataImport = exports.makeSureTableUpToDate = exports.checkForColumnUpdates = exports.clearColumns = void 0;
|
|
16
16
|
const csvParser_1 = require("../../../utilities/csvParser");
|
|
17
17
|
const utils_1 = require("../../../db/utils");
|
|
18
18
|
const lodash_1 = require("lodash");
|
|
19
19
|
const constants_1 = require("../../../constants");
|
|
20
20
|
const rowProcessor_1 = require("../../../utilities/rowProcessor");
|
|
21
21
|
const constants_2 = require("../../../constants");
|
|
22
|
-
const utils_2 = require("
|
|
23
|
-
const utils_3 = require("../view/utils");
|
|
22
|
+
const utils_2 = require("../view/utils");
|
|
24
23
|
const viewBuilder_1 = __importDefault(require("../view/viewBuilder"));
|
|
25
24
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
26
25
|
const fp_1 = require("lodash/fp");
|
|
@@ -130,7 +129,9 @@ function handleDataImport(user, table, dataImport) {
|
|
|
130
129
|
}
|
|
131
130
|
finalData.push(row);
|
|
132
131
|
}
|
|
133
|
-
yield pro_1.quotas.addRows(finalData.length, () => db.bulkDocs(finalData)
|
|
132
|
+
yield pro_1.quotas.addRows(finalData.length, () => db.bulkDocs(finalData), {
|
|
133
|
+
tableId: table._id,
|
|
134
|
+
});
|
|
134
135
|
yield backend_core_1.events.rows.imported(table, "csv", finalData.length);
|
|
135
136
|
return table;
|
|
136
137
|
});
|
|
@@ -228,52 +229,9 @@ class TableSaveFunctions {
|
|
|
228
229
|
return this.rows;
|
|
229
230
|
}
|
|
230
231
|
}
|
|
231
|
-
function getAllInternalTables() {
|
|
232
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
-
const db = getAppDB();
|
|
234
|
-
const internalTables = yield db.allDocs((0, utils_1.getTableParams)(null, {
|
|
235
|
-
include_docs: true,
|
|
236
|
-
}));
|
|
237
|
-
return internalTables.rows.map((tableDoc) => (Object.assign(Object.assign({}, tableDoc.doc), { type: "internal", sourceId: utils_1.BudibaseInternalDB._id })));
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
exports.getAllInternalTables = getAllInternalTables;
|
|
241
|
-
function getAllExternalTables(datasourceId) {
|
|
242
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
-
const db = getAppDB();
|
|
244
|
-
const datasource = yield db.get(datasourceId);
|
|
245
|
-
if (!datasource || !datasource.entities) {
|
|
246
|
-
throw "Datasource is not configured fully.";
|
|
247
|
-
}
|
|
248
|
-
return datasource.entities;
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
exports.getAllExternalTables = getAllExternalTables;
|
|
252
|
-
function getExternalTable(datasourceId, tableName) {
|
|
253
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
254
|
-
const entities = yield getAllExternalTables(datasourceId);
|
|
255
|
-
return entities[tableName];
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
exports.getExternalTable = getExternalTable;
|
|
259
|
-
function getTable(tableId) {
|
|
260
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
-
const db = getAppDB();
|
|
262
|
-
if ((0, utils_2.isExternalTable)(tableId)) {
|
|
263
|
-
let { datasourceId, tableName } = (0, utils_2.breakExternalTableId)(tableId);
|
|
264
|
-
const datasource = yield db.get(datasourceId);
|
|
265
|
-
const table = yield getExternalTable(datasourceId, tableName);
|
|
266
|
-
return Object.assign(Object.assign({}, table), { sql: (0, utils_2.isSQL)(datasource) });
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
return db.get(tableId);
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
exports.getTable = getTable;
|
|
274
232
|
function checkForViewUpdates(table, rename, deletedColumns) {
|
|
275
233
|
return __awaiter(this, void 0, void 0, function* () {
|
|
276
|
-
const views = yield (0,
|
|
234
|
+
const views = yield (0, utils_2.getViews)();
|
|
277
235
|
const tableViews = views.filter(view => view.meta.tableId === table._id);
|
|
278
236
|
// Check each table view to see if impacted by this table action
|
|
279
237
|
for (let view of tableViews) {
|
|
@@ -329,7 +287,7 @@ function checkForViewUpdates(table, rename, deletedColumns) {
|
|
|
329
287
|
// Update view if required
|
|
330
288
|
if (needsUpdated) {
|
|
331
289
|
const newViewTemplate = (0, viewBuilder_1.default)(view.meta);
|
|
332
|
-
yield (0,
|
|
290
|
+
yield (0, utils_2.saveView)(null, view.name, newViewTemplate);
|
|
333
291
|
if (!newViewTemplate.meta.schema) {
|
|
334
292
|
newViewTemplate.meta.schema = table.schema;
|
|
335
293
|
}
|
|
@@ -24,12 +24,12 @@ const { apiFileReturn } = require("../../../utilities/fileSystem");
|
|
|
24
24
|
const exporters = require("./exporters");
|
|
25
25
|
const { saveView, getView, getViews, deleteView } = require("./utils");
|
|
26
26
|
const { fetchView } = require("../row");
|
|
27
|
-
const { getTable } = require("../table/utils");
|
|
28
27
|
const { FieldTypes } = require("../../../constants");
|
|
29
28
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
30
29
|
const { events } = require("@budibase/backend-core");
|
|
31
30
|
const { DocumentType } = require("../../../db/utils");
|
|
32
31
|
const { cloneDeep, isEqual } = require("lodash");
|
|
32
|
+
const sdk = require("../../../sdk");
|
|
33
33
|
exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
34
|
ctx.body = yield getViews();
|
|
35
35
|
});
|
|
@@ -137,7 +137,7 @@ exports.exportView = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
137
137
|
let rows = ctx.body;
|
|
138
138
|
let schema = view && view.meta && view.meta.schema;
|
|
139
139
|
const tableId = ctx.params.tableId || view.meta.tableId;
|
|
140
|
-
const table = yield getTable(tableId);
|
|
140
|
+
const table = yield sdk.tables.getTable(tableId);
|
|
141
141
|
if (!schema) {
|
|
142
142
|
schema = table.schema;
|
|
143
143
|
}
|
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const router_1 = __importDefault(require("@koa/router"));
|
|
30
|
+
const controller = __importStar(require("../controllers/backup"));
|
|
31
|
+
const authorized_1 = __importDefault(require("../../middleware/authorized"));
|
|
32
|
+
const permissions_1 = require("@budibase/backend-core/permissions");
|
|
33
|
+
const router = new router_1.default();
|
|
34
|
+
router.get("/api/backups/export", (0, authorized_1.default)(permissions_1.BUILDER), controller.exportAppDump);
|
|
35
|
+
exports.default = router;
|
package/dist/api/routes/index.js
CHANGED
|
@@ -31,11 +31,16 @@ const dev_1 = __importDefault(require("./dev"));
|
|
|
31
31
|
const cloud_1 = __importDefault(require("./cloud"));
|
|
32
32
|
const migrations_1 = __importDefault(require("./migrations"));
|
|
33
33
|
const plugin_1 = __importDefault(require("./plugin"));
|
|
34
|
+
const pro_1 = require("@budibase/pro");
|
|
34
35
|
var static_1 = require("./static");
|
|
35
36
|
Object.defineProperty(exports, "staticRoutes", { enumerable: true, get: function () { return __importDefault(static_1).default; } });
|
|
36
37
|
var public_1 = require("./public");
|
|
37
38
|
Object.defineProperty(exports, "publicRoutes", { enumerable: true, get: function () { return __importDefault(public_1).default; } });
|
|
39
|
+
const appBackupRoutes = pro_1.api.appBackups;
|
|
40
|
+
const scheduleRoutes = pro_1.api.schedules;
|
|
38
41
|
exports.mainRoutes = [
|
|
42
|
+
appBackupRoutes,
|
|
43
|
+
backup_1.default,
|
|
39
44
|
auth_1.default,
|
|
40
45
|
deploy_1.default,
|
|
41
46
|
layout_1.default,
|
|
@@ -55,14 +60,14 @@ exports.mainRoutes = [
|
|
|
55
60
|
permission_1.default,
|
|
56
61
|
datasource_1.default,
|
|
57
62
|
query_1.default,
|
|
58
|
-
backup_1.default,
|
|
59
63
|
metadata_1.default,
|
|
60
64
|
dev_1.default,
|
|
61
65
|
cloud_1.default,
|
|
62
|
-
// these need to be handled last as they still use /api/:tableId
|
|
63
|
-
// this could be breaking as koa may recognise other routes as this
|
|
64
|
-
table_1.default,
|
|
65
66
|
row_1.default,
|
|
66
67
|
migrations_1.default,
|
|
67
68
|
plugin_1.default,
|
|
69
|
+
scheduleRoutes,
|
|
70
|
+
// these need to be handled last as they still use /api/:tableId
|
|
71
|
+
// this could be breaking as koa may recognise other routes as this
|
|
72
|
+
table_1.default,
|
|
68
73
|
];
|
package/dist/app.js
CHANGED
|
@@ -67,6 +67,8 @@ const backend_core_1 = require("@budibase/backend-core");
|
|
|
67
67
|
const workerRequests_1 = require("./utilities/workerRequests");
|
|
68
68
|
const watch_1 = require("./watch");
|
|
69
69
|
const websocket_1 = require("./websocket");
|
|
70
|
+
const sdk_1 = __importDefault(require("./sdk"));
|
|
71
|
+
const pro = __importStar(require("@budibase/pro"));
|
|
70
72
|
const app = new Koa();
|
|
71
73
|
// set up top level koa middleware
|
|
72
74
|
app.use(koaBody({
|
|
@@ -118,6 +120,17 @@ server.on("close", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
118
120
|
process.exit(errCode);
|
|
119
121
|
}
|
|
120
122
|
}));
|
|
123
|
+
const initPro = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
+
yield pro.init({
|
|
125
|
+
backups: {
|
|
126
|
+
processing: {
|
|
127
|
+
exportAppFn: sdk_1.default.backups.exportApp,
|
|
128
|
+
importAppFn: sdk_1.default.backups.importApp,
|
|
129
|
+
statsFn: sdk_1.default.backups.calculateBackupStats,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
});
|
|
121
134
|
module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
122
135
|
var _a;
|
|
123
136
|
console.log(`Budibase running on ${JSON.stringify(server.address())}`);
|
|
@@ -125,6 +138,7 @@ module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, vo
|
|
|
125
138
|
eventEmitter.emitPort(env.PORT);
|
|
126
139
|
fileSystem.init();
|
|
127
140
|
yield redis_1.default.init();
|
|
141
|
+
yield initPro();
|
|
128
142
|
// run migrations on startup if not done via http
|
|
129
143
|
// not recommended in a clustered environment
|
|
130
144
|
if (!env.HTTP_MIGRATIONS && !env.isTest()) {
|
|
@@ -8,8 +8,8 @@ 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 { getTable } = require("../api/controllers/table/utils");
|
|
12
11
|
const { findHBSBlocks, decodeJSBinding, isJSBinding, encodeJSBinding, } = require("@budibase/string-templates");
|
|
12
|
+
const sdk = require("../sdk");
|
|
13
13
|
/**
|
|
14
14
|
* When values are input to the system generally they will be of type string as this is required for template strings.
|
|
15
15
|
* This can generate some odd scenarios as the Schema of the automation requires a number but the builder might supply
|
|
@@ -67,7 +67,7 @@ exports.cleanInputValues = (inputs, schema) => {
|
|
|
67
67
|
* @returns {Promise<Object>} The cleaned up rows object, will should now have all the required primitive types.
|
|
68
68
|
*/
|
|
69
69
|
exports.cleanUpRow = (tableId, row) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
-
let table = yield getTable(tableId);
|
|
70
|
+
let table = yield sdk.tables.getTable(tableId);
|
|
71
71
|
return exports.cleanInputValues(row, { properties: table.schema });
|
|
72
72
|
});
|
|
73
73
|
exports.getError = err => {
|
|
@@ -11,34 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
const { createBullBoard } = require("@bull-board/api");
|
|
12
12
|
const { BullAdapter } = require("@bull-board/api/bullAdapter");
|
|
13
13
|
const { KoaAdapter } = require("@bull-board/koa");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
: require("bull");
|
|
18
|
-
const { JobQueues } = require("../constants");
|
|
19
|
-
const { utils } = require("@budibase/backend-core/redis");
|
|
20
|
-
const { opts, redisProtocolUrl } = utils.getRedisOptions();
|
|
21
|
-
const listeners = require("./listeners");
|
|
22
|
-
const CLEANUP_PERIOD_MS = 60 * 1000;
|
|
23
|
-
const queueConfig = redisProtocolUrl || { redis: opts };
|
|
24
|
-
let cleanupInternal = null;
|
|
25
|
-
let automationQueue = new Queue(JobQueues.AUTOMATIONS, queueConfig);
|
|
26
|
-
listeners.addListeners(automationQueue);
|
|
27
|
-
function cleanup() {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
yield automationQueue.clean(CLEANUP_PERIOD_MS, "completed");
|
|
30
|
-
});
|
|
31
|
-
}
|
|
14
|
+
const { queue } = require("@budibase/backend-core");
|
|
15
|
+
const automation = require("../threads/automation");
|
|
16
|
+
let automationQueue = queue.createQueue(queue.JobQueue.AUTOMATION, automation.removeStalled);
|
|
32
17
|
const PATH_PREFIX = "/bulladmin";
|
|
33
18
|
exports.init = () => {
|
|
34
|
-
// cleanup the events every 5 minutes
|
|
35
|
-
if (!cleanupInternal) {
|
|
36
|
-
cleanupInternal = setInterval(cleanup, CLEANUP_PERIOD_MS);
|
|
37
|
-
// fire off an initial cleanup
|
|
38
|
-
cleanup().catch(err => {
|
|
39
|
-
console.error(`Unable to cleanup automation queue initially - ${err}`);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
19
|
// Set up queues for bull board admin
|
|
43
20
|
const queues = [automationQueue];
|
|
44
21
|
const adapters = [];
|
|
@@ -54,11 +31,6 @@ exports.init = () => {
|
|
|
54
31
|
return serverAdapter.registerPlugin();
|
|
55
32
|
};
|
|
56
33
|
exports.shutdown = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
-
|
|
58
|
-
clearInterval(cleanupInternal);
|
|
59
|
-
yield automationQueue.close();
|
|
60
|
-
automationQueue = null;
|
|
61
|
-
}
|
|
62
|
-
console.log("Bull shutdown");
|
|
34
|
+
yield queue.shutdown();
|
|
63
35
|
});
|
|
64
|
-
exports.
|
|
36
|
+
exports.automationQueue = automationQueue;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const { processEvent } = require("./utils");
|
|
12
|
-
const {
|
|
12
|
+
const { automationQueue, shutdown } = require("./bullboard");
|
|
13
13
|
const { TRIGGER_DEFINITIONS, rebootTrigger } = require("./triggers");
|
|
14
14
|
const { ACTION_DEFINITIONS } = require("./actions");
|
|
15
15
|
/**
|
|
@@ -18,7 +18,7 @@ const { ACTION_DEFINITIONS } = require("./actions");
|
|
|
18
18
|
exports.init = function () {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
// this promise will not complete
|
|
21
|
-
const promise =
|
|
21
|
+
const promise = automationQueue.process((job) => __awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
yield processEvent(job);
|
|
23
23
|
}));
|
|
24
24
|
// on init we need to trigger any reboot automations
|
|
@@ -27,11 +27,11 @@ exports.init = function () {
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
exports.getQueues = () => {
|
|
30
|
-
return [
|
|
30
|
+
return [automationQueue];
|
|
31
31
|
};
|
|
32
32
|
exports.shutdown = () => {
|
|
33
33
|
return shutdown();
|
|
34
34
|
};
|
|
35
|
-
exports.
|
|
35
|
+
exports.automationQueue = automationQueue;
|
|
36
36
|
exports.TRIGGER_DEFINITIONS = TRIGGER_DEFINITIONS;
|
|
37
37
|
exports.ACTION_DEFINITIONS = ACTION_DEFINITIONS;
|
|
@@ -74,9 +74,9 @@ exports.run = function ({ inputs, appId, emitter }) {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
const tableId = inputs.row.tableId;
|
|
77
|
-
// clear any
|
|
77
|
+
// clear any undefined, null or empty string properties so that they aren't updated
|
|
78
78
|
for (let propKey of Object.keys(inputs.row)) {
|
|
79
|
-
if (
|
|
79
|
+
if (inputs.row[propKey] == null || inputs.row[propKey] === "") {
|
|
80
80
|
delete inputs.row[propKey];
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -14,7 +14,7 @@ const { coerce } = require("../utilities/rowProcessor");
|
|
|
14
14
|
const { definitions } = require("./triggerInfo");
|
|
15
15
|
const { isDevAppID } = require("../db/utils");
|
|
16
16
|
// need this to call directly, so we can get a response
|
|
17
|
-
const {
|
|
17
|
+
const { automationQueue } = require("./bullboard");
|
|
18
18
|
const { checkTestFlag } = require("../utilities/redis");
|
|
19
19
|
const utils = require("./utils");
|
|
20
20
|
const env = require("../environment");
|
|
@@ -57,7 +57,7 @@ function queueRelevantRowAutomations(event, eventType) {
|
|
|
57
57
|
}
|
|
58
58
|
if (automationTrigger.inputs &&
|
|
59
59
|
automationTrigger.inputs.tableId === event.row.tableId) {
|
|
60
|
-
yield
|
|
60
|
+
yield automationQueue.add({ automation, event }, JOB_OPTS);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
}));
|
|
@@ -110,7 +110,7 @@ exports.externalTrigger = function (automation, params, { getResponses } = {}) {
|
|
|
110
110
|
return utils.processEvent({ data });
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
113
|
-
return
|
|
113
|
+
return automationQueue.add(data, JOB_OPTS);
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
};
|
|
@@ -136,7 +136,7 @@ exports.rebootTrigger = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
136
136
|
timestamp: Date.now(),
|
|
137
137
|
},
|
|
138
138
|
};
|
|
139
|
-
rebootEvents.push(
|
|
139
|
+
rebootEvents.push(automationQueue.add(job, JOB_OPTS));
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
yield Promise.all(rebootEvents);
|
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.isErrorInOutput = exports.isRecurring = exports.cleanupAutomations = exports.checkForWebhooks = exports.enableCronTrigger = exports.isRebootTrigger = exports.isCronTrigger = exports.clearMetadata = exports.
|
|
38
|
+
exports.isErrorInOutput = exports.isRecurring = exports.cleanupAutomations = exports.checkForWebhooks = exports.enableCronTrigger = exports.isRebootTrigger = exports.isCronTrigger = exports.clearMetadata = exports.disableCronById = exports.disableAllCrons = exports.removeDeprecated = exports.updateTestHistory = exports.processEvent = void 0;
|
|
39
39
|
const threads_1 = require("../threads");
|
|
40
40
|
const triggerInfo_1 = require("./triggerInfo");
|
|
41
41
|
const webhooks = __importStar(require("../api/controllers/webhook"));
|
|
@@ -59,12 +59,14 @@ const jobMessage = (job, message) => {
|
|
|
59
59
|
function processEvent(job) {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
61
|
try {
|
|
62
|
+
const automationId = job.data.automation._id;
|
|
62
63
|
console.log(jobMessage(job, "running"));
|
|
63
64
|
// need to actually await these so that an error can be captured properly
|
|
64
|
-
|
|
65
|
-
return yield backend_core_1.tenancy.doInTenant(tenantId, () => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
return yield backend_core_1.context.doInContext(job.data.event.appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
66
66
|
const runFn = () => Runner.run(job);
|
|
67
|
-
return pro_1.quotas.addAutomation(runFn
|
|
67
|
+
return pro_1.quotas.addAutomation(runFn, {
|
|
68
|
+
automationId,
|
|
69
|
+
});
|
|
68
70
|
}));
|
|
69
71
|
}
|
|
70
72
|
catch (err) {
|
|
@@ -106,12 +108,12 @@ exports.removeDeprecated = removeDeprecated;
|
|
|
106
108
|
function disableAllCrons(appId) {
|
|
107
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
110
|
const promises = [];
|
|
109
|
-
const jobs = yield bullboard_1.
|
|
111
|
+
const jobs = yield bullboard_1.automationQueue.getRepeatableJobs();
|
|
110
112
|
for (let job of jobs) {
|
|
111
113
|
if (job.key.includes(`${appId}_cron`)) {
|
|
112
|
-
promises.push(bullboard_1.
|
|
114
|
+
promises.push(bullboard_1.automationQueue.removeRepeatableByKey(job.key));
|
|
113
115
|
if (job.id) {
|
|
114
|
-
promises.push(bullboard_1.
|
|
116
|
+
promises.push(bullboard_1.automationQueue.removeJobs(job.id));
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
}
|
|
@@ -119,14 +121,18 @@ function disableAllCrons(appId) {
|
|
|
119
121
|
});
|
|
120
122
|
}
|
|
121
123
|
exports.disableAllCrons = disableAllCrons;
|
|
122
|
-
function
|
|
124
|
+
function disableCronById(jobId) {
|
|
123
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
yield bullboard_1.
|
|
125
|
-
|
|
126
|
+
const repeatJobs = yield bullboard_1.automationQueue.getRepeatableJobs();
|
|
127
|
+
for (let repeatJob of repeatJobs) {
|
|
128
|
+
if (repeatJob.id === jobId) {
|
|
129
|
+
yield bullboard_1.automationQueue.removeRepeatableByKey(repeatJob.key);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
126
132
|
console.log(`jobId=${jobId} disabled`);
|
|
127
133
|
});
|
|
128
134
|
}
|
|
129
|
-
exports.
|
|
135
|
+
exports.disableCronById = disableCronById;
|
|
130
136
|
function clearMetadata() {
|
|
131
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
138
|
const db = (0, context_1.getProdAppDB)();
|
|
@@ -165,7 +171,7 @@ function enableCronTrigger(appId, automation) {
|
|
|
165
171
|
(trigger === null || trigger === void 0 ? void 0 : trigger.inputs.cron)) {
|
|
166
172
|
// make a job id rather than letting Bull decide, makes it easier to handle on way out
|
|
167
173
|
const jobId = `${appId}_cron_${(0, newid_1.default)()}`;
|
|
168
|
-
const job = yield bullboard_1.
|
|
174
|
+
const job = yield bullboard_1.automationQueue.add({
|
|
169
175
|
automation,
|
|
170
176
|
event: { appId, timestamp: Date.now() },
|
|
171
177
|
}, { repeat: { cron: trigger.inputs.cron }, jobId });
|
package/dist/constants/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
3
3
|
const { UserStatus } = require("@budibase/backend-core/constants");
|
|
4
|
-
const {
|
|
5
|
-
exports.JobQueues = {
|
|
6
|
-
AUTOMATIONS: "automationQueue",
|
|
7
|
-
};
|
|
4
|
+
const { objectStore } = require("@budibase/backend-core");
|
|
8
5
|
const FilterTypes = {
|
|
9
6
|
STRING: "string",
|
|
10
7
|
FUZZY: "fuzzy",
|
|
@@ -28,6 +25,7 @@ exports.NoEmptyFilterStrings = [
|
|
|
28
25
|
];
|
|
29
26
|
exports.FieldTypes = {
|
|
30
27
|
STRING: "string",
|
|
28
|
+
BARCODEQR: "barcodeqr",
|
|
31
29
|
LONGFORM: "longform",
|
|
32
30
|
OPTIONS: "options",
|
|
33
31
|
NUMBER: "number",
|
|
@@ -47,6 +45,7 @@ exports.CanSwitchTypes = [
|
|
|
47
45
|
exports.FieldTypes.STRING,
|
|
48
46
|
exports.FieldTypes.OPTIONS,
|
|
49
47
|
exports.FieldTypes.LONGFORM,
|
|
48
|
+
exports.FieldTypes.BARCODEQR,
|
|
50
49
|
],
|
|
51
50
|
[exports.FieldTypes.BOOLEAN, exports.FieldTypes.NUMBER],
|
|
52
51
|
];
|
|
@@ -186,5 +185,5 @@ exports.AutomationErrors = {
|
|
|
186
185
|
FAILURE_CONDITION: "FAILURE_CONDITION_MET",
|
|
187
186
|
};
|
|
188
187
|
// pass through the list from the auth/core lib
|
|
189
|
-
exports.ObjectStoreBuckets = ObjectStoreBuckets;
|
|
188
|
+
exports.ObjectStoreBuckets = objectStore.ObjectStoreBuckets;
|
|
190
189
|
exports.MAX_AUTOMATION_RECURRING_ERRORS = 5;
|
package/dist/db/utils.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const newid = require("./newid");
|
|
3
|
-
const { DocumentType:
|
|
3
|
+
const { DocumentType: CoreDocType, InternalTable, getRoleParams, generateRoleID, APP_DEV_PREFIX, APP_PREFIX, SEPARATOR, StaticDatabases, isDevAppID, isProdAppID, getDevelopmentAppID, generateAppID, getQueryIndex, ViewName, getDocParams, getRowParams, generateRowID, getUserMetadataParams, generateUserMetadataID, getGlobalIDFromUserMetadataID, } = require("@budibase/backend-core/db");
|
|
4
4
|
const UNICODE_MAX = "\ufff0";
|
|
5
5
|
const AppStatus = {
|
|
6
6
|
DEV: "development",
|
|
7
7
|
ALL: "all",
|
|
8
8
|
DEPLOYED: "published",
|
|
9
9
|
};
|
|
10
|
-
const DocumentType =
|
|
11
|
-
const InternalTables = {
|
|
12
|
-
USER_METADATA: "ta_users",
|
|
13
|
-
};
|
|
10
|
+
const DocumentType = CoreDocType;
|
|
14
11
|
const SearchIndexes = {
|
|
15
12
|
ROWS: "rows",
|
|
16
13
|
};
|
|
@@ -26,11 +23,11 @@ exports.APP_PREFIX = APP_PREFIX;
|
|
|
26
23
|
exports.APP_DEV_PREFIX = APP_DEV_PREFIX;
|
|
27
24
|
exports.isDevAppID = isDevAppID;
|
|
28
25
|
exports.isProdAppID = isProdAppID;
|
|
29
|
-
exports.USER_METDATA_PREFIX = `${DocumentType.ROW}${SEPARATOR}${
|
|
30
|
-
exports.LINK_USER_METADATA_PREFIX = `${DocumentType.LINK}${SEPARATOR}${
|
|
26
|
+
exports.USER_METDATA_PREFIX = `${DocumentType.ROW}${SEPARATOR}${InternalTable.USER_METADATA}${SEPARATOR}`;
|
|
27
|
+
exports.LINK_USER_METADATA_PREFIX = `${DocumentType.LINK}${SEPARATOR}${InternalTable.USER_METADATA}${SEPARATOR}`;
|
|
31
28
|
exports.TABLE_ROW_PREFIX = `${DocumentType.ROW}${SEPARATOR}${DocumentType.TABLE}`;
|
|
32
29
|
exports.ViewName = ViewName;
|
|
33
|
-
exports.InternalTables =
|
|
30
|
+
exports.InternalTables = InternalTable;
|
|
34
31
|
exports.DocumentType = DocumentType;
|
|
35
32
|
exports.SEPARATOR = SEPARATOR;
|
|
36
33
|
exports.UNICODE_MAX = UNICODE_MAX;
|
|
@@ -42,25 +39,12 @@ exports.generateDevAppID = getDevelopmentAppID;
|
|
|
42
39
|
exports.generateRoleID = generateRoleID;
|
|
43
40
|
exports.getRoleParams = getRoleParams;
|
|
44
41
|
exports.getQueryIndex = getQueryIndex;
|
|
45
|
-
/**
|
|
46
|
-
* If creating DB allDocs/query params with only a single top level ID this can be used, this
|
|
47
|
-
* is usually the case as most of our docs are top level e.g. tables, automations, users and so on.
|
|
48
|
-
* More complex cases such as link docs and rows which have multiple levels of IDs that their
|
|
49
|
-
* ID consists of need their own functions to build the allDocs parameters.
|
|
50
|
-
* @param {string} docType The type of document which input params are being built for, e.g. user,
|
|
51
|
-
* link, app, table and so on.
|
|
52
|
-
* @param {string|null} docId The ID of the document minus its type - this is only needed if looking
|
|
53
|
-
* for a singular document.
|
|
54
|
-
* @param {object} otherProps Add any other properties onto the request, e.g. include_docs.
|
|
55
|
-
* @returns {object} Parameters which can then be used with an allDocs request.
|
|
56
|
-
*/
|
|
57
|
-
function getDocParams(docType, docId = null, otherProps = {}) {
|
|
58
|
-
if (docId == null) {
|
|
59
|
-
docId = "";
|
|
60
|
-
}
|
|
61
|
-
return Object.assign(Object.assign({}, otherProps), { startkey: `${docType}${SEPARATOR}${docId}`, endkey: `${docType}${SEPARATOR}${docId}${UNICODE_MAX}` });
|
|
62
|
-
}
|
|
63
42
|
exports.getDocParams = getDocParams;
|
|
43
|
+
exports.getRowParams = getRowParams;
|
|
44
|
+
exports.generateRowID = generateRowID;
|
|
45
|
+
exports.getUserMetadataParams = getUserMetadataParams;
|
|
46
|
+
exports.generateUserMetadataID = generateUserMetadataID;
|
|
47
|
+
exports.getGlobalIDFromUserMetadataID = getGlobalIDFromUserMetadataID;
|
|
64
48
|
/**
|
|
65
49
|
* Gets parameters for retrieving tables, this is a utility function for the getDocParams function.
|
|
66
50
|
*/
|
|
@@ -74,21 +58,6 @@ exports.getTableParams = (tableId = null, otherProps = {}) => {
|
|
|
74
58
|
exports.generateTableID = () => {
|
|
75
59
|
return `${DocumentType.TABLE}${SEPARATOR}${newid()}`;
|
|
76
60
|
};
|
|
77
|
-
/**
|
|
78
|
-
* Gets the DB allDocs/query params for retrieving a row.
|
|
79
|
-
* @param {string|null} tableId The table in which the rows have been stored.
|
|
80
|
-
* @param {string|null} rowId The ID of the row which is being specifically queried for. This can be
|
|
81
|
-
* left null to get all the rows in the table.
|
|
82
|
-
* @param {object} otherProps Any other properties to add to the request.
|
|
83
|
-
* @returns {object} Parameters which can then be used with an allDocs request.
|
|
84
|
-
*/
|
|
85
|
-
exports.getRowParams = (tableId = null, rowId = null, otherProps = {}) => {
|
|
86
|
-
if (tableId == null) {
|
|
87
|
-
return getDocParams(DocumentType.ROW, null, otherProps);
|
|
88
|
-
}
|
|
89
|
-
const endOfKey = rowId == null ? `${tableId}${SEPARATOR}` : rowId;
|
|
90
|
-
return getDocParams(DocumentType.ROW, endOfKey, otherProps);
|
|
91
|
-
};
|
|
92
61
|
/**
|
|
93
62
|
* Given a row ID this will find the table ID within it (only works for internal tables).
|
|
94
63
|
* @param {string} rowId The ID of the row.
|
|
@@ -100,40 +69,6 @@ exports.getTableIDFromRowID = rowId => {
|
|
|
100
69
|
.split(SEPARATOR);
|
|
101
70
|
return `${DocumentType.TABLE}${SEPARATOR}${components[0]}`;
|
|
102
71
|
};
|
|
103
|
-
/**
|
|
104
|
-
* Gets a new row ID for the specified table.
|
|
105
|
-
* @param {string} tableId The table which the row is being created for.
|
|
106
|
-
* @param {string|null} id If an ID is to be used then the UUID can be substituted for this.
|
|
107
|
-
* @returns {string} The new ID which a row doc can be stored under.
|
|
108
|
-
*/
|
|
109
|
-
exports.generateRowID = (tableId, id = null) => {
|
|
110
|
-
id = id || newid();
|
|
111
|
-
return `${DocumentType.ROW}${SEPARATOR}${tableId}${SEPARATOR}${id}`;
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* Gets parameters for retrieving users, this is a utility function for the getDocParams function.
|
|
115
|
-
*/
|
|
116
|
-
exports.getUserMetadataParams = (userId = null, otherProps = {}) => {
|
|
117
|
-
return exports.getRowParams(InternalTables.USER_METADATA, userId, otherProps);
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Generates a new user ID based on the passed in global ID.
|
|
121
|
-
* @param {string} globalId The ID of the global user.
|
|
122
|
-
* @returns {string} The new user ID which the user doc can be stored under.
|
|
123
|
-
*/
|
|
124
|
-
exports.generateUserMetadataID = globalId => {
|
|
125
|
-
return exports.generateRowID(InternalTables.USER_METADATA, globalId);
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* Breaks up the ID to get the global ID.
|
|
129
|
-
*/
|
|
130
|
-
exports.getGlobalIDFromUserMetadataID = id => {
|
|
131
|
-
const prefix = `${DocumentType.ROW}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}`;
|
|
132
|
-
if (!id || !id.includes(prefix)) {
|
|
133
|
-
return id;
|
|
134
|
-
}
|
|
135
|
-
return id.split(prefix)[1];
|
|
136
|
-
};
|
|
137
72
|
/**
|
|
138
73
|
* Gets parameters for retrieving automations, this is a utility function for the getDocParams function.
|
|
139
74
|
*/
|
package/dist/index.js
CHANGED