@budibase/server 1.0.200-alpha.3 → 1.0.200
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 +0 -2
- package/builder/assets/index.f83b3433.js +1315 -0
- package/builder/index.html +1 -1
- package/coverage/clover.xml +1998 -2086
- package/coverage/coverage-final.json +122 -121
- package/coverage/lcov-report/api/controllers/analytics.js.html +202 -0
- 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 +72 -174
- package/coverage/lcov-report/api/controllers/backup.js.html +6 -30
- 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 +41 -53
- package/coverage/lcov-report/api/controllers/dev.js.html +70 -94
- package/coverage/lcov-report/api/controllers/index.html +72 -57
- package/coverage/lcov-report/api/controllers/integration.js.html +8 -8
- package/coverage/lcov-report/api/controllers/layout.js.html +19 -28
- 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 +48 -78
- 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 +20 -56
- 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 +17 -23
- package/coverage/lcov-report/api/controllers/table/index.html +26 -26
- package/coverage/lcov-report/api/controllers/table/index.js.html +49 -85
- 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 +65 -275
- 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 +45 -39
- package/coverage/lcov-report/api/routes/analytics.js.html +13 -7
- 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 +17 -29
- 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 +7 -7
- 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 +2762 -2903
- package/dist/api/controllers/analytics.js +30 -7
- package/dist/api/controllers/application.js +16 -56
- package/dist/api/controllers/automation.js +2 -31
- package/dist/api/controllers/backup.js +0 -7
- package/dist/api/controllers/datasource.js +2 -8
- package/dist/api/controllers/deploy/index.js +2 -6
- package/dist/api/controllers/dev.js +2 -9
- package/dist/api/controllers/layout.js +0 -3
- package/dist/api/controllers/query/import/index.js +2 -12
- package/dist/api/controllers/query/import/sources/curl.js +0 -3
- package/dist/api/controllers/query/import/sources/openapi2.js +0 -3
- package/dist/api/controllers/query/import/sources/openapi3.js +0 -3
- package/dist/api/controllers/query/index.js +2 -16
- package/dist/api/controllers/role.js +0 -11
- package/dist/api/controllers/screen.js +1 -10
- package/dist/api/controllers/static/index.js +15 -29
- package/dist/api/controllers/table/external.js +0 -2
- package/dist/api/controllers/table/index.js +0 -12
- package/dist/api/controllers/table/utils.js +3 -3
- package/dist/api/controllers/view/index.js +6 -62
- package/dist/api/index.js +4 -2
- package/dist/api/routes/analytics.js +3 -1
- package/dist/app.js +8 -16
- package/dist/automations/index.js +0 -4
- package/dist/automations/steps/executeQuery.js +1 -1
- package/dist/environment.js +2 -4
- package/dist/integrations/firebase.js +0 -1
- package/dist/migrations/index.js +31 -95
- package/dist/package.json +69 -79
- package/dist/tests/utilities/TestConfiguration.js +93 -121
- package/dist/tests/utilities/structures.js +0 -45
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/nodemon.json +1 -1
- package/package.json +70 -80
- package/scripts/dev/manage.js +0 -2
- package/scripts/jestSetup.js +0 -7
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/analytics.js +39 -0
- package/src/api/controllers/application.ts +18 -60
- package/src/api/controllers/automation.js +2 -36
- package/src/api/controllers/backup.js +0 -8
- package/src/api/controllers/datasource.js +4 -8
- package/src/api/controllers/deploy/index.ts +2 -6
- package/src/api/controllers/dev.js +2 -10
- package/src/api/controllers/layout.js +0 -3
- package/src/api/controllers/query/import/index.ts +3 -16
- package/src/api/controllers/query/import/sources/base/index.ts +1 -2
- package/src/api/controllers/query/import/sources/curl.ts +0 -4
- package/src/api/controllers/query/import/sources/openapi2.ts +0 -4
- package/src/api/controllers/query/import/sources/openapi3.ts +0 -4
- package/src/api/controllers/query/import/tests/index.spec.js +7 -20
- package/src/api/controllers/query/index.ts +3 -16
- package/src/api/controllers/role.js +0 -10
- package/src/api/controllers/screen.js +1 -13
- package/src/api/controllers/static/index.js +15 -28
- package/src/api/controllers/table/external.js +0 -2
- package/src/api/controllers/table/index.js +0 -12
- package/src/api/controllers/table/utils.ts +4 -4
- package/src/api/controllers/view/index.js +6 -76
- package/src/api/index.js +4 -2
- package/src/api/routes/analytics.js +3 -1
- package/src/api/routes/public/utils/Endpoint.ts +1 -1
- package/src/api/routes/tests/__snapshots__/datasource.spec.js.snap +1 -5
- package/src/api/routes/tests/application.spec.js +4 -64
- package/src/api/routes/tests/automation.spec.js +60 -168
- package/src/api/routes/tests/backup.spec.js +0 -2
- package/src/api/routes/tests/datasource.spec.js +0 -5
- package/src/api/routes/tests/layout.spec.js +0 -4
- package/src/api/routes/tests/query.spec.js +13 -56
- package/src/api/routes/tests/role.spec.js +7 -40
- package/src/api/routes/tests/row.spec.js +3 -2
- package/src/api/routes/tests/screen.spec.js +4 -30
- package/src/api/routes/tests/static.spec.js +54 -120
- package/src/api/routes/tests/table.spec.js +38 -102
- package/src/api/routes/tests/view.spec.js +43 -222
- package/src/app.ts +9 -18
- package/src/automations/index.js +0 -4
- package/src/automations/steps/executeQuery.js +1 -1
- package/src/automations/tests/delay.spec.js +0 -4
- package/src/environment.js +2 -5
- package/src/integrations/firebase.ts +0 -1
- package/src/migrations/index.ts +51 -120
- package/src/module.d.ts +1 -0
- package/src/tests/utilities/TestConfiguration.js +90 -138
- package/src/tests/utilities/structures.js +0 -71
- package/tsconfig.build.json +5 -20
- package/tsconfig.json +17 -22
- package/builder/assets/index.05491b9d.js +0 -1315
- package/dist/migrations/functions/backfill/app/automations.js +0 -31
- package/dist/migrations/functions/backfill/app/datasources.js +0 -28
- package/dist/migrations/functions/backfill/app/layouts.js +0 -33
- package/dist/migrations/functions/backfill/app/queries.js +0 -32
- package/dist/migrations/functions/backfill/app/roles.js +0 -28
- package/dist/migrations/functions/backfill/app/screens.js +0 -28
- package/dist/migrations/functions/backfill/app/tables.js +0 -40
- package/dist/migrations/functions/backfill/app.js +0 -175
- package/dist/migrations/functions/backfill/global/configs.js +0 -61
- package/dist/migrations/functions/backfill/global/quotas.js +0 -60
- package/dist/migrations/functions/backfill/global/users.js +0 -50
- package/dist/migrations/functions/backfill/global.js +0 -189
- package/dist/migrations/functions/backfill/index.js +0 -32
- package/dist/migrations/functions/backfill/installation.js +0 -80
- package/dist/migrations/tests/helpers.js +0 -72
- package/dist/migrations/tests/structures.js +0 -37
- package/src/api/controllers/analytics.ts +0 -8
- package/src/api/routes/tests/data/export.txt +0 -1
- package/src/api/routes/tests/deployment.spec.js +0 -25
- package/src/api/routes/tests/dev.spec.js +0 -40
- package/src/migrations/functions/backfill/app/automations.ts +0 -26
- package/src/migrations/functions/backfill/app/datasources.ts +0 -22
- package/src/migrations/functions/backfill/app/layouts.ts +0 -29
- package/src/migrations/functions/backfill/app/queries.ts +0 -33
- package/src/migrations/functions/backfill/app/roles.ts +0 -22
- package/src/migrations/functions/backfill/app/screens.ts +0 -22
- package/src/migrations/functions/backfill/app/tables.ts +0 -36
- package/src/migrations/functions/backfill/app.ts +0 -148
- package/src/migrations/functions/backfill/global/configs.ts +0 -66
- package/src/migrations/functions/backfill/global/quotas.ts +0 -60
- package/src/migrations/functions/backfill/global/users.ts +0 -49
- package/src/migrations/functions/backfill/global.ts +0 -194
- package/src/migrations/functions/backfill/index.ts +0 -7
- package/src/migrations/functions/backfill/installation.ts +0 -50
- package/src/migrations/tests/helpers.ts +0 -40
- package/src/migrations/tests/index.spec.ts +0 -132
- package/src/migrations/tests/structures.ts +0 -66
|
@@ -19,11 +19,10 @@ 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
|
|
22
|
+
const { DocumentTypes } = 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");
|
|
27
26
|
function prepareUpload({ s3Key, bucket, metadata, file }) {
|
|
28
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
28
|
const response = yield upload({
|
|
@@ -47,7 +46,6 @@ exports.serveBuilder = function (ctx) {
|
|
|
47
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
47
|
let builderPath = resolve(TOP_LEVEL_PATH, "builder");
|
|
49
48
|
yield send(ctx, ctx.file, { root: builderPath });
|
|
50
|
-
yield events.serve.servedBuilder();
|
|
51
49
|
});
|
|
52
50
|
};
|
|
53
51
|
exports.uploadFile = function (ctx) {
|
|
@@ -70,35 +68,23 @@ exports.uploadFile = function (ctx) {
|
|
|
70
68
|
};
|
|
71
69
|
exports.serveApp = function (ctx) {
|
|
72
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const App = require("./templates/BudibaseApp.svelte").default;
|
|
73
72
|
const db = getAppDB({ skip_setup: true });
|
|
74
73
|
const appInfo = yield db.get(DocumentTypes.APP_METADATA);
|
|
75
74
|
let appId = getAppId();
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
}
|
|
75
|
+
const { head, html, css } = App.render({
|
|
76
|
+
title: appInfo.name,
|
|
77
|
+
production: env.isProd(),
|
|
78
|
+
appId,
|
|
79
|
+
clientLibPath: clientLibraryPath(appId, appInfo.version),
|
|
80
|
+
});
|
|
81
|
+
const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`);
|
|
82
|
+
ctx.body = yield processString(appHbs, {
|
|
83
|
+
head,
|
|
84
|
+
body: html,
|
|
85
|
+
style: css.code,
|
|
86
|
+
appId,
|
|
87
|
+
});
|
|
102
88
|
});
|
|
103
89
|
};
|
|
104
90
|
exports.serveClientLibrary = function (ctx) {
|
|
@@ -16,7 +16,6 @@ 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");
|
|
20
19
|
function makeTableRequest(datasource, operation, table, tables, oldTable = null, renamed = null) {
|
|
21
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
21
|
const json = {
|
|
@@ -248,7 +247,6 @@ exports.bulkImport = function (ctx) {
|
|
|
248
247
|
yield handleRequest(DataSourceOperation.BULK_CREATE, table._id, {
|
|
249
248
|
rows,
|
|
250
249
|
});
|
|
251
|
-
yield events.rows.imported(table, "csv", rows.length);
|
|
252
250
|
return table;
|
|
253
251
|
});
|
|
254
252
|
};
|
|
@@ -15,7 +15,6 @@ 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");
|
|
19
18
|
function pickApi({ tableId, table }) {
|
|
20
19
|
if (table && !tableId) {
|
|
21
20
|
tableId = table._id;
|
|
@@ -58,17 +57,7 @@ exports.save = function (ctx) {
|
|
|
58
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
58
|
const appId = ctx.appId;
|
|
60
59
|
const table = ctx.request.body;
|
|
61
|
-
const importFormat = table.dataImport && table.dataImport.csvString ? "csv" : undefined;
|
|
62
60
|
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
|
-
}
|
|
72
61
|
ctx.status = 200;
|
|
73
62
|
ctx.message = `Table ${table.name} saved successfully.`;
|
|
74
63
|
ctx.eventEmitter &&
|
|
@@ -81,7 +70,6 @@ exports.destroy = function (ctx) {
|
|
|
81
70
|
const appId = ctx.appId;
|
|
82
71
|
const tableId = ctx.params.tableId;
|
|
83
72
|
const deletedTable = yield pickApi({ tableId }).destroy(ctx);
|
|
84
|
-
yield events.table.deleted(deletedTable);
|
|
85
73
|
ctx.eventEmitter &&
|
|
86
74
|
ctx.eventEmitter.emitTable(`table:delete`, appId, deletedTable);
|
|
87
75
|
ctx.status = 200;
|
|
@@ -25,7 +25,6 @@ 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");
|
|
29
28
|
function clearColumns(table, columnNames) {
|
|
30
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
30
|
const db = getAppDB();
|
|
@@ -131,7 +130,8 @@ function handleDataImport(user, table, dataImport) {
|
|
|
131
130
|
finalData.push(row);
|
|
132
131
|
}
|
|
133
132
|
yield pro_1.quotas.addRows(finalData.length, () => db.bulkDocs(finalData));
|
|
134
|
-
yield
|
|
133
|
+
let response = yield db.put(table);
|
|
134
|
+
table._rev = response._rev;
|
|
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
|
-
yield handleDataImport(this.user, table, this.dataImport);
|
|
223
|
+
table = yield handleDataImport(this.user, table, this.dataImport);
|
|
224
224
|
return table;
|
|
225
225
|
});
|
|
226
226
|
}
|
|
@@ -27,9 +27,6 @@ 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");
|
|
33
30
|
exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
31
|
ctx.body = yield getViews();
|
|
35
32
|
});
|
|
@@ -37,70 +34,24 @@ exports.save = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
37
34
|
const db = getAppDB();
|
|
38
35
|
const _a = ctx.request.body, { originalName } = _a, viewToSave = __rest(_a, ["originalName"]);
|
|
39
36
|
const view = viewTemplate(viewToSave);
|
|
40
|
-
|
|
41
|
-
if (!viewName) {
|
|
37
|
+
if (!viewToSave.name) {
|
|
42
38
|
ctx.throw(400, "Cannot create view without a name");
|
|
43
39
|
}
|
|
44
|
-
yield saveView(originalName,
|
|
40
|
+
yield saveView(originalName, viewToSave.name, view);
|
|
45
41
|
// add views to table document
|
|
46
|
-
const
|
|
47
|
-
const table = cloneDeep(existingTable);
|
|
42
|
+
const table = yield db.get(ctx.request.body.tableId);
|
|
48
43
|
if (!table.views)
|
|
49
44
|
table.views = {};
|
|
50
45
|
if (!view.meta.schema) {
|
|
51
46
|
view.meta.schema = table.schema;
|
|
52
47
|
}
|
|
53
|
-
table.views[
|
|
48
|
+
table.views[viewToSave.name] = view.meta;
|
|
54
49
|
if (originalName) {
|
|
55
50
|
delete table.views[originalName];
|
|
56
|
-
existingTable.views[viewName] = existingTable.views[originalName];
|
|
57
51
|
}
|
|
58
52
|
yield db.put(table);
|
|
59
|
-
yield handleViewEvents(existingTable.views[viewName], table.views[viewName]);
|
|
60
53
|
ctx.body = Object.assign(Object.assign({}, table.views[viewToSave.name]), { name: viewToSave.name });
|
|
61
54
|
});
|
|
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
|
-
});
|
|
104
55
|
exports.destroy = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
56
|
const db = getAppDB();
|
|
106
57
|
const viewName = decodeURI(ctx.params.viewName);
|
|
@@ -108,7 +59,6 @@ exports.destroy = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
108
59
|
const table = yield db.get(view.meta.tableId);
|
|
109
60
|
delete table.views[viewName];
|
|
110
61
|
yield db.put(table);
|
|
111
|
-
yield events.view.deleted(view);
|
|
112
62
|
ctx.body = view;
|
|
113
63
|
});
|
|
114
64
|
exports.exportView = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -136,9 +86,9 @@ exports.exportView = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
136
86
|
yield fetchView(ctx);
|
|
137
87
|
let rows = ctx.body;
|
|
138
88
|
let schema = view && view.meta && view.meta.schema;
|
|
139
|
-
const tableId = ctx.params.tableId || view.meta.tableId;
|
|
140
|
-
const table = yield getTable(tableId);
|
|
141
89
|
if (!schema) {
|
|
90
|
+
const tableId = ctx.params.tableId || view.meta.tableId;
|
|
91
|
+
const table = yield getTable(tableId);
|
|
142
92
|
schema = table.schema;
|
|
143
93
|
}
|
|
144
94
|
// remove any relationships
|
|
@@ -170,10 +120,4 @@ exports.exportView = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
170
120
|
// send down the file
|
|
171
121
|
ctx.attachment(filename);
|
|
172
122
|
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
|
-
}
|
|
179
123
|
});
|
package/dist/api/index.js
CHANGED
|
@@ -68,8 +68,10 @@ router.use((ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
68
68
|
validationErrors: err.validation,
|
|
69
69
|
error,
|
|
70
70
|
};
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
if (env.NODE_ENV !== "jest") {
|
|
72
|
+
ctx.log.error(err);
|
|
73
|
+
console.trace(err);
|
|
74
|
+
}
|
|
73
75
|
}
|
|
74
76
|
}));
|
|
75
77
|
// authenticated routes
|
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
const Router = require("@koa/router");
|
|
3
3
|
const controller = require("../controllers/analytics");
|
|
4
4
|
const router = Router();
|
|
5
|
-
router
|
|
5
|
+
router
|
|
6
|
+
.get("/api/bbtel", controller.isEnabled)
|
|
7
|
+
.post("/api/bbtel/ping", controller.endUserPing);
|
|
6
8
|
module.exports = router;
|
package/dist/app.js
CHANGED
|
@@ -53,7 +53,6 @@ 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");
|
|
57
56
|
const app = new Koa();
|
|
58
57
|
// set up top level koa middleware
|
|
59
58
|
app.use(koaBody({
|
|
@@ -104,7 +103,6 @@ server.on("close", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
104
103
|
}
|
|
105
104
|
yield automations.shutdown();
|
|
106
105
|
yield redis_1.default.shutdown();
|
|
107
|
-
yield backend_core_1.events.shutdown();
|
|
108
106
|
yield Thread.shutdown();
|
|
109
107
|
api.shutdown();
|
|
110
108
|
if (!env.isTest()) {
|
|
@@ -117,20 +115,6 @@ module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, vo
|
|
|
117
115
|
eventEmitter.emitPort(env.PORT);
|
|
118
116
|
fileSystem.init();
|
|
119
117
|
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
|
|
134
118
|
yield automations.init();
|
|
135
119
|
}));
|
|
136
120
|
const shutdown = () => {
|
|
@@ -150,3 +134,11 @@ process.on("uncaughtException", err => {
|
|
|
150
134
|
process.on("SIGTERM", () => {
|
|
151
135
|
shutdown();
|
|
152
136
|
});
|
|
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,8 +10,6 @@ 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");
|
|
15
13
|
/**
|
|
16
14
|
* This module is built purely to kick off the worker farm and manage the inputs/outputs
|
|
17
15
|
*/
|
|
@@ -28,5 +26,3 @@ exports.shutdown = () => {
|
|
|
28
26
|
return shutdown();
|
|
29
27
|
};
|
|
30
28
|
exports.queue = queue;
|
|
31
|
-
exports.TRIGGER_DEFINITIONS = TRIGGER_DEFINITIONS;
|
|
32
|
-
exports.ACTION_DEFINITIONS = ACTION_DEFINITIONS;
|
package/dist/environment.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const { join } = require("path");
|
|
3
3
|
function isTest() {
|
|
4
|
-
return isCypress() || isJest();
|
|
5
|
-
}
|
|
6
|
-
function isJest() {
|
|
7
4
|
return (process.env.NODE_ENV === "jest" ||
|
|
5
|
+
process.env.NODE_ENV === "cypress" ||
|
|
8
6
|
(process.env.JEST_WORKER_ID != null &&
|
|
9
7
|
process.env.JEST_WORKER_ID !== "null"));
|
|
10
8
|
}
|
|
@@ -59,6 +57,7 @@ module.exports = {
|
|
|
59
57
|
AUTOMATION_MAX_ITERATIONS: process.env.AUTOMATION_MAX_ITERATIONS,
|
|
60
58
|
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
|
|
61
59
|
DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT,
|
|
60
|
+
POSTHOG_TOKEN: process.env.POSTHOG_TOKEN,
|
|
62
61
|
QUERY_THREAD_TIMEOUT: parseIntSafe(process.env.QUERY_THREAD_TIMEOUT),
|
|
63
62
|
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
|
64
63
|
// flags
|
|
@@ -75,7 +74,6 @@ module.exports = {
|
|
|
75
74
|
module.exports[key] = value;
|
|
76
75
|
},
|
|
77
76
|
isTest,
|
|
78
|
-
isJest,
|
|
79
77
|
isCypress,
|
|
80
78
|
isDev,
|
|
81
79
|
isProd: () => {
|
package/dist/migrations/index.js
CHANGED
|
@@ -31,108 +31,44 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.migrate = exports.MIGRATIONS =
|
|
39
|
-
const
|
|
40
|
-
const types_1 = require("@budibase/types");
|
|
41
|
-
const environment_1 = __importDefault(require("../environment"));
|
|
35
|
+
exports.migrate = exports.MIGRATIONS = void 0;
|
|
36
|
+
const { MIGRATION_TYPES, runMigrations, } = require("@budibase/backend-core/migrations");
|
|
42
37
|
// migration functions
|
|
43
38
|
const userEmailViewCasing = __importStar(require("./functions/userEmailViewCasing"));
|
|
44
39
|
const quota1 = __importStar(require("./functions/quotas1"));
|
|
45
40
|
const appUrls = __importStar(require("./functions/appUrls"));
|
|
46
41
|
const developerQuota = __importStar(require("./functions/developerQuota"));
|
|
47
42
|
const publishedAppsQuota = __importStar(require("./functions/publishedAppsQuota"));
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
case types_1.MigrationName.EVENT_APP_BACKFILL: {
|
|
79
|
-
serverMigrations.push(Object.assign(Object.assign({}, definition), { appOpts: { all: true }, fn: backfill.app.run, silent: !!environment_1.default.SELF_HOSTED, preventRetry: !!environment_1.default.SELF_HOSTED }));
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
case types_1.MigrationName.EVENT_GLOBAL_BACKFILL: {
|
|
83
|
-
serverMigrations.push(Object.assign(Object.assign({}, definition), { fn: backfill.global.run, silent: !!environment_1.default.SELF_HOSTED, preventRetry: !!environment_1.default.SELF_HOSTED }));
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
case types_1.MigrationName.EVENT_INSTALLATION_BACKFILL: {
|
|
87
|
-
serverMigrations.push(Object.assign(Object.assign({}, definition), { fn: backfill.installation.run, silent: !!environment_1.default.SELF_HOSTED, preventRetry: !!environment_1.default.SELF_HOSTED }));
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return serverMigrations;
|
|
93
|
-
};
|
|
94
|
-
exports.buildMigrations = buildMigrations;
|
|
95
|
-
exports.MIGRATIONS = (0, exports.buildMigrations)();
|
|
43
|
+
exports.MIGRATIONS = [
|
|
44
|
+
{
|
|
45
|
+
type: MIGRATION_TYPES.GLOBAL,
|
|
46
|
+
name: "user_email_view_casing",
|
|
47
|
+
fn: userEmailViewCasing.run,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: MIGRATION_TYPES.GLOBAL,
|
|
51
|
+
name: "quotas_1",
|
|
52
|
+
fn: quota1.run,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: MIGRATION_TYPES.APP,
|
|
56
|
+
name: "app_urls",
|
|
57
|
+
opts: { all: true },
|
|
58
|
+
fn: appUrls.run,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: MIGRATION_TYPES.GLOBAL,
|
|
62
|
+
name: "developer_quota",
|
|
63
|
+
fn: developerQuota.run,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: MIGRATION_TYPES.GLOBAL,
|
|
67
|
+
name: "published_apps_quota",
|
|
68
|
+
fn: publishedAppsQuota.run,
|
|
69
|
+
},
|
|
70
|
+
];
|
|
96
71
|
const migrate = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
-
|
|
98
|
-
// self host runs migrations on startup
|
|
99
|
-
// make sure only a single instance runs them
|
|
100
|
-
yield migrateWithLock(options);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
yield backend_core_1.migrations.runMigrations(exports.MIGRATIONS, options);
|
|
104
|
-
}
|
|
72
|
+
yield runMigrations(exports.MIGRATIONS, options);
|
|
105
73
|
});
|
|
106
74
|
exports.migrate = migrate;
|
|
107
|
-
const migrateWithLock = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
-
// get a new lock client
|
|
109
|
-
const redlock = yield backend_core_1.redis.clients.getMigrationsRedlock();
|
|
110
|
-
// lock for 15 minutes
|
|
111
|
-
const ttl = 1000 * 60 * 15;
|
|
112
|
-
let migrationLock;
|
|
113
|
-
// acquire lock
|
|
114
|
-
try {
|
|
115
|
-
migrationLock = yield redlock.lock("migrations", ttl);
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
if (e.name === "LockError") {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
throw e;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// run migrations
|
|
126
|
-
try {
|
|
127
|
-
yield backend_core_1.migrations.runMigrations(exports.MIGRATIONS, options);
|
|
128
|
-
}
|
|
129
|
-
finally {
|
|
130
|
-
// release lock
|
|
131
|
-
try {
|
|
132
|
-
yield migrationLock.unlock();
|
|
133
|
-
}
|
|
134
|
-
catch (e) {
|
|
135
|
-
console.error("unable to release migration lock");
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
});
|