@budibase/server 1.0.49 → 1.0.50-alpha.0
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.c0cc369d.css +6 -0
- package/builder/assets/{index.2c37968e.js → index.ff2bad21.js} +252 -249
- package/builder/assets/{vendor.f9faf6ab.js → vendor.5ad9695a.js} +202 -106
- package/builder/index.html +3 -3
- package/coverage/clover.xml +3105 -2814
- package/coverage/coverage-final.json +106 -101
- 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 +257 -152
- package/coverage/lcov-report/api/controllers/auth.js.html +22 -13
- 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 +13 -16
- package/coverage/lcov-report/api/controllers/datasource.js.html +81 -51
- package/coverage/lcov-report/api/controllers/dev.js.html +6 -6
- package/coverage/lcov-report/api/controllers/index.html +78 -78
- 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/api/controllers/migrations.js.html +119 -0
- 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 +55 -40
- package/coverage/lcov-report/api/controllers/row/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/row/internal.js.html +118 -226
- 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 +47 -62
- 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 +58 -43
- package/coverage/lcov-report/api/controllers/table/index.js.html +58 -82
- package/coverage/lcov-report/api/controllers/table/internal.js.html +81 -66
- package/coverage/lcov-report/api/controllers/table/utils.js.html +218 -110
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +79 -76
- 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 +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/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/{hosting.js.html → migrations.js.html} +17 -14
- 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 +17 -2
- 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 +13 -22
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +11 -20
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +13 -13
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +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 +53 -26
- 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 +25 -37
- package/coverage/lcov-report/db/linkedRows/index.html +27 -27
- package/coverage/lcov-report/db/linkedRows/index.js.html +51 -96
- 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 +135 -120
- 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 +173 -65
- package/coverage/lcov-report/middleware/builder.js.html +10 -10
- package/coverage/lcov-report/middleware/currentapp.js.html +95 -83
- 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 +281 -53
- 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 +26 -26
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +39 -24
- 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 +58 -49
- package/coverage/lcov-report/utilities/index.html +37 -37
- package/coverage/lcov-report/utilities/index.js.html +43 -73
- 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 +97 -103
- 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 +141 -0
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +359 -0
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +305 -0
- package/coverage/lcov-report/{api/controllers/hosting.js.html → utilities/usageQuota/usageQuoteReset.js.html} +36 -48
- package/coverage/lcov-report/utilities/users.js.html +9 -9
- package/coverage/lcov-report/utilities/workerRequests.js.html +43 -112
- package/coverage/lcov.info +5010 -4425
- package/dist/api/controllers/application.js +90 -60
- package/dist/api/controllers/auth.js +8 -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 +20 -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 +13 -14
- package/dist/api/controllers/screen.js +5 -7
- package/dist/api/controllers/static/index.js +62 -16
- 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 +16 -13
- package/dist/api/controllers/table/internal.js +22 -16
- package/dist/api/controllers/table/utils.js +62 -35
- package/dist/api/controllers/user.js +43 -43
- 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 -2
- package/dist/api/routes/migrations.js +9 -0
- package/dist/api/routes/static.js +2 -1
- 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 +3 -5
- package/dist/automations/steps/deleteRow.js +1 -4
- 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 +7 -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/definitions/datasource.js +1 -0
- package/dist/environment.js +4 -1
- package/dist/integrations/base/sql.js +62 -21
- package/dist/integrations/googlesheets.js +340 -0
- package/dist/integrations/index.js +3 -0
- package/dist/integrations/utils.js +60 -9
- package/dist/middleware/authorized.js +57 -30
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +41 -37
- package/dist/middleware/usageQuota.js +82 -15
- package/dist/migrations/functions/appUrls.js +46 -0
- package/dist/migrations/functions/quotas1.js +50 -0
- package/dist/migrations/functions/usageQuotas/index.js +20 -0
- package/dist/migrations/functions/usageQuotas/syncApps.js +29 -0
- package/dist/migrations/functions/usageQuotas/syncRows.js +33 -0
- package/dist/migrations/functions/userEmailViewCasing.js +24 -0
- package/dist/migrations/index.js +62 -0
- package/dist/package.json +8 -5
- package/dist/tests/utilities/TestConfiguration.js +80 -50
- package/dist/threads/automation.js +13 -11
- package/dist/threads/query.js +15 -11
- 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.js → usageQuota/index.js} +45 -31
- package/dist/utilities/usageQuota/rows.js +78 -0
- package/dist/utilities/usageQuota/usageQuoteReset.js +16 -0
- package/dist/utilities/users.js +3 -3
- package/dist/utilities/workerRequests.js +4 -24
- package/nodemon.json +1 -1
- package/package.json +9 -6
- package/scripts/integrations/mssql/data/Dockerfile +1 -1
- package/scripts/integrations/mssql/data/setup.sql +17 -4
- package/scripts/integrations/postgres/init.sql +11 -6
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/application.js +85 -50
- package/src/api/controllers/auth.js +8 -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 +21 -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 +13 -18
- package/src/api/controllers/screen.js +5 -7
- package/src/api/controllers/static/index.js +66 -15
- 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 +20 -28
- package/src/api/controllers/table/internal.js +24 -19
- package/src/api/controllers/table/utils.js +78 -42
- package/src/api/controllers/user.js +46 -45
- 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 -2
- package/src/api/routes/migrations.js +14 -0
- package/src/api/routes/static.js +5 -0
- package/src/api/routes/tests/application.spec.js +2 -2
- package/src/api/routes/tests/auth.spec.js +1 -2
- 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/static.spec.js +98 -0
- 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 +2 -5
- package/src/automations/steps/deleteRow.js +1 -4
- 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 +9 -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/definitions/datasource.ts +3 -0
- package/src/environment.js +4 -1
- package/src/integrations/base/sql.ts +75 -29
- package/src/integrations/googlesheets.ts +353 -0
- package/src/integrations/index.ts +3 -0
- package/src/integrations/tests/sql.spec.js +16 -0
- package/src/integrations/utils.ts +75 -12
- package/src/middleware/authorized.js +66 -30
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +50 -46
- package/src/middleware/tests/authorized.spec.js +13 -6
- package/src/middleware/tests/currentapp.spec.js +6 -0
- package/src/middleware/tests/usageQuota.spec.js +18 -24
- package/src/middleware/usageQuota.js +93 -17
- 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/functions/tests/quotas1.spec.js +27 -0
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +25 -0
- package/src/migrations/functions/usageQuotas/index.ts +8 -0
- package/src/migrations/functions/usageQuotas/syncApps.ts +18 -0
- package/src/migrations/functions/usageQuotas/syncRows.ts +22 -0
- package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +37 -0
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +43 -0
- 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 +82 -55
- package/src/threads/automation.js +17 -15
- package/src/threads/query.js +17 -12
- 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/tests/usageQuota/usageQuota.spec.js +72 -0
- package/src/utilities/usageQuota/index.js +93 -0
- package/src/utilities/usageQuota/rows.js +75 -0
- package/src/utilities/usageQuota/usageQuoteReset.js +18 -0
- package/src/utilities/users.js +3 -3
- package/src/utilities/workerRequests.js +4 -27
- package/tsconfig.json +2 -1
- package/builder/assets/index.39e01193.css +0 -1
- package/dist/api/controllers/hosting.js +0 -30
- package/dist/api/routes/hosting.js +0 -11
- package/src/api/controllers/hosting.js +0 -22
- package/src/api/routes/hosting.js +0 -13
- package/src/api/routes/tests/hosting.spec.js +0 -36
- package/src/utilities/usageQuota.js +0 -73
|
@@ -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
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const getTenantId = jest.fn()
|
|
2
|
+
jest.mock("@budibase/backend-core/tenancy", () => ({
|
|
3
|
+
getTenantId
|
|
4
|
+
}))
|
|
5
|
+
const usageQuota = require("../../usageQuota")
|
|
6
|
+
const env = require("../../../environment")
|
|
7
|
+
|
|
8
|
+
class TestConfiguration {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.enableQuotas()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
enableQuotas = () => {
|
|
14
|
+
env.USE_QUOTAS = 1
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
disableQuotas = () => {
|
|
18
|
+
env.USE_QUOTAS = null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
setTenantId = (tenantId) => {
|
|
22
|
+
getTenantId.mockReturnValue(tenantId)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setExcludedTenants = (tenants) => {
|
|
26
|
+
env.EXCLUDE_QUOTAS_TENANTS = tenants
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
reset = () => {
|
|
30
|
+
this.disableQuotas()
|
|
31
|
+
this.setExcludedTenants(null)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe("usageQuota", () => {
|
|
36
|
+
let config
|
|
37
|
+
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
config = new TestConfiguration()
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
config.reset()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
describe("useQuotas", () => {
|
|
47
|
+
it("works when no settings have been provided", () => {
|
|
48
|
+
config.reset()
|
|
49
|
+
expect(usageQuota.useQuotas()).toBe(false)
|
|
50
|
+
})
|
|
51
|
+
it("honours USE_QUOTAS setting", () => {
|
|
52
|
+
config.disableQuotas()
|
|
53
|
+
expect(usageQuota.useQuotas()).toBe(false)
|
|
54
|
+
|
|
55
|
+
config.enableQuotas()
|
|
56
|
+
expect(usageQuota.useQuotas()).toBe(true)
|
|
57
|
+
})
|
|
58
|
+
it("honours EXCLUDE_QUOTAS_TENANTS setting", () => {
|
|
59
|
+
config.setTenantId("test")
|
|
60
|
+
|
|
61
|
+
// tenantId is in the list
|
|
62
|
+
config.setExcludedTenants("test, test2, test2")
|
|
63
|
+
expect(usageQuota.useQuotas()).toBe(false)
|
|
64
|
+
config.setExcludedTenants("test,test2,test2")
|
|
65
|
+
expect(usageQuota.useQuotas()).toBe(false)
|
|
66
|
+
|
|
67
|
+
// tenantId is not in the list
|
|
68
|
+
config.setTenantId("other")
|
|
69
|
+
expect(usageQuota.useQuotas()).toBe(true)
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
})
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const env = require("../../environment")
|
|
2
|
+
const { getGlobalDB, getTenantId } = require("@budibase/backend-core/tenancy")
|
|
3
|
+
const {
|
|
4
|
+
StaticDatabases,
|
|
5
|
+
generateNewUsageQuotaDoc,
|
|
6
|
+
} = require("@budibase/backend-core/db")
|
|
7
|
+
|
|
8
|
+
exports.useQuotas = () => {
|
|
9
|
+
// check if quotas are enabled
|
|
10
|
+
if (env.USE_QUOTAS) {
|
|
11
|
+
// check if there are any tenants without limits
|
|
12
|
+
if (env.EXCLUDE_QUOTAS_TENANTS) {
|
|
13
|
+
const excludedTenants = env.EXCLUDE_QUOTAS_TENANTS.replace(
|
|
14
|
+
/\s/g,
|
|
15
|
+
""
|
|
16
|
+
).split(",")
|
|
17
|
+
const tenantId = getTenantId()
|
|
18
|
+
if (excludedTenants.includes(tenantId)) {
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
return false
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.Properties = {
|
|
28
|
+
ROW: "rows",
|
|
29
|
+
UPLOAD: "storage", // doesn't work yet
|
|
30
|
+
VIEW: "views", // doesn't work yet
|
|
31
|
+
USER: "users", // doesn't work yet
|
|
32
|
+
AUTOMATION: "automationRuns", // doesn't work yet
|
|
33
|
+
APPS: "apps",
|
|
34
|
+
EMAILS: "emails", // doesn't work yet
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.getUsageQuotaDoc = async db => {
|
|
38
|
+
let quota
|
|
39
|
+
try {
|
|
40
|
+
quota = await db.get(StaticDatabases.GLOBAL.docs.usageQuota)
|
|
41
|
+
} catch (err) {
|
|
42
|
+
// doc doesn't exist. Create it
|
|
43
|
+
quota = generateNewUsageQuotaDoc()
|
|
44
|
+
const response = await db.put(quota)
|
|
45
|
+
quota._rev = response.rev
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return quota
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Given a specified tenantId this will add to the usage object for the specified property.
|
|
53
|
+
* @param {string} property The property which is to be added to (within the nested usageQuota object).
|
|
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.
|
|
56
|
+
* @returns {Promise<void>} When this completes the API key will now be up to date - the quota period may have
|
|
57
|
+
* also been reset after this call.
|
|
58
|
+
*/
|
|
59
|
+
exports.update = async (property, usage, opts = { dryRun: false }) => {
|
|
60
|
+
if (!exports.useQuotas()) {
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const db = getGlobalDB()
|
|
66
|
+
const quota = await exports.getUsageQuotaDoc(db)
|
|
67
|
+
|
|
68
|
+
// increment the quota
|
|
69
|
+
quota.usageQuota[property] += usage
|
|
70
|
+
|
|
71
|
+
if (
|
|
72
|
+
quota.usageQuota[property] > quota.usageLimits[property] &&
|
|
73
|
+
usage > 0 // allow for decrementing usage when the quota is already exceeded
|
|
74
|
+
) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
`You have exceeded your usage quota of ${quota.usageLimits[property]} ${property}.`
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (quota.usageQuota[property] < 0) {
|
|
81
|
+
// never go negative if the quota has previously been exceeded
|
|
82
|
+
quota.usageQuota[property] = 0
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// update the usage quotas
|
|
86
|
+
if (!opts.dryRun) {
|
|
87
|
+
await db.put(quota)
|
|
88
|
+
}
|
|
89
|
+
} catch (err) {
|
|
90
|
+
console.error(`Error updating usage quotas for ${property}`, err)
|
|
91
|
+
throw err
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const { getRowParams, USER_METDATA_PREFIX } = require("../../db/utils")
|
|
2
|
+
const CouchDB = require("../../db")
|
|
3
|
+
const { isDevAppID, getDevelopmentAppID } = require("@budibase/backend-core/db")
|
|
4
|
+
|
|
5
|
+
const ROW_EXCLUSIONS = [USER_METDATA_PREFIX]
|
|
6
|
+
|
|
7
|
+
const getAppPairs = appIds => {
|
|
8
|
+
// collect the app ids into dev / prod pairs
|
|
9
|
+
// keyed by the dev app id
|
|
10
|
+
const pairs = {}
|
|
11
|
+
for (let appId of appIds) {
|
|
12
|
+
const devId = getDevelopmentAppID(appId)
|
|
13
|
+
if (!pairs[devId]) {
|
|
14
|
+
pairs[devId] = {}
|
|
15
|
+
}
|
|
16
|
+
if (isDevAppID(appId)) {
|
|
17
|
+
pairs[devId].devId = appId
|
|
18
|
+
} else {
|
|
19
|
+
pairs[devId].prodId = appId
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return pairs
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const getAppRows = async appId => {
|
|
26
|
+
// need to specify the app ID, as this is used for different apps in one call
|
|
27
|
+
const appDb = new CouchDB(appId)
|
|
28
|
+
const response = await appDb.allDocs(
|
|
29
|
+
getRowParams(null, null, {
|
|
30
|
+
include_docs: false,
|
|
31
|
+
})
|
|
32
|
+
)
|
|
33
|
+
return response.rows
|
|
34
|
+
.map(r => r.id)
|
|
35
|
+
.filter(id => {
|
|
36
|
+
for (let exclusion of ROW_EXCLUSIONS) {
|
|
37
|
+
if (id.startsWith(exclusion)) {
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return true
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Return a set of all rows in the given app ids.
|
|
47
|
+
* The returned rows will be unique on a per dev/prod app basis.
|
|
48
|
+
* Rows duplicates may exist across apps due to data import so they are not filtered out.
|
|
49
|
+
*/
|
|
50
|
+
exports.getUniqueRows = async appIds => {
|
|
51
|
+
let uniqueRows = []
|
|
52
|
+
const pairs = getAppPairs(appIds)
|
|
53
|
+
|
|
54
|
+
for (let pair of Object.values(pairs)) {
|
|
55
|
+
let appRows = []
|
|
56
|
+
for (let appId of [pair.devId, pair.prodId]) {
|
|
57
|
+
if (!appId) {
|
|
58
|
+
continue
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
appRows.push(await getAppRows(appId))
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.error(e)
|
|
64
|
+
// don't error out if we can't count the app rows, just continue
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ensure uniqueness on a per app pair basis
|
|
69
|
+
// this can't be done on all rows because app import results in
|
|
70
|
+
// duplicate row ids across apps
|
|
71
|
+
uniqueRows = uniqueRows.concat(...new Set(appRows))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return uniqueRows
|
|
75
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// UNUSED CODE
|
|
2
|
+
// Preserved for future use
|
|
3
|
+
|
|
4
|
+
/* eslint-disable no-unused-vars */
|
|
5
|
+
|
|
6
|
+
function getNewQuotaReset() {
|
|
7
|
+
return Date.now() + 2592000000
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function resetQuotasIfRequired(quota) {
|
|
11
|
+
// Check if the quota needs reset
|
|
12
|
+
if (Date.now() >= quota.quotaReset) {
|
|
13
|
+
quota.quotaReset = getNewQuotaReset()
|
|
14
|
+
for (let prop of Object.keys(quota.usageQuota)) {
|
|
15
|
+
quota.usageQuota[prop] = 0
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
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")
|
|
@@ -58,29 +58,6 @@ exports.sendSmtpEmail = async (to, from, subject, contents, automation) => {
|
|
|
58
58
|
return response.json()
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
exports.getDeployedApps = async () => {
|
|
62
|
-
try {
|
|
63
|
-
const response = await fetch(
|
|
64
|
-
checkSlashesInUrl(env.WORKER_URL + `/api/apps`),
|
|
65
|
-
request(null, {
|
|
66
|
-
method: "GET",
|
|
67
|
-
})
|
|
68
|
-
)
|
|
69
|
-
const json = await response.json()
|
|
70
|
-
const apps = {}
|
|
71
|
-
for (let [key, value] of Object.entries(json)) {
|
|
72
|
-
if (value.url) {
|
|
73
|
-
value.url = value.url.toLowerCase()
|
|
74
|
-
apps[key.toLowerCase()] = value
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return apps
|
|
78
|
-
} catch (err) {
|
|
79
|
-
// error, cannot determine deployed apps, don't stop app creation - sort this later
|
|
80
|
-
return {}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
61
|
exports.getGlobalSelf = async (ctx, appId = null) => {
|
|
85
62
|
const endpoint = `/api/global/users/self`
|
|
86
63
|
const response = await fetch(
|
|
@@ -93,15 +70,15 @@ exports.getGlobalSelf = async (ctx, appId = null) => {
|
|
|
93
70
|
}
|
|
94
71
|
let json = await response.json()
|
|
95
72
|
if (appId) {
|
|
96
|
-
json = updateAppRole(
|
|
73
|
+
json = updateAppRole(json)
|
|
97
74
|
}
|
|
98
75
|
return json
|
|
99
76
|
}
|
|
100
77
|
|
|
101
78
|
exports.removeAppFromUserRoles = async (ctx, appId) => {
|
|
102
|
-
const
|
|
79
|
+
const prodAppId = getProdAppID(appId)
|
|
103
80
|
const response = await fetch(
|
|
104
|
-
checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${
|
|
81
|
+
checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${prodAppId}`),
|
|
105
82
|
request(ctx, {
|
|
106
83
|
method: "DELETE",
|
|
107
84
|
})
|