@budibase/server 1.0.49 → 1.0.50-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/arangojs.ts +1 -1
- package/__mocks__/aws-sdk.ts +4 -4
- package/__mocks__/mongodb.ts +4 -5
- package/__mocks__/mssql.ts +3 -3
- package/__mocks__/node-fetch.ts +2 -1
- package/__mocks__/pg.ts +3 -5
- package/builder/assets/{index.2c37968e.js → index.9fe798bd.js} +252 -249
- package/builder/assets/index.c0cc369d.css +6 -0
- package/builder/assets/{vendor.f9faf6ab.js → vendor.5ad9695a.js} +202 -106
- package/builder/index.html +3 -3
- package/coverage/clover.xml +3105 -2814
- package/coverage/coverage-final.json +106 -101
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.js.html +257 -152
- package/coverage/lcov-report/api/controllers/auth.js.html +22 -13
- package/coverage/lcov-report/api/controllers/automation.js.html +39 -69
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +8 -11
- package/coverage/lcov-report/api/controllers/component.js.html +13 -16
- package/coverage/lcov-report/api/controllers/datasource.js.html +81 -51
- package/coverage/lcov-report/api/controllers/dev.js.html +6 -6
- package/coverage/lcov-report/api/controllers/index.html +78 -78
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +9 -9
- package/coverage/lcov-report/api/controllers/metadata.js.html +6 -21
- package/coverage/lcov-report/api/controllers/migrations.js.html +119 -0
- package/coverage/lcov-report/api/controllers/permission.js.html +19 -19
- package/coverage/lcov-report/api/controllers/query/index.html +10 -10
- package/coverage/lcov-report/api/controllers/query/index.js.html +38 -35
- package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -6
- package/coverage/lcov-report/api/controllers/role.js.html +16 -16
- package/coverage/lcov-report/api/controllers/routing.js.html +7 -10
- package/coverage/lcov-report/api/controllers/row/external.js.html +48 -141
- package/coverage/lcov-report/api/controllers/row/index.html +55 -40
- package/coverage/lcov-report/api/controllers/row/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/row/internal.js.html +118 -226
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +52 -34
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +548 -0
- package/coverage/lcov-report/api/controllers/row/utils.js.html +47 -62
- package/coverage/lcov-report/api/controllers/screen.js.html +15 -21
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +599 -0
- package/coverage/lcov-report/api/controllers/table/external.js.html +25 -34
- package/coverage/lcov-report/api/controllers/table/index.html +58 -43
- package/coverage/lcov-report/api/controllers/table/index.js.html +58 -82
- package/coverage/lcov-report/api/controllers/table/internal.js.html +81 -66
- package/coverage/lcov-report/api/controllers/table/utils.js.html +218 -110
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +79 -76
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +16 -16
- package/coverage/lcov-report/api/controllers/view/index.js.html +27 -33
- package/coverage/lcov-report/api/controllers/view/utils.js.html +35 -20
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +34 -28
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +8 -8
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/application.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +18 -18
- package/coverage/lcov-report/api/routes/index.js.html +3 -3
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/{hosting.js.html → migrations.js.html} +17 -14
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/row.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +17 -2
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +7 -10
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +18 -18
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +13 -22
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +11 -20
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +13 -13
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +61 -55
- package/coverage/lcov-report/automations/utils.js.html +54 -42
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +53 -26
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +25 -37
- package/coverage/lcov-report/db/linkedRows/index.html +27 -27
- package/coverage/lcov-report/db/linkedRows/index.js.html +51 -96
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +42 -42
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +87 -87
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +5 -5
- package/coverage/lcov-report/events/utils.js.html +3 -3
- package/coverage/lcov-report/index.html +135 -120
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/authorized.js.html +173 -65
- package/coverage/lcov-report/middleware/builder.js.html +10 -10
- package/coverage/lcov-report/middleware/currentapp.js.html +95 -83
- package/coverage/lcov-report/middleware/index.html +38 -38
- package/coverage/lcov-report/middleware/joi-validator.js.html +3 -3
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +281 -53
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +30 -24
- package/coverage/lcov-report/threads/index.html +26 -26
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +39 -24
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +58 -49
- package/coverage/lcov-report/utilities/index.html +37 -37
- package/coverage/lcov-report/utilities/index.js.html +43 -73
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +8 -8
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +7 -7
- package/coverage/lcov-report/utilities/rowProcessor/index.html +27 -27
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +97 -103
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +75 -27
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +141 -0
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +359 -0
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +305 -0
- package/coverage/lcov-report/{api/controllers/hosting.js.html → utilities/usageQuota/usageQuoteReset.js.html} +36 -48
- package/coverage/lcov-report/utilities/users.js.html +9 -9
- package/coverage/lcov-report/utilities/workerRequests.js.html +43 -112
- package/coverage/lcov.info +5010 -4425
- package/dist/api/controllers/application.js +90 -60
- package/dist/api/controllers/auth.js +8 -5
- package/dist/api/controllers/automation.js +14 -19
- package/dist/api/controllers/cloud.js +2 -3
- package/dist/api/controllers/component.js +3 -4
- package/dist/api/controllers/datasource.js +20 -10
- package/dist/api/controllers/deploy/Deployment.js +3 -6
- package/dist/api/controllers/deploy/index.js +12 -13
- package/dist/api/controllers/dev.js +5 -5
- package/dist/api/controllers/layout.js +3 -3
- package/dist/api/controllers/metadata.js +4 -4
- package/dist/api/controllers/migrations.js +21 -0
- package/dist/api/controllers/permission.js +4 -4
- package/dist/api/controllers/query/import/index.js +4 -6
- package/dist/api/controllers/query/index.js +11 -10
- package/dist/api/controllers/role.js +5 -5
- package/dist/api/controllers/routing.js +5 -6
- package/dist/api/controllers/row/ExternalRequest.js +90 -67
- package/dist/api/controllers/row/external.js +14 -22
- package/dist/api/controllers/row/internal.js +55 -93
- package/dist/api/controllers/row/internalSearch.js +23 -17
- package/dist/api/controllers/row/staticFormula.js +147 -0
- package/dist/api/controllers/row/utils.js +13 -14
- package/dist/api/controllers/screen.js +5 -7
- package/dist/api/controllers/static/index.js +62 -16
- package/dist/api/controllers/table/bulkFormula.js +159 -0
- package/dist/api/controllers/table/external.js +7 -10
- package/dist/api/controllers/table/index.js +16 -13
- package/dist/api/controllers/table/internal.js +22 -16
- package/dist/api/controllers/table/utils.js +62 -35
- package/dist/api/controllers/user.js +43 -43
- package/dist/api/controllers/view/index.js +8 -10
- package/dist/api/controllers/view/utils.js +9 -4
- package/dist/api/controllers/webhook.js +10 -8
- package/dist/api/routes/index.js +2 -2
- package/dist/api/routes/migrations.js +9 -0
- package/dist/api/routes/static.js +2 -1
- package/dist/api/routes/tests/utilities/TestFunctions.js +37 -17
- package/dist/app.js +35 -5
- package/dist/automations/automationUtils.js +2 -3
- package/dist/automations/steps/createRow.js +3 -5
- package/dist/automations/steps/deleteRow.js +1 -4
- package/dist/automations/steps/updateRow.js +1 -1
- package/dist/automations/triggers.js +27 -25
- package/dist/automations/utils.js +10 -5
- package/dist/constants/index.js +7 -0
- package/dist/db/linkedRows/LinkController.js +3 -7
- package/dist/db/linkedRows/index.js +16 -27
- package/dist/db/linkedRows/linkUtils.js +6 -6
- package/dist/db/views/staticViews.js +9 -10
- package/dist/definitions/datasource.js +1 -0
- package/dist/environment.js +4 -1
- package/dist/integrations/base/sql.js +62 -21
- package/dist/integrations/googlesheets.js +340 -0
- package/dist/integrations/index.js +3 -0
- package/dist/integrations/utils.js +60 -9
- package/dist/middleware/authorized.js +57 -30
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +41 -37
- package/dist/middleware/usageQuota.js +82 -15
- package/dist/migrations/functions/appUrls.js +46 -0
- package/dist/migrations/functions/quotas1.js +50 -0
- package/dist/migrations/functions/usageQuotas/index.js +20 -0
- package/dist/migrations/functions/usageQuotas/syncApps.js +29 -0
- package/dist/migrations/functions/usageQuotas/syncRows.js +33 -0
- package/dist/migrations/functions/userEmailViewCasing.js +24 -0
- package/dist/migrations/index.js +62 -0
- package/dist/package.json +8 -5
- package/dist/tests/utilities/TestConfiguration.js +80 -50
- package/dist/threads/automation.js +13 -11
- package/dist/threads/query.js +15 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +4 -3
- package/dist/utilities/global.js +15 -12
- package/dist/utilities/index.js +7 -17
- package/dist/utilities/routing/index.js +5 -5
- package/dist/utilities/rowProcessor/index.js +23 -17
- package/dist/utilities/rowProcessor/utils.js +14 -4
- package/dist/utilities/{usageQuota.js → usageQuota/index.js} +45 -31
- package/dist/utilities/usageQuota/rows.js +78 -0
- package/dist/utilities/usageQuota/usageQuoteReset.js +16 -0
- package/dist/utilities/users.js +3 -3
- package/dist/utilities/workerRequests.js +4 -24
- package/nodemon.json +1 -1
- package/package.json +9 -6
- package/scripts/integrations/mssql/data/Dockerfile +1 -1
- package/scripts/integrations/mssql/data/setup.sql +17 -4
- package/scripts/integrations/postgres/init.sql +11 -6
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/application.js +85 -50
- package/src/api/controllers/auth.js +8 -5
- package/src/api/controllers/automation.js +13 -23
- package/src/api/controllers/cloud.js +2 -3
- package/src/api/controllers/component.js +3 -4
- package/src/api/controllers/datasource.js +21 -11
- package/src/api/controllers/deploy/Deployment.js +3 -7
- package/src/api/controllers/deploy/index.js +20 -13
- package/src/api/controllers/dev.js +5 -5
- package/src/api/controllers/layout.js +3 -3
- package/src/api/controllers/metadata.js +4 -9
- package/src/api/controllers/migrations.js +13 -0
- package/src/api/controllers/permission.js +4 -4
- package/src/api/controllers/query/import/index.ts +4 -6
- package/src/api/controllers/query/import/tests/index.spec.js +2 -1
- package/src/api/controllers/query/index.js +11 -10
- package/src/api/controllers/role.js +5 -5
- package/src/api/controllers/routing.js +5 -6
- package/src/api/controllers/row/ExternalRequest.ts +67 -43
- package/src/api/controllers/row/external.js +27 -58
- package/src/api/controllers/row/internal.js +54 -90
- package/src/api/controllers/row/internalSearch.js +23 -17
- package/src/api/controllers/row/staticFormula.js +156 -0
- package/src/api/controllers/row/utils.js +13 -18
- package/src/api/controllers/screen.js +5 -7
- package/src/api/controllers/static/index.js +66 -15
- package/src/api/controllers/table/bulkFormula.js +173 -0
- package/src/api/controllers/table/external.js +7 -10
- package/src/api/controllers/table/index.js +20 -28
- package/src/api/controllers/table/internal.js +24 -19
- package/src/api/controllers/table/utils.js +78 -42
- package/src/api/controllers/user.js +46 -45
- package/src/api/controllers/view/index.js +8 -10
- package/src/api/controllers/view/utils.js +9 -4
- package/src/api/controllers/webhook.js +10 -8
- package/src/api/routes/index.js +2 -2
- package/src/api/routes/migrations.js +14 -0
- package/src/api/routes/static.js +5 -0
- package/src/api/routes/tests/application.spec.js +2 -2
- package/src/api/routes/tests/auth.spec.js +1 -2
- package/src/api/routes/tests/automation.spec.js +1 -0
- package/src/api/routes/tests/misc.spec.js +0 -1
- package/src/api/routes/tests/routing.spec.js +21 -12
- package/src/api/routes/tests/row.spec.js +7 -4
- package/src/api/routes/tests/static.spec.js +98 -0
- package/src/api/routes/tests/utilities/TestFunctions.js +39 -17
- package/src/app.ts +18 -5
- package/src/automations/automationUtils.js +2 -3
- package/src/automations/steps/createRow.js +2 -5
- package/src/automations/steps/deleteRow.js +1 -4
- package/src/automations/steps/updateRow.js +1 -1
- package/src/automations/triggers.js +33 -31
- package/src/automations/utils.js +9 -5
- package/src/constants/index.js +9 -0
- package/src/db/linkedRows/LinkController.js +3 -7
- package/src/db/linkedRows/index.js +16 -31
- package/src/db/linkedRows/linkUtils.js +6 -6
- package/src/db/tests/linkController.spec.js +0 -1
- package/src/db/tests/linkTests.spec.js +5 -6
- package/src/db/views/staticViews.js +8 -10
- package/src/definitions/common.ts +3 -0
- package/src/definitions/datasource.ts +3 -0
- package/src/environment.js +4 -1
- package/src/integrations/base/sql.ts +75 -29
- package/src/integrations/googlesheets.ts +353 -0
- package/src/integrations/index.ts +3 -0
- package/src/integrations/tests/sql.spec.js +16 -0
- package/src/integrations/utils.ts +75 -12
- package/src/middleware/authorized.js +66 -30
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +50 -46
- package/src/middleware/tests/authorized.spec.js +13 -6
- package/src/middleware/tests/currentapp.spec.js +6 -0
- package/src/middleware/tests/usageQuota.spec.js +18 -24
- package/src/middleware/usageQuota.js +93 -17
- package/src/migrations/functions/appUrls.ts +34 -0
- package/src/migrations/functions/quotas1.ts +20 -0
- package/src/migrations/functions/tests/appUrls.spec.js +29 -0
- package/src/migrations/functions/tests/quotas1.spec.js +27 -0
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +25 -0
- package/src/migrations/functions/usageQuotas/index.ts +8 -0
- package/src/migrations/functions/usageQuotas/syncApps.ts +18 -0
- package/src/migrations/functions/usageQuotas/syncRows.ts +22 -0
- package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +37 -0
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +43 -0
- package/src/migrations/functions/userEmailViewCasing.ts +13 -0
- package/src/migrations/index.ts +56 -0
- package/src/module.d.ts +3 -0
- package/src/tests/utilities/TestConfiguration.js +82 -55
- package/src/threads/automation.js +17 -15
- package/src/threads/query.js +17 -12
- package/src/utilities/fileSystem/index.js +4 -3
- package/src/utilities/global.js +15 -12
- package/src/utilities/index.js +7 -17
- package/src/utilities/routing/index.js +5 -5
- package/src/utilities/rowProcessor/index.js +25 -27
- package/src/utilities/rowProcessor/utils.js +23 -7
- package/src/utilities/tests/usageQuota/usageQuota.spec.js +72 -0
- package/src/utilities/usageQuota/index.js +93 -0
- package/src/utilities/usageQuota/rows.js +75 -0
- package/src/utilities/usageQuota/usageQuoteReset.js +18 -0
- package/src/utilities/users.js +3 -3
- package/src/utilities/workerRequests.js +4 -27
- package/tsconfig.json +4 -2
- package/builder/assets/index.39e01193.css +0 -1
- package/dist/api/controllers/hosting.js +0 -30
- package/dist/api/routes/hosting.js +0 -11
- package/src/api/controllers/hosting.js +0 -22
- package/src/api/routes/hosting.js +0 -13
- package/src/api/routes/tests/hosting.spec.js +0 -36
- package/src/utilities/usageQuota.js +0 -73
|
@@ -8,7 +8,6 @@ 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");
|
|
12
11
|
const env = require("../../environment");
|
|
13
12
|
const packageJson = require("../../../package.json");
|
|
14
13
|
const { createLinkView, createRoutingView, createAllSearchIndex, } = require("../../db/views/staticViews");
|
|
@@ -18,9 +17,9 @@ const { BUILTIN_ROLE_IDS, AccessController, } = require("@budibase/backend-core/
|
|
|
18
17
|
const { BASE_LAYOUTS } = require("../../constants/layouts");
|
|
19
18
|
const { cloneDeep } = require("lodash/fp");
|
|
20
19
|
const { processObject } = require("@budibase/string-templates");
|
|
21
|
-
const { getAllApps, isDevAppID,
|
|
20
|
+
const { getAllApps, isDevAppID, getProdAppID, Replication, } = require("@budibase/backend-core/db");
|
|
22
21
|
const { USERS_TABLE_SCHEMA } = require("../../constants");
|
|
23
|
-
const {
|
|
22
|
+
const { removeAppFromUserRoles } = require("../../utilities/workerRequests");
|
|
24
23
|
const { clientLibraryPath, stringToReadStream } = require("../../utilities");
|
|
25
24
|
const { getAllLocks } = require("../../utilities/redis");
|
|
26
25
|
const { updateClientLibrary, backupClientLibrary, revertClientLibrary, } = require("../../utilities/fileSystem/clientLibrary");
|
|
@@ -28,17 +27,20 @@ const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy")
|
|
|
28
27
|
const { syncGlobalUsers } = require("./user");
|
|
29
28
|
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
30
29
|
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() {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const db = getAppDB();
|
|
35
36
|
return (yield db.allDocs(getLayoutParams(null, {
|
|
36
37
|
include_docs: true,
|
|
37
38
|
}))).rows.map(row => row.doc);
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
function getScreens(
|
|
41
|
+
function getScreens() {
|
|
41
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const db = getAppDB();
|
|
42
44
|
return (yield db.allDocs(getScreenParams(null, {
|
|
43
45
|
include_docs: true,
|
|
44
46
|
}))).rows.map(row => row.doc);
|
|
@@ -49,37 +51,49 @@ function getUserRoleId(ctx) {
|
|
|
49
51
|
? BUILTIN_ROLE_IDS.PUBLIC
|
|
50
52
|
: ctx.user.role._id;
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
54
|
+
exports.getAppUrl = ctx => {
|
|
55
|
+
// construct the url
|
|
56
|
+
let url;
|
|
57
|
+
if (ctx.request.body.url) {
|
|
58
|
+
// if the url is provided, use that
|
|
59
|
+
url = encodeURI(ctx.request.body.url);
|
|
60
|
+
}
|
|
61
|
+
else if (ctx.request.body.name) {
|
|
62
|
+
// otherwise use the name
|
|
63
|
+
url = encodeURI(`${ctx.request.body.name}`);
|
|
64
|
+
}
|
|
65
|
+
if (url) {
|
|
66
|
+
url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase();
|
|
67
|
+
}
|
|
68
|
+
return url;
|
|
69
|
+
};
|
|
70
|
+
const checkAppUrl = (ctx, apps, url, currentAppId) => {
|
|
71
|
+
if (currentAppId) {
|
|
72
|
+
apps = apps.filter(app => app.appId !== currentAppId);
|
|
73
|
+
}
|
|
74
|
+
if (apps.some(app => app.url === url)) {
|
|
75
|
+
ctx.throw(400, "App URL is already in use.");
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const checkAppName = (ctx, apps, name, currentAppId) => {
|
|
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
|
+
};
|
|
77
90
|
function createInstance(template) {
|
|
78
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
92
|
const tenantId = isMultiTenant() ? getTenantId() : null;
|
|
80
93
|
const baseAppId = generateAppID(tenantId);
|
|
81
94
|
const appId = generateDevAppID(baseAppId);
|
|
82
|
-
|
|
95
|
+
updateAppId(appId);
|
|
96
|
+
const db = getAppDB();
|
|
83
97
|
yield db.put({
|
|
84
98
|
_id: "_design/database",
|
|
85
99
|
// view collation information, read before writing any complex views:
|
|
@@ -88,9 +102,9 @@ function createInstance(template) {
|
|
|
88
102
|
});
|
|
89
103
|
// NOTE: indexes need to be created before any tables/templates
|
|
90
104
|
// add view for linked rows
|
|
91
|
-
yield createLinkView(
|
|
92
|
-
yield createRoutingView(
|
|
93
|
-
yield createAllSearchIndex(
|
|
105
|
+
yield createLinkView();
|
|
106
|
+
yield createRoutingView();
|
|
107
|
+
yield createAllSearchIndex();
|
|
94
108
|
// replicate the template data to the instance DB
|
|
95
109
|
// this is currently very hard to test, downloading and importing template files
|
|
96
110
|
if (template && template.templateString) {
|
|
@@ -116,7 +130,7 @@ function createInstance(template) {
|
|
|
116
130
|
exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
131
|
const dev = ctx.query && ctx.query.status === AppStatus.DEV;
|
|
118
132
|
const all = ctx.query && ctx.query.status === AppStatus.ALL;
|
|
119
|
-
const apps = yield getAllApps(
|
|
133
|
+
const apps = yield getAllApps({ dev, all });
|
|
120
134
|
// get the locks for all the dev apps
|
|
121
135
|
if (dev || all) {
|
|
122
136
|
const locks = yield getAllLocks();
|
|
@@ -137,11 +151,10 @@ exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
137
151
|
ctx.body = apps;
|
|
138
152
|
});
|
|
139
153
|
exports.fetchAppDefinition = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
-
const
|
|
141
|
-
const layouts = yield getLayouts(db);
|
|
154
|
+
const layouts = yield getLayouts();
|
|
142
155
|
const userRoleId = getUserRoleId(ctx);
|
|
143
|
-
const accessController = new AccessController(
|
|
144
|
-
const screens = yield accessController.checkScreensAccess(yield getScreens(
|
|
156
|
+
const accessController = new AccessController();
|
|
157
|
+
const screens = yield accessController.checkScreensAccess(yield getScreens(), userRoleId);
|
|
145
158
|
ctx.body = {
|
|
146
159
|
layouts,
|
|
147
160
|
screens,
|
|
@@ -149,14 +162,14 @@ exports.fetchAppDefinition = (ctx) => __awaiter(void 0, void 0, void 0, function
|
|
|
149
162
|
};
|
|
150
163
|
});
|
|
151
164
|
exports.fetchAppPackage = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
|
-
const db =
|
|
165
|
+
const db = getAppDB();
|
|
153
166
|
const application = yield db.get(DocumentTypes.APP_METADATA);
|
|
154
|
-
const layouts = yield getLayouts(
|
|
155
|
-
let screens = yield getScreens(
|
|
167
|
+
const layouts = yield getLayouts();
|
|
168
|
+
let screens = yield getScreens();
|
|
156
169
|
// Only filter screens if the user is not a builder
|
|
157
170
|
if (!(ctx.user.builder && ctx.user.builder.global)) {
|
|
158
171
|
const userRoleId = getUserRoleId(ctx);
|
|
159
|
-
const accessController = new AccessController(
|
|
172
|
+
const accessController = new AccessController();
|
|
160
173
|
screens = yield accessController.checkScreensAccess(screens, userRoleId);
|
|
161
174
|
}
|
|
162
175
|
ctx.body = {
|
|
@@ -167,6 +180,11 @@ exports.fetchAppPackage = (ctx) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
167
180
|
};
|
|
168
181
|
});
|
|
169
182
|
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);
|
|
170
188
|
const { useTemplate, templateKey, templateString } = ctx.request.body;
|
|
171
189
|
const instanceConfig = {
|
|
172
190
|
useTemplate,
|
|
@@ -178,8 +196,7 @@ exports.create = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
178
196
|
}
|
|
179
197
|
const instance = yield createInstance(instanceConfig);
|
|
180
198
|
const appId = instance._id;
|
|
181
|
-
const
|
|
182
|
-
const db = new CouchDB(appId);
|
|
199
|
+
const db = getAppDB();
|
|
183
200
|
let _rev;
|
|
184
201
|
try {
|
|
185
202
|
// if template there will be an existing doc
|
|
@@ -196,7 +213,7 @@ exports.create = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
196
213
|
type: "app",
|
|
197
214
|
version: packageJson.version,
|
|
198
215
|
componentLibraries: ["@budibase/standard-components"],
|
|
199
|
-
name:
|
|
216
|
+
name: name,
|
|
200
217
|
url: url,
|
|
201
218
|
template: ctx.request.body.template,
|
|
202
219
|
instance: instance,
|
|
@@ -219,14 +236,27 @@ exports.create = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
219
236
|
ctx.status = 200;
|
|
220
237
|
ctx.body = newApplication;
|
|
221
238
|
});
|
|
239
|
+
// This endpoint currently operates as a PATCH rather than a PUT
|
|
240
|
+
// Thus name and url fields are handled only if present
|
|
222
241
|
exports.update = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
223
|
-
const
|
|
242
|
+
const apps = yield getAllApps({ dev: true });
|
|
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);
|
|
224
254
|
ctx.status = 200;
|
|
225
255
|
ctx.body = data;
|
|
226
256
|
});
|
|
227
257
|
exports.updateClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
228
258
|
// Get current app version
|
|
229
|
-
const db =
|
|
259
|
+
const db = getAppDB();
|
|
230
260
|
const application = yield db.get(DocumentTypes.APP_METADATA);
|
|
231
261
|
const currentVersion = application.version;
|
|
232
262
|
// Update client library and manifest
|
|
@@ -239,13 +269,13 @@ exports.updateClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
239
269
|
version: packageJson.version,
|
|
240
270
|
revertableVersion: currentVersion,
|
|
241
271
|
};
|
|
242
|
-
const data = yield updateAppPackage(
|
|
272
|
+
const data = yield updateAppPackage(appPackageUpdates, ctx.params.appId);
|
|
243
273
|
ctx.status = 200;
|
|
244
274
|
ctx.body = data;
|
|
245
275
|
});
|
|
246
276
|
exports.revertClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
247
277
|
// Check app can be reverted
|
|
248
|
-
const db =
|
|
278
|
+
const db = getAppDB();
|
|
249
279
|
const application = yield db.get(DocumentTypes.APP_METADATA);
|
|
250
280
|
if (!application.revertableVersion) {
|
|
251
281
|
ctx.throw(400, "There is no version to revert to");
|
|
@@ -259,12 +289,12 @@ exports.revertClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
259
289
|
version: application.revertableVersion,
|
|
260
290
|
revertableVersion: null,
|
|
261
291
|
};
|
|
262
|
-
const data = yield updateAppPackage(
|
|
292
|
+
const data = yield updateAppPackage(appPackageUpdates, ctx.params.appId);
|
|
263
293
|
ctx.status = 200;
|
|
264
294
|
ctx.body = data;
|
|
265
295
|
});
|
|
266
296
|
exports.delete = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
267
|
-
const db =
|
|
297
|
+
const db = getAppDB();
|
|
268
298
|
const result = yield db.destroy();
|
|
269
299
|
/* istanbul ignore next */
|
|
270
300
|
if (!env.isTest() && !ctx.query.unpublish) {
|
|
@@ -285,9 +315,10 @@ exports.sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
285
315
|
ctx.throw(400, "This action cannot be performed for production apps");
|
|
286
316
|
}
|
|
287
317
|
// replicate prod to dev
|
|
288
|
-
const prodAppId =
|
|
318
|
+
const prodAppId = getProdAppID(appId);
|
|
289
319
|
try {
|
|
290
|
-
|
|
320
|
+
// specific case, want to make sure setup is skipped
|
|
321
|
+
const prodDb = getProdAppDB({ skip_setup: true });
|
|
291
322
|
const info = yield prodDb.info();
|
|
292
323
|
if (info.error)
|
|
293
324
|
throw info.error;
|
|
@@ -316,7 +347,7 @@ exports.sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
316
347
|
error = err;
|
|
317
348
|
}
|
|
318
349
|
// sync the users
|
|
319
|
-
yield syncGlobalUsers(
|
|
350
|
+
yield syncGlobalUsers();
|
|
320
351
|
if (error) {
|
|
321
352
|
ctx.throw(400, error);
|
|
322
353
|
}
|
|
@@ -326,11 +357,10 @@ exports.sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
326
357
|
};
|
|
327
358
|
}
|
|
328
359
|
});
|
|
329
|
-
const updateAppPackage = (
|
|
330
|
-
const
|
|
331
|
-
const db = new CouchDB(appId);
|
|
360
|
+
const updateAppPackage = (appPackage, appId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
361
|
+
const db = getAppDB();
|
|
332
362
|
const application = yield db.get(DocumentTypes.APP_METADATA);
|
|
333
|
-
const newAppPackage = Object.assign(Object.assign(
|
|
363
|
+
const newAppPackage = Object.assign(Object.assign({}, application), appPackage);
|
|
334
364
|
if (appPackage._rev !== application._rev) {
|
|
335
365
|
newAppPackage._rev = application._rev;
|
|
336
366
|
}
|
|
@@ -343,7 +373,7 @@ const updateAppPackage = (ctx, appPackage, appId) => __awaiter(void 0, void 0, v
|
|
|
343
373
|
return response;
|
|
344
374
|
});
|
|
345
375
|
const createEmptyAppPackage = (ctx, app) => __awaiter(void 0, void 0, void 0, function* () {
|
|
346
|
-
const db =
|
|
376
|
+
const db = getAppDB();
|
|
347
377
|
let screensAndLayouts = [];
|
|
348
378
|
for (let layout of BASE_LAYOUTS) {
|
|
349
379
|
const cloned = cloneDeep(layout);
|
|
@@ -8,13 +8,12 @@ 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");
|
|
12
11
|
const { outputProcessing } = require("../../utilities/rowProcessor");
|
|
13
12
|
const { InternalTables } = require("../../db/utils");
|
|
14
13
|
const { getFullUser } = require("../../utilities/users");
|
|
15
14
|
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;
|
|
18
17
|
let userId = ctx.user.userId || ctx.user._id;
|
|
19
18
|
/* istanbul ignore next */
|
|
20
19
|
if (!userId) {
|
|
@@ -24,15 +23,19 @@ exports.fetchSelf = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
24
23
|
const user = yield getFullUser(ctx, userId);
|
|
25
24
|
// this shouldn't be returned by the app self
|
|
26
25
|
delete user.roles;
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
// forward the csrf token from the session
|
|
27
|
+
user.csrfToken = ctx.user.csrfToken;
|
|
28
|
+
if (getAppId()) {
|
|
29
|
+
const db = getAppDB();
|
|
29
30
|
// remove the full roles structure
|
|
30
31
|
delete user.roles;
|
|
31
32
|
try {
|
|
32
33
|
const userTable = yield db.get(InternalTables.USER_METADATA);
|
|
33
34
|
const metadata = yield db.get(userId);
|
|
35
|
+
// make sure there is never a stale csrf token
|
|
36
|
+
delete metadata.csrfToken;
|
|
34
37
|
// specifically needs to make sure is enriched
|
|
35
|
-
ctx.body = yield outputProcessing(
|
|
38
|
+
ctx.body = yield outputProcessing(userTable, Object.assign(Object.assign({}, user), metadata));
|
|
36
39
|
}
|
|
37
40
|
catch (err) {
|
|
38
41
|
let response;
|
|
@@ -8,7 +8,6 @@ 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");
|
|
12
11
|
const actions = require("../../automations/actions");
|
|
13
12
|
const triggers = require("../../automations/triggers");
|
|
14
13
|
const { getAutomationParams, generateAutomationID } = require("../../db/utils");
|
|
@@ -16,6 +15,7 @@ const { checkForWebhooks, updateTestHistory, removeDeprecated, } = require("../.
|
|
|
16
15
|
const { deleteEntityMetadata } = require("../../utilities");
|
|
17
16
|
const { MetadataTypes } = require("../../constants");
|
|
18
17
|
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(
|
|
26
|
+
function cleanupAutomationMetadata(automationId) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
yield deleteEntityMetadata(
|
|
29
|
-
yield deleteEntityMetadata(
|
|
28
|
+
yield deleteEntityMetadata(MetadataTypes.AUTOMATION_TEST_INPUT, automationId);
|
|
29
|
+
yield deleteEntityMetadata(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 = getAppDB();
|
|
58
58
|
let automation = ctx.request.body;
|
|
59
59
|
automation.appId = ctx.appId;
|
|
60
60
|
// call through to update if already exists
|
|
@@ -65,7 +65,6 @@ exports.create = function (ctx) {
|
|
|
65
65
|
automation.type = "automation";
|
|
66
66
|
automation = cleanAutomationInputs(automation);
|
|
67
67
|
automation = yield checkForWebhooks({
|
|
68
|
-
appId: ctx.appId,
|
|
69
68
|
newAuto: automation,
|
|
70
69
|
});
|
|
71
70
|
const response = yield db.put(automation);
|
|
@@ -79,13 +78,12 @@ exports.create = function (ctx) {
|
|
|
79
78
|
};
|
|
80
79
|
exports.update = function (ctx) {
|
|
81
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const db =
|
|
81
|
+
const db = getAppDB();
|
|
83
82
|
let automation = ctx.request.body;
|
|
84
83
|
automation.appId = ctx.appId;
|
|
85
84
|
const oldAutomation = yield db.get(automation._id);
|
|
86
85
|
automation = cleanAutomationInputs(automation);
|
|
87
86
|
automation = yield checkForWebhooks({
|
|
88
|
-
appId: ctx.appId,
|
|
89
87
|
oldAuto: oldAutomation,
|
|
90
88
|
newAuto: automation,
|
|
91
89
|
});
|
|
@@ -110,7 +108,7 @@ exports.update = function (ctx) {
|
|
|
110
108
|
};
|
|
111
109
|
exports.fetch = function (ctx) {
|
|
112
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
const db =
|
|
111
|
+
const db = getAppDB();
|
|
114
112
|
const response = yield db.allDocs(getAutomationParams(null, {
|
|
115
113
|
include_docs: true,
|
|
116
114
|
}));
|
|
@@ -119,21 +117,20 @@ exports.fetch = function (ctx) {
|
|
|
119
117
|
};
|
|
120
118
|
exports.find = function (ctx) {
|
|
121
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
const db =
|
|
120
|
+
const db = getAppDB();
|
|
123
121
|
ctx.body = yield db.get(ctx.params.id);
|
|
124
122
|
});
|
|
125
123
|
};
|
|
126
124
|
exports.destroy = function (ctx) {
|
|
127
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
const db =
|
|
126
|
+
const db = getAppDB();
|
|
129
127
|
const automationId = ctx.params.id;
|
|
130
128
|
const oldAutomation = yield db.get(automationId);
|
|
131
129
|
yield checkForWebhooks({
|
|
132
|
-
appId: ctx.appId,
|
|
133
130
|
oldAuto: oldAutomation,
|
|
134
131
|
});
|
|
135
132
|
// delete metadata first
|
|
136
|
-
yield cleanupAutomationMetadata(
|
|
133
|
+
yield cleanupAutomationMetadata(automationId);
|
|
137
134
|
ctx.body = yield db.remove(automationId, ctx.params.rev);
|
|
138
135
|
});
|
|
139
136
|
};
|
|
@@ -162,10 +159,9 @@ module.exports.getDefinitionList = function (ctx) {
|
|
|
162
159
|
*********************/
|
|
163
160
|
exports.trigger = function (ctx) {
|
|
164
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
-
const
|
|
166
|
-
const db = new CouchDB(appId);
|
|
162
|
+
const db = getAppDB();
|
|
167
163
|
let automation = yield db.get(ctx.params.id);
|
|
168
|
-
yield triggers.externalTrigger(automation, Object.assign(Object.assign({}, ctx.request.body), { appId }));
|
|
164
|
+
yield triggers.externalTrigger(automation, Object.assign(Object.assign({}, ctx.request.body), { appId: ctx.appId }));
|
|
169
165
|
ctx.body = {
|
|
170
166
|
message: `Automation ${automation._id} has been triggered.`,
|
|
171
167
|
automation,
|
|
@@ -184,12 +180,11 @@ function prepareTestInput(input) {
|
|
|
184
180
|
}
|
|
185
181
|
exports.test = function (ctx) {
|
|
186
182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
const
|
|
188
|
-
const db = new CouchDB(appId);
|
|
183
|
+
const db = getAppDB();
|
|
189
184
|
let automation = yield db.get(ctx.params.id);
|
|
190
185
|
yield setTestFlag(automation._id);
|
|
191
186
|
const testInput = prepareTestInput(ctx.request.body);
|
|
192
|
-
const response = yield triggers.externalTrigger(automation, Object.assign(Object.assign({}, testInput), { appId }), { getResponses: true });
|
|
187
|
+
const response = yield triggers.externalTrigger(automation, Object.assign(Object.assign({}, testInput), { appId: ctx.appId }), { getResponses: true });
|
|
193
188
|
// save a test history run
|
|
194
189
|
yield updateTestHistory(ctx.appId, automation, Object.assign(Object.assign({}, ctx.request.body), { occurredAt: new Date().getTime() }));
|
|
195
190
|
yield clearTestFlag(automation._id);
|
|
@@ -10,7 +10,6 @@ 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");
|
|
14
13
|
const { exportDB, sendTempFile, readFileSync, } = require("../../utilities/fileSystem");
|
|
15
14
|
const { stringToReadStream } = require("../../utilities");
|
|
16
15
|
const { getGlobalDBName, getGlobalDB, } = require("@budibase/backend-core/tenancy");
|
|
@@ -33,7 +32,7 @@ exports.exportApps = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
33
32
|
if (env.SELF_HOSTED || !env.MULTI_TENANCY) {
|
|
34
33
|
ctx.throw(400, "Exporting only allowed in multi-tenant cloud environments.");
|
|
35
34
|
}
|
|
36
|
-
const apps = yield getAllApps(
|
|
35
|
+
const apps = yield getAllApps({ all: true });
|
|
37
36
|
const globalDBString = yield exportDB(getGlobalDBName(), {
|
|
38
37
|
filter: doc => !doc._id.startsWith(DocumentTypes.USER),
|
|
39
38
|
});
|
|
@@ -65,7 +64,7 @@ function hasBeenImported() {
|
|
|
65
64
|
if (!env.SELF_HOSTED || env.MULTI_TENANCY) {
|
|
66
65
|
return true;
|
|
67
66
|
}
|
|
68
|
-
const apps = yield getAllApps(
|
|
67
|
+
const apps = yield getAllApps({ all: true });
|
|
69
68
|
return apps.length !== 0;
|
|
70
69
|
});
|
|
71
70
|
}
|
|
@@ -8,16 +8,15 @@ 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");
|
|
12
11
|
const { DocumentTypes } = require("../../db/utils");
|
|
13
12
|
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
|
|
17
|
-
const db = new CouchDB(appId);
|
|
16
|
+
const db = getAppDB();
|
|
18
17
|
const app = yield db.get(DocumentTypes.APP_METADATA);
|
|
19
18
|
let componentManifests = yield Promise.all(app.componentLibraries.map((library) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
let manifest = yield getComponentLibraryManifest(
|
|
19
|
+
let manifest = yield getComponentLibraryManifest(library);
|
|
21
20
|
return {
|
|
22
21
|
manifest,
|
|
23
22
|
library,
|
|
@@ -8,32 +8,37 @@ 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");
|
|
12
11
|
const { generateDatasourceID, getDatasourceParams, getQueryParams, DocumentTypes, BudibaseInternalDB, getTableParams, } = require("../../db/utils");
|
|
13
12
|
const { BuildSchemaErrors, InvalidColumns } = require("../../constants");
|
|
14
13
|
const { integrations } = require("../../integrations");
|
|
15
14
|
const { getDatasourceAndQuery } = require("./row/utils");
|
|
16
15
|
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);
|
|
20
19
|
// Get internal tables
|
|
21
|
-
const db =
|
|
20
|
+
const db = getAppDB();
|
|
22
21
|
const internalTables = yield db.allDocs(getTableParams(null, {
|
|
23
22
|
include_docs: true,
|
|
24
23
|
}));
|
|
25
24
|
const internal = internalTables.rows.map(row => row.doc);
|
|
26
25
|
const bbInternalDb = Object.assign(Object.assign({}, BudibaseInternalDB), { entities: internal });
|
|
27
26
|
// Get external datasources
|
|
28
|
-
const datasources = (yield
|
|
27
|
+
const datasources = (yield db.allDocs(getDatasourceParams(null, {
|
|
29
28
|
include_docs: true,
|
|
30
29
|
}))).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
|
+
}
|
|
31
36
|
ctx.body = [bbInternalDb, ...datasources];
|
|
32
37
|
});
|
|
33
38
|
};
|
|
34
39
|
exports.buildSchemaFromDb = function (ctx) {
|
|
35
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const db =
|
|
41
|
+
const db = getAppDB();
|
|
37
42
|
const datasource = yield db.get(ctx.params.datasourceId);
|
|
38
43
|
const { tables, error } = yield buildSchemaHelper(datasource);
|
|
39
44
|
datasource.entities = tables;
|
|
@@ -75,11 +80,16 @@ const invalidateVariables = (existingDatasource, updatedDatasource) => __awaiter
|
|
|
75
80
|
});
|
|
76
81
|
exports.update = function (ctx) {
|
|
77
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
const db =
|
|
83
|
+
const db = getAppDB();
|
|
79
84
|
const datasourceId = ctx.params.datasourceId;
|
|
80
85
|
let datasource = yield db.get(datasourceId);
|
|
86
|
+
const auth = datasource.config.auth;
|
|
81
87
|
yield invalidateVariables(datasource, ctx.request.body);
|
|
82
88
|
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
|
+
}
|
|
83
93
|
const response = yield db.put(datasource);
|
|
84
94
|
datasource._rev = response.rev;
|
|
85
95
|
// Drain connection pools when configuration is changed
|
|
@@ -96,7 +106,7 @@ exports.update = function (ctx) {
|
|
|
96
106
|
};
|
|
97
107
|
exports.save = function (ctx) {
|
|
98
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
const db =
|
|
109
|
+
const db = getAppDB();
|
|
100
110
|
const plus = ctx.request.body.datasource.plus;
|
|
101
111
|
const fetchSchema = ctx.request.body.fetchSchema;
|
|
102
112
|
const datasource = Object.assign({ _id: generateDatasourceID({ plus }), type: plus ? DocumentTypes.DATASOURCE_PLUS : DocumentTypes.DATASOURCE }, ctx.request.body.datasource);
|
|
@@ -124,7 +134,7 @@ exports.save = function (ctx) {
|
|
|
124
134
|
};
|
|
125
135
|
exports.destroy = function (ctx) {
|
|
126
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
const db =
|
|
137
|
+
const db = getAppDB();
|
|
128
138
|
// Delete all queries for the datasource
|
|
129
139
|
const queries = yield db.allDocs(getQueryParams(ctx.params.datasourceId, null));
|
|
130
140
|
yield db.bulkDocs(queries.rows.map(row => ({
|
|
@@ -140,7 +150,7 @@ exports.destroy = function (ctx) {
|
|
|
140
150
|
};
|
|
141
151
|
exports.find = function (ctx) {
|
|
142
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
const database =
|
|
153
|
+
const database = getAppDB();
|
|
144
154
|
ctx.body = yield database.get(ctx.params.datasourceId);
|
|
145
155
|
});
|
|
146
156
|
};
|
|
@@ -149,7 +159,7 @@ exports.query = function (ctx) {
|
|
|
149
159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
160
|
const queryJson = ctx.request.body;
|
|
151
161
|
try {
|
|
152
|
-
ctx.body = yield getDatasourceAndQuery(
|
|
162
|
+
ctx.body = yield getDatasourceAndQuery(queryJson);
|
|
153
163
|
}
|
|
154
164
|
catch (err) {
|
|
155
165
|
ctx.throw(400, err);
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const newid = require("../../../db/newid");
|
|
3
|
+
const { getAppId } = require("@budibase/backend-core/context");
|
|
3
4
|
/**
|
|
4
5
|
* This is used to pass around information about the deployment that is occurring
|
|
5
6
|
*/
|
|
6
7
|
class Deployment {
|
|
7
|
-
constructor(
|
|
8
|
-
this.appId = appId;
|
|
8
|
+
constructor(id = null) {
|
|
9
9
|
this._id = id || newid();
|
|
10
10
|
}
|
|
11
|
-
getAppId() {
|
|
12
|
-
return this.appId;
|
|
13
|
-
}
|
|
14
11
|
setVerification(verification) {
|
|
15
12
|
if (!verification) {
|
|
16
13
|
return;
|
|
@@ -37,7 +34,7 @@ class Deployment {
|
|
|
37
34
|
getJSON() {
|
|
38
35
|
const obj = {
|
|
39
36
|
_id: this._id,
|
|
40
|
-
appId:
|
|
37
|
+
appId: getAppId(),
|
|
41
38
|
status: this.status,
|
|
42
39
|
};
|
|
43
40
|
if (this.err) {
|