@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,30 +1,34 @@
|
|
|
1
1
|
const TestConfig = require("../../tests/utilities/TestConfiguration")
|
|
2
2
|
const { basicTable } = require("../../tests/utilities/structures")
|
|
3
3
|
const linkUtils = require("../linkedRows/linkUtils")
|
|
4
|
-
const {
|
|
5
|
-
const { doWithDB } = require("@budibase/backend-core/db")
|
|
4
|
+
const { context } = require("@budibase/backend-core")
|
|
6
5
|
|
|
7
6
|
describe("test link functionality", () => {
|
|
8
7
|
const config = new TestConfig(false)
|
|
8
|
+
let appId
|
|
9
9
|
|
|
10
10
|
describe("getLinkedTable", () => {
|
|
11
|
-
let
|
|
11
|
+
let table
|
|
12
12
|
beforeEach(async () => {
|
|
13
|
-
await config.init()
|
|
14
|
-
|
|
13
|
+
const app = await config.init()
|
|
14
|
+
appId = app.appId
|
|
15
15
|
table = await config.createTable()
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
it("should be able to retrieve a linked table from a list", async () => {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
await context.doInAppContext(appId, async () => {
|
|
20
|
+
const retrieved = await linkUtils.getLinkedTable(table._id, [table])
|
|
21
|
+
expect(retrieved._id).toBe(table._id)
|
|
22
|
+
})
|
|
21
23
|
})
|
|
22
24
|
|
|
23
25
|
it("should be able to retrieve a table from DB and update list", async () => {
|
|
24
26
|
const tables = []
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
await context.doInAppContext(appId, async () => {
|
|
28
|
+
const retrieved = await linkUtils.getLinkedTable(table._id, tables)
|
|
29
|
+
expect(retrieved._id).toBe(table._id)
|
|
30
|
+
expect(tables[0]).toBeDefined()
|
|
31
|
+
})
|
|
28
32
|
})
|
|
29
33
|
})
|
|
30
34
|
|
|
@@ -48,15 +52,14 @@ describe("test link functionality", () => {
|
|
|
48
52
|
describe("getLinkDocuments", () => {
|
|
49
53
|
it("should create the link view when it doesn't exist", async () => {
|
|
50
54
|
// create the DB and a very basic app design DB
|
|
51
|
-
|
|
52
|
-
await
|
|
53
|
-
return await linkUtils.getLinkDocuments({
|
|
55
|
+
await context.doInAppContext(appId, async () => {
|
|
56
|
+
const output = await linkUtils.getLinkDocuments({
|
|
54
57
|
tableId: "test",
|
|
55
58
|
rowId: "test",
|
|
56
59
|
includeDocs: false,
|
|
57
60
|
})
|
|
61
|
+
expect(Array.isArray(output)).toBe(true)
|
|
58
62
|
})
|
|
59
|
-
expect(Array.isArray(output)).toBe(true)
|
|
60
63
|
})
|
|
61
64
|
})
|
|
62
65
|
})
|
|
@@ -1,44 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
APP_DEV_PREFIX,
|
|
8
|
-
APP_PREFIX,
|
|
9
|
-
SEPARATOR,
|
|
10
|
-
StaticDatabases,
|
|
11
|
-
isDevAppID,
|
|
12
|
-
isProdAppID,
|
|
13
|
-
getDevelopmentAppID,
|
|
14
|
-
generateAppID,
|
|
15
|
-
getQueryIndex,
|
|
16
|
-
ViewName,
|
|
17
|
-
getDocParams,
|
|
18
|
-
getRowParams,
|
|
19
|
-
generateRowID,
|
|
20
|
-
getUserMetadataParams,
|
|
21
|
-
generateUserMetadataID,
|
|
22
|
-
getGlobalIDFromUserMetadataID,
|
|
23
|
-
} = require("@budibase/backend-core/db")
|
|
24
|
-
|
|
25
|
-
const UNICODE_MAX = "\ufff0"
|
|
26
|
-
|
|
27
|
-
const AppStatus = {
|
|
1
|
+
import newid from "./newid"
|
|
2
|
+
import { db as dbCore } from "@budibase/backend-core"
|
|
3
|
+
|
|
4
|
+
type Optional = string | null
|
|
5
|
+
|
|
6
|
+
export const AppStatus = {
|
|
28
7
|
DEV: "development",
|
|
29
8
|
ALL: "all",
|
|
30
9
|
DEPLOYED: "published",
|
|
31
10
|
}
|
|
32
11
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const SearchIndexes = {
|
|
12
|
+
export const SearchIndexes = {
|
|
36
13
|
ROWS: "rows",
|
|
37
14
|
}
|
|
38
15
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const BudibaseInternalDB = {
|
|
16
|
+
export const BudibaseInternalDB = {
|
|
42
17
|
_id: "bb_internal",
|
|
43
18
|
type: "budibase",
|
|
44
19
|
name: "Budibase DB",
|
|
@@ -46,37 +21,36 @@ const BudibaseInternalDB = {
|
|
|
46
21
|
config: {},
|
|
47
22
|
}
|
|
48
23
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
exports.getGlobalIDFromUserMetadataID = getGlobalIDFromUserMetadataID
|
|
24
|
+
export const SEPARATOR = dbCore.SEPARATOR
|
|
25
|
+
export const StaticDatabases = dbCore.StaticDatabases
|
|
26
|
+
export const DocumentType = dbCore.DocumentType
|
|
27
|
+
export const APP_PREFIX = dbCore.APP_PREFIX
|
|
28
|
+
export const APP_DEV_PREFIX = dbCore.APP_DEV_PREFIX
|
|
29
|
+
export const isDevAppID = dbCore.isDevAppID
|
|
30
|
+
export const isProdAppID = dbCore.isProdAppID
|
|
31
|
+
export const USER_METDATA_PREFIX = `${DocumentType.ROW}${SEPARATOR}${dbCore.InternalTable.USER_METADATA}${SEPARATOR}`
|
|
32
|
+
export const LINK_USER_METADATA_PREFIX = `${DocumentType.LINK}${SEPARATOR}${dbCore.InternalTable.USER_METADATA}${SEPARATOR}`
|
|
33
|
+
export const TABLE_ROW_PREFIX = `${DocumentType.ROW}${SEPARATOR}${DocumentType.TABLE}`
|
|
34
|
+
export const ViewName = dbCore.ViewName
|
|
35
|
+
export const InternalTables = dbCore.InternalTable
|
|
36
|
+
export const UNICODE_MAX = dbCore.UNICODE_MAX
|
|
37
|
+
export const generateAppID = dbCore.generateAppID
|
|
38
|
+
export const generateDevAppID = dbCore.getDevelopmentAppID
|
|
39
|
+
export const generateRoleID = dbCore.generateRoleID
|
|
40
|
+
export const getRoleParams = dbCore.getRoleParams
|
|
41
|
+
export const getQueryIndex = dbCore.getQueryIndex
|
|
42
|
+
export const getDocParams = dbCore.getDocParams
|
|
43
|
+
export const getRowParams = dbCore.getRowParams
|
|
44
|
+
export const generateRowID = dbCore.generateRowID
|
|
45
|
+
export const getUserMetadataParams = dbCore.getUserMetadataParams
|
|
46
|
+
export const generateUserMetadataID = dbCore.generateUserMetadataID
|
|
47
|
+
export const getGlobalIDFromUserMetadataID =
|
|
48
|
+
dbCore.getGlobalIDFromUserMetadataID
|
|
75
49
|
|
|
76
50
|
/**
|
|
77
51
|
* Gets parameters for retrieving tables, this is a utility function for the getDocParams function.
|
|
78
52
|
*/
|
|
79
|
-
|
|
53
|
+
export function getTableParams(tableId?: Optional, otherProps = {}) {
|
|
80
54
|
return getDocParams(DocumentType.TABLE, tableId, otherProps)
|
|
81
55
|
}
|
|
82
56
|
|
|
@@ -84,7 +58,7 @@ exports.getTableParams = (tableId = null, otherProps = {}) => {
|
|
|
84
58
|
* Generates a new table ID.
|
|
85
59
|
* @returns {string} The new table ID which the table doc can be stored under.
|
|
86
60
|
*/
|
|
87
|
-
|
|
61
|
+
export function generateTableID() {
|
|
88
62
|
return `${DocumentType.TABLE}${SEPARATOR}${newid()}`
|
|
89
63
|
}
|
|
90
64
|
|
|
@@ -93,7 +67,7 @@ exports.generateTableID = () => {
|
|
|
93
67
|
* @param {string} rowId The ID of the row.
|
|
94
68
|
* @returns {string} The table ID.
|
|
95
69
|
*/
|
|
96
|
-
|
|
70
|
+
export function getTableIDFromRowID(rowId: string) {
|
|
97
71
|
const components = rowId
|
|
98
72
|
.split(DocumentType.TABLE + SEPARATOR)[1]
|
|
99
73
|
.split(SEPARATOR)
|
|
@@ -103,7 +77,10 @@ exports.getTableIDFromRowID = rowId => {
|
|
|
103
77
|
/**
|
|
104
78
|
* Gets parameters for retrieving automations, this is a utility function for the getDocParams function.
|
|
105
79
|
*/
|
|
106
|
-
|
|
80
|
+
export function getAutomationParams(
|
|
81
|
+
automationId?: Optional,
|
|
82
|
+
otherProps: any = {}
|
|
83
|
+
) {
|
|
107
84
|
return getDocParams(DocumentType.AUTOMATION, automationId, otherProps)
|
|
108
85
|
}
|
|
109
86
|
|
|
@@ -111,7 +88,7 @@ exports.getAutomationParams = (automationId = null, otherProps = {}) => {
|
|
|
111
88
|
* Generates a new automation ID.
|
|
112
89
|
* @returns {string} The new automation ID which the automation doc can be stored under.
|
|
113
90
|
*/
|
|
114
|
-
|
|
91
|
+
export function generateAutomationID() {
|
|
115
92
|
return `${DocumentType.AUTOMATION}${SEPARATOR}${newid()}`
|
|
116
93
|
}
|
|
117
94
|
|
|
@@ -126,14 +103,14 @@ exports.generateAutomationID = () => {
|
|
|
126
103
|
* @param {string} fieldName2 the name of the field in the linked row.
|
|
127
104
|
* @returns {string} The new link doc ID which the automation doc can be stored under.
|
|
128
105
|
*/
|
|
129
|
-
|
|
130
|
-
tableId1,
|
|
131
|
-
tableId2,
|
|
132
|
-
rowId1,
|
|
133
|
-
rowId2,
|
|
134
|
-
fieldName1,
|
|
135
|
-
fieldName2
|
|
136
|
-
)
|
|
106
|
+
export function generateLinkID(
|
|
107
|
+
tableId1: string,
|
|
108
|
+
tableId2: string,
|
|
109
|
+
rowId1: string,
|
|
110
|
+
rowId2: string,
|
|
111
|
+
fieldName1: string,
|
|
112
|
+
fieldName2: string
|
|
113
|
+
) {
|
|
137
114
|
const tables = `${SEPARATOR}${tableId1}${SEPARATOR}${tableId2}`
|
|
138
115
|
const rows = `${SEPARATOR}${rowId1}${SEPARATOR}${rowId2}`
|
|
139
116
|
const fields = `${SEPARATOR}${fieldName1}${SEPARATOR}${fieldName2}`
|
|
@@ -143,7 +120,7 @@ exports.generateLinkID = (
|
|
|
143
120
|
/**
|
|
144
121
|
* Gets parameters for retrieving link docs, this is a utility function for the getDocParams function.
|
|
145
122
|
*/
|
|
146
|
-
|
|
123
|
+
export function getLinkParams(otherProps: any = {}) {
|
|
147
124
|
return getDocParams(DocumentType.LINK, null, otherProps)
|
|
148
125
|
}
|
|
149
126
|
|
|
@@ -151,14 +128,14 @@ exports.getLinkParams = (otherProps = {}) => {
|
|
|
151
128
|
* Generates a new layout ID.
|
|
152
129
|
* @returns {string} The new layout ID which the layout doc can be stored under.
|
|
153
130
|
*/
|
|
154
|
-
|
|
131
|
+
export function generateLayoutID(id: string) {
|
|
155
132
|
return `${DocumentType.LAYOUT}${SEPARATOR}${id || newid()}`
|
|
156
133
|
}
|
|
157
134
|
|
|
158
135
|
/**
|
|
159
136
|
* Gets parameters for retrieving layout, this is a utility function for the getDocParams function.
|
|
160
137
|
*/
|
|
161
|
-
|
|
138
|
+
export function getLayoutParams(layoutId?: Optional, otherProps: any = {}) {
|
|
162
139
|
return getDocParams(DocumentType.LAYOUT, layoutId, otherProps)
|
|
163
140
|
}
|
|
164
141
|
|
|
@@ -166,14 +143,14 @@ exports.getLayoutParams = (layoutId = null, otherProps = {}) => {
|
|
|
166
143
|
* Generates a new screen ID.
|
|
167
144
|
* @returns {string} The new screen ID which the screen doc can be stored under.
|
|
168
145
|
*/
|
|
169
|
-
|
|
146
|
+
export function generateScreenID() {
|
|
170
147
|
return `${DocumentType.SCREEN}${SEPARATOR}${newid()}`
|
|
171
148
|
}
|
|
172
149
|
|
|
173
150
|
/**
|
|
174
151
|
* Gets parameters for retrieving screens, this is a utility function for the getDocParams function.
|
|
175
152
|
*/
|
|
176
|
-
|
|
153
|
+
export function getScreenParams(screenId?: Optional, otherProps: any = {}) {
|
|
177
154
|
return getDocParams(DocumentType.SCREEN, screenId, otherProps)
|
|
178
155
|
}
|
|
179
156
|
|
|
@@ -181,14 +158,14 @@ exports.getScreenParams = (screenId = null, otherProps = {}) => {
|
|
|
181
158
|
* Generates a new webhook ID.
|
|
182
159
|
* @returns {string} The new webhook ID which the webhook doc can be stored under.
|
|
183
160
|
*/
|
|
184
|
-
|
|
161
|
+
export function generateWebhookID() {
|
|
185
162
|
return `${DocumentType.WEBHOOK}${SEPARATOR}${newid()}`
|
|
186
163
|
}
|
|
187
164
|
|
|
188
165
|
/**
|
|
189
166
|
* Gets parameters for retrieving a webhook, this is a utility function for the getDocParams function.
|
|
190
167
|
*/
|
|
191
|
-
|
|
168
|
+
export function getWebhookParams(webhookId?: Optional, otherProps: any = {}) {
|
|
192
169
|
return getDocParams(DocumentType.WEBHOOK, webhookId, otherProps)
|
|
193
170
|
}
|
|
194
171
|
|
|
@@ -196,7 +173,7 @@ exports.getWebhookParams = (webhookId = null, otherProps = {}) => {
|
|
|
196
173
|
* Generates a new datasource ID.
|
|
197
174
|
* @returns {string} The new datasource ID which the webhook doc can be stored under.
|
|
198
175
|
*/
|
|
199
|
-
|
|
176
|
+
export function generateDatasourceID({ plus = false } = {}) {
|
|
200
177
|
return `${
|
|
201
178
|
plus ? DocumentType.DATASOURCE_PLUS : DocumentType.DATASOURCE
|
|
202
179
|
}${SEPARATOR}${newid()}`
|
|
@@ -205,7 +182,10 @@ exports.generateDatasourceID = ({ plus = false } = {}) => {
|
|
|
205
182
|
/**
|
|
206
183
|
* Gets parameters for retrieving a datasource, this is a utility function for the getDocParams function.
|
|
207
184
|
*/
|
|
208
|
-
|
|
185
|
+
export function getDatasourceParams(
|
|
186
|
+
datasourceId?: Optional,
|
|
187
|
+
otherProps: any = {}
|
|
188
|
+
) {
|
|
209
189
|
return getDocParams(DocumentType.DATASOURCE, datasourceId, otherProps)
|
|
210
190
|
}
|
|
211
191
|
|
|
@@ -213,7 +193,7 @@ exports.getDatasourceParams = (datasourceId = null, otherProps = {}) => {
|
|
|
213
193
|
* Generates a new query ID.
|
|
214
194
|
* @returns {string} The new query ID which the query doc can be stored under.
|
|
215
195
|
*/
|
|
216
|
-
|
|
196
|
+
export function generateQueryID(datasourceId: string) {
|
|
217
197
|
return `${
|
|
218
198
|
DocumentType.QUERY
|
|
219
199
|
}${SEPARATOR}${datasourceId}${SEPARATOR}${newid()}`
|
|
@@ -223,21 +203,21 @@ exports.generateQueryID = datasourceId => {
|
|
|
223
203
|
* Generates a metadata ID for automations, used to track errors in recurring
|
|
224
204
|
* automations etc.
|
|
225
205
|
*/
|
|
226
|
-
|
|
206
|
+
export function generateAutomationMetadataID(automationId: string) {
|
|
227
207
|
return `${DocumentType.AUTOMATION_METADATA}${SEPARATOR}${automationId}`
|
|
228
208
|
}
|
|
229
209
|
|
|
230
210
|
/**
|
|
231
211
|
* Retrieve all automation metadata in an app database.
|
|
232
212
|
*/
|
|
233
|
-
|
|
213
|
+
export function getAutomationMetadataParams(otherProps: any = {}) {
|
|
234
214
|
return getDocParams(DocumentType.AUTOMATION_METADATA, null, otherProps)
|
|
235
215
|
}
|
|
236
216
|
|
|
237
217
|
/**
|
|
238
218
|
* Gets parameters for retrieving a query, this is a utility function for the getDocParams function.
|
|
239
219
|
*/
|
|
240
|
-
|
|
220
|
+
export function getQueryParams(datasourceId?: Optional, otherProps: any = {}) {
|
|
241
221
|
if (datasourceId == null) {
|
|
242
222
|
return getDocParams(DocumentType.QUERY, null, otherProps)
|
|
243
223
|
}
|
|
@@ -253,15 +233,19 @@ exports.getQueryParams = (datasourceId = null, otherProps = {}) => {
|
|
|
253
233
|
* Generates a new flag document ID.
|
|
254
234
|
* @returns {string} The ID of the flag document that was generated.
|
|
255
235
|
*/
|
|
256
|
-
|
|
236
|
+
export function generateUserFlagID(userId: string) {
|
|
257
237
|
return `${DocumentType.USER_FLAG}${SEPARATOR}${userId}`
|
|
258
238
|
}
|
|
259
239
|
|
|
260
|
-
|
|
240
|
+
export function generateMetadataID(type: string, entityId: string) {
|
|
261
241
|
return `${DocumentType.METADATA}${SEPARATOR}${type}${SEPARATOR}${entityId}`
|
|
262
242
|
}
|
|
263
243
|
|
|
264
|
-
|
|
244
|
+
export function getMetadataParams(
|
|
245
|
+
type: string,
|
|
246
|
+
entityId?: Optional,
|
|
247
|
+
otherProps: any = {}
|
|
248
|
+
) {
|
|
265
249
|
let docId = `${type}${SEPARATOR}`
|
|
266
250
|
if (entityId != null) {
|
|
267
251
|
docId += entityId
|
|
@@ -269,22 +253,22 @@ exports.getMetadataParams = (type, entityId = null, otherProps = {}) => {
|
|
|
269
253
|
return getDocParams(DocumentType.METADATA, docId, otherProps)
|
|
270
254
|
}
|
|
271
255
|
|
|
272
|
-
|
|
256
|
+
export function generateMemoryViewID(viewName: string) {
|
|
273
257
|
return `${DocumentType.MEM_VIEW}${SEPARATOR}${viewName}`
|
|
274
258
|
}
|
|
275
259
|
|
|
276
|
-
|
|
260
|
+
export function getMemoryViewParams(otherProps: any = {}) {
|
|
277
261
|
return getDocParams(DocumentType.MEM_VIEW, null, otherProps)
|
|
278
262
|
}
|
|
279
263
|
|
|
280
|
-
|
|
264
|
+
export function generatePluginID(name: string) {
|
|
281
265
|
return `${DocumentType.PLUGIN}${SEPARATOR}${name}`
|
|
282
266
|
}
|
|
283
267
|
|
|
284
268
|
/**
|
|
285
269
|
* This can be used with the db.allDocs to get a list of IDs
|
|
286
270
|
*/
|
|
287
|
-
|
|
271
|
+
export function getMultiIDParams(ids: string[]) {
|
|
288
272
|
return {
|
|
289
273
|
keys: ids,
|
|
290
274
|
include_docs: true,
|
|
@@ -12,10 +12,7 @@ import { buildExternalTableId } from "./utils"
|
|
|
12
12
|
import { DataSourceOperation, FieldTypes } from "../constants"
|
|
13
13
|
import { GoogleSpreadsheet } from "google-spreadsheet"
|
|
14
14
|
import env from "../environment"
|
|
15
|
-
|
|
16
|
-
const { getGlobalDB } = require("@budibase/backend-core/tenancy")
|
|
17
|
-
const { getScopedConfig } = require("@budibase/backend-core/db")
|
|
18
|
-
const { Configs } = require("@budibase/backend-core/constants")
|
|
15
|
+
import { tenancy, db as dbCore, constants } from "@budibase/backend-core"
|
|
19
16
|
const fetch = require("node-fetch")
|
|
20
17
|
|
|
21
18
|
interface GoogleSheetsConfig {
|
|
@@ -176,9 +173,9 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|
|
176
173
|
async connect() {
|
|
177
174
|
try {
|
|
178
175
|
// Initialise oAuth client
|
|
179
|
-
const db = getGlobalDB()
|
|
180
|
-
let googleConfig = await getScopedConfig(db, {
|
|
181
|
-
type:
|
|
176
|
+
const db = tenancy.getGlobalDB()
|
|
177
|
+
let googleConfig = await dbCore.getScopedConfig(db, {
|
|
178
|
+
type: constants.Config.GOOGLE,
|
|
182
179
|
})
|
|
183
180
|
|
|
184
181
|
if (!googleConfig) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isDevAppID, isProdAppID } from "../db/utils"
|
|
2
|
+
import { BBContext } from "@budibase/types"
|
|
3
|
+
|
|
4
|
+
export enum AppType {
|
|
5
|
+
DEV = "dev",
|
|
6
|
+
PROD = "prod",
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function middleware({ appType }: { appType?: AppType } = {}) {
|
|
10
|
+
return (ctx: BBContext, next: any) => {
|
|
11
|
+
const appId = ctx.appId
|
|
12
|
+
if (appType === AppType.DEV && appId && !isDevAppID(appId)) {
|
|
13
|
+
ctx.throw(400, "Only apps in development support this endpoint")
|
|
14
|
+
}
|
|
15
|
+
if (appType === AppType.PROD && appId && !isProdAppID(appId)) {
|
|
16
|
+
ctx.throw(400, "Only apps in production support this endpoint")
|
|
17
|
+
}
|
|
18
|
+
return next()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
BUILTIN_ROLE_IDS,
|
|
5
5
|
} from "@budibase/backend-core/roles"
|
|
6
6
|
const {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
PermissionType,
|
|
8
|
+
PermissionLevel,
|
|
9
9
|
doesHaveBasePermission,
|
|
10
10
|
} = require("@budibase/backend-core/permissions")
|
|
11
11
|
const builderMiddleware = require("./builder")
|
|
@@ -33,7 +33,7 @@ const checkAuthorized = async (
|
|
|
33
33
|
) => {
|
|
34
34
|
// check if this is a builder api and the user is not a builder
|
|
35
35
|
const isBuilder = ctx.user && ctx.user.builder && ctx.user.builder.global
|
|
36
|
-
const isBuilderApi = permType ===
|
|
36
|
+
const isBuilderApi = permType === PermissionType.BUILDER
|
|
37
37
|
if (isBuilderApi && !isBuilder) {
|
|
38
38
|
return ctx.throw(403, "Not Authorized")
|
|
39
39
|
}
|
|
@@ -91,9 +91,9 @@ export = (permType: any, permLevel: any = null, opts = { schema: false }) =>
|
|
|
91
91
|
let resourceRoles: any = []
|
|
92
92
|
let otherLevelRoles: any = []
|
|
93
93
|
const otherLevel =
|
|
94
|
-
permLevel ===
|
|
95
|
-
?
|
|
96
|
-
:
|
|
94
|
+
permLevel === PermissionLevel.READ
|
|
95
|
+
? PermissionLevel.WRITE
|
|
96
|
+
: PermissionLevel.READ
|
|
97
97
|
const appId = getAppId()
|
|
98
98
|
if (appId && hasResource(ctx)) {
|
|
99
99
|
resourceRoles = await getRequiredResourceRole(permLevel, ctx)
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
APP_DEV_PREFIX,
|
|
3
|
+
DocumentType,
|
|
4
|
+
getGlobalIDFromUserMetadataID,
|
|
5
|
+
} from "../db/utils"
|
|
6
|
+
import {
|
|
3
7
|
doesUserHaveLock,
|
|
4
8
|
updateLock,
|
|
5
9
|
checkDebounce,
|
|
6
10
|
setDebounce,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const { PermissionTypes } = require("@budibase/backend-core/permissions")
|
|
11
|
-
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
11
|
+
} from "../utilities/redis"
|
|
12
|
+
import { db as dbCore, cache, permissions } from "@budibase/backend-core"
|
|
13
|
+
import { BBContext, Database } from "@budibase/types"
|
|
12
14
|
|
|
13
15
|
const DEBOUNCE_TIME_SEC = 30
|
|
14
16
|
|
|
@@ -21,11 +23,11 @@ const DEBOUNCE_TIME_SEC = 30
|
|
|
21
23
|
* through the authorized middleware *
|
|
22
24
|
****************************************************/
|
|
23
25
|
|
|
24
|
-
async function checkDevAppLocks(ctx) {
|
|
26
|
+
async function checkDevAppLocks(ctx: BBContext) {
|
|
25
27
|
const appId = ctx.appId
|
|
26
28
|
|
|
27
29
|
// if any public usage, don't proceed
|
|
28
|
-
if (!ctx.user
|
|
30
|
+
if (!ctx.user?._id && !ctx.user?.userId) {
|
|
29
31
|
return
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -41,34 +43,34 @@ async function checkDevAppLocks(ctx) {
|
|
|
41
43
|
await updateLock(appId, ctx.user)
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
async function updateAppUpdatedAt(ctx) {
|
|
46
|
+
async function updateAppUpdatedAt(ctx: BBContext) {
|
|
45
47
|
const appId = ctx.appId
|
|
46
48
|
// if debouncing skip this update
|
|
47
49
|
// get methods also aren't updating
|
|
48
50
|
if (ctx.method === "GET" || (await checkDebounce(appId))) {
|
|
49
51
|
return
|
|
50
52
|
}
|
|
51
|
-
await doWithDB(appId, async db => {
|
|
53
|
+
await dbCore.doWithDB(appId, async (db: Database) => {
|
|
52
54
|
const metadata = await db.get(DocumentType.APP_METADATA)
|
|
53
55
|
metadata.updatedAt = new Date().toISOString()
|
|
54
56
|
|
|
55
|
-
metadata.updatedBy = getGlobalIDFromUserMetadataID(ctx.user
|
|
57
|
+
metadata.updatedBy = getGlobalIDFromUserMetadataID(ctx.user?.userId!)
|
|
56
58
|
|
|
57
59
|
const response = await db.put(metadata)
|
|
58
60
|
metadata._rev = response.rev
|
|
59
|
-
await
|
|
61
|
+
await cache.app.invalidateAppMetadata(appId, metadata)
|
|
60
62
|
// set a new debounce record with a short TTL
|
|
61
63
|
await setDebounce(appId, DEBOUNCE_TIME_SEC)
|
|
62
64
|
})
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
export = async function builder(ctx: BBContext, permType: string) {
|
|
66
68
|
const appId = ctx.appId
|
|
67
69
|
// this only functions within an app context
|
|
68
70
|
if (!appId) {
|
|
69
71
|
return
|
|
70
72
|
}
|
|
71
|
-
const isBuilderApi = permType ===
|
|
73
|
+
const isBuilderApi = permType === permissions.PermissionType.BUILDER
|
|
72
74
|
const referer = ctx.headers["referer"]
|
|
73
75
|
|
|
74
76
|
const overviewPath = "/builder/portal/overview/"
|