@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
|
@@ -22,21 +22,19 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
const datasource_1 = require("../../../definitions/datasource");
|
|
24
24
|
const utils_1 = require("../../../integrations/utils");
|
|
25
|
-
const utils_2 = require("./utils");
|
|
26
|
-
const constants_1 = require("../../../constants");
|
|
27
|
-
const utils_3 = require("../../../integrations/utils");
|
|
28
|
-
const string_templates_1 = require("@budibase/string-templates");
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
const fp_1 = require("lodash/fp");
|
|
31
|
-
const utils_4 = require("../../../utilities/rowProcessor/utils");
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
const context_1 = require("@budibase/backend-core/context");
|
|
34
25
|
var External;
|
|
35
26
|
(function (External) {
|
|
27
|
+
const { getDatasourceAndQuery } = require("./utils");
|
|
28
|
+
const { DataSourceOperation, FieldTypes, RelationshipTypes, } = require("../../../constants");
|
|
29
|
+
const { breakExternalTableId, isSQL } = require("../../../integrations/utils");
|
|
30
|
+
const { processObjectSync } = require("@budibase/string-templates");
|
|
31
|
+
const { cloneDeep } = require("lodash/fp");
|
|
32
|
+
const CouchDB = require("../../../db");
|
|
33
|
+
const { processFormulas } = require("../../../utilities/rowProcessor/utils");
|
|
36
34
|
function buildFilters(id, filters, table) {
|
|
37
35
|
const primary = table.primary;
|
|
38
36
|
// if passed in array need to copy for shifting etc
|
|
39
|
-
let idCopy =
|
|
37
|
+
let idCopy = cloneDeep(id);
|
|
40
38
|
if (filters) {
|
|
41
39
|
// need to map over the filters and make sure the _id field isn't present
|
|
42
40
|
for (let filter of Object.values(filters)) {
|
|
@@ -79,10 +77,10 @@ var External;
|
|
|
79
77
|
*/
|
|
80
78
|
function cleanupConfig(config, table) {
|
|
81
79
|
const primaryOptions = [
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
FieldTypes.STRING,
|
|
81
|
+
FieldTypes.LONGFORM,
|
|
82
|
+
FieldTypes.OPTIONS,
|
|
83
|
+
FieldTypes.NUMBER,
|
|
86
84
|
];
|
|
87
85
|
// filter out fields which cannot be keys
|
|
88
86
|
const fieldNames = Object.entries(table.schema)
|
|
@@ -135,7 +133,7 @@ var External;
|
|
|
135
133
|
if (!tableId) {
|
|
136
134
|
return {};
|
|
137
135
|
}
|
|
138
|
-
const { datasourceId, tableName } =
|
|
136
|
+
const { datasourceId, tableName } = breakExternalTableId(tableId);
|
|
139
137
|
return {
|
|
140
138
|
datasourceId,
|
|
141
139
|
entityId: tableName,
|
|
@@ -159,7 +157,7 @@ var External;
|
|
|
159
157
|
}
|
|
160
158
|
function fixArrayTypes(row, table) {
|
|
161
159
|
for (let [fieldName, schema] of Object.entries(table.schema)) {
|
|
162
|
-
if (schema.type ===
|
|
160
|
+
if (schema.type === FieldTypes.ARRAY &&
|
|
163
161
|
typeof row[fieldName] === "string") {
|
|
164
162
|
try {
|
|
165
163
|
row[fieldName] = JSON.parse(row[fieldName]);
|
|
@@ -176,8 +174,9 @@ var External;
|
|
|
176
174
|
return (field.relationshipType && field.relationshipType.split("-")[0] === "one");
|
|
177
175
|
}
|
|
178
176
|
class ExternalRequest {
|
|
179
|
-
constructor(operation, tableId, datasource) {
|
|
177
|
+
constructor(appId, operation, tableId, datasource) {
|
|
180
178
|
this.tables = {};
|
|
179
|
+
this.appId = appId;
|
|
181
180
|
this.operation = operation;
|
|
182
181
|
this.tableId = tableId;
|
|
183
182
|
this.datasource = datasource;
|
|
@@ -189,10 +188,8 @@ var External;
|
|
|
189
188
|
if (!tableId) {
|
|
190
189
|
throw "Table ID is unknown, cannot find table";
|
|
191
190
|
}
|
|
192
|
-
const { tableName } =
|
|
193
|
-
|
|
194
|
-
return this.tables[tableName];
|
|
195
|
-
}
|
|
191
|
+
const { tableName } = breakExternalTableId(tableId);
|
|
192
|
+
return this.tables[tableName];
|
|
196
193
|
}
|
|
197
194
|
inputProcessing(row, table) {
|
|
198
195
|
if (!row) {
|
|
@@ -207,7 +204,7 @@ var External;
|
|
|
207
204
|
if (row[key] == null ||
|
|
208
205
|
newRow[key] ||
|
|
209
206
|
field.autocolumn ||
|
|
210
|
-
field.type ===
|
|
207
|
+
field.type === FieldTypes.FORMULA) {
|
|
211
208
|
continue;
|
|
212
209
|
}
|
|
213
210
|
// if its an empty string then it means return the column to null (if possible)
|
|
@@ -216,17 +213,17 @@ var External;
|
|
|
216
213
|
continue;
|
|
217
214
|
}
|
|
218
215
|
// parse floats/numbers
|
|
219
|
-
if (field.type ===
|
|
216
|
+
if (field.type === FieldTypes.NUMBER && !isNaN(parseFloat(row[key]))) {
|
|
220
217
|
newRow[key] = parseFloat(row[key]);
|
|
221
218
|
}
|
|
222
219
|
// if its not a link then just copy it over
|
|
223
|
-
if (field.type !==
|
|
220
|
+
if (field.type !== FieldTypes.LINK) {
|
|
224
221
|
newRow[key] = row[key];
|
|
225
222
|
continue;
|
|
226
223
|
}
|
|
227
|
-
const { tableName: linkTableName } =
|
|
224
|
+
const { tableName: linkTableName } = breakExternalTableId(field.tableId);
|
|
228
225
|
// table has to exist for many to many
|
|
229
|
-
if (!
|
|
226
|
+
if (!this.tables[linkTableName]) {
|
|
230
227
|
continue;
|
|
231
228
|
}
|
|
232
229
|
const linkTable = this.tables[linkTableName];
|
|
@@ -334,7 +331,7 @@ var External;
|
|
|
334
331
|
// do this at end once its been added to the final rows
|
|
335
332
|
finalRows = this.updateRelationshipColumns(row, finalRows, relationships);
|
|
336
333
|
}
|
|
337
|
-
return
|
|
334
|
+
return processFormulas(table, Object.values(finalRows));
|
|
338
335
|
}
|
|
339
336
|
/**
|
|
340
337
|
* Gets the list of relationship JSON structures based on the columns in the table,
|
|
@@ -344,12 +341,12 @@ var External;
|
|
|
344
341
|
buildRelationships(table) {
|
|
345
342
|
const relationships = [];
|
|
346
343
|
for (let [fieldName, field] of Object.entries(table.schema)) {
|
|
347
|
-
if (field.type !==
|
|
344
|
+
if (field.type !== FieldTypes.LINK) {
|
|
348
345
|
continue;
|
|
349
346
|
}
|
|
350
|
-
const { tableName: linkTableName } =
|
|
347
|
+
const { tableName: linkTableName } = breakExternalTableId(field.tableId);
|
|
351
348
|
// no table to link to, this is not a valid relationships
|
|
352
|
-
if (!
|
|
349
|
+
if (!this.tables[linkTableName]) {
|
|
353
350
|
continue;
|
|
354
351
|
}
|
|
355
352
|
const linkTable = this.tables[linkTableName];
|
|
@@ -365,7 +362,7 @@ var External;
|
|
|
365
362
|
column: fieldName,
|
|
366
363
|
};
|
|
367
364
|
if (field.through) {
|
|
368
|
-
const { tableName: throughTableName } =
|
|
365
|
+
const { tableName: throughTableName } = breakExternalTableId(field.through);
|
|
369
366
|
definition.through = throughTableName;
|
|
370
367
|
// don't support composite keys for relationships
|
|
371
368
|
definition.from = field.throughTo || table.primary[0];
|
|
@@ -384,24 +381,21 @@ var External;
|
|
|
384
381
|
lookupRelations(tableId, row) {
|
|
385
382
|
return __awaiter(this, void 0, void 0, function* () {
|
|
386
383
|
const related = {};
|
|
387
|
-
const { tableName } =
|
|
388
|
-
if (!tableName) {
|
|
389
|
-
return related;
|
|
390
|
-
}
|
|
384
|
+
const { tableName } = breakExternalTableId(tableId);
|
|
391
385
|
const table = this.tables[tableName];
|
|
392
386
|
// @ts-ignore
|
|
393
387
|
const primaryKey = table.primary[0];
|
|
394
388
|
// make a new request to get the row with all its relationships
|
|
395
389
|
// we need this to work out if any relationships need removed
|
|
396
390
|
for (let field of Object.values(table.schema)) {
|
|
397
|
-
if (field.type !==
|
|
391
|
+
if (field.type !== FieldTypes.LINK ||
|
|
398
392
|
!field.fieldName ||
|
|
399
393
|
isOneSide(field)) {
|
|
400
394
|
continue;
|
|
401
395
|
}
|
|
402
|
-
const isMany = field.relationshipType ===
|
|
396
|
+
const isMany = field.relationshipType === RelationshipTypes.MANY_TO_MANY;
|
|
403
397
|
const tableId = isMany ? field.through : field.tableId;
|
|
404
|
-
const { tableName: relatedTableName } =
|
|
398
|
+
const { tableName: relatedTableName } = breakExternalTableId(tableId);
|
|
405
399
|
// @ts-ignore
|
|
406
400
|
const linkPrimaryKey = this.tables[relatedTableName].primary[0];
|
|
407
401
|
const manyKey = field.throughTo || primaryKey;
|
|
@@ -410,8 +404,8 @@ var External;
|
|
|
410
404
|
if (!lookupField || !row[lookupField]) {
|
|
411
405
|
continue;
|
|
412
406
|
}
|
|
413
|
-
const response = yield
|
|
414
|
-
endpoint: getEndpoint(tableId,
|
|
407
|
+
const response = yield getDatasourceAndQuery(this.appId, {
|
|
408
|
+
endpoint: getEndpoint(tableId, DataSourceOperation.READ),
|
|
415
409
|
filters: {
|
|
416
410
|
equal: {
|
|
417
411
|
[fieldName]: row[lookupField],
|
|
@@ -437,27 +431,26 @@ var External;
|
|
|
437
431
|
* all and then re-create, as theres no chance of losing data (e.g. delete succeed, but write fail).
|
|
438
432
|
*/
|
|
439
433
|
handleManyRelationships(mainTableId, row, relationships) {
|
|
434
|
+
var _a;
|
|
440
435
|
return __awaiter(this, void 0, void 0, function* () {
|
|
436
|
+
const { appId } = this;
|
|
441
437
|
// if we're creating (in a through table) need to wipe the existing ones first
|
|
442
438
|
const promises = [];
|
|
443
439
|
const related = yield this.lookupRelations(mainTableId, row);
|
|
444
440
|
for (let relationship of relationships) {
|
|
445
441
|
const { key, tableId, isUpdate, id } = relationship, rest = __rest(relationship, ["key", "tableId", "isUpdate", "id"]);
|
|
446
|
-
const body =
|
|
442
|
+
const body = processObjectSync(rest, row);
|
|
447
443
|
const linkTable = this.getTable(tableId);
|
|
448
444
|
// @ts-ignore
|
|
449
|
-
const linkPrimary = linkTable
|
|
450
|
-
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
const rows = related[key].rows || [];
|
|
445
|
+
const linkPrimary = linkTable.primary[0];
|
|
446
|
+
const rows = ((_a = related[key]) === null || _a === void 0 ? void 0 : _a.rows) || [];
|
|
454
447
|
const found = rows.find((row) => row[linkPrimary] === relationship.id ||
|
|
455
|
-
row[linkPrimary] ===
|
|
448
|
+
row[linkPrimary] === body[linkPrimary]);
|
|
456
449
|
const operation = isUpdate
|
|
457
|
-
?
|
|
458
|
-
:
|
|
450
|
+
? DataSourceOperation.UPDATE
|
|
451
|
+
: DataSourceOperation.CREATE;
|
|
459
452
|
if (!found) {
|
|
460
|
-
promises.push(
|
|
453
|
+
promises.push(getDatasourceAndQuery(appId, {
|
|
461
454
|
endpoint: getEndpoint(tableId, operation),
|
|
462
455
|
// if we're doing many relationships then we're writing, only one response
|
|
463
456
|
body,
|
|
@@ -473,8 +466,7 @@ var External;
|
|
|
473
466
|
for (let [colName, { isMany, rows, tableId }] of Object.entries(related)) {
|
|
474
467
|
const table = this.getTable(tableId);
|
|
475
468
|
// if its not the foreign key skip it, nothing to do
|
|
476
|
-
if (
|
|
477
|
-
(table.primary && table.primary.indexOf(colName) !== -1)) {
|
|
469
|
+
if (table.primary && table.primary.indexOf(colName) !== -1) {
|
|
478
470
|
continue;
|
|
479
471
|
}
|
|
480
472
|
for (let row of rows) {
|
|
@@ -482,10 +474,10 @@ var External;
|
|
|
482
474
|
// safety check, if there are no filters on deletion bad things happen
|
|
483
475
|
if (Object.keys(filters).length !== 0) {
|
|
484
476
|
const op = isMany
|
|
485
|
-
?
|
|
486
|
-
:
|
|
477
|
+
? DataSourceOperation.DELETE
|
|
478
|
+
: DataSourceOperation.UPDATE;
|
|
487
479
|
const body = isMany ? null : { [colName]: null };
|
|
488
|
-
promises.push(
|
|
480
|
+
promises.push(getDatasourceAndQuery(this.appId, {
|
|
489
481
|
endpoint: getEndpoint(tableId, op),
|
|
490
482
|
body,
|
|
491
483
|
filters,
|
|
@@ -506,36 +498,31 @@ var External;
|
|
|
506
498
|
buildFields(table, includeRelations = datasource_1.IncludeRelationships.INCLUDE) {
|
|
507
499
|
function extractRealFields(table, existing = []) {
|
|
508
500
|
return Object.entries(table.schema)
|
|
509
|
-
.filter(column => column[1].type !==
|
|
510
|
-
column[1].type !==
|
|
501
|
+
.filter(column => column[1].type !== FieldTypes.LINK &&
|
|
502
|
+
column[1].type !== FieldTypes.FORMULA &&
|
|
511
503
|
!existing.find((field) => field === column[0]))
|
|
512
504
|
.map(column => `${table.name}.${column[0]}`);
|
|
513
505
|
}
|
|
514
506
|
let fields = extractRealFields(table);
|
|
515
507
|
for (let field of Object.values(table.schema)) {
|
|
516
|
-
if (field.type !==
|
|
508
|
+
if (field.type !== FieldTypes.LINK || !includeRelations) {
|
|
517
509
|
continue;
|
|
518
510
|
}
|
|
519
|
-
const { tableName: linkTableName } =
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
fields = fields.concat(linkedFields);
|
|
525
|
-
}
|
|
511
|
+
const { tableName: linkTableName } = breakExternalTableId(field.tableId);
|
|
512
|
+
const linkTable = this.tables[linkTableName];
|
|
513
|
+
if (linkTable) {
|
|
514
|
+
const linkedFields = extractRealFields(linkTable, fields);
|
|
515
|
+
fields = fields.concat(linkedFields);
|
|
526
516
|
}
|
|
527
517
|
}
|
|
528
518
|
return fields;
|
|
529
519
|
}
|
|
530
520
|
run(config) {
|
|
531
521
|
return __awaiter(this, void 0, void 0, function* () {
|
|
532
|
-
const { operation, tableId } = this;
|
|
533
|
-
let { datasourceId, tableName } =
|
|
534
|
-
if (!tableName) {
|
|
535
|
-
throw "Unable to run without a table name";
|
|
536
|
-
}
|
|
522
|
+
const { appId, operation, tableId } = this;
|
|
523
|
+
let { datasourceId, tableName } = breakExternalTableId(tableId);
|
|
537
524
|
if (!this.datasource) {
|
|
538
|
-
const db =
|
|
525
|
+
const db = new CouchDB(appId);
|
|
539
526
|
this.datasource = yield db.get(datasourceId);
|
|
540
527
|
if (!this.datasource || !this.datasource.entities) {
|
|
541
528
|
throw "No tables found, fetch tables before query.";
|
|
@@ -543,7 +530,7 @@ var External;
|
|
|
543
530
|
this.tables = this.datasource.entities;
|
|
544
531
|
}
|
|
545
532
|
const table = this.tables[tableName];
|
|
546
|
-
let isSql =
|
|
533
|
+
let isSql = isSQL(this.datasource);
|
|
547
534
|
if (!table) {
|
|
548
535
|
throw `Unable to process query, table "${tableName}" not defined.`;
|
|
549
536
|
}
|
|
@@ -554,7 +541,7 @@ var External;
|
|
|
554
541
|
// clean up row on ingress using schema
|
|
555
542
|
const processed = this.inputProcessing(row, table);
|
|
556
543
|
row = processed.row;
|
|
557
|
-
if (operation ===
|
|
544
|
+
if (operation === DataSourceOperation.DELETE &&
|
|
558
545
|
(filters == null || Object.keys(filters).length === 0)) {
|
|
559
546
|
throw "Deletion must be filtered";
|
|
560
547
|
}
|
|
@@ -582,15 +569,15 @@ var External;
|
|
|
582
569
|
},
|
|
583
570
|
};
|
|
584
571
|
// can't really use response right now
|
|
585
|
-
const response = yield
|
|
572
|
+
const response = yield getDatasourceAndQuery(appId, json);
|
|
586
573
|
// handle many to many relationships now if we know the ID (could be auto increment)
|
|
587
|
-
if (operation !==
|
|
574
|
+
if (operation !== DataSourceOperation.READ &&
|
|
588
575
|
processed.manyRelationships) {
|
|
589
576
|
yield this.handleManyRelationships(table._id || "", response[0], processed.manyRelationships);
|
|
590
577
|
}
|
|
591
578
|
const output = this.outputProcessing(response, table, relationships);
|
|
592
579
|
// if reading it'll just be an array of rows, return whole thing
|
|
593
|
-
return operation ===
|
|
580
|
+
return operation === DataSourceOperation.READ && Array.isArray(response)
|
|
594
581
|
? output
|
|
595
582
|
: { row: output[0], table };
|
|
596
583
|
});
|
|
@@ -22,8 +22,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
const { DataSourceOperation, SortDirection, FieldTypes, NoEmptyFilterStrings, } = require("../../../constants");
|
|
23
23
|
const { breakExternalTableId, breakRowIdField, } = require("../../../integrations/utils");
|
|
24
24
|
const ExternalRequest = require("./ExternalRequest");
|
|
25
|
-
const
|
|
26
|
-
function handleRequest(operation, tableId, opts = {}) {
|
|
25
|
+
const CouchDB = require("../../../db");
|
|
26
|
+
function handleRequest(appId, operation, tableId, opts = {}) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
28
|
// make sure the filters are cleaned up, no empty strings for equals, fuzzy or string
|
|
29
29
|
if (opts && opts.filters) {
|
|
@@ -38,7 +38,7 @@ function handleRequest(operation, tableId, opts = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
return new ExternalRequest(operation, tableId, opts.datasource).run(opts);
|
|
41
|
+
return new ExternalRequest(appId, operation, tableId, opts.datasource).run(opts);
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
exports.handleRequest = handleRequest;
|
|
@@ -164,7 +164,7 @@ exports.fetchEnrichedRow = (ctx) => __awaiter(void 0, void 0, void 0, function*
|
|
|
164
164
|
const id = ctx.params.rowId;
|
|
165
165
|
const tableId = ctx.params.tableId;
|
|
166
166
|
const { datasourceId, tableName } = breakExternalTableId(tableId);
|
|
167
|
-
const db =
|
|
167
|
+
const db = new CouchDB(appId);
|
|
168
168
|
const datasource = yield db.get(datasourceId);
|
|
169
169
|
if (!datasource || !datasource.entities) {
|
|
170
170
|
ctx.throw(400, "Datasource has not been configured for plus API.");
|