@budibase/server 2.1.22-alpha.6 → 2.1.22-alpha.8
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.dba40c82.js} +2 -2
- 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
|
@@ -4,16 +4,21 @@ jest.mock("node-fetch")
|
|
|
4
4
|
|
|
5
5
|
// Mock isProdAppID to we can later mock the implementation and pretend we are
|
|
6
6
|
// using prod app IDs
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
jest.mock("@budibase/backend-core", () => {
|
|
8
|
+
const core = jest.requireActual("@budibase/backend-core")
|
|
9
|
+
return {
|
|
10
|
+
...core,
|
|
11
|
+
db: {
|
|
12
|
+
...core.db,
|
|
13
|
+
isProdAppID: jest.fn(),
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
})
|
|
12
17
|
const setup = require("./utilities")
|
|
13
18
|
const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
14
19
|
const { checkCacheForDynamicVariable } = require("../../../threads/utils")
|
|
15
20
|
const { basicQuery, basicDatasource } = setup.structures
|
|
16
|
-
const { events } = require("@budibase/backend-core")
|
|
21
|
+
const { events, db: dbCore } = require("@budibase/backend-core")
|
|
17
22
|
|
|
18
23
|
describe("/queries", () => {
|
|
19
24
|
let request = setup.getRequest()
|
|
@@ -152,8 +157,8 @@ describe("/queries", () => {
|
|
|
152
157
|
|
|
153
158
|
it("should remove sensitive info for prod apps", async () => {
|
|
154
159
|
// Mock isProdAppID to pretend we are using a prod app
|
|
155
|
-
|
|
156
|
-
|
|
160
|
+
dbCore.isProdAppID.mockClear()
|
|
161
|
+
dbCore.isProdAppID.mockImplementation(() => true)
|
|
157
162
|
|
|
158
163
|
const query = await config.createQuery()
|
|
159
164
|
const res = await request
|
|
@@ -167,8 +172,8 @@ describe("/queries", () => {
|
|
|
167
172
|
expect(res.body.schema).toBeDefined()
|
|
168
173
|
|
|
169
174
|
// Reset isProdAppID mock
|
|
170
|
-
expect(
|
|
171
|
-
|
|
175
|
+
expect(dbCore.isProdAppID).toHaveBeenCalledTimes(1)
|
|
176
|
+
dbCore.isProdAppID.mockImplementation(() => false)
|
|
172
177
|
})
|
|
173
178
|
})
|
|
174
179
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
2
2
|
const {
|
|
3
|
-
|
|
3
|
+
BuiltinPermissionID,
|
|
4
4
|
} = require("@budibase/backend-core/permissions")
|
|
5
5
|
const setup = require("./utilities")
|
|
6
6
|
const { basicRole } = setup.structures
|
|
@@ -76,18 +76,18 @@ describe("/roles", () => {
|
|
|
76
76
|
const adminRole = res.body.find(r => r._id === BUILTIN_ROLE_IDS.ADMIN)
|
|
77
77
|
expect(adminRole).toBeDefined()
|
|
78
78
|
expect(adminRole.inherits).toEqual(BUILTIN_ROLE_IDS.POWER)
|
|
79
|
-
expect(adminRole.permissionId).toEqual(
|
|
79
|
+
expect(adminRole.permissionId).toEqual(BuiltinPermissionID.ADMIN)
|
|
80
80
|
|
|
81
81
|
const powerUserRole = res.body.find(r => r._id === BUILTIN_ROLE_IDS.POWER)
|
|
82
82
|
expect(powerUserRole).toBeDefined()
|
|
83
83
|
expect(powerUserRole.inherits).toEqual(BUILTIN_ROLE_IDS.BASIC)
|
|
84
|
-
expect(powerUserRole.permissionId).toEqual(
|
|
84
|
+
expect(powerUserRole.permissionId).toEqual(BuiltinPermissionID.POWER)
|
|
85
85
|
|
|
86
86
|
const customRoleFetched = res.body.find(r => r._id === customRole._id)
|
|
87
87
|
expect(customRoleFetched).toBeDefined()
|
|
88
88
|
expect(customRoleFetched.inherits).toEqual(BUILTIN_ROLE_IDS.BASIC)
|
|
89
89
|
expect(customRoleFetched.permissionId).toEqual(
|
|
90
|
-
|
|
90
|
+
BuiltinPermissionID.READ_ONLY
|
|
91
91
|
)
|
|
92
92
|
})
|
|
93
93
|
|
|
@@ -109,7 +109,7 @@ describe("/roles", () => {
|
|
|
109
109
|
it("should delete custom roles", async () => {
|
|
110
110
|
const customRole = await config.createRole({
|
|
111
111
|
name: "user",
|
|
112
|
-
permissionId:
|
|
112
|
+
permissionId: BuiltinPermissionID.READ_ONLY,
|
|
113
113
|
inherits: BUILTIN_ROLE_IDS.BASIC,
|
|
114
114
|
})
|
|
115
115
|
delete customRole._rev_tree
|
|
@@ -46,7 +46,7 @@ describe("/static", () => {
|
|
|
46
46
|
|
|
47
47
|
it("should serve the app by id", async () => {
|
|
48
48
|
const headers = config.defaultHeaders()
|
|
49
|
-
delete headers[constants.
|
|
49
|
+
delete headers[constants.Header.APP_ID]
|
|
50
50
|
|
|
51
51
|
const res = await request
|
|
52
52
|
.get(`/${config.prodAppId}`)
|
|
@@ -58,7 +58,7 @@ describe("/static", () => {
|
|
|
58
58
|
|
|
59
59
|
it("should serve the app by url", async () => {
|
|
60
60
|
const headers = config.defaultHeaders()
|
|
61
|
-
delete headers[constants.
|
|
61
|
+
delete headers[constants.Header.APP_ID]
|
|
62
62
|
|
|
63
63
|
const res = await request
|
|
64
64
|
.get(`/app${config.prodApp.url}`)
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
2
|
-
const { getAppDB } = require("@budibase/backend-core/context")
|
|
3
2
|
const setup = require("./utilities")
|
|
4
3
|
const { basicTable } = setup.structures
|
|
5
|
-
const { events } = require("@budibase/backend-core")
|
|
4
|
+
const { events, context } = require("@budibase/backend-core")
|
|
6
5
|
|
|
7
6
|
describe("/tables", () => {
|
|
8
7
|
let request = setup.getRequest()
|
|
9
8
|
let config = setup.getConfig()
|
|
9
|
+
let appId
|
|
10
10
|
|
|
11
11
|
afterAll(setup.afterAll)
|
|
12
12
|
|
|
13
13
|
beforeEach(async () => {
|
|
14
|
-
await config.init()
|
|
14
|
+
const app = await config.init()
|
|
15
|
+
appId = app.appId
|
|
15
16
|
})
|
|
16
17
|
|
|
17
18
|
describe("create", () => {
|
|
@@ -199,38 +200,6 @@ describe("/tables", () => {
|
|
|
199
200
|
})
|
|
200
201
|
})
|
|
201
202
|
|
|
202
|
-
describe("indexing", () => {
|
|
203
|
-
it("should be able to create a table with indexes", async () => {
|
|
204
|
-
const db = getAppDB(config)
|
|
205
|
-
const indexCount = (await db.getIndexes()).total_rows
|
|
206
|
-
const table = basicTable()
|
|
207
|
-
table.indexes = ["name"]
|
|
208
|
-
const res = await request
|
|
209
|
-
.post(`/api/tables`)
|
|
210
|
-
.send(table)
|
|
211
|
-
.set(config.defaultHeaders())
|
|
212
|
-
.expect('Content-Type', /json/)
|
|
213
|
-
.expect(200)
|
|
214
|
-
expect(res.body._id).toBeDefined()
|
|
215
|
-
expect(res.body._rev).toBeDefined()
|
|
216
|
-
expect((await db.getIndexes()).total_rows).toEqual(indexCount + 1)
|
|
217
|
-
// update index to see what happens
|
|
218
|
-
table.indexes = ["name", "description"]
|
|
219
|
-
await request
|
|
220
|
-
.post(`/api/tables`)
|
|
221
|
-
.send({
|
|
222
|
-
...table,
|
|
223
|
-
_id: res.body._id,
|
|
224
|
-
_rev: res.body._rev,
|
|
225
|
-
})
|
|
226
|
-
.set(config.defaultHeaders())
|
|
227
|
-
.expect('Content-Type', /json/)
|
|
228
|
-
.expect(200)
|
|
229
|
-
// shouldn't have created a new index
|
|
230
|
-
expect((await db.getIndexes()).total_rows).toEqual(indexCount + 1)
|
|
231
|
-
})
|
|
232
|
-
})
|
|
233
|
-
|
|
234
203
|
describe("validate csv", () => {
|
|
235
204
|
it("should be able to validate a CSV layout", async () => {
|
|
236
205
|
const res = await request
|
|
@@ -249,6 +218,40 @@ describe("/tables", () => {
|
|
|
249
218
|
})
|
|
250
219
|
})
|
|
251
220
|
|
|
221
|
+
describe("indexing", () => {
|
|
222
|
+
it("should be able to create a table with indexes", async () => {
|
|
223
|
+
await context.doInAppContext(appId, async () => {
|
|
224
|
+
const db = context.getAppDB()
|
|
225
|
+
const indexCount = (await db.getIndexes()).total_rows
|
|
226
|
+
const table = basicTable()
|
|
227
|
+
table.indexes = ["name"]
|
|
228
|
+
const res = await request
|
|
229
|
+
.post(`/api/tables`)
|
|
230
|
+
.send(table)
|
|
231
|
+
.set(config.defaultHeaders())
|
|
232
|
+
.expect('Content-Type', /json/)
|
|
233
|
+
.expect(200)
|
|
234
|
+
expect(res.body._id).toBeDefined()
|
|
235
|
+
expect(res.body._rev).toBeDefined()
|
|
236
|
+
expect((await db.getIndexes()).total_rows).toEqual(indexCount + 1)
|
|
237
|
+
// update index to see what happens
|
|
238
|
+
table.indexes = ["name", "description"]
|
|
239
|
+
await request
|
|
240
|
+
.post(`/api/tables`)
|
|
241
|
+
.send({
|
|
242
|
+
...table,
|
|
243
|
+
_id: res.body._id,
|
|
244
|
+
_rev: res.body._rev,
|
|
245
|
+
})
|
|
246
|
+
.set(config.defaultHeaders())
|
|
247
|
+
.expect('Content-Type', /json/)
|
|
248
|
+
.expect(200)
|
|
249
|
+
// shouldn't have created a new index
|
|
250
|
+
expect((await db.getIndexes()).total_rows).toEqual(indexCount + 1)
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
})
|
|
254
|
+
|
|
252
255
|
describe("destroy", () => {
|
|
253
256
|
let testTable
|
|
254
257
|
|
package/src/api/routes/user.js
CHANGED
|
@@ -2,8 +2,8 @@ const Router = require("@koa/router")
|
|
|
2
2
|
const controller = require("../controllers/user")
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
4
|
const {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
PermissionLevel,
|
|
6
|
+
PermissionType,
|
|
7
7
|
} = require("@budibase/backend-core/permissions")
|
|
8
8
|
|
|
9
9
|
const router = new Router()
|
|
@@ -11,42 +11,42 @@ const router = new Router()
|
|
|
11
11
|
router
|
|
12
12
|
.get(
|
|
13
13
|
"/api/users/metadata",
|
|
14
|
-
authorized(
|
|
14
|
+
authorized(PermissionType.USER, PermissionLevel.READ),
|
|
15
15
|
controller.fetchMetadata
|
|
16
16
|
)
|
|
17
17
|
.get(
|
|
18
18
|
"/api/users/metadata/:id",
|
|
19
|
-
authorized(
|
|
19
|
+
authorized(PermissionType.USER, PermissionLevel.READ),
|
|
20
20
|
controller.findMetadata
|
|
21
21
|
)
|
|
22
22
|
.put(
|
|
23
23
|
"/api/users/metadata",
|
|
24
|
-
authorized(
|
|
24
|
+
authorized(PermissionType.USER, PermissionLevel.WRITE),
|
|
25
25
|
controller.updateMetadata
|
|
26
26
|
)
|
|
27
27
|
.post(
|
|
28
28
|
"/api/users/metadata/self",
|
|
29
|
-
authorized(
|
|
29
|
+
authorized(PermissionType.USER, PermissionLevel.WRITE),
|
|
30
30
|
controller.updateSelfMetadata
|
|
31
31
|
)
|
|
32
32
|
.delete(
|
|
33
33
|
"/api/users/metadata/:id",
|
|
34
|
-
authorized(
|
|
34
|
+
authorized(PermissionType.USER, PermissionLevel.WRITE),
|
|
35
35
|
controller.destroyMetadata
|
|
36
36
|
)
|
|
37
37
|
.post(
|
|
38
38
|
"/api/users/metadata/sync/:id",
|
|
39
|
-
authorized(
|
|
39
|
+
authorized(PermissionType.USER, PermissionLevel.WRITE),
|
|
40
40
|
controller.syncUser
|
|
41
41
|
)
|
|
42
42
|
.post(
|
|
43
43
|
"/api/users/flags",
|
|
44
|
-
authorized(
|
|
44
|
+
authorized(PermissionType.USER, PermissionLevel.WRITE),
|
|
45
45
|
controller.setFlag
|
|
46
46
|
)
|
|
47
47
|
.get(
|
|
48
48
|
"/api/users/flags",
|
|
49
|
-
authorized(
|
|
49
|
+
authorized(PermissionType.USER, PermissionLevel.READ),
|
|
50
50
|
controller.getFlags
|
|
51
51
|
)
|
|
52
52
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const { joiValidator } = require("@budibase/backend-core/auth")
|
|
2
2
|
const { DataSourceOperation } = require("../../../constants")
|
|
3
3
|
const {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
BuiltinPermissionID,
|
|
5
|
+
PermissionLevel,
|
|
6
6
|
} = require("@budibase/backend-core/permissions")
|
|
7
7
|
const { WebhookActionType } = require("@budibase/types")
|
|
8
8
|
const Joi = require("joi")
|
|
@@ -133,14 +133,14 @@ exports.webhookValidator = () => {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
exports.roleValidator = () => {
|
|
136
|
-
const permLevelArray = Object.values(
|
|
136
|
+
const permLevelArray = Object.values(PermissionLevel)
|
|
137
137
|
// prettier-ignore
|
|
138
138
|
return joiValidator.body(Joi.object({
|
|
139
139
|
_id: OPTIONAL_STRING,
|
|
140
140
|
_rev: OPTIONAL_STRING,
|
|
141
141
|
name: Joi.string().required(),
|
|
142
142
|
// this is the base permission ID (for now a built in)
|
|
143
|
-
permissionId: Joi.string().valid(...Object.values(
|
|
143
|
+
permissionId: Joi.string().valid(...Object.values(BuiltinPermissionID)).required(),
|
|
144
144
|
permissions: Joi.object()
|
|
145
145
|
.pattern(/.*/, [Joi.string().valid(...permLevelArray)])
|
|
146
146
|
.optional(),
|
|
@@ -149,7 +149,7 @@ exports.roleValidator = () => {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
exports.permissionValidator = () => {
|
|
152
|
-
const permLevelArray = Object.values(
|
|
152
|
+
const permLevelArray = Object.values(PermissionLevel)
|
|
153
153
|
// prettier-ignore
|
|
154
154
|
return joiValidator.params(Joi.object({
|
|
155
155
|
level: Joi.string().valid(...permLevelArray).required(),
|
package/src/api/routes/view.js
CHANGED
|
@@ -5,8 +5,8 @@ const authorized = require("../../middleware/authorized")
|
|
|
5
5
|
const { paramResource } = require("../../middleware/resourceId")
|
|
6
6
|
const {
|
|
7
7
|
BUILDER,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
PermissionType,
|
|
9
|
+
PermissionLevel,
|
|
10
10
|
} = require("@budibase/backend-core/permissions")
|
|
11
11
|
|
|
12
12
|
const router = new Router()
|
|
@@ -16,7 +16,7 @@ router
|
|
|
16
16
|
.get(
|
|
17
17
|
"/api/views/:viewName",
|
|
18
18
|
paramResource("viewName"),
|
|
19
|
-
authorized(
|
|
19
|
+
authorized(PermissionType.VIEW, PermissionLevel.READ),
|
|
20
20
|
rowController.fetchView
|
|
21
21
|
)
|
|
22
22
|
.get("/api/views", authorized(BUILDER), viewController.fetch)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const TestConfig = require("../../../tests/utilities/TestConfiguration")
|
|
2
|
-
const {
|
|
3
|
-
const { doInTenant } = require("@budibase/backend-core/tenancy")
|
|
2
|
+
const { context } = require("@budibase/backend-core")
|
|
4
3
|
const actions = require("../../actions")
|
|
5
4
|
const emitter = require("../../../events/index")
|
|
6
5
|
const env = require("../../../environment")
|
|
@@ -33,7 +32,7 @@ exports.runInProd = async fn => {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
exports.runStep = async function runStep(stepId, inputs) {
|
|
36
|
-
|
|
35
|
+
async function run() {
|
|
37
36
|
let step = await actions.getAction(stepId)
|
|
38
37
|
expect(step).toBeDefined()
|
|
39
38
|
return step({
|
|
@@ -43,7 +42,14 @@ exports.runStep = async function runStep(stepId, inputs) {
|
|
|
43
42
|
apiKey: exports.apiKey,
|
|
44
43
|
emitter,
|
|
45
44
|
})
|
|
46
|
-
}
|
|
45
|
+
}
|
|
46
|
+
if (config?.appId) {
|
|
47
|
+
return context.doInContext(config?.appId, async () => {
|
|
48
|
+
return run()
|
|
49
|
+
})
|
|
50
|
+
} else {
|
|
51
|
+
return run()
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
exports.apiKey = "test"
|
package/src/automations/utils.ts
CHANGED
|
@@ -4,15 +4,9 @@ import { automationQueue } from "./bullboard"
|
|
|
4
4
|
import newid from "../db/newid"
|
|
5
5
|
import { updateEntityMetadata } from "../utilities"
|
|
6
6
|
import { MetadataTypes } from "../constants"
|
|
7
|
-
import {
|
|
7
|
+
import { db as dbCore, context } from "@budibase/backend-core"
|
|
8
8
|
import { getAutomationMetadataParams } from "../db/utils"
|
|
9
9
|
import { cloneDeep } from "lodash/fp"
|
|
10
|
-
import {
|
|
11
|
-
getAppDB,
|
|
12
|
-
getAppId,
|
|
13
|
-
getProdAppDB,
|
|
14
|
-
} from "@budibase/backend-core/context"
|
|
15
|
-
import { context } from "@budibase/backend-core"
|
|
16
10
|
import { quotas } from "@budibase/pro"
|
|
17
11
|
import { Automation, WebhookActionType } from "@budibase/types"
|
|
18
12
|
import sdk from "../sdk"
|
|
@@ -102,7 +96,7 @@ export async function disableCronById(jobId: number | string) {
|
|
|
102
96
|
}
|
|
103
97
|
|
|
104
98
|
export async function clearMetadata() {
|
|
105
|
-
const db = getProdAppDB()
|
|
99
|
+
const db = context.getProdAppDB()
|
|
106
100
|
const automationMetadata = (
|
|
107
101
|
await db.allDocs(
|
|
108
102
|
getAutomationMetadataParams({
|
|
@@ -157,7 +151,7 @@ export async function enableCronTrigger(appId: any, automation: Automation) {
|
|
|
157
151
|
// can't use getAppDB here as this is likely to be called from dev app,
|
|
158
152
|
// but this call could be for dev app or prod app, need to just use what
|
|
159
153
|
// was passed in
|
|
160
|
-
await doWithDB(appId, async (db: any) => {
|
|
154
|
+
await dbCore.doWithDB(appId, async (db: any) => {
|
|
161
155
|
const response = await db.put(automation)
|
|
162
156
|
automation._id = response.id
|
|
163
157
|
automation._rev = response.rev
|
|
@@ -175,7 +169,10 @@ export async function enableCronTrigger(appId: any, automation: Automation) {
|
|
|
175
169
|
* written to DB (this does not write to DB as it would be wasteful to repeat).
|
|
176
170
|
*/
|
|
177
171
|
export async function checkForWebhooks({ oldAuto, newAuto }: any) {
|
|
178
|
-
const appId = getAppId()
|
|
172
|
+
const appId = context.getAppId()
|
|
173
|
+
if (!appId) {
|
|
174
|
+
throw new Error("Unable to check webhooks - no app ID in context.")
|
|
175
|
+
}
|
|
179
176
|
const oldTrigger = oldAuto ? oldAuto.definition.trigger : null
|
|
180
177
|
const newTrigger = newAuto ? newAuto.definition.trigger : null
|
|
181
178
|
const triggerChanged =
|
|
@@ -194,7 +191,7 @@ export async function checkForWebhooks({ oldAuto, newAuto }: any) {
|
|
|
194
191
|
oldTrigger.webhookId
|
|
195
192
|
) {
|
|
196
193
|
try {
|
|
197
|
-
let db = getAppDB()
|
|
194
|
+
let db = context.getAppDB()
|
|
198
195
|
// need to get the webhook to get the rev
|
|
199
196
|
const webhook = await db.get(oldTrigger.webhookId)
|
|
200
197
|
// might be updating - reset the inputs to remove the URLs
|
|
@@ -224,7 +221,7 @@ export async function checkForWebhooks({ oldAuto, newAuto }: any) {
|
|
|
224
221
|
// the app ID has to be development for this endpoint
|
|
225
222
|
// it can only be used when building the app
|
|
226
223
|
// but the trigger endpoint will always be used in production
|
|
227
|
-
const prodAppId = getProdAppID(appId)
|
|
224
|
+
const prodAppId = dbCore.getProdAppID(appId)
|
|
228
225
|
newTrigger.inputs = {
|
|
229
226
|
schemaUrl: `api/webhooks/schema/${appId}/${id}`,
|
|
230
227
|
triggerUrl: `api/webhooks/trigger/${prodAppId}/${id}`,
|
package/src/db/inMemoryView.js
CHANGED
|
@@ -2,7 +2,7 @@ const newid = require("./newid")
|
|
|
2
2
|
|
|
3
3
|
// bypass the main application db config
|
|
4
4
|
// use in memory pouchdb directly
|
|
5
|
-
const { getPouch,
|
|
5
|
+
const { getPouch, closePouchDB } = require("@budibase/backend-core/db")
|
|
6
6
|
const Pouch = getPouch({ inMemory: true })
|
|
7
7
|
|
|
8
8
|
exports.runView = async (view, calculation, group, data) => {
|
|
@@ -44,6 +44,6 @@ exports.runView = async (view, calculation, group, data) => {
|
|
|
44
44
|
return response
|
|
45
45
|
} finally {
|
|
46
46
|
await db.destroy()
|
|
47
|
-
await
|
|
47
|
+
await closePouchDB(db)
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
const TestConfig = require("../../tests/utilities/TestConfiguration")
|
|
2
2
|
const { basicRow, basicLinkedRow, basicTable } = require("../../tests/utilities/structures")
|
|
3
3
|
const LinkController = require("../linkedRows/LinkController")
|
|
4
|
+
const { context } = require("@budibase/backend-core")
|
|
4
5
|
const { RelationshipTypes } = require("../../constants")
|
|
5
6
|
const { cloneDeep } = require("lodash/fp")
|
|
6
7
|
|
|
7
8
|
describe("test the link controller", () => {
|
|
8
9
|
let config = new TestConfig(false)
|
|
9
|
-
let table1, table2
|
|
10
|
+
let table1, table2, appId
|
|
10
11
|
|
|
11
12
|
beforeEach(async () => {
|
|
12
|
-
await config.init()
|
|
13
|
+
const app = await config.init()
|
|
14
|
+
appId = app.appId
|
|
13
15
|
const { _id } = await config.createTable()
|
|
14
16
|
table2 = await config.createLinkedTable(RelationshipTypes.MANY_TO_MANY, ["link", "link2"])
|
|
15
17
|
// update table after creating link
|
|
@@ -18,18 +20,20 @@ describe("test the link controller", () => {
|
|
|
18
20
|
|
|
19
21
|
afterAll(config.end)
|
|
20
22
|
|
|
21
|
-
function createLinkController(table, row = null, oldTable = null) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
async function createLinkController(table, row = null, oldTable = null) {
|
|
24
|
+
return context.doInAppContext(appId, () => {
|
|
25
|
+
const linkConfig = {
|
|
26
|
+
tableId: table._id,
|
|
27
|
+
table,
|
|
28
|
+
}
|
|
29
|
+
if (row) {
|
|
30
|
+
linkConfig.row = row
|
|
31
|
+
}
|
|
32
|
+
if (oldTable) {
|
|
33
|
+
linkConfig.oldTable = oldTable
|
|
34
|
+
}
|
|
35
|
+
return new LinkController(linkConfig)
|
|
36
|
+
})
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
async function createLinkedRow(linkField = "link", t1 = table1, t2 = table2) {
|
|
@@ -38,16 +42,16 @@ describe("test the link controller", () => {
|
|
|
38
42
|
return config.getRow(t1._id, _id)
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
it("should be able to confirm if two table schemas are equal", () => {
|
|
42
|
-
const controller = createLinkController(table1)
|
|
45
|
+
it("should be able to confirm if two table schemas are equal", async () => {
|
|
46
|
+
const controller = await createLinkController(table1)
|
|
43
47
|
let equal = controller.areLinkSchemasEqual(table2.schema.link, table2.schema.link)
|
|
44
48
|
expect(equal).toEqual(true)
|
|
45
49
|
equal = controller.areLinkSchemasEqual(table1.schema.link, table2.schema.link)
|
|
46
50
|
expect(equal).toEqual(false)
|
|
47
51
|
})
|
|
48
52
|
|
|
49
|
-
it("should be able to check the relationship types across two fields", () => {
|
|
50
|
-
const controller = createLinkController(table1)
|
|
53
|
+
it("should be able to check the relationship types across two fields", async () => {
|
|
54
|
+
const controller = await createLinkController(table1)
|
|
51
55
|
// empty case
|
|
52
56
|
let output = controller.handleRelationshipType({}, {})
|
|
53
57
|
expect(output.linkedField.relationshipType).toEqual(RelationshipTypes.MANY_TO_MANY)
|
|
@@ -65,29 +69,33 @@ describe("test the link controller", () => {
|
|
|
65
69
|
|
|
66
70
|
it("should be able to delete a row", async () => {
|
|
67
71
|
const row = await createLinkedRow()
|
|
68
|
-
const controller = createLinkController(table1, row)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
const controller = await createLinkController(table1, row)
|
|
73
|
+
await context.doInAppContext(appId, async () => {
|
|
74
|
+
// get initial count
|
|
75
|
+
const beforeLinks = await controller.getRowLinkDocs(row._id)
|
|
76
|
+
await controller.rowDeleted()
|
|
77
|
+
let afterLinks = await controller.getRowLinkDocs(row._id)
|
|
78
|
+
expect(beforeLinks.length).toEqual(1)
|
|
79
|
+
expect(afterLinks.length).toEqual(0)
|
|
80
|
+
})
|
|
75
81
|
})
|
|
76
82
|
|
|
77
83
|
it("shouldn't throw an error when deleting a row with no links", async () => {
|
|
78
84
|
const row = await config.createRow(basicRow(table1._id))
|
|
79
|
-
const controller = createLinkController(table1, row)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
const controller = await createLinkController(table1, row)
|
|
86
|
+
await context.doInAppContext(appId, async () => {
|
|
87
|
+
let error
|
|
88
|
+
try {
|
|
89
|
+
await controller.rowDeleted()
|
|
90
|
+
} catch (err) {
|
|
91
|
+
error = err
|
|
92
|
+
}
|
|
93
|
+
expect(error).toBeUndefined()
|
|
94
|
+
})
|
|
87
95
|
})
|
|
88
96
|
|
|
89
|
-
it("should throw an error when validating a table which is invalid", () => {
|
|
90
|
-
const controller = createLinkController(table1)
|
|
97
|
+
it("should throw an error when validating a table which is invalid", async () => {
|
|
98
|
+
const controller = await createLinkController(table1)
|
|
91
99
|
const copyTable = {
|
|
92
100
|
...table1
|
|
93
101
|
}
|
|
@@ -110,32 +118,38 @@ describe("test the link controller", () => {
|
|
|
110
118
|
const row = await createLinkedRow()
|
|
111
119
|
// remove the link from the row
|
|
112
120
|
row.link = []
|
|
113
|
-
const controller = createLinkController(table1, row)
|
|
114
|
-
await
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
const controller = await createLinkController(table1, row)
|
|
122
|
+
await context.doInAppContext(appId, async () => {
|
|
123
|
+
await controller.rowSaved()
|
|
124
|
+
let links = await controller.getRowLinkDocs(row._id)
|
|
125
|
+
expect(links.length).toEqual(0)
|
|
126
|
+
})
|
|
117
127
|
})
|
|
118
128
|
|
|
119
129
|
it("should be able to delete a table and have links deleted", async () => {
|
|
120
130
|
await createLinkedRow()
|
|
121
|
-
const controller = createLinkController(table1)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
const controller = await createLinkController(table1)
|
|
132
|
+
await context.doInAppContext(appId, async () => {
|
|
133
|
+
let before = await controller.getTableLinkDocs()
|
|
134
|
+
await controller.tableDeleted()
|
|
135
|
+
let after = await controller.getTableLinkDocs()
|
|
136
|
+
expect(before.length).toEqual(1)
|
|
137
|
+
expect(after.length).toEqual(0)
|
|
138
|
+
})
|
|
127
139
|
})
|
|
128
140
|
|
|
129
141
|
it("should be able to remove a linked field from a table", async () => {
|
|
130
142
|
await createLinkedRow()
|
|
131
143
|
await createLinkedRow("link2")
|
|
132
|
-
const controller = createLinkController(table1, null, table1)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
const controller = await createLinkController(table1, null, table1)
|
|
145
|
+
await context.doInAppContext(appId, async () => {
|
|
146
|
+
let before = await controller.getTableLinkDocs()
|
|
147
|
+
await controller.removeFieldFromTable("link")
|
|
148
|
+
let after = await controller.getTableLinkDocs()
|
|
149
|
+
expect(before.length).toEqual(2)
|
|
150
|
+
// shouldn't delete the other field
|
|
151
|
+
expect(after.length).toEqual(1)
|
|
152
|
+
})
|
|
139
153
|
})
|
|
140
154
|
|
|
141
155
|
it("should throw an error when overwriting a link column", async () => {
|
|
@@ -143,7 +157,7 @@ describe("test the link controller", () => {
|
|
|
143
157
|
update.schema.link.relationshipType = RelationshipTypes.MANY_TO_ONE
|
|
144
158
|
let error
|
|
145
159
|
try {
|
|
146
|
-
const controller = createLinkController(update)
|
|
160
|
+
const controller = await createLinkController(update)
|
|
147
161
|
await controller.tableSaved()
|
|
148
162
|
} catch (err) {
|
|
149
163
|
error = err
|
|
@@ -156,10 +170,12 @@ describe("test the link controller", () => {
|
|
|
156
170
|
await createLinkedRow()
|
|
157
171
|
const newTable = cloneDeep(table1)
|
|
158
172
|
delete newTable.schema.link
|
|
159
|
-
const controller = createLinkController(newTable, null, table1)
|
|
160
|
-
await
|
|
161
|
-
|
|
162
|
-
|
|
173
|
+
const controller = await createLinkController(newTable, null, table1)
|
|
174
|
+
await context.doInAppContext(appId, async () => {
|
|
175
|
+
await controller.tableUpdated()
|
|
176
|
+
const links = await controller.getTableLinkDocs()
|
|
177
|
+
expect(links.length).toEqual(0)
|
|
178
|
+
})
|
|
163
179
|
})
|
|
164
180
|
|
|
165
181
|
it("shouldn't allow one to many having many relationships against it", async () => {
|