@budibase/server 1.0.45 → 1.0.46-alpha.3
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.39e01193.css → index.0df4f7ab.css} +1 -1
- package/builder/assets/{index.04ee727d.js → index.6eae2fa0.js} +229 -227
- package/builder/assets/{vendor.f9faf6ab.js → vendor.10e2ad1b.js} +12 -12
- package/builder/index.html +3 -3
- package/coverage/clover.xml +1470 -1285
- package/coverage/coverage-final.json +90 -84
- 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 +90 -90
- 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/hosting.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- 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/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 +15 -15
- package/coverage/lcov-report/api/controllers/row/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/row/internal.js.html +44 -44
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +8 -8
- package/coverage/lcov-report/api/controllers/row/utils.js.html +53 -38
- 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/external.js.html +12 -12
- package/coverage/lcov-report/api/controllers/table/index.html +23 -23
- package/coverage/lcov-report/api/controllers/table/index.js.html +57 -39
- package/coverage/lcov-report/api/controllers/table/internal.js.html +40 -34
- package/coverage/lcov-report/api/controllers/table/utils.js.html +86 -62
- 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 +1 -1
- 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/hosting.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/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 +13 -19
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +11 -20
- 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 +13 -13
- 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 +22 -22
- 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 +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +18 -18
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +31 -31
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +15 -15
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +83 -83
- 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 +74 -44
- 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 +33 -6
- package/coverage/lcov-report/middleware/index.html +25 -25
- 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 +275 -41
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/migrations/usageQuotas/index.html +141 -0
- package/coverage/lcov-report/migrations/usageQuotas/index.js.html +152 -0
- package/coverage/lcov-report/migrations/usageQuotas/syncApps.js.html +134 -0
- package/coverage/lcov-report/migrations/usageQuotas/syncRows.js.html +143 -0
- 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 +25 -25
- 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 +53 -53
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
- 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 +141 -0
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +356 -0
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +302 -0
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +134 -0
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +31 -31
- package/coverage/lcov.info +2010 -1698
- package/dist/api/controllers/row/utils.js +12 -6
- package/dist/api/controllers/table/index.js +10 -4
- package/dist/api/controllers/table/internal.js +2 -0
- package/dist/api/controllers/table/utils.js +9 -2
- package/dist/automations/steps/createRow.js +2 -4
- package/dist/automations/steps/deleteRow.js +1 -4
- package/dist/environment.js +1 -0
- package/dist/integrations/base/sql.js +13 -6
- package/dist/integrations/utils.js +53 -8
- package/dist/middleware/currentapp.js +9 -0
- package/dist/middleware/usageQuota.js +82 -13
- package/dist/migrations/usageQuotas/index.js +24 -0
- package/dist/migrations/usageQuotas/syncApps.js +26 -0
- package/dist/migrations/usageQuotas/syncRows.js +29 -0
- package/dist/package.json +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/{usageQuota.js → usageQuota/index.js} +44 -31
- package/dist/utilities/usageQuota/rows.js +77 -0
- package/dist/utilities/usageQuota/usageQuoteReset.js +16 -0
- package/package.json +5 -5
- package/src/api/controllers/row/utils.js +11 -6
- package/src/api/controllers/table/index.js +15 -9
- package/src/api/controllers/table/internal.js +2 -0
- package/src/api/controllers/table/utils.js +9 -1
- package/src/automations/steps/createRow.js +2 -4
- package/src/automations/steps/deleteRow.js +1 -4
- package/src/environment.js +1 -0
- package/src/integrations/base/sql.ts +14 -7
- package/src/integrations/tests/sql.spec.js +16 -0
- package/src/integrations/utils.ts +57 -10
- package/src/middleware/currentapp.js +9 -0
- package/src/middleware/tests/usageQuota.spec.js +18 -24
- package/src/middleware/usageQuota.js +93 -15
- package/src/migrations/tests/usageQuotas/index.spec.js +27 -0
- package/src/migrations/tests/usageQuotas/syncApps.spec.js +37 -0
- package/src/migrations/tests/usageQuotas/syncRows.spec.js +43 -0
- package/src/migrations/usageQuotas/index.js +24 -0
- package/src/migrations/usageQuotas/syncApps.js +18 -0
- package/src/migrations/usageQuotas/syncRows.js +21 -0
- package/src/utilities/tests/usageQuota/usageQuota.spec.js +72 -0
- package/src/utilities/usageQuota/index.js +92 -0
- package/src/utilities/usageQuota/rows.js +74 -0
- package/src/utilities/usageQuota/usageQuoteReset.js +18 -0
- package/src/utilities/usageQuota.js +0 -73
|
@@ -65,12 +65,18 @@ exports.validate = ({ appId, tableId, row, table }) => __awaiter(void 0, void 0,
|
|
|
65
65
|
}
|
|
66
66
|
let res;
|
|
67
67
|
// Validate.js doesn't seem to handle array
|
|
68
|
-
if (type === FieldTypes.ARRAY && row[fieldName]
|
|
69
|
-
row[fieldName].
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
if (type === FieldTypes.ARRAY && row[fieldName]) {
|
|
69
|
+
if (row[fieldName].length) {
|
|
70
|
+
row[fieldName].map(val => {
|
|
71
|
+
if (!constraints.inclusion.includes(val)) {
|
|
72
|
+
errors[fieldName] = "Field not in list";
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else if (constraints.presence && row[fieldName].length === 0) {
|
|
77
|
+
// non required MultiSelect creates an empty array, which should not throw errors
|
|
78
|
+
errors[fieldName] = [`${fieldName} is required`];
|
|
79
|
+
}
|
|
74
80
|
}
|
|
75
81
|
else if (type === FieldTypes.JSON && typeof row[fieldName] === "string") {
|
|
76
82
|
// this should only happen if there is an error
|
|
@@ -12,7 +12,7 @@ const CouchDB = require("../../../db");
|
|
|
12
12
|
const internal = require("./internal");
|
|
13
13
|
const external = require("./external");
|
|
14
14
|
const csvParser = require("../../../utilities/csvParser");
|
|
15
|
-
const { isExternalTable } = require("../../../integrations/utils");
|
|
15
|
+
const { isExternalTable, isSQL } = require("../../../integrations/utils");
|
|
16
16
|
const { getTableParams, getDatasourceParams, BudibaseInternalDB, } = require("../../../db/utils");
|
|
17
17
|
const { getTable } = require("./utils");
|
|
18
18
|
function pickApi({ tableId, table }) {
|
|
@@ -34,12 +34,18 @@ exports.fetch = function (ctx) {
|
|
|
34
34
|
const internalTables = yield db.allDocs(getTableParams(null, {
|
|
35
35
|
include_docs: true,
|
|
36
36
|
}));
|
|
37
|
-
const internal = internalTables.rows.map(
|
|
37
|
+
const internal = internalTables.rows.map(tableDoc => (Object.assign(Object.assign({}, tableDoc.doc), { type: "internal", sourceId: BudibaseInternalDB._id })));
|
|
38
38
|
const externalTables = yield db.allDocs(getDatasourceParams("plus", {
|
|
39
39
|
include_docs: true,
|
|
40
40
|
}));
|
|
41
|
-
const external = externalTables.rows.flatMap(
|
|
42
|
-
|
|
41
|
+
const external = externalTables.rows.flatMap(tableDoc => {
|
|
42
|
+
let entities = tableDoc.doc.entities;
|
|
43
|
+
if (entities) {
|
|
44
|
+
return Object.values(entities).map(entity => (Object.assign(Object.assign({}, entity), { type: "external", sourceId: tableDoc.doc._id, sql: isSQL(tableDoc.doc) })));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
43
49
|
});
|
|
44
50
|
ctx.body = [...internal, ...external];
|
|
45
51
|
});
|
|
@@ -24,6 +24,7 @@ const linkRows = require("../../../db/linkedRows");
|
|
|
24
24
|
const { getRowParams, generateTableID } = require("../../../db/utils");
|
|
25
25
|
const { FieldTypes } = require("../../../constants");
|
|
26
26
|
const { TableSaveFunctions, hasTypeChanged, getTable, handleDataImport, } = require("./utils");
|
|
27
|
+
const usageQuota = require("../../../utilities/usageQuota");
|
|
27
28
|
exports.save = function (ctx) {
|
|
28
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
30
|
const appId = ctx.appId;
|
|
@@ -118,6 +119,7 @@ exports.destroy = function (ctx) {
|
|
|
118
119
|
include_docs: true,
|
|
119
120
|
}));
|
|
120
121
|
yield db.bulkDocs(rows.rows.map(row => (Object.assign(Object.assign({}, row.doc), { _deleted: true }))));
|
|
122
|
+
yield usageQuota.update(usageQuota.Properties.ROW, -rows.rows.length);
|
|
121
123
|
// update linked rows
|
|
122
124
|
yield linkRows.updateLinks({
|
|
123
125
|
appId,
|
|
@@ -15,9 +15,10 @@ const { isEqual } = require("lodash/fp");
|
|
|
15
15
|
const { AutoFieldSubTypes, FieldTypes } = require("../../../constants");
|
|
16
16
|
const { inputProcessing } = require("../../../utilities/rowProcessor");
|
|
17
17
|
const { USERS_TABLE_SCHEMA, SwitchableTypes } = require("../../../constants");
|
|
18
|
-
const { isExternalTable, breakExternalTableId, } = require("../../../integrations/utils");
|
|
18
|
+
const { isExternalTable, breakExternalTableId, isSQL, } = require("../../../integrations/utils");
|
|
19
19
|
const { getViews, saveView } = require("../view/utils");
|
|
20
20
|
const viewTemplate = require("../view/viewBuilder");
|
|
21
|
+
const usageQuota = require("../../../utilities/usageQuota");
|
|
21
22
|
exports.checkForColumnUpdates = (db, oldTable, updatedTable) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
23
|
let updatedRows = [];
|
|
23
24
|
const rename = updatedTable._rename;
|
|
@@ -95,7 +96,11 @@ exports.handleDataImport = (appId, user, table, dataImport) => __awaiter(void 0,
|
|
|
95
96
|
}
|
|
96
97
|
finalData.push(row);
|
|
97
98
|
}
|
|
99
|
+
yield usageQuota.update(usageQuota.Properties.ROW, finalData.length, {
|
|
100
|
+
dryRun: true,
|
|
101
|
+
});
|
|
98
102
|
yield db.bulkDocs(finalData);
|
|
103
|
+
yield usageQuota.update(usageQuota.Properties.ROW, finalData.length);
|
|
99
104
|
let response = yield db.put(table);
|
|
100
105
|
table._rev = response._rev;
|
|
101
106
|
return table;
|
|
@@ -207,7 +212,9 @@ exports.getTable = (appId, tableId) => __awaiter(void 0, void 0, void 0, functio
|
|
|
207
212
|
const db = new CouchDB(appId);
|
|
208
213
|
if (isExternalTable(tableId)) {
|
|
209
214
|
let { datasourceId, tableName } = breakExternalTableId(tableId);
|
|
210
|
-
|
|
215
|
+
const datasource = yield db.get(datasourceId);
|
|
216
|
+
const table = yield exports.getExternalTable(appId, datasourceId, tableName);
|
|
217
|
+
return Object.assign(Object.assign({}, table), { sql: isSQL(datasource) });
|
|
211
218
|
}
|
|
212
219
|
else {
|
|
213
220
|
return db.get(tableId);
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const rowController = require("../../api/controllers/row");
|
|
12
12
|
const automationUtils = require("../automationUtils");
|
|
13
|
-
const env = require("../../environment");
|
|
14
13
|
const usage = require("../../utilities/usageQuota");
|
|
15
14
|
const { buildCtx } = require("./utils");
|
|
16
15
|
exports.definition = {
|
|
@@ -87,10 +86,9 @@ exports.run = function ({ inputs, appId, emitter }) {
|
|
|
87
86
|
});
|
|
88
87
|
try {
|
|
89
88
|
inputs.row = yield automationUtils.cleanUpRow(appId, inputs.row.tableId, inputs.row);
|
|
90
|
-
|
|
91
|
-
yield usage.update(usage.Properties.ROW, 1);
|
|
92
|
-
}
|
|
89
|
+
yield usage.update(usage.Properties.ROW, 1, { dryRun: true });
|
|
93
90
|
yield rowController.save(ctx);
|
|
91
|
+
yield usage.update(usage.Properties.ROW, 1);
|
|
94
92
|
return {
|
|
95
93
|
row: inputs.row,
|
|
96
94
|
response: ctx.body,
|
|
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const rowController = require("../../api/controllers/row");
|
|
12
|
-
const env = require("../../environment");
|
|
13
12
|
const usage = require("../../utilities/usageQuota");
|
|
14
13
|
const { buildCtx } = require("./utils");
|
|
15
14
|
const automationUtils = require("../automationUtils");
|
|
@@ -81,9 +80,7 @@ exports.run = function ({ inputs, appId, emitter }) {
|
|
|
81
80
|
},
|
|
82
81
|
});
|
|
83
82
|
try {
|
|
84
|
-
|
|
85
|
-
yield usage.update(usage.Properties.ROW, -1);
|
|
86
|
-
}
|
|
83
|
+
yield usage.update(usage.Properties.ROW, -1);
|
|
87
84
|
yield rowController.destroy(ctx);
|
|
88
85
|
return {
|
|
89
86
|
response: ctx.body,
|
package/dist/environment.js
CHANGED
|
@@ -30,6 +30,7 @@ module.exports = {
|
|
|
30
30
|
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
|
31
31
|
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
|
32
32
|
USE_QUOTAS: process.env.USE_QUOTAS,
|
|
33
|
+
EXCLUDE_QUOTAS_TENANTS: process.env.EXCLUDE_QUOTAS_TENANTS,
|
|
33
34
|
REDIS_URL: process.env.REDIS_URL,
|
|
34
35
|
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
|
|
35
36
|
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
|
|
@@ -69,10 +69,16 @@ class InternalBuilder {
|
|
|
69
69
|
this.client = client;
|
|
70
70
|
}
|
|
71
71
|
// right now we only do filters on the specific table being queried
|
|
72
|
-
addFilters(
|
|
72
|
+
addFilters(query, filters, opts) {
|
|
73
73
|
function iterate(structure, fn) {
|
|
74
74
|
for (let [key, value] of Object.entries(structure)) {
|
|
75
|
-
|
|
75
|
+
const isRelationshipField = key.includes(".");
|
|
76
|
+
if (!opts.relationship && !isRelationshipField) {
|
|
77
|
+
fn(`${opts.tableName}.${key}`, value);
|
|
78
|
+
}
|
|
79
|
+
if (opts.relationship && isRelationshipField) {
|
|
80
|
+
fn(key, value);
|
|
81
|
+
}
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
84
|
if (!filters) {
|
|
@@ -248,7 +254,7 @@ class InternalBuilder {
|
|
|
248
254
|
if (foundOffset) {
|
|
249
255
|
query = query.offset(foundOffset);
|
|
250
256
|
}
|
|
251
|
-
query = this.addFilters(
|
|
257
|
+
query = this.addFilters(query, filters, { tableName });
|
|
252
258
|
// add sorting to pre-query
|
|
253
259
|
query = this.addSorting(query, json);
|
|
254
260
|
// @ts-ignore
|
|
@@ -261,13 +267,14 @@ class InternalBuilder {
|
|
|
261
267
|
preQuery = this.addSorting(preQuery, json);
|
|
262
268
|
}
|
|
263
269
|
// handle joins
|
|
264
|
-
|
|
270
|
+
query = this.addRelationships(knex, preQuery, selectStatement, tableName, relationships);
|
|
271
|
+
return this.addFilters(query, filters, { relationship: true });
|
|
265
272
|
}
|
|
266
273
|
update(knex, json, opts) {
|
|
267
274
|
const { endpoint, body, filters } = json;
|
|
268
275
|
let query = knex(endpoint.entityId);
|
|
269
276
|
const parsedBody = parseBody(body);
|
|
270
|
-
query = this.addFilters(endpoint.entityId
|
|
277
|
+
query = this.addFilters(query, filters, { tableName: endpoint.entityId });
|
|
271
278
|
// mysql can't use returning
|
|
272
279
|
if (opts.disableReturning) {
|
|
273
280
|
return query.update(parsedBody);
|
|
@@ -279,7 +286,7 @@ class InternalBuilder {
|
|
|
279
286
|
delete(knex, json, opts) {
|
|
280
287
|
const { endpoint, filters } = json;
|
|
281
288
|
let query = knex(endpoint.entityId);
|
|
282
|
-
query = this.addFilters(endpoint.entityId
|
|
289
|
+
query = this.addFilters(query, filters, { tableName: endpoint.entityId });
|
|
283
290
|
// mysql can't use returning
|
|
284
291
|
if (opts.disableReturning) {
|
|
285
292
|
return query.delete();
|
|
@@ -125,7 +125,12 @@ function isSQL(datasource) {
|
|
|
125
125
|
if (!datasource || !datasource.source) {
|
|
126
126
|
return false;
|
|
127
127
|
}
|
|
128
|
-
const SQL = [
|
|
128
|
+
const SQL = [
|
|
129
|
+
datasource_1.SourceNames.POSTGRES,
|
|
130
|
+
datasource_1.SourceNames.SQL_SERVER,
|
|
131
|
+
datasource_1.SourceNames.MYSQL,
|
|
132
|
+
datasource_1.SourceNames.ORACLE,
|
|
133
|
+
];
|
|
129
134
|
return SQL.indexOf(datasource.source) !== -1;
|
|
130
135
|
}
|
|
131
136
|
exports.isSQL = isSQL;
|
|
@@ -137,8 +142,40 @@ function isIsoDateString(str) {
|
|
|
137
142
|
return d.toISOString() === str;
|
|
138
143
|
}
|
|
139
144
|
exports.isIsoDateString = isIsoDateString;
|
|
140
|
-
|
|
141
|
-
function
|
|
145
|
+
/**
|
|
146
|
+
* This function will determine whether a column is a relationship and whether it
|
|
147
|
+
* is currently valid. The reason for the validity check is that tables can be deleted
|
|
148
|
+
* outside of Budibase control and if this is the case it will break Budibase relationships.
|
|
149
|
+
* The tableIds is a list passed down from the main finalise tables function, which is
|
|
150
|
+
* based on the tables that have just been fetched. This will only really be used on subsequent
|
|
151
|
+
* fetches to the first one - if the user is periodically refreshing Budibase knowledge of tables.
|
|
152
|
+
* @param column The column to check, to see if it is a valid relationship.
|
|
153
|
+
* @param tableIds The IDs of the tables which currently exist.
|
|
154
|
+
*/
|
|
155
|
+
function shouldCopyRelationship(column, tableIds) {
|
|
156
|
+
return column.type === constants_1.FieldTypes.LINK && column.tableId && tableIds.includes(column.tableId);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Similar function to the shouldCopyRelationship function, but instead this looks for options and boolean
|
|
160
|
+
* types. It is possible to switch a string -> options and a number -> boolean (and vice versus) need to make
|
|
161
|
+
* sure that these get copied over when tables are fetched. Also checks whether they are still valid, if a
|
|
162
|
+
* column has changed type in the external database then copying it over may not be possible.
|
|
163
|
+
* @param column The column to check for options or boolean type.
|
|
164
|
+
* @param fetchedColumn The fetched column to check for the type in the external database.
|
|
165
|
+
*/
|
|
166
|
+
function shouldCopySpecialColumn(column, fetchedColumn) {
|
|
167
|
+
return column.type === constants_1.FieldTypes.OPTIONS ||
|
|
168
|
+
((!fetchedColumn || fetchedColumn.type === constants_1.FieldTypes.NUMBER) && column.type === constants_1.FieldTypes.BOOLEAN);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Looks for columns which need to be copied over into the new table definitions, like relationships
|
|
172
|
+
* and options types.
|
|
173
|
+
* @param tableName The name of the table which is being checked.
|
|
174
|
+
* @param table The specific table which is being checked.
|
|
175
|
+
* @param entities All the tables that existed before - the old table definitions.
|
|
176
|
+
* @param tableIds The IDs of the tables which exist now, to check if anything has been removed.
|
|
177
|
+
*/
|
|
178
|
+
function copyExistingPropsOver(tableName, table, entities, tableIds) {
|
|
142
179
|
if (entities && entities[tableName]) {
|
|
143
180
|
if (entities[tableName].primaryDisplay) {
|
|
144
181
|
table.primaryDisplay = entities[tableName].primaryDisplay;
|
|
@@ -148,20 +185,28 @@ function copyExistingPropsOver(tableName, table, entities) {
|
|
|
148
185
|
if (!existingTableSchema.hasOwnProperty(key)) {
|
|
149
186
|
continue;
|
|
150
187
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
(
|
|
154
|
-
existingTableSchema[key].type === constants_1.FieldTypes.BOOLEAN)) {
|
|
188
|
+
const column = existingTableSchema[key];
|
|
189
|
+
if (shouldCopyRelationship(column, tableIds) ||
|
|
190
|
+
shouldCopySpecialColumn(column, table.schema[key])) {
|
|
155
191
|
table.schema[key] = existingTableSchema[key];
|
|
156
192
|
}
|
|
157
193
|
}
|
|
158
194
|
}
|
|
159
195
|
return table;
|
|
160
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Look through the final table definitions to see if anything needs to be
|
|
199
|
+
* copied over from the old and if any errors have occurred mark them so
|
|
200
|
+
* that the user can be made aware.
|
|
201
|
+
* @param tables The list of tables that have been retrieved from the external database.
|
|
202
|
+
* @param entities The old list of tables, if there was any to look for definitions in.
|
|
203
|
+
*/
|
|
161
204
|
function finaliseExternalTables(tables, entities) {
|
|
162
205
|
const invalidColumns = Object.values(constants_1.InvalidColumns);
|
|
163
206
|
let finalTables = {};
|
|
164
207
|
const errors = {};
|
|
208
|
+
// @ts-ignore
|
|
209
|
+
const tableIds = Object.values(tables).map(table => table._id);
|
|
165
210
|
for (let [name, table] of Object.entries(tables)) {
|
|
166
211
|
const schemaFields = Object.keys(table.schema);
|
|
167
212
|
// make sure every table has a key
|
|
@@ -174,7 +219,7 @@ function finaliseExternalTables(tables, entities) {
|
|
|
174
219
|
continue;
|
|
175
220
|
}
|
|
176
221
|
// make sure all previous props have been added back
|
|
177
|
-
finalTables[name] = copyExistingPropsOver(name, table, entities);
|
|
222
|
+
finalTables[name] = copyExistingPropsOver(name, table, entities, tableIds);
|
|
178
223
|
}
|
|
179
224
|
// sort the tables by name
|
|
180
225
|
finalTables = Object.entries(finalTables)
|
|
@@ -49,6 +49,15 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
49
49
|
!isWebhookEndpoint(ctx) &&
|
|
50
50
|
(!ctx.user || !ctx.user.builder || !ctx.user.builder.global)) {
|
|
51
51
|
clearCookie(ctx, Cookies.CurrentApp);
|
|
52
|
+
// have to set the return url on the server side as client side is not available
|
|
53
|
+
setCookie(ctx, ctx.url, Cookies.RETURN_URL, {
|
|
54
|
+
// don't sign so the browser can easily read
|
|
55
|
+
sign: false,
|
|
56
|
+
// use the request domain to match how ui handles the return url cookie.
|
|
57
|
+
// it's important we don't use the shared domain here as the builder
|
|
58
|
+
// can't delete from it without awareness of the domain.
|
|
59
|
+
requestDomain: true,
|
|
60
|
+
});
|
|
52
61
|
return ctx.redirect("/");
|
|
53
62
|
}
|
|
54
63
|
let appId, roleId = BUILTIN_ROLE_IDS.PUBLIC;
|
|
@@ -10,11 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const CouchDB = require("../db");
|
|
12
12
|
const usageQuota = require("../utilities/usageQuota");
|
|
13
|
-
const
|
|
14
|
-
const { getTenantId } = require("@budibase/backend-core/tenancy");
|
|
13
|
+
const { getUniqueRows } = require("../utilities/usageQuota/rows");
|
|
15
14
|
const { isExternalTable, isRowId: isExternalRowId, } = require("../integrations/utils");
|
|
16
|
-
|
|
17
|
-
const EXCLUDED_TENANTS = ["bb", "default", "bbtest", "bbstaging"];
|
|
15
|
+
const migration = require("../migrations/usageQuotas");
|
|
18
16
|
// currently only counting new writes and deletes
|
|
19
17
|
const METHOD_MAP = {
|
|
20
18
|
POST: 1,
|
|
@@ -22,13 +20,13 @@ const METHOD_MAP = {
|
|
|
22
20
|
};
|
|
23
21
|
const DOMAIN_MAP = {
|
|
24
22
|
rows: usageQuota.Properties.ROW,
|
|
25
|
-
upload: usageQuota.Properties.UPLOAD,
|
|
26
|
-
views: usageQuota.Properties.VIEW,
|
|
27
|
-
users: usageQuota.Properties.USER,
|
|
23
|
+
// upload: usageQuota.Properties.UPLOAD, // doesn't work yet
|
|
24
|
+
// views: usageQuota.Properties.VIEW, // doesn't work yet
|
|
25
|
+
// users: usageQuota.Properties.USER, // doesn't work yet
|
|
28
26
|
applications: usageQuota.Properties.APPS,
|
|
29
27
|
// this will not be updated by endpoint calls
|
|
30
28
|
// instead it will be updated by triggerInfo
|
|
31
|
-
automationRuns: usageQuota.Properties.AUTOMATION,
|
|
29
|
+
// automationRuns: usageQuota.Properties.AUTOMATION, // doesn't work yet
|
|
32
30
|
};
|
|
33
31
|
function getProperty(url) {
|
|
34
32
|
for (let domain of Object.keys(DOMAIN_MAP)) {
|
|
@@ -38,9 +36,7 @@ function getProperty(url) {
|
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
-
|
|
42
|
-
// if in development or a self hosted cloud usage quotas should not be executed
|
|
43
|
-
if (env.isDev() || env.SELF_HOSTED || EXCLUDED_TENANTS.includes(tenantId)) {
|
|
39
|
+
if (!usageQuota.useQuotas()) {
|
|
44
40
|
return next();
|
|
45
41
|
}
|
|
46
42
|
let usage = METHOD_MAP[ctx.req.method];
|
|
@@ -78,10 +74,83 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
78
74
|
usage = files.map(file => file.size).reduce((total, size) => total + size);
|
|
79
75
|
}
|
|
80
76
|
try {
|
|
81
|
-
yield
|
|
82
|
-
|
|
77
|
+
yield migration.run();
|
|
78
|
+
yield performRequest(ctx, next, property, usage);
|
|
83
79
|
}
|
|
84
80
|
catch (err) {
|
|
85
81
|
ctx.throw(400, err);
|
|
86
82
|
}
|
|
87
83
|
});
|
|
84
|
+
const performRequest = (ctx, next, property, usage) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
const usageContext = {
|
|
86
|
+
skipNext: false,
|
|
87
|
+
skipUsage: false,
|
|
88
|
+
[usageQuota.Properties.APPS]: {},
|
|
89
|
+
};
|
|
90
|
+
if (usage === -1) {
|
|
91
|
+
if (PRE_DELETE[property]) {
|
|
92
|
+
yield PRE_DELETE[property](ctx, usageContext);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (PRE_CREATE[property]) {
|
|
97
|
+
yield PRE_CREATE[property](ctx, usageContext);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// run the request
|
|
101
|
+
if (!usageContext.skipNext) {
|
|
102
|
+
yield usageQuota.update(property, usage, { dryRun: true });
|
|
103
|
+
yield next();
|
|
104
|
+
}
|
|
105
|
+
if (usage === -1) {
|
|
106
|
+
if (POST_DELETE[property]) {
|
|
107
|
+
yield POST_DELETE[property](ctx, usageContext);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
if (POST_CREATE[property]) {
|
|
112
|
+
yield POST_CREATE[property](ctx, usageContext);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// update the usage
|
|
116
|
+
if (!usageContext.skipUsage) {
|
|
117
|
+
yield usageQuota.update(property, usage);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const appPreDelete = (ctx, usageContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
+
if (ctx.query.unpublish) {
|
|
122
|
+
// don't run usage decrement for unpublish
|
|
123
|
+
usageContext.skipUsage = true;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
// store the row count to delete
|
|
127
|
+
const rows = yield getUniqueRows([ctx.appId]);
|
|
128
|
+
if (rows.length) {
|
|
129
|
+
usageContext[usageQuota.Properties.APPS] = { rowCount: rows.length };
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
const appPostDelete = (ctx, usageContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
+
// delete the app rows from usage
|
|
134
|
+
const rowCount = usageContext[usageQuota.Properties.APPS].rowCount;
|
|
135
|
+
if (rowCount) {
|
|
136
|
+
yield usageQuota.update(usageQuota.Properties.ROW, -rowCount);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const appPostCreate = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
+
// app import & template creation
|
|
141
|
+
if (ctx.request.body.useTemplate === "true") {
|
|
142
|
+
const rows = yield getUniqueRows([ctx.response.body.appId]);
|
|
143
|
+
const rowCount = rows ? rows.length : 0;
|
|
144
|
+
yield usageQuota.update(usageQuota.Properties.ROW, rowCount);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
const PRE_DELETE = {
|
|
148
|
+
[usageQuota.Properties.APPS]: appPreDelete,
|
|
149
|
+
};
|
|
150
|
+
const POST_DELETE = {
|
|
151
|
+
[usageQuota.Properties.APPS]: appPostDelete,
|
|
152
|
+
};
|
|
153
|
+
const PRE_CREATE = {};
|
|
154
|
+
const POST_CREATE = {
|
|
155
|
+
[usageQuota.Properties.APPS]: appPostCreate,
|
|
156
|
+
};
|
|
@@ -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
|
+
const { MIGRATIONS, MIGRATION_DBS, migrateIfRequired, } = require("@budibase/backend-core/migrations");
|
|
12
|
+
const { useQuotas } = require("../../utilities/usageQuota");
|
|
13
|
+
const syncApps = require("./syncApps");
|
|
14
|
+
const syncRows = require("./syncRows");
|
|
15
|
+
exports.run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
if (!useQuotas()) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Jan 2022
|
|
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
|
+
}));
|
|
24
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { getGlobalDB, getTenantId } = require("@budibase/backend-core/tenancy");
|
|
12
|
+
const { getAllApps } = require("@budibase/backend-core/db");
|
|
13
|
+
const CouchDB = require("../../db");
|
|
14
|
+
const { getUsageQuotaDoc } = require("../../utilities/usageQuota");
|
|
15
|
+
exports.run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const db = getGlobalDB();
|
|
17
|
+
// get app count
|
|
18
|
+
const devApps = yield getAllApps(CouchDB, { dev: true });
|
|
19
|
+
const appCount = devApps ? devApps.length : 0;
|
|
20
|
+
// sync app count
|
|
21
|
+
const tenantId = getTenantId();
|
|
22
|
+
console.log(`[Tenant: ${tenantId}] Syncing app count: ${appCount}`);
|
|
23
|
+
const usageDoc = yield getUsageQuotaDoc(db);
|
|
24
|
+
usageDoc.usageQuota.apps = appCount;
|
|
25
|
+
yield db.put(usageDoc);
|
|
26
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { getGlobalDB, getTenantId } = require("@budibase/backend-core/tenancy");
|
|
12
|
+
const { getAllApps } = require("@budibase/backend-core/db");
|
|
13
|
+
const CouchDB = require("../../db");
|
|
14
|
+
const { getUsageQuotaDoc } = require("../../utilities/usageQuota");
|
|
15
|
+
const { getUniqueRows } = require("../../utilities/usageQuota/rows");
|
|
16
|
+
exports.run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const db = getGlobalDB();
|
|
18
|
+
// get all rows in all apps
|
|
19
|
+
const allApps = yield getAllApps(CouchDB, { all: true });
|
|
20
|
+
const appIds = allApps ? allApps.map(app => app.appId) : [];
|
|
21
|
+
const rows = yield getUniqueRows(appIds);
|
|
22
|
+
const rowCount = rows ? rows.length : 0;
|
|
23
|
+
// sync row count
|
|
24
|
+
const tenantId = getTenantId();
|
|
25
|
+
console.log(`[Tenant: ${tenantId}] Syncing row count: ${rowCount}`);
|
|
26
|
+
const usageDoc = yield getUsageQuotaDoc(db);
|
|
27
|
+
usageDoc.usageQuota.rows = rowCount;
|
|
28
|
+
yield db.put(usageDoc);
|
|
29
|
+
});
|
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.
|
|
4
|
+
"version": "1.0.46-alpha.2",
|
|
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.
|
|
74
|
-
"@budibase/client": "^1.0.
|
|
75
|
-
"@budibase/string-templates": "^1.0.
|
|
73
|
+
"@budibase/backend-core": "^1.0.46-alpha.2",
|
|
74
|
+
"@budibase/client": "^1.0.46-alpha.2",
|
|
75
|
+
"@budibase/string-templates": "^1.0.46-alpha.2",
|
|
76
76
|
"@bull-board/api": "^3.7.0",
|
|
77
77
|
"@bull-board/koa": "^3.7.0",
|
|
78
78
|
"@elastic/elasticsearch": "7.10.0",
|