@scalar/api-client 2.39.3 → 2.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/components/AddressBar/AddressBarHistory.vue.d.ts.map +1 -1
- package/dist/components/AddressBar/AddressBarHistory.vue.js +1 -1
- package/dist/components/AddressBar/AddressBarHistory.vue.js.map +1 -1
- package/dist/components/AddressBar/AddressBarHistory.vue.script.js +2 -2
- package/dist/components/AddressBar/AddressBarHistory.vue.script.js.map +1 -1
- package/dist/hooks/useClientConfig.d.ts +12 -0
- package/dist/hooks/useClientConfig.d.ts.map +1 -1
- package/dist/hooks/useClientConfig.js +14 -1
- package/dist/hooks/useClientConfig.js.map +1 -1
- package/dist/hooks/useResponseBody.js +2 -2
- package/dist/hooks/useResponseBody.js.map +1 -1
- package/dist/libs/index.d.ts +0 -1
- package/dist/libs/index.d.ts.map +1 -1
- package/dist/libs/index.js +1 -2
- package/dist/libs/send-request/decode-buffer.js +2 -2
- package/dist/libs/send-request/decode-buffer.js.map +1 -1
- package/dist/style.css +222 -263
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +14 -10
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +57 -35
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/decode-buffer.js +2 -2
- package/dist/v2/blocks/operation-block/helpers/decode-buffer.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts +1 -5
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.js +18 -33
- package/dist/v2/blocks/operation-block/helpers/send-request.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js +1 -1
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js.map +1 -1
- package/dist/v2/blocks/operation-block/index.d.ts +0 -3
- package/dist/v2/blocks/operation-block/index.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/index.js +1 -4
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js +3 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts +4 -2
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js +3 -2
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.js +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts +7 -2
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js +4 -3
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js +2 -3
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts +3 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +5 -8
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/index.d.ts +0 -1
- package/dist/v2/blocks/operation-code-sample/index.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/index.js +2 -3
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +7 -9
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js +49 -42
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js +2 -3
- package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js +1 -0
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js +11 -9
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js +1 -1
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts +1 -1
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.js +2 -1
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.js.map +1 -1
- package/dist/v2/blocks/response-block/helpers/get-content-length.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/helpers/get-content-length.js +2 -2
- package/dist/v2/blocks/response-block/helpers/get-content-length.js.map +1 -1
- package/dist/v2/blocks/response-block/helpers/process-response-body.js +2 -2
- package/dist/v2/blocks/response-block/helpers/process-response-body.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.script.js +76 -25
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.script.js +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js +8 -4
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.js +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +6 -2
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts +0 -3
- package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/index.js +1 -3
- package/dist/v2/components/code-input/CodeInput.vue.d.ts +16 -8
- package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.script.js +15 -10
- package/dist/v2/components/code-input/CodeInput.vue.script.js.map +1 -1
- package/dist/v2/constants.js +1 -1
- package/dist/v2/features/app/App.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.js.map +1 -1
- package/dist/v2/features/app/App.vue.script.js +1 -5
- package/dist/v2/features/app/App.vue.script.js.map +1 -1
- package/dist/v2/features/app/app-events.d.ts.map +1 -1
- package/dist/v2/features/app/app-events.js +1 -1
- package/dist/v2/features/app/app-events.js.map +1 -1
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +2 -2
- package/dist/v2/features/app/app-state.js.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.script.js +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.script.js.map +1 -1
- package/dist/v2/features/app/helpers/routes.d.ts +0 -3
- package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/routes.js +1 -1
- package/dist/v2/features/app/helpers/routes.js.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.js.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.script.js +30 -52
- package/dist/v2/features/collection/DocumentCollection.vue.script.js.map +1 -1
- package/dist/v2/features/collection/OperationCollection.vue.script.js +0 -1
- package/dist/v2/features/collection/OperationCollection.vue.script.js.map +1 -1
- package/dist/v2/features/collection/WorkspaceCollection.vue.script.js +0 -1
- package/dist/v2/features/collection/WorkspaceCollection.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.js +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.js.map +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.script.js +6 -8
- package/dist/v2/features/collection/components/Authentication.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Cookies.vue.script.js +0 -1
- package/dist/v2/features/collection/components/Cookies.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Editor/Editor.vue.script.js +0 -1
- package/dist/v2/features/collection/components/Editor/Editor.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Environment.vue.script.js +0 -1
- package/dist/v2/features/collection/components/Environment.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Overview.vue.script.js +0 -1
- package/dist/v2/features/collection/components/Overview.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Servers.vue.script.js +0 -1
- package/dist/v2/features/collection/components/Servers.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Settings.vue.js.map +1 -1
- package/dist/v2/features/collection/components/Settings.vue.script.js +2 -3
- package/dist/v2/features/collection/components/Settings.vue.script.js.map +1 -1
- package/dist/v2/features/editor/hooks/use-three-way-merge-editor.js +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.d.ts.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.js.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
- package/dist/v2/features/modal/Modal.vue.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.script.js +3 -4
- package/dist/v2/features/modal/Modal.vue.script.js.map +1 -1
- package/dist/v2/features/modal/helpers/map-hidden-clients-config.js +1 -1
- package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.js.map +1 -1
- package/dist/v2/features/operation/Operation.vue.script.js +50 -84
- package/dist/v2/features/operation/Operation.vue.script.js.map +1 -1
- package/dist/v2/features/operation/index.d.ts +0 -4
- package/dist/v2/features/operation/index.d.ts.map +1 -1
- package/dist/v2/features/operation/index.js +1 -5
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.script.js +11 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.script.js.map +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.js +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.js.map +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.script.js +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.script.js.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue.script.js +1 -1
- package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.js.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.script.js +2 -2
- package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.script.js.map +1 -1
- package/dist/views/Request/libs/oauth2.js +1 -1
- package/dist/views/Request/libs/oauth2.js.map +1 -1
- package/package.json +25 -31
- package/dist/libs/formatters.d.ts +0 -12
- package/dist/libs/formatters.d.ts.map +0 -1
- package/dist/libs/formatters.js +0 -36
- package/dist/libs/formatters.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.d.ts +0 -6
- package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.js +0 -58
- package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts +0 -12
- package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-body.js +0 -65
- package/dist/v2/blocks/operation-block/helpers/build-request-body.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts +0 -31
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.js +0 -55
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts +0 -27
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js +0 -159
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-security.d.ts +0 -25
- package/dist/v2/blocks/operation-block/helpers/build-request-security.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-security.js +0 -53
- package/dist/v2/blocks/operation-block/helpers/build-request-security.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts +0 -46
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.js +0 -102
- package/dist/v2/blocks/operation-block/helpers/build-request.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.d.ts +0 -4
- package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.js +0 -41
- package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.d.ts +0 -14
- package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.js +0 -20
- package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-delimiter.d.ts +0 -8
- package/dist/v2/blocks/operation-block/helpers/get-delimiter.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-environment-variables.d.ts +0 -9
- package/dist/v2/blocks/operation-block/helpers/get-environment-variables.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-environment-variables.js +0 -17
- package/dist/v2/blocks/operation-block/helpers/get-environment-variables.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-example.d.ts +0 -10
- package/dist/v2/blocks/operation-block/helpers/get-example.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-example.js +0 -41
- package/dist/v2/blocks/operation-block/helpers/get-example.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-resolved-url.d.ts +0 -26
- package/dist/v2/blocks/operation-block/helpers/get-resolved-url.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-resolved-url.js +0 -32
- package/dist/v2/blocks/operation-block/helpers/get-resolved-url.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.d.ts +0 -10
- package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.js +0 -15
- package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-server-url.d.ts +0 -3
- package/dist/v2/blocks/operation-block/helpers/get-server-url.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-server-url.js +0 -18
- package/dist/v2/blocks/operation-block/helpers/get-server-url.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/serialize-parameter.d.ts +0 -96
- package/dist/v2/blocks/operation-block/helpers/serialize-parameter.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/serialize-parameter.js +0 -160
- package/dist/v2/blocks/operation-block/helpers/serialize-parameter.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts +0 -40
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.js +0 -437
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.js.map +0 -1
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.d.ts +0 -6
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.d.ts.map +0 -1
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.js +0 -25
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.js.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.js +0 -141
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.js.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.d.ts +0 -4
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.d.ts.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.js +0 -10
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.js.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.d.ts +0 -9
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.d.ts.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.js +0 -27
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.js.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/secret-types.d.ts +0 -25
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/secret-types.d.ts.map +0 -1
- package/dist/v2/components/callout/Callout.vue.js +0 -9
- package/dist/v2/components/callout/Callout.vue.js.map +0 -1
- package/dist/v2/components/callout/Callout.vue.script.js +0 -35
- package/dist/v2/components/callout/Callout.vue.script.js.map +0 -1
- package/dist/v2/features/operation/helpers/combine-params.d.ts +0 -4
- package/dist/v2/features/operation/helpers/combine-params.d.ts.map +0 -1
- package/dist/v2/features/operation/helpers/combine-params.js +0 -20
- package/dist/v2/features/operation/helpers/combine-params.js.map +0 -1
- package/dist/v2/features/operation/helpers/get-operation-header.d.ts +0 -17
- package/dist/v2/features/operation/helpers/get-operation-header.d.ts.map +0 -1
- package/dist/v2/features/operation/helpers/get-security-requirements.d.ts +0 -12
- package/dist/v2/features/operation/helpers/get-security-requirements.d.ts.map +0 -1
- package/dist/v2/features/operation/helpers/get-security-requirements.js +0 -17
- package/dist/v2/features/operation/helpers/get-security-requirements.js.map +0 -1
- package/dist/v2/features/operation/helpers/get-selected-security.d.ts +0 -15
- package/dist/v2/features/operation/helpers/get-selected-security.d.ts.map +0 -1
- package/dist/v2/features/operation/helpers/get-selected-security.js +0 -41
- package/dist/v2/features/operation/helpers/get-selected-security.js.map +0 -1
- package/dist/v2/features/operation/helpers/get-selected-server.d.ts +0 -13
- package/dist/v2/features/operation/helpers/get-selected-server.d.ts.map +0 -1
- package/dist/v2/features/operation/helpers/get-selected-server.js +0 -21
- package/dist/v2/features/operation/helpers/get-selected-server.js.map +0 -1
- package/dist/v2/helpers/get-active-environment.d.ts +0 -5
- package/dist/v2/helpers/get-active-environment.d.ts.map +0 -1
- package/dist/v2/helpers/get-active-environment.js +0 -19
- package/dist/v2/helpers/get-active-environment.js.map +0 -1
- package/dist/v2/helpers/get-active-proxy-url.d.ts +0 -18
- package/dist/v2/helpers/get-active-proxy-url.d.ts.map +0 -1
- package/dist/v2/helpers/get-active-proxy-url.js +0 -26
- package/dist/v2/helpers/get-active-proxy-url.js.map +0 -1
- package/dist/v2/helpers/get-servers.d.ts +0 -23
- package/dist/v2/helpers/get-servers.d.ts.map +0 -1
- package/dist/v2/helpers/get-servers.js +0 -106
- package/dist/v2/helpers/get-servers.js.map +0 -1
- package/dist/v2/helpers/index.d.ts +0 -3
- package/dist/v2/helpers/index.d.ts.map +0 -1
- package/dist/v2/helpers/index.js +0 -3
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
//#region src/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.ts
|
|
2
|
-
/**
|
|
3
|
-
* Reserved characters we can safely decode in query values when OpenAPI
|
|
4
|
-
* `allowReserved` is enabled.
|
|
5
|
-
*
|
|
6
|
-
* We intentionally keep percent-encodings for characters that can break query
|
|
7
|
-
* parsing (`#`, `&`, `=`, `?`, `[`, `]`) or change x-www-form-urlencoded
|
|
8
|
-
* semantics (`+`).
|
|
9
|
-
*
|
|
10
|
-
* @see https://spec.openapis.org/oas/v3.1.0.html#fixed-fields-10
|
|
11
|
-
*/
|
|
12
|
-
var DECODABLE_RESERVED_CHARACTERS_BY_PERCENT_ENCODING = {
|
|
13
|
-
"21": "!",
|
|
14
|
-
"24": "$",
|
|
15
|
-
"27": "'",
|
|
16
|
-
"28": "(",
|
|
17
|
-
"29": ")",
|
|
18
|
-
"2A": "*",
|
|
19
|
-
"2C": ",",
|
|
20
|
-
"2F": "/",
|
|
21
|
-
"3A": ":",
|
|
22
|
-
"3B": ";",
|
|
23
|
-
"40": "@"
|
|
24
|
-
};
|
|
25
|
-
var decodeReservedCharacters = (value) => value.replace(/%([0-9A-Fa-f]{2})/g, (match, code) => DECODABLE_RESERVED_CHARACTERS_BY_PERCENT_ENCODING[code.toUpperCase()] ?? match);
|
|
26
|
-
var decodeQueryKey = (key) => {
|
|
27
|
-
try {
|
|
28
|
-
return decodeURIComponent(key.replaceAll("+", "%20"));
|
|
29
|
-
} catch {
|
|
30
|
-
return key;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Decodes reserved character percent-encodings only for query keys marked with
|
|
35
|
-
* OpenAPI's `allowReserved: true`.
|
|
36
|
-
*/
|
|
37
|
-
var applyAllowReservedToUrl = (url, allowReservedQueryParameters) => {
|
|
38
|
-
if (allowReservedQueryParameters.size === 0) return url;
|
|
39
|
-
const queryStart = url.indexOf("?");
|
|
40
|
-
if (queryStart === -1) return url;
|
|
41
|
-
const hashStart = url.indexOf("#", queryStart);
|
|
42
|
-
const urlPrefix = url.slice(0, queryStart + 1);
|
|
43
|
-
const query = hashStart === -1 ? url.slice(queryStart + 1) : url.slice(queryStart + 1, hashStart);
|
|
44
|
-
const hash = hashStart === -1 ? "" : url.slice(hashStart);
|
|
45
|
-
if (!query) return url;
|
|
46
|
-
return `${urlPrefix}${query.split("&").map((segment) => {
|
|
47
|
-
if (!segment) return segment;
|
|
48
|
-
const equalsIndex = segment.indexOf("=");
|
|
49
|
-
const rawKey = equalsIndex === -1 ? segment : segment.slice(0, equalsIndex);
|
|
50
|
-
const key = decodeQueryKey(rawKey);
|
|
51
|
-
if (!allowReservedQueryParameters.has(key) || equalsIndex === -1) return segment;
|
|
52
|
-
return `${rawKey}=${decodeReservedCharacters(segment.slice(equalsIndex + 1))}`;
|
|
53
|
-
}).join("&")}${hash}`;
|
|
54
|
-
};
|
|
55
|
-
//#endregion
|
|
56
|
-
export { applyAllowReservedToUrl };
|
|
57
|
-
|
|
58
|
-
//# sourceMappingURL=apply-allow-reserved-to-url.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apply-allow-reserved-to-url.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.ts"],"sourcesContent":["/**\n * Reserved characters we can safely decode in query values when OpenAPI\n * `allowReserved` is enabled.\n *\n * We intentionally keep percent-encodings for characters that can break query\n * parsing (`#`, `&`, `=`, `?`, `[`, `]`) or change x-www-form-urlencoded\n * semantics (`+`).\n *\n * @see https://spec.openapis.org/oas/v3.1.0.html#fixed-fields-10\n */\nconst DECODABLE_RESERVED_CHARACTERS_BY_PERCENT_ENCODING: Record<string, string> = {\n '21': '!',\n '24': '$',\n '27': \"'\",\n '28': '(',\n '29': ')',\n '2A': '*',\n '2C': ',',\n '2F': '/',\n '3A': ':',\n '3B': ';',\n '40': '@',\n}\n\nconst decodeReservedCharacters = (value: string): string =>\n value.replace(\n /%([0-9A-Fa-f]{2})/g,\n (match, code: string) => DECODABLE_RESERVED_CHARACTERS_BY_PERCENT_ENCODING[code.toUpperCase()] ?? match,\n )\n\nconst decodeQueryKey = (key: string): string => {\n try {\n return decodeURIComponent(key.replaceAll('+', '%20'))\n } catch {\n return key\n }\n}\n\n/**\n * Decodes reserved character percent-encodings only for query keys marked with\n * OpenAPI's `allowReserved: true`.\n */\nexport const applyAllowReservedToUrl = (url: string, allowReservedQueryParameters: Set<string>): string => {\n if (allowReservedQueryParameters.size === 0) {\n return url\n }\n\n const queryStart = url.indexOf('?')\n if (queryStart === -1) {\n return url\n }\n\n const hashStart = url.indexOf('#', queryStart)\n const urlPrefix = url.slice(0, queryStart + 1)\n const query = hashStart === -1 ? url.slice(queryStart + 1) : url.slice(queryStart + 1, hashStart)\n const hash = hashStart === -1 ? '' : url.slice(hashStart)\n\n if (!query) {\n return url\n }\n\n const decodedQuery = query\n .split('&')\n .map((segment) => {\n if (!segment) {\n return segment\n }\n\n const equalsIndex = segment.indexOf('=')\n const rawKey = equalsIndex === -1 ? segment : segment.slice(0, equalsIndex)\n const key = decodeQueryKey(rawKey)\n\n if (!allowReservedQueryParameters.has(key) || equalsIndex === -1) {\n return segment\n }\n\n const rawValue = segment.slice(equalsIndex + 1)\n return `${rawKey}=${decodeReservedCharacters(rawValue)}`\n })\n .join('&')\n\n return `${urlPrefix}${decodedQuery}${hash}`\n}\n"],"mappings":";;;;;;;;;;;AAUA,IAAM,oDAA4E;CAChF,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACP;AAED,IAAM,4BAA4B,UAChC,MAAM,QACJ,uBACC,OAAO,SAAiB,kDAAkD,KAAK,aAAa,KAAK,MACnG;AAEH,IAAM,kBAAkB,QAAwB;AAC9C,KAAI;AACF,SAAO,mBAAmB,IAAI,WAAW,KAAK,MAAM,CAAC;SAC/C;AACN,SAAO;;;;;;;AAQX,IAAa,2BAA2B,KAAa,iCAAsD;AACzG,KAAI,6BAA6B,SAAS,EACxC,QAAO;CAGT,MAAM,aAAa,IAAI,QAAQ,IAAI;AACnC,KAAI,eAAe,GACjB,QAAO;CAGT,MAAM,YAAY,IAAI,QAAQ,KAAK,WAAW;CAC9C,MAAM,YAAY,IAAI,MAAM,GAAG,aAAa,EAAE;CAC9C,MAAM,QAAQ,cAAc,KAAK,IAAI,MAAM,aAAa,EAAE,GAAG,IAAI,MAAM,aAAa,GAAG,UAAU;CACjG,MAAM,OAAO,cAAc,KAAK,KAAK,IAAI,MAAM,UAAU;AAEzD,KAAI,CAAC,MACH,QAAO;AAuBT,QAAO,GAAG,YApBW,MAClB,MAAM,IAAI,CACV,KAAK,YAAY;AAChB,MAAI,CAAC,QACH,QAAO;EAGT,MAAM,cAAc,QAAQ,QAAQ,IAAI;EACxC,MAAM,SAAS,gBAAgB,KAAK,UAAU,QAAQ,MAAM,GAAG,YAAY;EAC3E,MAAM,MAAM,eAAe,OAAO;AAElC,MAAI,CAAC,6BAA6B,IAAI,IAAI,IAAI,gBAAgB,GAC5D,QAAO;AAIT,SAAO,GAAG,OAAO,GAAG,yBADH,QAAQ,MAAM,cAAc,EAAE,CACO;GACtD,CACD,KAAK,IAAI,GAEyB"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.1/strict/request-body';
|
|
2
|
-
/**
|
|
3
|
-
* Create the fetch request body
|
|
4
|
-
*/
|
|
5
|
-
export declare const buildRequestBody: (requestBody: RequestBodyObject | undefined,
|
|
6
|
-
/** Environment variables flattened into a key-value object */
|
|
7
|
-
env?: Record<string, string>,
|
|
8
|
-
/** The key of the current example */
|
|
9
|
-
exampleKey?: string,
|
|
10
|
-
/** Selected anyOf/oneOf request-body variants keyed by schema path */
|
|
11
|
-
requestBodyCompositionSelection?: Record<string, number>) => BodyInit | null;
|
|
12
|
-
//# sourceMappingURL=build-request-body.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request-body.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAyBjG;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,iBAAiB,GAAG,SAAS;AAC1C,8DAA8D;AAC9D,MAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;AAChC,qCAAqC;AACrC,mBAAsB;AACtB,sEAAsE;AACtE,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvD,QAAQ,GAAG,IAyGb,CAAA"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { getSelectedBodyContentType } from "./get-selected-body-content-type.js";
|
|
2
|
-
import { getExampleFromBody } from "../../request-block/helpers/get-request-body-example.js";
|
|
3
|
-
import { replaceEnvVariables } from "@scalar/helpers/regex/replace-variables";
|
|
4
|
-
import { unpackProxyObject } from "@scalar/workspace-store/helpers/unpack-proxy";
|
|
5
|
-
//#region src/v2/blocks/operation-block/helpers/build-request-body.ts
|
|
6
|
-
var getMultipartEncodingContentType = (requestBody, bodyContentType, fieldName, replacedFieldName) => requestBody.content[bodyContentType]?.encoding?.[fieldName]?.contentType ?? requestBody.content[bodyContentType]?.encoding?.[replacedFieldName]?.contentType;
|
|
7
|
-
var serializeMultipartValue = (value, env) => {
|
|
8
|
-
if (typeof value === "string") return replaceEnvVariables(value, env);
|
|
9
|
-
return replaceEnvVariables(typeof value === "object" && value !== null ? JSON.stringify(unpackProxyObject(value)) : String(value), env);
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Create the fetch request body
|
|
13
|
-
*/
|
|
14
|
-
var buildRequestBody = (requestBody, env = {}, exampleKey = "default", requestBodyCompositionSelection) => {
|
|
15
|
-
if (!requestBody) return null;
|
|
16
|
-
/** Selected content type for the body from the dropdown, stored as x-scalar-selected-content-type */
|
|
17
|
-
const bodyContentType = getSelectedBodyContentType(requestBody, exampleKey);
|
|
18
|
-
if (!bodyContentType) return null;
|
|
19
|
-
/** An example value or generated example from the schema */
|
|
20
|
-
const example = getExampleFromBody(requestBody, bodyContentType, exampleKey, requestBodyCompositionSelection);
|
|
21
|
-
if (!example) return null;
|
|
22
|
-
if ((bodyContentType === "multipart/form-data" || bodyContentType === "application/x-www-form-urlencoded") && Array.isArray(example.value)) {
|
|
23
|
-
const exampleValue = example.value.filter((item) => !item.isDisabled);
|
|
24
|
-
const form = bodyContentType === "multipart/form-data" ? new FormData() : new URLSearchParams();
|
|
25
|
-
exampleValue.forEach(({ name, value }) => {
|
|
26
|
-
if (!name) return;
|
|
27
|
-
const replacedName = replaceEnvVariables(name, env);
|
|
28
|
-
const partContentType = form instanceof FormData ? getMultipartEncodingContentType(requestBody, bodyContentType, name, replacedName) : void 0;
|
|
29
|
-
if (value instanceof File && form instanceof FormData) {
|
|
30
|
-
/**
|
|
31
|
-
* We need to unwrap the proxies to get the file name due to the
|
|
32
|
-
* "this" context in the proxy causing an illegal invocation error
|
|
33
|
-
*/
|
|
34
|
-
const unwrappedValue = unpackProxyObject(value);
|
|
35
|
-
const encodedValue = partContentType && partContentType !== unwrappedValue.type ? new File([unwrappedValue], unwrappedValue.name, {
|
|
36
|
-
type: partContentType,
|
|
37
|
-
lastModified: unwrappedValue.lastModified
|
|
38
|
-
}) : unwrappedValue;
|
|
39
|
-
form.append(replacedName, encodedValue, encodedValue.name);
|
|
40
|
-
} else if (value !== void 0 && value !== null) {
|
|
41
|
-
const serializedValue = serializeMultipartValue(value, env);
|
|
42
|
-
if (form instanceof FormData && partContentType) form.append(replacedName, new Blob([serializedValue], { type: partContentType }));
|
|
43
|
-
else form.append(replacedName, serializedValue);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return form;
|
|
47
|
-
}
|
|
48
|
-
if (bodyContentType === "application/x-www-form-urlencoded" && example.value !== null && typeof example.value === "object" && !Array.isArray(example.value)) {
|
|
49
|
-
const form = new URLSearchParams();
|
|
50
|
-
for (const [key, value] of Object.entries(example.value)) if (key && value !== void 0 && value !== null) {
|
|
51
|
-
const replacedKey = replaceEnvVariables(key, env);
|
|
52
|
-
const stringValue = typeof value === "string" ? value : String(value);
|
|
53
|
-
form.append(replacedKey, replaceEnvVariables(stringValue, env));
|
|
54
|
-
}
|
|
55
|
-
return form;
|
|
56
|
-
}
|
|
57
|
-
const exampleValue = example.value !== null && typeof example.value === "object" ? unpackProxyObject(example.value) : example.value;
|
|
58
|
-
if (exampleValue instanceof File) return exampleValue;
|
|
59
|
-
if (typeof exampleValue === "object") return replaceEnvVariables(JSON.stringify(exampleValue), env);
|
|
60
|
-
return typeof exampleValue === "string" ? replaceEnvVariables(exampleValue, env) : exampleValue;
|
|
61
|
-
};
|
|
62
|
-
//#endregion
|
|
63
|
-
export { buildRequestBody };
|
|
64
|
-
|
|
65
|
-
//# sourceMappingURL=build-request-body.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-body.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request-body.ts"],"sourcesContent":["import { replaceEnvVariables } from '@scalar/helpers/regex/replace-variables'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.1/strict/request-body'\n\nimport { getSelectedBodyContentType } from '@/v2/blocks/operation-block/helpers/get-selected-body-content-type'\nimport { getExampleFromBody } from '@/v2/blocks/request-block/helpers/get-request-body-example'\n\nconst getMultipartEncodingContentType = (\n requestBody: RequestBodyObject,\n bodyContentType: string,\n fieldName: string,\n replacedFieldName: string,\n) =>\n requestBody.content[bodyContentType]?.encoding?.[fieldName]?.contentType ??\n requestBody.content[bodyContentType]?.encoding?.[replacedFieldName]?.contentType\n\nconst serializeMultipartValue = (value: unknown, env: Record<string, string>) => {\n if (typeof value === 'string') {\n return replaceEnvVariables(value, env)\n }\n\n const serializedValue =\n typeof value === 'object' && value !== null ? JSON.stringify(unpackProxyObject(value)) : String(value)\n\n return replaceEnvVariables(serializedValue, env)\n}\n\n/**\n * Create the fetch request body\n */\nexport const buildRequestBody = (\n requestBody: RequestBodyObject | undefined,\n /** Environment variables flattened into a key-value object */\n env: Record<string, string> = {},\n /** The key of the current example */\n exampleKey = 'default',\n /** Selected anyOf/oneOf request-body variants keyed by schema path */\n requestBodyCompositionSelection?: Record<string, number>,\n): BodyInit | null => {\n if (!requestBody) {\n return null\n }\n\n /** Selected content type for the body from the dropdown, stored as x-scalar-selected-content-type */\n const bodyContentType = getSelectedBodyContentType(requestBody, exampleKey)\n if (!bodyContentType) {\n return null\n }\n\n /** An example value or generated example from the schema */\n const example = getExampleFromBody(requestBody, bodyContentType, exampleKey, requestBodyCompositionSelection)\n if (!example) {\n return null\n }\n\n // Form data - array format (from UI editor)\n if (\n (bodyContentType === 'multipart/form-data' || bodyContentType === 'application/x-www-form-urlencoded') &&\n Array.isArray(example.value)\n ) {\n const exampleValue = example.value.filter((item) => !item.isDisabled) as { name: string; value: unknown }[]\n const form = bodyContentType === 'multipart/form-data' ? new FormData() : new URLSearchParams()\n\n // Loop over all entries and add them to the form\n exampleValue.forEach(({ name, value }) => {\n if (!name) {\n return\n }\n const replacedName = replaceEnvVariables(name, env)\n const partContentType =\n form instanceof FormData\n ? getMultipartEncodingContentType(requestBody, bodyContentType, name, replacedName)\n : undefined\n\n // Handle file uploads\n if (value instanceof File && form instanceof FormData) {\n /**\n * We need to unwrap the proxies to get the file name due to the\n * \"this\" context in the proxy causing an illegal invocation error\n */\n const unwrappedValue = unpackProxyObject(value)\n const encodedValue =\n partContentType && partContentType !== unwrappedValue.type\n ? new File([unwrappedValue], unwrappedValue.name, {\n type: partContentType,\n lastModified: unwrappedValue.lastModified,\n })\n : unwrappedValue\n\n form.append(replacedName, encodedValue, encodedValue.name)\n }\n // Text and structured inputs\n else if (value !== undefined && value !== null) {\n const serializedValue = serializeMultipartValue(value, env)\n\n if (form instanceof FormData && partContentType) {\n form.append(replacedName, new Blob([serializedValue], { type: partContentType }))\n } else {\n form.append(replacedName, serializedValue)\n }\n }\n })\n\n return form\n }\n\n // Form data - object format (from schema examples)\n // When the example value is a plain object and content type is form-urlencoded,\n // convert to URLSearchParams instead of JSON stringifying\n if (\n bodyContentType === 'application/x-www-form-urlencoded' &&\n example.value !== null &&\n typeof example.value === 'object' &&\n !Array.isArray(example.value)\n ) {\n const form = new URLSearchParams()\n\n // Convert object properties to form fields\n for (const [key, value] of Object.entries(example.value)) {\n if (key && value !== undefined && value !== null) {\n const replacedKey = replaceEnvVariables(key, env)\n const stringValue = typeof value === 'string' ? value : String(value)\n form.append(replacedKey, replaceEnvVariables(stringValue, env))\n }\n }\n\n return form\n }\n\n const exampleValue =\n example.value !== null && typeof example.value === 'object' ? unpackProxyObject(example.value) : example.value\n\n if (exampleValue instanceof File) {\n return exampleValue\n }\n\n // Ensure we stringify the example value if it is an object\n if (typeof exampleValue === 'object') {\n return replaceEnvVariables(JSON.stringify(exampleValue), env)\n }\n\n // Return binary or string values\n return typeof exampleValue === 'string' ? replaceEnvVariables(exampleValue, env) : exampleValue\n}\n"],"mappings":";;;;;AAOA,IAAM,mCACJ,aACA,iBACA,WACA,sBAEA,YAAY,QAAQ,kBAAkB,WAAW,YAAY,eAC7D,YAAY,QAAQ,kBAAkB,WAAW,oBAAoB;AAEvE,IAAM,2BAA2B,OAAgB,QAAgC;AAC/E,KAAI,OAAO,UAAU,SACnB,QAAO,oBAAoB,OAAO,IAAI;AAMxC,QAAO,oBAFL,OAAO,UAAU,YAAY,UAAU,OAAO,KAAK,UAAU,kBAAkB,MAAM,CAAC,GAAG,OAAO,MAAM,EAE5D,IAAI;;;;;AAMlD,IAAa,oBACX,aAEA,MAA8B,EAAE,EAEhC,aAAa,WAEb,oCACoB;AACpB,KAAI,CAAC,YACH,QAAO;;CAIT,MAAM,kBAAkB,2BAA2B,aAAa,WAAW;AAC3E,KAAI,CAAC,gBACH,QAAO;;CAIT,MAAM,UAAU,mBAAmB,aAAa,iBAAiB,YAAY,gCAAgC;AAC7G,KAAI,CAAC,QACH,QAAO;AAIT,MACG,oBAAoB,yBAAyB,oBAAoB,wCAClE,MAAM,QAAQ,QAAQ,MAAM,EAC5B;EACA,MAAM,eAAe,QAAQ,MAAM,QAAQ,SAAS,CAAC,KAAK,WAAW;EACrE,MAAM,OAAO,oBAAoB,wBAAwB,IAAI,UAAU,GAAG,IAAI,iBAAiB;AAG/F,eAAa,SAAS,EAAE,MAAM,YAAY;AACxC,OAAI,CAAC,KACH;GAEF,MAAM,eAAe,oBAAoB,MAAM,IAAI;GACnD,MAAM,kBACJ,gBAAgB,WACZ,gCAAgC,aAAa,iBAAiB,MAAM,aAAa,GACjF,KAAA;AAGN,OAAI,iBAAiB,QAAQ,gBAAgB,UAAU;;;;;IAKrD,MAAM,iBAAiB,kBAAkB,MAAM;IAC/C,MAAM,eACJ,mBAAmB,oBAAoB,eAAe,OAClD,IAAI,KAAK,CAAC,eAAe,EAAE,eAAe,MAAM;KAC9C,MAAM;KACN,cAAc,eAAe;KAC9B,CAAC,GACF;AAEN,SAAK,OAAO,cAAc,cAAc,aAAa,KAAK;cAGnD,UAAU,KAAA,KAAa,UAAU,MAAM;IAC9C,MAAM,kBAAkB,wBAAwB,OAAO,IAAI;AAE3D,QAAI,gBAAgB,YAAY,gBAC9B,MAAK,OAAO,cAAc,IAAI,KAAK,CAAC,gBAAgB,EAAE,EAAE,MAAM,iBAAiB,CAAC,CAAC;QAEjF,MAAK,OAAO,cAAc,gBAAgB;;IAG9C;AAEF,SAAO;;AAMT,KACE,oBAAoB,uCACpB,QAAQ,UAAU,QAClB,OAAO,QAAQ,UAAU,YACzB,CAAC,MAAM,QAAQ,QAAQ,MAAM,EAC7B;EACA,MAAM,OAAO,IAAI,iBAAiB;AAGlC,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,MAAM,CACtD,KAAI,OAAO,UAAU,KAAA,KAAa,UAAU,MAAM;GAChD,MAAM,cAAc,oBAAoB,KAAK,IAAI;GACjD,MAAM,cAAc,OAAO,UAAU,WAAW,QAAQ,OAAO,MAAM;AACrE,QAAK,OAAO,aAAa,oBAAoB,aAAa,IAAI,CAAC;;AAInE,SAAO;;CAGT,MAAM,eACJ,QAAQ,UAAU,QAAQ,OAAO,QAAQ,UAAU,WAAW,kBAAkB,QAAQ,MAAM,GAAG,QAAQ;AAE3G,KAAI,wBAAwB,KAC1B,QAAO;AAIT,KAAI,OAAO,iBAAiB,SAC1B,QAAO,oBAAoB,KAAK,UAAU,aAAa,EAAE,IAAI;AAI/D,QAAO,OAAO,iBAAiB,WAAW,oBAAoB,cAAc,IAAI,GAAG"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
2
|
-
/**
|
|
3
|
-
* Generate a cookie header from the cookie params
|
|
4
|
-
*/
|
|
5
|
-
export declare const getCookieHeader: (cookieParams: XScalarCookie[], originalCookieHeader: string | undefined) => string;
|
|
6
|
-
/**
|
|
7
|
-
* Build out the cookies header taking in global, param and security scheme cookies
|
|
8
|
-
*/
|
|
9
|
-
export declare const buildRequestCookieHeader: ({ paramCookies, globalCookies, env, originalCookieHeader, url, useCustomCookieHeader, disabledGlobalCookies, }: {
|
|
10
|
-
/** Parsed/replaced cookies from the parameters and security schemes */
|
|
11
|
-
paramCookies: XScalarCookie[];
|
|
12
|
-
/** Raw global cookies from the workspace/document */
|
|
13
|
-
globalCookies: XScalarCookie[];
|
|
14
|
-
/** Environment variables flattened into a key-value object */
|
|
15
|
-
env: Record<string, string>;
|
|
16
|
-
/** Cookie header that previously exists from the spec OR from the user */
|
|
17
|
-
originalCookieHeader: string | undefined | null;
|
|
18
|
-
/** The url of the request used to filter global cookies by domain */
|
|
19
|
-
url: string;
|
|
20
|
-
/**
|
|
21
|
-
* If we are running in Electron or using the proxy, we need to add a custom header
|
|
22
|
-
* that's then forwarded as a `Cookie` header.
|
|
23
|
-
*/
|
|
24
|
-
useCustomCookieHeader: boolean;
|
|
25
|
-
/** The disabled global cookies for the current example */
|
|
26
|
-
disabledGlobalCookies: Record<string, boolean>;
|
|
27
|
-
}) => null | {
|
|
28
|
-
name: string;
|
|
29
|
-
value: string;
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=build-request-cookie-header.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-cookie-header.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request-cookie-header.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,qEAAqE,CAAA;AAa5E;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,cAAc,aAAa,EAAE,EAAE,sBAAsB,MAAM,GAAG,SAAS,KAAG,MAWzG,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,gHAQtC;IACD,uEAAuE;IACvE,YAAY,EAAE,aAAa,EAAE,CAAA;IAC7B,qDAAqD;IACrD,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3B,0EAA0E;IAC1E,oBAAoB,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;IAC/C,qEAAqE;IACrE,GAAG,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,qBAAqB,EAAE,OAAO,CAAA;IAC9B,0DAA0D;IAC1D,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/C,KAAG,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CA4BvC,CAAA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { filterGlobalCookie } from "./filter-global-cookies.js";
|
|
2
|
-
import { replaceEnvVariables } from "@scalar/helpers/regex/replace-variables";
|
|
3
|
-
import { xScalarCookieSchema } from "@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies";
|
|
4
|
-
import { coerceValue } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
5
|
-
//#region src/v2/blocks/operation-block/helpers/build-request-cookie-header.ts
|
|
6
|
-
var CUSTOM_COOKIE_HEADER_WARNING = "We're using a `X-Scalar-Cookie` custom header to the request. The proxy will forward this as a `Cookie` header. We do this to avoid the browser omitting the `Cookie` header for cross-origin requests for security reasons.";
|
|
7
|
-
var COOKIE_HEADER_WARNING = `We're trying to add a Cookie header, but browsers often omit them for cross-origin requests for various security reasons. If it's not working, that's probably why. Here are the requirements for it to work:
|
|
8
|
-
|
|
9
|
-
- The browser URL must be on the same domain as the server URL.
|
|
10
|
-
- The connection must be made over HTTPS.
|
|
11
|
-
`;
|
|
12
|
-
/**
|
|
13
|
-
* Generate a cookie header from the cookie params
|
|
14
|
-
*/
|
|
15
|
-
var getCookieHeader = (cookieParams, originalCookieHeader) => {
|
|
16
|
-
const cookieHeader = cookieParams.map((c) => `${c.name}=${c.value}`).join("; ");
|
|
17
|
-
if (originalCookieHeader && cookieHeader) return `${originalCookieHeader}; ${cookieHeader}`;
|
|
18
|
-
return originalCookieHeader || cookieHeader || "";
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Build out the cookies header taking in global, param and security scheme cookies
|
|
22
|
-
*/
|
|
23
|
-
var buildRequestCookieHeader = ({ paramCookies, globalCookies, env, originalCookieHeader, url, useCustomCookieHeader, disabledGlobalCookies }) => {
|
|
24
|
-
/** Generate the cookie header */
|
|
25
|
-
const cookieHeader = getCookieHeader([...globalCookies.filter((cookie) => filterGlobalCookie({
|
|
26
|
-
cookie,
|
|
27
|
-
url,
|
|
28
|
-
disabledGlobalCookies
|
|
29
|
-
})).map((cookie) => {
|
|
30
|
-
return coerceValue(xScalarCookieSchema, {
|
|
31
|
-
...cookie,
|
|
32
|
-
name: replaceEnvVariables(cookie.name, env),
|
|
33
|
-
value: replaceEnvVariables(cookie.value, env)
|
|
34
|
-
});
|
|
35
|
-
}), ...paramCookies], originalCookieHeader ?? void 0);
|
|
36
|
-
if (cookieHeader) {
|
|
37
|
-
if (useCustomCookieHeader) {
|
|
38
|
-
console.warn(CUSTOM_COOKIE_HEADER_WARNING);
|
|
39
|
-
return {
|
|
40
|
-
name: "X-Scalar-Cookie",
|
|
41
|
-
value: cookieHeader
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
console.warn(COOKIE_HEADER_WARNING);
|
|
45
|
-
return {
|
|
46
|
-
name: "Cookie",
|
|
47
|
-
value: cookieHeader
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return null;
|
|
51
|
-
};
|
|
52
|
-
//#endregion
|
|
53
|
-
export { buildRequestCookieHeader };
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=build-request-cookie-header.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-cookie-header.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request-cookie-header.ts"],"sourcesContent":["import { replaceEnvVariables } from '@scalar/helpers/regex/replace-variables'\nimport {\n type XScalarCookie,\n xScalarCookieSchema,\n} from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\n\nimport { filterGlobalCookie } from '@/v2/blocks/operation-block/helpers/filter-global-cookies'\n\nconst CUSTOM_COOKIE_HEADER_WARNING =\n \"We're using a `X-Scalar-Cookie` custom header to the request. The proxy will forward this as a `Cookie` header. We do this to avoid the browser omitting the `Cookie` header for cross-origin requests for security reasons.\"\nconst COOKIE_HEADER_WARNING = `We're trying to add a Cookie header, but browsers often omit them for cross-origin requests for various security reasons. If it's not working, that's probably why. Here are the requirements for it to work:\n\n - The browser URL must be on the same domain as the server URL.\n - The connection must be made over HTTPS.\n `\n\n/**\n * Generate a cookie header from the cookie params\n */\nexport const getCookieHeader = (cookieParams: XScalarCookie[], originalCookieHeader: string | undefined): string => {\n // Generate the cookie header from the cookie params\n const cookieHeader = cookieParams.map((c) => `${c.name}=${c.value}`).join('; ')\n\n // Merge with the original cookie header\n if (originalCookieHeader && cookieHeader) {\n return `${originalCookieHeader}; ${cookieHeader}`\n }\n\n // Return whichever one exists, or empty string if both are empty\n return originalCookieHeader || cookieHeader || ''\n}\n\n/**\n * Build out the cookies header taking in global, param and security scheme cookies\n */\nexport const buildRequestCookieHeader = ({\n paramCookies,\n globalCookies,\n env,\n originalCookieHeader,\n url,\n useCustomCookieHeader,\n disabledGlobalCookies,\n}: {\n /** Parsed/replaced cookies from the parameters and security schemes */\n paramCookies: XScalarCookie[]\n /** Raw global cookies from the workspace/document */\n globalCookies: XScalarCookie[]\n /** Environment variables flattened into a key-value object */\n env: Record<string, string>\n /** Cookie header that previously exists from the spec OR from the user */\n originalCookieHeader: string | undefined | null\n /** The url of the request used to filter global cookies by domain */\n url: string\n /**\n * If we are running in Electron or using the proxy, we need to add a custom header\n * that's then forwarded as a `Cookie` header.\n */\n useCustomCookieHeader: boolean\n /** The disabled global cookies for the current example */\n disabledGlobalCookies: Record<string, boolean>\n}): null | { name: string; value: string } => {\n /** Filter the global cookies by domain + parse */\n const filteredGlobalCookies = globalCookies\n .filter((cookie) => filterGlobalCookie({ cookie, url, disabledGlobalCookies }))\n .map((cookie) => {\n return coerceValue(xScalarCookieSchema, {\n ...cookie,\n name: replaceEnvVariables(cookie.name, env),\n value: replaceEnvVariables(cookie.value, env),\n })\n })\n\n /** Generate the cookie header */\n const cookieHeader = getCookieHeader([...filteredGlobalCookies, ...paramCookies], originalCookieHeader ?? undefined)\n\n if (cookieHeader) {\n // Add a custom header for the proxy (that's then forwarded as `Cookie`)\n if (useCustomCookieHeader) {\n console.warn(CUSTOM_COOKIE_HEADER_WARNING)\n return { name: 'X-Scalar-Cookie', value: cookieHeader }\n }\n\n // or stick to the original header (which might be removed by the browser)\n console.warn(COOKIE_HEADER_WARNING)\n return { name: 'Cookie', value: cookieHeader }\n }\n\n return null\n}\n"],"mappings":";;;;;AASA,IAAM,+BACJ;AACF,IAAM,wBAAwB;;;;;;;;AAS9B,IAAa,mBAAmB,cAA+B,yBAAqD;CAElH,MAAM,eAAe,aAAa,KAAK,MAAM,GAAG,EAAE,KAAK,GAAG,EAAE,QAAQ,CAAC,KAAK,KAAK;AAG/E,KAAI,wBAAwB,aAC1B,QAAO,GAAG,qBAAqB,IAAI;AAIrC,QAAO,wBAAwB,gBAAgB;;;;;AAMjD,IAAa,4BAA4B,EACvC,cACA,eACA,KACA,sBACA,KACA,uBACA,4BAmB4C;;CAa5C,MAAM,eAAe,gBAAgB,CAAC,GAXR,cAC3B,QAAQ,WAAW,mBAAmB;EAAE;EAAQ;EAAK;EAAuB,CAAC,CAAC,CAC9E,KAAK,WAAW;AACf,SAAO,YAAY,qBAAqB;GACtC,GAAG;GACH,MAAM,oBAAoB,OAAO,MAAM,IAAI;GAC3C,OAAO,oBAAoB,OAAO,OAAO,IAAI;GAC9C,CAAC;GACF,EAG4D,GAAG,aAAa,EAAE,wBAAwB,KAAA,EAAU;AAEpH,KAAI,cAAc;AAEhB,MAAI,uBAAuB;AACzB,WAAQ,KAAK,6BAA6B;AAC1C,UAAO;IAAE,MAAM;IAAmB,OAAO;IAAc;;AAIzD,UAAQ,KAAK,sBAAsB;AACnC,SAAO;GAAE,MAAM;GAAU,OAAO;GAAc;;AAGhD,QAAO"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { type XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
2
|
-
import type { ParameterObject, ReferenceType } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
3
|
-
/**
|
|
4
|
-
* Converts the parameters into a set of headers, cookies and url params while
|
|
5
|
-
* replacing environment variables and extracting example values. Also builds up a record of the path
|
|
6
|
-
* parameters which can then be used to replace variables in the path.
|
|
7
|
-
* Also handles both content based and schema based parameters.
|
|
8
|
-
*
|
|
9
|
-
* @param parameters - Unfiltered parameters
|
|
10
|
-
* @param env - Environment variables flattened into a key-value object
|
|
11
|
-
* @param exampleKey - The key of the current example
|
|
12
|
-
* @returns A set of headers, cookies and url params
|
|
13
|
-
*/
|
|
14
|
-
export declare const buildRequestParameters: (
|
|
15
|
-
/** All parameters */
|
|
16
|
-
parameters?: ReferenceType<ParameterObject>[],
|
|
17
|
-
/** Environment variables flattened into a key-value object */
|
|
18
|
-
env?: Record<string, string>,
|
|
19
|
-
/** The key of the current example */
|
|
20
|
-
exampleKey?: string) => {
|
|
21
|
-
cookies: XScalarCookie[];
|
|
22
|
-
headers: Record<string, string>;
|
|
23
|
-
pathVariables: Record<string, string>;
|
|
24
|
-
allowReservedQueryParameters: Set<string>;
|
|
25
|
-
urlParams: URLSearchParams;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=build-request-parameters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-parameters.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,qEAAqE,CAAA;AAE5E,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAA;AAoBlH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB;AACjC,qBAAqB;AACrB,aAAY,aAAa,CAAC,eAAe,CAAC,EAAO;AACjD,8DAA8D;AAC9D,MAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;AAChC,qCAAqC;AACrC,aAAY,MAAkB,KAC7B;IACD,OAAO,EAAE,aAAa,EAAE,CAAA;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,4BAA4B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACzC,SAAS,EAAE,eAAe,CAAA;CAwF3B,CAAA"}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { getExample } from "./get-example.js";
|
|
2
|
-
import { deSerializeParameter } from "./de-serialize-parameter.js";
|
|
3
|
-
import { isParamDisabled } from "../../request-block/helpers/is-param-disabled.js";
|
|
4
|
-
import { serializeContentValue, serializeDeepObjectStyle, serializeFormStyle, serializeFormStyleForCookies, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle } from "./serialize-parameter.js";
|
|
5
|
-
import { isDefined } from "@scalar/helpers/array/is-defined";
|
|
6
|
-
import { replaceEnvVariables } from "@scalar/helpers/regex/replace-variables";
|
|
7
|
-
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
8
|
-
import { xScalarCookieSchema } from "@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies";
|
|
9
|
-
import { coerceValue } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
10
|
-
import { isObject } from "@scalar/helpers/object/is-object";
|
|
11
|
-
//#region src/v2/blocks/operation-block/helpers/build-request-parameters.ts
|
|
12
|
-
/** Helper to get explode value with default */
|
|
13
|
-
var getExplode = (param, defaultValue) => "explode" in param && param.explode !== void 0 ? param.explode : defaultValue;
|
|
14
|
-
/**
|
|
15
|
-
* Converts the parameters into a set of headers, cookies and url params while
|
|
16
|
-
* replacing environment variables and extracting example values. Also builds up a record of the path
|
|
17
|
-
* parameters which can then be used to replace variables in the path.
|
|
18
|
-
* Also handles both content based and schema based parameters.
|
|
19
|
-
*
|
|
20
|
-
* @param parameters - Unfiltered parameters
|
|
21
|
-
* @param env - Environment variables flattened into a key-value object
|
|
22
|
-
* @param exampleKey - The key of the current example
|
|
23
|
-
* @returns A set of headers, cookies and url params
|
|
24
|
-
*/
|
|
25
|
-
var buildRequestParameters = (parameters = [], env = {}, exampleKey = "default") => {
|
|
26
|
-
const result = {
|
|
27
|
-
cookies: [],
|
|
28
|
-
headers: {},
|
|
29
|
-
pathVariables: {},
|
|
30
|
-
allowReservedQueryParameters: /* @__PURE__ */ new Set(),
|
|
31
|
-
urlParams: new URLSearchParams()
|
|
32
|
-
};
|
|
33
|
-
if (parameters.length === 0) return result;
|
|
34
|
-
for (const referencedParam of parameters) {
|
|
35
|
-
const param = getResolvedRef(referencedParam);
|
|
36
|
-
const example = getExample(param, exampleKey, void 0);
|
|
37
|
-
if (!example || isParamDisabled(param, example)) continue;
|
|
38
|
-
/** De-serialize the example value if it is a string and matches the schema type */
|
|
39
|
-
const deSerializedValue = deSerializeParameter(typeof example.value === "string" ? replaceEnvVariables(example.value, env) : example.value, param);
|
|
40
|
-
const paramName = replaceEnvVariables(param.name, env);
|
|
41
|
-
switch (param.in) {
|
|
42
|
-
case "header": {
|
|
43
|
-
if (paramName.toLowerCase() === "content-type" && deSerializedValue === "multipart/form-data") break;
|
|
44
|
-
/** Headers only support simple style according to OpenAPI 3.1.1 */
|
|
45
|
-
const serialized = serializeSimpleStyle(deSerializedValue, getExplode(param, false));
|
|
46
|
-
if (!isDefined(serialized)) break;
|
|
47
|
-
/** Headers can only be strings so we can cast numbers etc */
|
|
48
|
-
const serializedString = String(serialized);
|
|
49
|
-
if (result.headers[paramName]) result.headers[paramName] = `${result.headers[paramName]},${serializedString}`;
|
|
50
|
-
else result.headers[paramName] = serializedString;
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
case "path": {
|
|
54
|
-
const serialized = serializeSimpleStyle(deSerializedValue, getExplode(param, false));
|
|
55
|
-
result.pathVariables[paramName] = encodeURIComponent(String(serialized));
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
case "query":
|
|
59
|
-
processQueryParameter(param, paramName, deSerializedValue, result.urlParams, result.allowReservedQueryParameters);
|
|
60
|
-
break;
|
|
61
|
-
case "cookie":
|
|
62
|
-
processCookieParameter(paramName, deSerializedValue, getExplode(param, true), result.cookies);
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
67
|
-
};
|
|
68
|
-
/** Ensure we only apply the correcet style to the correct types */
|
|
69
|
-
var getStyle = (param, replacedValue) => {
|
|
70
|
-
if (!("style" in param) || !param.style) return "form";
|
|
71
|
-
if (param.style === "deepObject") {
|
|
72
|
-
if (isObject(replacedValue)) return "deepObject";
|
|
73
|
-
return "form";
|
|
74
|
-
}
|
|
75
|
-
return param.style;
|
|
76
|
-
};
|
|
77
|
-
/** Whether the parameter allows reserved characters (from param or schema). */
|
|
78
|
-
var isAllowReserved = (param) => {
|
|
79
|
-
if ("allowReserved" in param && param.allowReserved !== void 0) return param.allowReserved;
|
|
80
|
-
if ("schema" in param && param.schema && typeof param.schema === "object" && "allowReserved" in param.schema) return param.schema.allowReserved === true;
|
|
81
|
-
return false;
|
|
82
|
-
};
|
|
83
|
-
/** When allowReserved is true, add keys to the set so reserved chars stay unescaped in the URL. */
|
|
84
|
-
var trackReservedKeys = (allowReservedQueryParameters, allowReserved, ...keys) => {
|
|
85
|
-
if (allowReserved) for (const key of keys) allowReservedQueryParameters.add(key);
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Helper function to process query parameters.
|
|
89
|
-
* Extracted to reduce complexity in main function.
|
|
90
|
-
*/
|
|
91
|
-
var processQueryParameter = (param, paramName, replacedValue, urlParams, allowReservedQueryParameters) => {
|
|
92
|
-
/** If the parameter should be exploded, defaults to true for form style */
|
|
93
|
-
const explodeParam = "explode" in param && param.explode !== void 0 ? param.explode : true;
|
|
94
|
-
const allowReserved = isAllowReserved(param);
|
|
95
|
-
/** Style of the parameter, defaults to form */
|
|
96
|
-
const style = getStyle(param, replacedValue);
|
|
97
|
-
if ("content" in param && param.content) {
|
|
98
|
-
const serializedValue = serializeContentValue(replacedValue, Object.keys(param.content)[0] ?? "application/json");
|
|
99
|
-
urlParams.set(paramName, serializedValue);
|
|
100
|
-
trackReservedKeys(allowReservedQueryParameters, allowReserved, paramName);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (style === "deepObject" && explodeParam) {
|
|
104
|
-
const entries = serializeDeepObjectStyle(paramName, replacedValue);
|
|
105
|
-
for (const entry of entries) {
|
|
106
|
-
urlParams.append(entry.key, entry.value);
|
|
107
|
-
trackReservedKeys(allowReservedQueryParameters, allowReserved, entry.key);
|
|
108
|
-
}
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (style === "spaceDelimited") {
|
|
112
|
-
const serialized = serializeSpaceDelimitedStyle(replacedValue);
|
|
113
|
-
const existingValue = urlParams.get(paramName);
|
|
114
|
-
urlParams.set(paramName, existingValue ? `${existingValue} ${serialized}` : serialized);
|
|
115
|
-
trackReservedKeys(allowReservedQueryParameters, allowReserved, paramName);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (style === "pipeDelimited") {
|
|
119
|
-
const serialized = serializePipeDelimitedStyle(replacedValue);
|
|
120
|
-
const existingValue = urlParams.get(paramName);
|
|
121
|
-
urlParams.set(paramName, existingValue ? `${existingValue}|${serialized}` : serialized);
|
|
122
|
-
trackReservedKeys(allowReservedQueryParameters, allowReserved, paramName);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const serialized = serializeFormStyle(replacedValue, explodeParam);
|
|
126
|
-
if (Array.isArray(serialized)) for (const entry of serialized) {
|
|
127
|
-
const key = entry.key || paramName;
|
|
128
|
-
urlParams.append(key, String(entry.value));
|
|
129
|
-
trackReservedKeys(allowReservedQueryParameters, allowReserved, key);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
urlParams.append(paramName, String(serialized));
|
|
133
|
-
trackReservedKeys(allowReservedQueryParameters, allowReserved, paramName);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Helper function to process cookie parameters.
|
|
138
|
-
* Extracted to reduce complexity in main function.
|
|
139
|
-
*/
|
|
140
|
-
var processCookieParameter = (paramName, replacedValue, explode, cookies) => {
|
|
141
|
-
const serialized = serializeFormStyleForCookies(replacedValue, explode);
|
|
142
|
-
if (Array.isArray(serialized)) for (const entry of serialized) {
|
|
143
|
-
const key = entry.key || paramName;
|
|
144
|
-
cookies.push(coerceValue(xScalarCookieSchema, {
|
|
145
|
-
name: key,
|
|
146
|
-
value: String(entry.value),
|
|
147
|
-
path: "/"
|
|
148
|
-
}));
|
|
149
|
-
}
|
|
150
|
-
else cookies.push(coerceValue(xScalarCookieSchema, {
|
|
151
|
-
name: paramName,
|
|
152
|
-
value: String(serialized),
|
|
153
|
-
path: "/"
|
|
154
|
-
}));
|
|
155
|
-
};
|
|
156
|
-
//#endregion
|
|
157
|
-
export { buildRequestParameters };
|
|
158
|
-
|
|
159
|
-
//# sourceMappingURL=build-request-parameters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-parameters.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request-parameters.ts"],"sourcesContent":["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { isObject } from '@scalar/helpers/object/is-object'\nimport { replaceEnvVariables } from '@scalar/helpers/regex/replace-variables'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n type XScalarCookie,\n xScalarCookieSchema,\n} from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport type { ParameterObject, ReferenceType } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport { deSerializeParameter } from '@/v2/blocks/operation-block/helpers/de-serialize-parameter'\nimport { isParamDisabled } from '@/v2/blocks/request-block/helpers/is-param-disabled'\n\nimport { getExample } from './get-example'\nimport {\n serializeContentValue,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from './serialize-parameter'\n\n/** Helper to get explode value with default */\nconst getExplode = (param: ParameterObject, defaultValue: boolean): boolean =>\n 'explode' in param && param.explode !== undefined ? param.explode : defaultValue\n\n/**\n * Converts the parameters into a set of headers, cookies and url params while\n * replacing environment variables and extracting example values. Also builds up a record of the path\n * parameters which can then be used to replace variables in the path.\n * Also handles both content based and schema based parameters.\n *\n * @param parameters - Unfiltered parameters\n * @param env - Environment variables flattened into a key-value object\n * @param exampleKey - The key of the current example\n * @returns A set of headers, cookies and url params\n */\nexport const buildRequestParameters = (\n /** All parameters */\n parameters: ReferenceType<ParameterObject>[] = [],\n /** Environment variables flattened into a key-value object */\n env: Record<string, string> = {},\n /** The key of the current example */\n exampleKey: string = 'default',\n): {\n cookies: XScalarCookie[]\n headers: Record<string, string>\n pathVariables: Record<string, string>\n allowReservedQueryParameters: Set<string>\n urlParams: URLSearchParams\n} => {\n const result = {\n cookies: [] as XScalarCookie[],\n headers: {} as Record<string, string>,\n pathVariables: {} as Record<string, string>,\n allowReservedQueryParameters: new Set<string>(),\n urlParams: new URLSearchParams(),\n }\n\n // Early return for empty parameters\n if (parameters.length === 0) {\n return result\n }\n\n // Second pass: process all parameters\n for (const referencedParam of parameters) {\n const param = getResolvedRef(referencedParam)\n const example = getExample(param, exampleKey, undefined)\n\n // Skip disabled examples\n if (!example || isParamDisabled(param, example)) {\n continue\n }\n\n /** Replace environment variables in the key and value */\n const replacedEnvValue = typeof example.value === 'string' ? replaceEnvVariables(example.value, env) : example.value\n\n /** De-serialize the example value if it is a string and matches the schema type */\n const deSerializedValue = deSerializeParameter(replacedEnvValue, param)\n const paramName = replaceEnvVariables(param.name, env)\n\n // Handle by parameter location\n switch (param.in) {\n case 'header': {\n // Filter out Content-Type header when it is multipart/form-data\n // The browser will automatically set this header with the proper boundary\n const lowerParamName = paramName.toLowerCase()\n if (lowerParamName === 'content-type' && deSerializedValue === 'multipart/form-data') {\n break\n }\n\n /** Headers only support simple style according to OpenAPI 3.1.1 */\n const serialized = serializeSimpleStyle(deSerializedValue, getExplode(param, false))\n\n // Remove undefined/null headers\n if (!isDefined(serialized)) {\n break\n }\n\n /** Headers can only be strings so we can cast numbers etc */\n const serializedString = String(serialized)\n\n // If the header already exists, append with comma\n if (result.headers[paramName]) {\n result.headers[paramName] = `${result.headers[paramName]},${serializedString}`\n } else {\n result.headers[paramName] = serializedString\n }\n break\n }\n\n case 'path': {\n // Path parameters use simple style by default\n const serialized = serializeSimpleStyle(deSerializedValue, getExplode(param, false))\n result.pathVariables[paramName] = encodeURIComponent(String(serialized))\n break\n }\n\n case 'query': {\n processQueryParameter(\n param,\n paramName,\n deSerializedValue,\n result.urlParams,\n result.allowReservedQueryParameters,\n )\n break\n }\n\n case 'cookie': {\n processCookieParameter(paramName, deSerializedValue, getExplode(param, true), result.cookies)\n break\n }\n }\n }\n\n return result\n}\n\n/** Ensure we only apply the correcet style to the correct types */\nconst getStyle = (param: ParameterObject, replacedValue: unknown): string => {\n if (!('style' in param) || !param.style) {\n return 'form'\n }\n\n // DeepObject can only apply to objects\n if (param.style === 'deepObject') {\n if (isObject(replacedValue)) {\n return 'deepObject'\n }\n return 'form'\n }\n\n return param.style\n}\n\n/** Whether the parameter allows reserved characters (from param or schema). */\nconst isAllowReserved = (param: ParameterObject): boolean => {\n if ('allowReserved' in param && param.allowReserved !== undefined) {\n return param.allowReserved\n }\n if ('schema' in param && param.schema && typeof param.schema === 'object' && 'allowReserved' in param.schema) {\n return (param.schema as { allowReserved?: boolean }).allowReserved === true\n }\n return false\n}\n\n/** When allowReserved is true, add keys to the set so reserved chars stay unescaped in the URL. */\nconst trackReservedKeys = (\n allowReservedQueryParameters: Set<string>,\n allowReserved: boolean,\n ...keys: string[]\n): void => {\n if (allowReserved) {\n for (const key of keys) {\n allowReservedQueryParameters.add(key)\n }\n }\n}\n\n/**\n * Helper function to process query parameters.\n * Extracted to reduce complexity in main function.\n */\nconst processQueryParameter = (\n param: ParameterObject,\n paramName: string,\n replacedValue: unknown,\n urlParams: URLSearchParams,\n allowReservedQueryParameters: Set<string>,\n): void => {\n /** If the parameter should be exploded, defaults to true for form style */\n const explodeParam = 'explode' in param && param.explode !== undefined ? param.explode : true\n const allowReserved = isAllowReserved(param)\n\n /** Style of the parameter, defaults to form */\n const style = getStyle(param, replacedValue)\n\n // Content type parameters should be serialized according to the parameter's own content type\n if ('content' in param && param.content) {\n // We grab the first for now but eventually we should support selecting the content type per parameter\n const paramContentType = Object.keys(param.content)[0] ?? 'application/json'\n const serializedValue = serializeContentValue(replacedValue, paramContentType)\n urlParams.set(paramName, serializedValue)\n trackReservedKeys(allowReservedQueryParameters, allowReserved, paramName)\n return\n }\n\n // Handle deepObject style\n if (style === 'deepObject' && explodeParam) {\n const entries = serializeDeepObjectStyle(paramName, replacedValue)\n for (const entry of entries) {\n urlParams.append(entry.key, entry.value)\n trackReservedKeys(allowReservedQueryParameters, allowReserved, entry.key)\n }\n return\n }\n\n // Handle spaceDelimited style\n if (style === 'spaceDelimited') {\n const serialized = serializeSpaceDelimitedStyle(replacedValue)\n const existingValue = urlParams.get(paramName)\n urlParams.set(paramName, existingValue ? `${existingValue} ${serialized}` : serialized)\n trackReservedKeys(allowReservedQueryParameters, allowReserved, paramName)\n return\n }\n\n // Handle pipeDelimited style\n if (style === 'pipeDelimited') {\n const serialized = serializePipeDelimitedStyle(replacedValue)\n const existingValue = urlParams.get(paramName)\n urlParams.set(paramName, existingValue ? `${existingValue}|${serialized}` : serialized)\n trackReservedKeys(allowReservedQueryParameters, allowReserved, paramName)\n return\n }\n\n // Handle form style (default)\n const serialized = serializeFormStyle(replacedValue, explodeParam)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n // If key is empty, use paramName (for arrays)\n const key = entry.key || paramName\n urlParams.append(key, String(entry.value))\n trackReservedKeys(allowReservedQueryParameters, allowReserved, key)\n }\n } else {\n // Otherwise, convert to string for URLSearchParams\n urlParams.append(paramName, String(serialized))\n trackReservedKeys(allowReservedQueryParameters, allowReserved, paramName)\n }\n}\n\n/**\n * Helper function to process cookie parameters.\n * Extracted to reduce complexity in main function.\n */\nconst processCookieParameter = (\n paramName: string,\n replacedValue: unknown,\n explode: boolean,\n cookies: XScalarCookie[],\n): void => {\n // Cookies only support form style according to OpenAPI 3.1.1\n const serialized = serializeFormStyleForCookies(replacedValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || paramName\n cookies.push(\n coerceValue(xScalarCookieSchema, {\n name: key,\n value: String(entry.value),\n path: '/',\n }),\n )\n }\n } else {\n // Otherwise, convert to string for cookie value\n cookies.push(\n coerceValue(xScalarCookieSchema, {\n name: paramName,\n value: String(serialized),\n path: '/',\n }),\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,IAAM,cAAc,OAAwB,iBAC1C,aAAa,SAAS,MAAM,YAAY,KAAA,IAAY,MAAM,UAAU;;;;;;;;;;;;AAatE,IAAa,0BAEX,aAA+C,EAAE,EAEjD,MAA8B,EAAE,EAEhC,aAAqB,cAOlB;CACH,MAAM,SAAS;EACb,SAAS,EAAE;EACX,SAAS,EAAE;EACX,eAAe,EAAE;EACjB,8CAA8B,IAAI,KAAa;EAC/C,WAAW,IAAI,iBAAiB;EACjC;AAGD,KAAI,WAAW,WAAW,EACxB,QAAO;AAIT,MAAK,MAAM,mBAAmB,YAAY;EACxC,MAAM,QAAQ,eAAe,gBAAgB;EAC7C,MAAM,UAAU,WAAW,OAAO,YAAY,KAAA,EAAU;AAGxD,MAAI,CAAC,WAAW,gBAAgB,OAAO,QAAQ,CAC7C;;EAOF,MAAM,oBAAoB,qBAHD,OAAO,QAAQ,UAAU,WAAW,oBAAoB,QAAQ,OAAO,IAAI,GAAG,QAAQ,OAG9C,MAAM;EACvE,MAAM,YAAY,oBAAoB,MAAM,MAAM,IAAI;AAGtD,UAAQ,MAAM,IAAd;GACE,KAAK,UAAU;AAIb,QADuB,UAAU,aAAa,KACvB,kBAAkB,sBAAsB,sBAC7D;;IAIF,MAAM,aAAa,qBAAqB,mBAAmB,WAAW,OAAO,MAAM,CAAC;AAGpF,QAAI,CAAC,UAAU,WAAW,CACxB;;IAIF,MAAM,mBAAmB,OAAO,WAAW;AAG3C,QAAI,OAAO,QAAQ,WACjB,QAAO,QAAQ,aAAa,GAAG,OAAO,QAAQ,WAAW,GAAG;QAE5D,QAAO,QAAQ,aAAa;AAE9B;;GAGF,KAAK,QAAQ;IAEX,MAAM,aAAa,qBAAqB,mBAAmB,WAAW,OAAO,MAAM,CAAC;AACpF,WAAO,cAAc,aAAa,mBAAmB,OAAO,WAAW,CAAC;AACxE;;GAGF,KAAK;AACH,0BACE,OACA,WACA,mBACA,OAAO,WACP,OAAO,6BACR;AACD;GAGF,KAAK;AACH,2BAAuB,WAAW,mBAAmB,WAAW,OAAO,KAAK,EAAE,OAAO,QAAQ;AAC7F;;;AAKN,QAAO;;;AAIT,IAAM,YAAY,OAAwB,kBAAmC;AAC3E,KAAI,EAAE,WAAW,UAAU,CAAC,MAAM,MAChC,QAAO;AAIT,KAAI,MAAM,UAAU,cAAc;AAChC,MAAI,SAAS,cAAc,CACzB,QAAO;AAET,SAAO;;AAGT,QAAO,MAAM;;;AAIf,IAAM,mBAAmB,UAAoC;AAC3D,KAAI,mBAAmB,SAAS,MAAM,kBAAkB,KAAA,EACtD,QAAO,MAAM;AAEf,KAAI,YAAY,SAAS,MAAM,UAAU,OAAO,MAAM,WAAW,YAAY,mBAAmB,MAAM,OACpG,QAAQ,MAAM,OAAuC,kBAAkB;AAEzE,QAAO;;;AAIT,IAAM,qBACJ,8BACA,eACA,GAAG,SACM;AACT,KAAI,cACF,MAAK,MAAM,OAAO,KAChB,8BAA6B,IAAI,IAAI;;;;;;AAS3C,IAAM,yBACJ,OACA,WACA,eACA,WACA,iCACS;;CAET,MAAM,eAAe,aAAa,SAAS,MAAM,YAAY,KAAA,IAAY,MAAM,UAAU;CACzF,MAAM,gBAAgB,gBAAgB,MAAM;;CAG5C,MAAM,QAAQ,SAAS,OAAO,cAAc;AAG5C,KAAI,aAAa,SAAS,MAAM,SAAS;EAGvC,MAAM,kBAAkB,sBAAsB,eADrB,OAAO,KAAK,MAAM,QAAQ,CAAC,MAAM,mBACoB;AAC9E,YAAU,IAAI,WAAW,gBAAgB;AACzC,oBAAkB,8BAA8B,eAAe,UAAU;AACzE;;AAIF,KAAI,UAAU,gBAAgB,cAAc;EAC1C,MAAM,UAAU,yBAAyB,WAAW,cAAc;AAClE,OAAK,MAAM,SAAS,SAAS;AAC3B,aAAU,OAAO,MAAM,KAAK,MAAM,MAAM;AACxC,qBAAkB,8BAA8B,eAAe,MAAM,IAAI;;AAE3E;;AAIF,KAAI,UAAU,kBAAkB;EAC9B,MAAM,aAAa,6BAA6B,cAAc;EAC9D,MAAM,gBAAgB,UAAU,IAAI,UAAU;AAC9C,YAAU,IAAI,WAAW,gBAAgB,GAAG,cAAc,GAAG,eAAe,WAAW;AACvF,oBAAkB,8BAA8B,eAAe,UAAU;AACzE;;AAIF,KAAI,UAAU,iBAAiB;EAC7B,MAAM,aAAa,4BAA4B,cAAc;EAC7D,MAAM,gBAAgB,UAAU,IAAI,UAAU;AAC9C,YAAU,IAAI,WAAW,gBAAgB,GAAG,cAAc,GAAG,eAAe,WAAW;AACvF,oBAAkB,8BAA8B,eAAe,UAAU;AACzE;;CAIF,MAAM,aAAa,mBAAmB,eAAe,aAAa;AAGlE,KAAI,MAAM,QAAQ,WAAW,CAC3B,MAAK,MAAM,SAAS,YAAY;EAE9B,MAAM,MAAM,MAAM,OAAO;AACzB,YAAU,OAAO,KAAK,OAAO,MAAM,MAAM,CAAC;AAC1C,oBAAkB,8BAA8B,eAAe,IAAI;;MAEhE;AAEL,YAAU,OAAO,WAAW,OAAO,WAAW,CAAC;AAC/C,oBAAkB,8BAA8B,eAAe,UAAU;;;;;;;AAQ7E,IAAM,0BACJ,WACA,eACA,SACA,YACS;CAET,MAAM,aAAa,6BAA6B,eAAe,QAAQ;AAGvE,KAAI,MAAM,QAAQ,WAAW,CAC3B,MAAK,MAAM,SAAS,YAAY;EAC9B,MAAM,MAAM,MAAM,OAAO;AACzB,UAAQ,KACN,YAAY,qBAAqB;GAC/B,MAAM;GACN,OAAO,OAAO,MAAM,MAAM;GAC1B,MAAM;GACP,CAAC,CACH;;KAIH,SAAQ,KACN,YAAY,qBAAqB;EAC/B,MAAM;EACN,OAAO,OAAO,WAAW;EACzB,MAAM;EACP,CAAC,CACH"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
2
|
-
import type { SecurityRequirementObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
3
|
-
import type { MergedSecuritySchemes } from '../../../../v2/blocks/scalar-auth-selector-block/helpers/merge-security.js';
|
|
4
|
-
import type { SecuritySchemeObjectSecret } from '../../../../v2/blocks/scalar-auth-selector-block/helpers/secret-types';
|
|
5
|
-
/**
|
|
6
|
-
* Get the selected security schemes from security requirements.
|
|
7
|
-
* Takes security requirement objects and resolves them to actual security scheme objects.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getSecuritySchemes: (securitySchemes: MergedSecuritySchemes, selectedSecurity: SecurityRequirementObject[]) => SecuritySchemeObjectSecret[];
|
|
10
|
-
/**
|
|
11
|
-
* Generates the headers, cookies and query params for selected security schemes
|
|
12
|
-
* In the future we can add customization for where the security is applied
|
|
13
|
-
*/
|
|
14
|
-
export declare const buildRequestSecurity: (
|
|
15
|
-
/** Currently selected security for the current operation */
|
|
16
|
-
selectedSecuritySchemes: SecuritySchemeObjectSecret[],
|
|
17
|
-
/** Environment variables flattened into a key-value object */
|
|
18
|
-
env?: Record<string, string>,
|
|
19
|
-
/** Include this parameter to set the placeholder for empty tokens */
|
|
20
|
-
emptyTokenPlaceholder?: string) => {
|
|
21
|
-
headers: Record<string, string>;
|
|
22
|
-
cookies: XScalarCookie[];
|
|
23
|
-
urlParams: URLSearchParams;
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=build-request-security.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-security.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request-security.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,qEAAqE,CAAA;AAE5E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8DAA8D,CAAA;AAG7G,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+DAA+D,CAAA;AAC1G,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6DAA6D,CAAA;AAE7G;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC7B,iBAAiB,qBAAqB,EACtC,kBAAkB,yBAAyB,EAAE,KAC5C,0BAA0B,EAUpB,CAAA;AAET;;;GAGG;AACH,eAAO,MAAM,oBAAoB;AAC/B,4DAA4D;AAC5D,yBAAyB,0BAA0B,EAAE;AACrD,8DAA8D;AAC9D,MAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;AAChC,qEAAqE;AACrE,8BAA0B,KACzB;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,aAAa,EAAE,CAAC;IAAC,SAAS,EAAE,eAAe,CAAA;CAuDzF,CAAA"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { encode } from "js-base64";
|
|
2
|
-
import { isDefined } from "@scalar/helpers/array/is-defined";
|
|
3
|
-
import { objectKeys } from "@scalar/helpers/object/object-keys";
|
|
4
|
-
import { replaceEnvVariables } from "@scalar/helpers/regex/replace-variables";
|
|
5
|
-
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
6
|
-
import { xScalarCookieSchema } from "@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies";
|
|
7
|
-
import { coerceValue } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
8
|
-
//#region src/v2/blocks/operation-block/helpers/build-request-security.ts
|
|
9
|
-
/**
|
|
10
|
-
* Get the selected security schemes from security requirements.
|
|
11
|
-
* Takes security requirement objects and resolves them to actual security scheme objects.
|
|
12
|
-
*/
|
|
13
|
-
var getSecuritySchemes = (securitySchemes, selectedSecurity) => selectedSecurity.flatMap((scheme) => objectKeys(scheme).flatMap((key) => {
|
|
14
|
-
const scheme = getResolvedRef(securitySchemes?.[key]);
|
|
15
|
-
if (scheme) return scheme;
|
|
16
|
-
return [];
|
|
17
|
-
})) ?? [];
|
|
18
|
-
/**
|
|
19
|
-
* Generates the headers, cookies and query params for selected security schemes
|
|
20
|
-
* In the future we can add customization for where the security is applied
|
|
21
|
-
*/
|
|
22
|
-
var buildRequestSecurity = (selectedSecuritySchemes, env = {}, emptyTokenPlaceholder = "") => {
|
|
23
|
-
const headers = {};
|
|
24
|
-
const cookies = [];
|
|
25
|
-
const urlParams = new URLSearchParams();
|
|
26
|
-
selectedSecuritySchemes.forEach((scheme) => {
|
|
27
|
-
if (scheme.type === "apiKey") {
|
|
28
|
-
const name = replaceEnvVariables(scheme.name, env);
|
|
29
|
-
const value = replaceEnvVariables(scheme["x-scalar-secret-token"], env) || emptyTokenPlaceholder;
|
|
30
|
-
if (scheme.in === "header") headers[name] = value;
|
|
31
|
-
if (scheme.in === "query") urlParams.append(name, value);
|
|
32
|
-
if (scheme.in === "cookie") cookies.push(coerceValue(xScalarCookieSchema, {
|
|
33
|
-
name,
|
|
34
|
-
value,
|
|
35
|
-
path: "/"
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
if (scheme.type === "http") if (scheme.scheme === "basic") {
|
|
39
|
-
const value = `${replaceEnvVariables(scheme["x-scalar-secret-username"], env)}:${replaceEnvVariables(scheme["x-scalar-secret-password"], env)}`;
|
|
40
|
-
headers["Authorization"] = `Basic ${value === ":" ? "username:password" : encode(value)}`;
|
|
41
|
-
} else headers["Authorization"] = `Bearer ${replaceEnvVariables(scheme["x-scalar-secret-token"], env) || emptyTokenPlaceholder}`;
|
|
42
|
-
if (scheme.type === "oauth2") headers["Authorization"] = `Bearer ${replaceEnvVariables(Object.values(scheme?.flows ?? {}).filter(isDefined).find((f) => f["x-scalar-secret-token"])?.["x-scalar-secret-token"] ?? "", env) || emptyTokenPlaceholder}`;
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
headers,
|
|
46
|
-
cookies,
|
|
47
|
-
urlParams
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
//#endregion
|
|
51
|
-
export { buildRequestSecurity, getSecuritySchemes };
|
|
52
|
-
|
|
53
|
-
//# sourceMappingURL=build-request-security.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-security.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request-security.ts"],"sourcesContent":["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { objectKeys } from '@scalar/helpers/object/object-keys'\nimport { replaceEnvVariables } from '@scalar/helpers/regex/replace-variables'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n type XScalarCookie,\n xScalarCookieSchema,\n} from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport type { SecurityRequirementObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { encode } from 'js-base64'\n\nimport type { MergedSecuritySchemes } from '@/v2/blocks/scalar-auth-selector-block/helpers/merge-security'\nimport type { SecuritySchemeObjectSecret } from '@/v2/blocks/scalar-auth-selector-block/helpers/secret-types'\n\n/**\n * Get the selected security schemes from security requirements.\n * Takes security requirement objects and resolves them to actual security scheme objects.\n */\nexport const getSecuritySchemes = (\n securitySchemes: MergedSecuritySchemes,\n selectedSecurity: SecurityRequirementObject[],\n): SecuritySchemeObjectSecret[] =>\n selectedSecurity.flatMap((scheme) =>\n objectKeys(scheme).flatMap((key) => {\n const scheme = getResolvedRef(securitySchemes?.[key])\n if (scheme) {\n return scheme\n }\n\n return []\n }),\n ) ?? []\n\n/**\n * Generates the headers, cookies and query params for selected security schemes\n * In the future we can add customization for where the security is applied\n */\nexport const buildRequestSecurity = (\n /** Currently selected security for the current operation */\n selectedSecuritySchemes: SecuritySchemeObjectSecret[],\n /** Environment variables flattened into a key-value object */\n env: Record<string, string> = {},\n /** Include this parameter to set the placeholder for empty tokens */\n emptyTokenPlaceholder = '',\n): { headers: Record<string, string>; cookies: XScalarCookie[]; urlParams: URLSearchParams } => {\n const headers: Record<string, string> = {}\n const cookies: XScalarCookie[] = []\n const urlParams = new URLSearchParams()\n\n selectedSecuritySchemes.forEach((scheme) => {\n // Api key\n if (scheme.type === 'apiKey') {\n const name = replaceEnvVariables(scheme.name, env)\n const value = replaceEnvVariables(scheme['x-scalar-secret-token'], env) || emptyTokenPlaceholder\n\n if (scheme.in === 'header') {\n headers[name] = value\n }\n if (scheme.in === 'query') {\n urlParams.append(name, value)\n }\n if (scheme.in === 'cookie') {\n cookies.push(\n coerceValue(xScalarCookieSchema, {\n name,\n value,\n path: '/',\n }),\n )\n }\n }\n\n // HTTP\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = replaceEnvVariables(scheme['x-scalar-secret-username'], env)\n const password = replaceEnvVariables(scheme['x-scalar-secret-password'], env)\n const value = `${username}:${password}`\n\n headers['Authorization'] = `Basic ${value === ':' ? 'username:password' : encode(value)}`\n } else {\n const value = replaceEnvVariables(scheme['x-scalar-secret-token'], env)\n headers['Authorization'] = `Bearer ${value || emptyTokenPlaceholder}`\n }\n }\n\n // OAuth2\n if (scheme.type === 'oauth2') {\n const flows = Object.values(scheme?.flows ?? {})\n const token = replaceEnvVariables(\n flows.filter(isDefined).find((f) => f['x-scalar-secret-token'])?.['x-scalar-secret-token'] ?? '',\n env,\n )\n\n headers['Authorization'] = `Bearer ${token || emptyTokenPlaceholder}`\n }\n })\n\n return { headers, cookies, urlParams }\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,IAAa,sBACX,iBACA,qBAEA,iBAAiB,SAAS,WACxB,WAAW,OAAO,CAAC,SAAS,QAAQ;CAClC,MAAM,SAAS,eAAe,kBAAkB,KAAK;AACrD,KAAI,OACF,QAAO;AAGT,QAAO,EAAE;EACT,CACH,IAAI,EAAE;;;;;AAMT,IAAa,wBAEX,yBAEA,MAA8B,EAAE,EAEhC,wBAAwB,OACsE;CAC9F,MAAM,UAAkC,EAAE;CAC1C,MAAM,UAA2B,EAAE;CACnC,MAAM,YAAY,IAAI,iBAAiB;AAEvC,yBAAwB,SAAS,WAAW;AAE1C,MAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,OAAO,oBAAoB,OAAO,MAAM,IAAI;GAClD,MAAM,QAAQ,oBAAoB,OAAO,0BAA0B,IAAI,IAAI;AAE3E,OAAI,OAAO,OAAO,SAChB,SAAQ,QAAQ;AAElB,OAAI,OAAO,OAAO,QAChB,WAAU,OAAO,MAAM,MAAM;AAE/B,OAAI,OAAO,OAAO,SAChB,SAAQ,KACN,YAAY,qBAAqB;IAC/B;IACA;IACA,MAAM;IACP,CAAC,CACH;;AAKL,MAAI,OAAO,SAAS,OAClB,KAAI,OAAO,WAAW,SAAS;GAG7B,MAAM,QAAQ,GAFG,oBAAoB,OAAO,6BAA6B,IAAI,CAEnD,GADT,oBAAoB,OAAO,6BAA6B,IAAI;AAG7E,WAAQ,mBAAmB,SAAS,UAAU,MAAM,sBAAsB,OAAO,MAAM;QAGvF,SAAQ,mBAAmB,UADb,oBAAoB,OAAO,0BAA0B,IAAI,IACzB;AAKlD,MAAI,OAAO,SAAS,SAOlB,SAAQ,mBAAmB,UALb,oBADA,OAAO,OAAO,QAAQ,SAAS,EAAE,CAAC,CAExC,OAAO,UAAU,CAAC,MAAM,MAAM,EAAE,yBAAyB,GAAG,4BAA4B,IAC9F,IACD,IAE6C;GAEhD;AAEF,QAAO;EAAE;EAAS;EAAS;EAAW"}
|