@budibase/server 1.0.49-alpha.9 → 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.ad5370ae.js → index.2c37968e.js} +246 -249
- 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 +2827 -3117
- 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 +141 -48
- package/coverage/lcov-report/api/controllers/row/index.html +40 -55
- 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 +24 -39
- 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 +4431 -5013
- 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 +67 -90
- package/dist/api/controllers/row/external.js +22 -14
- 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 +14 -56
- 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 +11 -15
- 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/integrations/postgres/init.sql +6 -11
- 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 +43 -67
- package/src/api/controllers/row/external.js +58 -27
- 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 +21 -69
- 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 +12 -17
- 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/tsconfig.json +1 -2
- 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 -29
- 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 -18
- 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/module.d.ts +0 -3
- 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
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
const CouchDB = require("../../db");
|
|
11
12
|
const env = require("../../environment");
|
|
12
13
|
const packageJson = require("../../../package.json");
|
|
13
14
|
const { createLinkView, createRoutingView, createAllSearchIndex, } = require("../../db/views/staticViews");
|
|
@@ -17,9 +18,9 @@ const { BUILTIN_ROLE_IDS, AccessController, } = require("@budibase/backend-core/
|
|
|
17
18
|
const { BASE_LAYOUTS } = require("../../constants/layouts");
|
|
18
19
|
const { cloneDeep } = require("lodash/fp");
|
|
19
20
|
const { processObject } = require("@budibase/string-templates");
|
|
20
|
-
const { getAllApps, isDevAppID,
|
|
21
|
+
const { getAllApps, isDevAppID, getDeployedAppID, Replication, } = require("@budibase/backend-core/db");
|
|
21
22
|
const { USERS_TABLE_SCHEMA } = require("../../constants");
|
|
22
|
-
const { removeAppFromUserRoles } = require("../../utilities/workerRequests");
|
|
23
|
+
const { getDeployedApps, removeAppFromUserRoles, } = require("../../utilities/workerRequests");
|
|
23
24
|
const { clientLibraryPath, stringToReadStream } = require("../../utilities");
|
|
24
25
|
const { getAllLocks } = require("../../utilities/redis");
|
|
25
26
|
const { updateClientLibrary, backupClientLibrary, revertClientLibrary, } = require("../../utilities/fileSystem/clientLibrary");
|
|
@@ -27,20 +28,17 @@ const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy")
|
|
|
27
28
|
const { syncGlobalUsers } = require("./user");
|
|
28
29
|
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
29
30
|
const { cleanupAutomations } = require("../../automations/utils");
|
|
30
|
-
const { getAppDB, getProdAppDB, updateAppId, } = require("@budibase/backend-core/context");
|
|
31
31
|
const URL_REGEX_SLASH = /\/|\\/g;
|
|
32
32
|
// utility function, need to do away with this
|
|
33
|
-
function getLayouts() {
|
|
33
|
+
function getLayouts(db) {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const db = getAppDB();
|
|
36
35
|
return (yield db.allDocs(getLayoutParams(null, {
|
|
37
36
|
include_docs: true,
|
|
38
37
|
}))).rows.map(row => row.doc);
|
|
39
38
|
});
|
|
40
39
|
}
|
|
41
|
-
function getScreens() {
|
|
40
|
+
function getScreens(db) {
|
|
42
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const db = getAppDB();
|
|
44
42
|
return (yield db.allDocs(getScreenParams(null, {
|
|
45
43
|
include_docs: true,
|
|
46
44
|
}))).rows.map(row => row.doc);
|
|
@@ -51,49 +49,37 @@ function getUserRoleId(ctx) {
|
|
|
51
49
|
? BUILTIN_ROLE_IDS.PUBLIC
|
|
52
50
|
: ctx.user.role._id;
|
|
53
51
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
url
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// TODO: Replace with Joi
|
|
80
|
-
if (!name) {
|
|
81
|
-
ctx.throw(400, "Name is required");
|
|
82
|
-
}
|
|
83
|
-
if (currentAppId) {
|
|
84
|
-
apps = apps.filter(app => app.appId !== currentAppId);
|
|
85
|
-
}
|
|
86
|
-
if (apps.some(app => app.name === name)) {
|
|
87
|
-
ctx.throw(400, "App name is already in use.");
|
|
88
|
-
}
|
|
89
|
-
};
|
|
52
|
+
function getAppUrlIfNotInUse(ctx) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
let url;
|
|
55
|
+
if (ctx.request.body.url) {
|
|
56
|
+
url = encodeURI(ctx.request.body.url);
|
|
57
|
+
}
|
|
58
|
+
else if (ctx.request.body.name) {
|
|
59
|
+
url = encodeURI(`${ctx.request.body.name}`);
|
|
60
|
+
}
|
|
61
|
+
if (url) {
|
|
62
|
+
url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase();
|
|
63
|
+
}
|
|
64
|
+
if (!env.SELF_HOSTED) {
|
|
65
|
+
return url;
|
|
66
|
+
}
|
|
67
|
+
const deployedApps = yield getDeployedApps();
|
|
68
|
+
if (url &&
|
|
69
|
+
deployedApps[url] != null &&
|
|
70
|
+
ctx.params != null &&
|
|
71
|
+
deployedApps[url].appId !== ctx.params.appId) {
|
|
72
|
+
ctx.throw(400, "App name/URL is already in use.");
|
|
73
|
+
}
|
|
74
|
+
return url;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
90
77
|
function createInstance(template) {
|
|
91
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
79
|
const tenantId = isMultiTenant() ? getTenantId() : null;
|
|
93
80
|
const baseAppId = generateAppID(tenantId);
|
|
94
81
|
const appId = generateDevAppID(baseAppId);
|
|
95
|
-
|
|
96
|
-
const db = getAppDB();
|
|
82
|
+
const db = new CouchDB(appId);
|
|
97
83
|
yield db.put({
|
|
98
84
|
_id: "_design/database",
|
|
99
85
|
// view collation information, read before writing any complex views:
|
|
@@ -102,9 +88,9 @@ function createInstance(template) {
|
|
|
102
88
|
});
|
|
103
89
|
// NOTE: indexes need to be created before any tables/templates
|
|
104
90
|
// add view for linked rows
|
|
105
|
-
yield createLinkView();
|
|
106
|
-
yield createRoutingView();
|
|
107
|
-
yield createAllSearchIndex();
|
|
91
|
+
yield createLinkView(appId);
|
|
92
|
+
yield createRoutingView(appId);
|
|
93
|
+
yield createAllSearchIndex(appId);
|
|
108
94
|
// replicate the template data to the instance DB
|
|
109
95
|
// this is currently very hard to test, downloading and importing template files
|
|
110
96
|
if (template && template.templateString) {
|
|
@@ -130,7 +116,7 @@ function createInstance(template) {
|
|
|
130
116
|
exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
117
|
const dev = ctx.query && ctx.query.status === AppStatus.DEV;
|
|
132
118
|
const all = ctx.query && ctx.query.status === AppStatus.ALL;
|
|
133
|
-
const apps = yield getAllApps({ dev, all });
|
|
119
|
+
const apps = yield getAllApps(CouchDB, { dev, all });
|
|
134
120
|
// get the locks for all the dev apps
|
|
135
121
|
if (dev || all) {
|
|
136
122
|
const locks = yield getAllLocks();
|
|
@@ -151,10 +137,11 @@ exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
151
137
|
ctx.body = apps;
|
|
152
138
|
});
|
|
153
139
|
exports.fetchAppDefinition = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
154
|
-
const
|
|
140
|
+
const db = new CouchDB(ctx.params.appId);
|
|
141
|
+
const layouts = yield getLayouts(db);
|
|
155
142
|
const userRoleId = getUserRoleId(ctx);
|
|
156
|
-
const accessController = new AccessController();
|
|
157
|
-
const screens = yield accessController.checkScreensAccess(yield getScreens(), userRoleId);
|
|
143
|
+
const accessController = new AccessController(ctx.params.appId);
|
|
144
|
+
const screens = yield accessController.checkScreensAccess(yield getScreens(db), userRoleId);
|
|
158
145
|
ctx.body = {
|
|
159
146
|
layouts,
|
|
160
147
|
screens,
|
|
@@ -162,14 +149,14 @@ exports.fetchAppDefinition = (ctx) => __awaiter(void 0, void 0, void 0, function
|
|
|
162
149
|
};
|
|
163
150
|
});
|
|
164
151
|
exports.fetchAppPackage = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
165
|
-
const db =
|
|
152
|
+
const db = new CouchDB(ctx.params.appId);
|
|
166
153
|
const application = yield db.get(DocumentTypes.APP_METADATA);
|
|
167
|
-
const layouts = yield getLayouts();
|
|
168
|
-
let screens = yield getScreens();
|
|
154
|
+
const layouts = yield getLayouts(db);
|
|
155
|
+
let screens = yield getScreens(db);
|
|
169
156
|
// Only filter screens if the user is not a builder
|
|
170
157
|
if (!(ctx.user.builder && ctx.user.builder.global)) {
|
|
171
158
|
const userRoleId = getUserRoleId(ctx);
|
|
172
|
-
const accessController = new AccessController();
|
|
159
|
+
const accessController = new AccessController(ctx.params.appId);
|
|
173
160
|
screens = yield accessController.checkScreensAccess(screens, userRoleId);
|
|
174
161
|
}
|
|
175
162
|
ctx.body = {
|
|
@@ -180,11 +167,6 @@ exports.fetchAppPackage = (ctx) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
180
167
|
};
|
|
181
168
|
});
|
|
182
169
|
exports.create = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
|
-
const apps = yield getAllApps({ dev: true });
|
|
184
|
-
const name = ctx.request.body.name;
|
|
185
|
-
checkAppName(ctx, apps, name);
|
|
186
|
-
const url = exports.getAppUrl(ctx);
|
|
187
|
-
checkAppUrl(ctx, apps, url);
|
|
188
170
|
const { useTemplate, templateKey, templateString } = ctx.request.body;
|
|
189
171
|
const instanceConfig = {
|
|
190
172
|
useTemplate,
|
|
@@ -196,7 +178,8 @@ exports.create = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
196
178
|
}
|
|
197
179
|
const instance = yield createInstance(instanceConfig);
|
|
198
180
|
const appId = instance._id;
|
|
199
|
-
const
|
|
181
|
+
const url = yield getAppUrlIfNotInUse(ctx);
|
|
182
|
+
const db = new CouchDB(appId);
|
|
200
183
|
let _rev;
|
|
201
184
|
try {
|
|
202
185
|
// if template there will be an existing doc
|
|
@@ -213,7 +196,7 @@ exports.create = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
213
196
|
type: "app",
|
|
214
197
|
version: packageJson.version,
|
|
215
198
|
componentLibraries: ["@budibase/standard-components"],
|
|
216
|
-
name: name,
|
|
199
|
+
name: ctx.request.body.name,
|
|
217
200
|
url: url,
|
|
218
201
|
template: ctx.request.body.template,
|
|
219
202
|
instance: instance,
|
|
@@ -236,27 +219,14 @@ exports.create = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
236
219
|
ctx.status = 200;
|
|
237
220
|
ctx.body = newApplication;
|
|
238
221
|
});
|
|
239
|
-
// This endpoint currently operates as a PATCH rather than a PUT
|
|
240
|
-
// Thus name and url fields are handled only if present
|
|
241
222
|
exports.update = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
242
|
-
const
|
|
243
|
-
// validation
|
|
244
|
-
const name = ctx.request.body.name;
|
|
245
|
-
if (name) {
|
|
246
|
-
checkAppName(ctx, apps, name, ctx.params.appId);
|
|
247
|
-
}
|
|
248
|
-
const url = yield exports.getAppUrl(ctx);
|
|
249
|
-
if (url) {
|
|
250
|
-
checkAppUrl(ctx, apps, url, ctx.params.appId);
|
|
251
|
-
ctx.request.body.url = url;
|
|
252
|
-
}
|
|
253
|
-
const data = yield updateAppPackage(ctx.request.body, ctx.params.appId);
|
|
223
|
+
const data = yield updateAppPackage(ctx, ctx.request.body, ctx.params.appId);
|
|
254
224
|
ctx.status = 200;
|
|
255
225
|
ctx.body = data;
|
|
256
226
|
});
|
|
257
227
|
exports.updateClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
258
228
|
// Get current app version
|
|
259
|
-
const db =
|
|
229
|
+
const db = new CouchDB(ctx.params.appId);
|
|
260
230
|
const application = yield db.get(DocumentTypes.APP_METADATA);
|
|
261
231
|
const currentVersion = application.version;
|
|
262
232
|
// Update client library and manifest
|
|
@@ -269,13 +239,13 @@ exports.updateClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
269
239
|
version: packageJson.version,
|
|
270
240
|
revertableVersion: currentVersion,
|
|
271
241
|
};
|
|
272
|
-
const data = yield updateAppPackage(appPackageUpdates, ctx.params.appId);
|
|
242
|
+
const data = yield updateAppPackage(ctx, appPackageUpdates, ctx.params.appId);
|
|
273
243
|
ctx.status = 200;
|
|
274
244
|
ctx.body = data;
|
|
275
245
|
});
|
|
276
246
|
exports.revertClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
277
247
|
// Check app can be reverted
|
|
278
|
-
const db =
|
|
248
|
+
const db = new CouchDB(ctx.params.appId);
|
|
279
249
|
const application = yield db.get(DocumentTypes.APP_METADATA);
|
|
280
250
|
if (!application.revertableVersion) {
|
|
281
251
|
ctx.throw(400, "There is no version to revert to");
|
|
@@ -289,12 +259,12 @@ exports.revertClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
289
259
|
version: application.revertableVersion,
|
|
290
260
|
revertableVersion: null,
|
|
291
261
|
};
|
|
292
|
-
const data = yield updateAppPackage(appPackageUpdates, ctx.params.appId);
|
|
262
|
+
const data = yield updateAppPackage(ctx, appPackageUpdates, ctx.params.appId);
|
|
293
263
|
ctx.status = 200;
|
|
294
264
|
ctx.body = data;
|
|
295
265
|
});
|
|
296
266
|
exports.delete = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
297
|
-
const db =
|
|
267
|
+
const db = new CouchDB(ctx.params.appId);
|
|
298
268
|
const result = yield db.destroy();
|
|
299
269
|
/* istanbul ignore next */
|
|
300
270
|
if (!env.isTest() && !ctx.query.unpublish) {
|
|
@@ -315,10 +285,9 @@ exports.sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
315
285
|
ctx.throw(400, "This action cannot be performed for production apps");
|
|
316
286
|
}
|
|
317
287
|
// replicate prod to dev
|
|
318
|
-
const prodAppId =
|
|
288
|
+
const prodAppId = getDeployedAppID(appId);
|
|
319
289
|
try {
|
|
320
|
-
|
|
321
|
-
const prodDb = getProdAppDB({ skip_setup: true });
|
|
290
|
+
const prodDb = new CouchDB(prodAppId, { skip_setup: true });
|
|
322
291
|
const info = yield prodDb.info();
|
|
323
292
|
if (info.error)
|
|
324
293
|
throw info.error;
|
|
@@ -347,7 +316,7 @@ exports.sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
347
316
|
error = err;
|
|
348
317
|
}
|
|
349
318
|
// sync the users
|
|
350
|
-
yield syncGlobalUsers();
|
|
319
|
+
yield syncGlobalUsers(appId);
|
|
351
320
|
if (error) {
|
|
352
321
|
ctx.throw(400, error);
|
|
353
322
|
}
|
|
@@ -357,10 +326,11 @@ exports.sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
357
326
|
};
|
|
358
327
|
}
|
|
359
328
|
});
|
|
360
|
-
const updateAppPackage = (appPackage, appId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
361
|
-
const
|
|
329
|
+
const updateAppPackage = (ctx, appPackage, appId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
330
|
+
const url = yield getAppUrlIfNotInUse(ctx);
|
|
331
|
+
const db = new CouchDB(appId);
|
|
362
332
|
const application = yield db.get(DocumentTypes.APP_METADATA);
|
|
363
|
-
const newAppPackage = Object.assign(Object.assign({}, application), appPackage);
|
|
333
|
+
const newAppPackage = Object.assign(Object.assign(Object.assign({}, application), appPackage), { url });
|
|
364
334
|
if (appPackage._rev !== application._rev) {
|
|
365
335
|
newAppPackage._rev = application._rev;
|
|
366
336
|
}
|
|
@@ -373,7 +343,7 @@ const updateAppPackage = (appPackage, appId) => __awaiter(void 0, void 0, void 0
|
|
|
373
343
|
return response;
|
|
374
344
|
});
|
|
375
345
|
const createEmptyAppPackage = (ctx, app) => __awaiter(void 0, void 0, void 0, function* () {
|
|
376
|
-
const db =
|
|
346
|
+
const db = new CouchDB(app.appId);
|
|
377
347
|
let screensAndLayouts = [];
|
|
378
348
|
for (let layout of BASE_LAYOUTS) {
|
|
379
349
|
const cloned = cloneDeep(layout);
|
|
@@ -8,12 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
const CouchDB = require("../../db");
|
|
11
12
|
const { outputProcessing } = require("../../utilities/rowProcessor");
|
|
12
13
|
const { InternalTables } = require("../../db/utils");
|
|
13
14
|
const { getFullUser } = require("../../utilities/users");
|
|
14
15
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
15
|
-
const { getAppDB, getAppId } = require("@budibase/backend-core/context");
|
|
16
16
|
exports.fetchSelf = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const appId = ctx.appId;
|
|
17
18
|
let userId = ctx.user.userId || ctx.user._id;
|
|
18
19
|
/* istanbul ignore next */
|
|
19
20
|
if (!userId) {
|
|
@@ -23,19 +24,15 @@ exports.fetchSelf = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
23
24
|
const user = yield getFullUser(ctx, userId);
|
|
24
25
|
// this shouldn't be returned by the app self
|
|
25
26
|
delete user.roles;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (getAppId()) {
|
|
29
|
-
const db = getAppDB();
|
|
27
|
+
if (appId) {
|
|
28
|
+
const db = new CouchDB(appId);
|
|
30
29
|
// remove the full roles structure
|
|
31
30
|
delete user.roles;
|
|
32
31
|
try {
|
|
33
32
|
const userTable = yield db.get(InternalTables.USER_METADATA);
|
|
34
33
|
const metadata = yield db.get(userId);
|
|
35
|
-
// make sure there is never a stale csrf token
|
|
36
|
-
delete metadata.csrfToken;
|
|
37
34
|
// specifically needs to make sure is enriched
|
|
38
|
-
ctx.body = yield outputProcessing(userTable, Object.assign(Object.assign({}, user), metadata));
|
|
35
|
+
ctx.body = yield outputProcessing(ctx, userTable, Object.assign(Object.assign({}, user), metadata));
|
|
39
36
|
}
|
|
40
37
|
catch (err) {
|
|
41
38
|
let response;
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
const CouchDB = require("../../db");
|
|
11
12
|
const actions = require("../../automations/actions");
|
|
12
13
|
const triggers = require("../../automations/triggers");
|
|
13
14
|
const { getAutomationParams, generateAutomationID } = require("../../db/utils");
|
|
@@ -15,7 +16,6 @@ const { checkForWebhooks, updateTestHistory, removeDeprecated, } = require("../.
|
|
|
15
16
|
const { deleteEntityMetadata } = require("../../utilities");
|
|
16
17
|
const { MetadataTypes } = require("../../constants");
|
|
17
18
|
const { setTestFlag, clearTestFlag } = require("../../utilities/redis");
|
|
18
|
-
const { getAppDB } = require("@budibase/backend-core/context");
|
|
19
19
|
const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS);
|
|
20
20
|
const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS);
|
|
21
21
|
/*************************
|
|
@@ -23,10 +23,10 @@ const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS);
|
|
|
23
23
|
* BUILDER FUNCTIONS *
|
|
24
24
|
* *
|
|
25
25
|
*************************/
|
|
26
|
-
function cleanupAutomationMetadata(automationId) {
|
|
26
|
+
function cleanupAutomationMetadata(appId, automationId) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
yield deleteEntityMetadata(MetadataTypes.AUTOMATION_TEST_INPUT, automationId);
|
|
29
|
-
yield deleteEntityMetadata(MetadataTypes.AUTOMATION_TEST_HISTORY, automationId);
|
|
28
|
+
yield deleteEntityMetadata(appId, MetadataTypes.AUTOMATION_TEST_INPUT, automationId);
|
|
29
|
+
yield deleteEntityMetadata(appId, MetadataTypes.AUTOMATION_TEST_HISTORY, automationId);
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
function cleanAutomationInputs(automation) {
|
|
@@ -54,7 +54,7 @@ function cleanAutomationInputs(automation) {
|
|
|
54
54
|
}
|
|
55
55
|
exports.create = function (ctx) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const db =
|
|
57
|
+
const db = new CouchDB(ctx.appId);
|
|
58
58
|
let automation = ctx.request.body;
|
|
59
59
|
automation.appId = ctx.appId;
|
|
60
60
|
// call through to update if already exists
|
|
@@ -65,6 +65,7 @@ exports.create = function (ctx) {
|
|
|
65
65
|
automation.type = "automation";
|
|
66
66
|
automation = cleanAutomationInputs(automation);
|
|
67
67
|
automation = yield checkForWebhooks({
|
|
68
|
+
appId: ctx.appId,
|
|
68
69
|
newAuto: automation,
|
|
69
70
|
});
|
|
70
71
|
const response = yield db.put(automation);
|
|
@@ -78,12 +79,13 @@ exports.create = function (ctx) {
|
|
|
78
79
|
};
|
|
79
80
|
exports.update = function (ctx) {
|
|
80
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
const db =
|
|
82
|
+
const db = new CouchDB(ctx.appId);
|
|
82
83
|
let automation = ctx.request.body;
|
|
83
84
|
automation.appId = ctx.appId;
|
|
84
85
|
const oldAutomation = yield db.get(automation._id);
|
|
85
86
|
automation = cleanAutomationInputs(automation);
|
|
86
87
|
automation = yield checkForWebhooks({
|
|
88
|
+
appId: ctx.appId,
|
|
87
89
|
oldAuto: oldAutomation,
|
|
88
90
|
newAuto: automation,
|
|
89
91
|
});
|
|
@@ -108,7 +110,7 @@ exports.update = function (ctx) {
|
|
|
108
110
|
};
|
|
109
111
|
exports.fetch = function (ctx) {
|
|
110
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
const db =
|
|
113
|
+
const db = new CouchDB(ctx.appId);
|
|
112
114
|
const response = yield db.allDocs(getAutomationParams(null, {
|
|
113
115
|
include_docs: true,
|
|
114
116
|
}));
|
|
@@ -117,20 +119,21 @@ exports.fetch = function (ctx) {
|
|
|
117
119
|
};
|
|
118
120
|
exports.find = function (ctx) {
|
|
119
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
const db =
|
|
122
|
+
const db = new CouchDB(ctx.appId);
|
|
121
123
|
ctx.body = yield db.get(ctx.params.id);
|
|
122
124
|
});
|
|
123
125
|
};
|
|
124
126
|
exports.destroy = function (ctx) {
|
|
125
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const db =
|
|
128
|
+
const db = new CouchDB(ctx.appId);
|
|
127
129
|
const automationId = ctx.params.id;
|
|
128
130
|
const oldAutomation = yield db.get(automationId);
|
|
129
131
|
yield checkForWebhooks({
|
|
132
|
+
appId: ctx.appId,
|
|
130
133
|
oldAuto: oldAutomation,
|
|
131
134
|
});
|
|
132
135
|
// delete metadata first
|
|
133
|
-
yield cleanupAutomationMetadata(automationId);
|
|
136
|
+
yield cleanupAutomationMetadata(ctx.appId, automationId);
|
|
134
137
|
ctx.body = yield db.remove(automationId, ctx.params.rev);
|
|
135
138
|
});
|
|
136
139
|
};
|
|
@@ -159,9 +162,10 @@ module.exports.getDefinitionList = function (ctx) {
|
|
|
159
162
|
*********************/
|
|
160
163
|
exports.trigger = function (ctx) {
|
|
161
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
const
|
|
165
|
+
const appId = ctx.appId;
|
|
166
|
+
const db = new CouchDB(appId);
|
|
163
167
|
let automation = yield db.get(ctx.params.id);
|
|
164
|
-
yield triggers.externalTrigger(automation, Object.assign(Object.assign({}, ctx.request.body), { appId
|
|
168
|
+
yield triggers.externalTrigger(automation, Object.assign(Object.assign({}, ctx.request.body), { appId }));
|
|
165
169
|
ctx.body = {
|
|
166
170
|
message: `Automation ${automation._id} has been triggered.`,
|
|
167
171
|
automation,
|
|
@@ -180,11 +184,12 @@ function prepareTestInput(input) {
|
|
|
180
184
|
}
|
|
181
185
|
exports.test = function (ctx) {
|
|
182
186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
const
|
|
187
|
+
const appId = ctx.appId;
|
|
188
|
+
const db = new CouchDB(appId);
|
|
184
189
|
let automation = yield db.get(ctx.params.id);
|
|
185
190
|
yield setTestFlag(automation._id);
|
|
186
191
|
const testInput = prepareTestInput(ctx.request.body);
|
|
187
|
-
const response = yield triggers.externalTrigger(automation, Object.assign(Object.assign({}, testInput), { appId
|
|
192
|
+
const response = yield triggers.externalTrigger(automation, Object.assign(Object.assign({}, testInput), { appId }), { getResponses: true });
|
|
188
193
|
// save a test history run
|
|
189
194
|
yield updateTestHistory(ctx.appId, automation, Object.assign(Object.assign({}, ctx.request.body), { occurredAt: new Date().getTime() }));
|
|
190
195
|
yield clearTestFlag(automation._id);
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const env = require("../../environment");
|
|
12
12
|
const { getAllApps } = require("@budibase/backend-core/db");
|
|
13
|
+
const CouchDB = require("../../db");
|
|
13
14
|
const { exportDB, sendTempFile, readFileSync, } = require("../../utilities/fileSystem");
|
|
14
15
|
const { stringToReadStream } = require("../../utilities");
|
|
15
16
|
const { getGlobalDBName, getGlobalDB, } = require("@budibase/backend-core/tenancy");
|
|
@@ -32,7 +33,7 @@ exports.exportApps = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
32
33
|
if (env.SELF_HOSTED || !env.MULTI_TENANCY) {
|
|
33
34
|
ctx.throw(400, "Exporting only allowed in multi-tenant cloud environments.");
|
|
34
35
|
}
|
|
35
|
-
const apps = yield getAllApps({ all: true });
|
|
36
|
+
const apps = yield getAllApps(CouchDB, { all: true });
|
|
36
37
|
const globalDBString = yield exportDB(getGlobalDBName(), {
|
|
37
38
|
filter: doc => !doc._id.startsWith(DocumentTypes.USER),
|
|
38
39
|
});
|
|
@@ -64,7 +65,7 @@ function hasBeenImported() {
|
|
|
64
65
|
if (!env.SELF_HOSTED || env.MULTI_TENANCY) {
|
|
65
66
|
return true;
|
|
66
67
|
}
|
|
67
|
-
const apps = yield getAllApps({ all: true });
|
|
68
|
+
const apps = yield getAllApps(CouchDB, { all: true });
|
|
68
69
|
return apps.length !== 0;
|
|
69
70
|
});
|
|
70
71
|
}
|
|
@@ -8,15 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
const CouchDB = require("../../db");
|
|
11
12
|
const { DocumentTypes } = require("../../db/utils");
|
|
12
13
|
const { getComponentLibraryManifest } = require("../../utilities/fileSystem");
|
|
13
|
-
const { getAppDB } = require("@budibase/backend-core/context");
|
|
14
14
|
exports.fetchAppComponentDefinitions = function (ctx) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const
|
|
16
|
+
const appId = ctx.params.appId || ctx.appId;
|
|
17
|
+
const db = new CouchDB(appId);
|
|
17
18
|
const app = yield db.get(DocumentTypes.APP_METADATA);
|
|
18
19
|
let componentManifests = yield Promise.all(app.componentLibraries.map((library) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
let manifest = yield getComponentLibraryManifest(library);
|
|
20
|
+
let manifest = yield getComponentLibraryManifest(appId, library);
|
|
20
21
|
return {
|
|
21
22
|
manifest,
|
|
22
23
|
library,
|
|
@@ -8,37 +8,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
const CouchDB = require("../../db");
|
|
11
12
|
const { generateDatasourceID, getDatasourceParams, getQueryParams, DocumentTypes, BudibaseInternalDB, getTableParams, } = require("../../db/utils");
|
|
12
13
|
const { BuildSchemaErrors, InvalidColumns } = require("../../constants");
|
|
13
14
|
const { integrations } = require("../../integrations");
|
|
14
15
|
const { getDatasourceAndQuery } = require("./row/utils");
|
|
15
16
|
const { invalidateDynamicVariables } = require("../../threads/utils");
|
|
16
|
-
const { getAppDB } = require("@budibase/backend-core/context");
|
|
17
17
|
exports.fetch = function (ctx) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const database = new CouchDB(ctx.appId);
|
|
19
20
|
// Get internal tables
|
|
20
|
-
const db =
|
|
21
|
+
const db = new CouchDB(ctx.appId);
|
|
21
22
|
const internalTables = yield db.allDocs(getTableParams(null, {
|
|
22
23
|
include_docs: true,
|
|
23
24
|
}));
|
|
24
25
|
const internal = internalTables.rows.map(row => row.doc);
|
|
25
26
|
const bbInternalDb = Object.assign(Object.assign({}, BudibaseInternalDB), { entities: internal });
|
|
26
27
|
// Get external datasources
|
|
27
|
-
const datasources = (yield
|
|
28
|
+
const datasources = (yield database.allDocs(getDatasourceParams(null, {
|
|
28
29
|
include_docs: true,
|
|
29
30
|
}))).rows.map(row => row.doc);
|
|
30
|
-
for (let datasource of datasources) {
|
|
31
|
-
if (datasource.config && datasource.config.auth) {
|
|
32
|
-
// strip secrets from response so they don't show in the network request
|
|
33
|
-
delete datasource.config.auth;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
31
|
ctx.body = [bbInternalDb, ...datasources];
|
|
37
32
|
});
|
|
38
33
|
};
|
|
39
34
|
exports.buildSchemaFromDb = function (ctx) {
|
|
40
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const db =
|
|
36
|
+
const db = new CouchDB(ctx.appId);
|
|
42
37
|
const datasource = yield db.get(ctx.params.datasourceId);
|
|
43
38
|
const { tables, error } = yield buildSchemaHelper(datasource);
|
|
44
39
|
datasource.entities = tables;
|
|
@@ -80,16 +75,11 @@ const invalidateVariables = (existingDatasource, updatedDatasource) => __awaiter
|
|
|
80
75
|
});
|
|
81
76
|
exports.update = function (ctx) {
|
|
82
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
const db =
|
|
78
|
+
const db = new CouchDB(ctx.appId);
|
|
84
79
|
const datasourceId = ctx.params.datasourceId;
|
|
85
80
|
let datasource = yield db.get(datasourceId);
|
|
86
|
-
const auth = datasource.config.auth;
|
|
87
81
|
yield invalidateVariables(datasource, ctx.request.body);
|
|
88
82
|
datasource = Object.assign(Object.assign({}, datasource), ctx.request.body);
|
|
89
|
-
if (auth && !ctx.request.body.auth) {
|
|
90
|
-
// don't strip auth config from DB
|
|
91
|
-
datasource.config.auth = auth;
|
|
92
|
-
}
|
|
93
83
|
const response = yield db.put(datasource);
|
|
94
84
|
datasource._rev = response.rev;
|
|
95
85
|
// Drain connection pools when configuration is changed
|
|
@@ -106,7 +96,7 @@ exports.update = function (ctx) {
|
|
|
106
96
|
};
|
|
107
97
|
exports.save = function (ctx) {
|
|
108
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
const db =
|
|
99
|
+
const db = new CouchDB(ctx.appId);
|
|
110
100
|
const plus = ctx.request.body.datasource.plus;
|
|
111
101
|
const fetchSchema = ctx.request.body.fetchSchema;
|
|
112
102
|
const datasource = Object.assign({ _id: generateDatasourceID({ plus }), type: plus ? DocumentTypes.DATASOURCE_PLUS : DocumentTypes.DATASOURCE }, ctx.request.body.datasource);
|
|
@@ -134,7 +124,7 @@ exports.save = function (ctx) {
|
|
|
134
124
|
};
|
|
135
125
|
exports.destroy = function (ctx) {
|
|
136
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
const db =
|
|
127
|
+
const db = new CouchDB(ctx.appId);
|
|
138
128
|
// Delete all queries for the datasource
|
|
139
129
|
const queries = yield db.allDocs(getQueryParams(ctx.params.datasourceId, null));
|
|
140
130
|
yield db.bulkDocs(queries.rows.map(row => ({
|
|
@@ -150,7 +140,7 @@ exports.destroy = function (ctx) {
|
|
|
150
140
|
};
|
|
151
141
|
exports.find = function (ctx) {
|
|
152
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
const database =
|
|
143
|
+
const database = new CouchDB(ctx.appId);
|
|
154
144
|
ctx.body = yield database.get(ctx.params.datasourceId);
|
|
155
145
|
});
|
|
156
146
|
};
|
|
@@ -159,7 +149,7 @@ exports.query = function (ctx) {
|
|
|
159
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
150
|
const queryJson = ctx.request.body;
|
|
161
151
|
try {
|
|
162
|
-
ctx.body = yield getDatasourceAndQuery(queryJson);
|
|
152
|
+
ctx.body = yield getDatasourceAndQuery(ctx.appId, queryJson);
|
|
163
153
|
}
|
|
164
154
|
catch (err) {
|
|
165
155
|
ctx.throw(400, err);
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const newid = require("../../../db/newid");
|
|
3
|
-
const { getAppId } = require("@budibase/backend-core/context");
|
|
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
|
+
getAppId() {
|
|
12
|
+
return this.appId;
|
|
13
|
+
}
|
|
11
14
|
setVerification(verification) {
|
|
12
15
|
if (!verification) {
|
|
13
16
|
return;
|
|
@@ -34,7 +37,7 @@ class Deployment {
|
|
|
34
37
|
getJSON() {
|
|
35
38
|
const obj = {
|
|
36
39
|
_id: this._id,
|
|
37
|
-
appId:
|
|
40
|
+
appId: this.appId,
|
|
38
41
|
status: this.status,
|
|
39
42
|
};
|
|
40
43
|
if (this.err) {
|