@budibase/server 1.0.32 → 1.0.39
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 +21 -0
- package/builder/assets/bb-spaceship.8f6e81e1.svg +227 -0
- package/builder/assets/index.3079d0f9.js +1348 -0
- package/builder/assets/{index.4fb3f887.css → index.39e01193.css} +1 -1
- package/builder/assets/{vendor.470042a4.js → vendor.f9faf6ab.js} +88 -88
- package/builder/index.html +3 -3
- package/coverage/clover.xml +1591 -1345
- package/coverage/coverage-final.json +75 -74
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +3 -3
- package/coverage/lcov-report/api/controllers/application.js.html +73 -64
- package/coverage/lcov-report/api/controllers/auth.js.html +2 -2
- package/coverage/lcov-report/api/controllers/automation.js.html +22 -10
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +13 -4
- package/coverage/lcov-report/api/controllers/component.js.html +4 -4
- package/coverage/lcov-report/api/controllers/datasource.js.html +170 -68
- package/coverage/lcov-report/api/controllers/dev.js.html +3 -3
- package/coverage/lcov-report/api/controllers/hosting.js.html +3 -3
- package/coverage/lcov-report/api/controllers/index.html +39 -54
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +3 -3
- package/coverage/lcov-report/api/controllers/query/index.html +126 -0
- package/coverage/lcov-report/api/controllers/{query.js.html → query/index.js.html} +228 -114
- package/coverage/lcov-report/api/controllers/query/validation.js.html +206 -0
- package/coverage/lcov-report/api/controllers/role.js.html +2 -2
- package/coverage/lcov-report/api/controllers/routing.js.html +2 -2
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +22 -22
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +38 -11
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +8 -5
- package/coverage/lcov-report/api/controllers/row/utils.js.html +29 -20
- package/coverage/lcov-report/api/controllers/screen.js.html +2 -2
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +120 -12
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +19 -7
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +6 -6
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +2 -2
- package/coverage/lcov-report/api/routes/application.js.html +2 -2
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +2 -2
- package/coverage/lcov-report/api/routes/backup.js.html +2 -2
- package/coverage/lcov-report/api/routes/cloud.js.html +2 -2
- package/coverage/lcov-report/api/routes/component.js.html +2 -2
- package/coverage/lcov-report/api/routes/datasource.js.html +2 -2
- package/coverage/lcov-report/api/routes/deploy.js.html +2 -2
- package/coverage/lcov-report/api/routes/dev.js.html +2 -2
- package/coverage/lcov-report/api/routes/hosting.js.html +2 -2
- package/coverage/lcov-report/api/routes/index.html +9 -9
- package/coverage/lcov-report/api/routes/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +2 -2
- package/coverage/lcov-report/api/routes/layout.js.html +2 -2
- package/coverage/lcov-report/api/routes/metadata.js.html +2 -2
- package/coverage/lcov-report/api/routes/permission.js.html +12 -3
- package/coverage/lcov-report/api/routes/query.js.html +20 -86
- package/coverage/lcov-report/api/routes/role.js.html +2 -2
- package/coverage/lcov-report/api/routes/routing.js.html +2 -2
- package/coverage/lcov-report/api/routes/row.js.html +2 -2
- package/coverage/lcov-report/api/routes/screen.js.html +2 -2
- package/coverage/lcov-report/api/routes/script.js.html +2 -2
- package/coverage/lcov-report/api/routes/static.js.html +2 -2
- package/coverage/lcov-report/api/routes/table.js.html +2 -2
- package/coverage/lcov-report/api/routes/templates.js.html +2 -2
- package/coverage/lcov-report/api/routes/user.js.html +33 -3
- package/coverage/lcov-report/api/routes/view.js.html +2 -2
- package/coverage/lcov-report/api/routes/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +2 -2
- package/coverage/lcov-report/automations/index.html +20 -20
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +32 -8
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +11 -11
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +5 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/automations/utils.js.html +49 -16
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +25 -25
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +2 -2
- package/coverage/lcov-report/db/client.js.html +19 -19
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +108 -81
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +99 -84
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/authorized.js.html +12 -12
- package/coverage/lcov-report/middleware/builder.js.html +10 -10
- package/coverage/lcov-report/middleware/currentapp.js.html +48 -36
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +11 -11
- package/coverage/lcov-report/middleware/resourceId.js.html +18 -18
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +2 -2
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +3 -3
- package/coverage/lcov-report/threads/index.html +32 -32
- package/coverage/lcov-report/threads/index.js.html +12 -12
- package/coverage/lcov-report/threads/query.js.html +560 -65
- package/coverage/lcov-report/threads/utils.js.html +210 -15
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +2 -2
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +28 -19
- package/coverage/lcov-report/utilities/index.html +19 -19
- package/coverage/lcov-report/utilities/index.js.html +70 -37
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +19 -19
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +247 -10
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +14 -5
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +22 -22
- package/coverage/lcov.info +2740 -2315
- package/dist/api/controllers/apikeys.js +2 -2
- package/dist/api/controllers/application.js +4 -4
- package/dist/api/controllers/auth.js +1 -1
- package/dist/api/controllers/automation.js +7 -5
- package/dist/api/controllers/cloud.js +2 -2
- package/dist/api/controllers/datasource.js +29 -0
- package/dist/api/controllers/deploy/index.js +2 -2
- package/dist/api/controllers/dev.js +2 -2
- package/dist/api/controllers/hosting.js +2 -2
- package/dist/api/controllers/permission.js +2 -2
- package/dist/api/controllers/query/import/index.js +79 -0
- package/dist/api/controllers/query/import/sources/base/index.js +64 -0
- package/dist/api/controllers/query/import/sources/base/openapi.js +42 -0
- package/dist/api/controllers/query/import/sources/curl.js +96 -0
- package/dist/api/controllers/query/import/sources/openapi2.js +142 -0
- package/dist/api/controllers/query/import/sources/tests/openapi2/data/crud/crud.json +253 -0
- package/dist/api/controllers/query/import/sources/tests/openapi2/data/petstore/petstore.json +1054 -0
- package/dist/api/controllers/{query.js → query/index.js} +87 -52
- package/dist/api/controllers/query/validation.js +38 -0
- package/dist/api/controllers/role.js +1 -1
- package/dist/api/controllers/routing.js +1 -1
- package/dist/api/controllers/row/internal.js +14 -6
- package/dist/api/controllers/row/internalSearch.js +3 -2
- package/dist/api/controllers/row/utils.js +13 -6
- package/dist/api/controllers/screen.js +1 -1
- package/dist/api/controllers/user.js +40 -4
- package/dist/api/controllers/webhook.js +5 -1
- package/dist/api/index.js +1 -1
- package/dist/api/routes/apikeys.js +1 -1
- package/dist/api/routes/application.js +1 -1
- package/dist/api/routes/automation.js +1 -1
- package/dist/api/routes/backup.js +1 -1
- package/dist/api/routes/cloud.js +1 -1
- package/dist/api/routes/component.js +1 -1
- package/dist/api/routes/datasource.js +1 -1
- package/dist/api/routes/deploy.js +1 -1
- package/dist/api/routes/dev.js +1 -1
- package/dist/api/routes/hosting.js +1 -1
- package/dist/api/routes/integration.js +1 -1
- package/dist/api/routes/layout.js +1 -1
- package/dist/api/routes/metadata.js +1 -1
- package/dist/api/routes/permission.js +1 -1
- package/dist/api/routes/query.js +6 -34
- package/dist/api/routes/role.js +1 -1
- package/dist/api/routes/routing.js +1 -1
- package/dist/api/routes/row.js +1 -1
- package/dist/api/routes/screen.js +1 -1
- package/dist/api/routes/script.js +1 -1
- package/dist/api/routes/static.js +1 -1
- package/dist/api/routes/table.js +1 -1
- package/dist/api/routes/templates.js +1 -1
- package/dist/api/routes/tests/utilities/TestFunctions.js +1 -1
- package/dist/api/routes/user.js +4 -2
- package/dist/api/routes/view.js +1 -1
- package/dist/api/routes/webhook.js +1 -1
- package/dist/app.js +1 -1
- package/dist/automations/bullboard.js +1 -1
- package/dist/automations/steps/executeQuery.js +9 -2
- package/dist/automations/steps/outgoingWebhook.js +2 -3
- package/dist/automations/utils.js +11 -1
- package/dist/constants/index.js +3 -3
- package/dist/constants/screens.js +1 -1
- package/dist/db/client.js +1 -1
- package/dist/db/utils.js +9 -1
- package/dist/definitions/datasource.js +6 -1
- package/dist/environment.js +1 -0
- package/dist/integrations/base/sqlTable.js +1 -1
- package/dist/integrations/dynamodb.js +19 -0
- package/dist/integrations/rest.js +259 -120
- package/dist/integrations/s3.js +17 -8
- package/dist/integrations/utils.js +40 -37
- package/dist/middleware/authorized.js +2 -2
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +6 -6
- package/dist/middleware/usageQuota.js +1 -1
- package/dist/package.json +11 -4
- package/dist/tests/utilities/TestConfiguration.js +55 -8
- package/dist/tests/utilities/structures.js +2 -2
- package/dist/threads/automation.js +2 -2
- package/dist/threads/query.js +195 -38
- package/dist/threads/utils.js +62 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/budibaseDir.js +1 -1
- package/dist/utilities/fileSystem/utilities.js +2 -1
- package/dist/utilities/global.js +5 -5
- package/dist/utilities/index.js +11 -1
- package/dist/utilities/redis.js +1 -1
- package/dist/utilities/rowProcessor/index.js +76 -0
- package/dist/utilities/security.js +2 -2
- package/dist/utilities/usageQuota.js +2 -2
- package/dist/utilities/workerRequests.js +3 -3
- package/package.json +12 -5
- package/scripts/replicateApp.js +1 -1
- package/src/api/controllers/apikeys.js +2 -2
- package/src/api/controllers/application.js +7 -4
- package/src/api/controllers/auth.js +1 -1
- package/src/api/controllers/automation.js +8 -4
- package/src/api/controllers/cloud.js +5 -2
- package/src/api/controllers/datasource.js +34 -0
- package/src/api/controllers/deploy/index.js +2 -2
- package/src/api/controllers/dev.js +2 -2
- package/src/api/controllers/hosting.js +2 -2
- package/src/api/controllers/permission.js +2 -2
- package/src/api/controllers/query/import/index.ts +85 -0
- package/src/api/controllers/query/import/sources/base/index.ts +87 -0
- package/src/api/controllers/query/import/sources/base/openapi.ts +24 -0
- package/src/api/controllers/query/import/sources/curl.ts +102 -0
- package/src/api/controllers/query/import/sources/openapi2.ts +163 -0
- package/src/api/controllers/query/import/sources/tests/curl/curl.spec.js +103 -0
- package/src/api/controllers/query/import/sources/tests/curl/data/delete.txt +1 -0
- package/src/api/controllers/query/import/sources/tests/curl/data/empty-body.txt +2 -0
- package/src/api/controllers/query/import/sources/tests/curl/data/get.txt +1 -0
- package/src/api/controllers/query/import/sources/tests/curl/data/headers.txt +3 -0
- package/src/api/controllers/query/import/sources/tests/curl/data/patch.txt +2 -0
- package/src/api/controllers/query/import/sources/tests/curl/data/path.txt +1 -0
- package/src/api/controllers/query/import/sources/tests/curl/data/post.txt +2 -0
- package/src/api/controllers/query/import/sources/tests/curl/data/put.txt +2 -0
- package/src/api/controllers/query/import/sources/tests/curl/data/query.txt +1 -0
- package/src/api/controllers/query/import/sources/tests/openapi2/data/crud/crud.json +253 -0
- package/src/api/controllers/query/import/sources/tests/openapi2/data/crud/crud.yaml +160 -0
- package/src/api/controllers/query/import/sources/tests/openapi2/data/petstore/petstore.json +1054 -0
- package/src/api/controllers/query/import/sources/tests/openapi2/data/petstore/petstore.yaml +711 -0
- package/src/api/controllers/query/import/sources/tests/openapi2/openapi2.spec.js +238 -0
- package/src/api/controllers/query/import/tests/index.spec.js +109 -0
- package/src/api/controllers/query/index.js +196 -0
- package/src/api/controllers/query/validation.js +42 -0
- package/src/api/controllers/role.js +1 -1
- package/src/api/controllers/routing.js +1 -1
- package/src/api/controllers/row/internal.js +14 -5
- package/src/api/controllers/row/internalSearch.js +3 -2
- package/src/api/controllers/row/utils.js +11 -8
- package/src/api/controllers/screen.js +1 -1
- package/src/api/controllers/user.js +39 -3
- package/src/api/controllers/webhook.js +5 -1
- package/src/api/index.js +1 -1
- package/src/api/routes/apikeys.js +1 -1
- package/src/api/routes/application.js +1 -1
- package/src/api/routes/automation.js +1 -1
- package/src/api/routes/backup.js +1 -1
- package/src/api/routes/cloud.js +1 -1
- package/src/api/routes/component.js +1 -1
- package/src/api/routes/datasource.js +1 -1
- package/src/api/routes/deploy.js +1 -1
- package/src/api/routes/dev.js +1 -1
- package/src/api/routes/hosting.js +1 -1
- package/src/api/routes/integration.js +1 -1
- package/src/api/routes/layout.js +1 -1
- package/src/api/routes/metadata.js +1 -1
- package/src/api/routes/permission.js +4 -1
- package/src/api/routes/query.js +14 -36
- package/src/api/routes/role.js +1 -1
- package/src/api/routes/routing.js +1 -1
- package/src/api/routes/row.js +1 -1
- package/src/api/routes/screen.js +1 -1
- package/src/api/routes/script.js +1 -1
- package/src/api/routes/static.js +1 -1
- package/src/api/routes/table.js +1 -1
- package/src/api/routes/templates.js +1 -1
- package/src/api/routes/tests/datasource.spec.js +45 -0
- package/src/api/routes/tests/permissions.spec.js +1 -1
- package/src/api/routes/tests/query.spec.js +70 -1
- package/src/api/routes/tests/role.spec.js +2 -2
- package/src/api/routes/tests/routing.spec.js +1 -1
- package/src/api/routes/tests/user.spec.js +1 -1
- package/src/api/routes/tests/utilities/TestFunctions.js +1 -1
- package/src/api/routes/user.js +11 -1
- package/src/api/routes/view.js +1 -1
- package/src/api/routes/webhook.js +1 -1
- package/src/app.ts +1 -1
- package/src/automations/bullboard.js +1 -1
- package/src/automations/steps/executeQuery.js +10 -2
- package/src/automations/steps/outgoingWebhook.js +2 -3
- package/src/automations/utils.js +12 -1
- package/src/constants/index.js +3 -3
- package/src/constants/screens.js +1 -1
- package/src/db/client.js +1 -1
- package/src/db/utils.js +10 -1
- package/src/definitions/common.ts +2 -16
- package/src/definitions/datasource.ts +98 -1
- package/src/environment.js +1 -0
- package/src/integrations/base/IntegrationBase.ts +4 -4
- package/src/integrations/base/sqlTable.ts +1 -1
- package/src/integrations/dynamodb.ts +18 -0
- package/src/integrations/oracle.ts +1 -1
- package/src/integrations/rest.ts +311 -138
- package/src/integrations/s3.ts +18 -7
- package/src/integrations/tests/rest.spec.js +432 -21
- package/src/integrations/utils.ts +8 -7
- package/src/middleware/authorized.js +2 -2
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +11 -7
- package/src/middleware/tests/authorized.spec.js +2 -2
- package/src/middleware/tests/currentapp.spec.js +35 -41
- package/src/middleware/tests/usageQuota.spec.js +1 -1
- package/src/middleware/usageQuota.js +1 -1
- package/src/tests/utilities/TestConfiguration.js +65 -8
- package/src/tests/utilities/structures.js +2 -2
- package/src/threads/automation.js +2 -2
- package/src/threads/query.js +204 -39
- package/src/threads/utils.js +66 -1
- package/src/utilities/budibaseDir.js +1 -1
- package/src/utilities/fileSystem/utilities.js +3 -1
- package/src/utilities/global.js +8 -5
- package/src/utilities/index.js +12 -1
- package/src/utilities/redis.js +1 -1
- package/src/utilities/rowProcessor/index.js +79 -0
- package/src/utilities/security.js +5 -2
- package/src/utilities/usageQuota.js +2 -2
- package/src/utilities/workerRequests.js +3 -3
- package/builder/assets/index.891d496c.js +0 -1316
- package/src/api/controllers/query.js +0 -158
|
@@ -10,18 +10,57 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const datasource_1 = require("../definitions/datasource");
|
|
13
|
+
const BodyTypes = {
|
|
14
|
+
NONE: "none",
|
|
15
|
+
FORM_DATA: "form",
|
|
16
|
+
XML: "xml",
|
|
17
|
+
ENCODED: "encoded",
|
|
18
|
+
JSON: "json",
|
|
19
|
+
TEXT: "text",
|
|
20
|
+
};
|
|
21
|
+
const coreFields = {
|
|
22
|
+
path: {
|
|
23
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
24
|
+
display: "URL",
|
|
25
|
+
},
|
|
26
|
+
queryString: {
|
|
27
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
28
|
+
},
|
|
29
|
+
headers: {
|
|
30
|
+
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
31
|
+
},
|
|
32
|
+
enabledHeaders: {
|
|
33
|
+
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
34
|
+
},
|
|
35
|
+
requestBody: {
|
|
36
|
+
type: datasource_1.DatasourceFieldTypes.JSON,
|
|
37
|
+
},
|
|
38
|
+
bodyType: {
|
|
39
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
40
|
+
enum: Object.values(BodyTypes),
|
|
41
|
+
},
|
|
42
|
+
pagination: {
|
|
43
|
+
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
13
46
|
var RestModule;
|
|
14
47
|
(function (RestModule) {
|
|
15
48
|
const fetch = require("node-fetch");
|
|
49
|
+
const { formatBytes } = require("../utilities");
|
|
50
|
+
const { performance } = require("perf_hooks");
|
|
51
|
+
const FormData = require("form-data");
|
|
52
|
+
const { URLSearchParams } = require("url");
|
|
53
|
+
const { parseStringPromise: xmlParser, Builder: XmlBuilder, } = require("xml2js");
|
|
16
54
|
const SCHEMA = {
|
|
17
55
|
docs: "https://github.com/node-fetch/node-fetch",
|
|
18
|
-
description: "
|
|
56
|
+
description: "With the REST API datasource, you can connect, query and pull data from multiple REST APIs. You can then use the retrieved data to build apps.",
|
|
19
57
|
friendlyName: "REST API",
|
|
20
58
|
datasource: {
|
|
21
59
|
url: {
|
|
22
60
|
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
23
|
-
default: "
|
|
24
|
-
required:
|
|
61
|
+
default: "",
|
|
62
|
+
required: false,
|
|
63
|
+
deprecated: true,
|
|
25
64
|
},
|
|
26
65
|
defaultHeaders: {
|
|
27
66
|
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
@@ -34,174 +73,274 @@ var RestModule;
|
|
|
34
73
|
readable: true,
|
|
35
74
|
displayName: "POST",
|
|
36
75
|
type: datasource_1.QueryTypes.FIELDS,
|
|
37
|
-
|
|
38
|
-
fields: {
|
|
39
|
-
path: {
|
|
40
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
41
|
-
},
|
|
42
|
-
queryString: {
|
|
43
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
44
|
-
},
|
|
45
|
-
headers: {
|
|
46
|
-
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
47
|
-
},
|
|
48
|
-
requestBody: {
|
|
49
|
-
type: datasource_1.DatasourceFieldTypes.JSON,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
76
|
+
fields: coreFields,
|
|
52
77
|
},
|
|
53
78
|
read: {
|
|
54
79
|
displayName: "GET",
|
|
55
80
|
readable: true,
|
|
56
81
|
type: datasource_1.QueryTypes.FIELDS,
|
|
57
|
-
|
|
58
|
-
fields: {
|
|
59
|
-
path: {
|
|
60
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
61
|
-
},
|
|
62
|
-
queryString: {
|
|
63
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
64
|
-
},
|
|
65
|
-
headers: {
|
|
66
|
-
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
82
|
+
fields: coreFields,
|
|
69
83
|
},
|
|
70
84
|
update: {
|
|
71
85
|
displayName: "PUT",
|
|
72
86
|
readable: true,
|
|
73
87
|
type: datasource_1.QueryTypes.FIELDS,
|
|
74
|
-
|
|
75
|
-
fields: {
|
|
76
|
-
path: {
|
|
77
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
78
|
-
},
|
|
79
|
-
queryString: {
|
|
80
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
81
|
-
},
|
|
82
|
-
headers: {
|
|
83
|
-
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
84
|
-
},
|
|
85
|
-
requestBody: {
|
|
86
|
-
type: datasource_1.DatasourceFieldTypes.JSON,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
88
|
+
fields: coreFields,
|
|
89
89
|
},
|
|
90
90
|
patch: {
|
|
91
91
|
displayName: "PATCH",
|
|
92
92
|
readable: true,
|
|
93
93
|
type: datasource_1.QueryTypes.FIELDS,
|
|
94
|
-
|
|
95
|
-
fields: {
|
|
96
|
-
path: {
|
|
97
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
98
|
-
},
|
|
99
|
-
queryString: {
|
|
100
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
101
|
-
},
|
|
102
|
-
headers: {
|
|
103
|
-
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
104
|
-
},
|
|
105
|
-
requestBody: {
|
|
106
|
-
type: datasource_1.DatasourceFieldTypes.JSON,
|
|
107
|
-
},
|
|
108
|
-
},
|
|
94
|
+
fields: coreFields,
|
|
109
95
|
},
|
|
110
96
|
delete: {
|
|
111
97
|
displayName: "DELETE",
|
|
112
98
|
type: datasource_1.QueryTypes.FIELDS,
|
|
113
|
-
|
|
114
|
-
fields: {
|
|
115
|
-
path: {
|
|
116
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
117
|
-
},
|
|
118
|
-
queryString: {
|
|
119
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
120
|
-
},
|
|
121
|
-
headers: {
|
|
122
|
-
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
123
|
-
},
|
|
124
|
-
requestBody: {
|
|
125
|
-
type: datasource_1.DatasourceFieldTypes.JSON,
|
|
126
|
-
},
|
|
127
|
-
},
|
|
99
|
+
fields: coreFields,
|
|
128
100
|
},
|
|
129
101
|
},
|
|
130
102
|
};
|
|
131
103
|
class RestIntegration {
|
|
132
104
|
constructor(config) {
|
|
133
105
|
this.headers = {};
|
|
106
|
+
this.startTimeMs = performance.now();
|
|
134
107
|
this.config = config;
|
|
135
108
|
}
|
|
136
|
-
parseResponse(response) {
|
|
109
|
+
parseResponse(response, pagination) {
|
|
137
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
111
|
+
let data, raw, headers;
|
|
112
|
+
const contentType = response.headers.get("content-type") || "";
|
|
113
|
+
try {
|
|
114
|
+
if (contentType.includes("application/json")) {
|
|
115
|
+
data = yield response.json();
|
|
116
|
+
raw = JSON.stringify(data);
|
|
117
|
+
}
|
|
118
|
+
else if (contentType.includes("text/xml") ||
|
|
119
|
+
contentType.includes("application/xml")) {
|
|
120
|
+
const rawXml = yield response.text();
|
|
121
|
+
data =
|
|
122
|
+
(yield xmlParser(rawXml, {
|
|
123
|
+
explicitArray: false,
|
|
124
|
+
trim: true,
|
|
125
|
+
explicitRoot: false,
|
|
126
|
+
})) || {};
|
|
127
|
+
// there is only one structure, its an array, return the array so it appears as rows
|
|
128
|
+
const keys = Object.keys(data);
|
|
129
|
+
if (keys.length === 1 && Array.isArray(data[keys[0]])) {
|
|
130
|
+
data = data[keys[0]];
|
|
131
|
+
}
|
|
132
|
+
raw = rawXml;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
data = yield response.text();
|
|
136
|
+
raw = data;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
throw "Failed to parse response body.";
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
const size = formatBytes(response.headers.get("content-length") || Buffer.byteLength(raw, "utf8"));
|
|
143
|
+
const time = `${Math.round(performance.now() - this.startTimeMs)}ms`;
|
|
144
|
+
headers = response.headers.raw();
|
|
145
|
+
for (let [key, value] of Object.entries(headers)) {
|
|
146
|
+
headers[key] = Array.isArray(value) ? value[0] : value;
|
|
144
147
|
}
|
|
148
|
+
// Check if a pagination cursor exists in the response
|
|
149
|
+
let nextCursor = null;
|
|
150
|
+
if (pagination === null || pagination === void 0 ? void 0 : pagination.responseParam) {
|
|
151
|
+
nextCursor = data === null || data === void 0 ? void 0 : data[pagination.responseParam];
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
data,
|
|
155
|
+
info: {
|
|
156
|
+
code: response.status,
|
|
157
|
+
size,
|
|
158
|
+
time,
|
|
159
|
+
},
|
|
160
|
+
extra: {
|
|
161
|
+
raw,
|
|
162
|
+
headers,
|
|
163
|
+
},
|
|
164
|
+
pagination: {
|
|
165
|
+
cursor: nextCursor,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
145
168
|
});
|
|
146
169
|
}
|
|
147
|
-
getUrl(path, queryString) {
|
|
148
|
-
|
|
170
|
+
getUrl(path, queryString, pagination, paginationValues) {
|
|
171
|
+
// Add pagination params to query string if required
|
|
172
|
+
if ((pagination === null || pagination === void 0 ? void 0 : pagination.location) === "query" && paginationValues) {
|
|
173
|
+
const { pageParam, sizeParam } = pagination;
|
|
174
|
+
const params = new URLSearchParams();
|
|
175
|
+
// Append page number or cursor param if configured
|
|
176
|
+
if (pageParam && paginationValues.page != null) {
|
|
177
|
+
params.append(pageParam, paginationValues.page);
|
|
178
|
+
}
|
|
179
|
+
// Append page size param if configured
|
|
180
|
+
if (sizeParam && paginationValues.limit != null) {
|
|
181
|
+
params.append(sizeParam, paginationValues.limit);
|
|
182
|
+
}
|
|
183
|
+
// Prepend query string with pagination params
|
|
184
|
+
let paginationString = params.toString();
|
|
185
|
+
if (paginationString) {
|
|
186
|
+
queryString = `${paginationString}&${queryString}`;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const main = `${path}?${queryString}`;
|
|
190
|
+
let complete = main;
|
|
191
|
+
if (this.config.url && !main.startsWith("http")) {
|
|
192
|
+
complete = !this.config.url ? main : `${this.config.url}/${main}`;
|
|
193
|
+
}
|
|
194
|
+
if (!complete.startsWith("http")) {
|
|
195
|
+
complete = `http://${complete}`;
|
|
196
|
+
}
|
|
197
|
+
return complete;
|
|
198
|
+
}
|
|
199
|
+
addBody(bodyType, body, input, pagination, paginationValues) {
|
|
200
|
+
if (!input.headers) {
|
|
201
|
+
input.headers = {};
|
|
202
|
+
}
|
|
203
|
+
if (bodyType === BodyTypes.NONE) {
|
|
204
|
+
return input;
|
|
205
|
+
}
|
|
206
|
+
let error, object = {}, string = "";
|
|
207
|
+
try {
|
|
208
|
+
if (body) {
|
|
209
|
+
string = typeof body !== "string" ? JSON.stringify(body) : body;
|
|
210
|
+
object = typeof body === "object" ? body : JSON.parse(body);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
error = err;
|
|
215
|
+
}
|
|
216
|
+
// Util to add pagination values to a certain body type
|
|
217
|
+
const addPaginationToBody = (insertFn) => {
|
|
218
|
+
if ((pagination === null || pagination === void 0 ? void 0 : pagination.location) === "body") {
|
|
219
|
+
if ((pagination === null || pagination === void 0 ? void 0 : pagination.pageParam) && (paginationValues === null || paginationValues === void 0 ? void 0 : paginationValues.page) != null) {
|
|
220
|
+
insertFn(pagination.pageParam, paginationValues.page);
|
|
221
|
+
}
|
|
222
|
+
if ((pagination === null || pagination === void 0 ? void 0 : pagination.sizeParam) && (paginationValues === null || paginationValues === void 0 ? void 0 : paginationValues.limit) != null) {
|
|
223
|
+
insertFn(pagination.sizeParam, paginationValues.limit);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
switch (bodyType) {
|
|
228
|
+
case BodyTypes.TEXT:
|
|
229
|
+
// content type defaults to plaintext
|
|
230
|
+
input.body = string;
|
|
231
|
+
break;
|
|
232
|
+
case BodyTypes.ENCODED:
|
|
233
|
+
const params = new URLSearchParams();
|
|
234
|
+
for (let [key, value] of Object.entries(object)) {
|
|
235
|
+
params.append(key, value);
|
|
236
|
+
}
|
|
237
|
+
addPaginationToBody((key, value) => {
|
|
238
|
+
params.append(key, value);
|
|
239
|
+
});
|
|
240
|
+
input.body = params;
|
|
241
|
+
break;
|
|
242
|
+
case BodyTypes.FORM_DATA:
|
|
243
|
+
const form = new FormData();
|
|
244
|
+
for (let [key, value] of Object.entries(object)) {
|
|
245
|
+
form.append(key, value);
|
|
246
|
+
}
|
|
247
|
+
addPaginationToBody((key, value) => {
|
|
248
|
+
form.append(key, value);
|
|
249
|
+
});
|
|
250
|
+
input.body = form;
|
|
251
|
+
break;
|
|
252
|
+
case BodyTypes.XML:
|
|
253
|
+
if (object != null) {
|
|
254
|
+
string = new XmlBuilder().buildObject(object);
|
|
255
|
+
}
|
|
256
|
+
input.body = string;
|
|
257
|
+
input.headers["Content-Type"] = "application/xml";
|
|
258
|
+
break;
|
|
259
|
+
case BodyTypes.JSON:
|
|
260
|
+
// if JSON error, throw it
|
|
261
|
+
if (error) {
|
|
262
|
+
throw "Invalid JSON for request body";
|
|
263
|
+
}
|
|
264
|
+
addPaginationToBody((key, value) => {
|
|
265
|
+
object[key] = value;
|
|
266
|
+
});
|
|
267
|
+
input.body = JSON.stringify(object);
|
|
268
|
+
input.headers["Content-Type"] = "application/json";
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
return input;
|
|
272
|
+
}
|
|
273
|
+
getAuthHeaders(authConfigId) {
|
|
274
|
+
let headers = {};
|
|
275
|
+
if (this.config.authConfigs && authConfigId) {
|
|
276
|
+
const authConfig = this.config.authConfigs.filter(c => c._id === authConfigId)[0];
|
|
277
|
+
// check the config still exists before proceeding
|
|
278
|
+
// if not - do nothing
|
|
279
|
+
if (authConfig) {
|
|
280
|
+
let config;
|
|
281
|
+
switch (authConfig.type) {
|
|
282
|
+
case datasource_1.AuthType.BASIC:
|
|
283
|
+
config = authConfig.config;
|
|
284
|
+
headers.Authorization = `Basic ${Buffer.from(`${config.username}:${config.password}`).toString("base64")}`;
|
|
285
|
+
break;
|
|
286
|
+
case datasource_1.AuthType.BEARER:
|
|
287
|
+
config = authConfig.config;
|
|
288
|
+
headers.Authorization = `Bearer ${config.token}`;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return headers;
|
|
294
|
+
}
|
|
295
|
+
_req(query) {
|
|
296
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
297
|
+
const { path = "", queryString = "", headers = {}, method = "GET", disabledHeaders, bodyType, requestBody, authConfigId, pagination, paginationValues, } = query;
|
|
298
|
+
const authHeaders = this.getAuthHeaders(authConfigId);
|
|
299
|
+
this.headers = Object.assign(Object.assign(Object.assign({}, this.config.defaultHeaders), headers), authHeaders);
|
|
300
|
+
if (disabledHeaders) {
|
|
301
|
+
for (let headerKey of Object.keys(this.headers)) {
|
|
302
|
+
if (disabledHeaders[headerKey]) {
|
|
303
|
+
delete this.headers[headerKey];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
let input = { method, headers: this.headers };
|
|
308
|
+
input = this.addBody(bodyType, requestBody, input, pagination, paginationValues);
|
|
309
|
+
this.startTimeMs = performance.now();
|
|
310
|
+
const url = this.getUrl(path, queryString, pagination, paginationValues);
|
|
311
|
+
const response = yield fetch(url, input);
|
|
312
|
+
return yield this.parseResponse(response, pagination);
|
|
313
|
+
});
|
|
149
314
|
}
|
|
150
|
-
create(
|
|
315
|
+
create(opts) {
|
|
151
316
|
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
this.
|
|
153
|
-
const response = yield fetch(this.getUrl(path, queryString), {
|
|
154
|
-
method: "POST",
|
|
155
|
-
headers: this.headers,
|
|
156
|
-
body: JSON.stringify(json),
|
|
157
|
-
});
|
|
158
|
-
return yield this.parseResponse(response);
|
|
317
|
+
return this._req(Object.assign(Object.assign({}, opts), { method: "POST" }));
|
|
159
318
|
});
|
|
160
319
|
}
|
|
161
|
-
read(
|
|
320
|
+
read(opts) {
|
|
162
321
|
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
this.
|
|
164
|
-
const response = yield fetch(this.getUrl(path, queryString), {
|
|
165
|
-
headers: this.headers,
|
|
166
|
-
});
|
|
167
|
-
return yield this.parseResponse(response);
|
|
322
|
+
return this._req(Object.assign(Object.assign({}, opts), { method: "GET" }));
|
|
168
323
|
});
|
|
169
324
|
}
|
|
170
|
-
update(
|
|
325
|
+
update(opts) {
|
|
171
326
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
this.
|
|
173
|
-
const response = yield fetch(this.getUrl(path, queryString), {
|
|
174
|
-
method: "PUT",
|
|
175
|
-
headers: this.headers,
|
|
176
|
-
body: JSON.stringify(json),
|
|
177
|
-
});
|
|
178
|
-
return yield this.parseResponse(response);
|
|
327
|
+
return this._req(Object.assign(Object.assign({}, opts), { method: "PUT" }));
|
|
179
328
|
});
|
|
180
329
|
}
|
|
181
|
-
patch(
|
|
330
|
+
patch(opts) {
|
|
182
331
|
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
this.
|
|
184
|
-
const response = yield fetch(this.getUrl(path, queryString), {
|
|
185
|
-
method: "PATCH",
|
|
186
|
-
headers: this.headers,
|
|
187
|
-
body: JSON.stringify(json),
|
|
188
|
-
});
|
|
189
|
-
return yield this.parseResponse(response);
|
|
332
|
+
return this._req(Object.assign(Object.assign({}, opts), { method: "PATCH" }));
|
|
190
333
|
});
|
|
191
334
|
}
|
|
192
|
-
delete(
|
|
335
|
+
delete(opts) {
|
|
193
336
|
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
-
this.
|
|
195
|
-
const response = yield fetch(this.getUrl(path, queryString), {
|
|
196
|
-
method: "DELETE",
|
|
197
|
-
headers: this.headers,
|
|
198
|
-
});
|
|
199
|
-
return yield this.parseResponse(response);
|
|
337
|
+
return this._req(Object.assign(Object.assign({}, opts), { method: "DELETE" }));
|
|
200
338
|
});
|
|
201
339
|
}
|
|
202
340
|
}
|
|
203
341
|
module.exports = {
|
|
204
342
|
schema: SCHEMA,
|
|
205
343
|
integration: RestIntegration,
|
|
344
|
+
AuthType: datasource_1.AuthType,
|
|
206
345
|
};
|
|
207
346
|
})(RestModule || (RestModule = {}));
|
package/dist/integrations/s3.js
CHANGED
|
@@ -20,7 +20,7 @@ var S3Module;
|
|
|
20
20
|
datasource: {
|
|
21
21
|
region: {
|
|
22
22
|
type: "string",
|
|
23
|
-
required:
|
|
23
|
+
required: false,
|
|
24
24
|
default: "us-east-1",
|
|
25
25
|
},
|
|
26
26
|
accessKeyId: {
|
|
@@ -31,6 +31,15 @@ var S3Module;
|
|
|
31
31
|
type: "password",
|
|
32
32
|
required: true,
|
|
33
33
|
},
|
|
34
|
+
endpoint: {
|
|
35
|
+
type: "string",
|
|
36
|
+
required: false,
|
|
37
|
+
},
|
|
38
|
+
signatureVersion: {
|
|
39
|
+
type: "string",
|
|
40
|
+
required: false,
|
|
41
|
+
default: "v4"
|
|
42
|
+
},
|
|
34
43
|
},
|
|
35
44
|
query: {
|
|
36
45
|
read: {
|
|
@@ -47,13 +56,13 @@ var S3Module;
|
|
|
47
56
|
class S3Integration {
|
|
48
57
|
constructor(config) {
|
|
49
58
|
this.config = config;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
if (this.config.endpoint) {
|
|
60
|
+
this.config.s3ForcePathStyle = true;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
delete this.config.endpoint;
|
|
64
|
+
}
|
|
65
|
+
this.client = new AWS.S3(this.config);
|
|
57
66
|
}
|
|
58
67
|
read(query) {
|
|
59
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2,39 +2,39 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.finaliseExternalTables = exports.isIsoDateString = exports.isSQL = exports.getSqlQuery = exports.convertSqlType = exports.breakRowIdField = exports.convertRowId = exports.isRowId = exports.generateRowIdField = exports.breakExternalTableId = exports.buildExternalTableId = exports.isExternalTable = exports.SqlClients = void 0;
|
|
4
4
|
const datasource_1 = require("../definitions/datasource");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`;
|
|
5
|
+
const utils_1 = require("../db/utils");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const DOUBLE_SEPARATOR = `${utils_1.SEPARATOR}${utils_1.SEPARATOR}`;
|
|
8
8
|
const ROW_ID_REGEX = /^\[.*]$/g;
|
|
9
9
|
const SQL_TYPE_MAP = {
|
|
10
|
-
text: FieldTypes.LONGFORM,
|
|
11
|
-
varchar: FieldTypes.STRING,
|
|
12
|
-
integer: FieldTypes.NUMBER,
|
|
13
|
-
bigint: FieldTypes.NUMBER,
|
|
14
|
-
decimal: FieldTypes.NUMBER,
|
|
15
|
-
smallint: FieldTypes.NUMBER,
|
|
16
|
-
real: FieldTypes.NUMBER,
|
|
17
|
-
"double precision": FieldTypes.NUMBER,
|
|
18
|
-
timestamp: FieldTypes.DATETIME,
|
|
19
|
-
time: FieldTypes.DATETIME,
|
|
20
|
-
boolean: FieldTypes.BOOLEAN,
|
|
21
|
-
json: FieldTypes.JSON,
|
|
22
|
-
date: FieldTypes.DATETIME,
|
|
23
|
-
blob: FieldTypes.LONGFORM,
|
|
24
|
-
enum: FieldTypes.STRING,
|
|
25
|
-
float: FieldTypes.NUMBER,
|
|
26
|
-
int: FieldTypes.NUMBER,
|
|
27
|
-
numeric: FieldTypes.NUMBER,
|
|
28
|
-
mediumint: FieldTypes.NUMBER,
|
|
29
|
-
dec: FieldTypes.NUMBER,
|
|
30
|
-
double: FieldTypes.NUMBER,
|
|
31
|
-
fixed: FieldTypes.NUMBER,
|
|
32
|
-
datetime: FieldTypes.DATETIME,
|
|
33
|
-
tinyint: FieldTypes.BOOLEAN,
|
|
34
|
-
long: FieldTypes.LONGFORM,
|
|
35
|
-
number: FieldTypes.NUMBER,
|
|
36
|
-
binary_float: FieldTypes.NUMBER,
|
|
37
|
-
binary_double: FieldTypes.NUMBER,
|
|
10
|
+
text: constants_1.FieldTypes.LONGFORM,
|
|
11
|
+
varchar: constants_1.FieldTypes.STRING,
|
|
12
|
+
integer: constants_1.FieldTypes.NUMBER,
|
|
13
|
+
bigint: constants_1.FieldTypes.NUMBER,
|
|
14
|
+
decimal: constants_1.FieldTypes.NUMBER,
|
|
15
|
+
smallint: constants_1.FieldTypes.NUMBER,
|
|
16
|
+
real: constants_1.FieldTypes.NUMBER,
|
|
17
|
+
"double precision": constants_1.FieldTypes.NUMBER,
|
|
18
|
+
timestamp: constants_1.FieldTypes.DATETIME,
|
|
19
|
+
time: constants_1.FieldTypes.DATETIME,
|
|
20
|
+
boolean: constants_1.FieldTypes.BOOLEAN,
|
|
21
|
+
json: constants_1.FieldTypes.JSON,
|
|
22
|
+
date: constants_1.FieldTypes.DATETIME,
|
|
23
|
+
blob: constants_1.FieldTypes.LONGFORM,
|
|
24
|
+
enum: constants_1.FieldTypes.STRING,
|
|
25
|
+
float: constants_1.FieldTypes.NUMBER,
|
|
26
|
+
int: constants_1.FieldTypes.NUMBER,
|
|
27
|
+
numeric: constants_1.FieldTypes.NUMBER,
|
|
28
|
+
mediumint: constants_1.FieldTypes.NUMBER,
|
|
29
|
+
dec: constants_1.FieldTypes.NUMBER,
|
|
30
|
+
double: constants_1.FieldTypes.NUMBER,
|
|
31
|
+
fixed: constants_1.FieldTypes.NUMBER,
|
|
32
|
+
datetime: constants_1.FieldTypes.DATETIME,
|
|
33
|
+
tinyint: constants_1.FieldTypes.BOOLEAN,
|
|
34
|
+
long: constants_1.FieldTypes.LONGFORM,
|
|
35
|
+
number: constants_1.FieldTypes.NUMBER,
|
|
36
|
+
binary_float: constants_1.FieldTypes.NUMBER,
|
|
37
|
+
binary_double: constants_1.FieldTypes.NUMBER,
|
|
38
38
|
};
|
|
39
39
|
var SqlClients;
|
|
40
40
|
(function (SqlClients) {
|
|
@@ -44,7 +44,7 @@ var SqlClients;
|
|
|
44
44
|
SqlClients["ORACLE"] = "oracledb";
|
|
45
45
|
})(SqlClients = exports.SqlClients || (exports.SqlClients = {}));
|
|
46
46
|
function isExternalTable(tableId) {
|
|
47
|
-
return tableId.includes(DocumentTypes.DATASOURCE);
|
|
47
|
+
return tableId.includes(utils_1.DocumentTypes.DATASOURCE);
|
|
48
48
|
}
|
|
49
49
|
exports.isExternalTable = isExternalTable;
|
|
50
50
|
function buildExternalTableId(datasourceId, tableName) {
|
|
@@ -109,7 +109,7 @@ function convertSqlType(type) {
|
|
|
109
109
|
return internal;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
return FieldTypes.STRING;
|
|
112
|
+
return constants_1.FieldTypes.STRING;
|
|
113
113
|
}
|
|
114
114
|
exports.convertSqlType = convertSqlType;
|
|
115
115
|
function getSqlQuery(query) {
|
|
@@ -148,7 +148,10 @@ function copyExistingPropsOver(tableName, table, entities) {
|
|
|
148
148
|
if (!existingTableSchema.hasOwnProperty(key)) {
|
|
149
149
|
continue;
|
|
150
150
|
}
|
|
151
|
-
if (existingTableSchema[key].type ===
|
|
151
|
+
if (existingTableSchema[key].type === constants_1.FieldTypes.LINK ||
|
|
152
|
+
existingTableSchema[key].type === constants_1.FieldTypes.OPTIONS ||
|
|
153
|
+
((!table.schema[key] || table.schema[key].type === constants_1.FieldTypes.NUMBER) &&
|
|
154
|
+
existingTableSchema[key].type === constants_1.FieldTypes.BOOLEAN)) {
|
|
152
155
|
table.schema[key] = existingTableSchema[key];
|
|
153
156
|
}
|
|
154
157
|
}
|
|
@@ -156,18 +159,18 @@ function copyExistingPropsOver(tableName, table, entities) {
|
|
|
156
159
|
return table;
|
|
157
160
|
}
|
|
158
161
|
function finaliseExternalTables(tables, entities) {
|
|
159
|
-
const invalidColumns = Object.values(InvalidColumns);
|
|
162
|
+
const invalidColumns = Object.values(constants_1.InvalidColumns);
|
|
160
163
|
let finalTables = {};
|
|
161
164
|
const errors = {};
|
|
162
165
|
for (let [name, table] of Object.entries(tables)) {
|
|
163
166
|
const schemaFields = Object.keys(table.schema);
|
|
164
167
|
// make sure every table has a key
|
|
165
168
|
if (table.primary == null || table.primary.length === 0) {
|
|
166
|
-
errors[name] = BuildSchemaErrors.NO_KEY;
|
|
169
|
+
errors[name] = constants_1.BuildSchemaErrors.NO_KEY;
|
|
167
170
|
continue;
|
|
168
171
|
}
|
|
169
172
|
else if (schemaFields.find(field => invalidColumns.includes(field))) {
|
|
170
|
-
errors[name] = BuildSchemaErrors.INVALID_COLUMN;
|
|
173
|
+
errors[name] = constants_1.BuildSchemaErrors.INVALID_COLUMN;
|
|
171
174
|
continue;
|
|
172
175
|
}
|
|
173
176
|
// make sure all previous props have been added back
|
|
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const { getUserRoleHierarchy, getRequiredResourceRole, BUILTIN_ROLE_IDS, } = require("@budibase/
|
|
12
|
-
const { PermissionTypes, doesHaveBasePermission, } = require("@budibase/
|
|
11
|
+
const { getUserRoleHierarchy, getRequiredResourceRole, BUILTIN_ROLE_IDS, } = require("@budibase/backend-core/roles");
|
|
12
|
+
const { PermissionTypes, doesHaveBasePermission, } = require("@budibase/backend-core/permissions");
|
|
13
13
|
const builderMiddleware = require("./builder");
|
|
14
14
|
const { isWebhookEndpoint } = require("./utils");
|
|
15
15
|
function hasResource(ctx) {
|
|
@@ -12,8 +12,8 @@ const { APP_DEV_PREFIX } = require("../db/utils");
|
|
|
12
12
|
const { doesUserHaveLock, updateLock, checkDebounce, setDebounce, } = require("../utilities/redis");
|
|
13
13
|
const CouchDB = require("../db");
|
|
14
14
|
const { DocumentTypes } = require("../db/utils");
|
|
15
|
-
const { PermissionTypes } = require("@budibase/
|
|
16
|
-
const { app: appCache } = require("@budibase/
|
|
15
|
+
const { PermissionTypes } = require("@budibase/backend-core/permissions");
|
|
16
|
+
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
17
17
|
const DEBOUNCE_TIME_SEC = 30;
|
|
18
18
|
/************************************************** *
|
|
19
19
|
* This middleware has been broken out of the *
|
|
@@ -8,13 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const { getAppId, setCookie, getCookie, clearCookie } = require("@budibase/
|
|
12
|
-
const { Cookies } = require("@budibase/
|
|
13
|
-
const { getRole } = require("@budibase/
|
|
14
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
11
|
+
const { getAppId, setCookie, getCookie, clearCookie, } = require("@budibase/backend-core/utils");
|
|
12
|
+
const { Cookies } = require("@budibase/backend-core/constants");
|
|
13
|
+
const { getRole } = require("@budibase/backend-core/roles");
|
|
14
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
15
15
|
const { generateUserMetadataID, isDevAppID } = require("../db/utils");
|
|
16
|
-
const { dbExists } = require("@budibase/
|
|
17
|
-
const { isUserInAppTenant } = require("@budibase/
|
|
16
|
+
const { dbExists } = require("@budibase/backend-core/db");
|
|
17
|
+
const { isUserInAppTenant } = require("@budibase/backend-core/tenancy");
|
|
18
18
|
const { getCachedSelf } = require("../utilities/global");
|
|
19
19
|
const CouchDB = require("../db");
|
|
20
20
|
const env = require("../environment");
|