@budibase/server 1.0.199 → 1.0.200-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/Dockerfile +2 -0
- package/builder/assets/index.a5a0faf2.js +1315 -0
- package/builder/index.html +1 -1
- package/coverage/clover.xml +2089 -2001
- package/coverage/coverage-final.json +121 -122
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
- package/coverage/lcov-report/api/controllers/automation.js.html +174 -72
- package/coverage/lcov-report/api/controllers/backup.js.html +30 -6
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -11
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +53 -41
- package/coverage/lcov-report/api/controllers/dev.js.html +94 -70
- package/coverage/lcov-report/api/controllers/index.html +57 -72
- package/coverage/lcov-report/api/controllers/integration.js.html +8 -8
- package/coverage/lcov-report/api/controllers/layout.js.html +28 -19
- package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
- package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
- package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
- package/coverage/lcov-report/api/controllers/role.js.html +78 -48
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +19 -19
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +54 -54
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
- package/coverage/lcov-report/api/controllers/row/utils.js.html +24 -24
- package/coverage/lcov-report/api/controllers/screen.js.html +56 -20
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +49 -49
- package/coverage/lcov-report/api/controllers/table/external.js.html +23 -17
- package/coverage/lcov-report/api/controllers/table/index.html +26 -26
- package/coverage/lcov-report/api/controllers/table/index.js.html +85 -49
- package/coverage/lcov-report/api/controllers/templates.js.html +6 -6
- package/coverage/lcov-report/api/controllers/user.js.html +19 -19
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +11 -11
- package/coverage/lcov-report/api/controllers/view/index.html +21 -21
- package/coverage/lcov-report/api/controllers/view/index.js.html +275 -65
- package/coverage/lcov-report/api/controllers/view/utils.js.html +23 -23
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +40 -40
- package/coverage/lcov-report/api/controllers/webhook.js.html +17 -17
- package/coverage/lcov-report/api/index.html +15 -15
- package/coverage/lcov-report/api/index.js.html +39 -45
- package/coverage/lcov-report/api/routes/analytics.js.html +7 -13
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +11 -11
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +9 -9
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +13 -13
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
- package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
- package/coverage/lcov-report/api/routes/permission.js.html +9 -9
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +9 -9
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/screen.js.html +9 -9
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +10 -10
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +8 -8
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +36 -36
- package/coverage/lcov-report/api/routes/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +9 -9
- package/coverage/lcov-report/automations/actions.js.html +25 -25
- package/coverage/lcov-report/automations/automationUtils.js.html +8 -8
- package/coverage/lcov-report/automations/bullboard.js.html +35 -35
- package/coverage/lcov-report/automations/index.html +29 -29
- package/coverage/lcov-report/automations/index.js.html +29 -17
- package/coverage/lcov-report/automations/steps/bash.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/loop.js.html +2 -2
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +18 -18
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +30 -30
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/inMemoryView.js.html +5 -5
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +9 -9
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +17 -17
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +19 -19
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +81 -81
- 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 +7 -7
- package/coverage/lcov-report/events/utils.js.html +10 -10
- package/coverage/lcov-report/index.html +74 -74
- 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 +5 -5
- package/coverage/lcov-report/middleware/builder.js.html +20 -20
- package/coverage/lcov-report/middleware/currentapp.js.html +49 -49
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
- package/coverage/lcov-report/middleware/publicApi.js.html +5 -5
- package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +4 -4
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +1 -1
- package/coverage/lcov-report/threads/query.js.html +1 -1
- package/coverage/lcov-report/threads/utils.js.html +13 -13
- package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -3
- package/coverage/lcov-report/utilities/centralPath.js.html +14 -14
- package/coverage/lcov-report/utilities/csvParser.js.html +34 -34
- package/coverage/lcov-report/utilities/global.js.html +28 -28
- package/coverage/lcov-report/utilities/index.html +25 -25
- package/coverage/lcov-report/utilities/index.js.html +41 -41
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +18 -18
- package/coverage/lcov-report/utilities/queue/index.html +15 -15
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +59 -59
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +15 -15
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +30 -30
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +7 -7
- package/coverage/lcov-report/utilities/workerRequests.js.html +29 -29
- package/coverage/lcov.info +2903 -2762
- package/dist/api/controllers/analytics.js +7 -30
- package/dist/api/controllers/application.js +56 -16
- package/dist/api/controllers/automation.js +31 -2
- package/dist/api/controllers/backup.js +7 -0
- package/dist/api/controllers/datasource.js +8 -2
- package/dist/api/controllers/deploy/index.js +6 -2
- package/dist/api/controllers/dev.js +9 -2
- package/dist/api/controllers/layout.js +3 -0
- package/dist/api/controllers/query/import/index.js +12 -2
- package/dist/api/controllers/query/import/sources/curl.js +3 -0
- package/dist/api/controllers/query/import/sources/openapi2.js +3 -0
- package/dist/api/controllers/query/import/sources/openapi3.js +3 -0
- package/dist/api/controllers/query/index.js +16 -2
- package/dist/api/controllers/role.js +11 -0
- package/dist/api/controllers/screen.js +10 -1
- package/dist/api/controllers/static/index.js +29 -15
- package/dist/api/controllers/table/external.js +2 -0
- package/dist/api/controllers/table/index.js +12 -0
- package/dist/api/controllers/table/utils.js +3 -3
- package/dist/api/controllers/view/index.js +62 -6
- package/dist/api/index.js +2 -4
- package/dist/api/routes/analytics.js +1 -3
- package/dist/app.js +16 -8
- package/dist/automations/index.js +4 -0
- package/dist/environment.js +4 -2
- package/dist/migrations/functions/backfill/app/automations.js +31 -0
- package/dist/migrations/functions/backfill/app/datasources.js +28 -0
- package/dist/migrations/functions/backfill/app/layouts.js +33 -0
- package/dist/migrations/functions/backfill/app/queries.js +32 -0
- package/dist/migrations/functions/backfill/app/roles.js +28 -0
- package/dist/migrations/functions/backfill/app/screens.js +28 -0
- package/dist/migrations/functions/backfill/app/tables.js +40 -0
- package/dist/migrations/functions/backfill/app.js +175 -0
- package/dist/migrations/functions/backfill/global/configs.js +61 -0
- package/dist/migrations/functions/backfill/global/quotas.js +60 -0
- package/dist/migrations/functions/backfill/global/users.js +50 -0
- package/dist/migrations/functions/backfill/global.js +189 -0
- package/dist/migrations/functions/backfill/index.js +32 -0
- package/dist/migrations/functions/backfill/installation.js +81 -0
- package/dist/migrations/index.js +95 -31
- package/dist/migrations/tests/helpers.js +72 -0
- package/dist/migrations/tests/structures.js +37 -0
- package/dist/package.json +79 -69
- package/dist/tests/utilities/TestConfiguration.js +121 -93
- package/dist/tests/utilities/structures.js +45 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/nodemon.json +1 -1
- package/package.json +80 -70
- package/scripts/dev/manage.js +2 -0
- package/scripts/jestSetup.js +7 -0
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/analytics.ts +8 -0
- package/src/api/controllers/application.ts +60 -18
- package/src/api/controllers/automation.js +36 -2
- package/src/api/controllers/backup.js +8 -0
- package/src/api/controllers/datasource.js +8 -4
- package/src/api/controllers/deploy/index.ts +6 -2
- package/src/api/controllers/dev.js +10 -2
- package/src/api/controllers/layout.js +3 -0
- package/src/api/controllers/query/import/index.ts +16 -3
- package/src/api/controllers/query/import/sources/base/index.ts +2 -1
- package/src/api/controllers/query/import/sources/curl.ts +4 -0
- package/src/api/controllers/query/import/sources/openapi2.ts +4 -0
- package/src/api/controllers/query/import/sources/openapi3.ts +4 -0
- package/src/api/controllers/query/import/tests/index.spec.js +20 -7
- package/src/api/controllers/query/index.ts +16 -3
- package/src/api/controllers/role.js +10 -0
- package/src/api/controllers/screen.js +13 -1
- package/src/api/controllers/static/index.js +28 -15
- package/src/api/controllers/table/external.js +2 -0
- package/src/api/controllers/table/index.js +12 -0
- package/src/api/controllers/table/utils.ts +4 -4
- package/src/api/controllers/view/index.js +76 -6
- package/src/api/index.js +2 -4
- package/src/api/routes/analytics.js +1 -3
- package/src/api/routes/public/utils/Endpoint.ts +1 -1
- package/src/api/routes/tests/__snapshots__/datasource.spec.js.snap +5 -1
- package/src/api/routes/tests/application.spec.js +64 -4
- package/src/api/routes/tests/automation.spec.js +168 -60
- package/src/api/routes/tests/backup.spec.js +2 -0
- package/src/api/routes/tests/data/export.txt +1 -0
- package/src/api/routes/tests/datasource.spec.js +5 -0
- package/src/api/routes/tests/deployment.spec.js +25 -0
- package/src/api/routes/tests/dev.spec.js +40 -0
- package/src/api/routes/tests/layout.spec.js +4 -0
- package/src/api/routes/tests/query.spec.js +56 -13
- package/src/api/routes/tests/role.spec.js +40 -7
- package/src/api/routes/tests/row.spec.js +2 -3
- package/src/api/routes/tests/screen.spec.js +30 -4
- package/src/api/routes/tests/static.spec.js +120 -54
- package/src/api/routes/tests/table.spec.js +102 -38
- package/src/api/routes/tests/view.spec.js +222 -43
- package/src/app.ts +18 -9
- package/src/automations/index.js +4 -0
- package/src/automations/tests/delay.spec.js +4 -0
- package/src/environment.js +5 -2
- package/src/migrations/functions/backfill/app/automations.ts +26 -0
- package/src/migrations/functions/backfill/app/datasources.ts +22 -0
- package/src/migrations/functions/backfill/app/layouts.ts +29 -0
- package/src/migrations/functions/backfill/app/queries.ts +33 -0
- package/src/migrations/functions/backfill/app/roles.ts +22 -0
- package/src/migrations/functions/backfill/app/screens.ts +22 -0
- package/src/migrations/functions/backfill/app/tables.ts +36 -0
- package/src/migrations/functions/backfill/app.ts +148 -0
- package/src/migrations/functions/backfill/global/configs.ts +66 -0
- package/src/migrations/functions/backfill/global/quotas.ts +60 -0
- package/src/migrations/functions/backfill/global/users.ts +49 -0
- package/src/migrations/functions/backfill/global.ts +194 -0
- package/src/migrations/functions/backfill/index.ts +7 -0
- package/src/migrations/functions/backfill/installation.ts +51 -0
- package/src/migrations/index.ts +120 -51
- package/src/migrations/tests/helpers.ts +40 -0
- package/src/migrations/tests/index.spec.ts +132 -0
- package/src/migrations/tests/structures.ts +66 -0
- package/src/module.d.ts +0 -1
- package/src/tests/utilities/TestConfiguration.js +138 -90
- package/src/tests/utilities/structures.js +71 -0
- package/tsconfig.build.json +20 -5
- package/tsconfig.json +22 -17
- package/builder/assets/index.107ba2e5.js +0 -1315
- package/coverage/lcov-report/api/controllers/analytics.js.html +0 -202
- package/src/api/controllers/analytics.js +0 -39
|
@@ -19,10 +19,11 @@ const env = require("../../../environment");
|
|
|
19
19
|
const { clientLibraryPath } = require("../../../utilities");
|
|
20
20
|
const { upload } = require("../../../utilities/fileSystem");
|
|
21
21
|
const { attachmentsRelativeURL } = require("../../../utilities");
|
|
22
|
-
const { DocumentTypes } = require("../../../db/utils");
|
|
22
|
+
const { DocumentTypes, isDevAppID } = require("../../../db/utils");
|
|
23
23
|
const { getAppDB, getAppId } = require("@budibase/backend-core/context");
|
|
24
24
|
const AWS = require("aws-sdk");
|
|
25
25
|
const AWS_REGION = env.AWS_REGION ? env.AWS_REGION : "eu-west-1";
|
|
26
|
+
const { events } = require("@budibase/backend-core");
|
|
26
27
|
function prepareUpload({ s3Key, bucket, metadata, file }) {
|
|
27
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
29
|
const response = yield upload({
|
|
@@ -46,6 +47,7 @@ exports.serveBuilder = function (ctx) {
|
|
|
46
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
48
|
let builderPath = resolve(TOP_LEVEL_PATH, "builder");
|
|
48
49
|
yield send(ctx, ctx.file, { root: builderPath });
|
|
50
|
+
yield events.serve.servedBuilder();
|
|
49
51
|
});
|
|
50
52
|
};
|
|
51
53
|
exports.uploadFile = function (ctx) {
|
|
@@ -68,23 +70,35 @@ exports.uploadFile = function (ctx) {
|
|
|
68
70
|
};
|
|
69
71
|
exports.serveApp = function (ctx) {
|
|
70
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const App = require("./templates/BudibaseApp.svelte").default;
|
|
72
73
|
const db = getAppDB({ skip_setup: true });
|
|
73
74
|
const appInfo = yield db.get(DocumentTypes.APP_METADATA);
|
|
74
75
|
let appId = getAppId();
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
body
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
if (!env.isJest()) {
|
|
77
|
+
const App = require("./templates/BudibaseApp.svelte").default;
|
|
78
|
+
const { head, html, css } = App.render({
|
|
79
|
+
title: appInfo.name,
|
|
80
|
+
production: env.isProd(),
|
|
81
|
+
appId,
|
|
82
|
+
clientLibPath: clientLibraryPath(appId, appInfo.version),
|
|
83
|
+
});
|
|
84
|
+
const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`);
|
|
85
|
+
ctx.body = yield processString(appHbs, {
|
|
86
|
+
head,
|
|
87
|
+
body: html,
|
|
88
|
+
style: css.code,
|
|
89
|
+
appId,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// just return the app info for jest to assert on
|
|
94
|
+
ctx.body = appInfo;
|
|
95
|
+
}
|
|
96
|
+
if (isDevAppID(appInfo.appId)) {
|
|
97
|
+
yield events.serve.servedAppPreview(appInfo);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
yield events.serve.servedApp(appInfo);
|
|
101
|
+
}
|
|
88
102
|
});
|
|
89
103
|
};
|
|
90
104
|
exports.serveClientLibrary = function (ctx) {
|
|
@@ -16,6 +16,7 @@ const { cloneDeep } = require("lodash/fp");
|
|
|
16
16
|
const csvParser = require("../../../utilities/csvParser");
|
|
17
17
|
const { handleRequest } = require("../row/external");
|
|
18
18
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
19
|
+
const { events } = require("@budibase/backend-core");
|
|
19
20
|
function makeTableRequest(datasource, operation, table, tables, oldTable = null, renamed = null) {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
const json = {
|
|
@@ -247,6 +248,7 @@ exports.bulkImport = function (ctx) {
|
|
|
247
248
|
yield handleRequest(DataSourceOperation.BULK_CREATE, table._id, {
|
|
248
249
|
rows,
|
|
249
250
|
});
|
|
251
|
+
yield events.rows.imported(table, "csv", rows.length);
|
|
250
252
|
return table;
|
|
251
253
|
});
|
|
252
254
|
};
|
|
@@ -15,6 +15,7 @@ const { isExternalTable, isSQL } = require("../../../integrations/utils");
|
|
|
15
15
|
const { getDatasourceParams } = require("../../../db/utils");
|
|
16
16
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
17
17
|
const { getTable, getAllInternalTables } = require("./utils");
|
|
18
|
+
const { events } = require("@budibase/backend-core");
|
|
18
19
|
function pickApi({ tableId, table }) {
|
|
19
20
|
if (table && !tableId) {
|
|
20
21
|
tableId = table._id;
|
|
@@ -57,7 +58,17 @@ exports.save = function (ctx) {
|
|
|
57
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
59
|
const appId = ctx.appId;
|
|
59
60
|
const table = ctx.request.body;
|
|
61
|
+
const importFormat = table.dataImport && table.dataImport.csvString ? "csv" : undefined;
|
|
60
62
|
const savedTable = yield pickApi({ table }).save(ctx);
|
|
63
|
+
if (!table._id) {
|
|
64
|
+
yield events.table.created(savedTable);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
yield events.table.updated(savedTable);
|
|
68
|
+
}
|
|
69
|
+
if (importFormat) {
|
|
70
|
+
yield events.table.imported(savedTable, importFormat);
|
|
71
|
+
}
|
|
61
72
|
ctx.status = 200;
|
|
62
73
|
ctx.message = `Table ${table.name} saved successfully.`;
|
|
63
74
|
ctx.eventEmitter &&
|
|
@@ -70,6 +81,7 @@ exports.destroy = function (ctx) {
|
|
|
70
81
|
const appId = ctx.appId;
|
|
71
82
|
const tableId = ctx.params.tableId;
|
|
72
83
|
const deletedTable = yield pickApi({ tableId }).destroy(ctx);
|
|
84
|
+
yield events.table.deleted(deletedTable);
|
|
73
85
|
ctx.eventEmitter &&
|
|
74
86
|
ctx.eventEmitter.emitTable(`table:delete`, appId, deletedTable);
|
|
75
87
|
ctx.status = 200;
|
|
@@ -25,6 +25,7 @@ const viewBuilder_1 = __importDefault(require("../view/viewBuilder"));
|
|
|
25
25
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
26
26
|
const fp_1 = require("lodash/fp");
|
|
27
27
|
const pro_1 = require("@budibase/pro");
|
|
28
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
28
29
|
function clearColumns(table, columnNames) {
|
|
29
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
31
|
const db = getAppDB();
|
|
@@ -130,8 +131,7 @@ function handleDataImport(user, table, dataImport) {
|
|
|
130
131
|
finalData.push(row);
|
|
131
132
|
}
|
|
132
133
|
yield pro_1.quotas.addRows(finalData.length, () => db.bulkDocs(finalData));
|
|
133
|
-
|
|
134
|
-
table._rev = response._rev;
|
|
134
|
+
yield backend_core_1.events.rows.imported(table, "csv", finalData.length);
|
|
135
135
|
return table;
|
|
136
136
|
});
|
|
137
137
|
}
|
|
@@ -220,7 +220,7 @@ class TableSaveFunctions {
|
|
|
220
220
|
after(table) {
|
|
221
221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
222
222
|
table = yield handleSearchIndexes(table);
|
|
223
|
-
|
|
223
|
+
yield handleDataImport(this.user, table, this.dataImport);
|
|
224
224
|
return table;
|
|
225
225
|
});
|
|
226
226
|
}
|
|
@@ -27,6 +27,9 @@ const { fetchView } = require("../row");
|
|
|
27
27
|
const { getTable } = require("../table/utils");
|
|
28
28
|
const { FieldTypes } = require("../../../constants");
|
|
29
29
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
30
|
+
const { events } = require("@budibase/backend-core");
|
|
31
|
+
const { DocumentTypes } = require("../../../db/utils");
|
|
32
|
+
const { cloneDeep, isEqual } = require("lodash");
|
|
30
33
|
exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
34
|
ctx.body = yield getViews();
|
|
32
35
|
});
|
|
@@ -34,24 +37,70 @@ exports.save = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
34
37
|
const db = getAppDB();
|
|
35
38
|
const _a = ctx.request.body, { originalName } = _a, viewToSave = __rest(_a, ["originalName"]);
|
|
36
39
|
const view = viewTemplate(viewToSave);
|
|
37
|
-
|
|
40
|
+
const viewName = viewToSave.name;
|
|
41
|
+
if (!viewName) {
|
|
38
42
|
ctx.throw(400, "Cannot create view without a name");
|
|
39
43
|
}
|
|
40
|
-
yield saveView(originalName,
|
|
44
|
+
yield saveView(originalName, viewName, view);
|
|
41
45
|
// add views to table document
|
|
42
|
-
const
|
|
46
|
+
const existingTable = yield db.get(ctx.request.body.tableId);
|
|
47
|
+
const table = cloneDeep(existingTable);
|
|
43
48
|
if (!table.views)
|
|
44
49
|
table.views = {};
|
|
45
50
|
if (!view.meta.schema) {
|
|
46
51
|
view.meta.schema = table.schema;
|
|
47
52
|
}
|
|
48
|
-
table.views[
|
|
53
|
+
table.views[viewName] = view.meta;
|
|
49
54
|
if (originalName) {
|
|
50
55
|
delete table.views[originalName];
|
|
56
|
+
existingTable.views[viewName] = existingTable.views[originalName];
|
|
51
57
|
}
|
|
52
58
|
yield db.put(table);
|
|
59
|
+
yield handleViewEvents(existingTable.views[viewName], table.views[viewName]);
|
|
53
60
|
ctx.body = Object.assign(Object.assign({}, table.views[viewToSave.name]), { name: viewToSave.name });
|
|
54
61
|
});
|
|
62
|
+
const calculationEvents = (existingView, newView) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
const existingCalculation = existingView && existingView.calculation;
|
|
64
|
+
const newCalculation = newView && newView.calculation;
|
|
65
|
+
if (existingCalculation && !newCalculation) {
|
|
66
|
+
yield events.view.calculationDeleted(existingView);
|
|
67
|
+
}
|
|
68
|
+
if (!existingCalculation && newCalculation) {
|
|
69
|
+
yield events.view.calculationCreated(newView);
|
|
70
|
+
}
|
|
71
|
+
if (existingCalculation &&
|
|
72
|
+
newCalculation &&
|
|
73
|
+
existingCalculation !== newCalculation) {
|
|
74
|
+
yield events.view.calculationUpdated(newView);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const filterEvents = (existingView, newView) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
const hasExistingFilters = !!(existingView &&
|
|
79
|
+
existingView.filters &&
|
|
80
|
+
existingView.filters.length);
|
|
81
|
+
const hasNewFilters = !!(newView && newView.filters && newView.filters.length);
|
|
82
|
+
if (hasExistingFilters && !hasNewFilters) {
|
|
83
|
+
yield events.view.filterDeleted(newView);
|
|
84
|
+
}
|
|
85
|
+
if (!hasExistingFilters && hasNewFilters) {
|
|
86
|
+
yield events.view.filterCreated(newView);
|
|
87
|
+
}
|
|
88
|
+
if (hasExistingFilters &&
|
|
89
|
+
hasNewFilters &&
|
|
90
|
+
!isEqual(existingView.filters, newView.filters)) {
|
|
91
|
+
yield events.view.filterUpdated(newView);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const handleViewEvents = (existingView, newView) => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
if (!existingView) {
|
|
96
|
+
yield events.view.created(newView);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
yield events.view.updated(newView);
|
|
100
|
+
}
|
|
101
|
+
yield calculationEvents(existingView, newView);
|
|
102
|
+
yield filterEvents(existingView, newView);
|
|
103
|
+
});
|
|
55
104
|
exports.destroy = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
105
|
const db = getAppDB();
|
|
57
106
|
const viewName = decodeURI(ctx.params.viewName);
|
|
@@ -59,6 +108,7 @@ exports.destroy = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
59
108
|
const table = yield db.get(view.meta.tableId);
|
|
60
109
|
delete table.views[viewName];
|
|
61
110
|
yield db.put(table);
|
|
111
|
+
yield events.view.deleted(view);
|
|
62
112
|
ctx.body = view;
|
|
63
113
|
});
|
|
64
114
|
exports.exportView = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -86,9 +136,9 @@ exports.exportView = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
86
136
|
yield fetchView(ctx);
|
|
87
137
|
let rows = ctx.body;
|
|
88
138
|
let schema = view && view.meta && view.meta.schema;
|
|
139
|
+
const tableId = ctx.params.tableId || view.meta.tableId;
|
|
140
|
+
const table = yield getTable(tableId);
|
|
89
141
|
if (!schema) {
|
|
90
|
-
const tableId = ctx.params.tableId || view.meta.tableId;
|
|
91
|
-
const table = yield getTable(tableId);
|
|
92
142
|
schema = table.schema;
|
|
93
143
|
}
|
|
94
144
|
// remove any relationships
|
|
@@ -120,4 +170,10 @@ exports.exportView = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
120
170
|
// send down the file
|
|
121
171
|
ctx.attachment(filename);
|
|
122
172
|
ctx.body = apiFileReturn(exporter(headers, rows));
|
|
173
|
+
if (viewName.startsWith(DocumentTypes.TABLE)) {
|
|
174
|
+
yield events.table.exported(table, format);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
yield events.view.exported(table, format);
|
|
178
|
+
}
|
|
123
179
|
});
|
package/dist/api/index.js
CHANGED
|
@@ -68,10 +68,8 @@ router.use((ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
68
68
|
validationErrors: err.validation,
|
|
69
69
|
error,
|
|
70
70
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
console.trace(err);
|
|
74
|
-
}
|
|
71
|
+
ctx.log.error(err);
|
|
72
|
+
console.trace(err);
|
|
75
73
|
}
|
|
76
74
|
}));
|
|
77
75
|
// authenticated routes
|
|
@@ -2,7 +2,5 @@
|
|
|
2
2
|
const Router = require("@koa/router");
|
|
3
3
|
const controller = require("../controllers/analytics");
|
|
4
4
|
const router = Router();
|
|
5
|
-
router
|
|
6
|
-
.get("/api/bbtel", controller.isEnabled)
|
|
7
|
-
.post("/api/bbtel/ping", controller.endUserPing);
|
|
5
|
+
router.get("/api/bbtel", controller.isEnabled);
|
|
8
6
|
module.exports = router;
|
package/dist/app.js
CHANGED
|
@@ -53,6 +53,7 @@ const { logAlert } = require("@budibase/backend-core/logging");
|
|
|
53
53
|
const { Thread } = require("./threads");
|
|
54
54
|
const redis_1 = __importDefault(require("./utilities/redis"));
|
|
55
55
|
const migrations = __importStar(require("./migrations"));
|
|
56
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
56
57
|
const app = new Koa();
|
|
57
58
|
// set up top level koa middleware
|
|
58
59
|
app.use(koaBody({
|
|
@@ -103,6 +104,7 @@ server.on("close", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
103
104
|
}
|
|
104
105
|
yield automations.shutdown();
|
|
105
106
|
yield redis_1.default.shutdown();
|
|
107
|
+
yield backend_core_1.events.shutdown();
|
|
106
108
|
yield Thread.shutdown();
|
|
107
109
|
api.shutdown();
|
|
108
110
|
if (!env.isTest()) {
|
|
@@ -115,6 +117,20 @@ module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, vo
|
|
|
115
117
|
eventEmitter.emitPort(env.PORT);
|
|
116
118
|
fileSystem.init();
|
|
117
119
|
yield redis_1.default.init();
|
|
120
|
+
// run migrations on startup if not done via http
|
|
121
|
+
// not recommended in a clustered environment
|
|
122
|
+
if (!env.HTTP_MIGRATIONS && !env.isTest()) {
|
|
123
|
+
try {
|
|
124
|
+
yield migrations.migrate();
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
logAlert("Error performing migrations. Exiting.", e);
|
|
128
|
+
shutdown();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// check for version updates
|
|
132
|
+
yield backend_core_1.installation.checkInstallVersion();
|
|
133
|
+
// done last - this will never complete
|
|
118
134
|
yield automations.init();
|
|
119
135
|
}));
|
|
120
136
|
const shutdown = () => {
|
|
@@ -134,11 +150,3 @@ process.on("uncaughtException", err => {
|
|
|
134
150
|
process.on("SIGTERM", () => {
|
|
135
151
|
shutdown();
|
|
136
152
|
});
|
|
137
|
-
// run migrations on startup if not done via http
|
|
138
|
-
// not recommended in a clustered environment
|
|
139
|
-
if (!env.HTTP_MIGRATIONS) {
|
|
140
|
-
migrations.migrate().catch(err => {
|
|
141
|
-
logAlert("Error performing migrations. Exiting.", err);
|
|
142
|
-
shutdown();
|
|
143
|
-
});
|
|
144
|
-
}
|
|
@@ -10,6 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const { processEvent } = require("./utils");
|
|
12
12
|
const { queue, shutdown } = require("./bullboard");
|
|
13
|
+
const { TRIGGER_DEFINITIONS } = require("./triggers");
|
|
14
|
+
const { ACTION_DEFINITIONS } = require("./actions");
|
|
13
15
|
/**
|
|
14
16
|
* This module is built purely to kick off the worker farm and manage the inputs/outputs
|
|
15
17
|
*/
|
|
@@ -26,3 +28,5 @@ exports.shutdown = () => {
|
|
|
26
28
|
return shutdown();
|
|
27
29
|
};
|
|
28
30
|
exports.queue = queue;
|
|
31
|
+
exports.TRIGGER_DEFINITIONS = TRIGGER_DEFINITIONS;
|
|
32
|
+
exports.ACTION_DEFINITIONS = ACTION_DEFINITIONS;
|
package/dist/environment.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const { join } = require("path");
|
|
3
3
|
function isTest() {
|
|
4
|
+
return isCypress() || isJest();
|
|
5
|
+
}
|
|
6
|
+
function isJest() {
|
|
4
7
|
return (process.env.NODE_ENV === "jest" ||
|
|
5
|
-
process.env.NODE_ENV === "cypress" ||
|
|
6
8
|
(process.env.JEST_WORKER_ID != null &&
|
|
7
9
|
process.env.JEST_WORKER_ID !== "null"));
|
|
8
10
|
}
|
|
@@ -57,7 +59,6 @@ module.exports = {
|
|
|
57
59
|
AUTOMATION_MAX_ITERATIONS: process.env.AUTOMATION_MAX_ITERATIONS,
|
|
58
60
|
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
|
|
59
61
|
DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT,
|
|
60
|
-
POSTHOG_TOKEN: process.env.POSTHOG_TOKEN,
|
|
61
62
|
QUERY_THREAD_TIMEOUT: parseIntSafe(process.env.QUERY_THREAD_TIMEOUT),
|
|
62
63
|
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
|
63
64
|
// flags
|
|
@@ -74,6 +75,7 @@ module.exports = {
|
|
|
74
75
|
module.exports[key] = value;
|
|
75
76
|
},
|
|
76
77
|
isTest,
|
|
78
|
+
isJest,
|
|
77
79
|
isCypress,
|
|
78
80
|
isDev,
|
|
79
81
|
isProd: () => {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.backfill = void 0;
|
|
13
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
14
|
+
const utils_1 = require("../../../../db/utils");
|
|
15
|
+
const getAutomations = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const response = yield appDb.allDocs((0, utils_1.getAutomationParams)(null, {
|
|
17
|
+
include_docs: true,
|
|
18
|
+
}));
|
|
19
|
+
return response.rows.map((row) => row.doc);
|
|
20
|
+
});
|
|
21
|
+
const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const automations = yield getAutomations(appDb);
|
|
23
|
+
for (const automation of automations) {
|
|
24
|
+
yield backend_core_1.events.automation.created(automation, timestamp);
|
|
25
|
+
for (const step of automation.definition.steps) {
|
|
26
|
+
yield backend_core_1.events.automation.stepCreated(automation, step, timestamp);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return automations.length;
|
|
30
|
+
});
|
|
31
|
+
exports.backfill = backfill;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.backfill = void 0;
|
|
13
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
14
|
+
const utils_1 = require("../../../../db/utils");
|
|
15
|
+
const getDatasources = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const response = yield appDb.allDocs((0, utils_1.getDatasourceParams)(null, {
|
|
17
|
+
include_docs: true,
|
|
18
|
+
}));
|
|
19
|
+
return response.rows.map((row) => row.doc);
|
|
20
|
+
});
|
|
21
|
+
const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const datasources = yield getDatasources(appDb);
|
|
23
|
+
for (const datasource of datasources) {
|
|
24
|
+
yield backend_core_1.events.datasource.created(datasource, timestamp);
|
|
25
|
+
}
|
|
26
|
+
return datasources.length;
|
|
27
|
+
});
|
|
28
|
+
exports.backfill = backfill;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.backfill = void 0;
|
|
13
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
14
|
+
const utils_1 = require("../../../../db/utils");
|
|
15
|
+
const getLayouts = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const response = yield appDb.allDocs((0, utils_1.getLayoutParams)(null, {
|
|
17
|
+
include_docs: true,
|
|
18
|
+
}));
|
|
19
|
+
return response.rows.map((row) => row.doc);
|
|
20
|
+
});
|
|
21
|
+
const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const layouts = yield getLayouts(appDb);
|
|
23
|
+
for (const layout of layouts) {
|
|
24
|
+
// exclude default layouts
|
|
25
|
+
if (layout._id === "layout_private_master" ||
|
|
26
|
+
layout._id === "layout_public_master") {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
yield backend_core_1.events.layout.created(layout, timestamp);
|
|
30
|
+
}
|
|
31
|
+
return layouts.length;
|
|
32
|
+
});
|
|
33
|
+
exports.backfill = backfill;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.backfill = void 0;
|
|
13
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
14
|
+
const utils_1 = require("../../../../db/utils");
|
|
15
|
+
const getQueries = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const response = yield appDb.allDocs((0, utils_1.getQueryParams)(null, {
|
|
17
|
+
include_docs: true,
|
|
18
|
+
}));
|
|
19
|
+
return response.rows.map((row) => row.doc);
|
|
20
|
+
});
|
|
21
|
+
const getDatasource = (appDb, datasourceId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
return appDb.get(datasourceId);
|
|
23
|
+
});
|
|
24
|
+
const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
const queries = yield getQueries(appDb);
|
|
26
|
+
for (const query of queries) {
|
|
27
|
+
const datasource = yield getDatasource(appDb, query.datasourceId);
|
|
28
|
+
yield backend_core_1.events.query.created(datasource, query, timestamp);
|
|
29
|
+
}
|
|
30
|
+
return queries.length;
|
|
31
|
+
});
|
|
32
|
+
exports.backfill = backfill;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.backfill = void 0;
|
|
13
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
14
|
+
const utils_1 = require("../../../../db/utils");
|
|
15
|
+
const getRoles = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const response = yield appDb.allDocs((0, utils_1.getRoleParams)(null, {
|
|
17
|
+
include_docs: true,
|
|
18
|
+
}));
|
|
19
|
+
return response.rows.map((row) => row.doc);
|
|
20
|
+
});
|
|
21
|
+
const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const roles = yield getRoles(appDb);
|
|
23
|
+
for (const role of roles) {
|
|
24
|
+
yield backend_core_1.events.role.created(role, timestamp);
|
|
25
|
+
}
|
|
26
|
+
return roles.length;
|
|
27
|
+
});
|
|
28
|
+
exports.backfill = backfill;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.backfill = void 0;
|
|
13
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
14
|
+
const utils_1 = require("../../../../db/utils");
|
|
15
|
+
const getScreens = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const response = yield appDb.allDocs((0, utils_1.getScreenParams)(null, {
|
|
17
|
+
include_docs: true,
|
|
18
|
+
}));
|
|
19
|
+
return response.rows.map((row) => row.doc);
|
|
20
|
+
});
|
|
21
|
+
const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const screens = yield getScreens(appDb);
|
|
23
|
+
for (const screen of screens) {
|
|
24
|
+
yield backend_core_1.events.screen.created(screen, timestamp);
|
|
25
|
+
}
|
|
26
|
+
return screens.length;
|
|
27
|
+
});
|
|
28
|
+
exports.backfill = backfill;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.backfill = void 0;
|
|
13
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
14
|
+
const utils_1 = require("../../../../db/utils");
|
|
15
|
+
const getTables = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const response = yield appDb.allDocs((0, utils_1.getTableParams)(null, {
|
|
17
|
+
include_docs: true,
|
|
18
|
+
}));
|
|
19
|
+
return response.rows.map((row) => row.doc);
|
|
20
|
+
});
|
|
21
|
+
const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
var _a;
|
|
23
|
+
const tables = yield getTables(appDb);
|
|
24
|
+
for (const table of tables) {
|
|
25
|
+
yield backend_core_1.events.table.created(table, timestamp);
|
|
26
|
+
if (table.views) {
|
|
27
|
+
for (const view of Object.values(table.views)) {
|
|
28
|
+
yield backend_core_1.events.view.created(view, timestamp);
|
|
29
|
+
if (view.calculation) {
|
|
30
|
+
yield backend_core_1.events.view.calculationCreated(view, timestamp);
|
|
31
|
+
}
|
|
32
|
+
if ((_a = view.filters) === null || _a === void 0 ? void 0 : _a.length) {
|
|
33
|
+
yield backend_core_1.events.view.filterCreated(view, timestamp);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return tables.length;
|
|
39
|
+
});
|
|
40
|
+
exports.backfill = backfill;
|