@budibase/server 2.0.30-alpha.14 → 2.0.30-alpha.15
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/backups-default.8c011f1b.png +0 -0
- package/builder/assets/{index.acdbfe62.css → index.b15ffe95.css} +1 -1
- package/builder/assets/{index.099ad307.js → index.e50f636c.js} +320 -316
- package/builder/index.html +2 -2
- package/coverage/clover.xml +254 -313
- package/coverage/coverage-final.json +15 -17
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/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 +3 -3
- 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 +5 -5
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +5 -5
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +6 -18
- 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 +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +35 -308
- 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 +62 -62
- 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/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 +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- 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 +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 +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +451 -564
- package/dist/api/controllers/application.js +2 -5
- 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/static/index.js +2 -2
- 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 +2 -1
- package/dist/api/controllers/table/utils.js +4 -48
- 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/triggers.js +4 -4
- package/dist/automations/utils.js +13 -9
- package/dist/constants/index.js +2 -5
- package/dist/db/utils.js +10 -75
- package/dist/migrations/functions/backfill/app/tables.js +5 -8
- package/dist/package.json +11 -11
- 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/fileSystem/index.js +3 -95
- package/dist/utilities/fileSystem/utilities.js +2 -1
- package/package.json +12 -12
- package/src/api/controllers/application.ts +3 -10
- 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 -7
- package/src/api/controllers/static/index.ts +2 -2
- 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 +3 -7
- package/src/api/controllers/table/utils.ts +1 -52
- 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/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/triggers.js +4 -4
- package/src/automations/utils.ts +12 -8
- package/src/constants/index.js +2 -6
- package/src/db/utils.js +17 -108
- package/src/definitions/automations.ts +0 -12
- package/src/migrations/functions/backfill/app/tables.ts +6 -13
- 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 +168 -0
- package/src/sdk/app/backups/index.ts +9 -0
- package/src/sdk/app/backups/statistics.ts +77 -0
- package/src/sdk/app/tables/index.ts +60 -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/fileSystem/index.js +2 -119
- package/src/utilities/fileSystem/utilities.js +2 -0
- 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
|
@@ -38,6 +38,7 @@ const backend_core_2 = require("@budibase/backend-core");
|
|
|
38
38
|
const types_1 = require("@budibase/types");
|
|
39
39
|
const layouts_1 = require("../../constants/layouts");
|
|
40
40
|
const plugins_1 = require("../../utilities/plugins");
|
|
41
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
41
42
|
const URL_REGEX_SLASH = /\/|\\/g;
|
|
42
43
|
// utility function, need to do away with this
|
|
43
44
|
function getLayouts() {
|
|
@@ -125,11 +126,7 @@ function createInstance(template) {
|
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
else if (template && template.useTemplate === "true") {
|
|
128
|
-
|
|
129
|
-
const { ok } = yield db.load(yield (0, fileSystem_1.getTemplateStream)(template));
|
|
130
|
-
if (!ok) {
|
|
131
|
-
throw "Error loading database dump from template.";
|
|
132
|
-
}
|
|
129
|
+
yield sdk_1.default.backups.importApp(appId, db, template);
|
|
133
130
|
}
|
|
134
131
|
else {
|
|
135
132
|
// create the users table
|
|
@@ -8,22 +8,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
exports.exportAppDump =
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.exportAppDump = void 0;
|
|
16
|
+
const sdk_1 = __importDefault(require("../../sdk"));
|
|
17
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
18
|
+
const utils_1 = require("../../db/utils");
|
|
19
|
+
const utilities_1 = require("../../utilities");
|
|
20
|
+
function exportAppDump(ctx) {
|
|
16
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
22
|
let { appId, excludeRows } = ctx.query;
|
|
18
23
|
const appName = decodeURI(ctx.query.appname);
|
|
19
|
-
excludeRows = isQsTrue(excludeRows);
|
|
20
|
-
const backupIdentifier = `${appName}-export-${new Date().getTime()}.
|
|
24
|
+
excludeRows = (0, utilities_1.isQsTrue)(excludeRows);
|
|
25
|
+
const backupIdentifier = `${appName}-export-${new Date().getTime()}.tar.gz`;
|
|
21
26
|
ctx.attachment(backupIdentifier);
|
|
22
|
-
ctx.body = yield
|
|
23
|
-
yield context.doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const appDb = context.getAppDB();
|
|
25
|
-
const app = yield appDb.get(DocumentType.APP_METADATA);
|
|
26
|
-
yield events.app.exported(app);
|
|
27
|
+
ctx.body = yield sdk_1.default.backups.streamExportApp(appId, excludeRows);
|
|
28
|
+
yield backend_core_1.context.doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const appDb = backend_core_1.context.getAppDB();
|
|
30
|
+
const app = yield appDb.get(utils_1.DocumentType.APP_METADATA);
|
|
31
|
+
yield backend_core_1.events.app.exported(app);
|
|
27
32
|
}));
|
|
28
33
|
});
|
|
29
|
-
}
|
|
34
|
+
}
|
|
35
|
+
exports.exportAppDump = exportAppDump;
|
|
@@ -10,55 +10,57 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const env = require("../../environment");
|
|
12
12
|
const { getAllApps, getGlobalDBName } = require("@budibase/backend-core/db");
|
|
13
|
-
const { exportDB, sendTempFile, readFileSync, } = require("../../utilities/fileSystem");
|
|
14
|
-
const { stringToReadStream } = require("../../utilities");
|
|
15
13
|
const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
16
|
-
const {
|
|
14
|
+
const { streamFile } = require("../../utilities/fileSystem");
|
|
15
|
+
const { stringToReadStream } = require("../../utilities");
|
|
17
16
|
const { getDocParams, DocumentType, isDevAppID } = require("../../db/utils");
|
|
18
|
-
|
|
17
|
+
const { create } = require("./application");
|
|
18
|
+
const { join } = require("path");
|
|
19
|
+
const sdk = require("../../sdk");
|
|
20
|
+
function createApp(appName, appDirectory) {
|
|
19
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
22
|
const ctx = {
|
|
21
23
|
request: {
|
|
22
24
|
body: {
|
|
23
|
-
|
|
25
|
+
useTemplate: true,
|
|
24
26
|
name: appName,
|
|
25
27
|
},
|
|
28
|
+
files: {
|
|
29
|
+
templateFile: {
|
|
30
|
+
path: appDirectory,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
26
33
|
},
|
|
27
34
|
};
|
|
28
35
|
return create(ctx);
|
|
29
36
|
});
|
|
30
37
|
}
|
|
38
|
+
function getAllDocType(db, docType) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const response = yield db.allDocs(getDocParams(docType, null, {
|
|
41
|
+
include_docs: true,
|
|
42
|
+
}));
|
|
43
|
+
return response.rows.map(row => row.doc);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
31
46
|
exports.exportApps = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
47
|
if (env.SELF_HOSTED || !env.MULTI_TENANCY) {
|
|
33
48
|
ctx.throw(400, "Exporting only allowed in multi-tenant cloud environments.");
|
|
34
49
|
}
|
|
35
50
|
const apps = yield getAllApps({ all: true });
|
|
36
|
-
const globalDBString = yield exportDB(getGlobalDBName(), {
|
|
51
|
+
const globalDBString = yield sdk.backups.exportDB(getGlobalDBName(), {
|
|
37
52
|
filter: doc => !doc._id.startsWith(DocumentType.USER),
|
|
38
53
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (isDevAppID(appId)) {
|
|
47
|
-
allDBs[app.name] = yield exportDB(appId);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const filename = `cloud-export-${new Date().getTime()}.txt`;
|
|
54
|
+
// only export the dev apps as they will be the latest, the user can republish the apps
|
|
55
|
+
// in their self-hosted environment
|
|
56
|
+
let appMetadata = apps
|
|
57
|
+
.filter(app => isDevAppID(app.appId || app._id))
|
|
58
|
+
.map(app => ({ appId: app.appId || app._id, name: app.name }));
|
|
59
|
+
const tmpPath = yield sdk.backups.exportMultipleApps(appMetadata, globalDBString);
|
|
60
|
+
const filename = `cloud-export-${new Date().getTime()}.tar.gz`;
|
|
51
61
|
ctx.attachment(filename);
|
|
52
|
-
ctx.body =
|
|
62
|
+
ctx.body = streamFile(tmpPath);
|
|
53
63
|
});
|
|
54
|
-
function getAllDocType(db, docType) {
|
|
55
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
const response = yield db.allDocs(getDocParams(docType, null, {
|
|
57
|
-
include_docs: true,
|
|
58
|
-
}));
|
|
59
|
-
return response.rows.map(row => row.doc);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
64
|
function hasBeenImported() {
|
|
63
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
66
|
if (!env.SELF_HOSTED || env.MULTI_TENANCY) {
|
|
@@ -81,17 +83,18 @@ exports.importApps = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
81
83
|
if (beenImported || !ctx.request.files || !ctx.request.files.importFile) {
|
|
82
84
|
ctx.throw(400, "Import file is required and environment must be fresh to import apps.");
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
if (ctx.request.files.importFile.type !== "application/gzip") {
|
|
87
|
+
ctx.throw(400, "Import file must be a gzipped tarball.");
|
|
88
|
+
}
|
|
89
|
+
// initially get all the app databases out of the tarball
|
|
90
|
+
const tmpPath = sdk.backups.untarFile(ctx.request.files.importFile);
|
|
91
|
+
const globalDbImport = sdk.backups.getGlobalDBFile(tmpPath);
|
|
92
|
+
const appNames = sdk.backups.getListOfAppsInMulti(tmpPath);
|
|
90
93
|
const globalDb = getGlobalDB();
|
|
91
94
|
// load the global db first
|
|
92
95
|
yield globalDb.load(stringToReadStream(globalDbImport));
|
|
93
|
-
for (let
|
|
94
|
-
yield createApp(appName,
|
|
96
|
+
for (let appName of appNames) {
|
|
97
|
+
yield createApp(appName, join(tmpPath, appName));
|
|
95
98
|
}
|
|
96
99
|
// if there are any users make sure to remove them
|
|
97
100
|
let users = yield getAllDocType(globalDb, DocumentType.USER);
|
|
@@ -20,6 +20,8 @@ const utils_2 = require("../../../automations/utils");
|
|
|
20
20
|
const cache_1 = require("@budibase/backend-core/cache");
|
|
21
21
|
const context_1 = require("@budibase/backend-core/context");
|
|
22
22
|
const backend_core_1 = require("@budibase/backend-core");
|
|
23
|
+
const pro_1 = require("@budibase/pro");
|
|
24
|
+
const types_1 = require("@budibase/types");
|
|
23
25
|
// the max time we can wait for an invalidation to complete before considering it failed
|
|
24
26
|
const MAX_PENDING_TIME_MS = 30 * 60000;
|
|
25
27
|
const DeploymentStatus = {
|
|
@@ -87,13 +89,20 @@ function initDeployedApp(prodAppId) {
|
|
|
87
89
|
console.log("Enabled cron triggers for deployed app..");
|
|
88
90
|
});
|
|
89
91
|
}
|
|
90
|
-
function deployApp(deployment) {
|
|
92
|
+
function deployApp(deployment, userId) {
|
|
91
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
94
|
let replication;
|
|
93
95
|
try {
|
|
94
96
|
const appId = (0, context_1.getAppId)();
|
|
95
97
|
const devAppId = (0, db_1.getDevelopmentAppID)(appId);
|
|
96
98
|
const productionAppId = (0, db_1.getProdAppID)(appId);
|
|
99
|
+
// don't try this if feature isn't allowed, will error
|
|
100
|
+
if (yield pro_1.backups.isEnabled()) {
|
|
101
|
+
// trigger backup initially
|
|
102
|
+
yield pro_1.backups.triggerAppBackup(productionAppId, types_1.AppBackupTrigger.PUBLISH, {
|
|
103
|
+
createdBy: userId,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
97
106
|
const config = {
|
|
98
107
|
source: devAppId,
|
|
99
108
|
target: productionAppId,
|
|
@@ -195,7 +204,7 @@ const _deployApp = function (ctx) {
|
|
|
195
204
|
deployment = yield storeDeploymentHistory(deployment);
|
|
196
205
|
console.log("Stored deployment history");
|
|
197
206
|
console.log("Deploying app...");
|
|
198
|
-
let app = yield deployApp(deployment);
|
|
207
|
+
let app = yield deployApp(deployment, ctx.user._id);
|
|
199
208
|
yield backend_core_1.events.app.published(app);
|
|
200
209
|
ctx.body = deployment;
|
|
201
210
|
});
|
|
@@ -15,7 +15,7 @@ require("svelte/register");
|
|
|
15
15
|
const send = require("koa-send");
|
|
16
16
|
const { resolve, join } = require("../../../utilities/centralPath");
|
|
17
17
|
const uuid = require("uuid");
|
|
18
|
-
const { ObjectStoreBuckets } = require("../../../constants");
|
|
18
|
+
const { ObjectStoreBuckets, ATTACHMENT_DIR } = require("../../../constants");
|
|
19
19
|
const { processString } = require("@budibase/string-templates");
|
|
20
20
|
const { loadHandlebarsFile, NODE_MODULES_PATH, TOP_LEVEL_PATH, } = require("../../../utilities/fileSystem");
|
|
21
21
|
const env = require("../../../environment");
|
|
@@ -88,7 +88,7 @@ const uploadFile = function (ctx) {
|
|
|
88
88
|
const processedFileName = `${uuid.v4()}.${fileExtension}`;
|
|
89
89
|
return prepareUpload({
|
|
90
90
|
file,
|
|
91
|
-
s3Key: `${ctx.appId}
|
|
91
|
+
s3Key: `${ctx.appId}/${ATTACHMENT_DIR}/${processedFileName}`,
|
|
92
92
|
bucket: ObjectStoreBuckets.APPS,
|
|
93
93
|
});
|
|
94
94
|
}));
|
|
@@ -9,12 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const { FieldTypes, FormulaTypes } = require("../../../constants");
|
|
12
|
-
const {
|
|
12
|
+
const { clearColumns } = require("./utils");
|
|
13
13
|
const { doesContainStrings } = require("@budibase/string-templates");
|
|
14
14
|
const { cloneDeep } = require("lodash/fp");
|
|
15
15
|
const { isEqual, uniq } = require("lodash");
|
|
16
16
|
const { updateAllFormulasInTable } = require("../row/staticFormula");
|
|
17
17
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
18
|
+
const sdk = require("../../../sdk");
|
|
18
19
|
function isStaticFormula(column) {
|
|
19
20
|
return (column.type === FieldTypes.FORMULA &&
|
|
20
21
|
column.formulaType === FormulaTypes.STATIC);
|
|
@@ -46,7 +47,7 @@ function getFormulaThatUseColumn(table, columnNames) {
|
|
|
46
47
|
function checkIfFormulaNeedsCleared(table, { oldTable, deletion }) {
|
|
47
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
49
|
// start by retrieving all tables, remove the current table from the list
|
|
49
|
-
const tables = (yield getAllInternalTables()).filter(tbl => tbl._id !== table._id);
|
|
50
|
+
const tables = (yield sdk.tables.getAllInternalTables()).filter(tbl => tbl._id !== table._id);
|
|
50
51
|
const schemaToUse = oldTable ? oldTable.schema : table.schema;
|
|
51
52
|
let removedColumns = Object.values(schemaToUse).filter(column => deletion || !table.schema[column.name]);
|
|
52
53
|
// remove any formula columns that used related columns
|
|
@@ -96,7 +97,7 @@ function updateRelatedFormulaLinksOnTables(table, { deletion } = { deletion: fal
|
|
|
96
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
98
|
const db = getAppDB();
|
|
98
99
|
// start by retrieving all tables, remove the current table from the list
|
|
99
|
-
const tables = (yield getAllInternalTables()).filter(tbl => tbl._id !== table._id);
|
|
100
|
+
const tables = (yield sdk.tables.getAllInternalTables()).filter(tbl => tbl._id !== table._id);
|
|
100
101
|
// clone the tables, so we can compare at end
|
|
101
102
|
const initialTables = cloneDeep(tables);
|
|
102
103
|
// first find the related column names
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const { buildExternalTableId, breakExternalTableId, } = require("../../../integrations/utils");
|
|
12
|
-
const {
|
|
12
|
+
const { generateForeignKey, generateJunctionTableName, foreignKeyStructure, hasTypeChanged, } = require("./utils");
|
|
13
13
|
const { DataSourceOperation, FieldTypes, RelationshipTypes, } = require("../../../constants");
|
|
14
14
|
const { makeExternalQuery } = require("../../../integrations/base/query");
|
|
15
15
|
const { cloneDeep } = require("lodash/fp");
|
|
@@ -17,6 +17,7 @@ const csvParser = require("../../../utilities/csvParser");
|
|
|
17
17
|
const { handleRequest } = require("../row/external");
|
|
18
18
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
19
19
|
const { events } = require("@budibase/backend-core");
|
|
20
|
+
const sdk = require("../../../sdk");
|
|
20
21
|
function makeTableRequest(datasource, operation, table, tables, oldTable = null, renamed = null) {
|
|
21
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
23
|
const json = {
|
|
@@ -150,7 +151,7 @@ exports.save = function (ctx) {
|
|
|
150
151
|
let tableToSave = Object.assign({ type: "table", _id: buildExternalTableId(datasourceId, table.name) }, table);
|
|
151
152
|
let oldTable;
|
|
152
153
|
if (ctx.request.body && ctx.request.body._id) {
|
|
153
|
-
oldTable = yield getTable(ctx.request.body._id);
|
|
154
|
+
oldTable = yield sdk.tables.getTable(ctx.request.body._id);
|
|
154
155
|
}
|
|
155
156
|
if (hasTypeChanged(tableToSave, oldTable)) {
|
|
156
157
|
ctx.throw(400, "A column type has changed.");
|
|
@@ -221,7 +222,7 @@ exports.save = function (ctx) {
|
|
|
221
222
|
};
|
|
222
223
|
exports.destroy = function (ctx) {
|
|
223
224
|
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
-
const tableToDelete = yield getTable(ctx.params.tableId);
|
|
225
|
+
const tableToDelete = yield sdk.tables.getTable(ctx.params.tableId);
|
|
225
226
|
if (!tableToDelete || !tableToDelete.created) {
|
|
226
227
|
ctx.throw(400, "Cannot delete tables which weren't created in Budibase.");
|
|
227
228
|
}
|
|
@@ -239,7 +240,7 @@ exports.destroy = function (ctx) {
|
|
|
239
240
|
};
|
|
240
241
|
exports.bulkImport = function (ctx) {
|
|
241
242
|
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
-
const table = yield getTable(ctx.params.tableId);
|
|
243
|
+
const table = yield sdk.tables.getTable(ctx.params.tableId);
|
|
243
244
|
const { dataImport } = ctx.request.body;
|
|
244
245
|
if (!dataImport || !dataImport.schema || !dataImport.csvString) {
|
|
245
246
|
ctx.throw(400, "Provided data import information is invalid.");
|
|
@@ -14,8 +14,8 @@ const csvParser = require("../../../utilities/csvParser");
|
|
|
14
14
|
const { isExternalTable, isSQL } = require("../../../integrations/utils");
|
|
15
15
|
const { getDatasourceParams } = require("../../../db/utils");
|
|
16
16
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
17
|
-
const { getTable, getAllInternalTables } = require("./utils");
|
|
18
17
|
const { events } = require("@budibase/backend-core");
|
|
18
|
+
const sdk = require("../../../sdk");
|
|
19
19
|
function pickApi({ tableId, table }) {
|
|
20
20
|
if (table && !tableId) {
|
|
21
21
|
tableId = table._id;
|
|
@@ -32,7 +32,7 @@ function pickApi({ tableId, table }) {
|
|
|
32
32
|
exports.fetch = function (ctx) {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
const db = getAppDB();
|
|
35
|
-
const internal = yield getAllInternalTables();
|
|
35
|
+
const internal = yield sdk.tables.getAllInternalTables();
|
|
36
36
|
const externalTables = yield db.allDocs(getDatasourceParams("plus", {
|
|
37
37
|
include_docs: true,
|
|
38
38
|
}));
|
|
@@ -51,7 +51,7 @@ exports.fetch = function (ctx) {
|
|
|
51
51
|
exports.find = function (ctx) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
53
|
const tableId = ctx.params.tableId;
|
|
54
|
-
ctx.body = yield getTable(tableId);
|
|
54
|
+
ctx.body = yield sdk.tables.getTable(tableId);
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
57
|
exports.save = function (ctx) {
|
|
@@ -106,7 +106,7 @@ exports.validateCSVSchema = function (ctx) {
|
|
|
106
106
|
const { csvString, schema = {}, tableId } = ctx.request.body;
|
|
107
107
|
let existingTable;
|
|
108
108
|
if (tableId) {
|
|
109
|
-
existingTable = yield getTable(tableId);
|
|
109
|
+
existingTable = yield sdk.tables.getTable(tableId);
|
|
110
110
|
}
|
|
111
111
|
let result = yield csvParser.parse(csvString, schema);
|
|
112
112
|
if (existingTable) {
|
|
@@ -36,6 +36,7 @@ const pro_1 = require("@budibase/pro");
|
|
|
36
36
|
const lodash_1 = require("lodash");
|
|
37
37
|
const fp_1 = require("lodash/fp");
|
|
38
38
|
const environment_2 = __importDefault(require("../../../environment"));
|
|
39
|
+
const sdk_1 = __importDefault(require("../../../sdk"));
|
|
39
40
|
function checkAutoColumns(table, oldTable) {
|
|
40
41
|
if (!table.schema) {
|
|
41
42
|
return table;
|
|
@@ -184,7 +185,7 @@ function destroy(ctx) {
|
|
|
184
185
|
exports.destroy = destroy;
|
|
185
186
|
function bulkImport(ctx) {
|
|
186
187
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
const table = yield
|
|
188
|
+
const table = yield sdk_1.default.tables.getTable(ctx.params.tableId);
|
|
188
189
|
const { dataImport } = ctx.request.body;
|
|
189
190
|
yield (0, utils_2.handleDataImport)(ctx.user, table, dataImport);
|
|
190
191
|
return table;
|
|
@@ -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");
|
|
@@ -230,52 +229,9 @@ class TableSaveFunctions {
|
|
|
230
229
|
return this.rows;
|
|
231
230
|
}
|
|
232
231
|
}
|
|
233
|
-
function getAllInternalTables() {
|
|
234
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
-
const db = getAppDB();
|
|
236
|
-
const internalTables = yield db.allDocs((0, utils_1.getTableParams)(null, {
|
|
237
|
-
include_docs: true,
|
|
238
|
-
}));
|
|
239
|
-
return internalTables.rows.map((tableDoc) => (Object.assign(Object.assign({}, tableDoc.doc), { type: "internal", sourceId: utils_1.BudibaseInternalDB._id })));
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
exports.getAllInternalTables = getAllInternalTables;
|
|
243
|
-
function getAllExternalTables(datasourceId) {
|
|
244
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
-
const db = getAppDB();
|
|
246
|
-
const datasource = yield db.get(datasourceId);
|
|
247
|
-
if (!datasource || !datasource.entities) {
|
|
248
|
-
throw "Datasource is not configured fully.";
|
|
249
|
-
}
|
|
250
|
-
return datasource.entities;
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
exports.getAllExternalTables = getAllExternalTables;
|
|
254
|
-
function getExternalTable(datasourceId, tableName) {
|
|
255
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
-
const entities = yield getAllExternalTables(datasourceId);
|
|
257
|
-
return entities[tableName];
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
exports.getExternalTable = getExternalTable;
|
|
261
|
-
function getTable(tableId) {
|
|
262
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
-
const db = getAppDB();
|
|
264
|
-
if ((0, utils_2.isExternalTable)(tableId)) {
|
|
265
|
-
let { datasourceId, tableName } = (0, utils_2.breakExternalTableId)(tableId);
|
|
266
|
-
const datasource = yield db.get(datasourceId);
|
|
267
|
-
const table = yield getExternalTable(datasourceId, tableName);
|
|
268
|
-
return Object.assign(Object.assign({}, table), { sql: (0, utils_2.isSQL)(datasource) });
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
return db.get(tableId);
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
exports.getTable = getTable;
|
|
276
232
|
function checkForViewUpdates(table, rename, deletedColumns) {
|
|
277
233
|
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
-
const views = yield (0,
|
|
234
|
+
const views = yield (0, utils_2.getViews)();
|
|
279
235
|
const tableViews = views.filter(view => view.meta.tableId === table._id);
|
|
280
236
|
// Check each table view to see if impacted by this table action
|
|
281
237
|
for (let view of tableViews) {
|
|
@@ -331,7 +287,7 @@ function checkForViewUpdates(table, rename, deletedColumns) {
|
|
|
331
287
|
// Update view if required
|
|
332
288
|
if (needsUpdated) {
|
|
333
289
|
const newViewTemplate = (0, viewBuilder_1.default)(view.meta);
|
|
334
|
-
yield (0,
|
|
290
|
+
yield (0, utils_2.saveView)(null, view.name, newViewTemplate);
|
|
335
291
|
if (!newViewTemplate.meta.schema) {
|
|
336
292
|
newViewTemplate.meta.schema = table.schema;
|
|
337
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 => {
|