@budibase/server 1.0.35 → 1.0.42
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.17f372b7.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 +1589 -1344
- 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} +225 -120
- 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 +2735 -2313
- 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} +88 -56
- 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/integrations/base/sqlTable.js +1 -1
- package/dist/integrations/rest.js +259 -120
- package/dist/integrations/s3.js +1 -1
- 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/integrations/base/IntegrationBase.ts +4 -4
- package/src/integrations/base/sqlTable.ts +1 -1
- package/src/integrations/rest.ts +311 -138
- package/src/integrations/s3.ts +1 -1
- 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.9ac33cf1.js +0 -1316
- package/src/api/controllers/query.js +0 -161
|
@@ -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 { StaticDatabases } = require("@budibase/
|
|
12
|
-
const { getGlobalDB } = require("@budibase/
|
|
11
|
+
const { StaticDatabases } = require("@budibase/backend-core/db");
|
|
12
|
+
const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
13
13
|
const KEYS_DOC = StaticDatabases.GLOBAL.docs.apiKeys;
|
|
14
14
|
function getBuilderMainDoc() {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -14,19 +14,19 @@ const packageJson = require("../../../package.json");
|
|
|
14
14
|
const { createLinkView, createRoutingView, createAllSearchIndex, } = require("../../db/views/staticViews");
|
|
15
15
|
const { getTemplateStream, createApp, deleteApp, } = require("../../utilities/fileSystem");
|
|
16
16
|
const { generateAppID, getLayoutParams, getScreenParams, generateDevAppID, DocumentTypes, AppStatus, } = require("../../db/utils");
|
|
17
|
-
const { BUILTIN_ROLE_IDS, AccessController } = require("@budibase/
|
|
17
|
+
const { BUILTIN_ROLE_IDS, AccessController, } = require("@budibase/backend-core/roles");
|
|
18
18
|
const { BASE_LAYOUTS } = require("../../constants/layouts");
|
|
19
19
|
const { cloneDeep } = require("lodash/fp");
|
|
20
20
|
const { processObject } = require("@budibase/string-templates");
|
|
21
|
-
const { getAllApps, isDevAppID, getDeployedAppID, Replication, } = require("@budibase/
|
|
21
|
+
const { getAllApps, isDevAppID, getDeployedAppID, Replication, } = require("@budibase/backend-core/db");
|
|
22
22
|
const { USERS_TABLE_SCHEMA } = require("../../constants");
|
|
23
23
|
const { getDeployedApps, removeAppFromUserRoles, } = require("../../utilities/workerRequests");
|
|
24
24
|
const { clientLibraryPath, stringToReadStream } = require("../../utilities");
|
|
25
25
|
const { getAllLocks } = require("../../utilities/redis");
|
|
26
26
|
const { updateClientLibrary, backupClientLibrary, revertClientLibrary, } = require("../../utilities/fileSystem/clientLibrary");
|
|
27
|
-
const { getTenantId, isMultiTenant } = require("@budibase/
|
|
27
|
+
const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy");
|
|
28
28
|
const { syncGlobalUsers } = require("./user");
|
|
29
|
-
const { app: appCache } = require("@budibase/
|
|
29
|
+
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
30
30
|
const { cleanupAutomations } = require("../../automations/utils");
|
|
31
31
|
const URL_REGEX_SLASH = /\/|\\/g;
|
|
32
32
|
// utility function, need to do away with this
|
|
@@ -12,7 +12,7 @@ const CouchDB = require("../../db");
|
|
|
12
12
|
const { outputProcessing } = require("../../utilities/rowProcessor");
|
|
13
13
|
const { InternalTables } = require("../../db/utils");
|
|
14
14
|
const { getFullUser } = require("../../utilities/users");
|
|
15
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
15
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
16
16
|
exports.fetchSelf = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const appId = ctx.appId;
|
|
18
18
|
let userId = ctx.user.userId || ctx.user._id;
|
|
@@ -12,10 +12,12 @@ const CouchDB = require("../../db");
|
|
|
12
12
|
const actions = require("../../automations/actions");
|
|
13
13
|
const triggers = require("../../automations/triggers");
|
|
14
14
|
const { getAutomationParams, generateAutomationID } = require("../../db/utils");
|
|
15
|
-
const { checkForWebhooks, updateTestHistory, } = require("../../automations/utils");
|
|
15
|
+
const { checkForWebhooks, updateTestHistory, removeDeprecated, } = require("../../automations/utils");
|
|
16
16
|
const { deleteEntityMetadata } = require("../../utilities");
|
|
17
17
|
const { MetadataTypes } = require("../../constants");
|
|
18
18
|
const { setTestFlag, clearTestFlag } = require("../../utilities/redis");
|
|
19
|
+
const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS);
|
|
20
|
+
const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS);
|
|
19
21
|
/*************************
|
|
20
22
|
* *
|
|
21
23
|
* BUILDER FUNCTIONS *
|
|
@@ -137,19 +139,19 @@ exports.destroy = function (ctx) {
|
|
|
137
139
|
};
|
|
138
140
|
exports.getActionList = function (ctx) {
|
|
139
141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
ctx.body =
|
|
142
|
+
ctx.body = ACTION_DEFS;
|
|
141
143
|
});
|
|
142
144
|
};
|
|
143
145
|
exports.getTriggerList = function (ctx) {
|
|
144
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
ctx.body =
|
|
147
|
+
ctx.body = TRIGGER_DEFS;
|
|
146
148
|
});
|
|
147
149
|
};
|
|
148
150
|
module.exports.getDefinitionList = function (ctx) {
|
|
149
151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
152
|
ctx.body = {
|
|
151
|
-
trigger:
|
|
152
|
-
action:
|
|
153
|
+
trigger: TRIGGER_DEFS,
|
|
154
|
+
action: ACTION_DEFS,
|
|
153
155
|
};
|
|
154
156
|
});
|
|
155
157
|
};
|
|
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const env = require("../../environment");
|
|
12
|
-
const { getAllApps } = require("@budibase/
|
|
12
|
+
const { getAllApps } = require("@budibase/backend-core/db");
|
|
13
13
|
const CouchDB = require("../../db");
|
|
14
14
|
const { exportDB, sendTempFile, readFileSync, } = require("../../utilities/fileSystem");
|
|
15
15
|
const { stringToReadStream } = require("../../utilities");
|
|
16
|
-
const { getGlobalDBName, getGlobalDB } = require("@budibase/
|
|
16
|
+
const { getGlobalDBName, getGlobalDB, } = require("@budibase/backend-core/tenancy");
|
|
17
17
|
const { create } = require("./application");
|
|
18
18
|
const { getDocParams, DocumentTypes, isDevAppID } = require("../../db/utils");
|
|
19
19
|
function createApp(appName, appImport) {
|
|
@@ -13,6 +13,7 @@ const { generateDatasourceID, getDatasourceParams, getQueryParams, DocumentTypes
|
|
|
13
13
|
const { BuildSchemaErrors, InvalidColumns } = require("../../constants");
|
|
14
14
|
const { integrations } = require("../../integrations");
|
|
15
15
|
const { getDatasourceAndQuery } = require("./row/utils");
|
|
16
|
+
const { invalidateDynamicVariables } = require("../../threads/utils");
|
|
16
17
|
exports.fetch = function (ctx) {
|
|
17
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
const database = new CouchDB(ctx.appId);
|
|
@@ -45,11 +46,39 @@ exports.buildSchemaFromDb = function (ctx) {
|
|
|
45
46
|
ctx.body = response;
|
|
46
47
|
});
|
|
47
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Check for variables that have been updated or removed and invalidate them.
|
|
51
|
+
*/
|
|
52
|
+
const invalidateVariables = (existingDatasource, updatedDatasource) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const existingVariables = existingDatasource.config.dynamicVariables;
|
|
54
|
+
const updatedVariables = updatedDatasource.config.dynamicVariables;
|
|
55
|
+
const toInvalidate = [];
|
|
56
|
+
if (!existingVariables) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!updatedVariables) {
|
|
60
|
+
// invalidate all
|
|
61
|
+
toInvalidate.push(...existingVariables);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// invaldate changed / removed
|
|
65
|
+
existingVariables.forEach(existing => {
|
|
66
|
+
const unchanged = updatedVariables.find(updated => existing.name === updated.name &&
|
|
67
|
+
existing.queryId === updated.queryId &&
|
|
68
|
+
existing.value === updated.value);
|
|
69
|
+
if (!unchanged) {
|
|
70
|
+
toInvalidate.push(existing);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
yield invalidateDynamicVariables(toInvalidate);
|
|
75
|
+
});
|
|
48
76
|
exports.update = function (ctx) {
|
|
49
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
78
|
const db = new CouchDB(ctx.appId);
|
|
51
79
|
const datasourceId = ctx.params.datasourceId;
|
|
52
80
|
let datasource = yield db.get(datasourceId);
|
|
81
|
+
yield invalidateVariables(datasource, ctx.request.body);
|
|
53
82
|
datasource = Object.assign(Object.assign({}, datasource), ctx.request.body);
|
|
54
83
|
const response = yield db.put(datasource);
|
|
55
84
|
datasource._rev = response.rev;
|
|
@@ -10,10 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const CouchDB = require("../../../db");
|
|
12
12
|
const Deployment = require("./Deployment");
|
|
13
|
-
const { Replication, getDeployedAppID } = require("@budibase/
|
|
13
|
+
const { Replication, getDeployedAppID } = require("@budibase/backend-core/db");
|
|
14
14
|
const { DocumentTypes, getAutomationParams } = require("../../../db/utils");
|
|
15
15
|
const { disableAllCrons, enableCronTrigger, } = require("../../../automations/utils");
|
|
16
|
-
const { app: appCache } = require("@budibase/
|
|
16
|
+
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
17
17
|
// the max time we can wait for an invalidation to complete before considering it failed
|
|
18
18
|
const MAX_PENDING_TIME_MS = 30 * 60000;
|
|
19
19
|
const DeploymentStatus = {
|
|
@@ -14,9 +14,9 @@ const env = require("../../environment");
|
|
|
14
14
|
const { checkSlashesInUrl } = require("../../utilities");
|
|
15
15
|
const { request } = require("../../utilities/workerRequests");
|
|
16
16
|
const { clearLock } = require("../../utilities/redis");
|
|
17
|
-
const { Replication } = require("@budibase/
|
|
17
|
+
const { Replication } = require("@budibase/backend-core/db");
|
|
18
18
|
const { DocumentTypes } = require("../../db/utils");
|
|
19
|
-
const { app: appCache } = require("@budibase/
|
|
19
|
+
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
20
20
|
function redirect(ctx, method, path = "global") {
|
|
21
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
const { devPath } = ctx.params;
|
|
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const CouchDB = require("../../db");
|
|
12
12
|
const { getDeployedApps } = require("../../utilities/workerRequests");
|
|
13
|
-
const { getScopedConfig } = require("@budibase/
|
|
14
|
-
const { Configs } = require("@budibase/
|
|
13
|
+
const { getScopedConfig } = require("@budibase/backend-core/db");
|
|
14
|
+
const { Configs } = require("@budibase/backend-core/constants");
|
|
15
15
|
const { checkSlashesInUrl } = require("../../utilities");
|
|
16
16
|
exports.fetchUrls = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const appId = ctx.appId;
|
|
@@ -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 { getBuiltinPermissions } = require("@budibase/
|
|
12
|
-
const { isBuiltin, getDBRoleID, getExternalRoleID, getBuiltinRoles, } = require("@budibase/
|
|
11
|
+
const { getBuiltinPermissions } = require("@budibase/backend-core/permissions");
|
|
12
|
+
const { isBuiltin, getDBRoleID, getExternalRoleID, getBuiltinRoles, } = require("@budibase/backend-core/roles");
|
|
13
13
|
const { getRoleParams } = require("../../db/utils");
|
|
14
14
|
const CouchDB = require("../../db");
|
|
15
15
|
const { CURRENTLY_SUPPORTED_LEVELS, getBasePermissions, } = require("../../utilities/security");
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RestImporter = void 0;
|
|
16
|
+
const db_1 = __importDefault(require("../../../../db"));
|
|
17
|
+
const validation_1 = require("../validation");
|
|
18
|
+
const utils_1 = require("../../../../db/utils");
|
|
19
|
+
const openapi2_1 = require("./sources/openapi2");
|
|
20
|
+
const curl_1 = require("./sources/curl");
|
|
21
|
+
class RestImporter {
|
|
22
|
+
constructor(data) {
|
|
23
|
+
this.init = () => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
for (let source of this.sources) {
|
|
25
|
+
if (yield source.isSupported(this.data)) {
|
|
26
|
+
this.source = source;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
this.getInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return this.source.getInfo();
|
|
33
|
+
});
|
|
34
|
+
this.importQueries = (appId, datasourceId) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
// constuct the queries
|
|
36
|
+
let queries = yield this.source.getQueries(datasourceId);
|
|
37
|
+
// validate queries
|
|
38
|
+
const errorQueries = [];
|
|
39
|
+
const schema = validation_1.queryValidation();
|
|
40
|
+
queries = queries
|
|
41
|
+
.filter(query => {
|
|
42
|
+
const validation = schema.validate(query);
|
|
43
|
+
if (validation.error) {
|
|
44
|
+
errorQueries.push(query);
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
})
|
|
49
|
+
.map(query => {
|
|
50
|
+
query._id = utils_1.generateQueryID(query.datasourceId);
|
|
51
|
+
return query;
|
|
52
|
+
});
|
|
53
|
+
// persist queries
|
|
54
|
+
const db = new db_1.default(appId);
|
|
55
|
+
const response = yield db.bulkDocs(queries);
|
|
56
|
+
// create index to seperate queries and errors
|
|
57
|
+
const queryIndex = queries.reduce((acc, query) => {
|
|
58
|
+
if (query._id) {
|
|
59
|
+
acc[query._id] = query;
|
|
60
|
+
}
|
|
61
|
+
return acc;
|
|
62
|
+
}, {});
|
|
63
|
+
// check for failed writes
|
|
64
|
+
response.forEach((query) => {
|
|
65
|
+
if (!query.ok) {
|
|
66
|
+
errorQueries.push(queryIndex[query.id]);
|
|
67
|
+
delete queryIndex[query.id];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
errorQueries,
|
|
72
|
+
queries: Object.values(queryIndex),
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
this.data = data;
|
|
76
|
+
this.sources = [new openapi2_1.OpenAPI2(), new curl_1.Curl()];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.RestImporter = RestImporter;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportSource = void 0;
|
|
4
|
+
var MethodToVerb;
|
|
5
|
+
(function (MethodToVerb) {
|
|
6
|
+
MethodToVerb["get"] = "read";
|
|
7
|
+
MethodToVerb["post"] = "create";
|
|
8
|
+
MethodToVerb["put"] = "update";
|
|
9
|
+
MethodToVerb["patch"] = "patch";
|
|
10
|
+
MethodToVerb["delete"] = "delete";
|
|
11
|
+
})(MethodToVerb || (MethodToVerb = {}));
|
|
12
|
+
class ImportSource {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.constructQuery = (datasourceId, name, method, path, url, queryString, headers = {}, parameters = [], body = undefined) => {
|
|
15
|
+
const readable = true;
|
|
16
|
+
const queryVerb = this.verbFromMethod(method);
|
|
17
|
+
const transformer = "return data";
|
|
18
|
+
const schema = {};
|
|
19
|
+
path = this.processPath(path);
|
|
20
|
+
path = `${url.origin}/${path}`;
|
|
21
|
+
queryString = this.processQuery(queryString);
|
|
22
|
+
const requestBody = JSON.stringify(body, null, 2);
|
|
23
|
+
const query = {
|
|
24
|
+
datasourceId,
|
|
25
|
+
name,
|
|
26
|
+
parameters,
|
|
27
|
+
fields: {
|
|
28
|
+
headers,
|
|
29
|
+
queryString,
|
|
30
|
+
path,
|
|
31
|
+
requestBody,
|
|
32
|
+
},
|
|
33
|
+
transformer,
|
|
34
|
+
schema,
|
|
35
|
+
readable,
|
|
36
|
+
queryVerb,
|
|
37
|
+
};
|
|
38
|
+
return query;
|
|
39
|
+
};
|
|
40
|
+
this.verbFromMethod = (method) => {
|
|
41
|
+
const verb = MethodToVerb[method];
|
|
42
|
+
if (!verb) {
|
|
43
|
+
throw new Error(`Unsupported method: ${method}`);
|
|
44
|
+
}
|
|
45
|
+
return verb;
|
|
46
|
+
};
|
|
47
|
+
this.processPath = (path) => {
|
|
48
|
+
if (path === null || path === void 0 ? void 0 : path.startsWith("/")) {
|
|
49
|
+
path = path.substring(1);
|
|
50
|
+
}
|
|
51
|
+
// add extra braces around params for binding
|
|
52
|
+
path = path.replace(/[{]/g, "{{");
|
|
53
|
+
path = path.replace(/[}]/g, "}}");
|
|
54
|
+
return path;
|
|
55
|
+
};
|
|
56
|
+
this.processQuery = (queryString) => {
|
|
57
|
+
if (queryString === null || queryString === void 0 ? void 0 : queryString.startsWith("?")) {
|
|
58
|
+
return queryString.substring(1);
|
|
59
|
+
}
|
|
60
|
+
return queryString;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.ImportSource = ImportSource;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OpenAPISource = void 0;
|
|
16
|
+
const _1 = require(".");
|
|
17
|
+
const swagger_parser_1 = __importDefault(require("@apidevtools/swagger-parser"));
|
|
18
|
+
const yaml = require("js-yaml");
|
|
19
|
+
class OpenAPISource extends _1.ImportSource {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.parseData = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
let json;
|
|
24
|
+
try {
|
|
25
|
+
json = JSON.parse(data);
|
|
26
|
+
}
|
|
27
|
+
catch (jsonErr) {
|
|
28
|
+
// couldn't parse json
|
|
29
|
+
// try to convert yaml -> json
|
|
30
|
+
try {
|
|
31
|
+
json = yaml.load(data);
|
|
32
|
+
}
|
|
33
|
+
catch (yamlErr) {
|
|
34
|
+
// couldn't parse yaml
|
|
35
|
+
throw new Error("Could not parse JSON or YAML");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return swagger_parser_1.default.validate(json, {});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.OpenAPISource = OpenAPISource;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Curl = void 0;
|
|
13
|
+
const base_1 = require("./base");
|
|
14
|
+
const url_1 = require("url");
|
|
15
|
+
const curlconverter = require("curlconverter");
|
|
16
|
+
const parseCurl = (data) => {
|
|
17
|
+
const curlJson = curlconverter.toJsonString(data);
|
|
18
|
+
return JSON.parse(curlJson);
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The curl converter parses the request body into the key field of an object
|
|
22
|
+
* e.g. --d '{"key":"val"}' produces an object { "{"key":"val"}" : "" }
|
|
23
|
+
* This is not what we want, so we need to parse out the key from the object
|
|
24
|
+
*/
|
|
25
|
+
const parseBody = (curl) => {
|
|
26
|
+
if (curl.data) {
|
|
27
|
+
const keys = Object.keys(curl.data);
|
|
28
|
+
if (keys.length) {
|
|
29
|
+
let key = keys[0];
|
|
30
|
+
try {
|
|
31
|
+
// filter out the dollar syntax used by curl for shell support
|
|
32
|
+
if (key.startsWith("$")) {
|
|
33
|
+
key = key.substring(1);
|
|
34
|
+
}
|
|
35
|
+
return JSON.parse(key);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
// do nothing
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
};
|
|
44
|
+
const parseCookie = (curl) => {
|
|
45
|
+
if (curl.cookies) {
|
|
46
|
+
return Object.entries(curl.cookies).reduce((acc, entry) => {
|
|
47
|
+
const [key, value] = entry;
|
|
48
|
+
return acc + `${key}=${value}; `;
|
|
49
|
+
}, "");
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Curl
|
|
55
|
+
* https://curl.se/docs/manpage.html
|
|
56
|
+
*/
|
|
57
|
+
class Curl extends base_1.ImportSource {
|
|
58
|
+
constructor() {
|
|
59
|
+
super(...arguments);
|
|
60
|
+
this.isSupported = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
try {
|
|
62
|
+
const curl = parseCurl(data);
|
|
63
|
+
this.curl = curl;
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
});
|
|
70
|
+
this.getUrl = () => {
|
|
71
|
+
return new url_1.URL(this.curl.raw_url);
|
|
72
|
+
};
|
|
73
|
+
this.getInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const url = this.getUrl();
|
|
75
|
+
return {
|
|
76
|
+
name: url.hostname,
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
this.getQueries = (datasourceId) => __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const url = this.getUrl();
|
|
81
|
+
const name = url.pathname;
|
|
82
|
+
const path = url.pathname;
|
|
83
|
+
const method = this.curl.method;
|
|
84
|
+
const queryString = url.search;
|
|
85
|
+
const headers = this.curl.headers;
|
|
86
|
+
const requestBody = parseBody(this.curl);
|
|
87
|
+
const cookieHeader = parseCookie(this.curl);
|
|
88
|
+
if (cookieHeader) {
|
|
89
|
+
headers["Cookie"] = cookieHeader;
|
|
90
|
+
}
|
|
91
|
+
const query = this.constructQuery(datasourceId, name, method, path, url, queryString, headers, [], requestBody);
|
|
92
|
+
return [query];
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.Curl = Curl;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OpenAPI2 = void 0;
|
|
13
|
+
const openapi_types_1 = require("openapi-types");
|
|
14
|
+
const openapi_1 = require("./base/openapi");
|
|
15
|
+
const url_1 = require("url");
|
|
16
|
+
const parameterNotRef = (param) => {
|
|
17
|
+
// all refs are deferenced by parser library
|
|
18
|
+
return true;
|
|
19
|
+
};
|
|
20
|
+
const isOpenAPI2 = (document) => {
|
|
21
|
+
if (document.swagger === "2.0") {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const methods = Object.values(openapi_types_1.OpenAPIV2.HttpMethods);
|
|
29
|
+
const isOperation = (key, pathItem) => {
|
|
30
|
+
return methods.includes(key);
|
|
31
|
+
};
|
|
32
|
+
const isParameter = (key, pathItem) => {
|
|
33
|
+
return !isOperation(key, pathItem);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* OpenAPI Version 2.0 - aka "Swagger"
|
|
37
|
+
* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md
|
|
38
|
+
*/
|
|
39
|
+
class OpenAPI2 extends openapi_1.OpenAPISource {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this.isSupported = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
try {
|
|
44
|
+
const document = yield this.parseData(data);
|
|
45
|
+
if (isOpenAPI2(document)) {
|
|
46
|
+
this.document = document;
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
this.getUrl = () => {
|
|
58
|
+
var _a;
|
|
59
|
+
const scheme = ((_a = this.document.schemes) === null || _a === void 0 ? void 0 : _a.includes("https")) ? "https" : "http";
|
|
60
|
+
const basePath = this.document.basePath || "";
|
|
61
|
+
const host = this.document.host || "<host>";
|
|
62
|
+
return new url_1.URL(`${scheme}://${host}${basePath}`);
|
|
63
|
+
};
|
|
64
|
+
this.getInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const name = this.document.info.title || "Swagger Import";
|
|
66
|
+
return {
|
|
67
|
+
name,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
this.getQueries = (datasourceId) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const url = this.getUrl();
|
|
72
|
+
const queries = [];
|
|
73
|
+
for (let [path, pathItem] of Object.entries(this.document.paths)) {
|
|
74
|
+
// parameters that apply to every operation in the path
|
|
75
|
+
let pathParams = [];
|
|
76
|
+
for (let [key, opOrParams] of Object.entries(pathItem)) {
|
|
77
|
+
if (isParameter(key, opOrParams)) {
|
|
78
|
+
const pathParameters = opOrParams;
|
|
79
|
+
pathParams.push(...pathParameters);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
// can not be a parameter, must be an operation
|
|
83
|
+
const operation = opOrParams;
|
|
84
|
+
const methodName = key;
|
|
85
|
+
const name = operation.operationId || path;
|
|
86
|
+
let queryString = "";
|
|
87
|
+
const headers = {};
|
|
88
|
+
let requestBody = undefined;
|
|
89
|
+
const parameters = [];
|
|
90
|
+
if (operation.consumes) {
|
|
91
|
+
headers["Content-Type"] = operation.consumes[0];
|
|
92
|
+
}
|
|
93
|
+
// combine the path parameters with the operation parameters
|
|
94
|
+
const operationParams = operation.parameters || [];
|
|
95
|
+
const allParams = [...pathParams, ...operationParams];
|
|
96
|
+
for (let param of allParams) {
|
|
97
|
+
if (parameterNotRef(param)) {
|
|
98
|
+
switch (param.in) {
|
|
99
|
+
case "query":
|
|
100
|
+
let prefix = "";
|
|
101
|
+
if (queryString) {
|
|
102
|
+
prefix = "&";
|
|
103
|
+
}
|
|
104
|
+
queryString = `${queryString}${prefix}${param.name}={{${param.name}}}`;
|
|
105
|
+
break;
|
|
106
|
+
case "header":
|
|
107
|
+
headers[param.name] = `{{${param.name}}}`;
|
|
108
|
+
break;
|
|
109
|
+
case "path":
|
|
110
|
+
// do nothing: param is already in the path
|
|
111
|
+
break;
|
|
112
|
+
case "formData":
|
|
113
|
+
// future enhancement
|
|
114
|
+
break;
|
|
115
|
+
case "body":
|
|
116
|
+
// set the request body to the example provided
|
|
117
|
+
// future enhancement: generate an example from the schema
|
|
118
|
+
let bodyParam = param;
|
|
119
|
+
if (param.schema.example) {
|
|
120
|
+
const schema = bodyParam.schema;
|
|
121
|
+
requestBody = schema.example;
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
// add the parameter if it can be bound in our config
|
|
126
|
+
if (["query", "header", "path"].includes(param.in)) {
|
|
127
|
+
parameters.push({
|
|
128
|
+
name: param.name,
|
|
129
|
+
default: param.default || "",
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const query = this.constructQuery(datasourceId, name, methodName, path, url, queryString, headers, parameters, requestBody);
|
|
135
|
+
queries.push(query);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return queries;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.OpenAPI2 = OpenAPI2;
|