@budibase/server 2.1.32-alpha.4 → 2.1.32-alpha.6
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/builder/assets/{index.dfb2f13a.js → index.3ca79a83.js} +1 -1
- package/builder/index.html +1 -1
- package/coverage/clover.xml +3112 -3177
- package/coverage/coverage-final.json +105 -106
- package/coverage/lcov-report/index.html +145 -145
- package/coverage/lcov-report/src/api/controllers/analytics.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/{apikeys.js.html → apikeys.ts.html} +19 -19
- package/coverage/lcov-report/src/api/controllers/application.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/auth.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/{automation.js.html → automation.ts.html} +68 -68
- package/coverage/lcov-report/src/api/controllers/backup.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/{cloud.js.html → cloud.ts.html} +40 -40
- package/coverage/lcov-report/src/api/controllers/component.ts.html +6 -3
- package/coverage/lcov-report/src/api/controllers/{datasource.js.html → datasource.ts.html} +100 -79
- package/coverage/lcov-report/src/api/controllers/deploy/{Deployment.js.html → Deployment.ts.html} +30 -21
- package/coverage/lcov-report/src/api/controllers/deploy/index.html +6 -6
- package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/dev.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/index.html +108 -108
- package/coverage/lcov-report/src/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/{layout.js.html → layout.ts.html} +19 -19
- package/coverage/lcov-report/src/api/controllers/{metadata.js.html → metadata.ts.html} +19 -16
- package/coverage/lcov-report/src/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/{permission.js.html → permission.ts.html} +73 -64
- package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/plugin/index.html +11 -11
- package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +10 -13
- package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/tables.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/public/users.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/index.html +11 -11
- package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +8 -11
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/openapi.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/curl.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/index.html +2 -2
- package/coverage/lcov-report/src/api/controllers/query/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/{validation.js.html → validation.ts.html} +10 -10
- package/coverage/lcov-report/src/api/controllers/{role.js.html → role.ts.html} +37 -49
- package/coverage/lcov-report/src/api/controllers/{routing.js.html → routing.ts.html} +58 -49
- package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +6 -18
- package/coverage/lcov-report/src/api/controllers/row/external.js.html +4 -4
- package/coverage/lcov-report/src/api/controllers/row/index.html +35 -35
- package/coverage/lcov-report/src/api/controllers/row/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/internal.js.html +17 -20
- package/coverage/lcov-report/src/api/controllers/row/{internalSearch.js.html → internalSearch.ts.html} +175 -103
- package/coverage/lcov-report/src/api/controllers/row/{staticFormula.js.html → staticFormula.ts.html} +62 -47
- package/coverage/lcov-report/src/api/controllers/row/{utils.js.html → utils.ts.html} +57 -36
- package/coverage/lcov-report/src/api/controllers/screen.ts.html +29 -17
- package/coverage/lcov-report/src/api/controllers/{script.js.html → script.ts.html} +10 -7
- package/coverage/lcov-report/src/api/controllers/static/index.html +10 -10
- package/coverage/lcov-report/src/api/controllers/static/index.ts.html +15 -27
- package/coverage/lcov-report/src/api/controllers/table/{bulkFormula.js.html → bulkFormula.ts.html} +89 -47
- package/coverage/lcov-report/src/api/controllers/table/{external.js.html → external.ts.html} +192 -87
- package/coverage/lcov-report/src/api/controllers/table/index.html +39 -39
- package/coverage/lcov-report/src/api/controllers/table/{index.js.html → index.ts.html} +28 -28
- package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +3 -6
- package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +18 -18
- package/coverage/lcov-report/src/api/controllers/{templates.js.html → templates.ts.html} +27 -18
- package/coverage/lcov-report/src/api/controllers/{user.js.html → user.ts.html} +72 -78
- package/coverage/lcov-report/src/api/controllers/view/{exporters.js.html → exporters.ts.html} +13 -7
- package/coverage/lcov-report/src/api/controllers/view/index.html +21 -21
- package/coverage/lcov-report/src/api/controllers/view/{index.js.html → index.ts.html} +68 -41
- package/coverage/lcov-report/src/api/controllers/view/{utils.js.html → utils.ts.html} +54 -36
- package/coverage/lcov-report/src/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/webhook.ts.html +1 -1
- package/coverage/lcov-report/src/api/index.html +14 -14
- package/coverage/lcov-report/src/api/{index.js.html → index.ts.html} +28 -49
- package/coverage/lcov-report/src/api/routes/{analytics.js.html → analytics.ts.html} +7 -7
- package/coverage/lcov-report/src/api/routes/{apikeys.js.html → apikeys.ts.html} +11 -11
- package/coverage/lcov-report/src/api/routes/application.ts.html +35 -11
- package/coverage/lcov-report/src/api/routes/auth.ts.html +3 -3
- package/coverage/lcov-report/src/api/routes/{automation.js.html → automation.ts.html} +41 -35
- package/coverage/lcov-report/src/api/routes/backup.ts.html +18 -6
- package/coverage/lcov-report/src/api/routes/{deploy.js.html → cloud.ts.html} +18 -15
- package/coverage/lcov-report/src/api/routes/{component.js.html → component.ts.html} +10 -10
- package/coverage/lcov-report/src/api/routes/{datasource.js.html → datasource.ts.html} +53 -26
- package/coverage/lcov-report/src/api/routes/deploy.ts.html +148 -0
- package/coverage/lcov-report/src/api/routes/{dev.js.html → dev.ts.html} +54 -18
- package/coverage/lcov-report/src/api/routes/index.html +41 -41
- package/coverage/lcov-report/src/api/routes/index.ts.html +3 -3
- package/coverage/lcov-report/src/api/routes/integration.ts.html +133 -0
- package/coverage/lcov-report/src/api/routes/{layout.js.html → layout.ts.html} +11 -11
- package/coverage/lcov-report/src/api/routes/{metadata.js.html → metadata.ts.html} +17 -17
- package/coverage/lcov-report/src/api/routes/{migrations.js.html → migrations.ts.html} +12 -12
- package/coverage/lcov-report/src/api/routes/{permission.js.html → permission.ts.html} +41 -17
- package/coverage/lcov-report/src/api/routes/plugin.ts.html +32 -8
- package/coverage/lcov-report/src/api/routes/public/applications.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/middleware/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/queries.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/rows.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/tables.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/users.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/utils/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/{query.js.html → query.ts.html} +24 -33
- package/coverage/lcov-report/src/{utilities/routing/index.js.html → api/routes/role.ts.html} +32 -35
- package/coverage/lcov-report/src/api/routes/{routing.js.html → routing.ts.html} +10 -10
- package/coverage/lcov-report/src/api/routes/row.ts.html +8 -14
- package/coverage/lcov-report/src/api/routes/{screen.js.html → screen.ts.html} +29 -14
- package/coverage/lcov-report/src/api/routes/{script.js.html → script.ts.html} +10 -10
- package/coverage/lcov-report/src/api/routes/static.ts.html +9 -18
- package/coverage/lcov-report/src/api/routes/{table.js.html → table.ts.html} +16 -25
- package/coverage/lcov-report/src/api/routes/{templates.js.html → templates.ts.html} +11 -11
- package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +12 -18
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +10 -10
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/{user.js.html → user.ts.html} +14 -20
- package/coverage/lcov-report/src/api/routes/utils/index.html +6 -6
- package/coverage/lcov-report/src/api/routes/utils/{validators.js.html → validators.ts.html} +39 -51
- package/coverage/lcov-report/src/api/routes/{view.js.html → view.ts.html} +33 -24
- package/coverage/lcov-report/src/api/routes/webhook.ts.html +3 -3
- package/coverage/lcov-report/src/app.ts.html +9 -12
- package/coverage/lcov-report/src/automations/actions.js.html +1 -1
- package/coverage/lcov-report/src/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/src/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/src/automations/index.html +10 -10
- package/coverage/lcov-report/src/automations/index.js.html +1 -1
- package/coverage/lcov-report/src/automations/logging/index.html +1 -1
- package/coverage/lcov-report/src/automations/logging/index.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/createRow.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/index.html +1 -1
- package/coverage/lcov-report/src/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/src/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/src/automations/tests/utilities/index.html +1 -1
- package/coverage/lcov-report/src/automations/tests/utilities/index.js.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/src/automations/triggers.js.html +11 -14
- package/coverage/lcov-report/src/automations/utils.ts.html +1 -1
- package/coverage/lcov-report/src/constants/index.html +5 -5
- package/coverage/lcov-report/src/constants/index.js.html +7 -13
- package/coverage/lcov-report/src/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/src/constants/screens.js.html +3 -3
- package/coverage/lcov-report/src/db/defaultData/datasource_bb_default.js.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/employeeImport.js.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/expensesImport.js.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/index.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/inventoryImport.js.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/jobsImport.js.html +1 -1
- package/coverage/lcov-report/src/db/dynamoClient.js.html +1 -1
- package/coverage/lcov-report/src/db/inMemoryView.js.html +4 -4
- package/coverage/lcov-report/src/db/index.html +1 -1
- package/coverage/lcov-report/src/db/index.js.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/LinkController.js.html +3 -3
- package/coverage/lcov-report/src/db/linkedRows/LinkDocument.js.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/index.js.html +3 -3
- package/coverage/lcov-report/src/db/linkedRows/linkUtils.js.html +4 -4
- package/coverage/lcov-report/src/db/newid.js.html +1 -1
- package/coverage/lcov-report/src/db/utils.ts.html +2 -2
- package/coverage/lcov-report/src/definitions/automations.ts.html +1 -1
- package/coverage/lcov-report/src/definitions/datasource.ts.html +1 -1
- package/coverage/lcov-report/src/definitions/index.html +1 -1
- package/coverage/lcov-report/src/environment.js.html +1 -1
- package/coverage/lcov-report/src/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/src/events/index.html +1 -1
- package/coverage/lcov-report/src/events/index.js.html +1 -1
- package/coverage/lcov-report/src/events/utils.js.html +1 -1
- package/coverage/lcov-report/src/index.html +17 -32
- package/coverage/lcov-report/src/index.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/airtable.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/arangodb.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/base/index.html +1 -1
- package/coverage/lcov-report/src/integrations/base/query.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/base/sql.ts.html +2 -2
- package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +2 -2
- package/coverage/lcov-report/src/integrations/base/utils.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/couchdb.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/dynamodb.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/firebase.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/googlesheets.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/index.html +4 -4
- package/coverage/lcov-report/src/integrations/index.ts.html +58 -46
- package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/mongodb.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/mysql.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/oracle.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/postgres.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/queries/index.html +1 -1
- package/coverage/lcov-report/src/integrations/queries/sql.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/redis.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/rest.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/s3.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/snowflake.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/src/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/src/integrations/utils.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/appInfo.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/authorized.ts.html +30 -51
- package/coverage/lcov-report/src/middleware/builder.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/currentapp.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/index.html +10 -10
- package/coverage/lcov-report/src/middleware/joi-validator.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/publicApi.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/resourceId.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/selfhost.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/utils.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/queries.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/roles.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/syncQuotas.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +9 -9
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +7 -10
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncRows.ts.html +7 -10
- package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +4 -4
- package/coverage/lcov-report/src/migrations/index.html +1 -1
- package/coverage/lcov-report/src/migrations/index.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/tests/index.html +1 -1
- package/coverage/lcov-report/src/migrations/tests/structures.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/automations/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +16 -10
- package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +9 -21
- package/coverage/lcov-report/src/sdk/app/backups/index.html +16 -16
- package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/tables/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/index.html +1 -1
- package/coverage/lcov-report/src/sdk/index.ts.html +1 -1
- package/coverage/lcov-report/src/startup.ts.html +3 -3
- package/coverage/lcov-report/src/tests/utilities/TestConfiguration.js.html +61 -49
- package/coverage/lcov-report/src/tests/utilities/controllers.js.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/index.html +15 -15
- package/coverage/lcov-report/src/tests/utilities/index.js.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/structures.js.html +9 -12
- package/coverage/lcov-report/src/threads/automation.ts.html +20 -23
- package/coverage/lcov-report/src/threads/index.html +24 -24
- package/coverage/lcov-report/src/threads/index.ts.html +1 -1
- package/coverage/lcov-report/src/threads/query.ts.html +18 -33
- package/coverage/lcov-report/src/threads/utils.ts.html +10 -13
- package/coverage/lcov-report/src/utilities/{budibaseDir.js.html → budibaseDir.ts.html} +5 -5
- package/coverage/lcov-report/src/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/src/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.js.html +13 -13
- package/coverage/lcov-report/src/utilities/fileSystem/index.html +5 -20
- package/coverage/lcov-report/src/utilities/fileSystem/index.js.html +15 -15
- package/coverage/lcov-report/src/utilities/fileSystem/processor.js.html +1 -1
- package/coverage/lcov-report/src/utilities/global.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/index.html +44 -44
- package/coverage/lcov-report/src/utilities/{index.js.html → index.ts.html} +68 -44
- package/coverage/lcov-report/src/utilities/plugins.js.html +1 -1
- package/coverage/lcov-report/src/utilities/queue/inMemoryQueue.js.html +1 -1
- package/coverage/lcov-report/src/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/src/utilities/{redis.js.html → redis.ts.html} +36 -33
- package/coverage/lcov-report/src/utilities/routing/index.html +6 -6
- package/coverage/lcov-report/src/utilities/routing/index.ts.html +181 -0
- package/coverage/lcov-report/src/utilities/rowProcessor/index.html +38 -23
- package/coverage/lcov-report/src/utilities/rowProcessor/{index.js.html → index.ts.html} +106 -337
- package/coverage/lcov-report/src/utilities/rowProcessor/map.js.html +370 -0
- package/coverage/lcov-report/src/utilities/rowProcessor/{utils.js.html → utils.ts.html} +43 -31
- package/coverage/lcov-report/src/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/src/utilities/{security.js.html → security.ts.html} +49 -67
- package/coverage/lcov-report/src/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/src/utilities/usageQuota/index.html +18 -18
- package/coverage/lcov-report/src/utilities/usageQuota/{rows.js.html → rows.ts.html} +27 -39
- package/coverage/lcov-report/src/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/src/utilities/{users.js.html → users.ts.html} +22 -28
- package/coverage/lcov-report/src/utilities/{workerRequests.js.html → workerRequests.ts.html} +69 -54
- package/coverage/lcov-report/src/watch.ts.html +8 -11
- package/coverage/lcov-report/src/websocket.ts.html +1 -1
- package/coverage/lcov.info +5516 -5765
- package/dist/api/controllers/apikeys.js +12 -9
- package/dist/api/controllers/automation.js +104 -84
- package/dist/api/controllers/cloud.js +84 -71
- package/dist/api/controllers/component.js +4 -2
- package/dist/api/controllers/datasource.js +125 -111
- package/dist/api/controllers/deploy/Deployment.js +10 -6
- package/dist/api/controllers/layout.js +18 -15
- package/dist/api/controllers/metadata.js +51 -37
- package/dist/api/controllers/permission.js +52 -43
- package/dist/api/controllers/plugin/index.js +6 -7
- package/dist/api/controllers/public/tables.js +29 -9
- package/dist/api/controllers/query/import/index.js +1 -2
- 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 +6 -7
- package/dist/api/controllers/row/external.js +3 -3
- package/dist/api/controllers/row/internal.js +11 -12
- package/dist/api/controllers/row/internalSearch.js +95 -80
- package/dist/api/controllers/row/staticFormula.js +85 -75
- package/dist/api/controllers/row/utils.js +118 -84
- package/dist/api/controllers/screen.js +81 -66
- package/dist/api/controllers/script.js +13 -6
- package/dist/api/controllers/static/index.js +9 -11
- package/dist/api/controllers/table/bulkFormula.js +47 -35
- package/dist/api/controllers/table/external.js +67 -54
- package/dist/api/controllers/table/index.js +66 -33
- package/dist/api/controllers/table/internal.js +1 -2
- package/dist/api/controllers/table/utils.js +8 -9
- package/dist/api/controllers/templates.js +17 -10
- package/dist/api/controllers/user.js +82 -70
- 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/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 +10 -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/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 +2 -1
- 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/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 +3 -4
- package/dist/automations/triggers.js +5 -6
- package/dist/constants/index.js +3 -5
- package/dist/constants/screens.js +2 -2
- package/dist/db/inMemoryView.js +3 -3
- package/dist/db/linkedRows/LinkController.js +2 -2
- package/dist/db/linkedRows/index.js +2 -2
- package/dist/db/linkedRows/linkUtils.js +3 -3
- package/dist/db/views/staticViews.js +4 -4
- package/dist/integrations/index.js +15 -6
- package/dist/middleware/authorized.js +22 -21
- package/dist/migrations/functions/appUrls.js +2 -2
- 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/package.json +6 -6
- package/dist/sdk/app/backups/exports.js +1 -2
- package/dist/sdk/app/backups/imports.js +2 -3
- package/dist/startup.js +4 -4
- package/dist/tests/utilities/TestConfiguration.js +27 -35
- package/dist/tests/utilities/structures.js +3 -4
- package/dist/threads/automation.js +15 -16
- package/dist/threads/query.js +17 -19
- package/dist/threads/utils.js +11 -9
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/budibaseDir.js +4 -2
- package/dist/utilities/fileSystem/clientLibrary.js +12 -12
- package/dist/utilities/fileSystem/index.js +3 -3
- package/dist/utilities/index.js +102 -75
- package/dist/utilities/redis.js +100 -65
- package/dist/utilities/routing/index.js +27 -23
- package/dist/utilities/rowProcessor/index.js +124 -191
- package/dist/utilities/rowProcessor/map.js +96 -0
- package/dist/utilities/rowProcessor/utils.js +35 -26
- 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/package.json +7 -7
- package/scripts/exportAppTemplate.js +2 -2
- package/src/api/controllers/{apikeys.js → apikeys.ts} +10 -10
- package/src/api/controllers/auth.ts +2 -2
- package/src/api/controllers/{automation.js → automation.ts} +48 -48
- package/src/api/controllers/{cloud.js → cloud.ts} +24 -24
- package/src/api/controllers/component.ts +2 -1
- package/src/api/controllers/{datasource.js → datasource.ts} +55 -48
- package/src/api/controllers/deploy/{Deployment.js → Deployment.ts} +13 -10
- package/src/api/controllers/{layout.js → layout.ts} +8 -8
- package/src/api/controllers/{metadata.js → metadata.ts} +11 -10
- package/src/api/controllers/{permission.js → permission.ts} +49 -46
- package/src/api/controllers/plugin/index.ts +4 -5
- package/src/api/controllers/public/tables.ts +2 -2
- package/src/api/controllers/query/import/index.ts +2 -3
- 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 +4 -8
- package/src/api/controllers/row/external.js +3 -3
- package/src/api/controllers/row/internal.js +11 -12
- package/src/api/controllers/row/{internalSearch.js → internalSearch.ts} +92 -68
- package/src/api/controllers/row/{staticFormula.js → staticFormula.ts} +28 -23
- package/src/api/controllers/row/{utils.js → utils.ts} +25 -18
- package/src/api/controllers/screen.ts +10 -6
- package/src/api/controllers/script.ts +12 -0
- package/src/api/controllers/static/index.ts +9 -13
- package/src/api/controllers/table/{bulkFormula.js → bulkFormula.ts} +39 -25
- package/src/api/controllers/table/{external.js → external.ts} +86 -51
- package/src/api/controllers/table/{index.js → index.ts} +17 -17
- package/src/api/controllers/table/internal.ts +1 -2
- package/src/api/controllers/table/utils.ts +10 -10
- package/src/api/controllers/{templates.js → templates.ts} +10 -7
- package/src/api/controllers/{user.js → user.ts} +47 -49
- 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/{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/{query.js → query.ts} +17 -20
- package/src/api/routes/role.ts +24 -0
- package/src/api/routes/routing.ts +14 -0
- package/src/api/routes/row.ts +3 -5
- package/src/api/routes/screen.ts +23 -0
- package/src/api/routes/script.ts +10 -0
- package/src/api/routes/static.ts +4 -7
- package/src/api/routes/{table.js → table.ts} +9 -12
- package/src/api/routes/templates.ts +16 -0
- package/src/api/routes/tests/backup.spec.js +9 -1
- package/src/api/routes/tests/permissions.spec.js +2 -1
- package/src/api/routes/tests/role.spec.js +3 -5
- 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/user.spec.js +2 -1
- package/src/api/routes/tests/utilities/TestFunctions.ts +6 -8
- package/src/api/routes/{user.js → user.ts} +7 -9
- 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 +3 -4
- package/src/automations/triggers.js +5 -6
- package/src/constants/index.js +3 -5
- package/src/constants/screens.js +2 -2
- package/src/db/inMemoryView.js +3 -3
- package/src/db/linkedRows/LinkController.js +2 -2
- package/src/db/linkedRows/index.js +2 -2
- package/src/db/linkedRows/linkUtils.js +3 -3
- package/src/db/utils.ts +1 -1
- package/src/db/views/staticViews.js +4 -4
- package/src/integrations/base/sql.ts +1 -1
- package/src/integrations/base/sqlTable.ts +1 -1
- package/src/integrations/index.ts +45 -41
- package/src/middleware/authorized.ts +21 -28
- package/src/middleware/tests/authorized.spec.js +5 -6
- package/src/migrations/functions/appUrls.ts +2 -2
- package/src/migrations/functions/tests/appUrls.spec.js +4 -4
- 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 +3 -4
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +7 -7
- package/src/migrations/functions/userEmailViewCasing.ts +3 -3
- package/src/sdk/app/backups/exports.ts +5 -3
- package/src/sdk/app/backups/imports.ts +3 -7
- package/src/startup.ts +2 -2
- package/src/tests/utilities/TestConfiguration.js +39 -35
- package/src/tests/utilities/structures.js +3 -4
- package/src/threads/automation.ts +14 -15
- package/src/threads/query.ts +11 -16
- package/src/threads/utils.ts +4 -5
- package/src/utilities/budibaseDir.ts +3 -0
- package/src/utilities/fileSystem/clientLibrary.js +12 -12
- package/src/utilities/fileSystem/index.js +8 -8
- package/src/utilities/{index.js → index.ts} +40 -32
- 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} +65 -142
- package/src/utilities/rowProcessor/map.js +95 -0
- package/src/utilities/rowProcessor/{utils.js → utils.ts} +19 -15
- package/src/utilities/security.ts +65 -0
- package/src/utilities/usageQuota/{rows.js → rows.ts} +14 -18
- 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/coverage/lcov-report/src/api/routes/cloud.js.html +0 -127
- package/coverage/lcov-report/src/api/routes/integration.js.html +0 -121
- package/coverage/lcov-report/src/api/routes/role.js.html +0 -130
- package/coverage/lcov-report/src/module.d.ts.html +0 -127
- package/coverage/lcov-report/src/utilities/fileSystem/utilities.js.html +0 -193
- package/dist/utilities/fileSystem/utilities.js +0 -22
- 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/view.js +0 -31
- package/src/module.d.ts +0 -14
- package/src/utilities/budibaseDir.js +0 -3
- package/src/utilities/fileSystem/utilities.js +0 -36
- package/src/utilities/routing/index.js +0 -25
- package/src/utilities/security.js +0 -71
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
roles,
|
|
8
8
|
} from "@budibase/backend-core"
|
|
9
9
|
import { updateAppPackage } from "./application"
|
|
10
|
-
import { Plugin, ScreenProps } from "@budibase/types"
|
|
10
|
+
import { Plugin, ScreenProps, BBContext } from "@budibase/types"
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
export async function fetch(ctx: BBContext) {
|
|
13
13
|
const db = context.getAppDB()
|
|
14
14
|
|
|
15
15
|
const screens = (
|
|
@@ -20,13 +20,17 @@ exports.fetch = async (ctx: any) => {
|
|
|
20
20
|
)
|
|
21
21
|
).rows.map((el: any) => el.doc)
|
|
22
22
|
|
|
23
|
+
const roleId = ctx.user?.role?._id as string
|
|
24
|
+
if (!roleId) {
|
|
25
|
+
ctx.throw("Unable to retrieve users role ID.")
|
|
26
|
+
}
|
|
23
27
|
ctx.body = await new roles.AccessController().checkScreensAccess(
|
|
24
28
|
screens,
|
|
25
|
-
|
|
29
|
+
roleId
|
|
26
30
|
)
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
export async function save(ctx: BBContext) {
|
|
30
34
|
const db = context.getAppDB()
|
|
31
35
|
let screen = ctx.request.body
|
|
32
36
|
|
|
@@ -92,7 +96,7 @@ exports.save = async (ctx: any) => {
|
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
|
|
99
|
+
export async function destroy(ctx: BBContext) {
|
|
96
100
|
const db = context.getAppDB()
|
|
97
101
|
const id = ctx.params.screenId
|
|
98
102
|
const screen = await db.get(id)
|
|
@@ -106,7 +110,7 @@ exports.destroy = async (ctx: any) => {
|
|
|
106
110
|
ctx.status = 200
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
|
|
113
|
+
function findPlugins(component: ScreenProps, foundPlugins: string[]) {
|
|
110
114
|
if (!component) {
|
|
111
115
|
return
|
|
112
116
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ScriptRunner from "../../utilities/scriptRunner"
|
|
2
|
+
import { BBContext } from "@budibase/types"
|
|
3
|
+
|
|
4
|
+
export async function execute(ctx: BBContext) {
|
|
5
|
+
const { script, context } = ctx.request.body
|
|
6
|
+
const runner = new ScriptRunner(script, context)
|
|
7
|
+
ctx.body = runner.execute()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function save(ctx: BBContext) {
|
|
11
|
+
ctx.throw(501, "Not currently implemented")
|
|
12
|
+
}
|
|
@@ -17,13 +17,9 @@ const { clientLibraryPath } = require("../../../utilities")
|
|
|
17
17
|
const { upload, deleteFiles } = require("../../../utilities/fileSystem")
|
|
18
18
|
const { attachmentsRelativeURL } = require("../../../utilities")
|
|
19
19
|
const { DocumentType } = require("../../../db/utils")
|
|
20
|
-
const {
|
|
21
|
-
const { setCookie, clearCookie } = require("@budibase/backend-core/utils")
|
|
20
|
+
const { context, objectStore, utils } = require("@budibase/backend-core")
|
|
22
21
|
const AWS = require("aws-sdk")
|
|
23
22
|
const fs = require("fs")
|
|
24
|
-
const {
|
|
25
|
-
downloadTarballDirect,
|
|
26
|
-
} = require("../../../utilities/fileSystem/utilities")
|
|
27
23
|
|
|
28
24
|
async function prepareUpload({ s3Key, bucket, metadata, file }: any) {
|
|
29
25
|
const response = await upload({
|
|
@@ -48,7 +44,7 @@ export const toggleBetaUiFeature = async function (ctx: any) {
|
|
|
48
44
|
const cookieName = `beta:${ctx.params.feature}`
|
|
49
45
|
|
|
50
46
|
if (ctx.cookies.get(cookieName)) {
|
|
51
|
-
clearCookie(ctx, cookieName)
|
|
47
|
+
utils.clearCookie(ctx, cookieName)
|
|
52
48
|
ctx.body = {
|
|
53
49
|
message: `${ctx.params.feature} disabled`,
|
|
54
50
|
}
|
|
@@ -61,11 +57,11 @@ export const toggleBetaUiFeature = async function (ctx: any) {
|
|
|
61
57
|
if (!fs.existsSync(builderPath)) {
|
|
62
58
|
fs.mkdirSync(builderPath)
|
|
63
59
|
}
|
|
64
|
-
await downloadTarballDirect(
|
|
60
|
+
await objectStore.downloadTarballDirect(
|
|
65
61
|
"https://cdn.budi.live/beta:design_ui/new_ui.tar.gz",
|
|
66
62
|
builderPath
|
|
67
63
|
)
|
|
68
|
-
setCookie(ctx, {}, cookieName)
|
|
64
|
+
utils.setCookie(ctx, {}, cookieName)
|
|
69
65
|
|
|
70
66
|
ctx.body = {
|
|
71
67
|
message: `${ctx.params.feature} enabled`,
|
|
@@ -103,9 +99,9 @@ export const deleteObjects = async function (ctx: any) {
|
|
|
103
99
|
}
|
|
104
100
|
|
|
105
101
|
export const serveApp = async function (ctx: any) {
|
|
106
|
-
const db = getAppDB({ skip_setup: true })
|
|
102
|
+
const db = context.getAppDB({ skip_setup: true })
|
|
107
103
|
const appInfo = await db.get(DocumentType.APP_METADATA)
|
|
108
|
-
let appId = getAppId()
|
|
104
|
+
let appId = context.getAppId()
|
|
109
105
|
|
|
110
106
|
if (!env.isJest()) {
|
|
111
107
|
const App = require("./templates/BudibaseApp.svelte").default
|
|
@@ -134,11 +130,11 @@ export const serveApp = async function (ctx: any) {
|
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
export const serveBuilderPreview = async function (ctx: any) {
|
|
137
|
-
const db = getAppDB({ skip_setup: true })
|
|
133
|
+
const db = context.getAppDB({ skip_setup: true })
|
|
138
134
|
const appInfo = await db.get(DocumentType.APP_METADATA)
|
|
139
135
|
|
|
140
136
|
if (!env.isJest()) {
|
|
141
|
-
let appId = getAppId()
|
|
137
|
+
let appId = context.getAppId()
|
|
142
138
|
const previewHbs = loadHandlebarsFile(`${__dirname}/templates/preview.hbs`)
|
|
143
139
|
ctx.body = await processString(previewHbs, {
|
|
144
140
|
clientLibPath: clientLibraryPath(appId, appInfo.version, ctx),
|
|
@@ -156,7 +152,7 @@ export const serveClientLibrary = async function (ctx: any) {
|
|
|
156
152
|
}
|
|
157
153
|
|
|
158
154
|
export const getSignedUploadURL = async function (ctx: any) {
|
|
159
|
-
const database = getAppDB()
|
|
155
|
+
const database = context.getAppDB()
|
|
160
156
|
|
|
161
157
|
// Ensure datasource is valid
|
|
162
158
|
let datasource
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { FieldTypes, FormulaTypes } from "../../../constants"
|
|
2
|
+
import { clearColumns } from "./utils"
|
|
3
|
+
import { doesContainStrings } from "@budibase/string-templates"
|
|
4
|
+
import { cloneDeep } from "lodash/fp"
|
|
5
|
+
import { isEqual, uniq } from "lodash"
|
|
6
|
+
import { updateAllFormulasInTable } from "../row/staticFormula"
|
|
7
|
+
import { context } from "@budibase/backend-core"
|
|
8
|
+
import { FieldSchema, Table } from "@budibase/types"
|
|
9
|
+
import sdk from "../../../sdk"
|
|
9
10
|
|
|
10
|
-
function isStaticFormula(column) {
|
|
11
|
+
function isStaticFormula(column: FieldSchema) {
|
|
11
12
|
return (
|
|
12
13
|
column.type === FieldTypes.FORMULA &&
|
|
13
14
|
column.formulaType === FormulaTypes.STATIC
|
|
@@ -18,8 +19,8 @@ function isStaticFormula(column) {
|
|
|
18
19
|
* This retrieves the formula columns from a table schema that use a specified column name
|
|
19
20
|
* in the formula.
|
|
20
21
|
*/
|
|
21
|
-
function getFormulaThatUseColumn(table, columnNames) {
|
|
22
|
-
let formula = []
|
|
22
|
+
function getFormulaThatUseColumn(table: Table, columnNames: string[] | string) {
|
|
23
|
+
let formula: string[] = []
|
|
23
24
|
columnNames = Array.isArray(columnNames) ? columnNames : [columnNames]
|
|
24
25
|
for (let column of Object.values(table.schema)) {
|
|
25
26
|
// not a static formula, or doesn't contain a relationship
|
|
@@ -38,7 +39,10 @@ function getFormulaThatUseColumn(table, columnNames) {
|
|
|
38
39
|
* This functions checks for when a related table, column or related column is deleted, if any
|
|
39
40
|
* tables need to have the formula column removed.
|
|
40
41
|
*/
|
|
41
|
-
async function checkIfFormulaNeedsCleared(
|
|
42
|
+
async function checkIfFormulaNeedsCleared(
|
|
43
|
+
table: Table,
|
|
44
|
+
{ oldTable, deletion }: { oldTable?: Table; deletion?: boolean }
|
|
45
|
+
) {
|
|
42
46
|
// start by retrieving all tables, remove the current table from the list
|
|
43
47
|
const tables = (await sdk.tables.getAllInternalTables()).filter(
|
|
44
48
|
tbl => tbl._id !== table._id
|
|
@@ -49,11 +53,14 @@ async function checkIfFormulaNeedsCleared(table, { oldTable, deletion }) {
|
|
|
49
53
|
)
|
|
50
54
|
// remove any formula columns that used related columns
|
|
51
55
|
for (let removed of removedColumns) {
|
|
52
|
-
let tableToUse = table
|
|
56
|
+
let tableToUse: Table | undefined = table
|
|
53
57
|
// if relationship, get the related table
|
|
54
58
|
if (removed.type === FieldTypes.LINK) {
|
|
55
59
|
tableToUse = tables.find(table => table._id === removed.tableId)
|
|
56
60
|
}
|
|
61
|
+
if (!tableToUse) {
|
|
62
|
+
continue
|
|
63
|
+
}
|
|
57
64
|
const columnsToDelete = getFormulaThatUseColumn(tableToUse, removed.name)
|
|
58
65
|
if (columnsToDelete.length > 0) {
|
|
59
66
|
await clearColumns(table, columnsToDelete)
|
|
@@ -71,11 +78,11 @@ async function checkIfFormulaNeedsCleared(table, { oldTable, deletion }) {
|
|
|
71
78
|
// look to see if the column was used in a relationship formula,
|
|
72
79
|
// relationships won't be used for this
|
|
73
80
|
if (relatedTable && relatedColumns && removed.type !== FieldTypes.LINK) {
|
|
74
|
-
let relatedFormulaToRemove = []
|
|
81
|
+
let relatedFormulaToRemove: string[] = []
|
|
75
82
|
for (let column of relatedColumns) {
|
|
76
83
|
relatedFormulaToRemove = relatedFormulaToRemove.concat(
|
|
77
84
|
getFormulaThatUseColumn(relatedTable, [
|
|
78
|
-
column.fieldName
|
|
85
|
+
column.fieldName!,
|
|
79
86
|
removed.name,
|
|
80
87
|
])
|
|
81
88
|
)
|
|
@@ -95,13 +102,14 @@ async function checkIfFormulaNeedsCleared(table, { oldTable, deletion }) {
|
|
|
95
102
|
* specifically only for static formula.
|
|
96
103
|
*/
|
|
97
104
|
async function updateRelatedFormulaLinksOnTables(
|
|
98
|
-
table,
|
|
99
|
-
{ deletion }
|
|
105
|
+
table: Table,
|
|
106
|
+
{ deletion }: { deletion?: boolean } = {}
|
|
100
107
|
) {
|
|
101
|
-
const
|
|
108
|
+
const tableId: string = table._id!
|
|
109
|
+
const db = context.getAppDB()
|
|
102
110
|
// start by retrieving all tables, remove the current table from the list
|
|
103
111
|
const tables = (await sdk.tables.getAllInternalTables()).filter(
|
|
104
|
-
tbl => tbl._id !==
|
|
112
|
+
tbl => tbl._id !== tableId
|
|
105
113
|
)
|
|
106
114
|
// clone the tables, so we can compare at end
|
|
107
115
|
const initialTables = cloneDeep(tables)
|
|
@@ -114,7 +122,7 @@ async function updateRelatedFormulaLinksOnTables(
|
|
|
114
122
|
if (!otherTable.relatedFormula) {
|
|
115
123
|
continue
|
|
116
124
|
}
|
|
117
|
-
const index = otherTable.relatedFormula.indexOf(
|
|
125
|
+
const index = otherTable.relatedFormula.indexOf(tableId)
|
|
118
126
|
if (index !== -1) {
|
|
119
127
|
otherTable.relatedFormula.splice(index, 1)
|
|
120
128
|
}
|
|
@@ -133,11 +141,11 @@ async function updateRelatedFormulaLinksOnTables(
|
|
|
133
141
|
if (
|
|
134
142
|
relatedTable &&
|
|
135
143
|
(!relatedTable.relatedFormula ||
|
|
136
|
-
!relatedTable.relatedFormula.includes(
|
|
144
|
+
!relatedTable.relatedFormula.includes(tableId))
|
|
137
145
|
) {
|
|
138
146
|
relatedTable.relatedFormula = relatedTable.relatedFormula
|
|
139
|
-
? [...relatedTable.relatedFormula,
|
|
140
|
-
: [
|
|
147
|
+
? [...relatedTable.relatedFormula, tableId]
|
|
148
|
+
: [tableId]
|
|
141
149
|
}
|
|
142
150
|
}
|
|
143
151
|
}
|
|
@@ -150,7 +158,10 @@ async function updateRelatedFormulaLinksOnTables(
|
|
|
150
158
|
}
|
|
151
159
|
}
|
|
152
160
|
|
|
153
|
-
async function checkIfFormulaUpdated(
|
|
161
|
+
async function checkIfFormulaUpdated(
|
|
162
|
+
table: Table,
|
|
163
|
+
{ oldTable }: { oldTable?: Table }
|
|
164
|
+
) {
|
|
154
165
|
// look to see if any formula values have changed
|
|
155
166
|
const shouldUpdate = Object.values(table.schema).find(
|
|
156
167
|
column =>
|
|
@@ -165,7 +176,10 @@ async function checkIfFormulaUpdated(table, { oldTable }) {
|
|
|
165
176
|
}
|
|
166
177
|
}
|
|
167
178
|
|
|
168
|
-
|
|
179
|
+
export async function runStaticFormulaChecks(
|
|
180
|
+
table: Table,
|
|
181
|
+
{ oldTable, deletion }: { oldTable?: Table; deletion?: boolean }
|
|
182
|
+
) {
|
|
169
183
|
await updateRelatedFormulaLinksOnTables(table, { deletion })
|
|
170
184
|
await checkIfFormulaNeedsCleared(table, { oldTable, deletion })
|
|
171
185
|
if (!deletion) {
|
|
@@ -1,38 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
buildExternalTableId,
|
|
3
3
|
breakExternalTableId,
|
|
4
|
-
}
|
|
5
|
-
|
|
4
|
+
} from "../../../integrations/utils"
|
|
5
|
+
import {
|
|
6
6
|
generateForeignKey,
|
|
7
7
|
generateJunctionTableName,
|
|
8
8
|
foreignKeyStructure,
|
|
9
9
|
hasTypeChanged,
|
|
10
|
-
}
|
|
11
|
-
|
|
10
|
+
} from "./utils"
|
|
11
|
+
import {
|
|
12
12
|
DataSourceOperation,
|
|
13
13
|
FieldTypes,
|
|
14
14
|
RelationshipTypes,
|
|
15
|
-
}
|
|
16
|
-
|
|
15
|
+
} from "../../../constants"
|
|
16
|
+
import { makeExternalQuery } from "../../../integrations/base/query"
|
|
17
|
+
import csvParser from "../../../utilities/csvParser"
|
|
18
|
+
import { handleRequest } from "../row/external"
|
|
19
|
+
import { events, context } from "@budibase/backend-core"
|
|
20
|
+
import {
|
|
21
|
+
Datasource,
|
|
22
|
+
Table,
|
|
23
|
+
QueryJson,
|
|
24
|
+
Operation,
|
|
25
|
+
RenameColumn,
|
|
26
|
+
FieldSchema,
|
|
27
|
+
BBContext,
|
|
28
|
+
TableRequest,
|
|
29
|
+
} from "@budibase/types"
|
|
30
|
+
import sdk from "../../../sdk"
|
|
17
31
|
const { cloneDeep } = require("lodash/fp")
|
|
18
|
-
const csvParser = require("../../../utilities/csvParser")
|
|
19
|
-
const { handleRequest } = require("../row/external")
|
|
20
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
21
|
-
const { events } = require("@budibase/backend-core")
|
|
22
|
-
const sdk = require("../../../sdk")
|
|
23
32
|
|
|
24
33
|
async function makeTableRequest(
|
|
25
|
-
datasource,
|
|
26
|
-
operation,
|
|
27
|
-
table,
|
|
28
|
-
tables,
|
|
29
|
-
oldTable
|
|
30
|
-
renamed
|
|
34
|
+
datasource: Datasource,
|
|
35
|
+
operation: Operation,
|
|
36
|
+
table: Table,
|
|
37
|
+
tables: Record<string, Table>,
|
|
38
|
+
oldTable?: Table,
|
|
39
|
+
renamed?: RenameColumn
|
|
31
40
|
) {
|
|
32
|
-
const json = {
|
|
41
|
+
const json: QueryJson = {
|
|
33
42
|
endpoint: {
|
|
34
|
-
datasourceId: datasource._id
|
|
35
|
-
entityId: table._id
|
|
43
|
+
datasourceId: datasource._id!,
|
|
44
|
+
entityId: table._id!,
|
|
36
45
|
operation,
|
|
37
46
|
},
|
|
38
47
|
meta: {
|
|
@@ -41,15 +50,19 @@ async function makeTableRequest(
|
|
|
41
50
|
table,
|
|
42
51
|
}
|
|
43
52
|
if (oldTable) {
|
|
44
|
-
json.meta
|
|
53
|
+
json.meta!.table = oldTable
|
|
45
54
|
}
|
|
46
55
|
if (renamed) {
|
|
47
|
-
json.meta
|
|
56
|
+
json.meta!.renamed = renamed
|
|
48
57
|
}
|
|
49
58
|
return makeExternalQuery(datasource, json)
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
function cleanupRelationships(
|
|
61
|
+
function cleanupRelationships(
|
|
62
|
+
table: Table,
|
|
63
|
+
tables: Record<string, Table>,
|
|
64
|
+
oldTable?: Table
|
|
65
|
+
) {
|
|
53
66
|
const tableToIterate = oldTable ? oldTable : table
|
|
54
67
|
// clean up relationships in couch table schemas
|
|
55
68
|
for (let [key, schema] of Object.entries(tableToIterate.schema)) {
|
|
@@ -78,7 +91,7 @@ function cleanupRelationships(table, tables, oldTable = null) {
|
|
|
78
91
|
}
|
|
79
92
|
}
|
|
80
93
|
|
|
81
|
-
function getDatasourceId(table) {
|
|
94
|
+
function getDatasourceId(table: Table) {
|
|
82
95
|
if (!table) {
|
|
83
96
|
throw "No table supplied"
|
|
84
97
|
}
|
|
@@ -88,7 +101,7 @@ function getDatasourceId(table) {
|
|
|
88
101
|
return breakExternalTableId(table._id).datasourceId
|
|
89
102
|
}
|
|
90
103
|
|
|
91
|
-
function otherRelationshipType(type) {
|
|
104
|
+
function otherRelationshipType(type?: string) {
|
|
92
105
|
if (type === RelationshipTypes.MANY_TO_MANY) {
|
|
93
106
|
return RelationshipTypes.MANY_TO_MANY
|
|
94
107
|
}
|
|
@@ -97,13 +110,21 @@ function otherRelationshipType(type) {
|
|
|
97
110
|
: RelationshipTypes.ONE_TO_MANY
|
|
98
111
|
}
|
|
99
112
|
|
|
100
|
-
function generateManyLinkSchema(
|
|
113
|
+
function generateManyLinkSchema(
|
|
114
|
+
datasource: Datasource,
|
|
115
|
+
column: FieldSchema,
|
|
116
|
+
table: Table,
|
|
117
|
+
relatedTable: Table
|
|
118
|
+
): Table {
|
|
119
|
+
if (!table.primary || !relatedTable.primary) {
|
|
120
|
+
throw new Error("Unable to generate many link schema, no primary keys")
|
|
121
|
+
}
|
|
101
122
|
const primary = table.name + table.primary[0]
|
|
102
123
|
const relatedPrimary = relatedTable.name + relatedTable.primary[0]
|
|
103
124
|
const jcTblName = generateJunctionTableName(column, table, relatedTable)
|
|
104
125
|
// first create the new table
|
|
105
126
|
const junctionTable = {
|
|
106
|
-
_id: buildExternalTableId(datasource._id
|
|
127
|
+
_id: buildExternalTableId(datasource._id!, jcTblName),
|
|
107
128
|
name: jcTblName,
|
|
108
129
|
primary: [primary, relatedPrimary],
|
|
109
130
|
constrained: [primary, relatedPrimary],
|
|
@@ -125,7 +146,15 @@ function generateManyLinkSchema(datasource, column, table, relatedTable) {
|
|
|
125
146
|
return junctionTable
|
|
126
147
|
}
|
|
127
148
|
|
|
128
|
-
function generateLinkSchema(
|
|
149
|
+
function generateLinkSchema(
|
|
150
|
+
column: FieldSchema,
|
|
151
|
+
table: Table,
|
|
152
|
+
relatedTable: Table,
|
|
153
|
+
type: string
|
|
154
|
+
) {
|
|
155
|
+
if (!table.primary || !relatedTable.primary) {
|
|
156
|
+
throw new Error("Unable to generate link schema, no primary keys")
|
|
157
|
+
}
|
|
129
158
|
const isOneSide = type === RelationshipTypes.ONE_TO_MANY
|
|
130
159
|
const primary = isOneSide ? relatedTable.primary[0] : table.primary[0]
|
|
131
160
|
// generate a foreign key
|
|
@@ -136,7 +165,12 @@ function generateLinkSchema(column, table, relatedTable, type) {
|
|
|
136
165
|
return foreignKey
|
|
137
166
|
}
|
|
138
167
|
|
|
139
|
-
function generateRelatedSchema(
|
|
168
|
+
function generateRelatedSchema(
|
|
169
|
+
linkColumn: FieldSchema,
|
|
170
|
+
table: Table,
|
|
171
|
+
relatedTable: Table,
|
|
172
|
+
columnName: string
|
|
173
|
+
) {
|
|
140
174
|
// generate column for other table
|
|
141
175
|
const relatedSchema = cloneDeep(linkColumn)
|
|
142
176
|
// swap them from the main link
|
|
@@ -159,21 +193,21 @@ function generateRelatedSchema(linkColumn, table, relatedTable, columnName) {
|
|
|
159
193
|
table.schema[columnName] = relatedSchema
|
|
160
194
|
}
|
|
161
195
|
|
|
162
|
-
function isRelationshipSetup(column) {
|
|
196
|
+
function isRelationshipSetup(column: FieldSchema) {
|
|
163
197
|
return column.foreignKey || column.through
|
|
164
198
|
}
|
|
165
199
|
|
|
166
|
-
|
|
167
|
-
const table = ctx.request.body
|
|
168
|
-
const
|
|
200
|
+
export async function save(ctx: BBContext) {
|
|
201
|
+
const table: TableRequest = ctx.request.body
|
|
202
|
+
const renamed = table?._rename
|
|
169
203
|
// can't do this right now
|
|
170
204
|
delete table.dataImport
|
|
171
|
-
const datasourceId = getDatasourceId(ctx.request.body)
|
|
205
|
+
const datasourceId = getDatasourceId(ctx.request.body)!
|
|
172
206
|
// table doesn't exist already, note that it is created
|
|
173
207
|
if (!table._id) {
|
|
174
208
|
table.created = true
|
|
175
209
|
}
|
|
176
|
-
let tableToSave = {
|
|
210
|
+
let tableToSave: TableRequest = {
|
|
177
211
|
type: "table",
|
|
178
212
|
_id: buildExternalTableId(datasourceId, table.name),
|
|
179
213
|
...table,
|
|
@@ -188,10 +222,10 @@ exports.save = async function (ctx) {
|
|
|
188
222
|
ctx.throw(400, "A column type has changed.")
|
|
189
223
|
}
|
|
190
224
|
|
|
191
|
-
const db = getAppDB()
|
|
225
|
+
const db = context.getAppDB()
|
|
192
226
|
const datasource = await db.get(datasourceId)
|
|
193
227
|
const oldTables = cloneDeep(datasource.entities)
|
|
194
|
-
const tables = datasource.entities
|
|
228
|
+
const tables: Record<string, Table> = datasource.entities
|
|
195
229
|
|
|
196
230
|
const extraTablesToUpdate = []
|
|
197
231
|
|
|
@@ -203,8 +237,11 @@ exports.save = async function (ctx) {
|
|
|
203
237
|
const relatedTable = Object.values(tables).find(
|
|
204
238
|
table => table._id === schema.tableId
|
|
205
239
|
)
|
|
206
|
-
|
|
207
|
-
|
|
240
|
+
if (!relatedTable) {
|
|
241
|
+
continue
|
|
242
|
+
}
|
|
243
|
+
const relatedColumnName = schema.fieldName!
|
|
244
|
+
const relationType = schema.relationshipType!
|
|
208
245
|
if (relationType === RelationshipTypes.MANY_TO_MANY) {
|
|
209
246
|
const junctionTable = generateManyLinkSchema(
|
|
210
247
|
datasource,
|
|
@@ -244,9 +281,7 @@ exports.save = async function (ctx) {
|
|
|
244
281
|
|
|
245
282
|
cleanupRelationships(tableToSave, tables, oldTable)
|
|
246
283
|
|
|
247
|
-
const operation = oldTable
|
|
248
|
-
? DataSourceOperation.UPDATE_TABLE
|
|
249
|
-
: DataSourceOperation.CREATE_TABLE
|
|
284
|
+
const operation = oldTable ? Operation.UPDATE_TABLE : Operation.CREATE_TABLE
|
|
250
285
|
await makeTableRequest(
|
|
251
286
|
datasource,
|
|
252
287
|
operation,
|
|
@@ -258,9 +293,7 @@ exports.save = async function (ctx) {
|
|
|
258
293
|
// update any extra tables (like foreign keys in other tables)
|
|
259
294
|
for (let extraTable of extraTablesToUpdate) {
|
|
260
295
|
const oldExtraTable = oldTables[extraTable.name]
|
|
261
|
-
let op = oldExtraTable
|
|
262
|
-
? DataSourceOperation.UPDATE_TABLE
|
|
263
|
-
: DataSourceOperation.CREATE_TABLE
|
|
296
|
+
let op = oldExtraTable ? Operation.UPDATE_TABLE : Operation.CREATE_TABLE
|
|
264
297
|
await makeTableRequest(datasource, op, extraTable, tables, oldExtraTable)
|
|
265
298
|
}
|
|
266
299
|
|
|
@@ -280,18 +313,20 @@ exports.save = async function (ctx) {
|
|
|
280
313
|
return tableToSave
|
|
281
314
|
}
|
|
282
315
|
|
|
283
|
-
|
|
284
|
-
const tableToDelete = await sdk.tables.getTable(
|
|
316
|
+
export async function destroy(ctx: BBContext) {
|
|
317
|
+
const tableToDelete: TableRequest = await sdk.tables.getTable(
|
|
318
|
+
ctx.params.tableId
|
|
319
|
+
)
|
|
285
320
|
if (!tableToDelete || !tableToDelete.created) {
|
|
286
321
|
ctx.throw(400, "Cannot delete tables which weren't created in Budibase.")
|
|
287
322
|
}
|
|
288
323
|
const datasourceId = getDatasourceId(tableToDelete)
|
|
289
324
|
|
|
290
|
-
const db = getAppDB()
|
|
325
|
+
const db = context.getAppDB()
|
|
291
326
|
const datasource = await db.get(datasourceId)
|
|
292
327
|
const tables = datasource.entities
|
|
293
328
|
|
|
294
|
-
const operation =
|
|
329
|
+
const operation = Operation.DELETE_TABLE
|
|
295
330
|
await makeTableRequest(datasource, operation, tableToDelete, tables)
|
|
296
331
|
|
|
297
332
|
cleanupRelationships(tableToDelete, tables)
|
|
@@ -302,7 +337,7 @@ exports.destroy = async function (ctx) {
|
|
|
302
337
|
return tableToDelete
|
|
303
338
|
}
|
|
304
339
|
|
|
305
|
-
|
|
340
|
+
export async function bulkImport(ctx: BBContext) {
|
|
306
341
|
const table = await sdk.tables.getTable(ctx.params.tableId)
|
|
307
342
|
const { dataImport } = ctx.request.body
|
|
308
343
|
if (!dataImport || !dataImport.schema || !dataImport.csvString) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import * as internal from "./internal"
|
|
2
|
+
import * as external from "./external"
|
|
3
|
+
import csvParser from "../../../utilities/csvParser"
|
|
4
|
+
import { isExternalTable, isSQL } from "../../../integrations/utils"
|
|
5
|
+
import { getDatasourceParams } from "../../../db/utils"
|
|
6
|
+
import { context, events } from "@budibase/backend-core"
|
|
7
|
+
import { Table, BBContext } from "@budibase/types"
|
|
8
|
+
import sdk from "../../../sdk"
|
|
9
9
|
|
|
10
|
-
function pickApi({ tableId, table }) {
|
|
10
|
+
function pickApi({ tableId, table }: { tableId?: string; table?: Table }) {
|
|
11
11
|
if (table && !tableId) {
|
|
12
12
|
tableId = table._id
|
|
13
13
|
}
|
|
@@ -20,8 +20,8 @@ function pickApi({ tableId, table }) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// covers both internal and external
|
|
23
|
-
|
|
24
|
-
const db = getAppDB()
|
|
23
|
+
export async function fetch(ctx: BBContext) {
|
|
24
|
+
const db = context.getAppDB()
|
|
25
25
|
|
|
26
26
|
const internal = await sdk.tables.getAllInternalTables()
|
|
27
27
|
|
|
@@ -34,7 +34,7 @@ exports.fetch = async function (ctx) {
|
|
|
34
34
|
const external = externalTables.rows.flatMap(tableDoc => {
|
|
35
35
|
let entities = tableDoc.doc.entities
|
|
36
36
|
if (entities) {
|
|
37
|
-
return Object.values(entities).map(entity => ({
|
|
37
|
+
return Object.values(entities).map((entity: any) => ({
|
|
38
38
|
...entity,
|
|
39
39
|
type: "external",
|
|
40
40
|
sourceId: tableDoc.doc._id,
|
|
@@ -48,12 +48,12 @@ exports.fetch = async function (ctx) {
|
|
|
48
48
|
ctx.body = [...internal, ...external]
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
export async function find(ctx: BBContext) {
|
|
52
52
|
const tableId = ctx.params.tableId
|
|
53
53
|
ctx.body = await sdk.tables.getTable(tableId)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
export async function save(ctx: BBContext) {
|
|
57
57
|
const appId = ctx.appId
|
|
58
58
|
const table = ctx.request.body
|
|
59
59
|
const importFormat =
|
|
@@ -74,7 +74,7 @@ exports.save = async function (ctx) {
|
|
|
74
74
|
ctx.body = savedTable
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
export async function destroy(ctx: BBContext) {
|
|
78
78
|
const appId = ctx.appId
|
|
79
79
|
const tableId = ctx.params.tableId
|
|
80
80
|
const deletedTable = await pickApi({ tableId }).destroy(ctx)
|
|
@@ -86,7 +86,7 @@ exports.destroy = async function (ctx) {
|
|
|
86
86
|
ctx.body = { message: `Table ${tableId} deleted.` }
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
export async function bulkImport(ctx: BBContext) {
|
|
90
90
|
const tableId = ctx.params.tableId
|
|
91
91
|
await pickApi({ tableId }).bulkImport(ctx)
|
|
92
92
|
// right now we don't trigger anything for bulk import because it
|
|
@@ -96,7 +96,7 @@ exports.bulkImport = async function (ctx) {
|
|
|
96
96
|
ctx.body = { message: `Bulk rows created.` }
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
export async function validateCSVSchema(ctx: BBContext) {
|
|
100
100
|
// tableId being specified means its an import to an existing table
|
|
101
101
|
const { csvString, schema = {}, tableId } = ctx.request.body
|
|
102
102
|
let existingTable
|
|
@@ -133,7 +133,7 @@ export async function save(ctx: any) {
|
|
|
133
133
|
tableToSave._rev = result.rev
|
|
134
134
|
}
|
|
135
135
|
// has to run after, make sure it has _id
|
|
136
|
-
await runStaticFormulaChecks(tableToSave, { oldTable, deletion:
|
|
136
|
+
await runStaticFormulaChecks(tableToSave, { oldTable, deletion: false })
|
|
137
137
|
return tableToSave
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -176,7 +176,6 @@ export async function destroy(ctx: any) {
|
|
|
176
176
|
|
|
177
177
|
// has to run after, make sure it has _id
|
|
178
178
|
await runStaticFormulaChecks(tableToDelete, {
|
|
179
|
-
oldTable: null,
|
|
180
179
|
deletion: true,
|
|
181
180
|
})
|
|
182
181
|
await cleanupAttachments(tableToDelete, {
|