@budibase/server 2.0.14-alpha.0 → 2.0.14
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.cad26add.js → index.6851c223.js} +1 -1
- package/builder/index.html +1 -1
- package/coverage/clover.xml +341 -344
- package/coverage/coverage-final.json +23 -23
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +12 -12
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +15 -15
- package/coverage/lcov-report/api/controllers/row/utils.js.html +13 -13
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +5 -5
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/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 +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/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +5 -5
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +22 -22
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +11 -11
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +11 -11
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +3 -3
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +16 -10
- 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 +2 -2
- package/coverage/lcov-report/events/utils.js.html +9 -9
- package/coverage/lcov-report/index.html +15 -15
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +11 -11
- package/coverage/lcov-report/middleware/currentapp.js.html +34 -34
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +16 -16
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +13 -13
- 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 +38 -38
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +14 -14
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +11 -23
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +613 -618
- package/dist/api/controllers/application.js +2 -2
- package/dist/api/controllers/query/index.js +6 -6
- package/dist/api/controllers/row/index.js +10 -30
- package/dist/api/controllers/table/internal.js +1 -3
- package/dist/api/controllers/table/utils.js +1 -3
- package/dist/automations/utils.js +3 -5
- package/dist/db/utils.js +1 -1
- package/dist/migrations/functions/{usageQuotas/syncPlugins.js → pluginCount.js} +3 -1
- package/dist/migrations/functions/{syncQuotas.js → quotas1.js} +7 -3
- package/dist/migrations/functions/usageQuotas/syncApps.js +1 -0
- package/dist/migrations/functions/usageQuotas/syncRows.js +5 -9
- package/dist/migrations/index.js +9 -3
- package/dist/package.json +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/usageQuota/rows.js +4 -6
- package/package.json +7 -7
- package/src/api/controllers/application.ts +2 -2
- package/src/api/controllers/query/index.ts +6 -7
- package/src/api/controllers/row/index.ts +13 -36
- package/src/api/controllers/table/internal.ts +1 -3
- package/src/api/controllers/table/utils.ts +1 -3
- package/src/api/routes/tests/row.spec.js +27 -22
- package/src/automations/tests/automation.spec.js +6 -1
- package/src/automations/utils.ts +4 -6
- package/src/db/utils.js +2 -0
- package/src/migrations/functions/backfill/global.ts +1 -1
- package/src/migrations/functions/pluginCount.ts +12 -0
- package/src/migrations/functions/{syncQuotas.ts → quotas1.ts} +8 -3
- package/src/migrations/functions/tests/{syncQuotas.spec.js → quotas1.spec.js} +2 -5
- package/src/migrations/functions/usageQuotas/syncApps.ts +1 -0
- package/src/migrations/functions/usageQuotas/syncRows.ts +6 -15
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +1 -9
- package/src/migrations/index.ts +15 -3
- package/src/migrations/tests/index.spec.ts +1 -0
- package/src/utilities/usageQuota/rows.js +3 -7
- package/src/migrations/functions/usageQuotas/syncPlugins.ts +0 -10
|
@@ -313,7 +313,7 @@ const appPostCreate = (ctx, app) => __awaiter(void 0, void 0, void 0, function*
|
|
|
313
313
|
yield creationEvents(ctx.request, app);
|
|
314
314
|
// app import & template creation
|
|
315
315
|
if (ctx.request.body.useTemplate === "true") {
|
|
316
|
-
const
|
|
316
|
+
const rows = yield (0, rows_1.getUniqueRows)([app.appId]);
|
|
317
317
|
const rowCount = rows ? rows.length : 0;
|
|
318
318
|
if (rowCount) {
|
|
319
319
|
try {
|
|
@@ -438,7 +438,7 @@ const destroyApp = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
438
438
|
return result;
|
|
439
439
|
});
|
|
440
440
|
const preDestroyApp = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
441
|
-
const
|
|
441
|
+
const rows = yield (0, rows_1.getUniqueRows)([ctx.params.appId]);
|
|
442
442
|
ctx.rowCount = rows.length;
|
|
443
443
|
});
|
|
444
444
|
const postDestroyApp = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -149,9 +149,7 @@ function preview(ctx) {
|
|
|
149
149
|
auth: Object.assign({}, authConfigCtx),
|
|
150
150
|
},
|
|
151
151
|
});
|
|
152
|
-
const { rows, keys, info, extra } = yield pro_1.quotas.addQuery(runFn
|
|
153
|
-
datasourceId: datasource._id,
|
|
154
|
-
});
|
|
152
|
+
const { rows, keys, info, extra } = yield pro_1.quotas.addQuery(runFn);
|
|
155
153
|
const schemaFields = {};
|
|
156
154
|
if ((rows === null || rows === void 0 ? void 0 : rows.length) > 0) {
|
|
157
155
|
for (let key of [...new Set(keys)]) {
|
|
@@ -228,9 +226,11 @@ function execute(ctx, opts = { rowsOnly: false, isAutomation: false }) {
|
|
|
228
226
|
auth: Object.assign({}, authConfigCtx),
|
|
229
227
|
},
|
|
230
228
|
});
|
|
231
|
-
const { rows, pagination, extra } = yield pro_1.quotas.addQuery(runFn
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
const { rows, pagination, extra } = yield pro_1.quotas.addQuery(runFn);
|
|
230
|
+
// remove the raw from execution incase transformer being used to hide data
|
|
231
|
+
if (extra === null || extra === void 0 ? void 0 : extra.raw) {
|
|
232
|
+
delete extra.raw;
|
|
233
|
+
}
|
|
234
234
|
if (opts && opts.rowsOnly) {
|
|
235
235
|
ctx.body = rows;
|
|
236
236
|
}
|
|
@@ -44,9 +44,7 @@ function patch(ctx) {
|
|
|
44
44
|
return (0, exports.save)(ctx);
|
|
45
45
|
}
|
|
46
46
|
try {
|
|
47
|
-
const { row, table } = yield pro_1.quotas.addQuery(() => pickApi(tableId).patch(ctx)
|
|
48
|
-
datasourceId: tableId,
|
|
49
|
-
});
|
|
47
|
+
const { row, table } = yield pro_1.quotas.addQuery(() => pickApi(tableId).patch(ctx));
|
|
50
48
|
ctx.status = 200;
|
|
51
49
|
ctx.eventEmitter &&
|
|
52
50
|
ctx.eventEmitter.emitRow(`row:update`, appId, row, table);
|
|
@@ -68,9 +66,7 @@ const save = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
68
66
|
return patch(ctx);
|
|
69
67
|
}
|
|
70
68
|
try {
|
|
71
|
-
const { row, table } = yield pro_1.quotas.addRow(() => pro_1.quotas.addQuery(() => pickApi(tableId).save(ctx)
|
|
72
|
-
datasourceId: tableId,
|
|
73
|
-
}));
|
|
69
|
+
const { row, table } = yield pro_1.quotas.addRow(() => pro_1.quotas.addQuery(() => pickApi(tableId).save(ctx)));
|
|
74
70
|
ctx.status = 200;
|
|
75
71
|
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:save`, appId, row, table);
|
|
76
72
|
ctx.message = `${table.name} saved successfully`;
|
|
@@ -85,9 +81,7 @@ function fetchView(ctx) {
|
|
|
85
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
82
|
const tableId = getTableId(ctx);
|
|
87
83
|
try {
|
|
88
|
-
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).fetchView(ctx)
|
|
89
|
-
datasourceId: tableId,
|
|
90
|
-
});
|
|
84
|
+
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).fetchView(ctx));
|
|
91
85
|
}
|
|
92
86
|
catch (err) {
|
|
93
87
|
ctx.throw(400, err);
|
|
@@ -99,9 +93,7 @@ function fetch(ctx) {
|
|
|
99
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
94
|
const tableId = getTableId(ctx);
|
|
101
95
|
try {
|
|
102
|
-
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).fetch(ctx)
|
|
103
|
-
datasourceId: tableId,
|
|
104
|
-
});
|
|
96
|
+
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).fetch(ctx));
|
|
105
97
|
}
|
|
106
98
|
catch (err) {
|
|
107
99
|
ctx.throw(400, err);
|
|
@@ -113,9 +105,7 @@ function find(ctx) {
|
|
|
113
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
106
|
const tableId = getTableId(ctx);
|
|
115
107
|
try {
|
|
116
|
-
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).find(ctx)
|
|
117
|
-
datasourceId: tableId,
|
|
118
|
-
});
|
|
108
|
+
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).find(ctx));
|
|
119
109
|
}
|
|
120
110
|
catch (err) {
|
|
121
111
|
ctx.throw(400, err);
|
|
@@ -130,9 +120,7 @@ function destroy(ctx) {
|
|
|
130
120
|
const tableId = getTableId(ctx);
|
|
131
121
|
let response, row;
|
|
132
122
|
if (inputs.rows) {
|
|
133
|
-
let { rows } = yield pro_1.quotas.addQuery(() => pickApi(tableId).bulkDestroy(ctx)
|
|
134
|
-
datasourceId: tableId,
|
|
135
|
-
});
|
|
123
|
+
let { rows } = yield pro_1.quotas.addQuery(() => pickApi(tableId).bulkDestroy(ctx));
|
|
136
124
|
yield pro_1.quotas.removeRows(rows.length);
|
|
137
125
|
response = rows;
|
|
138
126
|
for (let row of rows) {
|
|
@@ -140,9 +128,7 @@ function destroy(ctx) {
|
|
|
140
128
|
}
|
|
141
129
|
}
|
|
142
130
|
else {
|
|
143
|
-
let resp = yield pro_1.quotas.addQuery(() => pickApi(tableId).destroy(ctx)
|
|
144
|
-
datasourceId: tableId,
|
|
145
|
-
});
|
|
131
|
+
let resp = yield pro_1.quotas.addQuery(() => pickApi(tableId).destroy(ctx));
|
|
146
132
|
yield pro_1.quotas.removeRow();
|
|
147
133
|
response = resp.response;
|
|
148
134
|
row = resp.row;
|
|
@@ -160,9 +146,7 @@ function search(ctx) {
|
|
|
160
146
|
const tableId = getTableId(ctx);
|
|
161
147
|
try {
|
|
162
148
|
ctx.status = 200;
|
|
163
|
-
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).search(ctx)
|
|
164
|
-
datasourceId: tableId,
|
|
165
|
-
});
|
|
149
|
+
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).search(ctx));
|
|
166
150
|
}
|
|
167
151
|
catch (err) {
|
|
168
152
|
ctx.throw(400, err);
|
|
@@ -186,9 +170,7 @@ function fetchEnrichedRow(ctx) {
|
|
|
186
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
171
|
const tableId = getTableId(ctx);
|
|
188
172
|
try {
|
|
189
|
-
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).fetchEnrichedRow(ctx)
|
|
190
|
-
datasourceId: tableId,
|
|
191
|
-
});
|
|
173
|
+
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).fetchEnrichedRow(ctx));
|
|
192
174
|
}
|
|
193
175
|
catch (err) {
|
|
194
176
|
ctx.throw(400, err);
|
|
@@ -199,9 +181,7 @@ exports.fetchEnrichedRow = fetchEnrichedRow;
|
|
|
199
181
|
const exportRows = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
200
182
|
const tableId = getTableId(ctx);
|
|
201
183
|
try {
|
|
202
|
-
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).exportRows(ctx)
|
|
203
|
-
datasourceId: tableId,
|
|
204
|
-
});
|
|
184
|
+
ctx.body = yield pro_1.quotas.addQuery(() => pickApi(tableId).exportRows(ctx));
|
|
205
185
|
}
|
|
206
186
|
catch (err) {
|
|
207
187
|
ctx.throw(400, err);
|
|
@@ -142,9 +142,7 @@ function destroy(ctx) {
|
|
|
142
142
|
include_docs: true,
|
|
143
143
|
}));
|
|
144
144
|
yield db.bulkDocs(rows.rows.map((row) => (Object.assign(Object.assign({}, row.doc), { _deleted: true }))));
|
|
145
|
-
yield pro_1.quotas.removeRows(rows.rows.length
|
|
146
|
-
tableId: ctx.params.tableId,
|
|
147
|
-
});
|
|
145
|
+
yield pro_1.quotas.removeRows(rows.rows.length);
|
|
148
146
|
// update linked rows
|
|
149
147
|
yield (0, linkedRows_1.updateLinks)({
|
|
150
148
|
eventType: linkedRows_1.EventType.TABLE_DELETE,
|
|
@@ -130,9 +130,7 @@ function handleDataImport(user, table, dataImport) {
|
|
|
130
130
|
}
|
|
131
131
|
finalData.push(row);
|
|
132
132
|
}
|
|
133
|
-
yield pro_1.quotas.addRows(finalData.length, () => db.bulkDocs(finalData)
|
|
134
|
-
tableId: table._id,
|
|
135
|
-
});
|
|
133
|
+
yield pro_1.quotas.addRows(finalData.length, () => db.bulkDocs(finalData));
|
|
136
134
|
yield backend_core_1.events.rows.imported(table, "csv", finalData.length);
|
|
137
135
|
return table;
|
|
138
136
|
});
|
|
@@ -59,14 +59,12 @@ const jobMessage = (job, message) => {
|
|
|
59
59
|
function processEvent(job) {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
61
|
try {
|
|
62
|
-
const automationId = job.data.automation._id;
|
|
63
62
|
console.log(jobMessage(job, "running"));
|
|
64
63
|
// need to actually await these so that an error can be captured properly
|
|
65
|
-
|
|
64
|
+
const tenantId = backend_core_1.tenancy.getTenantIDFromAppID(job.data.event.appId);
|
|
65
|
+
return yield backend_core_1.tenancy.doInTenant(tenantId, () => __awaiter(this, void 0, void 0, function* () {
|
|
66
66
|
const runFn = () => Runner.run(job);
|
|
67
|
-
return pro_1.quotas.addAutomation(runFn
|
|
68
|
-
automationId,
|
|
69
|
-
});
|
|
67
|
+
return pro_1.quotas.addAutomation(runFn);
|
|
70
68
|
}));
|
|
71
69
|
}
|
|
72
70
|
catch (err) {
|
package/dist/db/utils.js
CHANGED
|
@@ -7,7 +7,7 @@ const AppStatus = {
|
|
|
7
7
|
ALL: "all",
|
|
8
8
|
DEPLOYED: "published",
|
|
9
9
|
};
|
|
10
|
-
const DocumentType = Object.assign(Object.assign({}, CoreDocTypes), { TABLE: "ta", ROW: "ro", USER: "us", AUTOMATION: "au", LINK: "li", WEBHOOK: "wh", INSTANCE: "inst", LAYOUT: "layout", SCREEN: "screen", QUERY: "query", DEPLOYMENTS: "deployments", METADATA: "metadata", MEM_VIEW: "view", USER_FLAG: "flag", AUTOMATION_METADATA: "meta_au" });
|
|
10
|
+
const DocumentType = Object.assign(Object.assign({}, CoreDocTypes), { TABLE: "ta", ROW: "ro", USER: "us", AUTOMATION: "au", LINK: "li", WEBHOOK: "wh", INSTANCE: "inst", LAYOUT: "layout", SCREEN: "screen", DATASOURCE: "datasource", DATASOURCE_PLUS: "datasource_plus", QUERY: "query", DEPLOYMENTS: "deployments", METADATA: "metadata", MEM_VIEW: "view", USER_FLAG: "flag", AUTOMATION_METADATA: "meta_au" });
|
|
11
11
|
const InternalTables = {
|
|
12
12
|
USER_METADATA: "ta_users",
|
|
13
13
|
};
|
|
@@ -14,7 +14,9 @@ const backend_core_1 = require("@budibase/backend-core");
|
|
|
14
14
|
const pro_1 = require("@budibase/pro");
|
|
15
15
|
const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
try {
|
|
17
|
-
yield
|
|
17
|
+
yield backend_core_1.tenancy.doInTenant(backend_core_1.tenancy.DEFAULT_TENANT_ID, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
yield pro_1.plugins.checkPluginQuotas();
|
|
19
|
+
}));
|
|
18
20
|
}
|
|
19
21
|
catch (err) {
|
|
20
22
|
backend_core_1.logging.logAlert("Failed to update plugin quotas", err);
|
|
@@ -36,15 +36,19 @@ exports.run = void 0;
|
|
|
36
36
|
const usageQuotas_1 = require("./usageQuotas");
|
|
37
37
|
const syncApps = __importStar(require("./usageQuotas/syncApps"));
|
|
38
38
|
const syncRows = __importStar(require("./usageQuotas/syncRows"));
|
|
39
|
-
const syncPlugins = __importStar(require("./usageQuotas/syncPlugins"));
|
|
40
39
|
/**
|
|
41
|
-
*
|
|
40
|
+
* Date:
|
|
41
|
+
* January 2022
|
|
42
|
+
*
|
|
43
|
+
* Description:
|
|
44
|
+
* Synchronise the app and row quotas to the state of the db after it was
|
|
45
|
+
* discovered that the quota resets were still in place and the row quotas
|
|
46
|
+
* weren't being decremented correctly.
|
|
42
47
|
*/
|
|
43
48
|
const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
49
|
yield (0, usageQuotas_1.runQuotaMigration)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
50
|
yield syncApps.run();
|
|
46
51
|
yield syncRows.run();
|
|
47
|
-
yield syncPlugins.run();
|
|
48
52
|
}));
|
|
49
53
|
});
|
|
50
54
|
exports.run = run;
|
|
@@ -16,6 +16,7 @@ const pro_1 = require("@budibase/pro");
|
|
|
16
16
|
const types_1 = require("@budibase/types");
|
|
17
17
|
const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
// get app count
|
|
19
|
+
// @ts-ignore
|
|
19
20
|
const devApps = yield (0, db_1.getAllApps)({ dev: true });
|
|
20
21
|
const appCount = devApps ? devApps.length : 0;
|
|
21
22
|
// sync app count
|
|
@@ -17,19 +17,15 @@ const pro_1 = require("@budibase/pro");
|
|
|
17
17
|
const types_1 = require("@budibase/types");
|
|
18
18
|
const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
// get all rows in all apps
|
|
20
|
+
// @ts-ignore
|
|
20
21
|
const allApps = yield (0, db_1.getAllApps)({ all: true });
|
|
22
|
+
// @ts-ignore
|
|
21
23
|
const appIds = allApps ? allApps.map((app) => app.appId) : [];
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const counts = {};
|
|
25
|
-
let rowCount = 0;
|
|
26
|
-
Object.entries(appRows).forEach(([appId, rows]) => {
|
|
27
|
-
counts[appId] = rows.length;
|
|
28
|
-
rowCount += rows.length;
|
|
29
|
-
});
|
|
24
|
+
const rows = yield (0, rows_1.getUniqueRows)(appIds);
|
|
25
|
+
const rowCount = rows ? rows.length : 0;
|
|
30
26
|
// sync row count
|
|
31
27
|
const tenantId = (0, tenancy_1.getTenantId)();
|
|
32
28
|
console.log(`[Tenant: ${tenantId}] Syncing row count: ${rowCount}`);
|
|
33
|
-
yield pro_1.quotas.
|
|
29
|
+
yield pro_1.quotas.setUsage(rowCount, types_1.StaticQuotaName.ROWS, types_1.QuotaUsageType.STATIC);
|
|
34
30
|
});
|
|
35
31
|
exports.run = run;
|
package/dist/migrations/index.js
CHANGED
|
@@ -41,9 +41,10 @@ const types_1 = require("@budibase/types");
|
|
|
41
41
|
const environment_1 = __importDefault(require("../environment"));
|
|
42
42
|
// migration functions
|
|
43
43
|
const userEmailViewCasing = __importStar(require("./functions/userEmailViewCasing"));
|
|
44
|
-
const
|
|
44
|
+
const quota1 = __importStar(require("./functions/quotas1"));
|
|
45
45
|
const appUrls = __importStar(require("./functions/appUrls"));
|
|
46
46
|
const backfill = __importStar(require("./functions/backfill"));
|
|
47
|
+
const pluginCount = __importStar(require("./functions/pluginCount"));
|
|
47
48
|
/**
|
|
48
49
|
* Populate the migration function and additional configuration from
|
|
49
50
|
* the static migration definitions.
|
|
@@ -57,8 +58,8 @@ const buildMigrations = () => {
|
|
|
57
58
|
serverMigrations.push(Object.assign(Object.assign({}, definition), { fn: userEmailViewCasing.run }));
|
|
58
59
|
break;
|
|
59
60
|
}
|
|
60
|
-
case types_1.MigrationName.
|
|
61
|
-
serverMigrations.push(Object.assign(Object.assign({}, definition), { fn:
|
|
61
|
+
case types_1.MigrationName.QUOTAS_1: {
|
|
62
|
+
serverMigrations.push(Object.assign(Object.assign({}, definition), { fn: quota1.run }));
|
|
62
63
|
break;
|
|
63
64
|
}
|
|
64
65
|
case types_1.MigrationName.APP_URLS: {
|
|
@@ -77,6 +78,11 @@ const buildMigrations = () => {
|
|
|
77
78
|
serverMigrations.push(Object.assign(Object.assign({}, definition), { fn: backfill.installation.run, silent: !!environment_1.default.SELF_HOSTED, preventRetry: !!environment_1.default.SELF_HOSTED }));
|
|
78
79
|
break;
|
|
79
80
|
}
|
|
81
|
+
case types_1.MigrationName.PLUGIN_COUNT: {
|
|
82
|
+
if (environment_1.default.SELF_HOSTED) {
|
|
83
|
+
serverMigrations.push(Object.assign(Object.assign({}, definition), { fn: pluginCount.run, silent: !!environment_1.default.SELF_HOSTED, preventRetry: false }));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
88
|
return serverMigrations;
|