@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
|
@@ -19,19 +19,6 @@ import {
|
|
|
19
19
|
isRowId,
|
|
20
20
|
convertRowId,
|
|
21
21
|
} from "../../../integrations/utils"
|
|
22
|
-
import { getDatasourceAndQuery } from "./utils"
|
|
23
|
-
import {
|
|
24
|
-
DataSourceOperation,
|
|
25
|
-
FieldTypes,
|
|
26
|
-
RelationshipTypes,
|
|
27
|
-
} from "../../../constants"
|
|
28
|
-
import { breakExternalTableId, isSQL } from "../../../integrations/utils"
|
|
29
|
-
import { processObjectSync } from "@budibase/string-templates"
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
import { cloneDeep } from "lodash/fp"
|
|
32
|
-
import { processFormulas } from "../../../utilities/rowProcessor/utils"
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
import { getAppDB } from "@budibase/backend-core/context"
|
|
35
22
|
|
|
36
23
|
interface ManyRelationship {
|
|
37
24
|
tableId?: string
|
|
@@ -51,6 +38,18 @@ interface RunConfig {
|
|
|
51
38
|
}
|
|
52
39
|
|
|
53
40
|
module External {
|
|
41
|
+
const { getDatasourceAndQuery } = require("./utils")
|
|
42
|
+
const {
|
|
43
|
+
DataSourceOperation,
|
|
44
|
+
FieldTypes,
|
|
45
|
+
RelationshipTypes,
|
|
46
|
+
} = require("../../../constants")
|
|
47
|
+
const { breakExternalTableId, isSQL } = require("../../../integrations/utils")
|
|
48
|
+
const { processObjectSync } = require("@budibase/string-templates")
|
|
49
|
+
const { cloneDeep } = require("lodash/fp")
|
|
50
|
+
const CouchDB = require("../../../db")
|
|
51
|
+
const { processFormulas } = require("../../../utilities/rowProcessor/utils")
|
|
52
|
+
|
|
54
53
|
function buildFilters(
|
|
55
54
|
id: string | undefined,
|
|
56
55
|
filters: SearchFilters,
|
|
@@ -184,7 +183,7 @@ module External {
|
|
|
184
183
|
thisRow._id = generateIdForRow(row, table)
|
|
185
184
|
thisRow.tableId = table._id
|
|
186
185
|
thisRow._rev = "rev"
|
|
187
|
-
return
|
|
186
|
+
return thisRow
|
|
188
187
|
}
|
|
189
188
|
|
|
190
189
|
function fixArrayTypes(row: Row, table: Table) {
|
|
@@ -211,12 +210,19 @@ module External {
|
|
|
211
210
|
}
|
|
212
211
|
|
|
213
212
|
class ExternalRequest {
|
|
213
|
+
private readonly appId: string
|
|
214
214
|
private operation: Operation
|
|
215
215
|
private tableId: string
|
|
216
216
|
private datasource: Datasource
|
|
217
217
|
private tables: { [key: string]: Table } = {}
|
|
218
218
|
|
|
219
|
-
constructor(
|
|
219
|
+
constructor(
|
|
220
|
+
appId: string,
|
|
221
|
+
operation: Operation,
|
|
222
|
+
tableId: string,
|
|
223
|
+
datasource: Datasource
|
|
224
|
+
) {
|
|
225
|
+
this.appId = appId
|
|
220
226
|
this.operation = operation
|
|
221
227
|
this.tableId = tableId
|
|
222
228
|
this.datasource = datasource
|
|
@@ -225,14 +231,12 @@ module External {
|
|
|
225
231
|
}
|
|
226
232
|
}
|
|
227
233
|
|
|
228
|
-
getTable(tableId: string | undefined): Table
|
|
234
|
+
getTable(tableId: string | undefined): Table {
|
|
229
235
|
if (!tableId) {
|
|
230
236
|
throw "Table ID is unknown, cannot find table"
|
|
231
237
|
}
|
|
232
238
|
const { tableName } = breakExternalTableId(tableId)
|
|
233
|
-
|
|
234
|
-
return this.tables[tableName]
|
|
235
|
-
}
|
|
239
|
+
return this.tables[tableName]
|
|
236
240
|
}
|
|
237
241
|
|
|
238
242
|
inputProcessing(row: Row | undefined, table: Table) {
|
|
@@ -268,11 +272,9 @@ module External {
|
|
|
268
272
|
newRow[key] = row[key]
|
|
269
273
|
continue
|
|
270
274
|
}
|
|
271
|
-
const { tableName: linkTableName } = breakExternalTableId(
|
|
272
|
-
field?.tableId
|
|
273
|
-
)
|
|
275
|
+
const { tableName: linkTableName } = breakExternalTableId(field.tableId)
|
|
274
276
|
// table has to exist for many to many
|
|
275
|
-
if (!
|
|
277
|
+
if (!this.tables[linkTableName]) {
|
|
276
278
|
continue
|
|
277
279
|
}
|
|
278
280
|
const linkTable = this.tables[linkTableName]
|
|
@@ -327,12 +329,8 @@ module External {
|
|
|
327
329
|
* This iterates through the returned rows and works out what elements of the rows
|
|
328
330
|
* actually match up to another row (based on primary keys) - this is pretty specific
|
|
329
331
|
* to SQL and the way that SQL relationships are returned based on joins.
|
|
330
|
-
* This is complicated, but the idea is that when a SQL query returns all the relations
|
|
331
|
-
* will be separate rows, with all of the data in each row. We have to decipher what comes
|
|
332
|
-
* from where (which tables) and how to convert that into budibase columns.
|
|
333
332
|
*/
|
|
334
333
|
updateRelationshipColumns(
|
|
335
|
-
table: Table,
|
|
336
334
|
row: Row,
|
|
337
335
|
rows: { [key: string]: Row },
|
|
338
336
|
relationships: RelationshipsJson[]
|
|
@@ -343,13 +341,6 @@ module External {
|
|
|
343
341
|
if (!linkedTable) {
|
|
344
342
|
continue
|
|
345
343
|
}
|
|
346
|
-
const fromColumn = `${table.name}.${relationship.from}`
|
|
347
|
-
const toColumn = `${linkedTable.name}.${relationship.to}`
|
|
348
|
-
// this is important when working with multiple relationships
|
|
349
|
-
// between the same tables, don't want to overlap/multiply the relations
|
|
350
|
-
if (!relationship.through && row[fromColumn] !== row[toColumn]) {
|
|
351
|
-
continue
|
|
352
|
-
}
|
|
353
344
|
let linked = basicProcessing(row, linkedTable)
|
|
354
345
|
if (!linked._id) {
|
|
355
346
|
continue
|
|
@@ -397,7 +388,6 @@ module External {
|
|
|
397
388
|
// this is a relationship of some sort
|
|
398
389
|
if (finalRows[rowId]) {
|
|
399
390
|
finalRows = this.updateRelationshipColumns(
|
|
400
|
-
table,
|
|
401
391
|
row,
|
|
402
392
|
finalRows,
|
|
403
393
|
relationships
|
|
@@ -411,7 +401,6 @@ module External {
|
|
|
411
401
|
finalRows[thisRow._id] = thisRow
|
|
412
402
|
// do this at end once its been added to the final rows
|
|
413
403
|
finalRows = this.updateRelationshipColumns(
|
|
414
|
-
table,
|
|
415
404
|
row,
|
|
416
405
|
finalRows,
|
|
417
406
|
relationships
|
|
@@ -433,7 +422,7 @@ module External {
|
|
|
433
422
|
}
|
|
434
423
|
const { tableName: linkTableName } = breakExternalTableId(field.tableId)
|
|
435
424
|
// no table to link to, this is not a valid relationships
|
|
436
|
-
if (!
|
|
425
|
+
if (!this.tables[linkTableName]) {
|
|
437
426
|
continue
|
|
438
427
|
}
|
|
439
428
|
const linkTable = this.tables[linkTableName]
|
|
@@ -471,9 +460,6 @@ module External {
|
|
|
471
460
|
async lookupRelations(tableId: string, row: Row) {
|
|
472
461
|
const related: { [key: string]: any } = {}
|
|
473
462
|
const { tableName } = breakExternalTableId(tableId)
|
|
474
|
-
if (!tableName) {
|
|
475
|
-
return related
|
|
476
|
-
}
|
|
477
463
|
const table = this.tables[tableName]
|
|
478
464
|
// @ts-ignore
|
|
479
465
|
const primaryKey = table.primary[0]
|
|
@@ -498,7 +484,7 @@ module External {
|
|
|
498
484
|
if (!lookupField || !row[lookupField]) {
|
|
499
485
|
continue
|
|
500
486
|
}
|
|
501
|
-
const response = await getDatasourceAndQuery({
|
|
487
|
+
const response = await getDatasourceAndQuery(this.appId, {
|
|
502
488
|
endpoint: getEndpoint(tableId, DataSourceOperation.READ),
|
|
503
489
|
filters: {
|
|
504
490
|
equal: {
|
|
@@ -529,30 +515,28 @@ module External {
|
|
|
529
515
|
row: Row,
|
|
530
516
|
relationships: ManyRelationship[]
|
|
531
517
|
) {
|
|
518
|
+
const { appId } = this
|
|
532
519
|
// if we're creating (in a through table) need to wipe the existing ones first
|
|
533
520
|
const promises = []
|
|
534
521
|
const related = await this.lookupRelations(mainTableId, row)
|
|
535
522
|
for (let relationship of relationships) {
|
|
536
523
|
const { key, tableId, isUpdate, id, ...rest } = relationship
|
|
537
|
-
const body
|
|
524
|
+
const body = processObjectSync(rest, row)
|
|
538
525
|
const linkTable = this.getTable(tableId)
|
|
539
526
|
// @ts-ignore
|
|
540
|
-
const linkPrimary = linkTable
|
|
541
|
-
|
|
542
|
-
return
|
|
543
|
-
}
|
|
544
|
-
const rows = related[key].rows || []
|
|
527
|
+
const linkPrimary = linkTable.primary[0]
|
|
528
|
+
const rows = related[key]?.rows || []
|
|
545
529
|
const found = rows.find(
|
|
546
530
|
(row: { [key: string]: any }) =>
|
|
547
531
|
row[linkPrimary] === relationship.id ||
|
|
548
|
-
row[linkPrimary] === body
|
|
532
|
+
row[linkPrimary] === body[linkPrimary]
|
|
549
533
|
)
|
|
550
534
|
const operation = isUpdate
|
|
551
535
|
? DataSourceOperation.UPDATE
|
|
552
536
|
: DataSourceOperation.CREATE
|
|
553
537
|
if (!found) {
|
|
554
538
|
promises.push(
|
|
555
|
-
getDatasourceAndQuery({
|
|
539
|
+
getDatasourceAndQuery(appId, {
|
|
556
540
|
endpoint: getEndpoint(tableId, operation),
|
|
557
541
|
// if we're doing many relationships then we're writing, only one response
|
|
558
542
|
body,
|
|
@@ -568,12 +552,9 @@ module External {
|
|
|
568
552
|
for (let [colName, { isMany, rows, tableId }] of Object.entries(
|
|
569
553
|
related
|
|
570
554
|
)) {
|
|
571
|
-
const table: Table
|
|
555
|
+
const table: Table = this.getTable(tableId)
|
|
572
556
|
// if its not the foreign key skip it, nothing to do
|
|
573
|
-
if (
|
|
574
|
-
!table ||
|
|
575
|
-
(table.primary && table.primary.indexOf(colName) !== -1)
|
|
576
|
-
) {
|
|
557
|
+
if (table.primary && table.primary.indexOf(colName) !== -1) {
|
|
577
558
|
continue
|
|
578
559
|
}
|
|
579
560
|
for (let row of rows) {
|
|
@@ -585,7 +566,7 @@ module External {
|
|
|
585
566
|
: DataSourceOperation.UPDATE
|
|
586
567
|
const body = isMany ? null : { [colName]: null }
|
|
587
568
|
promises.push(
|
|
588
|
-
getDatasourceAndQuery({
|
|
569
|
+
getDatasourceAndQuery(this.appId, {
|
|
589
570
|
endpoint: getEndpoint(tableId, op),
|
|
590
571
|
body,
|
|
591
572
|
filters,
|
|
@@ -624,25 +605,20 @@ module External {
|
|
|
624
605
|
continue
|
|
625
606
|
}
|
|
626
607
|
const { tableName: linkTableName } = breakExternalTableId(field.tableId)
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
fields = fields.concat(linkedFields)
|
|
632
|
-
}
|
|
608
|
+
const linkTable = this.tables[linkTableName]
|
|
609
|
+
if (linkTable) {
|
|
610
|
+
const linkedFields = extractRealFields(linkTable, fields)
|
|
611
|
+
fields = fields.concat(linkedFields)
|
|
633
612
|
}
|
|
634
613
|
}
|
|
635
614
|
return fields
|
|
636
615
|
}
|
|
637
616
|
|
|
638
617
|
async run(config: RunConfig) {
|
|
639
|
-
const { operation, tableId } = this
|
|
618
|
+
const { appId, operation, tableId } = this
|
|
640
619
|
let { datasourceId, tableName } = breakExternalTableId(tableId)
|
|
641
|
-
if (!tableName) {
|
|
642
|
-
throw "Unable to run without a table name"
|
|
643
|
-
}
|
|
644
620
|
if (!this.datasource) {
|
|
645
|
-
const db =
|
|
621
|
+
const db = new CouchDB(appId)
|
|
646
622
|
this.datasource = await db.get(datasourceId)
|
|
647
623
|
if (!this.datasource || !this.datasource.entities) {
|
|
648
624
|
throw "No tables found, fetch tables before query."
|
|
@@ -694,7 +670,7 @@ module External {
|
|
|
694
670
|
},
|
|
695
671
|
}
|
|
696
672
|
// can't really use response right now
|
|
697
|
-
const response = await getDatasourceAndQuery(json)
|
|
673
|
+
const response = await getDatasourceAndQuery(appId, json)
|
|
698
674
|
// handle many to many relationships now if we know the ID (could be auto increment)
|
|
699
675
|
if (
|
|
700
676
|
operation !== DataSourceOperation.READ &&
|
|
@@ -9,9 +9,9 @@ const {
|
|
|
9
9
|
breakRowIdField,
|
|
10
10
|
} = require("../../../integrations/utils")
|
|
11
11
|
const ExternalRequest = require("./ExternalRequest")
|
|
12
|
-
const
|
|
12
|
+
const CouchDB = require("../../../db")
|
|
13
13
|
|
|
14
|
-
async function handleRequest(operation, tableId, opts = {}) {
|
|
14
|
+
async function handleRequest(appId, operation, tableId, opts = {}) {
|
|
15
15
|
// make sure the filters are cleaned up, no empty strings for equals, fuzzy or string
|
|
16
16
|
if (opts && opts.filters) {
|
|
17
17
|
for (let filterField of NoEmptyFilterStrings) {
|
|
@@ -25,27 +25,31 @@ async function handleRequest(operation, tableId, opts = {}) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
return new ExternalRequest(operation, tableId, opts.datasource).run(
|
|
28
|
+
return new ExternalRequest(appId, operation, tableId, opts.datasource).run(
|
|
29
|
+
opts
|
|
30
|
+
)
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
exports.handleRequest = handleRequest
|
|
32
34
|
|
|
33
35
|
exports.patch = async ctx => {
|
|
36
|
+
const appId = ctx.appId
|
|
34
37
|
const inputs = ctx.request.body
|
|
35
38
|
const tableId = ctx.params.tableId
|
|
36
39
|
const id = breakRowIdField(inputs._id)
|
|
37
40
|
// don't save the ID to db
|
|
38
41
|
delete inputs._id
|
|
39
|
-
return handleRequest(DataSourceOperation.UPDATE, tableId, {
|
|
42
|
+
return handleRequest(appId, DataSourceOperation.UPDATE, tableId, {
|
|
40
43
|
id,
|
|
41
44
|
row: inputs,
|
|
42
45
|
})
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
exports.save = async ctx => {
|
|
49
|
+
const appId = ctx.appId
|
|
46
50
|
const inputs = ctx.request.body
|
|
47
51
|
const tableId = ctx.params.tableId
|
|
48
|
-
return handleRequest(DataSourceOperation.CREATE, tableId, {
|
|
52
|
+
return handleRequest(appId, DataSourceOperation.CREATE, tableId, {
|
|
49
53
|
row: inputs,
|
|
50
54
|
})
|
|
51
55
|
}
|
|
@@ -59,35 +63,49 @@ exports.fetchView = async ctx => {
|
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
exports.fetch = async ctx => {
|
|
66
|
+
const appId = ctx.appId
|
|
62
67
|
const tableId = ctx.params.tableId
|
|
63
|
-
return handleRequest(DataSourceOperation.READ, tableId)
|
|
68
|
+
return handleRequest(appId, DataSourceOperation.READ, tableId)
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
exports.find = async ctx => {
|
|
72
|
+
const appId = ctx.appId
|
|
67
73
|
const id = ctx.params.rowId
|
|
68
74
|
const tableId = ctx.params.tableId
|
|
69
|
-
const response = await handleRequest(
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
const response = await handleRequest(
|
|
76
|
+
appId,
|
|
77
|
+
DataSourceOperation.READ,
|
|
78
|
+
tableId,
|
|
79
|
+
{
|
|
80
|
+
id,
|
|
81
|
+
}
|
|
82
|
+
)
|
|
72
83
|
return response ? response[0] : response
|
|
73
84
|
}
|
|
74
85
|
|
|
75
86
|
exports.destroy = async ctx => {
|
|
87
|
+
const appId = ctx.appId
|
|
76
88
|
const tableId = ctx.params.tableId
|
|
77
89
|
const id = ctx.request.body._id
|
|
78
|
-
const { row } = await handleRequest(
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
const { row } = await handleRequest(
|
|
91
|
+
appId,
|
|
92
|
+
DataSourceOperation.DELETE,
|
|
93
|
+
tableId,
|
|
94
|
+
{
|
|
95
|
+
id,
|
|
96
|
+
}
|
|
97
|
+
)
|
|
81
98
|
return { response: { ok: true }, row }
|
|
82
99
|
}
|
|
83
100
|
|
|
84
101
|
exports.bulkDestroy = async ctx => {
|
|
102
|
+
const appId = ctx.appId
|
|
85
103
|
const { rows } = ctx.request.body
|
|
86
104
|
const tableId = ctx.params.tableId
|
|
87
105
|
let promises = []
|
|
88
106
|
for (let row of rows) {
|
|
89
107
|
promises.push(
|
|
90
|
-
handleRequest(DataSourceOperation.DELETE, tableId, {
|
|
108
|
+
handleRequest(appId, DataSourceOperation.DELETE, tableId, {
|
|
91
109
|
id: breakRowIdField(row._id),
|
|
92
110
|
})
|
|
93
111
|
)
|
|
@@ -97,6 +115,7 @@ exports.bulkDestroy = async ctx => {
|
|
|
97
115
|
}
|
|
98
116
|
|
|
99
117
|
exports.search = async ctx => {
|
|
118
|
+
const appId = ctx.appId
|
|
100
119
|
const tableId = ctx.params.tableId
|
|
101
120
|
const { paginate, query, ...params } = ctx.request.body
|
|
102
121
|
let { bookmark, limit } = params
|
|
@@ -126,21 +145,26 @@ exports.search = async ctx => {
|
|
|
126
145
|
[params.sort]: direction,
|
|
127
146
|
}
|
|
128
147
|
}
|
|
129
|
-
const rows = await handleRequest(DataSourceOperation.READ, tableId, {
|
|
148
|
+
const rows = await handleRequest(appId, DataSourceOperation.READ, tableId, {
|
|
130
149
|
filters: query,
|
|
131
150
|
sort,
|
|
132
151
|
paginate: paginateObj,
|
|
133
152
|
})
|
|
134
153
|
let hasNextPage = false
|
|
135
154
|
if (paginate && rows.length === limit) {
|
|
136
|
-
const nextRows = await handleRequest(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
155
|
+
const nextRows = await handleRequest(
|
|
156
|
+
appId,
|
|
157
|
+
DataSourceOperation.READ,
|
|
158
|
+
tableId,
|
|
159
|
+
{
|
|
160
|
+
filters: query,
|
|
161
|
+
sort,
|
|
162
|
+
paginate: {
|
|
163
|
+
limit: 1,
|
|
164
|
+
page: bookmark * limit + 1,
|
|
165
|
+
},
|
|
166
|
+
}
|
|
167
|
+
)
|
|
144
168
|
hasNextPage = nextRows.length > 0
|
|
145
169
|
}
|
|
146
170
|
// need wrapper object for bookmarks etc when paginating
|
|
@@ -153,19 +177,25 @@ exports.validate = async () => {
|
|
|
153
177
|
}
|
|
154
178
|
|
|
155
179
|
exports.fetchEnrichedRow = async ctx => {
|
|
180
|
+
const appId = ctx.appId
|
|
156
181
|
const id = ctx.params.rowId
|
|
157
182
|
const tableId = ctx.params.tableId
|
|
158
183
|
const { datasourceId, tableName } = breakExternalTableId(tableId)
|
|
159
|
-
const db =
|
|
184
|
+
const db = new CouchDB(appId)
|
|
160
185
|
const datasource = await db.get(datasourceId)
|
|
161
186
|
if (!datasource || !datasource.entities) {
|
|
162
187
|
ctx.throw(400, "Datasource has not been configured for plus API.")
|
|
163
188
|
}
|
|
164
189
|
const tables = datasource.entities
|
|
165
|
-
const response = await handleRequest(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
190
|
+
const response = await handleRequest(
|
|
191
|
+
appId,
|
|
192
|
+
DataSourceOperation.READ,
|
|
193
|
+
tableId,
|
|
194
|
+
{
|
|
195
|
+
id,
|
|
196
|
+
datasource,
|
|
197
|
+
}
|
|
198
|
+
)
|
|
169
199
|
const table = tables[tableName]
|
|
170
200
|
const row = response[0]
|
|
171
201
|
// this seems like a lot of work, but basically we need to dig deeper for the enrich
|
|
@@ -184,6 +214,7 @@ exports.fetchEnrichedRow = async ctx => {
|
|
|
184
214
|
// don't support composite keys right now
|
|
185
215
|
const linkedIds = links.map(link => breakRowIdField(link._id)[0])
|
|
186
216
|
row[fieldName] = await handleRequest(
|
|
217
|
+
appId,
|
|
187
218
|
DataSourceOperation.READ,
|
|
188
219
|
linkedTableId,
|
|
189
220
|
{
|