@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,179 +1,313 @@
1
- import { HTTP_METHODS } from "@scalar/helpers/http/http-methods";
2
- import { isObject } from "@scalar/helpers/object/is-object";
3
- import { isLocalRef } from "../../helpers/general.js";
4
- import {
5
- syncParametersForPathChange
6
- } from "../../mutators/operation/helpers/sync-path-parameters.js";
7
- import { getResolvedRef } from "../../plugins/bundler/helpers.js";
8
- const loadingStatus = () => {
9
- return {
10
- type: "lifecycle",
11
- onResolveStart: (node) => {
12
- node["$status"] = "loading";
13
- },
14
- onResolveError: (node) => {
15
- node["$status"] = "error";
16
- },
17
- onResolveSuccess: (node) => {
18
- delete node["$status"];
19
- }
20
- };
1
+ /**
2
+ * This file contains a collection of plugins used for the bundler.
3
+ * Plugins defined here can extend or modify the behavior of the bundling process,
4
+ * such as adding lifecycle hooks or custom processing logic.
5
+ */
6
+ import { HTTP_METHODS } from '@scalar/helpers/http/http-methods';
7
+ import { isObject } from '@scalar/helpers/object/is-object';
8
+ import { isLocalRef } from '../../helpers/general.js';
9
+ import { syncParametersForPathChange, } from '../../mutators/operation/helpers/sync-path-parameters.js';
10
+ import { getResolvedRef } from '../../plugins/bundler/helpers.js';
11
+ /**
12
+ * A lifecycle plugin that adds a `$status` property to nodes during resolution.
13
+ * - Sets `$status` to 'loading' when resolution starts.
14
+ * - Sets `$status` to 'error' if resolution fails.
15
+ * - Removes `$status` when resolution succeeds.
16
+ */
17
+ export const loadingStatus = () => {
18
+ return {
19
+ type: 'lifecycle',
20
+ onResolveStart: (node) => {
21
+ node['$status'] = 'loading';
22
+ },
23
+ onResolveError: (node) => {
24
+ node['$status'] = 'error';
25
+ },
26
+ onResolveSuccess: (node) => {
27
+ delete node['$status'];
28
+ },
29
+ };
21
30
  };
22
- const externalValueResolver = () => {
23
- return {
24
- type: "lifecycle",
25
- onAfterNodeProcess: async (node, context) => {
26
- const externalValue = node["externalValue"];
27
- const cache = context.resolutionCache;
28
- if (typeof externalValue !== "string") {
29
- return;
30
- }
31
- const loader = context.loaders.find((it) => it.validate(externalValue));
32
- if (!loader) {
33
- return;
34
- }
35
- if (!cache.has(externalValue)) {
36
- cache.set(externalValue, loader.exec(externalValue));
37
- }
38
- const result = await cache.get(externalValue);
39
- if (result?.ok) {
40
- node["value"] = result.data;
41
- }
42
- }
43
- };
31
+ /**
32
+ * Lifecycle plugin to resolve and embed external content referenced by an 'externalValue' property in a node.
33
+ *
34
+ * When a node contains an 'externalValue' property (as a string), this plugin will:
35
+ * - Fetch the external resource (such as a URL or file) using the fetchUrls plugin.
36
+ * - If the fetch is successful, assign the fetched data to the node's 'value' property.
37
+ *
38
+ * This is useful for inlining external content (like examples or schemas) into the OpenAPI document during bundling.
39
+ *
40
+ * @param node - The node being processed, which may contain an 'externalValue' property.
41
+ */
42
+ export const externalValueResolver = () => {
43
+ return {
44
+ type: 'lifecycle',
45
+ onAfterNodeProcess: async (node, context) => {
46
+ const externalValue = node['externalValue'];
47
+ const cache = context.resolutionCache;
48
+ // Only process if 'externalValue' is a string
49
+ if (typeof externalValue !== 'string') {
50
+ return;
51
+ }
52
+ const loader = context.loaders.find((it) => it.validate(externalValue));
53
+ // We can not process the external value
54
+ if (!loader) {
55
+ return;
56
+ }
57
+ if (!cache.has(externalValue)) {
58
+ cache.set(externalValue, loader.exec(externalValue));
59
+ }
60
+ const result = await cache.get(externalValue);
61
+ // If fetch is successful, assign the data to the node's 'value' property
62
+ if (result?.ok) {
63
+ node['value'] = result.data;
64
+ }
65
+ },
66
+ };
44
67
  };
45
- const refsEverywhere = () => {
46
- return {
47
- type: "lifecycle",
48
- onBeforeNodeProcess: async (node, context) => {
49
- const { path, resolutionCache, parentNode } = context;
50
- const ref = node["$ref"];
51
- if (typeof ref !== "string") {
52
- return;
53
- }
54
- if (!parentNode || !path.length) {
55
- return;
56
- }
57
- const loader = context.loaders.find((it) => it.validate(ref));
58
- if (!loader) {
59
- return;
60
- }
61
- if (path[0] === "info") {
62
- if (!resolutionCache.has(ref)) {
63
- resolutionCache.set(ref, loader.exec(ref));
64
- }
65
- const result = await resolutionCache.get(ref);
66
- if (result?.ok) {
67
- parentNode[path.at(-1)] = result.data;
68
- }
69
- }
70
- }
71
- };
68
+ /**
69
+ * Lifecycle plugin to resolve $ref on any object, including non-standard locations like the info object.
70
+ *
71
+ * This plugin will:
72
+ * - Detect if a node contains a $ref property (as a string).
73
+ * - If the node is under the 'info' path, attempt to resolve the reference using fetchUrls.
74
+ * - Replace the node's properties with the resolved data if successful.
75
+ *
76
+ * Note: This currently only supports refs on the 'info' object and does not handle primitive types.
77
+ */
78
+ export const refsEverywhere = () => {
79
+ return {
80
+ type: 'lifecycle',
81
+ onBeforeNodeProcess: async (node, context) => {
82
+ const { path, resolutionCache, parentNode } = context;
83
+ const ref = node['$ref'];
84
+ // Only process nodes that have a $ref property as a string
85
+ if (typeof ref !== 'string') {
86
+ return;
87
+ }
88
+ // Can not resolve top level refs
89
+ if (!parentNode || !path.length) {
90
+ return;
91
+ }
92
+ const loader = context.loaders.find((it) => it.validate(ref));
93
+ // Can not load the external ref
94
+ if (!loader) {
95
+ return;
96
+ }
97
+ // Support resolving $ref on the info object
98
+ if (path[0] === 'info') {
99
+ // Use the cache to avoid duplicate fetches
100
+ if (!resolutionCache.has(ref)) {
101
+ resolutionCache.set(ref, loader.exec(ref));
102
+ }
103
+ const result = await resolutionCache.get(ref);
104
+ if (result?.ok) {
105
+ // Replace the ref with the resolved data
106
+ parentNode[path.at(-1)] = result.data;
107
+ }
108
+ }
109
+ },
110
+ };
72
111
  };
73
- const restoreOriginalRefs = () => {
74
- return {
75
- type: "lifecycle",
76
- onBeforeNodeProcess: (node, context) => {
77
- const ref = node["$ref"];
78
- const root = context.rootNode;
79
- const extUrls = root["x-ext-urls"];
80
- if (typeof ref !== "string" || typeof extUrls !== "object" || extUrls === null || !isLocalRef(ref)) {
81
- return;
82
- }
83
- const segments = ref.split("/");
84
- const key = segments.at(-1) ?? "";
85
- node["$ref"] = extUrls[key] ?? ref;
86
- }
87
- };
112
+ /**
113
+ * Lifecycle plugin to restore original $ref values after processing.
114
+ *
115
+ * This plugin is intended to be used as a "lifecycle" plugin in the bundling process.
116
+ * It operates in the `onAfterNodeProcess` hook, and its main purpose is to restore
117
+ * the original $ref values for external references that may have been replaced or
118
+ * rewritten during the bundling process.
119
+ *
120
+ * How it works:
121
+ * - For each node processed, if the node contains a $ref property (as a string),
122
+ * and the root document contains an "x-ext-urls" mapping object,
123
+ * the plugin will attempt to restore the original $ref value.
124
+ * - The "x-ext-urls" object is expected to be a mapping from the rewritten $ref
125
+ * (e.g., a hashed or compressed reference) back to the original external URL or path.
126
+ * - If a mapping exists for the current $ref, the plugin replaces the $ref value
127
+ * with the original value from the mapping. If no mapping exists (e.g., for local refs),
128
+ * the $ref value is left unchanged.
129
+ *
130
+ * This is useful for scenarios where you want to present or export the bundled document
131
+ * with the original external $ref values, rather than the internal or rewritten ones.
132
+ *
133
+ * @returns {LifecyclePlugin} The plugin object for use in the bundler.
134
+ */
135
+ export const restoreOriginalRefs = () => {
136
+ return {
137
+ type: 'lifecycle',
138
+ onBeforeNodeProcess: (node, context) => {
139
+ const ref = node['$ref'];
140
+ const root = context.rootNode;
141
+ const extUrls = root['x-ext-urls'];
142
+ // Only process if $ref is a string and x-ext-urls is a valid object
143
+ if (typeof ref !== 'string' || typeof extUrls !== 'object' || extUrls === null || !isLocalRef(ref)) {
144
+ return;
145
+ }
146
+ // Working with local refs
147
+ const segments = ref.split('/');
148
+ const key = segments.at(-1) ?? '';
149
+ // Replace the $ref with the original version from the mapping,
150
+ // or keep the current version if there is no mapping (e.g., for local refs)
151
+ node['$ref'] = extUrls[key] ?? ref;
152
+ },
153
+ };
88
154
  };
89
- const normalizeAuthSchemes = () => {
90
- return {
91
- type: "lifecycle",
92
- onAfterNodeProcess: (node, context) => {
93
- const { path } = context;
94
- if (path.length === 3 && path[0] === "components" && path[1] === "securitySchemes") {
95
- const targetNode = getResolvedRef(node, context);
96
- if (typeof targetNode === "object" && targetNode !== null && "scheme" in targetNode && typeof targetNode["scheme"] === "string" && targetNode["scheme"].toLowerCase() !== targetNode["scheme"]) {
97
- targetNode["scheme"] = targetNode["scheme"].toLowerCase();
98
- }
99
- }
100
- }
101
- };
155
+ /**
156
+ * Lifecycle plugin to normalize the `scheme` property in securitySchemes to lowercase.
157
+ *
158
+ * Our typebox schemas require the `scheme` property to be a lowercase string.
159
+ * This plugin ensures that any `scheme` field under `components.securitySchemes` is normalized to lowercase, fixing
160
+ * potential user input errors such as "Bearer" or "BASIC".
161
+ *
162
+ * Example:
163
+ * ```yaml
164
+ * Before normalization:
165
+ * components:
166
+ * securitySchemes:
167
+ * bearerAuth:
168
+ * type: http
169
+ * scheme: Bearer
170
+ * ```
171
+ * After normalization:
172
+ * ```yaml
173
+ * components:
174
+ * securitySchemes:
175
+ * bearerAuth:
176
+ * type: http
177
+ * scheme: bearer
178
+ * ```
179
+ */
180
+ export const normalizeAuthSchemes = () => {
181
+ return {
182
+ type: 'lifecycle',
183
+ onAfterNodeProcess: (node, context) => {
184
+ const { path } = context;
185
+ // Check if we're at components.securitySchemes.{schemeName}
186
+ if (path.length === 3 && path[0] === 'components' && path[1] === 'securitySchemes') {
187
+ const targetNode = getResolvedRef(node, context);
188
+ // If the scheme exists and is a string, normalize to lowercase if not already
189
+ if (typeof targetNode === 'object' &&
190
+ targetNode !== null &&
191
+ 'scheme' in targetNode &&
192
+ typeof targetNode['scheme'] === 'string' &&
193
+ targetNode['scheme'].toLowerCase() !== targetNode['scheme']) {
194
+ targetNode['scheme'] = targetNode['scheme'].toLowerCase();
195
+ }
196
+ }
197
+ },
198
+ };
102
199
  };
103
- const normalizeRefs = () => {
104
- return {
105
- type: "lifecycle",
106
- onBeforeNodeProcess: (node, context) => {
107
- const { path } = context;
108
- if (typeof node["$ref"] === "string" && !(path[0] === "components" && path[1] === "schemas")) {
109
- const keepProperties = /* @__PURE__ */ new Set(["$ref", "summary", "description", "$status"]);
110
- Object.keys(node).forEach((key) => {
111
- if (!keepProperties.has(key)) {
112
- delete node[key];
113
- }
114
- });
115
- }
116
- }
117
- };
200
+ /**
201
+ * Lifecycle plugin to normalize $ref nodes:
202
+ * Ensures that for any non-schema object containing a $ref, only $ref,
203
+ * summary, description, and $status properties are preserved.
204
+ * This keeps $ref references clean and predictable for downstream consumers.
205
+ */
206
+ export const normalizeRefs = () => {
207
+ return {
208
+ type: 'lifecycle',
209
+ onBeforeNodeProcess: (node, context) => {
210
+ const { path } = context;
211
+ // If the node is a $ref and we are not on the schema object, we need to normalize the $ref
212
+ if (typeof node['$ref'] === 'string' && !(path[0] === 'components' && path[1] === 'schemas')) {
213
+ // Remove any other properties from the node and only keep the '$ref', 'summary', 'description' and '$status'
214
+ const keepProperties = new Set(['$ref', 'summary', 'description', '$status']);
215
+ Object.keys(node).forEach((key) => {
216
+ if (!keepProperties.has(key)) {
217
+ delete node[key];
218
+ }
219
+ });
220
+ }
221
+ },
222
+ };
118
223
  };
119
- const syncPathParameters = () => {
120
- return {
121
- type: "lifecycle",
122
- onBeforeNodeProcess: (node, context) => {
123
- const { path } = context;
124
- if (path.length !== 2 || path[0] !== "paths" || typeof path[1] !== "string") {
125
- return;
126
- }
127
- const pathString = path[1];
128
- for (const method of HTTP_METHODS) {
129
- const operation = getResolvedRef(node[method], context);
130
- if (!isObject(operation)) {
131
- continue;
132
- }
133
- const isParameterNode = (param) => {
134
- const resolved = getResolvedRef(param, context);
135
- return isObject(resolved) && "name" in resolved && typeof resolved.name === "string" && "in" in resolved && typeof resolved.in === "string";
136
- };
137
- const isPathParameterNode = (param) => {
138
- const resolved = getResolvedRef(param, context);
139
- return isParameterNode(resolved) && resolved.in === "path";
140
- };
141
- const existingParameters = ("parameters" in operation && Array.isArray(operation.parameters) ? operation.parameters : []).filter(isParameterNode);
142
- const existingPathParameters = new Set(
143
- existingParameters.map((param) => getResolvedRef(param, context)).filter(isPathParameterNode).map((param) => param.name)
144
- );
145
- const pathItemParameters = "parameters" in node && Array.isArray(node.parameters) ? node.parameters : [];
146
- const pathItemPathParameters = pathItemParameters.filter((param) => {
147
- const resolved = getResolvedRef(param, context);
148
- if (!isPathParameterNode(resolved)) {
149
- return false;
150
- }
151
- const result2 = !existingPathParameters.has(resolved.name);
152
- if (result2) {
153
- existingPathParameters.add(resolved.name);
154
- }
155
- return result2;
156
- });
157
- const result = syncParametersForPathChange(
158
- pathString,
159
- pathString,
160
- [...existingParameters, ...pathItemPathParameters],
161
- (node2) => getResolvedRef(node2, context)
162
- );
163
- if (result.length > 0) {
164
- operation.parameters = result;
165
- }
166
- }
167
- }
168
- };
224
+ /**
225
+ * Lifecycle plugin to sync path parameters for all operations under a path item.
226
+ *
227
+ * When processing a path item (e.g., '/users/{id}'), this plugin will:
228
+ * - Extract path variables from the path string
229
+ * - For each HTTP method operation (get, post, put, delete, etc.)
230
+ * - Sync the operation's parameters to match the path variables
231
+ * - Preserve existing parameter configurations when possible
232
+ *
233
+ * This ensures that path parameters are always in sync with the path string,
234
+ * even after bundling or other transformations.
235
+ */
236
+ export const syncPathParameters = () => {
237
+ return {
238
+ type: 'lifecycle',
239
+ onBeforeNodeProcess: (node, context) => {
240
+ const { path } = context;
241
+ // Only process path items (e.g., paths -> /users/{id} -> operations)
242
+ if (path.length !== 2 || path[0] !== 'paths' || typeof path[1] !== 'string') {
243
+ return;
244
+ }
245
+ const pathString = path[1];
246
+ // Sync parameters for each operation method
247
+ for (const method of HTTP_METHODS) {
248
+ const operation = getResolvedRef(node[method], context);
249
+ if (!isObject(operation)) {
250
+ continue;
251
+ }
252
+ const isParameterNode = (param) => {
253
+ const resolved = getResolvedRef(param, context);
254
+ return (isObject(resolved) &&
255
+ 'name' in resolved &&
256
+ typeof resolved.name === 'string' &&
257
+ 'in' in resolved &&
258
+ typeof resolved.in === 'string');
259
+ };
260
+ const isPathParameterNode = (param) => {
261
+ const resolved = getResolvedRef(param, context);
262
+ return isParameterNode(resolved) && resolved.in === 'path';
263
+ };
264
+ const existingParameters = ('parameters' in operation && Array.isArray(operation.parameters) ? operation.parameters : []).filter(isParameterNode);
265
+ const existingPathParameters = new Set(existingParameters
266
+ .map((param) => getResolvedRef(param, context))
267
+ .filter(isPathParameterNode)
268
+ .map((param) => param.name));
269
+ // Include path-item level path parameters as fallbacks for any that the operation does not declare.
270
+ // Without this, syncParametersForPathChange would create bare `{ name, in: 'path' }` params,
271
+ // losing description, schema, required, etc. from the path-item definition.
272
+ const pathItemParameters = 'parameters' in node && Array.isArray(node.parameters) ? node.parameters : [];
273
+ const pathItemPathParameters = pathItemParameters.filter((param) => {
274
+ const resolved = getResolvedRef(param, context);
275
+ if (!isPathParameterNode(resolved)) {
276
+ return false;
277
+ }
278
+ const result = !existingPathParameters.has(resolved.name);
279
+ if (result) {
280
+ existingPathParameters.add(resolved.name);
281
+ }
282
+ return result;
283
+ });
284
+ const result = syncParametersForPathChange(pathString, pathString, [...existingParameters, ...pathItemPathParameters], (node) => getResolvedRef(node, context));
285
+ if (result.length > 0) {
286
+ operation.parameters = result;
287
+ }
288
+ }
289
+ },
290
+ };
169
291
  };
170
- export {
171
- externalValueResolver,
172
- loadingStatus,
173
- normalizeAuthSchemes,
174
- normalizeRefs,
175
- refsEverywhere,
176
- restoreOriginalRefs,
177
- syncPathParameters
292
+ // A list of nested internal keys that should be removed from nodes at any level.
293
+ const NESTED_INTERNAL_KEYS = ['__scalar_', '$status'];
294
+ /**
295
+ * Lifecycle plugin to remove extra Scalar internal keys from nodes.
296
+ *
297
+ * This plugin is used to remove extra Scalar internal keys from nodes during the bundling process.
298
+ * These keys are used for internal purposes and are not needed in the final bundled document.
299
+ */
300
+ export const removeExtraScalarKeys = () => {
301
+ return {
302
+ type: 'lifecycle',
303
+ onBeforeNodeProcess: (node) => {
304
+ if (isObject(node)) {
305
+ for (const key of NESTED_INTERNAL_KEYS) {
306
+ if (key in node) {
307
+ delete node[key];
308
+ }
309
+ }
310
+ }
311
+ },
312
+ };
178
313
  };
179
- //# sourceMappingURL=index.js.map
@@ -1,5 +1 @@
1
- import { persistencePlugin } from "./persistence.js";
2
- export {
3
- persistencePlugin
4
- };
5
- //# sourceMappingURL=index.js.map
1
+ export { persistencePlugin } from './persistence.js';