@budibase/server 2.2.12-alpha.43 → 2.2.12-alpha.45
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__/node-fetch.ts +2 -0
- package/builder/assets/{index.68e5f22f.js → index.353f1284.js} +392 -386
- package/builder/assets/{index.80229ab4.css → index.f9c1cb26.css} +2 -2
- package/builder/index.html +2 -2
- package/coverage/clover.xml +1872 -1762
- package/coverage/coverage-final.json +83 -78
- package/coverage/lcov-report/index.html +141 -96
- package/coverage/lcov-report/src/api/controllers/analytics.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/apikeys.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/application.ts.html +158 -137
- package/coverage/lcov-report/src/api/controllers/auth.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/automation.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/backup.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/cloud.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/component.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/datasource.ts.html +99 -75
- package/coverage/lcov-report/src/api/controllers/deploy/Deployment.ts.html +12 -12
- package/coverage/lcov-report/src/api/controllers/deploy/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +69 -69
- package/coverage/lcov-report/src/api/controllers/dev.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/index.html +24 -24
- package/coverage/lcov-report/src/api/controllers/integration.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/layout.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/metadata.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/migrations.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/permission.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +2 -2
- package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/plugin/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +14 -14
- package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/tables.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/users.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/openapi.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/curl.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/index.html +7 -7
- package/coverage/lcov-report/src/api/controllers/query/index.ts.html +70 -46
- package/coverage/lcov-report/src/api/controllers/query/validation.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/role.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/routing.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +9 -9
- package/coverage/lcov-report/src/api/controllers/row/external.ts.html +11 -14
- package/coverage/lcov-report/src/api/controllers/row/index.html +15 -15
- package/coverage/lcov-report/src/api/controllers/row/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/internal.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/internalSearch.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/staticFormula.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/utils.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/screen.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/script.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/static/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/static/index.ts.html +21 -24
- package/coverage/lcov-report/src/api/controllers/table/bulkFormula.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/external.ts.html +21 -15
- package/coverage/lcov-report/src/api/controllers/table/index.html +13 -13
- package/coverage/lcov-report/src/api/controllers/table/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/templates.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/user.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/exporters.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/utils.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/view/viewBuilder.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/webhook.ts.html +57 -51
- package/coverage/lcov-report/src/api/index.html +1 -1
- package/coverage/lcov-report/src/api/index.ts.html +7 -7
- package/coverage/lcov-report/src/api/routes/analytics.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/apikeys.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/application.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/auth.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/automation.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/backup.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/cloud.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/component.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/datasource.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/deploy.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/dev.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/index.html +5 -5
- package/coverage/lcov-report/src/api/routes/index.ts.html +10 -4
- package/coverage/lcov-report/src/api/routes/integration.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/layout.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/metadata.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/migrations.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/permission.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/plugin.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/applications.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/middleware/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/queries.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/rows.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/tables.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/tests/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/tests/utils.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/users.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/utils/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/query.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/role.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/routing.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/row.ts.html +2 -2
- package/coverage/lcov-report/src/api/routes/screen.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/script.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/static.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/table.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/templates.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/user.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/utils/validators.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/view.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/webhook.ts.html +1 -1
- package/coverage/lcov-report/src/app.ts.html +1 -1
- package/coverage/lcov-report/src/automations/actions.ts.html +1 -1
- package/coverage/lcov-report/src/automations/automationUtils.ts.html +1 -1
- package/coverage/lcov-report/src/automations/bullboard.ts.html +2 -2
- package/coverage/lcov-report/src/automations/index.html +15 -15
- package/coverage/lcov-report/src/automations/index.ts.html +1 -1
- package/coverage/lcov-report/src/automations/logging/index.html +1 -1
- package/coverage/lcov-report/src/automations/logging/index.ts.html +4 -4
- package/coverage/lcov-report/src/automations/steps/bash.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/createRow.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/delay.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/discord.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/executeQuery.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/executeScript.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/filter.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/index.html +1 -1
- package/coverage/lcov-report/src/automations/steps/integromat.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/loop.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/outgoingWebhook.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/queryRows.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/sendSmtpEmail.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/serverLog.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/slack.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/updateRow.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/utils.ts.html +1 -1
- package/coverage/lcov-report/src/automations/steps/zapier.ts.html +1 -1
- package/coverage/lcov-report/src/automations/tests/utilities/index.html +1 -1
- package/coverage/lcov-report/src/automations/tests/utilities/index.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/app.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/cron.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/index.ts.html +2 -2
- package/coverage/lcov-report/src/automations/triggerInfo/rowDeleted.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/rowSaved.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/rowUpdated.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/webhook.ts.html +1 -1
- package/coverage/lcov-report/src/automations/triggers.ts.html +1 -1
- package/coverage/lcov-report/src/automations/utils.ts.html +21 -21
- package/coverage/lcov-report/src/constants/index.html +1 -1
- package/coverage/lcov-report/src/constants/index.ts.html +2 -2
- package/coverage/lcov-report/src/constants/layouts.ts.html +1 -1
- package/coverage/lcov-report/src/constants/screens.ts.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/datasource_bb_default.ts.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/employeeImport.ts.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/expensesImport.ts.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/index.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/inventoryImport.ts.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/jobsImport.ts.html +1 -1
- package/coverage/lcov-report/src/db/dynamoClient.ts.html +15 -15
- package/coverage/lcov-report/src/db/inMemoryView.ts.html +1 -1
- package/coverage/lcov-report/src/db/index.html +1 -1
- package/coverage/lcov-report/src/db/index.ts.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/LinkController.ts.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/LinkDocument.ts.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/index.ts.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/linkUtils.ts.html +1 -1
- package/coverage/lcov-report/src/db/newid.ts.html +3 -3
- package/coverage/lcov-report/src/db/utils.ts.html +17 -17
- package/coverage/lcov-report/src/definitions/automations.ts.html +5 -2
- package/coverage/lcov-report/src/definitions/datasource.ts.html +2 -2
- package/coverage/lcov-report/src/definitions/index.html +1 -1
- package/coverage/lcov-report/src/environment.ts.html +9 -9
- package/coverage/lcov-report/src/events/AutomationEmitter.ts.html +1 -1
- package/coverage/lcov-report/src/events/BudibaseEmitter.ts.html +1 -1
- package/coverage/lcov-report/src/events/index.html +1 -1
- package/coverage/lcov-report/src/events/index.ts.html +1 -1
- package/coverage/lcov-report/src/events/utils.ts.html +1 -1
- package/coverage/lcov-report/src/index.html +7 -7
- package/coverage/lcov-report/src/index.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/airtable.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/arangodb.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/base/index.html +11 -11
- package/coverage/lcov-report/src/integrations/base/query.ts.html +13 -7
- package/coverage/lcov-report/src/integrations/base/sql.ts.html +12 -12
- package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +8 -8
- package/coverage/lcov-report/src/integrations/base/utils.ts.html +2 -2
- package/coverage/lcov-report/src/integrations/couchdb.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/dynamodb.ts.html +9 -9
- package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/firebase.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/googlesheets.ts.html +11 -11
- package/coverage/lcov-report/src/integrations/index.html +1 -1
- package/coverage/lcov-report/src/integrations/index.ts.html +37 -37
- package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +8 -8
- package/coverage/lcov-report/src/integrations/mongodb.ts.html +11 -11
- package/coverage/lcov-report/src/integrations/mysql.ts.html +11 -11
- package/coverage/lcov-report/src/integrations/oracle.ts.html +13 -13
- package/coverage/lcov-report/src/integrations/postgres.ts.html +10 -10
- package/coverage/lcov-report/src/integrations/queries/index.html +19 -19
- package/coverage/lcov-report/src/integrations/queries/sql.ts.html +15 -150
- package/coverage/lcov-report/src/integrations/redis.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/rest.ts.html +24 -24
- package/coverage/lcov-report/src/integrations/s3.ts.html +6 -6
- package/coverage/lcov-report/src/integrations/snowflake.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/src/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/src/integrations/utils.ts.html +2 -2
- package/coverage/lcov-report/src/middleware/appInfo.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/authorized.ts.html +19 -19
- package/coverage/lcov-report/src/middleware/builder.ts.html +13 -13
- package/coverage/lcov-report/src/middleware/currentapp.ts.html +33 -33
- package/coverage/lcov-report/src/middleware/index.html +1 -1
- package/coverage/lcov-report/src/middleware/joi-validator.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/publicApi.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/resourceId.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/selfhost.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/utils.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/queries.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/roles.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/syncQuotas.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/tableSettings.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncRows.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/index.html +1 -1
- package/coverage/lcov-report/src/migrations/index.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/tests/index.html +1 -1
- package/coverage/lcov-report/src/migrations/tests/structures.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/applications/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/applications/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/applications/sync.ts.html +18 -18
- package/coverage/lcov-report/src/sdk/app/applications/utils.ts.html +7 -7
- package/coverage/lcov-report/src/sdk/app/automations/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/datasources/datasources.ts.html +379 -0
- package/coverage/lcov-report/src/sdk/app/datasources/index.html +131 -0
- package/coverage/lcov-report/src/sdk/app/datasources/index.ts.html +100 -0
- package/coverage/lcov-report/src/sdk/app/queries/index.html +131 -0
- package/coverage/lcov-report/src/sdk/app/queries/index.ts.html +100 -0
- package/coverage/lcov-report/src/sdk/app/queries/queries.ts.html +235 -0
- package/coverage/lcov-report/src/sdk/app/rows/attachments.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/rows/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/rows/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/rows/rows.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/tables/index.html +11 -11
- package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +18 -9
- package/coverage/lcov-report/src/sdk/index.html +5 -5
- package/coverage/lcov-report/src/sdk/index.ts.html +17 -5
- package/coverage/lcov-report/src/sdk/users/index.html +1 -1
- package/coverage/lcov-report/src/sdk/users/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/users/utils.ts.html +20 -20
- package/coverage/lcov-report/src/sdk/utils/index.html +116 -0
- package/coverage/lcov-report/src/sdk/utils/index.ts.html +133 -0
- package/coverage/lcov-report/src/startup.ts.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/TestConfiguration.ts.html +89 -80
- package/coverage/lcov-report/src/tests/utilities/controllers.ts.html +4 -4
- package/coverage/lcov-report/src/tests/utilities/index.html +5 -5
- package/coverage/lcov-report/src/tests/utilities/index.ts.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/structures.ts.html +4 -4
- package/coverage/lcov-report/src/threads/automation.ts.html +42 -24
- package/coverage/lcov-report/src/threads/index.html +28 -28
- package/coverage/lcov-report/src/threads/index.ts.html +1 -1
- package/coverage/lcov-report/src/threads/query.ts.html +68 -29
- package/coverage/lcov-report/src/threads/utils.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/budibaseDir.ts.html +2 -2
- package/coverage/lcov-report/src/utilities/centralPath.ts.html +11 -11
- package/coverage/lcov-report/src/utilities/fileSystem/app.ts.html +8 -8
- package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/filesystem.ts.html +18 -12
- package/coverage/lcov-report/src/utilities/fileSystem/index.html +17 -17
- package/coverage/lcov-report/src/utilities/fileSystem/index.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/plugin.ts.html +5 -8
- package/coverage/lcov-report/src/utilities/fileSystem/processor.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/template.ts.html +3 -3
- package/coverage/lcov-report/src/utilities/global.ts.html +33 -33
- package/coverage/lcov-report/src/utilities/index.html +16 -16
- package/coverage/lcov-report/src/utilities/index.ts.html +12 -12
- package/coverage/lcov-report/src/utilities/redis.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/src/utilities/routing/index.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/src/utilities/rowProcessor/index.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/rowProcessor/map.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/rowProcessor/utils.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/schema.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/scriptRunner.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/security.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/src/utilities/usageQuota/rows.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/usageQuota/usageQuoteReset.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/users.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/workerRequests.ts.html +1 -1
- package/coverage/lcov-report/src/watch.ts.html +1 -1
- package/coverage/lcov-report/src/websocket.ts.html +3 -3
- package/coverage/lcov.info +2986 -2796
- package/dist/api/controllers/application.js +73 -74
- package/dist/api/controllers/datasource.js +24 -15
- package/dist/api/controllers/query/index.js +18 -11
- package/dist/api/controllers/row/ExternalRequest.js +5 -3
- package/dist/api/controllers/row/external.js +6 -5
- package/dist/api/controllers/row/utils.js +5 -2
- package/dist/api/controllers/static/index.js +38 -38
- package/dist/api/controllers/table/external.js +8 -5
- package/dist/api/controllers/webhook.js +45 -43
- package/dist/api/routes/index.js +2 -0
- package/dist/api/routes/row.js +2 -2
- package/dist/index.js +2 -2
- package/dist/integrations/base/query.js +7 -2
- package/dist/integrations/base/sqlTable.js +14 -14
- package/dist/integrations/dynamodb.js +8 -5
- package/dist/integrations/mysql.js +2 -2
- package/dist/integrations/queries/sql.js +73 -100
- package/dist/integrations/rest.js +14 -14
- package/dist/package.json +6 -6
- package/dist/sdk/app/datasources/datasources.js +113 -0
- package/dist/sdk/app/datasources/index.js +27 -0
- package/dist/sdk/app/queries/index.js +27 -0
- package/dist/sdk/app/queries/queries.js +60 -0
- package/dist/sdk/app/tables/index.js +6 -2
- package/dist/sdk/index.js +4 -0
- package/dist/sdk/utils/index.js +29 -0
- package/dist/threads/automation.js +9 -2
- package/dist/threads/query.js +27 -13
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/filesystem.js +36 -34
- package/dist/utilities/fileSystem/plugin.js +17 -14
- package/dist/utilities/fileSystem/template.js +7 -4
- package/package.json +7 -7
- package/scripts/dev/manage.js +1 -0
- package/src/api/controllers/application.ts +81 -74
- package/src/api/controllers/datasource.ts +33 -25
- package/src/api/controllers/query/index.ts +47 -39
- package/src/api/controllers/row/ExternalRequest.ts +2 -2
- package/src/api/controllers/row/external.ts +3 -4
- package/src/api/controllers/row/utils.ts +2 -2
- package/src/api/controllers/static/index.ts +17 -18
- package/src/api/controllers/table/external.ts +8 -6
- package/src/api/controllers/webhook.ts +48 -46
- package/src/api/routes/index.ts +2 -0
- package/src/api/routes/row.ts +1 -1
- package/src/api/routes/tests/datasource.spec.ts +35 -1
- package/src/definitions/automations.ts +1 -0
- package/src/index.ts +1 -1
- package/src/integrations/base/query.ts +3 -1
- package/src/integrations/base/sqlTable.ts +1 -1
- package/src/integrations/dynamodb.ts +3 -3
- package/src/integrations/mysql.ts +1 -1
- package/src/integrations/queries/sql.ts +5 -50
- package/src/integrations/rest.ts +8 -8
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +10 -6
- package/src/sdk/app/datasources/datasources.ts +98 -0
- package/src/sdk/app/datasources/index.ts +5 -0
- package/src/sdk/app/queries/index.ts +5 -0
- package/src/sdk/app/queries/queries.ts +50 -0
- package/src/sdk/app/tables/index.ts +6 -3
- package/src/sdk/index.ts +4 -0
- package/src/sdk/utils/index.ts +16 -0
- package/src/tests/utilities/TestConfiguration.ts +15 -12
- package/src/threads/automation.ts +9 -3
- package/src/threads/definitions.ts +3 -0
- package/src/threads/query.ts +28 -15
- package/src/utilities/fileSystem/filesystem.ts +6 -4
- package/src/utilities/fileSystem/plugin.ts +3 -4
- package/src/utilities/fileSystem/template.ts +2 -2
|
@@ -1,55 +1,10 @@
|
|
|
1
|
-
import { findHBSBlocks
|
|
1
|
+
import { findHBSBlocks } from "@budibase/string-templates"
|
|
2
2
|
import { DatasourcePlus } from "@budibase/types"
|
|
3
|
+
import sdk from "../../sdk"
|
|
3
4
|
|
|
4
5
|
const CONST_CHAR_REGEX = new RegExp("'[^']*'", "g")
|
|
5
6
|
|
|
6
|
-
export function
|
|
7
|
-
fields: { [key: string]: any },
|
|
8
|
-
parameters = {}
|
|
9
|
-
) {
|
|
10
|
-
const enrichedQuery: { [key: string]: any } = Array.isArray(fields) ? [] : {}
|
|
11
|
-
if (!fields || !parameters) {
|
|
12
|
-
return enrichedQuery
|
|
13
|
-
}
|
|
14
|
-
// enrich the fields with dynamic parameters
|
|
15
|
-
for (let key of Object.keys(fields)) {
|
|
16
|
-
if (fields[key] == null) {
|
|
17
|
-
continue
|
|
18
|
-
}
|
|
19
|
-
if (typeof fields[key] === "object") {
|
|
20
|
-
// enrich nested fields object
|
|
21
|
-
enrichedQuery[key] = enrichQueryFields(fields[key], parameters)
|
|
22
|
-
} else if (typeof fields[key] === "string") {
|
|
23
|
-
// enrich string value as normal
|
|
24
|
-
enrichedQuery[key] = processStringSync(fields[key], parameters, {
|
|
25
|
-
noEscaping: true,
|
|
26
|
-
noHelpers: true,
|
|
27
|
-
escapeNewlines: true,
|
|
28
|
-
})
|
|
29
|
-
} else {
|
|
30
|
-
enrichedQuery[key] = fields[key]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (
|
|
34
|
-
enrichedQuery.json ||
|
|
35
|
-
enrichedQuery.customData ||
|
|
36
|
-
enrichedQuery.requestBody
|
|
37
|
-
) {
|
|
38
|
-
try {
|
|
39
|
-
enrichedQuery.json = JSON.parse(
|
|
40
|
-
enrichedQuery.json ||
|
|
41
|
-
enrichedQuery.customData ||
|
|
42
|
-
enrichedQuery.requestBody
|
|
43
|
-
)
|
|
44
|
-
} catch (err) {
|
|
45
|
-
// no json found, ignore
|
|
46
|
-
}
|
|
47
|
-
delete enrichedQuery.customData
|
|
48
|
-
}
|
|
49
|
-
return enrichedQuery
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function interpolateSQL(
|
|
7
|
+
export async function interpolateSQL(
|
|
53
8
|
fields: { [key: string]: any },
|
|
54
9
|
parameters: { [key: string]: any },
|
|
55
10
|
integration: DatasourcePlus
|
|
@@ -90,7 +45,7 @@ export function interpolateSQL(
|
|
|
90
45
|
else if (listRegexMatch) {
|
|
91
46
|
arrays.push(binding)
|
|
92
47
|
// determine the length of the array
|
|
93
|
-
const value =
|
|
48
|
+
const value = (await sdk.queries.enrichContext([binding], parameters))[0]
|
|
94
49
|
.split(",")
|
|
95
50
|
.map((val: string) => val.trim())
|
|
96
51
|
// build a string like ($1, $2, $3)
|
|
@@ -109,7 +64,7 @@ export function interpolateSQL(
|
|
|
109
64
|
}
|
|
110
65
|
// replicate the knex structure
|
|
111
66
|
fields.sql = sql
|
|
112
|
-
fields.bindings =
|
|
67
|
+
fields.bindings = await sdk.queries.enrichContext(variables, parameters)
|
|
113
68
|
// check for arrays in the data
|
|
114
69
|
let updated: string[] = []
|
|
115
70
|
for (let i = 0; i < variables.length; i++) {
|
package/src/integrations/rest.ts
CHANGED
|
@@ -16,11 +16,11 @@ import {
|
|
|
16
16
|
import { get } from "lodash"
|
|
17
17
|
import * as https from "https"
|
|
18
18
|
import qs from "querystring"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
import fetch from "node-fetch"
|
|
20
|
+
import { formatBytes } from "../utilities"
|
|
21
|
+
import { performance } from "perf_hooks"
|
|
22
|
+
import FormData from "form-data"
|
|
23
|
+
import { URLSearchParams } from "url"
|
|
24
24
|
|
|
25
25
|
const BodyTypes = {
|
|
26
26
|
NONE: "none",
|
|
@@ -204,12 +204,12 @@ class RestIntegration implements IntegrationBase {
|
|
|
204
204
|
|
|
205
205
|
// Append page number or cursor param if configured
|
|
206
206
|
if (pageParam && paginationValues.page != null) {
|
|
207
|
-
params.append(pageParam, paginationValues.page)
|
|
207
|
+
params.append(pageParam, paginationValues.page as string)
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
// Append page size param if configured
|
|
211
211
|
if (sizeParam && paginationValues.limit != null) {
|
|
212
|
-
params.append(sizeParam, paginationValues.limit)
|
|
212
|
+
params.append(sizeParam, String(paginationValues.limit))
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
// Prepend query string with pagination params
|
|
@@ -280,7 +280,7 @@ class RestIntegration implements IntegrationBase {
|
|
|
280
280
|
case BodyTypes.ENCODED:
|
|
281
281
|
const params = new URLSearchParams()
|
|
282
282
|
for (let [key, value] of Object.entries(object)) {
|
|
283
|
-
params.append(key, value)
|
|
283
|
+
params.append(key, value as string)
|
|
284
284
|
}
|
|
285
285
|
addPaginationToBody((key: string, value: any) => {
|
|
286
286
|
params.append(key, value)
|
|
@@ -2,7 +2,7 @@ import TestConfig from "../../../../tests/utilities/TestConfiguration"
|
|
|
2
2
|
import * as syncRows from "../syncRows"
|
|
3
3
|
import { quotas } from "@budibase/pro"
|
|
4
4
|
import { QuotaUsageType, StaticQuotaName } from "@budibase/types"
|
|
5
|
-
|
|
5
|
+
import { db as dbCore, context } from "@budibase/backend-core"
|
|
6
6
|
|
|
7
7
|
describe("syncRows", () => {
|
|
8
8
|
let config = new TestConfig(false)
|
|
@@ -24,13 +24,17 @@ describe("syncRows", () => {
|
|
|
24
24
|
|
|
25
25
|
// app 1
|
|
26
26
|
const app1 = config.app
|
|
27
|
-
await
|
|
28
|
-
|
|
27
|
+
await context.doInAppContext(app1.appId, async () => {
|
|
28
|
+
await config.createTable()
|
|
29
|
+
await config.createRow()
|
|
30
|
+
})
|
|
29
31
|
// app 2
|
|
30
32
|
const app2 = await config.createApp("second-app")
|
|
31
|
-
await
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
await context.doInAppContext(app2.appId, async () => {
|
|
34
|
+
await config.createTable()
|
|
35
|
+
await config.createRow()
|
|
36
|
+
await config.createRow()
|
|
37
|
+
})
|
|
34
38
|
|
|
35
39
|
// migrate
|
|
36
40
|
await syncRows.run()
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { context } from "@budibase/backend-core"
|
|
2
|
+
import { processObjectSync, findHBSBlocks } from "@budibase/string-templates"
|
|
3
|
+
import {
|
|
4
|
+
Datasource,
|
|
5
|
+
DatasourceFieldType,
|
|
6
|
+
Integration,
|
|
7
|
+
PASSWORD_REPLACEMENT,
|
|
8
|
+
} from "@budibase/types"
|
|
9
|
+
import { cloneDeep } from "lodash/fp"
|
|
10
|
+
import { getEnvironmentVariables } from "../../utils"
|
|
11
|
+
import { getDefinitions } from "../../../integrations"
|
|
12
|
+
|
|
13
|
+
const ENV_VAR_PREFIX = "env."
|
|
14
|
+
const USER_PREFIX = "user"
|
|
15
|
+
|
|
16
|
+
async function enrichDatasourceWithValues(datasource: Datasource) {
|
|
17
|
+
const cloned = cloneDeep(datasource)
|
|
18
|
+
const env = await getEnvironmentVariables()
|
|
19
|
+
const processed = processObjectSync(cloned, { env }, { onlyFound: true })
|
|
20
|
+
return {
|
|
21
|
+
datasource: processed as Datasource,
|
|
22
|
+
envVars: env as Record<string, string>,
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function enrich(datasource: Datasource) {
|
|
27
|
+
const { datasource: response } = await enrichDatasourceWithValues(datasource)
|
|
28
|
+
return response
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function get(
|
|
32
|
+
datasourceId: string,
|
|
33
|
+
opts?: { enriched: boolean }
|
|
34
|
+
): Promise<Datasource> {
|
|
35
|
+
const appDb = context.getAppDB()
|
|
36
|
+
const datasource = await appDb.get(datasourceId)
|
|
37
|
+
if (opts?.enriched) {
|
|
38
|
+
return (await enrichDatasourceWithValues(datasource)).datasource
|
|
39
|
+
} else {
|
|
40
|
+
return datasource
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function getWithEnvVars(datasourceId: string) {
|
|
45
|
+
const appDb = context.getAppDB()
|
|
46
|
+
const datasource = await appDb.get(datasourceId)
|
|
47
|
+
return enrichDatasourceWithValues(datasource)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function removeSecrets(datasources: Datasource[]) {
|
|
51
|
+
const definitions = await getDefinitions()
|
|
52
|
+
for (let datasource of datasources) {
|
|
53
|
+
const schema = definitions[datasource.source]
|
|
54
|
+
if (datasource.config) {
|
|
55
|
+
// strip secrets from response, so they don't show in the network request
|
|
56
|
+
if (datasource.config.auth) {
|
|
57
|
+
delete datasource.config.auth
|
|
58
|
+
}
|
|
59
|
+
// remove passwords
|
|
60
|
+
for (let key of Object.keys(datasource.config)) {
|
|
61
|
+
if (typeof datasource.config[key] !== "string") {
|
|
62
|
+
continue
|
|
63
|
+
}
|
|
64
|
+
const blocks = findHBSBlocks(datasource.config[key] as string)
|
|
65
|
+
const usesEnvVars =
|
|
66
|
+
blocks.find(block => block.includes(ENV_VAR_PREFIX)) != null
|
|
67
|
+
if (
|
|
68
|
+
!usesEnvVars &&
|
|
69
|
+
schema.datasource?.[key]?.type === DatasourceFieldType.PASSWORD
|
|
70
|
+
) {
|
|
71
|
+
datasource.config[key] = PASSWORD_REPLACEMENT
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return datasources
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function removeSecretSingle(datasource: Datasource) {
|
|
80
|
+
return (await removeSecrets([datasource]))[0]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function mergeConfigs(update: Datasource, old: Datasource) {
|
|
84
|
+
if (!update.config) {
|
|
85
|
+
return update
|
|
86
|
+
}
|
|
87
|
+
for (let [key, value] of Object.entries(update.config)) {
|
|
88
|
+
if (value !== PASSWORD_REPLACEMENT) {
|
|
89
|
+
continue
|
|
90
|
+
}
|
|
91
|
+
if (old.config?.[key]) {
|
|
92
|
+
update.config[key] = old.config?.[key]
|
|
93
|
+
} else {
|
|
94
|
+
delete update.config[key]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return update
|
|
98
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getEnvironmentVariables } from "../../utils"
|
|
2
|
+
import { processStringSync } from "@budibase/string-templates"
|
|
3
|
+
|
|
4
|
+
export async function enrichContext(
|
|
5
|
+
fields: Record<string, any>,
|
|
6
|
+
inputs = {}
|
|
7
|
+
): Promise<Record<string, any>> {
|
|
8
|
+
const enrichedQuery: Record<string, any> = Array.isArray(fields) ? [] : {}
|
|
9
|
+
if (!fields || !inputs) {
|
|
10
|
+
return enrichedQuery
|
|
11
|
+
}
|
|
12
|
+
const env = await getEnvironmentVariables()
|
|
13
|
+
const parameters = { ...inputs, env }
|
|
14
|
+
// enrich the fields with dynamic parameters
|
|
15
|
+
for (let key of Object.keys(fields)) {
|
|
16
|
+
if (fields[key] == null) {
|
|
17
|
+
continue
|
|
18
|
+
}
|
|
19
|
+
if (typeof fields[key] === "object") {
|
|
20
|
+
// enrich nested fields object
|
|
21
|
+
enrichedQuery[key] = await enrichContext(fields[key], parameters)
|
|
22
|
+
} else if (typeof fields[key] === "string") {
|
|
23
|
+
// enrich string value as normal
|
|
24
|
+
enrichedQuery[key] = processStringSync(fields[key], parameters, {
|
|
25
|
+
noEscaping: true,
|
|
26
|
+
noHelpers: true,
|
|
27
|
+
escapeNewlines: true,
|
|
28
|
+
})
|
|
29
|
+
} else {
|
|
30
|
+
enrichedQuery[key] = fields[key]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (
|
|
34
|
+
enrichedQuery.json ||
|
|
35
|
+
enrichedQuery.customData ||
|
|
36
|
+
enrichedQuery.requestBody
|
|
37
|
+
) {
|
|
38
|
+
try {
|
|
39
|
+
enrichedQuery.json = JSON.parse(
|
|
40
|
+
enrichedQuery.json ||
|
|
41
|
+
enrichedQuery.customData ||
|
|
42
|
+
enrichedQuery.requestBody
|
|
43
|
+
)
|
|
44
|
+
} catch (err) {
|
|
45
|
+
// no json found, ignore
|
|
46
|
+
}
|
|
47
|
+
delete enrichedQuery.customData
|
|
48
|
+
}
|
|
49
|
+
return enrichedQuery
|
|
50
|
+
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
isSQL,
|
|
7
7
|
} from "../../../integrations/utils"
|
|
8
8
|
import { Table, Database } from "@budibase/types"
|
|
9
|
+
import datasources from "../datasources"
|
|
9
10
|
|
|
10
11
|
async function getAllInternalTables(db?: Database): Promise<Table[]> {
|
|
11
12
|
if (!db) {
|
|
@@ -23,9 +24,11 @@ async function getAllInternalTables(db?: Database): Promise<Table[]> {
|
|
|
23
24
|
}))
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
async function getAllExternalTables(
|
|
27
|
+
async function getAllExternalTables(
|
|
28
|
+
datasourceId: any
|
|
29
|
+
): Promise<Record<string, Table>> {
|
|
27
30
|
const db = context.getAppDB()
|
|
28
|
-
const datasource = await
|
|
31
|
+
const datasource = await datasources.get(datasourceId, { enriched: true })
|
|
29
32
|
if (!datasource || !datasource.entities) {
|
|
30
33
|
throw "Datasource is not configured fully."
|
|
31
34
|
}
|
|
@@ -44,7 +47,7 @@ async function getTable(tableId: any): Promise<Table> {
|
|
|
44
47
|
const db = context.getAppDB()
|
|
45
48
|
if (isExternalTable(tableId)) {
|
|
46
49
|
let { datasourceId, tableName } = breakExternalTableId(tableId)
|
|
47
|
-
const datasource = await
|
|
50
|
+
const datasource = await datasources.get(datasourceId!)
|
|
48
51
|
const table = await getExternalTable(datasourceId, tableName)
|
|
49
52
|
return { ...table, sql: isSQL(datasource) }
|
|
50
53
|
} else {
|
package/src/sdk/index.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { default as backups } from "./app/backups"
|
|
|
2
2
|
import { default as tables } from "./app/tables"
|
|
3
3
|
import { default as automations } from "./app/automations"
|
|
4
4
|
import { default as applications } from "./app/applications"
|
|
5
|
+
import { default as datasources } from "./app/datasources"
|
|
6
|
+
import { default as queries } from "./app/queries"
|
|
5
7
|
import { default as rows } from "./app/rows"
|
|
6
8
|
import { default as users } from "./users"
|
|
7
9
|
|
|
@@ -12,6 +14,8 @@ const sdk = {
|
|
|
12
14
|
applications,
|
|
13
15
|
rows,
|
|
14
16
|
users,
|
|
17
|
+
datasources,
|
|
18
|
+
queries,
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
// default export for TS
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { environmentVariables } from "@budibase/pro"
|
|
2
|
+
import { context, db as dbCore } from "@budibase/backend-core"
|
|
3
|
+
import { AppEnvironment } from "@budibase/types"
|
|
4
|
+
|
|
5
|
+
export async function getEnvironmentVariables() {
|
|
6
|
+
let envVars = context.getEnvironmentVariables()
|
|
7
|
+
if (!envVars) {
|
|
8
|
+
const appId = context.getAppId()
|
|
9
|
+
const appEnv = dbCore.isDevAppID(appId)
|
|
10
|
+
? AppEnvironment.DEVELOPMENT
|
|
11
|
+
: AppEnvironment.PRODUCTION
|
|
12
|
+
|
|
13
|
+
envVars = await environmentVariables.fetchValues(appEnv)
|
|
14
|
+
}
|
|
15
|
+
return envVars
|
|
16
|
+
}
|
|
@@ -364,20 +364,23 @@ class TestConfiguration {
|
|
|
364
364
|
// create dev app
|
|
365
365
|
// clear any old app
|
|
366
366
|
this.appId = null
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
367
|
+
await context.doInAppContext(null, async () => {
|
|
368
|
+
this.app = await this._req(
|
|
369
|
+
{ name: appName },
|
|
370
|
+
null,
|
|
371
|
+
controllers.app.create
|
|
372
|
+
)
|
|
373
|
+
this.appId = this.app.appId
|
|
374
|
+
})
|
|
375
|
+
return await context.doInAppContext(this.appId, async () => {
|
|
376
|
+
// create production app
|
|
377
|
+
this.prodApp = await this.publish()
|
|
376
378
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
+
this.allApps.push(this.prodApp)
|
|
380
|
+
this.allApps.push(this.app)
|
|
379
381
|
|
|
380
|
-
|
|
382
|
+
return this.app
|
|
383
|
+
})
|
|
381
384
|
}
|
|
382
385
|
|
|
383
386
|
async publish() {
|
|
@@ -16,7 +16,6 @@ import { storeLog } from "../automations/logging"
|
|
|
16
16
|
import { Automation, AutomationStep, AutomationStatus } from "@budibase/types"
|
|
17
17
|
import {
|
|
18
18
|
LoopStep,
|
|
19
|
-
LoopStepType,
|
|
20
19
|
LoopInput,
|
|
21
20
|
TriggerOutput,
|
|
22
21
|
AutomationContext,
|
|
@@ -26,6 +25,7 @@ import { WorkerCallback } from "./definitions"
|
|
|
26
25
|
import { context, logging } from "@budibase/backend-core"
|
|
27
26
|
import { processObject } from "@budibase/string-templates"
|
|
28
27
|
import { cloneDeep } from "lodash/fp"
|
|
28
|
+
import * as sdkUtils from "../sdk/utils"
|
|
29
29
|
import env from "../environment"
|
|
30
30
|
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId
|
|
31
31
|
const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId
|
|
@@ -225,6 +225,8 @@ class Orchestrator {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
async execute() {
|
|
228
|
+
// this will retrieve from context created at start of thread
|
|
229
|
+
this._context.env = await sdkUtils.getEnvironmentVariables()
|
|
228
230
|
let automation = this._automation
|
|
229
231
|
let stopped = false
|
|
230
232
|
let loopStep: AutomationStep | undefined = undefined
|
|
@@ -478,7 +480,11 @@ export const removeStalled = async (job: Job) => {
|
|
|
478
480
|
throw new Error("Unable to execute, event doesn't contain app ID.")
|
|
479
481
|
}
|
|
480
482
|
await context.doInAppContext(appId, async () => {
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
+
const envVars = await sdkUtils.getEnvironmentVariables()
|
|
484
|
+
// put into automation thread for whole context
|
|
485
|
+
await context.doInEnvironmentContext(envVars, async () => {
|
|
486
|
+
const automationOrchestrator = new Orchestrator(job)
|
|
487
|
+
await automationOrchestrator.stopCron("stalled")
|
|
488
|
+
})
|
|
483
489
|
})
|
|
484
490
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EnvironmentVariablesDecrypted } from "@budibase/types"
|
|
2
|
+
|
|
1
3
|
export type WorkerCallback = (error: any, response?: any) => void
|
|
2
4
|
|
|
3
5
|
export interface QueryEvent {
|
|
@@ -9,6 +11,7 @@ export interface QueryEvent {
|
|
|
9
11
|
pagination?: any
|
|
10
12
|
transformer: any
|
|
11
13
|
queryId: string
|
|
14
|
+
environmentVariables?: Record<string, string>
|
|
12
15
|
ctx?: any
|
|
13
16
|
}
|
|
14
17
|
|
package/src/threads/query.ts
CHANGED
|
@@ -6,13 +6,11 @@ import { getIntegration } from "../integrations"
|
|
|
6
6
|
import { processStringSync } from "@budibase/string-templates"
|
|
7
7
|
import { context, cache, auth } from "@budibase/backend-core"
|
|
8
8
|
import { getGlobalIDFromUserMetadataID } from "../db/utils"
|
|
9
|
+
import sdk from "../sdk"
|
|
9
10
|
import { cloneDeep } from "lodash/fp"
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
enrichQueryFields,
|
|
14
|
-
interpolateSQL,
|
|
15
|
-
} = require("../integrations/queries/sql")
|
|
12
|
+
import { isSQL } from "../integrations/utils"
|
|
13
|
+
import { interpolateSQL } from "../integrations/queries/sql"
|
|
16
14
|
|
|
17
15
|
class QueryRunner {
|
|
18
16
|
datasource: any
|
|
@@ -62,10 +60,11 @@ class QueryRunner {
|
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
if (datasourceClone.config.authConfigs) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
const updatedConfigs = []
|
|
64
|
+
for (let config of datasourceClone.config.authConfigs) {
|
|
65
|
+
updatedConfigs.push(await sdk.queries.enrichContext(config, this.ctx))
|
|
66
|
+
}
|
|
67
|
+
datasourceClone.config.authConfigs = updatedConfigs
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
const integration = new Integration(datasourceClone.config)
|
|
@@ -75,12 +74,15 @@ class QueryRunner {
|
|
|
75
74
|
|
|
76
75
|
// Enrich the parameters with the addition context items.
|
|
77
76
|
// 'user' is now a reserved variable key in mapping parameters
|
|
78
|
-
const enrichedParameters =
|
|
77
|
+
const enrichedParameters = await sdk.queries.enrichContext(
|
|
78
|
+
parameters,
|
|
79
|
+
this.ctx
|
|
80
|
+
)
|
|
79
81
|
const enrichedContext = { ...enrichedParameters, ...this.ctx }
|
|
80
82
|
|
|
81
83
|
// Parse global headers
|
|
82
84
|
if (datasourceClone.config.defaultHeaders) {
|
|
83
|
-
datasourceClone.config.defaultHeaders =
|
|
85
|
+
datasourceClone.config.defaultHeaders = await sdk.queries.enrichContext(
|
|
84
86
|
datasourceClone.config.defaultHeaders,
|
|
85
87
|
enrichedContext
|
|
86
88
|
)
|
|
@@ -89,9 +91,9 @@ class QueryRunner {
|
|
|
89
91
|
let query
|
|
90
92
|
// handle SQL injections by interpolating the variables
|
|
91
93
|
if (isSQL(datasourceClone)) {
|
|
92
|
-
query = interpolateSQL(fieldsClone, enrichedParameters, integration)
|
|
94
|
+
query = await interpolateSQL(fieldsClone, enrichedParameters, integration)
|
|
93
95
|
} else {
|
|
94
|
-
query =
|
|
96
|
+
query = await sdk.queries.enrichContext(fieldsClone, enrichedContext)
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
// Add pagination values for REST queries
|
|
@@ -166,7 +168,9 @@ class QueryRunner {
|
|
|
166
168
|
async runAnotherQuery(queryId: string, parameters: any) {
|
|
167
169
|
const db = context.getAppDB()
|
|
168
170
|
const query = await db.get(queryId)
|
|
169
|
-
const datasource = await
|
|
171
|
+
const datasource = await sdk.datasources.get(query.datasourceId, {
|
|
172
|
+
enriched: true,
|
|
173
|
+
})
|
|
170
174
|
return new QueryRunner(
|
|
171
175
|
{
|
|
172
176
|
datasource,
|
|
@@ -280,7 +284,7 @@ class QueryRunner {
|
|
|
280
284
|
}
|
|
281
285
|
|
|
282
286
|
export function execute(input: QueryEvent, callback: WorkerCallback) {
|
|
283
|
-
|
|
287
|
+
const run = async () => {
|
|
284
288
|
const Runner = new QueryRunner(input)
|
|
285
289
|
try {
|
|
286
290
|
const response = await Runner.execute()
|
|
@@ -288,5 +292,14 @@ export function execute(input: QueryEvent, callback: WorkerCallback) {
|
|
|
288
292
|
} catch (err) {
|
|
289
293
|
callback(err)
|
|
290
294
|
}
|
|
295
|
+
}
|
|
296
|
+
context.doInAppContext(input.appId!, async () => {
|
|
297
|
+
if (input.environmentVariables) {
|
|
298
|
+
return context.doInEnvironmentContext(input.environmentVariables, () => {
|
|
299
|
+
return run()
|
|
300
|
+
})
|
|
301
|
+
} else {
|
|
302
|
+
return run()
|
|
303
|
+
}
|
|
291
304
|
})
|
|
292
305
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PathLike } from "fs"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const uuid = require("uuid/v4")
|
|
2
|
+
import fs from "fs"
|
|
3
|
+
import { budibaseTempDir } from "../budibaseDir"
|
|
4
|
+
import { join } from "path"
|
|
6
5
|
import env from "../../environment"
|
|
7
6
|
import tar from "tar"
|
|
7
|
+
const uuid = require("uuid/v4")
|
|
8
8
|
|
|
9
9
|
export const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..")
|
|
10
10
|
|
|
@@ -112,6 +112,7 @@ export const sendTempFile = (fileContents: any) => {
|
|
|
112
112
|
* allows a centralised location to check logic is all good.
|
|
113
113
|
*/
|
|
114
114
|
export const readFileSync = (filepath: PathLike, options = "utf8") => {
|
|
115
|
+
// @ts-ignore
|
|
115
116
|
return fs.readFileSync(filepath, options)
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -147,6 +148,7 @@ export const findFileRec = (startPath: PathLike, filter: string): any => {
|
|
|
147
148
|
|
|
148
149
|
const files = fs.readdirSync(startPath)
|
|
149
150
|
for (let i = 0, len = files.length; i < len; i++) {
|
|
151
|
+
// @ts-ignore
|
|
150
152
|
const filename = join(startPath, files[i])
|
|
151
153
|
const stat = fs.lstatSync(filename)
|
|
152
154
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Plugin } from "@budibase/types"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { join } = require("path")
|
|
2
|
+
import { budibaseTempDir } from "../budibaseDir"
|
|
3
|
+
import fs from "fs"
|
|
4
|
+
import { join } from "path"
|
|
6
5
|
import { objectStore } from "@budibase/backend-core"
|
|
7
6
|
|
|
8
7
|
const DATASOURCE_PATH = join(budibaseTempDir(), "datasource")
|