@budibase/server 2.1.32-alpha.5 → 2.1.32-alpha.7
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.192baaa3.js → index.e0fdcf54.js} +184 -184
- 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 +16 -16
- 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 +5519 -5768
- 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,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { db as dbCore, tenancy } from "@budibase/backend-core"
|
|
2
|
+
import { BBContext, Document } from "@budibase/types"
|
|
3
3
|
|
|
4
|
-
const KEYS_DOC = StaticDatabases.GLOBAL.docs.apiKeys
|
|
4
|
+
const KEYS_DOC = dbCore.StaticDatabases.GLOBAL.docs.apiKeys
|
|
5
5
|
|
|
6
6
|
async function getBuilderMainDoc() {
|
|
7
|
-
const db = getGlobalDB()
|
|
7
|
+
const db = tenancy.getGlobalDB()
|
|
8
8
|
try {
|
|
9
9
|
return await db.get(KEYS_DOC)
|
|
10
10
|
} catch (err) {
|
|
@@ -15,24 +15,24 @@ async function getBuilderMainDoc() {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async function setBuilderMainDoc(doc) {
|
|
18
|
+
async function setBuilderMainDoc(doc: Document) {
|
|
19
19
|
// make sure to override the ID
|
|
20
20
|
doc._id = KEYS_DOC
|
|
21
|
-
const db = getGlobalDB()
|
|
21
|
+
const db = tenancy.getGlobalDB()
|
|
22
22
|
return db.put(doc)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
export async function fetch(ctx: BBContext) {
|
|
26
26
|
try {
|
|
27
27
|
const mainDoc = await getBuilderMainDoc()
|
|
28
28
|
ctx.body = mainDoc.apiKeys ? mainDoc.apiKeys : {}
|
|
29
|
-
} catch (err) {
|
|
29
|
+
} catch (err: any) {
|
|
30
30
|
/* istanbul ignore next */
|
|
31
31
|
ctx.throw(400, err)
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
export async function update(ctx: BBContext) {
|
|
36
36
|
const key = ctx.params.key
|
|
37
37
|
const value = ctx.request.body.value
|
|
38
38
|
|
|
@@ -47,7 +47,7 @@ exports.update = async function (ctx) {
|
|
|
47
47
|
_id: resp.id,
|
|
48
48
|
_rev: resp.rev,
|
|
49
49
|
}
|
|
50
|
-
} catch (err) {
|
|
50
|
+
} catch (err: any) {
|
|
51
51
|
/* istanbul ignore next */
|
|
52
52
|
ctx.throw(400, err)
|
|
53
53
|
}
|
|
@@ -3,7 +3,7 @@ import { InternalTables } from "../../db/utils"
|
|
|
3
3
|
import { getFullUser } from "../../utilities/users"
|
|
4
4
|
import { roles, context } from "@budibase/backend-core"
|
|
5
5
|
import { groups } from "@budibase/pro"
|
|
6
|
-
import { ContextUser, User } from "@budibase/types"
|
|
6
|
+
import { ContextUser, User, Row } from "@budibase/types"
|
|
7
7
|
|
|
8
8
|
const PUBLIC_ROLE = roles.BUILTIN_ROLE_IDS.PUBLIC
|
|
9
9
|
|
|
@@ -43,7 +43,7 @@ export async function fetchSelf(ctx: any) {
|
|
|
43
43
|
try {
|
|
44
44
|
const userTable = await db.get(InternalTables.USER_METADATA)
|
|
45
45
|
// specifically needs to make sure is enriched
|
|
46
|
-
ctx.body = await outputProcessing(userTable, user)
|
|
46
|
+
ctx.body = await outputProcessing(userTable, user as Row)
|
|
47
47
|
} catch (err: any) {
|
|
48
48
|
let response
|
|
49
49
|
// user didn't exist in app, don't pretend they do
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import actions from "../../automations/actions"
|
|
2
|
+
import triggers from "../../automations/triggers"
|
|
3
|
+
import {
|
|
4
4
|
getAutomationParams,
|
|
5
5
|
generateAutomationID,
|
|
6
6
|
DocumentType,
|
|
7
|
-
}
|
|
8
|
-
|
|
7
|
+
} from "../../db/utils"
|
|
8
|
+
import {
|
|
9
9
|
checkForWebhooks,
|
|
10
10
|
updateTestHistory,
|
|
11
11
|
removeDeprecated,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
doInAppContext,
|
|
20
|
-
} = require("@budibase/backend-core/context")
|
|
21
|
-
const { events } = require("@budibase/backend-core")
|
|
22
|
-
const { app } = require("@budibase/backend-core/cache")
|
|
23
|
-
const { automations } = require("@budibase/pro")
|
|
12
|
+
} from "../../automations/utils"
|
|
13
|
+
import { deleteEntityMetadata } from "../../utilities"
|
|
14
|
+
import { MetadataTypes } from "../../constants"
|
|
15
|
+
import { setTestFlag, clearTestFlag } from "../../utilities/redis"
|
|
16
|
+
import { context, cache, events } from "@budibase/backend-core"
|
|
17
|
+
import { automations } from "@budibase/pro"
|
|
18
|
+
import { Automation, BBContext } from "@budibase/types"
|
|
24
19
|
|
|
25
20
|
const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS)
|
|
26
21
|
const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS)
|
|
@@ -31,7 +26,7 @@ const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS)
|
|
|
31
26
|
* *
|
|
32
27
|
*************************/
|
|
33
28
|
|
|
34
|
-
async function cleanupAutomationMetadata(automationId) {
|
|
29
|
+
async function cleanupAutomationMetadata(automationId: string) {
|
|
35
30
|
await deleteEntityMetadata(MetadataTypes.AUTOMATION_TEST_INPUT, automationId)
|
|
36
31
|
await deleteEntityMetadata(
|
|
37
32
|
MetadataTypes.AUTOMATION_TEST_HISTORY,
|
|
@@ -39,7 +34,7 @@ async function cleanupAutomationMetadata(automationId) {
|
|
|
39
34
|
)
|
|
40
35
|
}
|
|
41
36
|
|
|
42
|
-
function cleanAutomationInputs(automation) {
|
|
37
|
+
function cleanAutomationInputs(automation: Automation) {
|
|
43
38
|
if (automation == null) {
|
|
44
39
|
return automation
|
|
45
40
|
}
|
|
@@ -63,14 +58,14 @@ function cleanAutomationInputs(automation) {
|
|
|
63
58
|
return automation
|
|
64
59
|
}
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
const db = getAppDB()
|
|
61
|
+
export async function create(ctx: BBContext) {
|
|
62
|
+
const db = context.getAppDB()
|
|
68
63
|
let automation = ctx.request.body
|
|
69
64
|
automation.appId = ctx.appId
|
|
70
65
|
|
|
71
66
|
// call through to update if already exists
|
|
72
67
|
if (automation._id && automation._rev) {
|
|
73
|
-
return
|
|
68
|
+
return update(ctx)
|
|
74
69
|
}
|
|
75
70
|
|
|
76
71
|
automation._id = generateAutomationID()
|
|
@@ -97,17 +92,23 @@ exports.create = async function (ctx) {
|
|
|
97
92
|
}
|
|
98
93
|
}
|
|
99
94
|
|
|
100
|
-
|
|
95
|
+
export function getNewSteps(oldAutomation: Automation, automation: Automation) {
|
|
101
96
|
const oldStepIds = oldAutomation.definition.steps.map(s => s.id)
|
|
102
97
|
return automation.definition.steps.filter(s => !oldStepIds.includes(s.id))
|
|
103
98
|
}
|
|
104
99
|
|
|
105
|
-
|
|
100
|
+
export function getDeletedSteps(
|
|
101
|
+
oldAutomation: Automation,
|
|
102
|
+
automation: Automation
|
|
103
|
+
) {
|
|
106
104
|
const stepIds = automation.definition.steps.map(s => s.id)
|
|
107
105
|
return oldAutomation.definition.steps.filter(s => !stepIds.includes(s.id))
|
|
108
106
|
}
|
|
109
107
|
|
|
110
|
-
|
|
108
|
+
export async function handleStepEvents(
|
|
109
|
+
oldAutomation: Automation,
|
|
110
|
+
automation: Automation
|
|
111
|
+
) {
|
|
111
112
|
// new steps
|
|
112
113
|
const newSteps = getNewSteps(oldAutomation, automation)
|
|
113
114
|
for (let step of newSteps) {
|
|
@@ -121,8 +122,8 @@ const handleStepEvents = async (oldAutomation, automation) => {
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
const db = getAppDB()
|
|
125
|
+
export async function update(ctx: BBContext) {
|
|
126
|
+
const db = context.getAppDB()
|
|
126
127
|
let automation = ctx.request.body
|
|
127
128
|
automation.appId = ctx.appId
|
|
128
129
|
const oldAutomation = await db.get(automation._id)
|
|
@@ -146,9 +147,8 @@ exports.update = async function (ctx) {
|
|
|
146
147
|
if (oldAutoTrigger && oldAutoTrigger.id !== newAutoTrigger.id) {
|
|
147
148
|
await events.automation.triggerUpdated(automation)
|
|
148
149
|
await deleteEntityMetadata(
|
|
149
|
-
ctx.appId,
|
|
150
150
|
MetadataTypes.AUTOMATION_TEST_INPUT,
|
|
151
|
-
automation._id
|
|
151
|
+
automation._id!
|
|
152
152
|
)
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -165,8 +165,8 @@ exports.update = async function (ctx) {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
const db = getAppDB()
|
|
168
|
+
export async function fetch(ctx: BBContext) {
|
|
169
|
+
const db = context.getAppDB()
|
|
170
170
|
const response = await db.allDocs(
|
|
171
171
|
getAutomationParams(null, {
|
|
172
172
|
include_docs: true,
|
|
@@ -175,13 +175,13 @@ exports.fetch = async function (ctx) {
|
|
|
175
175
|
ctx.body = response.rows.map(row => row.doc)
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
const db = getAppDB()
|
|
178
|
+
export async function find(ctx: BBContext) {
|
|
179
|
+
const db = context.getAppDB()
|
|
180
180
|
ctx.body = await db.get(ctx.params.id)
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
const db = getAppDB()
|
|
183
|
+
export async function destroy(ctx: BBContext) {
|
|
184
|
+
const db = context.getAppDB()
|
|
185
185
|
const automationId = ctx.params.id
|
|
186
186
|
const oldAutomation = await db.get(automationId)
|
|
187
187
|
await checkForWebhooks({
|
|
@@ -193,14 +193,14 @@ exports.destroy = async function (ctx) {
|
|
|
193
193
|
await events.automation.deleted(oldAutomation)
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
export async function logSearch(ctx: BBContext) {
|
|
197
197
|
ctx.body = await automations.logs.logSearch(ctx.request.body)
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
export async function clearLogError(ctx: BBContext) {
|
|
201
201
|
const { automationId, appId } = ctx.request.body
|
|
202
|
-
await doInAppContext(appId, async () => {
|
|
203
|
-
const db = getProdAppDB()
|
|
202
|
+
await context.doInAppContext(appId, async () => {
|
|
203
|
+
const db = context.getProdAppDB()
|
|
204
204
|
const metadata = await db.get(DocumentType.APP_METADATA)
|
|
205
205
|
if (!automationId) {
|
|
206
206
|
delete metadata.automationErrors
|
|
@@ -211,20 +211,20 @@ exports.clearLogError = async function (ctx) {
|
|
|
211
211
|
delete metadata.automationErrors[automationId]
|
|
212
212
|
}
|
|
213
213
|
await db.put(metadata)
|
|
214
|
-
await app.invalidateAppMetadata(metadata.appId, metadata)
|
|
214
|
+
await cache.app.invalidateAppMetadata(metadata.appId, metadata)
|
|
215
215
|
ctx.body = { message: `Error logs cleared.` }
|
|
216
216
|
})
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
export async function getActionList(ctx: BBContext) {
|
|
220
220
|
ctx.body = ACTION_DEFS
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
export async function getTriggerList(ctx: BBContext) {
|
|
224
224
|
ctx.body = TRIGGER_DEFS
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
export async function getDefinitionList(ctx: BBContext) {
|
|
228
228
|
ctx.body = {
|
|
229
229
|
trigger: TRIGGER_DEFS,
|
|
230
230
|
action: ACTION_DEFS,
|
|
@@ -237,8 +237,8 @@ module.exports.getDefinitionList = async function (ctx) {
|
|
|
237
237
|
* *
|
|
238
238
|
*********************/
|
|
239
239
|
|
|
240
|
-
|
|
241
|
-
const db = getAppDB()
|
|
240
|
+
export async function trigger(ctx: BBContext) {
|
|
241
|
+
const db = context.getAppDB()
|
|
242
242
|
let automation = await db.get(ctx.params.id)
|
|
243
243
|
await triggers.externalTrigger(automation, {
|
|
244
244
|
...ctx.request.body,
|
|
@@ -250,7 +250,7 @@ exports.trigger = async function (ctx) {
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
function prepareTestInput(input) {
|
|
253
|
+
function prepareTestInput(input: any) {
|
|
254
254
|
// prepare the test parameters
|
|
255
255
|
if (input.id && input.row) {
|
|
256
256
|
input.row._id = input.id
|
|
@@ -261,8 +261,8 @@ function prepareTestInput(input) {
|
|
|
261
261
|
return input
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
|
|
265
|
-
const db = getAppDB()
|
|
264
|
+
export async function test(ctx: BBContext) {
|
|
265
|
+
const db = context.getAppDB()
|
|
266
266
|
let automation = await db.get(ctx.params.id)
|
|
267
267
|
await setTestFlag(automation._id)
|
|
268
268
|
const testInput = prepareTestInput(ctx.request.body)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import env from "../../environment"
|
|
2
|
+
import { db as dbCore, tenancy } from "@budibase/backend-core"
|
|
3
|
+
import { streamFile } from "../../utilities/fileSystem"
|
|
4
|
+
import { stringToReadStream } from "../../utilities"
|
|
5
|
+
import { getDocParams, DocumentType, isDevAppID } from "../../db/utils"
|
|
6
|
+
import { create } from "./application"
|
|
7
|
+
import { join } from "path"
|
|
8
|
+
import { App, BBContext, Database } from "@budibase/types"
|
|
9
|
+
import sdk from "../../sdk"
|
|
10
10
|
|
|
11
|
-
async function createApp(appName, appDirectory) {
|
|
11
|
+
async function createApp(appName: string, appDirectory: string) {
|
|
12
12
|
const ctx = {
|
|
13
13
|
request: {
|
|
14
14
|
body: {
|
|
@@ -25,7 +25,7 @@ async function createApp(appName, appDirectory) {
|
|
|
25
25
|
return create(ctx)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async function getAllDocType(db, docType) {
|
|
28
|
+
async function getAllDocType(db: Database, docType: string) {
|
|
29
29
|
const response = await db.allDocs(
|
|
30
30
|
getDocParams(docType, null, {
|
|
31
31
|
include_docs: true,
|
|
@@ -34,19 +34,19 @@ async function getAllDocType(db, docType) {
|
|
|
34
34
|
return response.rows.map(row => row.doc)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
export async function exportApps(ctx: BBContext) {
|
|
38
38
|
if (env.SELF_HOSTED || !env.MULTI_TENANCY) {
|
|
39
39
|
ctx.throw(400, "Exporting only allowed in multi-tenant cloud environments.")
|
|
40
40
|
}
|
|
41
|
-
const apps = await getAllApps({ all: true })
|
|
42
|
-
const globalDBString = await sdk.backups.exportDB(getGlobalDBName(), {
|
|
43
|
-
filter: doc => !doc._id.startsWith(DocumentType.USER),
|
|
41
|
+
const apps = (await dbCore.getAllApps({ all: true })) as App[]
|
|
42
|
+
const globalDBString = await sdk.backups.exportDB(dbCore.getGlobalDBName(), {
|
|
43
|
+
filter: (doc: any) => !doc._id.startsWith(DocumentType.USER),
|
|
44
44
|
})
|
|
45
45
|
// only export the dev apps as they will be the latest, the user can republish the apps
|
|
46
46
|
// in their self-hosted environment
|
|
47
47
|
let appMetadata = apps
|
|
48
|
-
.filter(app => isDevAppID(app.appId || app._id))
|
|
49
|
-
.map(app => ({ appId: app.appId || app._id
|
|
48
|
+
.filter((app: App) => isDevAppID(app.appId || app._id))
|
|
49
|
+
.map((app: App) => ({ appId: (app.appId || app._id)!, name: app.name }))
|
|
50
50
|
const tmpPath = await sdk.backups.exportMultipleApps(
|
|
51
51
|
appMetadata,
|
|
52
52
|
globalDBString
|
|
@@ -56,25 +56,25 @@ exports.exportApps = async ctx => {
|
|
|
56
56
|
ctx.body = streamFile(tmpPath)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
async function
|
|
59
|
+
async function checkHasBeenImported() {
|
|
60
60
|
if (!env.SELF_HOSTED || env.MULTI_TENANCY) {
|
|
61
61
|
return true
|
|
62
62
|
}
|
|
63
|
-
const apps = await getAllApps({ all: true })
|
|
63
|
+
const apps = await dbCore.getAllApps({ all: true })
|
|
64
64
|
return apps.length !== 0
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
export async function hasBeenImported(ctx: BBContext) {
|
|
68
68
|
ctx.body = {
|
|
69
|
-
imported: await
|
|
69
|
+
imported: await checkHasBeenImported(),
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
export async function importApps(ctx: BBContext) {
|
|
74
74
|
if (!env.SELF_HOSTED || env.MULTI_TENANCY) {
|
|
75
75
|
ctx.throw(400, "Importing only allowed in self hosted environments.")
|
|
76
76
|
}
|
|
77
|
-
const beenImported = await
|
|
77
|
+
const beenImported = await checkHasBeenImported()
|
|
78
78
|
if (beenImported || !ctx.request.files || !ctx.request.files.importFile) {
|
|
79
79
|
ctx.throw(
|
|
80
80
|
400,
|
|
@@ -90,7 +90,7 @@ exports.importApps = async ctx => {
|
|
|
90
90
|
const globalDbImport = sdk.backups.getGlobalDBFile(tmpPath)
|
|
91
91
|
const appNames = sdk.backups.getListOfAppsInMulti(tmpPath)
|
|
92
92
|
|
|
93
|
-
const globalDb = getGlobalDB()
|
|
93
|
+
const globalDb = tenancy.getGlobalDB()
|
|
94
94
|
// load the global db first
|
|
95
95
|
await globalDb.load(stringToReadStream(globalDbImport))
|
|
96
96
|
for (let appName of appNames) {
|
|
@@ -2,8 +2,9 @@ import { DocumentType } from "../../db/utils"
|
|
|
2
2
|
import { Plugin } from "@budibase/types"
|
|
3
3
|
import { db as dbCore, context, tenancy } from "@budibase/backend-core"
|
|
4
4
|
import { getComponentLibraryManifest } from "../../utilities/fileSystem"
|
|
5
|
+
import { BBContext } from "@budibase/types"
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
export async function fetchAppComponentDefinitions(ctx: BBContext) {
|
|
7
8
|
try {
|
|
8
9
|
const db = context.getAppDB()
|
|
9
10
|
const app = await db.get(DocumentType.APP_METADATA)
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
generateDatasourceID,
|
|
3
3
|
getDatasourceParams,
|
|
4
4
|
getQueryParams,
|
|
5
5
|
DocumentType,
|
|
6
6
|
BudibaseInternalDB,
|
|
7
7
|
getTableParams,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exports.fetch = async function (ctx) {
|
|
8
|
+
} from "../../db/utils"
|
|
9
|
+
import { destroy as tableDestroy } from "./table/internal"
|
|
10
|
+
import { BuildSchemaErrors, InvalidColumns } from "../../constants"
|
|
11
|
+
import { getIntegration } from "../../integrations"
|
|
12
|
+
import { getDatasourceAndQuery } from "./row/utils"
|
|
13
|
+
import { invalidateDynamicVariables } from "../../threads/utils"
|
|
14
|
+
import { db as dbCore, context, events } from "@budibase/backend-core"
|
|
15
|
+
import { BBContext, Datasource, Row } from "@budibase/types"
|
|
16
|
+
|
|
17
|
+
export async function fetch(ctx: BBContext) {
|
|
19
18
|
// Get internal tables
|
|
20
|
-
const db = getAppDB()
|
|
19
|
+
const db = context.getAppDB()
|
|
21
20
|
const internalTables = await db.allDocs(
|
|
22
21
|
getTableParams(null, {
|
|
23
22
|
include_docs: true,
|
|
24
23
|
})
|
|
25
24
|
)
|
|
26
25
|
|
|
27
|
-
const internal = internalTables.rows.reduce((acc, row) => {
|
|
26
|
+
const internal = internalTables.rows.reduce((acc: any, row: Row) => {
|
|
28
27
|
const sourceId = row.doc.sourceId || "bb_internal"
|
|
29
28
|
acc[sourceId] = acc[sourceId] || []
|
|
30
29
|
acc[sourceId].push(row.doc)
|
|
@@ -60,8 +59,8 @@ exports.fetch = async function (ctx) {
|
|
|
60
59
|
ctx.body = [bbInternalDb, ...datasources]
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
const db = getAppDB()
|
|
62
|
+
export async function buildSchemaFromDb(ctx: BBContext) {
|
|
63
|
+
const db = context.getAppDB()
|
|
65
64
|
const datasource = await db.get(ctx.params.datasourceId)
|
|
66
65
|
const tablesFilter = ctx.request.body.tablesFilter
|
|
67
66
|
|
|
@@ -72,7 +71,9 @@ exports.buildSchemaFromDb = async function (ctx) {
|
|
|
72
71
|
}
|
|
73
72
|
for (let key in tables) {
|
|
74
73
|
if (
|
|
75
|
-
tablesFilter.some(
|
|
74
|
+
tablesFilter.some(
|
|
75
|
+
(filter: any) => filter.toLowerCase() === key.toLowerCase()
|
|
76
|
+
)
|
|
76
77
|
) {
|
|
77
78
|
datasource.entities[key] = tables[key]
|
|
78
79
|
}
|
|
@@ -85,7 +86,7 @@ exports.buildSchemaFromDb = async function (ctx) {
|
|
|
85
86
|
const dbResp = await db.put(datasource)
|
|
86
87
|
datasource._rev = dbResp.rev
|
|
87
88
|
|
|
88
|
-
const response = { datasource }
|
|
89
|
+
const response: any = { datasource }
|
|
89
90
|
if (error) {
|
|
90
91
|
response.error = error
|
|
91
92
|
}
|
|
@@ -95,9 +96,9 @@ exports.buildSchemaFromDb = async function (ctx) {
|
|
|
95
96
|
/**
|
|
96
97
|
* Make sure all datasource entities have a display name selected
|
|
97
98
|
*/
|
|
98
|
-
|
|
99
|
+
function setDefaultDisplayColumns(datasource: Datasource) {
|
|
99
100
|
//
|
|
100
|
-
for (let entity of Object.values(datasource.entities)) {
|
|
101
|
+
for (let entity of Object.values(datasource.entities || {})) {
|
|
101
102
|
if (entity.primaryDisplay) {
|
|
102
103
|
continue
|
|
103
104
|
}
|
|
@@ -113,9 +114,12 @@ const setDefaultDisplayColumns = datasource => {
|
|
|
113
114
|
/**
|
|
114
115
|
* Check for variables that have been updated or removed and invalidate them.
|
|
115
116
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
async function invalidateVariables(
|
|
118
|
+
existingDatasource: Datasource,
|
|
119
|
+
updatedDatasource: Datasource
|
|
120
|
+
) {
|
|
121
|
+
const existingVariables: any = existingDatasource.config?.dynamicVariables
|
|
122
|
+
const updatedVariables: any = updatedDatasource.config?.dynamicVariables
|
|
119
123
|
const toInvalidate = []
|
|
120
124
|
|
|
121
125
|
if (!existingVariables) {
|
|
@@ -127,9 +131,9 @@ const invalidateVariables = async (existingDatasource, updatedDatasource) => {
|
|
|
127
131
|
toInvalidate.push(...existingVariables)
|
|
128
132
|
} else {
|
|
129
133
|
// invaldate changed / removed
|
|
130
|
-
existingVariables.forEach(existing => {
|
|
134
|
+
existingVariables.forEach((existing: any) => {
|
|
131
135
|
const unchanged = updatedVariables.find(
|
|
132
|
-
updated =>
|
|
136
|
+
(updated: any) =>
|
|
133
137
|
existing.name === updated.name &&
|
|
134
138
|
existing.queryId === updated.queryId &&
|
|
135
139
|
existing.value === updated.value
|
|
@@ -142,8 +146,8 @@ const invalidateVariables = async (existingDatasource, updatedDatasource) => {
|
|
|
142
146
|
await invalidateDynamicVariables(toInvalidate)
|
|
143
147
|
}
|
|
144
148
|
|
|
145
|
-
|
|
146
|
-
const db = getAppDB()
|
|
149
|
+
export async function update(ctx: BBContext) {
|
|
150
|
+
const db = context.getAppDB()
|
|
147
151
|
const datasourceId = ctx.params.datasourceId
|
|
148
152
|
let datasource = await db.get(datasourceId)
|
|
149
153
|
const auth = datasource.config.auth
|
|
@@ -171,8 +175,8 @@ exports.update = async function (ctx) {
|
|
|
171
175
|
ctx.body = { datasource }
|
|
172
176
|
}
|
|
173
177
|
|
|
174
|
-
|
|
175
|
-
const db = getAppDB()
|
|
178
|
+
export async function save(ctx: BBContext) {
|
|
179
|
+
const db = context.getAppDB()
|
|
176
180
|
const plus = ctx.request.body.datasource.plus
|
|
177
181
|
const fetchSchema = ctx.request.body.fetchSchema
|
|
178
182
|
|
|
@@ -202,15 +206,15 @@ exports.save = async function (ctx) {
|
|
|
202
206
|
}
|
|
203
207
|
}
|
|
204
208
|
|
|
205
|
-
const response = { datasource }
|
|
209
|
+
const response: any = { datasource }
|
|
206
210
|
if (schemaError) {
|
|
207
211
|
response.error = schemaError
|
|
208
212
|
}
|
|
209
213
|
ctx.body = response
|
|
210
214
|
}
|
|
211
215
|
|
|
212
|
-
|
|
213
|
-
const db = getAppDB()
|
|
216
|
+
async function destroyInternalTablesBySourceId(datasourceId: string) {
|
|
217
|
+
const db = context.getAppDB()
|
|
214
218
|
|
|
215
219
|
// Get all internal tables
|
|
216
220
|
const internalTables = await db.allDocs(
|
|
@@ -220,12 +224,15 @@ const destroyInternalTablesBySourceId = async datasourceId => {
|
|
|
220
224
|
)
|
|
221
225
|
|
|
222
226
|
// Filter by datasource and return the docs.
|
|
223
|
-
const datasourceTableDocs = internalTables.rows.reduce(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
const datasourceTableDocs = internalTables.rows.reduce(
|
|
228
|
+
(acc: any, table: any) => {
|
|
229
|
+
if (table.doc.sourceId == datasourceId) {
|
|
230
|
+
acc.push(table.doc)
|
|
231
|
+
}
|
|
232
|
+
return acc
|
|
233
|
+
},
|
|
234
|
+
[]
|
|
235
|
+
)
|
|
229
236
|
|
|
230
237
|
// Destroy the tables.
|
|
231
238
|
for (const table of datasourceTableDocs) {
|
|
@@ -237,8 +244,8 @@ const destroyInternalTablesBySourceId = async datasourceId => {
|
|
|
237
244
|
}
|
|
238
245
|
}
|
|
239
246
|
|
|
240
|
-
|
|
241
|
-
const db = getAppDB()
|
|
247
|
+
export async function destroy(ctx: BBContext) {
|
|
248
|
+
const db = context.getAppDB()
|
|
242
249
|
const datasourceId = ctx.params.datasourceId
|
|
243
250
|
|
|
244
251
|
const datasource = await db.get(datasourceId)
|
|
@@ -249,7 +256,7 @@ exports.destroy = async function (ctx) {
|
|
|
249
256
|
} else {
|
|
250
257
|
const queries = await db.allDocs(getQueryParams(datasourceId, null))
|
|
251
258
|
await db.bulkDocs(
|
|
252
|
-
queries.rows.map(row => ({
|
|
259
|
+
queries.rows.map((row: any) => ({
|
|
253
260
|
_id: row.id,
|
|
254
261
|
_rev: row.value.rev,
|
|
255
262
|
_deleted: true,
|
|
@@ -265,28 +272,28 @@ exports.destroy = async function (ctx) {
|
|
|
265
272
|
ctx.status = 200
|
|
266
273
|
}
|
|
267
274
|
|
|
268
|
-
|
|
269
|
-
const database = getAppDB()
|
|
275
|
+
export async function find(ctx: BBContext) {
|
|
276
|
+
const database = context.getAppDB()
|
|
270
277
|
ctx.body = await database.get(ctx.params.datasourceId)
|
|
271
278
|
}
|
|
272
279
|
|
|
273
280
|
// dynamic query functionality
|
|
274
|
-
|
|
281
|
+
export async function query(ctx: BBContext) {
|
|
275
282
|
const queryJson = ctx.request.body
|
|
276
283
|
try {
|
|
277
284
|
ctx.body = await getDatasourceAndQuery(queryJson)
|
|
278
|
-
} catch (err) {
|
|
285
|
+
} catch (err: any) {
|
|
279
286
|
ctx.throw(400, err)
|
|
280
287
|
}
|
|
281
288
|
}
|
|
282
289
|
|
|
283
|
-
function getErrorTables(errors, errorType) {
|
|
290
|
+
function getErrorTables(errors: any, errorType: string) {
|
|
284
291
|
return Object.entries(errors)
|
|
285
292
|
.filter(entry => entry[1] === errorType)
|
|
286
293
|
.map(([name]) => name)
|
|
287
294
|
}
|
|
288
295
|
|
|
289
|
-
function updateError(error, newError, tables) {
|
|
296
|
+
function updateError(error: any, newError: any, tables: string[]) {
|
|
290
297
|
if (!error) {
|
|
291
298
|
error = ""
|
|
292
299
|
}
|
|
@@ -297,7 +304,7 @@ function updateError(error, newError, tables) {
|
|
|
297
304
|
return error
|
|
298
305
|
}
|
|
299
306
|
|
|
300
|
-
|
|
307
|
+
async function buildSchemaHelper(datasource: Datasource) {
|
|
301
308
|
const Connector = await getIntegration(datasource.source)
|
|
302
309
|
|
|
303
310
|
// Connect to the DB and build the schema
|