@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
|
@@ -3,6 +3,7 @@ import { InternalTables } from "../../db/utils"
|
|
|
3
3
|
import { getFullUser } from "../../utilities/users"
|
|
4
4
|
import { roles, context } from "@budibase/backend-core"
|
|
5
5
|
import { groups } from "@budibase/pro"
|
|
6
|
+
import { ContextUser, User } from "@budibase/types"
|
|
6
7
|
|
|
7
8
|
const PUBLIC_ROLE = roles.BUILTIN_ROLE_IDS.PUBLIC
|
|
8
9
|
|
|
@@ -24,7 +25,7 @@ export async function fetchSelf(ctx: any) {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const appId = context.getAppId()
|
|
27
|
-
const user = await getFullUser(ctx, userId)
|
|
28
|
+
const user: ContextUser = await getFullUser(ctx, userId)
|
|
28
29
|
// this shouldn't be returned by the app self
|
|
29
30
|
delete user.roles
|
|
30
31
|
// forward the csrf token from the session
|
|
@@ -34,7 +35,7 @@ export async function fetchSelf(ctx: any) {
|
|
|
34
35
|
const db = context.getAppDB()
|
|
35
36
|
// check for group permissions
|
|
36
37
|
if (!user.roleId || user.roleId === PUBLIC_ROLE) {
|
|
37
|
-
const groupRoleId = await groups.getGroupRoleId(user, appId)
|
|
38
|
+
const groupRoleId = await groups.getGroupRoleId(user as User, appId)
|
|
38
39
|
user.roleId = groupRoleId || user.roleId
|
|
39
40
|
}
|
|
40
41
|
// remove the full roles structure
|
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
import Deployment from "./Deployment"
|
|
2
|
-
import {
|
|
3
|
-
getDevelopmentAppID,
|
|
4
|
-
getProdAppID,
|
|
5
|
-
Replication,
|
|
6
|
-
} from "@budibase/backend-core/db"
|
|
2
|
+
import { context, db as dbCore, events, cache } from "@budibase/backend-core"
|
|
7
3
|
import { DocumentType, getAutomationParams } from "../../../db/utils"
|
|
8
4
|
import {
|
|
9
5
|
clearMetadata,
|
|
10
6
|
disableAllCrons,
|
|
11
7
|
enableCronTrigger,
|
|
12
8
|
} from "../../../automations/utils"
|
|
13
|
-
import { app as appCache } from "@budibase/backend-core/cache"
|
|
14
|
-
import {
|
|
15
|
-
getAppDB,
|
|
16
|
-
getAppId,
|
|
17
|
-
getDevAppDB,
|
|
18
|
-
getProdAppDB,
|
|
19
|
-
} from "@budibase/backend-core/context"
|
|
20
|
-
import { events } from "@budibase/backend-core"
|
|
21
9
|
import { backups } from "@budibase/pro"
|
|
22
10
|
import { AppBackupTrigger } from "@budibase/types"
|
|
23
11
|
|
|
@@ -49,7 +37,7 @@ async function checkAllDeployments(deployments: any) {
|
|
|
49
37
|
|
|
50
38
|
async function storeDeploymentHistory(deployment: any) {
|
|
51
39
|
const deploymentJSON = deployment.getJSON()
|
|
52
|
-
const db = getAppDB()
|
|
40
|
+
const db = context.getAppDB()
|
|
53
41
|
|
|
54
42
|
let deploymentDoc
|
|
55
43
|
try {
|
|
@@ -77,7 +65,7 @@ async function storeDeploymentHistory(deployment: any) {
|
|
|
77
65
|
}
|
|
78
66
|
|
|
79
67
|
async function initDeployedApp(prodAppId: any) {
|
|
80
|
-
const db = getProdAppDB()
|
|
68
|
+
const db = context.getProdAppDB()
|
|
81
69
|
console.log("Reading automation docs")
|
|
82
70
|
const automations = (
|
|
83
71
|
await db.allDocs(
|
|
@@ -103,9 +91,9 @@ async function initDeployedApp(prodAppId: any) {
|
|
|
103
91
|
async function deployApp(deployment: any, userId: string) {
|
|
104
92
|
let replication
|
|
105
93
|
try {
|
|
106
|
-
const appId = getAppId()
|
|
107
|
-
const devAppId = getDevelopmentAppID(appId)
|
|
108
|
-
const productionAppId = getProdAppID(appId)
|
|
94
|
+
const appId = context.getAppId()!
|
|
95
|
+
const devAppId = dbCore.getDevelopmentAppID(appId)
|
|
96
|
+
const productionAppId = dbCore.getProdAppID(appId)
|
|
109
97
|
|
|
110
98
|
// don't try this if feature isn't allowed, will error
|
|
111
99
|
if (await backups.isEnabled()) {
|
|
@@ -122,8 +110,8 @@ async function deployApp(deployment: any, userId: string) {
|
|
|
122
110
|
source: devAppId,
|
|
123
111
|
target: productionAppId,
|
|
124
112
|
}
|
|
125
|
-
replication = new Replication(config)
|
|
126
|
-
const devDb = getDevAppDB()
|
|
113
|
+
replication = new dbCore.Replication(config)
|
|
114
|
+
const devDb = context.getDevAppDB()
|
|
127
115
|
console.log("Compacting development DB")
|
|
128
116
|
await devDb.compact()
|
|
129
117
|
console.log("Replication object created")
|
|
@@ -131,7 +119,7 @@ async function deployApp(deployment: any, userId: string) {
|
|
|
131
119
|
console.log("replication complete.. replacing app meta doc")
|
|
132
120
|
// app metadata is excluded as it is likely to be in conflict
|
|
133
121
|
// replicate the app metadata document manually
|
|
134
|
-
const db = getProdAppDB()
|
|
122
|
+
const db = context.getProdAppDB()
|
|
135
123
|
const appDoc = await devDb.get(DocumentType.APP_METADATA)
|
|
136
124
|
try {
|
|
137
125
|
const prodAppDoc = await db.get(DocumentType.APP_METADATA)
|
|
@@ -147,7 +135,7 @@ async function deployApp(deployment: any, userId: string) {
|
|
|
147
135
|
// remove automation errors if they exist
|
|
148
136
|
delete appDoc.automationErrors
|
|
149
137
|
await db.put(appDoc)
|
|
150
|
-
await
|
|
138
|
+
await cache.app.invalidateAppMetadata(productionAppId)
|
|
151
139
|
console.log("New app doc written successfully.")
|
|
152
140
|
await initDeployedApp(productionAppId)
|
|
153
141
|
console.log("Deployed app initialised, setting deployment to successful")
|
|
@@ -170,7 +158,7 @@ async function deployApp(deployment: any, userId: string) {
|
|
|
170
158
|
|
|
171
159
|
export async function fetchDeployments(ctx: any) {
|
|
172
160
|
try {
|
|
173
|
-
const db = getAppDB()
|
|
161
|
+
const db = context.getAppDB()
|
|
174
162
|
const deploymentDoc = await db.get(DocumentType.DEPLOYMENTS)
|
|
175
163
|
const { updated, deployments } = await checkAllDeployments(deploymentDoc)
|
|
176
164
|
if (updated) {
|
|
@@ -184,7 +172,7 @@ export async function fetchDeployments(ctx: any) {
|
|
|
184
172
|
|
|
185
173
|
export async function deploymentProgress(ctx: any) {
|
|
186
174
|
try {
|
|
187
|
-
const db = getAppDB()
|
|
175
|
+
const db = context.getAppDB()
|
|
188
176
|
const deploymentDoc = await db.get(DocumentType.DEPLOYMENTS)
|
|
189
177
|
ctx.body = deploymentDoc[ctx.params.deploymentId]
|
|
190
178
|
} catch (err) {
|
|
@@ -197,7 +185,7 @@ export async function deploymentProgress(ctx: any) {
|
|
|
197
185
|
|
|
198
186
|
const isFirstDeploy = async () => {
|
|
199
187
|
try {
|
|
200
|
-
const db = getProdAppDB()
|
|
188
|
+
const db = context.getProdAppDB()
|
|
201
189
|
await db.get(DocumentType.APP_METADATA)
|
|
202
190
|
} catch (e: any) {
|
|
203
191
|
if (e.status === 404) {
|
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { getProdAppDB, getAppDB } = require("@budibase/backend-core/context")
|
|
10
|
-
const { events } = require("@budibase/backend-core")
|
|
1
|
+
import fetch from "node-fetch"
|
|
2
|
+
import env from "../../environment"
|
|
3
|
+
import { checkSlashesInUrl } from "../../utilities"
|
|
4
|
+
import { request } from "../../utilities/workerRequests"
|
|
5
|
+
import { clearLock as redisClearLock } from "../../utilities/redis"
|
|
6
|
+
import { DocumentType } from "../../db/utils"
|
|
7
|
+
import { context } from "@budibase/backend-core"
|
|
8
|
+
import { events, db as dbCore, cache } from "@budibase/backend-core"
|
|
11
9
|
|
|
12
|
-
async function redirect(ctx, method, path = "global") {
|
|
10
|
+
async function redirect(ctx: any, method: string, path: string = "global") {
|
|
13
11
|
const { devPath } = ctx.params
|
|
14
12
|
const queryString = ctx.originalUrl.split("?")[1] || ""
|
|
15
13
|
const response = await fetch(
|
|
16
14
|
checkSlashesInUrl(
|
|
17
15
|
`${env.WORKER_URL}/api/${path}/${devPath}?${queryString}`
|
|
18
16
|
),
|
|
19
|
-
request(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
body: ctx.request.body,
|
|
24
|
-
},
|
|
25
|
-
true
|
|
26
|
-
)
|
|
17
|
+
request(ctx, {
|
|
18
|
+
method,
|
|
19
|
+
body: ctx.request.body,
|
|
20
|
+
})
|
|
27
21
|
)
|
|
28
22
|
if (response.status !== 200) {
|
|
29
23
|
const err = await response.text()
|
|
@@ -46,28 +40,28 @@ async function redirect(ctx, method, path = "global") {
|
|
|
46
40
|
ctx.cookies
|
|
47
41
|
}
|
|
48
42
|
|
|
49
|
-
|
|
50
|
-
return async ctx => {
|
|
43
|
+
export function buildRedirectGet(path: string) {
|
|
44
|
+
return async (ctx: any) => {
|
|
51
45
|
await redirect(ctx, "GET", path)
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
48
|
|
|
55
|
-
|
|
56
|
-
return async ctx => {
|
|
49
|
+
export function buildRedirectPost(path: string) {
|
|
50
|
+
return async (ctx: any) => {
|
|
57
51
|
await redirect(ctx, "POST", path)
|
|
58
52
|
}
|
|
59
53
|
}
|
|
60
54
|
|
|
61
|
-
|
|
62
|
-
return async ctx => {
|
|
55
|
+
export function buildRedirectDelete(path: string) {
|
|
56
|
+
return async (ctx: any) => {
|
|
63
57
|
await redirect(ctx, "DELETE", path)
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
|
|
61
|
+
export async function clearLock(ctx: any) {
|
|
68
62
|
const { appId } = ctx.params
|
|
69
63
|
try {
|
|
70
|
-
await
|
|
64
|
+
await redisClearLock(appId, ctx.user)
|
|
71
65
|
} catch (err) {
|
|
72
66
|
ctx.throw(400, `Unable to remove lock. ${err}`)
|
|
73
67
|
}
|
|
@@ -76,16 +70,16 @@ exports.clearLock = async ctx => {
|
|
|
76
70
|
}
|
|
77
71
|
}
|
|
78
72
|
|
|
79
|
-
|
|
73
|
+
export async function revert(ctx: any) {
|
|
80
74
|
const { appId } = ctx.params
|
|
81
|
-
const productionAppId = getProdAppID(appId)
|
|
75
|
+
const productionAppId = dbCore.getProdAppID(appId)
|
|
82
76
|
|
|
83
77
|
// App must have been deployed first
|
|
84
78
|
try {
|
|
85
|
-
const db = getProdAppDB({ skip_setup: true })
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
throw
|
|
79
|
+
const db = context.getProdAppDB({ skip_setup: true })
|
|
80
|
+
const exists = await db.exists()
|
|
81
|
+
if (!exists) {
|
|
82
|
+
throw new Error("App must be deployed to be reverted.")
|
|
89
83
|
}
|
|
90
84
|
const deploymentDoc = await db.get(DocumentType.DEPLOYMENTS)
|
|
91
85
|
if (
|
|
@@ -98,7 +92,7 @@ exports.revert = async ctx => {
|
|
|
98
92
|
return ctx.throw(400, "App has not yet been deployed")
|
|
99
93
|
}
|
|
100
94
|
|
|
101
|
-
const replication = new Replication({
|
|
95
|
+
const replication = new dbCore.Replication({
|
|
102
96
|
source: productionAppId,
|
|
103
97
|
target: appId,
|
|
104
98
|
})
|
|
@@ -109,12 +103,12 @@ exports.revert = async ctx => {
|
|
|
109
103
|
}
|
|
110
104
|
|
|
111
105
|
// update appID in reverted app to be dev version again
|
|
112
|
-
const db = getAppDB()
|
|
106
|
+
const db = context.getAppDB()
|
|
113
107
|
const appDoc = await db.get(DocumentType.APP_METADATA)
|
|
114
108
|
appDoc.appId = appId
|
|
115
109
|
appDoc.instance._id = appId
|
|
116
110
|
await db.put(appDoc)
|
|
117
|
-
await
|
|
111
|
+
await cache.app.invalidateAppMetadata(appId)
|
|
118
112
|
ctx.body = {
|
|
119
113
|
message: "Reverted changes successfully.",
|
|
120
114
|
}
|
|
@@ -126,7 +120,7 @@ exports.revert = async ctx => {
|
|
|
126
120
|
}
|
|
127
121
|
}
|
|
128
122
|
|
|
129
|
-
|
|
123
|
+
export async function getBudibaseVersion(ctx: any) {
|
|
130
124
|
const version = require("../../../package.json").version
|
|
131
125
|
ctx.body = {
|
|
132
126
|
version,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const { doInAppContext } = require("@budibase/backend-core/context")
|
|
1
|
+
import { db as dbCore, context } from "@budibase/backend-core"
|
|
3
2
|
import { search as stringSearch, addRev } from "./utils"
|
|
4
3
|
import * as controller from "../application"
|
|
5
4
|
import { Application } from "../../../definitions/common"
|
|
@@ -15,15 +14,22 @@ function fixAppID(app: Application, params: any) {
|
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
async function setResponseApp(ctx: any) {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const appId = ctx.body?.appId
|
|
18
|
+
if (appId && (!ctx.params || !ctx.params.appId)) {
|
|
19
|
+
ctx.params = { appId }
|
|
20
|
+
}
|
|
21
|
+
if (appId) {
|
|
22
|
+
await context.doInContext(appId, () => {
|
|
23
|
+
return controller.fetchAppPackage(ctx)
|
|
24
|
+
})
|
|
25
|
+
} else {
|
|
26
|
+
return controller.fetchAppPackage(ctx)
|
|
20
27
|
}
|
|
21
|
-
await controller.fetchAppPackage(ctx)
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
export async function search(ctx: any, next: any) {
|
|
25
31
|
const { name } = ctx.request.body
|
|
26
|
-
const apps = await getAllApps({ all: true })
|
|
32
|
+
const apps = await dbCore.getAllApps({ all: true })
|
|
27
33
|
ctx.body = stringSearch(apps, name)
|
|
28
34
|
await next()
|
|
29
35
|
}
|
|
@@ -41,7 +47,7 @@ export async function create(ctx: any, next: any) {
|
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
export async function read(ctx: any, next: any) {
|
|
44
|
-
await doInAppContext(ctx.params.appId, async () => {
|
|
50
|
+
await context.doInAppContext(ctx.params.appId, async () => {
|
|
45
51
|
await setResponseApp(ctx)
|
|
46
52
|
await next()
|
|
47
53
|
})
|
|
@@ -49,7 +55,7 @@ export async function read(ctx: any, next: any) {
|
|
|
49
55
|
|
|
50
56
|
export async function update(ctx: any, next: any) {
|
|
51
57
|
ctx.request.body = await addRev(fixAppID(ctx.request.body, ctx.params))
|
|
52
|
-
await doInAppContext(ctx.params.appId, async () => {
|
|
58
|
+
await context.doInAppContext(ctx.params.appId, async () => {
|
|
53
59
|
await controller.update(ctx)
|
|
54
60
|
await setResponseApp(ctx)
|
|
55
61
|
await next()
|
|
@@ -57,7 +63,7 @@ export async function update(ctx: any, next: any) {
|
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
export async function destroy(ctx: any, next: any) {
|
|
60
|
-
await doInAppContext(ctx.params.appId, async () => {
|
|
66
|
+
await context.doInAppContext(ctx.params.appId, async () => {
|
|
61
67
|
// get the app before deleting it
|
|
62
68
|
await setResponseApp(ctx)
|
|
63
69
|
const body = ctx.body
|
|
@@ -5,11 +5,8 @@ import { save as saveDatasource } from "../datasource"
|
|
|
5
5
|
import { RestImporter } from "./import"
|
|
6
6
|
import { invalidateDynamicVariables } from "../../../threads/utils"
|
|
7
7
|
import { QUERY_THREAD_TIMEOUT } from "../../../environment"
|
|
8
|
-
import { getAppDB } from "@budibase/backend-core/context"
|
|
9
8
|
import { quotas } from "@budibase/pro"
|
|
10
|
-
import { events } from "@budibase/backend-core"
|
|
11
|
-
import { getCookie } from "@budibase/backend-core/utils"
|
|
12
|
-
import { Cookies, Configs } from "@budibase/backend-core/constants"
|
|
9
|
+
import { events, context, utils, constants } from "@budibase/backend-core"
|
|
13
10
|
|
|
14
11
|
const Runner = new Thread(ThreadType.QUERY, {
|
|
15
12
|
timeoutMs: QUERY_THREAD_TIMEOUT || 10000,
|
|
@@ -28,7 +25,7 @@ function enrichQueries(input: any) {
|
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
export async function fetch(ctx: any) {
|
|
31
|
-
const db = getAppDB()
|
|
28
|
+
const db = context.getAppDB()
|
|
32
29
|
|
|
33
30
|
const body = await db.allDocs(
|
|
34
31
|
getQueryParams(null, {
|
|
@@ -81,7 +78,7 @@ const _import = async (ctx: any) => {
|
|
|
81
78
|
export { _import as import }
|
|
82
79
|
|
|
83
80
|
export async function save(ctx: any) {
|
|
84
|
-
const db = getAppDB()
|
|
81
|
+
const db = context.getAppDB()
|
|
85
82
|
const query = ctx.request.body
|
|
86
83
|
|
|
87
84
|
const datasource = await db.get(query.datasourceId)
|
|
@@ -103,7 +100,7 @@ export async function save(ctx: any) {
|
|
|
103
100
|
}
|
|
104
101
|
|
|
105
102
|
export async function find(ctx: any) {
|
|
106
|
-
const db = getAppDB()
|
|
103
|
+
const db = context.getAppDB()
|
|
107
104
|
const query = enrichQueries(await db.get(ctx.params.queryId))
|
|
108
105
|
// remove properties that could be dangerous in real app
|
|
109
106
|
if (isProdAppID(ctx.appId)) {
|
|
@@ -115,13 +112,13 @@ export async function find(ctx: any) {
|
|
|
115
112
|
|
|
116
113
|
//Required to discern between OIDC OAuth config entries
|
|
117
114
|
function getOAuthConfigCookieId(ctx: any) {
|
|
118
|
-
if (ctx.user.providerType ===
|
|
119
|
-
return getCookie(ctx,
|
|
115
|
+
if (ctx.user.providerType === constants.Config.OIDC) {
|
|
116
|
+
return utils.getCookie(ctx, constants.Cookie.OIDC_CONFIG)
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
119
|
|
|
123
120
|
function getAuthConfig(ctx: any) {
|
|
124
|
-
const authCookie = getCookie(ctx,
|
|
121
|
+
const authCookie = utils.getCookie(ctx, constants.Cookie.Auth)
|
|
125
122
|
let authConfigCtx: any = {}
|
|
126
123
|
authConfigCtx["configId"] = getOAuthConfigCookieId(ctx)
|
|
127
124
|
authConfigCtx["sessionId"] = authCookie ? authCookie.sessionId : null
|
|
@@ -129,7 +126,7 @@ function getAuthConfig(ctx: any) {
|
|
|
129
126
|
}
|
|
130
127
|
|
|
131
128
|
export async function preview(ctx: any) {
|
|
132
|
-
const db = getAppDB()
|
|
129
|
+
const db = context.getAppDB()
|
|
133
130
|
|
|
134
131
|
const datasource = await db.get(ctx.request.body.datasourceId)
|
|
135
132
|
const query = ctx.request.body
|
|
@@ -201,7 +198,7 @@ async function execute(
|
|
|
201
198
|
ctx: any,
|
|
202
199
|
opts: any = { rowsOnly: false, isAutomation: false }
|
|
203
200
|
) {
|
|
204
|
-
const db = getAppDB()
|
|
201
|
+
const db = context.getAppDB()
|
|
205
202
|
|
|
206
203
|
const query = await db.get(ctx.params.queryId)
|
|
207
204
|
const datasource = await db.get(query.datasourceId)
|
|
@@ -267,7 +264,7 @@ export async function executeV2(
|
|
|
267
264
|
}
|
|
268
265
|
|
|
269
266
|
const removeDynamicVariables = async (queryId: any) => {
|
|
270
|
-
const db = getAppDB()
|
|
267
|
+
const db = context.getAppDB()
|
|
271
268
|
const query = await db.get(queryId)
|
|
272
269
|
const datasource = await db.get(query.datasourceId)
|
|
273
270
|
const dynamicVariables = datasource.config.dynamicVariables
|
|
@@ -288,7 +285,7 @@ const removeDynamicVariables = async (queryId: any) => {
|
|
|
288
285
|
}
|
|
289
286
|
|
|
290
287
|
export async function destroy(ctx: any) {
|
|
291
|
-
const db = getAppDB()
|
|
288
|
+
const db = context.getAppDB()
|
|
292
289
|
const queryId = ctx.params.queryId
|
|
293
290
|
await removeDynamicVariables(queryId)
|
|
294
291
|
const query = await db.get(queryId)
|
|
@@ -282,9 +282,11 @@ module External {
|
|
|
282
282
|
const linkTablePrimary = linkTable.primary[0]
|
|
283
283
|
// one to many
|
|
284
284
|
if (isOneSide(field)) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
285
|
+
let id = row[key][0]
|
|
286
|
+
if (typeof row[key] === "string") {
|
|
287
|
+
id = decodeURIComponent(row[key]).match(/\[(.*?)\]/)?.[1]
|
|
288
|
+
}
|
|
289
|
+
newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(id)[0]
|
|
288
290
|
}
|
|
289
291
|
// many to many
|
|
290
292
|
else if (field.through) {
|
|
@@ -30,16 +30,24 @@ export async function patch(ctx: any): Promise<any> {
|
|
|
30
30
|
if (body && !body._id) {
|
|
31
31
|
return save(ctx)
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
try {
|
|
34
|
+
const { row, table } = await quotas.addQuery(
|
|
35
|
+
() => pickApi(tableId).patch(ctx),
|
|
36
|
+
{
|
|
37
|
+
datasourceId: tableId,
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
if (!row) {
|
|
41
|
+
ctx.throw(404, "Row not found")
|
|
37
42
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
ctx.status = 200
|
|
44
|
+
ctx.eventEmitter &&
|
|
45
|
+
ctx.eventEmitter.emitRow(`row:update`, appId, row, table)
|
|
46
|
+
ctx.message = `${table.name} updated successfully.`
|
|
47
|
+
ctx.body = row
|
|
48
|
+
} catch (err) {
|
|
49
|
+
ctx.throw(400, err)
|
|
50
|
+
}
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
export const save = async (ctx: any) => {
|
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
DocumentType,
|
|
7
7
|
InternalTables,
|
|
8
8
|
} = require("../../../db/utils")
|
|
9
|
-
const {
|
|
9
|
+
const { getDB } = require("@budibase/backend-core/db")
|
|
10
10
|
const userController = require("../user")
|
|
11
11
|
const {
|
|
12
12
|
inputProcessing,
|
|
@@ -251,7 +251,7 @@ exports.fetch = async ctx => {
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
exports.find = async ctx => {
|
|
254
|
-
const db =
|
|
254
|
+
const db = getDB(ctx.appId)
|
|
255
255
|
const table = await db.get(ctx.params.tableId)
|
|
256
256
|
let row = await findRow(ctx, ctx.params.tableId, ctx.params.rowId)
|
|
257
257
|
row = await outputProcessing(table, row)
|
|
@@ -2,7 +2,7 @@ import { updateLinks, EventType } from "../../../db/linkedRows"
|
|
|
2
2
|
import { getRowParams, generateTableID } from "../../../db/utils"
|
|
3
3
|
import { FieldTypes } from "../../../constants"
|
|
4
4
|
import { TableSaveFunctions, hasTypeChanged, handleDataImport } from "./utils"
|
|
5
|
-
|
|
5
|
+
import { context } from "@budibase/backend-core"
|
|
6
6
|
import { isTest } from "../../../environment"
|
|
7
7
|
import {
|
|
8
8
|
cleanupAttachments,
|
|
@@ -35,7 +35,7 @@ function checkAutoColumns(table: Table, oldTable: Table) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export async function save(ctx: any) {
|
|
38
|
-
const db = getAppDB()
|
|
38
|
+
const db = context.getAppDB()
|
|
39
39
|
const { dataImport, ...rest } = ctx.request.body
|
|
40
40
|
let tableToSave = {
|
|
41
41
|
type: "table",
|
|
@@ -138,7 +138,7 @@ export async function save(ctx: any) {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
export async function destroy(ctx: any) {
|
|
141
|
-
const db = getAppDB()
|
|
141
|
+
const db = context.getAppDB()
|
|
142
142
|
const tableToDelete = await db.get(ctx.params.tableId)
|
|
143
143
|
|
|
144
144
|
// Delete all rows for that table
|
|
@@ -161,7 +161,7 @@ export async function destroy(ctx: any) {
|
|
|
161
161
|
})
|
|
162
162
|
|
|
163
163
|
// don't remove the table itself until very end
|
|
164
|
-
await db.remove(tableToDelete)
|
|
164
|
+
await db.remove(tableToDelete._id, tableToDelete._rev)
|
|
165
165
|
|
|
166
166
|
// remove table search index
|
|
167
167
|
if (!isTest() || env.COUCH_DB_URL) {
|
|
@@ -3,8 +3,8 @@ const controller = require("../controllers/automation")
|
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
4
|
const {
|
|
5
5
|
BUILDER,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
PermissionLevel,
|
|
7
|
+
PermissionType,
|
|
8
8
|
} = require("@budibase/backend-core/permissions")
|
|
9
9
|
const { bodyResource, paramResource } = require("../../middleware/resourceId")
|
|
10
10
|
const {
|
|
@@ -71,14 +71,14 @@ router
|
|
|
71
71
|
"/api/automations/:id/trigger",
|
|
72
72
|
appInfoMiddleware({ appType: AppType.PROD }),
|
|
73
73
|
paramResource("id"),
|
|
74
|
-
authorized(
|
|
74
|
+
authorized(PermissionType.AUTOMATION, PermissionLevel.EXECUTE),
|
|
75
75
|
controller.trigger
|
|
76
76
|
)
|
|
77
77
|
.post(
|
|
78
78
|
"/api/automations/:id/test",
|
|
79
79
|
appInfoMiddleware({ appType: AppType.DEV }),
|
|
80
80
|
paramResource("id"),
|
|
81
|
-
authorized(
|
|
81
|
+
authorized(PermissionType.AUTOMATION, PermissionLevel.EXECUTE),
|
|
82
82
|
controller.test
|
|
83
83
|
)
|
|
84
84
|
|
|
@@ -3,8 +3,8 @@ const datasourceController = require("../controllers/datasource")
|
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
4
|
const {
|
|
5
5
|
BUILDER,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
PermissionLevel,
|
|
7
|
+
PermissionType,
|
|
8
8
|
} = require("@budibase/backend-core/permissions")
|
|
9
9
|
const {
|
|
10
10
|
datasourceValidator,
|
|
@@ -17,17 +17,17 @@ router
|
|
|
17
17
|
.get("/api/datasources", authorized(BUILDER), datasourceController.fetch)
|
|
18
18
|
.get(
|
|
19
19
|
"/api/datasources/:datasourceId",
|
|
20
|
-
authorized(
|
|
20
|
+
authorized(PermissionType.TABLE, PermissionLevel.READ),
|
|
21
21
|
datasourceController.find
|
|
22
22
|
)
|
|
23
23
|
.put(
|
|
24
24
|
"/api/datasources/:datasourceId",
|
|
25
|
-
authorized(
|
|
25
|
+
authorized(PermissionType.TABLE, PermissionLevel.READ),
|
|
26
26
|
datasourceController.update
|
|
27
27
|
)
|
|
28
28
|
.post(
|
|
29
29
|
"/api/datasources/query",
|
|
30
|
-
authorized(
|
|
30
|
+
authorized(PermissionType.TABLE, PermissionLevel.READ),
|
|
31
31
|
datasourceQueryValidator(),
|
|
32
32
|
datasourceController.query
|
|
33
33
|
)
|
|
@@ -13,8 +13,8 @@ import env from "../../../environment"
|
|
|
13
13
|
const Router = require("@koa/router")
|
|
14
14
|
const { RateLimit, Stores } = require("koa2-ratelimit")
|
|
15
15
|
const {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
PermissionLevel,
|
|
17
|
+
PermissionType,
|
|
18
18
|
} = require("@budibase/backend-core/permissions")
|
|
19
19
|
const { getRedisOptions } = require("@budibase/backend-core/redis").utils
|
|
20
20
|
|
|
@@ -105,7 +105,7 @@ function applyRoutes(
|
|
|
105
105
|
: paramResource(resource)
|
|
106
106
|
const publicApiMiddleware = publicApi({
|
|
107
107
|
requiresAppId:
|
|
108
|
-
permType !==
|
|
108
|
+
permType !== PermissionType.APP && permType !== PermissionType.USER,
|
|
109
109
|
})
|
|
110
110
|
addMiddleware(endpoints.read, publicApiMiddleware)
|
|
111
111
|
addMiddleware(endpoints.write, publicApiMiddleware)
|
|
@@ -113,8 +113,8 @@ function applyRoutes(
|
|
|
113
113
|
addMiddleware(endpoints.read, paramMiddleware)
|
|
114
114
|
addMiddleware(endpoints.write, paramMiddleware)
|
|
115
115
|
// add the authorization middleware, using the correct perm type
|
|
116
|
-
addMiddleware(endpoints.read, authorized(permType,
|
|
117
|
-
addMiddleware(endpoints.write, authorized(permType,
|
|
116
|
+
addMiddleware(endpoints.read, authorized(permType, PermissionLevel.READ))
|
|
117
|
+
addMiddleware(endpoints.write, authorized(permType, PermissionLevel.WRITE))
|
|
118
118
|
// add the output mapper middleware
|
|
119
119
|
addMiddleware(endpoints.read, mapperMiddleware, { output: true })
|
|
120
120
|
addMiddleware(endpoints.write, mapperMiddleware, { output: true })
|
|
@@ -122,12 +122,12 @@ function applyRoutes(
|
|
|
122
122
|
addToRouter(endpoints.write)
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
applyRoutes(appEndpoints,
|
|
126
|
-
applyRoutes(tableEndpoints,
|
|
127
|
-
applyRoutes(userEndpoints,
|
|
128
|
-
applyRoutes(queryEndpoints,
|
|
125
|
+
applyRoutes(appEndpoints, PermissionType.APP, "appId")
|
|
126
|
+
applyRoutes(tableEndpoints, PermissionType.TABLE, "tableId")
|
|
127
|
+
applyRoutes(userEndpoints, PermissionType.USER, "userId")
|
|
128
|
+
applyRoutes(queryEndpoints, PermissionType.QUERY, "queryId")
|
|
129
129
|
// needs to be applied last for routing purposes, don't override other endpoints
|
|
130
|
-
applyRoutes(rowEndpoints,
|
|
130
|
+
applyRoutes(rowEndpoints, PermissionType.TABLE, "tableId", "rowId")
|
|
131
131
|
|
|
132
132
|
export default publicRouter
|
|
133
133
|
|
|
@@ -31,7 +31,7 @@ async function makeRequest(method, endpoint, body, appId = config.getAppId()) {
|
|
|
31
31
|
if (body) {
|
|
32
32
|
req.send(body)
|
|
33
33
|
}
|
|
34
|
-
const res = await req
|
|
34
|
+
const res = await req
|
|
35
35
|
expect(res.body).toBeDefined()
|
|
36
36
|
return res
|
|
37
37
|
}
|