@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,20 +1,12 @@
|
|
|
1
|
+
const CouchDB = require("../../../db")
|
|
1
2
|
const Deployment = require("./Deployment")
|
|
2
|
-
const {
|
|
3
|
-
Replication,
|
|
4
|
-
getProdAppID,
|
|
5
|
-
getDevelopmentAppID,
|
|
6
|
-
} = require("@budibase/backend-core/db")
|
|
3
|
+
const { Replication, getDeployedAppID } = require("@budibase/backend-core/db")
|
|
7
4
|
const { DocumentTypes, getAutomationParams } = require("../../../db/utils")
|
|
8
5
|
const {
|
|
9
6
|
disableAllCrons,
|
|
10
7
|
enableCronTrigger,
|
|
11
8
|
} = require("../../../automations/utils")
|
|
12
9
|
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
13
|
-
const {
|
|
14
|
-
getAppId,
|
|
15
|
-
getAppDB,
|
|
16
|
-
getProdAppDB,
|
|
17
|
-
} = require("@budibase/backend-core/context")
|
|
18
10
|
|
|
19
11
|
// the max time we can wait for an invalidation to complete before considering it failed
|
|
20
12
|
const MAX_PENDING_TIME_MS = 30 * 60000
|
|
@@ -42,8 +34,9 @@ async function checkAllDeployments(deployments) {
|
|
|
42
34
|
}
|
|
43
35
|
|
|
44
36
|
async function storeDeploymentHistory(deployment) {
|
|
37
|
+
const appId = deployment.getAppId()
|
|
45
38
|
const deploymentJSON = deployment.getJSON()
|
|
46
|
-
const db =
|
|
39
|
+
const db = new CouchDB(appId)
|
|
47
40
|
|
|
48
41
|
let deploymentDoc
|
|
49
42
|
try {
|
|
@@ -71,7 +64,7 @@ async function storeDeploymentHistory(deployment) {
|
|
|
71
64
|
}
|
|
72
65
|
|
|
73
66
|
async function initDeployedApp(prodAppId) {
|
|
74
|
-
const db =
|
|
67
|
+
const db = new CouchDB(prodAppId)
|
|
75
68
|
console.log("Reading automation docs")
|
|
76
69
|
const automations = (
|
|
77
70
|
await db.allDocs(
|
|
@@ -95,12 +88,10 @@ async function initDeployedApp(prodAppId) {
|
|
|
95
88
|
|
|
96
89
|
async function deployApp(deployment) {
|
|
97
90
|
try {
|
|
98
|
-
const
|
|
99
|
-
const devAppId = getDevelopmentAppID(appId)
|
|
100
|
-
const productionAppId = getProdAppID(appId)
|
|
91
|
+
const productionAppId = getDeployedAppID(deployment.appId)
|
|
101
92
|
|
|
102
93
|
const replication = new Replication({
|
|
103
|
-
source:
|
|
94
|
+
source: deployment.appId,
|
|
104
95
|
target: productionAppId,
|
|
105
96
|
})
|
|
106
97
|
|
|
@@ -108,7 +99,7 @@ async function deployApp(deployment) {
|
|
|
108
99
|
|
|
109
100
|
await replication.replicate()
|
|
110
101
|
console.log("replication complete.. replacing app meta doc")
|
|
111
|
-
const db =
|
|
102
|
+
const db = new CouchDB(productionAppId)
|
|
112
103
|
const appDoc = await db.get(DocumentTypes.APP_METADATA)
|
|
113
104
|
appDoc.appId = productionAppId
|
|
114
105
|
appDoc.instance._id = productionAppId
|
|
@@ -131,7 +122,8 @@ async function deployApp(deployment) {
|
|
|
131
122
|
|
|
132
123
|
exports.fetchDeployments = async function (ctx) {
|
|
133
124
|
try {
|
|
134
|
-
const
|
|
125
|
+
const appId = ctx.appId
|
|
126
|
+
const db = new CouchDB(appId)
|
|
135
127
|
const deploymentDoc = await db.get(DocumentTypes.DEPLOYMENTS)
|
|
136
128
|
const { updated, deployments } = await checkAllDeployments(
|
|
137
129
|
deploymentDoc,
|
|
@@ -148,7 +140,8 @@ exports.fetchDeployments = async function (ctx) {
|
|
|
148
140
|
|
|
149
141
|
exports.deploymentProgress = async function (ctx) {
|
|
150
142
|
try {
|
|
151
|
-
const
|
|
143
|
+
const appId = ctx.appId
|
|
144
|
+
const db = new CouchDB(appId)
|
|
152
145
|
const deploymentDoc = await db.get(DocumentTypes.DEPLOYMENTS)
|
|
153
146
|
ctx.body = deploymentDoc[ctx.params.deploymentId]
|
|
154
147
|
} catch (err) {
|
|
@@ -160,7 +153,7 @@ exports.deploymentProgress = async function (ctx) {
|
|
|
160
153
|
}
|
|
161
154
|
|
|
162
155
|
exports.deployApp = async function (ctx) {
|
|
163
|
-
let deployment = new Deployment()
|
|
156
|
+
let deployment = new Deployment(ctx.appId)
|
|
164
157
|
console.log("Deployment object created")
|
|
165
158
|
deployment.setStatus(DeploymentStatus.PENDING)
|
|
166
159
|
console.log("Deployment object set to pending")
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const fetch = require("node-fetch")
|
|
2
|
+
const CouchDB = require("../../db")
|
|
2
3
|
const env = require("../../environment")
|
|
3
4
|
const { checkSlashesInUrl } = require("../../utilities")
|
|
4
5
|
const { request } = require("../../utilities/workerRequests")
|
|
5
6
|
const { clearLock } = require("../../utilities/redis")
|
|
6
|
-
const { Replication
|
|
7
|
+
const { Replication } = require("@budibase/backend-core/db")
|
|
7
8
|
const { DocumentTypes } = require("../../db/utils")
|
|
8
9
|
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
9
|
-
const { getProdAppDB, getAppDB } = require("@budibase/backend-core/context")
|
|
10
10
|
|
|
11
11
|
async function redirect(ctx, method, path = "global") {
|
|
12
12
|
const { devPath } = ctx.params
|
|
@@ -77,11 +77,11 @@ exports.clearLock = async ctx => {
|
|
|
77
77
|
|
|
78
78
|
exports.revert = async ctx => {
|
|
79
79
|
const { appId } = ctx.params
|
|
80
|
-
const productionAppId =
|
|
80
|
+
const productionAppId = appId.replace("_dev", "")
|
|
81
81
|
|
|
82
82
|
// App must have been deployed first
|
|
83
83
|
try {
|
|
84
|
-
const db =
|
|
84
|
+
const db = new CouchDB(productionAppId, { skip_setup: true })
|
|
85
85
|
const info = await db.info()
|
|
86
86
|
if (info.error) throw info.error
|
|
87
87
|
const deploymentDoc = await db.get(DocumentTypes.DEPLOYMENTS)
|
|
@@ -103,7 +103,7 @@ exports.revert = async ctx => {
|
|
|
103
103
|
|
|
104
104
|
await replication.rollback()
|
|
105
105
|
// update appID in reverted app to be dev version again
|
|
106
|
-
const db =
|
|
106
|
+
const db = new CouchDB(appId)
|
|
107
107
|
const appDoc = await db.get(DocumentTypes.APP_METADATA)
|
|
108
108
|
appDoc.appId = appId
|
|
109
109
|
appDoc.instance._id = appId
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const CouchDB = require("../../db")
|
|
2
|
+
const { getDeployedApps } = require("../../utilities/workerRequests")
|
|
3
|
+
const { getScopedConfig } = require("@budibase/backend-core/db")
|
|
4
|
+
const { Configs } = require("@budibase/backend-core/constants")
|
|
5
|
+
const { checkSlashesInUrl } = require("../../utilities")
|
|
6
|
+
|
|
7
|
+
exports.fetchUrls = async ctx => {
|
|
8
|
+
const appId = ctx.appId
|
|
9
|
+
const db = new CouchDB(appId)
|
|
10
|
+
const settings = await getScopedConfig(db, { type: Configs.SETTINGS })
|
|
11
|
+
let appUrl = "http://localhost:10000/app"
|
|
12
|
+
if (settings && settings["platformUrl"]) {
|
|
13
|
+
appUrl = checkSlashesInUrl(`${settings["platformUrl"]}/app`)
|
|
14
|
+
}
|
|
15
|
+
ctx.body = {
|
|
16
|
+
app: appUrl,
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.getDeployedApps = async ctx => {
|
|
21
|
+
ctx.body = await getDeployedApps()
|
|
22
|
+
}
|
|
@@ -2,11 +2,11 @@ const {
|
|
|
2
2
|
EMPTY_LAYOUT,
|
|
3
3
|
BASE_LAYOUT_PROP_IDS,
|
|
4
4
|
} = require("../../constants/layouts")
|
|
5
|
+
const CouchDB = require("../../db")
|
|
5
6
|
const { generateLayoutID, getScreenParams } = require("../../db/utils")
|
|
6
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
7
7
|
|
|
8
8
|
exports.save = async function (ctx) {
|
|
9
|
-
const db =
|
|
9
|
+
const db = new CouchDB(ctx.appId)
|
|
10
10
|
let layout = ctx.request.body
|
|
11
11
|
|
|
12
12
|
if (!layout.props) {
|
|
@@ -26,7 +26,7 @@ exports.save = async function (ctx) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
exports.destroy = async function (ctx) {
|
|
29
|
-
const db =
|
|
29
|
+
const db = new CouchDB(ctx.appId)
|
|
30
30
|
const layoutId = ctx.params.layoutId,
|
|
31
31
|
layoutRev = ctx.params.layoutRev
|
|
32
32
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { MetadataTypes } = require("../../constants")
|
|
2
|
+
const CouchDB = require("../../db")
|
|
2
3
|
const { generateMetadataID } = require("../../db/utils")
|
|
3
4
|
const { saveEntityMetadata, deleteEntityMetadata } = require("../../utilities")
|
|
4
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
5
5
|
|
|
6
6
|
exports.getTypes = async ctx => {
|
|
7
7
|
ctx.body = {
|
|
@@ -14,12 +14,17 @@ exports.saveMetadata = async ctx => {
|
|
|
14
14
|
if (type === MetadataTypes.AUTOMATION_TEST_HISTORY) {
|
|
15
15
|
ctx.throw(400, "Cannot save automation history type")
|
|
16
16
|
}
|
|
17
|
-
ctx.body = await saveEntityMetadata(
|
|
17
|
+
ctx.body = await saveEntityMetadata(
|
|
18
|
+
ctx.appId,
|
|
19
|
+
type,
|
|
20
|
+
entityId,
|
|
21
|
+
ctx.request.body
|
|
22
|
+
)
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
exports.deleteMetadata = async ctx => {
|
|
21
26
|
const { type, entityId } = ctx.params
|
|
22
|
-
await deleteEntityMetadata(type, entityId)
|
|
27
|
+
await deleteEntityMetadata(ctx.appId, type, entityId)
|
|
23
28
|
ctx.body = {
|
|
24
29
|
message: "Metadata deleted successfully",
|
|
25
30
|
}
|
|
@@ -27,7 +32,7 @@ exports.deleteMetadata = async ctx => {
|
|
|
27
32
|
|
|
28
33
|
exports.getMetadata = async ctx => {
|
|
29
34
|
const { type, entityId } = ctx.params
|
|
30
|
-
const db =
|
|
35
|
+
const db = new CouchDB(ctx.appId)
|
|
31
36
|
const id = generateMetadataID(type, entityId)
|
|
32
37
|
try {
|
|
33
38
|
ctx.body = await db.get(id)
|
|
@@ -6,12 +6,12 @@ const {
|
|
|
6
6
|
getBuiltinRoles,
|
|
7
7
|
} = require("@budibase/backend-core/roles")
|
|
8
8
|
const { getRoleParams } = require("../../db/utils")
|
|
9
|
+
const CouchDB = require("../../db")
|
|
9
10
|
const {
|
|
10
11
|
CURRENTLY_SUPPORTED_LEVELS,
|
|
11
12
|
getBasePermissions,
|
|
12
13
|
} = require("../../utilities/security")
|
|
13
14
|
const { removeFromArray } = require("../../utilities")
|
|
14
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
15
15
|
|
|
16
16
|
const PermissionUpdateType = {
|
|
17
17
|
REMOVE: "remove",
|
|
@@ -35,7 +35,7 @@ async function updatePermissionOnRole(
|
|
|
35
35
|
{ roleId, resourceId, level },
|
|
36
36
|
updateType
|
|
37
37
|
) {
|
|
38
|
-
const db =
|
|
38
|
+
const db = new CouchDB(appId)
|
|
39
39
|
const remove = updateType === PermissionUpdateType.REMOVE
|
|
40
40
|
const isABuiltin = isBuiltin(roleId)
|
|
41
41
|
const dbRoleId = getDBRoleID(roleId)
|
|
@@ -106,7 +106,7 @@ exports.fetchLevels = function (ctx) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
exports.fetch = async function (ctx) {
|
|
109
|
-
const db =
|
|
109
|
+
const db = new CouchDB(ctx.appId)
|
|
110
110
|
const roles = await getAllDBRoles(db)
|
|
111
111
|
let permissions = {}
|
|
112
112
|
// create an object with structure role ID -> resource ID -> level
|
|
@@ -133,7 +133,7 @@ exports.fetch = async function (ctx) {
|
|
|
133
133
|
|
|
134
134
|
exports.getResourcePerms = async function (ctx) {
|
|
135
135
|
const resourceId = ctx.params.resourceId
|
|
136
|
-
const db =
|
|
136
|
+
const db = new CouchDB(ctx.appId)
|
|
137
137
|
const body = await db.allDocs(
|
|
138
138
|
getRoleParams(null, {
|
|
139
139
|
include_docs: true,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import CouchDB from "../../../../db"
|
|
1
2
|
import { queryValidation } from "../validation"
|
|
2
3
|
import { generateQueryID } from "../../../../db/utils"
|
|
3
4
|
import { ImportInfo, ImportSource } from "./sources/base"
|
|
4
5
|
import { OpenAPI2 } from "./sources/openapi2"
|
|
5
6
|
import { Query } from "./../../../../definitions/common"
|
|
6
7
|
import { Curl } from "./sources/curl"
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
import { getAppDB } from "@budibase/backend-core/context"
|
|
9
8
|
interface ImportResult {
|
|
10
9
|
errorQueries: Query[]
|
|
11
10
|
queries: Query[]
|
|
@@ -34,7 +33,10 @@ export class RestImporter {
|
|
|
34
33
|
return this.source.getInfo()
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
importQueries = async (
|
|
36
|
+
importQueries = async (
|
|
37
|
+
appId: string,
|
|
38
|
+
datasourceId: string
|
|
39
|
+
): Promise<ImportResult> => {
|
|
38
40
|
// constuct the queries
|
|
39
41
|
let queries = await this.source.getQueries(datasourceId)
|
|
40
42
|
|
|
@@ -56,7 +58,7 @@ export class RestImporter {
|
|
|
56
58
|
})
|
|
57
59
|
|
|
58
60
|
// persist queries
|
|
59
|
-
const db =
|
|
61
|
+
const db = new CouchDB(appId)
|
|
60
62
|
const response = await db.bulkDocs(queries)
|
|
61
63
|
|
|
62
64
|
// create index to seperate queries and errors
|
|
@@ -6,7 +6,6 @@ const db = jest.fn(() => {
|
|
|
6
6
|
}
|
|
7
7
|
})
|
|
8
8
|
jest.mock("../../../../../db", () => db)
|
|
9
|
-
require("@budibase/backend-core").init(require("../../../../../db"))
|
|
10
9
|
|
|
11
10
|
const { RestImporter } = require("../index")
|
|
12
11
|
|
|
@@ -78,7 +77,7 @@ describe("Rest Importer", () => {
|
|
|
78
77
|
const testImportQueries = async (key, data, assertions) => {
|
|
79
78
|
await init(data)
|
|
80
79
|
bulkDocs.mockReturnValue([])
|
|
81
|
-
const importResult = await restImporter.importQueries("datasourceId")
|
|
80
|
+
const importResult = await restImporter.importQueries("appId", "datasourceId")
|
|
82
81
|
expect(importResult.errorQueries.length).toBe(0)
|
|
83
82
|
expect(importResult.queries.length).toBe(assertions[key].count)
|
|
84
83
|
expect(bulkDocs).toHaveBeenCalledTimes(1)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const CouchDB = require("../../../db")
|
|
1
2
|
const {
|
|
2
3
|
generateQueryID,
|
|
3
4
|
getQueryParams,
|
|
@@ -9,7 +10,6 @@ const { save: saveDatasource } = require("../datasource")
|
|
|
9
10
|
const { RestImporter } = require("./import")
|
|
10
11
|
const { invalidateDynamicVariables } = require("../../../threads/utils")
|
|
11
12
|
const environment = require("../../../environment")
|
|
12
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
13
13
|
|
|
14
14
|
const Runner = new Thread(ThreadType.QUERY, {
|
|
15
15
|
timeoutMs: environment.QUERY_THREAD_TIMEOUT || 10000,
|
|
@@ -28,7 +28,7 @@ function enrichQueries(input) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
exports.fetch = async function (ctx) {
|
|
31
|
-
const db =
|
|
31
|
+
const db = new CouchDB(ctx.appId)
|
|
32
32
|
|
|
33
33
|
const body = await db.allDocs(
|
|
34
34
|
getQueryParams(null, {
|
|
@@ -69,7 +69,7 @@ exports.import = async ctx => {
|
|
|
69
69
|
datasourceId = body.datasourceId
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const importResult = await importer.importQueries(datasourceId)
|
|
72
|
+
const importResult = await importer.importQueries(ctx.appId, datasourceId)
|
|
73
73
|
|
|
74
74
|
ctx.body = {
|
|
75
75
|
...importResult,
|
|
@@ -79,7 +79,7 @@ exports.import = async ctx => {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
exports.save = async function (ctx) {
|
|
82
|
-
const db =
|
|
82
|
+
const db = new CouchDB(ctx.appId)
|
|
83
83
|
const query = ctx.request.body
|
|
84
84
|
|
|
85
85
|
if (!query._id) {
|
|
@@ -94,7 +94,7 @@ exports.save = async function (ctx) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
exports.find = async function (ctx) {
|
|
97
|
-
const db =
|
|
97
|
+
const db = new CouchDB(ctx.appId)
|
|
98
98
|
const query = enrichQueries(await db.get(ctx.params.queryId))
|
|
99
99
|
// remove properties that could be dangerous in real app
|
|
100
100
|
if (isProdAppID(ctx.appId)) {
|
|
@@ -105,7 +105,7 @@ exports.find = async function (ctx) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
exports.preview = async function (ctx) {
|
|
108
|
-
const db =
|
|
108
|
+
const db = new CouchDB(ctx.appId)
|
|
109
109
|
|
|
110
110
|
const datasource = await db.get(ctx.request.body.datasourceId)
|
|
111
111
|
// preview may not have a queryId as it hasn't been saved, but if it does
|
|
@@ -136,7 +136,7 @@ exports.preview = async function (ctx) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
async function execute(ctx, opts = { rowsOnly: false }) {
|
|
139
|
-
const db =
|
|
139
|
+
const db = new CouchDB(ctx.appId)
|
|
140
140
|
|
|
141
141
|
const query = await db.get(ctx.params.queryId)
|
|
142
142
|
const datasource = await db.get(query.datasourceId)
|
|
@@ -181,8 +181,7 @@ exports.executeV2 = async function (ctx) {
|
|
|
181
181
|
return execute(ctx, { rowsOnly: false })
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
const removeDynamicVariables = async queryId => {
|
|
185
|
-
const db = getAppDB()
|
|
184
|
+
const removeDynamicVariables = async (db, queryId) => {
|
|
186
185
|
const query = await db.get(queryId)
|
|
187
186
|
const datasource = await db.get(query.datasourceId)
|
|
188
187
|
const dynamicVariables = datasource.config.dynamicVariables
|
|
@@ -203,8 +202,8 @@ const removeDynamicVariables = async queryId => {
|
|
|
203
202
|
}
|
|
204
203
|
|
|
205
204
|
exports.destroy = async function (ctx) {
|
|
206
|
-
const db =
|
|
207
|
-
await removeDynamicVariables(ctx.params.queryId)
|
|
205
|
+
const db = new CouchDB(ctx.appId)
|
|
206
|
+
await removeDynamicVariables(db, ctx.params.queryId)
|
|
208
207
|
await db.remove(ctx.params.queryId, ctx.params.revId)
|
|
209
208
|
ctx.message = `Query deleted.`
|
|
210
209
|
ctx.status = 200
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const CouchDB = require("../../db")
|
|
1
2
|
const {
|
|
2
3
|
Role,
|
|
3
4
|
getRole,
|
|
@@ -9,7 +10,6 @@ const {
|
|
|
9
10
|
getUserMetadataParams,
|
|
10
11
|
InternalTables,
|
|
11
12
|
} = require("../../db/utils")
|
|
12
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
13
13
|
|
|
14
14
|
const UpdateRolesOptions = {
|
|
15
15
|
CREATED: "created",
|
|
@@ -40,15 +40,15 @@ async function updateRolesOnUserTable(db, roleId, updateOption) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
exports.fetch = async function (ctx) {
|
|
43
|
-
ctx.body = await getAllRoles()
|
|
43
|
+
ctx.body = await getAllRoles(ctx.appId)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
exports.find = async function (ctx) {
|
|
47
|
-
ctx.body = await getRole(ctx.params.roleId)
|
|
47
|
+
ctx.body = await getRole(ctx.appId, ctx.params.roleId)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
exports.save = async function (ctx) {
|
|
51
|
-
const db =
|
|
51
|
+
const db = new CouchDB(ctx.appId)
|
|
52
52
|
let { _id, name, inherits, permissionId } = ctx.request.body
|
|
53
53
|
if (!_id) {
|
|
54
54
|
_id = generateRoleID()
|
|
@@ -69,7 +69,7 @@ exports.save = async function (ctx) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
exports.destroy = async function (ctx) {
|
|
72
|
-
const db =
|
|
72
|
+
const db = new CouchDB(ctx.appId)
|
|
73
73
|
const roleId = ctx.params.roleId
|
|
74
74
|
if (isBuiltin(roleId)) {
|
|
75
75
|
ctx.throw(400, "Cannot delete builtin role.")
|
|
@@ -39,11 +39,12 @@ Routing.prototype.addScreenId = function (fullpath, roleId, screenId) {
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Gets the full routing structure by querying the routing view and processing the result into the tree.
|
|
42
|
+
* @param {string} appId The application to produce the routing structure for.
|
|
42
43
|
* @returns {Promise<object>} The routing structure, this is the full structure designed for use in the builder,
|
|
43
44
|
* if the client routing is required then the updateRoutingStructureForUserRole should be used.
|
|
44
45
|
*/
|
|
45
|
-
async function getRoutingStructure() {
|
|
46
|
-
const screenRoutes = await getRoutingInfo()
|
|
46
|
+
async function getRoutingStructure(appId) {
|
|
47
|
+
const screenRoutes = await getRoutingInfo(appId)
|
|
47
48
|
const routing = new Routing()
|
|
48
49
|
|
|
49
50
|
for (let screenRoute of screenRoutes) {
|
|
@@ -56,13 +57,13 @@ async function getRoutingStructure() {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
exports.fetch = async ctx => {
|
|
59
|
-
ctx.body = await getRoutingStructure()
|
|
60
|
+
ctx.body = await getRoutingStructure(ctx.appId)
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
exports.clientFetch = async ctx => {
|
|
63
|
-
const routing = await getRoutingStructure()
|
|
64
|
+
const routing = await getRoutingStructure(ctx.appId)
|
|
64
65
|
let roleId = ctx.user.role._id
|
|
65
|
-
const roleIds = await getUserRoleHierarchy(roleId)
|
|
66
|
+
const roleIds = await getUserRoleHierarchy(ctx.appId, roleId)
|
|
66
67
|
for (let topLevel of Object.values(routing.routes)) {
|
|
67
68
|
for (let subpathKey of Object.keys(topLevel.subpaths)) {
|
|
68
69
|
let found = false
|