@budibase/server 1.0.49-alpha.0 → 1.0.49-alpha.12
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/__mocks__/arangojs.ts +1 -1
- package/__mocks__/aws-sdk.ts +4 -4
- package/__mocks__/mongodb.ts +4 -5
- package/__mocks__/mssql.ts +3 -3
- package/__mocks__/node-fetch.ts +2 -1
- package/__mocks__/pg.ts +3 -5
- package/builder/assets/{index.8184eed9.js → index.0bdf1cad.js} +195 -194
- package/builder/assets/{index.dd9e386f.css → index.83c0944f.css} +1 -1
- package/builder/assets/{vendor.3bd2f661.js → vendor.d526bfe8.js} +1 -1
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2927 -2819
- package/coverage/coverage-final.json +104 -103
- 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 +157 -136
- package/coverage/lcov-report/api/controllers/auth.js.html +11 -14
- package/coverage/lcov-report/api/controllers/automation.js.html +39 -69
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +8 -11
- package/coverage/lcov-report/api/controllers/component.js.html +10 -13
- package/coverage/lcov-report/api/controllers/datasource.js.html +31 -37
- package/coverage/lcov-report/api/controllers/dev.js.html +6 -6
- package/coverage/lcov-report/api/controllers/index.html +69 -54
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +9 -9
- package/coverage/lcov-report/api/controllers/metadata.js.html +6 -21
- package/coverage/lcov-report/{migrations/usageQuotas/syncApps.js.html → api/controllers/migrations.js.html} +30 -45
- package/coverage/lcov-report/api/controllers/permission.js.html +19 -19
- package/coverage/lcov-report/api/controllers/query/index.html +10 -10
- package/coverage/lcov-report/api/controllers/query/index.js.html +38 -35
- package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -6
- package/coverage/lcov-report/api/controllers/role.js.html +16 -16
- package/coverage/lcov-report/api/controllers/routing.js.html +7 -10
- package/coverage/lcov-report/api/controllers/row/external.js.html +48 -141
- package/coverage/lcov-report/api/controllers/row/index.html +52 -37
- package/coverage/lcov-report/api/controllers/row/index.js.html +13 -13
- package/coverage/lcov-report/api/controllers/row/internal.js.html +108 -216
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +52 -34
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +548 -0
- package/coverage/lcov-report/api/controllers/row/utils.js.html +27 -24
- package/coverage/lcov-report/api/controllers/screen.js.html +15 -21
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +599 -0
- package/coverage/lcov-report/api/controllers/table/external.js.html +25 -34
- package/coverage/lcov-report/api/controllers/table/index.html +57 -42
- package/coverage/lcov-report/api/controllers/table/index.js.html +28 -70
- package/coverage/lcov-report/api/controllers/table/internal.js.html +56 -47
- package/coverage/lcov-report/api/controllers/table/utils.js.html +169 -85
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +43 -52
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +16 -16
- package/coverage/lcov-report/api/controllers/view/index.js.html +27 -33
- package/coverage/lcov-report/api/controllers/view/utils.js.html +35 -20
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +34 -28
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +3 -3
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/application.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +22 -7
- package/coverage/lcov-report/api/routes/index.js.html +10 -4
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/{migrations/usageQuotas/index.js.html → api/routes/migrations.js.html} +25 -55
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/row.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +7 -10
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +18 -18
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +7 -10
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +7 -7
- 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 +61 -55
- package/coverage/lcov-report/automations/utils.js.html +54 -42
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +42 -27
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +15 -27
- package/coverage/lcov-report/db/linkedRows/index.html +27 -27
- package/coverage/lcov-report/db/linkedRows/index.js.html +40 -85
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +40 -40
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +75 -75
- 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 +107 -122
- 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 +21 -15
- package/coverage/lcov-report/middleware/builder.js.html +3 -3
- package/coverage/lcov-report/middleware/currentapp.js.html +72 -60
- package/coverage/lcov-report/middleware/index.html +28 -28
- 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 +29 -35
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +30 -24
- package/coverage/lcov-report/threads/index.html +25 -25
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +26 -47
- 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 +57 -48
- package/coverage/lcov-report/utilities/index.html +27 -27
- package/coverage/lcov-report/utilities/index.js.html +42 -72
- 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 +7 -7
- package/coverage/lcov-report/utilities/rowProcessor/index.html +27 -27
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +65 -71
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +75 -27
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +13 -10
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +5 -2
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +9 -9
- package/coverage/lcov-report/utilities/workerRequests.js.html +16 -16
- package/coverage/lcov.info +4620 -4358
- package/dist/api/controllers/application.js +49 -48
- package/dist/api/controllers/auth.js +4 -5
- package/dist/api/controllers/automation.js +14 -19
- package/dist/api/controllers/cloud.js +2 -3
- package/dist/api/controllers/component.js +3 -4
- package/dist/api/controllers/datasource.js +9 -10
- package/dist/api/controllers/deploy/Deployment.js +3 -6
- package/dist/api/controllers/deploy/index.js +12 -13
- package/dist/api/controllers/dev.js +5 -5
- package/dist/api/controllers/layout.js +3 -3
- package/dist/api/controllers/metadata.js +4 -4
- package/dist/api/controllers/migrations.js +21 -0
- package/dist/api/controllers/permission.js +4 -4
- package/dist/api/controllers/query/import/index.js +4 -6
- package/dist/api/controllers/query/index.js +11 -10
- package/dist/api/controllers/role.js +5 -5
- package/dist/api/controllers/routing.js +5 -6
- package/dist/api/controllers/row/ExternalRequest.js +90 -67
- package/dist/api/controllers/row/external.js +14 -22
- package/dist/api/controllers/row/internal.js +55 -93
- package/dist/api/controllers/row/internalSearch.js +23 -17
- package/dist/api/controllers/row/staticFormula.js +147 -0
- package/dist/api/controllers/row/utils.js +7 -6
- package/dist/api/controllers/screen.js +5 -7
- package/dist/api/controllers/static/index.js +4 -4
- package/dist/api/controllers/table/bulkFormula.js +159 -0
- package/dist/api/controllers/table/external.js +7 -10
- package/dist/api/controllers/table/index.js +7 -10
- package/dist/api/controllers/table/internal.js +20 -16
- package/dist/api/controllers/table/utils.js +54 -34
- package/dist/api/controllers/user.js +16 -20
- package/dist/api/controllers/view/index.js +8 -10
- package/dist/api/controllers/view/utils.js +9 -4
- package/dist/api/controllers/webhook.js +10 -8
- package/dist/api/routes/index.js +2 -0
- package/dist/api/routes/migrations.js +9 -0
- package/dist/api/routes/tests/utilities/TestFunctions.js +37 -17
- package/dist/app.js +35 -5
- package/dist/automations/automationUtils.js +2 -3
- package/dist/automations/steps/createRow.js +1 -1
- package/dist/automations/steps/updateRow.js +1 -1
- package/dist/automations/triggers.js +27 -25
- package/dist/automations/utils.js +10 -5
- package/dist/constants/index.js +4 -0
- package/dist/db/linkedRows/LinkController.js +3 -7
- package/dist/db/linkedRows/index.js +16 -27
- package/dist/db/linkedRows/linkUtils.js +6 -6
- package/dist/db/views/staticViews.js +9 -10
- package/dist/environment.js +3 -1
- package/dist/integrations/base/sql.js +43 -8
- package/dist/integrations/utils.js +3 -0
- package/dist/middleware/authorized.js +5 -3
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +41 -37
- package/dist/middleware/usageQuota.js +2 -4
- package/dist/migrations/functions/appUrls.js +46 -0
- package/dist/migrations/functions/quotas1.js +50 -0
- package/dist/migrations/{usageQuotas → functions/usageQuotas}/index.js +6 -10
- package/dist/migrations/{usageQuotas → functions/usageQuotas}/syncApps.js +12 -9
- package/dist/migrations/{usageQuotas → functions/usageQuotas}/syncRows.js +16 -12
- package/dist/migrations/functions/userEmailViewCasing.js +24 -0
- package/dist/migrations/index.js +62 -0
- package/dist/package.json +4 -4
- package/dist/tests/utilities/TestConfiguration.js +70 -44
- package/dist/threads/automation.js +13 -11
- package/dist/threads/query.js +13 -19
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +4 -3
- package/dist/utilities/global.js +15 -12
- package/dist/utilities/index.js +7 -17
- package/dist/utilities/routing/index.js +5 -5
- package/dist/utilities/rowProcessor/index.js +23 -17
- package/dist/utilities/rowProcessor/utils.js +14 -4
- package/dist/utilities/usageQuota/index.js +1 -0
- package/dist/utilities/usageQuota/rows.js +1 -0
- package/dist/utilities/users.js +3 -3
- package/dist/utilities/workerRequests.js +4 -4
- package/package.json +5 -5
- package/scripts/integrations/postgres/init.sql +11 -6
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/application.js +38 -31
- package/src/api/controllers/auth.js +4 -5
- package/src/api/controllers/automation.js +13 -23
- package/src/api/controllers/cloud.js +2 -3
- package/src/api/controllers/component.js +3 -4
- package/src/api/controllers/datasource.js +9 -11
- package/src/api/controllers/deploy/Deployment.js +3 -7
- package/src/api/controllers/deploy/index.js +20 -13
- package/src/api/controllers/dev.js +5 -5
- package/src/api/controllers/layout.js +3 -3
- package/src/api/controllers/metadata.js +4 -9
- package/src/api/controllers/migrations.js +13 -0
- package/src/api/controllers/permission.js +4 -4
- package/src/api/controllers/query/import/index.ts +4 -6
- package/src/api/controllers/query/import/tests/index.spec.js +2 -1
- package/src/api/controllers/query/index.js +11 -10
- package/src/api/controllers/role.js +5 -5
- package/src/api/controllers/routing.js +5 -6
- package/src/api/controllers/row/ExternalRequest.ts +67 -43
- package/src/api/controllers/row/external.js +27 -58
- package/src/api/controllers/row/internal.js +54 -90
- package/src/api/controllers/row/internalSearch.js +23 -17
- package/src/api/controllers/row/staticFormula.js +156 -0
- package/src/api/controllers/row/utils.js +7 -6
- package/src/api/controllers/screen.js +5 -7
- package/src/api/controllers/static/index.js +4 -4
- package/src/api/controllers/table/bulkFormula.js +173 -0
- package/src/api/controllers/table/external.js +7 -10
- package/src/api/controllers/table/index.js +7 -21
- package/src/api/controllers/table/internal.js +22 -19
- package/src/api/controllers/table/utils.js +70 -42
- package/src/api/controllers/user.js +17 -20
- package/src/api/controllers/view/index.js +8 -10
- package/src/api/controllers/view/utils.js +9 -4
- package/src/api/controllers/webhook.js +10 -8
- package/src/api/routes/index.js +2 -0
- package/src/api/routes/migrations.js +14 -0
- package/src/api/routes/tests/automation.spec.js +1 -0
- package/src/api/routes/tests/misc.spec.js +0 -1
- package/src/api/routes/tests/routing.spec.js +21 -12
- package/src/api/routes/tests/row.spec.js +7 -4
- package/src/api/routes/tests/utilities/TestFunctions.js +39 -17
- package/src/app.ts +18 -5
- package/src/automations/automationUtils.js +2 -3
- package/src/automations/steps/createRow.js +0 -1
- package/src/automations/steps/updateRow.js +1 -1
- package/src/automations/triggers.js +33 -31
- package/src/automations/utils.js +9 -5
- package/src/constants/index.js +5 -0
- package/src/db/linkedRows/LinkController.js +3 -7
- package/src/db/linkedRows/index.js +16 -31
- package/src/db/linkedRows/linkUtils.js +6 -6
- package/src/db/tests/linkController.spec.js +0 -1
- package/src/db/tests/linkTests.spec.js +5 -6
- package/src/db/views/staticViews.js +8 -10
- package/src/definitions/common.ts +3 -0
- package/src/environment.js +3 -1
- package/src/integrations/base/sql.ts +55 -14
- package/src/integrations/utils.ts +4 -1
- package/src/middleware/authorized.js +5 -3
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +50 -46
- package/src/middleware/tests/authorized.spec.js +7 -2
- package/src/middleware/tests/currentapp.spec.js +6 -0
- package/src/middleware/usageQuota.js +2 -4
- package/src/migrations/functions/appUrls.ts +34 -0
- package/src/migrations/functions/quotas1.ts +20 -0
- package/src/migrations/functions/tests/appUrls.spec.js +29 -0
- package/src/migrations/{tests/usageQuotas/index.spec.js → functions/tests/quotas1.spec.js} +5 -5
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +25 -0
- package/src/migrations/functions/usageQuotas/index.ts +8 -0
- package/src/migrations/{usageQuotas/syncApps.js → functions/usageQuotas/syncApps.ts} +6 -6
- package/src/migrations/functions/usageQuotas/syncRows.ts +22 -0
- package/src/migrations/{tests/usageQuotas → functions/usageQuotas/tests}/syncApps.spec.js +4 -4
- package/src/migrations/{tests/usageQuotas → functions/usageQuotas/tests}/syncRows.spec.js +4 -4
- package/src/migrations/functions/userEmailViewCasing.ts +13 -0
- package/src/migrations/index.ts +56 -0
- package/src/module.d.ts +3 -0
- package/src/tests/utilities/TestConfiguration.js +73 -50
- package/src/threads/automation.js +17 -15
- package/src/threads/query.js +14 -21
- package/src/utilities/fileSystem/index.js +4 -3
- package/src/utilities/global.js +15 -12
- package/src/utilities/index.js +7 -17
- package/src/utilities/routing/index.js +5 -5
- package/src/utilities/rowProcessor/index.js +25 -27
- package/src/utilities/rowProcessor/utils.js +23 -7
- package/src/utilities/usageQuota/index.js +1 -0
- package/src/utilities/usageQuota/rows.js +1 -0
- package/src/utilities/users.js +3 -3
- package/src/utilities/workerRequests.js +4 -4
- package/tsconfig.json +2 -1
- package/coverage/lcov-report/migrations/usageQuotas/index.html +0 -141
- package/coverage/lcov-report/migrations/usageQuotas/syncRows.js.html +0 -143
- package/src/migrations/usageQuotas/index.js +0 -24
- package/src/migrations/usageQuotas/syncRows.js +0 -21
|
@@ -7,10 +7,10 @@ const { deleteFiles } = require("../../utilities/fileSystem/utilities")
|
|
|
7
7
|
const { ObjectStoreBuckets } = require("../../constants")
|
|
8
8
|
const {
|
|
9
9
|
isProdAppID,
|
|
10
|
-
|
|
10
|
+
getProdAppID,
|
|
11
11
|
dbExists,
|
|
12
12
|
} = require("@budibase/backend-core/db")
|
|
13
|
-
const
|
|
13
|
+
const { getAppId } = require("@budibase/backend-core/context")
|
|
14
14
|
|
|
15
15
|
const BASE_AUTO_ID = 1
|
|
16
16
|
|
|
@@ -180,6 +180,8 @@ function processAutoColumn(
|
|
|
180
180
|
}
|
|
181
181
|
exports.processAutoColumn = processAutoColumn
|
|
182
182
|
|
|
183
|
+
exports.processFormulas = processFormulas
|
|
184
|
+
|
|
183
185
|
/**
|
|
184
186
|
* This will coerce a value to the correct types based on the type transform map
|
|
185
187
|
* @param {object} row The value to coerce
|
|
@@ -229,11 +231,12 @@ exports.inputProcessing = (
|
|
|
229
231
|
}
|
|
230
232
|
continue
|
|
231
233
|
}
|
|
232
|
-
//
|
|
233
|
-
// type coercion cannot completely remove the field, so have to do it here
|
|
234
|
+
// remove any formula values, they are to be generated
|
|
234
235
|
if (field.type === FieldTypes.FORMULA) {
|
|
235
236
|
delete clonedRow[key]
|
|
236
|
-
}
|
|
237
|
+
}
|
|
238
|
+
// otherwise coerce what is there to correct types
|
|
239
|
+
else {
|
|
237
240
|
clonedRow[key] = exports.coerce(value, field.type)
|
|
238
241
|
}
|
|
239
242
|
}
|
|
@@ -250,30 +253,23 @@ exports.inputProcessing = (
|
|
|
250
253
|
/**
|
|
251
254
|
* This function enriches the input rows with anything they are supposed to contain, for example
|
|
252
255
|
* link records or attachment links.
|
|
253
|
-
* @param {object} ctx the request which is looking for enriched rows.
|
|
254
256
|
* @param {object} table the table from which these rows came from originally, this is used to determine
|
|
255
257
|
* the schema of the rows and then enrich.
|
|
256
258
|
* @param {object[]|object} rows the rows which are to be enriched.
|
|
257
259
|
* @param {object} opts used to set some options for the output, such as disabling relationship squashing.
|
|
258
260
|
* @returns {object[]|object} the enriched rows will be returned.
|
|
259
261
|
*/
|
|
260
|
-
exports.outputProcessing = async (
|
|
261
|
-
ctx,
|
|
262
|
-
table,
|
|
263
|
-
rows,
|
|
264
|
-
opts = { squash: true }
|
|
265
|
-
) => {
|
|
266
|
-
const appId = ctx.appId
|
|
262
|
+
exports.outputProcessing = async (table, rows, opts = { squash: true }) => {
|
|
267
263
|
let wasArray = true
|
|
268
264
|
if (!(rows instanceof Array)) {
|
|
269
265
|
rows = [rows]
|
|
270
266
|
wasArray = false
|
|
271
267
|
}
|
|
272
268
|
// attach any linked row information
|
|
273
|
-
let enriched = await linkRows.attachFullLinkedDocs(
|
|
269
|
+
let enriched = await linkRows.attachFullLinkedDocs(table, rows)
|
|
274
270
|
|
|
275
271
|
// process formulas
|
|
276
|
-
enriched = processFormulas(table, enriched)
|
|
272
|
+
enriched = processFormulas(table, enriched, { dynamic: true })
|
|
277
273
|
|
|
278
274
|
// update the attachments URL depending on hosting
|
|
279
275
|
for (let [property, column] of Object.entries(table.schema)) {
|
|
@@ -289,29 +285,27 @@ exports.outputProcessing = async (
|
|
|
289
285
|
}
|
|
290
286
|
}
|
|
291
287
|
if (opts.squash) {
|
|
292
|
-
enriched = await linkRows.squashLinksToPrimaryDisplay(
|
|
293
|
-
appId,
|
|
294
|
-
table,
|
|
295
|
-
enriched
|
|
296
|
-
)
|
|
288
|
+
enriched = await linkRows.squashLinksToPrimaryDisplay(table, enriched)
|
|
297
289
|
}
|
|
298
290
|
return wasArray ? enriched : enriched[0]
|
|
299
291
|
}
|
|
300
292
|
|
|
301
293
|
/**
|
|
302
294
|
* Clean up any attachments that were attached to a row.
|
|
303
|
-
* @param {string} appId The ID of the app from which a row is being deleted.
|
|
304
295
|
* @param {object} table The table from which a row is being removed.
|
|
305
296
|
* @param {any} row optional - the row being removed.
|
|
306
297
|
* @param {any} rows optional - if multiple rows being deleted can do this in bulk.
|
|
307
298
|
* @param {any} oldRow optional - if updating a row this will determine the difference.
|
|
299
|
+
* @param {any} oldTable optional - if updating a table, can supply the old table to look for
|
|
300
|
+
* deleted attachment columns.
|
|
308
301
|
* @return {Promise<void>} When all attachments have been removed this will return.
|
|
309
302
|
*/
|
|
310
|
-
exports.cleanupAttachments = async (
|
|
303
|
+
exports.cleanupAttachments = async (table, { row, rows, oldRow, oldTable }) => {
|
|
304
|
+
const appId = getAppId()
|
|
311
305
|
if (!isProdAppID(appId)) {
|
|
312
|
-
const prodAppId =
|
|
306
|
+
const prodAppId = getProdAppID(appId)
|
|
313
307
|
// if prod exists, then don't allow deleting
|
|
314
|
-
const exists = await dbExists(
|
|
308
|
+
const exists = await dbExists(prodAppId)
|
|
315
309
|
if (exists) {
|
|
316
310
|
return
|
|
317
311
|
}
|
|
@@ -322,12 +316,16 @@ exports.cleanupAttachments = async (appId, table, { row, rows, oldRow }) => {
|
|
|
322
316
|
files = files.concat(row[key].map(attachment => attachment.key))
|
|
323
317
|
}
|
|
324
318
|
}
|
|
325
|
-
|
|
319
|
+
const schemaToUse = oldTable ? oldTable.schema : table.schema
|
|
320
|
+
for (let [key, schema] of Object.entries(schemaToUse)) {
|
|
326
321
|
if (schema.type !== FieldTypes.ATTACHMENT) {
|
|
327
322
|
continue
|
|
328
323
|
}
|
|
329
|
-
//
|
|
330
|
-
if (
|
|
324
|
+
// old table had this column, new table doesn't - delete it
|
|
325
|
+
if (oldTable && !table.schema[key]) {
|
|
326
|
+
rows.forEach(row => addFiles(row, key))
|
|
327
|
+
} else if (oldRow && row) {
|
|
328
|
+
// if updating, need to manage the differences
|
|
331
329
|
files = files.concat(getRemovedAttachmentKeys(oldRow, row, key))
|
|
332
330
|
} else if (row) {
|
|
333
331
|
addFiles(row, key)
|
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
const { FieldTypes } = require("../../constants")
|
|
1
|
+
const { FieldTypes, FormulaTypes } = require("../../constants")
|
|
2
2
|
const { processStringSync } = require("@budibase/string-templates")
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Looks through the rows provided and finds formulas - which it then processes.
|
|
6
6
|
*/
|
|
7
|
-
exports.processFormulas = (
|
|
7
|
+
exports.processFormulas = (
|
|
8
|
+
table,
|
|
9
|
+
rows,
|
|
10
|
+
{ dynamic, contextRows } = { dynamic: true }
|
|
11
|
+
) => {
|
|
8
12
|
const single = !Array.isArray(rows)
|
|
9
13
|
if (single) {
|
|
10
14
|
rows = [rows]
|
|
15
|
+
contextRows = contextRows ? [contextRows] : contextRows
|
|
11
16
|
}
|
|
12
17
|
for (let [column, schema] of Object.entries(table.schema)) {
|
|
13
|
-
|
|
18
|
+
const isStatic = schema.formulaType === FormulaTypes.STATIC
|
|
19
|
+
if (
|
|
20
|
+
schema.type !== FieldTypes.FORMULA ||
|
|
21
|
+
(dynamic && isStatic) ||
|
|
22
|
+
(!dynamic && !isStatic)
|
|
23
|
+
) {
|
|
14
24
|
continue
|
|
15
25
|
}
|
|
16
26
|
// iterate through rows and process formula
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
for (let i = 0; i < rows.length; i++) {
|
|
28
|
+
if (schema.formula) {
|
|
29
|
+
let row = rows[i]
|
|
30
|
+
let context = contextRows ? contextRows[i] : row
|
|
31
|
+
rows[i] = {
|
|
32
|
+
...row,
|
|
33
|
+
[column]: processStringSync(schema.formula, context),
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
21
37
|
}
|
|
22
38
|
return single ? rows[0] : rows
|
|
23
39
|
}
|
|
@@ -52,6 +52,7 @@ exports.getUsageQuotaDoc = async db => {
|
|
|
52
52
|
* Given a specified tenantId this will add to the usage object for the specified property.
|
|
53
53
|
* @param {string} property The property which is to be added to (within the nested usageQuota object).
|
|
54
54
|
* @param {number} usage The amount (this can be negative) to adjust the number by.
|
|
55
|
+
* @param {object} opts optional - options such as dryRun, to check what update will do.
|
|
55
56
|
* @returns {Promise<void>} When this completes the API key will now be up to date - the quota period may have
|
|
56
57
|
* also been reset after this call.
|
|
57
58
|
*/
|
|
@@ -23,6 +23,7 @@ const getAppPairs = appIds => {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const getAppRows = async appId => {
|
|
26
|
+
// need to specify the app ID, as this is used for different apps in one call
|
|
26
27
|
const appDb = new CouchDB(appId)
|
|
27
28
|
const response = await appDb.allDocs(
|
|
28
29
|
getRowParams(null, null, {
|
package/src/utilities/users.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const CouchDB = require("../db")
|
|
2
1
|
const { InternalTables } = require("../db/utils")
|
|
3
2
|
const { getGlobalUser } = require("../utilities/global")
|
|
3
|
+
const { getAppDB } = require("@budibase/backend-core/context")
|
|
4
4
|
|
|
5
5
|
exports.getFullUser = async (ctx, userId) => {
|
|
6
|
-
const global = await getGlobalUser(
|
|
6
|
+
const global = await getGlobalUser(userId)
|
|
7
7
|
let metadata
|
|
8
8
|
try {
|
|
9
9
|
// this will throw an error if the db doesn't exist, or there is no appId
|
|
10
|
-
const db =
|
|
10
|
+
const db = getAppDB()
|
|
11
11
|
metadata = await db.get(userId)
|
|
12
12
|
} catch (err) {
|
|
13
13
|
// it is fine if there is no user metadata, just remove global db info
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fetch = require("node-fetch")
|
|
2
2
|
const env = require("../environment")
|
|
3
3
|
const { checkSlashesInUrl } = require("./index")
|
|
4
|
-
const {
|
|
4
|
+
const { getProdAppID } = require("@budibase/backend-core/db")
|
|
5
5
|
const { updateAppRole } = require("./global")
|
|
6
6
|
const { Headers } = require("@budibase/backend-core/constants")
|
|
7
7
|
const { getTenantId, isTenantIdSet } = require("@budibase/backend-core/tenancy")
|
|
@@ -70,15 +70,15 @@ exports.getGlobalSelf = async (ctx, appId = null) => {
|
|
|
70
70
|
}
|
|
71
71
|
let json = await response.json()
|
|
72
72
|
if (appId) {
|
|
73
|
-
json = updateAppRole(
|
|
73
|
+
json = updateAppRole(json)
|
|
74
74
|
}
|
|
75
75
|
return json
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
exports.removeAppFromUserRoles = async (ctx, appId) => {
|
|
79
|
-
const
|
|
79
|
+
const prodAppId = getProdAppID(appId)
|
|
80
80
|
const response = await fetch(
|
|
81
|
-
checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${
|
|
81
|
+
checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${prodAppId}`),
|
|
82
82
|
request(ctx, {
|
|
83
83
|
method: "DELETE",
|
|
84
84
|
})
|
package/tsconfig.json
CHANGED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for migrations/usageQuotas</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> migrations/usageQuotas</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">100% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>40/40</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">62.5% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>5/8</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">100% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>5/5</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">100% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>39/39</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
</div>
|
|
58
|
-
<div class='status-line high'></div>
|
|
59
|
-
<div class="pad1">
|
|
60
|
-
<table class="coverage-summary">
|
|
61
|
-
<thead>
|
|
62
|
-
<tr>
|
|
63
|
-
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
|
64
|
-
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
|
65
|
-
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
|
66
|
-
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
67
|
-
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
|
68
|
-
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
69
|
-
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
|
70
|
-
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
71
|
-
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
|
72
|
-
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
73
|
-
</tr>
|
|
74
|
-
</thead>
|
|
75
|
-
<tbody><tr>
|
|
76
|
-
<td class="file high" data-value="index.js"><a href="index.js.html">index.js</a></td>
|
|
77
|
-
<td data-value="100" class="pic high">
|
|
78
|
-
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
|
|
79
|
-
</td>
|
|
80
|
-
<td data-value="100" class="pct high">100%</td>
|
|
81
|
-
<td data-value="10" class="abs high">10/10</td>
|
|
82
|
-
<td data-value="100" class="pct high">100%</td>
|
|
83
|
-
<td data-value="2" class="abs high">2/2</td>
|
|
84
|
-
<td data-value="100" class="pct high">100%</td>
|
|
85
|
-
<td data-value="2" class="abs high">2/2</td>
|
|
86
|
-
<td data-value="100" class="pct high">100%</td>
|
|
87
|
-
<td data-value="10" class="abs high">10/10</td>
|
|
88
|
-
</tr>
|
|
89
|
-
|
|
90
|
-
<tr>
|
|
91
|
-
<td class="file high" data-value="syncApps.js"><a href="syncApps.js.html">syncApps.js</a></td>
|
|
92
|
-
<td data-value="100" class="pic high">
|
|
93
|
-
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
|
|
94
|
-
</td>
|
|
95
|
-
<td data-value="100" class="pct high">100%</td>
|
|
96
|
-
<td data-value="13" class="abs high">13/13</td>
|
|
97
|
-
<td data-value="50" class="pct medium">50%</td>
|
|
98
|
-
<td data-value="2" class="abs medium">1/2</td>
|
|
99
|
-
<td data-value="100" class="pct high">100%</td>
|
|
100
|
-
<td data-value="1" class="abs high">1/1</td>
|
|
101
|
-
<td data-value="100" class="pct high">100%</td>
|
|
102
|
-
<td data-value="13" class="abs high">13/13</td>
|
|
103
|
-
</tr>
|
|
104
|
-
|
|
105
|
-
<tr>
|
|
106
|
-
<td class="file high" data-value="syncRows.js"><a href="syncRows.js.html">syncRows.js</a></td>
|
|
107
|
-
<td data-value="100" class="pic high">
|
|
108
|
-
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
|
|
109
|
-
</td>
|
|
110
|
-
<td data-value="100" class="pct high">100%</td>
|
|
111
|
-
<td data-value="17" class="abs high">17/17</td>
|
|
112
|
-
<td data-value="50" class="pct medium">50%</td>
|
|
113
|
-
<td data-value="4" class="abs medium">2/4</td>
|
|
114
|
-
<td data-value="100" class="pct high">100%</td>
|
|
115
|
-
<td data-value="2" class="abs high">2/2</td>
|
|
116
|
-
<td data-value="100" class="pct high">100%</td>
|
|
117
|
-
<td data-value="16" class="abs high">16/16</td>
|
|
118
|
-
</tr>
|
|
119
|
-
|
|
120
|
-
</tbody>
|
|
121
|
-
</table>
|
|
122
|
-
</div>
|
|
123
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
124
|
-
</div><!-- /wrapper -->
|
|
125
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
126
|
-
Code coverage generated by
|
|
127
|
-
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
128
|
-
at Mon Jan 31 2022 14:38:52 GMT+0000 (Coordinated Universal Time)
|
|
129
|
-
</div>
|
|
130
|
-
</div>
|
|
131
|
-
<script src="../../prettify.js"></script>
|
|
132
|
-
<script>
|
|
133
|
-
window.onload = function () {
|
|
134
|
-
prettyPrint();
|
|
135
|
-
};
|
|
136
|
-
</script>
|
|
137
|
-
<script src="../../sorter.js"></script>
|
|
138
|
-
<script src="../../block-navigation.js"></script>
|
|
139
|
-
</body>
|
|
140
|
-
</html>
|
|
141
|
-
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for migrations/usageQuotas/syncRows.js</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> / <a href="index.html">migrations/usageQuotas</a> syncRows.js</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">100% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>17/17</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">50% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>2/4</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">100% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>2/2</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">100% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>16/16</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
</div>
|
|
58
|
-
<div class='status-line high'></div>
|
|
59
|
-
<pre><table class="coverage">
|
|
60
|
-
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
61
|
-
<a name='L2'></a><a href='#L2'>2</a>
|
|
62
|
-
<a name='L3'></a><a href='#L3'>3</a>
|
|
63
|
-
<a name='L4'></a><a href='#L4'>4</a>
|
|
64
|
-
<a name='L5'></a><a href='#L5'>5</a>
|
|
65
|
-
<a name='L6'></a><a href='#L6'>6</a>
|
|
66
|
-
<a name='L7'></a><a href='#L7'>7</a>
|
|
67
|
-
<a name='L8'></a><a href='#L8'>8</a>
|
|
68
|
-
<a name='L9'></a><a href='#L9'>9</a>
|
|
69
|
-
<a name='L10'></a><a href='#L10'>10</a>
|
|
70
|
-
<a name='L11'></a><a href='#L11'>11</a>
|
|
71
|
-
<a name='L12'></a><a href='#L12'>12</a>
|
|
72
|
-
<a name='L13'></a><a href='#L13'>13</a>
|
|
73
|
-
<a name='L14'></a><a href='#L14'>14</a>
|
|
74
|
-
<a name='L15'></a><a href='#L15'>15</a>
|
|
75
|
-
<a name='L16'></a><a href='#L16'>16</a>
|
|
76
|
-
<a name='L17'></a><a href='#L17'>17</a>
|
|
77
|
-
<a name='L18'></a><a href='#L18'>18</a>
|
|
78
|
-
<a name='L19'></a><a href='#L19'>19</a>
|
|
79
|
-
<a name='L20'></a><a href='#L20'>20</a>
|
|
80
|
-
<a name='L21'></a><a href='#L21'>21</a>
|
|
81
|
-
<a name='L22'></a><a href='#L22'>22</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">25x</span>
|
|
82
|
-
<span class="cline-any cline-yes">25x</span>
|
|
83
|
-
<span class="cline-any cline-yes">25x</span>
|
|
84
|
-
<span class="cline-any cline-yes">25x</span>
|
|
85
|
-
<span class="cline-any cline-yes">25x</span>
|
|
86
|
-
<span class="cline-any cline-neutral"> </span>
|
|
87
|
-
<span class="cline-any cline-yes">25x</span>
|
|
88
|
-
<span class="cline-any cline-yes">1x</span>
|
|
89
|
-
<span class="cline-any cline-neutral"> </span>
|
|
90
|
-
<span class="cline-any cline-yes">1x</span>
|
|
91
|
-
<span class="cline-any cline-yes">4x</span>
|
|
92
|
-
<span class="cline-any cline-yes">1x</span>
|
|
93
|
-
<span class="cline-any cline-yes">1x</span>
|
|
94
|
-
<span class="cline-any cline-neutral"> </span>
|
|
95
|
-
<span class="cline-any cline-neutral"> </span>
|
|
96
|
-
<span class="cline-any cline-yes">1x</span>
|
|
97
|
-
<span class="cline-any cline-yes">1x</span>
|
|
98
|
-
<span class="cline-any cline-yes">1x</span>
|
|
99
|
-
<span class="cline-any cline-yes">1x</span>
|
|
100
|
-
<span class="cline-any cline-yes">1x</span>
|
|
101
|
-
<span class="cline-any cline-neutral"> </span>
|
|
102
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">const { getGlobalDB, getTenantId } = require("@budibase/backend-core/tenancy")
|
|
103
|
-
const { getAllApps } = require("@budibase/backend-core/db")
|
|
104
|
-
const CouchDB = require("../../db")
|
|
105
|
-
const { getUsageQuotaDoc } = require("../../utilities/usageQuota")
|
|
106
|
-
const { getUniqueRows } = require("../../utilities/usageQuota/rows")
|
|
107
|
-
|
|
108
|
-
exports.run = async () => {
|
|
109
|
-
const db = getGlobalDB()
|
|
110
|
-
// get all rows in all apps
|
|
111
|
-
const allApps = await getAllApps(CouchDB, { all: true })
|
|
112
|
-
const appIds = allApps ? allApps.map(app => app.appId) : <span class="branch-1 cbranch-no" title="branch not covered" >[]</span>
|
|
113
|
-
const rows = await getUniqueRows(appIds)
|
|
114
|
-
const rowCount = rows ? rows.length : <span class="branch-1 cbranch-no" title="branch not covered" >0</span>
|
|
115
|
-
|
|
116
|
-
// sync row count
|
|
117
|
-
const tenantId = getTenantId()
|
|
118
|
-
console.log(`[Tenant: ${tenantId}] Syncing row count: ${rowCount}`)
|
|
119
|
-
const usageDoc = await getUsageQuotaDoc(db)
|
|
120
|
-
usageDoc.usageQuota.rows = rowCount
|
|
121
|
-
await db.put(usageDoc)
|
|
122
|
-
}
|
|
123
|
-
</pre></td></tr></table></pre>
|
|
124
|
-
|
|
125
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
126
|
-
</div><!-- /wrapper -->
|
|
127
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
128
|
-
Code coverage generated by
|
|
129
|
-
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
130
|
-
at Mon Jan 31 2022 14:38:52 GMT+0000 (Coordinated Universal Time)
|
|
131
|
-
</div>
|
|
132
|
-
</div>
|
|
133
|
-
<script src="../../prettify.js"></script>
|
|
134
|
-
<script>
|
|
135
|
-
window.onload = function () {
|
|
136
|
-
prettyPrint();
|
|
137
|
-
};
|
|
138
|
-
</script>
|
|
139
|
-
<script src="../../sorter.js"></script>
|
|
140
|
-
<script src="../../block-navigation.js"></script>
|
|
141
|
-
</body>
|
|
142
|
-
</html>
|
|
143
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
MIGRATIONS,
|
|
3
|
-
MIGRATION_DBS,
|
|
4
|
-
migrateIfRequired,
|
|
5
|
-
} = require("@budibase/backend-core/migrations")
|
|
6
|
-
const { useQuotas } = require("../../utilities/usageQuota")
|
|
7
|
-
const syncApps = require("./syncApps")
|
|
8
|
-
const syncRows = require("./syncRows")
|
|
9
|
-
|
|
10
|
-
exports.run = async () => {
|
|
11
|
-
if (!useQuotas()) {
|
|
12
|
-
return
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Jan 2022
|
|
16
|
-
await migrateIfRequired(
|
|
17
|
-
MIGRATION_DBS.GLOBAL_DB,
|
|
18
|
-
MIGRATIONS.QUOTAS_1,
|
|
19
|
-
async () => {
|
|
20
|
-
await syncApps.run()
|
|
21
|
-
await syncRows.run()
|
|
22
|
-
}
|
|
23
|
-
)
|
|
24
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const { getGlobalDB, getTenantId } = require("@budibase/backend-core/tenancy")
|
|
2
|
-
const { getAllApps } = require("@budibase/backend-core/db")
|
|
3
|
-
const CouchDB = require("../../db")
|
|
4
|
-
const { getUsageQuotaDoc } = require("../../utilities/usageQuota")
|
|
5
|
-
const { getUniqueRows } = require("../../utilities/usageQuota/rows")
|
|
6
|
-
|
|
7
|
-
exports.run = async () => {
|
|
8
|
-
const db = getGlobalDB()
|
|
9
|
-
// get all rows in all apps
|
|
10
|
-
const allApps = await getAllApps(CouchDB, { all: true })
|
|
11
|
-
const appIds = allApps ? allApps.map(app => app.appId) : []
|
|
12
|
-
const rows = await getUniqueRows(appIds)
|
|
13
|
-
const rowCount = rows ? rows.length : 0
|
|
14
|
-
|
|
15
|
-
// sync row count
|
|
16
|
-
const tenantId = getTenantId()
|
|
17
|
-
console.log(`[Tenant: ${tenantId}] Syncing row count: ${rowCount}`)
|
|
18
|
-
const usageDoc = await getUsageQuotaDoc(db)
|
|
19
|
-
usageDoc.usageQuota.rows = rowCount
|
|
20
|
-
await db.put(usageDoc)
|
|
21
|
-
}
|