@budibase/server 2.1.45 → 2.1.46-alpha.0
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__/aws-sdk.ts +14 -0
- package/__mocks__/node-fetch.ts +5 -1
- package/builder/assets/index.538092be.css +6 -0
- package/builder/assets/index.f3d43c3f.js +1020 -0
- package/builder/index.html +2 -2
- package/coverage/clover.xml +11101 -3980
- package/coverage/coverage-final.json +273 -118
- package/coverage/lcov-report/index.html +727 -187
- package/coverage/lcov-report/src/api/controllers/analytics.ts.html +190 -0
- package/coverage/lcov-report/{api/controllers/apikeys.js.html → src/api/controllers/apikeys.ts.html} +30 -30
- package/coverage/lcov-report/src/api/controllers/application.ts.html +1891 -0
- package/coverage/lcov-report/src/api/controllers/auth.ts.html +301 -0
- package/coverage/lcov-report/{api/controllers/automation.js.html → src/api/controllers/automation.ts.html} +99 -99
- package/coverage/lcov-report/src/api/controllers/backup.ts.html +148 -0
- package/coverage/lcov-report/{api/controllers/cloud.js.html → src/api/controllers/cloud.ts.html} +61 -58
- package/coverage/lcov-report/src/api/controllers/component.ts.html +259 -0
- package/coverage/lcov-report/{api/controllers/datasource.js.html → src/api/controllers/datasource.ts.html} +287 -107
- package/coverage/lcov-report/src/api/controllers/deploy/Deployment.ts.html +259 -0
- package/coverage/lcov-report/{utilities/rowProcessor → src/api/controllers/deploy}/index.html +40 -40
- package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +748 -0
- package/coverage/lcov-report/{api/controllers/dev.js.html → src/api/controllers/dev.ts.html} +69 -87
- package/coverage/lcov-report/src/api/controllers/index.html +431 -0
- package/coverage/lcov-report/src/api/controllers/integration.ts.html +124 -0
- package/coverage/lcov-report/{api/controllers/layout.js.html → src/api/controllers/layout.ts.html} +31 -31
- package/coverage/lcov-report/{api/controllers/metadata.js.html → src/api/controllers/metadata.ts.html} +33 -30
- package/coverage/lcov-report/{api/controllers/migrations.js.html → src/api/controllers/migrations.ts.html} +20 -17
- package/coverage/lcov-report/{api/controllers/permission.js.html → src/api/controllers/permission.ts.html} +88 -79
- package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +130 -0
- package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +310 -0
- package/coverage/lcov-report/src/api/controllers/plugin/index.html +206 -0
- package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +484 -0
- package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +253 -0
- package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +97 -0
- package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +121 -0
- package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +136 -0
- package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +334 -0
- package/coverage/lcov-report/src/api/controllers/public/index.html +191 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +181 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +191 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +124 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +202 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +178 -0
- package/coverage/lcov-report/{utilities/routing/index.js.html → src/api/controllers/public/mapping/tables.ts.html} +46 -43
- package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +181 -0
- package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +145 -0
- package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +328 -0
- package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +253 -0
- package/coverage/lcov-report/src/api/controllers/public/users.ts.html +325 -0
- package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +220 -0
- package/coverage/lcov-report/src/api/controllers/query/import/index.html +116 -0
- package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +373 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +131 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +379 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/openapi.ts.html +157 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/curl.ts.html +403 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +146 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +586 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +712 -0
- package/coverage/lcov-report/src/api/controllers/query/index.html +131 -0
- package/coverage/lcov-report/src/api/controllers/query/index.ts.html +976 -0
- package/coverage/lcov-report/{api/controllers/query/validation.js.html → src/api/controllers/query/validation.ts.html} +26 -26
- package/coverage/lcov-report/{api/controllers/role.js.html → src/api/controllers/role.ts.html} +51 -63
- package/coverage/lcov-report/{api/controllers/routing.js.html → src/api/controllers/routing.ts.html} +67 -58
- package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +2269 -0
- package/coverage/lcov-report/{api/controllers/row/external.js.html → src/api/controllers/row/external.ts.html} +162 -111
- package/coverage/lcov-report/{api → src/api}/controllers/row/index.html +82 -52
- package/coverage/lcov-report/src/api/controllers/row/index.ts.html +541 -0
- package/coverage/lcov-report/{api/controllers/row/internal.js.html → src/api/controllers/row/internal.ts.html} +163 -121
- package/coverage/lcov-report/{api/controllers/row/internalSearch.js.html → src/api/controllers/row/internalSearch.ts.html} +189 -117
- package/coverage/lcov-report/{api/controllers/row/staticFormula.js.html → src/api/controllers/row/staticFormula.ts.html} +73 -58
- package/coverage/lcov-report/{api/controllers/row/utils.js.html → src/api/controllers/row/utils.ts.html} +88 -58
- package/coverage/lcov-report/src/api/controllers/screen.ts.html +463 -0
- package/coverage/lcov-report/{api/controllers/script.js.html → src/api/controllers/script.ts.html} +19 -16
- package/coverage/lcov-report/src/api/controllers/static/index.html +116 -0
- package/coverage/lcov-report/src/api/controllers/static/index.ts.html +694 -0
- package/coverage/lcov-report/{api/controllers/table/bulkFormula.js.html → src/api/controllers/table/bulkFormula.ts.html} +104 -62
- package/coverage/lcov-report/{api/controllers/table/external.js.html → src/api/controllers/table/external.ts.html} +204 -111
- package/coverage/lcov-report/src/api/controllers/table/index.html +176 -0
- package/coverage/lcov-report/{api/controllers/table/index.js.html → src/api/controllers/table/index.ts.html} +58 -49
- package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +661 -0
- package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +1255 -0
- package/coverage/lcov-report/{api/controllers/templates.js.html → src/api/controllers/templates.ts.html} +38 -29
- package/coverage/lcov-report/{api/controllers/user.js.html → src/api/controllers/user.ts.html} +78 -255
- package/coverage/lcov-report/{api/controllers/view/exporters.js.html → src/api/controllers/view/exporters.ts.html} +22 -16
- package/coverage/lcov-report/{api → src/api}/controllers/view/index.html +36 -36
- package/coverage/lcov-report/{api/controllers/view/index.js.html → src/api/controllers/view/index.ts.html} +91 -64
- package/coverage/lcov-report/{api/controllers/view/utils.js.html → src/api/controllers/view/utils.ts.html} +72 -54
- package/coverage/lcov-report/{api/controllers/view/viewBuilder.js.html → src/api/controllers/view/viewBuilder.ts.html} +78 -36
- package/coverage/lcov-report/src/api/controllers/webhook.ts.html +379 -0
- package/coverage/lcov-report/{api → src/api}/index.html +23 -23
- package/coverage/lcov-report/{api/index.js.html → src/api/index.ts.html} +63 -84
- package/coverage/lcov-report/src/api/routes/analytics.ts.html +112 -0
- package/coverage/lcov-report/{api/routes/integration.js.html → src/api/routes/apikeys.ts.html} +25 -25
- package/coverage/lcov-report/src/api/routes/application.ts.html +223 -0
- package/coverage/lcov-report/src/api/routes/auth.ts.html +109 -0
- package/coverage/lcov-report/{api/routes/automation.js.html → src/api/routes/automation.ts.html} +53 -47
- package/coverage/lcov-report/{api/routes/cloud.js.html → src/api/routes/backup.ts.html} +28 -28
- package/coverage/lcov-report/{api/routes/deploy.js.html → src/api/routes/cloud.ts.html} +31 -28
- package/coverage/lcov-report/{api/routes/component.js.html → src/api/routes/component.ts.html} +24 -24
- package/coverage/lcov-report/src/api/routes/datasource.ts.html +265 -0
- package/coverage/lcov-report/src/api/routes/deploy.ts.html +148 -0
- package/coverage/lcov-report/src/api/routes/dev.ts.html +199 -0
- package/coverage/lcov-report/{api → src/api}/routes/index.html +167 -47
- package/coverage/lcov-report/src/api/routes/index.ts.html +289 -0
- package/coverage/lcov-report/src/api/routes/integration.ts.html +133 -0
- package/coverage/lcov-report/src/api/routes/layout.ts.html +133 -0
- package/coverage/lcov-report/{api/routes/metadata.js.html → src/api/routes/metadata.ts.html} +31 -31
- package/coverage/lcov-report/{api/routes/migrations.js.html → src/api/routes/migrations.ts.html} +24 -24
- package/coverage/lcov-report/{api/routes/permission.js.html → src/api/routes/permission.ts.html} +55 -31
- package/coverage/lcov-report/src/api/routes/plugin.ts.html +151 -0
- package/coverage/lcov-report/src/api/routes/public/applications.ts.html +541 -0
- package/coverage/lcov-report/src/api/routes/public/index.html +191 -0
- package/coverage/lcov-report/src/api/routes/public/index.ts.html +493 -0
- package/coverage/lcov-report/src/api/routes/public/middleware/index.html +116 -0
- package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +328 -0
- package/coverage/lcov-report/src/api/routes/public/queries.ts.html +313 -0
- package/coverage/lcov-report/src/api/routes/public/rows.ts.html +598 -0
- package/coverage/lcov-report/src/api/routes/public/tables.ts.html +586 -0
- package/coverage/lcov-report/src/api/routes/public/tests/index.html +116 -0
- package/coverage/lcov-report/src/api/routes/public/tests/utils.ts.html +169 -0
- package/coverage/lcov-report/src/api/routes/public/users.ts.html +511 -0
- package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +238 -0
- package/coverage/lcov-report/src/api/routes/public/utils/index.html +116 -0
- package/coverage/lcov-report/{api/routes/query.js.html → src/api/routes/query.ts.html} +41 -50
- package/coverage/lcov-report/src/api/routes/role.ts.html +157 -0
- package/coverage/lcov-report/{api/routes/routing.js.html → src/api/routes/routing.ts.html} +24 -24
- package/coverage/lcov-report/src/api/routes/row.ts.html +883 -0
- package/coverage/lcov-report/{api/routes/screen.js.html → src/api/routes/screen.ts.html} +43 -28
- package/coverage/lcov-report/{api/routes/script.js.html → src/api/routes/script.ts.html} +17 -17
- package/coverage/lcov-report/src/api/routes/static.ts.html +280 -0
- package/coverage/lcov-report/{api/routes/table.js.html → src/api/routes/table.ts.html} +32 -41
- package/coverage/lcov-report/src/api/routes/templates.ts.html +133 -0
- package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +550 -0
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +131 -0
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.ts.html +367 -0
- package/coverage/lcov-report/{api/routes/user.js.html → src/api/routes/user.ts.html} +35 -41
- package/coverage/lcov-report/{api → src/api}/routes/utils/index.html +15 -15
- package/coverage/lcov-report/{api/routes/utils/validators.js.html → src/api/routes/utils/validators.ts.html} +86 -98
- package/coverage/lcov-report/{api/routes/view.js.html → src/api/routes/view.ts.html} +45 -36
- package/coverage/lcov-report/src/api/routes/webhook.ts.html +166 -0
- package/coverage/lcov-report/src/app.ts.html +406 -0
- package/coverage/lcov-report/{automations/actions.js.html → src/automations/actions.ts.html} +69 -60
- package/coverage/lcov-report/{automations/automationUtils.js.html → src/automations/automationUtils.ts.html} +36 -33
- package/coverage/lcov-report/{automations/bullboard.js.html → src/automations/bullboard.ts.html} +39 -42
- package/coverage/lcov-report/{automations → src/automations}/index.html +63 -48
- package/coverage/lcov-report/{api/routes/dev.js.html → src/automations/index.ts.html} +46 -46
- package/coverage/lcov-report/src/automations/logging/index.html +116 -0
- package/coverage/lcov-report/src/automations/logging/index.ts.html +199 -0
- package/coverage/lcov-report/{automations/steps/bash.js.html → src/automations/steps/bash.ts.html} +45 -30
- package/coverage/lcov-report/src/automations/steps/createRow.ts.html +382 -0
- package/coverage/lcov-report/{automations/steps/delay.js.html → src/automations/steps/delay.ts.html} +34 -19
- package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +349 -0
- package/coverage/lcov-report/{automations/steps/discord.js.html → src/automations/steps/discord.ts.html} +43 -28
- package/coverage/lcov-report/{automations/steps/executeQuery.js.html → src/automations/steps/executeQuery.ts.html} +45 -30
- package/coverage/lcov-report/{automations/steps/executeScript.js.html → src/automations/steps/executeScript.ts.html} +58 -28
- package/coverage/lcov-report/{automations/steps/filter.js.html → src/automations/steps/filter.ts.html} +39 -30
- package/coverage/lcov-report/src/automations/steps/index.html +371 -0
- package/coverage/lcov-report/{automations/steps/integromat.js.html → src/automations/steps/integromat.ts.html} +38 -23
- package/coverage/lcov-report/{automations/steps/loop.js.html → src/automations/steps/loop.ts.html} +21 -15
- package/coverage/lcov-report/{automations/steps/outgoingWebhook.js.html → src/automations/steps/outgoingWebhook.ts.html} +54 -39
- package/coverage/lcov-report/{automations/steps/queryRows.js.html → src/automations/steps/queryRows.ts.html} +102 -66
- package/coverage/lcov-report/{automations/steps/sendSmtpEmail.js.html → src/automations/steps/sendSmtpEmail.ts.html} +40 -25
- package/coverage/lcov-report/{automations/steps/serverLog.js.html → src/automations/steps/serverLog.ts.html} +40 -22
- package/coverage/lcov-report/{automations/steps/slack.js.html → src/automations/steps/slack.ts.html} +38 -23
- package/coverage/lcov-report/{automations/steps/updateRow.js.html → src/automations/steps/updateRow.ts.html} +40 -25
- package/coverage/lcov-report/{automations/steps/utils.js.html → src/automations/steps/utils.ts.html} +45 -27
- package/coverage/lcov-report/{automations/steps/zapier.js.html → src/automations/steps/zapier.ts.html} +41 -23
- package/coverage/lcov-report/src/automations/tests/utilities/index.html +116 -0
- package/coverage/lcov-report/src/automations/tests/utilities/index.ts.html +265 -0
- package/coverage/lcov-report/src/automations/triggerInfo/app.ts.html +196 -0
- package/coverage/lcov-report/{automations/triggerInfo/cron.js.html → src/automations/triggerInfo/cron.ts.html} +30 -15
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/index.html +31 -31
- package/coverage/lcov-report/{automations/triggerInfo/index.js.html → src/automations/triggerInfo/index.ts.html} +24 -24
- package/coverage/lcov-report/{automations/triggerInfo/rowDeleted.js.html → src/automations/triggerInfo/rowDeleted.ts.html} +30 -15
- package/coverage/lcov-report/{automations/triggerInfo/rowSaved.js.html → src/automations/triggerInfo/rowSaved.ts.html} +30 -15
- package/coverage/lcov-report/{automations/triggerInfo/rowUpdated.js.html → src/automations/triggerInfo/rowUpdated.ts.html} +30 -15
- package/coverage/lcov-report/{automations/triggerInfo/webhook.js.html → src/automations/triggerInfo/webhook.ts.html} +30 -15
- package/coverage/lcov-report/{automations/triggers.js.html → src/automations/triggers.ts.html} +78 -66
- package/coverage/lcov-report/src/automations/utils.ts.html +886 -0
- package/coverage/lcov-report/{constants → src/constants}/index.html +26 -26
- package/coverage/lcov-report/src/constants/index.ts.html +697 -0
- package/coverage/lcov-report/{constants/layouts.js.html → src/constants/layouts.ts.html} +18 -36
- package/coverage/lcov-report/{constants/screens.js.html → src/constants/screens.ts.html} +64 -58
- package/coverage/lcov-report/src/db/defaultData/datasource_bb_default.ts.html +2059 -0
- package/coverage/lcov-report/src/db/defaultData/employeeImport.ts.html +541 -0
- package/coverage/lcov-report/src/db/defaultData/expensesImport.ts.html +427 -0
- package/coverage/lcov-report/src/db/defaultData/index.html +176 -0
- package/coverage/lcov-report/src/db/defaultData/inventoryImport.ts.html +403 -0
- package/coverage/lcov-report/src/db/defaultData/jobsImport.ts.html +559 -0
- package/coverage/lcov-report/src/db/dynamoClient.ts.html +526 -0
- package/coverage/lcov-report/{db/inMemoryView.js.html → src/db/inMemoryView.ts.html} +47 -29
- package/coverage/lcov-report/{db → src/db}/index.html +48 -33
- package/coverage/lcov-report/{api/routes/templates.js.html → src/db/index.ts.html} +28 -28
- package/coverage/lcov-report/{db/linkedRows/LinkController.js.html → src/db/linkedRows/LinkController.ts.html} +97 -160
- package/coverage/lcov-report/src/db/linkedRows/LinkDocument.ts.html +265 -0
- package/coverage/lcov-report/src/db/linkedRows/index.html +161 -0
- package/coverage/lcov-report/{db/linkedRows/index.js.html → src/db/linkedRows/index.ts.html} +93 -78
- package/coverage/lcov-report/{db/linkedRows/linkUtils.js.html → src/db/linkedRows/linkUtils.ts.html} +83 -56
- package/coverage/lcov-report/{db/newid.js.html → src/db/newid.ts.html} +14 -14
- package/coverage/lcov-report/{db/utils.js.html → src/db/utils.ts.html} +163 -211
- package/coverage/lcov-report/{automations/triggerInfo/app.js.html → src/definitions/automations.ts.html} +42 -42
- package/coverage/lcov-report/{api/routes/datasource.js.html → src/definitions/datasource.ts.html} +61 -64
- package/coverage/lcov-report/src/definitions/index.html +131 -0
- package/coverage/lcov-report/src/environment.ts.html +457 -0
- package/coverage/lcov-report/{events/AutomationEmitter.js.html → src/events/AutomationEmitter.ts.html} +40 -25
- package/coverage/lcov-report/{events/index.js.html → src/events/BudibaseEmitter.ts.html} +26 -29
- package/coverage/lcov-report/{events → src/events}/index.html +48 -33
- package/coverage/lcov-report/src/events/index.ts.html +100 -0
- package/coverage/lcov-report/src/events/utils.ts.html +319 -0
- package/coverage/lcov-report/src/index.html +191 -0
- package/coverage/lcov-report/{db/index.js.html → src/index.ts.html} +35 -35
- package/coverage/lcov-report/{utilities/queue/inMemoryQueue.js.html → src/integrations/airtable.ts.html} +213 -135
- package/coverage/lcov-report/src/integrations/arangodb.ts.html +415 -0
- package/coverage/lcov-report/src/integrations/base/index.html +161 -0
- package/coverage/lcov-report/src/integrations/base/query.ts.html +133 -0
- package/coverage/lcov-report/src/integrations/base/sql.ts.html +1951 -0
- package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +691 -0
- package/coverage/lcov-report/{api/routes/apikeys.js.html → src/integrations/base/utils.ts.html} +30 -30
- package/coverage/lcov-report/src/integrations/couchdb.ts.html +406 -0
- package/coverage/lcov-report/{constants/index.js.html → src/integrations/dynamodb.ts.html} +263 -227
- package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +634 -0
- package/coverage/lcov-report/src/integrations/firebase.ts.html +646 -0
- package/coverage/lcov-report/src/integrations/googlesheets.ts.html +1315 -0
- package/coverage/lcov-report/src/integrations/index.html +371 -0
- package/coverage/lcov-report/src/integrations/index.ts.html +445 -0
- package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +1012 -0
- package/coverage/lcov-report/src/integrations/mongodb.ts.html +1867 -0
- package/coverage/lcov-report/src/integrations/mysql.ts.html +967 -0
- package/coverage/lcov-report/src/integrations/oracle.ts.html +1387 -0
- package/coverage/lcov-report/src/integrations/postgres.ts.html +1087 -0
- package/coverage/lcov-report/src/integrations/queries/index.html +116 -0
- package/coverage/lcov-report/src/integrations/queries/sql.ts.html +463 -0
- package/coverage/lcov-report/src/integrations/redis.ts.html +550 -0
- package/coverage/lcov-report/src/integrations/rest.ts.html +1381 -0
- package/coverage/lcov-report/src/integrations/s3.ts.html +862 -0
- package/coverage/lcov-report/src/integrations/snowflake.ts.html +376 -0
- package/coverage/lcov-report/{integrations → src/integrations}/tests/TestConfiguration.js.html +10 -10
- package/coverage/lcov-report/{integrations → src/integrations}/tests/index.html +10 -10
- package/coverage/lcov-report/src/integrations/utils.ts.html +1018 -0
- package/coverage/lcov-report/{middleware/appInfo.js.html → src/middleware/appInfo.ts.html} +33 -30
- package/coverage/lcov-report/src/middleware/authorized.ts.html +460 -0
- package/coverage/lcov-report/{middleware/builder.js.html → src/middleware/builder.ts.html} +57 -51
- package/coverage/lcov-report/{middleware/currentapp.js.html → src/middleware/currentapp.ts.html} +116 -107
- package/coverage/lcov-report/{middleware → src/middleware}/index.html +78 -63
- package/coverage/lcov-report/{middleware/joi-validator.js.html → src/middleware/joi-validator.ts.html} +25 -22
- package/coverage/lcov-report/{middleware/publicApi.js.html → src/middleware/publicApi.ts.html} +31 -31
- package/coverage/lcov-report/{middleware/resourceId.js.html → src/middleware/resourceId.ts.html} +66 -51
- package/coverage/lcov-report/{api/controllers/integration.js.html → src/middleware/selfhost.ts.html} +22 -28
- package/coverage/lcov-report/{api/routes/analytics.js.html → src/middleware/utils.ts.html} +19 -19
- package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +166 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +163 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +206 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +172 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/queries.ts.html +226 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/roles.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +166 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +532 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +283 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +146 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +265 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +232 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +724 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/index.html +161 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +106 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +235 -0
- package/coverage/lcov-report/src/migrations/functions/index.html +161 -0
- package/coverage/lcov-report/{api/routes/role.js.html → src/migrations/functions/syncQuotas.ts.html} +36 -36
- package/coverage/lcov-report/src/migrations/functions/tableSettings.ts.html +520 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +161 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +94 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +127 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +115 -0
- package/coverage/lcov-report/{automations/index.js.html → src/migrations/functions/usageQuotas/syncRows.ts.html} +58 -61
- package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +124 -0
- package/coverage/lcov-report/{utilities/queue → src/migrations}/index.html +23 -23
- package/coverage/lcov-report/src/migrations/index.ts.html +430 -0
- package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +205 -0
- package/coverage/lcov-report/src/migrations/tests/index.html +131 -0
- package/coverage/lcov-report/src/migrations/tests/structures.ts.html +283 -0
- package/coverage/lcov-report/src/sdk/app/applications/index.html +146 -0
- package/coverage/lcov-report/{middleware/utils.js.html → src/sdk/app/applications/index.ts.html} +19 -19
- package/coverage/lcov-report/src/sdk/app/applications/sync.ts.html +268 -0
- package/coverage/lcov-report/src/sdk/app/applications/utils.ts.html +136 -0
- package/coverage/lcov-report/src/sdk/app/automations/index.html +131 -0
- package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +100 -0
- package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +214 -0
- package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +91 -0
- package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +604 -0
- package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +682 -0
- package/coverage/lcov-report/src/sdk/app/backups/index.html +176 -0
- package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +112 -0
- package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +292 -0
- package/coverage/lcov-report/src/sdk/app/tables/index.html +116 -0
- package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +265 -0
- package/coverage/lcov-report/{utilities/routing → src/sdk}/index.html +10 -10
- package/coverage/lcov-report/{api/routes/layout.js.html → src/sdk/index.ts.html} +24 -24
- package/coverage/lcov-report/src/sdk/users/index.html +131 -0
- package/coverage/lcov-report/src/sdk/users/index.ts.html +100 -0
- package/coverage/lcov-report/src/sdk/users/utils.ts.html +277 -0
- package/coverage/lcov-report/src/startup.ts.html +499 -0
- package/coverage/lcov-report/src/tests/utilities/TestConfiguration.ts.html +1966 -0
- package/coverage/lcov-report/src/tests/utilities/controllers.ts.html +127 -0
- package/coverage/lcov-report/src/tests/utilities/index.html +161 -0
- package/coverage/lcov-report/{middleware/selfhost.js.html → src/tests/utilities/index.ts.html} +33 -30
- package/coverage/lcov-report/src/tests/utilities/structures.ts.html +667 -0
- package/coverage/lcov-report/src/threads/automation.ts.html +1594 -0
- package/coverage/lcov-report/src/threads/index.html +161 -0
- package/coverage/lcov-report/src/threads/index.ts.html +418 -0
- package/coverage/lcov-report/src/threads/query.ts.html +961 -0
- package/coverage/lcov-report/src/threads/utils.ts.html +373 -0
- package/coverage/lcov-report/{utilities/budibaseDir.js.html → src/utilities/budibaseDir.ts.html} +14 -14
- package/coverage/lcov-report/{utilities/centralPath.js.html → src/utilities/centralPath.ts.html} +16 -16
- package/coverage/lcov-report/{utilities/csvParser.js.html → src/utilities/csvParser.ts.html} +107 -59
- package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.ts.html +547 -0
- package/coverage/lcov-report/{api/controllers/table → src/utilities/fileSystem}/index.html +44 -44
- package/coverage/lcov-report/src/utilities/fileSystem/index.ts.html +1129 -0
- package/coverage/lcov-report/src/utilities/fileSystem/processor.ts.html +142 -0
- package/coverage/lcov-report/{utilities/global.js.html → src/utilities/global.ts.html} +144 -111
- package/coverage/lcov-report/{utilities → src/utilities}/index.html +92 -77
- package/coverage/lcov-report/{utilities/index.js.html → src/utilities/index.ts.html} +98 -74
- package/coverage/lcov-report/{utilities/plugins.js.html → src/utilities/plugins.ts.html} +25 -22
- package/coverage/lcov-report/src/utilities/redis.ts.html +343 -0
- package/coverage/lcov-report/{api/controllers/query → src/utilities/routing}/index.html +8 -8
- package/coverage/lcov-report/src/utilities/routing/index.ts.html +181 -0
- package/coverage/lcov-report/src/utilities/rowProcessor/index.html +146 -0
- package/coverage/lcov-report/{utilities/rowProcessor/index.js.html → src/utilities/rowProcessor/index.ts.html} +128 -359
- package/coverage/lcov-report/src/utilities/rowProcessor/map.ts.html +373 -0
- package/coverage/lcov-report/{utilities/rowProcessor/utils.js.html → src/utilities/rowProcessor/utils.ts.html} +54 -42
- package/coverage/lcov-report/{utilities/scriptRunner.js.html → src/utilities/scriptRunner.ts.html} +31 -19
- package/coverage/lcov-report/{utilities/security.js.html → src/utilities/security.ts.html} +60 -78
- package/coverage/lcov-report/{utilities/statusCodes.js.html → src/utilities/statusCodes.ts.html} +11 -11
- package/coverage/lcov-report/{utilities → src/utilities}/usageQuota/index.html +30 -30
- package/coverage/lcov-report/{utilities/usageQuota/rows.js.html → src/utilities/usageQuota/rows.ts.html} +42 -54
- package/coverage/lcov-report/{utilities/usageQuota/usageQuoteReset.js.html → src/utilities/usageQuota/usageQuoteReset.ts.html} +13 -13
- package/coverage/lcov-report/{utilities/users.js.html → src/utilities/users.ts.html} +44 -50
- package/coverage/lcov-report/{utilities/workerRequests.js.html → src/utilities/workerRequests.ts.html} +127 -112
- package/coverage/lcov-report/{events/utils.js.html → src/watch.ts.html} +68 -71
- package/coverage/lcov-report/src/websocket.ts.html +163 -0
- package/coverage/lcov.info +19994 -7196
- package/dist/api/controllers/apikeys.js +12 -9
- package/dist/api/controllers/application.js +430 -446
- package/dist/api/controllers/automation.js +122 -82
- package/dist/api/controllers/cloud.js +85 -71
- package/dist/api/controllers/component.js +4 -2
- package/dist/api/controllers/datasource.js +151 -94
- package/dist/api/controllers/deploy/Deployment.js +10 -6
- package/dist/api/controllers/deploy/index.js +19 -16
- package/dist/api/controllers/dev.js +96 -81
- package/dist/api/controllers/integration.js +11 -8
- package/dist/api/controllers/layout.js +18 -15
- package/dist/api/controllers/metadata.js +51 -37
- package/dist/api/controllers/migrations.js +19 -11
- package/dist/api/controllers/permission.js +52 -43
- package/dist/api/controllers/plugin/index.js +6 -7
- package/dist/api/controllers/plugin/utils.js +2 -1
- package/dist/api/controllers/public/applications.js +17 -9
- package/dist/api/controllers/public/tables.js +29 -9
- package/dist/api/controllers/public/users.js +18 -0
- package/dist/api/controllers/public/utils.js +2 -2
- package/dist/api/controllers/query/import/index.js +1 -2
- package/dist/api/controllers/query/index.js +10 -13
- package/dist/api/controllers/query/validation.js +41 -33
- package/dist/api/controllers/role.js +29 -27
- package/dist/api/controllers/routing.js +71 -58
- package/dist/api/controllers/row/ExternalRequest.js +539 -542
- package/dist/api/controllers/row/external.js +258 -190
- package/dist/api/controllers/row/index.js +43 -14
- package/dist/api/controllers/row/internal.js +354 -295
- package/dist/api/controllers/row/internalSearch.js +95 -80
- package/dist/api/controllers/row/staticFormula.js +125 -112
- package/dist/api/controllers/row/utils.js +122 -84
- package/dist/api/controllers/screen.js +81 -66
- package/dist/api/controllers/script.js +13 -6
- package/dist/api/controllers/static/index.js +11 -14
- package/dist/api/controllers/table/bulkFormula.js +47 -35
- package/dist/api/controllers/table/external.js +89 -53
- package/dist/api/controllers/table/index.js +64 -31
- package/dist/api/controllers/table/internal.js +5 -6
- package/dist/api/controllers/table/utils.js +39 -35
- package/dist/api/controllers/templates.js +17 -10
- package/dist/api/controllers/user.js +65 -94
- package/dist/api/controllers/view/exporters.js +8 -4
- package/dist/api/controllers/view/index.js +201 -153
- package/dist/api/controllers/view/utils.js +151 -121
- package/dist/api/controllers/view/viewBuilder.js +4 -16
- package/dist/api/controllers/webhook.js +25 -2
- package/dist/api/index.js +38 -34
- package/dist/api/routes/analytics.js +29 -3
- package/dist/api/routes/apikeys.js +33 -7
- package/dist/api/routes/application.js +8 -9
- package/dist/api/routes/auth.js +1 -2
- package/dist/api/routes/automation.js +46 -20
- package/dist/api/routes/backup.js +3 -4
- package/dist/api/routes/cloud.js +32 -6
- package/dist/api/routes/component.js +32 -6
- package/dist/api/routes/datasource.js +39 -13
- package/dist/api/routes/deploy.js +34 -8
- package/dist/api/routes/dev.js +36 -10
- package/dist/api/routes/integration.js +33 -7
- package/dist/api/routes/layout.js +33 -7
- package/dist/api/routes/metadata.js +36 -10
- package/dist/api/routes/migrations.js +32 -6
- package/dist/api/routes/permission.js +38 -12
- package/dist/api/routes/plugin.js +5 -5
- package/dist/api/routes/public/index.js +11 -11
- package/dist/api/routes/public/tests/utils.js +33 -0
- package/dist/api/routes/query.js +42 -15
- package/dist/api/routes/role.js +36 -10
- package/dist/api/routes/routing.js +32 -6
- package/dist/api/routes/row.js +12 -11
- package/dist/api/routes/screen.js +35 -9
- package/dist/api/routes/script.js +32 -6
- package/dist/api/routes/static.js +9 -9
- package/dist/api/routes/table.js +40 -13
- package/dist/api/routes/templates.js +33 -7
- package/dist/api/routes/tests/utilities/TestFunctions.js +6 -8
- package/dist/api/routes/tests/utilities/index.js +69 -32
- package/dist/api/routes/user.js +40 -13
- package/dist/api/routes/utils/validators.js +142 -126
- package/dist/api/routes/view.js +38 -12
- package/dist/api/routes/webhook.js +1 -2
- package/dist/app.js +22 -22
- package/dist/automations/actions.js +53 -24
- package/dist/automations/automationUtils.js +31 -19
- package/dist/automations/bullboard.js +59 -29
- package/dist/automations/index.js +23 -18
- package/dist/automations/steps/bash.js +40 -10
- package/dist/automations/steps/createRow.js +2 -1
- package/dist/automations/steps/delay.js +9 -5
- package/dist/automations/steps/deleteRow.js +2 -1
- package/dist/automations/steps/discord.js +14 -7
- package/dist/automations/steps/executeQuery.js +34 -7
- package/dist/automations/steps/executeScript.js +34 -7
- package/dist/automations/steps/filter.js +20 -18
- package/dist/automations/steps/integromat.js +14 -7
- package/dist/automations/steps/loop.js +4 -1
- package/dist/automations/steps/outgoingWebhook.js +45 -14
- package/dist/automations/steps/queryRows.js +71 -38
- package/dist/automations/steps/sendSmtpEmail.js +33 -6
- package/dist/automations/steps/serverLog.js +12 -8
- package/dist/automations/steps/slack.js +14 -7
- package/dist/automations/steps/updateRow.js +34 -7
- package/dist/automations/steps/utils.js +22 -16
- package/dist/automations/steps/zapier.js +15 -7
- package/dist/automations/tests/utilities/index.js +62 -38
- package/dist/automations/triggerInfo/app.js +4 -1
- package/dist/automations/triggerInfo/cron.js +4 -1
- package/dist/automations/triggerInfo/index.js +31 -6
- package/dist/automations/triggerInfo/rowDeleted.js +4 -1
- package/dist/automations/triggerInfo/rowSaved.js +4 -1
- package/dist/automations/triggerInfo/rowUpdated.js +4 -1
- package/dist/automations/triggerInfo/webhook.js +4 -1
- package/dist/automations/triggers.js +90 -57
- package/dist/automations/utils.js +9 -8
- package/dist/constants/index.js +118 -104
- package/dist/constants/layouts.js +7 -10
- package/dist/constants/screens.js +49 -44
- package/dist/db/defaultData/datasource_bb_default.js +573 -0
- package/dist/db/defaultData/employeeImport.js +155 -0
- package/dist/db/defaultData/expensesImport.js +117 -0
- package/dist/db/defaultData/inventoryImport.js +109 -0
- package/dist/db/defaultData/jobsImport.js +152 -0
- package/dist/db/dynamoClient.js +20 -20
- package/dist/db/inMemoryView.js +47 -38
- package/dist/db/index.js +7 -4
- package/dist/db/linkedRows/LinkController.js +51 -70
- package/dist/db/linkedRows/LinkDocument.js +32 -0
- package/dist/db/linkedRows/index.js +93 -81
- package/dist/db/linkedRows/linkUtils.js +42 -32
- package/dist/db/utils.js +146 -119
- package/dist/db/views/staticViews.js +91 -74
- package/dist/environment.js +9 -6
- package/dist/events/AutomationEmitter.js +13 -10
- package/dist/events/BudibaseEmitter.js +24 -0
- package/dist/events/index.js +5 -23
- package/dist/events/utils.js +18 -10
- package/dist/integrations/base/types.js +2 -0
- package/dist/integrations/elasticsearch.js +26 -2
- package/dist/integrations/googlesheets.js +5 -6
- package/dist/integrations/index.js +15 -6
- package/dist/integrations/microsoftSqlServer.js +8 -3
- package/dist/integrations/oracle.js +8 -1
- package/dist/integrations/postgres.js +6 -3
- package/dist/integrations/s3.js +157 -1
- package/dist/middleware/appInfo.js +14 -9
- package/dist/middleware/authorized.js +22 -21
- package/dist/middleware/builder.js +41 -40
- package/dist/middleware/currentapp.js +39 -37
- package/dist/middleware/joi-validator.js +17 -10
- package/dist/middleware/publicApi.js +5 -6
- package/dist/middleware/resourceId.js +16 -9
- package/dist/middleware/selfhost.js +5 -4
- package/dist/middleware/utils.js +5 -2
- package/dist/migrations/functions/appUrls.js +7 -11
- package/dist/migrations/functions/backfill/global.js +1 -1
- package/dist/migrations/functions/tableSettings.js +130 -0
- package/dist/migrations/functions/usageQuotas/syncApps.js +3 -4
- package/dist/migrations/functions/usageQuotas/syncRows.js +3 -4
- package/dist/migrations/functions/userEmailViewCasing.js +3 -3
- package/dist/migrations/index.js +5 -0
- package/dist/package.json +11 -45
- package/dist/sdk/app/applications/index.js +28 -0
- package/dist/sdk/app/applications/sync.js +70 -0
- package/dist/sdk/app/applications/utils.js +21 -0
- package/dist/sdk/app/backups/exports.js +1 -2
- package/dist/sdk/app/backups/imports.js +2 -3
- package/dist/sdk/app/tables/index.js +5 -5
- package/dist/sdk/index.js +4 -2
- package/dist/sdk/users/index.js +27 -0
- package/dist/sdk/users/utils.js +65 -0
- package/dist/startup.js +10 -10
- package/dist/tests/utilities/TestConfiguration.js +111 -87
- package/dist/tests/utilities/controllers.js +38 -15
- package/dist/tests/utilities/structures.js +72 -53
- package/dist/threads/automation.js +49 -27
- package/dist/threads/query.js +17 -19
- package/dist/threads/utils.js +33 -8
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/budibaseDir.js +4 -2
- package/dist/utilities/centralPath.js +14 -7
- package/dist/utilities/csvParser.js +27 -21
- package/dist/utilities/fileSystem/clientLibrary.js +87 -73
- package/dist/utilities/fileSystem/index.js +203 -175
- package/dist/utilities/fileSystem/processor.js +8 -3
- package/dist/utilities/global.js +87 -66
- package/dist/utilities/index.js +102 -75
- package/dist/utilities/plugins.js +15 -9
- package/dist/utilities/redis.js +100 -65
- package/dist/utilities/routing/index.js +27 -23
- package/dist/utilities/rowProcessor/index.js +133 -191
- package/dist/utilities/rowProcessor/map.js +99 -0
- package/dist/utilities/rowProcessor/utils.js +35 -26
- package/dist/utilities/scriptRunner.js +8 -5
- package/dist/utilities/security.js +39 -35
- package/dist/utilities/usageQuota/rows.js +56 -49
- package/dist/utilities/users.js +31 -28
- package/dist/utilities/workerRequests.js +115 -82
- package/dist/watch.js +1 -2
- package/jest.config.ts +33 -0
- package/package.json +12 -46
- package/scripts/exportAppTemplate.js +2 -2
- package/scripts/integrations/mssql/data/setup.sql +3 -3
- package/scripts/integrations/postgres/emp-skill.sql +46 -0
- package/scripts/localdomain.js +34 -6
- package/src/api/controllers/{apikeys.js → apikeys.ts} +10 -10
- package/src/api/controllers/application.ts +100 -135
- package/src/api/controllers/auth.ts +4 -3
- package/src/api/controllers/{automation.js → automation.ts} +48 -48
- package/src/api/controllers/{cloud.js → cloud.ts} +25 -24
- package/src/api/controllers/component.ts +2 -1
- package/src/api/controllers/{datasource.js → datasource.ts} +109 -49
- package/src/api/controllers/deploy/{Deployment.js → Deployment.ts} +13 -10
- package/src/api/controllers/deploy/index.ts +19 -25
- package/src/api/controllers/{dev.js → dev.ts} +31 -37
- package/src/api/controllers/integration.ts +13 -0
- package/src/api/controllers/{layout.js → layout.ts} +8 -8
- package/src/api/controllers/{metadata.js → metadata.ts} +11 -10
- package/src/api/controllers/migrations.ts +14 -0
- package/src/api/controllers/{permission.js → permission.ts} +49 -46
- package/src/api/controllers/plugin/index.ts +4 -5
- package/src/api/controllers/plugin/utils.ts +3 -5
- package/src/api/controllers/public/applications.ts +15 -9
- package/src/api/controllers/public/rows.ts +1 -1
- package/src/api/controllers/public/tables.ts +2 -2
- package/src/api/controllers/public/users.ts +25 -6
- package/src/api/controllers/public/utils.ts +2 -2
- package/src/api/controllers/query/import/index.ts +2 -3
- package/src/api/controllers/query/index.ts +11 -14
- package/src/api/controllers/query/{validation.js → validation.ts} +7 -7
- package/src/api/controllers/{role.js → role.ts} +21 -25
- package/src/api/controllers/{routing.js → routing.ts} +37 -34
- package/src/api/controllers/row/ExternalRequest.ts +605 -624
- package/src/api/controllers/row/{external.js → external.ts} +79 -62
- package/src/api/controllers/row/index.ts +19 -11
- package/src/api/controllers/row/{internal.js → internal.ts} +87 -73
- package/src/api/controllers/row/{internalSearch.js → internalSearch.ts} +92 -68
- package/src/api/controllers/row/{staticFormula.js → staticFormula.ts} +30 -25
- package/src/api/controllers/row/{utils.js → utils.ts} +32 -22
- package/src/api/controllers/screen.ts +10 -6
- package/src/api/controllers/script.ts +12 -0
- package/src/api/controllers/static/index.ts +14 -16
- package/src/api/controllers/table/{bulkFormula.js → bulkFormula.ts} +39 -25
- package/src/api/controllers/table/{external.js → external.ts} +86 -55
- package/src/api/controllers/table/{index.js → index.ts} +21 -18
- package/src/api/controllers/table/internal.ts +5 -6
- package/src/api/controllers/table/utils.ts +26 -21
- package/src/api/controllers/{templates.js → templates.ts} +10 -7
- package/src/api/controllers/{user.js → user.ts} +42 -101
- package/src/api/controllers/view/{exporters.js → exporters.ts} +5 -3
- package/src/api/controllers/view/{index.js → index.ts} +36 -27
- package/src/api/controllers/view/{utils.js → utils.ts} +26 -20
- package/src/api/controllers/view/{viewBuilder.js → viewBuilder.ts} +25 -11
- package/src/api/controllers/webhook.ts +1 -1
- package/src/api/{index.js → index.ts} +15 -22
- package/src/api/routes/analytics.ts +9 -0
- package/src/api/routes/apikeys.ts +12 -0
- package/src/api/routes/application.ts +17 -9
- package/src/api/routes/auth.ts +2 -2
- package/src/api/routes/automation.ts +87 -0
- package/src/api/routes/backup.ts +8 -4
- package/src/api/routes/cloud.ts +18 -0
- package/src/api/routes/component.ts +14 -0
- package/src/api/routes/datasource.ts +60 -0
- package/src/api/routes/deploy.ts +21 -0
- package/src/api/routes/dev.ts +38 -0
- package/src/api/routes/integration.ts +16 -0
- package/src/api/routes/layout.ts +16 -0
- package/src/api/routes/{metadata.js → metadata.ts} +13 -13
- package/src/api/routes/migrations.ts +14 -0
- package/src/api/routes/permission.ts +41 -0
- package/src/api/routes/plugin.ts +14 -6
- package/src/api/routes/public/index.ts +11 -14
- package/src/api/routes/public/tests/compare.spec.js +3 -21
- package/src/api/routes/public/tests/users.spec.js +38 -0
- package/src/api/routes/public/tests/utils.ts +28 -0
- package/src/api/routes/{query.js → query.ts} +19 -22
- package/src/api/routes/role.ts +24 -0
- package/src/api/routes/routing.ts +14 -0
- package/src/api/routes/row.ts +13 -15
- package/src/api/routes/screen.ts +23 -0
- package/src/api/routes/script.ts +10 -0
- package/src/api/routes/static.ts +7 -10
- package/src/api/routes/{table.js → table.ts} +10 -13
- package/src/api/routes/templates.ts +16 -0
- package/src/api/routes/tests/analytics.spec.js +1 -1
- package/src/api/routes/tests/application.spec.js +0 -1
- package/src/api/routes/tests/backup.spec.js +9 -1
- package/src/api/routes/tests/deployment.spec.ts +1 -1
- package/src/api/routes/tests/permissions.spec.js +2 -1
- package/src/api/routes/tests/query.spec.js +15 -10
- package/src/api/routes/tests/role.spec.js +7 -9
- package/src/api/routes/tests/routing.spec.js +2 -1
- package/src/api/routes/tests/row.spec.js +3 -4
- package/src/api/routes/tests/static.spec.js +2 -2
- package/src/api/routes/tests/table.spec.js +40 -36
- package/src/api/routes/tests/user.spec.js +2 -1
- package/src/api/routes/tests/utilities/TestFunctions.ts +6 -8
- package/src/api/routes/tests/utilities/{index.js → index.ts} +12 -12
- package/src/api/routes/tests/view.spec.js +3 -3
- package/src/api/routes/user.ts +51 -0
- package/src/api/routes/utils/{validators.js → validators.ts} +33 -37
- package/src/api/routes/view.ts +34 -0
- package/src/api/routes/webhook.ts +2 -2
- package/src/app.ts +15 -14
- package/src/automations/{actions.js → actions.ts} +26 -23
- package/src/automations/{automationUtils.js → automationUtils.ts} +13 -12
- package/src/automations/bullboard.ts +38 -0
- package/src/automations/index.ts +26 -0
- package/src/automations/steps/{bash.js → bash.ts} +13 -8
- package/src/automations/steps/createRow.ts +8 -3
- package/src/automations/steps/{delay.js → delay.ts} +9 -4
- package/src/automations/steps/deleteRow.ts +8 -3
- package/src/automations/steps/{discord.js → discord.ts} +10 -5
- package/src/automations/steps/{executeQuery.js → executeQuery.ts} +12 -7
- package/src/automations/steps/{executeScript.js → executeScript.ts} +17 -7
- package/src/automations/steps/{filter.js → filter.ts} +12 -9
- package/src/automations/steps/{integromat.js → integromat.ts} +10 -5
- package/src/automations/steps/{loop.js → loop.ts} +4 -2
- package/src/automations/steps/{outgoingWebhook.js → outgoingWebhook.ts} +18 -13
- package/src/automations/steps/{queryRows.js → queryRows.ts} +48 -36
- package/src/automations/steps/{sendSmtpEmail.js → sendSmtpEmail.ts} +10 -5
- package/src/automations/steps/{serverLog.js → serverLog.ts} +9 -3
- package/src/automations/steps/{slack.js → slack.ts} +10 -5
- package/src/automations/steps/{updateRow.js → updateRow.ts} +12 -7
- package/src/automations/steps/{utils.js → utils.ts} +10 -4
- package/src/automations/steps/{zapier.js → zapier.ts} +11 -5
- package/src/automations/tests/updateRow.spec.js +0 -1
- package/src/automations/tests/utilities/index.ts +60 -0
- package/src/automations/triggerInfo/{app.js → app.ts} +7 -2
- package/src/automations/triggerInfo/{cron.js → cron.ts} +7 -2
- package/src/automations/triggerInfo/index.ts +15 -0
- package/src/automations/triggerInfo/{rowDeleted.js → rowDeleted.ts} +7 -2
- package/src/automations/triggerInfo/{rowSaved.js → rowSaved.ts} +7 -2
- package/src/automations/triggerInfo/{rowUpdated.js → rowUpdated.ts} +7 -2
- package/src/automations/triggerInfo/{webhook.js → webhook.ts} +7 -2
- package/src/automations/{triggers.js → triggers.ts} +30 -26
- package/src/automations/utils.ts +9 -12
- package/src/constants/index.ts +204 -0
- package/src/constants/{layouts.js → layouts.ts} +3 -9
- package/src/constants/screens.ts +48 -0
- package/src/db/defaultData/datasource_bb_default.ts +658 -0
- package/src/db/defaultData/employeeImport.ts +152 -0
- package/src/db/defaultData/expensesImport.ts +114 -0
- package/src/db/defaultData/inventoryImport.ts +106 -0
- package/src/db/defaultData/jobsImport.ts +158 -0
- package/src/db/{dynamoClient.js → dynamoClient.ts} +39 -19
- package/src/db/{inMemoryView.js → inMemoryView.ts} +15 -9
- package/src/db/index.ts +16 -0
- package/src/db/linkedRows/{LinkController.js → LinkController.ts} +64 -85
- package/src/db/linkedRows/LinkDocument.ts +60 -0
- package/src/db/linkedRows/{index.js → index.ts} +43 -38
- package/src/db/linkedRows/{linkUtils.js → linkUtils.ts} +33 -24
- package/src/db/{newid.js → newid.ts} +1 -1
- package/src/db/tests/linkController.spec.js +73 -57
- package/src/db/tests/linkTests.spec.js +17 -14
- package/src/db/{utils.js → utils.ts} +77 -93
- package/src/db/views/{staticViews.js → staticViews.ts} +20 -13
- package/src/{environment.js → environment.ts} +11 -7
- package/src/events/{AutomationEmitter.js → AutomationEmitter.ts} +12 -7
- package/src/events/{index.js → BudibaseEmitter.ts} +7 -8
- package/src/events/index.ts +5 -0
- package/src/events/utils.ts +78 -0
- package/src/integrations/base/sql.ts +1 -1
- package/src/integrations/base/sqlTable.ts +1 -1
- package/src/integrations/base/types.ts +134 -0
- package/src/integrations/elasticsearch.ts +32 -2
- package/src/integrations/googlesheets.ts +5 -7
- package/src/integrations/index.ts +45 -41
- package/src/integrations/microsoftSqlServer.ts +14 -12
- package/src/integrations/mysql.ts +4 -3
- package/src/integrations/oracle.ts +17 -46
- package/src/integrations/postgres.ts +8 -2
- package/src/integrations/s3.ts +179 -3
- package/src/integrations/tests/s3.spec.ts +85 -1
- package/src/integrations/utils.ts +6 -2
- package/src/middleware/appInfo.ts +20 -0
- package/src/middleware/authorized.ts +21 -28
- package/src/middleware/{builder.js → builder.ts} +17 -15
- package/src/middleware/{currentapp.js → currentapp.ts} +42 -39
- package/src/middleware/{joi-validator.js → joi-validator.ts} +9 -8
- package/src/middleware/publicApi.ts +21 -0
- package/src/middleware/{resourceId.js → resourceId.ts} +16 -11
- package/src/middleware/{selfhost.js → selfhost.ts} +4 -2
- package/src/middleware/tests/authorized.spec.js +5 -6
- package/src/middleware/tests/currentapp.spec.js +118 -63
- package/src/middleware/{utils.js → utils.ts} +3 -1
- package/src/migrations/functions/appUrls.ts +4 -11
- package/src/migrations/functions/backfill/app/tables.ts +2 -5
- package/src/migrations/functions/backfill/global.ts +1 -1
- package/src/migrations/functions/tableSettings.ts +145 -0
- package/src/migrations/functions/tests/appUrls.spec.js +4 -4
- package/src/migrations/functions/tests/tableSettings.spec.ts +144 -0
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +14 -9
- package/src/migrations/functions/usageQuotas/syncApps.ts +3 -4
- package/src/migrations/functions/usageQuotas/syncRows.ts +4 -5
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +7 -7
- package/src/migrations/functions/userEmailViewCasing.ts +3 -3
- package/src/migrations/index.ts +9 -0
- package/src/migrations/tests/index.spec.ts +1 -1
- package/src/sdk/app/applications/index.ts +7 -0
- package/src/sdk/app/applications/sync.ts +61 -0
- package/src/sdk/app/applications/utils.ts +17 -0
- package/src/sdk/app/backups/exports.ts +5 -3
- package/src/sdk/app/backups/imports.ts +7 -14
- package/src/sdk/app/backups/statistics.ts +9 -18
- package/src/sdk/app/tables/index.ts +7 -8
- package/src/sdk/index.ts +4 -3
- package/src/sdk/users/index.ts +5 -0
- package/src/sdk/users/utils.ts +64 -0
- package/src/startup.ts +5 -5
- package/{scripts/jestSetup.js → src/tests/jestSetup.ts} +11 -2
- package/src/tests/utilities/{TestConfiguration.js → TestConfiguration.ts} +111 -78
- package/src/tests/utilities/controllers.ts +14 -0
- package/src/tests/utilities/{index.js → index.ts} +2 -2
- package/src/tests/utilities/{structures.js → structures.ts} +41 -36
- package/src/threads/automation.ts +18 -19
- package/src/threads/query.ts +11 -16
- package/src/threads/utils.ts +4 -5
- package/src/utilities/budibaseDir.ts +3 -0
- package/src/utilities/{centralPath.js → centralPath.ts} +3 -3
- package/src/utilities/{csvParser.js → csvParser.ts} +42 -26
- package/src/utilities/fileSystem/{clientLibrary.js → clientLibrary.ts} +20 -20
- package/src/utilities/fileSystem/{index.js → index.ts} +61 -65
- package/src/utilities/fileSystem/{processor.js → processor.ts} +3 -5
- package/src/utilities/global.ts +138 -0
- package/src/utilities/{index.js → index.ts} +40 -32
- package/src/utilities/{plugins.js → plugins.ts} +5 -4
- package/src/utilities/{redis.js → redis.ts} +21 -20
- package/src/utilities/routing/index.ts +32 -0
- package/src/utilities/rowProcessor/{index.js → index.ts} +67 -144
- package/src/utilities/rowProcessor/map.ts +96 -0
- package/src/utilities/rowProcessor/{utils.js → utils.ts} +19 -15
- package/src/utilities/{scriptRunner.js → scriptRunner.ts} +8 -4
- package/src/utilities/security.ts +65 -0
- package/src/utilities/{statusCodes.js → statusCodes.ts} +1 -1
- package/src/utilities/usageQuota/{rows.js → rows.ts} +14 -18
- package/src/utilities/usageQuota/{usageQuoteReset.js → usageQuoteReset.ts} +1 -1
- package/src/utilities/{users.js → users.ts} +11 -13
- package/src/utilities/{workerRequests.js → workerRequests.ts} +43 -38
- package/src/watch.ts +2 -3
- package/tsconfig.build.json +1 -2
- package/tsconfig.json +3 -1
- package/builder/assets/index.534f6c29.css +0 -6
- package/builder/assets/index.f1f9afd2.js +0 -1021
- package/coverage/lcov-report/api/controllers/index.html +0 -326
- package/coverage/lcov-report/automations/steps/index.html +0 -341
- package/coverage/lcov-report/db/linkedRows/index.html +0 -146
- package/dist/integrations/tests/TestConfiguration.js +0 -1
- package/dist/utilities/fileSystem/utilities.js +0 -22
- package/dist/utilities/queue/inMemoryQueue.js +0 -126
- package/src/api/controllers/integration.js +0 -14
- package/src/api/controllers/migrations.js +0 -13
- package/src/api/controllers/script.js +0 -11
- package/src/api/routes/analytics.js +0 -9
- package/src/api/routes/apikeys.js +0 -12
- package/src/api/routes/automation.js +0 -85
- package/src/api/routes/cloud.js +0 -14
- package/src/api/routes/component.js +0 -14
- package/src/api/routes/datasource.js +0 -51
- package/src/api/routes/deploy.js +0 -17
- package/src/api/routes/dev.js +0 -26
- package/src/api/routes/integration.js +0 -12
- package/src/api/routes/layout.js +0 -16
- package/src/api/routes/migrations.js +0 -14
- package/src/api/routes/permission.js +0 -33
- package/src/api/routes/role.js +0 -15
- package/src/api/routes/routing.js +0 -14
- package/src/api/routes/screen.js +0 -18
- package/src/api/routes/script.js +0 -10
- package/src/api/routes/templates.js +0 -16
- package/src/api/routes/user.js +0 -53
- package/src/api/routes/view.js +0 -31
- package/src/automations/bullboard.js +0 -39
- package/src/automations/index.js +0 -29
- package/src/automations/tests/utilities/index.js +0 -51
- package/src/automations/triggerInfo/index.js +0 -15
- package/src/constants/index.js +0 -208
- package/src/constants/screens.js +0 -46
- package/src/db/index.js +0 -16
- package/src/events/utils.js +0 -38
- package/src/middleware/appInfo.js +0 -19
- package/src/middleware/publicApi.js +0 -21
- package/src/module.d.ts +0 -14
- package/src/tests/utilities/controllers.js +0 -16
- package/src/utilities/budibaseDir.js +0 -3
- package/src/utilities/fileSystem/utilities.js +0 -36
- package/src/utilities/global.js +0 -127
- package/src/utilities/queue/inMemoryQueue.js +0 -122
- package/src/utilities/routing/index.js +0 -25
- package/src/utilities/security.js +0 -71
package/src/db/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { init as coreInit } from "@budibase/backend-core"
|
|
2
|
+
import env = require("../environment")
|
|
3
|
+
|
|
4
|
+
export function init() {
|
|
5
|
+
const dbConfig: any = {
|
|
6
|
+
replication: true,
|
|
7
|
+
find: true,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (env.isTest() && !env.COUCH_DB_URL) {
|
|
11
|
+
dbConfig.inMemory = true
|
|
12
|
+
dbConfig.allDbs = true
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
coreInit({ db: dbConfig })
|
|
16
|
+
}
|
|
@@ -1,59 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { IncludeDocs, getLinkDocuments } from "./linkUtils"
|
|
2
|
+
import { InternalTables, getUserMetadataParams } from "../utils"
|
|
3
|
+
import Sentry from "@sentry/node"
|
|
4
|
+
import { FieldTypes, RelationshipTypes } from "../../constants"
|
|
5
|
+
import { context } from "@budibase/backend-core"
|
|
6
|
+
import LinkDocument from "./LinkDocument"
|
|
7
|
+
import {
|
|
8
|
+
Database,
|
|
9
|
+
FieldSchema,
|
|
10
|
+
LinkDocumentValue,
|
|
11
|
+
Row,
|
|
12
|
+
Table,
|
|
13
|
+
} from "@budibase/types"
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @param {string} tableId2 The ID of the second table (the linked).
|
|
17
|
-
* @param {string} fieldName1 The name of the field in the linker table.
|
|
18
|
-
* @param {string} fieldName2 The name of the field in the linked table.
|
|
19
|
-
* @param {string} rowId1 The ID of the row which is acting as the linker.
|
|
20
|
-
* @param {string} rowId2 The ID of the row which is acting as the linked.
|
|
21
|
-
* @constructor
|
|
22
|
-
*/
|
|
23
|
-
function LinkDocument(
|
|
24
|
-
tableId1,
|
|
25
|
-
fieldName1,
|
|
26
|
-
rowId1,
|
|
27
|
-
tableId2,
|
|
28
|
-
fieldName2,
|
|
29
|
-
rowId2
|
|
30
|
-
) {
|
|
31
|
-
// build the ID out of unique references to this link document
|
|
32
|
-
this._id = generateLinkID(
|
|
33
|
-
tableId1,
|
|
34
|
-
tableId2,
|
|
35
|
-
rowId1,
|
|
36
|
-
rowId2,
|
|
37
|
-
fieldName1,
|
|
38
|
-
fieldName2
|
|
39
|
-
)
|
|
40
|
-
// required for referencing in view
|
|
41
|
-
this.type = FieldTypes.LINK
|
|
42
|
-
this.doc1 = {
|
|
43
|
-
tableId: tableId1,
|
|
44
|
-
fieldName: fieldName1,
|
|
45
|
-
rowId: rowId1,
|
|
46
|
-
}
|
|
47
|
-
this.doc2 = {
|
|
48
|
-
tableId: tableId2,
|
|
49
|
-
fieldName: fieldName2,
|
|
50
|
-
rowId: rowId2,
|
|
51
|
-
}
|
|
15
|
+
type LinkControllerOpts = {
|
|
16
|
+
tableId?: string
|
|
17
|
+
row?: Row
|
|
18
|
+
table?: Table
|
|
19
|
+
oldTable?: Table
|
|
52
20
|
}
|
|
53
21
|
|
|
54
22
|
class LinkController {
|
|
55
|
-
|
|
56
|
-
|
|
23
|
+
_db: Database
|
|
24
|
+
_tableId?: string
|
|
25
|
+
_row?: Row
|
|
26
|
+
_table?: Table
|
|
27
|
+
_oldTable?: Table
|
|
28
|
+
|
|
29
|
+
constructor({ tableId, row, table, oldTable }: LinkControllerOpts) {
|
|
30
|
+
this._db = context.getAppDB()
|
|
57
31
|
this._tableId = tableId
|
|
58
32
|
this._row = row
|
|
59
33
|
this._table = table
|
|
@@ -70,7 +44,7 @@ class LinkController {
|
|
|
70
44
|
this._table =
|
|
71
45
|
this._table == null ? await this._db.get(this._tableId) : this._table
|
|
72
46
|
}
|
|
73
|
-
return this._table
|
|
47
|
+
return this._table!
|
|
74
48
|
}
|
|
75
49
|
|
|
76
50
|
/**
|
|
@@ -80,7 +54,7 @@ class LinkController {
|
|
|
80
54
|
* @returns {Promise<boolean>} True if there are any linked fields, otherwise it will return
|
|
81
55
|
* false.
|
|
82
56
|
*/
|
|
83
|
-
async doesTableHaveLinkedFields(table
|
|
57
|
+
async doesTableHaveLinkedFields(table?: Table) {
|
|
84
58
|
if (table == null) {
|
|
85
59
|
table = await this.table()
|
|
86
60
|
}
|
|
@@ -96,7 +70,7 @@ class LinkController {
|
|
|
96
70
|
/**
|
|
97
71
|
* Utility function for main getLinkDocuments function - refer to it for functionality.
|
|
98
72
|
*/
|
|
99
|
-
getRowLinkDocs(rowId) {
|
|
73
|
+
getRowLinkDocs(rowId: string) {
|
|
100
74
|
return getLinkDocuments({
|
|
101
75
|
tableId: this._tableId,
|
|
102
76
|
rowId,
|
|
@@ -107,23 +81,23 @@ class LinkController {
|
|
|
107
81
|
/**
|
|
108
82
|
* Utility function for main getLinkDocuments function - refer to it for functionality.
|
|
109
83
|
*/
|
|
110
|
-
getTableLinkDocs() {
|
|
111
|
-
return getLinkDocuments({
|
|
84
|
+
async getTableLinkDocs() {
|
|
85
|
+
return (await getLinkDocuments({
|
|
112
86
|
tableId: this._tableId,
|
|
113
87
|
includeDocs: IncludeDocs.INCLUDE,
|
|
114
|
-
})
|
|
88
|
+
})) as LinkDocument[]
|
|
115
89
|
}
|
|
116
90
|
|
|
117
91
|
/**
|
|
118
92
|
* Makes sure the passed in table schema contains valid relationship structures.
|
|
119
93
|
*/
|
|
120
|
-
validateTable(table) {
|
|
94
|
+
validateTable(table: Table) {
|
|
121
95
|
const usedAlready = []
|
|
122
96
|
for (let schema of Object.values(table.schema)) {
|
|
123
97
|
if (schema.type !== FieldTypes.LINK) {
|
|
124
98
|
continue
|
|
125
99
|
}
|
|
126
|
-
const unique = schema.tableId + schema
|
|
100
|
+
const unique = schema.tableId! + schema?.fieldName
|
|
127
101
|
if (usedAlready.indexOf(unique) !== -1) {
|
|
128
102
|
throw new Error(
|
|
129
103
|
"Cannot re-use the linked column name for a linked table."
|
|
@@ -136,7 +110,7 @@ class LinkController {
|
|
|
136
110
|
/**
|
|
137
111
|
* Returns whether the two link schemas are equal (in the important parts, not a pure equality check)
|
|
138
112
|
*/
|
|
139
|
-
areLinkSchemasEqual(linkSchema1, linkSchema2) {
|
|
113
|
+
areLinkSchemasEqual(linkSchema1: FieldSchema, linkSchema2: FieldSchema) {
|
|
140
114
|
const compareFields = [
|
|
141
115
|
"name",
|
|
142
116
|
"type",
|
|
@@ -146,6 +120,7 @@ class LinkController {
|
|
|
146
120
|
"relationshipType",
|
|
147
121
|
]
|
|
148
122
|
for (let field of compareFields) {
|
|
123
|
+
// @ts-ignore
|
|
149
124
|
if (linkSchema1[field] !== linkSchema2[field]) {
|
|
150
125
|
return false
|
|
151
126
|
}
|
|
@@ -157,7 +132,7 @@ class LinkController {
|
|
|
157
132
|
* Given the link field of this table, and the link field of the linked table, this makes sure
|
|
158
133
|
* the state of relationship type is accurate on both.
|
|
159
134
|
*/
|
|
160
|
-
handleRelationshipType(linkerField, linkedField) {
|
|
135
|
+
handleRelationshipType(linkerField: FieldSchema, linkedField: FieldSchema) {
|
|
161
136
|
if (
|
|
162
137
|
!linkerField.relationshipType ||
|
|
163
138
|
linkerField.relationshipType === RelationshipTypes.MANY_TO_MANY
|
|
@@ -184,10 +159,10 @@ class LinkController {
|
|
|
184
159
|
*/
|
|
185
160
|
async rowSaved() {
|
|
186
161
|
const table = await this.table()
|
|
187
|
-
const row = this._row
|
|
162
|
+
const row = this._row!
|
|
188
163
|
const operations = []
|
|
189
164
|
// get link docs to compare against
|
|
190
|
-
const linkDocs = await this.getRowLinkDocs(row._id)
|
|
165
|
+
const linkDocs = (await this.getRowLinkDocs(row._id!)) as LinkDocument[]
|
|
191
166
|
for (let fieldName of Object.keys(table.schema)) {
|
|
192
167
|
// get the links this row wants to make
|
|
193
168
|
const rowField = row[fieldName]
|
|
@@ -207,30 +182,32 @@ class LinkController {
|
|
|
207
182
|
|
|
208
183
|
// if 1:N, ensure that this ID is not already attached to another record
|
|
209
184
|
const linkedTable = await this._db.get(field.tableId)
|
|
210
|
-
const linkedSchema = linkedTable.schema[field.fieldName]
|
|
185
|
+
const linkedSchema = linkedTable.schema[field.fieldName!]
|
|
211
186
|
|
|
212
187
|
// We need to map the global users to metadata in each app for relationships
|
|
213
188
|
if (field.tableId === InternalTables.USER_METADATA) {
|
|
214
189
|
const users = await this._db.allDocs(getUserMetadataParams(null, {}))
|
|
215
190
|
const metadataRequired = rowField.filter(
|
|
216
|
-
userId => !users.rows.some(user => user.id === userId)
|
|
191
|
+
(userId: string) => !users.rows.some(user => user.id === userId)
|
|
217
192
|
)
|
|
218
193
|
|
|
219
194
|
// ensure non-existing user metadata is created in the app DB
|
|
220
195
|
await this._db.bulkDocs(
|
|
221
|
-
metadataRequired.map(userId => ({ _id: userId }))
|
|
196
|
+
metadataRequired.map((userId: string) => ({ _id: userId }))
|
|
222
197
|
)
|
|
223
198
|
}
|
|
224
199
|
|
|
225
200
|
// iterate through the link IDs in the row field, see if any don't exist already
|
|
226
201
|
for (let linkId of rowField) {
|
|
227
|
-
if (
|
|
202
|
+
if (
|
|
203
|
+
linkedSchema?.relationshipType === RelationshipTypes.ONE_TO_MANY
|
|
204
|
+
) {
|
|
228
205
|
let links = (
|
|
229
|
-
await getLinkDocuments({
|
|
206
|
+
(await getLinkDocuments({
|
|
230
207
|
tableId: field.tableId,
|
|
231
208
|
rowId: linkId,
|
|
232
209
|
includeDocs: IncludeDocs.EXCLUDE,
|
|
233
|
-
})
|
|
210
|
+
})) as LinkDocumentValue[]
|
|
234
211
|
).filter(
|
|
235
212
|
link =>
|
|
236
213
|
link.id !== row._id && link.fieldName === linkedSchema.name
|
|
@@ -255,11 +232,11 @@ class LinkController {
|
|
|
255
232
|
}
|
|
256
233
|
operations.push(
|
|
257
234
|
new LinkDocument(
|
|
258
|
-
table._id
|
|
235
|
+
table._id!,
|
|
259
236
|
fieldName,
|
|
260
|
-
row._id
|
|
261
|
-
field.tableId
|
|
262
|
-
field.fieldName
|
|
237
|
+
row._id!,
|
|
238
|
+
field.tableId!,
|
|
239
|
+
field.fieldName!,
|
|
263
240
|
linkId
|
|
264
241
|
)
|
|
265
242
|
)
|
|
@@ -292,9 +269,9 @@ class LinkController {
|
|
|
292
269
|
* be accurate. This also returns the row that was deleted.
|
|
293
270
|
*/
|
|
294
271
|
async rowDeleted() {
|
|
295
|
-
const row = this._row
|
|
272
|
+
const row = this._row!
|
|
296
273
|
// need to get the full link docs to be be able to delete it
|
|
297
|
-
const linkDocs = await this.getRowLinkDocs(row._id)
|
|
274
|
+
const linkDocs = await this.getRowLinkDocs(row._id!)
|
|
298
275
|
if (linkDocs.length === 0) {
|
|
299
276
|
return null
|
|
300
277
|
}
|
|
@@ -313,13 +290,13 @@ class LinkController {
|
|
|
313
290
|
* @param {string} fieldName The field to be removed from the table.
|
|
314
291
|
* @returns {Promise<void>} The table has now been updated.
|
|
315
292
|
*/
|
|
316
|
-
async removeFieldFromTable(fieldName) {
|
|
293
|
+
async removeFieldFromTable(fieldName: string) {
|
|
317
294
|
let oldTable = this._oldTable
|
|
318
|
-
let field = oldTable
|
|
295
|
+
let field = oldTable?.schema[fieldName] as FieldSchema
|
|
319
296
|
const linkDocs = await this.getTableLinkDocs()
|
|
320
297
|
let toDelete = linkDocs.filter(linkDoc => {
|
|
321
298
|
let correctFieldName =
|
|
322
|
-
linkDoc.doc1.tableId === oldTable
|
|
299
|
+
linkDoc.doc1.tableId === oldTable?._id
|
|
323
300
|
? linkDoc.doc1.fieldName
|
|
324
301
|
: linkDoc.doc2.fieldName
|
|
325
302
|
return correctFieldName === fieldName
|
|
@@ -334,7 +311,9 @@ class LinkController {
|
|
|
334
311
|
)
|
|
335
312
|
// remove schema from other table
|
|
336
313
|
let linkedTable = await this._db.get(field.tableId)
|
|
337
|
-
|
|
314
|
+
if (field.fieldName) {
|
|
315
|
+
delete linkedTable.schema[field.fieldName]
|
|
316
|
+
}
|
|
338
317
|
await this._db.put(linkedTable)
|
|
339
318
|
}
|
|
340
319
|
|
|
@@ -351,7 +330,7 @@ class LinkController {
|
|
|
351
330
|
const schema = table.schema
|
|
352
331
|
for (let fieldName of Object.keys(schema)) {
|
|
353
332
|
const field = schema[fieldName]
|
|
354
|
-
if (field.type === FieldTypes.LINK) {
|
|
333
|
+
if (field.type === FieldTypes.LINK && field.fieldName) {
|
|
355
334
|
// handle this in a separate try catch, want
|
|
356
335
|
// the put to bubble up as an error, if can't update
|
|
357
336
|
// table for some reason
|
|
@@ -408,8 +387,8 @@ class LinkController {
|
|
|
408
387
|
const oldTable = this._oldTable
|
|
409
388
|
// first start by checking if any link columns have been deleted
|
|
410
389
|
const newTable = await this.table()
|
|
411
|
-
for (let fieldName of Object.keys(oldTable
|
|
412
|
-
const field = oldTable
|
|
390
|
+
for (let fieldName of Object.keys(oldTable?.schema || {})) {
|
|
391
|
+
const field = oldTable?.schema[fieldName] as FieldSchema
|
|
413
392
|
// this field has been removed from the table schema
|
|
414
393
|
if (
|
|
415
394
|
field.type === FieldTypes.LINK &&
|
|
@@ -435,7 +414,7 @@ class LinkController {
|
|
|
435
414
|
for (let fieldName of Object.keys(schema)) {
|
|
436
415
|
const field = schema[fieldName]
|
|
437
416
|
try {
|
|
438
|
-
if (field.type === FieldTypes.LINK) {
|
|
417
|
+
if (field.type === FieldTypes.LINK && field.fieldName) {
|
|
439
418
|
const linkedTable = await this._db.get(field.tableId)
|
|
440
419
|
delete linkedTable.schema[field.fieldName]
|
|
441
420
|
await this._db.put(linkedTable)
|
|
@@ -462,4 +441,4 @@ class LinkController {
|
|
|
462
441
|
}
|
|
463
442
|
}
|
|
464
443
|
|
|
465
|
-
|
|
444
|
+
export = LinkController
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { generateLinkID } from "../utils"
|
|
2
|
+
import { FieldTypes } from "../../constants"
|
|
3
|
+
import { LinkDocument } from "@budibase/types"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new link document structure which can be put to the database. It is important to
|
|
7
|
+
* note that while this talks about linker/linked the link is bi-directional and for all intent
|
|
8
|
+
* and purposes it does not matter from which direction the link was initiated.
|
|
9
|
+
* @param {string} tableId1 The ID of the first table (the linker).
|
|
10
|
+
* @param {string} tableId2 The ID of the second table (the linked).
|
|
11
|
+
* @param {string} fieldName1 The name of the field in the linker table.
|
|
12
|
+
* @param {string} fieldName2 The name of the field in the linked table.
|
|
13
|
+
* @param {string} rowId1 The ID of the row which is acting as the linker.
|
|
14
|
+
* @param {string} rowId2 The ID of the row which is acting as the linked.
|
|
15
|
+
* @constructor
|
|
16
|
+
*/
|
|
17
|
+
class LinkDocumentImpl implements LinkDocument {
|
|
18
|
+
_id: string
|
|
19
|
+
type: string
|
|
20
|
+
doc1: {
|
|
21
|
+
rowId: string
|
|
22
|
+
fieldName: string
|
|
23
|
+
tableId: string
|
|
24
|
+
}
|
|
25
|
+
doc2: {
|
|
26
|
+
rowId: string
|
|
27
|
+
fieldName: string
|
|
28
|
+
tableId: string
|
|
29
|
+
}
|
|
30
|
+
constructor(
|
|
31
|
+
tableId1: string,
|
|
32
|
+
fieldName1: string,
|
|
33
|
+
rowId1: string,
|
|
34
|
+
tableId2: string,
|
|
35
|
+
fieldName2: string,
|
|
36
|
+
rowId2: string
|
|
37
|
+
) {
|
|
38
|
+
this._id = generateLinkID(
|
|
39
|
+
tableId1,
|
|
40
|
+
tableId2,
|
|
41
|
+
rowId1,
|
|
42
|
+
rowId2,
|
|
43
|
+
fieldName1,
|
|
44
|
+
fieldName2
|
|
45
|
+
)
|
|
46
|
+
this.type = FieldTypes.LINK
|
|
47
|
+
this.doc1 = {
|
|
48
|
+
tableId: tableId1,
|
|
49
|
+
fieldName: fieldName1,
|
|
50
|
+
rowId: rowId1,
|
|
51
|
+
}
|
|
52
|
+
this.doc2 = {
|
|
53
|
+
tableId: tableId2,
|
|
54
|
+
fieldName: fieldName2,
|
|
55
|
+
rowId: rowId2,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export = LinkDocumentImpl
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import LinkController from "./LinkController"
|
|
2
|
+
import {
|
|
3
3
|
IncludeDocs,
|
|
4
4
|
getLinkDocuments,
|
|
5
5
|
createLinkView,
|
|
@@ -7,21 +7,24 @@ const {
|
|
|
7
7
|
getRelatedTableForField,
|
|
8
8
|
getLinkedTableIDs,
|
|
9
9
|
getLinkedTable,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
} from "./linkUtils"
|
|
11
|
+
import { flatten } from "lodash"
|
|
12
|
+
import { FieldTypes } from "../../constants"
|
|
13
|
+
import { getMultiIDParams, USER_METDATA_PREFIX } from "../utils"
|
|
14
|
+
import { partition } from "lodash"
|
|
15
|
+
import { getGlobalUsersFromMetadata } from "../../utilities/global"
|
|
16
|
+
import { processFormulas } from "../../utilities/rowProcessor"
|
|
17
|
+
import { context } from "@budibase/backend-core"
|
|
18
|
+
import { Table, Row, LinkDocumentValue } from "@budibase/types"
|
|
19
|
+
|
|
20
|
+
export { IncludeDocs, getLinkDocuments, createLinkView } from "./linkUtils"
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
23
|
* This functionality makes sure that when rows with links are created, updated or deleted they are processed
|
|
21
24
|
* correctly - making sure that no stale links are left around and that all links have been made successfully.
|
|
22
25
|
*/
|
|
23
26
|
|
|
24
|
-
const EventType = {
|
|
27
|
+
export const EventType = {
|
|
25
28
|
ROW_SAVE: "row:save",
|
|
26
29
|
ROW_UPDATE: "row:update",
|
|
27
30
|
ROW_DELETE: "row:delete",
|
|
@@ -30,13 +33,7 @@ const EventType = {
|
|
|
30
33
|
TABLE_DELETE: "table:delete",
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
// re-export search here for ease of use
|
|
35
|
-
exports.IncludeDocs = IncludeDocs
|
|
36
|
-
exports.getLinkDocuments = getLinkDocuments
|
|
37
|
-
exports.createLinkView = createLinkView
|
|
38
|
-
|
|
39
|
-
function clearRelationshipFields(table, rows) {
|
|
36
|
+
function clearRelationshipFields(table: Table, rows: Row[]) {
|
|
40
37
|
for (let [key, field] of Object.entries(table.schema)) {
|
|
41
38
|
if (field.type === FieldTypes.LINK) {
|
|
42
39
|
rows = rows.map(row => {
|
|
@@ -48,18 +45,17 @@ function clearRelationshipFields(table, rows) {
|
|
|
48
45
|
return rows
|
|
49
46
|
}
|
|
50
47
|
|
|
51
|
-
async function getLinksForRows(rows) {
|
|
48
|
+
async function getLinksForRows(rows: Row[]) {
|
|
52
49
|
const tableIds = [...new Set(rows.map(el => el.tableId))]
|
|
53
50
|
// start by getting all the link values for performance reasons
|
|
51
|
+
const promises = tableIds.map(tableId =>
|
|
52
|
+
getLinkDocuments({
|
|
53
|
+
tableId: tableId,
|
|
54
|
+
includeDocs: IncludeDocs.EXCLUDE,
|
|
55
|
+
})
|
|
56
|
+
)
|
|
54
57
|
const responses = flatten(
|
|
55
|
-
await Promise.all(
|
|
56
|
-
tableIds.map(tableId =>
|
|
57
|
-
getLinkDocuments({
|
|
58
|
-
tableId: tableId,
|
|
59
|
-
includeDocs: IncludeDocs.EXCLUDE,
|
|
60
|
-
})
|
|
61
|
-
)
|
|
62
|
-
)
|
|
58
|
+
(await Promise.all(promises)) as LinkDocumentValue[][]
|
|
63
59
|
)
|
|
64
60
|
// have to get unique as the previous table query can
|
|
65
61
|
// return duplicates, could be querying for both tables in a relation
|
|
@@ -72,9 +68,9 @@ async function getLinksForRows(rows) {
|
|
|
72
68
|
)
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
async function getFullLinkedDocs(links) {
|
|
71
|
+
async function getFullLinkedDocs(links: LinkDocumentValue[]) {
|
|
76
72
|
// create DBs
|
|
77
|
-
const db = getAppDB()
|
|
73
|
+
const db = context.getAppDB()
|
|
78
74
|
const linkedRowIds = links.map(link => link.id)
|
|
79
75
|
const uniqueRowIds = [...new Set(linkedRowIds)]
|
|
80
76
|
let dbRows = (await db.allDocs(getMultiIDParams(uniqueRowIds))).rows.map(
|
|
@@ -103,12 +99,18 @@ async function getFullLinkedDocs(links) {
|
|
|
103
99
|
* @returns {Promise<object>} When the update is complete this will respond successfully. Returns the row for
|
|
104
100
|
* row operations and the table for table operations.
|
|
105
101
|
*/
|
|
106
|
-
|
|
102
|
+
export async function updateLinks(args: {
|
|
103
|
+
tableId?: string
|
|
104
|
+
eventType: string
|
|
105
|
+
row?: Row
|
|
106
|
+
table?: Table
|
|
107
|
+
oldTable?: Table
|
|
108
|
+
}) {
|
|
107
109
|
const { eventType, row, tableId, table, oldTable } = args
|
|
108
110
|
const baseReturnObj = row == null ? table : row
|
|
109
111
|
// make sure table ID is set
|
|
110
112
|
if (tableId == null && table != null) {
|
|
111
|
-
args.tableId = table._id
|
|
113
|
+
args.tableId = table._id!
|
|
112
114
|
}
|
|
113
115
|
let linkController = new LinkController(args)
|
|
114
116
|
try {
|
|
@@ -146,7 +148,7 @@ exports.updateLinks = async function (args) {
|
|
|
146
148
|
* @param {array<object>} rows The rows which are to be enriched.
|
|
147
149
|
* @return {Promise<*>} returns the rows with all of the enriched relationships on it.
|
|
148
150
|
*/
|
|
149
|
-
|
|
151
|
+
export async function attachFullLinkedDocs(table: Table, rows: Row[]) {
|
|
150
152
|
const linkedTableIds = getLinkedTableIDs(table)
|
|
151
153
|
if (linkedTableIds.length === 0) {
|
|
152
154
|
return rows
|
|
@@ -159,7 +161,7 @@ exports.attachFullLinkedDocs = async (table, rows) => {
|
|
|
159
161
|
rows = clearRelationshipFields(table, rows)
|
|
160
162
|
// now get the docs and combine into the rows
|
|
161
163
|
let linked = await getFullLinkedDocs(links)
|
|
162
|
-
const linkedTables = []
|
|
164
|
+
const linkedTables: Table[] = []
|
|
163
165
|
for (let row of rows) {
|
|
164
166
|
for (let link of links.filter(link => link.thisId === row._id)) {
|
|
165
167
|
if (row[link.fieldName] == null) {
|
|
@@ -185,13 +187,16 @@ exports.attachFullLinkedDocs = async (table, rows) => {
|
|
|
185
187
|
* @param {array<object>} enriched The pre-enriched rows (full docs) which are to be squashed.
|
|
186
188
|
* @returns {Promise<Array>} The rows after having their links squashed to only contain the ID and primary display.
|
|
187
189
|
*/
|
|
188
|
-
|
|
190
|
+
export async function squashLinksToPrimaryDisplay(
|
|
191
|
+
table: Table,
|
|
192
|
+
enriched: Row[]
|
|
193
|
+
) {
|
|
189
194
|
// will populate this as we find them
|
|
190
195
|
const linkedTables = [table]
|
|
191
196
|
for (let row of enriched) {
|
|
192
197
|
// this only fetches the table if its not already in array
|
|
193
|
-
const rowTable = await getLinkedTable(row.tableId
|
|
194
|
-
for (let [column, schema] of Object.entries(rowTable
|
|
198
|
+
const rowTable = await getLinkedTable(row.tableId!, linkedTables)
|
|
199
|
+
for (let [column, schema] of Object.entries(rowTable?.schema || {})) {
|
|
195
200
|
if (schema.type !== FieldTypes.LINK || !Array.isArray(row[column])) {
|
|
196
201
|
continue
|
|
197
202
|
}
|
|
@@ -199,8 +204,8 @@ exports.squashLinksToPrimaryDisplay = async (table, enriched) => {
|
|
|
199
204
|
for (let link of row[column]) {
|
|
200
205
|
const linkTblId = link.tableId || getRelatedTableForField(table, column)
|
|
201
206
|
const linkedTable = await getLinkedTable(linkTblId, linkedTables)
|
|
202
|
-
const obj = { _id: link._id }
|
|
203
|
-
if (link[linkedTable.primaryDisplay]) {
|
|
207
|
+
const obj: any = { _id: link._id }
|
|
208
|
+
if (linkedTable?.primaryDisplay && link[linkedTable.primaryDisplay]) {
|
|
204
209
|
obj.primaryDisplay = link[linkedTable.primaryDisplay]
|
|
205
210
|
}
|
|
206
211
|
newLinks.push(obj)
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ViewName, getQueryIndex } from "../utils"
|
|
2
|
+
import { FieldTypes } from "../../constants"
|
|
3
|
+
import { createLinkView } from "../views/staticViews"
|
|
4
|
+
import { context, logging } from "@budibase/backend-core"
|
|
5
|
+
import {
|
|
6
|
+
FieldSchema,
|
|
7
|
+
LinkDocument,
|
|
8
|
+
LinkDocumentValue,
|
|
9
|
+
Table,
|
|
10
|
+
} from "@budibase/types"
|
|
11
|
+
export { createLinkView } from "../views/staticViews"
|
|
6
12
|
|
|
7
13
|
/**
|
|
8
14
|
* Only needed so that boolean parameters are being used for includeDocs
|
|
9
15
|
* @type {{EXCLUDE: boolean, INCLUDE: boolean}}
|
|
10
16
|
*/
|
|
11
|
-
|
|
17
|
+
export const IncludeDocs = {
|
|
12
18
|
INCLUDE: true,
|
|
13
19
|
EXCLUDE: false,
|
|
14
20
|
}
|
|
15
21
|
|
|
16
|
-
exports.createLinkView = createLinkView
|
|
17
|
-
|
|
18
22
|
/**
|
|
19
23
|
* Gets the linking documents, not the linked documents themselves.
|
|
20
24
|
* @param {string} args.tableId The table which we are searching for linked rows against.
|
|
@@ -28,10 +32,14 @@ exports.createLinkView = createLinkView
|
|
|
28
32
|
* @returns {Promise<object[]>} This will return an array of the linking documents that were found
|
|
29
33
|
* (if any).
|
|
30
34
|
*/
|
|
31
|
-
|
|
35
|
+
export async function getLinkDocuments(args: {
|
|
36
|
+
tableId?: string
|
|
37
|
+
rowId?: string
|
|
38
|
+
includeDocs?: any
|
|
39
|
+
}): Promise<LinkDocumentValue[] | LinkDocument[]> {
|
|
32
40
|
const { tableId, rowId, includeDocs } = args
|
|
33
|
-
const db = getAppDB()
|
|
34
|
-
let params
|
|
41
|
+
const db = context.getAppDB()
|
|
42
|
+
let params: any
|
|
35
43
|
if (rowId != null) {
|
|
36
44
|
params = { key: [tableId, rowId] }
|
|
37
45
|
}
|
|
@@ -43,7 +51,7 @@ exports.getLinkDocuments = async function (args) {
|
|
|
43
51
|
try {
|
|
44
52
|
let linkRows = (await db.query(getQueryIndex(ViewName.LINK), params)).rows
|
|
45
53
|
// filter to get unique entries
|
|
46
|
-
const foundIds = []
|
|
54
|
+
const foundIds: string[] = []
|
|
47
55
|
linkRows = linkRows.filter(link => {
|
|
48
56
|
// make sure anything unique is the correct key
|
|
49
57
|
if (
|
|
@@ -60,36 +68,37 @@ exports.getLinkDocuments = async function (args) {
|
|
|
60
68
|
})
|
|
61
69
|
|
|
62
70
|
if (includeDocs) {
|
|
63
|
-
return linkRows.map(row => row.doc)
|
|
71
|
+
return linkRows.map(row => row.doc) as LinkDocument[]
|
|
64
72
|
} else {
|
|
65
|
-
return linkRows.map(row => row.value)
|
|
73
|
+
return linkRows.map(row => row.value) as LinkDocumentValue[]
|
|
66
74
|
}
|
|
67
|
-
} catch (err) {
|
|
75
|
+
} catch (err: any) {
|
|
68
76
|
// check if the view doesn't exist, it should for all new instances
|
|
69
77
|
if (err != null && err.name === "not_found") {
|
|
70
|
-
await
|
|
71
|
-
return
|
|
78
|
+
await createLinkView()
|
|
79
|
+
return getLinkDocuments(arguments[0])
|
|
72
80
|
} else {
|
|
73
81
|
/* istanbul ignore next */
|
|
74
|
-
|
|
82
|
+
logging.logAlert("Failed to get link documents", err)
|
|
83
|
+
throw err
|
|
75
84
|
}
|
|
76
85
|
}
|
|
77
86
|
}
|
|
78
87
|
|
|
79
|
-
|
|
88
|
+
export function getUniqueByProp(array: any[], prop: string) {
|
|
80
89
|
return array.filter((obj, pos, arr) => {
|
|
81
90
|
return arr.map(mapObj => mapObj[prop]).indexOf(obj[prop]) === pos
|
|
82
91
|
})
|
|
83
92
|
}
|
|
84
93
|
|
|
85
|
-
|
|
94
|
+
export function getLinkedTableIDs(table: Table) {
|
|
86
95
|
return Object.values(table.schema)
|
|
87
|
-
.filter(column => column.type === FieldTypes.LINK)
|
|
96
|
+
.filter((column: FieldSchema) => column.type === FieldTypes.LINK)
|
|
88
97
|
.map(column => column.tableId)
|
|
89
98
|
}
|
|
90
99
|
|
|
91
|
-
|
|
92
|
-
const db = getAppDB()
|
|
100
|
+
export async function getLinkedTable(id: string, tables: Table[]) {
|
|
101
|
+
const db = context.getAppDB()
|
|
93
102
|
let linkedTable = tables.find(table => table._id === id)
|
|
94
103
|
if (linkedTable) {
|
|
95
104
|
return linkedTable
|
|
@@ -101,7 +110,7 @@ exports.getLinkedTable = async (id, tables) => {
|
|
|
101
110
|
return linkedTable
|
|
102
111
|
}
|
|
103
112
|
|
|
104
|
-
|
|
113
|
+
export function getRelatedTableForField(table: Table, fieldName: string) {
|
|
105
114
|
// look to see if its on the table, straight in the schema
|
|
106
115
|
const field = table.schema[fieldName]
|
|
107
116
|
if (field != null) {
|