@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
|
@@ -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) {
|
package/src/integrations/s3.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Integration,
|
|
3
|
+
QueryType,
|
|
4
|
+
IntegrationBase,
|
|
5
|
+
DatasourceFieldType,
|
|
6
|
+
} from "@budibase/types"
|
|
7
|
+
|
|
2
8
|
const AWS = require("aws-sdk")
|
|
9
|
+
const csv = require("csvtojson")
|
|
3
10
|
|
|
4
11
|
interface S3Config {
|
|
5
12
|
region: string
|
|
@@ -40,16 +47,106 @@ const SCHEMA: Integration = {
|
|
|
40
47
|
},
|
|
41
48
|
},
|
|
42
49
|
query: {
|
|
50
|
+
create: {
|
|
51
|
+
type: QueryType.FIELDS,
|
|
52
|
+
fields: {
|
|
53
|
+
bucket: {
|
|
54
|
+
display: "New Bucket",
|
|
55
|
+
type: DatasourceFieldType.STRING,
|
|
56
|
+
required: true,
|
|
57
|
+
},
|
|
58
|
+
location: {
|
|
59
|
+
required: true,
|
|
60
|
+
default: "us-east-1",
|
|
61
|
+
type: DatasourceFieldType.STRING,
|
|
62
|
+
},
|
|
63
|
+
grantFullControl: {
|
|
64
|
+
display: "Grant full control",
|
|
65
|
+
type: DatasourceFieldType.STRING,
|
|
66
|
+
},
|
|
67
|
+
grantRead: {
|
|
68
|
+
display: "Grant read",
|
|
69
|
+
type: DatasourceFieldType.STRING,
|
|
70
|
+
},
|
|
71
|
+
grantReadAcp: {
|
|
72
|
+
display: "Grant read ACP",
|
|
73
|
+
type: DatasourceFieldType.STRING,
|
|
74
|
+
},
|
|
75
|
+
grantWrite: {
|
|
76
|
+
display: "Grant write",
|
|
77
|
+
type: DatasourceFieldType.STRING,
|
|
78
|
+
},
|
|
79
|
+
grantWriteAcp: {
|
|
80
|
+
display: "Grant write ACP",
|
|
81
|
+
type: DatasourceFieldType.STRING,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
43
85
|
read: {
|
|
44
86
|
type: QueryType.FIELDS,
|
|
45
87
|
fields: {
|
|
46
88
|
bucket: {
|
|
47
|
-
type:
|
|
89
|
+
type: DatasourceFieldType.STRING,
|
|
90
|
+
required: true,
|
|
91
|
+
},
|
|
92
|
+
delimiter: {
|
|
93
|
+
type: DatasourceFieldType.STRING,
|
|
94
|
+
},
|
|
95
|
+
marker: {
|
|
96
|
+
type: DatasourceFieldType.STRING,
|
|
97
|
+
},
|
|
98
|
+
maxKeys: {
|
|
99
|
+
type: DatasourceFieldType.NUMBER,
|
|
100
|
+
display: "Max Keys",
|
|
101
|
+
},
|
|
102
|
+
prefix: {
|
|
103
|
+
type: DatasourceFieldType.STRING,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
readCsv: {
|
|
108
|
+
displayName: "Read CSV",
|
|
109
|
+
type: QueryType.FIELDS,
|
|
110
|
+
fields: {
|
|
111
|
+
bucket: {
|
|
112
|
+
type: DatasourceFieldType.STRING,
|
|
113
|
+
required: true,
|
|
114
|
+
},
|
|
115
|
+
key: {
|
|
116
|
+
type: DatasourceFieldType.STRING,
|
|
117
|
+
required: true,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
delete: {
|
|
122
|
+
type: QueryType.FIELDS,
|
|
123
|
+
fields: {
|
|
124
|
+
bucket: {
|
|
125
|
+
type: DatasourceFieldType.STRING,
|
|
126
|
+
required: true,
|
|
127
|
+
},
|
|
128
|
+
delete: {
|
|
129
|
+
type: DatasourceFieldType.JSON,
|
|
48
130
|
required: true,
|
|
49
131
|
},
|
|
50
132
|
},
|
|
51
133
|
},
|
|
52
134
|
},
|
|
135
|
+
extra: {
|
|
136
|
+
acl: {
|
|
137
|
+
required: false,
|
|
138
|
+
displayName: "ACL",
|
|
139
|
+
type: DatasourceFieldType.LIST,
|
|
140
|
+
data: {
|
|
141
|
+
create: [
|
|
142
|
+
"private",
|
|
143
|
+
"public-read",
|
|
144
|
+
"public-read-write",
|
|
145
|
+
"authenticated-read",
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
53
150
|
}
|
|
54
151
|
|
|
55
152
|
class S3Integration implements IntegrationBase {
|
|
@@ -67,14 +164,93 @@ class S3Integration implements IntegrationBase {
|
|
|
67
164
|
this.client = new AWS.S3(this.config)
|
|
68
165
|
}
|
|
69
166
|
|
|
70
|
-
async
|
|
167
|
+
async create(query: {
|
|
168
|
+
bucket: string
|
|
169
|
+
location: string
|
|
170
|
+
grantFullControl: string
|
|
171
|
+
grantRead: string
|
|
172
|
+
grantReadAcp: string
|
|
173
|
+
grantWrite: string
|
|
174
|
+
grantWriteAcp: string
|
|
175
|
+
extra: {
|
|
176
|
+
acl: string
|
|
177
|
+
}
|
|
178
|
+
}) {
|
|
179
|
+
let params: any = {
|
|
180
|
+
Bucket: query.bucket,
|
|
181
|
+
ACL: query.extra?.acl,
|
|
182
|
+
GrantFullControl: query.grantFullControl,
|
|
183
|
+
GrantRead: query.grantRead,
|
|
184
|
+
GrantReadACP: query.grantReadAcp,
|
|
185
|
+
GrantWrite: query.grantWrite,
|
|
186
|
+
GrantWriteACP: query.grantWriteAcp,
|
|
187
|
+
}
|
|
188
|
+
if (query.location) {
|
|
189
|
+
params["CreateBucketConfiguration"] = {
|
|
190
|
+
LocationConstraint: query.location,
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return await this.client.createBucket(params).promise()
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async read(query: {
|
|
197
|
+
bucket: string
|
|
198
|
+
delimiter: string
|
|
199
|
+
expectedBucketOwner: string
|
|
200
|
+
marker: string
|
|
201
|
+
maxKeys: number
|
|
202
|
+
prefix: string
|
|
203
|
+
}) {
|
|
71
204
|
const response = await this.client
|
|
72
205
|
.listObjects({
|
|
73
206
|
Bucket: query.bucket,
|
|
207
|
+
Delimiter: query.delimiter,
|
|
208
|
+
Marker: query.marker,
|
|
209
|
+
MaxKeys: query.maxKeys,
|
|
210
|
+
Prefix: query.prefix,
|
|
74
211
|
})
|
|
75
212
|
.promise()
|
|
76
213
|
return response.Contents
|
|
77
214
|
}
|
|
215
|
+
|
|
216
|
+
async readCsv(query: { bucket: string; key: string }) {
|
|
217
|
+
const stream = this.client
|
|
218
|
+
.getObject({
|
|
219
|
+
Bucket: query.bucket,
|
|
220
|
+
Key: query.key,
|
|
221
|
+
})
|
|
222
|
+
.createReadStream()
|
|
223
|
+
|
|
224
|
+
let csvError = false
|
|
225
|
+
return new Promise((resolve, reject) => {
|
|
226
|
+
stream.on("error", (err: Error) => {
|
|
227
|
+
reject(err)
|
|
228
|
+
})
|
|
229
|
+
const response = csv()
|
|
230
|
+
.fromStream(stream)
|
|
231
|
+
.on("error", () => {
|
|
232
|
+
csvError = true
|
|
233
|
+
})
|
|
234
|
+
stream.on("finish", () => {
|
|
235
|
+
resolve(response)
|
|
236
|
+
})
|
|
237
|
+
}).catch(err => {
|
|
238
|
+
if (csvError) {
|
|
239
|
+
throw new Error("Could not read CSV")
|
|
240
|
+
} else {
|
|
241
|
+
throw err
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async delete(query: { bucket: string; delete: string }) {
|
|
247
|
+
return await this.client
|
|
248
|
+
.deleteObjects({
|
|
249
|
+
Bucket: query.bucket,
|
|
250
|
+
Delete: JSON.parse(query.delete),
|
|
251
|
+
})
|
|
252
|
+
.promise()
|
|
253
|
+
}
|
|
78
254
|
}
|
|
79
255
|
|
|
80
256
|
export default {
|
|
@@ -18,11 +18,95 @@ describe("S3 Integration", () => {
|
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
it("calls the read method with the correct params", async () => {
|
|
21
|
-
|
|
21
|
+
await config.integration.read({
|
|
22
22
|
bucket: "test",
|
|
23
|
+
delimiter: "/",
|
|
24
|
+
marker: "file.txt",
|
|
25
|
+
maxKeys: 999,
|
|
26
|
+
prefix: "directory/",
|
|
23
27
|
})
|
|
24
28
|
expect(config.integration.client.listObjects).toHaveBeenCalledWith({
|
|
25
29
|
Bucket: "test",
|
|
30
|
+
Delimiter: "/",
|
|
31
|
+
Marker: "file.txt",
|
|
32
|
+
MaxKeys: 999,
|
|
33
|
+
Prefix: "directory/",
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it("calls the create method with the correct params", async () => {
|
|
38
|
+
await config.integration.create({
|
|
39
|
+
bucket: "test",
|
|
40
|
+
location: "af-south-1",
|
|
41
|
+
grantFullControl: "me",
|
|
42
|
+
grantRead: "him",
|
|
43
|
+
grantReadAcp: "her",
|
|
44
|
+
grantWrite: "she",
|
|
45
|
+
grantWriteAcp: "he",
|
|
46
|
+
objectLockEnabledForBucket: true,
|
|
47
|
+
extra: {
|
|
48
|
+
acl: "private",
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
expect(config.integration.client.createBucket).toHaveBeenCalledWith({
|
|
52
|
+
Bucket: "test",
|
|
53
|
+
CreateBucketConfiguration: {
|
|
54
|
+
LocationConstraint: "af-south-1",
|
|
55
|
+
},
|
|
56
|
+
GrantFullControl: "me",
|
|
57
|
+
GrantRead: "him",
|
|
58
|
+
GrantReadACP: "her",
|
|
59
|
+
GrantWrite: "she",
|
|
60
|
+
GrantWriteACP: "he",
|
|
61
|
+
ACL: "private",
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it("does not add undefined location constraint when calling the create method", async () => {
|
|
66
|
+
await config.integration.create({
|
|
67
|
+
bucket: "test",
|
|
68
|
+
})
|
|
69
|
+
expect(config.integration.client.createBucket).toHaveBeenCalledWith({
|
|
70
|
+
Bucket: "test",
|
|
71
|
+
GrantFullControl: undefined,
|
|
72
|
+
GrantRead: undefined,
|
|
73
|
+
GrantReadACP: undefined,
|
|
74
|
+
GrantWrite: undefined,
|
|
75
|
+
GrantWriteACP: undefined,
|
|
76
|
+
ACL: undefined,
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it("calls the delete method with the correct params ", async () => {
|
|
81
|
+
await config.integration.delete({
|
|
82
|
+
bucket: "test",
|
|
83
|
+
delete: `{
|
|
84
|
+
"Objects": [
|
|
85
|
+
{
|
|
86
|
+
"Key": "HappyFace.jpg",
|
|
87
|
+
"VersionId": "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"Key": "HappyFace.jpg",
|
|
91
|
+
"VersionId": "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}`,
|
|
95
|
+
})
|
|
96
|
+
expect(config.integration.client.deleteObjects).toHaveBeenCalledWith({
|
|
97
|
+
Bucket: "test",
|
|
98
|
+
Delete: {
|
|
99
|
+
Objects: [
|
|
100
|
+
{
|
|
101
|
+
Key: "HappyFace.jpg",
|
|
102
|
+
VersionId: "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
Key: "HappyFace.jpg",
|
|
106
|
+
VersionId: "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd",
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
26
110
|
})
|
|
27
111
|
})
|
|
28
112
|
})
|
|
@@ -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/"
|
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const env = require("../environment")
|
|
15
|
-
const { isWebhookEndpoint } = require("./utils")
|
|
16
|
-
const { doInAppContext } = require("@budibase/backend-core/context")
|
|
1
|
+
import {
|
|
2
|
+
utils,
|
|
3
|
+
constants,
|
|
4
|
+
roles,
|
|
5
|
+
db as dbCore,
|
|
6
|
+
tenancy,
|
|
7
|
+
context,
|
|
8
|
+
} from "@budibase/backend-core"
|
|
9
|
+
import { generateUserMetadataID, isDevAppID } from "../db/utils"
|
|
10
|
+
import { getCachedSelf } from "../utilities/global"
|
|
11
|
+
import env from "../environment"
|
|
12
|
+
import { isWebhookEndpoint } from "./utils"
|
|
13
|
+
import { BBContext } from "@budibase/types"
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
export = async (ctx: BBContext, next: any) => {
|
|
19
16
|
// try to get the appID from the request
|
|
20
|
-
let requestAppId = await getAppIdFromCtx(ctx)
|
|
17
|
+
let requestAppId = await utils.getAppIdFromCtx(ctx)
|
|
21
18
|
// get app cookie if it exists
|
|
22
|
-
let appCookie
|
|
19
|
+
let appCookie: { appId?: string } | undefined
|
|
23
20
|
try {
|
|
24
|
-
appCookie = getCookie(ctx,
|
|
21
|
+
appCookie = utils.getCookie(ctx, constants.Cookie.CurrentApp)
|
|
25
22
|
} catch (err) {
|
|
26
|
-
clearCookie(ctx,
|
|
23
|
+
utils.clearCookie(ctx, constants.Cookie.CurrentApp)
|
|
27
24
|
}
|
|
28
25
|
if (!appCookie && !requestAppId) {
|
|
29
26
|
return next()
|
|
@@ -31,9 +28,9 @@ module.exports = async (ctx, next) => {
|
|
|
31
28
|
// check the app exists referenced in cookie
|
|
32
29
|
if (appCookie) {
|
|
33
30
|
const appId = appCookie.appId
|
|
34
|
-
const exists = await dbExists(appId)
|
|
31
|
+
const exists = await dbCore.dbExists(appId)
|
|
35
32
|
if (!exists) {
|
|
36
|
-
clearCookie(ctx,
|
|
33
|
+
utils.clearCookie(ctx, constants.Cookie.CurrentApp)
|
|
37
34
|
return next()
|
|
38
35
|
}
|
|
39
36
|
// if the request app ID wasn't set, update it with the cookie
|
|
@@ -47,13 +44,13 @@ module.exports = async (ctx, next) => {
|
|
|
47
44
|
!isWebhookEndpoint(ctx) &&
|
|
48
45
|
(!ctx.user || !ctx.user.builder || !ctx.user.builder.global)
|
|
49
46
|
) {
|
|
50
|
-
clearCookie(ctx,
|
|
47
|
+
utils.clearCookie(ctx, constants.Cookie.CurrentApp)
|
|
51
48
|
return ctx.redirect("/")
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
let appId,
|
|
56
|
-
roleId = BUILTIN_ROLE_IDS.PUBLIC
|
|
52
|
+
let appId: string | undefined,
|
|
53
|
+
roleId = roles.BUILTIN_ROLE_IDS.PUBLIC
|
|
57
54
|
if (!ctx.user) {
|
|
58
55
|
// not logged in, try to set a cookie for public apps
|
|
59
56
|
appId = requestAppId
|
|
@@ -68,16 +65,20 @@ module.exports = async (ctx, next) => {
|
|
|
68
65
|
const isBuilder =
|
|
69
66
|
globalUser && globalUser.builder && globalUser.builder.global
|
|
70
67
|
const isDevApp = appId && isDevAppID(appId)
|
|
71
|
-
const roleHeader =
|
|
68
|
+
const roleHeader =
|
|
69
|
+
ctx.request &&
|
|
70
|
+
(ctx.request.headers[constants.Header.PREVIEW_ROLE] as string)
|
|
72
71
|
if (isBuilder && isDevApp && roleHeader) {
|
|
73
72
|
// Ensure the role is valid by ensuring a definition exists
|
|
74
73
|
try {
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
if (roleHeader) {
|
|
75
|
+
await roles.getRole(roleHeader)
|
|
76
|
+
roleId = roleHeader
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
// Delete admin and builder flags so that the specified role is honoured
|
|
79
|
+
delete ctx.user.builder
|
|
80
|
+
delete ctx.user.admin
|
|
81
|
+
}
|
|
81
82
|
} catch (error) {
|
|
82
83
|
// Swallow error and do nothing
|
|
83
84
|
}
|
|
@@ -89,7 +90,7 @@ module.exports = async (ctx, next) => {
|
|
|
89
90
|
return next()
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
return doInAppContext(appId, async () => {
|
|
93
|
+
return context.doInAppContext(appId, async () => {
|
|
93
94
|
let skipCookie = false
|
|
94
95
|
// if the user not in the right tenant then make sure they have no permissions
|
|
95
96
|
// need to judge this only based on the request app ID,
|
|
@@ -97,14 +98,14 @@ module.exports = async (ctx, next) => {
|
|
|
97
98
|
env.MULTI_TENANCY &&
|
|
98
99
|
ctx.user &&
|
|
99
100
|
requestAppId &&
|
|
100
|
-
!isUserInAppTenant(requestAppId, ctx.user)
|
|
101
|
+
!tenancy.isUserInAppTenant(requestAppId, ctx.user)
|
|
101
102
|
) {
|
|
102
103
|
// don't error, simply remove the users rights (they are a public user)
|
|
103
104
|
delete ctx.user.builder
|
|
104
105
|
delete ctx.user.admin
|
|
105
106
|
delete ctx.user.roles
|
|
106
107
|
ctx.isAuthenticated = false
|
|
107
|
-
roleId = BUILTIN_ROLE_IDS.PUBLIC
|
|
108
|
+
roleId = roles.BUILTIN_ROLE_IDS.PUBLIC
|
|
108
109
|
skipCookie = true
|
|
109
110
|
}
|
|
110
111
|
|
|
@@ -112,15 +113,17 @@ module.exports = async (ctx, next) => {
|
|
|
112
113
|
if (roleId) {
|
|
113
114
|
ctx.roleId = roleId
|
|
114
115
|
const globalId = ctx.user ? ctx.user._id : undefined
|
|
115
|
-
const userId = ctx.user
|
|
116
|
+
const userId = ctx.user
|
|
117
|
+
? generateUserMetadataID(ctx.user._id!)
|
|
118
|
+
: undefined
|
|
116
119
|
ctx.user = {
|
|
117
|
-
...ctx.user
|
|
120
|
+
...ctx.user!,
|
|
118
121
|
// override userID with metadata one
|
|
119
122
|
_id: userId,
|
|
120
123
|
userId,
|
|
121
124
|
globalId,
|
|
122
125
|
roleId,
|
|
123
|
-
role: await getRole(roleId),
|
|
126
|
+
role: await roles.getRole(roleId),
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
if (
|
|
@@ -129,7 +132,7 @@ module.exports = async (ctx, next) => {
|
|
|
129
132
|
appCookie.appId !== requestAppId) &&
|
|
130
133
|
!skipCookie
|
|
131
134
|
) {
|
|
132
|
-
setCookie(ctx, { appId },
|
|
135
|
+
utils.setCookie(ctx, { appId }, constants.Cookie.CurrentApp)
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
return next()
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import Joi from "joi"
|
|
2
|
+
import { BBContext } from "@budibase/types"
|
|
2
3
|
|
|
3
|
-
function validate(schema, property) {
|
|
4
|
+
function validate(schema: Joi.Schema, property: string) {
|
|
4
5
|
// Return a Koa middleware function
|
|
5
|
-
return (ctx, next) => {
|
|
6
|
+
return (ctx: BBContext, next: any) => {
|
|
6
7
|
if (!schema) {
|
|
7
8
|
return next()
|
|
8
9
|
}
|
|
9
10
|
let params = null
|
|
10
11
|
if (ctx[property] != null) {
|
|
11
12
|
params = ctx[property]
|
|
12
|
-
} else if (ctx.request
|
|
13
|
-
params = ctx.request
|
|
13
|
+
} else if (ctx.request.get(property) != null) {
|
|
14
|
+
params = ctx.request.get(property)
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
// not all schemas have the append property e.g. array schemas
|
|
17
|
-
if (schema.append) {
|
|
18
|
+
if ("append" in schema && schema.append) {
|
|
18
19
|
schema = schema.append({
|
|
19
20
|
createdAt: Joi.any().optional(),
|
|
20
21
|
updatedAt: Joi.any().optional(),
|
|
@@ -30,10 +31,10 @@ function validate(schema, property) {
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
export function body(schema: Joi.Schema) {
|
|
34
35
|
return validate(schema, "body")
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
export function params(schema: Joi.Schema) {
|
|
38
39
|
return validate(schema, "params")
|
|
39
40
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { constants, utils } from "@budibase/backend-core"
|
|
2
|
+
import { BBContext } from "@budibase/types"
|
|
3
|
+
|
|
4
|
+
export = function ({ requiresAppId }: { requiresAppId?: boolean } = {}) {
|
|
5
|
+
return async (ctx: BBContext, next: any) => {
|
|
6
|
+
const appId = await utils.getAppIdFromCtx(ctx)
|
|
7
|
+
if (requiresAppId && !appId) {
|
|
8
|
+
ctx.throw(
|
|
9
|
+
400,
|
|
10
|
+
`Invalid app ID provided, please check the ${constants.Header.APP_ID} header.`
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
if (!ctx.headers[constants.Header.API_KEY]) {
|
|
14
|
+
ctx.throw(
|
|
15
|
+
400,
|
|
16
|
+
`Invalid API key provided, please check the ${constants.Header.API_KEY} header.`
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
return next()
|
|
20
|
+
}
|
|
21
|
+
}
|