@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,37 +0,0 @@
1
- import { apply, diff } from "@scalar/json-magic/diff";
2
- import { split } from "../helpers/general.js";
3
- const isSecretKey = (key) => key.startsWith("x-scalar-secret-");
4
- const EXCLUDE_KEYS = [
5
- // Bundler keys
6
- "x-ext",
7
- "x-ext-urls",
8
- "$status",
9
- // Scalar keys
10
- "x-scalar-navigation",
11
- "x-scalar-is-dirty",
12
- "x-original-oas-version",
13
- "x-scalar-original-document-hash",
14
- "x-scalar-original-source-url"
15
- ];
16
- const excludeKeysSet = new Set(EXCLUDE_KEYS);
17
- const filterDiff = (diff2) => {
18
- if (diff2.path.some((p) => excludeKeysSet.has(p))) {
19
- return false;
20
- }
21
- if (isSecretKey(diff2.path.at(-1) ?? "")) {
22
- return false;
23
- }
24
- return true;
25
- };
26
- const applySelectiveUpdates = (originalDocument, updatedDocument) => {
27
- const diffs = diff(originalDocument, updatedDocument);
28
- const [writableDiffs, excludedDiffs] = split(diffs, filterDiff);
29
- apply(originalDocument, writableDiffs);
30
- return excludedDiffs;
31
- };
32
- export {
33
- EXCLUDE_KEYS,
34
- applySelectiveUpdates,
35
- excludeKeysSet
36
- };
37
- //# sourceMappingURL=apply-selective-updates.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/apply-selective-updates.ts"],
4
- "sourcesContent": ["import { type Difference, apply, diff } from '@scalar/json-magic/diff'\n\nimport { type UnknownObject, split } from '@/helpers/general'\nimport type { OpenAPIExtensions } from '@/schemas/v3.1/strict/openapi-document'\n\n/**\n * Checks if a key is a Scalar secret key.\n * Secret keys start with 'x-scalar-secret-' prefix.\n */\nconst isSecretKey = (key: string) => key.startsWith('x-scalar-secret-')\n\n/**\n * Keys to exclude from diffs.\n * These are metadata fields that should be omitted when syncing updates to the original document.\n * Changes to these fields are not persisted.\n */\ntype BunlderKeys = 'x-ext' | 'x-ext-urls' | '$status'\nexport const EXCLUDE_KEYS = [\n // Bundler keys\n 'x-ext',\n 'x-ext-urls',\n '$status',\n // Scalar keys\n 'x-scalar-navigation',\n 'x-scalar-is-dirty',\n 'x-original-oas-version',\n 'x-scalar-original-document-hash',\n 'x-scalar-original-source-url',\n] satisfies (keyof OpenAPIExtensions | BunlderKeys)[] as string[]\nexport const excludeKeysSet = new Set(EXCLUDE_KEYS)\n\n/**\n * Determines whether a diff should be included when applying updates.\n *\n * Returns `true` if the diff does not involve excluded metadata fields\n * (such as navigation or external references) or secret keys.\n * Excluded keys and secret keys are not persisted to the original document.\n */\nconst filterDiff = (diff: Difference<unknown>) => {\n // Omit diff if its path contains a key we want to exclude from updates\n if (diff.path.some((p) => excludeKeysSet.has(p))) {\n return false\n }\n\n // Omit diff if its last path element is a secret key\n if (isSecretKey(diff.path.at(-1) ?? '')) {\n return false\n }\n\n return true\n}\n\n/**\n * Applies updates from an updated document to an original document, while excluding changes to certain metadata keys.\n *\n * This function computes the differences between the original and updated documents,\n * filters out any diffs that affect excluded keys (such as navigation, external references, or status fields),\n * and applies only the allowed changes to the original document in place.\n *\n * Note: The originalDocument is mutated directly.\n *\n * @param originalDocument - The document to be updated (mutated in place)\n * @param updatedDocument - The document containing the desired changes\n * @returns A tuple: [the updated original document, array of excluded diffs that were not applied]\n */\nexport const applySelectiveUpdates = (originalDocument: UnknownObject, updatedDocument: UnknownObject) => {\n const diffs: Difference<unknown>[] = diff(originalDocument, updatedDocument)\n\n const [writableDiffs, excludedDiffs] = split(diffs, filterDiff)\n\n apply(originalDocument, writableDiffs)\n\n return excludedDiffs\n}\n"],
5
- "mappings": "AAAA,SAA0B,OAAO,YAAY;AAE7C,SAA6B,aAAa;AAO1C,MAAM,cAAc,CAAC,QAAgB,IAAI,WAAW,kBAAkB;AAQ/D,MAAM,eAAe;AAAA;AAAA,EAE1B;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACO,MAAM,iBAAiB,IAAI,IAAI,YAAY;AASlD,MAAM,aAAa,CAACA,UAA8B;AAEhD,MAAIA,MAAK,KAAK,KAAK,CAAC,MAAM,eAAe,IAAI,CAAC,CAAC,GAAG;AAChD,WAAO;AAAA,EACT;AAGA,MAAI,YAAYA,MAAK,KAAK,GAAG,EAAE,KAAK,EAAE,GAAG;AACvC,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAeO,MAAM,wBAAwB,CAAC,kBAAiC,oBAAmC;AACxG,QAAM,QAA+B,KAAK,kBAAkB,eAAe;AAE3E,QAAM,CAAC,eAAe,aAAa,IAAI,MAAM,OAAO,UAAU;AAE9D,QAAM,kBAAkB,aAAa;AAErC,SAAO;AACT;",
6
- "names": ["diff"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/deep-clone.ts"],
4
- "sourcesContent": ["/**\n * Deeply clones an object or array, handling circular references.\n *\n * This function recursively copies all properties of the input value,\n * creating a new object or array. If the input contains circular references,\n * they are preserved in the clone using a WeakMap to track already-cloned objects.\n *\n * @param value - The value to deep clone (object, array, or primitive)\n * @param hash - (internal) WeakMap for tracking circular references\n * @returns A deep clone of the input value\n *\n * @example\n * const obj: any = { a: 1 }\n * obj.self = obj\n * const clone = deepClone(obj)\n * console.log(clone) // { a: 1, self: [Circular] }\n * console.log(clone !== obj) // true\n * console.log(clone.self === clone) // true\n */\nexport const deepClone = <T>(value: T, hash = new WeakMap()): T => {\n if (typeof value !== 'object' || value === null) {\n return value\n }\n\n if (hash.has(value)) {\n return hash.get(value)\n }\n\n const result = Array.isArray(value) ? [] : {}\n hash.set(value, result)\n\n Object.keys(value).forEach((key) => {\n // @ts-expect-error: Index signature for generic object\n result[key] = deepClone(value[key], hash)\n })\n\n return result as T\n}\n"],
5
- "mappings": "AAmBO,MAAM,YAAY,CAAI,OAAU,OAAO,oBAAI,QAAQ,MAAS;AACjE,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO;AAAA,EACT;AAEA,MAAI,KAAK,IAAI,KAAK,GAAG;AACnB,WAAO,KAAK,IAAI,KAAK;AAAA,EACvB;AAEA,QAAM,SAAS,MAAM,QAAQ,KAAK,IAAI,CAAC,IAAI,CAAC;AAC5C,OAAK,IAAI,OAAO,MAAM;AAEtB,SAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,QAAQ;AAElC,WAAO,GAAG,IAAI,UAAU,MAAM,GAAG,GAAG,IAAI;AAAA,EAC1C,CAAC;AAED,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/detect-changes-proxy.ts"],
4
- "sourcesContent": ["import { isObject } from '@scalar/helpers/object/is-object'\n\nconst isDetectChangesProxy = Symbol('isDetectChangesProxy')\nconst detectChangesProxyTarget = Symbol('detectChangesProxyTarget')\n\ntype OnBeforeChangeHook = (path: string[], value?: unknown) => void\ntype OnAfterChangeHook = (path: string[], value?: unknown) => void\n\n/**\n * createDetectChangesProxy - Creates a proxy for an object or array that detects and triggers hooks on changes.\n *\n * This proxy enables detection of set operations, triggering optional hooks (onBeforeChange, onAfterChange) with the path and value changed.\n * The proxy can be applied recursively to all nested objects/arrays, and caches proxies to prevent creating multiple proxies for the same object.\n *\n * Example usage:\n *\n * const obj = { foo: 1, bar: { baz: 2 } };\n * const proxy = createDetectChangesProxy(obj, {\n * hooks: {\n * onBeforeChange: (path, value) => console.log('Before', path, value),\n * onAfterChange: (path, value) => console.log('After', path, value),\n * }\n * });\n * proxy.foo = 42; // Console: Before ['foo'] '42', After ['foo'] '42'\n * proxy.bar.baz = 99; // Console: Before ['bar', 'baz'] '99', After ['bar', 'baz'] '99'\n *\n * @param target The target object or array to wrap in a proxy\n * @param options Optional: hooks for change detection\n * @param args Internal: proxy cache and current property path (used for recursion)\n * @returns The proxied object/array with change detection capabilities\n */\nexport const createDetectChangesProxy = <T>(\n target: T,\n options?: {\n hooks: Partial<{\n onBeforeChange: OnBeforeChangeHook\n onAfterChange: OnAfterChangeHook\n }>\n },\n args: {\n /** Cache for storing proxies */\n proxyCache: WeakMap<object, unknown>\n /** Path for the target */\n path: string[]\n } = {\n proxyCache: new WeakMap<object, unknown>(),\n path: [],\n },\n): T => {\n // Only wrap objects or arrays\n if (!isObject(target) && !Array.isArray(target)) {\n return target\n }\n\n // Return cached proxy if already created for this target\n if (args.proxyCache.has(target)) {\n return args.proxyCache.get(target)! as T\n }\n\n const proxy = new Proxy(target, {\n get(target, prop, receiver) {\n // Allow identifying if an object is a detect changes proxy\n if (prop === isDetectChangesProxy) {\n return true\n }\n // Allow access to the original target\n if (prop === detectChangesProxyTarget) {\n return target\n }\n\n // Recursively wrap property values in the detect changes proxy\n const value = Reflect.get(target, prop, receiver)\n\n if (isDetectChangesProxyObject(value)) {\n return value\n }\n\n return createDetectChangesProxy(value, options, { ...args, path: [...args.path, String(prop)] })\n },\n set(target, prop, value, receiver) {\n const path = [...args.path, String(prop)]\n // Call before-change hook if provided\n options?.hooks?.onBeforeChange?.(path, value)\n const result = Reflect.set(target, prop, value, receiver)\n // Call after-change hook if provided\n options?.hooks?.onAfterChange?.(path, value)\n return result\n },\n deleteProperty(target, prop) {\n const path = [...args.path, String(prop)]\n options?.hooks?.onBeforeChange?.(path)\n const result = Reflect.deleteProperty(target, prop)\n options?.hooks?.onAfterChange?.(path)\n return result\n },\n })\n\n // Cache the proxy for this target\n args.proxyCache.set(target, proxy)\n return proxy\n}\n\nexport const isDetectChangesProxyObject = (obj: unknown): boolean => {\n return (\n typeof obj === 'object' &&\n obj !== null &&\n (obj as { [isDetectChangesProxy]: boolean })[isDetectChangesProxy] === true\n )\n}\n\n/**\n * Returns the raw/original (non-proxy) object if the passed object is a detect-changes proxy.\n * If the object is not a proxy, it returns the same object.\n *\n * @example\n * const proxy = createDetectChangesProxy({ a: 1 });\n * const raw = unpackDetectChangesProxy(proxy); // Gets the original object { a: 1 }\n * const notProxy = { b: 2 };\n * const stillRaw = unpackDetectChangesProxy(notProxy); // Returns { b: 2 }, unchanged\n */\nexport const unpackDetectChangesProxy = <T>(obj: T): T => {\n if (typeof obj !== 'object' || obj === null) {\n return obj\n }\n\n // If object is a detect-changes proxy, return its underlying target\n if ((obj as T & { [isDetectChangesProxy]: boolean | undefined })[isDetectChangesProxy]) {\n return (obj as T & { [detectChangesProxyTarget]: T })[detectChangesProxyTarget]\n }\n\n return obj\n}\n"],
5
- "mappings": "AAAA,SAAS,gBAAgB;AAEzB,MAAM,uBAAuB,OAAO,sBAAsB;AAC1D,MAAM,2BAA2B,OAAO,0BAA0B;AA4B3D,MAAM,2BAA2B,CACtC,QACA,SAMA,OAKI;AAAA,EACF,YAAY,oBAAI,QAAyB;AAAA,EACzC,MAAM,CAAC;AACT,MACM;AAEN,MAAI,CAAC,SAAS,MAAM,KAAK,CAAC,MAAM,QAAQ,MAAM,GAAG;AAC/C,WAAO;AAAA,EACT;AAGA,MAAI,KAAK,WAAW,IAAI,MAAM,GAAG;AAC/B,WAAO,KAAK,WAAW,IAAI,MAAM;AAAA,EACnC;AAEA,QAAM,QAAQ,IAAI,MAAM,QAAQ;AAAA,IAC9B,IAAIA,SAAQ,MAAM,UAAU;AAE1B,UAAI,SAAS,sBAAsB;AACjC,eAAO;AAAA,MACT;AAEA,UAAI,SAAS,0BAA0B;AACrC,eAAOA;AAAA,MACT;AAGA,YAAM,QAAQ,QAAQ,IAAIA,SAAQ,MAAM,QAAQ;AAEhD,UAAI,2BAA2B,KAAK,GAAG;AACrC,eAAO;AAAA,MACT;AAEA,aAAO,yBAAyB,OAAO,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,KAAK,MAAM,OAAO,IAAI,CAAC,EAAE,CAAC;AAAA,IACjG;AAAA,IACA,IAAIA,SAAQ,MAAM,OAAO,UAAU;AACjC,YAAM,OAAO,CAAC,GAAG,KAAK,MAAM,OAAO,IAAI,CAAC;AAExC,eAAS,OAAO,iBAAiB,MAAM,KAAK;AAC5C,YAAM,SAAS,QAAQ,IAAIA,SAAQ,MAAM,OAAO,QAAQ;AAExD,eAAS,OAAO,gBAAgB,MAAM,KAAK;AAC3C,aAAO;AAAA,IACT;AAAA,IACA,eAAeA,SAAQ,MAAM;AAC3B,YAAM,OAAO,CAAC,GAAG,KAAK,MAAM,OAAO,IAAI,CAAC;AACxC,eAAS,OAAO,iBAAiB,IAAI;AACrC,YAAM,SAAS,QAAQ,eAAeA,SAAQ,IAAI;AAClD,eAAS,OAAO,gBAAgB,IAAI;AACpC,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AAGD,OAAK,WAAW,IAAI,QAAQ,KAAK;AACjC,SAAO;AACT;AAEO,MAAM,6BAA6B,CAAC,QAA0B;AACnE,SACE,OAAO,QAAQ,YACf,QAAQ,QACP,IAA4C,oBAAoB,MAAM;AAE3E;AAYO,MAAM,2BAA2B,CAAI,QAAc;AACxD,MAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAC3C,WAAO;AAAA,EACT;AAGA,MAAK,IAA4D,oBAAoB,GAAG;AACtF,WAAQ,IAA8C,wBAAwB;AAAA,EAChF;AAEA,SAAO;AACT;",
6
- "names": ["target"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/general.ts"],
4
- "sourcesContent": ["export type UnknownObject = Record<string, unknown>\n\n/**\n * Checks if a string is a local reference (starts with #)\n * @param value - The reference string to check\n * @returns true if the string is a local reference, false otherwise\n * @example\n * ```ts\n * isLocalRef('#/components/schemas/User') // true\n * isLocalRef('https://example.com/schema.json') // false\n * isLocalRef('./local-schema.json') // false\n * ```\n */\nexport function isLocalRef(value: string): boolean {\n return value.startsWith('#')\n}\n\nexport function keyOf<T extends Record<string, unknown>>(value: T) {\n return Object.keys(value) as (keyof T)[]\n}\n\n/**\n * Deep clones a value using JSON serialization.\n *\n * @param value - The value to deep clone\n * @template T - The type of the value\n * @returns A deep clone of the value\n */\nexport const deepClone = <T>(value: T): T => {\n return JSON.parse(JSON.stringify(value)) as T\n}\n\n/**\n * Splits an array into two arrays based on a condition.\n *\n * This function takes an array and a predicate function, then returns a tuple containing\n * two arrays: the first contains elements that pass the condition, and the second contains\n * elements that fail the condition.\n *\n * @param array - The array to split\n * @param condition - A predicate function that determines which array each element belongs to\n * @returns A tuple of two arrays: [passingElements, failingElements]\n *\n * @example\n * ```ts\n * const numbers = [1, 2, 3, 4, 5, 6]\n * const [evens, odds] = split(numbers, (n) => n % 2 === 0)\n * // evens: [2, 4, 6]\n * // odds: [1, 3, 5]\n *\n * const words = ['apple', 'banana', 'cherry', 'date']\n * const [longWords, shortWords] = split(words, (word) => word.length > 5)\n * // longWords: ['banana', 'cherry']\n * // shortWords: ['apple', 'date']\n * ```\n */\nexport const split = <T>(array: T[], condition: (element: T) => boolean) => {\n return array.reduce<[T[], T[]]>(\n ([pass, fail], item) => {\n return condition(item) ? [[...pass, item], fail] : [pass, [...fail, item]]\n },\n [[], []],\n )\n}\n\n/**\n * Safely assigns properties from a source object to a target object.\n *\n * This function uses Object.assign to copy enumerable properties from the source object\n * to the target object. It's a type-safe wrapper around Object.assign that ensures\n * the source object is compatible with the target object's type.\n *\n * @param target - The target object to assign properties to\n * @param source - The source object containing properties to assign\n * @template T - The type of the target object\n *\n * @example\n * ```ts\n * const target = { name: 'John', age: 30 }\n * const source = { age: 31, city: 'New York' }\n * safeAssign(target, source)\n * // target is now: { name: 'John', age: 31, city: 'New York' }\n *\n * const config = { theme: 'dark', language: 'en' }\n * const updates = { theme: 'light' }\n * safeAssign(config, updates)\n * // config is now: { theme: 'light', language: 'en' }\n * ```\n */\nexport const safeAssign = <T extends Record<string, unknown>>(target: T, source: Partial<T>) => {\n Object.assign(target, source)\n}\n"],
5
- "mappings": "AAaO,SAAS,WAAW,OAAwB;AACjD,SAAO,MAAM,WAAW,GAAG;AAC7B;AAEO,SAAS,MAAyC,OAAU;AACjE,SAAO,OAAO,KAAK,KAAK;AAC1B;AASO,MAAM,YAAY,CAAI,UAAgB;AAC3C,SAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;AA0BO,MAAM,QAAQ,CAAI,OAAY,cAAuC;AAC1E,SAAO,MAAM;AAAA,IACX,CAAC,CAAC,MAAM,IAAI,GAAG,SAAS;AACtB,aAAO,UAAU,IAAI,IAAI,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC;AAAA,IAC3E;AAAA,IACA,CAAC,CAAC,GAAG,CAAC,CAAC;AAAA,EACT;AACF;AA0BO,MAAM,aAAa,CAAoC,QAAW,WAAuB;AAC9F,SAAO,OAAO,QAAQ,MAAM;AAC9B;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/generate-unique-value.ts"],
4
- "sourcesContent": ["/**\n * Generates a unique value based on a given default value and a validation function.\n *\n * The process works as follows:\n * 1. Optionally transform (e.g., slugify) the default value using a transformation function.\n * 2. Check if this value is unique by executing the provided validation function.\n * 3. If not unique, repeatedly append an incrementing integer (e.g., \"my-name 1\", \"my-name 2\", ...) and re-check uniqueness,\n * up to a maximum number of attempts (maxRetries).\n * 4. Returns the first unique value found or undefined if a unique value cannot be generated within the maximum retries.\n *\n * Example:\n * ```ts\n * // Existing names in use\n * const existing = new Set(['foo', 'foo 1', 'foo 2']);\n * const uniqueName = generateUniqueValue({\n * defaultValue: 'foo',\n * validation: (value) => !existing.has(value),\n * // transformation is optional, e.g. (val) => val.toLowerCase().replace(/[^\\w]+/g, '-'),\n * maxRetries: 10,\n * });\n * // uniqueName === 'foo 3'\n * ```\n */\nexport async function generateUniqueValue({\n defaultValue,\n /** Check function to verify the uniqueness of the value */\n validation,\n /** Transformation function to transform the default value (such as into a slug) */\n transformation,\n /** The maximum number of attempts to create a unique value by incrementing. */\n maxRetries = 5,\n}: {\n /**\n * The original value to base the unique generation upon.\n * Example: \"workspace\", which may end up producing \"workspace 2\", \"workspace 3\", etc.\n */\n defaultValue: string\n\n /**\n * Validation function that determines if a generated value is unique.\n * Should return true if the value is unique; false if not.\n * Can be asynchronous or synchronous.\n */\n validation: (value: string) => Promise<boolean> | boolean\n\n /**\n * Optional function to transform the default value before attempting uniqueness.\n * Example: Transform \"Workspace A\" into \"workspace-a\" to follow a slug schema.\n */\n transformation?: (value: string) => string\n\n /**\n * The maximum number of attempts to create a unique value by incrementing.\n * For example, if set to 5: \"foo\", \"foo 1\", \"foo 2\", \"foo 3\", \"foo 4\" will be attempted.\n */\n maxRetries: number\n}) {\n const transformed = transformation?.(defaultValue) ?? defaultValue\n\n if (await validation(transformed)) {\n return transformed\n }\n\n return incrementValue({\n value: [transformed, 1],\n validation,\n maxRetries,\n transformation,\n })\n}\n\n/**\n * Attempts to generate a unique value by appending and incrementing a counter to a base string.\n *\n * On each attempt, appends the next incrementing integer (e.g. \"foo 1\", \"foo 2\", etc.) to the original value,\n * and checks with the validation function whether the candidate value is unique.\n *\n * Continues until a unique value is found, or the maximum number of attempts is reached.\n *\n * Returns the first unique value found, or undefined if a unique value cannot be generated within maxRetries.\n *\n * Example:\n * ```ts\n * const existing = new Set(['bar', 'bar 1']);\n * const result = incrementValue({\n * value: ['bar', 1],\n * validation: (val) => !existing.has(val),\n * maxRetries: 5,\n * });\n * // result === \"bar 2\"\n * ```\n */\nasync function incrementValue({\n value,\n validation,\n maxRetries,\n attempts = 0,\n transformation,\n}: {\n /**\n * Tuple containing the base value and the starting increment number.\n * Example: [\"workspace\", 1] will try \"workspace 1\", \"workspace 2\", etc.\n */\n value: [string, number] // [base value, next increment]\n\n /**\n * Function to validate if the generated value is unique.\n * Should return true if the value is unique, otherwise false.\n * Supports both synchronous and asynchronous operation.\n */\n validation: (value: string) => Promise<boolean> | boolean\n\n /**\n * The maximum number of retry attempts to generate a unique value.\n * Generation will stop and return undefined if this number is exceeded.\n */\n maxRetries: number\n\n /**\n * The current attempt count.\n * Used internally for recursion; users should generally omit this field.\n */\n attempts?: number\n\n /**\n * Optional function to transform the value before passing it to validation.\n * E.g., for slugifying a value for URLs.\n */\n transformation?: (value: string) => string\n}) {\n if (attempts >= maxRetries) {\n return\n }\n\n const incremented = value.join(' ')\n const transformed = transformation?.(incremented) ?? incremented\n\n if (await validation(transformed)) {\n return transformed\n }\n\n return incrementValue({\n value: [value[0], value[1] + 1],\n validation,\n maxRetries,\n transformation,\n attempts: attempts + 1,\n })\n}\n"],
5
- "mappings": "AAuBA,eAAsB,oBAAoB;AAAA,EACxC;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA,aAAa;AACf,GAyBG;AACD,QAAM,cAAc,iBAAiB,YAAY,KAAK;AAEtD,MAAI,MAAM,WAAW,WAAW,GAAG;AACjC,WAAO;AAAA,EACT;AAEA,SAAO,eAAe;AAAA,IACpB,OAAO,CAAC,aAAa,CAAC;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAuBA,eAAe,eAAe;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,GA+BG;AACD,MAAI,YAAY,YAAY;AAC1B;AAAA,EACF;AAEA,QAAM,cAAc,MAAM,KAAK,GAAG;AAClC,QAAM,cAAc,iBAAiB,WAAW,KAAK;AAErD,MAAI,MAAM,WAAW,WAAW,GAAG;AACjC,WAAO;AAAA,EACT;AAEA,SAAO,eAAe;AAAA,IACpB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,WAAW;AAAA,EACvB,CAAC;AACH;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/get-fetch.ts"],
4
- "sourcesContent": ["import { redirectToProxy } from '@scalar/helpers/url/redirect-to-proxy'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport type { UrlDoc } from '@scalar/workspace-store/client'\n\n/**\n * Get the fetch function from the configuration\n *\n * @param config - The API reference configuration.\n * @returns The fetch function.\n */\nexport const getFetch = (\n config: Partial<Pick<ApiReferenceConfigurationRaw, 'fetch' | 'proxyUrl'>>,\n): NonNullable<UrlDoc['fetch']> => {\n if (config.fetch) {\n return config.fetch\n }\n\n return ((input, init) => fetch(redirectToProxy(config.proxyUrl, input.toString()), init)) satisfies UrlDoc['fetch']\n}\n"],
5
- "mappings": "AAAA,SAAS,uBAAuB;AAUzB,MAAM,WAAW,CACtB,WACiC;AACjC,MAAI,OAAO,OAAO;AAChB,WAAO,OAAO;AAAA,EAChB;AAEA,SAAQ,CAAC,OAAO,SAAS,MAAM,gBAAgB,OAAO,UAAU,MAAM,SAAS,CAAC,GAAG,IAAI;AACzF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/get-resolved-ref.ts"],
4
- "sourcesContent": ["export type RefNode<Node> = Partial<Node> & { $ref: string; '$ref-value': Node }\nexport type NodeInput<Node> = Node | RefNode<Node>\n\nconst defaultTransform = <Node>(node: RefNode<Node>) => {\n return node['$ref-value']\n}\n\n/**\n * Resolves a node that may be a $ref object to its actual value.\n * If the node contains a $ref, applies the provided transform (default: returns '$ref-value').\n * Otherwise, returns the node as-is.\n */\nexport const getResolvedRef = <Node>(\n node: NodeInput<Node>,\n transform: (node: RefNode<Node>) => Node = defaultTransform,\n) => {\n if (typeof node === 'object' && node !== null && '$ref' in node) {\n return transform(node)\n }\n\n return node\n}\n\n/**\n * Type helper we can use if we have getResolvedRef higher in the stack\n */\nexport type Dereference<T> = T extends { $ref: string; '$ref-value'?: infer V } ? (V extends object ? V : never) : T\n"],
5
- "mappings": "AAGA,MAAM,mBAAmB,CAAO,SAAwB;AACtD,SAAO,KAAK,YAAY;AAC1B;AAOO,MAAM,iBAAiB,CAC5B,MACA,YAA2C,qBACxC;AACH,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU,MAAM;AAC/D,WAAO,UAAU,IAAI;AAAA,EACvB;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/is-non-optional-security-requirement.ts"],
4
- "sourcesContent": ["import type { SecurityRequirementObject } from '@/schemas/v3.1/strict/openapi-document'\n\n/** Type guard to determine if a security requirement is non-optional */\nexport const isNonOptionalSecurityRequirement = (\n securityRequirement: SecurityRequirementObject | undefined,\n): securityRequirement is Record<string, string[]> => {\n return securityRequirement !== undefined && Object.keys(securityRequirement).length > 0\n}\n"],
5
- "mappings": "AAGO,MAAM,mCAAmC,CAC9C,wBACoD;AACpD,SAAO,wBAAwB,UAAa,OAAO,KAAK,mBAAmB,EAAE,SAAS;AACxF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/merge-object.ts"],
4
- "sourcesContent": ["import { getRaw } from '@scalar/json-magic/magic-proxy'\n\nimport type { UnknownObject } from '@/helpers/general'\n\n/**\n * Deep merges two objects, combining their properties recursively.\n * Handles circular references by tracking visited objects to prevent infinite recursion.\n *\n * \u26A0\uFE0F Note: This operation assumes there are no key collisions between the objects.\n * Use isKeyCollisions() to check for collisions before merging.\n *\n * @param a - Target object to merge into\n * @param b - Source object to merge from\n * @param cache - Set of visited objects to prevent circular reference issues\n * @returns The merged object (mutates and returns a)\n *\n * @example\n * // Simple merge\n * const a = { name: 'John' }\n * const b = { age: 30 }\n * mergeObjects(a, b) // { name: 'John', age: 30 }\n *\n * // Nested merge\n * const a = { user: { name: 'John' } }\n * const b = { user: { age: 30 } }\n * mergeObjects(a, b) // { user: { name: 'John', age: 30 } }\n *\n * // Circular reference safe\n * const obj = { name: 'John' }\n * obj.self = obj\n * const target = { age: 30 }\n * mergeObjects(target, obj) // Safely merges without infinite recursion\n */\nexport const mergeObjects = <R>(\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n /**\n * By default we overwrite array indexes, our store is built on this assumption when coercing the document\n * Alternatively we may want to prevent this behaviour when merging with defaults and replace the whole array instead\n */\n replaceArrays = false,\n cache: Set<unknown> = new Set(),\n): R => {\n for (const key in b) {\n if (!(key in a)) {\n a[key] = b[key]\n } else {\n const aValue = a[key]\n const bValue = b[key]\n\n /** Replace whole array instead of replacing each index */\n const shouldReplaceArrays = replaceArrays && (Array.isArray(aValue) || Array.isArray(bValue))\n\n if (\n typeof aValue === 'object' &&\n aValue !== null &&\n typeof bValue === 'object' &&\n bValue !== null &&\n !shouldReplaceArrays\n ) {\n const rawA = getRaw(aValue as UnknownObject)\n const rawB = getRaw(bValue as UnknownObject)\n\n // Check for circular references before recursive merge\n if (cache.has(rawA) || cache.has(rawB)) {\n // Skip merging this branch to prevent infinite recursion\n continue\n }\n\n // Add objects to cache before recursive call\n cache.add(rawA)\n cache.add(rawB)\n\n mergeObjects(aValue as Record<string, unknown>, bValue as Record<string, unknown>, replaceArrays, cache)\n } else {\n try {\n a[key] = bValue // Overwrite with b's value if not an object\n } catch (error) {\n console.warn(`Issue setting ${key} on object`)\n console.warn(error)\n }\n }\n }\n }\n\n return a as R\n}\n"],
5
- "mappings": "AAAA,SAAS,cAAc;AAiChB,MAAM,eAAe,CAC1B,GACA,GAKA,gBAAgB,OAChB,QAAsB,oBAAI,IAAI,MACxB;AACN,aAAW,OAAO,GAAG;AACnB,QAAI,EAAE,OAAO,IAAI;AACf,QAAE,GAAG,IAAI,EAAE,GAAG;AAAA,IAChB,OAAO;AACL,YAAM,SAAS,EAAE,GAAG;AACpB,YAAM,SAAS,EAAE,GAAG;AAGpB,YAAM,sBAAsB,kBAAkB,MAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,MAAM;AAE3F,UACE,OAAO,WAAW,YAClB,WAAW,QACX,OAAO,WAAW,YAClB,WAAW,QACX,CAAC,qBACD;AACA,cAAM,OAAO,OAAO,MAAuB;AAC3C,cAAM,OAAO,OAAO,MAAuB;AAG3C,YAAI,MAAM,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,GAAG;AAEtC;AAAA,QACF;AAGA,cAAM,IAAI,IAAI;AACd,cAAM,IAAI,IAAI;AAEd,qBAAa,QAAmC,QAAmC,eAAe,KAAK;AAAA,MACzG,OAAO;AACL,YAAI;AACF,YAAE,GAAG,IAAI;AAAA,QACX,SAAS,OAAO;AACd,kBAAQ,KAAK,iBAAiB,GAAG,YAAY;AAC7C,kBAAQ,KAAK,KAAK;AAAA,QACpB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/overrides-proxy.ts"],
4
- "sourcesContent": ["import { isObject } from '@scalar/helpers/object/is-object'\n\nconst isOverridesProxy = Symbol('isOverridesProxy')\nexport const getOverridesTarget = Symbol('getOverridesTarget')\n\n/**\n * Recursively makes all properties of a type optional.\n *\n * - If T is an object, recursively applies DeepPartial to each property, making them optional.\n * - Otherwise, T is returned as-is.\n *\n * @template T - The type to make deeply partial (optional).\n * @example\n * type Example = { a: { b: number } }\n * type PartialExample = DeepPartial<Example>\n * // Result: { a?: { b?: number } }\n */\nexport type DeepPartial<T> = T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T\n\n/**\n * Creates a proxy object that overlays \"overrides\" on top of a target object.\n *\n * - When reading a property, if an override exists, it is returned; otherwise, the original value is returned.\n * - When writing to a property, if an override exists, it is updated; otherwise, the original object is updated.\n * - This works recursively for nested objects, so overrides can be deeply partial.\n * - Special symbols are used to identify the proxy and to access the original target.\n *\n * @template T - The type of the target object.\n * @param target - The original object to proxy.\n * @param overrides - An optional object containing override values (deeply partial).\n * @returns A proxy object that reflects overrides on top of the target.\n *\n * @example\n * const original = { a: 1, b: { c: 2 } }\n * const overrides = { b: { c: 42 } }\n * const proxy = createOverridesProxy(original, { overrides })\n *\n * console.log(proxy.a) // 1 (from original)\n * console.log(proxy.b.c) // 42 (from overrides)\n *\n * proxy.a = 100\n * console.log(original.a) // 100\n *\n * proxy.b.c = 99\n * console.log(overrides.b.c) // 99\n */\nexport const createOverridesProxy = <T extends Record<string, unknown>>(\n target: T,\n options?: {\n overrides?: DeepPartial<T>\n },\n args: {\n cache: WeakMap<object, any>\n } = {\n cache: new WeakMap(),\n },\n): T => {\n if (!target || typeof target !== 'object') {\n return target\n }\n\n // Return existing proxy for the same target to ensure referential stability\n if (args.cache.has(target)) {\n return args.cache.get(target)!\n }\n\n const { overrides } = options ?? {}\n\n // Proxy handler to intercept get/set operations\n const handler: ProxyHandler<T> = {\n get(target, prop, receiver) {\n // Special symbol to identify this as an overrides proxy\n if (prop === isOverridesProxy) {\n return true\n }\n\n // Special symbol to access the original target object\n if (prop === getOverridesTarget) {\n return target\n }\n\n const value = Reflect.get(target, prop, receiver)\n\n // Return early if the value is already an overrides proxy\n if (isOverridesProxyObject(value)) {\n return value\n }\n\n // If the value is not an object, return the override if it exists, else the original value\n if (!isObject(value)) {\n return Reflect.get(overrides ?? {}, prop) ?? value\n }\n\n // For nested objects, recursively create a proxy with the corresponding overrides\n return createOverridesProxy(value, { overrides: Reflect.get(overrides ?? {}, prop) }, args)\n },\n\n set(target, prop, value, receiver) {\n // Prevent setting special symbols\n if (prop === isOverridesProxy || prop === getOverridesTarget) {\n return false\n }\n\n // If an override exists for this property, update it\n const hasOverride = overrides && Reflect.has(overrides, prop)\n\n if (hasOverride && overrides && typeof overrides === 'object') {\n ;(overrides as any)[prop] = value\n return true\n }\n\n // Otherwise, update the original target\n return Reflect.set(target, prop, value, receiver)\n },\n }\n\n // Return the proxy object\n const proxy = new Proxy<T>(target, handler)\n args.cache.set(target, proxy)\n return proxy\n}\n\nexport const isOverridesProxyObject = (obj: unknown): boolean => {\n return typeof obj === 'object' && obj !== null && (obj as { [isOverridesProxy]: boolean })[isOverridesProxy] === true\n}\n\n/**\n * Unpacks an object from the overrides proxy, returning the original (unproxied) target object.\n * If the input is not an overrides proxy, returns the object as-is.\n *\n * @param input - The potentially proxied object\n * @returns The original unproxied target object or the input object\n */\nexport function unpackOverridesProxy<T>(input: T): T {\n if (\n typeof input === 'object' &&\n input !== null &&\n (input as T & { [isOverridesProxy]: boolean | undefined })[isOverridesProxy]\n ) {\n return (input as T & { [getOverridesTarget]: T })[getOverridesTarget]\n }\n\n return input\n}\n"],
5
- "mappings": "AAAA,SAAS,gBAAgB;AAEzB,MAAM,mBAAmB,OAAO,kBAAkB;AAC3C,MAAM,qBAAqB,OAAO,oBAAoB;AA2CtD,MAAM,uBAAuB,CAClC,QACA,SAGA,OAEI;AAAA,EACF,OAAO,oBAAI,QAAQ;AACrB,MACM;AACN,MAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,WAAO;AAAA,EACT;AAGA,MAAI,KAAK,MAAM,IAAI,MAAM,GAAG;AAC1B,WAAO,KAAK,MAAM,IAAI,MAAM;AAAA,EAC9B;AAEA,QAAM,EAAE,UAAU,IAAI,WAAW,CAAC;AAGlC,QAAM,UAA2B;AAAA,IAC/B,IAAIA,SAAQ,MAAM,UAAU;AAE1B,UAAI,SAAS,kBAAkB;AAC7B,eAAO;AAAA,MACT;AAGA,UAAI,SAAS,oBAAoB;AAC/B,eAAOA;AAAA,MACT;AAEA,YAAM,QAAQ,QAAQ,IAAIA,SAAQ,MAAM,QAAQ;AAGhD,UAAI,uBAAuB,KAAK,GAAG;AACjC,eAAO;AAAA,MACT;AAGA,UAAI,CAAC,SAAS,KAAK,GAAG;AACpB,eAAO,QAAQ,IAAI,aAAa,CAAC,GAAG,IAAI,KAAK;AAAA,MAC/C;AAGA,aAAO,qBAAqB,OAAO,EAAE,WAAW,QAAQ,IAAI,aAAa,CAAC,GAAG,IAAI,EAAE,GAAG,IAAI;AAAA,IAC5F;AAAA,IAEA,IAAIA,SAAQ,MAAM,OAAO,UAAU;AAEjC,UAAI,SAAS,oBAAoB,SAAS,oBAAoB;AAC5D,eAAO;AAAA,MACT;AAGA,YAAM,cAAc,aAAa,QAAQ,IAAI,WAAW,IAAI;AAE5D,UAAI,eAAe,aAAa,OAAO,cAAc,UAAU;AAC7D;AAAC,QAAC,UAAkB,IAAI,IAAI;AAC5B,eAAO;AAAA,MACT;AAGA,aAAO,QAAQ,IAAIA,SAAQ,MAAM,OAAO,QAAQ;AAAA,IAClD;AAAA,EACF;AAGA,QAAM,QAAQ,IAAI,MAAS,QAAQ,OAAO;AAC1C,OAAK,MAAM,IAAI,QAAQ,KAAK;AAC5B,SAAO;AACT;AAEO,MAAM,yBAAyB,CAAC,QAA0B;AAC/D,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAS,IAAwC,gBAAgB,MAAM;AACnH;AASO,SAAS,qBAAwB,OAAa;AACnD,MACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA0D,gBAAgB,GAC3E;AACA,WAAQ,MAA0C,kBAAkB;AAAA,EACtE;AAEA,SAAO;AACT;",
6
- "names": ["target"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/unpack-proxy.ts"],
4
- "sourcesContent": ["import { getRaw } from '@scalar/json-magic/magic-proxy'\nimport { toRaw } from 'vue'\n\nimport { unpackDetectChangesProxy } from '@/helpers/detect-changes-proxy'\nimport { unpackOverridesProxy } from '@/helpers/overrides-proxy'\n\n/**\n * Unpacks special vue reactivity & override & detect-changes & magic proxy from an input object or array,\n * returning the \"raw\" plain object or array.\n *\n * This function recursively traverses the input object or array, removing any proxies\n * (e.g. Vue reactivity proxies, magic proxies, override proxies, detect-changes proxies)\n * to obtain and return the underlying \"raw\" plain object or array.\n *\n * The recursion is controlled by the `depth` parameter. If `depth` is `null`, unlimited depth is allowed.\n * If a proxied object is detected and unwrapped at non-root level, a warning is logged.\n *\n * @param input - The object or array (possibly deeply nested or proxied) to recursively unwrap.\n * @param depth - Optional, limits recursion depth. `null` means unlimited depth (default is 1).\n * @returns - A plain object or array with all proxies removed up to the specified depth.\n */\nexport const unpackProxyObject = <T>(input: T, { depth = 0 }: { depth?: number | null } = {}): T => {\n // Internal DFS helper to recursively strip all known proxies (Vue, overrides, detect-changes, magic proxies)\n const dfs = (value: any, currentDepth: number = 0): any => {\n // Base case: non-objects (primitives, null) are returned as-is\n if (typeof value !== 'object' || value === null) {\n return value\n }\n\n // Compose all the proxy unwraps in order\n const raw = unpackDetectChangesProxy(toRaw(getRaw(unpackOverridesProxy(value))))\n\n // If we have reached the maximum depth, return the value (potentially still partially proxied)\n if (depth !== null && currentDepth >= depth) {\n return raw\n }\n\n // Show a warning if a nested value was a proxy (usually undesired, can cause subtle bugs)\n if (currentDepth !== 0 && raw !== value) {\n console.warn(\n '%c\u26A0 Warning:%c You tried to assign a proxied object (depth: %d).\\n' +\n '%c\uD83D\uDCA1 Tip:%c Pass a plain object instead \u2014 wrapping a proxy inside another proxy may cause weird bugs.\\n' +\n '%c\uD83D\uDD0D Debug Info:%c The problematic value is shown below:',\n // styles\n 'background: #fdd835; color: #000; font-weight: bold; padding: 2px 4px; border-radius: 3px;',\n 'color: inherit;',\n currentDepth,\n 'color: #00bfa5; font-weight: bold;',\n 'color: inherit;',\n 'color: #03a9f4; font-weight: bold;',\n 'color: inherit;',\n value,\n input,\n )\n\n // Collapsed trace group for cleaner output\n console.groupCollapsed('%c\uD83D\uDCDC Proxy assignment trace', 'color: #9c27b0; font-weight: bold;')\n console.trace({ value, raw })\n console.groupEnd()\n }\n\n // Recursively process all properties/entries to make sure we are not assigning proxies directly,\n // but are always assigning plain objects at any level.\n Object.entries(raw).forEach(([key, value]) => {\n const propertyResult = dfs(value, currentDepth + 1)\n const result = Reflect.set(raw, key, propertyResult)\n\n if (!result) {\n console.warn(\n '%c\uD83D\uDEAB Readonly Property Error:%c Failed to set property \"%s\" on object.\\n' +\n '%c\uD83D\uDCA1 Tip:%c This property is readonly or non-configurable. You cannot unpack a readonly property \u2014 the value was not updated.\\n' +\n '%c\uD83D\uDD0D Debug Info:%c Property: %s | Value: %o | Object: %o',\n // styles\n 'background: #f44336; color: #fff; font-weight: bold; padding: 2px 4px; border-radius: 3px;',\n 'color: inherit;',\n key,\n 'color: #00bfa5; font-weight: bold;',\n 'color: inherit;',\n 'color: #03a9f4; font-weight: bold;',\n 'color: inherit;',\n key,\n propertyResult,\n raw,\n )\n }\n })\n\n return raw\n }\n\n return dfs(input)\n}\n"],
5
- "mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,aAAa;AAEtB,SAAS,gCAAgC;AACzC,SAAS,4BAA4B;AAiB9B,MAAM,oBAAoB,CAAI,OAAU,EAAE,QAAQ,EAAE,IAA+B,CAAC,MAAS;AAElG,QAAM,MAAM,CAAC,OAAY,eAAuB,MAAW;AAEzD,QAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,aAAO;AAAA,IACT;AAGA,UAAM,MAAM,yBAAyB,MAAM,OAAO,qBAAqB,KAAK,CAAC,CAAC,CAAC;AAG/E,QAAI,UAAU,QAAQ,gBAAgB,OAAO;AAC3C,aAAO;AAAA,IACT;AAGA,QAAI,iBAAiB,KAAK,QAAQ,OAAO;AACvC,cAAQ;AAAA,QACN;AAAA;AAAA,QAIA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAGA,cAAQ,eAAe,sCAA+B,oCAAoC;AAC1F,cAAQ,MAAM,EAAE,OAAO,IAAI,CAAC;AAC5B,cAAQ,SAAS;AAAA,IACnB;AAIA,WAAO,QAAQ,GAAG,EAAE,QAAQ,CAAC,CAAC,KAAKA,MAAK,MAAM;AAC5C,YAAM,iBAAiB,IAAIA,QAAO,eAAe,CAAC;AAClD,YAAM,SAAS,QAAQ,IAAI,KAAK,KAAK,cAAc;AAEnD,UAAI,CAAC,QAAQ;AACX,gBAAQ;AAAA,UACN;AAAA;AAAA,UAIA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAEA,SAAO,IAAI,KAAK;AAClB;",
6
- "names": ["value"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/mutators/auth.ts"],
4
- "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { AuthEvents } from '@/events/definitions/auth'\nimport { generateUniqueValue } from '@/helpers/generate-unique-value'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { isNonOptionalSecurityRequirement } from '@/helpers/is-non-optional-security-requirement'\nimport { mergeObjects } from '@/helpers/merge-object'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { SecurityRequirementObject } from '@/schemas/v3.1/strict/security-requirement'\nimport type { OAuth2Object } from '@/schemas/v3.1/strict/security-scheme'\n\n/**\n * Updates the selected security schemes for either the entire document or a specific operation.\n * - Adds newly created security schemes (if any) to the workspace document's components.\n * - Ensures that each new scheme name is unique within the document by using `generateUniqueValue`.\n * - Updates the `x-scalar-selected-security` property on the target (document or operation) to reflect the new set of selected security schemes.\n * - Corrects and maintains the selected index so it points to a valid security scheme.\n *\n * @param document - The workspace OpenAPI document to mutate (can be null, in which case nothing happens)\n * @param selectedSecuritySchemes - The current list of selected security scheme objects\n * @param create - Array of new schemes to create, each with a name and a scheme definition\n * @param meta - Location to update: whole document or a specific operation (`{ type: 'document' }` or `{ type: 'operation', path, method }`)\n *\n * Example usage:\n * ```\n * updateSelectedSecuritySchemes({\n * document,\n * selectedSecuritySchemes: [{ bearerAuth: [] }],\n * create: [\n * { name: 'ApiKeyAuth', scheme: { type: 'apiKey', in: 'header', name: 'X-API-Key' } }\n * ],\n * meta: { type: 'document' }\n * })\n * ```\n */\nexport const updateSelectedSecuritySchemes = async (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { selectedRequirements, newSchemes, meta }: AuthEvents['auth:update:selected-security-schemes'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n // Helper to get the target (whole document or a specific operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n }\n\n return store?.auth.getAuthSelectedSchemas({ type: 'operation', documentName, path: meta.path, method: meta.method })\n }\n\n const createdSecurityRequirements = await Promise.all(\n newSchemes.map(async (newScheme) => {\n const uniqueSchemeName = await generateUniqueValue({\n defaultValue: newScheme.name,\n validation: (value) => !document.components?.securitySchemes?.[value],\n maxRetries: 100,\n })\n\n if (!uniqueSchemeName) {\n return\n }\n\n // Ensure components and securitySchemes exist\n if (!document.components) {\n document.components = {}\n }\n if (!document.components.securitySchemes) {\n document.components.securitySchemes = {}\n }\n\n // Add the new security scheme definition\n document.components.securitySchemes[uniqueSchemeName] = newScheme.scheme\n\n // Return an OpenAPI Security Requirement Object for this new scheme (empty scope array)\n return {\n [uniqueSchemeName]: [],\n }\n }),\n )\n\n // Create any new security schemes required, ensuring unique names for the components\n const createdSchemes = createdSecurityRequirements.filter(Boolean) as SecurityRequirementObject[]\n\n const target = getTarget()\n\n const newSelectedSecuritySchemes = [...selectedRequirements, ...createdSchemes]\n\n const getSelectedIndex = () => {\n if (!target?.selectedIndex) {\n return 0\n }\n\n if (target.selectedIndex >= newSelectedSecuritySchemes.length) {\n return newSelectedSecuritySchemes.length - 1\n }\n\n return target.selectedIndex\n }\n\n // if (payload. === 'document') {\n if (meta.type === 'document') {\n return store?.auth.setAuthSelectedSchemas(\n { type: 'document', documentName },\n { selectedIndex: getSelectedIndex(), selectedSchemes: newSelectedSecuritySchemes },\n )\n }\n return store?.auth.setAuthSelectedSchemas(\n { type: 'operation', documentName, path: meta.path, method: meta.method },\n { selectedIndex: getSelectedIndex(), selectedSchemes: newSelectedSecuritySchemes },\n )\n}\n\n/**\n * Clears the selected security schemes from the workspace store for a document or operation.\n * This function will remove any selection state related to security (auth) for either the entire document\n * or for a specific operation if meta.type is 'operation'.\n * If the document name cannot be determined, nothing happens.\n */\nconst clearSelectedSecuritySchemes = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { meta }: AuthEvents['auth:clear:selected-security-schemes'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n if (meta.type === 'document') {\n return store?.auth.clearAuthSelectedSchemas({ type: 'document', documentName })\n }\n return store?.auth.clearAuthSelectedSchemas({ type: 'operation', documentName, path: meta.path, method: meta.method })\n}\n\n/**\n * Updates a security scheme in the OpenAPI document's components object.\n * Handles updates for HTTP, API Key, and OAuth2 types, saving secret information and configuration for UI-auth flows.\n *\n * @param document - The OpenAPI workspace document (can be null)\n * @param data - The update information, including type and payload\n * @param name - The name of the security scheme in document.components.securitySchemes\n *\n * Example usage:\n *\n * updateSecurityScheme({\n * document,\n * data: {\n * type: 'http',\n * payload: {\n * username: 'user123',\n * password: 'pw123',\n * token: 'tokenval'\n * }\n * },\n * name: 'MyHttpAuth',\n * })\n */\nexport const updateSecurityScheme = (\n document: WorkspaceDocument | null,\n { payload, name }: AuthEvents['auth:update:security-scheme'],\n) => {\n const target = getResolvedRef(document?.components?.securitySchemes?.[name])\n if (!target) {\n console.error(`Security scheme ${name} not found`)\n return\n }\n\n // Handle HTTP (basic, bearer, etc.)\n if (target.type === payload.type) {\n mergeObjects(target, payload)\n }\n\n return target\n}\n\nconst updateSecuritySchemeSecrets = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { payload, name, overwrite = false }: AuthEvents['auth:update:security-scheme-secrets'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n // If we want to remove properties then we should set replace to true\n if (overwrite) {\n store?.auth.setAuthSecrets(documentName, name, payload)\n return\n }\n\n const auth = store?.auth.getAuthSecrets(documentName, name)\n const result = mergeObjects(\n unpackProxyObject(auth, { depth: 1 }) ?? {},\n payload,\n ) as AuthEvents['auth:update:security-scheme-secrets']['payload']\n store?.auth.setAuthSecrets(documentName, name, result)\n}\n\nconst clearSecuritySchemeSecrets = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { name }: AuthEvents['auth:clear:security-scheme-secrets'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n store?.auth.clearAuthSecrets(documentName, name)\n}\n\n/**\n * Sets the selected authentication tab (scheme) index for the given OpenAPI document or operation.\n * - When on the document level, updates the 'selectedIndex' on the document's x-scalar-selected-security extension.\n * - When on an operation (endpoint) level, updates the 'selectedIndex' for that operation's x-scalar-selected-security.\n *\n * Also initializes the x-scalar-selected-security extension if it does not exist.\n *\n * @param document The OpenAPI document object (may be null)\n * @param index The index to set as selected\n * @param meta Context where the selection applies ('document' or specific operation)\n *\n * @example\n * // Document-level tab selection\n * updateSelectedAuthTab({\n * document,\n * index: 1,\n * meta: { type: 'document' }\n * });\n *\n * // Operation-level tab selection (e.g., GET /pets)\n * updateSelectedAuthTab({\n * document,\n * index: 0,\n * meta: { type: 'operation', path: '/pets', method: 'get' }\n * });\n */\nexport const updateSelectedAuthTab = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { index, meta }: AuthEvents['auth:update:active-index'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n // Ensure the path/method exists in the document\n if (meta.type === 'operation' && document?.paths?.[meta.path]?.[meta.method] === undefined) {\n return\n }\n\n // Determine the target object for setting the auth tab index:\n // - Document/root level\n // - Operation/endpoint level (if meta specifies operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n }\n return store?.auth.getAuthSelectedSchemas({ type: 'operation', documentName, path: meta.path, method: meta.method })\n }\n\n const target = getTarget()\n\n if (!target) {\n if (meta.type === 'document') {\n return store?.auth.setAuthSelectedSchemas(\n { type: 'document', documentName },\n { selectedIndex: index, selectedSchemes: [] },\n )\n }\n return store?.auth.setAuthSelectedSchemas(\n { type: 'operation', documentName, path: meta.path, method: meta.method },\n { selectedIndex: index, selectedSchemes: [] },\n )\n }\n\n // Set the selected index\n target.selectedIndex = index\n}\n\n/**\n * Updates the scopes for a specific security requirement in the selected security schemes of\n * a document or operation. Also allow to add a new scope to the scheme.\n *\n * @param document - The OpenAPI WorkspaceDocument to update.\n * @param id - An array of scheme names that uniquely identifies the target security requirement.\n * For example: ['OAuth', 'ApiKeyAuth']\n * @param name - The security scheme name to update scopes for (e.g., 'OAuth').\n * @param scopes - The new list of scopes to set. For example: ['read:pets', 'write:pets']\n * @param newScopePayload - The payload to add a new scope with\n * @param meta - The context specifying whether the update is at the document-level or operation-level.\n *\n * Example usage:\n * ```ts\n * // Suppose your document (or operation) x-scalar-selected-security looks like:\n * // \"x-scalar-selected-security\": {\n * // selectedIndex: 0,\n * // selectedSchemes: [\n * // { \"OAuth\": [\"read:pets\"] },\n * // { \"ApiKeyAuth\": [] }\n * // ]\n * // }\n *\n * updateSelectedScopes({\n * document,\n * id: [\"OAuth\"], // identifies the scheme object: { \"OAuth\": [...] }\n * name: \"OAuth\", // scheme name to update within this security requirement\n * scopes: [\"write:pets\"], // new scopes array\n * meta: { type: \"document\" }\n * })\n * // After, the first scheme becomes: { \"OAuth\": [\"write:pets\"] }\n * ```\n */\nexport const updateSelectedScopes = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { id, name, scopes, newScopePayload, meta }: AuthEvents['auth:update:selected-scopes'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n // Determine the target object (document or the operation)\n const getTarget = () => {\n if (meta.type === 'document') {\n return store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n }\n return store?.auth.getAuthSelectedSchemas({ type: 'operation', documentName, path: meta.path, method: meta.method })\n }\n\n const target = getTarget()\n if (!target) {\n return\n }\n\n // Find the security requirement that matches the given id (scheme key names)\n // For example: if id = [\"OAuth\"], matches { OAuth: [...] }\n const scheme = target.selectedSchemes.find((scheme) => JSON.stringify(Object.keys(scheme)) === JSON.stringify(id))\n\n // If the scheme is optional, do nothing as it cannot have scopes\n if (!isNonOptionalSecurityRequirement(scheme)) {\n return\n }\n\n // If we have a new scope payload, add it to the scheme\n if (newScopePayload) {\n const securityScheme = getResolvedRef(document.components?.securitySchemes?.[name])\n const flow = (securityScheme as OAuth2Object)?.flows?.[newScopePayload?.flowType]\n if (!flow) {\n return\n }\n flow.scopes ||= {}\n\n flow.scopes[newScopePayload.name] = newScopePayload.description\n scheme[name] = [...scopes, newScopePayload.name]\n return\n }\n\n // Set the scopes array for the named security scheme within the found security requirement\n scheme[name] = scopes\n}\n\n/**\n * Deletes one or more security schemes from an OpenAPI WorkspaceDocument,\n * and removes all references to those schemes from selected security, document-level security,\n * and operation-level security/selected security (e.g., on paths).\n *\n * Example usage:\n *\n * ```ts\n * deleteSecurityScheme({\n * document, // The OpenAPI document to update\n * names: ['ApiKeyAuth', 'BearerAuth'], // The names of security schemes you want to delete\n * });\n * ```\n *\n * After running this function:\n * - The named security schemes are removed from the components.securitySchemes section.\n * - All document-level and operation-level security entries referencing those schemes are removed.\n * - Any extended x-scalar-selected-security references to those schemes are also removed.\n */\nexport const deleteSecurityScheme = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { names }: AuthEvents['auth:delete:security-scheme'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!documentName) {\n // Early exit if there is no document to modify\n return\n }\n\n // Get the mutable reference to securitySchemes in components (may be a proxy/resolved reference)\n const target = getResolvedRef(document.components?.securitySchemes)\n\n if (!target) {\n // If there are no security schemes to delete from, return early\n return\n }\n\n // Remove each named security scheme from the components.securitySchemes object\n names.forEach((name) => {\n delete target[name]\n })\n\n const clampIndex = (index: number, length: number) => {\n return Math.max(0, Math.min(index, length - 1))\n }\n\n // Function to remove any security requirement objects that reference given scheme names.\n const filterSecuritySchemes = (_schemes: SecurityRequirementObject[]) => {\n const schemes = unpackProxyObject(_schemes, { depth: 1 }) ?? []\n // Remove schemes whose key is included in the `names` to be deleted.\n return schemes.filter((scheme) => !names.some((name) => Object.keys(scheme).includes(name)))\n }\n\n const documentSelectedSecurity = store?.auth.getAuthSelectedSchemas({ type: 'document', documentName })\n\n // -- Remove from document-level `x-scalar-selected-security` extension, if present\n if (documentSelectedSecurity) {\n documentSelectedSecurity.selectedSchemes = filterSecuritySchemes(documentSelectedSecurity.selectedSchemes)\n documentSelectedSecurity.selectedIndex = clampIndex(\n documentSelectedSecurity.selectedIndex,\n documentSelectedSecurity.selectedSchemes.length,\n )\n }\n\n // -- Remove from document-level `security` property, if present\n if (document['security']) {\n document['security'] = filterSecuritySchemes(document['security'])\n }\n\n // -- For each path and operation, remove deleted security schemes from operation-level security and custom extension\n Object.entries(document.paths ?? {}).forEach(([path, pathItemObject]) => {\n Object.entries(pathItemObject).forEach(([method, operation]) => {\n if (typeof operation !== 'object') {\n // Ignore operations that are not objects (could be undefined)\n return\n }\n\n // Get mutable reference for the operation (could resolve $ref proxies)\n const resolvedOperation = getResolvedRef(operation)\n\n // Remove from operation-level security array\n if ('security' in resolvedOperation && resolvedOperation['security']) {\n resolvedOperation['security'] = filterSecuritySchemes(resolvedOperation['security'])\n }\n\n // // Remove from operation-level x-scalar-selected-security array\n const operationSelectedSecurity = store?.auth.getAuthSelectedSchemas({\n type: 'operation',\n documentName,\n path,\n method,\n })\n if (operationSelectedSecurity) {\n operationSelectedSecurity.selectedSchemes = filterSecuritySchemes(operationSelectedSecurity.selectedSchemes)\n operationSelectedSecurity.selectedIndex = clampIndex(\n operationSelectedSecurity.selectedIndex,\n operationSelectedSecurity.selectedSchemes.length,\n )\n }\n })\n })\n}\n\nexport const authMutatorsFactory = ({\n document,\n store,\n}: {\n document: WorkspaceDocument | null\n store: WorkspaceStore | null\n}) => {\n return {\n updateSelectedSecuritySchemes: (payload: AuthEvents['auth:update:selected-security-schemes']) =>\n updateSelectedSecuritySchemes(store, document, payload),\n clearSelectedSecuritySchemes: (payload: AuthEvents['auth:clear:selected-security-schemes']) =>\n clearSelectedSecuritySchemes(store, document, payload),\n updateSecurityScheme: (payload: AuthEvents['auth:update:security-scheme']) =>\n updateSecurityScheme(document, payload),\n updateSecuritySchemeSecrets: (payload: AuthEvents['auth:update:security-scheme-secrets']) =>\n updateSecuritySchemeSecrets(store, document, payload),\n clearSecuritySchemeSecrets: (payload: AuthEvents['auth:clear:security-scheme-secrets']) =>\n clearSecuritySchemeSecrets(store, document, payload),\n updateSelectedAuthTab: (payload: AuthEvents['auth:update:active-index']) =>\n updateSelectedAuthTab(store, document, payload),\n updateSelectedScopes: (payload: AuthEvents['auth:update:selected-scopes']) =>\n updateSelectedScopes(store, document, payload),\n deleteSecurityScheme: (payload: AuthEvents['auth:delete:security-scheme']) =>\n deleteSecurityScheme(store, document, payload),\n }\n}\n"],
5
- "mappings": "AAEA,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,wCAAwC;AACjD,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AA6B3B,MAAM,gCAAgC,OAC3C,OACA,UACA,EAAE,sBAAsB,YAAY,KAAK,MACtC;AACH,QAAM,eAAe,WAAW,qBAAqB,GAAG;AACxD,MAAI,CAAC,cAAc;AACjB;AAAA,EACF;AAGA,QAAM,YAAY,MAAM;AACtB,QAAI,KAAK,SAAS,YAAY;AAC5B,aAAO,OAAO,KAAK,uBAAuB,EAAE,MAAM,YAAY,aAAa,CAAC;AAAA,IAC9E;AAEA,WA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C,YAC9B,8BAA8B,OAAO,UAAU,OAAO;AAAA,IACxD,8BAA8B,CAAC,YAC7B,6BAA6B,OAAO,UAAU,OAAO;AAAA,IACvD,sBAAsB,CAAC,YACrB,qBAAqB,UAAU,OAAO;AAAA,IACxC,6BAA6B,CAAC,YAC5B,4BAA4B,OAAO,UAAU,OAAO;AAAA,IACtD,4BAA4B,CAAC,YAC3B,2BAA2B,OAAO,UAAU,OAAO;AAAA,IACrD,uBAAuB,CAAC,YACtB,sBAAsB,OAAO,UAAU,OAAO;AAAA,IAChD,sBAAsB,CAAC,YACrB,qBAAqB,OAAO,UAAU,OAAO;AAAA,IAC/C,sBAAsB,CAAC,YACrB,qBAAqB,OAAO,UAAU,OAAO;AAAA,EACjD;AACF;",
6
- "names": ["scheme"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/mutators/cookie.ts"],
4
- "sourcesContent": ["import type { CookieEvents } from '@/events/definitions/cookie'\nimport type { Workspace, WorkspaceDocument } from '@/schemas'\nimport { type XScalarCookie, xScalarCookieSchema } from '@/schemas/extensions/general/x-scalar-cookies'\nimport { coerceValue } from '@/schemas/typebox-coerce'\n\ntype Event<T extends keyof CookieEvents> = Omit<CookieEvents[T], 'collectionType'>\n\n/**\n * Adds OR updates a cookie to the document or workspace.\n *\n * @param document - current document if available\n * @param workspace - current workspace if available\n * @param payload - The cookie configuration to add or update\n * @param index - Optional index for updating an existing cookie\n * @param collectionType - Whether this is for a document or workspace\n * @returns the parsed cookie that was added or updated or undefined if the collection is not found\n */\nexport const upsertCookie = (\n collection: WorkspaceDocument | Workspace | null,\n { payload, index }: Event<'cookie:upsert:cookie'>,\n): XScalarCookie | undefined => {\n if (!collection) {\n return\n }\n\n if (!collection['x-scalar-cookies']) {\n collection['x-scalar-cookies'] = []\n }\n\n if (index !== undefined) {\n // Update existing cookie at index\n if (index < 0 || index >= collection['x-scalar-cookies'].length) {\n return\n }\n\n // Ensure we parse the payload but keep the existing cookie data\n const parsed = coerceValue(xScalarCookieSchema, {\n ...collection['x-scalar-cookies'][index],\n ...payload,\n })\n\n // Update\n collection['x-scalar-cookies'][index] = parsed\n return parsed\n }\n\n // Add new cookie\n const parsed = coerceValue(xScalarCookieSchema, payload)\n collection['x-scalar-cookies'].push(parsed)\n return parsed\n}\n\n/**\n * Deletes a cookie from the document or workspace by index.\n *\n * @param document - current document if available\n * @param workspace - current workspace if available\n * @param index - Index of the cookie to delete\n * @param collectionType - Whether this is for a document or workspace\n * @returns true if the cookie was deleted, false otherwise\n */\nexport const deleteCookie = (\n collection: WorkspaceDocument | Workspace | null,\n { index }: Event<'cookie:delete:cookie'>,\n): boolean => {\n if (!collection || !collection['x-scalar-cookies']) {\n return false\n }\n\n if (index < 0 || index >= collection['x-scalar-cookies'].length) {\n return false\n }\n\n collection['x-scalar-cookies'].splice(index, 1)\n return true\n}\n\nexport const cookieMutatorsFactory = ({ collection }: { collection: WorkspaceDocument | Workspace | null }) => {\n return {\n upsertCookie: (payload: Event<'cookie:upsert:cookie'>) => upsertCookie(collection, payload),\n deleteCookie: (payload: Event<'cookie:delete:cookie'>) => deleteCookie(collection, payload),\n }\n}\n"],
5
- "mappings": "AAEA,SAA6B,2BAA2B;AACxD,SAAS,mBAAmB;AAcrB,MAAM,eAAe,CAC1B,YACA,EAAE,SAAS,MAAM,MACa;AAC9B,MAAI,CAAC,YAAY;AACf;AAAA,EACF;AAEA,MAAI,CAAC,WAAW,kBAAkB,GAAG;AACnC,eAAW,kBAAkB,IAAI,CAAC;AAAA,EACpC;AAEA,MAAI,UAAU,QAAW;AAEvB,QAAI,QAAQ,KAAK,SAAS,WAAW,kBAAkB,EAAE,QAAQ;AAC/D;AAAA,IACF;AAGA,UAAMA,UAAS,YAAY,qBAAqB;AAAA,MAC9C,GAAG,WAAW,kBAAkB,EAAE,KAAK;AAAA,MACvC,GAAG;AAAA,IACL,CAAC;AAGD,eAAW,kBAAkB,EAAE,KAAK,IAAIA;AACxC,WAAOA;AAAA,EACT;AAGA,QAAM,SAAS,YAAY,qBAAqB,OAAO;AACvD,aAAW,kBAAkB,EAAE,KAAK,MAAM;AAC1C,SAAO;AACT;AAWO,MAAM,eAAe,CAC1B,YACA,EAAE,MAAM,MACI;AACZ,MAAI,CAAC,cAAc,CAAC,WAAW,kBAAkB,GAAG;AAClD,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,KAAK,SAAS,WAAW,kBAAkB,EAAE,QAAQ;AAC/D,WAAO;AAAA,EACT;AAEA,aAAW,kBAAkB,EAAE,OAAO,OAAO,CAAC;AAC9C,SAAO;AACT;AAEO,MAAM,wBAAwB,CAAC,EAAE,WAAW,MAA4D;AAC7G,SAAO;AAAA,IACL,cAAc,CAAC,YAA2C,aAAa,YAAY,OAAO;AAAA,IAC1F,cAAc,CAAC,YAA2C,aAAa,YAAY,OAAO;AAAA,EAC5F;AACF;",
6
- "names": ["parsed"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/mutators/document.ts"],
4
- "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { DocumentEvents } from '@/events/definitions/document'\nimport { mergeObjects } from '@/helpers/merge-object'\nimport type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Updates the \"watch mode\" state of the given document.\n *\n * @param document WorkspaceDocument or null \u2013 The document to modify.\n * @param watchMode boolean \u2013 True enables watch mode, false disables it.\n *\n * If document is null, does nothing.\n */\nexport const updateWatchMode = (document: WorkspaceDocument | null, watchMode: boolean) => {\n if (!document) {\n return\n }\n\n // Set (or unset) the x-scalar-watch-mode property on the document\n document['x-scalar-watch-mode'] = watchMode\n}\n\n/**\n * Updates the document's info object (typically, title, description, version, etc.).\n *\n * Uses a shallow merge: only properties present in payload will be overwritten or added.\n *\n * @param document WorkspaceDocument | null \u2013 The document whose info should be updated.\n * @param payload DocumentEvents['document:update:info'] \u2013 Partial info fields to update/merge.\n *\n * If document is null, does nothing.\n */\nexport const updateDocumentInfo = (\n document: WorkspaceDocument | null,\n payload: DocumentEvents['document:update:info'],\n) => {\n if (!document) {\n return\n }\n // Merge the given payload into the document's info object\n mergeObjects(document.info, payload)\n\n // Update the document title if it is present and the navigation object is present\n // We do this because we don't want to rebuild the entire navigation object if only the title is changed\n // Normalize like traverseDocument: trim and treat whitespace-only as empty so we show \"Untitled Document\"\n if (document['x-scalar-navigation'] && payload.title !== undefined) {\n document['x-scalar-navigation'].title = payload.title?.trim() || 'Untitled Document'\n }\n}\n\n/**\n * Update the document icon and also update the corresponding sidebar entry\n *\n * Does not perform a sidebar rebuild for performance benefit\n */\nexport const updateDocumentIcon = (document: WorkspaceDocument | null, icon: string) => {\n if (!document || !document['x-scalar-navigation']) {\n return\n }\n\n // Update the document icon\n document['x-scalar-icon'] = icon\n // Update the sidebar document icon\n document['x-scalar-navigation'].icon = icon\n}\n\n/**\n * Creates an empty OpenAPI document and adds it to the workspace.\n *\n * - If the store is null, this is a no-op.\n * - The document name must be unique; if already present, callback is called with `false`.\n * - On success, a new OpenAPI 3.1.0 document is added with a basic path and info.\n * - Callback is called with `true` if document is created.\n *\n * @param store WorkspaceStore | null \u2013 The workspace store to add the document to.\n * @param payload DocumentEvents['document:create:empty-document'] \u2013 Contains name, icon, and callback.\n */\nexport const createEmptyDocument = async (\n store: WorkspaceStore | null,\n payload: DocumentEvents['document:create:empty-document'],\n) => {\n if (!store) {\n return\n }\n\n // Check if the document already exists by name for uniqueness\n if (store.workspace.documents[payload.name]) {\n // Document name already exists, call callback with false\n payload.callback?.(false)\n return\n }\n\n // Add a new empty OpenAPI 3.1.0 document with minimal info and icon\n await store.addDocument({\n name: payload.name,\n document: {\n openapi: '3.1.0',\n info: { title: payload.name, version: '1.0.0' },\n paths: {\n '/': {\n get: {},\n },\n },\n 'x-scalar-icon': payload.icon,\n },\n })\n\n // Notify success via callback\n payload.callback?.(true)\n}\n\n/**\n * Deletes a document from the workspace by its name.\n *\n * Safely no-ops if the store is null.\n */\nexport const deleteDocument = (store: WorkspaceStore | null, payload: DocumentEvents['document:delete:document']) => {\n if (!store) {\n return\n }\n\n store.deleteDocument(payload.name)\n}\n\nexport const documentMutatorsFactory = ({\n document,\n store,\n}: {\n document: WorkspaceDocument | null\n store: WorkspaceStore | null\n}) => {\n return {\n updateDocumentInfo: (payload: DocumentEvents['document:update:info']) => updateDocumentInfo(document, payload),\n updateWatchMode: (payload: DocumentEvents['document:update:watch-mode']) => updateWatchMode(document, payload),\n updateDocumentIcon: (payload: DocumentEvents['document:update:icon']) => updateDocumentIcon(document, payload),\n createEmptyDocument: (payload: DocumentEvents['document:create:empty-document']) =>\n createEmptyDocument(store, payload),\n deleteDocument: (payload: DocumentEvents['document:delete:document']) => deleteDocument(store, payload),\n }\n}\n"],
5
- "mappings": "AAEA,SAAS,oBAAoB;AAWtB,MAAM,kBAAkB,CAAC,UAAoC,cAAuB;AACzF,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAGA,WAAS,qBAAqB,IAAI;AACpC;AAYO,MAAM,qBAAqB,CAChC,UACA,YACG;AACH,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,eAAa,SAAS,MAAM,OAAO;AAKnC,MAAI,SAAS,qBAAqB,KAAK,QAAQ,UAAU,QAAW;AAClE,aAAS,qBAAqB,EAAE,QAAQ,QAAQ,OAAO,KAAK,KAAK;AAAA,EACnE;AACF;AAOO,MAAM,qBAAqB,CAAC,UAAoC,SAAiB;AACtF,MAAI,CAAC,YAAY,CAAC,SAAS,qBAAqB,GAAG;AACjD;AAAA,EACF;AAGA,WAAS,eAAe,IAAI;AAE5B,WAAS,qBAAqB,EAAE,OAAO;AACzC;AAaO,MAAM,sBAAsB,OACjC,OACA,YACG;AACH,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAGA,MAAI,MAAM,UAAU,UAAU,QAAQ,IAAI,GAAG;AAE3C,YAAQ,WAAW,KAAK;AACxB;AAAA,EACF;AAGA,QAAM,MAAM,YAAY;AAAA,IACtB,MAAM,QAAQ;AAAA,IACd,UAAU;AAAA,MACR,SAAS;AAAA,MACT,MAAM,EAAE,OAAO,QAAQ,MAAM,SAAS,QAAQ;AAAA,MAC9C,OAAO;AAAA,QACL,KAAK;AAAA,UACH,KAAK,CAAC;AAAA,QACR;AAAA,MACF;AAAA,MACA,iBAAiB,QAAQ;AAAA,IAC3B;AAAA,EACF,CAAC;AAGD,UAAQ,WAAW,IAAI;AACzB;AAOO,MAAM,iBAAiB,CAAC,OAA8B,YAAwD;AACnH,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAEA,QAAM,eAAe,QAAQ,IAAI;AACnC;AAEO,MAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AACF,MAGM;AACJ,SAAO;AAAA,IACL,oBAAoB,CAAC,YAAoD,mBAAmB,UAAU,OAAO;AAAA,IAC7G,iBAAiB,CAAC,YAA0D,gBAAgB,UAAU,OAAO;AAAA,IAC7G,oBAAoB,CAAC,YAAoD,mBAAmB,UAAU,OAAO;AAAA,IAC7G,qBAAqB,CAAC,YACpB,oBAAoB,OAAO,OAAO;AAAA,IACpC,gBAAgB,CAAC,YAAwD,eAAe,OAAO,OAAO;AAAA,EACxG;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/mutators/environment.ts"],
4
- "sourcesContent": ["import type { EnvironmentEvents } from '@/events/definitions/environment'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport type { Workspace, WorkspaceDocument } from '@/schemas'\nimport {\n type XScalarEnvVar,\n type XScalarEnvironment,\n xScalarEnvVarSchema,\n xScalarEnvironmentSchema,\n} from '@/schemas/extensions/document/x-scalar-environments'\nimport { coerceValue } from '@/schemas/typebox-coerce'\n\ntype Event<T extends keyof EnvironmentEvents> = Omit<EnvironmentEvents[T], 'collectionType'>\n\n/**\n * Adds OR updates an environment to the document or workspace.\n *\n * @param document - current document if available\n * @param workspace - current workspace if available\n * @param environmentName - Name of the environment to add\n * @param payload - The environment configuration to add\n * @param oldEnvironmentName - Only needed when renaming the environment\n * @returns the parsed environment that was added or updated or undefined if the collection is not found\n */\nexport const upsertEnvironment = (\n workspace: Workspace | null,\n collection: WorkspaceDocument | Workspace | null,\n { environmentName, payload, oldEnvironmentName }: Event<'environment:upsert:environment'>,\n): XScalarEnvironment | undefined => {\n /** Discriminating between document and workspace */\n if (!collection || !workspace) {\n return\n }\n\n if (!collection['x-scalar-environments']) {\n collection['x-scalar-environments'] = {}\n }\n\n // Check if this is a new environment before we create it\n const isNewEnvironment = !collection['x-scalar-environments'][oldEnvironmentName ?? environmentName]\n\n // Ensure we parse the payload but keep the old variables\n const parsed = coerceValue(xScalarEnvironmentSchema, {\n ...unpackProxyObject(collection['x-scalar-environments'][oldEnvironmentName ?? environmentName], { depth: 1 }),\n ...payload,\n })\n collection['x-scalar-environments'][environmentName] = parsed\n\n // If we are renaming the environment, we need to delete the old one\n if (oldEnvironmentName && oldEnvironmentName !== environmentName) {\n delete collection['x-scalar-environments'][oldEnvironmentName]\n\n // If the old environment was active, we need to set the new environment as active\n if (workspace['x-scalar-active-environment'] === oldEnvironmentName) {\n workspace['x-scalar-active-environment'] = environmentName\n }\n }\n\n // Set the newly created workspace environment as active\n if (isNewEnvironment) {\n workspace['x-scalar-active-environment'] = environmentName\n }\n\n return parsed\n}\n\n/**\n * Deletes an environment from the given collection and handles active environment state.\n *\n * @param workspace - The workspace object, or null if unavailable.\n * @param collection - The workspace document or workspace object, or null if unavailable.\n * @param environmentName - The name of the environment to delete.\n */\nexport const deleteEnvironment = (\n workspace: Workspace | null,\n collection: WorkspaceDocument | Workspace | null,\n { environmentName }: Event<'environment:delete:environment'>,\n) => {\n if (!collection || !workspace) {\n return\n }\n\n // Trigegr the change event for the active environment\n delete collection['x-scalar-environments']?.[environmentName]\n}\n\n/**\n * Adds OR updates an environment variable to the document or workspace.\n *\n * @param collection - Workspace OR document\n * @param environmentName - Name of the environment to add the variable to\n * @param variableName - Name of the variable to add\n * @param value - Value of the variable to add\n * @returns the parsed variable that was added or updated or undefined if the collection is not found\n */\nexport const upsertEnvironmentVariable = (\n collection: WorkspaceDocument | Workspace | null,\n { environmentName, variable, index }: Event<'environment:upsert:environment-variable'>,\n): XScalarEnvVar | undefined => {\n // The environment should exist by now if we are upserting a variable\n if (!collection?.['x-scalar-environments']?.[environmentName]) {\n console.error('Environment not found', environmentName)\n return\n }\n\n // Ensure we parse the variable for type safety\n const parsed = coerceValue(xScalarEnvVarSchema, variable)\n\n if (index !== undefined) {\n // Delete the row if the name is empty\n if (parsed.name === '') {\n collection['x-scalar-environments'][environmentName].variables.splice(index, 1)\n return\n }\n\n // Update\n collection['x-scalar-environments'][environmentName].variables[index] = parsed\n }\n // Add\n else {\n collection['x-scalar-environments'][environmentName].variables.push(parsed)\n }\n\n return parsed\n}\n\nexport const deleteEnvironmentVariable = (\n collection: WorkspaceDocument | Workspace | null,\n { environmentName, index }: Event<'environment:delete:environment-variable'>,\n) => {\n if (!collection?.['x-scalar-environments']?.[environmentName]) {\n console.error('Environment not found', environmentName)\n return\n }\n collection['x-scalar-environments']?.[environmentName]?.variables?.splice(index, 1)\n}\n\nexport const environmentMutatorsFactory = ({\n workspace,\n collection,\n}: {\n workspace: Workspace | null\n collection: WorkspaceDocument | Workspace | null\n}) => {\n return {\n upsertEnvironment: (payload: Event<'environment:upsert:environment'>) =>\n upsertEnvironment(workspace, collection, payload),\n deleteEnvironment: (payload: Event<'environment:delete:environment'>) =>\n deleteEnvironment(workspace, collection, payload),\n upsertEnvironmentVariable: (payload: Event<'environment:upsert:environment-variable'>) =>\n upsertEnvironmentVariable(collection, payload),\n deleteEnvironmentVariable: (payload: Event<'environment:delete:environment-variable'>) =>\n deleteEnvironmentVariable(collection, payload),\n }\n}\n"],
5
- "mappings": "AACA,SAAS,yBAAyB;AAElC;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAcrB,MAAM,oBAAoB,CAC/B,WACA,YACA,EAAE,iBAAiB,SAAS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AEK;AACH,eAAW,uBAAuB,EAAE,eAAe,EAAE,UAAU,KAAK,MAAM;AAAA,EAC5E;AAEA,SAAO;AACT;AAEO,MAAM,4BAA4B,CACvC,YACA,EAAE,iBAAiB,MAAM,MACtB;AACH,MAAI,CAAC,aAAa,uBAAuB,IAAI,eAAe,GAAG;AAC7D,YAAQ,MAAM,yBAAyB,eAAe;AACtD;AAAA,EACF;AACA,aAAW,uBAAuB,IAAI,eAAe,GAAG,WAAW,OAAO,OAAO,CAAC;AACpF;AAEO,MAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AACF,MAGM;AACJ,SAAO;AAAA,IACL,mBAAmB,CAAC,YAClB,kBAAkB,WAAW,YAAY,OAAO;AAAA,IAClD,mBAAmB,CAAC,YAClB,kBAAkB,WAAW,YAAY,OAAO;AAAA,IAClD,2BAA2B,CAAC,YAC1B,0BAA0B,YAAY,OAAO;AAAA,IAC/C,2BAA2B,CAAC,YAC1B,0BAA0B,YAAY,OAAO;AAAA,EACjD;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/mutators/helpers.ts"],
4
- "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { WorkspaceDocument } from '@/schemas'\n\nexport const getDocument = (store: WorkspaceStore | null, documentName: string): WorkspaceDocument | null => {\n if (!store) {\n return null\n }\n\n const document = store.workspace.documents[documentName]\n\n if (!document) {\n return null\n }\n\n return document\n}\n"],
5
- "mappings": "AAGO,MAAM,cAAc,CAAC,OAA8B,iBAAmD;AAC3G,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,MAAM,UAAU,UAAU,YAAY;AAEvD,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/mutators/index.ts"],
4
- "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport { authMutatorsFactory } from '@/mutators/auth'\nimport { cookieMutatorsFactory } from '@/mutators/cookie'\nimport { documentMutatorsFactory } from '@/mutators/document'\nimport { environmentMutatorsFactory } from '@/mutators/environment'\nimport { getDocument } from '@/mutators/helpers'\nimport { operationMutatorsFactory } from '@/mutators/operation'\nimport { serverMutatorsFactory } from '@/mutators/server'\nimport { tabsMutatorsFactory } from '@/mutators/tabs'\nimport { tagMutatorsFactory } from '@/mutators/tag'\nimport { workspaceMutatorsFactory } from '@/mutators/workspace'\nimport type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Generates a set of mutators for managing OpenAPI document and workspace state.\n *\n * @param store - The workspace store containing all documents and workspace-level data\n * @returns An object with mutators for the workspace, the active document, and any named document\n */\nexport function generateClientMutators(store: WorkspaceStore | null) {\n /**\n * Returns mutators for a specific document by name.\n *\n * @param documentName - The name of the document to get mutators for\n * @returns An object containing mutators for requests, request examples, security schemes, environments, and cookies\n */\n const documentMutators = (document: WorkspaceDocument | null) => {\n return {\n auth: authMutatorsFactory({ store, document }),\n cookie: cookieMutatorsFactory({ collection: document }),\n document: documentMutatorsFactory({ document, store }),\n operation: operationMutatorsFactory({ document, store }),\n server: serverMutatorsFactory({ document }),\n tag: tagMutatorsFactory({ store }),\n environment: environmentMutatorsFactory({ workspace: store?.workspace ?? null, collection: document }),\n }\n }\n\n /**\n * Returns mutators for the workspace-level configuration.\n *\n * @returns An object containing mutators for environments and cookies at the workspace level\n */\n const workspaceMutators = () => {\n return {\n cookie: cookieMutatorsFactory({ collection: store?.workspace ?? null }),\n tabs: tabsMutatorsFactory({ workspace: store?.workspace ?? null }),\n workspace: workspaceMutatorsFactory({ workspace: store?.workspace ?? null }),\n environment: environmentMutatorsFactory({\n workspace: store?.workspace ?? null,\n collection: store?.workspace ?? null,\n }),\n }\n }\n\n return {\n /**\n * Returns mutators for the workspace-level configuration.\n */\n workspace: () => workspaceMutators(),\n /**\n * Returns mutators for the currently active document.\n * Falls back to the first document if no active document is set.\n */\n active: () => documentMutators(store?.workspace.activeDocument ?? null),\n /**\n * Returns mutators for a specific document by name.\n *\n * @param name - The name of the document\n */\n doc: (name: string) => documentMutators(getDocument(store, name)),\n }\n}\n"],
5
- "mappings": "AACA,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,+BAA+B;AACxC,SAAS,kCAAkC;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,gCAAgC;AASlC,SAAS,uBAAuB,OAA8B;AAOnE,QAAM,mBAAmB,CAAC,aAAuC;AAC/D,WAAO;AAAA,MACL,MAAM,oBAAoB,EAAE,OAAO,SAAS,CAAC;AAAA,MAC7C,QAAQ,sBAAsB,EAAE,YAAY,SAAS,CAAC;AAAA,MACtD,UAAU,wBAAwB,EAAE,UAAU,MAAM,CAAC;AAAA,MACrD,WAAW,yBAAyB,EAAE,UAAU,MAAM,CAAC;AAAA,MACvD,QAAQ,sBAAsB,EAAE,SAAS,CAAC;AAAA,MAC1C,KAAK,mBAAmB,EAAE,MAAM,CAAC;AAAA,MACjC,aAAa,2BAA2B,EAAE,WAAW,OAAO,aAAa,MAAM,YAAY,SAAS,CAAC;AAAA,IACvG;AAAA,EACF;AAOA,QAAM,oBAAoB,MAAM;AAC9B,WAAO;AAAA,MACL,QAAQ,sBAAsB,EAAE,YAAY,OAAO,aAAa,KAAK,CAAC;AAAA,MACtE,MAAM,oBAAoB,EAAE,WAAW,OAAO,aAAa,KAAK,CAAC;AAAA,MACjE,WAAW,yBAAyB,EAAE,WAAW,OAAO,aAAa,KAAK,CAAC;AAAA,MAC3E,aAAa,2BAA2B;AAAA,QACtC,WAAW,OAAO,aAAa;AAAA,QAC/B,YAAY,OAAO,aAAa;AAAA,MAClC,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA;AAAA;AAAA;AAAA,IAIL,WAAW,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA,IAKnC,QAAQ,MAAM,iBAAiB,OAAO,UAAU,kBAAkB,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMtE,KAAK,CAAC,SAAiB,iBAAiB,YAAY,OAAO,IAAI,CAAC;AAAA,EAClE;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/mutators/operation/body.ts"],
4
- "sourcesContent": ["import type { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport type { WorkspaceDocument } from '@/schemas'\nimport type { ExampleObject } from '@/schemas/v3.1/strict/example'\n\n/** Ensure the json that we need exists up to the example object in the request body */\nconst findOrCreateRequestBodyExample = (\n document: WorkspaceDocument | null,\n contentType: string,\n meta: OperationEvents['operation:update:requestBody:contentType']['meta'],\n): ExampleObject | null => {\n const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return null\n }\n\n // Ensure that the request body exists\n let requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n operation.requestBody = {\n content: {},\n }\n requestBody = getResolvedRef(operation.requestBody)\n }\n\n // Ensure that the example exists\n requestBody.content[contentType] ||= {}\n requestBody.content[contentType].examples ||= {}\n requestBody.content[contentType].examples[meta.exampleKey] ||= {}\n\n const example = getResolvedRef(requestBody.content[contentType].examples?.[meta.exampleKey])\n return example ?? null\n}\n\n/**\n * Sets the selected request-body content type for the current `exampleKey`.\n * This stores the selection under `x-scalar-selected-content-type` on the\n * resolved requestBody. Safely no-ops if the document or operation does not exist.\n *\n * Example:\n * ```ts\n * updateOperationRequestBodyContentType({\n * document,\n * meta: { method: 'post', path: '/upload', exampleKey: 'default' },\n * payload: { contentType: 'multipart/form-data' },\n * })\n * ```\n */\nexport const updateOperationRequestBodyContentType = (\n document: WorkspaceDocument | null,\n { meta, payload }: OperationEvents['operation:update:requestBody:contentType'],\n) => {\n if (!document) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return\n }\n\n let requestBody = getResolvedRef(operation.requestBody)\n if (!requestBody) {\n operation.requestBody = {\n content: {},\n }\n requestBody = getResolvedRef(operation.requestBody)\n }\n\n if (!requestBody!['x-scalar-selected-content-type']) {\n requestBody!['x-scalar-selected-content-type'] = {}\n }\n\n requestBody!['x-scalar-selected-content-type'][meta.exampleKey] = payload.contentType\n}\n\n/**\n * Creates or updates a concrete example value for a specific request-body\n * `contentType` and `exampleKey`. Safely no-ops if the document or operation\n * does not exist.\n *\n * Example:\n * ```ts\n * updateOperationRequestBodyExample({\n * document,\n * contentType: 'application/json',\n * meta: { method: 'post', path: '/users', exampleKey: 'default' },\n * payload: { value: JSON.stringify({ name: 'Ada' }) },\n * })\n * ```\n */\nexport const updateOperationRequestBodyExample = (\n document: WorkspaceDocument | null,\n { meta, payload, contentType }: OperationEvents['operation:update:requestBody:value'],\n) => {\n const example = findOrCreateRequestBodyExample(document, contentType, meta)\n if (!example) {\n console.error('Example not found', meta.exampleKey)\n return\n }\n\n example.value = payload\n}\n\n/**\n * Stores the form data for the request body example\n *\n * This needs special handling as we store it as an array of objects with a schema type of object\n */\nexport const updateOperationRequestBodyFormValue = (\n document: WorkspaceDocument | null,\n { meta, payload, contentType }: OperationEvents['operation:update:requestBody:formValue'],\n) => {\n const example = findOrCreateRequestBodyExample(document, contentType, meta)\n if (!example) {\n console.error('Example not found', meta.exampleKey)\n return\n }\n\n example.value = unpackProxyObject(payload, { depth: 3 })\n}\n"],
5
- "mappings": "AACA,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAKlC,MAAM,iCAAiC,CACrC,UACA,aACA,SACyB;AACzB,QAAM,YAAY,eAAe,UAAU,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC;AAC5E,MAAI,CAAC,WAAW;AACd,WAAO;AAAA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AAI;AAC1E,MAAI,CAAC,SAAS;AACZ,YAAQ,MAAM,qBAAqB,KAAK,UAAU;AAClD;AAAA,EACF;AAEA,UAAQ,QAAQ,kBAAkB,SAAS,EAAE,OAAO,EAAE,CAAC;AACzD;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/mutators/operation/extensions.ts"],
4
- "sourcesContent": ["import type { OperationEvents } from '@/events'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { mergeObjects } from '@/helpers/merge-object'\nimport type { WorkspaceDocument } from '@/schemas'\n\n/**\n * Updates an extension of the operation\n *\n * @example\n * ```ts\n * updateOperationExtension({\n * document,\n * meta: { method: 'get', path: '/users' },\n * payload: { 'x-post-response': 'console.log(response)' },\n * })\n * ```\n */\nexport const updateOperationExtension = (\n document: WorkspaceDocument | null,\n { meta, payload }: OperationEvents['operation:update:extension'],\n) => {\n const operation = getResolvedRef(document?.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return\n }\n\n mergeObjects(operation, payload)\n}\n"],
5
- "mappings": "AACA,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAetB,MAAM,2BAA2B,CACtC,UACA,EAAE,MAAM,QAAQ,MACb;AACH,QAAM,YAAY,eAAe,UAAU,QAAQ,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC;AAC5E,MAAI,CAAC,WAAW;AACd;AAAA,EACF;AAEA,eAAa,WAAW,OAAO;AACjC;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/mutators/operation/helpers/fetch-request-to-har.ts"],
4
- "sourcesContent": ["import type { HarRequest } from '@scalar/snippetz'\n\ntype FetchRequestToHarProps = {\n /** The Fetch API Request object to convert */\n request: Request\n /**\n * Whether to include the request body in the HAR postData.\n * Note: Reading the body consumes it, so the request will be cloned automatically.\n * @default true\n */\n includeBody?: boolean\n /**\n * HTTP version string to use (since Fetch API does not expose this)\n * @default 'HTTP/1.1'\n */\n httpVersion?: string\n /**\n * The maximum size of the request body to include in the HAR postData.\n * @default 1MB\n */\n bodySizeLimit?: number\n}\n\n/**\n * Converts a Fetch API Request object to HAR (HTTP Archive) Request format.\n *\n * This function transforms a standard JavaScript Fetch API Request into the\n * HAR format, which is useful for:\n * - Recording HTTP requests for replay or analysis\n * - Creating request fixtures from real API calls\n * - Debugging and monitoring HTTP traffic\n * - Storing request history in a standard format\n * - Generating API documentation from real requests\n *\n * The conversion handles:\n * - Request method and URL\n * - Headers extraction (excluding sensitive headers if needed)\n * - Query parameters extraction from URL\n * - Cookie extraction from headers\n * - Request body reading (with automatic cloning to preserve the original)\n * - Content-Type detection and MIME type extraction\n * - Size calculations for headers and body\n * - Form data bodies are converted to params array\n * - Other body types are read as text\n *\n * Note: The Fetch API does not expose the HTTP version, so it defaults to HTTP/1.1\n * unless specified otherwise.\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Request\n *\n * @example\n * const request = new Request('https://api.example.com/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * })\n * const harRequest = await fetchRequestToHar({ request })\n * console.log(harRequest.method) // 'POST'\n * console.log(harRequest.postData?.text) // '{\"name\":\"John\"}'\n */\nexport const fetchRequestToHar = async ({\n request,\n includeBody = true,\n httpVersion = 'HTTP/1.1',\n // Default to 1MB\n bodySizeLimit = 1048576,\n}: FetchRequestToHarProps): Promise<HarRequest> => {\n // Extract query string from URL\n const url = new URL(request.url)\n\n // Extract the query strings from the URL\n const queryString = Array.from(url.searchParams.entries()).map(([name, value]) => ({ name, value }))\n\n // Extract the headers from the request\n const { headers, headersSize, cookies } = processRequestHeaders(request)\n\n // Extract the MIME type from the request headers\n const mimeType = request.headers.get('content-type')?.split(';')[0]?.trim() ?? 'text/plain'\n\n // Read the request body if requested\n const bodyDetails = await (async () => {\n if (includeBody && request.body) {\n const details = await processRequestBody(request.clone())\n if (details.size <= bodySizeLimit) {\n return details\n }\n }\n return { text: '', size: -1 }\n })()\n\n // Create the HAR request object\n const harRequest: HarRequest = {\n method: request.method,\n url: request.url,\n httpVersion,\n headers,\n cookies,\n queryString,\n headersSize,\n bodySize: bodyDetails.size,\n postData:\n 'params' in bodyDetails\n ? {\n mimeType,\n params: bodyDetails.params,\n }\n : {\n mimeType,\n text: bodyDetails.text,\n },\n }\n\n return harRequest\n}\n\nconst processRequestBody = async (request: Request) => {\n const formData = await tryGetRequestFormData(request.clone())\n if (formData) {\n return Array.from(formData.entries()).reduce<{ params: { name: string; value: string }[]; size: number }>(\n (acc, [name, value]) => {\n if (value instanceof File) {\n const fileName = `@${value.name}`\n acc.params.push({ name, value: fileName })\n acc.size += fileName.length\n return acc\n }\n\n acc.params.push({ name, value })\n acc.size += value.length\n return acc\n },\n { params: [], size: 0 },\n )\n }\n // Skip binary bodies\n if (request.headers.get('content-type')?.includes('application/octet-stream')) {\n return { text: '', size: -1 }\n }\n\n // Read the request body as text\n const arrayBuffer = await request.arrayBuffer()\n const size = arrayBuffer.byteLength\n return { size, text: new TextDecoder().decode(arrayBuffer) }\n}\n\nasync function tryGetRequestFormData(request: Request): Promise<FormData | null> {\n if (typeof request.formData !== 'function') {\n return null\n }\n\n if (request.bodyUsed) {\n return null\n }\n\n const contentType = request.headers.get('content-type') ?? ''\n if (!contentType.includes('multipart/form-data') && !contentType.includes('application/x-www-form-urlencoded')) {\n return null\n }\n\n try {\n return await request.formData()\n } catch {\n return null\n }\n}\n\nconst processRequestHeaders = (request: Request) => {\n return Array.from(request.headers.entries()).reduce<{\n headers: { name: string; value: string }[]\n headersSize: number\n cookies: { name: string; value: string }[]\n }>(\n (acc, [name, value]) => {\n if (name.toLowerCase() === 'cookie') {\n const parsedCookies = parseCookieHeader(value)\n acc.cookies.push(...parsedCookies.cookies)\n } else {\n acc.headers.push({ name, value })\n acc.headersSize += name.length + 2 + value.length + 2\n }\n return acc\n },\n { headers: [], headersSize: 0, cookies: [] },\n )\n}\n\n/**\n * Parses a Cookie header value into an array of cookie objects.\n * Cookie format: name1=value1; name2=value2\n */\nconst parseCookieHeader = (cookieValue: string) => {\n return cookieValue.split(';').reduce<{ cookies: { name: string; value: string }[]; size: number }>(\n (acc, part) => {\n const trimmedPart = part.trim()\n const equalIndex = trimmedPart.indexOf('=')\n\n if (equalIndex === -1) {\n return acc\n }\n\n const name = trimmedPart.substring(0, equalIndex).trim()\n const value = trimmedPart.substring(equalIndex + 1).trim()\n\n acc.cookies.push({ name, value })\n acc.size += name.length + 2 + value.length + 2\n return acc\n },\n { cookies: [], size: 0 },\n )\n}\n"],
5
- "mappings": "AA6DO,MAAM,oBAAoB,OAAO;AAAA,EACtC;AAAA,EACA,cAAc;AAAA,EACd,cAAc;AAAA;AAAA,EAEd,gBAAgB;AAClB,MAAmD;AAEjD,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAG/B,QAAM,cAAc,MAAM,KAAK,IAAI,aAAa,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,EAAE,MAAM,MAAM,EAAE;AAGnG,QAAM,EAAE,SAAS,aAAa,QAAQ,IAAI,sBAAsB,OAAO;AAGvE,QAAM,WAAW,QAAQ,QAAQ,IAAI,cAAc,GAAG,MAAM,GAAG,EAAE,CAAC,GAAG,KAAK,KAAK;AAG/E,QAAM,cAAc,OAAO,YAAY;AACrC,QAAI,eAAe,QAAQ,MAAM;AAC/B,YAAM,UAAU,MAAM,mBAAmB,QAAQ,MAAM,CAAC;AACxD,UAAI,QAAQ,QAAQ,eAAe;AACjC,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO,EAAE,MAAM,IAAI,MAAM,GAAG;AAAA,EAC9B,GAAG;AAGH,QAAM,aAAyB;AAAA,IAC7B,QAAQ,QAAQ;AAAA,IAChB,KAAK,QAAQ;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;A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ourcesContent": ["import type { HarResponse } from '@scalar/snippetz'\n\ntype FetchResponseToHarProps = {\n /** The Fetch API Response object to convert */\n response: Response\n /**\n * Whether to include the response body in the HAR content.\n * Note: Reading the body consumes it, so the response will be cloned automatically.\n * Bodies will only be included if they meet the following criteria:\n * - Not a streaming response (text/event-stream)\n * - Text-based content (not binary)\n * - Under 1MB in size\n * @default true\n */\n includeBody?: boolean\n /**\n * HTTP version string to use (since Fetch API does not expose this)\n * @default 'HTTP/1.1'\n */\n httpVersion?: string\n /**\n * The maximum size of the response body to include in the HAR content.\n * @default 1MB\n */\n bodySizeLimit?: number\n}\n\n/**\n * Converts a Fetch API Response object to HAR (HTTP Archive) Response format.\n *\n * This function transforms a standard JavaScript Fetch API Response into the\n * HAR format, which is useful for:\n * - Recording HTTP responses for replay or analysis\n * - Creating test fixtures from real API responses\n * - Debugging and monitoring HTTP traffic\n * - Generating API documentation from real responses\n *\n * The conversion handles:\n * - Response status and status text\n * - Headers extraction (including Set-Cookie headers converted to cookies)\n * - Response body reading (with automatic cloning to preserve the original)\n * - Content-Type detection and MIME type extraction\n * - Size calculations for headers and body\n * - Redirect URL extraction from Location header\n *\n * Note: The Fetch API does not expose the HTTP version, so it defaults to HTTP/1.1\n * unless specified otherwise.\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Response\n *\n * @example\n * const response = await fetch('https://api.example.com/users')\n * const harResponse = await fetchResponseToHar({ response })\n * console.log(harResponse.status) // 200\n */\nexport const fetchResponseToHar = async ({\n response,\n includeBody = true,\n httpVersion = 'HTTP/1.1',\n bodySizeLimit = 1048576,\n}: FetchResponseToHarProps): Promise<HarResponse> => {\n // Extract the headers from the response\n const { headers, headersSize, cookies } = processResponseHeaders(response)\n\n // Extract redirect URL from Location header\n const redirectURL = response.headers.get('location') || ''\n\n // Get content type\n const contentType = response.headers.get('content-type') ?? 'text/plain'\n\n // Read the response body if requested\n const bodyDetails = await (async () => {\n if (includeBody && response.body) {\n const details = await processResponseBody(response.clone())\n if (details.size <= bodySizeLimit) {\n return details\n }\n }\n return { text: '', size: -1, encoding: undefined }\n })()\n\n // Create the HAR response object\n const harResponse: HarResponse = {\n status: response.status,\n statusText: response.statusText,\n httpVersion,\n headers,\n cookies,\n content: {\n size: bodyDetails.size,\n mimeType: contentType,\n text: bodyDetails.text,\n encoding: bodyDetails.encoding,\n },\n redirectURL,\n headersSize,\n bodySize: bodyDetails.size,\n }\n\n return harResponse\n}\n\nconst processResponseHeaders = (response: Response) => {\n return Array.from(response.headers.entries()).reduce<{\n headers: { name: string; value: string }[]\n headersSize: number\n cookies: { name: string; value: string }[]\n }>(\n (acc, [name, value]) => {\n acc.headers.push({ name, value })\n acc.headersSize += name.length + 2 + value.length + 2\n\n // Parse Set-Cookie headers into cookies array\n if (name.toLowerCase() === 'set-cookie') {\n const cookie = parseSetCookieHeader(value)\n if (cookie) {\n acc.cookies.push(cookie)\n }\n }\n\n return acc\n },\n { headers: [], headersSize: 0, cookies: [] },\n )\n}\n\nconst processResponseBody = async (response: Response) => {\n const contentType = response.headers.get('content-type')\n if (!contentType || !isTextBasedContent(contentType)) {\n return { text: '', size: -1, encoding: undefined }\n }\n\n try {\n // Read as ArrayBuffer to get the size\n const arrayBuffer = await response.arrayBuffer()\n const bodySize = arrayBuffer.byteLength\n const text = new TextDecoder('utf-8').decode(arrayBuffer)\n return { text, size: bodySize, encoding: undefined }\n } catch {\n // If body cannot be read, leave it empty\n return { text: '', size: -1, encoding: undefined }\n }\n}\n\n/**\n * Checks if the content type is text-based and should be included in HAR.\n * Text-based content types include:\n * - text/* (text/plain, text/html, text/css, etc.)\n * - application/json\n * - application/xml and text/xml\n * - application/javascript\n * - application/*+json and application/*+xml variants\n */\nexport const isTextBasedContent = (contentType: string): boolean => {\n const lowerContentType = contentType.toLowerCase()\n\n // Check for text/* types\n if (lowerContentType.startsWith('text/')) {\n return true\n }\n\n // Check for JSON types\n if (lowerContentType.includes('application/json') || lowerContentType.includes('+json')) {\n return true\n }\n\n // Check for XML types\n if (\n lowerContentType.includes('application/xml') ||\n lowerContentType.includes('text/xml') ||\n lowerContentType.includes('+xml')\n ) {\n return true\n }\n\n // Check for JavaScript\n if (lowerContentType.includes('application/javascript') || lowerContentType.includes('application/x-javascript')) {\n return true\n }\n\n // Check for common text-based formats\n if (\n lowerContentType.includes('application/x-www-form-urlencoded') ||\n lowerContentType.includes('application/graphql')\n ) {\n return true\n }\n\n return false\n}\n\n/**\n * Parses a Set-Cookie header value into a cookie object.\n * This is a simplified parser that extracts the name and value.\n * For full cookie parsing with attributes, a more robust parser would be needed.\n */\nconst parseSetCookieHeader = (setCookieValue: string): { name: string; value: string } | null => {\n // Set-Cookie format: name=value; attribute1=value1; attribute2=value2\n const parts = setCookieValue.split(';')\n if (parts.length === 0 || !parts[0]) {\n return null\n }\n\n const cookiePart = parts[0].trim()\n const equalIndex = cookiePart.indexOf('=')\n\n if (equalIndex === -1) {\n return null\n }\n\n const name = cookiePart.substring(0, equalIndex).trim()\n const value = cookiePart.substring(equalIndex + 1).trim()\n\n return { name, value }\n}\n"],
5
- "mappings": "AAwDO,MAAM,qBAAqB,OAAO;AAAA,EACvC;AAAA,EACA,cAAc;AAAA,EACd,cAAc;AAAA,EACd,gBAAgB;AAClB,MAAqD;AAEnD,QAAM,EAAE,SAAS,aAAa,QAAQ,IAAI,uBAAuB,QAAQ;AAGzE,QAAM,cAAc,SAAS,QAAQ,IAAI,UAAU,KAAK;AAGxD,QAAM,cAAc,SAAS,QAAQ,IAAI,cAAc,KAAK;AAG5D,QAAM,cAAc,OAAO,YAAY;AACrC,QAAI,eAAe,SAAS,MAAM;AAChC,YAAM,UAAU,MAAM,oBAAoB,SAAS,MAAM,CAAC;AAC1D,UAAI,QAAQ,QAAQ,eAAe;AACjC,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO,EAAE,MAAM,IAAI,MAAM,IAAI,UAAU,OAAU;AAAA,EACnD,GAAG;AAGH,QAA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WO,MAAM,qBAAqB,CAAC,gBAAiC;AAClE,QAAM,mBAAmB,YAAY,YAAY;AAGjD,MAAI,iBAAiB,WAAW,OAAO,GAAG;AACxC,WAAO;AAAA,EACT;AAGA,MAAI,iBAAiB,SAAS,kBAAkB,KAAK,iBAAiB,SAAS,OAAO,GAAG;AACvF,WAAO;AAAA,EACT;AAGA,MACE,iBAAiB,SAAS,iBAAiB,KAC3C,iBAAiB,SAAS,UAAU,KACpC,iBAAiB,SAAS,MAAM,GAChC;AACA,WAAO;AAAA,EACT;AAGA,MAAI,iBAAiB,SAAS,wBAAwB,KAAK,iBAAiB,SAAS,0BAA0B,GAAG;AAChH,WAAO;AAAA,EACT;AAGA,MACE,iBAAiB,SAAS,mCAAmC,KAC7D,iBAAiB,SAAS,qBAAqB,GAC/C;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAOA,MAAM,uBAAuB,CAAC,mBAAmE;AAE/F,QAAM,QAAQ,eAAe,MAAM,GAAG;AACtC,MAAI,MAAM,WAAW,KAAK,CAAC,MAAM,CAAC,GAAG;AACnC,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,MAAM,CAAC,EAAE,KAAK;AACjC,QAAM,aAAa,WAAW,QAAQ,GAAG;AAEzC,MAAI,eAAe,IAAI;AACrB,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,WAAW,UAAU,GAAG,UAAU,EAAE,KAAK;AACtD,QAAM,QAAQ,WAAW,UAAU,aAAa,CAAC,EAAE,KAAK;AAExD,SAAO,EAAE,MAAM,MAAM;AACvB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/mutators/operation/helpers/get-parameter-position.ts"],
4
- "sourcesContent": ["/**\n * Creates a map of parameter names to their character positions in a path.\n * Used to detect renamed path parameters by position matching.\n */\nexport const getParameterPositions = (path: string, parameters: readonly string[]): Record<string, number> => {\n const positions: Record<string, number> = {}\n\n for (const paramName of parameters) {\n const position = path.indexOf(`{${paramName}}`)\n if (position !== -1) {\n positions[paramName] = position\n }\n }\n\n return positions\n}\n"],
5
- "mappings": "AAIO,MAAM,wBAAwB,CAAC,MAAc,eAA0D;AAC5G,QAAM,YAAoC,CAAC;AAE3C,aAAW,aAAa,YAAY;AAClC,UAAM,WAAW,KAAK,QAAQ,IAAI,SAAS,GAAG;AAC9C,QAAI,aAAa,IAAI;AACnB,gBAAU,SAAS,IAAI;AAAA,IACzB;AAAA,EACF;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/mutators/operation/helpers/har-to-operation.ts"],
4
- "sourcesContent": ["import type { HarRequest } from '@scalar/snippetz'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { ReferenceType } from '@scalar/workspace-store/schemas/v3.1/strict/reference'\n\nimport { isContentTypeParameterObject } from '@/schemas/v3.1/strict/type-guards'\n\ntype HarToOperationProps = {\n /** HAR request to convert */\n harRequest: HarRequest\n /** Name of the example to populate (e.g., 'default', 'example1') */\n exampleKey: string\n /** Optional base operation to merge with */\n baseOperation?: OperationObject\n /** Optional path variables to merge with */\n pathVariables?: Record<string, string>\n}\n\nconst preprocessParameters = (\n parameters: ReferenceType<ParameterObject>[],\n pathVariables: Record<string, string>,\n exampleKey: string,\n) => {\n parameters.forEach((param) => {\n const resolvedParam = getResolvedRef(param)\n if (isContentTypeParameterObject(resolvedParam)) {\n return\n }\n\n setParameterDisabled(getResolvedRef(param), exampleKey, true)\n\n if (resolvedParam.in === 'path') {\n resolvedParam.examples ||= {}\n resolvedParam.examples[exampleKey] = {\n value: pathVariables[resolvedParam.name] ?? '',\n 'x-disabled': false,\n }\n }\n })\n}\n\n/**\n * Converts a HAR request back to an OpenAPI Operation object with populated examples.\n *\n * This function is the reverse of operationToHar - it takes a HAR request and\n * converts it back into an OpenAPI operation structure, populating the example\n * values based on the HAR request data.\n *\n * The conversion handles:\n * - URL parsing to extract path and query parameters\n * - Header extraction and mapping to operation parameters\n * - Query string parsing and mapping to parameters\n * - Cookie extraction and mapping to cookie parameters\n * - Request body extraction and mapping to requestBody with examples\n * - Content-Type detection and media type assignment\n *\n * Note: This function focuses on populating examples and does not reconstruct\n * schema definitions. If you need full schema generation, consider combining\n * this with a schema inference tool.\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const harToOperation = ({\n harRequest,\n exampleKey,\n baseOperation = {},\n pathVariables = {},\n}: HarToOperationProps): OperationObject => {\n // Ensure parameters array exists on the base operation\n if (!baseOperation.parameters) {\n baseOperation.parameters = []\n }\n\n // Set any other parameters as disabled and set the path variables\n preprocessParameters(baseOperation.parameters, pathVariables, exampleKey)\n\n // Process query string parameters from the HAR request\n if (harRequest.queryString && harRequest.queryString.length > 0) {\n for (const queryParam of harRequest.queryString) {\n const param = findOrCreateParameter(baseOperation.parameters, queryParam.name, 'query')\n\n if (!param || isContentTypeParameterObject(param)) {\n continue\n }\n\n param.examples ||= {}\n param.examples[exampleKey] = {\n value: queryParam.value,\n 'x-disabled': false,\n }\n }\n }\n\n // Process headers from the HAR request\n if (harRequest.headers && harRequest.headers.length > 0) {\n for (const header of harRequest.headers) {\n const param = findOrCreateParameter(baseOperation.parameters, header.name, 'header')\n\n if (!param || isContentTypeParameterObject(param)) {\n continue\n }\n\n param.examples ||= {}\n param.examples[exampleKey] = {\n value: header.value,\n 'x-disabled': false,\n }\n }\n }\n\n // Process cookies from the HAR request\n if (harRequest.cookies && harRequest.cookies.length > 0) {\n for (const cookie of harRequest.cookies) {\n const param = findOrCreateParameter(baseOperation.parameters, cookie.name, 'cookie')\n\n if (!param || isContentTypeParameterObject(param)) {\n continue\n }\n\n param.examples ||= {}\n param.examples[exampleKey] = {\n value: cookie.value,\n 'x-disabled': false,\n }\n }\n }\n\n // Process request body from the HAR request\n if (harRequest.postData) {\n const { mimeType, text, params } = harRequest.postData\n\n // Ensure requestBody exists on the base operation\n if (!baseOperation.requestBody) {\n baseOperation.requestBody = {\n content: {},\n }\n }\n\n // Resolve the request body in case it is a reference\n const requestBody = getResolvedRef(baseOperation.requestBody)\n\n // Ensure the content type exists in the requestBody\n if (!requestBody.content[mimeType]) {\n requestBody.content[mimeType] = {\n schema: {\n type: 'object',\n },\n }\n }\n\n // Get the media type object\n const mediaType = requestBody.content[mimeType]\n if (!mediaType) {\n return baseOperation\n }\n\n // Ensure examples object exists\n mediaType.examples ||= {}\n\n // Convert the HAR postData to an example value\n let exampleValue: any\n\n // If params exist (form data), convert to array\n if (params && params.length > 0) {\n exampleValue = []\n for (const param of params) {\n exampleValue.push({\n name: param.name,\n value: param.value,\n 'x-disabled': false,\n })\n }\n } else {\n exampleValue = text\n }\n\n // Add the example to the media type\n mediaType.examples[exampleKey] = {\n value: exampleValue,\n 'x-disabled': false,\n }\n\n // Update the selected media type\n requestBody['x-scalar-selected-content-type'] ||= {}\n requestBody['x-scalar-selected-content-type'][exampleKey] = mimeType\n }\n\n return baseOperation\n}\n\nconst setParameterDisabled = (param: ParameterObject, exampleKey: string, disabled: boolean): void => {\n if (isContentTypeParameterObject(param)) {\n return\n }\n\n if (!param.examples?.[exampleKey]) {\n return\n }\n\n getResolvedRef(param.examples[exampleKey])['x-disabled'] = disabled\n}\n\n/**\n * Finds an existing parameter in the parameters array or creates a new one.\n * This ensures we do not create duplicate parameters.\n */\nconst findOrCreateParameter = (\n parameters: ReferenceType<ParameterObject>[],\n name: string,\n inValue: 'query' | 'header' | 'path' | 'cookie',\n): ParameterObject => {\n // Try to find existing parameter using getResolvedRef to handle references\n for (const param of parameters) {\n const resolved = getResolvedRef(param)\n if (isContentTypeParameterObject(resolved)) {\n continue\n }\n\n // Check if parameter location matches\n if (resolved.in !== inValue) {\n continue\n }\n\n // For headers, use case-insensitive comparison; otherwise use exact match\n const namesMatch =\n inValue === 'header' ? resolved.name.toLowerCase() === name.toLowerCase() : resolved.name === name\n\n if (namesMatch) {\n return resolved\n }\n }\n\n // Create new parameter with schema\n const newParam: ParameterObject = {\n name,\n in: inValue,\n schema: {\n type: 'string',\n },\n }\n\n parameters.push(newParam)\n return newParam\n}\n"],
5
- "mappings": "AACA,SAAS,sBAAsB;AAI/B,SAAS,oCAAoC;AAa7C,MAAM,uBAAuB,CAC3B,YACA,eACA,eACG;AACH,aAAW,QAAQ,CAAC,UAAU;AAC5B,UAAM,gBAAgB,eAAe,KAAK;AAC1C,QAAI,6BAA6B,aAAa,GAAG;AAC/C;AAAA,IACF;AAEA,yBAAqB,eAAe,KAAK,GAAG,YAAY,IAAI;AAE5D,QAAI,cAAc,OAAO,QAAQ;AAC/B,oBAAc,aAAa,CAAC;AAC5B,oBAAc,SAAS,UAAU,IAAI;AAAA,QACnC,OAAO,cAAc,cAAc,IAAI,KAAK;AAAA,QAC5C,cAAc;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAwBO,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA,gBAAgB,CAAC;AAAA,EACjB,gBAAgB,CAAC;AACnB,MAA4C;AAE1C,MAAI,CAAC,cAAc,YAAY;AAC7B,kBAAc,aAAa,CAAC;AAAA,EAC9B;AAGA,uBAAqB,cAAc,YAAY,eAAe,UAAU;AAGxE,MAAI,WAAW,eAAe,WAAW,YAAY,SAAS,GAAG;AAC/D,eAAW,cAAc,WAAW,aAAa;AAC/C,YAAM,QAAQ,sBAAsB,cAAc,YAAY,WAAW,MAAM,OAAO;AAEtF,UAAI,CAAC,SAAS,6BAA6B,KAAK,GAAG;AACjD;AAAA,MACF;AAEA,YAAM,aAAa,CAAC;AACpB,YAAM,SAAS,UAAU,IAAI;AAAA,QAC3B,OAAO,WAAW;AAAA,QAClB,cAAc;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAGA,MAAI,WAAW,WAAW,WAAW,QAA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AAM;AAAA,UACZ,OAAO,MAAM;AAAA,UACb,cAAc;AAAA,QAChB,CAAC;AAAA,MACH;AAAA,IACF,OAAO;AACL,qBAAe;AAAA,IACjB;AAGA,cAAU,SAAS,UAAU,IAAI;AAAA,MAC/B,OAAO;AAAA,MACP,cAAc;AAAA,IAChB;AAGA,gBAAY,gCAAgC,MAAM,CAAC;AACnD,gBAAY,gCAAgC,EAAE,UAAU,IAAI;AAAA,EAC9D;AAEA,SAAO;AACT;AAEA,MAAM,uBAAuB,CAAC,OAAwB,YAAoB,aAA4B;AACpG,MAAI,6BAA6B,KAAK,GAAG;AACvC;AAAA,EACF;AAEA,MAAI,CAAC,MAAM,WAAW,UAAU,GAAG;AACjC;AAAA,EACF;AAEA,iBAAe,MAAM,SAAS,UAAU,CAAC,EAAE,YAAY,IAAI;AAC7D;AAMA,MAAM,wBAAwB,CAC5B,YACA,MACA,YACoB;AAEpB,aAAW,SAAS,YAAY;AAC9B,UAAM,WAAW,eAAe,KAAK;AACrC,QAAI,6BAA6B,QAAQ,GAAG;AAC1C;AAAA,IACF;AAGA,QAAI,SAAS,OAAO,SAAS;AAC3B;AAAA,IACF;AAGA,UAAM,aACJ,YAAY,WAAW,SAAS,KAAK,YAAY,MAAM,KAAK,YAAY,IAAI,SAAS,SAAS;AAEhG,QAAI,YAAY;AACd,aAAO;AAAA,IACT;AAAA,EACF;AAGA,QAAM,WAA4B;AAAA,IAChC;AAAA,IACA,IAAI;AAAA,IACJ,QAAQ;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AAEA,aAAW,KAAK,QAAQ;AACxB,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/mutators/operation/helpers/sync-path-parameters.ts"],
4
- "sourcesContent": ["import { findVariables } from '@scalar/helpers/regex/find-variables'\n\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\nimport { getParameterPositions } from '@/mutators/operation/helpers/get-parameter-position'\nimport type { ParameterObject } from '@/schemas/v3.1/strict/parameter'\nimport type { ReferenceType } from '@/schemas/v3.1/strict/reference'\n\n// We use a minimal parameter object becuase we use this function during bundling and we don't want to prevalidate the parameters\nexport type MinimalParameterObject = Pick<ParameterObject, 'name' | 'in'>\n\n/**\n * Synchronizes path parameters when a path string changes.\n *\n * Behavior:\n * - Preserves as much of the existing parameter configuration as possible when the set of path variables\n * changes due to a path update.\n * - If a parameter with the same name exists in the new path, its configuration is preserved.\n * - If a parameter appears at the same position as an old parameter (name changed), the old parameter's\n * configuration is kept and its name is updated in place via the resolved object.\n * - Any newly required parameters (variables present in the new path but not in the old path) are added\n * as new minimal parameter objects.\n * - Parameters that are no longer present in the new path are dropped.\n * - Non-path parameters (query, header, etc.) from `existingParameters` are included unchanged in the result.\n *\n * \u26A0\uFE0F This function mutates parameter objects in the `existingParameters` array in place when a path\n * parameter is renamed (i.e., reused objects may have their `name` updated via `resolve`).\n *\n * Returns the full new parameters array. Use the return value directly as the new operation.parameters.\n *\n * @param newPath - The path string after the change (e.g. '/users/{id}/posts/{postId}').\n * @param oldPath - The path string before the change (e.g. '/users/{userId}').\n * @param existingParameters - Current operation parameters (may be refs); path params are synced, others passed through.\n * @param resolve - Callback to resolve a reference to a minimal parameter object (used for reading and mutating).\n *\n * @example\n * ```ts\n * // Given:\n * // - oldPath: '/users/{userId}'\n * // - newPath: '/users/{id}/posts/{postId}'\n * // - existingParameters: [ { name: 'userId', in: 'path' } ]\n *\n * const newParams = syncParametersForPathChange(\n * '/users/{id}/posts/{postId}',\n * '/users/{userId}',\n * existingParameters,\n * (node) => resolveRef(node) // or unwrap $ref to get { name, in }\n * )\n *\n * // existingParameters[0] was mutated in place (name -> 'id' via resolve).\n * // newParams is the full array: [ renamed path param 'id', new path param 'postId' ]\n *\n * operation.parameters = newParams\n * ```\n */\nexport const syncParametersForPathChange = <T extends MinimalParameterObject>(\n newPath: string,\n oldPath: string,\n existingParameters: ReferenceType<T>[],\n resolve: (node: ReferenceType<T>) => MinimalParameterObject,\n): ReferenceType<T>[] => {\n // Extract path parameter names from both paths\n const oldPathParams = findVariables(oldPath, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n const newPathParams = findVariables(newPath, { includePath: true, includeEnv: false }).filter(\n (v): v is string => v !== undefined,\n )\n\n const oldPositions = getParameterPositions(oldPath, oldPathParams)\n const newPositions = getParameterPositions(newPath, newPathParams)\n\n // Keep a map of path parameters by name for quick lookup (references unchanged objects)\n const pathParameters: Record<string, ReferenceType<T>> = Object.create(null)\n\n // Populate the map with the existing path parameters\n for (const param of existingParameters) {\n const resolved = resolve(param)\n if (resolved?.in === 'path') {\n pathParameters[resolved.name] = param\n }\n }\n\n // Keep track of old parameters that we have already used\n const usedOldParams = new Set<string>()\n // Keep track of path parameter objects we keep after sync\n const usedPathParameters = new Set<ReferenceType<T>>()\n // These are only truly new parameters created in this run\n const newPathParameters: T[] = []\n\n for (const newParamName of newPathParams) {\n // Case 1: Parameter with same name exists - preserve its config, and mark as used\n if (pathParameters[newParamName]) {\n usedOldParams.add(newParamName)\n usedPathParameters.add(pathParameters[newParamName])\n continue\n }\n\n // Case 2: Check for parameter at same position (likely a rename)\n const newParamPosition = newPositions[newParamName]\n const oldParamAtPosition = oldPathParams.find(\n (oldParam) => oldPositions[oldParam] === newParamPosition && !usedOldParams.has(oldParam),\n )\n\n // If found, mutate old parameter's name and mark as used\n if (oldParamAtPosition && pathParameters[oldParamAtPosition] !== undefined) {\n const oldParam = pathParameters[oldParamAtPosition]\n if (oldParam) {\n // Change its name in-place\n resolve(oldParam).name = newParamName\n usedPathParameters.add(oldParam)\n }\n usedOldParams.add(oldParamAtPosition)\n continue\n }\n\n // Case 3: New parameter - create a new minimal parameter object\n newPathParameters.push({\n in: 'path',\n name: newParamName,\n } as T)\n }\n\n const result: ReferenceType<T>[] = []\n\n // Push the raw parameters to enure we are not pushing proxies\n for (const param of existingParameters) {\n const resolved = resolve(param)\n const rawParam = unpackProxyObject(param, { depth: 1 })\n if (resolved?.in !== 'path') {\n result.push(rawParam)\n continue\n }\n\n // Only adda the parameter if HAS not been used in the old path\n // This we we ensure to drop parameters that are no longer present in the new path\n if (usedPathParameters.has(param)) {\n result.push(rawParam)\n }\n }\n\n // Only return newly created parameter objects\u2014call site should combine with possibly-mutated originals\n return result.concat(newPathParameters)\n}\n"],
5
- "mappings": "AAAA,SAAS,qBAAqB;AAE9B,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AAmD/B,MAAM,8BAA8B,CACzC,SACA,SACA,oBACA,YACuB;AAEvB,QAAM,gBAAgB,cAAc,SAAS,EAAE,aAAa,MAAM,YAAY,MAAM,CAAC,EAAE;AAAA,IACrF,CAAC,MAAmB,MAAM;AAAA,EAC5B;AACA,QAAM,gBAAgB,cAAc,SAAS,EAAE,aAAa,MAAM,YAAY,MAAM,CAAC,EAAE;AAAA,IACrF,CAAC,MAAmB,MAAM;AAAA,EAC5B;AAEA,QAAM,eAAe,sBAAsB,SAAS,aAAa;AACjE,QAAM,eAAe,sBAAsB,SAAS,aAAa;AAGjE,QAAM,iBAAmD,uBAAO,OAAO,IAAI;AAG3E,aAAW,SAAS,oBAAoB;AACtC,UAAM,WAAW,QAAQ,KAAK;AAC9B,QAAI,UAAU,OAAO,QAAQ;AAC3B,qBAAe,SAAS,IAAI,IAAI;AAAA,IAClC;AAAA,EACF;AAGA,QAAM,gBAAgB,oBAAI,IAAY;AAEtC,QAAM,qBAAqB,oBAAI,IAAsB;AAErD,QAAM,oBAAyB,CAAC;AAEhC,aAAW,gBAAgB,eAAe;AAExC,QAAI,eAAe,YAAY,GAAG;AAChC,oBAAc,IAAI,YAAY;AAC9B,yBAAmB,IAAI,eAAe,YAAY,CAAC;AACnD;AAAA,IACF;AAGA,UAAM,mBAAmB,aAAa,YAAY;AAClD,UAAM,qBAAqB,cAAc;AAAA,MACvC,CAAC,aAAa,aAAa,QAAQ,MAAM,oBAAoB,CAAC,cAAc,IAAI,QAAQ;AAAA,IAC1F;AAGA,QAAI,sBAAsB,eAAe,kBAAkB,MAAM,QAAW;AAC1E,YAAM,WAAW,eAAe,kBAAkB;AAClD,UAAI,UAAU;AAEZ,gBAAQ,QAAQ,EAAE,OAAO;AACzB,2BAAmB,IAAI,QAAQ;AAAA,MACjC;AACA,oBAAc,IAAI,kBAAkB;AACpC;AAAA,IACF;AAGA,sBAAkB,KAAK;AAAA,MACrB,IAAI;AAAA,MACJ,MAAM;AAAA,IACR,CAAM;AAAA,EACR;AAEA,QAAM,SAA6B,CAAC;AAGpC,aAAW,SAAS,oBAAoB;AACtC,UAAM,WAAW,QAAQ,KAAK;AAC9B,UAAM,WAAW,kBAAkB,OAAO,EAAE,OAAO,EAAE,CAAC;AACtD,QAAI,UAAU,OAAO,QAAQ;AAC3B,aAAO,KAAK,QAAQ;AACpB;AAAA,IACF;AAIA,QAAI,mBAAmB,IAAI,KAAK,GAAG;AACjC,aAAO,KAAK,QAAQ;AAAA,IACtB;AAAA,EACF;AAGA,SAAO,OAAO,OAAO,iBAAiB;AACxC;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/mutators/operation/history.ts"],
4
- "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { HooksEvents } from '@/events/definitions/hooks'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport type { WorkspaceDocument } from '@/schemas'\nimport { isContentTypeParameterObject } from '@/schemas/v3.1/strict/type-guards'\n\nimport { fetchRequestToHar } from './helpers/fetch-request-to-har'\nimport { fetchResponseToHar } from './helpers/fetch-response-to-har'\nimport { harToOperation } from './helpers/har-to-operation'\n\nexport const addResponseToHistory = async (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { payload, meta }: HooksEvents['hooks:on:request:complete'],\n) => {\n const documentName = document?.['x-scalar-navigation']?.name\n if (!document || !documentName || !payload) {\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n return\n }\n\n const operationParameters = operation.parameters ?? []\n\n // Get all the variables from the operation parameters\n const variables = operationParameters.reduce<Record<string, string>>((acc, param) => {\n const resolvedParam = getResolvedRef(param)\n if (isContentTypeParameterObject(resolvedParam)) {\n return acc\n }\n if (resolvedParam.in === 'path') {\n acc[resolvedParam.name] = getResolvedRef(resolvedParam.examples?.[meta.exampleKey])?.value ?? ''\n }\n return acc\n }, {})\n\n const requestHar = await fetchRequestToHar({ request: payload.request })\n const responseHar = await fetchResponseToHar({ response: payload.response })\n\n store?.history.addHistory(documentName, meta.path, meta.method, {\n response: responseHar,\n request: requestHar,\n meta: {\n example: meta.exampleKey,\n },\n time: payload.duration,\n timestamp: payload.timestamp,\n requestMetadata: {\n variables,\n },\n })\n}\n\nexport const reloadOperationHistory = (\n store: WorkspaceStore | null,\n document: WorkspaceDocument | null,\n { meta, index, callback }: OperationEvents['operation:reload:history'],\n) => {\n if (!document) {\n console.error('Document not found', meta.path, meta.method)\n return\n }\n\n const operation = getResolvedRef(document.paths?.[meta.path]?.[meta.method])\n if (!operation) {\n console.error('Operation not found', meta.path, meta.method)\n return\n }\n\n const historyItem = store?.history.getHistory(document['x-scalar-navigation']?.name ?? '', meta.path, meta.method)?.[\n index\n ]\n if (!historyItem) {\n console.error('History item not found', index)\n return\n }\n\n harToOperation({\n harRequest: historyItem.request,\n exampleKey: 'draft',\n baseOperation: operation,\n pathVariables: historyItem.requestMetadata.variables,\n })\n callback('success')\n}\n"],
5
- "mappings": "AAGA,SAAS,sBAAsB;AAE/B,SAAS,oCAAoC;AAE7C,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAExB,MAAM,uBAAuB,OAClC,OACA,UACA,EAAE,SAAS,KAAK,MACb;AACH,QAAM,eAAe,WAAW,qBAAqB,GAAG;AACxD,MAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS;AAC1C;AAAA,EACF;AAEA,QA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KAAK,MAAM,KAAK,MAAM,IAC/G,KACF;AACA,MAAI,CAAC,aAAa;AAChB,YAAQ,MAAM,0BAA0B,KAAK;AAC7C;AAAA,EACF;AAEA,iBAAe;AAAA,IACb,YAAY,YAAY;AAAA,IACxB,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,eAAe,YAAY,gBAAgB;AAAA,EAC7C,CAAC;AACD,WAAS,SAAS;AACpB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/mutators/operation/index.ts"],
4
- "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport type { HooksEvents } from '@/events/definitions/hooks'\nimport type { OperationEvents } from '@/events/definitions/operation'\nimport {\n updateOperationRequestBodyContentType,\n updateOperationRequestBodyExample,\n updateOperationRequestBodyFormValue,\n} from '@/mutators/operation/body'\nimport { updateOperationExtension } from '@/mutators/operation/extensions'\nimport { addResponseToHistory, reloadOperationHistory } from '@/mutators/operation/history'\nimport {\n createOperation,\n createOperationDraftExample,\n deleteOperation,\n deleteOperationExample,\n renameOperationExample,\n updateOperationMeta,\n updateOperationPathMethod,\n} from '@/mutators/operation/operation'\nimport {\n deleteAllOperationParameters,\n deleteOperationParameter,\n updateOperationExtraParameters,\n upsertOperationParameter,\n} from '@/mutators/operation/parameters'\nimport type { WorkspaceDocument } from '@/schemas'\n\nexport const operationMutatorsFactory = ({\n document,\n store,\n}: {\n document: WorkspaceDocument | null\n store: WorkspaceStore | null\n}) => {\n return {\n createOperation: (payload: OperationEvents['operation:create:operation']) => createOperation(store, payload),\n updateOperationMeta: (payload: OperationEvents['operation:update:meta']) =>\n updateOperationMeta(store, document, payload),\n updateOperationPathMethod: (payload: OperationEvents['operation:update:pathMethod']) =>\n updateOperationPathMethod(document, store, payload),\n deleteOperation: (payload: OperationEvents['operation:delete:operation']) => deleteOperation(store, payload),\n createOperationDraftExample: (payload: OperationEvents['operation:create:draft-example']) =>\n createOperationDraftExample(store, payload),\n deleteOperationExample: (payload: OperationEvents['operation:delete:example']) =>\n deleteOperationExample(store, payload),\n renameOperationExample: (payload: OperationEvents['operation:rename:example']) =>\n renameOperationExample(store, payload),\n updateOperationExtension: (payload: OperationEvents['operation:update:extension']) =>\n updateOperationExtension(document, payload),\n updateOperationExtraParameters: (payload: OperationEvents['operation:update:extra-parameters']) =>\n updateOperationExtraParameters(document, payload),\n upsertOperationParameter: (payload: OperationEvents['operation:upsert:parameter']) =>\n upsertOperationParameter(document, payload),\n deleteOperationParameter: (payload: OperationEvents['operation:delete:parameter']) =>\n deleteOperationParameter(document, payload),\n deleteAllOperationParameters: (payload: OperationEvents['operation:delete-all:parameters']) =>\n deleteAllOperationParameters(document, payload),\n updateOperationRequestBodyContentType: (payload: OperationEvents['operation:update:requestBody:contentType']) =>\n updateOperationRequestBodyContentType(document, payload),\n updateOperationRequestBodyExample: (payload: OperationEvents['operation:update:requestBody:value']) =>\n updateOperationRequestBodyExample(document, payload),\n updateOperationRequestBodyFormValue: (payload: OperationEvents['operation:update:requestBody:formValue']) =>\n updateOperationRequestBodyFormValue(document, payload),\n addResponseToHistory: (payload: HooksEvents['hooks:on:request:complete']) =>\n addResponseToHistory(store, document, payload),\n reloadOperationHistory: (payload: OperationEvents['operation:reload:history']) =>\n reloadOperationHistory(store, document, payload),\n }\n}\n"],
5
- "mappings": "AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,sBAAsB,8BAA8B;AAC7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AACF,MAGM;AACJ,SAAO;AAAA,IACL,iBAAiB,CAAC,YAA2D,gBAAgB,OAAO,OAAO;AAAA,IAC3G,qBAAqB,CAAC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