@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.
Files changed (338) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/components/AddressBar/AddressBarHistory.vue.d.ts.map +1 -1
  3. package/dist/components/AddressBar/AddressBarHistory.vue.js +1 -1
  4. package/dist/components/AddressBar/AddressBarHistory.vue.js.map +1 -1
  5. package/dist/components/AddressBar/AddressBarHistory.vue.script.js +2 -2
  6. package/dist/components/AddressBar/AddressBarHistory.vue.script.js.map +1 -1
  7. package/dist/hooks/useClientConfig.d.ts +12 -0
  8. package/dist/hooks/useClientConfig.d.ts.map +1 -1
  9. package/dist/hooks/useClientConfig.js +14 -1
  10. package/dist/hooks/useClientConfig.js.map +1 -1
  11. package/dist/hooks/useResponseBody.js +2 -2
  12. package/dist/hooks/useResponseBody.js.map +1 -1
  13. package/dist/libs/index.d.ts +0 -1
  14. package/dist/libs/index.d.ts.map +1 -1
  15. package/dist/libs/index.js +1 -2
  16. package/dist/libs/send-request/decode-buffer.js +2 -2
  17. package/dist/libs/send-request/decode-buffer.js.map +1 -1
  18. package/dist/style.css +222 -263
  19. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +14 -10
  20. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
  21. package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
  22. package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +57 -35
  23. package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
  24. package/dist/v2/blocks/operation-block/helpers/decode-buffer.js +2 -2
  25. package/dist/v2/blocks/operation-block/helpers/decode-buffer.js.map +1 -1
  26. package/dist/v2/blocks/operation-block/helpers/send-request.d.ts +1 -5
  27. package/dist/v2/blocks/operation-block/helpers/send-request.d.ts.map +1 -1
  28. package/dist/v2/blocks/operation-block/helpers/send-request.js +18 -33
  29. package/dist/v2/blocks/operation-block/helpers/send-request.js.map +1 -1
  30. package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.d.ts.map +1 -1
  31. package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js +1 -1
  32. package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js.map +1 -1
  33. package/dist/v2/blocks/operation-block/index.d.ts +0 -3
  34. package/dist/v2/blocks/operation-block/index.d.ts.map +1 -1
  35. package/dist/v2/blocks/operation-block/index.js +1 -4
  36. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts +1 -1
  37. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +1 -1
  38. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +1 -1
  39. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js.map +1 -1
  40. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js +3 -1
  41. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js.map +1 -1
  42. package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts +4 -2
  43. package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts.map +1 -1
  44. package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js +3 -2
  45. package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js.map +1 -1
  46. package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.js +1 -1
  47. package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts +1 -1
  48. package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts.map +1 -1
  49. package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.js.map +1 -1
  50. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts +7 -2
  51. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
  52. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js +4 -3
  53. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js.map +1 -1
  54. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts.map +1 -1
  55. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js +2 -3
  56. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js.map +1 -1
  57. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts +3 -1
  58. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
  59. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +5 -8
  60. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js.map +1 -1
  61. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts +1 -1
  62. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts.map +1 -1
  63. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.js.map +1 -1
  64. package/dist/v2/blocks/operation-code-sample/index.d.ts +0 -1
  65. package/dist/v2/blocks/operation-code-sample/index.d.ts.map +1 -1
  66. package/dist/v2/blocks/operation-code-sample/index.js +2 -3
  67. package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +7 -9
  68. package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
  69. package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
  70. package/dist/v2/blocks/request-block/RequestBlock.vue.js.map +1 -1
  71. package/dist/v2/blocks/request-block/RequestBlock.vue.script.js +49 -42
  72. package/dist/v2/blocks/request-block/RequestBlock.vue.script.js.map +1 -1
  73. package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts.map +1 -1
  74. package/dist/v2/blocks/request-block/components/RequestBody.vue.js +1 -1
  75. package/dist/v2/blocks/request-block/components/RequestBody.vue.js.map +1 -1
  76. package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js +2 -3
  77. package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js.map +1 -1
  78. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
  79. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js.map +1 -1
  80. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js +1 -0
  81. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js.map +1 -1
  82. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
  83. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js.map +1 -1
  84. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js +11 -9
  85. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js.map +1 -1
  86. package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js +1 -1
  87. package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts +1 -1
  88. package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts.map +1 -1
  89. package/dist/v2/blocks/request-block/helpers/is-param-disabled.js +2 -1
  90. package/dist/v2/blocks/request-block/helpers/is-param-disabled.js.map +1 -1
  91. package/dist/v2/blocks/response-block/helpers/get-content-length.d.ts.map +1 -1
  92. package/dist/v2/blocks/response-block/helpers/get-content-length.js +2 -2
  93. package/dist/v2/blocks/response-block/helpers/get-content-length.js.map +1 -1
  94. package/dist/v2/blocks/response-block/helpers/process-response-body.js +2 -2
  95. package/dist/v2/blocks/response-block/helpers/process-response-body.js.map +1 -1
  96. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
  97. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +1 -1
  98. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js.map +1 -1
  99. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.script.js +76 -25
  100. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.script.js.map +1 -1
  101. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts.map +1 -1
  102. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js +1 -1
  103. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js.map +1 -1
  104. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.script.js +2 -2
  105. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.script.js.map +1 -1
  106. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts +1 -1
  107. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts.map +1 -1
  108. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.js.map +1 -1
  109. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js +1 -1
  110. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js.map +1 -1
  111. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts +1 -1
  112. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -1
  113. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js.map +1 -1
  114. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js +8 -4
  115. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js.map +1 -1
  116. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts +1 -1
  117. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts.map +1 -1
  118. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.js.map +1 -1
  119. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.script.js.map +1 -1
  120. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts +1 -1
  121. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -1
  122. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.js.map +1 -1
  123. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.script.js.map +1 -1
  124. package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts +1 -1
  125. package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts.map +1 -1
  126. package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.js +1 -1
  127. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts +1 -1
  128. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
  129. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +6 -2
  130. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js.map +1 -1
  131. package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts +0 -3
  132. package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts.map +1 -1
  133. package/dist/v2/blocks/scalar-auth-selector-block/index.js +1 -3
  134. package/dist/v2/components/code-input/CodeInput.vue.d.ts +16 -8
  135. package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
  136. package/dist/v2/components/code-input/CodeInput.vue.js +1 -1
  137. package/dist/v2/components/code-input/CodeInput.vue.js.map +1 -1
  138. package/dist/v2/components/code-input/CodeInput.vue.script.js +15 -10
  139. package/dist/v2/components/code-input/CodeInput.vue.script.js.map +1 -1
  140. package/dist/v2/constants.js +1 -1
  141. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  142. package/dist/v2/features/app/App.vue.js.map +1 -1
  143. package/dist/v2/features/app/App.vue.script.js +1 -5
  144. package/dist/v2/features/app/App.vue.script.js.map +1 -1
  145. package/dist/v2/features/app/app-events.d.ts.map +1 -1
  146. package/dist/v2/features/app/app-events.js +1 -1
  147. package/dist/v2/features/app/app-events.js.map +1 -1
  148. package/dist/v2/features/app/app-state.d.ts.map +1 -1
  149. package/dist/v2/features/app/app-state.js +2 -2
  150. package/dist/v2/features/app/app-state.js.map +1 -1
  151. package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
  152. package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
  153. package/dist/v2/features/app/components/AppSidebar.vue.js.map +1 -1
  154. package/dist/v2/features/app/components/AppSidebar.vue.script.js +1 -1
  155. package/dist/v2/features/app/components/AppSidebar.vue.script.js.map +1 -1
  156. package/dist/v2/features/app/helpers/routes.d.ts +0 -3
  157. package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
  158. package/dist/v2/features/app/helpers/routes.js +1 -1
  159. package/dist/v2/features/app/helpers/routes.js.map +1 -1
  160. package/dist/v2/features/collection/DocumentCollection.vue.d.ts.map +1 -1
  161. package/dist/v2/features/collection/DocumentCollection.vue.js.map +1 -1
  162. package/dist/v2/features/collection/DocumentCollection.vue.script.js +30 -52
  163. package/dist/v2/features/collection/DocumentCollection.vue.script.js.map +1 -1
  164. package/dist/v2/features/collection/OperationCollection.vue.script.js +0 -1
  165. package/dist/v2/features/collection/OperationCollection.vue.script.js.map +1 -1
  166. package/dist/v2/features/collection/WorkspaceCollection.vue.script.js +0 -1
  167. package/dist/v2/features/collection/WorkspaceCollection.vue.script.js.map +1 -1
  168. package/dist/v2/features/collection/components/Authentication.vue.d.ts.map +1 -1
  169. package/dist/v2/features/collection/components/Authentication.vue.js +1 -1
  170. package/dist/v2/features/collection/components/Authentication.vue.js.map +1 -1
  171. package/dist/v2/features/collection/components/Authentication.vue.script.js +6 -8
  172. package/dist/v2/features/collection/components/Authentication.vue.script.js.map +1 -1
  173. package/dist/v2/features/collection/components/Cookies.vue.script.js +0 -1
  174. package/dist/v2/features/collection/components/Cookies.vue.script.js.map +1 -1
  175. package/dist/v2/features/collection/components/Editor/Editor.vue.script.js +0 -1
  176. package/dist/v2/features/collection/components/Editor/Editor.vue.script.js.map +1 -1
  177. package/dist/v2/features/collection/components/Environment.vue.script.js +0 -1
  178. package/dist/v2/features/collection/components/Environment.vue.script.js.map +1 -1
  179. package/dist/v2/features/collection/components/Overview.vue.script.js +0 -1
  180. package/dist/v2/features/collection/components/Overview.vue.script.js.map +1 -1
  181. package/dist/v2/features/collection/components/Servers.vue.script.js +0 -1
  182. package/dist/v2/features/collection/components/Servers.vue.script.js.map +1 -1
  183. package/dist/v2/features/collection/components/Settings.vue.js.map +1 -1
  184. package/dist/v2/features/collection/components/Settings.vue.script.js +2 -3
  185. package/dist/v2/features/collection/components/Settings.vue.script.js.map +1 -1
  186. package/dist/v2/features/editor/hooks/use-three-way-merge-editor.js +1 -1
  187. package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.d.ts.map +1 -1
  188. package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.js.map +1 -1
  189. package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js +1 -1
  190. package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js.map +1 -1
  191. package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
  192. package/dist/v2/features/modal/Modal.vue.js.map +1 -1
  193. package/dist/v2/features/modal/Modal.vue.script.js +3 -4
  194. package/dist/v2/features/modal/Modal.vue.script.js.map +1 -1
  195. package/dist/v2/features/modal/helpers/map-hidden-clients-config.js +1 -1
  196. package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
  197. package/dist/v2/features/operation/Operation.vue.js.map +1 -1
  198. package/dist/v2/features/operation/Operation.vue.script.js +50 -84
  199. package/dist/v2/features/operation/Operation.vue.script.js.map +1 -1
  200. package/dist/v2/features/operation/index.d.ts +0 -4
  201. package/dist/v2/features/operation/index.d.ts.map +1 -1
  202. package/dist/v2/features/operation/index.js +1 -5
  203. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
  204. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js.map +1 -1
  205. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.script.js +11 -1
  206. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.script.js.map +1 -1
  207. package/dist/views/Request/RequestSection/RequestTable.vue.d.ts.map +1 -1
  208. package/dist/views/Request/RequestSection/RequestTable.vue.js +1 -1
  209. package/dist/views/Request/RequestSection/RequestTable.vue.js.map +1 -1
  210. package/dist/views/Request/RequestSection/RequestTable.vue.script.js +1 -1
  211. package/dist/views/Request/RequestSection/RequestTable.vue.script.js.map +1 -1
  212. package/dist/views/Request/ResponseSection/ResponseEmpty.vue.script.js +1 -1
  213. package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.d.ts.map +1 -1
  214. package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.js.map +1 -1
  215. package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.script.js +2 -2
  216. package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.script.js.map +1 -1
  217. package/dist/views/Request/libs/oauth2.js +1 -1
  218. package/dist/views/Request/libs/oauth2.js.map +1 -1
  219. package/package.json +25 -31
  220. package/dist/libs/formatters.d.ts +0 -12
  221. package/dist/libs/formatters.d.ts.map +0 -1
  222. package/dist/libs/formatters.js +0 -36
  223. package/dist/libs/formatters.js.map +0 -1
  224. package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.d.ts +0 -6
  225. package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.d.ts.map +0 -1
  226. package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.js +0 -58
  227. package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.js.map +0 -1
  228. package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts +0 -12
  229. package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts.map +0 -1
  230. package/dist/v2/blocks/operation-block/helpers/build-request-body.js +0 -65
  231. package/dist/v2/blocks/operation-block/helpers/build-request-body.js.map +0 -1
  232. package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts +0 -31
  233. package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts.map +0 -1
  234. package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.js +0 -55
  235. package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.js.map +0 -1
  236. package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts +0 -27
  237. package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts.map +0 -1
  238. package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js +0 -159
  239. package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js.map +0 -1
  240. package/dist/v2/blocks/operation-block/helpers/build-request-security.d.ts +0 -25
  241. package/dist/v2/blocks/operation-block/helpers/build-request-security.d.ts.map +0 -1
  242. package/dist/v2/blocks/operation-block/helpers/build-request-security.js +0 -53
  243. package/dist/v2/blocks/operation-block/helpers/build-request-security.js.map +0 -1
  244. package/dist/v2/blocks/operation-block/helpers/build-request.d.ts +0 -46
  245. package/dist/v2/blocks/operation-block/helpers/build-request.d.ts.map +0 -1
  246. package/dist/v2/blocks/operation-block/helpers/build-request.js +0 -102
  247. package/dist/v2/blocks/operation-block/helpers/build-request.js.map +0 -1
  248. package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.d.ts +0 -4
  249. package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.d.ts.map +0 -1
  250. package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.js +0 -41
  251. package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.js.map +0 -1
  252. package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.d.ts +0 -14
  253. package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.d.ts.map +0 -1
  254. package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.js +0 -20
  255. package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.js.map +0 -1
  256. package/dist/v2/blocks/operation-block/helpers/get-delimiter.d.ts +0 -8
  257. package/dist/v2/blocks/operation-block/helpers/get-delimiter.d.ts.map +0 -1
  258. package/dist/v2/blocks/operation-block/helpers/get-environment-variables.d.ts +0 -9
  259. package/dist/v2/blocks/operation-block/helpers/get-environment-variables.d.ts.map +0 -1
  260. package/dist/v2/blocks/operation-block/helpers/get-environment-variables.js +0 -17
  261. package/dist/v2/blocks/operation-block/helpers/get-environment-variables.js.map +0 -1
  262. package/dist/v2/blocks/operation-block/helpers/get-example.d.ts +0 -10
  263. package/dist/v2/blocks/operation-block/helpers/get-example.d.ts.map +0 -1
  264. package/dist/v2/blocks/operation-block/helpers/get-example.js +0 -41
  265. package/dist/v2/blocks/operation-block/helpers/get-example.js.map +0 -1
  266. package/dist/v2/blocks/operation-block/helpers/get-resolved-url.d.ts +0 -26
  267. package/dist/v2/blocks/operation-block/helpers/get-resolved-url.d.ts.map +0 -1
  268. package/dist/v2/blocks/operation-block/helpers/get-resolved-url.js +0 -32
  269. package/dist/v2/blocks/operation-block/helpers/get-resolved-url.js.map +0 -1
  270. package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.d.ts +0 -10
  271. package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.d.ts.map +0 -1
  272. package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.js +0 -15
  273. package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.js.map +0 -1
  274. package/dist/v2/blocks/operation-block/helpers/get-server-url.d.ts +0 -3
  275. package/dist/v2/blocks/operation-block/helpers/get-server-url.d.ts.map +0 -1
  276. package/dist/v2/blocks/operation-block/helpers/get-server-url.js +0 -18
  277. package/dist/v2/blocks/operation-block/helpers/get-server-url.js.map +0 -1
  278. package/dist/v2/blocks/operation-block/helpers/serialize-parameter.d.ts +0 -96
  279. package/dist/v2/blocks/operation-block/helpers/serialize-parameter.d.ts.map +0 -1
  280. package/dist/v2/blocks/operation-block/helpers/serialize-parameter.js +0 -160
  281. package/dist/v2/blocks/operation-block/helpers/serialize-parameter.js.map +0 -1
  282. package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts +0 -40
  283. package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts.map +0 -1
  284. package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.js +0 -437
  285. package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.js.map +0 -1
  286. package/dist/v2/blocks/request-block/helpers/get-request-body-example.d.ts +0 -6
  287. package/dist/v2/blocks/request-block/helpers/get-request-body-example.d.ts.map +0 -1
  288. package/dist/v2/blocks/request-block/helpers/get-request-body-example.js +0 -25
  289. package/dist/v2/blocks/request-block/helpers/get-request-body-example.js.map +0 -1
  290. package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.js +0 -141
  291. package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.js.map +0 -1
  292. package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.d.ts +0 -4
  293. package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.d.ts.map +0 -1
  294. package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.js +0 -10
  295. package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.js.map +0 -1
  296. package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.d.ts +0 -9
  297. package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.d.ts.map +0 -1
  298. package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.js +0 -27
  299. package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.js.map +0 -1
  300. package/dist/v2/blocks/scalar-auth-selector-block/helpers/secret-types.d.ts +0 -25
  301. package/dist/v2/blocks/scalar-auth-selector-block/helpers/secret-types.d.ts.map +0 -1
  302. package/dist/v2/components/callout/Callout.vue.js +0 -9
  303. package/dist/v2/components/callout/Callout.vue.js.map +0 -1
  304. package/dist/v2/components/callout/Callout.vue.script.js +0 -35
  305. package/dist/v2/components/callout/Callout.vue.script.js.map +0 -1
  306. package/dist/v2/features/operation/helpers/combine-params.d.ts +0 -4
  307. package/dist/v2/features/operation/helpers/combine-params.d.ts.map +0 -1
  308. package/dist/v2/features/operation/helpers/combine-params.js +0 -20
  309. package/dist/v2/features/operation/helpers/combine-params.js.map +0 -1
  310. package/dist/v2/features/operation/helpers/get-operation-header.d.ts +0 -17
  311. package/dist/v2/features/operation/helpers/get-operation-header.d.ts.map +0 -1
  312. package/dist/v2/features/operation/helpers/get-security-requirements.d.ts +0 -12
  313. package/dist/v2/features/operation/helpers/get-security-requirements.d.ts.map +0 -1
  314. package/dist/v2/features/operation/helpers/get-security-requirements.js +0 -17
  315. package/dist/v2/features/operation/helpers/get-security-requirements.js.map +0 -1
  316. package/dist/v2/features/operation/helpers/get-selected-security.d.ts +0 -15
  317. package/dist/v2/features/operation/helpers/get-selected-security.d.ts.map +0 -1
  318. package/dist/v2/features/operation/helpers/get-selected-security.js +0 -41
  319. package/dist/v2/features/operation/helpers/get-selected-security.js.map +0 -1
  320. package/dist/v2/features/operation/helpers/get-selected-server.d.ts +0 -13
  321. package/dist/v2/features/operation/helpers/get-selected-server.d.ts.map +0 -1
  322. package/dist/v2/features/operation/helpers/get-selected-server.js +0 -21
  323. package/dist/v2/features/operation/helpers/get-selected-server.js.map +0 -1
  324. package/dist/v2/helpers/get-active-environment.d.ts +0 -5
  325. package/dist/v2/helpers/get-active-environment.d.ts.map +0 -1
  326. package/dist/v2/helpers/get-active-environment.js +0 -19
  327. package/dist/v2/helpers/get-active-environment.js.map +0 -1
  328. package/dist/v2/helpers/get-active-proxy-url.d.ts +0 -18
  329. package/dist/v2/helpers/get-active-proxy-url.d.ts.map +0 -1
  330. package/dist/v2/helpers/get-active-proxy-url.js +0 -26
  331. package/dist/v2/helpers/get-active-proxy-url.js.map +0 -1
  332. package/dist/v2/helpers/get-servers.d.ts +0 -23
  333. package/dist/v2/helpers/get-servers.d.ts.map +0 -1
  334. package/dist/v2/helpers/get-servers.js +0 -106
  335. package/dist/v2/helpers/get-servers.js.map +0 -1
  336. package/dist/v2/helpers/index.d.ts +0 -3
  337. package/dist/v2/helpers/index.d.ts.map +0 -1
  338. package/dist/v2/helpers/index.js +0 -3
@@ -1,9 +1,8 @@
1
1
  import { getResolvedRefDeep } from "../get-resolved-ref-deep.js";
2
- import { getExample } from "../../../operation-block/helpers/get-example.js";
3
- import { getExampleFromSchema } from "../get-example-from-schema.js";
2
+ import { getExample, getExampleFromSchema } from "@scalar/workspace-store/request-example";
4
3
  import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
5
- import { unpackProxyObject } from "@scalar/workspace-store/helpers/unpack-proxy";
6
4
  import { json2xml } from "@scalar/helpers/file/json2xml";
5
+ import { unpackProxyObject } from "@scalar/workspace-store/helpers/unpack-proxy";
7
6
  //#region src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.ts
8
7
  /**
9
8
  * Converts an object to an array of form parameters
@@ -1 +1 @@
1
- {"version":3,"file":"process-body.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.ts"],"sourcesContent":["import { json2xml } from '@scalar/helpers/file/json2xml'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport type {\n MediaTypeObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { getExampleFromSchema } from '@v2/blocks/operation-code-sample/helpers/get-example-from-schema'\nimport { getResolvedRefDeep } from '@v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep'\nimport type { Param, PostData } from 'har-format'\n\nimport { getExample } from '@/v2/blocks/operation-block/helpers/get-example'\n\nimport type { OperationToHarProps } from './operation-to-har'\n\ntype ProcessBodyProps = Pick<OperationToHarProps, 'contentType' | 'example' | 'requestBodyCompositionSelection'> & {\n requestBody: RequestBodyObject\n}\n\ntype MultipartEncodingMap = MediaTypeObject['encoding']\n\n/**\n * Converts an object to an array of form parameters\n * @param obj - The object to convert\n * @returns Array of form parameters with name and value properties\n */\nconst objectToFormParams = (\n obj: object | { name: string; value: unknown; isDisabled: boolean }[],\n encoding?: MultipartEncodingMap,\n parentKey?: string,\n): Param[] => {\n const params: Param[] = []\n\n /** Ensure we do not include disabled items */\n const entries = Array.isArray(obj)\n ? obj.filter((item) => !item.isDisabled).map((item) => [item.name, item.value])\n : Object.entries(obj)\n\n for (const [key, value] of entries) {\n if (value === undefined || value === null) {\n continue\n }\n\n const partContentType = parentKey ? undefined : encoding?.[key]?.contentType\n\n // Handle File objects by converting them to 'BINARY'\n if (value instanceof File) {\n const file = unpackProxyObject(value)\n params.push({ name: key, value: `@${file.name}`, ...(partContentType ? { contentType: partContentType } : {}) })\n }\n // Multipart encodings can override the entire top-level part payload\n else if (partContentType && typeof value === 'object') {\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: partContentType,\n })\n }\n // Handle arrays by adding each item with the same key\n else if (Array.isArray(value)) {\n for (const item of value) {\n // Check if array item is a File\n if (item instanceof File) {\n const file = unpackProxyObject(item)\n params.push({ name: key, value: `@${file.name}` })\n } else {\n params.push({ name: key, value: String(item) })\n }\n }\n }\n // Handle nested objects by flattening them\n else if (typeof value === 'object') {\n const nestedParams = objectToFormParams(value, undefined, key)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({ name: key, value: String(value), ...(partContentType ? { contentType: partContentType } : {}) })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n * Returns undefined if no example is found\n */\nexport const processBody = ({\n requestBody,\n contentType,\n example,\n requestBodyCompositionSelection,\n}: ProcessBodyProps): PostData | undefined => {\n const _contentType = contentType || Object.keys(requestBody.content)[0] || ''\n const formatBinaryFile = (file: File) => {\n const unwrappedFile = unpackProxyObject(file)\n return `@${unwrappedFile.name || 'filename'}`\n }\n const encoding = requestBody.content[_contentType]?.encoding\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n const isXml = _contentType === 'application/xml'\n\n // Get the example value\n const _example = getExample(requestBody, example, contentType)?.value\n\n // Return the provided top level example\n if (typeof _example !== 'undefined') {\n const exampleValue = _example !== null && typeof _example === 'object' ? unpackProxyObject(_example) : _example\n\n if (isFormData && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: _contentType,\n params: objectToFormParams(exampleValue, _contentType === 'multipart/form-data' ? encoding : undefined),\n }\n }\n\n if (isXml && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: _contentType,\n text: json2xml(exampleValue),\n }\n }\n\n if (exampleValue instanceof File) {\n return {\n mimeType: _contentType,\n text: formatBinaryFile(exampleValue),\n }\n }\n\n return {\n mimeType: _contentType,\n text: typeof exampleValue === 'string' ? exampleValue : JSON.stringify(exampleValue),\n }\n }\n\n // Try to extract examples from the schema\n const contentSchema = getResolvedRef(requestBody.content[_contentType]?.schema)\n if (typeof contentSchema !== 'undefined') {\n const resolvedContentSchema = getResolvedRefDeep(contentSchema) as SchemaObject\n const extractedExample = getExampleFromSchema(\n resolvedContentSchema,\n {\n compositionSelection: requestBodyCompositionSelection,\n mode: 'write',\n xml: isXml,\n },\n {\n schemaPath: ['requestBody'],\n },\n )\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: _contentType,\n params: objectToFormParams(extractedExample, _contentType === 'multipart/form-data' ? encoding : undefined),\n }\n }\n\n if (isXml && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: _contentType,\n text: json2xml(extractedExample),\n }\n }\n\n return {\n mimeType: _contentType,\n text: typeof extractedExample === 'string' ? extractedExample : JSON.stringify(extractedExample),\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;;;;;AA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IAC5G;AAGH,OAAI,SAAS,OAAO,qBAAqB,YAAY,qBAAqB,KACxE,QAAO;IACL,UAAU;IACV,MAAM,SAAS,iBAAiB;IACjC;AAGH,UAAO;IACL,UAAU;IACV,MAAM,OAAO,qBAAqB,WAAW,mBAAmB,KAAK,UAAU,iBAAiB;IACjG"}
1
+ {"version":3,"file":"process-body.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.ts"],"sourcesContent":["import { json2xml } from '@scalar/helpers/file/json2xml'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport { getExample, getExampleFromSchema } from '@scalar/workspace-store/request-example'\nimport type {\n MediaTypeObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { getResolvedRefDeep } from '@v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep'\nimport type { Param, PostData } from 'har-format'\n\nimport type { OperationToHarProps } from './operation-to-har'\n\ntype ProcessBodyProps = Pick<OperationToHarProps, 'contentType' | 'example' | 'requestBodyCompositionSelection'> & {\n requestBody: RequestBodyObject\n}\n\ntype MultipartEncodingMap = MediaTypeObject['encoding']\n\n/**\n * Converts an object to an array of form parameters\n * @param obj - The object to convert\n * @returns Array of form parameters with name and value properties\n */\nconst objectToFormParams = (\n obj: object | { name: string; value: unknown; isDisabled: boolean }[],\n encoding?: MultipartEncodingMap,\n parentKey?: string,\n): Param[] => {\n const params: Param[] = []\n\n /** Ensure we do not include disabled items */\n const entries = Array.isArray(obj)\n ? obj.filter((item) => !item.isDisabled).map((item) => [item.name, item.value])\n : Object.entries(obj)\n\n for (const [key, value] of entries) {\n if (value === undefined || value === null) {\n continue\n }\n\n const partContentType = parentKey ? undefined : encoding?.[key]?.contentType\n\n // Handle File objects by converting them to 'BINARY'\n if (value instanceof File) {\n const file = unpackProxyObject(value)\n params.push({ name: key, value: `@${file.name}`, ...(partContentType ? { contentType: partContentType } : {}) })\n }\n // Multipart encodings can override the entire top-level part payload\n else if (partContentType && typeof value === 'object') {\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: partContentType,\n })\n }\n // Handle arrays by adding each item with the same key\n else if (Array.isArray(value)) {\n for (const item of value) {\n // Check if array item is a File\n if (item instanceof File) {\n const file = unpackProxyObject(item)\n params.push({ name: key, value: `@${file.name}` })\n } else {\n params.push({ name: key, value: String(item) })\n }\n }\n }\n // Handle nested objects by flattening them\n else if (typeof value === 'object') {\n const nestedParams = objectToFormParams(value, undefined, key)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({ name: key, value: String(value), ...(partContentType ? { contentType: partContentType } : {}) })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n * Returns undefined if no example is found\n */\nexport const processBody = ({\n requestBody,\n contentType,\n example,\n requestBodyCompositionSelection,\n}: ProcessBodyProps): PostData | undefined => {\n const _contentType = contentType || Object.keys(requestBody.content)[0] || ''\n const formatBinaryFile = (file: File) => {\n const unwrappedFile = unpackProxyObject(file)\n return `@${unwrappedFile.name || 'filename'}`\n }\n const encoding = requestBody.content[_contentType]?.encoding\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n const isXml = _contentType === 'application/xml'\n\n // Get the example value\n const _example = getExample(requestBody, example, contentType)?.value\n\n // Return the provided top level example\n if (typeof _example !== 'undefined') {\n const exampleValue = _example !== null && typeof _example === 'object' ? unpackProxyObject(_example) : _example\n\n if (isFormData && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: _contentType,\n params: objectToFormParams(exampleValue, _contentType === 'multipart/form-data' ? encoding : undefined),\n }\n }\n\n if (isXml && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: _contentType,\n text: json2xml(exampleValue),\n }\n }\n\n if (exampleValue instanceof File) {\n return {\n mimeType: _contentType,\n text: formatBinaryFile(exampleValue),\n }\n }\n\n return {\n mimeType: _contentType,\n text: typeof exampleValue === 'string' ? exampleValue : JSON.stringify(exampleValue),\n }\n }\n\n // Try to extract examples from the schema\n const contentSchema = getResolvedRef(requestBody.content[_contentType]?.schema)\n if (typeof contentSchema !== 'undefined') {\n const resolvedContentSchema = getResolvedRefDeep(contentSchema) as SchemaObject\n const extractedExample = getExampleFromSchema(\n resolvedContentSchema,\n {\n compositionSelection: requestBodyCompositionSelection,\n mode: 'write',\n xml: isXml,\n },\n {\n schemaPath: ['requestBody'],\n },\n )\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: _contentType,\n params: objectToFormParams(extractedExample, _contentType === 'multipart/form-data' ? encoding : undefined),\n }\n }\n\n if (isXml && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: _contentType,\n text: json2xml(extractedExample),\n }\n }\n\n return {\n mimeType: _contentType,\n text: typeof extractedExample === 'string' ? extractedExample : JSON.stringify(extractedExample),\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;;;;AAyBA,IAAM,sBACJ,KACA,UACA,cACY;CACZ,MAAM,SAAkB,EAAE;;CAG1B,MAAM,UAAU,MAAM,QAAQ,IAAI,GAC9B,IAAI,QAAQ,SAAS,CAAC,KAAK,WAAW,CAAC,KAAK,SAAS,CAAC,KAAK,MAAM,KAAK,MAAM,CAAC,GAC7E,OAAO,QAAQ,IAAI;AAEvB,MAAK,MAAM,CAAC,KAAK,UAAU,SAAS;AAClC,MAAI,UAAU,KAAA,KAAa,UAAU,KACnC;EAGF,MAAM,kBAAkB,YAAY,KAAA,IAAY,WAAW,MAAM;AAGjE,MAAI,iBAAiB,MAAM;GACzB,MAAM,OAAO,kBAAkB,MAAM;AACrC,UAAO,KAAK;IAAE,MAAM;IAAK,OAAO,IAAI,KAAK;IAAQ,G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AiB,YAAY,iBAAiB,KACrE,QAAO;GACL,UAAU;GACV,QAAQ,mBAAmB,cAAc,iBAAiB,wBAAwB,WAAW,KAAA,EAAU;GACxG;AAGH,MAAI,SAAS,OAAO,iBAAiB,YAAY,iBAAiB,KAChE,QAAO;GACL,UAAU;GACV,MAAM,SAAS,aAAa;GAC7B;AAGH,MAAI,wBAAwB,KAC1B,QAAO;GACL,UAAU;GACV,MAAM,iBAAiB,aAAa;GACrC;AAGH,SAAO;GACL,UAAU;GACV,MAAM,OAAO,iBAAiB,WAAW,eAAe,KAAK,UAAU,aAAa;GACrF;;CAIH,MAAM,gBAAgB,eAAe,YAAY,QAAQ,eAAe,OAAO;AAC/E,KAAI,OAAO,kBAAkB,aAAa;EAExC,MAAM,mBAAmB,qBADK,mBAAmB,cAAc,EAG7D;GACE,sBAAsB;GACtB,MAAM;GACN,KAAK;GACN,EACD,EACE,YAAY,CAAC,cAAc,EAC5B,CACF;AAED,MAAI,qBAAqB,KAAA,GAAW;AAClC,OAAI,cAAc,OAAO,qBAAqB,YAAY,qBAAqB,KAC7E,QAAO;IACL,UAAU;IACV,QAAQ,mBAAmB,kBAAkB,iBAAiB,wBAAwB,WAAW,KAAA,EAAU;IAC5G;AAGH,OAAI,SAAS,OAAO,qBAAqB,YAAY,qBAAqB,KACxE,QAAO;IACL,UAAU;IACV,MAAM,SAAS,iBAAiB;IACjC;AAGH,UAAO;IACL,UAAU;IACV,MAAM,OAAO,qBAAqB,WAAW,mBAAmB,KAAK,UAAU,iBAAiB;IACjG"}
@@ -12,11 +12,13 @@ type ProcessedParameters = {
12
12
  *
13
13
  * @see https://spec.openapis.org/oas/latest.html#style-values
14
14
  */
15
- export declare const processParameters: ({ harRequest, parameters, example, }: {
15
+ export declare const processParameters: ({ harRequest, parameters, example, defaultDisabled, }: {
16
16
  harRequest: HarRequest;
17
17
  parameters: OperationObject["parameters"];
18
18
  /** The name of the example to use */
19
19
  example?: string | undefined;
20
+ /** Whether to disable parameters by default. */
21
+ defaultDisabled: boolean;
20
22
  }) => ProcessedParameters;
21
23
  export {};
22
24
  //# sourceMappingURL=process-parameters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AAEpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAevD,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAuED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,sCAI/B;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7B,KAAG,mBAuHH,CAAA"}
1
+ {"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AACpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAIvD,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAwED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,uDAK/B;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,gDAAgD;IAChD,eAAe,EAAE,OAAO,CAAA;CACzB,KAAG,mBAuHH,CAAA"}
@@ -1,8 +1,5 @@
1
- import { getExample } from "../../../operation-block/helpers/get-example.js";
2
- import { getExampleFromSchema } from "../get-example-from-schema.js";
3
- import { deSerializeParameter } from "../../../operation-block/helpers/de-serialize-parameter.js";
4
1
  import { isParamDisabled } from "../../../request-block/helpers/is-param-disabled.js";
5
- import { serializeContentValue, serializeDeepObjectStyle, serializeFormStyle, serializeFormStyleForCookies, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle } from "../../../operation-block/helpers/serialize-parameter.js";
2
+ import { deSerializeParameter, getExample, getExampleFromSchema, serializeContentValue, serializeDeepObjectStyle, serializeFormStyle, serializeFormStyleForCookies, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle } from "@scalar/workspace-store/request-example";
6
3
  import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
7
4
  //#region src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts
8
5
  /** Ensures we don't have any references in the parameters */
@@ -37,9 +34,9 @@ var getParameterStyleAndExplode = (param) => {
37
34
  * Prioritizes example data over schema examples.
38
35
  * Returns null if the parameter is disabled so we can skip it.
39
36
  */
40
- var getParameterValue = (param, example, contentType) => {
37
+ var getParameterValue = (param, example, contentType, defaultDisabled) => {
41
38
  const exampleValue = getExample(param, example, contentType);
42
- if (isParamDisabled(param, exampleValue)) return;
39
+ if (isParamDisabled(param, exampleValue, defaultDisabled)) return;
43
40
  if (exampleValue?.value !== void 0) return deSerializeParameter(exampleValue.value, param);
44
41
  if (!("schema" in param) || !param.schema) return;
45
42
  const options = param.in === "path" ? { emptyString: `{${param.name}}` } : {};
@@ -51,14 +48,14 @@ var getParameterValue = (param, example, contentType) => {
51
48
  *
52
49
  * @see https://spec.openapis.org/oas/latest.html#style-values
53
50
  */
54
- var processParameters = ({ harRequest, parameters, example }) => {
51
+ var processParameters = ({ harRequest, parameters, example, defaultDisabled }) => {
55
52
  const newHeaders = [...harRequest.headers];
56
53
  const newQueryString = [...harRequest.queryString];
57
54
  let newUrl = harRequest.url;
58
55
  const deReferencedParams = deReferenceParams(parameters);
59
56
  for (const param of deReferencedParams) {
60
57
  if (!param.in || !param.name) continue;
61
- const paramValue = getParameterValue(param, example, void 0);
58
+ const paramValue = getParameterValue(param, example, void 0, defaultDisabled);
62
59
  if (paramValue === void 0) continue;
63
60
  const { style, explode } = getParameterStyleAndExplode(param);
64
61
  switch (param.in) {
@@ -1 +1 @@
1
- {"version":3,"file":"process-parameters.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { getExampleFromSchema } from '@v2/blocks/operation-code-sample/helpers/get-example-from-schema'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { deSerializeParameter } from '@/v2/blocks/operation-block/helpers/de-serialize-parameter'\nimport { getExample } from '@/v2/blocks/operation-block/helpers/get-example'\nimport {\n serializeContentValue,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@/v2/blocks/operation-block/helpers/serialize-parameter'\nimport { isParamDisabled } from '@/v2/blocks/request-block/helpers/is-param-disabled'\n\ntype ProcessedParameters = {\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param))\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies only support 'form' style\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'form', explode }\n }\n\n const defaultStyle = {\n path: 'simple',\n query: 'form',\n header: 'simple',\n cookie: 'form',\n }[param.in]\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (\n param: ParameterObject,\n example: string | undefined,\n contentType: string | undefined,\n): unknown => {\n // Try to get value from example first\n const exampleValue = getExample(param, example, contentType)\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (exampleValue?.value !== undefined) {\n return deSerializeParameter(exampleValue.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = param.in === 'path' ? { emptyString: `{${param.name}}` } : {}\n return getExampleFromSchema(getResolvedRef(param.schema), options)\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n let newUrl = harRequest.url\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n const paramValue = getParameterValue(param, example, undefined)\n if (paramValue === undefined) {\n continue\n }\n\n const { style, explode } = getParameterStyleAndExplode(param)\n\n switch (param.in) {\n case 'path': {\n newUrl = processPathParameters(newUrl, param, paramValue, style, explode)\n break\n }\n\n case 'query': {\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(paramValue, paramContentType)\n newQueryString.push({ name: param.name, value: serializedValue })\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, 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 || param.name\n newQueryString.push({ name: key, value: String(entry.value) })\n }\n }\n // Otherwise, convert to string\n else {\n newQueryString.push({ name: param.name, value: String(serialized) })\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: serialized })\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: serialized })\n break\n }\n case 'deepObject': {\n if (explode) {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n newQueryString.push({ name: entry.key, value: entry.value })\n }\n }\n break\n }\n\n // Default to form style\n default:\n newQueryString.push({ name: param.name, value: String(paramValue) })\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Cookies only support 'form' style according to OpenAPI 3.1.1\n case 'cookie': {\n const serialized = serializeFormStyleForCookies(paramValue, 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 || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n harRequest.cookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n harRequest.cookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: harRequest.cookies,\n }\n}\n\n/**\n * Process path parameters according to OpenAPI specification.\n * Handles matrix, label, and simple styles with explode options.\n *\n * @param url - The URL to process\n * @param param - The parameter object\n * @param paramValue - The value of the parameter\n * @param style - The style of the parameter (matrix, label, simple)\n * @param explode - Whether to explode the parameter\n * @returns The updated URL with processed path parameters\n */\nconst processPathParameters = (\n url: string,\n param: ParameterObject,\n paramValue: unknown,\n style: string,\n explode: boolean,\n): string => {\n switch (style) {\n case 'matrix': {\n if (explode) {\n // Matrix explode array: ;color=blue;color=black;color=brown\n if (Array.isArray(paramValue)) {\n const values = (paramValue as unknown[]).map((v) => `${param.name}=${v}`).join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode object: ;R=100;G=200;B=150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k}=${v}`)\n .join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n\n // Matrix no explode array: ;color=blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{;${param.name}}`, `;${param.name}=${(paramValue as unknown[]).join(',')}`)\n }\n\n // Matrix no explode object: ;color=R,100,G,200,B,150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n return url.replace(`{;${param.name}}`, `;${param.name}=${values}`)\n }\n\n // Matrix no explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n case 'label': {\n if (explode) {\n // Label explode array: .blue.black.brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${(paramValue as unknown[]).join('.')}`)\n }\n\n // Label explode object: .R=100.G=200.B=150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k}=${v}`)\n .join('.')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n // Label no explode array: .blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${(paramValue as unknown[]).join(',')}`)\n }\n\n // Label no explode object: .R,100,G,200,B,150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label no explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n case 'simple': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n return url.replace(`{${param.name}}`, String(serialized))\n }\n\n // Default to simple style\n default:\n return url.replace(`{${param.name}}`, String(paramValue))\n }\n}\n"],"mappings":";;;;;;;;AA0BA,IAAM,qBAAqB,YACxB,UAAU,EAAE,EAAE,KAAK,UAAU,eAAe,MAAM,CAAC;;;;;AAMtD,IAAM,+BAA+B,UAAgE;AAEnG,KAAI,MAAM,OAAO,SAEf,QA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I,OAAO,WAAW,CAAC;;EAI3D,QACE,QAAO,IAAI,QAAQ,IAAI,MAAM,KAAK,IAAI,OAAO,WAAW,CAAC"}
1
+ {"version":3,"file":"process-parameters.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n deSerializeParameter,\n getExample,\n getExampleFromSchema,\n serializeContentValue,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { isParamDisabled } from '@/v2/blocks/request-block/helpers/is-param-disabled'\n\ntype ProcessedParameters = {\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param))\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies only support 'form' style\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'form', explode }\n }\n\n const defaultStyle = {\n path: 'simple',\n query: 'form',\n header: 'simple',\n cookie: 'form',\n }[param.in]\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (\n param: ParameterObject,\n example: string | undefined,\n contentType: string | undefined,\n defaultDisabled: boolean,\n): unknown => {\n // Try to get value from example first\n const exampleValue = getExample(param, example, contentType)\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue, defaultDisabled)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (exampleValue?.value !== undefined) {\n return deSerializeParameter(exampleValue.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = param.in === 'path' ? { emptyString: `{${param.name}}` } : {}\n return getExampleFromSchema(getResolvedRef(param.schema), options)\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n defaultDisabled,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n /** Whether to disable parameters by default. */\n defaultDisabled: boolean\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n let newUrl = harRequest.url\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n const paramValue = getParameterValue(param, example, undefined, defaultDisabled)\n if (paramValue === undefined) {\n continue\n }\n\n const { style, explode } = getParameterStyleAndExplode(param)\n\n switch (param.in) {\n case 'path': {\n newUrl = processPathParameters(newUrl, param, paramValue, style, explode)\n break\n }\n\n case 'query': {\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(paramValue, paramContentType)\n newQueryString.push({ name: param.name, value: serializedValue })\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, 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 || param.name\n newQueryString.push({ name: key, value: String(entry.value) })\n }\n }\n // Otherwise, convert to string\n else {\n newQueryString.push({ name: param.name, value: String(serialized) })\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: serialized })\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: serialized })\n break\n }\n case 'deepObject': {\n if (explode) {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n newQueryString.push({ name: entry.key, value: entry.value })\n }\n }\n break\n }\n\n // Default to form style\n default:\n newQueryString.push({ name: param.name, value: String(paramValue) })\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Cookies only support 'form' style according to OpenAPI 3.1.1\n case 'cookie': {\n const serialized = serializeFormStyleForCookies(paramValue, 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 || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n harRequest.cookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n harRequest.cookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: harRequest.cookies,\n }\n}\n\n/**\n * Process path parameters according to OpenAPI specification.\n * Handles matrix, label, and simple styles with explode options.\n *\n * @param url - The URL to process\n * @param param - The parameter object\n * @param paramValue - The value of the parameter\n * @param style - The style of the parameter (matrix, label, simple)\n * @param explode - Whether to explode the parameter\n * @returns The updated URL with processed path parameters\n */\nconst processPathParameters = (\n url: string,\n param: ParameterObject,\n paramValue: unknown,\n style: string,\n explode: boolean,\n): string => {\n switch (style) {\n case 'matrix': {\n if (explode) {\n // Matrix explode array: ;color=blue;color=black;color=brown\n if (Array.isArray(paramValue)) {\n const values = (paramValue as unknown[]).map((v) => `${param.name}=${v}`).join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode object: ;R=100;G=200;B=150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k}=${v}`)\n .join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n\n // Matrix no explode array: ;color=blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{;${param.name}}`, `;${param.name}=${(paramValue as unknown[]).join(',')}`)\n }\n\n // Matrix no explode object: ;color=R,100,G,200,B,150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n return url.replace(`{;${param.name}}`, `;${param.name}=${values}`)\n }\n\n // Matrix no explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n case 'label': {\n if (explode) {\n // Label explode array: .blue.black.brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${(paramValue as unknown[]).join('.')}`)\n }\n\n // Label explode object: .R=100.G=200.B=150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k}=${v}`)\n .join('.')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n // Label no explode array: .blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${(paramValue as unknown[]).join(',')}`)\n }\n\n // Label no explode object: .R,100,G,200,B,150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label no explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n case 'simple': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n return url.replace(`{${param.name}}`, String(serialized))\n }\n\n // Default to simple style\n default:\n return url.replace(`{${param.name}}`, String(paramValue))\n }\n}\n"],"mappings":";;;;;AA0BA,IAAM,qBAAqB,YACxB,UAAU,EAAE,EAAE,KAAK,UAAU,eAAe,MAAM,CAAC;;;;;AAMtD,IAAM,+BAA+B,UAAgE;AAEnG,KAAI,MAAM,OAAO,SAEf,QAAO;EAAE,OAAO;EAAU,SADV,aAAa,SAAS,MAAM,YAAY,KAAA,IAAY,MAAM,UAAU;EACjD;AAIrC,KAAI,MAAM,OAAO,SAEf,QAAO;EAAE,OAAO;EAAQ,SADR,aAAa,SAAS,MAAM,YAAY,KAAA,IAAY,MAAM,UAAU;EACnD;CAGnC,MAAM,eAAe;EACnB,MAAM;EACN,OAAO;EACP,QAAQ;EACR,QAAQ;EACT,CAAC,MAAM;CAGR,MAAM,QAAQ,WAAW,SAAS,MAAM,QAAQ,MAAM,QAAQ;AAK9D,QAAO;EAAE;EAAO,SAFA,aAAa,SAAS,MAAM,YAAY,KAAA,IAAY,MAAM,UAAU,UAAU;EAErE;;;;;;;AAQ3B,IAAM,qBACJ,OACA,SACA,aACA,oBACY;CAEZ,MAAM,e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AAO,eAAe,YAAY,eAAe,MAAM;KACzD,MAAM,SAAS,OAAO,QAAQ,WAAsC,CACjE,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,IAAI,CAC5B,KAAK,IAAI;AAEZ,YAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAI,SAAS;;AAItD,WAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAI,aAAa;;AAI1D,OAAI,MAAM,QAAQ,WAAW,CAC3B,QAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAK,WAAyB,KAAK,IAAI,GAAG;AAInF,OAAI,OAAO,eAAe,YAAY,eAAe,MAAM;IACzD,MAAM,SAAS,OAAO,QAAQ,WAAsC,CACjE,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,IAAI,CAC5B,KAAK,IAAI;AAEZ,WAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAI,SAAS;;AAItD,UAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAI,aAAa;EAG1D,KAAK,UAAU;GACb,MAAM,aAAa,qBAAqB,YAAY,QAAQ;AAC5D,UAAO,IAAI,QAAQ,IAAI,MAAM,KAAK,IAAI,OAAO,WAAW,CAAC;;EAI3D,QACE,QAAO,IAAI,QAAQ,IAAI,MAAM,KAAK,IAAI,OAAO,WAAW,CAAC"}
@@ -1,5 +1,5 @@
1
+ import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
1
2
  import type { Request as HarRequest } from 'har-format';
2
- import type { SecuritySchemeObjectSecret } from '../../../../../v2/blocks/scalar-auth-selector-block/helpers/secret-types';
3
3
  type ProcessedSecuritySchemesReturn = {
4
4
  headers: HarRequest['headers'];
5
5
  queryString: HarRequest['queryString'];
@@ -1 +1 @@
1
- {"version":3,"file":"process-security-schemes.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6DAA6D,CAAA;AAE7G,KAAK,8BAA8B,GAAG;IACpC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,iBAAiB,0BAA0B,EAAE,KAC5C,8BAuEF,CAAA"}
1
+ {"version":3,"file":"process-security-schemes.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvD,KAAK,8BAA8B,GAAG;IACpC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,iBAAiB,0BAA0B,EAAE,KAC5C,8BAuEF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"process-security-schemes.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\nimport type { SecuritySchemeObjectSecret } from '@/v2/blocks/scalar-auth-selector-block/helpers/secret-types'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push(param)\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":";;;;;;;AAgBA,IAAa,0BACX,oBACmC;CACnC,MAAM,SAAyC;EAC7C,SAAS,EAAE;EACX,aAAa,EAAE;EACf,SAAS,EAAE;EACZ;AAED,MAAK,MAAM,UAAU,iBAAiB;AAEpC,MAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,QAAQ,OAAO,4BAA4B;AACjD,OAAI,CAAC,OAAO,KACV;GAGF,MAAM,QAAQ;IAAE,MAAM,OAAO;IAAM;IAAO;AAE1C,WAAQ,OAAO,IAAf;IACE,KAAK;AACH,YAAO,QAAQ,KAAK,MAAM;AAC1B;IACF,KAAK;AACH,YAAO,YAAY,KAAK,MAAM;AAC9B;IACF,KAAK;AACH,YAAO,QAAQ,KAAK,MAAM;AAC1B;;AAEJ;;AAIF,MAAI,OAAO,SAAS,QAAQ;AAC1B,OAAI,OAAO,WAAW,SAAS;IAI7B,MAAM,QAAQ,GAHG,OAAO,+BAA+B,GAG7B,GAFT,OAAO,+BAA+B;IAGvD,MAAM,OAAO,UAAU,MAAM,sBAAsB,OAAO,MAAM;AAEhE,WAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,SAAS;KACjB,CAAC;cACO,OAAO,WAAW,UAAU;IACrC,MAAM,QAAQ,OAAO,4BAA4B;AAEjD,WAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,UAAU;KAClB,CAAC;;AAEJ;;AAIF,MAAI,OAAO,SAAS,YAAY,OAAO,OAAO;GAK5C,MAAM,QAJQ,OAAO,OAAO,OAAO,MAAM,CAGtB,MAAM,MAAM,EAAE,yBAAyB,GACrC,4BAA4B;AAEjD,UAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,UAAU;IAClB,CAAC;;;AAIN,QAAO"}
1
+ {"version":3,"file":"process-security-schemes.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push(param)\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":";;;;;;;AAeA,IAAa,0BACX,oBACmC;CACnC,MAAM,SAAyC;EAC7C,SAAS,EAAE;EACX,aAAa,EAAE;EACf,SAAS,EAAE;EACZ;AAED,MAAK,MAAM,UAAU,iBAAiB;AAEpC,MAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,QAAQ,OAAO,4BAA4B;AACjD,OAAI,CAAC,OAAO,KACV;GAGF,MAAM,QAAQ;IAAE,MAAM,OAAO;IAAM;IAAO;AAE1C,WAAQ,OAAO,IAAf;IACE,KAAK;AACH,YAAO,QAAQ,KAAK,MAAM;AAC1B;IACF,KAAK;AACH,YAAO,YAAY,KAAK,MAAM;AAC9B;IACF,KAAK;AACH,YAAO,QAAQ,KAAK,MAAM;AAC1B;;AAEJ;;AAIF,MAAI,OAAO,SAAS,QAAQ;AAC1B,OAAI,OAAO,WAAW,SAAS;IAI7B,MAAM,QAAQ,GAHG,OAAO,+BAA+B,GAG7B,GAFT,OAAO,+BAA+B;IAGvD,MAAM,OAAO,UAAU,MAAM,sBAAsB,OAAO,MAAM;AAEhE,WAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,SAAS;KACjB,CAAC;cACO,OAAO,WAAW,UAAU;IACrC,MAAM,QAAQ,OAAO,4BAA4B;AAEjD,WAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,UAAU;KAClB,CAAC;;AAEJ;;AAIF,MAAI,OAAO,SAAS,YAAY,OAAO,OAAO;GAK5C,MAAM,QAJQ,OAAO,OAAO,OAAO,MAAM,CAGtB,MAAM,MAAM,EAAE,yBAAyB,GACrC,4BAA4B;AAEjD,UAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,UAAU;IAClB,CAAC;;;AAIN,QAAO"}
@@ -3,7 +3,6 @@ export { default as OperationCodeSample } from './components/OperationCodeSample
3
3
  export { filterClientsByQuery } from './helpers/filter-clients-by-query.js';
4
4
  export { DEFAULT_CLIENT, findClient, isClient } from './helpers/find-client.js';
5
5
  export { generateClientOptions } from './helpers/generate-client-options.js';
6
- export { getExampleFromSchema } from './helpers/get-example-from-schema.js';
7
6
  export { getResolvedRefDeep } from './helpers/get-resolved-ref-deep.js';
8
7
  export type { ClientOption, ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from './types';
9
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/v2/blocks/operation-code-sample/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/v2/blocks/operation-code-sample/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
@@ -1,8 +1,7 @@
1
- import { getResolvedRefDeep } from "./helpers/get-resolved-ref-deep.js";
2
- import { getExampleFromSchema } from "./helpers/get-example-from-schema.js";
3
1
  import ExamplePicker_default from "./components/ExamplePicker.vue.js";
2
+ import { getResolvedRefDeep } from "./helpers/get-resolved-ref-deep.js";
4
3
  import { filterClientsByQuery } from "./helpers/filter-clients-by-query.js";
5
4
  import { DEFAULT_CLIENT, findClient, isClient } from "./helpers/find-client.js";
6
5
  import { generateClientOptions } from "./helpers/generate-client-options.js";
7
6
  import OperationCodeSample_default from "./components/OperationCodeSample.vue.js";
8
- export { DEFAULT_CLIENT, ExamplePicker_default as ExamplePicker, OperationCodeSample_default as OperationCodeSample, filterClientsByQuery, findClient, generateClientOptions, getExampleFromSchema, getResolvedRefDeep, isClient };
7
+ export { DEFAULT_CLIENT, ExamplePicker_default as ExamplePicker, OperationCodeSample_default as OperationCodeSample, filterClientsByQuery, findClient, generateClientOptions, getResolvedRefDeep, isClient };
@@ -3,38 +3,36 @@ import type { ClientPlugin } from '@scalar/oas-utils/helpers';
3
3
  import type { WorkspaceStore } from '@scalar/workspace-store/client';
4
4
  import type { SelectedSecurity } from '@scalar/workspace-store/entities/auth';
5
5
  import type { AuthMeta, WorkspaceEventBus } from '@scalar/workspace-store/events';
6
+ import { type MergedSecuritySchemes, type SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
6
7
  import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
7
8
  import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
8
9
  import type { OpenApiDocument, OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
9
10
  import type { ClientLayout } from '../../../hooks/index.js';
10
11
  import type { ClientOptionGroup } from '../../../v2/blocks/operation-code-sample/index.js';
11
- import { type MergedSecuritySchemes } from '../../../v2/blocks/scalar-auth-selector-block/index.js';
12
- import type { SecuritySchemeObjectSecret } from '../../../v2/blocks/scalar-auth-selector-block/helpers/secret-types';
13
- export type ExtendedScalarCookie = XScalarCookie & {
14
- location: 'document' | 'workspace';
15
- };
16
- type __VLS_Props = {
12
+ export type RequestBlockProps = {
17
13
  authMeta: AuthMeta;
18
14
  clientOptions: ClientOptionGroup[];
19
15
  environment: XScalarEnvironment;
20
16
  eventBus: WorkspaceEventBus;
21
17
  exampleKey: string;
22
- globalCookies: ExtendedScalarCookie[];
18
+ workspaceCookies: XScalarCookie[];
19
+ documentCookies: XScalarCookie[];
23
20
  layout: ClientLayout;
24
21
  method: HttpMethod;
25
22
  operation: OperationObject;
26
23
  path: string;
27
24
  plugins: ClientPlugin[];
28
25
  proxyUrl: string;
29
- requestBodyCompositionSelection?: Record<string, number>;
30
26
  securityRequirements: OpenApiDocument['security'];
31
27
  securitySchemes: MergedSecuritySchemes;
28
+ requestBodyCompositionSelection?: Record<string, number>;
32
29
  selectedClient: WorkspaceStore['workspace']['x-scalar-default-client'];
33
30
  selectedSecurity: SelectedSecurity;
34
31
  selectedSecuritySchemes: SecuritySchemeObjectSecret[];
35
32
  server: ServerObject | null;
33
+ defaultHeaders: Record<string, string>;
36
34
  };
37
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
35
+ declare const __VLS_export: import("vue").DefineComponent<RequestBlockProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<RequestBlockProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
36
  declare const _default: typeof __VLS_export;
39
37
  export default _default;
40
38
  //# sourceMappingURL=RequestBlock.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RequestBlock.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/blocks/request-block/RequestBlock.vue"],"names":[],"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M,mCAAmC,CAAA;AAoB1E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa,EAAE,iBAAiB,EAAE,CAAA;IAClC,WAAW,EAAE,kBAAkB,CAAA;IAC/B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,aAAa,EAAE,CAAA;IACjC,eAAe,EAAE,aAAa,EAAE,CAAA;IAChC,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,UAAU,CAAA;IAClB,SAAS,EAAE,eAAe,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,oBAAoB,EAAE,eAAe,CAAC,UAAU,CAAC,CAAA;IACjD,eAAe,EAAE,qBAAqB,CAAA;IACtC,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxD,cAAc,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC,yBAAyB,CAAC,CAAA;IACtE,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,uBAAuB,EAAE,0BAA0B,EAAE,CAAA;IACrD,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACvC,CAAA;AA8tBD,QAAA,MAAM,YAAY,8SAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -2,7 +2,7 @@ import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_exp
2
2
  import RequestBlock_vue_vue_type_script_setup_true_lang_default from "./RequestBlock.vue.script.js";
3
3
  /* empty css */
4
4
  //#region src/v2/blocks/request-block/RequestBlock.vue
5
- var RequestBlock_default = /* @__PURE__ */ _plugin_vue_export_helper_default(RequestBlock_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-e0c182d2"]]);
5
+ var RequestBlock_default = /* @__PURE__ */ _plugin_vue_export_helper_default(RequestBlock_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-2d4e3b5d"]]);
6
6
  //#endregion
7
7
  export { RequestBlock_default as default };
8
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"RequestBlock.vue.js","names":[],"sources":["../../../../src/v2/blocks/request-block/RequestBlock.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarErrorBoundary } from '@scalar/components'\nimport { canMethodHaveBody } from '@scalar/helpers/http/can-method-have-body'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { REGEX } from '@scalar/helpers/regex/regex-helpers'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { SelectedSecurity } from '@scalar/workspace-store/entities/auth'\nimport type {\n ApiReferenceEvents,\n AuthMeta,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OpenApiDocument,\n OperationObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed, ref, useId, watch } from 'vue'\n\nimport SectionFilter from '@/components/SectionFilter.vue'\nimport ViewLayoutSection from '@/components/ViewLayout/ViewLayoutSection.vue'\nimport type { ClientLayout } from '@/hooks'\nimport { filterGlobalCookie } from '@/v2/blocks/operation-block/helpers/filter-global-cookies'\nimport { getExample } from '@/v2/blocks/operation-block/helpers/get-example'\nimport { getResolvedUrl } from '@/v2/blocks/operation-block/helpers/get-resolved-url'\nimport type { ClientOptionGroup } from '@/v2/blocks/operation-code-sample'\nimport RequestBody from '@/v2/blocks/request-block/components/RequestBody.vue'\nimport RequestCodeSnippet from '@/v2/blocks/request-block/components/RequestCodeSnippet.vue'\nimport RequestParams from '@/v2/blocks/request-block/components/RequestParams.vue'\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\nimport { createParameterHandlers } from '@/v2/blocks/request-block/helpers/create-parameter-handlers'\nimport { getDefaultHeaders } from '@/v2/blocks/request-block/helpers/get-default-headers'\nimport { getParameterSchema } from '@/v2/blocks/request-block/helpers/get-parameter-schema'\nimport { groupBy } from '@/v2/blocks/request-block/helpers/group-by'\nimport { isParamDisabled } from '@/v2/blocks/request-block/helpers/is-param-disabled'\nimport {\n AuthSelector,\n type MergedSecuritySchemes,\n} from '@/v2/blocks/scalar-auth-selector-block'\nimport type { SecuritySchemeObjectSecret } from '@/v2/blocks/scalar-auth-selector-block/helpers/secret-types'\n\ntype Filter =\n | 'All'\n | 'Auth'\n | 'Variables'\n | 'Cookies'\n | 'Headers'\n | 'Query'\n | 'Body'\n\nexport type ExtendedScalarCookie = XScalarCookie & {\n location: 'document' | 'workspace'\n}\n\nconst {\n authMeta = { type: 'document' },\n clientOptions,\n environment,\n eventBus,\n exampleKey,\n globalCookies,\n layout,\n method,\n operation,\n path,\n plugins,\n proxyUrl,\n requestBodyCompositionSelection,\n securityRequirements,\n securitySchemes,\n selectedClient,\n selectedSecurity,\n selectedSecuritySchemes,\n server,\n} = defineProps<{\n authMeta: AuthMeta\n clientOptions: ClientOptionGroup[]\n environment: XScalarEnvironment\n eventBus: WorkspaceEventBus\n exampleKey: string\n globalCookies: ExtendedScalarCookie[]\n layout: ClientLayout\n method: HttpMethod\n operation: OperationObject\n path: string\n plugins: ClientPlugin[]\n proxyUrl: string\n requestBodyCompositionSelection?: Record<string, number>\n securityRequirements: OpenApiDocument['security']\n securitySchemes: MergedSecuritySchemes\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n selectedSecurity: SelectedSecurity\n selectedSecuritySchemes: SecuritySchemeObjectSecret[]\n server: ServerObject | null\n}>()\n\n/** Operation metadata used across event emissions */\nconst meta = computed(() => ({\n method,\n path,\n exampleKey,\n}))\n\n/** Parameters grouped by type (path, query, header, cookie) */\nconst sections = computed(() =>\n groupBy(\n operation.parameters?.map((param) => getResolvedRef(param)) ?? [],\n 'in',\n (param) => {\n const example = getExample(param, exampleKey, undefined)\n\n return {\n name: param.name,\n value: example?.value ?? '',\n description: param.description,\n schema: getParameterSchema(param),\n isRequired: param.required,\n isDisabled: isParamDisabled(param, example),\n originalParameter: param,\n } as TableRow\n },\n ),\n)\n\n// Generate a reverse map for fast lookup of headers by the name\nconst headersMap = computed(() =>\n groupBy(\n sections.value.header?.map((it) => ({\n ...it,\n name: it.name.toLowerCase(),\n })) ?? [],\n 'name',\n ),\n)\n\nconst autoGeneratedHeaders = computed(() =>\n getDefaultHeaders({ method, operation, exampleKey }),\n)\n\nconst defaultHeaders = computed(() => {\n const disableParameters =\n operation['x-scalar-disable-parameters']?.['default-headers']?.[\n exampleKey\n ] ?? {}\n\n return autoGeneratedHeaders.value.map((it) => {\n const realHeader = headersMap.value[it.name.toLowerCase()]?.[0]\n\n return {\n name: it.name,\n value: it.defaultValue,\n schema: undefined,\n isOverridden: realHeader && !realHeader?.isDisabled,\n isReadonly: true,\n isDisabled: disableParameters[it.name.toLowerCase()] ?? false,\n } satisfies TableRow\n })\n})\n\nconst headers = computed(() => [\n ...defaultHeaders.value,\n ...(sections.value.header ?? []),\n])\n\nconst defaultCookies = computed(() => {\n const resolvedUrl = getResolvedUrl({\n environment,\n server,\n path,\n pathVariables: {},\n })\n\n const disabledGlobalCookies =\n operation['x-scalar-disable-parameters']?.['global-cookies']?.[\n exampleKey\n ] ?? {}\n\n return (\n globalCookies\n ?.filter((cookie) =>\n filterGlobalCookie({\n cookie,\n url: resolvedUrl,\n // Do not filter global cookies for the default cookies section (it's already filtered in the buildRequestCookieHeader function)\n // This is because we still want to show them on the UI\n disabledGlobalCookies: {},\n }),\n )\n .map((it) => ({\n name: it.name,\n value: it.value,\n globalRoute:\n it.location === 'document'\n ? ({ page: 'document', path: 'cookies' } as const)\n : ({ page: 'workspace', path: 'cookies' } as const),\n isReadonly: true,\n isDisabled: disabledGlobalCookies[it.name.toLowerCase()] ?? false,\n })) ?? ([] satisfies TableRow[])\n )\n})\n\nconst cookies = computed(() => [\n ...(defaultCookies.value ?? []),\n ...(sections.value.cookie ?? []),\n])\n\n/** Currently selected filter for the request sections */\nconst selectedFilter = ref<Filter>('All')\n\n/** Available operation sections */\nconst OPERATION_SECTIONS: readonly Filter[] = [\n 'Auth',\n 'Variables',\n 'Cookies',\n 'Headers',\n 'Query',\n 'Body',\n] as const\n\n/**\n * Pre-generated stable IDs for all possible filter sections.\n * These are created once at setup time to avoid regenerating IDs on re-render.\n */\nconst sectionIds: Record<Filter, string> = {\n All: useId(),\n Auth: useId(),\n Variables: useId(),\n Cookies: useId(),\n Headers: useId(),\n Query: useId(),\n Body: useId(),\n}\n\n/** Filters available based on operation state */\nconst filters = computed<Filter[]>(() => {\n const availableFilters = new Set<Filter>(['All', ...OPERATION_SECTIONS])\n\n if (!sections.value.path?.length) {\n availableFilters.delete('Variables')\n }\n if (!canMethodHaveBody(method)) {\n availableFilters.delete('Body')\n }\n if (isAuthHidden.value) {\n availableFilters.delete('Auth')\n }\n\n return [...availableFilters]\n})\n\n/**\n * Map available filters to their pre-generated stable IDs.\n * Only includes IDs for filters that are currently available.\n */\nconst filterIds = computed(\n () =>\n Object.fromEntries(\n filters.value.map((section) => [section, sectionIds[section]]),\n ) as Record<Filter, string>,\n)\n\n/**\n * Hide auth selector in readonly mode when no security schemes are defined.\n * This keeps the UI clean when there are no authentication options available.\n */\nconst isAuthHidden = computed(\n () => layout === 'modal' && !Object.keys(securitySchemes ?? {}).length,\n)\n\n/**\n * Keep auth available for unauthenticated operations, but collapse it by default\n * in readonly modal layouts unless a requirement or manual selection exists.\n */\nconst isAuthDefaultOpen = computed(\n () =>\n layout !== 'modal' ||\n Boolean(\n securityRequirements?.length || selectedSecurity.selectedSchemes.length,\n ),\n)\n\n/** Get a sensible placeholder for the request name input */\nconst requestNamePlaceholder = computed(() => {\n if (operation.summary) {\n return operation.summary\n }\n const cleanPath = path.replace(REGEX.PROTOCOL, '')\n return cleanPath || 'Request Name'\n})\n\n/** Check if the section should be shown based on the selected filter */\nconst isSectionVisible = (section: Filter): boolean => {\n return selectedFilter.value === 'All' || selectedFilter.value === section\n}\n\n/**\n * Reset filter to 'All' if Body filter is selected but method changes to one that cannot have a body.\n * This prevents showing an empty Body section when switching methods.\n */\nwatch(\n () => method,\n (newMethod) => {\n if (selectedFilter.value === 'Body' && !canMethodHaveBody(newMethod)) {\n selectedFilter.value = 'All'\n }\n },\n)\n\n/** Handle operation summary updates */\nconst handleSummaryUpdate = (event: Event): void => {\n const summary = (event.target as HTMLInputElement).value\n eventBus.emit('operation:update:meta', {\n meta: meta.value,\n payload: { summary: summary.trim() },\n })\n}\n\n/** Parameter handlers */\nconst parameterHandlers = computed(() => ({\n path: createParameterHandlers('path', eventBus, meta.value, {\n context: sections.value.path ?? [],\n }),\n cookie: createParameterHandlers('cookie', eventBus, meta.value, {\n context: cookies.value ?? [],\n globalParameters: defaultCookies.value.length,\n }),\n header: createParameterHandlers('header', eventBus, meta.value, {\n context: headers.value,\n defaultParameters: defaultHeaders.value.length,\n }),\n query: createParameterHandlers('query', eventBus, meta.value, {\n context: sections.value.query ?? [],\n }),\n}))\n\n/** Handle request body content type update */\nconst handleUpdateContentType = (payload: { value: string }): void =>\n eventBus.emit('operation:update:requestBody:contentType', {\n payload: { contentType: payload.value },\n meta: meta.value,\n })\n\n/** Handle request body value update */\nconst handleUpdateBodyValue = ({\n payload,\n contentType,\n}: Pick<\n ApiReferenceEvents['operation:update:requestBody:value'],\n 'payload' | 'contentType'\n>): void => {\n const debounceKey =\n typeof payload === 'string'\n ? `update:requestBody:value-${contentType}`\n : undefined\n\n eventBus.emit(\n 'operation:update:requestBody:value',\n {\n payload,\n contentType,\n meta: meta.value,\n },\n {\n debounceKey,\n },\n )\n}\n\n/** Handle request body value update */\nconst handleUpdateBodyFormValue = ({\n payload,\n contentType,\n}: Pick<\n ApiReferenceEvents['operation:update:requestBody:formValue'],\n 'payload' | 'contentType'\n>): void => {\n const debounceKey = `update:requestBody:${contentType}-form-value`\n\n eventBus.emit(\n 'operation:update:requestBody:formValue',\n {\n payload: payload.map((row) => unpackProxyObject(row, { depth: 1 })),\n contentType,\n meta: meta.value,\n },\n {\n debounceKey,\n },\n )\n}\n\nconst labelRequestNameId = useId()\n\n/** Allow updating the operation extensions for the plugins */\nconst updateOperationExtension = (\n payload: ApiReferenceEvents['operation:update:extension']['payload'],\n): void =>\n eventBus.emit('operation:update:extension', { payload, meta: meta.value })\n</script>\n<template>\n <ViewLayoutSection :aria-label=\"`Request: ${operation.summary}`\">\n <template #title>\n <div\n class=\"group pointer-events-none flex flex-1 items-center gap-1 lg:pr-24\">\n <label\n v-if=\"layout !== 'modal'\"\n class=\"pointer-events-auto absolute top-0 left-0 h-full w-full cursor-text opacity-0\"\n :for=\"labelRequestNameId\" />\n <input\n v-if=\"layout !== 'modal'\"\n :id=\"labelRequestNameId\"\n class=\"text-c-1 group-hover-input pointer-events-auto relative z-10 -ml-0.5 h-8 w-full rounded pl-1.25 has-[:focus-visible]:outline md:-ml-1.25\"\n :placeholder=\"requestNamePlaceholder\"\n :value=\"operation.summary\"\n @blur=\"handleSummaryUpdate\" />\n <span\n v-else\n class=\"text-c-1 flex h-8 items-center\">\n {{ operation.summary }}\n </span>\n </div>\n <SectionFilter\n v-model=\"selectedFilter\"\n :filterIds=\"filterIds\"\n :filters=\"filters\" />\n </template>\n\n <div\n :id=\"filterIds.All\"\n class=\"request-section-content custom-scroll relative flex flex-1 flex-col\"\n :role=\"selectedFilter === 'All' ? 'tabpanel' : 'none'\">\n <!-- Auth Selector -->\n <AuthSelector\n v-show=\"isSectionVisible('Auth') && !isAuthHidden\"\n :id=\"filterIds.Auth\"\n :createAnySecurityScheme=\"layout !== 'modal'\"\n :defaultOpen=\"isAuthDefaultOpen\"\n :environment\n :eventBus\n :meta=\"authMeta\"\n :proxyUrl\n :securityRequirements\n :securitySchemes\n :selectedSecurity\n :selectedSecuritySchemes\n :server\n title=\"Authentication\" />\n\n <!-- Variables (Path Parameters) -->\n <RequestParams\n v-show=\"isSectionVisible('Variables') && sections.path?.length\"\n :id=\"filterIds.Variables\"\n :environment\n :eventBus\n :exampleKey\n :rows=\"sections.path ?? []\"\n :showAddRowPlaceholder=\"false\"\n title=\"Variables\"\n v-on=\"parameterHandlers.path\" />\n\n <!-- Cookies -->\n <RequestParams\n v-show=\"isSectionVisible('Cookies')\"\n :id=\"filterIds.Cookies\"\n :environment\n :eventBus\n :exampleKey\n :rows=\"cookies ?? []\"\n :showAddRowPlaceholder=\"true\"\n title=\"Cookies\"\n v-on=\"parameterHandlers.cookie\" />\n\n <!-- Headers -->\n <RequestParams\n v-show=\"isSectionVisible('Headers')\"\n :id=\"filterIds.Headers\"\n :environment\n :eventBus\n :exampleKey\n :rows=\"headers ?? []\"\n title=\"Headers\"\n v-on=\"parameterHandlers.header\" />\n\n <!-- Query Parameters -->\n <RequestParams\n v-show=\"isSectionVisible('Query')\"\n :id=\"filterIds.Query\"\n :environment\n :eventBus\n :exampleKey\n :rows=\"sections.query ?? []\"\n title=\"Query Parameters\"\n v-on=\"parameterHandlers.query\" />\n\n <!-- Request Body -->\n <RequestBody\n v-show=\"isSectionVisible('Body') && canMethodHaveBody(method)\"\n :id=\"filterIds.Body\"\n :environment\n :exampleKey\n :requestBody=\"getResolvedRef(operation.requestBody)\"\n :requestBodyCompositionSelection\n title=\"Request Body\"\n @update:contentType=\"handleUpdateContentType\"\n @update:formValue=\"handleUpdateBodyFormValue\"\n @update:value=\"handleUpdateBodyValue\" />\n\n <!-- Inject request section plugin components -->\n <ScalarErrorBoundary\n v-for=\"(plugin, index) in plugins\"\n :key=\"index\">\n <component\n :is=\"plugin.components.request.component\"\n v-if=\"plugin?.components?.request\"\n v-show=\"selectedFilter === 'All'\"\n :operation\n v-bind=\"plugin.components.request.additionalProps\"\n @operation:update:extension=\"updateOperationExtension\" />\n </ScalarErrorBoundary>\n\n <!-- Spacer -->\n <div class=\"flex grow\" />\n <!-- Code Snippet -->\n <RequestCodeSnippet\n v-show=\"selectedFilter === 'All'\"\n :clientOptions\n :eventBus\n :globalCookies=\"globalCookies\"\n integration=\"client\"\n :method\n :operation\n :path\n :securitySchemes=\"selectedSecuritySchemes\"\n :selectedClient\n :selectedContentType=\"\n getResolvedRef(operation.requestBody)?.[\n 'x-scalar-selected-content-type'\n ]?.[exampleKey]\n \"\n :selectedServer=\"server ?? undefined\" />\n </div>\n </ViewLayoutSection>\n</template>\n<style scoped>\n.request-section-content {\n --scalar-border-width: 0.5px;\n}\n.request-section-content-filter {\n box-shadow: 0 -10px 0 10px var(--scalar-background-1);\n}\n.request-item:focus-within .request-meta-buttons {\n opacity: 1;\n}\n.group-hover-input {\n border-width: var(--scalar-border-width);\n border-color: transparent;\n}\n.group:hover .group-hover-input {\n background: color-mix(\n in srgb,\n var(--scalar-background-1),\n var(--scalar-background-2)\n );\n border-color: var(--scalar-border-color);\n}\n.group-hover-input:focus {\n background: transparent !important;\n border-color: var(--scalar-border-color) !important;\n}\n</style>\n"],"mappings":""}
1
+ {"version":3,"file":"RequestBlock.vue.js","names":[],"sources":["../../../../src/v2/blocks/request-block/RequestBlock.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarErrorBoundary } from '@scalar/components'\nimport { canMethodHaveBody } from '@scalar/helpers/http/can-method-have-body'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { REGEX } from '@scalar/helpers/regex/regex-helpers'\nimport { replaceEnvVariables } from '@scalar/helpers/regex/replace-variables'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { SelectedSecurity } from '@scalar/workspace-store/entities/auth'\nimport type {\n ApiReferenceEvents,\n AuthMeta,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport {\n filterGlobalCookie,\n getEnvironmentVariables,\n getExample,\n getResolvedUrl,\n type MergedSecuritySchemes,\n type SecuritySchemeObjectSecret,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OpenApiDocument,\n OperationObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed, ref, useId, watch } from 'vue'\n\nimport SectionFilter from '@/components/SectionFilter.vue'\nimport ViewLayoutSection from '@/components/ViewLayout/ViewLayoutSection.vue'\nimport type { ClientLayout } from '@/hooks'\nimport type { ClientOptionGroup } from '@/v2/blocks/operation-code-sample'\nimport RequestBody from '@/v2/blocks/request-block/components/RequestBody.vue'\nimport RequestCodeSnippet from '@/v2/blocks/request-block/components/RequestCodeSnippet.vue'\nimport RequestParams from '@/v2/blocks/request-block/components/RequestParams.vue'\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\nimport { createParameterHandlers } from '@/v2/blocks/request-block/helpers/create-parameter-handlers'\nimport { getParameterSchema } from '@/v2/blocks/request-block/helpers/get-parameter-schema'\nimport { groupBy } from '@/v2/blocks/request-block/helpers/group-by'\nimport { isParamDisabled } from '@/v2/blocks/request-block/helpers/is-param-disabled'\nimport { AuthSelector } from '@/v2/blocks/scalar-auth-selector-block'\n\ntype Filter =\n | 'All'\n | 'Auth'\n | 'Variables'\n | 'Cookies'\n | 'Headers'\n | 'Query'\n | 'Body'\n\nexport type RequestBlockProps = {\n authMeta: AuthMeta\n clientOptions: ClientOptionGroup[]\n environment: XScalarEnvironment\n eventBus: WorkspaceEventBus\n exampleKey: string\n workspaceCookies: XScalarCookie[]\n documentCookies: XScalarCookie[]\n layout: ClientLayout\n method: HttpMethod\n operation: OperationObject\n path: string\n plugins: ClientPlugin[]\n proxyUrl: string\n securityRequirements: OpenApiDocument['security']\n securitySchemes: MergedSecuritySchemes\n requestBodyCompositionSelection?: Record<string, number>\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n selectedSecurity: SelectedSecurity\n selectedSecuritySchemes: SecuritySchemeObjectSecret[]\n server: ServerObject | null\n defaultHeaders: Record<string, string>\n}\n\nconst {\n authMeta = { type: 'document' },\n clientOptions,\n environment,\n eventBus,\n exampleKey,\n workspaceCookies,\n documentCookies,\n layout,\n method,\n operation,\n path,\n plugins,\n proxyUrl,\n requestBodyCompositionSelection,\n securityRequirements,\n securitySchemes,\n selectedClient,\n selectedSecurity,\n selectedSecuritySchemes,\n server,\n defaultHeaders: autoGeneratedHeaders,\n} = defineProps<RequestBlockProps>()\n\n/** Operation metadata used across event emissions */\nconst meta = computed(() => ({\n method,\n path,\n exampleKey,\n}))\n\n/** Parameters grouped by type (path, query, header, cookie) */\nconst sections = computed(() =>\n groupBy(\n operation.parameters?.map((param) => getResolvedRef(param)) ?? [],\n 'in',\n (param) => {\n const example = getExample(param, exampleKey, undefined)\n\n return {\n name: param.name,\n value: example?.value ?? '',\n description: param.description,\n schema: getParameterSchema(param),\n isRequired: param.required,\n isDisabled: isParamDisabled(param, example),\n originalParameter: param,\n } as TableRow\n },\n ),\n)\n\n// Generate a reverse map for fast lookup of headers by the name\nconst headersMap = computed(() =>\n groupBy(\n sections.value.header?.map((it) => ({\n ...it,\n name: it.name.toLowerCase(),\n })) ?? [],\n 'name',\n ),\n)\n\nconst defaultHeaders = computed(() => {\n const disableParameters =\n operation['x-scalar-disable-parameters']?.['default-headers']?.[\n exampleKey\n ] ?? {}\n\n const isOverridden = (name: string) => {\n const header = headersMap.value[name.toLowerCase()]?.[0]\n\n if (!header) {\n return false\n }\n\n return !header.isDisabled\n }\n\n return Object.entries(autoGeneratedHeaders).map(([name, value]) => {\n return {\n name,\n value,\n schema: undefined,\n isOverridden: isOverridden(name),\n isReadonly: true,\n isDisabled: disableParameters[name.toLowerCase()] ?? false,\n } satisfies TableRow\n })\n})\n\nconst headers = computed(() => [\n ...defaultHeaders.value,\n ...(sections.value.header ?? []),\n])\n\nconst defaultCookies = computed(() => {\n const environmentVariables = getEnvironmentVariables(environment)\n const resolvedUrl = getResolvedUrl({\n server,\n path,\n })\n const url = replaceEnvVariables(resolvedUrl, environmentVariables)\n\n const disabledGlobalCookies =\n operation['x-scalar-disable-parameters']?.['global-cookies']?.[\n exampleKey\n ] ?? {}\n\n const transform = (\n cookie: XScalarCookie,\n location: 'document' | 'workspace',\n ) => {\n return {\n name: cookie.name,\n value: cookie.value,\n globalRoute: { page: location, path: 'cookies' } as const,\n isReadonly: true,\n isDisabled: disabledGlobalCookies[cookie.name.toLowerCase()] ?? false,\n } satisfies TableRow\n }\n\n const globalCookies = [\n {\n location: 'workspace',\n cookies: workspaceCookies,\n },\n {\n location: 'document',\n cookies: documentCookies,\n },\n ] as const\n\n return globalCookies.flatMap(({ location, cookies }) => {\n return cookies\n .filter((cookie) =>\n filterGlobalCookie({\n cookie,\n url,\n disabledGlobalCookies: {},\n }),\n )\n .map((cookie) => transform(cookie, location))\n })\n})\n\nconst cookies = computed(() => [\n ...(defaultCookies.value ?? []),\n ...(sections.value.cookie ?? []),\n])\n\n/** Currently selected filter for the request sections */\nconst selectedFilter = ref<Filter>('All')\n\n/** Available operation sections */\nconst OPERATION_SECTIONS: readonly Filter[] = [\n 'Auth',\n 'Variables',\n 'Cookies',\n 'Headers',\n 'Query',\n 'Body',\n] as const\n\n/**\n * Pre-generated stable IDs for all possible filter sections.\n * These are created once at setup time to avoid regenerating IDs on re-render.\n */\nconst sectionIds: Record<Filter, string> = {\n All: useId(),\n Auth: useId(),\n Variables: useId(),\n Cookies: useId(),\n Headers: useId(),\n Query: useId(),\n Body: useId(),\n}\n\n/** Filters available based on operation state */\nconst filters = computed<Filter[]>(() => {\n const availableFilters = new Set<Filter>(['All', ...OPERATION_SECTIONS])\n\n if (!sections.value.path?.length) {\n availableFilters.delete('Variables')\n }\n if (!canMethodHaveBody(method)) {\n availableFilters.delete('Body')\n }\n if (isAuthHidden.value) {\n availableFilters.delete('Auth')\n }\n\n return [...availableFilters]\n})\n\n/**\n * Map available filters to their pre-generated stable IDs.\n * Only includes IDs for filters that are currently available.\n */\nconst filterIds = computed(\n () =>\n Object.fromEntries(\n filters.value.map((section) => [section, sectionIds[section]]),\n ) as Record<Filter, string>,\n)\n\n/**\n * Hide auth selector in readonly mode when no security schemes are defined.\n * This keeps the UI clean when there are no authentication options available.\n */\nconst isAuthHidden = computed(\n () => layout === 'modal' && !Object.keys(securitySchemes ?? {}).length,\n)\n\n/**\n * Keep auth available for unauthenticated operations, but collapse it by default\n * in readonly modal layouts unless a requirement or manual selection exists.\n */\nconst isAuthDefaultOpen = computed(\n () =>\n layout !== 'modal' ||\n Boolean(\n securityRequirements?.length || selectedSecurity.selectedSchemes.length,\n ),\n)\n\n/** Get a sensible placeholder for the request name input */\nconst requestNamePlaceholder = computed(() => {\n if (operation.summary) {\n return operation.summary\n }\n const cleanPath = path.replace(REGEX.PROTOCOL, '')\n return cleanPath || 'Request Name'\n})\n\n/** Check if the section should be shown based on the selected filter */\nconst isSectionVisible = (section: Filter): boolean => {\n return selectedFilter.value === 'All' || selectedFilter.value === section\n}\n\n/**\n * Reset filter to 'All' if Body filter is selected but method changes to one that cannot have a body.\n * This prevents showing an empty Body section when switching methods.\n */\nwatch(\n () => method,\n (newMethod) => {\n if (selectedFilter.value === 'Body' && !canMethodHaveBody(newMethod)) {\n selectedFilter.value = 'All'\n }\n },\n)\n\n/** Handle operation summary updates */\nconst handleSummaryUpdate = (event: Event): void => {\n const summary = (event.target as HTMLInputElement).value\n eventBus.emit('operation:update:meta', {\n meta: meta.value,\n payload: { summary: summary.trim() },\n })\n}\n\n/** Parameter handlers */\nconst parameterHandlers = computed(() => ({\n path: createParameterHandlers('path', eventBus, meta.value, {\n context: sections.value.path ?? [],\n }),\n cookie: createParameterHandlers('cookie', eventBus, meta.value, {\n context: cookies.value ?? [],\n globalParameters: defaultCookies.value.length,\n }),\n header: createParameterHandlers('header', eventBus, meta.value, {\n context: headers.value,\n defaultParameters: defaultHeaders.value.length,\n }),\n query: createParameterHandlers('query', eventBus, meta.value, {\n context: sections.value.query ?? [],\n }),\n}))\n\n/** Handle request body content type update */\nconst handleUpdateContentType = (payload: { value: string }): void =>\n eventBus.emit('operation:update:requestBody:contentType', {\n payload: { contentType: payload.value },\n meta: meta.value,\n })\n\n/** Handle request body value update */\nconst handleUpdateBodyValue = ({\n payload,\n contentType,\n}: Pick<\n ApiReferenceEvents['operation:update:requestBody:value'],\n 'payload' | 'contentType'\n>): void => {\n const debounceKey =\n typeof payload === 'string'\n ? `update:requestBody:value-${contentType}`\n : undefined\n\n eventBus.emit(\n 'operation:update:requestBody:value',\n {\n payload,\n contentType,\n meta: meta.value,\n },\n {\n debounceKey,\n },\n )\n}\n\n/** Handle request body value update */\nconst handleUpdateBodyFormValue = ({\n payload,\n contentType,\n}: Pick<\n ApiReferenceEvents['operation:update:requestBody:formValue'],\n 'payload' | 'contentType'\n>): void => {\n const debounceKey = `update:requestBody:${contentType}-form-value`\n\n eventBus.emit(\n 'operation:update:requestBody:formValue',\n {\n payload: payload.map((row) => unpackProxyObject(row, { depth: 1 })),\n contentType,\n meta: meta.value,\n },\n {\n debounceKey,\n },\n )\n}\n\nconst labelRequestNameId = useId()\n\nconst globalCookies = computed(() => [...workspaceCookies, ...documentCookies])\n\n/** Allow updating the operation extensions for the plugins */\nconst updateOperationExtension = (\n payload: ApiReferenceEvents['operation:update:extension']['payload'],\n): void =>\n eventBus.emit('operation:update:extension', { payload, meta: meta.value })\n</script>\n<template>\n <ViewLayoutSection :aria-label=\"`Request: ${operation.summary}`\">\n <template #title>\n <div\n class=\"group pointer-events-none flex flex-1 items-center gap-1 lg:pr-24\">\n <label\n v-if=\"layout !== 'modal'\"\n class=\"pointer-events-auto absolute top-0 left-0 h-full w-full cursor-text opacity-0\"\n :for=\"labelRequestNameId\" />\n <input\n v-if=\"layout !== 'modal'\"\n :id=\"labelRequestNameId\"\n class=\"text-c-1 group-hover-input pointer-events-auto relative z-10 -ml-0.5 h-8 w-full rounded pl-1.25 has-[:focus-visible]:outline md:-ml-1.25\"\n :placeholder=\"requestNamePlaceholder\"\n :value=\"operation.summary\"\n @blur=\"handleSummaryUpdate\" />\n <span\n v-else\n class=\"text-c-1 flex h-8 items-center\">\n {{ operation.summary }}\n </span>\n </div>\n <SectionFilter\n v-model=\"selectedFilter\"\n :filterIds=\"filterIds\"\n :filters=\"filters\" />\n </template>\n\n <div\n :id=\"filterIds.All\"\n class=\"request-section-content custom-scroll relative flex flex-1 flex-col\"\n :role=\"selectedFilter === 'All' ? 'tabpanel' : 'none'\">\n <!-- Auth Selector -->\n <AuthSelector\n v-show=\"isSectionVisible('Auth') && !isAuthHidden\"\n :id=\"filterIds.Auth\"\n :createAnySecurityScheme=\"layout !== 'modal'\"\n :defaultOpen=\"isAuthDefaultOpen\"\n :environment\n :eventBus\n :meta=\"authMeta\"\n :proxyUrl\n :securityRequirements\n :securitySchemes\n :selectedSecurity\n :selectedSecuritySchemes\n :server\n title=\"Authentication\" />\n\n <!-- Variables (Path Parameters) -->\n <RequestParams\n v-show=\"isSectionVisible('Variables') && sections.path?.length\"\n :id=\"filterIds.Variables\"\n :environment\n :eventBus\n :exampleKey\n :rows=\"sections.path ?? []\"\n :showAddRowPlaceholder=\"false\"\n title=\"Variables\"\n v-on=\"parameterHandlers.path\" />\n\n <!-- Cookies -->\n <RequestParams\n v-show=\"isSectionVisible('Cookies')\"\n :id=\"filterIds.Cookies\"\n :environment\n :eventBus\n :exampleKey\n :rows=\"cookies ?? []\"\n :showAddRowPlaceholder=\"true\"\n title=\"Cookies\"\n v-on=\"parameterHandlers.cookie\" />\n\n <!-- Headers -->\n <RequestParams\n v-show=\"isSectionVisible('Headers')\"\n :id=\"filterIds.Headers\"\n :environment\n :eventBus\n :exampleKey\n :rows=\"headers ?? []\"\n title=\"Headers\"\n v-on=\"parameterHandlers.header\" />\n\n <!-- Query Parameters -->\n <RequestParams\n v-show=\"isSectionVisible('Query')\"\n :id=\"filterIds.Query\"\n :environment\n :eventBus\n :exampleKey\n :rows=\"sections.query ?? []\"\n title=\"Query Parameters\"\n v-on=\"parameterHandlers.query\" />\n\n <!-- Request Body -->\n <RequestBody\n v-show=\"isSectionVisible('Body') && canMethodHaveBody(method)\"\n :id=\"filterIds.Body\"\n :environment\n :exampleKey\n :requestBody=\"getResolvedRef(operation.requestBody)\"\n :requestBodyCompositionSelection\n title=\"Request Body\"\n @update:contentType=\"handleUpdateContentType\"\n @update:formValue=\"handleUpdateBodyFormValue\"\n @update:value=\"handleUpdateBodyValue\" />\n\n <!-- Inject request section plugin components -->\n <ScalarErrorBoundary\n v-for=\"(plugin, index) in plugins\"\n :key=\"index\">\n <component\n :is=\"plugin.components.request.component\"\n v-if=\"plugin?.components?.request\"\n v-show=\"selectedFilter === 'All'\"\n :operation\n v-bind=\"plugin.components.request.additionalProps\"\n @operation:update:extension=\"updateOperationExtension\" />\n </ScalarErrorBoundary>\n\n <!-- Spacer -->\n <div class=\"flex grow\" />\n <!-- Code Snippet -->\n <RequestCodeSnippet\n v-show=\"selectedFilter === 'All'\"\n :clientOptions\n :eventBus\n :globalCookies\n integration=\"client\"\n :method\n :operation\n :path\n :securitySchemes=\"selectedSecuritySchemes\"\n :selectedClient\n :selectedContentType=\"\n getResolvedRef(operation.requestBody)?.[\n 'x-scalar-selected-content-type'\n ]?.[exampleKey]\n \"\n :selectedServer=\"server ?? undefined\" />\n </div>\n </ViewLayoutSection>\n</template>\n<style scoped>\n.request-section-content {\n --scalar-border-width: 0.5px;\n}\n.request-section-content-filter {\n box-shadow: 0 -10px 0 10px var(--scalar-background-1);\n}\n.request-item:focus-within .request-meta-buttons {\n opacity: 1;\n}\n.group-hover-input {\n border-width: var(--scalar-border-width);\n border-color: transparent;\n}\n.group:hover .group-hover-input {\n background: color-mix(\n in srgb,\n var(--scalar-background-1),\n var(--scalar-background-2)\n );\n border-color: var(--scalar-border-color);\n}\n.group-hover-input:focus {\n background: transparent !important;\n border-color: var(--scalar-border-color) !important;\n}\n</style>\n"],"mappings":""}
@@ -1,7 +1,3 @@
1
- import { getExample } from "../operation-block/helpers/get-example.js";
2
- import { getResolvedUrl } from "../operation-block/helpers/get-resolved-url.js";
3
- import { getDefaultHeaders } from "./helpers/get-default-headers.js";
4
- import { filterGlobalCookie } from "../operation-block/helpers/filter-global-cookies.js";
5
1
  import { isParamDisabled } from "./helpers/is-param-disabled.js";
6
2
  import SectionFilter_default from "../../../components/SectionFilter.vue.js";
7
3
  import ViewLayoutSection_default from "../../../components/ViewLayout/ViewLayoutSection.vue.js";
@@ -14,9 +10,11 @@ import { groupBy } from "./helpers/group-by.js";
14
10
  import AuthSelector_default from "../scalar-auth-selector-block/components/AuthSelector.vue.js";
15
11
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, mergeProps, openBlock, ref, renderList, resolveDynamicComponent, toDisplayString, toHandlers, unref, useId, vShow, watch, withCtx, withDirectives } from "vue";
16
12
  import { ScalarErrorBoundary } from "@scalar/components";
13
+ import { filterGlobalCookie, getEnvironmentVariables, getExample, getResolvedUrl } from "@scalar/workspace-store/request-example";
17
14
  import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
18
- import { unpackProxyObject } from "@scalar/workspace-store/helpers/unpack-proxy";
19
15
  import { canMethodHaveBody } from "@scalar/helpers/http/can-method-have-body";
16
+ import { unpackProxyObject } from "@scalar/workspace-store/helpers/unpack-proxy";
17
+ import { replaceEnvVariables } from "@scalar/helpers/regex/replace-variables";
20
18
  import { REGEX } from "@scalar/helpers/regex/regex-helpers";
21
19
  //#region src/v2/blocks/request-block/RequestBlock.vue?vue&type=script&setup=true&lang.ts
22
20
  var _hoisted_1 = { class: "group pointer-events-none flex flex-1 items-center gap-1 lg:pr-24" };
@@ -39,20 +37,22 @@ var RequestBlock_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
39
37
  environment: {},
40
38
  eventBus: {},
41
39
  exampleKey: {},
42
- globalCookies: {},
40
+ workspaceCookies: {},
41
+ documentCookies: {},
43
42
  layout: {},
44
43
  method: {},
45
44
  operation: {},
46
45
  path: {},
47
46
  plugins: {},
48
47
  proxyUrl: {},
49
- requestBodyCompositionSelection: {},
50
48
  securityRequirements: {},
51
49
  securitySchemes: {},
50
+ requestBodyCompositionSelection: {},
52
51
  selectedClient: {},
53
52
  selectedSecurity: {},
54
53
  selectedSecuritySchemes: {},
55
- server: {}
54
+ server: {},
55
+ defaultHeaders: {}
56
56
  },
57
57
  setup(__props) {
58
58
  /** Operation metadata used across event emissions */
@@ -78,51 +78,57 @@ var RequestBlock_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
78
78
  ...it,
79
79
  name: it.name.toLowerCase()
80
80
  })) ?? [], "name"));
81
- const autoGeneratedHeaders = computed(() => getDefaultHeaders({
82
- method: __props.method,
83
- operation: __props.operation,
84
- exampleKey: __props.exampleKey
85
- }));
86
81
  const defaultHeaders = computed(() => {
87
82
  const disableParameters = __props.operation["x-scalar-disable-parameters"]?.["default-headers"]?.[__props.exampleKey] ?? {};
88
- return autoGeneratedHeaders.value.map((it) => {
89
- const realHeader = headersMap.value[it.name.toLowerCase()]?.[0];
83
+ const isOverridden = (name) => {
84
+ const header = headersMap.value[name.toLowerCase()]?.[0];
85
+ if (!header) return false;
86
+ return !header.isDisabled;
87
+ };
88
+ return Object.entries(__props.defaultHeaders).map(([name, value]) => {
90
89
  return {
91
- name: it.name,
92
- value: it.defaultValue,
90
+ name,
91
+ value,
93
92
  schema: void 0,
94
- isOverridden: realHeader && !realHeader?.isDisabled,
93
+ isOverridden: isOverridden(name),
95
94
  isReadonly: true,
96
- isDisabled: disableParameters[it.name.toLowerCase()] ?? false
95
+ isDisabled: disableParameters[name.toLowerCase()] ?? false
97
96
  };
98
97
  });
99
98
  });
100
99
  const headers = computed(() => [...defaultHeaders.value, ...sections.value.header ?? []]);
101
100
  const defaultCookies = computed(() => {
102
- const resolvedUrl = getResolvedUrl({
103
- environment: __props.environment,
101
+ const environmentVariables = getEnvironmentVariables(__props.environment);
102
+ const url = replaceEnvVariables(getResolvedUrl({
104
103
  server: __props.server,
105
- path: __props.path,
106
- pathVariables: {}
107
- });
104
+ path: __props.path
105
+ }), environmentVariables);
108
106
  const disabledGlobalCookies = __props.operation["x-scalar-disable-parameters"]?.["global-cookies"]?.[__props.exampleKey] ?? {};
109
- return __props.globalCookies?.filter((cookie) => filterGlobalCookie({
110
- cookie,
111
- url: resolvedUrl,
112
- disabledGlobalCookies: {}
113
- })).map((it) => ({
114
- name: it.name,
115
- value: it.value,
116
- globalRoute: it.location === "document" ? {
117
- page: "document",
118
- path: "cookies"
119
- } : {
120
- page: "workspace",
121
- path: "cookies"
122
- },
123
- isReadonly: true,
124
- isDisabled: disabledGlobalCookies[it.name.toLowerCase()] ?? false
125
- })) ?? [];
107
+ const transform = (cookie, location) => {
108
+ return {
109
+ name: cookie.name,
110
+ value: cookie.value,
111
+ globalRoute: {
112
+ page: location,
113
+ path: "cookies"
114
+ },
115
+ isReadonly: true,
116
+ isDisabled: disabledGlobalCookies[cookie.name.toLowerCase()] ?? false
117
+ };
118
+ };
119
+ return [{
120
+ location: "workspace",
121
+ cookies: __props.workspaceCookies
122
+ }, {
123
+ location: "document",
124
+ cookies: __props.documentCookies
125
+ }].flatMap(({ location, cookies }) => {
126
+ return cookies.filter((cookie) => filterGlobalCookie({
127
+ cookie,
128
+ url,
129
+ disabledGlobalCookies: {}
130
+ })).map((cookie) => transform(cookie, location));
131
+ });
126
132
  });
127
133
  const cookies = computed(() => [...defaultCookies.value ?? [], ...sections.value.cookie ?? []]);
128
134
  /** Currently selected filter for the request sections */
@@ -233,6 +239,7 @@ var RequestBlock_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
233
239
  }, { debounceKey });
234
240
  };
235
241
  const labelRequestNameId = useId();
242
+ const globalCookies = computed(() => [...__props.workspaceCookies, ...__props.documentCookies]);
236
243
  /** Allow updating the operation extensions for the plugins */
237
244
  const updateOperationExtension = (payload) => __props.eventBus.emit("operation:update:extension", {
238
245
  payload,
@@ -382,7 +389,7 @@ var RequestBlock_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
382
389
  withDirectives(createVNode(RequestCodeSnippet_default, {
383
390
  clientOptions: __props.clientOptions,
384
391
  eventBus: __props.eventBus,
385
- globalCookies: __props.globalCookies,
392
+ globalCookies: globalCookies.value,
386
393
  integration: "client",
387
394
  method: __props.method,
388
395
  operation: __props.operation,