@budibase/server 1.0.49-alpha.1 → 1.0.49-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builder/assets/{index.ed1cf508.js → index.82e12602.js} +149 -149
- package/builder/assets/{index.ba78c49d.css → index.83c0944f.css} +1 -1
- package/builder/index.html +2 -2
- package/coverage/clover.xml +989 -1020
- package/coverage/coverage-final.json +90 -91
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.js.html +106 -106
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +27 -12
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/{migrations/usageQuotas/syncApps.js.html → api/controllers/migrations.js.html} +30 -45
- package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.js.html +19 -19
- package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -6
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +16 -16
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.js.html +13 -13
- package/coverage/lcov-report/api/controllers/row/internal.js.html +26 -26
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +8 -8
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +10 -10
- package/coverage/lcov-report/api/controllers/row/utils.js.html +13 -13
- package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +9 -9
- package/coverage/lcov-report/api/controllers/table/external.js.html +12 -12
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/table/internal.js.html +12 -12
- package/coverage/lcov-report/api/controllers/table/utils.js.html +30 -30
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +20 -20
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/view/utils.js.html +11 -11
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +15 -15
- 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/application.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +22 -7
- package/coverage/lcov-report/api/routes/index.js.html +10 -4
- 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/{migrations/usageQuotas/index.js.html → api/routes/migrations.js.html} +25 -55
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/row.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +18 -18
- package/coverage/lcov-report/automations/utils.js.html +32 -32
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +26 -26
- 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/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +7 -7
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +18 -18
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +13 -13
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +70 -70
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +5 -5
- package/coverage/lcov-report/events/utils.js.html +3 -3
- package/coverage/lcov-report/index.html +26 -41
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/authorized.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +11 -11
- package/coverage/lcov-report/middleware/joi-validator.js.html +3 -3
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +6 -12
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +1 -1
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +1 -1
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +14 -14
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +8 -8
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +18 -18
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +4 -4
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +10 -10
- 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 +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +12 -12
- package/coverage/lcov.info +1128 -1176
- package/dist/api/controllers/application.js +18 -20
- package/dist/api/controllers/migrations.js +21 -0
- package/dist/api/routes/index.js +2 -0
- package/dist/api/routes/migrations.js +9 -0
- package/dist/app.js +35 -5
- package/dist/environment.js +1 -0
- package/dist/middleware/usageQuota.js +0 -2
- package/dist/migrations/functions/appUrls.js +37 -0
- package/dist/migrations/functions/quotas1.js +50 -0
- package/dist/migrations/{usageQuotas → functions/usageQuotas}/index.js +6 -10
- package/dist/migrations/{usageQuotas → functions/usageQuotas}/syncApps.js +11 -5
- package/dist/migrations/{usageQuotas → functions/usageQuotas}/syncRows.js +14 -8
- package/dist/migrations/functions/userEmailViewCasing.js +24 -0
- package/dist/migrations/index.js +62 -0
- package/dist/package.json +4 -4
- package/dist/tests/utilities/TestConfiguration.js +3 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/api/controllers/application.js +3 -3
- package/src/api/controllers/migrations.js +13 -0
- package/src/api/routes/index.js +2 -0
- package/src/api/routes/migrations.js +14 -0
- package/src/app.ts +18 -5
- package/src/environment.js +1 -0
- package/src/middleware/usageQuota.js +0 -2
- package/src/migrations/functions/appUrls.ts +25 -0
- package/src/migrations/functions/quotas1.ts +20 -0
- package/src/migrations/functions/tests/appUrls.spec.js +29 -0
- package/src/migrations/{tests/usageQuotas/index.spec.js → functions/tests/quotas1.spec.js} +5 -5
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +25 -0
- package/src/migrations/functions/usageQuotas/index.ts +8 -0
- package/src/migrations/{usageQuotas/syncApps.js → functions/usageQuotas/syncApps.ts} +3 -3
- package/src/migrations/{usageQuotas/syncRows.js → functions/usageQuotas/syncRows.ts} +5 -5
- package/src/migrations/{tests/usageQuotas → functions/usageQuotas/tests}/syncApps.spec.js +4 -4
- package/src/migrations/{tests/usageQuotas → functions/usageQuotas/tests}/syncRows.spec.js +4 -4
- package/src/migrations/functions/userEmailViewCasing.ts +13 -0
- package/src/migrations/index.ts +56 -0
- package/src/tests/utilities/TestConfiguration.js +4 -0
- package/coverage/lcov-report/migrations/usageQuotas/index.html +0 -141
- package/coverage/lcov-report/migrations/usageQuotas/syncRows.js.html +0 -143
- package/src/migrations/usageQuotas/index.js +0 -24
|
@@ -49,24 +49,22 @@ function getUserRoleId(ctx) {
|
|
|
49
49
|
? BUILTIN_ROLE_IDS.PUBLIC
|
|
50
50
|
: ctx.user.role._id;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
}
|
|
52
|
+
exports.getAppUrl = ctx => {
|
|
53
|
+
// construct the url
|
|
54
|
+
let url;
|
|
55
|
+
if (ctx.request.body.url) {
|
|
56
|
+
// if the url is provided, use that
|
|
57
|
+
url = encodeURI(ctx.request.body.url);
|
|
58
|
+
}
|
|
59
|
+
else if (ctx.request.body.name) {
|
|
60
|
+
// otherwise use the name
|
|
61
|
+
url = encodeURI(`${ctx.request.body.name}`);
|
|
62
|
+
}
|
|
63
|
+
if (url) {
|
|
64
|
+
url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase();
|
|
65
|
+
}
|
|
66
|
+
return url;
|
|
67
|
+
};
|
|
70
68
|
const checkAppUrl = (ctx, apps, url, currentAppId) => {
|
|
71
69
|
if (currentAppId) {
|
|
72
70
|
apps = apps.filter(app => app.appId !== currentAppId);
|
|
@@ -183,7 +181,7 @@ exports.create = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
183
181
|
const apps = yield getAllApps(CouchDB, { dev: true });
|
|
184
182
|
const name = ctx.request.body.name;
|
|
185
183
|
checkAppName(ctx, apps, name);
|
|
186
|
-
const url =
|
|
184
|
+
const url = exports.getAppUrl(ctx);
|
|
187
185
|
checkAppUrl(ctx, apps, url);
|
|
188
186
|
const { useTemplate, templateKey, templateString } = ctx.request.body;
|
|
189
187
|
const instanceConfig = {
|
|
@@ -245,7 +243,7 @@ exports.update = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
245
243
|
if (name) {
|
|
246
244
|
checkAppName(ctx, apps, name, ctx.params.appId);
|
|
247
245
|
}
|
|
248
|
-
const url = yield getAppUrl(ctx);
|
|
246
|
+
const url = yield exports.getAppUrl(ctx);
|
|
249
247
|
if (url) {
|
|
250
248
|
checkAppUrl(ctx, apps, url, ctx.params.appId);
|
|
251
249
|
ctx.request.body.url = url;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
const { migrate, MIGRATIONS } = require("../../migrations");
|
|
12
|
+
exports.migrate = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
const options = ctx.request.body;
|
|
14
|
+
// don't await as can take a while, just return
|
|
15
|
+
migrate(options);
|
|
16
|
+
ctx.status = 200;
|
|
17
|
+
});
|
|
18
|
+
exports.fetchDefinitions = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
ctx.body = MIGRATIONS;
|
|
20
|
+
ctx.status = 200;
|
|
21
|
+
});
|
package/dist/api/routes/index.js
CHANGED
|
@@ -25,6 +25,7 @@ const backupRoutes = require("./backup");
|
|
|
25
25
|
const metadataRoutes = require("./metadata");
|
|
26
26
|
const devRoutes = require("./dev");
|
|
27
27
|
const cloudRoutes = require("./cloud");
|
|
28
|
+
const migrationRoutes = require("./migrations");
|
|
28
29
|
exports.mainRoutes = [
|
|
29
30
|
authRoutes,
|
|
30
31
|
deployRoutes,
|
|
@@ -53,5 +54,6 @@ exports.mainRoutes = [
|
|
|
53
54
|
// this could be breaking as koa may recognise other routes as this
|
|
54
55
|
tableRoutes,
|
|
55
56
|
rowRoutes,
|
|
57
|
+
migrationRoutes,
|
|
56
58
|
];
|
|
57
59
|
exports.staticRoutes = staticRoutes;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Router = require("@koa/router");
|
|
3
|
+
const migrationsController = require("../controllers/migrations");
|
|
4
|
+
const router = Router();
|
|
5
|
+
const { internalApi } = require("@budibase/backend-core/auth");
|
|
6
|
+
router
|
|
7
|
+
.post("/api/migrations/run", internalApi, migrationsController.migrate)
|
|
8
|
+
.get("/api/migrations/definitions", internalApi, migrationsController.fetchDefinitions);
|
|
9
|
+
module.exports = router;
|
package/dist/app.js
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -9,7 +28,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
28
|
});
|
|
10
29
|
};
|
|
11
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const env = require("./environment");
|
|
31
|
+
const env = __importStar(require("./environment"));
|
|
13
32
|
const CouchDB = require("./db");
|
|
14
33
|
require("@budibase/backend-core").init(CouchDB);
|
|
15
34
|
const Koa = require("koa");
|
|
@@ -24,6 +43,7 @@ const Sentry = require("@sentry/node");
|
|
|
24
43
|
const fileSystem = require("./utilities/fileSystem");
|
|
25
44
|
const bullboard = require("./automations/bullboard");
|
|
26
45
|
const redis = require("./utilities/redis");
|
|
46
|
+
const migrations = __importStar(require("./migrations"));
|
|
27
47
|
const app = new Koa();
|
|
28
48
|
// set up top level koa middleware
|
|
29
49
|
app.use(koaBody({
|
|
@@ -76,12 +96,22 @@ module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, vo
|
|
|
76
96
|
yield redis.init();
|
|
77
97
|
yield automations.init();
|
|
78
98
|
}));
|
|
79
|
-
|
|
80
|
-
console.error(err);
|
|
99
|
+
const shutdown = () => {
|
|
81
100
|
server.close();
|
|
82
101
|
server.destroy();
|
|
102
|
+
};
|
|
103
|
+
process.on("uncaughtException", err => {
|
|
104
|
+
console.error(err);
|
|
105
|
+
shutdown();
|
|
83
106
|
});
|
|
84
107
|
process.on("SIGTERM", () => {
|
|
85
|
-
|
|
86
|
-
server.destroy();
|
|
108
|
+
shutdown();
|
|
87
109
|
});
|
|
110
|
+
// run migrations on startup if not done via http
|
|
111
|
+
// not recommended in a clustered environment
|
|
112
|
+
if (!env.HTTP_MIGRATIONS) {
|
|
113
|
+
migrations.migrate().catch(err => {
|
|
114
|
+
console.error("Error performing migrations. Exiting.\n", err);
|
|
115
|
+
shutdown();
|
|
116
|
+
});
|
|
117
|
+
}
|
package/dist/environment.js
CHANGED
|
@@ -35,6 +35,7 @@ module.exports = {
|
|
|
35
35
|
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
|
|
36
36
|
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
|
|
37
37
|
MULTI_TENANCY: process.env.MULTI_TENANCY,
|
|
38
|
+
HTTP_MIGRATIONS: process.env.HTTP_MIGRATIONS,
|
|
38
39
|
// environment
|
|
39
40
|
NODE_ENV: process.env.NODE_ENV,
|
|
40
41
|
JEST_WORKER_ID: process.env.JEST_WORKER_ID,
|
|
@@ -12,7 +12,6 @@ const CouchDB = require("../db");
|
|
|
12
12
|
const usageQuota = require("../utilities/usageQuota");
|
|
13
13
|
const { getUniqueRows } = require("../utilities/usageQuota/rows");
|
|
14
14
|
const { isExternalTable, isRowId: isExternalRowId, } = require("../integrations/utils");
|
|
15
|
-
const migration = require("../migrations/usageQuotas");
|
|
16
15
|
// currently only counting new writes and deletes
|
|
17
16
|
const METHOD_MAP = {
|
|
18
17
|
POST: 1,
|
|
@@ -74,7 +73,6 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
74
73
|
usage = files.map(file => file.size).reduce((total, size) => total + size);
|
|
75
74
|
}
|
|
76
75
|
try {
|
|
77
|
-
yield migration.run();
|
|
78
76
|
yield performRequest(ctx, next, property, usage);
|
|
79
77
|
}
|
|
80
78
|
catch (err) {
|
|
@@ -0,0 +1,37 @@
|
|
|
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.run = void 0;
|
|
13
|
+
const { DocumentTypes } = require("@budibase/backend-core/db");
|
|
14
|
+
const application_1 = require("../../api/controllers/application");
|
|
15
|
+
/**
|
|
16
|
+
* Date:
|
|
17
|
+
* January 2022
|
|
18
|
+
*
|
|
19
|
+
* Description:
|
|
20
|
+
* Add the url to the app metadata if it doesn't exist
|
|
21
|
+
*/
|
|
22
|
+
const run = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const metadata = yield appDb.get(DocumentTypes.APP_METADATA);
|
|
24
|
+
if (!metadata.url) {
|
|
25
|
+
const context = {
|
|
26
|
+
request: {
|
|
27
|
+
body: {
|
|
28
|
+
name: metadata.name,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
metadata.url = application_1.getAppUrl(context);
|
|
33
|
+
console.log(`Adding url to app: ${metadata.url}`);
|
|
34
|
+
}
|
|
35
|
+
yield appDb.put(metadata);
|
|
36
|
+
});
|
|
37
|
+
exports.run = run;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.run = void 0;
|
|
32
|
+
const usageQuotas_1 = require("./usageQuotas");
|
|
33
|
+
const syncApps = __importStar(require("./usageQuotas/syncApps"));
|
|
34
|
+
const syncRows = __importStar(require("./usageQuotas/syncRows"));
|
|
35
|
+
/**
|
|
36
|
+
* Date:
|
|
37
|
+
* January 2022
|
|
38
|
+
*
|
|
39
|
+
* Description:
|
|
40
|
+
* Synchronise the app and row quotas to the state of the db after it was
|
|
41
|
+
* discovered that the quota resets were still in place and the row quotas
|
|
42
|
+
* weren't being decremented correctly.
|
|
43
|
+
*/
|
|
44
|
+
const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
yield usageQuotas_1.runQuotaMigration(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
yield syncApps.run();
|
|
47
|
+
yield syncRows.run();
|
|
48
|
+
}));
|
|
49
|
+
});
|
|
50
|
+
exports.run = run;
|
|
@@ -8,17 +8,13 @@ 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
|
-
const
|
|
14
|
-
const
|
|
15
|
-
exports.run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.runQuotaMigration = void 0;
|
|
13
|
+
const { useQuotas } = require("../../../utilities/usageQuota");
|
|
14
|
+
const runQuotaMigration = (migration) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
15
|
if (!useQuotas()) {
|
|
17
16
|
return;
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
yield migrateIfRequired(MIGRATION_DBS.GLOBAL_DB, MIGRATIONS.QUOTAS_1, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
yield syncApps.run();
|
|
22
|
-
yield syncRows.run();
|
|
23
|
-
}));
|
|
18
|
+
yield migration();
|
|
24
19
|
});
|
|
20
|
+
exports.runQuotaMigration = runQuotaMigration;
|
|
@@ -8,19 +8,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
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.run = void 0;
|
|
11
16
|
const { getGlobalDB, getTenantId } = require("@budibase/backend-core/tenancy");
|
|
12
17
|
const { getAllApps } = require("@budibase/backend-core/db");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
18
|
+
const db_1 = __importDefault(require("../../../db"));
|
|
19
|
+
const usageQuota_1 = require("../../../utilities/usageQuota");
|
|
20
|
+
const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
21
|
const db = getGlobalDB();
|
|
17
22
|
// get app count
|
|
18
|
-
const devApps = yield getAllApps(
|
|
23
|
+
const devApps = yield getAllApps(db_1.default, { dev: true });
|
|
19
24
|
const appCount = devApps ? devApps.length : 0;
|
|
20
25
|
// sync app count
|
|
21
26
|
const tenantId = getTenantId();
|
|
22
27
|
console.log(`[Tenant: ${tenantId}] Syncing app count: ${appCount}`);
|
|
23
|
-
const usageDoc = yield getUsageQuotaDoc(db);
|
|
28
|
+
const usageDoc = yield usageQuota_1.getUsageQuotaDoc(db);
|
|
24
29
|
usageDoc.usageQuota.apps = appCount;
|
|
25
30
|
yield db.put(usageDoc);
|
|
26
31
|
});
|
|
32
|
+
exports.run = run;
|
|
@@ -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
|
+
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.run = void 0;
|
|
11
16
|
const { getGlobalDB, getTenantId } = require("@budibase/backend-core/tenancy");
|
|
12
17
|
const { getAllApps } = require("@budibase/backend-core/db");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
18
|
+
const db_1 = __importDefault(require("../../../db"));
|
|
19
|
+
const usageQuota_1 = require("../../../utilities/usageQuota");
|
|
20
|
+
const rows_1 = require("../../../utilities/usageQuota/rows");
|
|
21
|
+
const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
22
|
const db = getGlobalDB();
|
|
18
23
|
// get all rows in all apps
|
|
19
|
-
const allApps = yield getAllApps(
|
|
20
|
-
const appIds = allApps ? allApps.map(app => app.appId) : [];
|
|
21
|
-
const rows = yield getUniqueRows(appIds);
|
|
24
|
+
const allApps = yield getAllApps(db_1.default, { all: true });
|
|
25
|
+
const appIds = allApps ? allApps.map((app) => app.appId) : [];
|
|
26
|
+
const rows = yield rows_1.getUniqueRows(appIds);
|
|
22
27
|
const rowCount = rows ? rows.length : 0;
|
|
23
28
|
// sync row count
|
|
24
29
|
const tenantId = getTenantId();
|
|
25
30
|
console.log(`[Tenant: ${tenantId}] Syncing row count: ${rowCount}`);
|
|
26
|
-
const usageDoc = yield getUsageQuotaDoc(db);
|
|
31
|
+
const usageDoc = yield usageQuota_1.getUsageQuotaDoc(db);
|
|
27
32
|
usageDoc.usageQuota.rows = rowCount;
|
|
28
33
|
yield db.put(usageDoc);
|
|
29
34
|
});
|
|
35
|
+
exports.run = run;
|
|
@@ -0,0 +1,24 @@
|
|
|
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.run = void 0;
|
|
13
|
+
const { createUserEmailView } = require("@budibase/backend-core/db");
|
|
14
|
+
/**
|
|
15
|
+
* Date:
|
|
16
|
+
* October 2021
|
|
17
|
+
*
|
|
18
|
+
* Description:
|
|
19
|
+
* Recreate the user email view to include latest changes i.e. lower casing the email address
|
|
20
|
+
*/
|
|
21
|
+
const run = (db) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
yield createUserEmailView(db);
|
|
23
|
+
});
|
|
24
|
+
exports.run = run;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.migrate = exports.MIGRATIONS = void 0;
|
|
35
|
+
const db_1 = __importDefault(require("../db"));
|
|
36
|
+
const { MIGRATION_TYPES, runMigrations, } = require("@budibase/backend-core/migrations");
|
|
37
|
+
// migration functions
|
|
38
|
+
const userEmailViewCasing = __importStar(require("./functions/userEmailViewCasing"));
|
|
39
|
+
const quota1 = __importStar(require("./functions/quotas1"));
|
|
40
|
+
const appUrls = __importStar(require("./functions/appUrls"));
|
|
41
|
+
exports.MIGRATIONS = [
|
|
42
|
+
{
|
|
43
|
+
type: MIGRATION_TYPES.GLOBAL,
|
|
44
|
+
name: "user_email_view_casing",
|
|
45
|
+
fn: userEmailViewCasing.run,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: MIGRATION_TYPES.GLOBAL,
|
|
49
|
+
name: "quotas_1",
|
|
50
|
+
fn: quota1.run,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: MIGRATION_TYPES.APP,
|
|
54
|
+
name: "app_urls",
|
|
55
|
+
opts: { all: true },
|
|
56
|
+
fn: appUrls.run,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
const migrate = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
yield runMigrations(db_1.default, exports.MIGRATIONS, options);
|
|
61
|
+
});
|
|
62
|
+
exports.migrate = migrate;
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.49-alpha.
|
|
4
|
+
"version": "1.0.49-alpha.1",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"license": "GPL-3.0",
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
73
|
-
"@budibase/backend-core": "^1.0.49-alpha.
|
|
74
|
-
"@budibase/client": "^1.0.49-alpha.
|
|
75
|
-
"@budibase/string-templates": "^1.0.49-alpha.
|
|
73
|
+
"@budibase/backend-core": "^1.0.49-alpha.1",
|
|
74
|
+
"@budibase/client": "^1.0.49-alpha.1",
|
|
75
|
+
"@budibase/string-templates": "^1.0.49-alpha.1",
|
|
76
76
|
"@bull-board/api": "^3.7.0",
|
|
77
77
|
"@bull-board/koa": "^3.7.0",
|
|
78
78
|
"@elastic/elasticsearch": "7.10.0",
|