@budibase/server 1.0.49-alpha.6 → 1.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/arangojs.ts +1 -1
- package/__mocks__/aws-sdk.ts +4 -4
- package/__mocks__/mongodb.ts +5 -4
- package/__mocks__/mssql.ts +3 -3
- package/__mocks__/node-fetch.ts +1 -2
- package/__mocks__/pg.ts +5 -3
- package/builder/assets/{index.1b905242.js → index.2c37968e.js} +231 -234
- package/builder/assets/index.39e01193.css +1 -0
- package/builder/assets/{vendor.d526bfe8.js → vendor.f9faf6ab.js} +12 -12
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2816 -3119
- package/coverage/coverage-final.json +101 -106
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.js.html +152 -257
- package/coverage/lcov-report/api/controllers/auth.js.html +13 -22
- package/coverage/lcov-report/api/controllers/automation.js.html +69 -39
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -8
- package/coverage/lcov-report/api/controllers/component.js.html +16 -13
- package/coverage/lcov-report/api/controllers/datasource.js.html +51 -81
- package/coverage/lcov-report/api/controllers/dev.js.html +6 -6
- package/coverage/lcov-report/{utilities/usageQuota/usageQuoteReset.js.html → api/controllers/hosting.js.html} +48 -36
- package/coverage/lcov-report/api/controllers/index.html +76 -76
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +9 -9
- package/coverage/lcov-report/api/controllers/metadata.js.html +21 -6
- package/coverage/lcov-report/api/controllers/permission.js.html +19 -19
- package/coverage/lcov-report/api/controllers/query/index.html +10 -10
- package/coverage/lcov-report/api/controllers/query/index.js.html +35 -38
- package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -6
- package/coverage/lcov-report/api/controllers/role.js.html +16 -16
- package/coverage/lcov-report/api/controllers/routing.js.html +10 -7
- package/coverage/lcov-report/api/controllers/row/external.js.html +27 -21
- package/coverage/lcov-report/api/controllers/row/index.html +34 -49
- package/coverage/lcov-report/api/controllers/row/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/row/internal.js.html +226 -118
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +34 -52
- package/coverage/lcov-report/api/controllers/row/utils.js.html +62 -47
- package/coverage/lcov-report/api/controllers/screen.js.html +21 -15
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/external.js.html +34 -25
- package/coverage/lcov-report/api/controllers/table/index.html +43 -58
- package/coverage/lcov-report/api/controllers/table/index.js.html +82 -58
- package/coverage/lcov-report/api/controllers/table/internal.js.html +66 -81
- package/coverage/lcov-report/api/controllers/table/utils.js.html +110 -218
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +50 -47
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +16 -16
- package/coverage/lcov-report/api/controllers/view/index.js.html +33 -27
- package/coverage/lcov-report/api/controllers/view/utils.js.html +20 -35
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +28 -34
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +8 -8
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/application.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/{migrations.js.html → hosting.js.html} +14 -17
- package/coverage/lcov-report/api/routes/index.html +18 -18
- package/coverage/lcov-report/api/routes/index.js.html +3 -3
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/row.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +2 -17
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +10 -7
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +18 -18
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +22 -13
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +20 -11
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +13 -13
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +55 -61
- package/coverage/lcov-report/automations/utils.js.html +42 -54
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +26 -53
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +37 -25
- package/coverage/lcov-report/db/linkedRows/index.html +27 -27
- package/coverage/lcov-report/db/linkedRows/index.js.html +96 -51
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +42 -42
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +87 -87
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +5 -5
- package/coverage/lcov-report/events/utils.js.html +3 -3
- package/coverage/lcov-report/index.html +120 -135
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/authorized.js.html +65 -173
- package/coverage/lcov-report/middleware/builder.js.html +10 -10
- package/coverage/lcov-report/middleware/currentapp.js.html +83 -95
- package/coverage/lcov-report/middleware/index.html +38 -38
- package/coverage/lcov-report/middleware/joi-validator.js.html +3 -3
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +53 -281
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +24 -30
- package/coverage/lcov-report/threads/index.html +26 -26
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +26 -62
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +49 -58
- package/coverage/lcov-report/utilities/index.html +37 -37
- package/coverage/lcov-report/utilities/index.js.html +73 -43
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +8 -8
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +7 -7
- package/coverage/lcov-report/utilities/rowProcessor/index.html +27 -27
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +103 -97
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +27 -75
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +9 -9
- package/coverage/lcov-report/utilities/workerRequests.js.html +112 -43
- package/coverage/lcov.info +4423 -5022
- package/dist/api/controllers/application.js +60 -90
- package/dist/api/controllers/auth.js +5 -8
- package/dist/api/controllers/automation.js +19 -14
- package/dist/api/controllers/cloud.js +3 -2
- package/dist/api/controllers/component.js +4 -3
- package/dist/api/controllers/datasource.js +10 -20
- package/dist/api/controllers/deploy/Deployment.js +6 -3
- package/dist/api/controllers/deploy/index.js +13 -12
- package/dist/api/controllers/dev.js +5 -5
- package/dist/api/controllers/hosting.js +30 -0
- package/dist/api/controllers/layout.js +3 -3
- package/dist/api/controllers/metadata.js +4 -4
- package/dist/api/controllers/permission.js +4 -4
- package/dist/api/controllers/query/import/index.js +6 -4
- package/dist/api/controllers/query/index.js +10 -11
- package/dist/api/controllers/role.js +5 -5
- package/dist/api/controllers/routing.js +6 -5
- package/dist/api/controllers/row/ExternalRequest.js +63 -76
- package/dist/api/controllers/row/external.js +4 -4
- package/dist/api/controllers/row/internal.js +93 -55
- package/dist/api/controllers/row/internalSearch.js +17 -23
- package/dist/api/controllers/row/utils.js +14 -13
- package/dist/api/controllers/screen.js +7 -5
- package/dist/api/controllers/static/index.js +12 -61
- package/dist/api/controllers/table/external.js +10 -7
- package/dist/api/controllers/table/index.js +13 -16
- package/dist/api/controllers/table/internal.js +16 -22
- package/dist/api/controllers/table/utils.js +35 -62
- package/dist/api/controllers/user.js +20 -18
- package/dist/api/controllers/view/index.js +10 -8
- package/dist/api/controllers/view/utils.js +4 -9
- package/dist/api/controllers/webhook.js +8 -10
- package/dist/api/routes/hosting.js +11 -0
- package/dist/api/routes/index.js +2 -2
- package/dist/api/routes/static.js +1 -2
- package/dist/api/routes/tests/utilities/TestFunctions.js +17 -37
- package/dist/app.js +5 -35
- package/dist/automations/automationUtils.js +3 -2
- package/dist/automations/steps/createRow.js +5 -3
- package/dist/automations/steps/deleteRow.js +4 -1
- package/dist/automations/steps/updateRow.js +1 -1
- package/dist/automations/triggers.js +25 -27
- package/dist/automations/utils.js +5 -10
- package/dist/constants/index.js +0 -7
- package/dist/db/linkedRows/LinkController.js +7 -3
- package/dist/db/linkedRows/index.js +27 -16
- package/dist/db/linkedRows/linkUtils.js +6 -6
- package/dist/db/views/staticViews.js +10 -9
- package/dist/definitions/datasource.js +0 -1
- package/dist/environment.js +1 -4
- package/dist/integrations/base/sql.js +6 -13
- package/dist/integrations/index.js +0 -3
- package/dist/integrations/utils.js +9 -60
- package/dist/middleware/authorized.js +30 -57
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +37 -41
- package/dist/middleware/usageQuota.js +15 -82
- package/dist/package.json +5 -8
- package/dist/tests/utilities/TestConfiguration.js +50 -80
- package/dist/threads/automation.js +11 -13
- package/dist/threads/query.js +13 -23
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +3 -4
- package/dist/utilities/global.js +12 -15
- package/dist/utilities/index.js +17 -7
- package/dist/utilities/routing/index.js +5 -5
- package/dist/utilities/rowProcessor/index.js +17 -23
- package/dist/utilities/rowProcessor/utils.js +4 -14
- package/dist/utilities/{usageQuota/index.js → usageQuota.js} +31 -45
- package/dist/utilities/users.js +3 -3
- package/dist/utilities/workerRequests.js +24 -4
- package/nodemon.json +1 -1
- package/package.json +6 -9
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/application.js +50 -85
- package/src/api/controllers/auth.js +5 -8
- package/src/api/controllers/automation.js +23 -13
- package/src/api/controllers/cloud.js +3 -2
- package/src/api/controllers/component.js +4 -3
- package/src/api/controllers/datasource.js +11 -21
- package/src/api/controllers/deploy/Deployment.js +7 -3
- package/src/api/controllers/deploy/index.js +13 -20
- package/src/api/controllers/dev.js +5 -5
- package/src/api/controllers/hosting.js +22 -0
- package/src/api/controllers/layout.js +3 -3
- package/src/api/controllers/metadata.js +9 -4
- package/src/api/controllers/permission.js +4 -4
- package/src/api/controllers/query/import/index.ts +6 -4
- package/src/api/controllers/query/import/tests/index.spec.js +1 -2
- package/src/api/controllers/query/index.js +10 -11
- package/src/api/controllers/role.js +5 -5
- package/src/api/controllers/routing.js +6 -5
- package/src/api/controllers/row/ExternalRequest.ts +42 -53
- package/src/api/controllers/row/external.js +6 -4
- package/src/api/controllers/row/internal.js +90 -54
- package/src/api/controllers/row/internalSearch.js +17 -23
- package/src/api/controllers/row/utils.js +18 -13
- package/src/api/controllers/screen.js +7 -5
- package/src/api/controllers/static/index.js +12 -65
- package/src/api/controllers/table/external.js +10 -7
- package/src/api/controllers/table/index.js +28 -20
- package/src/api/controllers/table/internal.js +19 -24
- package/src/api/controllers/table/utils.js +42 -78
- package/src/api/controllers/user.js +20 -19
- package/src/api/controllers/view/index.js +10 -8
- package/src/api/controllers/view/utils.js +4 -9
- package/src/api/controllers/webhook.js +8 -10
- package/src/api/routes/hosting.js +13 -0
- package/src/api/routes/index.js +2 -2
- package/src/api/routes/static.js +0 -5
- package/src/api/routes/tests/application.spec.js +2 -2
- package/src/api/routes/tests/auth.spec.js +2 -1
- package/src/api/routes/tests/automation.spec.js +0 -1
- package/src/api/routes/tests/hosting.spec.js +36 -0
- package/src/api/routes/tests/misc.spec.js +1 -0
- package/src/api/routes/tests/routing.spec.js +12 -21
- package/src/api/routes/tests/row.spec.js +4 -7
- package/src/api/routes/tests/utilities/TestFunctions.js +17 -39
- package/src/app.ts +5 -18
- package/src/automations/automationUtils.js +3 -2
- package/src/automations/steps/createRow.js +5 -2
- package/src/automations/steps/deleteRow.js +4 -1
- package/src/automations/steps/updateRow.js +1 -1
- package/src/automations/triggers.js +31 -33
- package/src/automations/utils.js +5 -9
- package/src/constants/index.js +0 -9
- package/src/db/linkedRows/LinkController.js +7 -3
- package/src/db/linkedRows/index.js +31 -16
- package/src/db/linkedRows/linkUtils.js +6 -6
- package/src/db/tests/linkController.spec.js +1 -0
- package/src/db/tests/linkTests.spec.js +6 -5
- package/src/db/views/staticViews.js +10 -8
- package/src/definitions/common.ts +0 -3
- package/src/definitions/datasource.ts +0 -3
- package/src/environment.js +1 -4
- package/src/integrations/base/sql.ts +7 -14
- package/src/integrations/index.ts +0 -3
- package/src/integrations/tests/sql.spec.js +0 -16
- package/src/integrations/utils.ts +12 -75
- package/src/middleware/authorized.js +30 -66
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +46 -50
- package/src/middleware/tests/authorized.spec.js +6 -13
- package/src/middleware/tests/currentapp.spec.js +0 -6
- package/src/middleware/tests/usageQuota.spec.js +24 -18
- package/src/middleware/usageQuota.js +17 -93
- package/src/tests/utilities/TestConfiguration.js +55 -82
- package/src/threads/automation.js +15 -17
- package/src/threads/query.js +14 -26
- package/src/utilities/fileSystem/index.js +3 -4
- package/src/utilities/global.js +12 -15
- package/src/utilities/index.js +17 -7
- package/src/utilities/routing/index.js +5 -5
- package/src/utilities/rowProcessor/index.js +27 -25
- package/src/utilities/rowProcessor/utils.js +7 -23
- package/src/utilities/usageQuota.js +73 -0
- package/src/utilities/users.js +3 -3
- package/src/utilities/workerRequests.js +27 -4
- package/builder/assets/index.83c0944f.css +0 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +0 -119
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +0 -548
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +0 -599
- package/coverage/lcov-report/utilities/usageQuota/index.html +0 -141
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +0 -359
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +0 -305
- package/dist/api/controllers/migrations.js +0 -21
- package/dist/api/controllers/row/staticFormula.js +0 -147
- package/dist/api/controllers/table/bulkFormula.js +0 -159
- package/dist/api/routes/migrations.js +0 -9
- package/dist/integrations/googlesheets.js +0 -340
- package/dist/migrations/functions/appUrls.js +0 -46
- package/dist/migrations/functions/quotas1.js +0 -50
- package/dist/migrations/functions/usageQuotas/index.js +0 -20
- package/dist/migrations/functions/usageQuotas/syncApps.js +0 -30
- package/dist/migrations/functions/usageQuotas/syncRows.js +0 -33
- package/dist/migrations/functions/userEmailViewCasing.js +0 -24
- package/dist/migrations/index.js +0 -62
- package/dist/utilities/usageQuota/rows.js +0 -78
- package/dist/utilities/usageQuota/usageQuoteReset.js +0 -16
- package/src/api/controllers/migrations.js +0 -13
- package/src/api/controllers/row/staticFormula.js +0 -156
- package/src/api/controllers/table/bulkFormula.js +0 -173
- package/src/api/routes/migrations.js +0 -14
- package/src/api/routes/tests/static.spec.js +0 -98
- package/src/integrations/googlesheets.ts +0 -353
- package/src/migrations/functions/appUrls.ts +0 -34
- package/src/migrations/functions/quotas1.ts +0 -20
- package/src/migrations/functions/tests/appUrls.spec.js +0 -29
- package/src/migrations/functions/tests/quotas1.spec.js +0 -27
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +0 -25
- package/src/migrations/functions/usageQuotas/index.ts +0 -8
- package/src/migrations/functions/usageQuotas/syncApps.ts +0 -19
- package/src/migrations/functions/usageQuotas/syncRows.ts +0 -22
- package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +0 -37
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +0 -43
- package/src/migrations/functions/userEmailViewCasing.ts +0 -13
- package/src/migrations/index.ts +0 -56
- package/src/utilities/tests/usageQuota/usageQuota.spec.js +0 -72
- package/src/utilities/usageQuota/index.js +0 -93
- package/src/utilities/usageQuota/rows.js +0 -75
- package/src/utilities/usageQuota/usageQuoteReset.js +0 -18
|
@@ -16,9 +16,9 @@ const { generateUserMetadataID, isDevAppID } = require("../db/utils");
|
|
|
16
16
|
const { dbExists } = require("@budibase/backend-core/db");
|
|
17
17
|
const { isUserInAppTenant } = require("@budibase/backend-core/tenancy");
|
|
18
18
|
const { getCachedSelf } = require("../utilities/global");
|
|
19
|
+
const CouchDB = require("../db");
|
|
19
20
|
const env = require("../environment");
|
|
20
21
|
const { isWebhookEndpoint } = require("./utils");
|
|
21
|
-
const { doInAppContext } = require("@budibase/backend-core/context");
|
|
22
22
|
module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
23
|
// try to get the appID from the request
|
|
24
24
|
let requestAppId = getAppId(ctx);
|
|
@@ -36,7 +36,7 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
36
36
|
// check the app exists referenced in cookie
|
|
37
37
|
if (appCookie) {
|
|
38
38
|
const appId = appCookie.appId;
|
|
39
|
-
const exists = yield dbExists(appId);
|
|
39
|
+
const exists = yield dbExists(CouchDB, appId);
|
|
40
40
|
if (!exists) {
|
|
41
41
|
clearCookie(ctx, Cookies.CurrentApp);
|
|
42
42
|
return next();
|
|
@@ -45,13 +45,11 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
45
45
|
requestAppId = requestAppId || appId;
|
|
46
46
|
}
|
|
47
47
|
// deny access to application preview
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return ctx.redirect("/");
|
|
54
|
-
}
|
|
48
|
+
if (isDevAppID(requestAppId) &&
|
|
49
|
+
!isWebhookEndpoint(ctx) &&
|
|
50
|
+
(!ctx.user || !ctx.user.builder || !ctx.user.builder.global)) {
|
|
51
|
+
clearCookie(ctx, Cookies.CurrentApp);
|
|
52
|
+
return ctx.redirect("/");
|
|
55
53
|
}
|
|
56
54
|
let appId, roleId = BUILTIN_ROLE_IDS.PUBLIC;
|
|
57
55
|
if (!ctx.user) {
|
|
@@ -69,36 +67,34 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
69
67
|
if (!appId) {
|
|
70
68
|
return next();
|
|
71
69
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return next();
|
|
103
|
-
}));
|
|
70
|
+
let noCookieSet = false;
|
|
71
|
+
// if the user not in the right tenant then make sure they have no permissions
|
|
72
|
+
// need to judge this only based on the request app ID,
|
|
73
|
+
if (env.MULTI_TENANCY &&
|
|
74
|
+
ctx.user &&
|
|
75
|
+
requestAppId &&
|
|
76
|
+
!isUserInAppTenant(requestAppId)) {
|
|
77
|
+
// don't error, simply remove the users rights (they are a public user)
|
|
78
|
+
delete ctx.user.builder;
|
|
79
|
+
delete ctx.user.admin;
|
|
80
|
+
delete ctx.user.roles;
|
|
81
|
+
roleId = BUILTIN_ROLE_IDS.PUBLIC;
|
|
82
|
+
noCookieSet = true;
|
|
83
|
+
}
|
|
84
|
+
ctx.appId = appId;
|
|
85
|
+
if (roleId) {
|
|
86
|
+
ctx.roleId = roleId;
|
|
87
|
+
const userId = ctx.user ? generateUserMetadataID(ctx.user._id) : null;
|
|
88
|
+
ctx.user = Object.assign(Object.assign({}, ctx.user), {
|
|
89
|
+
// override userID with metadata one
|
|
90
|
+
_id: userId, userId,
|
|
91
|
+
roleId, role: yield getRole(appId, roleId) });
|
|
92
|
+
}
|
|
93
|
+
if ((requestAppId !== appId ||
|
|
94
|
+
appCookie == null ||
|
|
95
|
+
appCookie.appId !== requestAppId) &&
|
|
96
|
+
!noCookieSet) {
|
|
97
|
+
setCookie(ctx, { appId }, Cookies.CurrentApp);
|
|
98
|
+
}
|
|
99
|
+
return next();
|
|
104
100
|
});
|
|
@@ -8,10 +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 usageQuota = require("../utilities/usageQuota");
|
|
12
|
-
const
|
|
13
|
+
const env = require("../environment");
|
|
14
|
+
const { getTenantId } = require("@budibase/backend-core/tenancy");
|
|
13
15
|
const { isExternalTable, isRowId: isExternalRowId, } = require("../integrations/utils");
|
|
14
|
-
|
|
16
|
+
// tenants without limits
|
|
17
|
+
const EXCLUDED_TENANTS = ["bb", "default", "bbtest", "bbstaging"];
|
|
15
18
|
// currently only counting new writes and deletes
|
|
16
19
|
const METHOD_MAP = {
|
|
17
20
|
POST: 1,
|
|
@@ -19,13 +22,13 @@ const METHOD_MAP = {
|
|
|
19
22
|
};
|
|
20
23
|
const DOMAIN_MAP = {
|
|
21
24
|
rows: usageQuota.Properties.ROW,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
upload: usageQuota.Properties.UPLOAD,
|
|
26
|
+
views: usageQuota.Properties.VIEW,
|
|
27
|
+
users: usageQuota.Properties.USER,
|
|
25
28
|
applications: usageQuota.Properties.APPS,
|
|
26
29
|
// this will not be updated by endpoint calls
|
|
27
30
|
// instead it will be updated by triggerInfo
|
|
28
|
-
|
|
31
|
+
automationRuns: usageQuota.Properties.AUTOMATION,
|
|
29
32
|
};
|
|
30
33
|
function getProperty(url) {
|
|
31
34
|
for (let domain of Object.keys(DOMAIN_MAP)) {
|
|
@@ -35,7 +38,9 @@ function getProperty(url) {
|
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
|
|
41
|
+
const tenantId = getTenantId();
|
|
42
|
+
// if in development or a self hosted cloud usage quotas should not be executed
|
|
43
|
+
if (env.isDev() || env.SELF_HOSTED || EXCLUDED_TENANTS.includes(tenantId)) {
|
|
39
44
|
return next();
|
|
40
45
|
}
|
|
41
46
|
let usage = METHOD_MAP[ctx.req.method];
|
|
@@ -48,7 +53,7 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
48
53
|
const usageId = ctx.request.body._id;
|
|
49
54
|
try {
|
|
50
55
|
if (ctx.appId) {
|
|
51
|
-
const db =
|
|
56
|
+
const db = new CouchDB(ctx.appId);
|
|
52
57
|
yield db.get(usageId);
|
|
53
58
|
}
|
|
54
59
|
return next();
|
|
@@ -73,82 +78,10 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
73
78
|
usage = files.map(file => file.size).reduce((total, size) => total + size);
|
|
74
79
|
}
|
|
75
80
|
try {
|
|
76
|
-
yield
|
|
81
|
+
yield usageQuota.update(property, usage);
|
|
82
|
+
return next();
|
|
77
83
|
}
|
|
78
84
|
catch (err) {
|
|
79
85
|
ctx.throw(400, err);
|
|
80
86
|
}
|
|
81
87
|
});
|
|
82
|
-
const performRequest = (ctx, next, property, usage) => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
-
const usageContext = {
|
|
84
|
-
skipNext: false,
|
|
85
|
-
skipUsage: false,
|
|
86
|
-
[usageQuota.Properties.APPS]: {},
|
|
87
|
-
};
|
|
88
|
-
if (usage === -1) {
|
|
89
|
-
if (PRE_DELETE[property]) {
|
|
90
|
-
yield PRE_DELETE[property](ctx, usageContext);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
if (PRE_CREATE[property]) {
|
|
95
|
-
yield PRE_CREATE[property](ctx, usageContext);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// run the request
|
|
99
|
-
if (!usageContext.skipNext) {
|
|
100
|
-
yield usageQuota.update(property, usage, { dryRun: true });
|
|
101
|
-
yield next();
|
|
102
|
-
}
|
|
103
|
-
if (usage === -1) {
|
|
104
|
-
if (POST_DELETE[property]) {
|
|
105
|
-
yield POST_DELETE[property](ctx, usageContext);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
if (POST_CREATE[property]) {
|
|
110
|
-
yield POST_CREATE[property](ctx, usageContext);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
// update the usage
|
|
114
|
-
if (!usageContext.skipUsage) {
|
|
115
|
-
yield usageQuota.update(property, usage);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
const appPreDelete = (ctx, usageContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
-
if (ctx.query.unpublish) {
|
|
120
|
-
// don't run usage decrement for unpublish
|
|
121
|
-
usageContext.skipUsage = true;
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
// store the row count to delete
|
|
125
|
-
const rows = yield getUniqueRows([ctx.appId]);
|
|
126
|
-
if (rows.length) {
|
|
127
|
-
usageContext[usageQuota.Properties.APPS] = { rowCount: rows.length };
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
const appPostDelete = (ctx, usageContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
|
-
// delete the app rows from usage
|
|
132
|
-
const rowCount = usageContext[usageQuota.Properties.APPS].rowCount;
|
|
133
|
-
if (rowCount) {
|
|
134
|
-
yield usageQuota.update(usageQuota.Properties.ROW, -rowCount);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
const appPostCreate = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
-
// app import & template creation
|
|
139
|
-
if (ctx.request.body.useTemplate === "true") {
|
|
140
|
-
const rows = yield getUniqueRows([ctx.response.body.appId]);
|
|
141
|
-
const rowCount = rows ? rows.length : 0;
|
|
142
|
-
yield usageQuota.update(usageQuota.Properties.ROW, rowCount);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
const PRE_DELETE = {
|
|
146
|
-
[usageQuota.Properties.APPS]: appPreDelete,
|
|
147
|
-
};
|
|
148
|
-
const POST_DELETE = {
|
|
149
|
-
[usageQuota.Properties.APPS]: appPostDelete,
|
|
150
|
-
};
|
|
151
|
-
const PRE_CREATE = {};
|
|
152
|
-
const POST_CREATE = {
|
|
153
|
-
[usageQuota.Properties.APPS]: appPostCreate,
|
|
154
|
-
};
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.48",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"license": "GPL-3.0",
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
73
|
-
"@budibase/backend-core": "^1.0.
|
|
74
|
-
"@budibase/client": "^1.0.
|
|
75
|
-
"@budibase/string-templates": "^1.0.
|
|
73
|
+
"@budibase/backend-core": "^1.0.48",
|
|
74
|
+
"@budibase/client": "^1.0.48",
|
|
75
|
+
"@budibase/string-templates": "^1.0.48",
|
|
76
76
|
"@bull-board/api": "^3.7.0",
|
|
77
77
|
"@bull-board/koa": "^3.7.0",
|
|
78
78
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -92,8 +92,6 @@
|
|
|
92
92
|
"fix-path": "3.0.0",
|
|
93
93
|
"form-data": "^4.0.0",
|
|
94
94
|
"fs-extra": "8.1.0",
|
|
95
|
-
"google-auth-library": "^7.11.0",
|
|
96
|
-
"google-spreadsheet": "^3.2.0",
|
|
97
95
|
"jimp": "0.16.1",
|
|
98
96
|
"joi": "17.2.1",
|
|
99
97
|
"js-yaml": "^4.1.0",
|
|
@@ -112,7 +110,7 @@
|
|
|
112
110
|
"mongodb": "3.6.3",
|
|
113
111
|
"mssql": "6.2.3",
|
|
114
112
|
"mysql2": "^2.3.1",
|
|
115
|
-
"node-fetch": "2.6.
|
|
113
|
+
"node-fetch": "2.6.0",
|
|
116
114
|
"open": "^8.4.0",
|
|
117
115
|
"pg": "8.5.1",
|
|
118
116
|
"pino-pretty": "4.0.0",
|
|
@@ -141,7 +139,6 @@
|
|
|
141
139
|
"@jest/test-sequencer": "^24.8.0",
|
|
142
140
|
"@types/apidoc": "^0.50.0",
|
|
143
141
|
"@types/bull": "^3.15.1",
|
|
144
|
-
"@types/google-spreadsheet": "^3.1.5",
|
|
145
142
|
"@types/jest": "^26.0.23",
|
|
146
143
|
"@types/koa": "^2.13.3",
|
|
147
144
|
"@types/koa-router": "^7.4.2",
|
|
@@ -8,9 +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 core = require("@budibase/backend-core");
|
|
12
|
-
const CouchDB = require("../../db");
|
|
13
|
-
core.init(CouchDB);
|
|
14
11
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
15
12
|
const env = require("../../environment");
|
|
16
13
|
const { basicTable, basicRow, basicRole, basicAutomation, basicDatasource, basicQuery, basicScreen, basicLayout, basicWebhook, TENANT_ID, } = require("./structures");
|
|
@@ -19,14 +16,14 @@ const supertest = require("supertest");
|
|
|
19
16
|
const { cleanup } = require("../../utilities/fileSystem");
|
|
20
17
|
const { Cookies, Headers } = require("@budibase/backend-core/constants");
|
|
21
18
|
const { jwt } = require("@budibase/backend-core/auth");
|
|
19
|
+
const core = require("@budibase/backend-core");
|
|
22
20
|
const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
23
21
|
const { createASession } = require("@budibase/backend-core/sessions");
|
|
24
22
|
const { user: userCache } = require("@budibase/backend-core/cache");
|
|
25
|
-
const
|
|
26
|
-
|
|
23
|
+
const CouchDB = require("../../db");
|
|
24
|
+
core.init(CouchDB);
|
|
27
25
|
const GLOBAL_USER_ID = "us_uuid1";
|
|
28
26
|
const EMAIL = "babs@babs.com";
|
|
29
|
-
const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306";
|
|
30
27
|
class TestConfiguration {
|
|
31
28
|
constructor(openServer = true) {
|
|
32
29
|
if (openServer) {
|
|
@@ -45,9 +42,6 @@ class TestConfiguration {
|
|
|
45
42
|
getAppId() {
|
|
46
43
|
return this.appId;
|
|
47
44
|
}
|
|
48
|
-
getCouch() {
|
|
49
|
-
return CouchDB;
|
|
50
|
-
}
|
|
51
45
|
_req(config, params, controlFunc) {
|
|
52
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
47
|
const request = {};
|
|
@@ -60,24 +54,11 @@ class TestConfiguration {
|
|
|
60
54
|
request.request = {
|
|
61
55
|
body: config,
|
|
62
56
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (params) {
|
|
66
|
-
request.params = params;
|
|
67
|
-
}
|
|
68
|
-
yield controlFunc(request);
|
|
69
|
-
return request.body;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
// check if already in a context
|
|
73
|
-
if (context.getAppId() == null) {
|
|
74
|
-
return context.doInAppContext(this.appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
return run();
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
return run();
|
|
57
|
+
if (params) {
|
|
58
|
+
request.params = params;
|
|
80
59
|
}
|
|
60
|
+
yield controlFunc(request);
|
|
61
|
+
return request.body;
|
|
81
62
|
});
|
|
82
63
|
}
|
|
83
64
|
globalUser({ id = GLOBAL_USER_ID, builder = true, email = EMAIL, roles, } = {}) {
|
|
@@ -91,11 +72,7 @@ class TestConfiguration {
|
|
|
91
72
|
existing = { email };
|
|
92
73
|
}
|
|
93
74
|
const user = Object.assign(Object.assign({ _id: id }, existing), { roles: roles || {}, tenantId: TENANT_ID });
|
|
94
|
-
yield createASession(id, {
|
|
95
|
-
sessionId: "sessionid",
|
|
96
|
-
tenantId: TENANT_ID,
|
|
97
|
-
csrfToken: CSRF_TOKEN,
|
|
98
|
-
});
|
|
75
|
+
yield createASession(id, { sessionId: "sessionid", tenantId: TENANT_ID });
|
|
99
76
|
if (builder) {
|
|
100
77
|
user.builder = { global: true };
|
|
101
78
|
}
|
|
@@ -106,8 +83,7 @@ class TestConfiguration {
|
|
|
106
83
|
return Object.assign({ _rev: resp._rev }, user);
|
|
107
84
|
});
|
|
108
85
|
}
|
|
109
|
-
|
|
110
|
-
init(appName = newid()) {
|
|
86
|
+
init(appName = "test_application") {
|
|
111
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
88
|
yield this.globalUser();
|
|
113
89
|
return this.createApp(appName);
|
|
@@ -140,7 +116,6 @@ class TestConfiguration {
|
|
|
140
116
|
`${Cookies.Auth}=${authToken}`,
|
|
141
117
|
`${Cookies.CurrentApp}=${appToken}`,
|
|
142
118
|
],
|
|
143
|
-
[Headers.CSRF_TOKEN]: CSRF_TOKEN,
|
|
144
119
|
};
|
|
145
120
|
if (this.appId) {
|
|
146
121
|
headers[Headers.APP_ID] = this.appId;
|
|
@@ -167,7 +142,6 @@ class TestConfiguration {
|
|
|
167
142
|
// create dev app
|
|
168
143
|
this.app = yield this._req({ name: appName }, null, controllers.app.create);
|
|
169
144
|
this.appId = this.app.appId;
|
|
170
|
-
context.updateAppId(this.appId);
|
|
171
145
|
// create production app
|
|
172
146
|
this.prodApp = yield this.deploy();
|
|
173
147
|
this.prodAppId = this.prodApp.appId;
|
|
@@ -178,12 +152,10 @@ class TestConfiguration {
|
|
|
178
152
|
}
|
|
179
153
|
deploy() {
|
|
180
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
yield this._req(null, null, controllers.deploy.deployApp);
|
|
182
|
-
const prodAppId =
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return appPackage.application;
|
|
186
|
-
}));
|
|
155
|
+
const deployment = yield this._req(null, null, controllers.deploy.deployApp);
|
|
156
|
+
const prodAppId = deployment.appId.replace("_dev", "");
|
|
157
|
+
const appPackage = yield this._req(null, { appId: prodAppId }, controllers.app.fetchAppPackage);
|
|
158
|
+
return appPackage.application;
|
|
187
159
|
});
|
|
188
160
|
}
|
|
189
161
|
updateTable(config = null) {
|
|
@@ -410,46 +382,44 @@ class TestConfiguration {
|
|
|
410
382
|
login({ roleId, userId, builder, prodApp = false } = {}) {
|
|
411
383
|
return __awaiter(this, void 0, void 0, function* () {
|
|
412
384
|
const appId = prodApp ? this.prodAppId : this.appId;
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
yield this.globalUser({
|
|
421
|
-
id: userId,
|
|
422
|
-
builder,
|
|
423
|
-
roles: { [this.prodAppId]: roleId },
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
yield createASession(userId, {
|
|
427
|
-
sessionId: "sessionid",
|
|
428
|
-
tenantId: TENANT_ID,
|
|
429
|
-
});
|
|
430
|
-
// have to fake this
|
|
431
|
-
const auth = {
|
|
385
|
+
userId = !userId ? `us_uuid1` : userId;
|
|
386
|
+
if (!this.request) {
|
|
387
|
+
throw "Server has not been opened, cannot login.";
|
|
388
|
+
}
|
|
389
|
+
// make sure the user exists in the global DB
|
|
390
|
+
if (roleId !== BUILTIN_ROLE_IDS.PUBLIC) {
|
|
391
|
+
yield this.globalUser({
|
|
432
392
|
userId,
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
393
|
+
builder,
|
|
394
|
+
roles: { [this.prodAppId]: roleId },
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
yield createASession(userId, {
|
|
398
|
+
sessionId: "sessionid",
|
|
399
|
+
tenantId: TENANT_ID,
|
|
400
|
+
});
|
|
401
|
+
// have to fake this
|
|
402
|
+
const auth = {
|
|
403
|
+
userId,
|
|
404
|
+
sessionId: "sessionid",
|
|
405
|
+
tenantId: TENANT_ID,
|
|
406
|
+
};
|
|
407
|
+
const app = {
|
|
408
|
+
roleId: roleId,
|
|
409
|
+
appId,
|
|
410
|
+
};
|
|
411
|
+
const authToken = jwt.sign(auth, env.JWT_SECRET);
|
|
412
|
+
const appToken = jwt.sign(app, env.JWT_SECRET);
|
|
413
|
+
// returning necessary request headers
|
|
414
|
+
yield userCache.invalidateUser(userId);
|
|
415
|
+
return {
|
|
416
|
+
Accept: "application/json",
|
|
417
|
+
Cookie: [
|
|
418
|
+
`${Cookies.Auth}=${authToken}`,
|
|
419
|
+
`${Cookies.CurrentApp}=${appToken}`,
|
|
420
|
+
],
|
|
421
|
+
[Headers.APP_ID]: appId,
|
|
422
|
+
};
|
|
453
423
|
});
|
|
454
424
|
}
|
|
455
425
|
}
|
|
@@ -15,11 +15,11 @@ const automationUtils = require("../automations/automationUtils");
|
|
|
15
15
|
const AutomationEmitter = require("../events/AutomationEmitter");
|
|
16
16
|
const { processObject } = require("@budibase/string-templates");
|
|
17
17
|
const { DEFAULT_TENANT_ID } = require("@budibase/backend-core/constants");
|
|
18
|
+
const CouchDB = require("../db");
|
|
18
19
|
const { DocumentTypes, isDevAppID } = require("../db/utils");
|
|
19
20
|
const { doInTenant } = require("@budibase/backend-core/tenancy");
|
|
20
21
|
const usage = require("../utilities/usageQuota");
|
|
21
22
|
const { definitions: triggerDefs } = require("../automations/triggerInfo");
|
|
22
|
-
const { doInAppContext, getAppDB } = require("@budibase/backend-core/context");
|
|
23
23
|
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId;
|
|
24
24
|
const CRON_STEP_ID = triggerDefs.CRON.stepId;
|
|
25
25
|
const STOPPED_STATUS = { success: false, status: "STOPPED" };
|
|
@@ -67,10 +67,11 @@ class Orchestrator {
|
|
|
67
67
|
}
|
|
68
68
|
getApp() {
|
|
69
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const appId = this._appId;
|
|
70
71
|
if (this._app) {
|
|
71
72
|
return this._app;
|
|
72
73
|
}
|
|
73
|
-
const db =
|
|
74
|
+
const db = new CouchDB(appId);
|
|
74
75
|
this._app = yield db.get(DocumentTypes.APP_METADATA);
|
|
75
76
|
return this._app;
|
|
76
77
|
});
|
|
@@ -132,16 +133,13 @@ class Orchestrator {
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
module.exports = (input, callback) => {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
.catch(err => {
|
|
144
|
-
callback(err);
|
|
145
|
-
});
|
|
136
|
+
const automationOrchestrator = new Orchestrator(input.data.automation, input.data.event);
|
|
137
|
+
automationOrchestrator
|
|
138
|
+
.execute()
|
|
139
|
+
.then(response => {
|
|
140
|
+
callback(null, response);
|
|
141
|
+
})
|
|
142
|
+
.catch(err => {
|
|
143
|
+
callback(err);
|
|
146
144
|
});
|
|
147
145
|
};
|
package/dist/threads/query.js
CHANGED
|
@@ -13,11 +13,10 @@ threadUtils.threadSetup();
|
|
|
13
13
|
const ScriptRunner = require("../utilities/scriptRunner");
|
|
14
14
|
const { integrations } = require("../integrations");
|
|
15
15
|
const { processStringSync } = require("@budibase/string-templates");
|
|
16
|
-
const
|
|
17
|
-
const IS_TRIPLE_BRACE = new RegExp(/^{{3}.*}{3}$/);
|
|
18
|
-
const IS_HANDLEBARS = new RegExp(/^{{2}.*}{2}$/);
|
|
16
|
+
const CouchDB = require("../db");
|
|
19
17
|
class QueryRunner {
|
|
20
18
|
constructor(input, flags = { noRecursiveQuery: false }) {
|
|
19
|
+
this.appId = input.appId;
|
|
21
20
|
this.datasource = input.datasource;
|
|
22
21
|
this.queryVerb = input.queryVerb;
|
|
23
22
|
this.fields = input.fields;
|
|
@@ -74,10 +73,6 @@ class QueryRunner {
|
|
|
74
73
|
yield threadUtils.invalidateDynamicVariables(this.cachedVariables);
|
|
75
74
|
return this.execute();
|
|
76
75
|
}
|
|
77
|
-
// check for undefined response
|
|
78
|
-
if (!rows) {
|
|
79
|
-
rows = [];
|
|
80
|
-
}
|
|
81
76
|
// needs to an array for next step
|
|
82
77
|
if (!Array.isArray(rows)) {
|
|
83
78
|
rows = [rows];
|
|
@@ -96,10 +91,11 @@ class QueryRunner {
|
|
|
96
91
|
}
|
|
97
92
|
runAnotherQuery(queryId, parameters) {
|
|
98
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
const db =
|
|
94
|
+
const db = new CouchDB(this.appId);
|
|
100
95
|
const query = yield db.get(queryId);
|
|
101
96
|
const datasource = yield db.get(query.datasourceId);
|
|
102
97
|
return new QueryRunner({
|
|
98
|
+
appId: this.appId,
|
|
103
99
|
datasource,
|
|
104
100
|
queryVerb: query.queryVerb,
|
|
105
101
|
fields: query.fields,
|
|
@@ -180,12 +176,8 @@ class QueryRunner {
|
|
|
180
176
|
}
|
|
181
177
|
else if (typeof fields[key] === "string") {
|
|
182
178
|
// enrich string value as normal
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (IS_HANDLEBARS.test(value) && !IS_TRIPLE_BRACE.test(value)) {
|
|
186
|
-
value = `{${value}}`;
|
|
187
|
-
}
|
|
188
|
-
enrichedQuery[key] = processStringSync(value, parameters, {
|
|
179
|
+
enrichedQuery[key] = processStringSync(fields[key], parameters, {
|
|
180
|
+
noEscaping: true,
|
|
189
181
|
noHelpers: true,
|
|
190
182
|
});
|
|
191
183
|
}
|
|
@@ -210,14 +202,12 @@ class QueryRunner {
|
|
|
210
202
|
}
|
|
211
203
|
}
|
|
212
204
|
module.exports = (input, callback) => {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
callback(err);
|
|
221
|
-
});
|
|
205
|
+
const Runner = new QueryRunner(input);
|
|
206
|
+
Runner.execute()
|
|
207
|
+
.then(response => {
|
|
208
|
+
callback(null, response);
|
|
209
|
+
})
|
|
210
|
+
.catch(err => {
|
|
211
|
+
callback(err);
|
|
222
212
|
});
|
|
223
213
|
};
|