@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,3 +1,4 @@
|
|
|
1
|
+
const CouchDB = require("../../db")
|
|
1
2
|
const env = require("../../environment")
|
|
2
3
|
const packageJson = require("../../../package.json")
|
|
3
4
|
const {
|
|
@@ -28,11 +29,14 @@ const { processObject } = require("@budibase/string-templates")
|
|
|
28
29
|
const {
|
|
29
30
|
getAllApps,
|
|
30
31
|
isDevAppID,
|
|
31
|
-
|
|
32
|
+
getDeployedAppID,
|
|
32
33
|
Replication,
|
|
33
34
|
} = require("@budibase/backend-core/db")
|
|
34
35
|
const { USERS_TABLE_SCHEMA } = require("../../constants")
|
|
35
|
-
const {
|
|
36
|
+
const {
|
|
37
|
+
getDeployedApps,
|
|
38
|
+
removeAppFromUserRoles,
|
|
39
|
+
} = require("../../utilities/workerRequests")
|
|
36
40
|
const { clientLibraryPath, stringToReadStream } = require("../../utilities")
|
|
37
41
|
const { getAllLocks } = require("../../utilities/redis")
|
|
38
42
|
const {
|
|
@@ -44,17 +48,11 @@ const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy")
|
|
|
44
48
|
const { syncGlobalUsers } = require("./user")
|
|
45
49
|
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
46
50
|
const { cleanupAutomations } = require("../../automations/utils")
|
|
47
|
-
const {
|
|
48
|
-
getAppDB,
|
|
49
|
-
getProdAppDB,
|
|
50
|
-
updateAppId,
|
|
51
|
-
} = require("@budibase/backend-core/context")
|
|
52
51
|
|
|
53
52
|
const URL_REGEX_SLASH = /\/|\\/g
|
|
54
53
|
|
|
55
54
|
// utility function, need to do away with this
|
|
56
|
-
async function getLayouts() {
|
|
57
|
-
const db = getAppDB()
|
|
55
|
+
async function getLayouts(db) {
|
|
58
56
|
return (
|
|
59
57
|
await db.allDocs(
|
|
60
58
|
getLayoutParams(null, {
|
|
@@ -64,8 +62,7 @@ async function getLayouts() {
|
|
|
64
62
|
).rows.map(row => row.doc)
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
async function getScreens() {
|
|
68
|
-
const db = getAppDB()
|
|
65
|
+
async function getScreens(db) {
|
|
69
66
|
return (
|
|
70
67
|
await db.allDocs(
|
|
71
68
|
getScreenParams(null, {
|
|
@@ -81,51 +78,37 @@ function getUserRoleId(ctx) {
|
|
|
81
78
|
: ctx.user.role._id
|
|
82
79
|
}
|
|
83
80
|
|
|
84
|
-
|
|
85
|
-
// construct the url
|
|
81
|
+
async function getAppUrlIfNotInUse(ctx) {
|
|
86
82
|
let url
|
|
87
83
|
if (ctx.request.body.url) {
|
|
88
|
-
// if the url is provided, use that
|
|
89
84
|
url = encodeURI(ctx.request.body.url)
|
|
90
85
|
} else if (ctx.request.body.name) {
|
|
91
|
-
// otherwise use the name
|
|
92
86
|
url = encodeURI(`${ctx.request.body.name}`)
|
|
93
87
|
}
|
|
94
88
|
if (url) {
|
|
95
89
|
url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase()
|
|
96
90
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const checkAppUrl = (ctx, apps, url, currentAppId) => {
|
|
101
|
-
if (currentAppId) {
|
|
102
|
-
apps = apps.filter(app => app.appId !== currentAppId)
|
|
103
|
-
}
|
|
104
|
-
if (apps.some(app => app.url === url)) {
|
|
105
|
-
ctx.throw(400, "App URL is already in use.")
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const checkAppName = (ctx, apps, name, currentAppId) => {
|
|
110
|
-
// TODO: Replace with Joi
|
|
111
|
-
if (!name) {
|
|
112
|
-
ctx.throw(400, "Name is required")
|
|
113
|
-
}
|
|
114
|
-
if (currentAppId) {
|
|
115
|
-
apps = apps.filter(app => app.appId !== currentAppId)
|
|
91
|
+
if (!env.SELF_HOSTED) {
|
|
92
|
+
return url
|
|
116
93
|
}
|
|
117
|
-
|
|
118
|
-
|
|
94
|
+
const deployedApps = await getDeployedApps()
|
|
95
|
+
if (
|
|
96
|
+
url &&
|
|
97
|
+
deployedApps[url] != null &&
|
|
98
|
+
ctx.params != null &&
|
|
99
|
+
deployedApps[url].appId !== ctx.params.appId
|
|
100
|
+
) {
|
|
101
|
+
ctx.throw(400, "App name/URL is already in use.")
|
|
119
102
|
}
|
|
103
|
+
return url
|
|
120
104
|
}
|
|
121
105
|
|
|
122
106
|
async function createInstance(template) {
|
|
123
107
|
const tenantId = isMultiTenant() ? getTenantId() : null
|
|
124
108
|
const baseAppId = generateAppID(tenantId)
|
|
125
109
|
const appId = generateDevAppID(baseAppId)
|
|
126
|
-
updateAppId(appId)
|
|
127
110
|
|
|
128
|
-
const db =
|
|
111
|
+
const db = new CouchDB(appId)
|
|
129
112
|
await db.put({
|
|
130
113
|
_id: "_design/database",
|
|
131
114
|
// view collation information, read before writing any complex views:
|
|
@@ -135,9 +118,9 @@ async function createInstance(template) {
|
|
|
135
118
|
|
|
136
119
|
// NOTE: indexes need to be created before any tables/templates
|
|
137
120
|
// add view for linked rows
|
|
138
|
-
await createLinkView()
|
|
139
|
-
await createRoutingView()
|
|
140
|
-
await createAllSearchIndex()
|
|
121
|
+
await createLinkView(appId)
|
|
122
|
+
await createRoutingView(appId)
|
|
123
|
+
await createAllSearchIndex(appId)
|
|
141
124
|
|
|
142
125
|
// replicate the template data to the instance DB
|
|
143
126
|
// this is currently very hard to test, downloading and importing template files
|
|
@@ -163,7 +146,7 @@ async function createInstance(template) {
|
|
|
163
146
|
exports.fetch = async ctx => {
|
|
164
147
|
const dev = ctx.query && ctx.query.status === AppStatus.DEV
|
|
165
148
|
const all = ctx.query && ctx.query.status === AppStatus.ALL
|
|
166
|
-
const apps = await getAllApps({ dev, all })
|
|
149
|
+
const apps = await getAllApps(CouchDB, { dev, all })
|
|
167
150
|
|
|
168
151
|
// get the locks for all the dev apps
|
|
169
152
|
if (dev || all) {
|
|
@@ -186,11 +169,12 @@ exports.fetch = async ctx => {
|
|
|
186
169
|
}
|
|
187
170
|
|
|
188
171
|
exports.fetchAppDefinition = async ctx => {
|
|
189
|
-
const
|
|
172
|
+
const db = new CouchDB(ctx.params.appId)
|
|
173
|
+
const layouts = await getLayouts(db)
|
|
190
174
|
const userRoleId = getUserRoleId(ctx)
|
|
191
|
-
const accessController = new AccessController()
|
|
175
|
+
const accessController = new AccessController(ctx.params.appId)
|
|
192
176
|
const screens = await accessController.checkScreensAccess(
|
|
193
|
-
await getScreens(),
|
|
177
|
+
await getScreens(db),
|
|
194
178
|
userRoleId
|
|
195
179
|
)
|
|
196
180
|
ctx.body = {
|
|
@@ -201,15 +185,15 @@ exports.fetchAppDefinition = async ctx => {
|
|
|
201
185
|
}
|
|
202
186
|
|
|
203
187
|
exports.fetchAppPackage = async ctx => {
|
|
204
|
-
const db =
|
|
188
|
+
const db = new CouchDB(ctx.params.appId)
|
|
205
189
|
const application = await db.get(DocumentTypes.APP_METADATA)
|
|
206
|
-
const layouts = await getLayouts()
|
|
207
|
-
let screens = await getScreens()
|
|
190
|
+
const layouts = await getLayouts(db)
|
|
191
|
+
let screens = await getScreens(db)
|
|
208
192
|
|
|
209
193
|
// Only filter screens if the user is not a builder
|
|
210
194
|
if (!(ctx.user.builder && ctx.user.builder.global)) {
|
|
211
195
|
const userRoleId = getUserRoleId(ctx)
|
|
212
|
-
const accessController = new AccessController()
|
|
196
|
+
const accessController = new AccessController(ctx.params.appId)
|
|
213
197
|
screens = await accessController.checkScreensAccess(screens, userRoleId)
|
|
214
198
|
}
|
|
215
199
|
|
|
@@ -222,12 +206,6 @@ exports.fetchAppPackage = async ctx => {
|
|
|
222
206
|
}
|
|
223
207
|
|
|
224
208
|
exports.create = async ctx => {
|
|
225
|
-
const apps = await getAllApps({ dev: true })
|
|
226
|
-
const name = ctx.request.body.name
|
|
227
|
-
checkAppName(ctx, apps, name)
|
|
228
|
-
const url = exports.getAppUrl(ctx)
|
|
229
|
-
checkAppUrl(ctx, apps, url)
|
|
230
|
-
|
|
231
209
|
const { useTemplate, templateKey, templateString } = ctx.request.body
|
|
232
210
|
const instanceConfig = {
|
|
233
211
|
useTemplate,
|
|
@@ -240,7 +218,8 @@ exports.create = async ctx => {
|
|
|
240
218
|
const instance = await createInstance(instanceConfig)
|
|
241
219
|
const appId = instance._id
|
|
242
220
|
|
|
243
|
-
const
|
|
221
|
+
const url = await getAppUrlIfNotInUse(ctx)
|
|
222
|
+
const db = new CouchDB(appId)
|
|
244
223
|
let _rev
|
|
245
224
|
try {
|
|
246
225
|
// if template there will be an existing doc
|
|
@@ -256,7 +235,7 @@ exports.create = async ctx => {
|
|
|
256
235
|
type: "app",
|
|
257
236
|
version: packageJson.version,
|
|
258
237
|
componentLibraries: ["@budibase/standard-components"],
|
|
259
|
-
name: name,
|
|
238
|
+
name: ctx.request.body.name,
|
|
260
239
|
url: url,
|
|
261
240
|
template: ctx.request.body.template,
|
|
262
241
|
instance: instance,
|
|
@@ -283,29 +262,15 @@ exports.create = async ctx => {
|
|
|
283
262
|
ctx.body = newApplication
|
|
284
263
|
}
|
|
285
264
|
|
|
286
|
-
// This endpoint currently operates as a PATCH rather than a PUT
|
|
287
|
-
// Thus name and url fields are handled only if present
|
|
288
265
|
exports.update = async ctx => {
|
|
289
|
-
const
|
|
290
|
-
// validation
|
|
291
|
-
const name = ctx.request.body.name
|
|
292
|
-
if (name) {
|
|
293
|
-
checkAppName(ctx, apps, name, ctx.params.appId)
|
|
294
|
-
}
|
|
295
|
-
const url = await exports.getAppUrl(ctx)
|
|
296
|
-
if (url) {
|
|
297
|
-
checkAppUrl(ctx, apps, url, ctx.params.appId)
|
|
298
|
-
ctx.request.body.url = url
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
const data = await updateAppPackage(ctx.request.body, ctx.params.appId)
|
|
266
|
+
const data = await updateAppPackage(ctx, ctx.request.body, ctx.params.appId)
|
|
302
267
|
ctx.status = 200
|
|
303
268
|
ctx.body = data
|
|
304
269
|
}
|
|
305
270
|
|
|
306
271
|
exports.updateClient = async ctx => {
|
|
307
272
|
// Get current app version
|
|
308
|
-
const db =
|
|
273
|
+
const db = new CouchDB(ctx.params.appId)
|
|
309
274
|
const application = await db.get(DocumentTypes.APP_METADATA)
|
|
310
275
|
const currentVersion = application.version
|
|
311
276
|
|
|
@@ -320,14 +285,14 @@ exports.updateClient = async ctx => {
|
|
|
320
285
|
version: packageJson.version,
|
|
321
286
|
revertableVersion: currentVersion,
|
|
322
287
|
}
|
|
323
|
-
const data = await updateAppPackage(appPackageUpdates, ctx.params.appId)
|
|
288
|
+
const data = await updateAppPackage(ctx, appPackageUpdates, ctx.params.appId)
|
|
324
289
|
ctx.status = 200
|
|
325
290
|
ctx.body = data
|
|
326
291
|
}
|
|
327
292
|
|
|
328
293
|
exports.revertClient = async ctx => {
|
|
329
294
|
// Check app can be reverted
|
|
330
|
-
const db =
|
|
295
|
+
const db = new CouchDB(ctx.params.appId)
|
|
331
296
|
const application = await db.get(DocumentTypes.APP_METADATA)
|
|
332
297
|
if (!application.revertableVersion) {
|
|
333
298
|
ctx.throw(400, "There is no version to revert to")
|
|
@@ -343,13 +308,13 @@ exports.revertClient = async ctx => {
|
|
|
343
308
|
version: application.revertableVersion,
|
|
344
309
|
revertableVersion: null,
|
|
345
310
|
}
|
|
346
|
-
const data = await updateAppPackage(appPackageUpdates, ctx.params.appId)
|
|
311
|
+
const data = await updateAppPackage(ctx, appPackageUpdates, ctx.params.appId)
|
|
347
312
|
ctx.status = 200
|
|
348
313
|
ctx.body = data
|
|
349
314
|
}
|
|
350
315
|
|
|
351
316
|
exports.delete = async ctx => {
|
|
352
|
-
const db =
|
|
317
|
+
const db = new CouchDB(ctx.params.appId)
|
|
353
318
|
|
|
354
319
|
const result = await db.destroy()
|
|
355
320
|
/* istanbul ignore next */
|
|
@@ -374,11 +339,10 @@ exports.sync = async (ctx, next) => {
|
|
|
374
339
|
}
|
|
375
340
|
|
|
376
341
|
// replicate prod to dev
|
|
377
|
-
const prodAppId =
|
|
342
|
+
const prodAppId = getDeployedAppID(appId)
|
|
378
343
|
|
|
379
344
|
try {
|
|
380
|
-
|
|
381
|
-
const prodDb = getProdAppDB({ skip_setup: true })
|
|
345
|
+
const prodDb = new CouchDB(prodAppId, { skip_setup: true })
|
|
382
346
|
const info = await prodDb.info()
|
|
383
347
|
if (info.error) throw info.error
|
|
384
348
|
} catch (err) {
|
|
@@ -406,7 +370,7 @@ exports.sync = async (ctx, next) => {
|
|
|
406
370
|
}
|
|
407
371
|
|
|
408
372
|
// sync the users
|
|
409
|
-
await syncGlobalUsers()
|
|
373
|
+
await syncGlobalUsers(appId)
|
|
410
374
|
|
|
411
375
|
if (error) {
|
|
412
376
|
ctx.throw(400, error)
|
|
@@ -417,11 +381,12 @@ exports.sync = async (ctx, next) => {
|
|
|
417
381
|
}
|
|
418
382
|
}
|
|
419
383
|
|
|
420
|
-
const updateAppPackage = async (appPackage, appId) => {
|
|
421
|
-
const
|
|
384
|
+
const updateAppPackage = async (ctx, appPackage, appId) => {
|
|
385
|
+
const url = await getAppUrlIfNotInUse(ctx)
|
|
386
|
+
const db = new CouchDB(appId)
|
|
422
387
|
const application = await db.get(DocumentTypes.APP_METADATA)
|
|
423
388
|
|
|
424
|
-
const newAppPackage = { ...application, ...appPackage }
|
|
389
|
+
const newAppPackage = { ...application, ...appPackage, url }
|
|
425
390
|
if (appPackage._rev !== application._rev) {
|
|
426
391
|
newAppPackage._rev = application._rev
|
|
427
392
|
}
|
|
@@ -437,7 +402,7 @@ const updateAppPackage = async (appPackage, appId) => {
|
|
|
437
402
|
}
|
|
438
403
|
|
|
439
404
|
const createEmptyAppPackage = async (ctx, app) => {
|
|
440
|
-
const db =
|
|
405
|
+
const db = new CouchDB(app.appId)
|
|
441
406
|
|
|
442
407
|
let screensAndLayouts = []
|
|
443
408
|
for (let layout of BASE_LAYOUTS) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
const CouchDB = require("../../db")
|
|
1
2
|
const { outputProcessing } = require("../../utilities/rowProcessor")
|
|
2
3
|
const { InternalTables } = require("../../db/utils")
|
|
3
4
|
const { getFullUser } = require("../../utilities/users")
|
|
4
5
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
5
|
-
const { getAppDB, getAppId } = require("@budibase/backend-core/context")
|
|
6
6
|
|
|
7
7
|
exports.fetchSelf = async ctx => {
|
|
8
|
+
const appId = ctx.appId
|
|
8
9
|
let userId = ctx.user.userId || ctx.user._id
|
|
9
10
|
/* istanbul ignore next */
|
|
10
11
|
if (!userId) {
|
|
@@ -15,20 +16,16 @@ exports.fetchSelf = async ctx => {
|
|
|
15
16
|
const user = await getFullUser(ctx, userId)
|
|
16
17
|
// this shouldn't be returned by the app self
|
|
17
18
|
delete user.roles
|
|
18
|
-
// forward the csrf token from the session
|
|
19
|
-
user.csrfToken = ctx.user.csrfToken
|
|
20
19
|
|
|
21
|
-
if (
|
|
22
|
-
const db =
|
|
20
|
+
if (appId) {
|
|
21
|
+
const db = new CouchDB(appId)
|
|
23
22
|
// remove the full roles structure
|
|
24
23
|
delete user.roles
|
|
25
24
|
try {
|
|
26
25
|
const userTable = await db.get(InternalTables.USER_METADATA)
|
|
27
26
|
const metadata = await db.get(userId)
|
|
28
|
-
// make sure there is never a stale csrf token
|
|
29
|
-
delete metadata.csrfToken
|
|
30
27
|
// specifically needs to make sure is enriched
|
|
31
|
-
ctx.body = await outputProcessing(userTable, {
|
|
28
|
+
ctx.body = await outputProcessing(ctx, userTable, {
|
|
32
29
|
...user,
|
|
33
30
|
...metadata,
|
|
34
31
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const CouchDB = require("../../db")
|
|
1
2
|
const actions = require("../../automations/actions")
|
|
2
3
|
const triggers = require("../../automations/triggers")
|
|
3
4
|
const { getAutomationParams, generateAutomationID } = require("../../db/utils")
|
|
@@ -9,7 +10,6 @@ const {
|
|
|
9
10
|
const { deleteEntityMetadata } = require("../../utilities")
|
|
10
11
|
const { MetadataTypes } = require("../../constants")
|
|
11
12
|
const { setTestFlag, clearTestFlag } = require("../../utilities/redis")
|
|
12
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
13
13
|
|
|
14
14
|
const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS)
|
|
15
15
|
const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS)
|
|
@@ -20,9 +20,14 @@ const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS)
|
|
|
20
20
|
* *
|
|
21
21
|
*************************/
|
|
22
22
|
|
|
23
|
-
async function cleanupAutomationMetadata(automationId) {
|
|
24
|
-
await deleteEntityMetadata(MetadataTypes.AUTOMATION_TEST_INPUT, automationId)
|
|
23
|
+
async function cleanupAutomationMetadata(appId, automationId) {
|
|
25
24
|
await deleteEntityMetadata(
|
|
25
|
+
appId,
|
|
26
|
+
MetadataTypes.AUTOMATION_TEST_INPUT,
|
|
27
|
+
automationId
|
|
28
|
+
)
|
|
29
|
+
await deleteEntityMetadata(
|
|
30
|
+
appId,
|
|
26
31
|
MetadataTypes.AUTOMATION_TEST_HISTORY,
|
|
27
32
|
automationId
|
|
28
33
|
)
|
|
@@ -53,7 +58,7 @@ function cleanAutomationInputs(automation) {
|
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
exports.create = async function (ctx) {
|
|
56
|
-
const db =
|
|
61
|
+
const db = new CouchDB(ctx.appId)
|
|
57
62
|
let automation = ctx.request.body
|
|
58
63
|
automation.appId = ctx.appId
|
|
59
64
|
|
|
@@ -67,6 +72,7 @@ exports.create = async function (ctx) {
|
|
|
67
72
|
automation.type = "automation"
|
|
68
73
|
automation = cleanAutomationInputs(automation)
|
|
69
74
|
automation = await checkForWebhooks({
|
|
75
|
+
appId: ctx.appId,
|
|
70
76
|
newAuto: automation,
|
|
71
77
|
})
|
|
72
78
|
const response = await db.put(automation)
|
|
@@ -83,12 +89,13 @@ exports.create = async function (ctx) {
|
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
exports.update = async function (ctx) {
|
|
86
|
-
const db =
|
|
92
|
+
const db = new CouchDB(ctx.appId)
|
|
87
93
|
let automation = ctx.request.body
|
|
88
94
|
automation.appId = ctx.appId
|
|
89
95
|
const oldAutomation = await db.get(automation._id)
|
|
90
96
|
automation = cleanAutomationInputs(automation)
|
|
91
97
|
automation = await checkForWebhooks({
|
|
98
|
+
appId: ctx.appId,
|
|
92
99
|
oldAuto: oldAutomation,
|
|
93
100
|
newAuto: automation,
|
|
94
101
|
})
|
|
@@ -124,7 +131,7 @@ exports.update = async function (ctx) {
|
|
|
124
131
|
}
|
|
125
132
|
|
|
126
133
|
exports.fetch = async function (ctx) {
|
|
127
|
-
const db =
|
|
134
|
+
const db = new CouchDB(ctx.appId)
|
|
128
135
|
const response = await db.allDocs(
|
|
129
136
|
getAutomationParams(null, {
|
|
130
137
|
include_docs: true,
|
|
@@ -134,19 +141,20 @@ exports.fetch = async function (ctx) {
|
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
exports.find = async function (ctx) {
|
|
137
|
-
const db =
|
|
144
|
+
const db = new CouchDB(ctx.appId)
|
|
138
145
|
ctx.body = await db.get(ctx.params.id)
|
|
139
146
|
}
|
|
140
147
|
|
|
141
148
|
exports.destroy = async function (ctx) {
|
|
142
|
-
const db =
|
|
149
|
+
const db = new CouchDB(ctx.appId)
|
|
143
150
|
const automationId = ctx.params.id
|
|
144
151
|
const oldAutomation = await db.get(automationId)
|
|
145
152
|
await checkForWebhooks({
|
|
153
|
+
appId: ctx.appId,
|
|
146
154
|
oldAuto: oldAutomation,
|
|
147
155
|
})
|
|
148
156
|
// delete metadata first
|
|
149
|
-
await cleanupAutomationMetadata(automationId)
|
|
157
|
+
await cleanupAutomationMetadata(ctx.appId, automationId)
|
|
150
158
|
ctx.body = await db.remove(automationId, ctx.params.rev)
|
|
151
159
|
}
|
|
152
160
|
|
|
@@ -172,11 +180,12 @@ module.exports.getDefinitionList = async function (ctx) {
|
|
|
172
180
|
*********************/
|
|
173
181
|
|
|
174
182
|
exports.trigger = async function (ctx) {
|
|
175
|
-
const
|
|
183
|
+
const appId = ctx.appId
|
|
184
|
+
const db = new CouchDB(appId)
|
|
176
185
|
let automation = await db.get(ctx.params.id)
|
|
177
186
|
await triggers.externalTrigger(automation, {
|
|
178
187
|
...ctx.request.body,
|
|
179
|
-
appId
|
|
188
|
+
appId,
|
|
180
189
|
})
|
|
181
190
|
ctx.body = {
|
|
182
191
|
message: `Automation ${automation._id} has been triggered.`,
|
|
@@ -196,7 +205,8 @@ function prepareTestInput(input) {
|
|
|
196
205
|
}
|
|
197
206
|
|
|
198
207
|
exports.test = async function (ctx) {
|
|
199
|
-
const
|
|
208
|
+
const appId = ctx.appId
|
|
209
|
+
const db = new CouchDB(appId)
|
|
200
210
|
let automation = await db.get(ctx.params.id)
|
|
201
211
|
await setTestFlag(automation._id)
|
|
202
212
|
const testInput = prepareTestInput(ctx.request.body)
|
|
@@ -204,7 +214,7 @@ exports.test = async function (ctx) {
|
|
|
204
214
|
automation,
|
|
205
215
|
{
|
|
206
216
|
...testInput,
|
|
207
|
-
appId
|
|
217
|
+
appId,
|
|
208
218
|
},
|
|
209
219
|
{ getResponses: true }
|
|
210
220
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const env = require("../../environment")
|
|
2
2
|
const { getAllApps } = require("@budibase/backend-core/db")
|
|
3
|
+
const CouchDB = require("../../db")
|
|
3
4
|
const {
|
|
4
5
|
exportDB,
|
|
5
6
|
sendTempFile,
|
|
@@ -29,7 +30,7 @@ exports.exportApps = async ctx => {
|
|
|
29
30
|
if (env.SELF_HOSTED || !env.MULTI_TENANCY) {
|
|
30
31
|
ctx.throw(400, "Exporting only allowed in multi-tenant cloud environments.")
|
|
31
32
|
}
|
|
32
|
-
const apps = await getAllApps({ all: true })
|
|
33
|
+
const apps = await getAllApps(CouchDB, { all: true })
|
|
33
34
|
const globalDBString = await exportDB(getGlobalDBName(), {
|
|
34
35
|
filter: doc => !doc._id.startsWith(DocumentTypes.USER),
|
|
35
36
|
})
|
|
@@ -62,7 +63,7 @@ async function hasBeenImported() {
|
|
|
62
63
|
if (!env.SELF_HOSTED || env.MULTI_TENANCY) {
|
|
63
64
|
return true
|
|
64
65
|
}
|
|
65
|
-
const apps = await getAllApps({ all: true })
|
|
66
|
+
const apps = await getAllApps(CouchDB, { all: true })
|
|
66
67
|
return apps.length !== 0
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
const CouchDB = require("../../db")
|
|
1
2
|
const { DocumentTypes } = require("../../db/utils")
|
|
2
3
|
const { getComponentLibraryManifest } = require("../../utilities/fileSystem")
|
|
3
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
4
4
|
|
|
5
5
|
exports.fetchAppComponentDefinitions = async function (ctx) {
|
|
6
|
-
const
|
|
6
|
+
const appId = ctx.params.appId || ctx.appId
|
|
7
|
+
const db = new CouchDB(appId)
|
|
7
8
|
const app = await db.get(DocumentTypes.APP_METADATA)
|
|
8
9
|
|
|
9
10
|
let componentManifests = await Promise.all(
|
|
10
11
|
app.componentLibraries.map(async library => {
|
|
11
|
-
let manifest = await getComponentLibraryManifest(library)
|
|
12
|
+
let manifest = await getComponentLibraryManifest(appId, library)
|
|
12
13
|
|
|
13
14
|
return {
|
|
14
15
|
manifest,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const CouchDB = require("../../db")
|
|
1
2
|
const {
|
|
2
3
|
generateDatasourceID,
|
|
3
4
|
getDatasourceParams,
|
|
@@ -10,11 +11,12 @@ const { BuildSchemaErrors, InvalidColumns } = require("../../constants")
|
|
|
10
11
|
const { integrations } = require("../../integrations")
|
|
11
12
|
const { getDatasourceAndQuery } = require("./row/utils")
|
|
12
13
|
const { invalidateDynamicVariables } = require("../../threads/utils")
|
|
13
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
14
14
|
|
|
15
15
|
exports.fetch = async function (ctx) {
|
|
16
|
+
const database = new CouchDB(ctx.appId)
|
|
17
|
+
|
|
16
18
|
// Get internal tables
|
|
17
|
-
const db =
|
|
19
|
+
const db = new CouchDB(ctx.appId)
|
|
18
20
|
const internalTables = await db.allDocs(
|
|
19
21
|
getTableParams(null, {
|
|
20
22
|
include_docs: true,
|
|
@@ -29,25 +31,18 @@ exports.fetch = async function (ctx) {
|
|
|
29
31
|
|
|
30
32
|
// Get external datasources
|
|
31
33
|
const datasources = (
|
|
32
|
-
await
|
|
34
|
+
await database.allDocs(
|
|
33
35
|
getDatasourceParams(null, {
|
|
34
36
|
include_docs: true,
|
|
35
37
|
})
|
|
36
38
|
)
|
|
37
39
|
).rows.map(row => row.doc)
|
|
38
40
|
|
|
39
|
-
for (let datasource of datasources) {
|
|
40
|
-
if (datasource.config && datasource.config.auth) {
|
|
41
|
-
// strip secrets from response so they don't show in the network request
|
|
42
|
-
delete datasource.config.auth
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
41
|
ctx.body = [bbInternalDb, ...datasources]
|
|
47
42
|
}
|
|
48
43
|
|
|
49
44
|
exports.buildSchemaFromDb = async function (ctx) {
|
|
50
|
-
const db =
|
|
45
|
+
const db = new CouchDB(ctx.appId)
|
|
51
46
|
const datasource = await db.get(ctx.params.datasourceId)
|
|
52
47
|
|
|
53
48
|
const { tables, error } = await buildSchemaHelper(datasource)
|
|
@@ -96,16 +91,11 @@ const invalidateVariables = async (existingDatasource, updatedDatasource) => {
|
|
|
96
91
|
}
|
|
97
92
|
|
|
98
93
|
exports.update = async function (ctx) {
|
|
99
|
-
const db =
|
|
94
|
+
const db = new CouchDB(ctx.appId)
|
|
100
95
|
const datasourceId = ctx.params.datasourceId
|
|
101
96
|
let datasource = await db.get(datasourceId)
|
|
102
|
-
const auth = datasource.config.auth
|
|
103
97
|
await invalidateVariables(datasource, ctx.request.body)
|
|
104
98
|
datasource = { ...datasource, ...ctx.request.body }
|
|
105
|
-
if (auth && !ctx.request.body.auth) {
|
|
106
|
-
// don't strip auth config from DB
|
|
107
|
-
datasource.config.auth = auth
|
|
108
|
-
}
|
|
109
99
|
|
|
110
100
|
const response = await db.put(datasource)
|
|
111
101
|
datasource._rev = response.rev
|
|
@@ -124,7 +114,7 @@ exports.update = async function (ctx) {
|
|
|
124
114
|
}
|
|
125
115
|
|
|
126
116
|
exports.save = async function (ctx) {
|
|
127
|
-
const db =
|
|
117
|
+
const db = new CouchDB(ctx.appId)
|
|
128
118
|
const plus = ctx.request.body.datasource.plus
|
|
129
119
|
const fetchSchema = ctx.request.body.fetchSchema
|
|
130
120
|
|
|
@@ -160,7 +150,7 @@ exports.save = async function (ctx) {
|
|
|
160
150
|
}
|
|
161
151
|
|
|
162
152
|
exports.destroy = async function (ctx) {
|
|
163
|
-
const db =
|
|
153
|
+
const db = new CouchDB(ctx.appId)
|
|
164
154
|
|
|
165
155
|
// Delete all queries for the datasource
|
|
166
156
|
const queries = await db.allDocs(
|
|
@@ -182,7 +172,7 @@ exports.destroy = async function (ctx) {
|
|
|
182
172
|
}
|
|
183
173
|
|
|
184
174
|
exports.find = async function (ctx) {
|
|
185
|
-
const database =
|
|
175
|
+
const database = new CouchDB(ctx.appId)
|
|
186
176
|
ctx.body = await database.get(ctx.params.datasourceId)
|
|
187
177
|
}
|
|
188
178
|
|
|
@@ -190,7 +180,7 @@ exports.find = async function (ctx) {
|
|
|
190
180
|
exports.query = async function (ctx) {
|
|
191
181
|
const queryJson = ctx.request.body
|
|
192
182
|
try {
|
|
193
|
-
ctx.body = await getDatasourceAndQuery(queryJson)
|
|
183
|
+
ctx.body = await getDatasourceAndQuery(ctx.appId, queryJson)
|
|
194
184
|
} catch (err) {
|
|
195
185
|
ctx.throw(400, err)
|
|
196
186
|
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
const newid = require("../../../db/newid")
|
|
2
|
-
const { getAppId } = require("@budibase/backend-core/context")
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* This is used to pass around information about the deployment that is occurring
|
|
6
5
|
*/
|
|
7
6
|
class Deployment {
|
|
8
|
-
constructor(id = null) {
|
|
7
|
+
constructor(appId, id = null) {
|
|
8
|
+
this.appId = appId
|
|
9
9
|
this._id = id || newid()
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
getAppId() {
|
|
13
|
+
return this.appId
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
setVerification(verification) {
|
|
13
17
|
if (!verification) {
|
|
14
18
|
return
|
|
@@ -39,7 +43,7 @@ class Deployment {
|
|
|
39
43
|
getJSON() {
|
|
40
44
|
const obj = {
|
|
41
45
|
_id: this._id,
|
|
42
|
-
appId:
|
|
46
|
+
appId: this.appId,
|
|
43
47
|
status: this.status,
|
|
44
48
|
}
|
|
45
49
|
if (this.err) {
|