@budibase/server 2.1.30 → 2.1.32-alpha.0
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__/aws-sdk.ts +14 -0
- package/__mocks__/node-fetch.ts +5 -1
- package/builder/assets/{index.bdbc5a13.js → index.3a6f5b99.js} +270 -270
- package/builder/assets/{index.534f6c29.css → index.7176fd99.css} +1 -1
- package/builder/index.html +2 -2
- package/coverage/clover.xml +9664 -2787
- package/coverage/coverage-final.json +162 -19
- package/coverage/lcov-report/index.html +621 -126
- package/coverage/lcov-report/src/api/controllers/analytics.ts.html +190 -0
- package/coverage/lcov-report/{api → src/api}/controllers/apikeys.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/application.ts.html +1981 -0
- package/coverage/lcov-report/src/api/controllers/auth.ts.html +301 -0
- package/coverage/lcov-report/{api → src/api}/controllers/automation.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/backup.ts.html +148 -0
- package/coverage/lcov-report/{api → src/api}/controllers/cloud.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/component.ts.html +256 -0
- package/coverage/lcov-report/{api → src/api}/controllers/datasource.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/deploy/Deployment.js.html +250 -0
- package/coverage/lcov-report/src/api/controllers/deploy/index.html +131 -0
- package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +730 -0
- package/coverage/lcov-report/{api/controllers/dev.js.html → src/api/controllers/dev.ts.html} +53 -71
- package/coverage/lcov-report/{api → src/api}/controllers/index.html +134 -29
- package/coverage/lcov-report/{api → src/api}/controllers/integration.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/layout.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/metadata.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/migrations.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/permission.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +130 -0
- package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +310 -0
- package/coverage/lcov-report/src/api/controllers/plugin/index.html +206 -0
- package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +487 -0
- package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +253 -0
- package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +97 -0
- package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +121 -0
- package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +142 -0
- package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +334 -0
- package/coverage/lcov-report/src/api/controllers/public/index.html +191 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +181 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +191 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +124 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +202 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +178 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/tables.ts.html +163 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +181 -0
- package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +145 -0
- package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +328 -0
- package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +253 -0
- package/coverage/lcov-report/src/api/controllers/public/users.ts.html +268 -0
- package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +220 -0
- package/coverage/lcov-report/src/api/controllers/query/import/index.html +116 -0
- package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +376 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +131 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +379 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/openapi.ts.html +157 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/curl.ts.html +403 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +146 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +586 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +712 -0
- package/coverage/lcov-report/src/api/controllers/query/index.html +131 -0
- package/coverage/lcov-report/src/api/controllers/query/index.ts.html +976 -0
- package/coverage/lcov-report/{api → src/api}/controllers/query/validation.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/role.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/routing.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +2332 -0
- package/coverage/lcov-report/{api → src/api}/controllers/row/external.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/row/index.html +48 -18
- package/coverage/lcov-report/src/api/controllers/row/index.ts.html +541 -0
- package/coverage/lcov-report/{api → src/api}/controllers/row/internal.js.html +12 -12
- package/coverage/lcov-report/{api → src/api}/controllers/row/internalSearch.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/row/staticFormula.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/row/utils.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/screen.ts.html +451 -0
- package/coverage/lcov-report/{api → src/api}/controllers/script.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/static/index.html +116 -0
- package/coverage/lcov-report/src/api/controllers/static/index.ts.html +700 -0
- package/coverage/lcov-report/{api → src/api}/controllers/table/bulkFormula.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/table/external.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/table/index.html +49 -19
- package/coverage/lcov-report/{api → src/api}/controllers/table/index.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +664 -0
- package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +1240 -0
- package/coverage/lcov-report/{api → src/api}/controllers/templates.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/user.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/view/exporters.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/view/index.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/view/index.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/view/utils.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/view/viewBuilder.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/webhook.ts.html +379 -0
- package/coverage/lcov-report/{api → src/api}/index.html +10 -10
- package/coverage/lcov-report/{api → src/api}/index.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/analytics.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/apikeys.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/application.ts.html +199 -0
- package/coverage/lcov-report/src/api/routes/auth.ts.html +109 -0
- package/coverage/lcov-report/{api → src/api}/routes/automation.js.html +14 -14
- package/coverage/lcov-report/src/api/routes/backup.ts.html +115 -0
- package/coverage/lcov-report/{api → src/api}/routes/cloud.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/component.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/datasource.js.html +15 -15
- package/coverage/lcov-report/{api → src/api}/routes/deploy.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/dev.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/index.html +137 -17
- package/coverage/lcov-report/src/api/routes/index.ts.html +289 -0
- package/coverage/lcov-report/{api → src/api}/routes/integration.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/layout.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/metadata.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/migrations.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/permission.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/plugin.ts.html +127 -0
- package/coverage/lcov-report/src/api/routes/public/applications.ts.html +541 -0
- package/coverage/lcov-report/src/api/routes/public/index.html +191 -0
- package/coverage/lcov-report/src/api/routes/public/index.ts.html +502 -0
- package/coverage/lcov-report/src/api/routes/public/middleware/index.html +116 -0
- package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +328 -0
- package/coverage/lcov-report/src/api/routes/public/queries.ts.html +313 -0
- package/coverage/lcov-report/src/api/routes/public/rows.ts.html +598 -0
- package/coverage/lcov-report/src/api/routes/public/tables.ts.html +586 -0
- package/coverage/lcov-report/src/api/routes/public/users.ts.html +511 -0
- package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +238 -0
- package/coverage/lcov-report/src/api/routes/public/utils/index.html +116 -0
- package/coverage/lcov-report/{api → src/api}/routes/query.js.html +15 -15
- package/coverage/lcov-report/{api → src/api}/routes/role.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/routing.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/row.ts.html +889 -0
- package/coverage/lcov-report/{api → src/api}/routes/screen.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/script.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/static.ts.html +289 -0
- package/coverage/lcov-report/{api → src/api}/routes/table.js.html +13 -13
- package/coverage/lcov-report/{api → src/api}/routes/templates.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +556 -0
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +131 -0
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.js.html +367 -0
- package/coverage/lcov-report/{api → src/api}/routes/user.js.html +20 -20
- package/coverage/lcov-report/{api → src/api}/routes/utils/index.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/utils/validators.js.html +15 -15
- package/coverage/lcov-report/{api → src/api}/routes/view.js.html +13 -13
- package/coverage/lcov-report/src/api/routes/webhook.ts.html +166 -0
- package/coverage/lcov-report/src/app.ts.html +403 -0
- package/coverage/lcov-report/{automations → src/automations}/actions.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/automationUtils.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/bullboard.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/index.html +34 -19
- package/coverage/lcov-report/{automations → src/automations}/index.js.html +10 -10
- package/coverage/lcov-report/src/automations/logging/index.html +116 -0
- package/coverage/lcov-report/src/automations/logging/index.ts.html +199 -0
- package/coverage/lcov-report/{automations → src/automations}/steps/bash.js.html +10 -10
- package/coverage/lcov-report/src/automations/steps/createRow.ts.html +367 -0
- package/coverage/lcov-report/{automations → src/automations}/steps/delay.js.html +10 -10
- package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +334 -0
- package/coverage/lcov-report/{automations → src/automations}/steps/discord.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/executeQuery.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/executeScript.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/filter.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/index.html +56 -26
- package/coverage/lcov-report/{automations → src/automations}/steps/integromat.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/loop.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/outgoingWebhook.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/sendSmtpEmail.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/serverLog.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/slack.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/updateRow.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/utils.js.html +19 -19
- package/coverage/lcov-report/{automations → src/automations}/steps/zapier.js.html +10 -10
- package/coverage/lcov-report/src/automations/tests/utilities/index.html +116 -0
- package/coverage/lcov-report/src/automations/tests/utilities/index.js.html +256 -0
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/app.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/cron.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/index.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/index.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/rowDeleted.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/rowSaved.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/rowUpdated.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/webhook.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggers.js.html +10 -10
- package/coverage/lcov-report/src/automations/utils.ts.html +886 -0
- package/coverage/lcov-report/{constants → src/constants}/index.html +10 -10
- package/coverage/lcov-report/{constants → src/constants}/index.js.html +10 -10
- package/coverage/lcov-report/{constants → src/constants}/layouts.js.html +10 -10
- package/coverage/lcov-report/{constants → src/constants}/screens.js.html +10 -10
- package/coverage/lcov-report/src/db/dynamoClient.js.html +466 -0
- package/coverage/lcov-report/{db → src/db}/inMemoryView.js.html +12 -12
- package/coverage/lcov-report/{db → src/db}/index.html +42 -27
- package/coverage/lcov-report/{db → src/db}/index.js.html +18 -18
- package/coverage/lcov-report/{db → src/db}/linkedRows/LinkController.js.html +10 -10
- package/coverage/lcov-report/{db → src/db}/linkedRows/index.html +10 -10
- package/coverage/lcov-report/{db → src/db}/linkedRows/index.js.html +10 -10
- package/coverage/lcov-report/{db → src/db}/linkedRows/linkUtils.js.html +10 -10
- package/coverage/lcov-report/{db → src/db}/newid.js.html +10 -10
- package/coverage/lcov-report/{db/utils.js.html → src/db/utils.ts.html} +104 -152
- package/coverage/lcov-report/src/definitions/automations.ts.html +181 -0
- package/coverage/lcov-report/src/definitions/datasource.ts.html +235 -0
- package/coverage/lcov-report/src/definitions/index.html +131 -0
- package/coverage/lcov-report/src/environment.js.html +445 -0
- package/coverage/lcov-report/{events → src/events}/AutomationEmitter.js.html +10 -10
- package/coverage/lcov-report/{events → src/events}/index.html +10 -10
- package/coverage/lcov-report/{events → src/events}/index.js.html +10 -10
- package/coverage/lcov-report/{events → src/events}/utils.js.html +10 -10
- package/coverage/lcov-report/src/index.html +206 -0
- package/coverage/lcov-report/src/index.ts.html +133 -0
- package/coverage/lcov-report/src/integrations/airtable.ts.html +529 -0
- package/coverage/lcov-report/src/integrations/arangodb.ts.html +415 -0
- package/coverage/lcov-report/src/integrations/base/index.html +161 -0
- package/coverage/lcov-report/src/integrations/base/query.ts.html +133 -0
- package/coverage/lcov-report/src/integrations/base/sql.ts.html +1951 -0
- package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +691 -0
- package/coverage/lcov-report/src/integrations/base/utils.ts.html +121 -0
- package/coverage/lcov-report/src/integrations/couchdb.ts.html +406 -0
- package/coverage/lcov-report/src/integrations/dynamodb.ts.html +745 -0
- package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +634 -0
- package/coverage/lcov-report/src/integrations/firebase.ts.html +646 -0
- package/coverage/lcov-report/src/integrations/googlesheets.ts.html +1312 -0
- package/coverage/lcov-report/src/integrations/index.html +371 -0
- package/coverage/lcov-report/src/integrations/index.ts.html +433 -0
- package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +1006 -0
- package/coverage/lcov-report/src/integrations/mongodb.ts.html +1867 -0
- package/coverage/lcov-report/src/integrations/mysql.ts.html +952 -0
- package/coverage/lcov-report/src/integrations/oracle.ts.html +1474 -0
- package/coverage/lcov-report/src/integrations/postgres.ts.html +1069 -0
- package/coverage/lcov-report/src/integrations/queries/index.html +116 -0
- package/coverage/lcov-report/src/integrations/queries/sql.ts.html +463 -0
- package/coverage/lcov-report/src/integrations/redis.ts.html +550 -0
- package/coverage/lcov-report/src/integrations/rest.ts.html +1381 -0
- package/coverage/lcov-report/src/integrations/s3.ts.html +862 -0
- package/coverage/lcov-report/src/integrations/snowflake.ts.html +376 -0
- package/coverage/lcov-report/{integrations → src/integrations}/tests/TestConfiguration.js.html +10 -10
- package/coverage/lcov-report/{integrations → src/integrations}/tests/index.html +10 -10
- package/coverage/lcov-report/src/integrations/utils.ts.html +1006 -0
- package/coverage/lcov-report/{middleware/appInfo.js.html → src/middleware/appInfo.ts.html} +31 -28
- package/coverage/lcov-report/src/middleware/authorized.ts.html +481 -0
- package/coverage/lcov-report/{middleware/builder.js.html → src/middleware/builder.ts.html} +43 -37
- package/coverage/lcov-report/{middleware/currentapp.js.html → src/middleware/currentapp.ts.html} +77 -68
- package/coverage/lcov-report/{middleware → src/middleware}/index.html +78 -63
- package/coverage/lcov-report/{middleware/joi-validator.js.html → src/middleware/joi-validator.ts.html} +25 -22
- package/coverage/lcov-report/{middleware/publicApi.js.html → src/middleware/publicApi.ts.html} +24 -24
- package/coverage/lcov-report/{middleware/resourceId.js.html → src/middleware/resourceId.ts.html} +40 -25
- package/coverage/lcov-report/{middleware/selfhost.js.html → src/middleware/selfhost.ts.html} +25 -19
- package/coverage/lcov-report/{middleware/utils.js.html → src/middleware/utils.ts.html} +19 -13
- package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +187 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +163 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +206 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +172 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/queries.ts.html +226 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/roles.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +166 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +532 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +283 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +146 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +265 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +232 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +724 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/index.html +161 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +106 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +235 -0
- package/coverage/lcov-report/src/migrations/functions/index.html +146 -0
- package/coverage/lcov-report/src/migrations/functions/syncQuotas.ts.html +130 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +161 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +94 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +130 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +115 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncRows.ts.html +172 -0
- package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +124 -0
- package/coverage/lcov-report/src/migrations/index.html +116 -0
- package/coverage/lcov-report/src/migrations/index.ts.html +403 -0
- package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +205 -0
- package/coverage/lcov-report/src/migrations/tests/index.html +131 -0
- package/coverage/lcov-report/src/migrations/tests/structures.ts.html +283 -0
- package/coverage/lcov-report/src/module.d.ts.html +127 -0
- package/coverage/lcov-report/src/sdk/app/automations/index.html +131 -0
- package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +100 -0
- package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +214 -0
- package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +91 -0
- package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +598 -0
- package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +694 -0
- package/coverage/lcov-report/src/sdk/app/backups/index.html +176 -0
- package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +112 -0
- package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +292 -0
- package/coverage/lcov-report/src/sdk/app/tables/index.html +116 -0
- package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +265 -0
- package/coverage/lcov-report/{utilities/routing → src/sdk}/index.html +10 -10
- package/coverage/lcov-report/src/sdk/index.ts.html +130 -0
- package/coverage/lcov-report/src/startup.ts.html +499 -0
- package/coverage/lcov-report/src/tests/utilities/TestConfiguration.js.html +1873 -0
- package/coverage/lcov-report/src/tests/utilities/controllers.js.html +133 -0
- package/coverage/lcov-report/src/tests/utilities/index.html +161 -0
- package/coverage/lcov-report/src/tests/utilities/index.js.html +118 -0
- package/coverage/lcov-report/src/tests/utilities/structures.js.html +652 -0
- package/coverage/lcov-report/src/threads/automation.ts.html +1597 -0
- package/coverage/lcov-report/src/threads/index.html +161 -0
- package/coverage/lcov-report/src/threads/index.ts.html +418 -0
- package/coverage/lcov-report/src/threads/query.ts.html +976 -0
- package/coverage/lcov-report/src/threads/utils.ts.html +376 -0
- package/coverage/lcov-report/{utilities → src/utilities}/budibaseDir.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/centralPath.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/csvParser.js.html +10 -10
- package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.js.html +547 -0
- package/coverage/lcov-report/src/utilities/fileSystem/index.html +161 -0
- package/coverage/lcov-report/src/utilities/fileSystem/index.js.html +1141 -0
- package/coverage/lcov-report/src/utilities/fileSystem/processor.js.html +148 -0
- package/coverage/lcov-report/src/utilities/fileSystem/utilities.js.html +193 -0
- package/coverage/lcov-report/{utilities/global.js.html → src/utilities/global.ts.html} +107 -74
- package/coverage/lcov-report/{utilities → src/utilities}/index.html +42 -27
- package/coverage/lcov-report/{utilities → src/utilities}/index.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/plugins.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/queue/inMemoryQueue.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/queue/index.html +10 -10
- package/coverage/lcov-report/src/utilities/redis.js.html +340 -0
- package/coverage/lcov-report/{api/controllers/query → src/utilities/routing}/index.html +8 -8
- package/coverage/lcov-report/{utilities → src/utilities}/routing/index.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/rowProcessor/index.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/rowProcessor/index.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/rowProcessor/utils.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/scriptRunner.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/security.js.html +22 -22
- package/coverage/lcov-report/{utilities → src/utilities}/statusCodes.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/usageQuota/index.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/usageQuota/rows.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/usageQuota/usageQuoteReset.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/users.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/workerRequests.js.html +13 -13
- package/coverage/lcov-report/src/watch.ts.html +199 -0
- package/coverage/lcov-report/src/websocket.ts.html +163 -0
- package/coverage/lcov.info +17589 -5003
- 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/ExternalRequest.js +6 -1
- package/dist/api/controllers/row/index.js +16 -7
- package/dist/api/controllers/row/internal.js +2 -2
- package/dist/api/controllers/table/internal.js +4 -4
- 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/elasticsearch.js +26 -2
- package/dist/integrations/googlesheets.js +4 -6
- package/dist/integrations/s3.js +157 -1
- 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/migrations/functions/backfill/global.js +1 -1
- package/dist/migrations/functions/usageQuotas/syncRows.js +1 -1
- package/dist/package.json +10 -44
- package/dist/sdk/app/tables/index.js +4 -4
- package/dist/tests/utilities/TestConfiguration.js +12 -10
- 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 +33 -0
- package/package.json +11 -45
- package/scripts/localdomain.js +34 -6
- 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/ExternalRequest.ts +5 -3
- package/src/api/controllers/row/index.ts +17 -9
- package/src/api/controllers/row/internal.js +2 -2
- package/src/api/controllers/table/internal.ts +4 -4
- 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/elasticsearch.ts +32 -2
- package/src/integrations/googlesheets.ts +4 -7
- package/src/integrations/s3.ts +179 -3
- package/src/integrations/tests/s3.spec.ts +85 -1
- 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/migrations/functions/backfill/global.ts +1 -1
- package/src/migrations/functions/usageQuotas/syncRows.ts +2 -2
- 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/{scripts/jestSetup.js → src/tests/jestSetup.ts} +11 -2
- package/src/tests/utilities/TestConfiguration.js +12 -10
- 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/tsconfig.json +3 -1
- package/src/middleware/appInfo.js +0 -19
- package/src/middleware/publicApi.js +0 -21
- package/src/utilities/global.js +0 -127
package/src/api/routes/query.js
CHANGED
|
@@ -2,8 +2,8 @@ const Router = require("@koa/router")
|
|
|
2
2
|
const queryController = require("../controllers/query")
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
4
|
const {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
PermissionLevel,
|
|
6
|
+
PermissionType,
|
|
7
7
|
BUILDER,
|
|
8
8
|
} = require("@budibase/backend-core/permissions")
|
|
9
9
|
const {
|
|
@@ -38,20 +38,20 @@ router
|
|
|
38
38
|
.get(
|
|
39
39
|
"/api/queries/:queryId",
|
|
40
40
|
paramResource("queryId"),
|
|
41
|
-
authorized(
|
|
41
|
+
authorized(PermissionType.QUERY, PermissionLevel.READ),
|
|
42
42
|
queryController.find
|
|
43
43
|
)
|
|
44
44
|
// DEPRECATED - use new query endpoint for future work
|
|
45
45
|
.post(
|
|
46
46
|
"/api/queries/:queryId",
|
|
47
47
|
paramResource("queryId"),
|
|
48
|
-
authorized(
|
|
48
|
+
authorized(PermissionType.QUERY, PermissionLevel.WRITE),
|
|
49
49
|
queryController.executeV1
|
|
50
50
|
)
|
|
51
51
|
.post(
|
|
52
52
|
"/api/v2/queries/:queryId",
|
|
53
53
|
paramResource("queryId"),
|
|
54
|
-
authorized(
|
|
54
|
+
authorized(PermissionType.QUERY, PermissionLevel.WRITE),
|
|
55
55
|
queryController.executeV2
|
|
56
56
|
)
|
|
57
57
|
.delete(
|
package/src/api/routes/row.ts
CHANGED
|
@@ -3,8 +3,8 @@ import * as rowController from "../controllers/row"
|
|
|
3
3
|
import authorized from "../../middleware/authorized"
|
|
4
4
|
import { paramResource, paramSubResource } from "../../middleware/resourceId"
|
|
5
5
|
const {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
PermissionLevel,
|
|
7
|
+
PermissionType,
|
|
8
8
|
} = require("@budibase/backend-core/permissions")
|
|
9
9
|
const { internalSearchValidator } = require("./utils/validators")
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ router
|
|
|
28
28
|
.get(
|
|
29
29
|
"/api/:tableId/:rowId/enrich",
|
|
30
30
|
paramSubResource("tableId", "rowId"),
|
|
31
|
-
authorized(
|
|
31
|
+
authorized(PermissionType.TABLE, PermissionLevel.READ),
|
|
32
32
|
rowController.fetchEnrichedRow
|
|
33
33
|
)
|
|
34
34
|
/**
|
|
@@ -48,7 +48,7 @@ router
|
|
|
48
48
|
.get(
|
|
49
49
|
"/api/:tableId/rows",
|
|
50
50
|
paramResource("tableId"),
|
|
51
|
-
authorized(
|
|
51
|
+
authorized(PermissionType.TABLE, PermissionLevel.READ),
|
|
52
52
|
rowController.fetch
|
|
53
53
|
)
|
|
54
54
|
/**
|
|
@@ -67,7 +67,7 @@ router
|
|
|
67
67
|
.get(
|
|
68
68
|
"/api/:tableId/rows/:rowId",
|
|
69
69
|
paramSubResource("tableId", "rowId"),
|
|
70
|
-
authorized(
|
|
70
|
+
authorized(PermissionType.TABLE, PermissionLevel.READ),
|
|
71
71
|
rowController.find
|
|
72
72
|
)
|
|
73
73
|
/**
|
|
@@ -137,7 +137,7 @@ router
|
|
|
137
137
|
"/api/:tableId/search",
|
|
138
138
|
internalSearchValidator(),
|
|
139
139
|
paramResource("tableId"),
|
|
140
|
-
authorized(
|
|
140
|
+
authorized(PermissionType.TABLE, PermissionLevel.READ),
|
|
141
141
|
rowController.search
|
|
142
142
|
)
|
|
143
143
|
// DEPRECATED - this is an old API, but for backwards compat it needs to be
|
|
@@ -145,7 +145,7 @@ router
|
|
|
145
145
|
.post(
|
|
146
146
|
"/api/search/:tableId/rows",
|
|
147
147
|
paramResource("tableId"),
|
|
148
|
-
authorized(
|
|
148
|
+
authorized(PermissionType.TABLE, PermissionLevel.READ),
|
|
149
149
|
rowController.search
|
|
150
150
|
)
|
|
151
151
|
/**
|
|
@@ -175,7 +175,7 @@ router
|
|
|
175
175
|
.post(
|
|
176
176
|
"/api/:tableId/rows",
|
|
177
177
|
paramResource("tableId"),
|
|
178
|
-
authorized(
|
|
178
|
+
authorized(PermissionType.TABLE, PermissionLevel.WRITE),
|
|
179
179
|
rowController.save
|
|
180
180
|
)
|
|
181
181
|
/**
|
|
@@ -189,7 +189,7 @@ router
|
|
|
189
189
|
.patch(
|
|
190
190
|
"/api/:tableId/rows",
|
|
191
191
|
paramResource("tableId"),
|
|
192
|
-
authorized(
|
|
192
|
+
authorized(PermissionType.TABLE, PermissionLevel.WRITE),
|
|
193
193
|
rowController.patch
|
|
194
194
|
)
|
|
195
195
|
/**
|
|
@@ -215,7 +215,7 @@ router
|
|
|
215
215
|
.post(
|
|
216
216
|
"/api/:tableId/rows/validate",
|
|
217
217
|
paramResource("tableId"),
|
|
218
|
-
authorized(
|
|
218
|
+
authorized(PermissionType.TABLE, PermissionLevel.WRITE),
|
|
219
219
|
rowController.validate
|
|
220
220
|
)
|
|
221
221
|
/**
|
|
@@ -241,7 +241,7 @@ router
|
|
|
241
241
|
.delete(
|
|
242
242
|
"/api/:tableId/rows",
|
|
243
243
|
paramResource("tableId"),
|
|
244
|
-
authorized(
|
|
244
|
+
authorized(PermissionType.TABLE, PermissionLevel.WRITE),
|
|
245
245
|
rowController.destroy
|
|
246
246
|
)
|
|
247
247
|
|
|
@@ -261,7 +261,7 @@ router
|
|
|
261
261
|
.post(
|
|
262
262
|
"/api/:tableId/rows/exportRows",
|
|
263
263
|
paramResource("tableId"),
|
|
264
|
-
authorized(
|
|
264
|
+
authorized(PermissionType.TABLE, PermissionLevel.WRITE),
|
|
265
265
|
rowController.exportRows
|
|
266
266
|
)
|
|
267
267
|
|
package/src/api/routes/static.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { budibaseTempDir } from "../../utilities/budibaseDir"
|
|
|
4
4
|
import authorized from "../../middleware/authorized"
|
|
5
5
|
import {
|
|
6
6
|
BUILDER,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
PermissionType,
|
|
8
|
+
PermissionLevel,
|
|
9
9
|
} from "@budibase/backend-core/permissions"
|
|
10
10
|
import * as env from "../../environment"
|
|
11
11
|
import { paramResource } from "../../middleware/resourceId"
|
|
@@ -47,13 +47,13 @@ router
|
|
|
47
47
|
.post(
|
|
48
48
|
"/api/attachments/:tableId/upload",
|
|
49
49
|
paramResource("tableId"),
|
|
50
|
-
authorized(
|
|
50
|
+
authorized(PermissionType.TABLE, PermissionLevel.WRITE),
|
|
51
51
|
controller.uploadFile
|
|
52
52
|
)
|
|
53
53
|
.post(
|
|
54
54
|
"/api/attachments/:tableId/delete",
|
|
55
55
|
paramResource("tableId"),
|
|
56
|
-
authorized(
|
|
56
|
+
authorized(PermissionType.TABLE, PermissionLevel.WRITE),
|
|
57
57
|
controller.deleteObjects
|
|
58
58
|
)
|
|
59
59
|
.get("/app/preview", authorized(BUILDER), controller.serveBuilderPreview)
|
|
@@ -61,7 +61,7 @@ router
|
|
|
61
61
|
.get("/app/:appUrl/:path*", controller.serveApp)
|
|
62
62
|
.post(
|
|
63
63
|
"/api/attachments/:datasourceId/url",
|
|
64
|
-
authorized(
|
|
64
|
+
authorized(PermissionType.TABLE, PermissionLevel.READ),
|
|
65
65
|
controller.getSignedUploadURL
|
|
66
66
|
)
|
|
67
67
|
|
package/src/api/routes/table.js
CHANGED
|
@@ -4,8 +4,8 @@ const authorized = require("../../middleware/authorized")
|
|
|
4
4
|
const { paramResource, bodyResource } = require("../../middleware/resourceId")
|
|
5
5
|
const {
|
|
6
6
|
BUILDER,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
PermissionLevel,
|
|
8
|
+
PermissionType,
|
|
9
9
|
} = require("@budibase/backend-core/permissions")
|
|
10
10
|
const { tableValidator } = require("./utils/validators")
|
|
11
11
|
|
|
@@ -40,7 +40,7 @@ router
|
|
|
40
40
|
.get(
|
|
41
41
|
"/api/tables/:tableId",
|
|
42
42
|
paramResource("tableId"),
|
|
43
|
-
authorized(
|
|
43
|
+
authorized(PermissionType.TABLE, PermissionLevel.READ, { schema: true }),
|
|
44
44
|
tableController.find
|
|
45
45
|
)
|
|
46
46
|
/**
|
|
@@ -43,7 +43,7 @@ describe("/static", () => {
|
|
|
43
43
|
|
|
44
44
|
it("should ping from app", async () => {
|
|
45
45
|
const headers = config.defaultHeaders()
|
|
46
|
-
headers[constants.
|
|
46
|
+
headers[constants.Header.APP_ID] = config.prodAppId
|
|
47
47
|
|
|
48
48
|
await request
|
|
49
49
|
.post("/api/bbtel/ping")
|
|
@@ -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
|
}
|