@budibase/server 2.1.43-alpha.8 → 2.1.43-alpha.9
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.29f946a8.js → index.1c5913ba.js} +1 -1
- package/builder/index.html +1 -1
- package/coverage/clover.xml +542 -514
- package/coverage/coverage-final.json +20 -15
- package/coverage/lcov-report/index.html +64 -34
- package/coverage/lcov-report/src/api/controllers/analytics.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/apikeys.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/application.ts.html +86 -233
- package/coverage/lcov-report/src/api/controllers/auth.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/automation.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/backup.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/cloud.ts.html +5 -2
- package/coverage/lcov-report/src/api/controllers/component.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/datasource.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/deploy/Deployment.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/deploy/index.html +1 -1
- 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 +28 -28
- package/coverage/lcov-report/src/api/controllers/integration.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/layout.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/metadata.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/migrations.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/permission.ts.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 +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 +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 +1 -1
- package/coverage/lcov-report/src/api/controllers/query/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/validation.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/role.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/routing.ts.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.ts.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.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/internalSearch.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/staticFormula.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/utils.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/screen.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/script.ts.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.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/external.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/index.ts.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.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/user.ts.html +13 -184
- package/coverage/lcov-report/src/api/controllers/view/exporters.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/utils.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/viewBuilder.ts.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.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/analytics.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/apikeys.ts.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.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/backup.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/cloud.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/component.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/datasource.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/deploy.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/dev.ts.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.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/layout.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/metadata.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/migrations.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/permission.ts.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 +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.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/role.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/routing.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/row.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/screen.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/script.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/static.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/table.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/templates.ts.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.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/user.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/utils/validators.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/view.ts.html +1 -1
- 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.ts.html +1 -1
- package/coverage/lcov-report/src/automations/automationUtils.ts.html +1 -1
- package/coverage/lcov-report/src/automations/bullboard.ts.html +1 -1
- package/coverage/lcov-report/src/automations/index.html +1 -1
- package/coverage/lcov-report/src/automations/index.ts.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.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/createRow.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/delay.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/discord.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/executeQuery.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/executeScript.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/filter.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/index.html +1 -1
- package/coverage/lcov-report/src/automations/steps/integromat.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/loop.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/outgoingWebhook.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/queryRows.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/sendSmtpEmail.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/serverLog.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/slack.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/updateRow.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/utils.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/zapier.ts.html +1 -1
- package/coverage/lcov-report/src/automations/tests/utilities/index.html +1 -1
- package/coverage/lcov-report/src/automations/tests/utilities/index.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/app.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/cron.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/index.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/rowDeleted.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/rowSaved.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/rowUpdated.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/webhook.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggers.ts.html +1 -1
- package/coverage/lcov-report/src/automations/utils.ts.html +1 -1
- package/coverage/lcov-report/src/constants/index.html +1 -1
- package/coverage/lcov-report/src/constants/index.ts.html +1 -1
- package/coverage/lcov-report/src/constants/layouts.ts.html +1 -1
- package/coverage/lcov-report/src/constants/screens.ts.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/datasource_bb_default.ts.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/employeeImport.ts.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/expensesImport.ts.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/index.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/inventoryImport.ts.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/jobsImport.ts.html +1 -1
- package/coverage/lcov-report/src/db/dynamoClient.ts.html +1 -1
- package/coverage/lcov-report/src/db/inMemoryView.ts.html +1 -1
- package/coverage/lcov-report/src/db/index.html +1 -1
- package/coverage/lcov-report/src/db/index.ts.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/LinkController.ts.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/LinkDocument.ts.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/index.ts.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/linkUtils.ts.html +1 -1
- package/coverage/lcov-report/src/db/newid.ts.html +1 -1
- package/coverage/lcov-report/src/db/utils.ts.html +1 -1
- 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.ts.html +1 -1
- package/coverage/lcov-report/src/events/AutomationEmitter.ts.html +1 -1
- package/coverage/lcov-report/src/events/BudibaseEmitter.ts.html +1 -1
- package/coverage/lcov-report/src/events/index.html +1 -1
- package/coverage/lcov-report/src/events/index.ts.html +1 -1
- package/coverage/lcov-report/src/events/utils.ts.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 +1 -1
- package/coverage/lcov-report/src/integrations/index.html +1 -1
- 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.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/authorized.ts.html +1 -1
- 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 +1 -1
- 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 +8 -29
- 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 +11 -11
- package/coverage/lcov-report/src/migrations/functions/syncQuotas.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/tableSettings.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/sdk/app/applications/index.html +146 -0
- package/coverage/lcov-report/src/sdk/app/applications/index.ts.html +106 -0
- package/coverage/lcov-report/src/sdk/app/applications/sync.ts.html +244 -0
- package/coverage/lcov-report/src/sdk/app/applications/utils.ts.html +136 -0
- package/coverage/lcov-report/src/sdk/app/automations/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +3 -3
- package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +6 -6
- package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +3 -3
- package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +17 -17
- package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +17 -17
- package/coverage/lcov-report/src/sdk/app/backups/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +5 -5
- package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +7 -7
- package/coverage/lcov-report/src/sdk/app/tables/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +5 -5
- package/coverage/lcov-report/src/sdk/index.html +5 -5
- package/coverage/lcov-report/src/sdk/index.ts.html +15 -12
- package/coverage/lcov-report/src/sdk/users/index.html +131 -0
- package/coverage/lcov-report/src/sdk/users/index.ts.html +100 -0
- package/coverage/lcov-report/src/sdk/users/utils.ts.html +277 -0
- package/coverage/lcov-report/src/startup.ts.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/TestConfiguration.ts.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/controllers.ts.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/index.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/index.ts.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/structures.ts.html +1 -1
- package/coverage/lcov-report/src/threads/automation.ts.html +1 -1
- 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.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/centralPath.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/csvParser.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/index.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/index.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/processor.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/global.ts.html +34 -34
- package/coverage/lcov-report/src/utilities/index.html +1 -1
- package/coverage/lcov-report/src/utilities/index.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/plugins.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/redis.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/src/utilities/routing/index.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/src/utilities/rowProcessor/index.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/rowProcessor/map.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/rowProcessor/utils.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/scriptRunner.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/security.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/statusCodes.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/usageQuota/index.html +15 -15
- package/coverage/lcov-report/src/utilities/usageQuota/rows.ts.html +13 -13
- package/coverage/lcov-report/src/utilities/usageQuota/usageQuoteReset.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/users.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/workerRequests.ts.html +1 -1
- package/coverage/lcov-report/src/watch.ts.html +1 -1
- package/coverage/lcov-report/src/websocket.ts.html +1 -1
- package/coverage/lcov.info +886 -842
- package/dist/api/controllers/application.js +419 -438
- package/dist/api/controllers/cloud.js +1 -0
- package/dist/api/controllers/user.js +7 -48
- package/dist/migrations/functions/appUrls.js +5 -9
- package/dist/package.json +6 -6
- package/dist/sdk/app/applications/index.js +28 -0
- package/dist/sdk/app/applications/sync.js +66 -0
- package/dist/sdk/app/applications/utils.js +21 -0
- package/dist/sdk/index.js +4 -2
- package/dist/sdk/users/index.js +27 -0
- package/dist/sdk/users/utils.js +65 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/api/controllers/application.ts +55 -104
- package/src/api/controllers/cloud.ts +1 -0
- package/src/api/controllers/user.ts +4 -61
- package/src/api/routes/tests/application.spec.js +0 -1
- package/src/migrations/functions/appUrls.ts +2 -9
- package/src/sdk/app/applications/index.ts +7 -0
- package/src/sdk/app/applications/sync.ts +53 -0
- package/src/sdk/app/applications/utils.ts +17 -0
- package/src/sdk/index.ts +4 -3
- package/src/sdk/users/index.ts +5 -0
- package/src/sdk/users/utils.ts +64 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.1.43-alpha.
|
|
4
|
+
"version": "2.1.43-alpha.9",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"license": "GPL-3.0",
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
46
|
-
"@budibase/backend-core": "2.1.43-alpha.
|
|
47
|
-
"@budibase/client": "2.1.43-alpha.
|
|
48
|
-
"@budibase/pro": "2.1.43-alpha.
|
|
49
|
-
"@budibase/string-templates": "2.1.43-alpha.
|
|
50
|
-
"@budibase/types": "2.1.43-alpha.
|
|
46
|
+
"@budibase/backend-core": "2.1.43-alpha.9",
|
|
47
|
+
"@budibase/client": "2.1.43-alpha.9",
|
|
48
|
+
"@budibase/pro": "2.1.43-alpha.8",
|
|
49
|
+
"@budibase/string-templates": "2.1.43-alpha.9",
|
|
50
|
+
"@budibase/types": "2.1.43-alpha.9",
|
|
51
51
|
"@bull-board/api": "3.7.0",
|
|
52
52
|
"@bull-board/koa": "3.9.4",
|
|
53
53
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -165,5 +165,5 @@
|
|
|
165
165
|
"optionalDependencies": {
|
|
166
166
|
"oracledb": "5.3.0"
|
|
167
167
|
},
|
|
168
|
-
"gitHead": "
|
|
168
|
+
"gitHead": "b31cceb0f8545a3a0fc16d09c366e2c89854583f"
|
|
169
169
|
}
|
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
} from "@budibase/backend-core"
|
|
27
27
|
import { USERS_TABLE_SCHEMA } from "../../constants"
|
|
28
28
|
import { buildDefaultDocs } from "../../db/defaultData/datasource_bb_default"
|
|
29
|
-
|
|
30
29
|
import { removeAppFromUserRoles } from "../../utilities/workerRequests"
|
|
31
30
|
import {
|
|
32
31
|
clientLibraryPath,
|
|
@@ -39,18 +38,22 @@ import {
|
|
|
39
38
|
backupClientLibrary,
|
|
40
39
|
revertClientLibrary,
|
|
41
40
|
} from "../../utilities/fileSystem/clientLibrary"
|
|
42
|
-
import { syncGlobalUsers } from "./user"
|
|
43
41
|
import { cleanupAutomations } from "../../automations/utils"
|
|
44
42
|
import { checkAppMetadata } from "../../automations/logging"
|
|
45
43
|
import { getUniqueRows } from "../../utilities/usageQuota/rows"
|
|
46
44
|
import { quotas, groups } from "@budibase/pro"
|
|
47
|
-
import {
|
|
45
|
+
import {
|
|
46
|
+
App,
|
|
47
|
+
Layout,
|
|
48
|
+
Screen,
|
|
49
|
+
MigrationType,
|
|
50
|
+
BBContext,
|
|
51
|
+
Database,
|
|
52
|
+
} from "@budibase/types"
|
|
48
53
|
import { BASE_LAYOUT_PROP_IDS } from "../../constants/layouts"
|
|
49
54
|
import { enrichPluginURLs } from "../../utilities/plugins"
|
|
50
55
|
import sdk from "../../sdk"
|
|
51
56
|
|
|
52
|
-
const URL_REGEX_SLASH = /\/|\\/g
|
|
53
|
-
|
|
54
57
|
// utility function, need to do away with this
|
|
55
58
|
async function getLayouts() {
|
|
56
59
|
const db = context.getAppDB()
|
|
@@ -74,29 +77,18 @@ async function getScreens() {
|
|
|
74
77
|
).rows.map((row: any) => row.doc)
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
function getUserRoleId(ctx:
|
|
78
|
-
return !ctx.user
|
|
80
|
+
function getUserRoleId(ctx: BBContext) {
|
|
81
|
+
return !ctx.user?.role || !ctx.user.role._id
|
|
79
82
|
? roles.BUILTIN_ROLE_IDS.PUBLIC
|
|
80
83
|
: ctx.user.role._id
|
|
81
84
|
}
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} else if (ctx.request.body.name) {
|
|
90
|
-
// otherwise use the name
|
|
91
|
-
url = encodeURI(`${ctx.request.body.name}`)
|
|
92
|
-
}
|
|
93
|
-
if (url) {
|
|
94
|
-
url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase()
|
|
95
|
-
}
|
|
96
|
-
return url
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const checkAppUrl = (ctx: any, apps: any, url: any, currentAppId?: string) => {
|
|
86
|
+
function checkAppUrl(
|
|
87
|
+
ctx: BBContext,
|
|
88
|
+
apps: App[],
|
|
89
|
+
url: string,
|
|
90
|
+
currentAppId?: string
|
|
91
|
+
) {
|
|
100
92
|
if (currentAppId) {
|
|
101
93
|
apps = apps.filter((app: any) => app.appId !== currentAppId)
|
|
102
94
|
}
|
|
@@ -105,12 +97,12 @@ const checkAppUrl = (ctx: any, apps: any, url: any, currentAppId?: string) => {
|
|
|
105
97
|
}
|
|
106
98
|
}
|
|
107
99
|
|
|
108
|
-
|
|
109
|
-
ctx:
|
|
110
|
-
apps:
|
|
111
|
-
name:
|
|
100
|
+
function checkAppName(
|
|
101
|
+
ctx: BBContext,
|
|
102
|
+
apps: App[],
|
|
103
|
+
name: string,
|
|
112
104
|
currentAppId?: string
|
|
113
|
-
)
|
|
105
|
+
) {
|
|
114
106
|
// TODO: Replace with Joi
|
|
115
107
|
if (!name) {
|
|
116
108
|
ctx.throw(400, "Name is required")
|
|
@@ -165,14 +157,14 @@ async function createInstance(template: any, includeSampleData: boolean) {
|
|
|
165
157
|
return { _id: appId }
|
|
166
158
|
}
|
|
167
159
|
|
|
168
|
-
|
|
160
|
+
async function addDefaultTables(db: Database) {
|
|
169
161
|
const defaultDbDocs = buildDefaultDocs()
|
|
170
162
|
|
|
171
163
|
// add in the default db data docs - tables, datasource, rows and links
|
|
172
164
|
await db.bulkDocs([...defaultDbDocs])
|
|
173
165
|
}
|
|
174
166
|
|
|
175
|
-
export
|
|
167
|
+
export async function fetch(ctx: BBContext) {
|
|
176
168
|
const dev = ctx.query && ctx.query.status === AppStatus.DEV
|
|
177
169
|
const all = ctx.query && ctx.query.status === AppStatus.ALL
|
|
178
170
|
const apps = (await dbCore.getAllApps({ dev, all })) as App[]
|
|
@@ -197,7 +189,7 @@ export const fetch = async (ctx: any) => {
|
|
|
197
189
|
ctx.body = await checkAppMetadata(apps)
|
|
198
190
|
}
|
|
199
191
|
|
|
200
|
-
export
|
|
192
|
+
export async function fetchAppDefinition(ctx: BBContext) {
|
|
201
193
|
const layouts = await getLayouts()
|
|
202
194
|
const userRoleId = getUserRoleId(ctx)
|
|
203
195
|
const accessController = new roles.AccessController()
|
|
@@ -212,7 +204,7 @@ export const fetchAppDefinition = async (ctx: any) => {
|
|
|
212
204
|
}
|
|
213
205
|
}
|
|
214
206
|
|
|
215
|
-
export
|
|
207
|
+
export async function fetchAppPackage(ctx: BBContext) {
|
|
216
208
|
const db = context.getAppDB()
|
|
217
209
|
let application = await db.get(DocumentType.APP_METADATA)
|
|
218
210
|
const layouts = await getLayouts()
|
|
@@ -222,7 +214,7 @@ export const fetchAppPackage = async (ctx: any) => {
|
|
|
222
214
|
application.usedPlugins = enrichPluginURLs(application.usedPlugins)
|
|
223
215
|
|
|
224
216
|
// Only filter screens if the user is not a builder
|
|
225
|
-
if (!(ctx.user
|
|
217
|
+
if (!(ctx.user?.builder && ctx.user.builder.global)) {
|
|
226
218
|
const userRoleId = getUserRoleId(ctx)
|
|
227
219
|
const accessController = new roles.AccessController()
|
|
228
220
|
screens = await accessController.checkScreensAccess(screens, userRoleId)
|
|
@@ -236,11 +228,12 @@ export const fetchAppPackage = async (ctx: any) => {
|
|
|
236
228
|
}
|
|
237
229
|
}
|
|
238
230
|
|
|
239
|
-
|
|
240
|
-
const apps = await dbCore.getAllApps({ dev: true })
|
|
241
|
-
const name = ctx.request.body.name
|
|
231
|
+
async function performAppCreate(ctx: BBContext) {
|
|
232
|
+
const apps = (await dbCore.getAllApps({ dev: true })) as App[]
|
|
233
|
+
const name = ctx.request.body.name,
|
|
234
|
+
possibleUrl = ctx.request.body.url
|
|
242
235
|
checkAppName(ctx, apps, name)
|
|
243
|
-
const url = getAppUrl(
|
|
236
|
+
const url = sdk.applications.getAppUrl({ name, url: possibleUrl })
|
|
244
237
|
checkAppUrl(ctx, apps, url)
|
|
245
238
|
|
|
246
239
|
const { useTemplate, templateKey, templateString } = ctx.request.body
|
|
@@ -331,7 +324,7 @@ const performAppCreate = async (ctx: any) => {
|
|
|
331
324
|
return newApplication
|
|
332
325
|
}
|
|
333
326
|
|
|
334
|
-
|
|
327
|
+
async function creationEvents(request: any, app: App) {
|
|
335
328
|
let creationFns: ((app: App) => Promise<void>)[] = []
|
|
336
329
|
|
|
337
330
|
const body = request.body
|
|
@@ -356,7 +349,7 @@ const creationEvents = async (request: any, app: App) => {
|
|
|
356
349
|
}
|
|
357
350
|
}
|
|
358
351
|
|
|
359
|
-
|
|
352
|
+
async function appPostCreate(ctx: BBContext, app: App) {
|
|
360
353
|
const tenantId = tenancy.getTenantId()
|
|
361
354
|
await migrations.backPopulateMigrations({
|
|
362
355
|
type: MigrationType.APP,
|
|
@@ -377,7 +370,7 @@ const appPostCreate = async (ctx: any, app: App) => {
|
|
|
377
370
|
if (err.code && err.code === errors.codes.USAGE_LIMIT_EXCEEDED) {
|
|
378
371
|
// this import resulted in row usage exceeding the quota
|
|
379
372
|
// delete the app
|
|
380
|
-
// skip pre and post
|
|
373
|
+
// skip pre- and post-steps as no rows have been added to quotas yet
|
|
381
374
|
ctx.params.appId = app.appId
|
|
382
375
|
await destroyApp(ctx)
|
|
383
376
|
}
|
|
@@ -387,7 +380,7 @@ const appPostCreate = async (ctx: any, app: App) => {
|
|
|
387
380
|
}
|
|
388
381
|
}
|
|
389
382
|
|
|
390
|
-
export
|
|
383
|
+
export async function create(ctx: BBContext) {
|
|
391
384
|
const newApplication = await quotas.addApp(() => performAppCreate(ctx))
|
|
392
385
|
await appPostCreate(ctx, newApplication)
|
|
393
386
|
await cache.bustCache(cache.CacheKey.CHECKLIST)
|
|
@@ -397,14 +390,15 @@ export const create = async (ctx: any) => {
|
|
|
397
390
|
|
|
398
391
|
// This endpoint currently operates as a PATCH rather than a PUT
|
|
399
392
|
// Thus name and url fields are handled only if present
|
|
400
|
-
export
|
|
401
|
-
const apps = await dbCore.getAllApps({ dev: true })
|
|
393
|
+
export async function update(ctx: BBContext) {
|
|
394
|
+
const apps = (await dbCore.getAllApps({ dev: true })) as App[]
|
|
402
395
|
// validation
|
|
403
|
-
const name = ctx.request.body.name
|
|
396
|
+
const name = ctx.request.body.name,
|
|
397
|
+
possibleUrl = ctx.request.body.url
|
|
404
398
|
if (name) {
|
|
405
399
|
checkAppName(ctx, apps, name, ctx.params.appId)
|
|
406
400
|
}
|
|
407
|
-
const url = getAppUrl(
|
|
401
|
+
const url = sdk.applications.getAppUrl({ name, url: possibleUrl })
|
|
408
402
|
if (url) {
|
|
409
403
|
checkAppUrl(ctx, apps, url, ctx.params.appId)
|
|
410
404
|
ctx.request.body.url = url
|
|
@@ -416,7 +410,7 @@ export const update = async (ctx: any) => {
|
|
|
416
410
|
ctx.body = app
|
|
417
411
|
}
|
|
418
412
|
|
|
419
|
-
export
|
|
413
|
+
export async function updateClient(ctx: BBContext) {
|
|
420
414
|
// Get current app version
|
|
421
415
|
const db = context.getAppDB()
|
|
422
416
|
const application = await db.get(DocumentType.APP_METADATA)
|
|
@@ -440,7 +434,7 @@ export const updateClient = async (ctx: any) => {
|
|
|
440
434
|
ctx.body = app
|
|
441
435
|
}
|
|
442
436
|
|
|
443
|
-
export
|
|
437
|
+
export async function revertClient(ctx: BBContext) {
|
|
444
438
|
// Check app can be reverted
|
|
445
439
|
const db = context.getAppDB()
|
|
446
440
|
const application = await db.get(DocumentType.APP_METADATA)
|
|
@@ -466,12 +460,15 @@ export const revertClient = async (ctx: any) => {
|
|
|
466
460
|
ctx.body = app
|
|
467
461
|
}
|
|
468
462
|
|
|
469
|
-
|
|
463
|
+
async function destroyApp(ctx: BBContext) {
|
|
470
464
|
let appId = ctx.params.appId
|
|
471
465
|
let isUnpublish = ctx.query && ctx.query.unpublish
|
|
472
466
|
|
|
473
467
|
if (isUnpublish) {
|
|
474
468
|
appId = dbCore.getProdAppID(appId)
|
|
469
|
+
const devAppId = dbCore.getDevAppID(appId)
|
|
470
|
+
// sync before removing the published app
|
|
471
|
+
await sdk.applications.syncApp(devAppId)
|
|
475
472
|
}
|
|
476
473
|
|
|
477
474
|
const db = isUnpublish ? context.getProdAppDB() : context.getAppDB()
|
|
@@ -501,12 +498,12 @@ const destroyApp = async (ctx: any) => {
|
|
|
501
498
|
return result
|
|
502
499
|
}
|
|
503
500
|
|
|
504
|
-
|
|
501
|
+
async function preDestroyApp(ctx: BBContext) {
|
|
505
502
|
const { rows } = await getUniqueRows([ctx.params.appId])
|
|
506
503
|
ctx.rowCount = rows.length
|
|
507
504
|
}
|
|
508
505
|
|
|
509
|
-
|
|
506
|
+
async function postDestroyApp(ctx: BBContext) {
|
|
510
507
|
const rowCount = ctx.rowCount
|
|
511
508
|
await groups.cleanupApp(ctx.params.appId)
|
|
512
509
|
if (rowCount) {
|
|
@@ -514,7 +511,7 @@ const postDestroyApp = async (ctx: any) => {
|
|
|
514
511
|
}
|
|
515
512
|
}
|
|
516
513
|
|
|
517
|
-
export
|
|
514
|
+
export async function destroy(ctx: BBContext) {
|
|
518
515
|
await preDestroyApp(ctx)
|
|
519
516
|
const result = await destroyApp(ctx)
|
|
520
517
|
await postDestroyApp(ctx)
|
|
@@ -522,62 +519,16 @@ export const destroy = async (ctx: any) => {
|
|
|
522
519
|
ctx.body = result
|
|
523
520
|
}
|
|
524
521
|
|
|
525
|
-
export
|
|
526
|
-
if (env.DISABLE_AUTO_PROD_APP_SYNC) {
|
|
527
|
-
ctx.status = 200
|
|
528
|
-
ctx.body = {
|
|
529
|
-
message:
|
|
530
|
-
"App sync disabled. You can reenable with the DISABLE_AUTO_PROD_APP_SYNC environment variable.",
|
|
531
|
-
}
|
|
532
|
-
return next()
|
|
533
|
-
}
|
|
534
|
-
|
|
522
|
+
export async function sync(ctx: BBContext) {
|
|
535
523
|
const appId = ctx.params.appId
|
|
536
|
-
if (!dbCore.isDevAppID(appId)) {
|
|
537
|
-
ctx.throw(400, "This action cannot be performed for production apps")
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
// replicate prod to dev
|
|
541
|
-
const prodAppId = dbCore.getProdAppID(appId)
|
|
542
|
-
|
|
543
|
-
// specific case, want to make sure setup is skipped
|
|
544
|
-
const prodDb = context.getProdAppDB({ skip_setup: true })
|
|
545
|
-
const exists = await prodDb.exists()
|
|
546
|
-
if (!exists) {
|
|
547
|
-
// the database doesn't exist. Don't replicate
|
|
548
|
-
ctx.status = 200
|
|
549
|
-
ctx.body = {
|
|
550
|
-
message: "App sync not required, app not deployed.",
|
|
551
|
-
}
|
|
552
|
-
return next()
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
const replication = new dbCore.Replication({
|
|
556
|
-
source: prodAppId,
|
|
557
|
-
target: appId,
|
|
558
|
-
})
|
|
559
|
-
let error
|
|
560
524
|
try {
|
|
561
|
-
await
|
|
562
|
-
} catch (err) {
|
|
563
|
-
|
|
564
|
-
} finally {
|
|
565
|
-
await replication.close()
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
// sync the users
|
|
569
|
-
await syncGlobalUsers()
|
|
570
|
-
|
|
571
|
-
if (error) {
|
|
572
|
-
ctx.throw(400, error)
|
|
573
|
-
} else {
|
|
574
|
-
ctx.body = {
|
|
575
|
-
message: "App sync completed successfully.",
|
|
576
|
-
}
|
|
525
|
+
ctx.body = await sdk.applications.syncApp(appId)
|
|
526
|
+
} catch (err: any) {
|
|
527
|
+
ctx.throw(err.status || 400, err.message)
|
|
577
528
|
}
|
|
578
529
|
}
|
|
579
530
|
|
|
580
|
-
export
|
|
531
|
+
export async function updateAppPackage(appPackage: any, appId: any) {
|
|
581
532
|
return context.doInAppContext(appId, async () => {
|
|
582
533
|
const db = context.getAppDB()
|
|
583
534
|
const application = await db.get(DocumentType.APP_METADATA)
|
|
@@ -598,7 +549,7 @@ export const updateAppPackage = async (appPackage: any, appId: any) => {
|
|
|
598
549
|
})
|
|
599
550
|
}
|
|
600
551
|
|
|
601
|
-
|
|
552
|
+
async function migrateAppNavigation() {
|
|
602
553
|
const db = context.getAppDB()
|
|
603
554
|
const existing: App = await db.get(DocumentType.APP_METADATA)
|
|
604
555
|
const layouts: Layout[] = await getLayouts()
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
generateUserMetadataID,
|
|
3
|
-
getUserMetadataParams,
|
|
4
|
-
generateUserFlagID,
|
|
5
|
-
} from "../../db/utils"
|
|
1
|
+
import { generateUserMetadataID, generateUserFlagID } from "../../db/utils"
|
|
6
2
|
import { InternalTables } from "../../db/utils"
|
|
7
3
|
import { getGlobalUsers, getRawGlobalUser } from "../../utilities/global"
|
|
8
4
|
import { getFullUser } from "../../utilities/users"
|
|
9
|
-
import { isEqual } from "lodash"
|
|
10
5
|
import {
|
|
11
6
|
context,
|
|
12
7
|
constants,
|
|
@@ -14,59 +9,7 @@ import {
|
|
|
14
9
|
db as dbCore,
|
|
15
10
|
} from "@budibase/backend-core"
|
|
16
11
|
import { BBContext, User } from "@budibase/types"
|
|
17
|
-
|
|
18
|
-
async function rawMetadata() {
|
|
19
|
-
const db = context.getAppDB()
|
|
20
|
-
return (
|
|
21
|
-
await db.allDocs(
|
|
22
|
-
getUserMetadataParams(null, {
|
|
23
|
-
include_docs: true,
|
|
24
|
-
})
|
|
25
|
-
)
|
|
26
|
-
).rows.map(row => row.doc)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function combineMetadataAndUser(user: any, metadata: any) {
|
|
30
|
-
// skip users with no access
|
|
31
|
-
if (user.roleId === rolesCore.BUILTIN_ROLE_IDS.PUBLIC) {
|
|
32
|
-
return null
|
|
33
|
-
}
|
|
34
|
-
delete user._rev
|
|
35
|
-
const metadataId = generateUserMetadataID(user._id)
|
|
36
|
-
const newDoc = {
|
|
37
|
-
...user,
|
|
38
|
-
_id: metadataId,
|
|
39
|
-
tableId: InternalTables.USER_METADATA,
|
|
40
|
-
}
|
|
41
|
-
const found = Array.isArray(metadata)
|
|
42
|
-
? metadata.find(doc => doc._id === metadataId)
|
|
43
|
-
: metadata
|
|
44
|
-
// copy rev over for the purposes of equality check
|
|
45
|
-
if (found) {
|
|
46
|
-
newDoc._rev = found._rev
|
|
47
|
-
}
|
|
48
|
-
if (found == null || !isEqual(newDoc, found)) {
|
|
49
|
-
return {
|
|
50
|
-
...found,
|
|
51
|
-
...newDoc,
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return null
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export async function syncGlobalUsers() {
|
|
58
|
-
// sync user metadata
|
|
59
|
-
const db = context.getAppDB()
|
|
60
|
-
const [users, metadata] = await Promise.all([getGlobalUsers(), rawMetadata()])
|
|
61
|
-
const toWrite = []
|
|
62
|
-
for (let user of users) {
|
|
63
|
-
const combined = await combineMetadataAndUser(user, metadata)
|
|
64
|
-
if (combined) {
|
|
65
|
-
toWrite.push(combined)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
await db.bulkDocs(toWrite)
|
|
69
|
-
}
|
|
12
|
+
import sdk from "../../sdk"
|
|
70
13
|
|
|
71
14
|
export async function syncUser(ctx: BBContext) {
|
|
72
15
|
let deleting = false,
|
|
@@ -123,7 +66,7 @@ export async function syncUser(ctx: BBContext) {
|
|
|
123
66
|
metadata.roleId = roleId
|
|
124
67
|
}
|
|
125
68
|
let combined = !deleting
|
|
126
|
-
? combineMetadataAndUser(user, metadata)
|
|
69
|
+
? sdk.users.combineMetadataAndUser(user, metadata)
|
|
127
70
|
: {
|
|
128
71
|
...metadata,
|
|
129
72
|
status: constants.UserStatus.INACTIVE,
|
|
@@ -143,7 +86,7 @@ export async function syncUser(ctx: BBContext) {
|
|
|
143
86
|
|
|
144
87
|
export async function fetchMetadata(ctx: BBContext) {
|
|
145
88
|
const global = await getGlobalUsers()
|
|
146
|
-
const metadata = await
|
|
89
|
+
const metadata = await sdk.users.rawUserMetadata()
|
|
147
90
|
const users = []
|
|
148
91
|
for (let user of global) {
|
|
149
92
|
// find the metadata that matches up to the global ID
|
|
@@ -17,7 +17,6 @@ const {
|
|
|
17
17
|
checkBuilderEndpoint,
|
|
18
18
|
} = require("./utilities/TestFunctions")
|
|
19
19
|
const setup = require("./utilities")
|
|
20
|
-
const { basicScreen, basicLayout } = setup.structures
|
|
21
20
|
const { AppStatus } = require("../../../db/utils")
|
|
22
21
|
const { events } = require("@budibase/backend-core")
|
|
23
22
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { db as dbCore } from "@budibase/backend-core"
|
|
2
|
-
import
|
|
2
|
+
import sdk from "../../sdk"
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Date:
|
|
@@ -20,14 +20,7 @@ export const run = async (appDb: any) => {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
if (!metadata.url) {
|
|
23
|
-
|
|
24
|
-
request: {
|
|
25
|
-
body: {
|
|
26
|
-
name: metadata.name,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
metadata.url = getAppUrl(context)
|
|
23
|
+
metadata.url = sdk.applications.getAppUrl({ name: metadata.name })
|
|
31
24
|
console.log(`Adding url to app: ${metadata.url}`)
|
|
32
25
|
await appDb.put(metadata)
|
|
33
26
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import env from "../../../environment"
|
|
2
|
+
import { db as dbCore, context } from "@budibase/backend-core"
|
|
3
|
+
import sdk from "../../"
|
|
4
|
+
|
|
5
|
+
export async function syncApp(appId: string) {
|
|
6
|
+
if (env.DISABLE_AUTO_PROD_APP_SYNC) {
|
|
7
|
+
return {
|
|
8
|
+
message:
|
|
9
|
+
"App sync disabled. You can reenable with the DISABLE_AUTO_PROD_APP_SYNC environment variable.",
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (dbCore.isProdAppID(appId)) {
|
|
14
|
+
throw new Error("This action cannot be performed for production apps")
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// replicate prod to dev
|
|
18
|
+
const prodAppId = dbCore.getProdAppID(appId)
|
|
19
|
+
|
|
20
|
+
// specific case, want to make sure setup is skipped
|
|
21
|
+
const prodDb = context.getProdAppDB({ skip_setup: true })
|
|
22
|
+
const exists = await prodDb.exists()
|
|
23
|
+
if (!exists) {
|
|
24
|
+
// the database doesn't exist. Don't replicate
|
|
25
|
+
return {
|
|
26
|
+
message: "App sync not required, app not deployed.",
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const replication = new dbCore.Replication({
|
|
31
|
+
source: prodAppId,
|
|
32
|
+
target: appId,
|
|
33
|
+
})
|
|
34
|
+
let error
|
|
35
|
+
try {
|
|
36
|
+
await replication.replicate(replication.appReplicateOpts())
|
|
37
|
+
} catch (err) {
|
|
38
|
+
error = err
|
|
39
|
+
} finally {
|
|
40
|
+
await replication.close()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// sync the users
|
|
44
|
+
await sdk.users.syncGlobalUsers()
|
|
45
|
+
|
|
46
|
+
if (error) {
|
|
47
|
+
throw error
|
|
48
|
+
} else {
|
|
49
|
+
return {
|
|
50
|
+
message: "App sync completed successfully.",
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const URL_REGEX_SLASH = /\/|\\/g
|
|
2
|
+
|
|
3
|
+
export function getAppUrl(opts?: { name?: string; url?: string }) {
|
|
4
|
+
// construct the url
|
|
5
|
+
let url
|
|
6
|
+
if (opts?.url) {
|
|
7
|
+
// if the url is provided, use that
|
|
8
|
+
url = encodeURI(opts?.url)
|
|
9
|
+
} else if (opts?.name) {
|
|
10
|
+
// otherwise use the name
|
|
11
|
+
url = encodeURI(`${opts?.name}`)
|
|
12
|
+
}
|
|
13
|
+
if (url) {
|
|
14
|
+
url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase()
|
|
15
|
+
}
|
|
16
|
+
return url as string
|
|
17
|
+
}
|
package/src/sdk/index.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { default as backups } from "./app/backups"
|
|
2
2
|
import { default as tables } from "./app/tables"
|
|
3
3
|
import { default as automations } from "./app/automations"
|
|
4
|
+
import { default as applications } from "./app/applications"
|
|
5
|
+
import { default as users } from "./users"
|
|
4
6
|
|
|
5
7
|
const sdk = {
|
|
6
8
|
backups,
|
|
7
9
|
tables,
|
|
8
10
|
automations,
|
|
11
|
+
applications,
|
|
12
|
+
users,
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
// default export for TS
|
|
12
16
|
export default sdk
|
|
13
|
-
|
|
14
|
-
// default export for JS
|
|
15
|
-
module.exports = sdk
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getGlobalUsers } from "../../utilities/global"
|
|
2
|
+
import { context, roles as rolesCore } from "@budibase/backend-core"
|
|
3
|
+
import {
|
|
4
|
+
generateUserMetadataID,
|
|
5
|
+
getUserMetadataParams,
|
|
6
|
+
InternalTables,
|
|
7
|
+
} from "../../db/utils"
|
|
8
|
+
import { isEqual } from "lodash"
|
|
9
|
+
|
|
10
|
+
export function combineMetadataAndUser(user: any, metadata: any) {
|
|
11
|
+
// skip users with no access
|
|
12
|
+
if (user.roleId === rolesCore.BUILTIN_ROLE_IDS.PUBLIC) {
|
|
13
|
+
return null
|
|
14
|
+
}
|
|
15
|
+
delete user._rev
|
|
16
|
+
const metadataId = generateUserMetadataID(user._id)
|
|
17
|
+
const newDoc = {
|
|
18
|
+
...user,
|
|
19
|
+
_id: metadataId,
|
|
20
|
+
tableId: InternalTables.USER_METADATA,
|
|
21
|
+
}
|
|
22
|
+
const found = Array.isArray(metadata)
|
|
23
|
+
? metadata.find(doc => doc._id === metadataId)
|
|
24
|
+
: metadata
|
|
25
|
+
// copy rev over for the purposes of equality check
|
|
26
|
+
if (found) {
|
|
27
|
+
newDoc._rev = found._rev
|
|
28
|
+
}
|
|
29
|
+
if (found == null || !isEqual(newDoc, found)) {
|
|
30
|
+
return {
|
|
31
|
+
...found,
|
|
32
|
+
...newDoc,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function rawUserMetadata() {
|
|
39
|
+
const db = context.getAppDB()
|
|
40
|
+
return (
|
|
41
|
+
await db.allDocs(
|
|
42
|
+
getUserMetadataParams(null, {
|
|
43
|
+
include_docs: true,
|
|
44
|
+
})
|
|
45
|
+
)
|
|
46
|
+
).rows.map(row => row.doc)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function syncGlobalUsers() {
|
|
50
|
+
// sync user metadata
|
|
51
|
+
const db = context.getAppDB()
|
|
52
|
+
const [users, metadata] = await Promise.all([
|
|
53
|
+
getGlobalUsers(),
|
|
54
|
+
rawUserMetadata(),
|
|
55
|
+
])
|
|
56
|
+
const toWrite = []
|
|
57
|
+
for (let user of users) {
|
|
58
|
+
const combined = await combineMetadataAndUser(user, metadata)
|
|
59
|
+
if (combined) {
|
|
60
|
+
toWrite.push(combined)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
await db.bulkDocs(toWrite)
|
|
64
|
+
}
|