@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
|
@@ -13,28 +13,28 @@ import {
|
|
|
13
13
|
} from "../../../constants"
|
|
14
14
|
import { getViews, saveView } from "../view/utils"
|
|
15
15
|
import viewTemplate from "../view/viewBuilder"
|
|
16
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
17
16
|
import { cloneDeep } from "lodash/fp"
|
|
18
17
|
import { quotas } from "@budibase/pro"
|
|
19
|
-
import { events } from "@budibase/backend-core"
|
|
18
|
+
import { events, context } from "@budibase/backend-core"
|
|
19
|
+
import { Database } from "@budibase/types"
|
|
20
20
|
|
|
21
21
|
export async function clearColumns(table: any, columnNames: any) {
|
|
22
|
-
const db = getAppDB()
|
|
22
|
+
const db: Database = context.getAppDB()
|
|
23
23
|
const rows = await db.allDocs(
|
|
24
24
|
getRowParams(table._id, null, {
|
|
25
25
|
include_docs: true,
|
|
26
26
|
})
|
|
27
27
|
)
|
|
28
|
-
return db.bulkDocs(
|
|
28
|
+
return (await db.bulkDocs(
|
|
29
29
|
rows.rows.map(({ doc }: any) => {
|
|
30
30
|
columnNames.forEach((colName: any) => delete doc[colName])
|
|
31
31
|
return doc
|
|
32
32
|
})
|
|
33
|
-
)
|
|
33
|
+
)) as { id: string; _rev?: string }[]
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export async function checkForColumnUpdates(oldTable: any, updatedTable: any) {
|
|
37
|
-
const db = getAppDB()
|
|
37
|
+
const db = context.getAppDB()
|
|
38
38
|
let updatedRows = []
|
|
39
39
|
const rename = updatedTable._rename
|
|
40
40
|
let deletedColumns: any = []
|
|
@@ -133,7 +133,7 @@ export async function handleDataImport(user: any, table: any, dataImport: any) {
|
|
|
133
133
|
return table
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
const db = getAppDB()
|
|
136
|
+
const db = context.getAppDB()
|
|
137
137
|
// Populate the table with rows imported from CSV in a bulk update
|
|
138
138
|
const data = await transform({
|
|
139
139
|
...dataImport,
|
|
@@ -150,7 +150,7 @@ export async function handleDataImport(user: any, table: any, dataImport: any) {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
export async function handleSearchIndexes(table: any) {
|
|
153
|
-
const db = getAppDB()
|
|
153
|
+
const db = context.getAppDB()
|
|
154
154
|
// create relevant search indexes
|
|
155
155
|
if (table.indexes && table.indexes.length > 0) {
|
|
156
156
|
const currentIndexes = await db.getIndexes()
|
|
@@ -214,7 +214,7 @@ class TableSaveFunctions {
|
|
|
214
214
|
rows: any
|
|
215
215
|
|
|
216
216
|
constructor({ user, oldTable, dataImport }: any) {
|
|
217
|
-
this.db = getAppDB()
|
|
217
|
+
this.db = context.getAppDB()
|
|
218
218
|
this.user = user
|
|
219
219
|
this.oldTable = oldTable
|
|
220
220
|
this.dataImport = dataImport
|
|
@@ -338,7 +338,7 @@ export function generateJunctionTableName(
|
|
|
338
338
|
return `jt_${table.name}_${relatedTable.name}_${column.name}_${column.fieldName}`
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
export function foreignKeyStructure(keyName: any, meta
|
|
341
|
+
export function foreignKeyStructure(keyName: any, meta?: any) {
|
|
342
342
|
const structure: any = {
|
|
343
343
|
type: FieldTypes.NUMBER,
|
|
344
344
|
constraints: {},
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import nodeFetch from "node-fetch"
|
|
2
|
+
import { downloadTemplate as dlTemplate } from "../../utilities/fileSystem"
|
|
3
|
+
import env from "../../environment"
|
|
4
|
+
import { BBContext } from "@budibase/types"
|
|
4
5
|
|
|
5
6
|
// development flag, can be used to test against templates exported locally
|
|
6
7
|
const DEFAULT_TEMPLATES_BUCKET =
|
|
7
8
|
"prod-budi-templates.s3-eu-west-1.amazonaws.com"
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
export async function fetch(ctx: BBContext) {
|
|
10
11
|
let type = env.TEMPLATE_REPOSITORY
|
|
11
12
|
let response,
|
|
12
13
|
error = false
|
|
13
14
|
try {
|
|
14
|
-
response = await
|
|
15
|
+
response = await nodeFetch(
|
|
16
|
+
`https://${DEFAULT_TEMPLATES_BUCKET}/manifest.json`
|
|
17
|
+
)
|
|
15
18
|
if (response.status !== 200) {
|
|
16
19
|
error = true
|
|
17
20
|
}
|
|
@@ -29,10 +32,10 @@ exports.fetch = async function (ctx) {
|
|
|
29
32
|
|
|
30
33
|
// can't currently test this, have to ignore from coverage
|
|
31
34
|
/* istanbul ignore next */
|
|
32
|
-
|
|
35
|
+
export async function downloadTemplate(ctx: BBContext) {
|
|
33
36
|
const { type, name } = ctx.params
|
|
34
37
|
|
|
35
|
-
await
|
|
38
|
+
await dlTemplate(type, name)
|
|
36
39
|
|
|
37
40
|
ctx.body = {
|
|
38
41
|
message: `template ${type}:${name} downloaded successfully.`,
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
generateUserMetadataID,
|
|
3
3
|
getUserMetadataParams,
|
|
4
4
|
generateUserFlagID,
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const { getAppDB, doInAppContext } = require("@budibase/backend-core/context")
|
|
5
|
+
} from "../../db/utils"
|
|
6
|
+
import { InternalTables } from "../../db/utils"
|
|
7
|
+
import { getGlobalUsers, getRawGlobalUser } from "../../utilities/global"
|
|
8
|
+
import { getFullUser } from "../../utilities/users"
|
|
9
|
+
import { isEqual } from "lodash"
|
|
10
|
+
import {
|
|
11
|
+
context,
|
|
12
|
+
constants,
|
|
13
|
+
roles as rolesCore,
|
|
14
|
+
db as dbCore,
|
|
15
|
+
} from "@budibase/backend-core"
|
|
16
|
+
import { BBContext, User } from "@budibase/types"
|
|
18
17
|
|
|
19
18
|
async function rawMetadata() {
|
|
20
|
-
const db = getAppDB()
|
|
19
|
+
const db = context.getAppDB()
|
|
21
20
|
return (
|
|
22
21
|
await db.allDocs(
|
|
23
22
|
getUserMetadataParams(null, {
|
|
@@ -27,9 +26,9 @@ async function rawMetadata() {
|
|
|
27
26
|
).rows.map(row => row.doc)
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
function combineMetadataAndUser(user, metadata) {
|
|
29
|
+
function combineMetadataAndUser(user: any, metadata: any) {
|
|
31
30
|
// skip users with no access
|
|
32
|
-
if (user.roleId === BUILTIN_ROLE_IDS.PUBLIC) {
|
|
31
|
+
if (user.roleId === rolesCore.BUILTIN_ROLE_IDS.PUBLIC) {
|
|
33
32
|
return null
|
|
34
33
|
}
|
|
35
34
|
delete user._rev
|
|
@@ -55,9 +54,9 @@ function combineMetadataAndUser(user, metadata) {
|
|
|
55
54
|
return null
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
export async function syncGlobalUsers() {
|
|
59
58
|
// sync user metadata
|
|
60
|
-
const db = getAppDB()
|
|
59
|
+
const db = context.getAppDB()
|
|
61
60
|
const [users, metadata] = await Promise.all([getGlobalUsers(), rawMetadata()])
|
|
62
61
|
const toWrite = []
|
|
63
62
|
for (let user of users) {
|
|
@@ -69,13 +68,13 @@ exports.syncGlobalUsers = async () => {
|
|
|
69
68
|
await db.bulkDocs(toWrite)
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
|
|
71
|
+
export async function syncUser(ctx: BBContext) {
|
|
73
72
|
let deleting = false,
|
|
74
|
-
user
|
|
73
|
+
user: User | any
|
|
75
74
|
const userId = ctx.params.id
|
|
76
75
|
try {
|
|
77
76
|
user = await getRawGlobalUser(userId)
|
|
78
|
-
} catch (err) {
|
|
77
|
+
} catch (err: any) {
|
|
79
78
|
if (err && err.status === 404) {
|
|
80
79
|
user = {}
|
|
81
80
|
deleting = true
|
|
@@ -92,21 +91,21 @@ exports.syncUser = async function (ctx) {
|
|
|
92
91
|
let prodAppIds
|
|
93
92
|
// if they are a builder then get all production app IDs
|
|
94
93
|
if ((user.builder && user.builder.global) || deleting) {
|
|
95
|
-
prodAppIds = await getProdAppIDs()
|
|
94
|
+
prodAppIds = await dbCore.getProdAppIDs()
|
|
96
95
|
} else {
|
|
97
96
|
prodAppIds = Object.entries(roles)
|
|
98
|
-
.filter(entry => entry[1] !== BUILTIN_ROLE_IDS.PUBLIC)
|
|
97
|
+
.filter(entry => entry[1] !== rolesCore.BUILTIN_ROLE_IDS.PUBLIC)
|
|
99
98
|
.map(([appId]) => appId)
|
|
100
99
|
}
|
|
101
100
|
for (let prodAppId of prodAppIds) {
|
|
102
101
|
const roleId = roles[prodAppId]
|
|
103
|
-
const devAppId = getDevelopmentAppID(prodAppId)
|
|
102
|
+
const devAppId = dbCore.getDevelopmentAppID(prodAppId)
|
|
104
103
|
for (let appId of [prodAppId, devAppId]) {
|
|
105
|
-
if (!(await dbExists(appId))) {
|
|
104
|
+
if (!(await dbCore.dbExists(appId))) {
|
|
106
105
|
continue
|
|
107
106
|
}
|
|
108
|
-
await doInAppContext(appId, async () => {
|
|
109
|
-
const db = getAppDB()
|
|
107
|
+
await context.doInAppContext(appId, async () => {
|
|
108
|
+
const db = context.getAppDB()
|
|
110
109
|
const metadataId = generateUserMetadataID(userId)
|
|
111
110
|
let metadata
|
|
112
111
|
try {
|
|
@@ -127,8 +126,8 @@ exports.syncUser = async function (ctx) {
|
|
|
127
126
|
? combineMetadataAndUser(user, metadata)
|
|
128
127
|
: {
|
|
129
128
|
...metadata,
|
|
130
|
-
status: UserStatus.INACTIVE,
|
|
131
|
-
metadata: BUILTIN_ROLE_IDS.PUBLIC,
|
|
129
|
+
status: constants.UserStatus.INACTIVE,
|
|
130
|
+
metadata: rolesCore.BUILTIN_ROLE_IDS.PUBLIC,
|
|
132
131
|
}
|
|
133
132
|
// if its null then there was no updates required
|
|
134
133
|
if (combined) {
|
|
@@ -142,10 +141,9 @@ exports.syncUser = async function (ctx) {
|
|
|
142
141
|
}
|
|
143
142
|
}
|
|
144
143
|
|
|
145
|
-
|
|
146
|
-
const database = getAppDB()
|
|
144
|
+
export async function fetchMetadata(ctx: BBContext) {
|
|
147
145
|
const global = await getGlobalUsers()
|
|
148
|
-
const metadata = await rawMetadata(
|
|
146
|
+
const metadata = await rawMetadata()
|
|
149
147
|
const users = []
|
|
150
148
|
for (let user of global) {
|
|
151
149
|
// find the metadata that matches up to the global ID
|
|
@@ -162,18 +160,18 @@ exports.fetchMetadata = async function (ctx) {
|
|
|
162
160
|
ctx.body = users
|
|
163
161
|
}
|
|
164
162
|
|
|
165
|
-
|
|
163
|
+
export async function updateSelfMetadata(ctx: BBContext) {
|
|
166
164
|
// overwrite the ID with current users
|
|
167
|
-
ctx.request.body._id = ctx.user
|
|
165
|
+
ctx.request.body._id = ctx.user?._id
|
|
168
166
|
// make sure no stale rev
|
|
169
167
|
delete ctx.request.body._rev
|
|
170
168
|
// make sure no csrf token
|
|
171
169
|
delete ctx.request.body.csrfToken
|
|
172
|
-
await
|
|
170
|
+
await updateMetadata(ctx)
|
|
173
171
|
}
|
|
174
172
|
|
|
175
|
-
|
|
176
|
-
const db = getAppDB()
|
|
173
|
+
export async function updateMetadata(ctx: BBContext) {
|
|
174
|
+
const db = context.getAppDB()
|
|
177
175
|
const user = ctx.request.body
|
|
178
176
|
// this isn't applicable to the user
|
|
179
177
|
delete user.roles
|
|
@@ -184,8 +182,8 @@ exports.updateMetadata = async function (ctx) {
|
|
|
184
182
|
ctx.body = await db.put(metadata)
|
|
185
183
|
}
|
|
186
184
|
|
|
187
|
-
|
|
188
|
-
const db = getAppDB()
|
|
185
|
+
export async function destroyMetadata(ctx: BBContext) {
|
|
186
|
+
const db = context.getAppDB()
|
|
189
187
|
try {
|
|
190
188
|
const dbUser = await db.get(ctx.params.id)
|
|
191
189
|
await db.remove(dbUser._id, dbUser._rev)
|
|
@@ -197,18 +195,18 @@ exports.destroyMetadata = async function (ctx) {
|
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
197
|
|
|
200
|
-
|
|
198
|
+
export async function findMetadata(ctx: BBContext) {
|
|
201
199
|
ctx.body = await getFullUser(ctx, ctx.params.id)
|
|
202
200
|
}
|
|
203
201
|
|
|
204
|
-
|
|
205
|
-
const userId = ctx.user
|
|
202
|
+
export async function setFlag(ctx: BBContext) {
|
|
203
|
+
const userId = ctx.user?._id
|
|
206
204
|
const { flag, value } = ctx.request.body
|
|
207
205
|
if (!flag) {
|
|
208
206
|
ctx.throw(400, "Must supply a 'flag' field in request body.")
|
|
209
207
|
}
|
|
210
|
-
const flagDocId = generateUserFlagID(userId)
|
|
211
|
-
const db = getAppDB()
|
|
208
|
+
const flagDocId = generateUserFlagID(userId!)
|
|
209
|
+
const db = context.getAppDB()
|
|
212
210
|
let doc
|
|
213
211
|
try {
|
|
214
212
|
doc = await db.get(flagDocId)
|
|
@@ -220,10 +218,10 @@ exports.setFlag = async function (ctx) {
|
|
|
220
218
|
ctx.body = { message: "Flag set successfully" }
|
|
221
219
|
}
|
|
222
220
|
|
|
223
|
-
|
|
224
|
-
const userId = ctx.user
|
|
225
|
-
const docId = generateUserFlagID(userId)
|
|
226
|
-
const db = getAppDB()
|
|
221
|
+
export async function getFlags(ctx: BBContext) {
|
|
222
|
+
const userId = ctx.user?._id
|
|
223
|
+
const docId = generateUserFlagID(userId!)
|
|
224
|
+
const db = context.getAppDB()
|
|
227
225
|
let doc
|
|
228
226
|
try {
|
|
229
227
|
doc = await db.get(docId)
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { Row } from "@budibase/types"
|
|
2
|
+
|
|
3
|
+
export function csv(headers: string[], rows: Row[]) {
|
|
2
4
|
let csv = headers.map(key => `"${key}"`).join(",")
|
|
3
5
|
|
|
4
6
|
for (let row of rows) {
|
|
@@ -16,11 +18,11 @@ exports.csv = function (headers, rows) {
|
|
|
16
18
|
return csv
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
export function json(headers: string[], rows: Row[]) {
|
|
20
22
|
return JSON.stringify(rows, undefined, 2)
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
export const ExportFormats = {
|
|
24
26
|
CSV: "csv",
|
|
25
27
|
JSON: "json",
|
|
26
28
|
}
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import viewTemplate from "./viewBuilder"
|
|
2
|
+
import { apiFileReturn } from "../../../utilities/fileSystem"
|
|
3
|
+
import * as exporters from "./exporters"
|
|
4
|
+
import { deleteView, getView, getViews, saveView } from "./utils"
|
|
5
|
+
import { fetchView } from "../row"
|
|
6
|
+
import { FieldTypes } from "../../../constants"
|
|
7
|
+
import { context, events } from "@budibase/backend-core"
|
|
8
|
+
import { DocumentType } from "../../../db/utils"
|
|
9
|
+
import sdk from "../../../sdk"
|
|
10
|
+
import {
|
|
11
|
+
BBContext,
|
|
12
|
+
Row,
|
|
13
|
+
Table,
|
|
14
|
+
TableExportFormat,
|
|
15
|
+
TableSchema,
|
|
16
|
+
View,
|
|
17
|
+
} from "@budibase/types"
|
|
18
|
+
|
|
10
19
|
const { cloneDeep, isEqual } = require("lodash")
|
|
11
|
-
const sdk = require("../../../sdk")
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
export async function fetch(ctx: BBContext) {
|
|
14
22
|
ctx.body = await getViews()
|
|
15
23
|
}
|
|
16
24
|
|
|
17
|
-
|
|
18
|
-
const db = getAppDB()
|
|
25
|
+
export async function save(ctx: BBContext) {
|
|
26
|
+
const db = context.getAppDB()
|
|
19
27
|
const { originalName, ...viewToSave } = ctx.request.body
|
|
20
28
|
const view = viewTemplate(viewToSave)
|
|
21
29
|
const viewName = viewToSave.name
|
|
@@ -47,7 +55,7 @@ exports.save = async ctx => {
|
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
export async function calculationEvents(existingView: View, newView: View) {
|
|
51
59
|
const existingCalculation = existingView && existingView.calculation
|
|
52
60
|
const newCalculation = newView && newView.calculation
|
|
53
61
|
|
|
@@ -68,7 +76,7 @@ const calculationEvents = async (existingView, newView) => {
|
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
78
|
|
|
71
|
-
|
|
79
|
+
export async function filterEvents(existingView: View, newView: View) {
|
|
72
80
|
const hasExistingFilters = !!(
|
|
73
81
|
existingView &&
|
|
74
82
|
existingView.filters &&
|
|
@@ -93,7 +101,7 @@ const filterEvents = async (existingView, newView) => {
|
|
|
93
101
|
}
|
|
94
102
|
}
|
|
95
103
|
|
|
96
|
-
|
|
104
|
+
async function handleViewEvents(existingView: View, newView: View) {
|
|
97
105
|
if (!existingView) {
|
|
98
106
|
await events.view.created(newView)
|
|
99
107
|
} else {
|
|
@@ -103,8 +111,8 @@ const handleViewEvents = async (existingView, newView) => {
|
|
|
103
111
|
await filterEvents(existingView, newView)
|
|
104
112
|
}
|
|
105
113
|
|
|
106
|
-
|
|
107
|
-
const db = getAppDB()
|
|
114
|
+
export async function destroy(ctx: BBContext) {
|
|
115
|
+
const db = context.getAppDB()
|
|
108
116
|
const viewName = decodeURI(ctx.params.viewName)
|
|
109
117
|
const view = await deleteView(viewName)
|
|
110
118
|
const table = await db.get(view.meta.tableId)
|
|
@@ -115,11 +123,11 @@ exports.destroy = async ctx => {
|
|
|
115
123
|
ctx.body = view
|
|
116
124
|
}
|
|
117
125
|
|
|
118
|
-
|
|
119
|
-
const viewName = decodeURI(ctx.query.view)
|
|
126
|
+
export async function exportView(ctx: BBContext) {
|
|
127
|
+
const viewName = decodeURI(ctx.query.view as string)
|
|
120
128
|
const view = await getView(viewName)
|
|
121
129
|
|
|
122
|
-
const format = ctx.query.format
|
|
130
|
+
const format = ctx.query.format as string
|
|
123
131
|
if (!format || !Object.values(exporters.ExportFormats).includes(format)) {
|
|
124
132
|
ctx.throw(400, "Format must be specified, either csv or json")
|
|
125
133
|
}
|
|
@@ -130,6 +138,7 @@ exports.exportView = async ctx => {
|
|
|
130
138
|
ctx.query = {
|
|
131
139
|
group: view.meta.groupBy,
|
|
132
140
|
calculation: view.meta.calculation,
|
|
141
|
+
// @ts-ignore
|
|
133
142
|
stats: !!view.meta.field,
|
|
134
143
|
field: view.meta.field,
|
|
135
144
|
}
|
|
@@ -140,11 +149,11 @@ exports.exportView = async ctx => {
|
|
|
140
149
|
}
|
|
141
150
|
|
|
142
151
|
await fetchView(ctx)
|
|
143
|
-
let rows = ctx.body
|
|
152
|
+
let rows = ctx.body as Row[]
|
|
144
153
|
|
|
145
|
-
let schema = view && view.meta && view.meta.schema
|
|
154
|
+
let schema: TableSchema = view && view.meta && view.meta.schema
|
|
146
155
|
const tableId = ctx.params.tableId || view.meta.tableId
|
|
147
|
-
const table = await sdk.tables.getTable(tableId)
|
|
156
|
+
const table: Table = await sdk.tables.getTable(tableId)
|
|
148
157
|
if (!schema) {
|
|
149
158
|
schema = table.schema
|
|
150
159
|
}
|
|
@@ -175,15 +184,15 @@ exports.exportView = async ctx => {
|
|
|
175
184
|
|
|
176
185
|
// Export part
|
|
177
186
|
let headers = Object.keys(schema)
|
|
178
|
-
const exporter = exporters
|
|
187
|
+
const exporter = format === "csv" ? exporters.csv : exporters.json
|
|
179
188
|
const filename = `${viewName}.${format}`
|
|
180
189
|
// send down the file
|
|
181
190
|
ctx.attachment(filename)
|
|
182
191
|
ctx.body = apiFileReturn(exporter(headers, rows))
|
|
183
192
|
|
|
184
193
|
if (viewName.startsWith(DocumentType.TABLE)) {
|
|
185
|
-
await events.table.exported(table, format)
|
|
194
|
+
await events.table.exported(table, format as TableExportFormat)
|
|
186
195
|
} else {
|
|
187
|
-
await events.view.exported(table, format)
|
|
196
|
+
await events.view.exported(table, format as TableExportFormat)
|
|
188
197
|
}
|
|
189
198
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
ViewName,
|
|
3
3
|
generateMemoryViewID,
|
|
4
4
|
getMemoryViewParams,
|
|
5
5
|
DocumentType,
|
|
6
6
|
SEPARATOR,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
} from "../../../db/utils"
|
|
8
|
+
import env from "../../../environment"
|
|
9
|
+
import { context } from "@budibase/backend-core"
|
|
10
|
+
import viewBuilder from "./viewBuilder"
|
|
11
|
+
import { Database } from "@budibase/types"
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
const db = getAppDB()
|
|
13
|
+
export async function getView(viewName: string) {
|
|
14
|
+
const db = context.getAppDB()
|
|
14
15
|
if (env.SELF_HOSTED) {
|
|
15
16
|
const designDoc = await db.get("_design/database")
|
|
16
17
|
return designDoc.views[viewName]
|
|
@@ -23,7 +24,7 @@ exports.getView = async viewName => {
|
|
|
23
24
|
try {
|
|
24
25
|
const viewDoc = await db.get(generateMemoryViewID(viewName))
|
|
25
26
|
return viewDoc.view
|
|
26
|
-
} catch (err) {
|
|
27
|
+
} catch (err: any) {
|
|
27
28
|
// Return null when PouchDB doesn't found the view
|
|
28
29
|
if (err.status === 404) {
|
|
29
30
|
return null
|
|
@@ -34,14 +35,15 @@ exports.getView = async viewName => {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
const db = getAppDB()
|
|
38
|
+
export async function getViews() {
|
|
39
|
+
const db = context.getAppDB()
|
|
39
40
|
const response = []
|
|
40
41
|
if (env.SELF_HOSTED) {
|
|
41
42
|
const designDoc = await db.get("_design/database")
|
|
42
43
|
for (let name of Object.keys(designDoc.views)) {
|
|
43
44
|
// Only return custom views, not built ins
|
|
44
|
-
|
|
45
|
+
const viewNames = Object.values(ViewName) as string[]
|
|
46
|
+
if (viewNames.indexOf(name) !== -1) {
|
|
45
47
|
continue
|
|
46
48
|
}
|
|
47
49
|
response.push({
|
|
@@ -67,8 +69,12 @@ exports.getViews = async () => {
|
|
|
67
69
|
return response
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
export async function saveView(
|
|
73
|
+
originalName: string | null,
|
|
74
|
+
viewName: string,
|
|
75
|
+
viewTemplate: any
|
|
76
|
+
) {
|
|
77
|
+
const db = context.getAppDB()
|
|
72
78
|
if (env.SELF_HOSTED) {
|
|
73
79
|
const designDoc = await db.get("_design/database")
|
|
74
80
|
designDoc.views = {
|
|
@@ -83,7 +89,7 @@ exports.saveView = async (originalName, viewName, viewTemplate) => {
|
|
|
83
89
|
} else {
|
|
84
90
|
const id = generateMemoryViewID(viewName)
|
|
85
91
|
const originalId = originalName ? generateMemoryViewID(originalName) : null
|
|
86
|
-
const viewDoc = {
|
|
92
|
+
const viewDoc: any = {
|
|
87
93
|
_id: id,
|
|
88
94
|
view: viewTemplate,
|
|
89
95
|
name: viewName,
|
|
@@ -105,8 +111,8 @@ exports.saveView = async (originalName, viewName, viewTemplate) => {
|
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
|
|
108
|
-
|
|
109
|
-
const db = getAppDB()
|
|
114
|
+
export async function deleteView(viewName: string) {
|
|
115
|
+
const db = context.getAppDB()
|
|
110
116
|
if (env.SELF_HOSTED) {
|
|
111
117
|
const designDoc = await db.get("_design/database")
|
|
112
118
|
const view = designDoc.views[viewName]
|
|
@@ -121,7 +127,7 @@ exports.deleteView = async viewName => {
|
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
129
|
|
|
124
|
-
|
|
130
|
+
export async function migrateToInMemoryView(db: Database, viewName: string) {
|
|
125
131
|
// delete the view initially
|
|
126
132
|
const designDoc = await db.get("_design/database")
|
|
127
133
|
// run the view back through the view builder to update it
|
|
@@ -131,7 +137,7 @@ exports.migrateToInMemoryView = async (db, viewName) => {
|
|
|
131
137
|
await exports.saveView(db, null, viewName, view)
|
|
132
138
|
}
|
|
133
139
|
|
|
134
|
-
|
|
140
|
+
export async function migrateToDesignView(db: Database, viewName: string) {
|
|
135
141
|
let view = await db.get(generateMemoryViewID(viewName))
|
|
136
142
|
const designDoc = await db.get("_design/database")
|
|
137
143
|
designDoc.views[viewName] = viewBuilder(view.view.meta)
|
|
@@ -139,7 +145,7 @@ exports.migrateToDesignView = async (db, viewName) => {
|
|
|
139
145
|
await db.remove(view._id, view._rev)
|
|
140
146
|
}
|
|
141
147
|
|
|
142
|
-
|
|
148
|
+
export async function getFromDesignDoc(db: Database, viewName: string) {
|
|
143
149
|
const designDoc = await db.get("_design/database")
|
|
144
150
|
let view = designDoc.views[viewName]
|
|
145
151
|
if (view == null) {
|
|
@@ -148,7 +154,7 @@ exports.getFromDesignDoc = async (db, viewName) => {
|
|
|
148
154
|
return view
|
|
149
155
|
}
|
|
150
156
|
|
|
151
|
-
|
|
157
|
+
export async function getFromMemoryDoc(db: Database, viewName: string) {
|
|
152
158
|
let view = await db.get(generateMemoryViewID(viewName))
|
|
153
159
|
if (view) {
|
|
154
160
|
view = view.view
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import Router from "@koa/router"
|
|
2
|
+
import { errors, auth } from "@budibase/backend-core"
|
|
3
|
+
import currentApp from "../middleware/currentapp"
|
|
4
|
+
import zlib from "zlib"
|
|
5
|
+
import { mainRoutes, staticRoutes, publicRoutes } from "./routes"
|
|
6
|
+
import pkg from "../../package.json"
|
|
7
|
+
import env from "../environment"
|
|
8
|
+
import { middleware as pro } from "@budibase/pro"
|
|
9
|
+
export { shutdown } from "./routes/public"
|
|
9
10
|
const compress = require("koa-compress")
|
|
10
|
-
const zlib = require("zlib")
|
|
11
|
-
const { mainRoutes, staticRoutes, publicRoutes } = require("./routes")
|
|
12
|
-
const pkg = require("../../package.json")
|
|
13
|
-
const env = require("../environment")
|
|
14
|
-
const { middleware: pro } = require("@budibase/pro")
|
|
15
|
-
const { shutdown } = require("./routes/public")
|
|
16
11
|
|
|
17
|
-
const router = new Router()
|
|
12
|
+
export const router: Router = new Router()
|
|
18
13
|
|
|
19
14
|
router.get("/health", ctx => (ctx.status = 200))
|
|
20
15
|
router.get("/version", ctx => (ctx.body = pkg.version))
|
|
@@ -42,7 +37,7 @@ router
|
|
|
42
37
|
// re-direct before any middlewares occur
|
|
43
38
|
.redirect("/", "/builder")
|
|
44
39
|
.use(
|
|
45
|
-
buildAuthMiddleware(null, {
|
|
40
|
+
auth.buildAuthMiddleware(null, {
|
|
46
41
|
publicAllowed: true,
|
|
47
42
|
})
|
|
48
43
|
)
|
|
@@ -50,19 +45,20 @@ router
|
|
|
50
45
|
// the server can be public anywhere, so nowhere should throw errors
|
|
51
46
|
// if the tenancy has not been set, it'll have to be discovered at application layer
|
|
52
47
|
.use(
|
|
53
|
-
buildTenancyMiddleware(null, null, {
|
|
48
|
+
auth.buildTenancyMiddleware(null, null, {
|
|
54
49
|
noTenancyRequired: true,
|
|
55
50
|
})
|
|
56
51
|
)
|
|
57
52
|
.use(pro.licensing())
|
|
53
|
+
// @ts-ignore
|
|
58
54
|
.use(currentApp)
|
|
59
|
-
.use(auditLog)
|
|
55
|
+
.use(auth.auditLog)
|
|
60
56
|
|
|
61
57
|
// error handling middleware
|
|
62
58
|
router.use(async (ctx, next) => {
|
|
63
59
|
try {
|
|
64
60
|
await next()
|
|
65
|
-
} catch (err) {
|
|
61
|
+
} catch (err: any) {
|
|
66
62
|
ctx.status = err.status || err.statusCode || 500
|
|
67
63
|
const error = errors.getPublicError(err)
|
|
68
64
|
ctx.body = {
|
|
@@ -91,6 +87,3 @@ router.use(publicRoutes.allowedMethods())
|
|
|
91
87
|
// WARNING - static routes will catch everything else after them this must be last
|
|
92
88
|
router.use(staticRoutes.routes())
|
|
93
89
|
router.use(staticRoutes.allowedMethods())
|
|
94
|
-
|
|
95
|
-
module.exports.router = router
|
|
96
|
-
module.exports.shutdown = shutdown
|