@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
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import env from "../environment"
|
|
2
|
+
import { OBJ_STORE_DIRECTORY } from "../constants"
|
|
3
|
+
import { objectStore, context } from "@budibase/backend-core"
|
|
4
|
+
import { generateMetadataID } from "../db/utils"
|
|
5
|
+
import { Document } from "@budibase/types"
|
|
6
|
+
import stream from "stream"
|
|
7
|
+
const Readable = stream.Readable
|
|
8
|
+
|
|
9
|
+
export function wait(ms: number) {
|
|
10
|
+
return new Promise(resolve => setTimeout(resolve, ms))
|
|
11
|
+
}
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
export const isDev = env.isDev
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
export const NUMBER_REGEX = /^[+-]?([0-9]*[.])?[0-9]+$/g
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
export function removeFromArray(array: any[], element: any) {
|
|
15
18
|
const index = array.indexOf(element)
|
|
16
19
|
if (index !== -1) {
|
|
17
20
|
array.splice(index, 1)
|
|
@@ -25,7 +28,7 @@ exports.removeFromArray = (array, element) => {
|
|
|
25
28
|
* @param {string} url The URL to test and remove any extra double slashes.
|
|
26
29
|
* @return {string} The updated url.
|
|
27
30
|
*/
|
|
28
|
-
|
|
31
|
+
export function checkSlashesInUrl(url: string) {
|
|
29
32
|
return url.replace(/(https?:\/\/)|(\/)+/g, "$1$2")
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -33,7 +36,7 @@ exports.checkSlashesInUrl = url => {
|
|
|
33
36
|
* Gets the address of the object store, depending on whether self hosted or in cloud.
|
|
34
37
|
* @return {string} The base URL of the object store (MinIO or S3).
|
|
35
38
|
*/
|
|
36
|
-
|
|
39
|
+
export function objectStoreUrl() {
|
|
37
40
|
if (env.SELF_HOSTED || env.MINIO_URL) {
|
|
38
41
|
// can use a relative url for this as all goes through the proxy (this is hosted in minio)
|
|
39
42
|
return OBJ_STORE_DIRECTORY
|
|
@@ -52,9 +55,9 @@ exports.objectStoreUrl = () => {
|
|
|
52
55
|
* @return {string} The URL to be inserted into appPackage response or server rendered
|
|
53
56
|
* app index file.
|
|
54
57
|
*/
|
|
55
|
-
|
|
58
|
+
export function clientLibraryPath(appId: string, version: string) {
|
|
56
59
|
if (env.isProd()) {
|
|
57
|
-
let url = `${
|
|
60
|
+
let url = `${objectStoreUrl()}/${objectStore.sanitizeKey(
|
|
58
61
|
appId
|
|
59
62
|
)}/budibase-client.js`
|
|
60
63
|
|
|
@@ -68,18 +71,19 @@ exports.clientLibraryPath = (appId, version) => {
|
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
|
|
72
|
-
return
|
|
73
|
-
`${exports.objectStoreUrl()}/${attachmentKey}`
|
|
74
|
-
)
|
|
74
|
+
export function attachmentsRelativeURL(attachmentKey: string) {
|
|
75
|
+
return checkSlashesInUrl(`${objectStoreUrl()}/${attachmentKey}`)
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
export async function updateEntityMetadata(
|
|
79
|
+
type: string,
|
|
80
|
+
entityId: string,
|
|
81
|
+
updateFn: any
|
|
82
|
+
) {
|
|
83
|
+
const db = context.getAppDB()
|
|
79
84
|
const id = generateMetadataID(type, entityId)
|
|
80
85
|
// read it to see if it exists, we'll overwrite it no matter what
|
|
81
|
-
let rev,
|
|
82
|
-
metadata = {}
|
|
86
|
+
let rev, metadata: Document
|
|
83
87
|
try {
|
|
84
88
|
const oldMetadata = await db.get(id)
|
|
85
89
|
rev = oldMetadata._rev
|
|
@@ -100,14 +104,18 @@ exports.updateEntityMetadata = async (type, entityId, updateFn) => {
|
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
export async function saveEntityMetadata(
|
|
108
|
+
type: string,
|
|
109
|
+
entityId: string,
|
|
110
|
+
metadata: Document
|
|
111
|
+
) {
|
|
112
|
+
return updateEntityMetadata(type, entityId, () => {
|
|
105
113
|
return metadata
|
|
106
114
|
})
|
|
107
115
|
}
|
|
108
116
|
|
|
109
|
-
|
|
110
|
-
const db = getAppDB()
|
|
117
|
+
export async function deleteEntityMetadata(type: string, entityId: string) {
|
|
118
|
+
const db = context.getAppDB()
|
|
111
119
|
const id = generateMetadataID(type, entityId)
|
|
112
120
|
let rev
|
|
113
121
|
try {
|
|
@@ -123,7 +131,7 @@ exports.deleteEntityMetadata = async (type, entityId) => {
|
|
|
123
131
|
}
|
|
124
132
|
}
|
|
125
133
|
|
|
126
|
-
|
|
134
|
+
export function escapeDangerousCharacters(string: string) {
|
|
127
135
|
return string
|
|
128
136
|
.replace(/[\\]/g, "\\\\")
|
|
129
137
|
.replace(/[\b]/g, "\\b")
|
|
@@ -133,7 +141,7 @@ exports.escapeDangerousCharacters = string => {
|
|
|
133
141
|
.replace(/[\t]/g, "\\t")
|
|
134
142
|
}
|
|
135
143
|
|
|
136
|
-
|
|
144
|
+
export function stringToReadStream(string: string) {
|
|
137
145
|
return new Readable({
|
|
138
146
|
read() {
|
|
139
147
|
this.push(string)
|
|
@@ -142,7 +150,7 @@ exports.stringToReadStream = string => {
|
|
|
142
150
|
})
|
|
143
151
|
}
|
|
144
152
|
|
|
145
|
-
|
|
153
|
+
export function formatBytes(bytes: string) {
|
|
146
154
|
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
|
147
155
|
const byteIncrements = 1024
|
|
148
156
|
let unit = 0
|
|
@@ -153,7 +161,7 @@ exports.formatBytes = bytes => {
|
|
|
153
161
|
return `${size.toFixed(size < 10 && unit > 0 ? 1 : 0)}${units[unit]}`
|
|
154
162
|
}
|
|
155
163
|
|
|
156
|
-
|
|
164
|
+
export function convertBookmark(bookmark: string) {
|
|
157
165
|
const IS_NUMBER = /^\d+\.?\d*$/
|
|
158
166
|
if (typeof bookmark === "string" && bookmark.match(IS_NUMBER)) {
|
|
159
167
|
return parseFloat(bookmark)
|
|
@@ -161,7 +169,7 @@ exports.convertBookmark = bookmark => {
|
|
|
161
169
|
return bookmark
|
|
162
170
|
}
|
|
163
171
|
|
|
164
|
-
|
|
172
|
+
export function isQsTrue(param: string) {
|
|
165
173
|
if (typeof param === "string") {
|
|
166
174
|
return param.toLowerCase() === "true"
|
|
167
175
|
} else {
|
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { redis } from "@budibase/backend-core"
|
|
2
|
+
import { getGlobalIDFromUserMetadataID } from "../db/utils"
|
|
3
|
+
import { ContextUser } from "@budibase/types"
|
|
3
4
|
|
|
4
5
|
const APP_DEV_LOCK_SECONDS = 600
|
|
5
6
|
const AUTOMATION_TEST_FLAG_SECONDS = 60
|
|
6
|
-
let devAppClient, debounceClient, flagClient
|
|
7
|
+
let devAppClient: any, debounceClient: any, flagClient: any
|
|
7
8
|
|
|
8
9
|
// we init this as we want to keep the connection open all the time
|
|
9
10
|
// reduces the performance hit
|
|
10
|
-
|
|
11
|
-
devAppClient = new Client(utils.Databases.DEV_LOCKS)
|
|
12
|
-
debounceClient = new Client(utils.Databases.DEBOUNCE)
|
|
13
|
-
flagClient = new Client(utils.Databases.FLAGS)
|
|
11
|
+
export async function init() {
|
|
12
|
+
devAppClient = new redis.Client(redis.utils.Databases.DEV_LOCKS)
|
|
13
|
+
debounceClient = new redis.Client(redis.utils.Databases.DEBOUNCE)
|
|
14
|
+
flagClient = new redis.Client(redis.utils.Databases.FLAGS)
|
|
14
15
|
await devAppClient.init()
|
|
15
16
|
await debounceClient.init()
|
|
16
17
|
await flagClient.init()
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
export async function shutdown() {
|
|
20
21
|
if (devAppClient) await devAppClient.finish()
|
|
21
22
|
if (debounceClient) await debounceClient.finish()
|
|
22
23
|
if (flagClient) await flagClient.finish()
|
|
23
24
|
console.log("Redis shutdown")
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
export async function doesUserHaveLock(devAppId: string, user: ContextUser) {
|
|
27
28
|
const value = await devAppClient.get(devAppId)
|
|
28
29
|
if (!value) {
|
|
29
30
|
return true
|
|
30
31
|
}
|
|
31
32
|
// make sure both IDs are global
|
|
32
33
|
const expected = getGlobalIDFromUserMetadataID(value._id)
|
|
33
|
-
const userId = getGlobalIDFromUserMetadataID(user._id)
|
|
34
|
+
const userId = getGlobalIDFromUserMetadataID(user._id!)
|
|
34
35
|
return expected === userId
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
export async function getLocksById(appIds: string[]) {
|
|
38
39
|
return await devAppClient.bulkGet(appIds)
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
export async function updateLock(devAppId: string, user: ContextUser) {
|
|
42
43
|
// make sure always global user ID
|
|
43
|
-
const globalId = getGlobalIDFromUserMetadataID(user._id)
|
|
44
|
+
const globalId = getGlobalIDFromUserMetadataID(user._id!)
|
|
44
45
|
const inputUser = {
|
|
45
46
|
...user,
|
|
46
47
|
userId: globalId,
|
|
@@ -51,35 +52,35 @@ exports.updateLock = async (devAppId, user) => {
|
|
|
51
52
|
await devAppClient.store(devAppId, inputUser, APP_DEV_LOCK_SECONDS)
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
export async function clearLock(devAppId: string, user: ContextUser) {
|
|
55
56
|
const value = await devAppClient.get(devAppId)
|
|
56
57
|
if (!value) {
|
|
57
58
|
return
|
|
58
59
|
}
|
|
59
|
-
const userId = getGlobalIDFromUserMetadataID(user._id)
|
|
60
|
+
const userId = getGlobalIDFromUserMetadataID(user._id!)
|
|
60
61
|
if (value._id !== userId) {
|
|
61
62
|
throw "User does not hold lock, cannot clear it."
|
|
62
63
|
}
|
|
63
64
|
await devAppClient.delete(devAppId)
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
export async function checkDebounce(id: string) {
|
|
67
68
|
return debounceClient.get(id)
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
export async function setDebounce(id: string, seconds: number) {
|
|
71
72
|
await debounceClient.store(id, "debouncing", seconds)
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
export async function setTestFlag(id: string) {
|
|
75
76
|
await flagClient.store(id, { testing: true }, AUTOMATION_TEST_FLAG_SECONDS)
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
export async function checkTestFlag(id: string) {
|
|
79
80
|
const flag = await flagClient.get(id)
|
|
80
81
|
return !!(flag && flag.testing)
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
|
|
84
|
+
export async function clearTestFlag(id: string) {
|
|
84
85
|
await devAppClient.delete(id)
|
|
85
86
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createRoutingView } from "../../db/views/staticViews"
|
|
2
|
+
import { ViewName, getQueryIndex, UNICODE_MAX } from "../../db/utils"
|
|
3
|
+
import { context } from "@budibase/backend-core"
|
|
4
|
+
import { ScreenRouting } from "@budibase/types"
|
|
5
|
+
|
|
6
|
+
type ScreenRoutesView = {
|
|
7
|
+
id: string
|
|
8
|
+
routing: ScreenRouting
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function getRoutingInfo(): Promise<ScreenRoutesView[]> {
|
|
12
|
+
const db = context.getAppDB()
|
|
13
|
+
try {
|
|
14
|
+
const allRouting = await db.query<ScreenRoutesView>(
|
|
15
|
+
getQueryIndex(ViewName.ROUTING),
|
|
16
|
+
{
|
|
17
|
+
startkey: "",
|
|
18
|
+
endkey: UNICODE_MAX,
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
return allRouting.rows.map(row => row.value as ScreenRoutesView)
|
|
22
|
+
} catch (err: any) {
|
|
23
|
+
// check if the view doesn't exist, it should for all new instances
|
|
24
|
+
/* istanbul ignore next */
|
|
25
|
+
if (err != null && err.name === "not_found") {
|
|
26
|
+
await createRoutingView()
|
|
27
|
+
return getRoutingInfo()
|
|
28
|
+
} else {
|
|
29
|
+
throw err
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,129 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
import linkRows from "../../db/linkedRows"
|
|
2
|
+
import { FieldTypes, AutoFieldSubTypes } from "../../constants"
|
|
3
|
+
import { attachmentsRelativeURL } from "../index"
|
|
4
|
+
import { processFormulas, fixAutoColumnSubType } from "./utils"
|
|
5
|
+
import { ObjectStoreBuckets } from "../../constants"
|
|
6
|
+
import { context, db as dbCore, objectStore } from "@budibase/backend-core"
|
|
7
|
+
import { InternalTables } from "../../db/utils"
|
|
8
|
+
import { TYPE_TRANSFORM_MAP } from "./map"
|
|
9
|
+
import { Row, User, Table } from "@budibase/types"
|
|
2
10
|
const { cloneDeep } = require("lodash/fp")
|
|
3
|
-
|
|
4
|
-
const { attachmentsRelativeURL } = require("../index")
|
|
5
|
-
const { processFormulas, fixAutoColumnSubType } = require("./utils")
|
|
6
|
-
const { deleteFiles } = require("../../utilities/fileSystem/utilities")
|
|
7
|
-
const { ObjectStoreBuckets } = require("../../constants")
|
|
8
|
-
const {
|
|
9
|
-
isProdAppID,
|
|
10
|
-
getProdAppID,
|
|
11
|
-
dbExists,
|
|
12
|
-
} = require("@budibase/backend-core/db")
|
|
13
|
-
const { getAppId } = require("@budibase/backend-core/context")
|
|
14
|
-
const { InternalTables } = require("../../db/utils")
|
|
11
|
+
export * from "./utils"
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* A map of how we convert various properties in rows to each other based on the row type.
|
|
20
|
-
*/
|
|
21
|
-
const TYPE_TRANSFORM_MAP = {
|
|
22
|
-
[FieldTypes.LINK]: {
|
|
23
|
-
"": [],
|
|
24
|
-
[null]: [],
|
|
25
|
-
[undefined]: undefined,
|
|
26
|
-
parse: link => {
|
|
27
|
-
if (Array.isArray(link) && typeof link[0] === "object") {
|
|
28
|
-
return link.map(el => (el && el._id ? el._id : el))
|
|
29
|
-
}
|
|
30
|
-
if (typeof link === "string") {
|
|
31
|
-
return [link]
|
|
32
|
-
}
|
|
33
|
-
return link
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
[FieldTypes.OPTIONS]: {
|
|
37
|
-
"": null,
|
|
38
|
-
[null]: null,
|
|
39
|
-
[undefined]: undefined,
|
|
40
|
-
},
|
|
41
|
-
[FieldTypes.ARRAY]: {
|
|
42
|
-
"": [],
|
|
43
|
-
[null]: [],
|
|
44
|
-
[undefined]: undefined,
|
|
45
|
-
},
|
|
46
|
-
[FieldTypes.STRING]: {
|
|
47
|
-
"": "",
|
|
48
|
-
[null]: "",
|
|
49
|
-
[undefined]: undefined,
|
|
50
|
-
},
|
|
51
|
-
[FieldTypes.BARCODEQR]: {
|
|
52
|
-
"": "",
|
|
53
|
-
[null]: "",
|
|
54
|
-
[undefined]: undefined,
|
|
55
|
-
},
|
|
56
|
-
[FieldTypes.FORMULA]: {
|
|
57
|
-
"": "",
|
|
58
|
-
[null]: "",
|
|
59
|
-
[undefined]: undefined,
|
|
60
|
-
},
|
|
61
|
-
[FieldTypes.LONGFORM]: {
|
|
62
|
-
"": "",
|
|
63
|
-
[null]: "",
|
|
64
|
-
[undefined]: undefined,
|
|
65
|
-
},
|
|
66
|
-
[FieldTypes.NUMBER]: {
|
|
67
|
-
"": null,
|
|
68
|
-
[null]: null,
|
|
69
|
-
[undefined]: undefined,
|
|
70
|
-
parse: n => parseFloat(n),
|
|
71
|
-
},
|
|
72
|
-
[FieldTypes.DATETIME]: {
|
|
73
|
-
"": null,
|
|
74
|
-
[undefined]: undefined,
|
|
75
|
-
[null]: null,
|
|
76
|
-
parse: date => {
|
|
77
|
-
if (date instanceof Date) {
|
|
78
|
-
return date.toISOString()
|
|
79
|
-
}
|
|
80
|
-
return date
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
[FieldTypes.ATTACHMENT]: {
|
|
84
|
-
"": [],
|
|
85
|
-
[null]: [],
|
|
86
|
-
[undefined]: undefined,
|
|
87
|
-
},
|
|
88
|
-
[FieldTypes.BOOLEAN]: {
|
|
89
|
-
"": null,
|
|
90
|
-
[null]: null,
|
|
91
|
-
[undefined]: undefined,
|
|
92
|
-
true: true,
|
|
93
|
-
false: false,
|
|
94
|
-
},
|
|
95
|
-
[FieldTypes.AUTO]: {
|
|
96
|
-
parse: () => undefined,
|
|
97
|
-
},
|
|
98
|
-
[FieldTypes.JSON]: {
|
|
99
|
-
parse: input => {
|
|
100
|
-
try {
|
|
101
|
-
if (input === "") {
|
|
102
|
-
return undefined
|
|
103
|
-
}
|
|
104
|
-
return JSON.parse(input)
|
|
105
|
-
} catch (err) {
|
|
106
|
-
return input
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
},
|
|
13
|
+
type AutoColumnProcessingOpts = {
|
|
14
|
+
reprocessing?: boolean
|
|
15
|
+
noAutoRelationships?: boolean
|
|
110
16
|
}
|
|
111
17
|
|
|
18
|
+
const BASE_AUTO_ID = 1
|
|
19
|
+
|
|
112
20
|
/**
|
|
113
21
|
* Given the old state of the row and the new one after an update, this will
|
|
114
22
|
* find the keys that have been removed in the updated row.
|
|
115
23
|
*/
|
|
116
|
-
function getRemovedAttachmentKeys(
|
|
24
|
+
function getRemovedAttachmentKeys(
|
|
25
|
+
oldRow: Row,
|
|
26
|
+
row: Row,
|
|
27
|
+
attachmentKey: string
|
|
28
|
+
) {
|
|
117
29
|
if (!oldRow[attachmentKey]) {
|
|
118
30
|
return []
|
|
119
31
|
}
|
|
120
|
-
const oldKeys = oldRow[attachmentKey].map(attachment => attachment.key)
|
|
32
|
+
const oldKeys = oldRow[attachmentKey].map((attachment: any) => attachment.key)
|
|
121
33
|
// no attachments in new row, all removed
|
|
122
34
|
if (!row[attachmentKey]) {
|
|
123
35
|
return oldKeys
|
|
124
36
|
}
|
|
125
|
-
const newKeys = row[attachmentKey].map(attachment => attachment.key)
|
|
126
|
-
return oldKeys.filter(key => newKeys.indexOf(key) === -1)
|
|
37
|
+
const newKeys = row[attachmentKey].map((attachment: any) => attachment.key)
|
|
38
|
+
return oldKeys.filter((key: any) => newKeys.indexOf(key) === -1)
|
|
127
39
|
}
|
|
128
40
|
|
|
129
41
|
/**
|
|
@@ -136,11 +48,11 @@ function getRemovedAttachmentKeys(oldRow, row, attachmentKey) {
|
|
|
136
48
|
* @returns {{row: Object, table: Object}} The updated row and table, the table may need to be updated
|
|
137
49
|
* for automatic ID purposes.
|
|
138
50
|
*/
|
|
139
|
-
function processAutoColumn(
|
|
140
|
-
user,
|
|
141
|
-
table,
|
|
142
|
-
row,
|
|
143
|
-
opts
|
|
51
|
+
export function processAutoColumn(
|
|
52
|
+
user: User | null,
|
|
53
|
+
table: Table,
|
|
54
|
+
row: Row,
|
|
55
|
+
opts?: AutoColumnProcessingOpts
|
|
144
56
|
) {
|
|
145
57
|
let noUser = !user || !user.userId
|
|
146
58
|
let isUserTable = table._id === InternalTables.USER_METADATA
|
|
@@ -149,7 +61,7 @@ function processAutoColumn(
|
|
|
149
61
|
const creating = !row._rev
|
|
150
62
|
// check its not user table, or whether any of the processing options have been disabled
|
|
151
63
|
const shouldUpdateUserFields =
|
|
152
|
-
!isUserTable && !opts
|
|
64
|
+
!isUserTable && !opts?.reprocessing && !opts?.noAutoRelationships && !noUser
|
|
153
65
|
for (let [key, schema] of Object.entries(table.schema)) {
|
|
154
66
|
if (!schema.autocolumn) {
|
|
155
67
|
continue
|
|
@@ -159,7 +71,7 @@ function processAutoColumn(
|
|
|
159
71
|
}
|
|
160
72
|
switch (schema.subtype) {
|
|
161
73
|
case AutoFieldSubTypes.CREATED_BY:
|
|
162
|
-
if (creating && shouldUpdateUserFields) {
|
|
74
|
+
if (creating && shouldUpdateUserFields && user) {
|
|
163
75
|
row[key] = [user.userId]
|
|
164
76
|
}
|
|
165
77
|
break
|
|
@@ -169,7 +81,7 @@ function processAutoColumn(
|
|
|
169
81
|
}
|
|
170
82
|
break
|
|
171
83
|
case AutoFieldSubTypes.UPDATED_BY:
|
|
172
|
-
if (shouldUpdateUserFields) {
|
|
84
|
+
if (shouldUpdateUserFields && user) {
|
|
173
85
|
row[key] = [user.userId]
|
|
174
86
|
}
|
|
175
87
|
break
|
|
@@ -186,9 +98,6 @@ function processAutoColumn(
|
|
|
186
98
|
}
|
|
187
99
|
return { table, row }
|
|
188
100
|
}
|
|
189
|
-
exports.processAutoColumn = processAutoColumn
|
|
190
|
-
exports.fixAutoColumnSubType = fixAutoColumnSubType
|
|
191
|
-
exports.processFormulas = processFormulas
|
|
192
101
|
|
|
193
102
|
/**
|
|
194
103
|
* This will coerce a value to the correct types based on the type transform map
|
|
@@ -196,15 +105,17 @@ exports.processFormulas = processFormulas
|
|
|
196
105
|
* @param {object} type The type fo coerce to
|
|
197
106
|
* @returns {object} The coerced value
|
|
198
107
|
*/
|
|
199
|
-
|
|
108
|
+
export function coerce(row: any, type: any) {
|
|
200
109
|
// no coercion specified for type, skip it
|
|
201
110
|
if (!TYPE_TRANSFORM_MAP[type]) {
|
|
202
111
|
return row
|
|
203
112
|
}
|
|
204
113
|
// eslint-disable-next-line no-prototype-builtins
|
|
205
114
|
if (TYPE_TRANSFORM_MAP[type].hasOwnProperty(row)) {
|
|
115
|
+
// @ts-ignore
|
|
206
116
|
return TYPE_TRANSFORM_MAP[type][row]
|
|
207
117
|
} else if (TYPE_TRANSFORM_MAP[type].parse) {
|
|
118
|
+
// @ts-ignore
|
|
208
119
|
return TYPE_TRANSFORM_MAP[type].parse(row)
|
|
209
120
|
}
|
|
210
121
|
|
|
@@ -220,12 +131,12 @@ exports.coerce = (row, type) => {
|
|
|
220
131
|
* @param {object} opts some input processing options (like disabling auto-column relationships).
|
|
221
132
|
* @returns {object} the row which has been prepared to be written to the DB.
|
|
222
133
|
*/
|
|
223
|
-
|
|
224
|
-
user
|
|
225
|
-
table,
|
|
226
|
-
row,
|
|
227
|
-
opts
|
|
228
|
-
)
|
|
134
|
+
export function inputProcessing(
|
|
135
|
+
user: User,
|
|
136
|
+
table: Table,
|
|
137
|
+
row: Row,
|
|
138
|
+
opts: AutoColumnProcessingOpts
|
|
139
|
+
) {
|
|
229
140
|
let clonedRow = cloneDeep(row)
|
|
230
141
|
// need to copy the table so it can be differenced on way out
|
|
231
142
|
const copiedTable = cloneDeep(table)
|
|
@@ -245,7 +156,7 @@ exports.inputProcessing = (
|
|
|
245
156
|
}
|
|
246
157
|
// otherwise coerce what is there to correct types
|
|
247
158
|
else {
|
|
248
|
-
clonedRow[key] =
|
|
159
|
+
clonedRow[key] = coerce(value, field.type)
|
|
249
160
|
}
|
|
250
161
|
}
|
|
251
162
|
|
|
@@ -267,7 +178,11 @@ exports.inputProcessing = (
|
|
|
267
178
|
* @param {object} opts used to set some options for the output, such as disabling relationship squashing.
|
|
268
179
|
* @returns {object[]|object} the enriched rows will be returned.
|
|
269
180
|
*/
|
|
270
|
-
|
|
181
|
+
export async function outputProcessing(
|
|
182
|
+
table: Table,
|
|
183
|
+
rows: Row[] | Row,
|
|
184
|
+
opts = { squash: true }
|
|
185
|
+
) {
|
|
271
186
|
let wasArray = true
|
|
272
187
|
if (!(rows instanceof Array)) {
|
|
273
188
|
rows = [rows]
|
|
@@ -286,7 +201,7 @@ exports.outputProcessing = async (table, rows, opts = { squash: true }) => {
|
|
|
286
201
|
if (row[property] == null || !Array.isArray(row[property])) {
|
|
287
202
|
continue
|
|
288
203
|
}
|
|
289
|
-
row[property].forEach(attachment => {
|
|
204
|
+
row[property].forEach((attachment: any) => {
|
|
290
205
|
attachment.url = attachmentsRelativeURL(attachment.key)
|
|
291
206
|
})
|
|
292
207
|
}
|
|
@@ -308,20 +223,28 @@ exports.outputProcessing = async (table, rows, opts = { squash: true }) => {
|
|
|
308
223
|
* deleted attachment columns.
|
|
309
224
|
* @return {Promise<void>} When all attachments have been removed this will return.
|
|
310
225
|
*/
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
226
|
+
export async function cleanupAttachments(
|
|
227
|
+
table: Table,
|
|
228
|
+
{
|
|
229
|
+
row,
|
|
230
|
+
rows,
|
|
231
|
+
oldRow,
|
|
232
|
+
oldTable,
|
|
233
|
+
}: { row?: Row; rows?: Row[]; oldRow?: Row; oldTable?: Table }
|
|
234
|
+
): Promise<any> {
|
|
235
|
+
const appId = context.getAppId()
|
|
236
|
+
if (!dbCore.isProdAppID(appId)) {
|
|
237
|
+
const prodAppId = dbCore.getProdAppID(appId!)
|
|
315
238
|
// if prod exists, then don't allow deleting
|
|
316
|
-
const exists = await dbExists(prodAppId)
|
|
239
|
+
const exists = await dbCore.dbExists(prodAppId)
|
|
317
240
|
if (exists) {
|
|
318
241
|
return
|
|
319
242
|
}
|
|
320
243
|
}
|
|
321
|
-
let files = []
|
|
322
|
-
function addFiles(row, key) {
|
|
244
|
+
let files: string[] = []
|
|
245
|
+
function addFiles(row: Row, key: string) {
|
|
323
246
|
if (row[key]) {
|
|
324
|
-
files = files.concat(row[key].map(attachment => attachment.key))
|
|
247
|
+
files = files.concat(row[key].map((attachment: any) => attachment.key))
|
|
325
248
|
}
|
|
326
249
|
}
|
|
327
250
|
const schemaToUse = oldTable ? oldTable.schema : table.schema
|
|
@@ -330,7 +253,7 @@ exports.cleanupAttachments = async (table, { row, rows, oldRow, oldTable }) => {
|
|
|
330
253
|
continue
|
|
331
254
|
}
|
|
332
255
|
// old table had this column, new table doesn't - delete it
|
|
333
|
-
if (oldTable && !table.schema[key]) {
|
|
256
|
+
if (rows && oldTable && !table.schema[key]) {
|
|
334
257
|
rows.forEach(row => addFiles(row, key))
|
|
335
258
|
} else if (oldRow && row) {
|
|
336
259
|
// if updating, need to manage the differences
|
|
@@ -342,6 +265,6 @@ exports.cleanupAttachments = async (table, { row, rows, oldRow, oldTable }) => {
|
|
|
342
265
|
}
|
|
343
266
|
}
|
|
344
267
|
if (files.length > 0) {
|
|
345
|
-
return deleteFiles(ObjectStoreBuckets.APPS, files)
|
|
268
|
+
return objectStore.deleteFiles(ObjectStoreBuckets.APPS, files)
|
|
346
269
|
}
|
|
347
270
|
}
|