@budibase/server 1.0.49-alpha.9 → 1.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/arangojs.ts +1 -1
- package/__mocks__/aws-sdk.ts +4 -4
- package/__mocks__/mongodb.ts +5 -4
- package/__mocks__/mssql.ts +3 -3
- package/__mocks__/node-fetch.ts +1 -2
- package/__mocks__/pg.ts +5 -3
- package/builder/assets/{index.ad5370ae.js → index.2c37968e.js} +246 -249
- package/builder/assets/index.39e01193.css +1 -0
- package/builder/assets/{vendor.d526bfe8.js → vendor.f9faf6ab.js} +12 -12
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2827 -3117
- package/coverage/coverage-final.json +101 -106
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.js.html +152 -257
- package/coverage/lcov-report/api/controllers/auth.js.html +13 -22
- package/coverage/lcov-report/api/controllers/automation.js.html +69 -39
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -8
- package/coverage/lcov-report/api/controllers/component.js.html +16 -13
- package/coverage/lcov-report/api/controllers/datasource.js.html +51 -81
- package/coverage/lcov-report/api/controllers/dev.js.html +6 -6
- package/coverage/lcov-report/{utilities/usageQuota/usageQuoteReset.js.html → api/controllers/hosting.js.html} +48 -36
- package/coverage/lcov-report/api/controllers/index.html +76 -76
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +9 -9
- package/coverage/lcov-report/api/controllers/metadata.js.html +21 -6
- package/coverage/lcov-report/api/controllers/permission.js.html +19 -19
- package/coverage/lcov-report/api/controllers/query/index.html +10 -10
- package/coverage/lcov-report/api/controllers/query/index.js.html +35 -38
- package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -6
- package/coverage/lcov-report/api/controllers/role.js.html +16 -16
- package/coverage/lcov-report/api/controllers/routing.js.html +10 -7
- package/coverage/lcov-report/api/controllers/row/external.js.html +141 -48
- package/coverage/lcov-report/api/controllers/row/index.html +40 -55
- package/coverage/lcov-report/api/controllers/row/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/row/internal.js.html +226 -118
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +34 -52
- package/coverage/lcov-report/api/controllers/row/utils.js.html +62 -47
- package/coverage/lcov-report/api/controllers/screen.js.html +21 -15
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/external.js.html +34 -25
- package/coverage/lcov-report/api/controllers/table/index.html +43 -58
- package/coverage/lcov-report/api/controllers/table/index.js.html +82 -58
- package/coverage/lcov-report/api/controllers/table/internal.js.html +66 -81
- package/coverage/lcov-report/api/controllers/table/utils.js.html +110 -218
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +50 -47
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +16 -16
- package/coverage/lcov-report/api/controllers/view/index.js.html +33 -27
- package/coverage/lcov-report/api/controllers/view/utils.js.html +20 -35
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +28 -34
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +8 -8
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/application.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/{migrations.js.html → hosting.js.html} +14 -17
- package/coverage/lcov-report/api/routes/index.html +18 -18
- package/coverage/lcov-report/api/routes/index.js.html +3 -3
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/row.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +2 -17
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +10 -7
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +18 -18
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +22 -13
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +20 -11
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +13 -13
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +55 -61
- package/coverage/lcov-report/automations/utils.js.html +42 -54
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +26 -53
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +37 -25
- package/coverage/lcov-report/db/linkedRows/index.html +27 -27
- package/coverage/lcov-report/db/linkedRows/index.js.html +96 -51
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +42 -42
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +87 -87
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +5 -5
- package/coverage/lcov-report/events/utils.js.html +3 -3
- package/coverage/lcov-report/index.html +120 -135
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/authorized.js.html +65 -173
- package/coverage/lcov-report/middleware/builder.js.html +10 -10
- package/coverage/lcov-report/middleware/currentapp.js.html +83 -95
- package/coverage/lcov-report/middleware/index.html +38 -38
- package/coverage/lcov-report/middleware/joi-validator.js.html +3 -3
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +53 -281
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +24 -30
- package/coverage/lcov-report/threads/index.html +26 -26
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +24 -39
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +49 -58
- package/coverage/lcov-report/utilities/index.html +37 -37
- package/coverage/lcov-report/utilities/index.js.html +73 -43
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +8 -8
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +7 -7
- package/coverage/lcov-report/utilities/rowProcessor/index.html +27 -27
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +103 -97
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +27 -75
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +9 -9
- package/coverage/lcov-report/utilities/workerRequests.js.html +112 -43
- package/coverage/lcov.info +4431 -5013
- package/dist/api/controllers/application.js +60 -90
- package/dist/api/controllers/auth.js +5 -8
- package/dist/api/controllers/automation.js +19 -14
- package/dist/api/controllers/cloud.js +3 -2
- package/dist/api/controllers/component.js +4 -3
- package/dist/api/controllers/datasource.js +10 -20
- package/dist/api/controllers/deploy/Deployment.js +6 -3
- package/dist/api/controllers/deploy/index.js +13 -12
- package/dist/api/controllers/dev.js +5 -5
- package/dist/api/controllers/hosting.js +30 -0
- package/dist/api/controllers/layout.js +3 -3
- package/dist/api/controllers/metadata.js +4 -4
- package/dist/api/controllers/permission.js +4 -4
- package/dist/api/controllers/query/import/index.js +6 -4
- package/dist/api/controllers/query/index.js +10 -11
- package/dist/api/controllers/role.js +5 -5
- package/dist/api/controllers/routing.js +6 -5
- package/dist/api/controllers/row/ExternalRequest.js +67 -90
- package/dist/api/controllers/row/external.js +22 -14
- package/dist/api/controllers/row/internal.js +93 -55
- package/dist/api/controllers/row/internalSearch.js +17 -23
- package/dist/api/controllers/row/utils.js +14 -13
- package/dist/api/controllers/screen.js +7 -5
- package/dist/api/controllers/static/index.js +12 -61
- package/dist/api/controllers/table/external.js +10 -7
- package/dist/api/controllers/table/index.js +13 -16
- package/dist/api/controllers/table/internal.js +16 -22
- package/dist/api/controllers/table/utils.js +35 -62
- package/dist/api/controllers/user.js +20 -18
- package/dist/api/controllers/view/index.js +10 -8
- package/dist/api/controllers/view/utils.js +4 -9
- package/dist/api/controllers/webhook.js +8 -10
- package/dist/api/routes/hosting.js +11 -0
- package/dist/api/routes/index.js +2 -2
- package/dist/api/routes/static.js +1 -2
- package/dist/api/routes/tests/utilities/TestFunctions.js +17 -37
- package/dist/app.js +5 -35
- package/dist/automations/automationUtils.js +3 -2
- package/dist/automations/steps/createRow.js +5 -3
- package/dist/automations/steps/deleteRow.js +4 -1
- package/dist/automations/steps/updateRow.js +1 -1
- package/dist/automations/triggers.js +25 -27
- package/dist/automations/utils.js +5 -10
- package/dist/constants/index.js +0 -7
- package/dist/db/linkedRows/LinkController.js +7 -3
- package/dist/db/linkedRows/index.js +27 -16
- package/dist/db/linkedRows/linkUtils.js +6 -6
- package/dist/db/views/staticViews.js +10 -9
- package/dist/definitions/datasource.js +0 -1
- package/dist/environment.js +1 -4
- package/dist/integrations/base/sql.js +14 -56
- package/dist/integrations/index.js +0 -3
- package/dist/integrations/utils.js +9 -60
- package/dist/middleware/authorized.js +30 -57
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +37 -41
- package/dist/middleware/usageQuota.js +15 -82
- package/dist/package.json +5 -8
- package/dist/tests/utilities/TestConfiguration.js +50 -80
- package/dist/threads/automation.js +11 -13
- package/dist/threads/query.js +11 -15
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +3 -4
- package/dist/utilities/global.js +12 -15
- package/dist/utilities/index.js +17 -7
- package/dist/utilities/routing/index.js +5 -5
- package/dist/utilities/rowProcessor/index.js +17 -23
- package/dist/utilities/rowProcessor/utils.js +4 -14
- package/dist/utilities/{usageQuota/index.js → usageQuota.js} +31 -45
- package/dist/utilities/users.js +3 -3
- package/dist/utilities/workerRequests.js +24 -4
- package/nodemon.json +1 -1
- package/package.json +6 -9
- package/scripts/integrations/postgres/init.sql +6 -11
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/application.js +50 -85
- package/src/api/controllers/auth.js +5 -8
- package/src/api/controllers/automation.js +23 -13
- package/src/api/controllers/cloud.js +3 -2
- package/src/api/controllers/component.js +4 -3
- package/src/api/controllers/datasource.js +11 -21
- package/src/api/controllers/deploy/Deployment.js +7 -3
- package/src/api/controllers/deploy/index.js +13 -20
- package/src/api/controllers/dev.js +5 -5
- package/src/api/controllers/hosting.js +22 -0
- package/src/api/controllers/layout.js +3 -3
- package/src/api/controllers/metadata.js +9 -4
- package/src/api/controllers/permission.js +4 -4
- package/src/api/controllers/query/import/index.ts +6 -4
- package/src/api/controllers/query/import/tests/index.spec.js +1 -2
- package/src/api/controllers/query/index.js +10 -11
- package/src/api/controllers/role.js +5 -5
- package/src/api/controllers/routing.js +6 -5
- package/src/api/controllers/row/ExternalRequest.ts +43 -67
- package/src/api/controllers/row/external.js +58 -27
- package/src/api/controllers/row/internal.js +90 -54
- package/src/api/controllers/row/internalSearch.js +17 -23
- package/src/api/controllers/row/utils.js +18 -13
- package/src/api/controllers/screen.js +7 -5
- package/src/api/controllers/static/index.js +12 -65
- package/src/api/controllers/table/external.js +10 -7
- package/src/api/controllers/table/index.js +28 -20
- package/src/api/controllers/table/internal.js +19 -24
- package/src/api/controllers/table/utils.js +42 -78
- package/src/api/controllers/user.js +20 -19
- package/src/api/controllers/view/index.js +10 -8
- package/src/api/controllers/view/utils.js +4 -9
- package/src/api/controllers/webhook.js +8 -10
- package/src/api/routes/hosting.js +13 -0
- package/src/api/routes/index.js +2 -2
- package/src/api/routes/static.js +0 -5
- package/src/api/routes/tests/application.spec.js +2 -2
- package/src/api/routes/tests/auth.spec.js +2 -1
- package/src/api/routes/tests/automation.spec.js +0 -1
- package/src/api/routes/tests/hosting.spec.js +36 -0
- package/src/api/routes/tests/misc.spec.js +1 -0
- package/src/api/routes/tests/routing.spec.js +12 -21
- package/src/api/routes/tests/row.spec.js +4 -7
- package/src/api/routes/tests/utilities/TestFunctions.js +17 -39
- package/src/app.ts +5 -18
- package/src/automations/automationUtils.js +3 -2
- package/src/automations/steps/createRow.js +5 -2
- package/src/automations/steps/deleteRow.js +4 -1
- package/src/automations/steps/updateRow.js +1 -1
- package/src/automations/triggers.js +31 -33
- package/src/automations/utils.js +5 -9
- package/src/constants/index.js +0 -9
- package/src/db/linkedRows/LinkController.js +7 -3
- package/src/db/linkedRows/index.js +31 -16
- package/src/db/linkedRows/linkUtils.js +6 -6
- package/src/db/tests/linkController.spec.js +1 -0
- package/src/db/tests/linkTests.spec.js +6 -5
- package/src/db/views/staticViews.js +10 -8
- package/src/definitions/common.ts +0 -3
- package/src/definitions/datasource.ts +0 -3
- package/src/environment.js +1 -4
- package/src/integrations/base/sql.ts +21 -69
- package/src/integrations/index.ts +0 -3
- package/src/integrations/tests/sql.spec.js +0 -16
- package/src/integrations/utils.ts +12 -75
- package/src/middleware/authorized.js +30 -66
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +46 -50
- package/src/middleware/tests/authorized.spec.js +6 -13
- package/src/middleware/tests/currentapp.spec.js +0 -6
- package/src/middleware/tests/usageQuota.spec.js +24 -18
- package/src/middleware/usageQuota.js +17 -93
- package/src/tests/utilities/TestConfiguration.js +55 -82
- package/src/threads/automation.js +15 -17
- package/src/threads/query.js +12 -17
- package/src/utilities/fileSystem/index.js +3 -4
- package/src/utilities/global.js +12 -15
- package/src/utilities/index.js +17 -7
- package/src/utilities/routing/index.js +5 -5
- package/src/utilities/rowProcessor/index.js +27 -25
- package/src/utilities/rowProcessor/utils.js +7 -23
- package/src/utilities/usageQuota.js +73 -0
- package/src/utilities/users.js +3 -3
- package/src/utilities/workerRequests.js +27 -4
- package/tsconfig.json +1 -2
- package/builder/assets/index.83c0944f.css +0 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +0 -119
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +0 -548
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +0 -599
- package/coverage/lcov-report/utilities/usageQuota/index.html +0 -141
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +0 -359
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +0 -305
- package/dist/api/controllers/migrations.js +0 -21
- package/dist/api/controllers/row/staticFormula.js +0 -147
- package/dist/api/controllers/table/bulkFormula.js +0 -159
- package/dist/api/routes/migrations.js +0 -9
- package/dist/integrations/googlesheets.js +0 -340
- package/dist/migrations/functions/appUrls.js +0 -46
- package/dist/migrations/functions/quotas1.js +0 -50
- package/dist/migrations/functions/usageQuotas/index.js +0 -20
- package/dist/migrations/functions/usageQuotas/syncApps.js +0 -29
- package/dist/migrations/functions/usageQuotas/syncRows.js +0 -33
- package/dist/migrations/functions/userEmailViewCasing.js +0 -24
- package/dist/migrations/index.js +0 -62
- package/dist/utilities/usageQuota/rows.js +0 -78
- package/dist/utilities/usageQuota/usageQuoteReset.js +0 -16
- package/src/api/controllers/migrations.js +0 -13
- package/src/api/controllers/row/staticFormula.js +0 -156
- package/src/api/controllers/table/bulkFormula.js +0 -173
- package/src/api/routes/migrations.js +0 -14
- package/src/api/routes/tests/static.spec.js +0 -98
- package/src/integrations/googlesheets.ts +0 -353
- package/src/migrations/functions/appUrls.ts +0 -34
- package/src/migrations/functions/quotas1.ts +0 -20
- package/src/migrations/functions/tests/appUrls.spec.js +0 -29
- package/src/migrations/functions/tests/quotas1.spec.js +0 -27
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +0 -25
- package/src/migrations/functions/usageQuotas/index.ts +0 -8
- package/src/migrations/functions/usageQuotas/syncApps.ts +0 -18
- package/src/migrations/functions/usageQuotas/syncRows.ts +0 -22
- package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +0 -37
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +0 -43
- package/src/migrations/functions/userEmailViewCasing.ts +0 -13
- package/src/migrations/index.ts +0 -56
- package/src/module.d.ts +0 -3
- package/src/utilities/tests/usageQuota/usageQuota.spec.js +0 -72
- package/src/utilities/usageQuota/index.js +0 -93
- package/src/utilities/usageQuota/rows.js +0 -75
- package/src/utilities/usageQuota/usageQuoteReset.js +0 -18
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const CouchDB = require("../../db")
|
|
1
2
|
const {
|
|
2
3
|
generateUserMetadataID,
|
|
3
4
|
getUserMetadataParams,
|
|
@@ -10,14 +11,12 @@ const { isEqual } = require("lodash")
|
|
|
10
11
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
11
12
|
const {
|
|
12
13
|
getDevelopmentAppID,
|
|
13
|
-
|
|
14
|
-
dbExists,
|
|
14
|
+
getDeployedAppIDs,
|
|
15
15
|
} = require("@budibase/backend-core/db")
|
|
16
|
+
const { doesDatabaseExist } = require("../../utilities")
|
|
16
17
|
const { UserStatus } = require("@budibase/backend-core/constants")
|
|
17
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
18
18
|
|
|
19
|
-
async function rawMetadata() {
|
|
20
|
-
const db = getAppDB()
|
|
19
|
+
async function rawMetadata(db) {
|
|
21
20
|
return (
|
|
22
21
|
await db.allDocs(
|
|
23
22
|
getUserMetadataParams(null, {
|
|
@@ -55,10 +54,13 @@ function combineMetadataAndUser(user, metadata) {
|
|
|
55
54
|
return null
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
exports.syncGlobalUsers = async
|
|
57
|
+
exports.syncGlobalUsers = async appId => {
|
|
59
58
|
// sync user metadata
|
|
60
|
-
const db =
|
|
61
|
-
const [users, metadata] = await Promise.all([
|
|
59
|
+
const db = new CouchDB(appId)
|
|
60
|
+
const [users, metadata] = await Promise.all([
|
|
61
|
+
getGlobalUsers(appId),
|
|
62
|
+
rawMetadata(db),
|
|
63
|
+
])
|
|
62
64
|
const toWrite = []
|
|
63
65
|
for (let user of users) {
|
|
64
66
|
const combined = await combineMetadataAndUser(user, metadata)
|
|
@@ -92,7 +94,7 @@ exports.syncUser = async function (ctx) {
|
|
|
92
94
|
let prodAppIds
|
|
93
95
|
// if they are a builder then get all production app IDs
|
|
94
96
|
if ((user.builder && user.builder.global) || deleting) {
|
|
95
|
-
prodAppIds = await
|
|
97
|
+
prodAppIds = await getDeployedAppIDs(CouchDB)
|
|
96
98
|
} else {
|
|
97
99
|
prodAppIds = Object.entries(roles)
|
|
98
100
|
.filter(entry => entry[1] !== BUILTIN_ROLE_IDS.PUBLIC)
|
|
@@ -102,10 +104,10 @@ exports.syncUser = async function (ctx) {
|
|
|
102
104
|
const roleId = roles[prodAppId]
|
|
103
105
|
const devAppId = getDevelopmentAppID(prodAppId)
|
|
104
106
|
for (let appId of [prodAppId, devAppId]) {
|
|
105
|
-
if (!(await
|
|
107
|
+
if (!(await doesDatabaseExist(appId))) {
|
|
106
108
|
continue
|
|
107
109
|
}
|
|
108
|
-
const db =
|
|
110
|
+
const db = new CouchDB(appId)
|
|
109
111
|
const metadataId = generateUserMetadataID(userId)
|
|
110
112
|
let metadata
|
|
111
113
|
try {
|
|
@@ -141,8 +143,8 @@ exports.syncUser = async function (ctx) {
|
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
exports.fetchMetadata = async function (ctx) {
|
|
144
|
-
const database =
|
|
145
|
-
const global = await getGlobalUsers()
|
|
146
|
+
const database = new CouchDB(ctx.appId)
|
|
147
|
+
const global = await getGlobalUsers(ctx.appId)
|
|
146
148
|
const metadata = await rawMetadata(database)
|
|
147
149
|
const users = []
|
|
148
150
|
for (let user of global) {
|
|
@@ -165,13 +167,12 @@ exports.updateSelfMetadata = async function (ctx) {
|
|
|
165
167
|
ctx.request.body._id = ctx.user._id
|
|
166
168
|
// make sure no stale rev
|
|
167
169
|
delete ctx.request.body._rev
|
|
168
|
-
// make sure no csrf token
|
|
169
|
-
delete ctx.request.body.csrfToken
|
|
170
170
|
await exports.updateMetadata(ctx)
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
exports.updateMetadata = async function (ctx) {
|
|
174
|
-
const
|
|
174
|
+
const appId = ctx.appId
|
|
175
|
+
const db = new CouchDB(appId)
|
|
175
176
|
const user = ctx.request.body
|
|
176
177
|
// this isn't applicable to the user
|
|
177
178
|
delete user.roles
|
|
@@ -183,7 +184,7 @@ exports.updateMetadata = async function (ctx) {
|
|
|
183
184
|
}
|
|
184
185
|
|
|
185
186
|
exports.destroyMetadata = async function (ctx) {
|
|
186
|
-
const db =
|
|
187
|
+
const db = new CouchDB(ctx.appId)
|
|
187
188
|
try {
|
|
188
189
|
const dbUser = await db.get(ctx.params.id)
|
|
189
190
|
await db.remove(dbUser._id, dbUser._rev)
|
|
@@ -206,7 +207,7 @@ exports.setFlag = async function (ctx) {
|
|
|
206
207
|
ctx.throw(400, "Must supply a 'flag' field in request body.")
|
|
207
208
|
}
|
|
208
209
|
const flagDocId = generateUserFlagID(userId)
|
|
209
|
-
const db =
|
|
210
|
+
const db = new CouchDB(ctx.appId)
|
|
210
211
|
let doc
|
|
211
212
|
try {
|
|
212
213
|
doc = await db.get(flagDocId)
|
|
@@ -221,7 +222,7 @@ exports.setFlag = async function (ctx) {
|
|
|
221
222
|
exports.getFlags = async function (ctx) {
|
|
222
223
|
const userId = ctx.user._id
|
|
223
224
|
const docId = generateUserFlagID(userId)
|
|
224
|
-
const db =
|
|
225
|
+
const db = new CouchDB(ctx.appId)
|
|
225
226
|
let doc
|
|
226
227
|
try {
|
|
227
228
|
doc = await db.get(docId)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const CouchDB = require("../../../db")
|
|
1
2
|
const viewTemplate = require("./viewBuilder")
|
|
2
3
|
const { apiFileReturn } = require("../../../utilities/fileSystem")
|
|
3
4
|
const exporters = require("./exporters")
|
|
@@ -5,14 +6,14 @@ const { saveView, getView, getViews, deleteView } = require("./utils")
|
|
|
5
6
|
const { fetchView } = require("../row")
|
|
6
7
|
const { getTable } = require("../table/utils")
|
|
7
8
|
const { FieldTypes } = require("../../../constants")
|
|
8
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
9
9
|
|
|
10
10
|
exports.fetch = async ctx => {
|
|
11
|
-
|
|
11
|
+
const db = new CouchDB(ctx.appId)
|
|
12
|
+
ctx.body = await getViews(db)
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
exports.save = async ctx => {
|
|
15
|
-
const db =
|
|
16
|
+
const db = new CouchDB(ctx.appId)
|
|
16
17
|
const { originalName, ...viewToSave } = ctx.request.body
|
|
17
18
|
const view = viewTemplate(viewToSave)
|
|
18
19
|
|
|
@@ -20,7 +21,7 @@ exports.save = async ctx => {
|
|
|
20
21
|
ctx.throw(400, "Cannot create view without a name")
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
await saveView(originalName, viewToSave.name, view)
|
|
24
|
+
await saveView(db, originalName, viewToSave.name, view)
|
|
24
25
|
|
|
25
26
|
// add views to table document
|
|
26
27
|
const table = await db.get(ctx.request.body.tableId)
|
|
@@ -41,9 +42,9 @@ exports.save = async ctx => {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
exports.destroy = async ctx => {
|
|
44
|
-
const db =
|
|
45
|
+
const db = new CouchDB(ctx.appId)
|
|
45
46
|
const viewName = decodeURI(ctx.params.viewName)
|
|
46
|
-
const view = await deleteView(viewName)
|
|
47
|
+
const view = await deleteView(db, viewName)
|
|
47
48
|
const table = await db.get(view.meta.tableId)
|
|
48
49
|
delete table.views[viewName]
|
|
49
50
|
await db.put(table)
|
|
@@ -52,8 +53,9 @@ exports.destroy = async ctx => {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
exports.exportView = async ctx => {
|
|
56
|
+
const db = new CouchDB(ctx.appId)
|
|
55
57
|
const viewName = decodeURI(ctx.query.view)
|
|
56
|
-
const view = await getView(viewName)
|
|
58
|
+
const view = await getView(db, viewName)
|
|
57
59
|
|
|
58
60
|
const format = ctx.query.format
|
|
59
61
|
if (!format || !Object.values(exporters.ExportFormats).includes(format)) {
|
|
@@ -81,7 +83,7 @@ exports.exportView = async ctx => {
|
|
|
81
83
|
let schema = view && view.meta && view.meta.schema
|
|
82
84
|
if (!schema) {
|
|
83
85
|
const tableId = ctx.params.tableId || view.meta.tableId
|
|
84
|
-
const table = await getTable(tableId)
|
|
86
|
+
const table = await getTable(ctx.appId, tableId)
|
|
85
87
|
schema = table.schema
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -6,10 +6,8 @@ const {
|
|
|
6
6
|
SEPARATOR,
|
|
7
7
|
} = require("../../../db/utils")
|
|
8
8
|
const env = require("../../../environment")
|
|
9
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
10
9
|
|
|
11
|
-
exports.getView = async viewName => {
|
|
12
|
-
const db = getAppDB()
|
|
10
|
+
exports.getView = async (db, viewName) => {
|
|
13
11
|
if (env.SELF_HOSTED) {
|
|
14
12
|
const designDoc = await db.get("_design/database")
|
|
15
13
|
return designDoc.views[viewName]
|
|
@@ -24,8 +22,7 @@ exports.getView = async viewName => {
|
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
exports.getViews = async
|
|
28
|
-
const db = getAppDB()
|
|
25
|
+
exports.getViews = async db => {
|
|
29
26
|
const response = []
|
|
30
27
|
if (env.SELF_HOSTED) {
|
|
31
28
|
const designDoc = await db.get("_design/database")
|
|
@@ -57,8 +54,7 @@ exports.getViews = async () => {
|
|
|
57
54
|
return response
|
|
58
55
|
}
|
|
59
56
|
|
|
60
|
-
exports.saveView = async (originalName, viewName, viewTemplate) => {
|
|
61
|
-
const db = getAppDB()
|
|
57
|
+
exports.saveView = async (db, originalName, viewName, viewTemplate) => {
|
|
62
58
|
if (env.SELF_HOSTED) {
|
|
63
59
|
const designDoc = await db.get("_design/database")
|
|
64
60
|
designDoc.views = {
|
|
@@ -95,8 +91,7 @@ exports.saveView = async (originalName, viewName, viewTemplate) => {
|
|
|
95
91
|
}
|
|
96
92
|
}
|
|
97
93
|
|
|
98
|
-
exports.deleteView = async viewName => {
|
|
99
|
-
const db = getAppDB()
|
|
94
|
+
exports.deleteView = async (db, viewName) => {
|
|
100
95
|
if (env.SELF_HOSTED) {
|
|
101
96
|
const designDoc = await db.get("_design/database")
|
|
102
97
|
const view = designDoc.views[viewName]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
const CouchDB = require("../../db")
|
|
1
2
|
const { generateWebhookID, getWebhookParams } = require("../../db/utils")
|
|
2
3
|
const toJsonSchema = require("to-json-schema")
|
|
3
4
|
const validate = require("jsonschema").validate
|
|
4
5
|
const triggers = require("../../automations/triggers")
|
|
5
|
-
const {
|
|
6
|
-
const { getAppDB, updateAppId } = require("@budibase/backend-core/context")
|
|
6
|
+
const { getDeployedAppID } = require("@budibase/backend-core/db")
|
|
7
7
|
|
|
8
8
|
const AUTOMATION_DESCRIPTION = "Generated from Webhook Schema"
|
|
9
9
|
|
|
@@ -23,7 +23,7 @@ exports.WebhookType = {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
exports.fetch = async ctx => {
|
|
26
|
-
const db =
|
|
26
|
+
const db = new CouchDB(ctx.appId)
|
|
27
27
|
const response = await db.allDocs(
|
|
28
28
|
getWebhookParams(null, {
|
|
29
29
|
include_docs: true,
|
|
@@ -33,7 +33,7 @@ exports.fetch = async ctx => {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
exports.save = async ctx => {
|
|
36
|
-
const db =
|
|
36
|
+
const db = new CouchDB(ctx.appId)
|
|
37
37
|
const webhook = ctx.request.body
|
|
38
38
|
webhook.appId = ctx.appId
|
|
39
39
|
|
|
@@ -52,13 +52,12 @@ exports.save = async ctx => {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
exports.destroy = async ctx => {
|
|
55
|
-
const db =
|
|
55
|
+
const db = new CouchDB(ctx.appId)
|
|
56
56
|
ctx.body = await db.remove(ctx.params.id, ctx.params.rev)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
exports.buildSchema = async ctx => {
|
|
60
|
-
|
|
61
|
-
const db = getAppDB()
|
|
60
|
+
const db = new CouchDB(ctx.params.instance)
|
|
62
61
|
const webhook = await db.get(ctx.params.id)
|
|
63
62
|
webhook.bodySchema = toJsonSchema(ctx.request.body)
|
|
64
63
|
// update the automation outputs
|
|
@@ -82,10 +81,9 @@ exports.buildSchema = async ctx => {
|
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
exports.trigger = async ctx => {
|
|
85
|
-
const prodAppId =
|
|
86
|
-
updateAppId(prodAppId)
|
|
84
|
+
const prodAppId = getDeployedAppID(ctx.params.instance)
|
|
87
85
|
try {
|
|
88
|
-
const db =
|
|
86
|
+
const db = new CouchDB(prodAppId)
|
|
89
87
|
const webhook = await db.get(ctx.params.id)
|
|
90
88
|
// validate against the schema
|
|
91
89
|
if (webhook.bodySchema) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const Router = require("@koa/router")
|
|
2
|
+
const controller = require("../controllers/hosting")
|
|
3
|
+
const authorized = require("../../middleware/authorized")
|
|
4
|
+
const { BUILDER } = require("@budibase/backend-core/permissions")
|
|
5
|
+
|
|
6
|
+
const router = Router()
|
|
7
|
+
|
|
8
|
+
router
|
|
9
|
+
.get("/api/hosting/urls", authorized(BUILDER), controller.fetchUrls)
|
|
10
|
+
// this isn't risky, doesn't return anything about apps other than names and URLs
|
|
11
|
+
.get("/api/hosting/apps", controller.getDeployedApps)
|
|
12
|
+
|
|
13
|
+
module.exports = router
|
package/src/api/routes/index.js
CHANGED
|
@@ -20,11 +20,11 @@ const integrationRoutes = require("./integration")
|
|
|
20
20
|
const permissionRoutes = require("./permission")
|
|
21
21
|
const datasourceRoutes = require("./datasource")
|
|
22
22
|
const queryRoutes = require("./query")
|
|
23
|
+
const hostingRoutes = require("./hosting")
|
|
23
24
|
const backupRoutes = require("./backup")
|
|
24
25
|
const metadataRoutes = require("./metadata")
|
|
25
26
|
const devRoutes = require("./dev")
|
|
26
27
|
const cloudRoutes = require("./cloud")
|
|
27
|
-
const migrationRoutes = require("./migrations")
|
|
28
28
|
|
|
29
29
|
exports.mainRoutes = [
|
|
30
30
|
authRoutes,
|
|
@@ -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,7 +55,6 @@ 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
|
|
|
60
60
|
exports.staticRoutes = staticRoutes
|
package/src/api/routes/static.js
CHANGED
|
@@ -46,10 +46,5 @@ router
|
|
|
46
46
|
)
|
|
47
47
|
// TODO: this likely needs to be secured in some way
|
|
48
48
|
.get("/:appId/:path*", controller.serveApp)
|
|
49
|
-
.post(
|
|
50
|
-
"/api/attachments/:datasourceId/url",
|
|
51
|
-
authorized(PermissionTypes.TABLE, PermissionLevels.READ),
|
|
52
|
-
controller.getSignedUploadURL
|
|
53
|
-
)
|
|
54
49
|
|
|
55
50
|
module.exports = router
|
|
@@ -53,8 +53,8 @@ describe("/applications", () => {
|
|
|
53
53
|
|
|
54
54
|
describe("fetch", () => {
|
|
55
55
|
it("lists all applications", async () => {
|
|
56
|
-
await config.createApp("app1")
|
|
57
|
-
await config.createApp("app2")
|
|
56
|
+
await config.createApp(request, "app1")
|
|
57
|
+
await config.createApp(request, "app2")
|
|
58
58
|
|
|
59
59
|
const res = await request
|
|
60
60
|
.get(`/api/applications?status=${AppStatus.DEV}`)
|
|
@@ -13,9 +13,10 @@ describe("/authenticate", () => {
|
|
|
13
13
|
|
|
14
14
|
describe("fetch self", () => {
|
|
15
15
|
it("should be able to fetch self", async () => {
|
|
16
|
+
const headers = await config.login()
|
|
16
17
|
const res = await request
|
|
17
18
|
.get(`/api/self`)
|
|
18
|
-
.set(
|
|
19
|
+
.set(headers)
|
|
19
20
|
.expect("Content-Type", /json/)
|
|
20
21
|
.expect(200)
|
|
21
22
|
expect(res.body._id).toEqual(generateUserMetadataID("us_uuid1"))
|
|
@@ -145,7 +145,6 @@ describe("/automations", () => {
|
|
|
145
145
|
let table = await config.createTable()
|
|
146
146
|
automation.definition.trigger.inputs.tableId = table._id
|
|
147
147
|
automation.definition.steps[0].inputs.row.tableId = table._id
|
|
148
|
-
automation.appId = config.appId
|
|
149
148
|
automation = await config.createAutomation(automation)
|
|
150
149
|
await setup.delay(500)
|
|
151
150
|
const res = await testAutomation(config, automation)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// mock out node fetch for this
|
|
2
|
+
jest.mock("node-fetch")
|
|
3
|
+
|
|
4
|
+
const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
5
|
+
const setup = require("./utilities")
|
|
6
|
+
|
|
7
|
+
describe("/hosting", () => {
|
|
8
|
+
let request = setup.getRequest()
|
|
9
|
+
let config = setup.getConfig()
|
|
10
|
+
let app
|
|
11
|
+
|
|
12
|
+
afterAll(setup.afterAll)
|
|
13
|
+
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
app = await config.init()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
describe("fetchUrls", () => {
|
|
19
|
+
it("should be able to fetch current app URLs", async () => {
|
|
20
|
+
const res = await request
|
|
21
|
+
.get(`/api/hosting/urls`)
|
|
22
|
+
.set(config.defaultHeaders())
|
|
23
|
+
.expect("Content-Type", /json/)
|
|
24
|
+
.expect(200)
|
|
25
|
+
expect(res.body.app).toEqual(`http://localhost:10000/app`)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it("should apply authorization to endpoint", async () => {
|
|
29
|
+
await checkBuilderEndpoint({
|
|
30
|
+
config,
|
|
31
|
+
method: "GET",
|
|
32
|
+
url: `/api/hosting/urls`,
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
})
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
const setup = require("./utilities")
|
|
2
2
|
const { basicScreen } = setup.structures
|
|
3
|
-
const { checkBuilderEndpoint
|
|
3
|
+
const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
4
4
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
5
|
-
const { doInAppContext } = require("@budibase/backend-core/context")
|
|
6
5
|
|
|
7
6
|
const route = "/test"
|
|
8
7
|
|
|
9
|
-
// there are checks which are disabled in test env,
|
|
10
|
-
// these checks need to be enabled for this test
|
|
11
|
-
|
|
12
|
-
|
|
13
8
|
describe("/routing", () => {
|
|
14
9
|
let request = setup.getRequest()
|
|
15
10
|
let config = setup.getConfig()
|
|
@@ -31,24 +26,20 @@ describe("/routing", () => {
|
|
|
31
26
|
|
|
32
27
|
describe("fetch", () => {
|
|
33
28
|
it("prevents a public user from accessing development app", async () => {
|
|
34
|
-
await
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.expect(302)
|
|
39
|
-
})
|
|
29
|
+
await request
|
|
30
|
+
.get(`/api/routing/client`)
|
|
31
|
+
.set(config.publicHeaders({ prodApp: false }))
|
|
32
|
+
.expect(302)
|
|
40
33
|
})
|
|
41
34
|
|
|
42
35
|
it("prevents a non builder from accessing development app", async () => {
|
|
43
|
-
await
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.expect(302)
|
|
51
|
-
})
|
|
36
|
+
await request
|
|
37
|
+
.get(`/api/routing/client`)
|
|
38
|
+
.set(await config.roleHeaders({
|
|
39
|
+
roleId: BUILTIN_ROLE_IDS.BASIC,
|
|
40
|
+
prodApp: false
|
|
41
|
+
}))
|
|
42
|
+
.expect(302)
|
|
52
43
|
})
|
|
53
44
|
it("returns the correct routing for basic user", async () => {
|
|
54
45
|
const res = await request
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { outputProcessing } = require("../../../utilities/rowProcessor")
|
|
2
2
|
const setup = require("./utilities")
|
|
3
3
|
const { basicRow } = setup.structures
|
|
4
|
-
const { doInAppContext } = require("@budibase/backend-core/context")
|
|
5
4
|
|
|
6
5
|
// mock the fetch for the search system
|
|
7
6
|
jest.mock("node-fetch")
|
|
@@ -388,12 +387,10 @@ describe("/rows", () => {
|
|
|
388
387
|
})
|
|
389
388
|
// the environment needs configured for this
|
|
390
389
|
await setup.switchToSelfHosted(async () => {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
)
|
|
396
|
-
})
|
|
390
|
+
const enriched = await outputProcessing({ appId: config.getAppId() }, table, [row])
|
|
391
|
+
expect(enriched[0].attachment[0].url).toBe(
|
|
392
|
+
`/prod-budi-app-assets/${config.getAppId()}/attachments/test/thing.csv`
|
|
393
|
+
)
|
|
397
394
|
})
|
|
398
395
|
})
|
|
399
396
|
})
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
const rowController = require("../../../controllers/row")
|
|
2
2
|
const appController = require("../../../controllers/application")
|
|
3
|
+
const CouchDB = require("../../../../db")
|
|
3
4
|
const { AppStatus } = require("../../../../db/utils")
|
|
4
5
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
5
6
|
const { TENANT_ID } = require("../../../../tests/utilities/structures")
|
|
6
|
-
const { getAppDB, doInAppContext } = require("@budibase/backend-core/context")
|
|
7
|
-
const env = require("../../../../environment")
|
|
8
7
|
|
|
9
8
|
function Request(appId, params) {
|
|
10
9
|
this.appId = appId
|
|
@@ -12,15 +11,9 @@ function Request(appId, params) {
|
|
|
12
11
|
this.request = {}
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
function runRequest(appId, controlFunc, request) {
|
|
16
|
-
return doInAppContext(appId, async () => {
|
|
17
|
-
return controlFunc(request)
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
|
|
21
14
|
exports.getAllTableRows = async config => {
|
|
22
15
|
const req = new Request(config.appId, { tableId: config.table._id })
|
|
23
|
-
await
|
|
16
|
+
await rowController.fetch(req)
|
|
24
17
|
return req.body
|
|
25
18
|
}
|
|
26
19
|
|
|
@@ -33,17 +26,14 @@ exports.clearAllApps = async (tenantId = TENANT_ID) => {
|
|
|
33
26
|
}
|
|
34
27
|
for (let app of apps) {
|
|
35
28
|
const { appId } = app
|
|
36
|
-
|
|
37
|
-
await runRequest(appId, appController.delete, req)
|
|
29
|
+
await appController.delete(new Request(null, { appId }))
|
|
38
30
|
}
|
|
39
31
|
}
|
|
40
32
|
|
|
41
33
|
exports.clearAllAutomations = async config => {
|
|
42
34
|
const automations = await config.getAllAutomations()
|
|
43
35
|
for (let auto of automations) {
|
|
44
|
-
await
|
|
45
|
-
await config.deleteAutomation(auto)
|
|
46
|
-
})
|
|
36
|
+
await config.deleteAutomation(auto)
|
|
47
37
|
}
|
|
48
38
|
}
|
|
49
39
|
|
|
@@ -106,32 +96,20 @@ exports.checkPermissionsEndpoint = async ({
|
|
|
106
96
|
.expect(403)
|
|
107
97
|
}
|
|
108
98
|
|
|
109
|
-
exports.getDB =
|
|
110
|
-
return
|
|
99
|
+
exports.getDB = config => {
|
|
100
|
+
return new CouchDB(config.getAppId())
|
|
111
101
|
}
|
|
112
102
|
|
|
113
103
|
exports.testAutomation = async (config, automation) => {
|
|
114
|
-
return
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
.expect(200)
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
exports.runInProd = async func => {
|
|
130
|
-
const nodeEnv = env.NODE_ENV
|
|
131
|
-
const workerId = env.JEST_WORKER_ID
|
|
132
|
-
env._set("NODE_ENV", "PRODUCTION")
|
|
133
|
-
env._set("JEST_WORKER_ID", null)
|
|
134
|
-
await func()
|
|
135
|
-
env._set("NODE_ENV", nodeEnv)
|
|
136
|
-
env._set("JEST_WORKER_ID", workerId)
|
|
104
|
+
return await config.request
|
|
105
|
+
.post(`/api/automations/${automation._id}/test`)
|
|
106
|
+
.send({
|
|
107
|
+
row: {
|
|
108
|
+
name: "Test",
|
|
109
|
+
description: "TEST",
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
.set(config.defaultHeaders())
|
|
113
|
+
.expect("Content-Type", /json/)
|
|
114
|
+
.expect(200)
|
|
137
115
|
}
|
package/src/app.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// need to load environment first
|
|
2
2
|
import { ExtendableContext } from "koa"
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const env = require("./environment")
|
|
5
5
|
const CouchDB = require("./db")
|
|
6
6
|
require("@budibase/backend-core").init(CouchDB)
|
|
7
7
|
const Koa = require("koa")
|
|
@@ -16,7 +16,6 @@ const Sentry = require("@sentry/node")
|
|
|
16
16
|
const fileSystem = require("./utilities/fileSystem")
|
|
17
17
|
const bullboard = require("./automations/bullboard")
|
|
18
18
|
const redis = require("./utilities/redis")
|
|
19
|
-
import * as migrations from "./migrations"
|
|
20
19
|
|
|
21
20
|
const app = new Koa()
|
|
22
21
|
|
|
@@ -85,25 +84,13 @@ module.exports = server.listen(env.PORT || 0, async () => {
|
|
|
85
84
|
await automations.init()
|
|
86
85
|
})
|
|
87
86
|
|
|
88
|
-
const shutdown = () => {
|
|
89
|
-
server.close()
|
|
90
|
-
server.destroy()
|
|
91
|
-
}
|
|
92
|
-
|
|
93
87
|
process.on("uncaughtException", err => {
|
|
94
88
|
console.error(err)
|
|
95
|
-
|
|
89
|
+
server.close()
|
|
90
|
+
server.destroy()
|
|
96
91
|
})
|
|
97
92
|
|
|
98
93
|
process.on("SIGTERM", () => {
|
|
99
|
-
|
|
94
|
+
server.close()
|
|
95
|
+
server.destroy()
|
|
100
96
|
})
|
|
101
|
-
|
|
102
|
-
// run migrations on startup if not done via http
|
|
103
|
-
// not recommended in a clustered environment
|
|
104
|
-
if (!env.HTTP_MIGRATIONS) {
|
|
105
|
-
migrations.migrate().catch(err => {
|
|
106
|
-
console.error("Error performing migrations. Exiting.\n", err)
|
|
107
|
-
shutdown()
|
|
108
|
-
})
|
|
109
|
-
}
|
|
@@ -53,12 +53,13 @@ exports.cleanInputValues = (inputs, schema) => {
|
|
|
53
53
|
* the automation but is instead part of the Table/Table. This function will get the table schema and use it to instead
|
|
54
54
|
* perform the cleanInputValues function on the input row.
|
|
55
55
|
*
|
|
56
|
+
* @param {string} appId The instance which the Table/Table is contained under.
|
|
56
57
|
* @param {string} tableId The ID of the Table/Table which the schema is to be retrieved for.
|
|
57
58
|
* @param {object} row The input row structure which requires clean-up after having been through template statements.
|
|
58
59
|
* @returns {Promise<Object>} The cleaned up rows object, will should now have all the required primitive types.
|
|
59
60
|
*/
|
|
60
|
-
exports.cleanUpRow = async (tableId, row) => {
|
|
61
|
-
let table = await getTable(tableId)
|
|
61
|
+
exports.cleanUpRow = async (appId, tableId, row) => {
|
|
62
|
+
let table = await getTable(appId, tableId)
|
|
62
63
|
return exports.cleanInputValues(row, { properties: table.schema })
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const rowController = require("../../api/controllers/row")
|
|
2
2
|
const automationUtils = require("../automationUtils")
|
|
3
|
+
const env = require("../../environment")
|
|
3
4
|
const usage = require("../../utilities/usageQuota")
|
|
4
5
|
const { buildCtx } = require("./utils")
|
|
5
6
|
|
|
@@ -78,12 +79,14 @@ exports.run = async function ({ inputs, appId, emitter }) {
|
|
|
78
79
|
|
|
79
80
|
try {
|
|
80
81
|
inputs.row = await automationUtils.cleanUpRow(
|
|
82
|
+
appId,
|
|
81
83
|
inputs.row.tableId,
|
|
82
84
|
inputs.row
|
|
83
85
|
)
|
|
84
|
-
|
|
86
|
+
if (env.USE_QUOTAS) {
|
|
87
|
+
await usage.update(usage.Properties.ROW, 1)
|
|
88
|
+
}
|
|
85
89
|
await rowController.save(ctx)
|
|
86
|
-
await usage.update(usage.Properties.ROW, 1)
|
|
87
90
|
return {
|
|
88
91
|
row: inputs.row,
|
|
89
92
|
response: ctx.body,
|