@budibase/server 1.0.46-alpha.7 → 1.0.48
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.dd9e386f.css → index.39e01193.css} +1 -1
- package/builder/assets/{index.af9e71d8.js → index.e083dcaf.js} +221 -223
- package/builder/assets/{vendor.3bd2f661.js → vendor.f9faf6ab.js} +12 -12
- package/builder/index.html +3 -3
- package/coverage/clover.xml +1637 -1793
- package/coverage/coverage-final.json +94 -98
- 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 +126 -210
- 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 +4 -4
- package/coverage/lcov-report/api/controllers/datasource.js.html +36 -72
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/{migrations/usageQuotas/syncRows.js.html → api/controllers/hosting.js.html} +44 -41
- package/coverage/lcov-report/api/controllers/index.html +42 -27
- 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 +57 -39
- 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 +32 -32
- package/coverage/lcov-report/api/controllers/table/index.js.html +39 -57
- package/coverage/lcov-report/api/controllers/table/internal.js.html +34 -40
- package/coverage/lcov-report/api/controllers/table/utils.js.html +122 -83
- 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 +10 -10
- 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/{migrations/usageQuotas/syncApps.js.html → api/routes/hosting.js.html} +27 -42
- 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/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 +2 -17
- 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 +19 -13
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +20 -11
- 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 +11 -11
- package/coverage/lcov-report/constants/index.js.html +37 -40
- 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 +85 -85
- 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 +86 -116
- 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 +11 -11
- package/coverage/lcov-report/middleware/builder.js.html +8 -8
- package/coverage/lcov-report/middleware/currentapp.js.html +29 -29
- package/coverage/lcov-report/middleware/index.html +20 -20
- 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 +41 -275
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +15 -15
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +8 -23
- 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 +26 -26
- package/coverage/lcov-report/utilities/index.html +19 -19
- 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/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +108 -39
- package/coverage/lcov.info +2332 -2599
- package/dist/api/controllers/application.js +20 -49
- package/dist/api/controllers/datasource.js +0 -11
- package/dist/api/controllers/hosting.js +30 -0
- package/dist/api/controllers/row/ExternalRequest.js +2 -1
- package/dist/api/controllers/row/utils.js +8 -6
- package/dist/api/controllers/static/index.js +10 -59
- package/dist/api/controllers/table/index.js +4 -10
- package/dist/api/controllers/table/internal.js +0 -2
- package/dist/api/controllers/table/utils.js +17 -11
- package/dist/api/routes/hosting.js +11 -0
- package/dist/api/routes/index.js +2 -0
- package/dist/api/routes/static.js +1 -2
- package/dist/automations/steps/createRow.js +4 -2
- package/dist/automations/steps/deleteRow.js +4 -1
- package/dist/constants/index.js +5 -8
- package/dist/definitions/datasource.js +0 -1
- package/dist/environment.js +0 -1
- package/dist/integrations/base/sql.js +6 -13
- package/dist/integrations/index.js +0 -3
- package/dist/integrations/utils.js +9 -56
- package/dist/middleware/usageQuota.js +13 -82
- package/dist/package.json +5 -8
- package/dist/tests/utilities/TestConfiguration.js +1 -3
- package/dist/threads/query.js +0 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/{usageQuota/index.js → usageQuota.js} +31 -44
- package/dist/utilities/workerRequests.js +20 -0
- package/nodemon.json +1 -1
- package/package.json +6 -9
- package/src/api/controllers/application.js +24 -52
- package/src/api/controllers/datasource.js +0 -12
- package/src/api/controllers/hosting.js +22 -0
- package/src/api/controllers/row/ExternalRequest.ts +1 -1
- package/src/api/controllers/row/utils.js +12 -6
- package/src/api/controllers/static/index.js +10 -63
- package/src/api/controllers/table/index.js +9 -15
- package/src/api/controllers/table/internal.js +0 -2
- package/src/api/controllers/table/utils.js +24 -11
- package/src/api/routes/hosting.js +13 -0
- package/src/api/routes/index.js +2 -0
- package/src/api/routes/static.js +0 -5
- package/src/api/routes/tests/application.spec.js +2 -2
- package/src/api/routes/tests/hosting.spec.js +36 -0
- package/src/automations/steps/createRow.js +4 -2
- package/src/automations/steps/deleteRow.js +4 -1
- package/src/constants/index.js +8 -9
- package/src/definitions/datasource.ts +0 -3
- package/src/environment.js +0 -1
- package/src/integrations/base/sql.ts +7 -14
- package/src/integrations/index.ts +0 -3
- package/src/integrations/tests/sql.spec.js +0 -16
- package/src/integrations/utils.ts +11 -70
- package/src/middleware/tests/usageQuota.spec.js +24 -18
- package/src/middleware/usageQuota.js +15 -93
- package/src/tests/utilities/TestConfiguration.js +1 -3
- package/src/threads/query.js +0 -5
- package/src/utilities/usageQuota.js +73 -0
- package/src/utilities/workerRequests.js +23 -0
- package/coverage/lcov-report/migrations/usageQuotas/index.html +0 -141
- package/coverage/lcov-report/migrations/usageQuotas/index.js.html +0 -152
- package/coverage/lcov-report/utilities/usageQuota/index.html +0 -141
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +0 -356
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +0 -302
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +0 -134
- package/dist/integrations/googlesheets.js +0 -340
- package/dist/migrations/usageQuotas/index.js +0 -24
- package/dist/migrations/usageQuotas/syncApps.js +0 -26
- package/dist/migrations/usageQuotas/syncRows.js +0 -29
- package/dist/utilities/usageQuota/rows.js +0 -77
- package/dist/utilities/usageQuota/usageQuoteReset.js +0 -16
- package/src/api/routes/tests/static.spec.js +0 -98
- package/src/integrations/googlesheets.ts +0 -353
- package/src/migrations/tests/usageQuotas/index.spec.js +0 -27
- package/src/migrations/tests/usageQuotas/syncApps.spec.js +0 -37
- package/src/migrations/tests/usageQuotas/syncRows.spec.js +0 -43
- package/src/migrations/usageQuotas/index.js +0 -24
- package/src/migrations/usageQuotas/syncApps.js +0 -18
- package/src/migrations/usageQuotas/syncRows.js +0 -21
- package/src/utilities/tests/usageQuota/usageQuota.spec.js +0 -72
- package/src/utilities/usageQuota/index.js +0 -92
- package/src/utilities/usageQuota/rows.js +0 -74
- package/src/utilities/usageQuota/usageQuoteReset.js +0 -18
|
@@ -10,7 +10,6 @@ const airtable = require("./airtable");
|
|
|
10
10
|
const mysql = require("./mysql");
|
|
11
11
|
const arangodb = require("./arangodb");
|
|
12
12
|
const rest = require("./rest");
|
|
13
|
-
const googlesheets = require("./googlesheets");
|
|
14
13
|
const { SourceNames } = require("../definitions/datasource");
|
|
15
14
|
const DEFINITIONS = {
|
|
16
15
|
[SourceNames.POSTGRES]: postgres.schema,
|
|
@@ -24,7 +23,6 @@ const DEFINITIONS = {
|
|
|
24
23
|
[SourceNames.MYSQL]: mysql.schema,
|
|
25
24
|
[SourceNames.ARANGODB]: arangodb.schema,
|
|
26
25
|
[SourceNames.REST]: rest.schema,
|
|
27
|
-
[SourceNames.GOOGLE_SHEETS]: googlesheets.schema,
|
|
28
26
|
};
|
|
29
27
|
const INTEGRATIONS = {
|
|
30
28
|
[SourceNames.POSTGRES]: postgres.integration,
|
|
@@ -38,7 +36,6 @@ const INTEGRATIONS = {
|
|
|
38
36
|
[SourceNames.MYSQL]: mysql.integration,
|
|
39
37
|
[SourceNames.ARANGODB]: arangodb.integration,
|
|
40
38
|
[SourceNames.REST]: rest.integration,
|
|
41
|
-
[SourceNames.GOOGLE_SHEETS]: googlesheets.integration,
|
|
42
39
|
};
|
|
43
40
|
// optionally add oracle integration if the oracle binary can be installed
|
|
44
41
|
if (!(process.arch === "arm64" && process.platform === "darwin")) {
|
|
@@ -125,12 +125,7 @@ function isSQL(datasource) {
|
|
|
125
125
|
if (!datasource || !datasource.source) {
|
|
126
126
|
return false;
|
|
127
127
|
}
|
|
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
|
-
];
|
|
128
|
+
const SQL = [datasource_1.SourceNames.POSTGRES, datasource_1.SourceNames.SQL_SERVER, datasource_1.SourceNames.MYSQL];
|
|
134
129
|
return SQL.indexOf(datasource.source) !== -1;
|
|
135
130
|
}
|
|
136
131
|
exports.isSQL = isSQL;
|
|
@@ -142,43 +137,8 @@ function isIsoDateString(str) {
|
|
|
142
137
|
return d.toISOString() === str;
|
|
143
138
|
}
|
|
144
139
|
exports.isIsoDateString = isIsoDateString;
|
|
145
|
-
|
|
146
|
-
|
|
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 &&
|
|
157
|
-
column.tableId &&
|
|
158
|
-
tableIds.includes(column.tableId));
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Similar function to the shouldCopyRelationship function, but instead this looks for options and boolean
|
|
162
|
-
* types. It is possible to switch a string -> options and a number -> boolean (and vice versus) need to make
|
|
163
|
-
* sure that these get copied over when tables are fetched. Also checks whether they are still valid, if a
|
|
164
|
-
* column has changed type in the external database then copying it over may not be possible.
|
|
165
|
-
* @param column The column to check for options or boolean type.
|
|
166
|
-
* @param fetchedColumn The fetched column to check for the type in the external database.
|
|
167
|
-
*/
|
|
168
|
-
function shouldCopySpecialColumn(column, fetchedColumn) {
|
|
169
|
-
return (column.type === constants_1.FieldTypes.OPTIONS ||
|
|
170
|
-
((!fetchedColumn || fetchedColumn.type === constants_1.FieldTypes.NUMBER) &&
|
|
171
|
-
column.type === constants_1.FieldTypes.BOOLEAN));
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Looks for columns which need to be copied over into the new table definitions, like relationships
|
|
175
|
-
* and options types.
|
|
176
|
-
* @param tableName The name of the table which is being checked.
|
|
177
|
-
* @param table The specific table which is being checked.
|
|
178
|
-
* @param entities All the tables that existed before - the old table definitions.
|
|
179
|
-
* @param tableIds The IDs of the tables which exist now, to check if anything has been removed.
|
|
180
|
-
*/
|
|
181
|
-
function copyExistingPropsOver(tableName, table, entities, tableIds) {
|
|
140
|
+
// add the existing relationships from the entities if they exist, to prevent them from being overridden
|
|
141
|
+
function copyExistingPropsOver(tableName, table, entities) {
|
|
182
142
|
if (entities && entities[tableName]) {
|
|
183
143
|
if (entities[tableName].primaryDisplay) {
|
|
184
144
|
table.primaryDisplay = entities[tableName].primaryDisplay;
|
|
@@ -188,28 +148,21 @@ function copyExistingPropsOver(tableName, table, entities, tableIds) {
|
|
|
188
148
|
if (!existingTableSchema.hasOwnProperty(key)) {
|
|
189
149
|
continue;
|
|
190
150
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
151
|
+
if (existingTableSchema[key].type === constants_1.FieldTypes.LINK ||
|
|
152
|
+
existingTableSchema[key].type === constants_1.FieldTypes.OPTIONS ||
|
|
153
|
+
existingTableSchema[key].type === constants_1.FieldTypes.ARRAY ||
|
|
154
|
+
((!table.schema[key] || table.schema[key].type === constants_1.FieldTypes.NUMBER) &&
|
|
155
|
+
existingTableSchema[key].type === constants_1.FieldTypes.BOOLEAN)) {
|
|
194
156
|
table.schema[key] = existingTableSchema[key];
|
|
195
157
|
}
|
|
196
158
|
}
|
|
197
159
|
}
|
|
198
160
|
return table;
|
|
199
161
|
}
|
|
200
|
-
/**
|
|
201
|
-
* Look through the final table definitions to see if anything needs to be
|
|
202
|
-
* copied over from the old and if any errors have occurred mark them so
|
|
203
|
-
* that the user can be made aware.
|
|
204
|
-
* @param tables The list of tables that have been retrieved from the external database.
|
|
205
|
-
* @param entities The old list of tables, if there was any to look for definitions in.
|
|
206
|
-
*/
|
|
207
162
|
function finaliseExternalTables(tables, entities) {
|
|
208
163
|
const invalidColumns = Object.values(constants_1.InvalidColumns);
|
|
209
164
|
let finalTables = {};
|
|
210
165
|
const errors = {};
|
|
211
|
-
// @ts-ignore
|
|
212
|
-
const tableIds = Object.values(tables).map(table => table._id);
|
|
213
166
|
for (let [name, table] of Object.entries(tables)) {
|
|
214
167
|
const schemaFields = Object.keys(table.schema);
|
|
215
168
|
// make sure every table has a key
|
|
@@ -222,7 +175,7 @@ function finaliseExternalTables(tables, entities) {
|
|
|
222
175
|
continue;
|
|
223
176
|
}
|
|
224
177
|
// make sure all previous props have been added back
|
|
225
|
-
finalTables[name] = copyExistingPropsOver(name, table, entities
|
|
178
|
+
finalTables[name] = copyExistingPropsOver(name, table, entities);
|
|
226
179
|
}
|
|
227
180
|
// sort the tables by name
|
|
228
181
|
finalTables = Object.entries(finalTables)
|
|
@@ -10,9 +10,11 @@ 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
|
|
13
|
+
const env = require("../environment");
|
|
14
|
+
const { getTenantId } = require("@budibase/backend-core/tenancy");
|
|
14
15
|
const { isExternalTable, isRowId: isExternalRowId, } = require("../integrations/utils");
|
|
15
|
-
|
|
16
|
+
// tenants without limits
|
|
17
|
+
const EXCLUDED_TENANTS = ["bb", "default", "bbtest", "bbstaging"];
|
|
16
18
|
// currently only counting new writes and deletes
|
|
17
19
|
const METHOD_MAP = {
|
|
18
20
|
POST: 1,
|
|
@@ -20,13 +22,13 @@ const METHOD_MAP = {
|
|
|
20
22
|
};
|
|
21
23
|
const DOMAIN_MAP = {
|
|
22
24
|
rows: usageQuota.Properties.ROW,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
upload: usageQuota.Properties.UPLOAD,
|
|
26
|
+
views: usageQuota.Properties.VIEW,
|
|
27
|
+
users: usageQuota.Properties.USER,
|
|
26
28
|
applications: usageQuota.Properties.APPS,
|
|
27
29
|
// this will not be updated by endpoint calls
|
|
28
30
|
// instead it will be updated by triggerInfo
|
|
29
|
-
|
|
31
|
+
automationRuns: usageQuota.Properties.AUTOMATION,
|
|
30
32
|
};
|
|
31
33
|
function getProperty(url) {
|
|
32
34
|
for (let domain of Object.keys(DOMAIN_MAP)) {
|
|
@@ -36,7 +38,9 @@ function getProperty(url) {
|
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
|
|
41
|
+
const tenantId = getTenantId();
|
|
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)) {
|
|
40
44
|
return next();
|
|
41
45
|
}
|
|
42
46
|
let usage = METHOD_MAP[ctx.req.method];
|
|
@@ -74,83 +78,10 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
74
78
|
usage = files.map(file => file.size).reduce((total, size) => total + size);
|
|
75
79
|
}
|
|
76
80
|
try {
|
|
77
|
-
yield
|
|
78
|
-
|
|
81
|
+
yield usageQuota.update(property, usage);
|
|
82
|
+
return next();
|
|
79
83
|
}
|
|
80
84
|
catch (err) {
|
|
81
85
|
ctx.throw(400, err);
|
|
82
86
|
}
|
|
83
87
|
});
|
|
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
|
-
};
|
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.47",
|
|
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.47",
|
|
74
|
+
"@budibase/client": "^1.0.47",
|
|
75
|
+
"@budibase/string-templates": "^1.0.47",
|
|
76
76
|
"@bull-board/api": "^3.7.0",
|
|
77
77
|
"@bull-board/koa": "^3.7.0",
|
|
78
78
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -92,8 +92,6 @@
|
|
|
92
92
|
"fix-path": "3.0.0",
|
|
93
93
|
"form-data": "^4.0.0",
|
|
94
94
|
"fs-extra": "8.1.0",
|
|
95
|
-
"google-auth-library": "^7.11.0",
|
|
96
|
-
"google-spreadsheet": "^3.2.0",
|
|
97
95
|
"jimp": "0.16.1",
|
|
98
96
|
"joi": "17.2.1",
|
|
99
97
|
"js-yaml": "^4.1.0",
|
|
@@ -112,7 +110,7 @@
|
|
|
112
110
|
"mongodb": "3.6.3",
|
|
113
111
|
"mssql": "6.2.3",
|
|
114
112
|
"mysql2": "^2.3.1",
|
|
115
|
-
"node-fetch": "2.6.
|
|
113
|
+
"node-fetch": "2.6.0",
|
|
116
114
|
"open": "^8.4.0",
|
|
117
115
|
"pg": "8.5.1",
|
|
118
116
|
"pino-pretty": "4.0.0",
|
|
@@ -141,7 +139,6 @@
|
|
|
141
139
|
"@jest/test-sequencer": "^24.8.0",
|
|
142
140
|
"@types/apidoc": "^0.50.0",
|
|
143
141
|
"@types/bull": "^3.15.1",
|
|
144
|
-
"@types/google-spreadsheet": "^3.1.5",
|
|
145
142
|
"@types/jest": "^26.0.23",
|
|
146
143
|
"@types/koa": "^2.13.3",
|
|
147
144
|
"@types/koa-router": "^7.4.2",
|
|
@@ -21,7 +21,6 @@ const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
|
21
21
|
const { createASession } = require("@budibase/backend-core/sessions");
|
|
22
22
|
const { user: userCache } = require("@budibase/backend-core/cache");
|
|
23
23
|
const CouchDB = require("../../db");
|
|
24
|
-
const newid = require("../../db/newid");
|
|
25
24
|
core.init(CouchDB);
|
|
26
25
|
const GLOBAL_USER_ID = "us_uuid1";
|
|
27
26
|
const EMAIL = "babs@babs.com";
|
|
@@ -84,8 +83,7 @@ class TestConfiguration {
|
|
|
84
83
|
return Object.assign({ _rev: resp._rev }, user);
|
|
85
84
|
});
|
|
86
85
|
}
|
|
87
|
-
|
|
88
|
-
init(appName = newid()) {
|
|
86
|
+
init(appName = "test_application") {
|
|
89
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
88
|
yield this.globalUser();
|
|
91
89
|
return this.createApp(appName);
|
package/dist/threads/query.js
CHANGED
|
@@ -75,10 +75,6 @@ class QueryRunner {
|
|
|
75
75
|
yield threadUtils.invalidateDynamicVariables(this.cachedVariables);
|
|
76
76
|
return this.execute();
|
|
77
77
|
}
|
|
78
|
-
// check for undefined response
|
|
79
|
-
if (!rows) {
|
|
80
|
-
rows = [];
|
|
81
|
-
}
|
|
82
78
|
// needs to an array for next step
|
|
83
79
|
if (!Array.isArray(rows)) {
|
|
84
80
|
rows = [rows];
|