@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
|
@@ -8,12 +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");
|
|
11
12
|
const { generateWebhookID, getWebhookParams } = require("../../db/utils");
|
|
12
13
|
const toJsonSchema = require("to-json-schema");
|
|
13
14
|
const validate = require("jsonschema").validate;
|
|
14
15
|
const triggers = require("../../automations/triggers");
|
|
15
|
-
const {
|
|
16
|
-
const { getAppDB, updateAppId } = require("@budibase/backend-core/context");
|
|
16
|
+
const { getDeployedAppID } = require("@budibase/backend-core/db");
|
|
17
17
|
const AUTOMATION_DESCRIPTION = "Generated from Webhook Schema";
|
|
18
18
|
function Webhook(name, type, target) {
|
|
19
19
|
this.live = true;
|
|
@@ -28,14 +28,14 @@ exports.WebhookType = {
|
|
|
28
28
|
AUTOMATION: "automation",
|
|
29
29
|
};
|
|
30
30
|
exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
const db =
|
|
31
|
+
const db = new CouchDB(ctx.appId);
|
|
32
32
|
const response = yield db.allDocs(getWebhookParams(null, {
|
|
33
33
|
include_docs: true,
|
|
34
34
|
}));
|
|
35
35
|
ctx.body = response.rows.map(row => row.doc);
|
|
36
36
|
});
|
|
37
37
|
exports.save = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
const db =
|
|
38
|
+
const db = new CouchDB(ctx.appId);
|
|
39
39
|
const webhook = ctx.request.body;
|
|
40
40
|
webhook.appId = ctx.appId;
|
|
41
41
|
// check that the webhook exists
|
|
@@ -53,12 +53,11 @@ exports.save = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
53
53
|
};
|
|
54
54
|
});
|
|
55
55
|
exports.destroy = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
const db =
|
|
56
|
+
const db = new CouchDB(ctx.appId);
|
|
57
57
|
ctx.body = yield db.remove(ctx.params.id, ctx.params.rev);
|
|
58
58
|
});
|
|
59
59
|
exports.buildSchema = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
-
|
|
61
|
-
const db = getAppDB();
|
|
60
|
+
const db = new CouchDB(ctx.params.instance);
|
|
62
61
|
const webhook = yield db.get(ctx.params.id);
|
|
63
62
|
webhook.bodySchema = toJsonSchema(ctx.request.body);
|
|
64
63
|
// update the automation outputs
|
|
@@ -81,10 +80,9 @@ exports.buildSchema = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
81
80
|
ctx.body = yield db.put(webhook);
|
|
82
81
|
});
|
|
83
82
|
exports.trigger = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
-
const prodAppId =
|
|
85
|
-
updateAppId(prodAppId);
|
|
83
|
+
const prodAppId = getDeployedAppID(ctx.params.instance);
|
|
86
84
|
try {
|
|
87
|
-
const db =
|
|
85
|
+
const db = new CouchDB(prodAppId);
|
|
88
86
|
const webhook = yield db.get(ctx.params.id);
|
|
89
87
|
// validate against the schema
|
|
90
88
|
if (webhook.bodySchema) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Router = require("@koa/router");
|
|
3
|
+
const controller = require("../controllers/hosting");
|
|
4
|
+
const authorized = require("../../middleware/authorized");
|
|
5
|
+
const { BUILDER } = require("@budibase/backend-core/permissions");
|
|
6
|
+
const router = Router();
|
|
7
|
+
router
|
|
8
|
+
.get("/api/hosting/urls", authorized(BUILDER), controller.fetchUrls)
|
|
9
|
+
// this isn't risky, doesn't return anything about apps other than names and URLs
|
|
10
|
+
.get("/api/hosting/apps", controller.getDeployedApps);
|
|
11
|
+
module.exports = router;
|
package/dist/api/routes/index.js
CHANGED
|
@@ -21,11 +21,11 @@ const integrationRoutes = require("./integration");
|
|
|
21
21
|
const permissionRoutes = require("./permission");
|
|
22
22
|
const datasourceRoutes = require("./datasource");
|
|
23
23
|
const queryRoutes = require("./query");
|
|
24
|
+
const hostingRoutes = require("./hosting");
|
|
24
25
|
const backupRoutes = require("./backup");
|
|
25
26
|
const metadataRoutes = require("./metadata");
|
|
26
27
|
const devRoutes = require("./dev");
|
|
27
28
|
const cloudRoutes = require("./cloud");
|
|
28
|
-
const migrationRoutes = require("./migrations");
|
|
29
29
|
exports.mainRoutes = [
|
|
30
30
|
authRoutes,
|
|
31
31
|
deployRoutes,
|
|
@@ -46,6 +46,7 @@ exports.mainRoutes = [
|
|
|
46
46
|
permissionRoutes,
|
|
47
47
|
datasourceRoutes,
|
|
48
48
|
queryRoutes,
|
|
49
|
+
hostingRoutes,
|
|
49
50
|
backupRoutes,
|
|
50
51
|
metadataRoutes,
|
|
51
52
|
devRoutes,
|
|
@@ -54,6 +55,5 @@ exports.mainRoutes = [
|
|
|
54
55
|
// this could be breaking as koa may recognise other routes as this
|
|
55
56
|
tableRoutes,
|
|
56
57
|
rowRoutes,
|
|
57
|
-
migrationRoutes,
|
|
58
58
|
];
|
|
59
59
|
exports.staticRoutes = staticRoutes;
|
|
@@ -43,6 +43,5 @@ router
|
|
|
43
43
|
.post("/api/attachments/process", authorized(BUILDER), controller.uploadFile)
|
|
44
44
|
.post("/api/attachments/:tableId/upload", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), controller.uploadFile)
|
|
45
45
|
// TODO: this likely needs to be secured in some way
|
|
46
|
-
.get("/:appId/:path*", controller.serveApp)
|
|
47
|
-
.post("/api/attachments/:datasourceId/url", authorized(PermissionTypes.TABLE, PermissionLevels.READ), controller.getSignedUploadURL);
|
|
46
|
+
.get("/:appId/:path*", controller.serveApp);
|
|
48
47
|
module.exports = router;
|
|
@@ -10,24 +10,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const rowController = require("../../../controllers/row");
|
|
12
12
|
const appController = require("../../../controllers/application");
|
|
13
|
+
const CouchDB = require("../../../../db");
|
|
13
14
|
const { AppStatus } = require("../../../../db/utils");
|
|
14
15
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
15
16
|
const { TENANT_ID } = require("../../../../tests/utilities/structures");
|
|
16
|
-
const { getAppDB, doInAppContext } = require("@budibase/backend-core/context");
|
|
17
|
-
const env = require("../../../../environment");
|
|
18
17
|
function Request(appId, params) {
|
|
19
18
|
this.appId = appId;
|
|
20
19
|
this.params = params;
|
|
21
20
|
this.request = {};
|
|
22
21
|
}
|
|
23
|
-
function runRequest(appId, controlFunc, request) {
|
|
24
|
-
return doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
return controlFunc(request);
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
22
|
exports.getAllTableRows = (config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
23
|
const req = new Request(config.appId, { tableId: config.table._id });
|
|
30
|
-
yield
|
|
24
|
+
yield rowController.fetch(req);
|
|
31
25
|
return req.body;
|
|
32
26
|
});
|
|
33
27
|
exports.clearAllApps = (tenantId = TENANT_ID) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -39,16 +33,13 @@ exports.clearAllApps = (tenantId = TENANT_ID) => __awaiter(void 0, void 0, void
|
|
|
39
33
|
}
|
|
40
34
|
for (let app of apps) {
|
|
41
35
|
const { appId } = app;
|
|
42
|
-
|
|
43
|
-
yield runRequest(appId, appController.delete, req);
|
|
36
|
+
yield appController.delete(new Request(null, { appId }));
|
|
44
37
|
}
|
|
45
38
|
});
|
|
46
39
|
exports.clearAllAutomations = (config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
40
|
const automations = yield config.getAllAutomations();
|
|
48
41
|
for (let auto of automations) {
|
|
49
|
-
yield
|
|
50
|
-
yield config.deleteAutomation(auto);
|
|
51
|
-
}));
|
|
42
|
+
yield config.deleteAutomation(auto);
|
|
52
43
|
}
|
|
53
44
|
});
|
|
54
45
|
exports.createRequest = (request, method, url, body) => {
|
|
@@ -101,30 +92,19 @@ exports.checkPermissionsEndpoint = ({ config, method, url, body, passRole, failR
|
|
|
101
92
|
.set(failHeader)
|
|
102
93
|
.expect(403);
|
|
103
94
|
});
|
|
104
|
-
exports.getDB =
|
|
105
|
-
return
|
|
95
|
+
exports.getDB = config => {
|
|
96
|
+
return new CouchDB(config.getAppId());
|
|
106
97
|
};
|
|
107
98
|
exports.testAutomation = (config, automation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
.expect(200);
|
|
120
|
-
}));
|
|
121
|
-
});
|
|
122
|
-
exports.runInProd = (func) => __awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
-
const nodeEnv = env.NODE_ENV;
|
|
124
|
-
const workerId = env.JEST_WORKER_ID;
|
|
125
|
-
env._set("NODE_ENV", "PRODUCTION");
|
|
126
|
-
env._set("JEST_WORKER_ID", null);
|
|
127
|
-
yield func();
|
|
128
|
-
env._set("NODE_ENV", nodeEnv);
|
|
129
|
-
env._set("JEST_WORKER_ID", workerId);
|
|
99
|
+
return yield config.request
|
|
100
|
+
.post(`/api/automations/${automation._id}/test`)
|
|
101
|
+
.send({
|
|
102
|
+
row: {
|
|
103
|
+
name: "Test",
|
|
104
|
+
description: "TEST",
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
.set(config.defaultHeaders())
|
|
108
|
+
.expect("Content-Type", /json/)
|
|
109
|
+
.expect(200);
|
|
130
110
|
});
|
package/dist/app.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -28,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
28
9
|
});
|
|
29
10
|
};
|
|
30
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
const env =
|
|
12
|
+
const env = require("./environment");
|
|
32
13
|
const CouchDB = require("./db");
|
|
33
14
|
require("@budibase/backend-core").init(CouchDB);
|
|
34
15
|
const Koa = require("koa");
|
|
@@ -43,7 +24,6 @@ const Sentry = require("@sentry/node");
|
|
|
43
24
|
const fileSystem = require("./utilities/fileSystem");
|
|
44
25
|
const bullboard = require("./automations/bullboard");
|
|
45
26
|
const redis = require("./utilities/redis");
|
|
46
|
-
const migrations = __importStar(require("./migrations"));
|
|
47
27
|
const app = new Koa();
|
|
48
28
|
// set up top level koa middleware
|
|
49
29
|
app.use(koaBody({
|
|
@@ -96,22 +76,12 @@ module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, vo
|
|
|
96
76
|
yield redis.init();
|
|
97
77
|
yield automations.init();
|
|
98
78
|
}));
|
|
99
|
-
const shutdown = () => {
|
|
100
|
-
server.close();
|
|
101
|
-
server.destroy();
|
|
102
|
-
};
|
|
103
79
|
process.on("uncaughtException", err => {
|
|
104
80
|
console.error(err);
|
|
105
|
-
|
|
81
|
+
server.close();
|
|
82
|
+
server.destroy();
|
|
106
83
|
});
|
|
107
84
|
process.on("SIGTERM", () => {
|
|
108
|
-
|
|
85
|
+
server.close();
|
|
86
|
+
server.destroy();
|
|
109
87
|
});
|
|
110
|
-
// run migrations on startup if not done via http
|
|
111
|
-
// not recommended in a clustered environment
|
|
112
|
-
if (!env.HTTP_MIGRATIONS) {
|
|
113
|
-
migrations.migrate().catch(err => {
|
|
114
|
-
console.error("Error performing migrations. Exiting.\n", err);
|
|
115
|
-
shutdown();
|
|
116
|
-
});
|
|
117
|
-
}
|
|
@@ -61,12 +61,13 @@ exports.cleanInputValues = (inputs, schema) => {
|
|
|
61
61
|
* the automation but is instead part of the Table/Table. This function will get the table schema and use it to instead
|
|
62
62
|
* perform the cleanInputValues function on the input row.
|
|
63
63
|
*
|
|
64
|
+
* @param {string} appId The instance which the Table/Table is contained under.
|
|
64
65
|
* @param {string} tableId The ID of the Table/Table which the schema is to be retrieved for.
|
|
65
66
|
* @param {object} row The input row structure which requires clean-up after having been through template statements.
|
|
66
67
|
* @returns {Promise<Object>} The cleaned up rows object, will should now have all the required primitive types.
|
|
67
68
|
*/
|
|
68
|
-
exports.cleanUpRow = (tableId, row) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
let table = yield getTable(tableId);
|
|
69
|
+
exports.cleanUpRow = (appId, tableId, row) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
let table = yield getTable(appId, tableId);
|
|
70
71
|
return exports.cleanInputValues(row, { properties: table.schema });
|
|
71
72
|
});
|
|
72
73
|
exports.getError = err => {
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const rowController = require("../../api/controllers/row");
|
|
12
12
|
const automationUtils = require("../automationUtils");
|
|
13
|
+
const env = require("../../environment");
|
|
13
14
|
const usage = require("../../utilities/usageQuota");
|
|
14
15
|
const { buildCtx } = require("./utils");
|
|
15
16
|
exports.definition = {
|
|
@@ -85,10 +86,11 @@ exports.run = function ({ inputs, appId, emitter }) {
|
|
|
85
86
|
},
|
|
86
87
|
});
|
|
87
88
|
try {
|
|
88
|
-
inputs.row = yield automationUtils.cleanUpRow(inputs.row.tableId, inputs.row);
|
|
89
|
-
|
|
89
|
+
inputs.row = yield automationUtils.cleanUpRow(appId, inputs.row.tableId, inputs.row);
|
|
90
|
+
if (env.USE_QUOTAS) {
|
|
91
|
+
yield usage.update(usage.Properties.ROW, 1);
|
|
92
|
+
}
|
|
90
93
|
yield rowController.save(ctx);
|
|
91
|
-
yield usage.update(usage.Properties.ROW, 1);
|
|
92
94
|
return {
|
|
93
95
|
row: inputs.row,
|
|
94
96
|
response: ctx.body,
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const rowController = require("../../api/controllers/row");
|
|
12
|
+
const env = require("../../environment");
|
|
12
13
|
const usage = require("../../utilities/usageQuota");
|
|
13
14
|
const { buildCtx } = require("./utils");
|
|
14
15
|
const automationUtils = require("../automationUtils");
|
|
@@ -80,7 +81,9 @@ exports.run = function ({ inputs, appId, emitter }) {
|
|
|
80
81
|
},
|
|
81
82
|
});
|
|
82
83
|
try {
|
|
83
|
-
|
|
84
|
+
if (env.isProd()) {
|
|
85
|
+
yield usage.update(usage.Properties.ROW, -1);
|
|
86
|
+
}
|
|
84
87
|
yield rowController.destroy(ctx);
|
|
85
88
|
return {
|
|
86
89
|
response: ctx.body,
|
|
@@ -90,7 +90,7 @@ exports.run = function ({ inputs, appId, emitter }) {
|
|
|
90
90
|
});
|
|
91
91
|
try {
|
|
92
92
|
if (tableId) {
|
|
93
|
-
inputs.row = yield automationUtils.cleanUpRow(tableId, inputs.row);
|
|
93
|
+
inputs.row = yield automationUtils.cleanUpRow(appId, tableId, inputs.row);
|
|
94
94
|
}
|
|
95
95
|
yield rowController.patch(ctx);
|
|
96
96
|
return {
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
const CouchDB = require("../db");
|
|
11
12
|
const emitter = require("../events/index");
|
|
12
13
|
const { getAutomationParams } = require("../db/utils");
|
|
13
14
|
const { coerce } = require("../utilities/rowProcessor");
|
|
@@ -18,7 +19,6 @@ const { queue } = require("./bullboard");
|
|
|
18
19
|
const { checkTestFlag } = require("../utilities/redis");
|
|
19
20
|
const utils = require("./utils");
|
|
20
21
|
const env = require("../environment");
|
|
21
|
-
const { doInAppContext, getAppDB } = require("@budibase/backend-core/context");
|
|
22
22
|
const TRIGGER_DEFINITIONS = definitions;
|
|
23
23
|
const JOB_OPTS = {
|
|
24
24
|
removeOnComplete: true,
|
|
@@ -29,33 +29,31 @@ function queueRelevantRowAutomations(event, eventType) {
|
|
|
29
29
|
if (event.appId == null) {
|
|
30
30
|
throw `No appId specified for ${eventType} - check event emitters.`;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (automationTrigger.inputs &&
|
|
54
|
-
automationTrigger.inputs.tableId === event.row.tableId) {
|
|
55
|
-
yield queue.add({ automation, event }, JOB_OPTS);
|
|
56
|
-
}
|
|
32
|
+
const db = new CouchDB(event.appId);
|
|
33
|
+
let automations = yield db.allDocs(getAutomationParams(null, { include_docs: true }));
|
|
34
|
+
// filter down to the correct event type
|
|
35
|
+
automations = automations.rows
|
|
36
|
+
.map(automation => automation.doc)
|
|
37
|
+
.filter(automation => {
|
|
38
|
+
const trigger = automation.definition.trigger;
|
|
39
|
+
return trigger && trigger.event === eventType;
|
|
40
|
+
});
|
|
41
|
+
for (let automation of automations) {
|
|
42
|
+
let automationDef = automation.definition;
|
|
43
|
+
let automationTrigger = automationDef ? automationDef.trigger : {};
|
|
44
|
+
// don't queue events which are for dev apps, only way to test automations is
|
|
45
|
+
// running tests on them, in production the test flag will never
|
|
46
|
+
// be checked due to lazy evaluation (first always false)
|
|
47
|
+
if (!env.ALLOW_DEV_AUTOMATIONS &&
|
|
48
|
+
isDevAppID(event.appId) &&
|
|
49
|
+
!(yield checkTestFlag(automation._id))) {
|
|
50
|
+
continue;
|
|
57
51
|
}
|
|
58
|
-
|
|
52
|
+
if (automationTrigger.inputs &&
|
|
53
|
+
automationTrigger.inputs.tableId === event.row.tableId) {
|
|
54
|
+
yield queue.add({ automation, event }, JOB_OPTS);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
59
57
|
});
|
|
60
58
|
}
|
|
61
59
|
emitter.on("row:save", function (event) {
|
|
@@ -16,9 +16,8 @@ const { queue } = require("./bullboard");
|
|
|
16
16
|
const newid = require("../db/newid");
|
|
17
17
|
const { updateEntityMetadata } = require("../utilities");
|
|
18
18
|
const { MetadataTypes } = require("../constants");
|
|
19
|
-
const {
|
|
19
|
+
const { getDeployedAppID } = require("@budibase/backend-core/db");
|
|
20
20
|
const { cloneDeep } = require("lodash/fp");
|
|
21
|
-
const { getAppDB, getAppId } = require("@budibase/backend-core/context");
|
|
22
21
|
const WH_STEP_ID = definitions.WEBHOOK.stepId;
|
|
23
22
|
const CRON_STEP_ID = definitions.CRON.stepId;
|
|
24
23
|
const Runner = new Thread(ThreadType.AUTOMATION);
|
|
@@ -33,7 +32,7 @@ exports.processEvent = (job) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
33
32
|
}
|
|
34
33
|
});
|
|
35
34
|
exports.updateTestHistory = (appId, automation, history) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
return updateEntityMetadata(MetadataTypes.AUTOMATION_TEST_HISTORY, automation._id, metadata => {
|
|
35
|
+
return updateEntityMetadata(appId, MetadataTypes.AUTOMATION_TEST_HISTORY, automation._id, metadata => {
|
|
37
36
|
if (metadata && Array.isArray(metadata.history)) {
|
|
38
37
|
metadata.history.push(history);
|
|
39
38
|
}
|
|
@@ -88,9 +87,6 @@ exports.enableCronTrigger = (appId, automation) => __awaiter(void 0, void 0, voi
|
|
|
88
87
|
}, { repeat: { cron: trigger.inputs.cron }, jobId });
|
|
89
88
|
// Assign cron job ID from bull so we can remove it later if the cron trigger is removed
|
|
90
89
|
trigger.cronJobId = job.id;
|
|
91
|
-
// can't use getAppDB here as this is likely to be called from dev app,
|
|
92
|
-
// but this call could be for dev app or prod app, need to just use what
|
|
93
|
-
// was passed in
|
|
94
90
|
const db = new CouchDB(appId);
|
|
95
91
|
const response = yield db.put(automation);
|
|
96
92
|
automation._id = response.id;
|
|
@@ -106,8 +102,7 @@ exports.enableCronTrigger = (appId, automation) => __awaiter(void 0, void 0, voi
|
|
|
106
102
|
* @returns {Promise<object|undefined>} After this is complete the new automation object may have been updated and should be
|
|
107
103
|
* written to DB (this does not write to DB as it would be wasteful to repeat).
|
|
108
104
|
*/
|
|
109
|
-
exports.checkForWebhooks = ({ oldAuto, newAuto }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
-
const appId = getAppId();
|
|
105
|
+
exports.checkForWebhooks = ({ appId, oldAuto, newAuto }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
111
106
|
const oldTrigger = oldAuto ? oldAuto.definition.trigger : null;
|
|
112
107
|
const newTrigger = newAuto ? newAuto.definition.trigger : null;
|
|
113
108
|
const triggerChanged = oldTrigger && newTrigger && oldTrigger.id !== newTrigger.id;
|
|
@@ -121,7 +116,7 @@ exports.checkForWebhooks = ({ oldAuto, newAuto }) => __awaiter(void 0, void 0, v
|
|
|
121
116
|
(!isWebhookTrigger(newAuto) || triggerChanged) &&
|
|
122
117
|
oldTrigger.webhookId) {
|
|
123
118
|
try {
|
|
124
|
-
let db =
|
|
119
|
+
let db = new CouchDB(appId);
|
|
125
120
|
// need to get the webhook to get the rev
|
|
126
121
|
const webhook = yield db.get(oldTrigger.webhookId);
|
|
127
122
|
const ctx = {
|
|
@@ -154,7 +149,7 @@ exports.checkForWebhooks = ({ oldAuto, newAuto }) => __awaiter(void 0, void 0, v
|
|
|
154
149
|
// the app ID has to be development for this endpoint
|
|
155
150
|
// it can only be used when building the app
|
|
156
151
|
// but the trigger endpoint will always be used in production
|
|
157
|
-
const prodAppId =
|
|
152
|
+
const prodAppId = getDeployedAppID(appId);
|
|
158
153
|
newTrigger.inputs = {
|
|
159
154
|
schemaUrl: `api/webhooks/schema/${appId}/${id}`,
|
|
160
155
|
triggerUrl: `api/webhooks/trigger/${prodAppId}/${id}`,
|
package/dist/constants/index.js
CHANGED
|
@@ -52,10 +52,6 @@ exports.RelationshipTypes = {
|
|
|
52
52
|
MANY_TO_ONE: "many-to-one",
|
|
53
53
|
MANY_TO_MANY: "many-to-many",
|
|
54
54
|
};
|
|
55
|
-
exports.FormulaTypes = {
|
|
56
|
-
STATIC: "static",
|
|
57
|
-
DYNAMIC: "dynamic",
|
|
58
|
-
};
|
|
59
55
|
exports.AuthTypes = {
|
|
60
56
|
APP: "app",
|
|
61
57
|
BUILDER: "builder",
|
|
@@ -71,9 +67,6 @@ exports.DataSourceOperation = {
|
|
|
71
67
|
UPDATE_TABLE: "UPDATE_TABLE",
|
|
72
68
|
DELETE_TABLE: "DELETE_TABLE",
|
|
73
69
|
};
|
|
74
|
-
exports.DatasourceAuthTypes = {
|
|
75
|
-
GOOGLE: "google",
|
|
76
|
-
};
|
|
77
70
|
exports.SortDirection = {
|
|
78
71
|
ASCENDING: "ASCENDING",
|
|
79
72
|
DESCENDING: "DESCENDING",
|
|
@@ -8,11 +8,11 @@ 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("../index");
|
|
11
12
|
const { IncludeDocs, getLinkDocuments } = require("./linkUtils");
|
|
12
13
|
const { generateLinkID, InternalTables, getUserMetadataParams, } = require("../utils");
|
|
13
14
|
const Sentry = require("@sentry/node");
|
|
14
15
|
const { FieldTypes, RelationshipTypes } = require("../../constants");
|
|
15
|
-
const { getAppDB } = require("@budibase/backend-core/context");
|
|
16
16
|
/**
|
|
17
17
|
* Creates a new link document structure which can be put to the database. It is important to
|
|
18
18
|
* note that while this talks about linker/linked the link is bi-directional and for all intent
|
|
@@ -42,8 +42,9 @@ function LinkDocument(tableId1, fieldName1, rowId1, tableId2, fieldName2, rowId2
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
class LinkController {
|
|
45
|
-
constructor({ tableId, row, table, oldTable }) {
|
|
46
|
-
this.
|
|
45
|
+
constructor({ appId, tableId, row, table, oldTable }) {
|
|
46
|
+
this._appId = appId;
|
|
47
|
+
this._db = new CouchDB(appId);
|
|
47
48
|
this._tableId = tableId;
|
|
48
49
|
this._row = row;
|
|
49
50
|
this._table = table;
|
|
@@ -89,6 +90,7 @@ class LinkController {
|
|
|
89
90
|
*/
|
|
90
91
|
getRowLinkDocs(rowId) {
|
|
91
92
|
return getLinkDocuments({
|
|
93
|
+
appId: this._appId,
|
|
92
94
|
tableId: this._tableId,
|
|
93
95
|
rowId,
|
|
94
96
|
includeDocs: IncludeDocs.INCLUDE,
|
|
@@ -99,6 +101,7 @@ class LinkController {
|
|
|
99
101
|
*/
|
|
100
102
|
getTableLinkDocs() {
|
|
101
103
|
return getLinkDocuments({
|
|
104
|
+
appId: this._appId,
|
|
102
105
|
tableId: this._tableId,
|
|
103
106
|
includeDocs: IncludeDocs.INCLUDE,
|
|
104
107
|
});
|
|
@@ -200,6 +203,7 @@ class LinkController {
|
|
|
200
203
|
for (let linkId of rowField) {
|
|
201
204
|
if (linkedSchema.relationshipType === RelationshipTypes.ONE_TO_MANY) {
|
|
202
205
|
let links = (yield getLinkDocuments({
|
|
206
|
+
appId: this._appId,
|
|
203
207
|
tableId: field.tableId,
|
|
204
208
|
rowId: linkId,
|
|
205
209
|
includeDocs: IncludeDocs.EXCLUDE,
|