@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
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { BBContext } from "@budibase/types"
|
|
2
|
+
|
|
3
|
+
export class ResourceIdGetter {
|
|
4
|
+
parameter: string
|
|
5
|
+
main: string | null
|
|
6
|
+
sub: string | null
|
|
7
|
+
|
|
8
|
+
constructor(ctxProperty: string) {
|
|
3
9
|
this.parameter = ctxProperty
|
|
4
10
|
this.main = null
|
|
5
11
|
this.sub = null
|
|
6
12
|
return this
|
|
7
13
|
}
|
|
8
14
|
|
|
9
|
-
mainResource(field) {
|
|
15
|
+
mainResource(field: string) {
|
|
10
16
|
this.main = field
|
|
11
17
|
return this
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
subResource(field) {
|
|
20
|
+
subResource(field: string) {
|
|
15
21
|
this.sub = field
|
|
16
22
|
return this
|
|
17
23
|
}
|
|
@@ -20,7 +26,8 @@ class ResourceIdGetter {
|
|
|
20
26
|
const parameter = this.parameter,
|
|
21
27
|
main = this.main,
|
|
22
28
|
sub = this.sub
|
|
23
|
-
return (ctx, next) => {
|
|
29
|
+
return (ctx: BBContext, next: any) => {
|
|
30
|
+
// @ts-ignore
|
|
24
31
|
const request = ctx.request[parameter] || ctx[parameter]
|
|
25
32
|
if (request == null) {
|
|
26
33
|
return next()
|
|
@@ -36,24 +43,22 @@ class ResourceIdGetter {
|
|
|
36
43
|
}
|
|
37
44
|
}
|
|
38
45
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
module.exports.paramResource = main => {
|
|
46
|
+
export function paramResource(main: string) {
|
|
42
47
|
return new ResourceIdGetter("params").mainResource(main).build()
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
export function paramSubResource(main: string, sub: string) {
|
|
46
51
|
return new ResourceIdGetter("params")
|
|
47
52
|
.mainResource(main)
|
|
48
53
|
.subResource(sub)
|
|
49
54
|
.build()
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
|
|
57
|
+
export function bodyResource(main: string) {
|
|
53
58
|
return new ResourceIdGetter("body").mainResource(main).build()
|
|
54
59
|
}
|
|
55
60
|
|
|
56
|
-
|
|
61
|
+
export function bodySubResource(main: string, sub: string) {
|
|
57
62
|
return new ResourceIdGetter("body")
|
|
58
63
|
.mainResource(main)
|
|
59
64
|
.subResource(sub)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import env from "../environment"
|
|
2
|
+
import { BBContext } from "@budibase/types"
|
|
3
|
+
|
|
2
4
|
// if added as a middleware will stop requests unless builder is in self host mode
|
|
3
5
|
// or cloud is in self host
|
|
4
|
-
|
|
6
|
+
export = async (ctx: BBContext, next: any) => {
|
|
5
7
|
if (env.SELF_HOSTED) {
|
|
6
8
|
await next()
|
|
7
9
|
return
|
|
@@ -9,7 +9,7 @@ jest.mock("../../environment", () => ({
|
|
|
9
9
|
)
|
|
10
10
|
const authorizedMiddleware = require("../authorized")
|
|
11
11
|
const env = require("../../environment")
|
|
12
|
-
const {
|
|
12
|
+
const { PermissionType, PermissionLevel } = require("@budibase/backend-core/permissions")
|
|
13
13
|
const { doInAppContext } = require("@budibase/backend-core/context")
|
|
14
14
|
|
|
15
15
|
const APP_ID = ""
|
|
@@ -113,7 +113,7 @@ describe("Authorization middleware", () => {
|
|
|
113
113
|
|
|
114
114
|
it("throws if the user does not have builder permissions", async () => {
|
|
115
115
|
config.setEnvironment(false)
|
|
116
|
-
config.setMiddlewareRequiredPermission(
|
|
116
|
+
config.setMiddlewareRequiredPermission(PermissionType.BUILDER)
|
|
117
117
|
config.setUser({
|
|
118
118
|
role: {
|
|
119
119
|
_id: ""
|
|
@@ -125,13 +125,13 @@ describe("Authorization middleware", () => {
|
|
|
125
125
|
})
|
|
126
126
|
|
|
127
127
|
it("passes on to next() middleware if the user has resource permission", async () => {
|
|
128
|
-
config.setResourceId(
|
|
128
|
+
config.setResourceId(PermissionType.QUERY)
|
|
129
129
|
config.setUser({
|
|
130
130
|
role: {
|
|
131
131
|
_id: ""
|
|
132
132
|
}
|
|
133
133
|
})
|
|
134
|
-
config.setMiddlewareRequiredPermission(
|
|
134
|
+
config.setMiddlewareRequiredPermission(PermissionType.QUERY)
|
|
135
135
|
|
|
136
136
|
await config.executeMiddleware()
|
|
137
137
|
expect(config.next).toHaveBeenCalled()
|
|
@@ -155,7 +155,7 @@ describe("Authorization middleware", () => {
|
|
|
155
155
|
_id: ""
|
|
156
156
|
},
|
|
157
157
|
})
|
|
158
|
-
config.setMiddlewareRequiredPermission(
|
|
158
|
+
config.setMiddlewareRequiredPermission(PermissionType.ADMIN, PermissionLevel.BASIC)
|
|
159
159
|
|
|
160
160
|
await config.executeMiddleware()
|
|
161
161
|
expect(config.throw).toHaveBeenCalledWith(403, "User does not have permission")
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
+
require("../../db").init()
|
|
1
2
|
mockAuthWithNoCookie()
|
|
2
3
|
mockWorker()
|
|
3
4
|
mockUserGroups()
|
|
4
5
|
|
|
5
|
-
jest.mock("@budibase/backend-core/db", () => {
|
|
6
|
-
const coreDb = jest.requireActual("@budibase/backend-core/db")
|
|
7
|
-
coreDb.init()
|
|
8
|
-
return {
|
|
9
|
-
...coreDb,
|
|
10
|
-
dbExists: () => true,
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
|
|
14
6
|
function mockWorker() {
|
|
15
7
|
jest.mock("../../utilities/workerRequests", () => ({
|
|
16
8
|
getGlobalSelf: () => {
|
|
@@ -43,42 +35,62 @@ function mockUserGroups() {
|
|
|
43
35
|
function mockAuthWithNoCookie() {
|
|
44
36
|
jest.resetModules()
|
|
45
37
|
mockWorker()
|
|
46
|
-
jest.mock("@budibase/backend-core
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
jest.mock("@budibase/backend-core", () => {
|
|
39
|
+
const core = jest.requireActual("@budibase/backend-core")
|
|
40
|
+
return {
|
|
41
|
+
...core,
|
|
42
|
+
db: {
|
|
43
|
+
...core.db,
|
|
44
|
+
dbExists: () => true,
|
|
52
45
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
46
|
+
cache: {
|
|
47
|
+
user: {
|
|
48
|
+
getUser: async id => {
|
|
49
|
+
return {
|
|
50
|
+
_id: "us_uuid1",
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
utils: {
|
|
56
|
+
getAppIdFromCtx: jest.fn(),
|
|
57
|
+
setCookie: jest.fn(),
|
|
58
|
+
getCookie: jest.fn(),
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
})
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
function mockAuthWithCookie() {
|
|
66
65
|
jest.resetModules()
|
|
67
66
|
mockWorker()
|
|
68
|
-
jest.mock("@budibase/backend-core
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
67
|
+
jest.mock("@budibase/backend-core", () => {
|
|
68
|
+
const core = jest.requireActual("@budibase/backend-core")
|
|
69
|
+
return {
|
|
70
|
+
...core,
|
|
71
|
+
db: {
|
|
72
|
+
...core.db,
|
|
73
|
+
dbExists: () => true,
|
|
74
|
+
},
|
|
75
|
+
utils: {
|
|
76
|
+
getAppIdFromCtx: () => {
|
|
77
|
+
return "app_test"
|
|
78
|
+
},
|
|
79
|
+
setCookie: jest.fn(),
|
|
80
|
+
clearCookie: jest.fn(),
|
|
81
|
+
getCookie: () => ({ appId: "app_different", roleId: "PUBLIC" }),
|
|
82
|
+
},
|
|
83
|
+
cache: {
|
|
84
|
+
user: {
|
|
85
|
+
getUser: async id => {
|
|
86
|
+
return {
|
|
87
|
+
_id: "us_uuid1",
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
})
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
class TestConfiguration {
|
|
@@ -88,7 +100,16 @@ class TestConfiguration {
|
|
|
88
100
|
|
|
89
101
|
this.ctx = {
|
|
90
102
|
next: this.next,
|
|
91
|
-
throw: this.throw
|
|
103
|
+
throw: this.throw,
|
|
104
|
+
request: {
|
|
105
|
+
body: {},
|
|
106
|
+
headers: {},
|
|
107
|
+
},
|
|
108
|
+
headers: {},
|
|
109
|
+
path: "",
|
|
110
|
+
cookies: {
|
|
111
|
+
set: jest.fn(),
|
|
112
|
+
}
|
|
92
113
|
}
|
|
93
114
|
}
|
|
94
115
|
|
|
@@ -101,6 +122,8 @@ class TestConfiguration {
|
|
|
101
122
|
|
|
102
123
|
executeMiddleware() {
|
|
103
124
|
// import as late as possible for mocks
|
|
125
|
+
jest.resetModules()
|
|
126
|
+
require("../../db").init()
|
|
104
127
|
const currentAppMiddleware = require("../currentapp")
|
|
105
128
|
return currentAppMiddleware(this.ctx, this.next)
|
|
106
129
|
}
|
|
@@ -138,11 +161,11 @@ describe("Current app middleware", () => {
|
|
|
138
161
|
async function checkExpected(setCookie) {
|
|
139
162
|
config.setUser()
|
|
140
163
|
await config.executeMiddleware()
|
|
141
|
-
let {
|
|
164
|
+
let { utils } = require("@budibase/backend-core")
|
|
142
165
|
if (setCookie) {
|
|
143
|
-
expect(
|
|
166
|
+
expect(utils.setCookie).toHaveBeenCalled()
|
|
144
167
|
} else {
|
|
145
|
-
expect(
|
|
168
|
+
expect(utils.setCookie).not.toHaveBeenCalled()
|
|
146
169
|
}
|
|
147
170
|
expect(config.ctx.roleId).toEqual("PUBLIC")
|
|
148
171
|
expect(config.ctx.user.role._id).toEqual("PUBLIC")
|
|
@@ -157,31 +180,63 @@ describe("Current app middleware", () => {
|
|
|
157
180
|
|
|
158
181
|
it("should perform correct when no cookie exists", async () => {
|
|
159
182
|
mockReset()
|
|
160
|
-
jest.mock("@budibase/backend-core
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
183
|
+
jest.mock("@budibase/backend-core", () => {
|
|
184
|
+
const core = jest.requireActual("@budibase/backend-core")
|
|
185
|
+
return {
|
|
186
|
+
...core,
|
|
187
|
+
db: {
|
|
188
|
+
...core.db,
|
|
189
|
+
dbExists: () => true,
|
|
190
|
+
},
|
|
191
|
+
utils: {
|
|
192
|
+
getAppIdFromCtx: () => {
|
|
193
|
+
return "app_test"
|
|
194
|
+
},
|
|
195
|
+
setCookie: jest.fn(),
|
|
196
|
+
getCookie: jest.fn(),
|
|
197
|
+
},
|
|
198
|
+
cache: {
|
|
199
|
+
user: {
|
|
200
|
+
getUser: async id => {
|
|
201
|
+
return {
|
|
202
|
+
_id: "us_uuid1",
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
}
|
|
208
|
+
})
|
|
170
209
|
await checkExpected(true)
|
|
171
210
|
})
|
|
172
211
|
|
|
173
212
|
it("lastly check what occurs when cookie doesn't need updated", async () => {
|
|
174
213
|
mockReset()
|
|
175
|
-
jest.mock("@budibase/backend-core
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
214
|
+
jest.mock("@budibase/backend-core", () => {
|
|
215
|
+
const core = jest.requireActual("@budibase/backend-core")
|
|
216
|
+
return {
|
|
217
|
+
...core,
|
|
218
|
+
db: {
|
|
219
|
+
...core.db,
|
|
220
|
+
dbExists: () => true,
|
|
221
|
+
},
|
|
222
|
+
utils: {
|
|
223
|
+
getAppIdFromCtx: () => {
|
|
224
|
+
return "app_test"
|
|
225
|
+
},
|
|
226
|
+
setCookie: jest.fn(),
|
|
227
|
+
getCookie: () => ({ appId: "app_test", roleId: "PUBLIC" }),
|
|
228
|
+
},
|
|
229
|
+
cache: {
|
|
230
|
+
user: {
|
|
231
|
+
getUser: async id => {
|
|
232
|
+
return {
|
|
233
|
+
_id: "us_uuid1",
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
}
|
|
239
|
+
})
|
|
185
240
|
await checkExpected(false)
|
|
186
241
|
})
|
|
187
242
|
})
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { BBContext } from "@budibase/types"
|
|
2
|
+
|
|
1
3
|
const WEBHOOK_ENDPOINTS = new RegExp(
|
|
2
4
|
["webhooks/trigger", "webhooks/schema"].join("|")
|
|
3
5
|
)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
export function isWebhookEndpoint(ctx: BBContext) {
|
|
6
8
|
return WEBHOOK_ENDPOINTS.test(ctx.request.url)
|
|
7
9
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { events } from "@budibase/backend-core"
|
|
2
|
+
import { Database } from "@budibase/types"
|
|
2
3
|
import sdk from "../../../../sdk"
|
|
3
|
-
import PouchDB from "pouchdb"
|
|
4
4
|
|
|
5
|
-
export const backfill = async (
|
|
6
|
-
appDb: PouchDB.Database,
|
|
7
|
-
timestamp: string | number
|
|
8
|
-
) => {
|
|
5
|
+
export const backfill = async (appDb: Database, timestamp: string | number) => {
|
|
9
6
|
const tables = await sdk.tables.getAllInternalTables(appDb)
|
|
10
7
|
|
|
11
8
|
for (const table of tables) {
|
|
@@ -149,7 +149,7 @@ export const run = async (db: any) => {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
try {
|
|
152
|
-
const allApps
|
|
152
|
+
const allApps = (await dbUtils.getAllApps({ dev: true })) as App[]
|
|
153
153
|
totals.apps = allApps.length
|
|
154
154
|
|
|
155
155
|
totals.usage = await quotas.backfill(allApps)
|
|
@@ -2,11 +2,11 @@ import { getTenantId } from "@budibase/backend-core/tenancy"
|
|
|
2
2
|
import { getAllApps } from "@budibase/backend-core/db"
|
|
3
3
|
import { getUniqueRows } from "../../../utilities/usageQuota/rows"
|
|
4
4
|
import { quotas } from "@budibase/pro"
|
|
5
|
-
import { StaticQuotaName, QuotaUsageType } from "@budibase/types"
|
|
5
|
+
import { StaticQuotaName, QuotaUsageType, App } from "@budibase/types"
|
|
6
6
|
|
|
7
7
|
export const run = async () => {
|
|
8
8
|
// get all rows in all apps
|
|
9
|
-
const allApps = await getAllApps({ all: true })
|
|
9
|
+
const allApps = (await getAllApps({ all: true })) as App[]
|
|
10
10
|
const appIds = allApps ? allApps.map((app: { appId: any }) => app.appId) : []
|
|
11
11
|
const { appRows } = await getUniqueRows(appIds)
|
|
12
12
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { db as dbCore } from "@budibase/backend-core"
|
|
2
|
+
import { Database } from "@budibase/types"
|
|
2
3
|
import { getAutomationParams, TABLE_ROW_PREFIX } from "../../../db/utils"
|
|
3
4
|
import { budibaseTempDir } from "../../../utilities/budibaseDir"
|
|
4
5
|
import { DB_EXPORT_FILE, GLOBAL_DB_EXPORT_FILE } from "./constants"
|
|
@@ -17,7 +18,6 @@ import {
|
|
|
17
18
|
CouchFindOptions,
|
|
18
19
|
RowAttachment,
|
|
19
20
|
} from "@budibase/types"
|
|
20
|
-
import PouchDB from "pouchdb"
|
|
21
21
|
const uuid = require("uuid/v4")
|
|
22
22
|
const tar = require("tar")
|
|
23
23
|
|
|
@@ -29,10 +29,7 @@ type TemplateType = {
|
|
|
29
29
|
key?: string
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async function updateAttachmentColumns(
|
|
33
|
-
prodAppId: string,
|
|
34
|
-
db: PouchDB.Database
|
|
35
|
-
) {
|
|
32
|
+
async function updateAttachmentColumns(prodAppId: string, db: Database) {
|
|
36
33
|
// iterate through attachment documents and update them
|
|
37
34
|
const tables = await sdk.tables.getAllInternalTables(db)
|
|
38
35
|
for (let table of tables) {
|
|
@@ -86,7 +83,7 @@ async function updateAttachmentColumns(
|
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
85
|
|
|
89
|
-
async function updateAutomations(prodAppId: string, db:
|
|
86
|
+
async function updateAutomations(prodAppId: string, db: Database) {
|
|
90
87
|
const automations = (
|
|
91
88
|
await db.allDocs(
|
|
92
89
|
getAutomationParams(null, {
|
|
@@ -154,7 +151,7 @@ export function getListOfAppsInMulti(tmpPath: string) {
|
|
|
154
151
|
|
|
155
152
|
export async function importApp(
|
|
156
153
|
appId: string,
|
|
157
|
-
db:
|
|
154
|
+
db: Database,
|
|
158
155
|
template: TemplateType
|
|
159
156
|
) {
|
|
160
157
|
let prodAppId = dbCore.getProdAppID(appId)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { context, db as dbCore } from "@budibase/backend-core"
|
|
2
|
+
import { Database } from "@budibase/types"
|
|
2
3
|
import {
|
|
3
4
|
getDatasourceParams,
|
|
4
5
|
getTableParams,
|
|
5
6
|
getAutomationParams,
|
|
6
7
|
getScreenParams,
|
|
7
8
|
} from "../../../db/utils"
|
|
8
|
-
import PouchDB from "pouchdb"
|
|
9
9
|
|
|
10
|
-
async function runInContext(appId: string, cb: any, db?:
|
|
10
|
+
async function runInContext(appId: string, cb: any, db?: Database) {
|
|
11
11
|
if (db) {
|
|
12
12
|
return cb(db)
|
|
13
13
|
} else {
|
|
@@ -19,13 +19,10 @@ async function runInContext(appId: string, cb: any, db?: PouchDB.Database) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export async function calculateDatasourceCount(
|
|
23
|
-
appId: string,
|
|
24
|
-
db?: PouchDB.Database
|
|
25
|
-
) {
|
|
22
|
+
export async function calculateDatasourceCount(appId: string, db?: Database) {
|
|
26
23
|
return runInContext(
|
|
27
24
|
appId,
|
|
28
|
-
async (db:
|
|
25
|
+
async (db: Database) => {
|
|
29
26
|
const datasourceList = await db.allDocs(getDatasourceParams())
|
|
30
27
|
const tableList = await db.allDocs(getTableParams())
|
|
31
28
|
return datasourceList.rows.length + tableList.rows.length
|
|
@@ -34,13 +31,10 @@ export async function calculateDatasourceCount(
|
|
|
34
31
|
)
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
export async function calculateAutomationCount(
|
|
38
|
-
appId: string,
|
|
39
|
-
db?: PouchDB.Database
|
|
40
|
-
) {
|
|
34
|
+
export async function calculateAutomationCount(appId: string, db?: Database) {
|
|
41
35
|
return runInContext(
|
|
42
36
|
appId,
|
|
43
|
-
async (db:
|
|
37
|
+
async (db: Database) => {
|
|
44
38
|
const automationList = await db.allDocs(getAutomationParams())
|
|
45
39
|
return automationList.rows.length
|
|
46
40
|
},
|
|
@@ -48,13 +42,10 @@ export async function calculateAutomationCount(
|
|
|
48
42
|
)
|
|
49
43
|
}
|
|
50
44
|
|
|
51
|
-
export async function calculateScreenCount(
|
|
52
|
-
appId: string,
|
|
53
|
-
db?: PouchDB.Database
|
|
54
|
-
) {
|
|
45
|
+
export async function calculateScreenCount(appId: string, db?: Database) {
|
|
55
46
|
return runInContext(
|
|
56
47
|
appId,
|
|
57
|
-
async (db:
|
|
48
|
+
async (db: Database) => {
|
|
58
49
|
const screenList = await db.allDocs(getScreenParams())
|
|
59
50
|
return screenList.rows.length
|
|
60
51
|
},
|
|
@@ -63,7 +54,7 @@ export async function calculateScreenCount(
|
|
|
63
54
|
}
|
|
64
55
|
|
|
65
56
|
export async function calculateBackupStats(appId: string) {
|
|
66
|
-
return runInContext(appId, async (db:
|
|
57
|
+
return runInContext(appId, async (db: Database) => {
|
|
67
58
|
const promises = []
|
|
68
59
|
promises.push(calculateDatasourceCount(appId, db))
|
|
69
60
|
promises.push(calculateAutomationCount(appId, db))
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { context } from "@budibase/backend-core"
|
|
2
2
|
import { BudibaseInternalDB, getTableParams } from "../../../db/utils"
|
|
3
3
|
import {
|
|
4
4
|
breakExternalTableId,
|
|
5
5
|
isExternalTable,
|
|
6
6
|
isSQL,
|
|
7
7
|
} from "../../../integrations/utils"
|
|
8
|
-
import { Table } from "@budibase/types"
|
|
9
|
-
import PouchDB from "pouchdb"
|
|
8
|
+
import { Table, Database } from "@budibase/types"
|
|
10
9
|
|
|
11
|
-
async function getAllInternalTables(db?:
|
|
10
|
+
async function getAllInternalTables(db?: Database): Promise<Table[]> {
|
|
12
11
|
if (!db) {
|
|
13
|
-
db = getAppDB()
|
|
12
|
+
db = context.getAppDB()
|
|
14
13
|
}
|
|
15
14
|
const internalTables = await db.allDocs(
|
|
16
15
|
getTableParams(null, {
|
|
@@ -25,7 +24,7 @@ async function getAllInternalTables(db?: PouchDB.Database): Promise<Table[]> {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
async function getAllExternalTables(datasourceId: any): Promise<Table[]> {
|
|
28
|
-
const db = getAppDB()
|
|
27
|
+
const db = context.getAppDB()
|
|
29
28
|
const datasource = await db.get(datasourceId)
|
|
30
29
|
if (!datasource || !datasource.entities) {
|
|
31
30
|
throw "Datasource is not configured fully."
|
|
@@ -42,7 +41,7 @@ async function getExternalTable(
|
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
async function getTable(tableId: any): Promise<Table> {
|
|
45
|
-
const db = getAppDB()
|
|
44
|
+
const db = context.getAppDB()
|
|
46
45
|
if (isExternalTable(tableId)) {
|
|
47
46
|
let { datasourceId, tableName } = breakExternalTableId(tableId)
|
|
48
47
|
const datasource = await db.get(datasourceId)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { tmpdir } = require("os")
|
|
2
|
-
|
|
2
|
+
import env from "../environment"
|
|
3
3
|
|
|
4
4
|
env._set("SELF_HOSTED", "1")
|
|
5
5
|
env._set("NODE_ENV", "jest")
|
|
@@ -8,8 +8,11 @@ env._set("CLIENT_ID", "test-client-id")
|
|
|
8
8
|
env._set("BUDIBASE_DIR", tmpdir("budibase-unittests"))
|
|
9
9
|
env._set("LOG_LEVEL", "silent")
|
|
10
10
|
env._set("PORT", 0)
|
|
11
|
+
env._set("MINIO_URL", "http://localhost")
|
|
12
|
+
env._set("MINIO_ACCESS_KEY", "test")
|
|
13
|
+
env._set("MINIO_SECRET_KEY", "test")
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
import { mocks } from "@budibase/backend-core/tests"
|
|
13
16
|
|
|
14
17
|
// mock all dates to 2020-01-01T00:00:00.000Z
|
|
15
18
|
// use tk.reset() to use real dates in individual tests
|
|
@@ -17,3 +20,9 @@ const tk = require("timekeeper")
|
|
|
17
20
|
tk.freeze(mocks.date.MOCK_DATE)
|
|
18
21
|
|
|
19
22
|
global.console.log = jest.fn() // console.log are ignored in tests
|
|
23
|
+
|
|
24
|
+
if (!process.env.CI) {
|
|
25
|
+
// set a longer timeout in dev for debugging
|
|
26
|
+
// 100 seconds
|
|
27
|
+
jest.setTimeout(100000)
|
|
28
|
+
}
|
|
@@ -16,7 +16,7 @@ const {
|
|
|
16
16
|
const controllers = require("./controllers")
|
|
17
17
|
const supertest = require("supertest")
|
|
18
18
|
const { cleanup } = require("../../utilities/fileSystem")
|
|
19
|
-
const {
|
|
19
|
+
const { Cookie, Header } = require("@budibase/backend-core/constants")
|
|
20
20
|
const { jwt } = require("@budibase/backend-core/auth")
|
|
21
21
|
const { doInTenant, doWithGlobalDB } = require("@budibase/backend-core/tenancy")
|
|
22
22
|
const { createASession } = require("@budibase/backend-core/sessions")
|
|
@@ -116,7 +116,9 @@ class TestConfiguration {
|
|
|
116
116
|
if (this.server) {
|
|
117
117
|
this.server.close()
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
if (this.allApps) {
|
|
120
|
+
cleanup(this.allApps.map(app => app.appId))
|
|
121
|
+
}
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
// UTILS
|
|
@@ -254,10 +256,10 @@ class TestConfiguration {
|
|
|
254
256
|
return {
|
|
255
257
|
Accept: "application/json",
|
|
256
258
|
Cookie: [
|
|
257
|
-
`${
|
|
258
|
-
`${
|
|
259
|
+
`${Cookie.Auth}=${authToken}`,
|
|
260
|
+
`${Cookie.CurrentApp}=${appToken}`,
|
|
259
261
|
],
|
|
260
|
-
[
|
|
262
|
+
[Header.APP_ID]: appId,
|
|
261
263
|
}
|
|
262
264
|
})
|
|
263
265
|
}
|
|
@@ -277,14 +279,14 @@ class TestConfiguration {
|
|
|
277
279
|
const headers = {
|
|
278
280
|
Accept: "application/json",
|
|
279
281
|
Cookie: [
|
|
280
|
-
`${
|
|
281
|
-
`${
|
|
282
|
+
`${Cookie.Auth}=${authToken}`,
|
|
283
|
+
`${Cookie.CurrentApp}=${appToken}`,
|
|
282
284
|
],
|
|
283
|
-
[
|
|
285
|
+
[Header.CSRF_TOKEN]: CSRF_TOKEN,
|
|
284
286
|
...extras,
|
|
285
287
|
}
|
|
286
288
|
if (this.appId) {
|
|
287
|
-
headers[
|
|
289
|
+
headers[Header.APP_ID] = this.appId
|
|
288
290
|
}
|
|
289
291
|
return headers
|
|
290
292
|
}
|
|
@@ -296,7 +298,7 @@ class TestConfiguration {
|
|
|
296
298
|
Accept: "application/json",
|
|
297
299
|
}
|
|
298
300
|
if (appId) {
|
|
299
|
-
headers[
|
|
301
|
+
headers[Header.APP_ID] = appId
|
|
300
302
|
}
|
|
301
303
|
return headers
|
|
302
304
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
2
|
-
const {
|
|
2
|
+
const { BuiltinPermissionID } = require("@budibase/backend-core/permissions")
|
|
3
3
|
const { createHomeScreen } = require("../../constants/screens")
|
|
4
4
|
const { EMPTY_LAYOUT } = require("../../constants/layouts")
|
|
5
5
|
const { cloneDeep } = require("lodash/fp")
|
|
@@ -135,7 +135,7 @@ exports.basicRole = () => {
|
|
|
135
135
|
return {
|
|
136
136
|
name: "NewRole",
|
|
137
137
|
inherits: BUILTIN_ROLE_IDS.BASIC,
|
|
138
|
-
permissionId:
|
|
138
|
+
permissionId: BuiltinPermissionID.READ_ONLY,
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|