@budibase/server 2.1.22-alpha.6 → 2.1.22-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/__mocks__/node-fetch.ts +5 -1
- package/builder/assets/{index.5ec5f06c.js → index.22484e23.js} +1 -1
- package/builder/index.html +1 -1
- package/coverage/clover.xml +1182 -1209
- package/coverage/coverage-final.json +35 -35
- package/coverage/lcov-report/index.html +94 -94
- package/coverage/lcov-report/src/api/controllers/analytics.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/application.ts.html +45 -60
- package/coverage/lcov-report/src/api/controllers/auth.ts.html +7 -4
- package/coverage/lcov-report/src/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/backup.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/component.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/deploy/Deployment.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/deploy/index.html +10 -10
- package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +19 -55
- package/coverage/lcov-report/src/api/controllers/{dev.js.html → dev.ts.html} +46 -64
- package/coverage/lcov-report/src/api/controllers/index.html +25 -25
- package/coverage/lcov-report/src/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/permission.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +1 -1
- 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 +37 -19
- package/coverage/lcov-report/src/api/controllers/public/index.html +16 -16
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +1 -1
- 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 +10 -10
- package/coverage/lcov-report/src/api/controllers/query/index.ts.html +17 -26
- package/coverage/lcov-report/src/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/internal.js.html +3 -3
- package/coverage/lcov-report/src/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/screen.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/static/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/static/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/utils.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/api/index.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/application.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/auth.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/automation.js.html +5 -5
- package/coverage/lcov-report/src/api/routes/backup.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/datasource.js.html +6 -6
- package/coverage/lcov-report/src/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/plugin.ts.html +1 -1
- 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 +11 -11
- 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 +6 -6
- package/coverage/lcov-report/src/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/row.ts.html +13 -13
- package/coverage/lcov-report/src/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/static.ts.html +6 -6
- package/coverage/lcov-report/src/api/routes/table.js.html +4 -4
- package/coverage/lcov-report/src/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/user.js.html +11 -11
- package/coverage/lcov-report/src/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/utils/validators.js.html +6 -6
- package/coverage/lcov-report/src/api/routes/view.js.html +4 -4
- package/coverage/lcov-report/src/api/routes/webhook.ts.html +1 -1
- package/coverage/lcov-report/src/app.ts.html +1 -1
- 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 +15 -15
- 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 +17 -17
- package/coverage/lcov-report/src/automations/tests/utilities/index.js.html +33 -15
- 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 +1 -1
- package/coverage/lcov-report/src/automations/utils.ts.html +20 -29
- package/coverage/lcov-report/src/constants/index.html +1 -1
- package/coverage/lcov-report/src/constants/index.js.html +1 -1
- package/coverage/lcov-report/src/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/src/constants/screens.js.html +1 -1
- package/coverage/lcov-report/src/db/dynamoClient.js.html +1 -1
- package/coverage/lcov-report/src/db/inMemoryView.js.html +3 -3
- package/coverage/lcov-report/src/db/index.html +16 -16
- package/coverage/lcov-report/src/db/index.js.html +9 -9
- package/coverage/lcov-report/src/db/linkedRows/LinkController.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 +1 -1
- package/coverage/lcov-report/src/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/src/db/newid.js.html +1 -1
- package/coverage/lcov-report/src/db/{utils.js.html → utils.ts.html} +97 -145
- 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 +4 -4
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +1 -1
- 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 +10 -19
- package/coverage/lcov-report/src/integrations/index.html +11 -11
- package/coverage/lcov-report/src/integrations/index.ts.html +1 -1
- 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.js.html → appInfo.ts.html} +24 -21
- package/coverage/lcov-report/src/middleware/authorized.ts.html +7 -7
- package/coverage/lcov-report/src/middleware/{builder.js.html → builder.ts.html} +36 -30
- package/coverage/lcov-report/src/middleware/{currentapp.js.html → currentapp.ts.html} +70 -61
- package/coverage/lcov-report/src/middleware/index.html +55 -55
- package/coverage/lcov-report/src/middleware/{joi-validator.js.html → joi-validator.ts.html} +18 -15
- package/coverage/lcov-report/src/middleware/{publicApi.js.html → publicApi.ts.html} +17 -17
- package/coverage/lcov-report/src/middleware/{resourceId.js.html → resourceId.ts.html} +33 -18
- package/coverage/lcov-report/src/middleware/{selfhost.js.html → selfhost.ts.html} +18 -12
- package/coverage/lcov-report/src/middleware/{utils.js.html → utils.ts.html} +12 -6
- package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +1 -1
- 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 +4 -4
- 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 +6 -15
- 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 +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncRows.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +1 -1
- 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/module.d.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 +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +7 -16
- package/coverage/lcov-report/src/sdk/app/backups/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +12 -39
- package/coverage/lcov-report/src/sdk/app/tables/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +8 -11
- 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 +1 -1
- package/coverage/lcov-report/src/tests/utilities/TestConfiguration.js.html +24 -24
- package/coverage/lcov-report/src/tests/utilities/controllers.js.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/index.html +19 -19
- package/coverage/lcov-report/src/tests/utilities/index.js.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/structures.js.html +3 -3
- package/coverage/lcov-report/src/threads/automation.ts.html +2 -2
- package/coverage/lcov-report/src/threads/index.html +1 -1
- package/coverage/lcov-report/src/threads/index.ts.html +1 -1
- package/coverage/lcov-report/src/threads/query.ts.html +1 -1
- package/coverage/lcov-report/src/threads/utils.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/budibaseDir.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/index.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/index.js.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/processor.js.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/utilities.js.html +1 -1
- package/coverage/lcov-report/src/utilities/{global.js.html → global.ts.html} +100 -67
- package/coverage/lcov-report/src/utilities/index.html +16 -16
- package/coverage/lcov-report/src/utilities/index.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/src/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/src/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/src/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/src/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/src/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/src/utilities/security.js.html +13 -13
- package/coverage/lcov-report/src/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/src/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/src/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/src/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/src/utilities/users.js.html +1 -1
- package/coverage/lcov-report/src/utilities/workerRequests.js.html +4 -4
- package/coverage/lcov-report/src/watch.ts.html +1 -1
- package/coverage/lcov-report/src/websocket.ts.html +1 -1
- package/coverage/lcov.info +2052 -2049
- package/dist/api/controllers/application.js +35 -43
- package/dist/api/controllers/deploy/index.js +13 -16
- package/dist/api/controllers/dev.js +96 -81
- package/dist/api/controllers/public/applications.js +17 -9
- package/dist/api/controllers/query/index.js +10 -13
- package/dist/api/controllers/row/internal.js +2 -2
- package/dist/api/routes/automation.js +3 -3
- package/dist/api/routes/datasource.js +4 -4
- package/dist/api/routes/public/index.js +9 -9
- package/dist/api/routes/query.js +4 -4
- package/dist/api/routes/row.js +11 -11
- package/dist/api/routes/static.js +3 -3
- package/dist/api/routes/table.js +2 -2
- package/dist/api/routes/user.js +9 -9
- package/dist/api/routes/utils/validators.js +4 -4
- package/dist/api/routes/view.js +2 -2
- package/dist/automations/tests/utilities/index.js +21 -12
- package/dist/automations/utils.js +9 -8
- package/dist/db/inMemoryView.js +2 -2
- package/dist/db/utils.js +145 -118
- package/dist/integrations/googlesheets.js +4 -6
- package/dist/middleware/appInfo.js +14 -9
- package/dist/middleware/authorized.js +5 -5
- package/dist/middleware/builder.js +41 -40
- package/dist/middleware/currentapp.js +39 -37
- package/dist/middleware/joi-validator.js +17 -10
- package/dist/middleware/publicApi.js +5 -6
- package/dist/middleware/resourceId.js +16 -9
- package/dist/middleware/selfhost.js +5 -4
- package/dist/middleware/utils.js +5 -2
- package/dist/package.json +6 -6
- package/dist/sdk/app/tables/index.js +4 -4
- package/dist/tests/utilities/TestConfiguration.js +9 -9
- package/dist/tests/utilities/structures.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/global.js +87 -66
- package/dist/utilities/security.js +10 -10
- package/dist/utilities/workerRequests.js +3 -3
- package/jest.config.ts +1 -0
- package/package.json +7 -7
- package/src/api/controllers/application.ts +34 -39
- package/src/api/controllers/auth.ts +3 -2
- package/src/api/controllers/deploy/index.ts +13 -25
- package/src/api/controllers/{dev.js → dev.ts} +31 -37
- package/src/api/controllers/public/applications.ts +15 -9
- package/src/api/controllers/query/index.ts +11 -14
- package/src/api/controllers/row/internal.js +2 -2
- package/src/api/routes/automation.js +4 -4
- package/src/api/routes/datasource.js +5 -5
- package/src/api/routes/public/index.ts +10 -10
- package/src/api/routes/public/tests/compare.spec.js +1 -1
- package/src/api/routes/query.js +5 -5
- package/src/api/routes/row.ts +12 -12
- package/src/api/routes/static.ts +5 -5
- package/src/api/routes/table.js +3 -3
- package/src/api/routes/tests/analytics.spec.js +1 -1
- package/src/api/routes/tests/query.spec.js +15 -10
- package/src/api/routes/tests/role.spec.js +5 -5
- package/src/api/routes/tests/static.spec.js +2 -2
- package/src/api/routes/tests/table.spec.js +38 -35
- package/src/api/routes/user.js +10 -10
- package/src/api/routes/utils/validators.js +5 -5
- package/src/api/routes/view.js +3 -3
- package/src/automations/tests/updateRow.spec.js +0 -1
- package/src/automations/tests/utilities/index.js +10 -4
- package/src/automations/utils.ts +9 -12
- package/src/db/inMemoryView.js +2 -2
- package/src/db/tests/linkController.spec.js +73 -57
- package/src/db/tests/linkTests.spec.js +17 -14
- package/src/db/{utils.js → utils.ts} +76 -92
- package/src/integrations/googlesheets.ts +4 -7
- package/src/middleware/appInfo.ts +20 -0
- package/src/middleware/authorized.ts +6 -6
- package/src/middleware/{builder.js → builder.ts} +17 -15
- package/src/middleware/{currentapp.js → currentapp.ts} +42 -39
- package/src/middleware/{joi-validator.js → joi-validator.ts} +9 -8
- package/src/middleware/publicApi.ts +21 -0
- package/src/middleware/{resourceId.js → resourceId.ts} +16 -11
- package/src/middleware/{selfhost.js → selfhost.ts} +4 -2
- package/src/middleware/tests/authorized.spec.js +5 -5
- package/src/middleware/tests/currentapp.spec.js +118 -63
- package/src/middleware/{utils.js → utils.ts} +3 -1
- package/src/migrations/functions/backfill/app/tables.ts +2 -5
- package/src/sdk/app/backups/imports.ts +4 -7
- package/src/sdk/app/backups/statistics.ts +9 -18
- package/src/sdk/app/tables/index.ts +6 -7
- package/src/tests/utilities/TestConfiguration.js +9 -9
- package/src/tests/utilities/structures.js +2 -2
- package/src/threads/automation.ts +1 -1
- package/src/utilities/global.ts +138 -0
- package/src/utilities/security.js +12 -12
- package/src/utilities/workerRequests.js +3 -3
- package/src/middleware/appInfo.js +0 -19
- package/src/middleware/publicApi.js +0 -21
- package/src/utilities/global.js +0 -127
|
@@ -18,23 +18,17 @@ const package_json_1 = __importDefault(require("../../../package.json"));
|
|
|
18
18
|
const staticViews_1 = require("../../db/views/staticViews");
|
|
19
19
|
const fileSystem_1 = require("../../utilities/fileSystem");
|
|
20
20
|
const utils_1 = require("../../db/utils");
|
|
21
|
-
const
|
|
22
|
-
const { CacheKeys, bustCache } = require("@budibase/backend-core/cache");
|
|
23
|
-
const { getAllApps, isDevAppID, getProdAppID, Replication, } = require("@budibase/backend-core/db");
|
|
21
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
24
22
|
const constants_1 = require("../../constants");
|
|
25
23
|
const workerRequests_1 = require("../../utilities/workerRequests");
|
|
26
24
|
const utilities_1 = require("../../utilities");
|
|
27
25
|
const redis_1 = require("../../utilities/redis");
|
|
28
26
|
const clientLibrary_1 = require("../../utilities/fileSystem/clientLibrary");
|
|
29
|
-
const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy");
|
|
30
27
|
const user_1 = require("./user");
|
|
31
|
-
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
32
28
|
const utils_2 = require("../../automations/utils");
|
|
33
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
34
29
|
const logging_1 = require("../../automations/logging");
|
|
35
30
|
const rows_1 = require("../../utilities/usageQuota/rows");
|
|
36
31
|
const pro_1 = require("@budibase/pro");
|
|
37
|
-
const backend_core_2 = require("@budibase/backend-core");
|
|
38
32
|
const types_1 = require("@budibase/types");
|
|
39
33
|
const layouts_1 = require("../../constants/layouts");
|
|
40
34
|
const plugins_1 = require("../../utilities/plugins");
|
|
@@ -59,7 +53,7 @@ function getScreens() {
|
|
|
59
53
|
}
|
|
60
54
|
function getUserRoleId(ctx) {
|
|
61
55
|
return !ctx.user.role || !ctx.user.role._id
|
|
62
|
-
? BUILTIN_ROLE_IDS.PUBLIC
|
|
56
|
+
? backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC
|
|
63
57
|
: ctx.user.role._id;
|
|
64
58
|
}
|
|
65
59
|
const getAppUrl = (ctx) => {
|
|
@@ -101,7 +95,7 @@ const checkAppName = (ctx, apps, name, currentAppId) => {
|
|
|
101
95
|
};
|
|
102
96
|
function createInstance(template) {
|
|
103
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const tenantId = isMultiTenant() ? getTenantId() : null;
|
|
98
|
+
const tenantId = backend_core_1.tenancy.isMultiTenant() ? backend_core_1.tenancy.getTenantId() : null;
|
|
105
99
|
const baseAppId = (0, utils_1.generateAppID)(tenantId);
|
|
106
100
|
const appId = (0, utils_1.generateDevAppID)(baseAppId);
|
|
107
101
|
yield backend_core_1.context.updateAppId(appId);
|
|
@@ -138,7 +132,7 @@ function createInstance(template) {
|
|
|
138
132
|
const fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
133
|
const dev = ctx.query && ctx.query.status === utils_1.AppStatus.DEV;
|
|
140
134
|
const all = ctx.query && ctx.query.status === utils_1.AppStatus.ALL;
|
|
141
|
-
const apps = yield getAllApps({ dev, all });
|
|
135
|
+
const apps = (yield backend_core_1.db.getAllApps({ dev, all }));
|
|
142
136
|
const appIds = apps
|
|
143
137
|
.filter((app) => app.status === "development")
|
|
144
138
|
.map((app) => app.appId);
|
|
@@ -162,7 +156,7 @@ exports.fetch = fetch;
|
|
|
162
156
|
const fetchAppDefinition = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
163
157
|
const layouts = yield getLayouts();
|
|
164
158
|
const userRoleId = getUserRoleId(ctx);
|
|
165
|
-
const accessController = new AccessController();
|
|
159
|
+
const accessController = new backend_core_1.roles.AccessController();
|
|
166
160
|
const screens = yield accessController.checkScreensAccess(yield getScreens(), userRoleId);
|
|
167
161
|
ctx.body = {
|
|
168
162
|
layouts,
|
|
@@ -181,7 +175,7 @@ const fetchAppPackage = (ctx) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
181
175
|
// Only filter screens if the user is not a builder
|
|
182
176
|
if (!(ctx.user.builder && ctx.user.builder.global)) {
|
|
183
177
|
const userRoleId = getUserRoleId(ctx);
|
|
184
|
-
const accessController = new AccessController();
|
|
178
|
+
const accessController = new backend_core_1.roles.AccessController();
|
|
185
179
|
screens = yield accessController.checkScreensAccess(screens, userRoleId);
|
|
186
180
|
}
|
|
187
181
|
ctx.body = {
|
|
@@ -193,7 +187,7 @@ const fetchAppPackage = (ctx) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
193
187
|
});
|
|
194
188
|
exports.fetchAppPackage = fetchAppPackage;
|
|
195
189
|
const performAppCreate = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
196
|
-
const apps = yield getAllApps({ dev: true });
|
|
190
|
+
const apps = yield backend_core_1.db.getAllApps({ dev: true });
|
|
197
191
|
const name = ctx.request.body.name;
|
|
198
192
|
checkAppName(ctx, apps, name);
|
|
199
193
|
const url = (0, exports.getAppUrl)(ctx);
|
|
@@ -221,7 +215,7 @@ const performAppCreate = (ctx) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
221
215
|
url: url,
|
|
222
216
|
template: templateKey,
|
|
223
217
|
instance,
|
|
224
|
-
tenantId: getTenantId(),
|
|
218
|
+
tenantId: backend_core_1.tenancy.getTenantId(),
|
|
225
219
|
updatedAt: new Date().toISOString(),
|
|
226
220
|
createdAt: new Date().toISOString(),
|
|
227
221
|
status: utils_1.AppStatus.DEV,
|
|
@@ -276,7 +270,7 @@ const performAppCreate = (ctx) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
276
270
|
if (!environment_1.default.isTest()) {
|
|
277
271
|
yield (0, fileSystem_1.createApp)(appId);
|
|
278
272
|
}
|
|
279
|
-
yield
|
|
273
|
+
yield backend_core_1.cache.app.invalidateAppMetadata(appId, newApplication);
|
|
280
274
|
return newApplication;
|
|
281
275
|
});
|
|
282
276
|
const creationEvents = (request, app) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -286,25 +280,25 @@ const creationEvents = (request, app) => __awaiter(void 0, void 0, void 0, funct
|
|
|
286
280
|
if (body.useTemplate === "true") {
|
|
287
281
|
// from template
|
|
288
282
|
if (body.templateKey && body.templateKey !== "undefined") {
|
|
289
|
-
creationFns.push(a =>
|
|
283
|
+
creationFns.push(a => backend_core_1.events.app.templateImported(a, body.templateKey));
|
|
290
284
|
}
|
|
291
285
|
// from file
|
|
292
286
|
else if ((_a = request.files) === null || _a === void 0 ? void 0 : _a.templateFile) {
|
|
293
|
-
creationFns.push(a =>
|
|
287
|
+
creationFns.push(a => backend_core_1.events.app.fileImported(a));
|
|
294
288
|
}
|
|
295
289
|
// unknown
|
|
296
290
|
else {
|
|
297
291
|
console.error("Could not determine template creation event");
|
|
298
292
|
}
|
|
299
293
|
}
|
|
300
|
-
creationFns.push(a =>
|
|
294
|
+
creationFns.push(a => backend_core_1.events.app.created(a));
|
|
301
295
|
for (let fn of creationFns) {
|
|
302
296
|
yield fn(app);
|
|
303
297
|
}
|
|
304
298
|
});
|
|
305
299
|
const appPostCreate = (ctx, app) => __awaiter(void 0, void 0, void 0, function* () {
|
|
306
|
-
const tenantId = getTenantId();
|
|
307
|
-
yield
|
|
300
|
+
const tenantId = backend_core_1.tenancy.getTenantId();
|
|
301
|
+
yield backend_core_1.migrations.backPopulateMigrations({
|
|
308
302
|
type: types_1.MigrationType.APP,
|
|
309
303
|
tenantId,
|
|
310
304
|
appId: app.appId,
|
|
@@ -316,10 +310,12 @@ const appPostCreate = (ctx, app) => __awaiter(void 0, void 0, void 0, function*
|
|
|
316
310
|
const rowCount = rows ? rows.length : 0;
|
|
317
311
|
if (rowCount) {
|
|
318
312
|
try {
|
|
319
|
-
yield
|
|
313
|
+
yield backend_core_1.context.doInAppContext(app.appId, () => {
|
|
314
|
+
return pro_1.quotas.addRows(rowCount);
|
|
315
|
+
});
|
|
320
316
|
}
|
|
321
317
|
catch (err) {
|
|
322
|
-
if (err.code && err.code ===
|
|
318
|
+
if (err.code && err.code === backend_core_1.errors.codes.USAGE_LIMIT_EXCEEDED) {
|
|
323
319
|
// this import resulted in row usage exceeding the quota
|
|
324
320
|
// delete the app
|
|
325
321
|
// skip pre and post steps as no rows have been added to quotas yet
|
|
@@ -334,7 +330,7 @@ const appPostCreate = (ctx, app) => __awaiter(void 0, void 0, void 0, function*
|
|
|
334
330
|
const create = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
335
331
|
const newApplication = yield pro_1.quotas.addApp(() => performAppCreate(ctx));
|
|
336
332
|
yield appPostCreate(ctx, newApplication);
|
|
337
|
-
yield bustCache(CacheKeys.CHECKLIST);
|
|
333
|
+
yield backend_core_1.cache.bustCache(backend_core_1.cache.CacheKeys.CHECKLIST);
|
|
338
334
|
ctx.body = newApplication;
|
|
339
335
|
ctx.status = 200;
|
|
340
336
|
});
|
|
@@ -342,7 +338,7 @@ exports.create = create;
|
|
|
342
338
|
// This endpoint currently operates as a PATCH rather than a PUT
|
|
343
339
|
// Thus name and url fields are handled only if present
|
|
344
340
|
const update = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
345
|
-
const apps = yield getAllApps({ dev: true });
|
|
341
|
+
const apps = yield backend_core_1.db.getAllApps({ dev: true });
|
|
346
342
|
// validation
|
|
347
343
|
const name = ctx.request.body.name;
|
|
348
344
|
if (name) {
|
|
@@ -354,7 +350,7 @@ const update = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
354
350
|
ctx.request.body.url = url;
|
|
355
351
|
}
|
|
356
352
|
const app = yield (0, exports.updateAppPackage)(ctx.request.body, ctx.params.appId);
|
|
357
|
-
yield
|
|
353
|
+
yield backend_core_1.events.app.updated(app);
|
|
358
354
|
ctx.status = 200;
|
|
359
355
|
ctx.body = app;
|
|
360
356
|
});
|
|
@@ -376,7 +372,7 @@ const updateClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
376
372
|
revertableVersion: currentVersion,
|
|
377
373
|
};
|
|
378
374
|
const app = yield (0, exports.updateAppPackage)(appPackageUpdates, ctx.params.appId);
|
|
379
|
-
yield
|
|
375
|
+
yield backend_core_1.events.app.versionUpdated(app, currentVersion, updatedToVersion);
|
|
380
376
|
ctx.status = 200;
|
|
381
377
|
ctx.body = app;
|
|
382
378
|
});
|
|
@@ -400,7 +396,7 @@ const revertClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
400
396
|
revertableVersion: null,
|
|
401
397
|
};
|
|
402
398
|
const app = yield (0, exports.updateAppPackage)(appPackageUpdates, ctx.params.appId);
|
|
403
|
-
yield
|
|
399
|
+
yield backend_core_1.events.app.versionReverted(app, currentVersion, revertedToVersion);
|
|
404
400
|
ctx.status = 200;
|
|
405
401
|
ctx.body = app;
|
|
406
402
|
});
|
|
@@ -409,17 +405,17 @@ const destroyApp = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
409
405
|
let appId = ctx.params.appId;
|
|
410
406
|
let isUnpublish = ctx.query && ctx.query.unpublish;
|
|
411
407
|
if (isUnpublish) {
|
|
412
|
-
appId = getProdAppID(appId);
|
|
408
|
+
appId = backend_core_1.db.getProdAppID(appId);
|
|
413
409
|
}
|
|
414
410
|
const db = isUnpublish ? backend_core_1.context.getProdAppDB() : backend_core_1.context.getAppDB();
|
|
415
411
|
const app = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
416
412
|
const result = yield db.destroy();
|
|
417
413
|
if (isUnpublish) {
|
|
418
|
-
yield
|
|
414
|
+
yield backend_core_1.events.app.unpublished(app);
|
|
419
415
|
}
|
|
420
416
|
else {
|
|
421
417
|
yield pro_1.quotas.removeApp();
|
|
422
|
-
yield
|
|
418
|
+
yield backend_core_1.events.app.deleted(app);
|
|
423
419
|
}
|
|
424
420
|
/* istanbul ignore next */
|
|
425
421
|
if (!environment_1.default.isTest() && !isUnpublish) {
|
|
@@ -433,7 +429,7 @@ const destroyApp = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
433
429
|
else {
|
|
434
430
|
yield (0, workerRequests_1.removeAppFromUserRoles)(ctx, appId);
|
|
435
431
|
}
|
|
436
|
-
yield
|
|
432
|
+
yield backend_core_1.cache.app.invalidateAppMetadata(appId);
|
|
437
433
|
return result;
|
|
438
434
|
});
|
|
439
435
|
const preDestroyApp = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -464,19 +460,15 @@ const sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
464
460
|
return next();
|
|
465
461
|
}
|
|
466
462
|
const appId = ctx.params.appId;
|
|
467
|
-
if (!isDevAppID(appId)) {
|
|
463
|
+
if (!backend_core_1.db.isDevAppID(appId)) {
|
|
468
464
|
ctx.throw(400, "This action cannot be performed for production apps");
|
|
469
465
|
}
|
|
470
466
|
// replicate prod to dev
|
|
471
|
-
const prodAppId = getProdAppID(appId);
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
if (info.error)
|
|
477
|
-
throw info.error;
|
|
478
|
-
}
|
|
479
|
-
catch (err) {
|
|
467
|
+
const prodAppId = backend_core_1.db.getProdAppID(appId);
|
|
468
|
+
// specific case, want to make sure setup is skipped
|
|
469
|
+
const prodDb = backend_core_1.context.getProdAppDB({ skip_setup: true });
|
|
470
|
+
const exists = yield prodDb.exists();
|
|
471
|
+
if (!exists) {
|
|
480
472
|
// the database doesn't exist. Don't replicate
|
|
481
473
|
ctx.status = 200;
|
|
482
474
|
ctx.body = {
|
|
@@ -484,7 +476,7 @@ const sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
484
476
|
};
|
|
485
477
|
return next();
|
|
486
478
|
}
|
|
487
|
-
const replication = new Replication({
|
|
479
|
+
const replication = new backend_core_1.db.Replication({
|
|
488
480
|
source: prodAppId,
|
|
489
481
|
target: appId,
|
|
490
482
|
});
|
|
@@ -523,7 +515,7 @@ const updateAppPackage = (appPackage, appId) => __awaiter(void 0, void 0, void 0
|
|
|
523
515
|
delete newAppPackage.lockedBy;
|
|
524
516
|
yield db.put(newAppPackage);
|
|
525
517
|
// remove any cached metadata, so that it will be updated
|
|
526
|
-
yield
|
|
518
|
+
yield backend_core_1.cache.app.invalidateAppMetadata(appId);
|
|
527
519
|
return newAppPackage;
|
|
528
520
|
}));
|
|
529
521
|
});
|
|
@@ -14,12 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.deployApp = exports.deploymentProgress = exports.fetchDeployments = void 0;
|
|
16
16
|
const Deployment_1 = __importDefault(require("./Deployment"));
|
|
17
|
-
const
|
|
17
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
18
18
|
const utils_1 = require("../../../db/utils");
|
|
19
19
|
const utils_2 = require("../../../automations/utils");
|
|
20
|
-
const cache_1 = require("@budibase/backend-core/cache");
|
|
21
|
-
const context_1 = require("@budibase/backend-core/context");
|
|
22
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
23
20
|
const pro_1 = require("@budibase/pro");
|
|
24
21
|
const types_1 = require("@budibase/types");
|
|
25
22
|
// the max time we can wait for an invalidation to complete before considering it failed
|
|
@@ -49,7 +46,7 @@ function checkAllDeployments(deployments) {
|
|
|
49
46
|
function storeDeploymentHistory(deployment) {
|
|
50
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
48
|
const deploymentJSON = deployment.getJSON();
|
|
52
|
-
const db =
|
|
49
|
+
const db = backend_core_1.context.getAppDB();
|
|
53
50
|
let deploymentDoc;
|
|
54
51
|
try {
|
|
55
52
|
// theres only one deployment doc per app database
|
|
@@ -70,7 +67,7 @@ function storeDeploymentHistory(deployment) {
|
|
|
70
67
|
}
|
|
71
68
|
function initDeployedApp(prodAppId) {
|
|
72
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
const db =
|
|
70
|
+
const db = backend_core_1.context.getProdAppDB();
|
|
74
71
|
console.log("Reading automation docs");
|
|
75
72
|
const automations = (yield db.allDocs((0, utils_1.getAutomationParams)(null, {
|
|
76
73
|
include_docs: true,
|
|
@@ -93,9 +90,9 @@ function deployApp(deployment, userId) {
|
|
|
93
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
91
|
let replication;
|
|
95
92
|
try {
|
|
96
|
-
const appId =
|
|
97
|
-
const devAppId =
|
|
98
|
-
const productionAppId =
|
|
93
|
+
const appId = backend_core_1.context.getAppId();
|
|
94
|
+
const devAppId = backend_core_1.db.getDevelopmentAppID(appId);
|
|
95
|
+
const productionAppId = backend_core_1.db.getProdAppID(appId);
|
|
99
96
|
// don't try this if feature isn't allowed, will error
|
|
100
97
|
if (yield pro_1.backups.isEnabled()) {
|
|
101
98
|
// trigger backup initially
|
|
@@ -107,8 +104,8 @@ function deployApp(deployment, userId) {
|
|
|
107
104
|
source: devAppId,
|
|
108
105
|
target: productionAppId,
|
|
109
106
|
};
|
|
110
|
-
replication = new
|
|
111
|
-
const devDb =
|
|
107
|
+
replication = new backend_core_1.db.Replication(config);
|
|
108
|
+
const devDb = backend_core_1.context.getDevAppDB();
|
|
112
109
|
console.log("Compacting development DB");
|
|
113
110
|
yield devDb.compact();
|
|
114
111
|
console.log("Replication object created");
|
|
@@ -116,7 +113,7 @@ function deployApp(deployment, userId) {
|
|
|
116
113
|
console.log("replication complete.. replacing app meta doc");
|
|
117
114
|
// app metadata is excluded as it is likely to be in conflict
|
|
118
115
|
// replicate the app metadata document manually
|
|
119
|
-
const db =
|
|
116
|
+
const db = backend_core_1.context.getProdAppDB();
|
|
120
117
|
const appDoc = yield devDb.get(utils_1.DocumentType.APP_METADATA);
|
|
121
118
|
try {
|
|
122
119
|
const prodAppDoc = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
@@ -132,7 +129,7 @@ function deployApp(deployment, userId) {
|
|
|
132
129
|
// remove automation errors if they exist
|
|
133
130
|
delete appDoc.automationErrors;
|
|
134
131
|
yield db.put(appDoc);
|
|
135
|
-
yield
|
|
132
|
+
yield backend_core_1.cache.app.invalidateAppMetadata(productionAppId);
|
|
136
133
|
console.log("New app doc written successfully.");
|
|
137
134
|
yield initDeployedApp(productionAppId);
|
|
138
135
|
console.log("Deployed app initialised, setting deployment to successful");
|
|
@@ -155,7 +152,7 @@ function deployApp(deployment, userId) {
|
|
|
155
152
|
function fetchDeployments(ctx) {
|
|
156
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
154
|
try {
|
|
158
|
-
const db =
|
|
155
|
+
const db = backend_core_1.context.getAppDB();
|
|
159
156
|
const deploymentDoc = yield db.get(utils_1.DocumentType.DEPLOYMENTS);
|
|
160
157
|
const { updated, deployments } = yield checkAllDeployments(deploymentDoc);
|
|
161
158
|
if (updated) {
|
|
@@ -172,7 +169,7 @@ exports.fetchDeployments = fetchDeployments;
|
|
|
172
169
|
function deploymentProgress(ctx) {
|
|
173
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
174
171
|
try {
|
|
175
|
-
const db =
|
|
172
|
+
const db = backend_core_1.context.getAppDB();
|
|
176
173
|
const deploymentDoc = yield db.get(utils_1.DocumentType.DEPLOYMENTS);
|
|
177
174
|
ctx.body = deploymentDoc[ctx.params.deploymentId];
|
|
178
175
|
}
|
|
@@ -184,7 +181,7 @@ function deploymentProgress(ctx) {
|
|
|
184
181
|
exports.deploymentProgress = deploymentProgress;
|
|
185
182
|
const isFirstDeploy = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
186
183
|
try {
|
|
187
|
-
const db =
|
|
184
|
+
const db = backend_core_1.context.getProdAppDB();
|
|
188
185
|
yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
189
186
|
}
|
|
190
187
|
catch (e) {
|
|
@@ -8,24 +8,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getBudibaseVersion = exports.revert = exports.clearLock = exports.buildRedirectDelete = exports.buildRedirectPost = exports.buildRedirectGet = void 0;
|
|
16
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
17
|
+
const environment_1 = __importDefault(require("../../environment"));
|
|
18
|
+
const utilities_1 = require("../../utilities");
|
|
19
|
+
const workerRequests_1 = require("../../utilities/workerRequests");
|
|
20
|
+
const redis_1 = require("../../utilities/redis");
|
|
21
|
+
const utils_1 = require("../../db/utils");
|
|
22
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
23
|
+
const backend_core_2 = require("@budibase/backend-core");
|
|
21
24
|
function redirect(ctx, method, path = "global") {
|
|
22
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
26
|
const { devPath } = ctx.params;
|
|
24
27
|
const queryString = ctx.originalUrl.split("?")[1] || "";
|
|
25
|
-
const response = yield
|
|
28
|
+
const response = yield (0, node_fetch_1.default)((0, utilities_1.checkSlashesInUrl)(`${environment_1.default.WORKER_URL}/api/${path}/${devPath}?${queryString}`), (0, workerRequests_1.request)(ctx, {
|
|
26
29
|
method,
|
|
27
30
|
body: ctx.request.body,
|
|
28
|
-
}
|
|
31
|
+
}));
|
|
29
32
|
if (response.status !== 200) {
|
|
30
33
|
const err = yield response.text();
|
|
31
34
|
ctx.throw(400, err);
|
|
@@ -48,84 +51,96 @@ function redirect(ctx, method, path = "global") {
|
|
|
48
51
|
ctx.cookies;
|
|
49
52
|
});
|
|
50
53
|
}
|
|
51
|
-
|
|
52
|
-
return (ctx) => __awaiter(
|
|
54
|
+
function buildRedirectGet(path) {
|
|
55
|
+
return (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
53
56
|
yield redirect(ctx, "GET", path);
|
|
54
57
|
});
|
|
55
|
-
}
|
|
56
|
-
exports.
|
|
57
|
-
|
|
58
|
+
}
|
|
59
|
+
exports.buildRedirectGet = buildRedirectGet;
|
|
60
|
+
function buildRedirectPost(path) {
|
|
61
|
+
return (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
58
62
|
yield redirect(ctx, "POST", path);
|
|
59
63
|
});
|
|
60
|
-
}
|
|
61
|
-
exports.
|
|
62
|
-
|
|
64
|
+
}
|
|
65
|
+
exports.buildRedirectPost = buildRedirectPost;
|
|
66
|
+
function buildRedirectDelete(path) {
|
|
67
|
+
return (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
63
68
|
yield redirect(ctx, "DELETE", path);
|
|
64
69
|
});
|
|
65
|
-
}
|
|
66
|
-
exports.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
ctx.throw(400, `Unable to remove lock. ${err}`);
|
|
73
|
-
}
|
|
74
|
-
ctx.body = {
|
|
75
|
-
message: "Lock released successfully.",
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
exports.revert = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
-
const { appId } = ctx.params;
|
|
80
|
-
const productionAppId = getProdAppID(appId);
|
|
81
|
-
// App must have been deployed first
|
|
82
|
-
try {
|
|
83
|
-
const db = getProdAppDB({ skip_setup: true });
|
|
84
|
-
const info = yield db.info();
|
|
85
|
-
if (info.error) {
|
|
86
|
-
throw info.error;
|
|
70
|
+
}
|
|
71
|
+
exports.buildRedirectDelete = buildRedirectDelete;
|
|
72
|
+
function clearLock(ctx) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const { appId } = ctx.params;
|
|
75
|
+
try {
|
|
76
|
+
yield (0, redis_1.clearLock)(appId, ctx.user);
|
|
87
77
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Object.keys(deploymentDoc.history).length === 0) {
|
|
91
|
-
throw new Error("No deployments for app");
|
|
78
|
+
catch (err) {
|
|
79
|
+
ctx.throw(400, `Unable to remove lock. ${err}`);
|
|
92
80
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
const replication = new Replication({
|
|
98
|
-
source: productionAppId,
|
|
99
|
-
target: appId,
|
|
81
|
+
ctx.body = {
|
|
82
|
+
message: "Lock released successfully.",
|
|
83
|
+
};
|
|
100
84
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
85
|
+
}
|
|
86
|
+
exports.clearLock = clearLock;
|
|
87
|
+
function revert(ctx) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const { appId } = ctx.params;
|
|
90
|
+
const productionAppId = backend_core_2.db.getProdAppID(appId);
|
|
91
|
+
// App must have been deployed first
|
|
92
|
+
try {
|
|
93
|
+
const db = backend_core_1.context.getProdAppDB({ skip_setup: true });
|
|
94
|
+
const exists = yield db.exists();
|
|
95
|
+
if (!exists) {
|
|
96
|
+
throw new Error("App must be deployed to be reverted.");
|
|
97
|
+
}
|
|
98
|
+
const deploymentDoc = yield db.get(utils_1.DocumentType.DEPLOYMENTS);
|
|
99
|
+
if (!deploymentDoc.history ||
|
|
100
|
+
Object.keys(deploymentDoc.history).length === 0) {
|
|
101
|
+
throw new Error("No deployments for app");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
return ctx.throw(400, "App has not yet been deployed");
|
|
106
|
+
}
|
|
107
|
+
const replication = new backend_core_2.db.Replication({
|
|
108
|
+
source: productionAppId,
|
|
109
|
+
target: appId,
|
|
110
|
+
});
|
|
111
|
+
try {
|
|
112
|
+
if (environment_1.default.COUCH_DB_URL) {
|
|
113
|
+
// in-memory db stalls on rollback
|
|
114
|
+
yield replication.rollback();
|
|
115
|
+
}
|
|
116
|
+
// update appID in reverted app to be dev version again
|
|
117
|
+
const db = backend_core_1.context.getAppDB();
|
|
118
|
+
const appDoc = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
119
|
+
appDoc.appId = appId;
|
|
120
|
+
appDoc.instance._id = appId;
|
|
121
|
+
yield db.put(appDoc);
|
|
122
|
+
yield backend_core_2.cache.app.invalidateAppMetadata(appId);
|
|
123
|
+
ctx.body = {
|
|
124
|
+
message: "Reverted changes successfully.",
|
|
125
|
+
};
|
|
126
|
+
yield backend_core_2.events.app.reverted(appDoc);
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
ctx.throw(400, `Unable to revert. ${err}`);
|
|
105
130
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
131
|
+
finally {
|
|
132
|
+
yield replication.close();
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
exports.revert = revert;
|
|
137
|
+
function getBudibaseVersion(ctx) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
const version = require("../../../package.json").version;
|
|
113
140
|
ctx.body = {
|
|
114
|
-
|
|
141
|
+
version,
|
|
115
142
|
};
|
|
116
|
-
yield events.
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
yield replication.close();
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
exports.getBudibaseVersion = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
-
const version = require("../../../package.json").version;
|
|
127
|
-
ctx.body = {
|
|
128
|
-
version,
|
|
129
|
-
};
|
|
130
|
-
yield events.installation.versionChecked(version);
|
|
131
|
-
});
|
|
143
|
+
yield backend_core_2.events.installation.versionChecked(version);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
exports.getBudibaseVersion = getBudibaseVersion;
|
|
@@ -33,8 +33,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.destroy = exports.update = exports.read = exports.create = exports.search = void 0;
|
|
36
|
-
const
|
|
37
|
-
const { doInAppContext } = require("@budibase/backend-core/context");
|
|
36
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
38
37
|
const utils_1 = require("./utils");
|
|
39
38
|
const controller = __importStar(require("../application"));
|
|
40
39
|
function fixAppID(app, params) {
|
|
@@ -47,17 +46,26 @@ function fixAppID(app, params) {
|
|
|
47
46
|
return app;
|
|
48
47
|
}
|
|
49
48
|
function setResponseApp(ctx) {
|
|
49
|
+
var _a;
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const appId = (_a = ctx.body) === null || _a === void 0 ? void 0 : _a.appId;
|
|
52
|
+
if (appId && (!ctx.params || !ctx.params.appId)) {
|
|
53
|
+
ctx.params = { appId };
|
|
54
|
+
}
|
|
55
|
+
if (appId) {
|
|
56
|
+
yield backend_core_1.context.doInContext(appId, () => {
|
|
57
|
+
return controller.fetchAppPackage(ctx);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return controller.fetchAppPackage(ctx);
|
|
53
62
|
}
|
|
54
|
-
yield controller.fetchAppPackage(ctx);
|
|
55
63
|
});
|
|
56
64
|
}
|
|
57
65
|
function search(ctx, next) {
|
|
58
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
67
|
const { name } = ctx.request.body;
|
|
60
|
-
const apps = yield getAllApps({ all: true });
|
|
68
|
+
const apps = yield backend_core_1.db.getAllApps({ all: true });
|
|
61
69
|
ctx.body = (0, utils_1.search)(apps, name);
|
|
62
70
|
yield next();
|
|
63
71
|
});
|
|
@@ -76,7 +84,7 @@ function create(ctx, next) {
|
|
|
76
84
|
exports.create = create;
|
|
77
85
|
function read(ctx, next) {
|
|
78
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
yield doInAppContext(ctx.params.appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
yield backend_core_1.context.doInAppContext(ctx.params.appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
80
88
|
yield setResponseApp(ctx);
|
|
81
89
|
yield next();
|
|
82
90
|
}));
|
|
@@ -86,7 +94,7 @@ exports.read = read;
|
|
|
86
94
|
function update(ctx, next) {
|
|
87
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
96
|
ctx.request.body = yield (0, utils_1.addRev)(fixAppID(ctx.request.body, ctx.params));
|
|
89
|
-
yield doInAppContext(ctx.params.appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
yield backend_core_1.context.doInAppContext(ctx.params.appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
90
98
|
yield controller.update(ctx);
|
|
91
99
|
yield setResponseApp(ctx);
|
|
92
100
|
yield next();
|
|
@@ -96,7 +104,7 @@ function update(ctx, next) {
|
|
|
96
104
|
exports.update = update;
|
|
97
105
|
function destroy(ctx, next) {
|
|
98
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
yield doInAppContext(ctx.params.appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
yield backend_core_1.context.doInAppContext(ctx.params.appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
100
108
|
// get the app before deleting it
|
|
101
109
|
yield setResponseApp(ctx);
|
|
102
110
|
const body = ctx.body;
|