@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
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { context, db as dbCore } from "@budibase/backend-core"
|
|
2
|
+
import { Database } from "@budibase/types"
|
|
2
3
|
import {
|
|
3
4
|
getDatasourceParams,
|
|
4
5
|
getTableParams,
|
|
5
6
|
getAutomationParams,
|
|
6
7
|
getScreenParams,
|
|
7
8
|
} from "../../../db/utils"
|
|
8
|
-
import PouchDB from "pouchdb"
|
|
9
9
|
|
|
10
|
-
async function runInContext(appId: string, cb: any, db?:
|
|
10
|
+
async function runInContext(appId: string, cb: any, db?: Database) {
|
|
11
11
|
if (db) {
|
|
12
12
|
return cb(db)
|
|
13
13
|
} else {
|
|
@@ -19,13 +19,10 @@ async function runInContext(appId: string, cb: any, db?: PouchDB.Database) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export async function calculateDatasourceCount(
|
|
23
|
-
appId: string,
|
|
24
|
-
db?: PouchDB.Database
|
|
25
|
-
) {
|
|
22
|
+
export async function calculateDatasourceCount(appId: string, db?: Database) {
|
|
26
23
|
return runInContext(
|
|
27
24
|
appId,
|
|
28
|
-
async (db:
|
|
25
|
+
async (db: Database) => {
|
|
29
26
|
const datasourceList = await db.allDocs(getDatasourceParams())
|
|
30
27
|
const tableList = await db.allDocs(getTableParams())
|
|
31
28
|
return datasourceList.rows.length + tableList.rows.length
|
|
@@ -34,13 +31,10 @@ export async function calculateDatasourceCount(
|
|
|
34
31
|
)
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
export async function calculateAutomationCount(
|
|
38
|
-
appId: string,
|
|
39
|
-
db?: PouchDB.Database
|
|
40
|
-
) {
|
|
34
|
+
export async function calculateAutomationCount(appId: string, db?: Database) {
|
|
41
35
|
return runInContext(
|
|
42
36
|
appId,
|
|
43
|
-
async (db:
|
|
37
|
+
async (db: Database) => {
|
|
44
38
|
const automationList = await db.allDocs(getAutomationParams())
|
|
45
39
|
return automationList.rows.length
|
|
46
40
|
},
|
|
@@ -48,13 +42,10 @@ export async function calculateAutomationCount(
|
|
|
48
42
|
)
|
|
49
43
|
}
|
|
50
44
|
|
|
51
|
-
export async function calculateScreenCount(
|
|
52
|
-
appId: string,
|
|
53
|
-
db?: PouchDB.Database
|
|
54
|
-
) {
|
|
45
|
+
export async function calculateScreenCount(appId: string, db?: Database) {
|
|
55
46
|
return runInContext(
|
|
56
47
|
appId,
|
|
57
|
-
async (db:
|
|
48
|
+
async (db: Database) => {
|
|
58
49
|
const screenList = await db.allDocs(getScreenParams())
|
|
59
50
|
return screenList.rows.length
|
|
60
51
|
},
|
|
@@ -63,7 +54,7 @@ export async function calculateScreenCount(
|
|
|
63
54
|
}
|
|
64
55
|
|
|
65
56
|
export async function calculateBackupStats(appId: string) {
|
|
66
|
-
return runInContext(appId, async (db:
|
|
57
|
+
return runInContext(appId, async (db: Database) => {
|
|
67
58
|
const promises = []
|
|
68
59
|
promises.push(calculateDatasourceCount(appId, db))
|
|
69
60
|
promises.push(calculateAutomationCount(appId, db))
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { context } from "@budibase/backend-core"
|
|
2
2
|
import { BudibaseInternalDB, getTableParams } from "../../../db/utils"
|
|
3
3
|
import {
|
|
4
4
|
breakExternalTableId,
|
|
5
5
|
isExternalTable,
|
|
6
6
|
isSQL,
|
|
7
7
|
} from "../../../integrations/utils"
|
|
8
|
-
import { Table } from "@budibase/types"
|
|
9
|
-
import PouchDB from "pouchdb"
|
|
8
|
+
import { Table, Database } from "@budibase/types"
|
|
10
9
|
|
|
11
|
-
async function getAllInternalTables(db?:
|
|
10
|
+
async function getAllInternalTables(db?: Database): Promise<Table[]> {
|
|
12
11
|
if (!db) {
|
|
13
|
-
db = getAppDB()
|
|
12
|
+
db = context.getAppDB()
|
|
14
13
|
}
|
|
15
14
|
const internalTables = await db.allDocs(
|
|
16
15
|
getTableParams(null, {
|
|
@@ -25,7 +24,7 @@ async function getAllInternalTables(db?: PouchDB.Database): Promise<Table[]> {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
async function getAllExternalTables(datasourceId: any): Promise<Table[]> {
|
|
28
|
-
const db = getAppDB()
|
|
27
|
+
const db = context.getAppDB()
|
|
29
28
|
const datasource = await db.get(datasourceId)
|
|
30
29
|
if (!datasource || !datasource.entities) {
|
|
31
30
|
throw "Datasource is not configured fully."
|
|
@@ -42,7 +41,7 @@ async function getExternalTable(
|
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
async function getTable(tableId: any): Promise<Table> {
|
|
45
|
-
const db = getAppDB()
|
|
44
|
+
const db = context.getAppDB()
|
|
46
45
|
if (isExternalTable(tableId)) {
|
|
47
46
|
let { datasourceId, tableName } = breakExternalTableId(tableId)
|
|
48
47
|
const datasource = await db.get(datasourceId)
|
|
@@ -16,7 +16,7 @@ const {
|
|
|
16
16
|
const controllers = require("./controllers")
|
|
17
17
|
const supertest = require("supertest")
|
|
18
18
|
const { cleanup } = require("../../utilities/fileSystem")
|
|
19
|
-
const {
|
|
19
|
+
const { Cookie, Header } = require("@budibase/backend-core/constants")
|
|
20
20
|
const { jwt } = require("@budibase/backend-core/auth")
|
|
21
21
|
const { doInTenant, doWithGlobalDB } = require("@budibase/backend-core/tenancy")
|
|
22
22
|
const { createASession } = require("@budibase/backend-core/sessions")
|
|
@@ -256,10 +256,10 @@ class TestConfiguration {
|
|
|
256
256
|
return {
|
|
257
257
|
Accept: "application/json",
|
|
258
258
|
Cookie: [
|
|
259
|
-
`${
|
|
260
|
-
`${
|
|
259
|
+
`${Cookie.Auth}=${authToken}`,
|
|
260
|
+
`${Cookie.CurrentApp}=${appToken}`,
|
|
261
261
|
],
|
|
262
|
-
[
|
|
262
|
+
[Header.APP_ID]: appId,
|
|
263
263
|
}
|
|
264
264
|
})
|
|
265
265
|
}
|
|
@@ -279,14 +279,14 @@ class TestConfiguration {
|
|
|
279
279
|
const headers = {
|
|
280
280
|
Accept: "application/json",
|
|
281
281
|
Cookie: [
|
|
282
|
-
`${
|
|
283
|
-
`${
|
|
282
|
+
`${Cookie.Auth}=${authToken}`,
|
|
283
|
+
`${Cookie.CurrentApp}=${appToken}`,
|
|
284
284
|
],
|
|
285
|
-
[
|
|
285
|
+
[Header.CSRF_TOKEN]: CSRF_TOKEN,
|
|
286
286
|
...extras,
|
|
287
287
|
}
|
|
288
288
|
if (this.appId) {
|
|
289
|
-
headers[
|
|
289
|
+
headers[Header.APP_ID] = this.appId
|
|
290
290
|
}
|
|
291
291
|
return headers
|
|
292
292
|
}
|
|
@@ -298,7 +298,7 @@ class TestConfiguration {
|
|
|
298
298
|
Accept: "application/json",
|
|
299
299
|
}
|
|
300
300
|
if (appId) {
|
|
301
|
-
headers[
|
|
301
|
+
headers[Header.APP_ID] = appId
|
|
302
302
|
}
|
|
303
303
|
return headers
|
|
304
304
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
2
|
-
const {
|
|
2
|
+
const { BuiltinPermissionID } = require("@budibase/backend-core/permissions")
|
|
3
3
|
const { createHomeScreen } = require("../../constants/screens")
|
|
4
4
|
const { EMPTY_LAYOUT } = require("../../constants/layouts")
|
|
5
5
|
const { cloneDeep } = require("lodash/fp")
|
|
@@ -135,7 +135,7 @@ exports.basicRole = () => {
|
|
|
135
135
|
return {
|
|
136
136
|
name: "NewRole",
|
|
137
137
|
inherits: BUILTIN_ROLE_IDS.BASIC,
|
|
138
|
-
permissionId:
|
|
138
|
+
permissionId: BuiltinPermissionID.READ_ONLY,
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
@@ -120,7 +120,7 @@ class Orchestrator {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
async getMetadata(): Promise<AutomationMetadata> {
|
|
123
|
-
const metadataId = generateAutomationMetadataID(this._automation._id)
|
|
123
|
+
const metadataId = generateAutomationMetadataID(this._automation._id!)
|
|
124
124
|
const db = getAppDB()
|
|
125
125
|
let metadata: AutomationMetadata
|
|
126
126
|
try {
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { getMultiIDParams, getGlobalIDFromUserMetadataID } from "../db/utils"
|
|
2
|
+
import {
|
|
3
|
+
roles,
|
|
4
|
+
db as dbCore,
|
|
5
|
+
cache,
|
|
6
|
+
tenancy,
|
|
7
|
+
context,
|
|
8
|
+
} from "@budibase/backend-core"
|
|
9
|
+
import env from "../environment"
|
|
10
|
+
import { groups } from "@budibase/pro"
|
|
11
|
+
import { BBContext, ContextUser, User } from "@budibase/types"
|
|
12
|
+
|
|
13
|
+
export function updateAppRole(
|
|
14
|
+
user: ContextUser,
|
|
15
|
+
{ appId }: { appId?: string } = {}
|
|
16
|
+
) {
|
|
17
|
+
appId = appId || context.getAppId()
|
|
18
|
+
|
|
19
|
+
if (!user || !user.roles) {
|
|
20
|
+
return user
|
|
21
|
+
}
|
|
22
|
+
// if in an multi-tenancy environment make sure roles are never updated
|
|
23
|
+
if (env.MULTI_TENANCY && appId && !tenancy.isUserInAppTenant(appId, user)) {
|
|
24
|
+
delete user.builder
|
|
25
|
+
delete user.admin
|
|
26
|
+
user.roleId = roles.BUILTIN_ROLE_IDS.PUBLIC
|
|
27
|
+
return user
|
|
28
|
+
}
|
|
29
|
+
// always use the deployed app
|
|
30
|
+
if (appId) {
|
|
31
|
+
user.roleId = user.roles[dbCore.getProdAppID(appId)]
|
|
32
|
+
}
|
|
33
|
+
// if a role wasn't found then either set as admin (builder) or public (everyone else)
|
|
34
|
+
if (!user.roleId && user.builder && user.builder.global) {
|
|
35
|
+
user.roleId = roles.BUILTIN_ROLE_IDS.ADMIN
|
|
36
|
+
} else if (!user.roleId && !user?.userGroups?.length) {
|
|
37
|
+
user.roleId = roles.BUILTIN_ROLE_IDS.PUBLIC
|
|
38
|
+
} else if (user?.userGroups?.length) {
|
|
39
|
+
user.roleId = undefined
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
delete user.roles
|
|
43
|
+
return user
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function checkGroupRoles(
|
|
47
|
+
user: ContextUser,
|
|
48
|
+
{ appId }: { appId?: string } = {}
|
|
49
|
+
) {
|
|
50
|
+
if (user.roleId && user.roleId !== roles.BUILTIN_ROLE_IDS.PUBLIC) {
|
|
51
|
+
return user
|
|
52
|
+
}
|
|
53
|
+
if (appId) {
|
|
54
|
+
user.roleId = await groups.getGroupRoleId(user as User, appId)
|
|
55
|
+
}
|
|
56
|
+
return user
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function processUser(
|
|
60
|
+
user: ContextUser,
|
|
61
|
+
{ appId }: { appId?: string } = {}
|
|
62
|
+
) {
|
|
63
|
+
if (user) {
|
|
64
|
+
delete user.password
|
|
65
|
+
}
|
|
66
|
+
user = await updateAppRole(user, { appId })
|
|
67
|
+
if (!user.roleId && user?.userGroups?.length) {
|
|
68
|
+
user = await checkGroupRoles(user, { appId })
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return user
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function getCachedSelf(ctx: BBContext, appId: string) {
|
|
75
|
+
// this has to be tenant aware, can't depend on the context to find it out
|
|
76
|
+
// running some middlewares before the tenancy causes context to break
|
|
77
|
+
const user = await cache.user.getUser(ctx.user?._id!)
|
|
78
|
+
return processUser(user, { appId })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function getRawGlobalUser(userId: string) {
|
|
82
|
+
const db = tenancy.getGlobalDB()
|
|
83
|
+
return db.get(getGlobalIDFromUserMetadataID(userId))
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function getGlobalUser(userId: string) {
|
|
87
|
+
const appId = context.getAppId()
|
|
88
|
+
let user = await getRawGlobalUser(userId)
|
|
89
|
+
return processUser(user, { appId })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export async function getGlobalUsers(users?: ContextUser[]) {
|
|
93
|
+
const appId = context.getAppId()
|
|
94
|
+
const db = tenancy.getGlobalDB()
|
|
95
|
+
let globalUsers
|
|
96
|
+
if (users) {
|
|
97
|
+
const globalIds = users.map(user =>
|
|
98
|
+
getGlobalIDFromUserMetadataID(user._id!)
|
|
99
|
+
)
|
|
100
|
+
globalUsers = (await db.allDocs(getMultiIDParams(globalIds))).rows.map(
|
|
101
|
+
row => row.doc
|
|
102
|
+
)
|
|
103
|
+
} else {
|
|
104
|
+
globalUsers = (
|
|
105
|
+
await db.allDocs(
|
|
106
|
+
dbCore.getGlobalUserParams(null, {
|
|
107
|
+
include_docs: true,
|
|
108
|
+
})
|
|
109
|
+
)
|
|
110
|
+
).rows.map(row => row.doc)
|
|
111
|
+
}
|
|
112
|
+
globalUsers = globalUsers
|
|
113
|
+
.filter(user => user != null)
|
|
114
|
+
.map(user => {
|
|
115
|
+
delete user.password
|
|
116
|
+
delete user.forceResetPassword
|
|
117
|
+
return user
|
|
118
|
+
})
|
|
119
|
+
if (!appId) {
|
|
120
|
+
return globalUsers
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return globalUsers.map(user => updateAppRole(user))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export async function getGlobalUsersFromMetadata(users: ContextUser[]) {
|
|
127
|
+
const globalUsers = await getGlobalUsers(users)
|
|
128
|
+
return users.map(user => {
|
|
129
|
+
const globalUser = globalUsers.find(
|
|
130
|
+
globalUser => globalUser && user._id?.includes(globalUser._id)
|
|
131
|
+
)
|
|
132
|
+
return {
|
|
133
|
+
...globalUser,
|
|
134
|
+
// doing user second overwrites the id and rev (always metadata)
|
|
135
|
+
...user,
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
PermissionLevel,
|
|
3
|
+
PermissionType,
|
|
4
4
|
getBuiltinPermissionByID,
|
|
5
5
|
isPermissionLevelHigherThanRead,
|
|
6
6
|
} = require("@budibase/backend-core/permissions")
|
|
@@ -11,9 +11,9 @@ const {
|
|
|
11
11
|
const { DocumentType } = require("../db/utils")
|
|
12
12
|
|
|
13
13
|
const CURRENTLY_SUPPORTED_LEVELS = [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
PermissionLevel.WRITE,
|
|
15
|
+
PermissionLevel.READ,
|
|
16
|
+
PermissionLevel.EXECUTE,
|
|
17
17
|
]
|
|
18
18
|
|
|
19
19
|
exports.getPermissionType = resourceId => {
|
|
@@ -23,17 +23,17 @@ exports.getPermissionType = resourceId => {
|
|
|
23
23
|
switch (docType) {
|
|
24
24
|
case DocumentType.TABLE:
|
|
25
25
|
case DocumentType.ROW:
|
|
26
|
-
return
|
|
26
|
+
return PermissionType.TABLE
|
|
27
27
|
case DocumentType.AUTOMATION:
|
|
28
|
-
return
|
|
28
|
+
return PermissionType.AUTOMATION
|
|
29
29
|
case DocumentType.WEBHOOK:
|
|
30
|
-
return
|
|
30
|
+
return PermissionType.WEBHOOK
|
|
31
31
|
case DocumentType.QUERY:
|
|
32
32
|
case DocumentType.DATASOURCE:
|
|
33
|
-
return
|
|
33
|
+
return PermissionType.QUERY
|
|
34
34
|
default:
|
|
35
35
|
// views don't have an ID, will end up here
|
|
36
|
-
return
|
|
36
|
+
return PermissionType.VIEW
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -58,8 +58,8 @@ exports.getBasePermissions = resourceId => {
|
|
|
58
58
|
const level = typedPermission.level
|
|
59
59
|
permissions[level] = lowerBuiltinRoleID(permissions[level], roleId)
|
|
60
60
|
if (isPermissionLevelHigherThanRead(level)) {
|
|
61
|
-
permissions[
|
|
62
|
-
permissions[
|
|
61
|
+
permissions[PermissionLevel.READ] = lowerBuiltinRoleID(
|
|
62
|
+
permissions[PermissionLevel.READ],
|
|
63
63
|
roleId
|
|
64
64
|
)
|
|
65
65
|
}
|
|
@@ -3,7 +3,7 @@ const env = require("../environment")
|
|
|
3
3
|
const { checkSlashesInUrl } = require("./index")
|
|
4
4
|
const { getProdAppID } = require("@budibase/backend-core/db")
|
|
5
5
|
const { updateAppRole } = require("./global")
|
|
6
|
-
const {
|
|
6
|
+
const { Header } = require("@budibase/backend-core/constants")
|
|
7
7
|
const { getTenantId, isTenantIdSet } = require("@budibase/backend-core/tenancy")
|
|
8
8
|
|
|
9
9
|
function request(ctx, request) {
|
|
@@ -11,9 +11,9 @@ function request(ctx, request) {
|
|
|
11
11
|
request.headers = {}
|
|
12
12
|
}
|
|
13
13
|
if (!ctx) {
|
|
14
|
-
request.headers[
|
|
14
|
+
request.headers[Header.API_KEY] = env.INTERNAL_API_KEY
|
|
15
15
|
if (isTenantIdSet()) {
|
|
16
|
-
request.headers[
|
|
16
|
+
request.headers[Header.TENANT_ID] = getTenantId()
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
if (request.body && Object.keys(request.body).length > 0) {
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const { isDevAppID, isProdAppID } = require("../db/utils")
|
|
2
|
-
|
|
3
|
-
exports.AppType = {
|
|
4
|
-
DEV: "dev",
|
|
5
|
-
PROD: "prod",
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
exports.middleware =
|
|
9
|
-
({ appType } = {}) =>
|
|
10
|
-
(ctx, next) => {
|
|
11
|
-
const appId = ctx.appId
|
|
12
|
-
if (appType === exports.AppType.DEV && appId && !isDevAppID(appId)) {
|
|
13
|
-
ctx.throw(400, "Only apps in development support this endpoint")
|
|
14
|
-
}
|
|
15
|
-
if (appType === exports.AppType.PROD && appId && !isProdAppID(appId)) {
|
|
16
|
-
ctx.throw(400, "Only apps in production support this endpoint")
|
|
17
|
-
}
|
|
18
|
-
return next()
|
|
19
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const { Headers } = require("@budibase/backend-core/constants")
|
|
2
|
-
const { getAppIdFromCtx } = require("@budibase/backend-core/utils")
|
|
3
|
-
|
|
4
|
-
module.exports = function ({ requiresAppId } = {}) {
|
|
5
|
-
return async (ctx, next) => {
|
|
6
|
-
const appId = await getAppIdFromCtx(ctx)
|
|
7
|
-
if (requiresAppId && !appId) {
|
|
8
|
-
ctx.throw(
|
|
9
|
-
400,
|
|
10
|
-
`Invalid app ID provided, please check the ${Headers.APP_ID} header.`
|
|
11
|
-
)
|
|
12
|
-
}
|
|
13
|
-
if (!ctx.headers[Headers.API_KEY]) {
|
|
14
|
-
ctx.throw(
|
|
15
|
-
400,
|
|
16
|
-
`Invalid API key provided, please check the ${Headers.API_KEY} header.`
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
return next()
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/utilities/global.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
getMultiIDParams,
|
|
3
|
-
getGlobalIDFromUserMetadataID,
|
|
4
|
-
} = require("../db/utils")
|
|
5
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
6
|
-
const { getProdAppID } = require("@budibase/backend-core/db")
|
|
7
|
-
const { getGlobalUserParams } = require("@budibase/backend-core/db")
|
|
8
|
-
const { user: userCache } = require("@budibase/backend-core/cache")
|
|
9
|
-
const {
|
|
10
|
-
getGlobalDB,
|
|
11
|
-
isUserInAppTenant,
|
|
12
|
-
} = require("@budibase/backend-core/tenancy")
|
|
13
|
-
const env = require("../environment")
|
|
14
|
-
const { getAppId } = require("@budibase/backend-core/context")
|
|
15
|
-
const { groups } = require("@budibase/pro")
|
|
16
|
-
|
|
17
|
-
exports.updateAppRole = (user, { appId } = {}) => {
|
|
18
|
-
appId = appId || getAppId()
|
|
19
|
-
|
|
20
|
-
if (!user || !user.roles) {
|
|
21
|
-
return user
|
|
22
|
-
}
|
|
23
|
-
// if in an multi-tenancy environment make sure roles are never updated
|
|
24
|
-
if (env.MULTI_TENANCY && !isUserInAppTenant(appId, user)) {
|
|
25
|
-
delete user.builder
|
|
26
|
-
delete user.admin
|
|
27
|
-
user.roleId = BUILTIN_ROLE_IDS.PUBLIC
|
|
28
|
-
return user
|
|
29
|
-
}
|
|
30
|
-
// always use the deployed app
|
|
31
|
-
user.roleId = user.roles[getProdAppID(appId)]
|
|
32
|
-
// if a role wasn't found then either set as admin (builder) or public (everyone else)
|
|
33
|
-
if (!user.roleId && user.builder && user.builder.global) {
|
|
34
|
-
user.roleId = BUILTIN_ROLE_IDS.ADMIN
|
|
35
|
-
} else if (!user.roleId && !user?.userGroups?.length) {
|
|
36
|
-
user.roleId = BUILTIN_ROLE_IDS.PUBLIC
|
|
37
|
-
} else if (user?.userGroups?.length) {
|
|
38
|
-
user.roleId = null
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
delete user.roles
|
|
42
|
-
return user
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async function checkGroupRoles(user, { appId } = {}) {
|
|
46
|
-
if (user.roleId && user.roleId !== BUILTIN_ROLE_IDS.PUBLIC) {
|
|
47
|
-
return user
|
|
48
|
-
}
|
|
49
|
-
user.roleId = await groups.getGroupRoleId(user, appId)
|
|
50
|
-
return user
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function processUser(user, { appId } = {}) {
|
|
54
|
-
if (user) {
|
|
55
|
-
delete user.password
|
|
56
|
-
}
|
|
57
|
-
user = await exports.updateAppRole(user, { appId })
|
|
58
|
-
if (!user.roleId && user?.userGroups?.length) {
|
|
59
|
-
user = await checkGroupRoles(user, { appId })
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return user
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
exports.getCachedSelf = async (ctx, appId) => {
|
|
66
|
-
// this has to be tenant aware, can't depend on the context to find it out
|
|
67
|
-
// running some middlewares before the tenancy causes context to break
|
|
68
|
-
const user = await userCache.getUser(ctx.user._id)
|
|
69
|
-
return processUser(user, { appId })
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
exports.getRawGlobalUser = async userId => {
|
|
73
|
-
const db = getGlobalDB()
|
|
74
|
-
return db.get(getGlobalIDFromUserMetadataID(userId))
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
exports.getGlobalUser = async userId => {
|
|
78
|
-
const appId = getAppId()
|
|
79
|
-
let user = await exports.getRawGlobalUser(userId)
|
|
80
|
-
return processUser(user, { appId })
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
exports.getGlobalUsers = async (users = null) => {
|
|
84
|
-
const appId = getAppId()
|
|
85
|
-
const db = getGlobalDB()
|
|
86
|
-
let globalUsers
|
|
87
|
-
if (users) {
|
|
88
|
-
const globalIds = users.map(user => getGlobalIDFromUserMetadataID(user._id))
|
|
89
|
-
globalUsers = (await db.allDocs(getMultiIDParams(globalIds))).rows.map(
|
|
90
|
-
row => row.doc
|
|
91
|
-
)
|
|
92
|
-
} else {
|
|
93
|
-
globalUsers = (
|
|
94
|
-
await db.allDocs(
|
|
95
|
-
getGlobalUserParams(null, {
|
|
96
|
-
include_docs: true,
|
|
97
|
-
})
|
|
98
|
-
)
|
|
99
|
-
).rows.map(row => row.doc)
|
|
100
|
-
}
|
|
101
|
-
globalUsers = globalUsers
|
|
102
|
-
.filter(user => user != null)
|
|
103
|
-
.map(user => {
|
|
104
|
-
delete user.password
|
|
105
|
-
delete user.forceResetPassword
|
|
106
|
-
return user
|
|
107
|
-
})
|
|
108
|
-
if (!appId) {
|
|
109
|
-
return globalUsers
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return globalUsers.map(user => exports.updateAppRole(user))
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
exports.getGlobalUsersFromMetadata = async users => {
|
|
116
|
-
const globalUsers = await exports.getGlobalUsers(users)
|
|
117
|
-
return users.map(user => {
|
|
118
|
-
const globalUser = globalUsers.find(
|
|
119
|
-
globalUser => globalUser && user._id.includes(globalUser._id)
|
|
120
|
-
)
|
|
121
|
-
return {
|
|
122
|
-
...globalUser,
|
|
123
|
-
// doing user second overwrites the id and rev (always metadata)
|
|
124
|
-
...user,
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
}
|