@scalar/workspace-store 0.40.2 → 0.40.3

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 (354) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/client.d.ts +7 -2
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +820 -681
  5. package/dist/entities/auth/index.js +96 -101
  6. package/dist/entities/auth/schema.js +42 -116
  7. package/dist/entities/history/index.js +80 -60
  8. package/dist/entities/history/schema.js +94 -88
  9. package/dist/events/bus.js +146 -93
  10. package/dist/events/definitions/analytics.js +1 -1
  11. package/dist/events/definitions/auth.js +1 -1
  12. package/dist/events/definitions/common.js +1 -1
  13. package/dist/events/definitions/cookie.js +1 -1
  14. package/dist/events/definitions/document.js +1 -1
  15. package/dist/events/definitions/environment.js +1 -1
  16. package/dist/events/definitions/hooks.js +1 -1
  17. package/dist/events/definitions/index.js +1 -1
  18. package/dist/events/definitions/meta.js +1 -1
  19. package/dist/events/definitions/operation.js +1 -1
  20. package/dist/events/definitions/server.js +1 -1
  21. package/dist/events/definitions/tabs.js +1 -1
  22. package/dist/events/definitions/tag.js +1 -1
  23. package/dist/events/definitions/ui.js +1 -1
  24. package/dist/events/definitions/workspace.js +1 -1
  25. package/dist/events/index.js +3 -9
  26. package/dist/events/listeners.js +20 -22
  27. package/dist/events/old-definitions.js +15 -12
  28. package/dist/helpers/deep-clone.js +33 -17
  29. package/dist/helpers/detect-changes-proxy.js +95 -57
  30. package/dist/helpers/general.js +78 -23
  31. package/dist/helpers/generate-unique-value.js +77 -45
  32. package/dist/helpers/get-fetch.js +12 -10
  33. package/dist/helpers/get-resolved-ref.js +11 -10
  34. package/dist/helpers/is-non-optional-security-requirement.js +3 -6
  35. package/dist/helpers/merge-object.js +71 -30
  36. package/dist/helpers/overrides-proxy.js +98 -58
  37. package/dist/helpers/unpack-proxy.js +60 -58
  38. package/dist/mutators/auth.js +358 -230
  39. package/dist/mutators/cookie.js +59 -42
  40. package/dist/mutators/document.js +104 -66
  41. package/dist/mutators/environment.js +97 -72
  42. package/dist/mutators/helpers.js +9 -13
  43. package/dist/mutators/index.js +62 -49
  44. package/dist/mutators/operation/body.js +88 -57
  45. package/dist/mutators/operation/extensions.js +20 -12
  46. package/dist/mutators/operation/helpers/fetch-request-to-har.js +144 -107
  47. package/dist/mutators/operation/helpers/fetch-response-to-har.js +143 -95
  48. package/dist/mutators/operation/helpers/get-parameter-position.js +12 -12
  49. package/dist/mutators/operation/helpers/har-to-operation.js +169 -132
  50. package/dist/mutators/operation/helpers/sync-path-parameters.js +109 -60
  51. package/dist/mutators/operation/history.js +60 -64
  52. package/dist/mutators/operation/index.js +25 -49
  53. package/dist/mutators/operation/operation.js +349 -240
  54. package/dist/mutators/operation/parameters.js +157 -93
  55. package/dist/mutators/server.js +213 -152
  56. package/dist/mutators/tabs.js +173 -130
  57. package/dist/mutators/tag.js +131 -97
  58. package/dist/mutators/workspace.js +72 -42
  59. package/dist/navigation/get-navigation-options.js +97 -84
  60. package/dist/navigation/helpers/get-openapi-object.js +46 -29
  61. package/dist/navigation/helpers/get-operation-entries.js +72 -32
  62. package/dist/navigation/helpers/get-parent-entry.js +16 -12
  63. package/dist/navigation/helpers/get-tag-entries.js +56 -29
  64. package/dist/navigation/helpers/get-tag.js +22 -23
  65. package/dist/navigation/helpers/get-x-keys.js +13 -9
  66. package/dist/navigation/helpers/traverse-description.js +90 -72
  67. package/dist/navigation/helpers/traverse-document.js +111 -98
  68. package/dist/navigation/helpers/traverse-examples.js +35 -31
  69. package/dist/navigation/helpers/traverse-paths.js +118 -106
  70. package/dist/navigation/helpers/traverse-schemas.js +65 -64
  71. package/dist/navigation/helpers/traverse-tags.js +158 -129
  72. package/dist/navigation/helpers/traverse-webhooks.js +96 -90
  73. package/dist/navigation/helpers/update-order-ids.js +59 -51
  74. package/dist/navigation/helpers/utils.js +71 -21
  75. package/dist/navigation/index.js +5 -13
  76. package/dist/navigation/types.js +1 -1
  77. package/dist/persistence/index.js +283 -285
  78. package/dist/persistence/indexdb.js +263 -126
  79. package/dist/plugins/bundler/helpers.js +21 -12
  80. package/dist/plugins/bundler/index.d.ts +7 -0
  81. package/dist/plugins/bundler/index.d.ts.map +1 -1
  82. package/dist/plugins/bundler/index.js +305 -171
  83. package/dist/plugins/client/index.js +1 -5
  84. package/dist/plugins/client/persistence.js +95 -90
  85. package/dist/resolve.js +18 -25
  86. package/dist/schemas/compose.js +6 -7
  87. package/dist/schemas/extensions/document/x-internal.js +3 -7
  88. package/dist/schemas/extensions/document/x-scalar-environments.js +16 -22
  89. package/dist/schemas/extensions/document/x-scalar-icon.js +3 -7
  90. package/dist/schemas/extensions/document/x-scalar-ignore.js +3 -7
  91. package/dist/schemas/extensions/document/x-scalar-is-dirty.js +21 -8
  92. package/dist/schemas/extensions/document/x-scalar-original-document-hash.js +17 -8
  93. package/dist/schemas/extensions/document/x-scalar-registry-meta.js +15 -21
  94. package/dist/schemas/extensions/document/x-scalar-sdk-installation.js +5 -13
  95. package/dist/schemas/extensions/document/x-scalar-watch-mode.js +4 -8
  96. package/dist/schemas/extensions/document/x-tags.js +3 -7
  97. package/dist/schemas/extensions/example/x-disabled.js +17 -7
  98. package/dist/schemas/extensions/general/x-scalar-active-environment.js +4 -7
  99. package/dist/schemas/extensions/general/x-scalar-cookies.js +9 -14
  100. package/dist/schemas/extensions/general/x-scalar-order.js +8 -7
  101. package/dist/schemas/extensions/operation/index.js +4 -23
  102. package/dist/schemas/extensions/operation/x-badge.js +42 -50
  103. package/dist/schemas/extensions/operation/x-code-samples.js +8 -12
  104. package/dist/schemas/extensions/operation/x-draft-examples.js +3 -7
  105. package/dist/schemas/extensions/operation/x-post-response.js +18 -7
  106. package/dist/schemas/extensions/operation/x-scalar-disable-parameters.js +57 -13
  107. package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js +9 -7
  108. package/dist/schemas/extensions/operation/x-scalar-stability.js +15 -14
  109. package/dist/schemas/extensions/parameter/x-global.js +12 -7
  110. package/dist/schemas/extensions/schema/x-additional-properties-name.js +10 -7
  111. package/dist/schemas/extensions/schema/x-enum-descriptions.js +17 -12
  112. package/dist/schemas/extensions/schema/x-enum-varnames.js +21 -8
  113. package/dist/schemas/extensions/schema/x-examples.js +3 -7
  114. package/dist/schemas/extensions/schema/x-variable.js +3 -7
  115. package/dist/schemas/extensions/security/index.js +1 -1
  116. package/dist/schemas/extensions/security/x-default-scopes.js +16 -7
  117. package/dist/schemas/extensions/security/x-scalar-credentials-location.js +16 -7
  118. package/dist/schemas/extensions/security/x-scalar-security-body.js +14 -7
  119. package/dist/schemas/extensions/security/x-scalar-security-query.js +14 -7
  120. package/dist/schemas/extensions/security/x-scalar-security-secrets.js +66 -37
  121. package/dist/schemas/extensions/security/x-tokenName.js +11 -7
  122. package/dist/schemas/extensions/security/x-use-pkce.js +6 -10
  123. package/dist/schemas/extensions/server/x-scalar-selected-server.js +3 -7
  124. package/dist/schemas/extensions/tag/index.js +1 -1
  125. package/dist/schemas/extensions/tag/x-display-name.js +11 -7
  126. package/dist/schemas/extensions/tag/x-tag-groups.js +13 -15
  127. package/dist/schemas/extensions/workspace/index.js +2 -11
  128. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js +13 -7
  129. package/dist/schemas/extensions/workspace/x-scalar-tabs.js +15 -13
  130. package/dist/schemas/extensions.js +11 -15
  131. package/dist/schemas/inmemory-workspace.js +13 -21
  132. package/dist/schemas/navigation.js +48 -85
  133. package/dist/schemas/reference-config/appearance.js +15 -22
  134. package/dist/schemas/reference-config/features.js +14 -21
  135. package/dist/schemas/reference-config/index.js +42 -44
  136. package/dist/schemas/reference-config/meta.js +11 -18
  137. package/dist/schemas/reference-config/routing.js +7 -14
  138. package/dist/schemas/reference-config/settings.js +10 -17
  139. package/dist/schemas/typebox-coerce.js +23 -6
  140. package/dist/schemas/v3.1/strict/callback.js +6 -12
  141. package/dist/schemas/v3.1/strict/components.js +26 -48
  142. package/dist/schemas/v3.1/strict/contact.js +9 -12
  143. package/dist/schemas/v3.1/strict/discriminator.js +11 -10
  144. package/dist/schemas/v3.1/strict/encoding.js +15 -12
  145. package/dist/schemas/v3.1/strict/example.js +11 -13
  146. package/dist/schemas/v3.1/strict/external-documentation.js +7 -10
  147. package/dist/schemas/v3.1/strict/header.js +27 -28
  148. package/dist/schemas/v3.1/strict/info.js +10 -16
  149. package/dist/schemas/v3.1/strict/license.js +9 -12
  150. package/dist/schemas/v3.1/strict/link.js +22 -19
  151. package/dist/schemas/v3.1/strict/media-type.js +17 -16
  152. package/dist/schemas/v3.1/strict/oauth-flow.js +28 -62
  153. package/dist/schemas/v3.1/strict/oauthflows.js +14 -20
  154. package/dist/schemas/v3.1/strict/openapi-document.js +126 -210
  155. package/dist/schemas/v3.1/strict/operation.js +16 -43
  156. package/dist/schemas/v3.1/strict/parameter.js +27 -35
  157. package/dist/schemas/v3.1/strict/path-item.js +36 -40
  158. package/dist/schemas/v3.1/strict/paths.js +8 -11
  159. package/dist/schemas/v3.1/strict/ref-definitions.js +76 -100
  160. package/dist/schemas/v3.1/strict/reference.js +18 -21
  161. package/dist/schemas/v3.1/strict/request-body.js +8 -16
  162. package/dist/schemas/v3.1/strict/response.js +12 -16
  163. package/dist/schemas/v3.1/strict/responses.js +13 -11
  164. package/dist/schemas/v3.1/strict/schema.js +149 -157
  165. package/dist/schemas/v3.1/strict/security-requirement.js +13 -12
  166. package/dist/schemas/v3.1/strict/security-scheme.js +29 -41
  167. package/dist/schemas/v3.1/strict/server-variable.js +9 -12
  168. package/dist/schemas/v3.1/strict/server.js +10 -13
  169. package/dist/schemas/v3.1/strict/tag.js +11 -20
  170. package/dist/schemas/v3.1/strict/type-guards.js +20 -20
  171. package/dist/schemas/v3.1/strict/xml.js +17 -16
  172. package/dist/schemas/workspace-specification/index.js +11 -23
  173. package/dist/schemas/workspace-specification/info.js +4 -8
  174. package/dist/schemas/workspace.js +25 -51
  175. package/dist/schemas.js +2 -6
  176. package/dist/server.js +286 -176
  177. package/dist/workspace-plugin.js +1 -1
  178. package/package.json +13 -19
  179. package/dist/client.js.map +0 -7
  180. package/dist/entities/auth/index.js.map +0 -7
  181. package/dist/entities/auth/schema.js.map +0 -7
  182. package/dist/entities/history/index.js.map +0 -7
  183. package/dist/entities/history/schema.js.map +0 -7
  184. package/dist/events/bus.js.map +0 -7
  185. package/dist/events/definitions/analytics.js.map +0 -7
  186. package/dist/events/definitions/auth.js.map +0 -7
  187. package/dist/events/definitions/common.js.map +0 -7
  188. package/dist/events/definitions/cookie.js.map +0 -7
  189. package/dist/events/definitions/document.js.map +0 -7
  190. package/dist/events/definitions/environment.js.map +0 -7
  191. package/dist/events/definitions/hooks.js.map +0 -7
  192. package/dist/events/definitions/index.js.map +0 -7
  193. package/dist/events/definitions/meta.js.map +0 -7
  194. package/dist/events/definitions/operation.js.map +0 -7
  195. package/dist/events/definitions/server.js.map +0 -7
  196. package/dist/events/definitions/tabs.js.map +0 -7
  197. package/dist/events/definitions/tag.js.map +0 -7
  198. package/dist/events/definitions/ui.js.map +0 -7
  199. package/dist/events/definitions/workspace.js.map +0 -7
  200. package/dist/events/index.js.map +0 -7
  201. package/dist/events/listeners.js.map +0 -7
  202. package/dist/events/old-definitions.js.map +0 -7
  203. package/dist/helpers/apply-selective-updates.d.ts +0 -19
  204. package/dist/helpers/apply-selective-updates.d.ts.map +0 -1
  205. package/dist/helpers/apply-selective-updates.js +0 -37
  206. package/dist/helpers/apply-selective-updates.js.map +0 -7
  207. package/dist/helpers/deep-clone.js.map +0 -7
  208. package/dist/helpers/detect-changes-proxy.js.map +0 -7
  209. package/dist/helpers/general.js.map +0 -7
  210. package/dist/helpers/generate-unique-value.js.map +0 -7
  211. package/dist/helpers/get-fetch.js.map +0 -7
  212. package/dist/helpers/get-resolved-ref.js.map +0 -7
  213. package/dist/helpers/is-non-optional-security-requirement.js.map +0 -7
  214. package/dist/helpers/merge-object.js.map +0 -7
  215. package/dist/helpers/overrides-proxy.js.map +0 -7
  216. package/dist/helpers/unpack-proxy.js.map +0 -7
  217. package/dist/mutators/auth.js.map +0 -7
  218. package/dist/mutators/cookie.js.map +0 -7
  219. package/dist/mutators/document.js.map +0 -7
  220. package/dist/mutators/environment.js.map +0 -7
  221. package/dist/mutators/helpers.js.map +0 -7
  222. package/dist/mutators/index.js.map +0 -7
  223. package/dist/mutators/operation/body.js.map +0 -7
  224. package/dist/mutators/operation/extensions.js.map +0 -7
  225. package/dist/mutators/operation/helpers/fetch-request-to-har.js.map +0 -7
  226. package/dist/mutators/operation/helpers/fetch-response-to-har.js.map +0 -7
  227. package/dist/mutators/operation/helpers/get-parameter-position.js.map +0 -7
  228. package/dist/mutators/operation/helpers/har-to-operation.js.map +0 -7
  229. package/dist/mutators/operation/helpers/sync-path-parameters.js.map +0 -7
  230. package/dist/mutators/operation/history.js.map +0 -7
  231. package/dist/mutators/operation/index.js.map +0 -7
  232. package/dist/mutators/operation/operation.js.map +0 -7
  233. package/dist/mutators/operation/parameters.js.map +0 -7
  234. package/dist/mutators/server.js.map +0 -7
  235. package/dist/mutators/tabs.js.map +0 -7
  236. package/dist/mutators/tag.js.map +0 -7
  237. package/dist/mutators/workspace.js.map +0 -7
  238. package/dist/navigation/get-navigation-options.js.map +0 -7
  239. package/dist/navigation/helpers/get-openapi-object.js.map +0 -7
  240. package/dist/navigation/helpers/get-operation-entries.js.map +0 -7
  241. package/dist/navigation/helpers/get-parent-entry.js.map +0 -7
  242. package/dist/navigation/helpers/get-tag-entries.js.map +0 -7
  243. package/dist/navigation/helpers/get-tag.js.map +0 -7
  244. package/dist/navigation/helpers/get-x-keys.js.map +0 -7
  245. package/dist/navigation/helpers/traverse-description.js.map +0 -7
  246. package/dist/navigation/helpers/traverse-document.js.map +0 -7
  247. package/dist/navigation/helpers/traverse-examples.js.map +0 -7
  248. package/dist/navigation/helpers/traverse-paths.js.map +0 -7
  249. package/dist/navigation/helpers/traverse-schemas.js.map +0 -7
  250. package/dist/navigation/helpers/traverse-tags.js.map +0 -7
  251. package/dist/navigation/helpers/traverse-webhooks.js.map +0 -7
  252. package/dist/navigation/helpers/update-order-ids.js.map +0 -7
  253. package/dist/navigation/helpers/utils.js.map +0 -7
  254. package/dist/navigation/index.js.map +0 -7
  255. package/dist/navigation/types.js.map +0 -7
  256. package/dist/persistence/index.js.map +0 -7
  257. package/dist/persistence/indexdb.js.map +0 -7
  258. package/dist/plugins/bundler/helpers.js.map +0 -7
  259. package/dist/plugins/bundler/index.js.map +0 -7
  260. package/dist/plugins/client/index.js.map +0 -7
  261. package/dist/plugins/client/persistence.js.map +0 -7
  262. package/dist/resolve.js.map +0 -7
  263. package/dist/schemas/compose.js.map +0 -7
  264. package/dist/schemas/extensions/document/x-internal.js.map +0 -7
  265. package/dist/schemas/extensions/document/x-scalar-environments.js.map +0 -7
  266. package/dist/schemas/extensions/document/x-scalar-icon.js.map +0 -7
  267. package/dist/schemas/extensions/document/x-scalar-ignore.js.map +0 -7
  268. package/dist/schemas/extensions/document/x-scalar-is-dirty.js.map +0 -7
  269. package/dist/schemas/extensions/document/x-scalar-original-document-hash.js.map +0 -7
  270. package/dist/schemas/extensions/document/x-scalar-registry-meta.js.map +0 -7
  271. package/dist/schemas/extensions/document/x-scalar-sdk-installation.js.map +0 -7
  272. package/dist/schemas/extensions/document/x-scalar-watch-mode.js.map +0 -7
  273. package/dist/schemas/extensions/document/x-tags.js.map +0 -7
  274. package/dist/schemas/extensions/example/x-disabled.js.map +0 -7
  275. package/dist/schemas/extensions/general/x-scalar-active-environment.js.map +0 -7
  276. package/dist/schemas/extensions/general/x-scalar-cookies.js.map +0 -7
  277. package/dist/schemas/extensions/general/x-scalar-order.js.map +0 -7
  278. package/dist/schemas/extensions/operation/index.js.map +0 -7
  279. package/dist/schemas/extensions/operation/x-badge.js.map +0 -7
  280. package/dist/schemas/extensions/operation/x-code-samples.js.map +0 -7
  281. package/dist/schemas/extensions/operation/x-draft-examples.js.map +0 -7
  282. package/dist/schemas/extensions/operation/x-post-response.js.map +0 -7
  283. package/dist/schemas/extensions/operation/x-scalar-disable-parameters.js.map +0 -7
  284. package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js.map +0 -7
  285. package/dist/schemas/extensions/operation/x-scalar-stability.js.map +0 -7
  286. package/dist/schemas/extensions/parameter/x-global.js.map +0 -7
  287. package/dist/schemas/extensions/schema/x-additional-properties-name.js.map +0 -7
  288. package/dist/schemas/extensions/schema/x-enum-descriptions.js.map +0 -7
  289. package/dist/schemas/extensions/schema/x-enum-varnames.js.map +0 -7
  290. package/dist/schemas/extensions/schema/x-examples.js.map +0 -7
  291. package/dist/schemas/extensions/schema/x-variable.js.map +0 -7
  292. package/dist/schemas/extensions/security/index.js.map +0 -7
  293. package/dist/schemas/extensions/security/x-default-scopes.js.map +0 -7
  294. package/dist/schemas/extensions/security/x-scalar-credentials-location.js.map +0 -7
  295. package/dist/schemas/extensions/security/x-scalar-security-body.js.map +0 -7
  296. package/dist/schemas/extensions/security/x-scalar-security-query.js.map +0 -7
  297. package/dist/schemas/extensions/security/x-scalar-security-secrets.js.map +0 -7
  298. package/dist/schemas/extensions/security/x-tokenName.js.map +0 -7
  299. package/dist/schemas/extensions/security/x-use-pkce.js.map +0 -7
  300. package/dist/schemas/extensions/server/x-scalar-selected-server.js.map +0 -7
  301. package/dist/schemas/extensions/tag/index.js.map +0 -7
  302. package/dist/schemas/extensions/tag/x-display-name.js.map +0 -7
  303. package/dist/schemas/extensions/tag/x-tag-groups.js.map +0 -7
  304. package/dist/schemas/extensions/workspace/index.js.map +0 -7
  305. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js.map +0 -7
  306. package/dist/schemas/extensions/workspace/x-scalar-tabs.js.map +0 -7
  307. package/dist/schemas/extensions.js.map +0 -7
  308. package/dist/schemas/inmemory-workspace.js.map +0 -7
  309. package/dist/schemas/navigation.js.map +0 -7
  310. package/dist/schemas/reference-config/appearance.js.map +0 -7
  311. package/dist/schemas/reference-config/features.js.map +0 -7
  312. package/dist/schemas/reference-config/index.js.map +0 -7
  313. package/dist/schemas/reference-config/meta.js.map +0 -7
  314. package/dist/schemas/reference-config/routing.js.map +0 -7
  315. package/dist/schemas/reference-config/settings.js.map +0 -7
  316. package/dist/schemas/typebox-coerce.js.map +0 -7
  317. package/dist/schemas/v3.1/strict/callback.js.map +0 -7
  318. package/dist/schemas/v3.1/strict/components.js.map +0 -7
  319. package/dist/schemas/v3.1/strict/contact.js.map +0 -7
  320. package/dist/schemas/v3.1/strict/discriminator.js.map +0 -7
  321. package/dist/schemas/v3.1/strict/encoding.js.map +0 -7
  322. package/dist/schemas/v3.1/strict/example.js.map +0 -7
  323. package/dist/schemas/v3.1/strict/external-documentation.js.map +0 -7
  324. package/dist/schemas/v3.1/strict/header.js.map +0 -7
  325. package/dist/schemas/v3.1/strict/info.js.map +0 -7
  326. package/dist/schemas/v3.1/strict/license.js.map +0 -7
  327. package/dist/schemas/v3.1/strict/link.js.map +0 -7
  328. package/dist/schemas/v3.1/strict/media-type.js.map +0 -7
  329. package/dist/schemas/v3.1/strict/oauth-flow.js.map +0 -7
  330. package/dist/schemas/v3.1/strict/oauthflows.js.map +0 -7
  331. package/dist/schemas/v3.1/strict/openapi-document.js.map +0 -7
  332. package/dist/schemas/v3.1/strict/operation.js.map +0 -7
  333. package/dist/schemas/v3.1/strict/parameter.js.map +0 -7
  334. package/dist/schemas/v3.1/strict/path-item.js.map +0 -7
  335. package/dist/schemas/v3.1/strict/paths.js.map +0 -7
  336. package/dist/schemas/v3.1/strict/ref-definitions.js.map +0 -7
  337. package/dist/schemas/v3.1/strict/reference.js.map +0 -7
  338. package/dist/schemas/v3.1/strict/request-body.js.map +0 -7
  339. package/dist/schemas/v3.1/strict/response.js.map +0 -7
  340. package/dist/schemas/v3.1/strict/responses.js.map +0 -7
  341. package/dist/schemas/v3.1/strict/schema.js.map +0 -7
  342. package/dist/schemas/v3.1/strict/security-requirement.js.map +0 -7
  343. package/dist/schemas/v3.1/strict/security-scheme.js.map +0 -7
  344. package/dist/schemas/v3.1/strict/server-variable.js.map +0 -7
  345. package/dist/schemas/v3.1/strict/server.js.map +0 -7
  346. package/dist/schemas/v3.1/strict/tag.js.map +0 -7
  347. package/dist/schemas/v3.1/strict/type-guards.js.map +0 -7
  348. package/dist/schemas/v3.1/strict/xml.js.map +0 -7
  349. package/dist/schemas/workspace-specification/index.js.map +0 -7
  350. package/dist/schemas/workspace-specification/info.js.map +0 -7
  351. package/dist/schemas/workspace.js.map +0 -7
  352. package/dist/schemas.js.map +0 -7
  353. package/dist/server.js.map +0 -7
  354. package/dist/workspace-plugin.js.map +0 -7
@@ -1,62 +1,93 @@
1
- import { getResolvedRef } from "../../helpers/get-resolved-ref.js";
2
- import { unpackProxyObject } from "../../helpers/unpack-proxy.js";
1
+ import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
2
+ import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
3
+ /** Ensure the json that we need exists up to the example object in the request body */
3
4
  const findOrCreateRequestBodyExample = (document, contentType, meta) => {
4
- const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method]);
5
- if (!operation) {
6
- return null;
7
- }
8
- let requestBody = getResolvedRef(operation.requestBody);
9
- if (!requestBody) {
10
- operation.requestBody = {
11
- content: {}
12
- };
13
- requestBody = getResolvedRef(operation.requestBody);
14
- }
15
- requestBody.content[contentType] ||= {};
16
- requestBody.content[contentType].examples ||= {};
17
- requestBody.content[contentType].examples[meta.exampleKey] ||= {};
18
- const example = getResolvedRef(requestBody.content[contentType].examples?.[meta.exampleKey]);
19
- return example ?? null;
5
+ const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method]);
6
+ if (!operation) {
7
+ return null;
8
+ }
9
+ // Ensure that the request body exists
10
+ let requestBody = getResolvedRef(operation.requestBody);
11
+ if (!requestBody) {
12
+ operation.requestBody = {
13
+ content: {},
14
+ };
15
+ requestBody = getResolvedRef(operation.requestBody);
16
+ }
17
+ // Ensure that the example exists
18
+ requestBody.content[contentType] ||= {};
19
+ requestBody.content[contentType].examples ||= {};
20
+ requestBody.content[contentType].examples[meta.exampleKey] ||= {};
21
+ const example = getResolvedRef(requestBody.content[contentType].examples?.[meta.exampleKey]);
22
+ return example ?? null;
20
23
  };
21
- const updateOperationRequestBodyContentType = (document, { meta, payload }) => {
22
- if (!document) {
23
- return;
24
- }
25
- const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
26
- if (!operation) {
27
- return;
28
- }
29
- let requestBody = getResolvedRef(operation.requestBody);
30
- if (!requestBody) {
31
- operation.requestBody = {
32
- content: {}
33
- };
34
- requestBody = getResolvedRef(operation.requestBody);
35
- }
36
- if (!requestBody["x-scalar-selected-content-type"]) {
37
- requestBody["x-scalar-selected-content-type"] = {};
38
- }
39
- requestBody["x-scalar-selected-content-type"][meta.exampleKey] = payload.contentType;
24
+ /**
25
+ * Sets the selected request-body content type for the current `exampleKey`.
26
+ * This stores the selection under `x-scalar-selected-content-type` on the
27
+ * resolved requestBody. Safely no-ops if the document or operation does not exist.
28
+ *
29
+ * Example:
30
+ * ```ts
31
+ * updateOperationRequestBodyContentType({
32
+ * document,
33
+ * meta: { method: 'post', path: '/upload', exampleKey: 'default' },
34
+ * payload: { contentType: 'multipart/form-data' },
35
+ * })
36
+ * ```
37
+ */
38
+ export const updateOperationRequestBodyContentType = (document, { meta, payload }) => {
39
+ if (!document) {
40
+ return;
41
+ }
42
+ const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method]);
43
+ if (!operation) {
44
+ return;
45
+ }
46
+ let requestBody = getResolvedRef(operation.requestBody);
47
+ if (!requestBody) {
48
+ operation.requestBody = {
49
+ content: {},
50
+ };
51
+ requestBody = getResolvedRef(operation.requestBody);
52
+ }
53
+ if (!requestBody['x-scalar-selected-content-type']) {
54
+ requestBody['x-scalar-selected-content-type'] = {};
55
+ }
56
+ requestBody['x-scalar-selected-content-type'][meta.exampleKey] = payload.contentType;
40
57
  };
41
- const updateOperationRequestBodyExample = (document, { meta, payload, contentType }) => {
42
- const example = findOrCreateRequestBodyExample(document, contentType, meta);
43
- if (!example) {
44
- console.error("Example not found", meta.exampleKey);
45
- return;
46
- }
47
- example.value = payload;
58
+ /**
59
+ * Creates or updates a concrete example value for a specific request-body
60
+ * `contentType` and `exampleKey`. Safely no-ops if the document or operation
61
+ * does not exist.
62
+ *
63
+ * Example:
64
+ * ```ts
65
+ * updateOperationRequestBodyExample({
66
+ * document,
67
+ * contentType: 'application/json',
68
+ * meta: { method: 'post', path: '/users', exampleKey: 'default' },
69
+ * payload: { value: JSON.stringify({ name: 'Ada' }) },
70
+ * })
71
+ * ```
72
+ */
73
+ export const updateOperationRequestBodyExample = (document, { meta, payload, contentType }) => {
74
+ const example = findOrCreateRequestBodyExample(document, contentType, meta);
75
+ if (!example) {
76
+ console.error('Example not found', meta.exampleKey);
77
+ return;
78
+ }
79
+ example.value = payload;
48
80
  };
49
- const updateOperationRequestBodyFormValue = (document, { meta, payload, contentType }) => {
50
- const example = findOrCreateRequestBodyExample(document, contentType, meta);
51
- if (!example) {
52
- console.error("Example not found", meta.exampleKey);
53
- return;
54
- }
55
- example.value = unpackProxyObject(payload, { depth: 3 });
81
+ /**
82
+ * Stores the form data for the request body example
83
+ *
84
+ * This needs special handling as we store it as an array of objects with a schema type of object
85
+ */
86
+ export const updateOperationRequestBodyFormValue = (document, { meta, payload, contentType }) => {
87
+ const example = findOrCreateRequestBodyExample(document, contentType, meta);
88
+ if (!example) {
89
+ console.error('Example not found', meta.exampleKey);
90
+ return;
91
+ }
92
+ example.value = unpackProxyObject(payload, { depth: 3 });
56
93
  };
57
- export {
58
- updateOperationRequestBodyContentType,
59
- updateOperationRequestBodyExample,
60
- updateOperationRequestBodyFormValue
61
- };
62
- //# sourceMappingURL=body.js.map
@@ -1,13 +1,21 @@
1
- import { getResolvedRef } from "../../helpers/get-resolved-ref.js";
2
- import { mergeObjects } from "../../helpers/merge-object.js";
3
- const updateOperationExtension = (document, { meta, payload }) => {
4
- const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method]);
5
- if (!operation) {
6
- return;
7
- }
8
- mergeObjects(operation, payload);
1
+ import { getResolvedRef } from '../../helpers/get-resolved-ref.js';
2
+ import { mergeObjects } from '../../helpers/merge-object.js';
3
+ /**
4
+ * Updates an extension of the operation
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * updateOperationExtension({
9
+ * document,
10
+ * meta: { method: 'get', path: '/users' },
11
+ * payload: { 'x-post-response': 'console.log(response)' },
12
+ * })
13
+ * ```
14
+ */
15
+ export const updateOperationExtension = (document, { meta, payload }) => {
16
+ const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method]);
17
+ if (!operation) {
18
+ return;
19
+ }
20
+ mergeObjects(operation, payload);
9
21
  };
10
- export {
11
- updateOperationExtension
12
- };
13
- //# sourceMappingURL=extensions.js.map
@@ -1,117 +1,154 @@
1
- const fetchRequestToHar = async ({
2
- request,
3
- includeBody = true,
4
- httpVersion = "HTTP/1.1",
5
- // Default to 1MB
6
- bodySizeLimit = 1048576
7
- }) => {
8
- const url = new URL(request.url);
9
- const queryString = Array.from(url.searchParams.entries()).map(([name, value]) => ({ name, value }));
10
- const { headers, headersSize, cookies } = processRequestHeaders(request);
11
- const mimeType = request.headers.get("content-type")?.split(";")[0]?.trim() ?? "text/plain";
12
- const bodyDetails = await (async () => {
13
- if (includeBody && request.body) {
14
- const details = await processRequestBody(request.clone());
15
- if (details.size <= bodySizeLimit) {
16
- return details;
17
- }
18
- }
19
- return { text: "", size: -1 };
20
- })();
21
- const harRequest = {
22
- method: request.method,
23
- url: request.url,
24
- httpVersion,
25
- headers,
26
- cookies,
27
- queryString,
28
- headersSize,
29
- bodySize: bodyDetails.size,
30
- postData: "params" in bodyDetails ? {
31
- mimeType,
32
- params: bodyDetails.params
33
- } : {
34
- mimeType,
35
- text: bodyDetails.text
36
- }
37
- };
38
- return harRequest;
1
+ /**
2
+ * Converts a Fetch API Request object to HAR (HTTP Archive) Request format.
3
+ *
4
+ * This function transforms a standard JavaScript Fetch API Request into the
5
+ * HAR format, which is useful for:
6
+ * - Recording HTTP requests for replay or analysis
7
+ * - Creating request fixtures from real API calls
8
+ * - Debugging and monitoring HTTP traffic
9
+ * - Storing request history in a standard format
10
+ * - Generating API documentation from real requests
11
+ *
12
+ * The conversion handles:
13
+ * - Request method and URL
14
+ * - Headers extraction (excluding sensitive headers if needed)
15
+ * - Query parameters extraction from URL
16
+ * - Cookie extraction from headers
17
+ * - Request body reading (with automatic cloning to preserve the original)
18
+ * - Content-Type detection and MIME type extraction
19
+ * - Size calculations for headers and body
20
+ * - Form data bodies are converted to params array
21
+ * - Other body types are read as text
22
+ *
23
+ * Note: The Fetch API does not expose the HTTP version, so it defaults to HTTP/1.1
24
+ * unless specified otherwise.
25
+ *
26
+ * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
27
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Request
28
+ *
29
+ * @example
30
+ * const request = new Request('https://api.example.com/users', {
31
+ * method: 'POST',
32
+ * headers: { 'Content-Type': 'application/json' },
33
+ * body: JSON.stringify({ name: 'John' })
34
+ * })
35
+ * const harRequest = await fetchRequestToHar({ request })
36
+ * console.log(harRequest.method) // 'POST'
37
+ * console.log(harRequest.postData?.text) // '{"name":"John"}'
38
+ */
39
+ export const fetchRequestToHar = async ({ request, includeBody = true, httpVersion = 'HTTP/1.1',
40
+ // Default to 1MB
41
+ bodySizeLimit = 1048576, }) => {
42
+ // Extract query string from URL
43
+ const url = new URL(request.url);
44
+ // Extract the query strings from the URL
45
+ const queryString = Array.from(url.searchParams.entries()).map(([name, value]) => ({ name, value }));
46
+ // Extract the headers from the request
47
+ const { headers, headersSize, cookies } = processRequestHeaders(request);
48
+ // Extract the MIME type from the request headers
49
+ const mimeType = request.headers.get('content-type')?.split(';')[0]?.trim() ?? 'text/plain';
50
+ // Read the request body if requested
51
+ const bodyDetails = await (async () => {
52
+ if (includeBody && request.body) {
53
+ const details = await processRequestBody(request.clone());
54
+ if (details.size <= bodySizeLimit) {
55
+ return details;
56
+ }
57
+ }
58
+ return { text: '', size: -1 };
59
+ })();
60
+ // Create the HAR request object
61
+ const harRequest = {
62
+ method: request.method,
63
+ url: request.url,
64
+ httpVersion,
65
+ headers,
66
+ cookies,
67
+ queryString,
68
+ headersSize,
69
+ bodySize: bodyDetails.size,
70
+ postData: 'params' in bodyDetails
71
+ ? {
72
+ mimeType,
73
+ params: bodyDetails.params,
74
+ }
75
+ : {
76
+ mimeType,
77
+ text: bodyDetails.text,
78
+ },
79
+ };
80
+ return harRequest;
39
81
  };
40
82
  const processRequestBody = async (request) => {
41
- const formData = await tryGetRequestFormData(request.clone());
42
- if (formData) {
43
- return Array.from(formData.entries()).reduce(
44
- (acc, [name, value]) => {
45
- if (value instanceof File) {
46
- const fileName = `@${value.name}`;
47
- acc.params.push({ name, value: fileName });
48
- acc.size += fileName.length;
49
- return acc;
50
- }
51
- acc.params.push({ name, value });
52
- acc.size += value.length;
53
- return acc;
54
- },
55
- { params: [], size: 0 }
56
- );
57
- }
58
- if (request.headers.get("content-type")?.includes("application/octet-stream")) {
59
- return { text: "", size: -1 };
60
- }
61
- const arrayBuffer = await request.arrayBuffer();
62
- const size = arrayBuffer.byteLength;
63
- return { size, text: new TextDecoder().decode(arrayBuffer) };
83
+ const formData = await tryGetRequestFormData(request.clone());
84
+ if (formData) {
85
+ return Array.from(formData.entries()).reduce((acc, [name, value]) => {
86
+ if (value instanceof File) {
87
+ const fileName = `@${value.name}`;
88
+ acc.params.push({ name, value: fileName });
89
+ acc.size += fileName.length;
90
+ return acc;
91
+ }
92
+ acc.params.push({ name, value });
93
+ acc.size += value.length;
94
+ return acc;
95
+ }, { params: [], size: 0 });
96
+ }
97
+ // Skip binary bodies
98
+ if (request.headers.get('content-type')?.includes('application/octet-stream')) {
99
+ return { text: '', size: -1 };
100
+ }
101
+ // Read the request body as text
102
+ const arrayBuffer = await request.arrayBuffer();
103
+ const size = arrayBuffer.byteLength;
104
+ return { size, text: new TextDecoder().decode(arrayBuffer) };
64
105
  };
65
106
  async function tryGetRequestFormData(request) {
66
- if (typeof request.formData !== "function") {
67
- return null;
68
- }
69
- if (request.bodyUsed) {
70
- return null;
71
- }
72
- const contentType = request.headers.get("content-type") ?? "";
73
- if (!contentType.includes("multipart/form-data") && !contentType.includes("application/x-www-form-urlencoded")) {
74
- return null;
75
- }
76
- try {
77
- return await request.formData();
78
- } catch {
79
- return null;
80
- }
107
+ if (typeof request.formData !== 'function') {
108
+ return null;
109
+ }
110
+ if (request.bodyUsed) {
111
+ return null;
112
+ }
113
+ const contentType = request.headers.get('content-type') ?? '';
114
+ if (!contentType.includes('multipart/form-data') && !contentType.includes('application/x-www-form-urlencoded')) {
115
+ return null;
116
+ }
117
+ try {
118
+ return await request.formData();
119
+ }
120
+ catch {
121
+ return null;
122
+ }
81
123
  }
82
124
  const processRequestHeaders = (request) => {
83
- return Array.from(request.headers.entries()).reduce(
84
- (acc, [name, value]) => {
85
- if (name.toLowerCase() === "cookie") {
86
- const parsedCookies = parseCookieHeader(value);
87
- acc.cookies.push(...parsedCookies.cookies);
88
- } else {
89
- acc.headers.push({ name, value });
90
- acc.headersSize += name.length + 2 + value.length + 2;
91
- }
92
- return acc;
93
- },
94
- { headers: [], headersSize: 0, cookies: [] }
95
- );
125
+ return Array.from(request.headers.entries()).reduce((acc, [name, value]) => {
126
+ if (name.toLowerCase() === 'cookie') {
127
+ const parsedCookies = parseCookieHeader(value);
128
+ acc.cookies.push(...parsedCookies.cookies);
129
+ }
130
+ else {
131
+ acc.headers.push({ name, value });
132
+ acc.headersSize += name.length + 2 + value.length + 2;
133
+ }
134
+ return acc;
135
+ }, { headers: [], headersSize: 0, cookies: [] });
96
136
  };
137
+ /**
138
+ * Parses a Cookie header value into an array of cookie objects.
139
+ * Cookie format: name1=value1; name2=value2
140
+ */
97
141
  const parseCookieHeader = (cookieValue) => {
98
- return cookieValue.split(";").reduce(
99
- (acc, part) => {
100
- const trimmedPart = part.trim();
101
- const equalIndex = trimmedPart.indexOf("=");
102
- if (equalIndex === -1) {
142
+ return cookieValue.split(';').reduce((acc, part) => {
143
+ const trimmedPart = part.trim();
144
+ const equalIndex = trimmedPart.indexOf('=');
145
+ if (equalIndex === -1) {
146
+ return acc;
147
+ }
148
+ const name = trimmedPart.substring(0, equalIndex).trim();
149
+ const value = trimmedPart.substring(equalIndex + 1).trim();
150
+ acc.cookies.push({ name, value });
151
+ acc.size += name.length + 2 + value.length + 2;
103
152
  return acc;
104
- }
105
- const name = trimmedPart.substring(0, equalIndex).trim();
106
- const value = trimmedPart.substring(equalIndex + 1).trim();
107
- acc.cookies.push({ name, value });
108
- acc.size += name.length + 2 + value.length + 2;
109
- return acc;
110
- },
111
- { cookies: [], size: 0 }
112
- );
113
- };
114
- export {
115
- fetchRequestToHar
153
+ }, { cookies: [], size: 0 });
116
154
  };
117
- //# sourceMappingURL=fetch-request-to-har.js.map