@budibase/server 1.0.49-alpha.6 → 1.0.49
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 +5 -4
- package/__mocks__/mssql.ts +3 -3
- package/__mocks__/node-fetch.ts +1 -2
- package/__mocks__/pg.ts +5 -3
- package/builder/assets/{index.1b905242.js → index.2c37968e.js} +231 -234
- package/builder/assets/index.39e01193.css +1 -0
- package/builder/assets/{vendor.d526bfe8.js → vendor.f9faf6ab.js} +12 -12
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2816 -3119
- package/coverage/coverage-final.json +101 -106
- 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 +152 -257
- package/coverage/lcov-report/api/controllers/auth.js.html +13 -22
- package/coverage/lcov-report/api/controllers/automation.js.html +69 -39
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -8
- package/coverage/lcov-report/api/controllers/component.js.html +16 -13
- package/coverage/lcov-report/api/controllers/datasource.js.html +51 -81
- package/coverage/lcov-report/api/controllers/dev.js.html +6 -6
- package/coverage/lcov-report/{utilities/usageQuota/usageQuoteReset.js.html → api/controllers/hosting.js.html} +48 -36
- package/coverage/lcov-report/api/controllers/index.html +76 -76
- 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 +21 -6
- 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 +35 -38
- 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 +10 -7
- package/coverage/lcov-report/api/controllers/row/external.js.html +27 -21
- package/coverage/lcov-report/api/controllers/row/index.html +34 -49
- package/coverage/lcov-report/api/controllers/row/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/row/internal.js.html +226 -118
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +34 -52
- package/coverage/lcov-report/api/controllers/row/utils.js.html +62 -47
- package/coverage/lcov-report/api/controllers/screen.js.html +21 -15
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/external.js.html +34 -25
- package/coverage/lcov-report/api/controllers/table/index.html +43 -58
- package/coverage/lcov-report/api/controllers/table/index.js.html +82 -58
- package/coverage/lcov-report/api/controllers/table/internal.js.html +66 -81
- package/coverage/lcov-report/api/controllers/table/utils.js.html +110 -218
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +50 -47
- 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 +33 -27
- package/coverage/lcov-report/api/controllers/view/utils.js.html +20 -35
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +28 -34
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +8 -8
- 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/{migrations.js.html → hosting.js.html} +14 -17
- package/coverage/lcov-report/api/routes/index.html +18 -18
- package/coverage/lcov-report/api/routes/index.js.html +3 -3
- 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 +10 -7
- 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 +22 -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 +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 +55 -61
- package/coverage/lcov-report/automations/utils.js.html +42 -54
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +26 -53
- 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 +37 -25
- package/coverage/lcov-report/db/linkedRows/index.html +27 -27
- package/coverage/lcov-report/db/linkedRows/index.js.html +96 -51
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +42 -42
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +87 -87
- 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 +120 -135
- 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 +65 -173
- package/coverage/lcov-report/middleware/builder.js.html +10 -10
- package/coverage/lcov-report/middleware/currentapp.js.html +83 -95
- package/coverage/lcov-report/middleware/index.html +38 -38
- 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 +53 -281
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +24 -30
- package/coverage/lcov-report/threads/index.html +26 -26
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +26 -62
- 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 +49 -58
- package/coverage/lcov-report/utilities/index.html +37 -37
- package/coverage/lcov-report/utilities/index.js.html +73 -43
- 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 +103 -97
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +27 -75
- 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 +9 -9
- package/coverage/lcov-report/utilities/workerRequests.js.html +112 -43
- package/coverage/lcov.info +4423 -5022
- package/dist/api/controllers/application.js +60 -90
- package/dist/api/controllers/auth.js +5 -8
- package/dist/api/controllers/automation.js +19 -14
- package/dist/api/controllers/cloud.js +3 -2
- package/dist/api/controllers/component.js +4 -3
- package/dist/api/controllers/datasource.js +10 -20
- package/dist/api/controllers/deploy/Deployment.js +6 -3
- package/dist/api/controllers/deploy/index.js +13 -12
- package/dist/api/controllers/dev.js +5 -5
- package/dist/api/controllers/hosting.js +30 -0
- package/dist/api/controllers/layout.js +3 -3
- package/dist/api/controllers/metadata.js +4 -4
- package/dist/api/controllers/permission.js +4 -4
- package/dist/api/controllers/query/import/index.js +6 -4
- package/dist/api/controllers/query/index.js +10 -11
- package/dist/api/controllers/role.js +5 -5
- package/dist/api/controllers/routing.js +6 -5
- package/dist/api/controllers/row/ExternalRequest.js +63 -76
- package/dist/api/controllers/row/external.js +4 -4
- package/dist/api/controllers/row/internal.js +93 -55
- package/dist/api/controllers/row/internalSearch.js +17 -23
- package/dist/api/controllers/row/utils.js +14 -13
- package/dist/api/controllers/screen.js +7 -5
- package/dist/api/controllers/static/index.js +12 -61
- package/dist/api/controllers/table/external.js +10 -7
- package/dist/api/controllers/table/index.js +13 -16
- package/dist/api/controllers/table/internal.js +16 -22
- package/dist/api/controllers/table/utils.js +35 -62
- package/dist/api/controllers/user.js +20 -18
- package/dist/api/controllers/view/index.js +10 -8
- package/dist/api/controllers/view/utils.js +4 -9
- package/dist/api/controllers/webhook.js +8 -10
- package/dist/api/routes/hosting.js +11 -0
- package/dist/api/routes/index.js +2 -2
- package/dist/api/routes/static.js +1 -2
- package/dist/api/routes/tests/utilities/TestFunctions.js +17 -37
- package/dist/app.js +5 -35
- package/dist/automations/automationUtils.js +3 -2
- package/dist/automations/steps/createRow.js +5 -3
- package/dist/automations/steps/deleteRow.js +4 -1
- package/dist/automations/steps/updateRow.js +1 -1
- package/dist/automations/triggers.js +25 -27
- package/dist/automations/utils.js +5 -10
- package/dist/constants/index.js +0 -7
- package/dist/db/linkedRows/LinkController.js +7 -3
- package/dist/db/linkedRows/index.js +27 -16
- package/dist/db/linkedRows/linkUtils.js +6 -6
- package/dist/db/views/staticViews.js +10 -9
- package/dist/definitions/datasource.js +0 -1
- package/dist/environment.js +1 -4
- package/dist/integrations/base/sql.js +6 -13
- package/dist/integrations/index.js +0 -3
- package/dist/integrations/utils.js +9 -60
- package/dist/middleware/authorized.js +30 -57
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +37 -41
- package/dist/middleware/usageQuota.js +15 -82
- package/dist/package.json +5 -8
- package/dist/tests/utilities/TestConfiguration.js +50 -80
- package/dist/threads/automation.js +11 -13
- package/dist/threads/query.js +13 -23
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +3 -4
- package/dist/utilities/global.js +12 -15
- package/dist/utilities/index.js +17 -7
- package/dist/utilities/routing/index.js +5 -5
- package/dist/utilities/rowProcessor/index.js +17 -23
- package/dist/utilities/rowProcessor/utils.js +4 -14
- package/dist/utilities/{usageQuota/index.js → usageQuota.js} +31 -45
- package/dist/utilities/users.js +3 -3
- package/dist/utilities/workerRequests.js +24 -4
- package/nodemon.json +1 -1
- package/package.json +6 -9
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/application.js +50 -85
- package/src/api/controllers/auth.js +5 -8
- package/src/api/controllers/automation.js +23 -13
- package/src/api/controllers/cloud.js +3 -2
- package/src/api/controllers/component.js +4 -3
- package/src/api/controllers/datasource.js +11 -21
- package/src/api/controllers/deploy/Deployment.js +7 -3
- package/src/api/controllers/deploy/index.js +13 -20
- package/src/api/controllers/dev.js +5 -5
- package/src/api/controllers/hosting.js +22 -0
- package/src/api/controllers/layout.js +3 -3
- package/src/api/controllers/metadata.js +9 -4
- package/src/api/controllers/permission.js +4 -4
- package/src/api/controllers/query/import/index.ts +6 -4
- package/src/api/controllers/query/import/tests/index.spec.js +1 -2
- package/src/api/controllers/query/index.js +10 -11
- package/src/api/controllers/role.js +5 -5
- package/src/api/controllers/routing.js +6 -5
- package/src/api/controllers/row/ExternalRequest.ts +42 -53
- package/src/api/controllers/row/external.js +6 -4
- package/src/api/controllers/row/internal.js +90 -54
- package/src/api/controllers/row/internalSearch.js +17 -23
- package/src/api/controllers/row/utils.js +18 -13
- package/src/api/controllers/screen.js +7 -5
- package/src/api/controllers/static/index.js +12 -65
- package/src/api/controllers/table/external.js +10 -7
- package/src/api/controllers/table/index.js +28 -20
- package/src/api/controllers/table/internal.js +19 -24
- package/src/api/controllers/table/utils.js +42 -78
- package/src/api/controllers/user.js +20 -19
- package/src/api/controllers/view/index.js +10 -8
- package/src/api/controllers/view/utils.js +4 -9
- package/src/api/controllers/webhook.js +8 -10
- package/src/api/routes/hosting.js +13 -0
- package/src/api/routes/index.js +2 -2
- package/src/api/routes/static.js +0 -5
- package/src/api/routes/tests/application.spec.js +2 -2
- package/src/api/routes/tests/auth.spec.js +2 -1
- package/src/api/routes/tests/automation.spec.js +0 -1
- package/src/api/routes/tests/hosting.spec.js +36 -0
- package/src/api/routes/tests/misc.spec.js +1 -0
- package/src/api/routes/tests/routing.spec.js +12 -21
- package/src/api/routes/tests/row.spec.js +4 -7
- package/src/api/routes/tests/utilities/TestFunctions.js +17 -39
- package/src/app.ts +5 -18
- package/src/automations/automationUtils.js +3 -2
- package/src/automations/steps/createRow.js +5 -2
- package/src/automations/steps/deleteRow.js +4 -1
- package/src/automations/steps/updateRow.js +1 -1
- package/src/automations/triggers.js +31 -33
- package/src/automations/utils.js +5 -9
- package/src/constants/index.js +0 -9
- package/src/db/linkedRows/LinkController.js +7 -3
- package/src/db/linkedRows/index.js +31 -16
- package/src/db/linkedRows/linkUtils.js +6 -6
- package/src/db/tests/linkController.spec.js +1 -0
- package/src/db/tests/linkTests.spec.js +6 -5
- package/src/db/views/staticViews.js +10 -8
- package/src/definitions/common.ts +0 -3
- package/src/definitions/datasource.ts +0 -3
- package/src/environment.js +1 -4
- 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 +12 -75
- package/src/middleware/authorized.js +30 -66
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +46 -50
- package/src/middleware/tests/authorized.spec.js +6 -13
- package/src/middleware/tests/currentapp.spec.js +0 -6
- package/src/middleware/tests/usageQuota.spec.js +24 -18
- package/src/middleware/usageQuota.js +17 -93
- package/src/tests/utilities/TestConfiguration.js +55 -82
- package/src/threads/automation.js +15 -17
- package/src/threads/query.js +14 -26
- package/src/utilities/fileSystem/index.js +3 -4
- package/src/utilities/global.js +12 -15
- package/src/utilities/index.js +17 -7
- package/src/utilities/routing/index.js +5 -5
- package/src/utilities/rowProcessor/index.js +27 -25
- package/src/utilities/rowProcessor/utils.js +7 -23
- package/src/utilities/usageQuota.js +73 -0
- package/src/utilities/users.js +3 -3
- package/src/utilities/workerRequests.js +27 -4
- package/builder/assets/index.83c0944f.css +0 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +0 -119
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +0 -548
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +0 -599
- package/coverage/lcov-report/utilities/usageQuota/index.html +0 -141
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +0 -359
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +0 -305
- package/dist/api/controllers/migrations.js +0 -21
- package/dist/api/controllers/row/staticFormula.js +0 -147
- package/dist/api/controllers/table/bulkFormula.js +0 -159
- package/dist/api/routes/migrations.js +0 -9
- package/dist/integrations/googlesheets.js +0 -340
- package/dist/migrations/functions/appUrls.js +0 -46
- package/dist/migrations/functions/quotas1.js +0 -50
- package/dist/migrations/functions/usageQuotas/index.js +0 -20
- package/dist/migrations/functions/usageQuotas/syncApps.js +0 -30
- package/dist/migrations/functions/usageQuotas/syncRows.js +0 -33
- package/dist/migrations/functions/userEmailViewCasing.js +0 -24
- package/dist/migrations/index.js +0 -62
- package/dist/utilities/usageQuota/rows.js +0 -78
- package/dist/utilities/usageQuota/usageQuoteReset.js +0 -16
- package/src/api/controllers/migrations.js +0 -13
- package/src/api/controllers/row/staticFormula.js +0 -156
- package/src/api/controllers/table/bulkFormula.js +0 -173
- package/src/api/routes/migrations.js +0 -14
- package/src/api/routes/tests/static.spec.js +0 -98
- package/src/integrations/googlesheets.ts +0 -353
- package/src/migrations/functions/appUrls.ts +0 -34
- package/src/migrations/functions/quotas1.ts +0 -20
- package/src/migrations/functions/tests/appUrls.spec.js +0 -29
- package/src/migrations/functions/tests/quotas1.spec.js +0 -27
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +0 -25
- package/src/migrations/functions/usageQuotas/index.ts +0 -8
- package/src/migrations/functions/usageQuotas/syncApps.ts +0 -19
- package/src/migrations/functions/usageQuotas/syncRows.ts +0 -22
- package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +0 -37
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +0 -43
- package/src/migrations/functions/userEmailViewCasing.ts +0 -13
- package/src/migrations/index.ts +0 -56
- package/src/utilities/tests/usageQuota/usageQuota.spec.js +0 -72
- package/src/utilities/usageQuota/index.js +0 -93
- package/src/utilities/usageQuota/rows.js +0 -75
- package/src/utilities/usageQuota/usageQuoteReset.js +0 -18
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for utilities/usageQuota/rows.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">utilities/usageQuota</a> rows.js</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">91.66% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>33/36</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">75% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>6/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">91.66% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>33/36</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>
|
|
82
|
-
<a name='L23'></a><a href='#L23'>23</a>
|
|
83
|
-
<a name='L24'></a><a href='#L24'>24</a>
|
|
84
|
-
<a name='L25'></a><a href='#L25'>25</a>
|
|
85
|
-
<a name='L26'></a><a href='#L26'>26</a>
|
|
86
|
-
<a name='L27'></a><a href='#L27'>27</a>
|
|
87
|
-
<a name='L28'></a><a href='#L28'>28</a>
|
|
88
|
-
<a name='L29'></a><a href='#L29'>29</a>
|
|
89
|
-
<a name='L30'></a><a href='#L30'>30</a>
|
|
90
|
-
<a name='L31'></a><a href='#L31'>31</a>
|
|
91
|
-
<a name='L32'></a><a href='#L32'>32</a>
|
|
92
|
-
<a name='L33'></a><a href='#L33'>33</a>
|
|
93
|
-
<a name='L34'></a><a href='#L34'>34</a>
|
|
94
|
-
<a name='L35'></a><a href='#L35'>35</a>
|
|
95
|
-
<a name='L36'></a><a href='#L36'>36</a>
|
|
96
|
-
<a name='L37'></a><a href='#L37'>37</a>
|
|
97
|
-
<a name='L38'></a><a href='#L38'>38</a>
|
|
98
|
-
<a name='L39'></a><a href='#L39'>39</a>
|
|
99
|
-
<a name='L40'></a><a href='#L40'>40</a>
|
|
100
|
-
<a name='L41'></a><a href='#L41'>41</a>
|
|
101
|
-
<a name='L42'></a><a href='#L42'>42</a>
|
|
102
|
-
<a name='L43'></a><a href='#L43'>43</a>
|
|
103
|
-
<a name='L44'></a><a href='#L44'>44</a>
|
|
104
|
-
<a name='L45'></a><a href='#L45'>45</a>
|
|
105
|
-
<a name='L46'></a><a href='#L46'>46</a>
|
|
106
|
-
<a name='L47'></a><a href='#L47'>47</a>
|
|
107
|
-
<a name='L48'></a><a href='#L48'>48</a>
|
|
108
|
-
<a name='L49'></a><a href='#L49'>49</a>
|
|
109
|
-
<a name='L50'></a><a href='#L50'>50</a>
|
|
110
|
-
<a name='L51'></a><a href='#L51'>51</a>
|
|
111
|
-
<a name='L52'></a><a href='#L52'>52</a>
|
|
112
|
-
<a name='L53'></a><a href='#L53'>53</a>
|
|
113
|
-
<a name='L54'></a><a href='#L54'>54</a>
|
|
114
|
-
<a name='L55'></a><a href='#L55'>55</a>
|
|
115
|
-
<a name='L56'></a><a href='#L56'>56</a>
|
|
116
|
-
<a name='L57'></a><a href='#L57'>57</a>
|
|
117
|
-
<a name='L58'></a><a href='#L58'>58</a>
|
|
118
|
-
<a name='L59'></a><a href='#L59'>59</a>
|
|
119
|
-
<a name='L60'></a><a href='#L60'>60</a>
|
|
120
|
-
<a name='L61'></a><a href='#L61'>61</a>
|
|
121
|
-
<a name='L62'></a><a href='#L62'>62</a>
|
|
122
|
-
<a name='L63'></a><a href='#L63'>63</a>
|
|
123
|
-
<a name='L64'></a><a href='#L64'>64</a>
|
|
124
|
-
<a name='L65'></a><a href='#L65'>65</a>
|
|
125
|
-
<a name='L66'></a><a href='#L66'>66</a>
|
|
126
|
-
<a name='L67'></a><a href='#L67'>67</a>
|
|
127
|
-
<a name='L68'></a><a href='#L68'>68</a>
|
|
128
|
-
<a name='L69'></a><a href='#L69'>69</a>
|
|
129
|
-
<a name='L70'></a><a href='#L70'>70</a>
|
|
130
|
-
<a name='L71'></a><a href='#L71'>71</a>
|
|
131
|
-
<a name='L72'></a><a href='#L72'>72</a>
|
|
132
|
-
<a name='L73'></a><a href='#L73'>73</a>
|
|
133
|
-
<a name='L74'></a><a href='#L74'>74</a>
|
|
134
|
-
<a name='L75'></a><a href='#L75'>75</a>
|
|
135
|
-
<a name='L76'></a><a href='#L76'>76</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">25x</span>
|
|
136
|
-
<span class="cline-any cline-yes">25x</span>
|
|
137
|
-
<span class="cline-any cline-yes">25x</span>
|
|
138
|
-
<span class="cline-any cline-neutral"> </span>
|
|
139
|
-
<span class="cline-any cline-yes">25x</span>
|
|
140
|
-
<span class="cline-any cline-neutral"> </span>
|
|
141
|
-
<span class="cline-any cline-yes">25x</span>
|
|
142
|
-
<span class="cline-any cline-neutral"> </span>
|
|
143
|
-
<span class="cline-any cline-neutral"> </span>
|
|
144
|
-
<span class="cline-any cline-yes">1x</span>
|
|
145
|
-
<span class="cline-any cline-yes">1x</span>
|
|
146
|
-
<span class="cline-any cline-yes">4x</span>
|
|
147
|
-
<span class="cline-any cline-yes">4x</span>
|
|
148
|
-
<span class="cline-any cline-yes">2x</span>
|
|
149
|
-
<span class="cline-any cline-neutral"> </span>
|
|
150
|
-
<span class="cline-any cline-yes">4x</span>
|
|
151
|
-
<span class="cline-any cline-yes">2x</span>
|
|
152
|
-
<span class="cline-any cline-neutral"> </span>
|
|
153
|
-
<span class="cline-any cline-yes">2x</span>
|
|
154
|
-
<span class="cline-any cline-neutral"> </span>
|
|
155
|
-
<span class="cline-any cline-neutral"> </span>
|
|
156
|
-
<span class="cline-any cline-yes">1x</span>
|
|
157
|
-
<span class="cline-any cline-neutral"> </span>
|
|
158
|
-
<span class="cline-any cline-neutral"> </span>
|
|
159
|
-
<span class="cline-any cline-yes">25x</span>
|
|
160
|
-
<span class="cline-any cline-neutral"> </span>
|
|
161
|
-
<span class="cline-any cline-yes">4x</span>
|
|
162
|
-
<span class="cline-any cline-yes">4x</span>
|
|
163
|
-
<span class="cline-any cline-neutral"> </span>
|
|
164
|
-
<span class="cline-any cline-neutral"> </span>
|
|
165
|
-
<span class="cline-any cline-neutral"> </span>
|
|
166
|
-
<span class="cline-any cline-neutral"> </span>
|
|
167
|
-
<span class="cline-any cline-yes">4x</span>
|
|
168
|
-
<span class="cline-any cline-yes">3x</span>
|
|
169
|
-
<span class="cline-any cline-neutral"> </span>
|
|
170
|
-
<span class="cline-any cline-yes">3x</span>
|
|
171
|
-
<span class="cline-any cline-yes">3x</span>
|
|
172
|
-
<span class="cline-any cline-no"> </span>
|
|
173
|
-
<span class="cline-any cline-neutral"> </span>
|
|
174
|
-
<span class="cline-any cline-neutral"> </span>
|
|
175
|
-
<span class="cline-any cline-yes">3x</span>
|
|
176
|
-
<span class="cline-any cline-neutral"> </span>
|
|
177
|
-
<span class="cline-any cline-neutral"> </span>
|
|
178
|
-
<span class="cline-any cline-neutral"> </span>
|
|
179
|
-
<span class="cline-any cline-neutral"> </span>
|
|
180
|
-
<span class="cline-any cline-neutral"> </span>
|
|
181
|
-
<span class="cline-any cline-neutral"> </span>
|
|
182
|
-
<span class="cline-any cline-neutral"> </span>
|
|
183
|
-
<span class="cline-any cline-neutral"> </span>
|
|
184
|
-
<span class="cline-any cline-yes">25x</span>
|
|
185
|
-
<span class="cline-any cline-yes">1x</span>
|
|
186
|
-
<span class="cline-any cline-yes">1x</span>
|
|
187
|
-
<span class="cline-any cline-neutral"> </span>
|
|
188
|
-
<span class="cline-any cline-yes">1x</span>
|
|
189
|
-
<span class="cline-any cline-yes">2x</span>
|
|
190
|
-
<span class="cline-any cline-yes">2x</span>
|
|
191
|
-
<span class="cline-any cline-yes">4x</span>
|
|
192
|
-
<span class="cline-any cline-no"> </span>
|
|
193
|
-
<span class="cline-any cline-neutral"> </span>
|
|
194
|
-
<span class="cline-any cline-yes">4x</span>
|
|
195
|
-
<span class="cline-any cline-yes">4x</span>
|
|
196
|
-
<span class="cline-any cline-neutral"> </span>
|
|
197
|
-
<span class="cline-any cline-no"> </span>
|
|
198
|
-
<span class="cline-any cline-neutral"> </span>
|
|
199
|
-
<span class="cline-any cline-neutral"> </span>
|
|
200
|
-
<span class="cline-any cline-neutral"> </span>
|
|
201
|
-
<span class="cline-any cline-neutral"> </span>
|
|
202
|
-
<span class="cline-any cline-neutral"> </span>
|
|
203
|
-
<span class="cline-any cline-neutral"> </span>
|
|
204
|
-
<span class="cline-any cline-neutral"> </span>
|
|
205
|
-
<span class="cline-any cline-yes">2x</span>
|
|
206
|
-
<span class="cline-any cline-neutral"> </span>
|
|
207
|
-
<span class="cline-any cline-neutral"> </span>
|
|
208
|
-
<span class="cline-any cline-yes">1x</span>
|
|
209
|
-
<span class="cline-any cline-neutral"> </span>
|
|
210
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">const { getRowParams, USER_METDATA_PREFIX } = require("../../db/utils")
|
|
211
|
-
const CouchDB = require("../../db")
|
|
212
|
-
const { isDevAppID, getDevelopmentAppID } = require("@budibase/backend-core/db")
|
|
213
|
-
|
|
214
|
-
const ROW_EXCLUSIONS = [USER_METDATA_PREFIX]
|
|
215
|
-
|
|
216
|
-
const getAppPairs = appIds => {
|
|
217
|
-
// collect the app ids into dev / prod pairs
|
|
218
|
-
// keyed by the dev app id
|
|
219
|
-
const pairs = {}
|
|
220
|
-
for (let appId of appIds) {
|
|
221
|
-
const devId = getDevelopmentAppID(appId)
|
|
222
|
-
if (!pairs[devId]) {
|
|
223
|
-
pairs[devId] = {}
|
|
224
|
-
}
|
|
225
|
-
if (isDevAppID(appId)) {
|
|
226
|
-
pairs[devId].devId = appId
|
|
227
|
-
} else {
|
|
228
|
-
pairs[devId].prodId = appId
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return pairs
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const getAppRows = async appId => {
|
|
235
|
-
// need to specify the app ID, as this is used for different apps in one call
|
|
236
|
-
const appDb = new CouchDB(appId)
|
|
237
|
-
const response = await appDb.allDocs(
|
|
238
|
-
getRowParams(null, null, {
|
|
239
|
-
include_docs: false,
|
|
240
|
-
})
|
|
241
|
-
)
|
|
242
|
-
return response.rows
|
|
243
|
-
.map(r => r.id)
|
|
244
|
-
.filter(id => {
|
|
245
|
-
for (let exclusion of ROW_EXCLUSIONS) {
|
|
246
|
-
<span class="missing-if-branch" title="if path not taken" >I</span>if (id.startsWith(exclusion)) {
|
|
247
|
-
<span class="cstat-no" title="statement not covered" > return false</span>
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return true
|
|
251
|
-
})
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Return a set of all rows in the given app ids.
|
|
256
|
-
* The returned rows will be unique on a per dev/prod app basis.
|
|
257
|
-
* Rows duplicates may exist across apps due to data import so they are not filtered out.
|
|
258
|
-
*/
|
|
259
|
-
exports.getUniqueRows = async appIds => {
|
|
260
|
-
let uniqueRows = []
|
|
261
|
-
const pairs = getAppPairs(appIds)
|
|
262
|
-
|
|
263
|
-
for (let pair of Object.values(pairs)) {
|
|
264
|
-
let appRows = []
|
|
265
|
-
for (let appId of [pair.devId, pair.prodId]) {
|
|
266
|
-
<span class="missing-if-branch" title="if path not taken" >I</span>if (!appId) {
|
|
267
|
-
<span class="cstat-no" title="statement not covered" > continue</span>
|
|
268
|
-
}
|
|
269
|
-
try {
|
|
270
|
-
appRows.push(await getAppRows(appId))
|
|
271
|
-
} catch (e) {
|
|
272
|
-
<span class="cstat-no" title="statement not covered" > console.error(e)</span>
|
|
273
|
-
// don't error out if we can't count the app rows, just continue
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// ensure uniqueness on a per app pair basis
|
|
278
|
-
// this can't be done on all rows because app import results in
|
|
279
|
-
// duplicate row ids across apps
|
|
280
|
-
uniqueRows = uniqueRows.concat(...new Set(appRows))
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
return uniqueRows
|
|
284
|
-
}
|
|
285
|
-
</pre></td></tr></table></pre>
|
|
286
|
-
|
|
287
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
288
|
-
</div><!-- /wrapper -->
|
|
289
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
290
|
-
Code coverage generated by
|
|
291
|
-
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
292
|
-
at Tue Feb 01 2022 16:32:19 GMT+0000 (Coordinated Universal Time)
|
|
293
|
-
</div>
|
|
294
|
-
</div>
|
|
295
|
-
<script src="../../prettify.js"></script>
|
|
296
|
-
<script>
|
|
297
|
-
window.onload = function () {
|
|
298
|
-
prettyPrint();
|
|
299
|
-
};
|
|
300
|
-
</script>
|
|
301
|
-
<script src="../../sorter.js"></script>
|
|
302
|
-
<script src="../../block-navigation.js"></script>
|
|
303
|
-
</body>
|
|
304
|
-
</html>
|
|
305
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
const { migrate, MIGRATIONS } = require("../../migrations");
|
|
12
|
-
exports.migrate = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
-
const options = ctx.request.body;
|
|
14
|
-
// don't await as can take a while, just return
|
|
15
|
-
migrate(options);
|
|
16
|
-
ctx.status = 200;
|
|
17
|
-
});
|
|
18
|
-
exports.fetchDefinitions = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
ctx.body = MIGRATIONS;
|
|
20
|
-
ctx.status = 200;
|
|
21
|
-
});
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
const { getRowParams } = require("../../../db/utils");
|
|
12
|
-
const { outputProcessing, processAutoColumn, processFormulas, } = require("../../../utilities/rowProcessor");
|
|
13
|
-
const { FieldTypes, FormulaTypes } = require("../../../constants");
|
|
14
|
-
const { isEqual } = require("lodash");
|
|
15
|
-
const { cloneDeep } = require("lodash/fp");
|
|
16
|
-
const { getAppDB } = require("@budibase/backend-core/context");
|
|
17
|
-
/**
|
|
18
|
-
* This function runs through a list of enriched rows, looks at the rows which
|
|
19
|
-
* are related and then checks if they need the state of their formulas
|
|
20
|
-
* updated.
|
|
21
|
-
* NOTE: this will only for affect static formulas.
|
|
22
|
-
*/
|
|
23
|
-
exports.updateRelatedFormula = (table, enrichedRows) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
const db = getAppDB();
|
|
25
|
-
// no formula to update, we're done
|
|
26
|
-
if (!table.relatedFormula) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
let promises = [];
|
|
30
|
-
for (let enrichedRow of Array.isArray(enrichedRows)
|
|
31
|
-
? enrichedRows
|
|
32
|
-
: [enrichedRows]) {
|
|
33
|
-
// the related rows by tableId
|
|
34
|
-
let relatedRows = {};
|
|
35
|
-
for (let [key, field] of Object.entries(enrichedRow)) {
|
|
36
|
-
const columnDefinition = table.schema[key];
|
|
37
|
-
if (columnDefinition && columnDefinition.type === FieldTypes.LINK) {
|
|
38
|
-
const relatedTableId = columnDefinition.tableId;
|
|
39
|
-
if (!relatedRows[relatedTableId]) {
|
|
40
|
-
relatedRows[relatedTableId] = [];
|
|
41
|
-
}
|
|
42
|
-
relatedRows[relatedTableId] = relatedRows[relatedTableId].concat(field);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
for (let tableId of table.relatedFormula) {
|
|
46
|
-
let relatedTable;
|
|
47
|
-
try {
|
|
48
|
-
// no rows to update, skip
|
|
49
|
-
if (!relatedRows[tableId] || relatedRows[tableId].length === 0) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
relatedTable = yield db.get(tableId);
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
// no error scenario, table doesn't seem to exist anymore, ignore
|
|
56
|
-
}
|
|
57
|
-
for (let column of Object.values(relatedTable.schema)) {
|
|
58
|
-
// needs updated in related rows
|
|
59
|
-
if (column.type === FieldTypes.FORMULA &&
|
|
60
|
-
column.formulaType === FormulaTypes.STATIC) {
|
|
61
|
-
// re-enrich rows for all the related, don't update the related formula for them
|
|
62
|
-
promises = promises.concat(relatedRows[tableId].map(related => exports.finaliseRow(relatedTable, related, {
|
|
63
|
-
updateFormula: false,
|
|
64
|
-
})));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
yield Promise.all(promises);
|
|
70
|
-
});
|
|
71
|
-
exports.updateAllFormulasInTable = (table) => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
-
const db = getAppDB();
|
|
73
|
-
// start by getting the raw rows (which will be written back to DB after update)
|
|
74
|
-
let rows = (yield db.allDocs(getRowParams(table._id, null, {
|
|
75
|
-
include_docs: true,
|
|
76
|
-
}))).rows.map(row => row.doc);
|
|
77
|
-
// now enrich the rows, note the clone so that we have the base state of the
|
|
78
|
-
// rows so that we don't write any of the enriched information back
|
|
79
|
-
let enrichedRows = yield outputProcessing(table, cloneDeep(rows), {
|
|
80
|
-
squash: false,
|
|
81
|
-
});
|
|
82
|
-
const updatedRows = [];
|
|
83
|
-
for (let row of rows) {
|
|
84
|
-
// find the enriched row, if found process the formulas
|
|
85
|
-
const enrichedRow = enrichedRows.find(enriched => enriched._id === row._id);
|
|
86
|
-
if (enrichedRow) {
|
|
87
|
-
const processed = processFormulas(table, cloneDeep(row), {
|
|
88
|
-
dynamic: false,
|
|
89
|
-
contextRows: enrichedRow,
|
|
90
|
-
});
|
|
91
|
-
// values have changed, need to add to bulk docs to update
|
|
92
|
-
if (!isEqual(processed, row)) {
|
|
93
|
-
updatedRows.push(processed);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
yield db.bulkDocs(updatedRows);
|
|
98
|
-
});
|
|
99
|
-
/**
|
|
100
|
-
* This function runs at the end of the save/patch functions of the row controller, all this
|
|
101
|
-
* really does is enrich the row, handle any static formula processing, then return the enriched
|
|
102
|
-
* row. The reason we need to return the enriched row is that the automation row created trigger
|
|
103
|
-
* expects the row to be totally enriched/contain all relationships.
|
|
104
|
-
*/
|
|
105
|
-
exports.finaliseRow = (table, row, { oldTable, updateFormula } = { updateFormula: true }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
const db = getAppDB();
|
|
107
|
-
row.type = "row";
|
|
108
|
-
// process the row before return, to include relationships
|
|
109
|
-
let enrichedRow = yield outputProcessing(table, cloneDeep(row), {
|
|
110
|
-
squash: false,
|
|
111
|
-
});
|
|
112
|
-
// use enriched row to generate formulas for saving, specifically only use as context
|
|
113
|
-
row = processFormulas(table, row, {
|
|
114
|
-
dynamic: false,
|
|
115
|
-
contextRows: enrichedRow,
|
|
116
|
-
});
|
|
117
|
-
// don't worry about rev, tables handle rev/lastID updates
|
|
118
|
-
// if another row has been written since processing this will
|
|
119
|
-
// handle the auto ID clash
|
|
120
|
-
if (oldTable && !isEqual(oldTable, table)) {
|
|
121
|
-
try {
|
|
122
|
-
yield db.put(table);
|
|
123
|
-
}
|
|
124
|
-
catch (err) {
|
|
125
|
-
if (err.status === 409) {
|
|
126
|
-
const updatedTable = yield db.get(table._id);
|
|
127
|
-
let response = processAutoColumn(null, updatedTable, row, {
|
|
128
|
-
reprocessing: true,
|
|
129
|
-
});
|
|
130
|
-
yield db.put(response.table);
|
|
131
|
-
row = response.row;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
throw err;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const response = yield db.put(row);
|
|
139
|
-
// for response, calculate the formulas for the enriched row
|
|
140
|
-
enrichedRow._rev = response.rev;
|
|
141
|
-
enrichedRow = yield processFormulas(table, enrichedRow, { dynamic: false });
|
|
142
|
-
// this updates the related formulas in other rows based on the relations to this row
|
|
143
|
-
if (updateFormula) {
|
|
144
|
-
yield exports.updateRelatedFormula(table, enrichedRow);
|
|
145
|
-
}
|
|
146
|
-
return { row: enrichedRow, table };
|
|
147
|
-
});
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
const { FieldTypes, FormulaTypes } = require("../../../constants");
|
|
12
|
-
const { getAllInternalTables, clearColumns } = require("./utils");
|
|
13
|
-
const { doesContainStrings } = require("@budibase/string-templates");
|
|
14
|
-
const { cloneDeep } = require("lodash/fp");
|
|
15
|
-
const { isEqual, uniq } = require("lodash");
|
|
16
|
-
const { updateAllFormulasInTable } = require("../row/staticFormula");
|
|
17
|
-
const { getAppDB } = require("@budibase/backend-core/context");
|
|
18
|
-
function isStaticFormula(column) {
|
|
19
|
-
return (column.type === FieldTypes.FORMULA &&
|
|
20
|
-
column.formulaType === FormulaTypes.STATIC);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* This retrieves the formula columns from a table schema that use a specified column name
|
|
24
|
-
* in the formula.
|
|
25
|
-
*/
|
|
26
|
-
function getFormulaThatUseColumn(table, columnNames) {
|
|
27
|
-
let formula = [];
|
|
28
|
-
columnNames = Array.isArray(columnNames) ? columnNames : [columnNames];
|
|
29
|
-
for (let column of Object.values(table.schema)) {
|
|
30
|
-
// not a static formula, or doesn't contain a relationship
|
|
31
|
-
if (!isStaticFormula(column)) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
if (!doesContainStrings(column.formula, columnNames)) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
formula.push(column.name);
|
|
38
|
-
}
|
|
39
|
-
return formula;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* This functions checks for when a related table, column or related column is deleted, if any
|
|
43
|
-
* tables need to have the formula column removed.
|
|
44
|
-
*/
|
|
45
|
-
function checkIfFormulaNeedsCleared(table, { oldTable, deletion }) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
// start by retrieving all tables, remove the current table from the list
|
|
48
|
-
const tables = (yield getAllInternalTables()).filter(tbl => tbl._id !== table._id);
|
|
49
|
-
const schemaToUse = oldTable ? oldTable.schema : table.schema;
|
|
50
|
-
let removedColumns = Object.values(schemaToUse).filter(column => deletion || !table.schema[column.name]);
|
|
51
|
-
// remove any formula columns that used related columns
|
|
52
|
-
for (let removed of removedColumns) {
|
|
53
|
-
let tableToUse = table;
|
|
54
|
-
// if relationship, get the related table
|
|
55
|
-
if (removed.type === FieldTypes.LINK) {
|
|
56
|
-
tableToUse = tables.find(table => table._id === removed.tableId);
|
|
57
|
-
}
|
|
58
|
-
const columnsToDelete = getFormulaThatUseColumn(tableToUse, removed.name);
|
|
59
|
-
if (columnsToDelete.length > 0) {
|
|
60
|
-
yield clearColumns(table, columnsToDelete);
|
|
61
|
-
}
|
|
62
|
-
// need a special case, where a column has been removed from this table, but was used
|
|
63
|
-
// in a different, related tables formula
|
|
64
|
-
if (!table.relatedFormula) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
for (let relatedTableId of table.relatedFormula) {
|
|
68
|
-
const relatedColumns = Object.values(table.schema).filter(column => column.tableId === relatedTableId);
|
|
69
|
-
const relatedTable = tables.find(table => table._id === relatedTableId);
|
|
70
|
-
// look to see if the column was used in a relationship formula,
|
|
71
|
-
// relationships won't be used for this
|
|
72
|
-
if (relatedTable && relatedColumns && removed.type !== FieldTypes.LINK) {
|
|
73
|
-
let relatedFormulaToRemove = [];
|
|
74
|
-
for (let column of relatedColumns) {
|
|
75
|
-
relatedFormulaToRemove = relatedFormulaToRemove.concat(getFormulaThatUseColumn(relatedTable, [
|
|
76
|
-
column.fieldName,
|
|
77
|
-
removed.name,
|
|
78
|
-
]));
|
|
79
|
-
}
|
|
80
|
-
if (relatedFormulaToRemove.length > 0) {
|
|
81
|
-
yield clearColumns(relatedTable, uniq(relatedFormulaToRemove));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* This function adds a note to related tables that they are
|
|
90
|
-
* used in a static formula - so that the link controller
|
|
91
|
-
* can manage hydrating related rows formula fields. This is
|
|
92
|
-
* specifically only for static formula.
|
|
93
|
-
*/
|
|
94
|
-
function updateRelatedFormulaLinksOnTables(table, { deletion } = { deletion: false }) {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const db = getAppDB();
|
|
97
|
-
// start by retrieving all tables, remove the current table from the list
|
|
98
|
-
const tables = (yield getAllInternalTables()).filter(tbl => tbl._id !== table._id);
|
|
99
|
-
// clone the tables, so we can compare at end
|
|
100
|
-
const initialTables = cloneDeep(tables);
|
|
101
|
-
// first find the related column names
|
|
102
|
-
const relatedColumns = Object.values(table.schema).filter(col => col.type === FieldTypes.LINK);
|
|
103
|
-
// we start by removing the formula field from all tables
|
|
104
|
-
for (let otherTable of tables) {
|
|
105
|
-
if (!otherTable.relatedFormula) {
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
const index = otherTable.relatedFormula.indexOf(table._id);
|
|
109
|
-
if (index !== -1) {
|
|
110
|
-
otherTable.relatedFormula.splice(index, 1);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
// if deleting, just remove the table IDs, don't try add
|
|
114
|
-
if (!deletion) {
|
|
115
|
-
for (let relatedCol of relatedColumns) {
|
|
116
|
-
let columns = getFormulaThatUseColumn(table, relatedCol.name);
|
|
117
|
-
if (!columns || columns.length === 0) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
const relatedTable = tables.find(related => related._id === relatedCol.tableId);
|
|
121
|
-
// check if the table is already in the list of related formula, if it isn't, then add it
|
|
122
|
-
if (relatedTable &&
|
|
123
|
-
(!relatedTable.relatedFormula ||
|
|
124
|
-
!relatedTable.relatedFormula.includes(table._id))) {
|
|
125
|
-
relatedTable.relatedFormula = relatedTable.relatedFormula
|
|
126
|
-
? [...relatedTable.relatedFormula, table._id]
|
|
127
|
-
: [table._id];
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
// now we just need to compare all the tables and see if any need saved
|
|
132
|
-
for (let initial of initialTables) {
|
|
133
|
-
const found = tables.find(tbl => initial._id === tbl._id);
|
|
134
|
-
if (found && !isEqual(initial, found)) {
|
|
135
|
-
yield db.put(found);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
function checkIfFormulaUpdated(table, { oldTable }) {
|
|
141
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
// look to see if any formula values have changed
|
|
143
|
-
const shouldUpdate = Object.values(table.schema).find(column => isStaticFormula(column) &&
|
|
144
|
-
(!oldTable ||
|
|
145
|
-
!oldTable.schema[column.name] ||
|
|
146
|
-
!isEqual(oldTable.schema[column.name], column)));
|
|
147
|
-
// if a static formula column has updated, then need to run the update
|
|
148
|
-
if (shouldUpdate != null) {
|
|
149
|
-
yield updateAllFormulasInTable(table);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
exports.runStaticFormulaChecks = (table, { oldTable, deletion }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
154
|
-
yield updateRelatedFormulaLinksOnTables(table, { deletion });
|
|
155
|
-
yield checkIfFormulaNeedsCleared(table, { oldTable, deletion });
|
|
156
|
-
if (!deletion) {
|
|
157
|
-
yield checkIfFormulaUpdated(table, { oldTable });
|
|
158
|
-
}
|
|
159
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const Router = require("@koa/router");
|
|
3
|
-
const migrationsController = require("../controllers/migrations");
|
|
4
|
-
const router = Router();
|
|
5
|
-
const { internalApi } = require("@budibase/backend-core/auth");
|
|
6
|
-
router
|
|
7
|
-
.post("/api/migrations/run", internalApi, migrationsController.migrate)
|
|
8
|
-
.get("/api/migrations/definitions", internalApi, migrationsController.fetchDefinitions);
|
|
9
|
-
module.exports = router;
|