@budibase/server 2.1.31 → 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.6e202eba.js → index.3a6f5b99.js} +270 -270
- package/builder/assets/{index.534f6c29.css → index.7176fd99.css} +1 -1
- package/builder/index.html +2 -2
- package/coverage/clover.xml +9664 -2787
- package/coverage/coverage-final.json +162 -19
- package/coverage/lcov-report/index.html +621 -126
- package/coverage/lcov-report/src/api/controllers/analytics.ts.html +190 -0
- package/coverage/lcov-report/{api → src/api}/controllers/apikeys.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/application.ts.html +1981 -0
- package/coverage/lcov-report/src/api/controllers/auth.ts.html +301 -0
- package/coverage/lcov-report/{api → src/api}/controllers/automation.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/backup.ts.html +148 -0
- package/coverage/lcov-report/{api → src/api}/controllers/cloud.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/component.ts.html +256 -0
- package/coverage/lcov-report/{api → src/api}/controllers/datasource.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/deploy/Deployment.js.html +250 -0
- package/coverage/lcov-report/src/api/controllers/deploy/index.html +131 -0
- package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +730 -0
- package/coverage/lcov-report/{api/controllers/dev.js.html → src/api/controllers/dev.ts.html} +53 -71
- package/coverage/lcov-report/{api → src/api}/controllers/index.html +134 -29
- package/coverage/lcov-report/{api → src/api}/controllers/integration.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/layout.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/metadata.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/migrations.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/permission.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +130 -0
- package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +310 -0
- package/coverage/lcov-report/src/api/controllers/plugin/index.html +206 -0
- package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +487 -0
- package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +253 -0
- package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +97 -0
- package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +121 -0
- package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +142 -0
- package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +334 -0
- package/coverage/lcov-report/src/api/controllers/public/index.html +191 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +181 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +191 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +124 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +202 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +178 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/tables.ts.html +163 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +181 -0
- package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +145 -0
- package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +328 -0
- package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +253 -0
- package/coverage/lcov-report/src/api/controllers/public/users.ts.html +268 -0
- package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +220 -0
- package/coverage/lcov-report/src/api/controllers/query/import/index.html +116 -0
- package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +376 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +131 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +379 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/openapi.ts.html +157 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/curl.ts.html +403 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +146 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +586 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +712 -0
- package/coverage/lcov-report/src/api/controllers/query/index.html +131 -0
- package/coverage/lcov-report/src/api/controllers/query/index.ts.html +976 -0
- package/coverage/lcov-report/{api → src/api}/controllers/query/validation.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/role.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/routing.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +2332 -0
- package/coverage/lcov-report/{api → src/api}/controllers/row/external.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/row/index.html +48 -18
- package/coverage/lcov-report/src/api/controllers/row/index.ts.html +541 -0
- package/coverage/lcov-report/{api → src/api}/controllers/row/internal.js.html +12 -12
- package/coverage/lcov-report/{api → src/api}/controllers/row/internalSearch.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/row/staticFormula.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/row/utils.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/screen.ts.html +451 -0
- package/coverage/lcov-report/{api → src/api}/controllers/script.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/static/index.html +116 -0
- package/coverage/lcov-report/src/api/controllers/static/index.ts.html +700 -0
- package/coverage/lcov-report/{api → src/api}/controllers/table/bulkFormula.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/table/external.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/table/index.html +49 -19
- package/coverage/lcov-report/{api → src/api}/controllers/table/index.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +664 -0
- package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +1240 -0
- package/coverage/lcov-report/{api → src/api}/controllers/templates.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/user.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/view/exporters.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/view/index.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/view/index.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/view/utils.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/controllers/view/viewBuilder.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/webhook.ts.html +379 -0
- package/coverage/lcov-report/{api → src/api}/index.html +10 -10
- package/coverage/lcov-report/{api → src/api}/index.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/analytics.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/apikeys.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/application.ts.html +199 -0
- package/coverage/lcov-report/src/api/routes/auth.ts.html +109 -0
- package/coverage/lcov-report/{api → src/api}/routes/automation.js.html +14 -14
- package/coverage/lcov-report/src/api/routes/backup.ts.html +115 -0
- package/coverage/lcov-report/{api → src/api}/routes/cloud.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/component.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/datasource.js.html +15 -15
- package/coverage/lcov-report/{api → src/api}/routes/deploy.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/dev.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/index.html +137 -17
- package/coverage/lcov-report/src/api/routes/index.ts.html +289 -0
- package/coverage/lcov-report/{api → src/api}/routes/integration.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/layout.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/metadata.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/migrations.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/permission.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/plugin.ts.html +127 -0
- package/coverage/lcov-report/src/api/routes/public/applications.ts.html +541 -0
- package/coverage/lcov-report/src/api/routes/public/index.html +191 -0
- package/coverage/lcov-report/src/api/routes/public/index.ts.html +502 -0
- package/coverage/lcov-report/src/api/routes/public/middleware/index.html +116 -0
- package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +328 -0
- package/coverage/lcov-report/src/api/routes/public/queries.ts.html +313 -0
- package/coverage/lcov-report/src/api/routes/public/rows.ts.html +598 -0
- package/coverage/lcov-report/src/api/routes/public/tables.ts.html +586 -0
- package/coverage/lcov-report/src/api/routes/public/users.ts.html +511 -0
- package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +238 -0
- package/coverage/lcov-report/src/api/routes/public/utils/index.html +116 -0
- package/coverage/lcov-report/{api → src/api}/routes/query.js.html +15 -15
- package/coverage/lcov-report/{api → src/api}/routes/role.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/routing.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/row.ts.html +889 -0
- package/coverage/lcov-report/{api → src/api}/routes/screen.js.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/script.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/static.ts.html +289 -0
- package/coverage/lcov-report/{api → src/api}/routes/table.js.html +13 -13
- package/coverage/lcov-report/{api → src/api}/routes/templates.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +556 -0
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +131 -0
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.js.html +367 -0
- package/coverage/lcov-report/{api → src/api}/routes/user.js.html +20 -20
- package/coverage/lcov-report/{api → src/api}/routes/utils/index.html +10 -10
- package/coverage/lcov-report/{api → src/api}/routes/utils/validators.js.html +15 -15
- package/coverage/lcov-report/{api → src/api}/routes/view.js.html +13 -13
- package/coverage/lcov-report/src/api/routes/webhook.ts.html +166 -0
- package/coverage/lcov-report/src/app.ts.html +403 -0
- package/coverage/lcov-report/{automations → src/automations}/actions.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/automationUtils.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/bullboard.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/index.html +34 -19
- package/coverage/lcov-report/{automations → src/automations}/index.js.html +10 -10
- package/coverage/lcov-report/src/automations/logging/index.html +116 -0
- package/coverage/lcov-report/src/automations/logging/index.ts.html +199 -0
- package/coverage/lcov-report/{automations → src/automations}/steps/bash.js.html +10 -10
- package/coverage/lcov-report/src/automations/steps/createRow.ts.html +367 -0
- package/coverage/lcov-report/{automations → src/automations}/steps/delay.js.html +10 -10
- package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +334 -0
- package/coverage/lcov-report/{automations → src/automations}/steps/discord.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/executeQuery.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/executeScript.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/filter.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/index.html +56 -26
- package/coverage/lcov-report/{automations → src/automations}/steps/integromat.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/loop.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/outgoingWebhook.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/sendSmtpEmail.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/serverLog.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/slack.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/updateRow.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/steps/utils.js.html +19 -19
- package/coverage/lcov-report/{automations → src/automations}/steps/zapier.js.html +10 -10
- package/coverage/lcov-report/src/automations/tests/utilities/index.html +116 -0
- package/coverage/lcov-report/src/automations/tests/utilities/index.js.html +256 -0
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/app.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/cron.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/index.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/index.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/rowDeleted.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/rowSaved.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/rowUpdated.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/webhook.js.html +10 -10
- package/coverage/lcov-report/{automations → src/automations}/triggers.js.html +10 -10
- package/coverage/lcov-report/src/automations/utils.ts.html +886 -0
- package/coverage/lcov-report/{constants → src/constants}/index.html +10 -10
- package/coverage/lcov-report/{constants → src/constants}/index.js.html +10 -10
- package/coverage/lcov-report/{constants → src/constants}/layouts.js.html +10 -10
- package/coverage/lcov-report/{constants → src/constants}/screens.js.html +10 -10
- package/coverage/lcov-report/src/db/dynamoClient.js.html +466 -0
- package/coverage/lcov-report/{db → src/db}/inMemoryView.js.html +12 -12
- package/coverage/lcov-report/{db → src/db}/index.html +42 -27
- package/coverage/lcov-report/{db → src/db}/index.js.html +18 -18
- package/coverage/lcov-report/{db → src/db}/linkedRows/LinkController.js.html +10 -10
- package/coverage/lcov-report/{db → src/db}/linkedRows/index.html +10 -10
- package/coverage/lcov-report/{db → src/db}/linkedRows/index.js.html +10 -10
- package/coverage/lcov-report/{db → src/db}/linkedRows/linkUtils.js.html +10 -10
- package/coverage/lcov-report/{db → src/db}/newid.js.html +10 -10
- package/coverage/lcov-report/{db/utils.js.html → src/db/utils.ts.html} +104 -152
- package/coverage/lcov-report/src/definitions/automations.ts.html +181 -0
- package/coverage/lcov-report/src/definitions/datasource.ts.html +235 -0
- package/coverage/lcov-report/src/definitions/index.html +131 -0
- package/coverage/lcov-report/src/environment.js.html +445 -0
- package/coverage/lcov-report/{events → src/events}/AutomationEmitter.js.html +10 -10
- package/coverage/lcov-report/{events → src/events}/index.html +10 -10
- package/coverage/lcov-report/{events → src/events}/index.js.html +10 -10
- package/coverage/lcov-report/{events → src/events}/utils.js.html +10 -10
- package/coverage/lcov-report/src/index.html +206 -0
- package/coverage/lcov-report/src/index.ts.html +133 -0
- package/coverage/lcov-report/src/integrations/airtable.ts.html +529 -0
- package/coverage/lcov-report/src/integrations/arangodb.ts.html +415 -0
- package/coverage/lcov-report/src/integrations/base/index.html +161 -0
- package/coverage/lcov-report/src/integrations/base/query.ts.html +133 -0
- package/coverage/lcov-report/src/integrations/base/sql.ts.html +1951 -0
- package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +691 -0
- package/coverage/lcov-report/src/integrations/base/utils.ts.html +121 -0
- package/coverage/lcov-report/src/integrations/couchdb.ts.html +406 -0
- package/coverage/lcov-report/src/integrations/dynamodb.ts.html +745 -0
- package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +634 -0
- package/coverage/lcov-report/src/integrations/firebase.ts.html +646 -0
- package/coverage/lcov-report/src/integrations/googlesheets.ts.html +1312 -0
- package/coverage/lcov-report/src/integrations/index.html +371 -0
- package/coverage/lcov-report/src/integrations/index.ts.html +433 -0
- package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +1006 -0
- package/coverage/lcov-report/src/integrations/mongodb.ts.html +1867 -0
- package/coverage/lcov-report/src/integrations/mysql.ts.html +952 -0
- package/coverage/lcov-report/src/integrations/oracle.ts.html +1474 -0
- package/coverage/lcov-report/src/integrations/postgres.ts.html +1069 -0
- package/coverage/lcov-report/src/integrations/queries/index.html +116 -0
- package/coverage/lcov-report/src/integrations/queries/sql.ts.html +463 -0
- package/coverage/lcov-report/src/integrations/redis.ts.html +550 -0
- package/coverage/lcov-report/src/integrations/rest.ts.html +1381 -0
- package/coverage/lcov-report/src/integrations/s3.ts.html +862 -0
- package/coverage/lcov-report/src/integrations/snowflake.ts.html +376 -0
- package/coverage/lcov-report/{integrations → src/integrations}/tests/TestConfiguration.js.html +10 -10
- package/coverage/lcov-report/{integrations → src/integrations}/tests/index.html +10 -10
- package/coverage/lcov-report/src/integrations/utils.ts.html +1006 -0
- package/coverage/lcov-report/{middleware/appInfo.js.html → src/middleware/appInfo.ts.html} +31 -28
- package/coverage/lcov-report/src/middleware/authorized.ts.html +481 -0
- package/coverage/lcov-report/{middleware/builder.js.html → src/middleware/builder.ts.html} +43 -37
- package/coverage/lcov-report/{middleware/currentapp.js.html → src/middleware/currentapp.ts.html} +77 -68
- package/coverage/lcov-report/{middleware → src/middleware}/index.html +78 -63
- package/coverage/lcov-report/{middleware/joi-validator.js.html → src/middleware/joi-validator.ts.html} +25 -22
- package/coverage/lcov-report/{middleware/publicApi.js.html → src/middleware/publicApi.ts.html} +24 -24
- package/coverage/lcov-report/{middleware/resourceId.js.html → src/middleware/resourceId.ts.html} +40 -25
- package/coverage/lcov-report/{middleware/selfhost.js.html → src/middleware/selfhost.ts.html} +25 -19
- package/coverage/lcov-report/{middleware/utils.js.html → src/middleware/utils.ts.html} +19 -13
- package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +187 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +163 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +206 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +172 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/queries.ts.html +226 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/roles.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +166 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +532 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +283 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +146 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +265 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +232 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +724 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/index.html +161 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +106 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +235 -0
- package/coverage/lcov-report/src/migrations/functions/index.html +146 -0
- package/coverage/lcov-report/src/migrations/functions/syncQuotas.ts.html +130 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +161 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +94 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +130 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +115 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncRows.ts.html +172 -0
- package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +124 -0
- package/coverage/lcov-report/src/migrations/index.html +116 -0
- package/coverage/lcov-report/src/migrations/index.ts.html +403 -0
- package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +205 -0
- package/coverage/lcov-report/src/migrations/tests/index.html +131 -0
- package/coverage/lcov-report/src/migrations/tests/structures.ts.html +283 -0
- package/coverage/lcov-report/src/module.d.ts.html +127 -0
- package/coverage/lcov-report/src/sdk/app/automations/index.html +131 -0
- package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +100 -0
- package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +214 -0
- package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +91 -0
- package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +598 -0
- package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +694 -0
- package/coverage/lcov-report/src/sdk/app/backups/index.html +176 -0
- package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +112 -0
- package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +292 -0
- package/coverage/lcov-report/src/sdk/app/tables/index.html +116 -0
- package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +265 -0
- package/coverage/lcov-report/{utilities/routing → src/sdk}/index.html +10 -10
- package/coverage/lcov-report/src/sdk/index.ts.html +130 -0
- package/coverage/lcov-report/src/startup.ts.html +499 -0
- package/coverage/lcov-report/src/tests/utilities/TestConfiguration.js.html +1873 -0
- package/coverage/lcov-report/src/tests/utilities/controllers.js.html +133 -0
- package/coverage/lcov-report/src/tests/utilities/index.html +161 -0
- package/coverage/lcov-report/src/tests/utilities/index.js.html +118 -0
- package/coverage/lcov-report/src/tests/utilities/structures.js.html +652 -0
- package/coverage/lcov-report/src/threads/automation.ts.html +1597 -0
- package/coverage/lcov-report/src/threads/index.html +161 -0
- package/coverage/lcov-report/src/threads/index.ts.html +418 -0
- package/coverage/lcov-report/src/threads/query.ts.html +976 -0
- package/coverage/lcov-report/src/threads/utils.ts.html +376 -0
- package/coverage/lcov-report/{utilities → src/utilities}/budibaseDir.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/centralPath.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/csvParser.js.html +10 -10
- package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.js.html +547 -0
- package/coverage/lcov-report/src/utilities/fileSystem/index.html +161 -0
- package/coverage/lcov-report/src/utilities/fileSystem/index.js.html +1141 -0
- package/coverage/lcov-report/src/utilities/fileSystem/processor.js.html +148 -0
- package/coverage/lcov-report/src/utilities/fileSystem/utilities.js.html +193 -0
- package/coverage/lcov-report/{utilities/global.js.html → src/utilities/global.ts.html} +107 -74
- package/coverage/lcov-report/{utilities → src/utilities}/index.html +42 -27
- package/coverage/lcov-report/{utilities → src/utilities}/index.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/plugins.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/queue/inMemoryQueue.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/queue/index.html +10 -10
- package/coverage/lcov-report/src/utilities/redis.js.html +340 -0
- package/coverage/lcov-report/{api/controllers/query → src/utilities/routing}/index.html +8 -8
- package/coverage/lcov-report/{utilities → src/utilities}/routing/index.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/rowProcessor/index.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/rowProcessor/index.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/rowProcessor/utils.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/scriptRunner.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/security.js.html +22 -22
- package/coverage/lcov-report/{utilities → src/utilities}/statusCodes.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/usageQuota/index.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/usageQuota/rows.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/usageQuota/usageQuoteReset.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/users.js.html +10 -10
- package/coverage/lcov-report/{utilities → src/utilities}/workerRequests.js.html +13 -13
- package/coverage/lcov-report/src/watch.ts.html +199 -0
- package/coverage/lcov-report/src/websocket.ts.html +163 -0
- package/coverage/lcov.info +17589 -5003
- package/dist/api/controllers/application.js +35 -43
- package/dist/api/controllers/deploy/index.js +13 -16
- package/dist/api/controllers/dev.js +96 -81
- package/dist/api/controllers/public/applications.js +17 -9
- package/dist/api/controllers/query/index.js +10 -13
- package/dist/api/controllers/row/ExternalRequest.js +6 -1
- package/dist/api/controllers/row/index.js +16 -7
- package/dist/api/controllers/row/internal.js +2 -2
- package/dist/api/controllers/table/internal.js +4 -4
- package/dist/api/routes/automation.js +3 -3
- package/dist/api/routes/datasource.js +4 -4
- package/dist/api/routes/public/index.js +9 -9
- package/dist/api/routes/query.js +4 -4
- package/dist/api/routes/row.js +11 -11
- package/dist/api/routes/static.js +3 -3
- package/dist/api/routes/table.js +2 -2
- package/dist/api/routes/user.js +9 -9
- package/dist/api/routes/utils/validators.js +4 -4
- package/dist/api/routes/view.js +2 -2
- package/dist/automations/tests/utilities/index.js +21 -12
- package/dist/automations/utils.js +9 -8
- package/dist/db/inMemoryView.js +2 -2
- package/dist/db/utils.js +145 -118
- package/dist/integrations/elasticsearch.js +26 -2
- package/dist/integrations/googlesheets.js +4 -6
- package/dist/integrations/s3.js +157 -1
- package/dist/middleware/appInfo.js +14 -9
- package/dist/middleware/authorized.js +5 -5
- package/dist/middleware/builder.js +41 -40
- package/dist/middleware/currentapp.js +39 -37
- package/dist/middleware/joi-validator.js +17 -10
- package/dist/middleware/publicApi.js +5 -6
- package/dist/middleware/resourceId.js +16 -9
- package/dist/middleware/selfhost.js +5 -4
- package/dist/middleware/utils.js +5 -2
- package/dist/migrations/functions/backfill/global.js +1 -1
- package/dist/migrations/functions/usageQuotas/syncRows.js +1 -1
- package/dist/package.json +10 -44
- package/dist/sdk/app/tables/index.js +4 -4
- package/dist/tests/utilities/TestConfiguration.js +12 -10
- package/dist/tests/utilities/structures.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/global.js +87 -66
- package/dist/utilities/security.js +10 -10
- package/dist/utilities/workerRequests.js +3 -3
- package/jest.config.ts +33 -0
- package/package.json +11 -45
- package/scripts/localdomain.js +34 -6
- package/src/api/controllers/application.ts +34 -39
- package/src/api/controllers/auth.ts +3 -2
- package/src/api/controllers/deploy/index.ts +13 -25
- package/src/api/controllers/{dev.js → dev.ts} +31 -37
- package/src/api/controllers/public/applications.ts +15 -9
- package/src/api/controllers/query/index.ts +11 -14
- package/src/api/controllers/row/ExternalRequest.ts +5 -3
- package/src/api/controllers/row/index.ts +17 -9
- package/src/api/controllers/row/internal.js +2 -2
- package/src/api/controllers/table/internal.ts +4 -4
- package/src/api/routes/automation.js +4 -4
- package/src/api/routes/datasource.js +5 -5
- package/src/api/routes/public/index.ts +10 -10
- package/src/api/routes/public/tests/compare.spec.js +1 -1
- package/src/api/routes/query.js +5 -5
- package/src/api/routes/row.ts +12 -12
- package/src/api/routes/static.ts +5 -5
- package/src/api/routes/table.js +3 -3
- package/src/api/routes/tests/analytics.spec.js +1 -1
- package/src/api/routes/tests/query.spec.js +15 -10
- package/src/api/routes/tests/role.spec.js +5 -5
- package/src/api/routes/tests/static.spec.js +2 -2
- package/src/api/routes/tests/table.spec.js +38 -35
- package/src/api/routes/user.js +10 -10
- package/src/api/routes/utils/validators.js +5 -5
- package/src/api/routes/view.js +3 -3
- package/src/automations/tests/updateRow.spec.js +0 -1
- package/src/automations/tests/utilities/index.js +10 -4
- package/src/automations/utils.ts +9 -12
- package/src/db/inMemoryView.js +2 -2
- package/src/db/tests/linkController.spec.js +73 -57
- package/src/db/tests/linkTests.spec.js +17 -14
- package/src/db/{utils.js → utils.ts} +76 -92
- package/src/integrations/elasticsearch.ts +32 -2
- package/src/integrations/googlesheets.ts +4 -7
- package/src/integrations/s3.ts +179 -3
- package/src/integrations/tests/s3.spec.ts +85 -1
- package/src/middleware/appInfo.ts +20 -0
- package/src/middleware/authorized.ts +6 -6
- package/src/middleware/{builder.js → builder.ts} +17 -15
- package/src/middleware/{currentapp.js → currentapp.ts} +42 -39
- package/src/middleware/{joi-validator.js → joi-validator.ts} +9 -8
- package/src/middleware/publicApi.ts +21 -0
- package/src/middleware/{resourceId.js → resourceId.ts} +16 -11
- package/src/middleware/{selfhost.js → selfhost.ts} +4 -2
- package/src/middleware/tests/authorized.spec.js +5 -5
- package/src/middleware/tests/currentapp.spec.js +118 -63
- package/src/middleware/{utils.js → utils.ts} +3 -1
- package/src/migrations/functions/backfill/app/tables.ts +2 -5
- package/src/migrations/functions/backfill/global.ts +1 -1
- package/src/migrations/functions/usageQuotas/syncRows.ts +2 -2
- package/src/sdk/app/backups/imports.ts +4 -7
- package/src/sdk/app/backups/statistics.ts +9 -18
- package/src/sdk/app/tables/index.ts +6 -7
- package/{scripts/jestSetup.js → src/tests/jestSetup.ts} +11 -2
- package/src/tests/utilities/TestConfiguration.js +12 -10
- package/src/tests/utilities/structures.js +2 -2
- package/src/threads/automation.ts +1 -1
- package/src/utilities/global.ts +138 -0
- package/src/utilities/security.js +12 -12
- package/src/utilities/workerRequests.js +3 -3
- package/tsconfig.json +3 -1
- package/src/middleware/appInfo.js +0 -19
- package/src/middleware/publicApi.js +0 -21
- package/src/utilities/global.js +0 -127
package/dist/utilities/global.js
CHANGED
|
@@ -8,49 +8,54 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getGlobalUsersFromMetadata = exports.getGlobalUsers = exports.getGlobalUser = exports.getRawGlobalUser = exports.getCachedSelf = exports.updateAppRole = void 0;
|
|
16
|
+
const utils_1 = require("../db/utils");
|
|
17
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
18
|
+
const environment_1 = __importDefault(require("../environment"));
|
|
19
|
+
const pro_1 = require("@budibase/pro");
|
|
20
|
+
function updateAppRole(user, { appId } = {}) {
|
|
21
21
|
var _a, _b;
|
|
22
|
-
appId = appId || getAppId();
|
|
22
|
+
appId = appId || backend_core_1.context.getAppId();
|
|
23
23
|
if (!user || !user.roles) {
|
|
24
24
|
return user;
|
|
25
25
|
}
|
|
26
26
|
// if in an multi-tenancy environment make sure roles are never updated
|
|
27
|
-
if (
|
|
27
|
+
if (environment_1.default.MULTI_TENANCY && appId && !backend_core_1.tenancy.isUserInAppTenant(appId, user)) {
|
|
28
28
|
delete user.builder;
|
|
29
29
|
delete user.admin;
|
|
30
|
-
user.roleId = BUILTIN_ROLE_IDS.PUBLIC;
|
|
30
|
+
user.roleId = backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC;
|
|
31
31
|
return user;
|
|
32
32
|
}
|
|
33
33
|
// always use the deployed app
|
|
34
|
-
|
|
34
|
+
if (appId) {
|
|
35
|
+
user.roleId = user.roles[backend_core_1.db.getProdAppID(appId)];
|
|
36
|
+
}
|
|
35
37
|
// if a role wasn't found then either set as admin (builder) or public (everyone else)
|
|
36
38
|
if (!user.roleId && user.builder && user.builder.global) {
|
|
37
|
-
user.roleId = BUILTIN_ROLE_IDS.ADMIN;
|
|
39
|
+
user.roleId = backend_core_1.roles.BUILTIN_ROLE_IDS.ADMIN;
|
|
38
40
|
}
|
|
39
41
|
else if (!user.roleId && !((_a = user === null || user === void 0 ? void 0 : user.userGroups) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
40
|
-
user.roleId = BUILTIN_ROLE_IDS.PUBLIC;
|
|
42
|
+
user.roleId = backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC;
|
|
41
43
|
}
|
|
42
44
|
else if ((_b = user === null || user === void 0 ? void 0 : user.userGroups) === null || _b === void 0 ? void 0 : _b.length) {
|
|
43
|
-
user.roleId =
|
|
45
|
+
user.roleId = undefined;
|
|
44
46
|
}
|
|
45
47
|
delete user.roles;
|
|
46
48
|
return user;
|
|
47
|
-
}
|
|
49
|
+
}
|
|
50
|
+
exports.updateAppRole = updateAppRole;
|
|
48
51
|
function checkGroupRoles(user, { appId } = {}) {
|
|
49
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
if (user.roleId && user.roleId !== BUILTIN_ROLE_IDS.PUBLIC) {
|
|
53
|
+
if (user.roleId && user.roleId !== backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC) {
|
|
51
54
|
return user;
|
|
52
55
|
}
|
|
53
|
-
|
|
56
|
+
if (appId) {
|
|
57
|
+
user.roleId = yield pro_1.groups.getGroupRoleId(user, appId);
|
|
58
|
+
}
|
|
54
59
|
return user;
|
|
55
60
|
});
|
|
56
61
|
}
|
|
@@ -60,57 +65,73 @@ function processUser(user, { appId } = {}) {
|
|
|
60
65
|
if (user) {
|
|
61
66
|
delete user.password;
|
|
62
67
|
}
|
|
63
|
-
user = yield
|
|
68
|
+
user = yield updateAppRole(user, { appId });
|
|
64
69
|
if (!user.roleId && ((_a = user === null || user === void 0 ? void 0 : user.userGroups) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
65
70
|
user = yield checkGroupRoles(user, { appId });
|
|
66
71
|
}
|
|
67
72
|
return user;
|
|
68
73
|
});
|
|
69
74
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const db = getGlobalDB();
|
|
78
|
-
return db.get(getGlobalIDFromUserMetadataID(userId));
|
|
79
|
-
});
|
|
80
|
-
exports.getGlobalUser = (userId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
-
const appId = getAppId();
|
|
82
|
-
let user = yield exports.getRawGlobalUser(userId);
|
|
83
|
-
return processUser(user, { appId });
|
|
84
|
-
});
|
|
85
|
-
exports.getGlobalUsers = (users = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
-
const appId = getAppId();
|
|
87
|
-
const db = getGlobalDB();
|
|
88
|
-
let globalUsers;
|
|
89
|
-
if (users) {
|
|
90
|
-
const globalIds = users.map(user => getGlobalIDFromUserMetadataID(user._id));
|
|
91
|
-
globalUsers = (yield db.allDocs(getMultiIDParams(globalIds))).rows.map(row => row.doc);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
globalUsers = (yield db.allDocs(getGlobalUserParams(null, {
|
|
95
|
-
include_docs: true,
|
|
96
|
-
}))).rows.map(row => row.doc);
|
|
97
|
-
}
|
|
98
|
-
globalUsers = globalUsers
|
|
99
|
-
.filter(user => user != null)
|
|
100
|
-
.map(user => {
|
|
101
|
-
delete user.password;
|
|
102
|
-
delete user.forceResetPassword;
|
|
103
|
-
return user;
|
|
75
|
+
function getCachedSelf(ctx, appId) {
|
|
76
|
+
var _a;
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
// this has to be tenant aware, can't depend on the context to find it out
|
|
79
|
+
// running some middlewares before the tenancy causes context to break
|
|
80
|
+
const user = yield backend_core_1.cache.user.getUser((_a = ctx.user) === null || _a === void 0 ? void 0 : _a._id);
|
|
81
|
+
return processUser(user, { appId });
|
|
104
82
|
});
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
83
|
+
}
|
|
84
|
+
exports.getCachedSelf = getCachedSelf;
|
|
85
|
+
function getRawGlobalUser(userId) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
const db = backend_core_1.tenancy.getGlobalDB();
|
|
88
|
+
return db.get((0, utils_1.getGlobalIDFromUserMetadataID)(userId));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
exports.getRawGlobalUser = getRawGlobalUser;
|
|
92
|
+
function getGlobalUser(userId) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const appId = backend_core_1.context.getAppId();
|
|
95
|
+
let user = yield getRawGlobalUser(userId);
|
|
96
|
+
return processUser(user, { appId });
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
exports.getGlobalUser = getGlobalUser;
|
|
100
|
+
function getGlobalUsers(users) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const appId = backend_core_1.context.getAppId();
|
|
103
|
+
const db = backend_core_1.tenancy.getGlobalDB();
|
|
104
|
+
let globalUsers;
|
|
105
|
+
if (users) {
|
|
106
|
+
const globalIds = users.map(user => (0, utils_1.getGlobalIDFromUserMetadataID)(user._id));
|
|
107
|
+
globalUsers = (yield db.allDocs((0, utils_1.getMultiIDParams)(globalIds))).rows.map(row => row.doc);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
globalUsers = (yield db.allDocs(backend_core_1.db.getGlobalUserParams(null, {
|
|
111
|
+
include_docs: true,
|
|
112
|
+
}))).rows.map(row => row.doc);
|
|
113
|
+
}
|
|
114
|
+
globalUsers = globalUsers
|
|
115
|
+
.filter(user => user != null)
|
|
116
|
+
.map(user => {
|
|
117
|
+
delete user.password;
|
|
118
|
+
delete user.forceResetPassword;
|
|
119
|
+
return user;
|
|
120
|
+
});
|
|
121
|
+
if (!appId) {
|
|
122
|
+
return globalUsers;
|
|
123
|
+
}
|
|
124
|
+
return globalUsers.map(user => updateAppRole(user));
|
|
115
125
|
});
|
|
116
|
-
}
|
|
126
|
+
}
|
|
127
|
+
exports.getGlobalUsers = getGlobalUsers;
|
|
128
|
+
function getGlobalUsersFromMetadata(users) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const globalUsers = yield getGlobalUsers(users);
|
|
131
|
+
return users.map(user => {
|
|
132
|
+
const globalUser = globalUsers.find(globalUser => { var _a; return globalUser && ((_a = user._id) === null || _a === void 0 ? void 0 : _a.includes(globalUser._id)); });
|
|
133
|
+
return Object.assign(Object.assign({}, globalUser), user);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
exports.getGlobalUsersFromMetadata = getGlobalUsersFromMetadata;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const {
|
|
2
|
+
const { PermissionLevel, PermissionType, getBuiltinPermissionByID, isPermissionLevelHigherThanRead, } = require("@budibase/backend-core/permissions");
|
|
3
3
|
const { lowerBuiltinRoleID, getBuiltinRoles, } = require("@budibase/backend-core/roles");
|
|
4
4
|
const { DocumentType } = require("../db/utils");
|
|
5
5
|
const CURRENTLY_SUPPORTED_LEVELS = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
PermissionLevel.WRITE,
|
|
7
|
+
PermissionLevel.READ,
|
|
8
|
+
PermissionLevel.EXECUTE,
|
|
9
9
|
];
|
|
10
10
|
exports.getPermissionType = resourceId => {
|
|
11
11
|
const docType = Object.values(DocumentType).filter(docType => resourceId.startsWith(docType))[0];
|
|
12
12
|
switch (docType) {
|
|
13
13
|
case DocumentType.TABLE:
|
|
14
14
|
case DocumentType.ROW:
|
|
15
|
-
return
|
|
15
|
+
return PermissionType.TABLE;
|
|
16
16
|
case DocumentType.AUTOMATION:
|
|
17
|
-
return
|
|
17
|
+
return PermissionType.AUTOMATION;
|
|
18
18
|
case DocumentType.WEBHOOK:
|
|
19
|
-
return
|
|
19
|
+
return PermissionType.WEBHOOK;
|
|
20
20
|
case DocumentType.QUERY:
|
|
21
21
|
case DocumentType.DATASOURCE:
|
|
22
|
-
return
|
|
22
|
+
return PermissionType.QUERY;
|
|
23
23
|
default:
|
|
24
24
|
// views don't have an ID, will end up here
|
|
25
|
-
return
|
|
25
|
+
return PermissionType.VIEW;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
@@ -44,7 +44,7 @@ exports.getBasePermissions = resourceId => {
|
|
|
44
44
|
const level = typedPermission.level;
|
|
45
45
|
permissions[level] = lowerBuiltinRoleID(permissions[level], roleId);
|
|
46
46
|
if (isPermissionLevelHigherThanRead(level)) {
|
|
47
|
-
permissions[
|
|
47
|
+
permissions[PermissionLevel.READ] = lowerBuiltinRoleID(permissions[PermissionLevel.READ], roleId);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -13,16 +13,16 @@ const env = require("../environment");
|
|
|
13
13
|
const { checkSlashesInUrl } = require("./index");
|
|
14
14
|
const { getProdAppID } = require("@budibase/backend-core/db");
|
|
15
15
|
const { updateAppRole } = require("./global");
|
|
16
|
-
const {
|
|
16
|
+
const { Header } = require("@budibase/backend-core/constants");
|
|
17
17
|
const { getTenantId, isTenantIdSet } = require("@budibase/backend-core/tenancy");
|
|
18
18
|
function request(ctx, request) {
|
|
19
19
|
if (!request.headers) {
|
|
20
20
|
request.headers = {};
|
|
21
21
|
}
|
|
22
22
|
if (!ctx) {
|
|
23
|
-
request.headers[
|
|
23
|
+
request.headers[Header.API_KEY] = env.INTERNAL_API_KEY;
|
|
24
24
|
if (isTenantIdSet()) {
|
|
25
|
-
request.headers[
|
|
25
|
+
request.headers[Header.TENANT_ID] = getTenantId();
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
if (request.body && Object.keys(request.body).length > 0) {
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Config } from "@jest/types"
|
|
2
|
+
import * as fs from "fs"
|
|
3
|
+
|
|
4
|
+
const config: Config.InitialOptions = {
|
|
5
|
+
preset: "ts-jest",
|
|
6
|
+
testEnvironment: "node",
|
|
7
|
+
setupFiles: ["./src/tests/jestSetup.ts"],
|
|
8
|
+
collectCoverageFrom: [
|
|
9
|
+
"src/**/*.{js,ts}",
|
|
10
|
+
// The use of coverage with couchdb view functions breaks tests
|
|
11
|
+
"!src/db/views/staticViews.*",
|
|
12
|
+
],
|
|
13
|
+
coverageReporters: ["lcov", "json", "clover"],
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (!process.env.CI) {
|
|
17
|
+
// use sources when not in CI
|
|
18
|
+
config.moduleNameMapper = {
|
|
19
|
+
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
|
|
20
|
+
"@budibase/backend-core": "<rootDir>/../backend-core/src",
|
|
21
|
+
"@budibase/types": "<rootDir>/../types/src",
|
|
22
|
+
"^axios.*$": "<rootDir>/node_modules/axios/lib/axios.js",
|
|
23
|
+
}
|
|
24
|
+
// add pro sources if they exist
|
|
25
|
+
if (fs.existsSync("../../../budibase-pro")) {
|
|
26
|
+
config.moduleNameMapper["@budibase/pro"] =
|
|
27
|
+
"<rootDir>/../../../budibase-pro/packages/pro/src"
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
console.log("Running tests with compiled dependency sources")
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default config
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.32-alpha.0",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -36,40 +36,6 @@
|
|
|
36
36
|
"env:account:enable": "node scripts/account.js enable",
|
|
37
37
|
"env:account:disable": "node scripts/account.js disable"
|
|
38
38
|
},
|
|
39
|
-
"jest": {
|
|
40
|
-
"preset": "ts-jest",
|
|
41
|
-
"testEnvironment": "node",
|
|
42
|
-
"moduleNameMapper": {
|
|
43
|
-
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
|
|
44
|
-
"@budibase/backend-core": "<rootDir>/../backend-core/src",
|
|
45
|
-
"@budibase/types": "<rootDir>/../types/src"
|
|
46
|
-
},
|
|
47
|
-
"setupFiles": [
|
|
48
|
-
"./scripts/jestSetup.js"
|
|
49
|
-
],
|
|
50
|
-
"collectCoverageFrom": [
|
|
51
|
-
"src/**/*.js",
|
|
52
|
-
"!**/node_modules/**",
|
|
53
|
-
"!src/db/views/*.js",
|
|
54
|
-
"!src/api/controllers/deploy/**/*.js",
|
|
55
|
-
"!src/*.js",
|
|
56
|
-
"!src/api/controllers/static/**/*",
|
|
57
|
-
"!src/db/dynamoClient.js",
|
|
58
|
-
"!src/utilities/usageQuota.js",
|
|
59
|
-
"!src/api/routes/tests/**/*",
|
|
60
|
-
"!src/db/tests/**/*",
|
|
61
|
-
"!src/tests/**/*",
|
|
62
|
-
"!src/automations/tests/**/*",
|
|
63
|
-
"!src/utilities/fileProcessor.js",
|
|
64
|
-
"!src/utilities/fileSystem/**/*",
|
|
65
|
-
"!src/utilities/redis.js"
|
|
66
|
-
],
|
|
67
|
-
"coverageReporters": [
|
|
68
|
-
"lcov",
|
|
69
|
-
"json",
|
|
70
|
-
"clover"
|
|
71
|
-
]
|
|
72
|
-
},
|
|
73
39
|
"keywords": [
|
|
74
40
|
"budibase"
|
|
75
41
|
],
|
|
@@ -77,11 +43,11 @@
|
|
|
77
43
|
"license": "GPL-3.0",
|
|
78
44
|
"dependencies": {
|
|
79
45
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
80
|
-
"@budibase/backend-core": "
|
|
81
|
-
"@budibase/client": "
|
|
82
|
-
"@budibase/pro": "2.1.
|
|
83
|
-
"@budibase/string-templates": "
|
|
84
|
-
"@budibase/types": "
|
|
46
|
+
"@budibase/backend-core": "2.1.32-alpha.0",
|
|
47
|
+
"@budibase/client": "2.1.32-alpha.0",
|
|
48
|
+
"@budibase/pro": "2.1.31",
|
|
49
|
+
"@budibase/string-templates": "2.1.32-alpha.0",
|
|
50
|
+
"@budibase/types": "2.1.32-alpha.0",
|
|
85
51
|
"@bull-board/api": "3.7.0",
|
|
86
52
|
"@bull-board/koa": "3.9.4",
|
|
87
53
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -179,7 +145,7 @@
|
|
|
179
145
|
"eslint": "6.8.0",
|
|
180
146
|
"ioredis-mock": "7.2.0",
|
|
181
147
|
"is-wsl": "2.2.0",
|
|
182
|
-
"jest": "
|
|
148
|
+
"jest": "28.1.1",
|
|
183
149
|
"jest-openapi": "0.14.2",
|
|
184
150
|
"nodemon": "2.0.15",
|
|
185
151
|
"openapi-types": "9.3.1",
|
|
@@ -190,14 +156,14 @@
|
|
|
190
156
|
"supertest": "4.0.2",
|
|
191
157
|
"swagger-jsdoc": "6.1.0",
|
|
192
158
|
"timekeeper": "2.2.0",
|
|
193
|
-
"ts-jest": "
|
|
194
|
-
"ts-node": "10.
|
|
159
|
+
"ts-jest": "28.0.4",
|
|
160
|
+
"ts-node": "10.8.1",
|
|
195
161
|
"tsconfig-paths": "4.0.0",
|
|
196
|
-
"typescript": "4.
|
|
162
|
+
"typescript": "4.7.3",
|
|
197
163
|
"update-dotenv": "1.1.1"
|
|
198
164
|
},
|
|
199
165
|
"optionalDependencies": {
|
|
200
166
|
"oracledb": "5.3.0"
|
|
201
167
|
},
|
|
202
|
-
"gitHead": "
|
|
168
|
+
"gitHead": "f192fc72b3035780f5d1b7595f24227841f50cf6"
|
|
203
169
|
}
|
package/scripts/localdomain.js
CHANGED
|
@@ -2,6 +2,36 @@
|
|
|
2
2
|
const updateDotEnv = require("update-dotenv")
|
|
3
3
|
|
|
4
4
|
const arg = process.argv.slice(2)[0]
|
|
5
|
+
const isEnable = arg === "enable"
|
|
6
|
+
|
|
7
|
+
let domain = process.argv.slice(2)[1]
|
|
8
|
+
if (!domain) {
|
|
9
|
+
domain = "local.com"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const getAccountPortalUrl = () => {
|
|
13
|
+
if (isEnable) {
|
|
14
|
+
return `http://account.${domain}:10001`
|
|
15
|
+
} else {
|
|
16
|
+
return `http://localhost:10001`
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const getBudibaseUrl = () => {
|
|
21
|
+
if (isEnable) {
|
|
22
|
+
return `http://${domain}:10000`
|
|
23
|
+
} else {
|
|
24
|
+
return `http://localhost:10000`
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const getCookieDomain = () => {
|
|
29
|
+
if (isEnable) {
|
|
30
|
+
return `.${domain}`
|
|
31
|
+
} else {
|
|
32
|
+
return ""
|
|
33
|
+
}
|
|
34
|
+
}
|
|
5
35
|
|
|
6
36
|
/**
|
|
7
37
|
* For testing multi tenancy sub domains locally.
|
|
@@ -16,9 +46,7 @@ const arg = process.argv.slice(2)[0]
|
|
|
16
46
|
* 127.0.0.1 t2.local.com
|
|
17
47
|
*/
|
|
18
48
|
updateDotEnv({
|
|
19
|
-
ACCOUNT_PORTAL_URL:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
COOKIE_DOMAIN: arg === "enable" ? ".local.com" : "",
|
|
24
|
-
}).then(() => console.log("Updated worker!"))
|
|
49
|
+
ACCOUNT_PORTAL_URL: getAccountPortalUrl(),
|
|
50
|
+
COOKIE_DOMAIN: getCookieDomain(),
|
|
51
|
+
PLATFORM_URL: getBudibaseUrl(),
|
|
52
|
+
}).then(() => console.log("Updated server!"))
|
|
@@ -14,17 +14,16 @@ import {
|
|
|
14
14
|
DocumentType,
|
|
15
15
|
AppStatus,
|
|
16
16
|
} from "../../db/utils"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} = require("@budibase/backend-core/db")
|
|
17
|
+
import {
|
|
18
|
+
db as dbCore,
|
|
19
|
+
roles,
|
|
20
|
+
cache,
|
|
21
|
+
tenancy,
|
|
22
|
+
context,
|
|
23
|
+
errors,
|
|
24
|
+
events,
|
|
25
|
+
migrations,
|
|
26
|
+
} from "@budibase/backend-core"
|
|
28
27
|
import { USERS_TABLE_SCHEMA } from "../../constants"
|
|
29
28
|
import { removeAppFromUserRoles } from "../../utilities/workerRequests"
|
|
30
29
|
import { clientLibraryPath, stringToReadStream } from "../../utilities"
|
|
@@ -34,15 +33,11 @@ import {
|
|
|
34
33
|
backupClientLibrary,
|
|
35
34
|
revertClientLibrary,
|
|
36
35
|
} from "../../utilities/fileSystem/clientLibrary"
|
|
37
|
-
const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy")
|
|
38
36
|
import { syncGlobalUsers } from "./user"
|
|
39
|
-
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
40
37
|
import { cleanupAutomations } from "../../automations/utils"
|
|
41
|
-
import { context } from "@budibase/backend-core"
|
|
42
38
|
import { checkAppMetadata } from "../../automations/logging"
|
|
43
39
|
import { getUniqueRows } from "../../utilities/usageQuota/rows"
|
|
44
40
|
import { quotas, groups } from "@budibase/pro"
|
|
45
|
-
import { errors, events, migrations } from "@budibase/backend-core"
|
|
46
41
|
import { App, Layout, Screen, MigrationType } from "@budibase/types"
|
|
47
42
|
import { BASE_LAYOUT_PROP_IDS } from "../../constants/layouts"
|
|
48
43
|
import { enrichPluginURLs } from "../../utilities/plugins"
|
|
@@ -75,7 +70,7 @@ async function getScreens() {
|
|
|
75
70
|
|
|
76
71
|
function getUserRoleId(ctx: any) {
|
|
77
72
|
return !ctx.user.role || !ctx.user.role._id
|
|
78
|
-
? BUILTIN_ROLE_IDS.PUBLIC
|
|
73
|
+
? roles.BUILTIN_ROLE_IDS.PUBLIC
|
|
79
74
|
: ctx.user.role._id
|
|
80
75
|
}
|
|
81
76
|
|
|
@@ -123,7 +118,7 @@ const checkAppName = (
|
|
|
123
118
|
}
|
|
124
119
|
|
|
125
120
|
async function createInstance(template: any) {
|
|
126
|
-
const tenantId = isMultiTenant() ? getTenantId() : null
|
|
121
|
+
const tenantId = tenancy.isMultiTenant() ? tenancy.getTenantId() : null
|
|
127
122
|
const baseAppId = generateAppID(tenantId)
|
|
128
123
|
const appId = generateDevAppID(baseAppId)
|
|
129
124
|
await context.updateAppId(appId)
|
|
@@ -162,7 +157,7 @@ async function createInstance(template: any) {
|
|
|
162
157
|
export const fetch = async (ctx: any) => {
|
|
163
158
|
const dev = ctx.query && ctx.query.status === AppStatus.DEV
|
|
164
159
|
const all = ctx.query && ctx.query.status === AppStatus.ALL
|
|
165
|
-
const apps = await getAllApps({ dev, all })
|
|
160
|
+
const apps = (await dbCore.getAllApps({ dev, all })) as App[]
|
|
166
161
|
|
|
167
162
|
const appIds = apps
|
|
168
163
|
.filter((app: any) => app.status === "development")
|
|
@@ -187,7 +182,7 @@ export const fetch = async (ctx: any) => {
|
|
|
187
182
|
export const fetchAppDefinition = async (ctx: any) => {
|
|
188
183
|
const layouts = await getLayouts()
|
|
189
184
|
const userRoleId = getUserRoleId(ctx)
|
|
190
|
-
const accessController = new AccessController()
|
|
185
|
+
const accessController = new roles.AccessController()
|
|
191
186
|
const screens = await accessController.checkScreensAccess(
|
|
192
187
|
await getScreens(),
|
|
193
188
|
userRoleId
|
|
@@ -211,7 +206,7 @@ export const fetchAppPackage = async (ctx: any) => {
|
|
|
211
206
|
// Only filter screens if the user is not a builder
|
|
212
207
|
if (!(ctx.user.builder && ctx.user.builder.global)) {
|
|
213
208
|
const userRoleId = getUserRoleId(ctx)
|
|
214
|
-
const accessController = new AccessController()
|
|
209
|
+
const accessController = new roles.AccessController()
|
|
215
210
|
screens = await accessController.checkScreensAccess(screens, userRoleId)
|
|
216
211
|
}
|
|
217
212
|
|
|
@@ -224,7 +219,7 @@ export const fetchAppPackage = async (ctx: any) => {
|
|
|
224
219
|
}
|
|
225
220
|
|
|
226
221
|
const performAppCreate = async (ctx: any) => {
|
|
227
|
-
const apps = await getAllApps({ dev: true })
|
|
222
|
+
const apps = await dbCore.getAllApps({ dev: true })
|
|
228
223
|
const name = ctx.request.body.name
|
|
229
224
|
checkAppName(ctx, apps, name)
|
|
230
225
|
const url = getAppUrl(ctx)
|
|
@@ -254,7 +249,7 @@ const performAppCreate = async (ctx: any) => {
|
|
|
254
249
|
url: url,
|
|
255
250
|
template: templateKey,
|
|
256
251
|
instance,
|
|
257
|
-
tenantId: getTenantId(),
|
|
252
|
+
tenantId: tenancy.getTenantId(),
|
|
258
253
|
updatedAt: new Date().toISOString(),
|
|
259
254
|
createdAt: new Date().toISOString(),
|
|
260
255
|
status: AppStatus.DEV,
|
|
@@ -313,7 +308,7 @@ const performAppCreate = async (ctx: any) => {
|
|
|
313
308
|
await createApp(appId)
|
|
314
309
|
}
|
|
315
310
|
|
|
316
|
-
await
|
|
311
|
+
await cache.app.invalidateAppMetadata(appId, newApplication)
|
|
317
312
|
return newApplication
|
|
318
313
|
}
|
|
319
314
|
|
|
@@ -343,7 +338,7 @@ const creationEvents = async (request: any, app: App) => {
|
|
|
343
338
|
}
|
|
344
339
|
|
|
345
340
|
const appPostCreate = async (ctx: any, app: App) => {
|
|
346
|
-
const tenantId = getTenantId()
|
|
341
|
+
const tenantId = tenancy.getTenantId()
|
|
347
342
|
await migrations.backPopulateMigrations({
|
|
348
343
|
type: MigrationType.APP,
|
|
349
344
|
tenantId,
|
|
@@ -356,7 +351,9 @@ const appPostCreate = async (ctx: any, app: App) => {
|
|
|
356
351
|
const rowCount = rows ? rows.length : 0
|
|
357
352
|
if (rowCount) {
|
|
358
353
|
try {
|
|
359
|
-
await
|
|
354
|
+
await context.doInAppContext(app.appId, () => {
|
|
355
|
+
return quotas.addRows(rowCount)
|
|
356
|
+
})
|
|
360
357
|
} catch (err: any) {
|
|
361
358
|
if (err.code && err.code === errors.codes.USAGE_LIMIT_EXCEEDED) {
|
|
362
359
|
// this import resulted in row usage exceeding the quota
|
|
@@ -374,7 +371,7 @@ const appPostCreate = async (ctx: any, app: App) => {
|
|
|
374
371
|
export const create = async (ctx: any) => {
|
|
375
372
|
const newApplication = await quotas.addApp(() => performAppCreate(ctx))
|
|
376
373
|
await appPostCreate(ctx, newApplication)
|
|
377
|
-
await bustCache(CacheKeys.CHECKLIST)
|
|
374
|
+
await cache.bustCache(cache.CacheKeys.CHECKLIST)
|
|
378
375
|
ctx.body = newApplication
|
|
379
376
|
ctx.status = 200
|
|
380
377
|
}
|
|
@@ -382,7 +379,7 @@ export const create = async (ctx: any) => {
|
|
|
382
379
|
// This endpoint currently operates as a PATCH rather than a PUT
|
|
383
380
|
// Thus name and url fields are handled only if present
|
|
384
381
|
export const update = async (ctx: any) => {
|
|
385
|
-
const apps = await getAllApps({ dev: true })
|
|
382
|
+
const apps = await dbCore.getAllApps({ dev: true })
|
|
386
383
|
// validation
|
|
387
384
|
const name = ctx.request.body.name
|
|
388
385
|
if (name) {
|
|
@@ -455,7 +452,7 @@ const destroyApp = async (ctx: any) => {
|
|
|
455
452
|
let isUnpublish = ctx.query && ctx.query.unpublish
|
|
456
453
|
|
|
457
454
|
if (isUnpublish) {
|
|
458
|
-
appId = getProdAppID(appId)
|
|
455
|
+
appId = dbCore.getProdAppID(appId)
|
|
459
456
|
}
|
|
460
457
|
|
|
461
458
|
const db = isUnpublish ? context.getProdAppDB() : context.getAppDB()
|
|
@@ -481,7 +478,7 @@ const destroyApp = async (ctx: any) => {
|
|
|
481
478
|
else {
|
|
482
479
|
await removeAppFromUserRoles(ctx, appId)
|
|
483
480
|
}
|
|
484
|
-
await
|
|
481
|
+
await cache.app.invalidateAppMetadata(appId)
|
|
485
482
|
return result
|
|
486
483
|
}
|
|
487
484
|
|
|
@@ -517,19 +514,17 @@ export const sync = async (ctx: any, next: any) => {
|
|
|
517
514
|
}
|
|
518
515
|
|
|
519
516
|
const appId = ctx.params.appId
|
|
520
|
-
if (!isDevAppID(appId)) {
|
|
517
|
+
if (!dbCore.isDevAppID(appId)) {
|
|
521
518
|
ctx.throw(400, "This action cannot be performed for production apps")
|
|
522
519
|
}
|
|
523
520
|
|
|
524
521
|
// replicate prod to dev
|
|
525
|
-
const prodAppId = getProdAppID(appId)
|
|
522
|
+
const prodAppId = dbCore.getProdAppID(appId)
|
|
526
523
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
if (info.error) throw info.error
|
|
532
|
-
} catch (err) {
|
|
524
|
+
// specific case, want to make sure setup is skipped
|
|
525
|
+
const prodDb = context.getProdAppDB({ skip_setup: true })
|
|
526
|
+
const exists = await prodDb.exists()
|
|
527
|
+
if (!exists) {
|
|
533
528
|
// the database doesn't exist. Don't replicate
|
|
534
529
|
ctx.status = 200
|
|
535
530
|
ctx.body = {
|
|
@@ -538,7 +533,7 @@ export const sync = async (ctx: any, next: any) => {
|
|
|
538
533
|
return next()
|
|
539
534
|
}
|
|
540
535
|
|
|
541
|
-
const replication = new Replication({
|
|
536
|
+
const replication = new dbCore.Replication({
|
|
542
537
|
source: prodAppId,
|
|
543
538
|
target: appId,
|
|
544
539
|
})
|
|
@@ -579,7 +574,7 @@ export const updateAppPackage = async (appPackage: any, appId: any) => {
|
|
|
579
574
|
|
|
580
575
|
await db.put(newAppPackage)
|
|
581
576
|
// remove any cached metadata, so that it will be updated
|
|
582
|
-
await
|
|
577
|
+
await cache.app.invalidateAppMetadata(appId)
|
|
583
578
|
return newAppPackage
|
|
584
579
|
})
|
|
585
580
|
}
|