@scalar/workspace-store 0.12.0 → 0.14.1

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 (431) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/client.d.ts +261 -33
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +176 -282
  5. package/dist/client.js.map +2 -2
  6. package/dist/helpers/apply-selective-updates.d.ts +1 -1
  7. package/dist/helpers/apply-selective-updates.d.ts.map +1 -1
  8. package/dist/helpers/apply-selective-updates.js +1 -1
  9. package/dist/helpers/apply-selective-updates.js.map +2 -2
  10. package/dist/helpers/deep-clone.d.ts +21 -0
  11. package/dist/helpers/deep-clone.d.ts.map +1 -0
  12. package/dist/helpers/deep-clone.js +18 -0
  13. package/dist/helpers/deep-clone.js.map +7 -0
  14. package/dist/helpers/get-resolved-ref.d.ts +19 -0
  15. package/dist/helpers/get-resolved-ref.d.ts.map +1 -0
  16. package/dist/helpers/get-resolved-ref.js +13 -0
  17. package/dist/helpers/get-resolved-ref.js.map +7 -0
  18. package/dist/helpers/merge-object.d.ts +9 -1
  19. package/dist/helpers/merge-object.d.ts.map +1 -1
  20. package/dist/helpers/merge-object.js +10 -2
  21. package/dist/helpers/merge-object.js.map +2 -2
  22. package/dist/helpers/overrides-proxy.d.ts +43 -1
  23. package/dist/helpers/overrides-proxy.d.ts.map +1 -1
  24. package/dist/helpers/overrides-proxy.js +2 -2
  25. package/dist/helpers/overrides-proxy.js.map +2 -2
  26. package/dist/mutators/helpers.d.ts +2 -34830
  27. package/dist/mutators/helpers.d.ts.map +1 -1
  28. package/dist/mutators/helpers.js.map +2 -2
  29. package/dist/mutators/request-example.d.ts.map +1 -1
  30. package/dist/mutators/request-example.js +4 -7
  31. package/dist/mutators/request-example.js.map +2 -2
  32. package/dist/navigation/helpers/traverse-document.js +2 -2
  33. package/dist/navigation/helpers/traverse-document.js.map +2 -2
  34. package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
  35. package/dist/navigation/helpers/traverse-paths.js +8 -5
  36. package/dist/navigation/helpers/traverse-paths.js.map +2 -2
  37. package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
  38. package/dist/navigation/helpers/traverse-schemas.js +8 -5
  39. package/dist/navigation/helpers/traverse-schemas.js.map +2 -2
  40. package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
  41. package/dist/navigation/helpers/traverse-webhooks.js +9 -5
  42. package/dist/navigation/helpers/traverse-webhooks.js.map +2 -2
  43. package/dist/navigation/types.d.ts +3 -3
  44. package/dist/navigation/types.d.ts.map +1 -1
  45. package/dist/plugins.d.ts +93 -0
  46. package/dist/plugins.d.ts.map +1 -0
  47. package/dist/plugins.js +107 -0
  48. package/dist/plugins.js.map +7 -0
  49. package/dist/schemas/extensions/document/x-internal.d.ts +4 -0
  50. package/dist/schemas/extensions/document/x-internal.d.ts.map +1 -0
  51. package/dist/schemas/extensions/document/x-internal.js +8 -0
  52. package/dist/schemas/extensions/document/x-internal.js.map +7 -0
  53. package/dist/schemas/extensions/document/x-scalar-icon.d.ts +4 -0
  54. package/dist/schemas/extensions/document/x-scalar-icon.d.ts.map +1 -0
  55. package/dist/schemas/extensions/document/x-scalar-icon.js +8 -0
  56. package/dist/schemas/extensions/document/x-scalar-icon.js.map +7 -0
  57. package/dist/schemas/extensions/document/x-scalar-ignore.d.ts +4 -0
  58. package/dist/schemas/extensions/document/x-scalar-ignore.d.ts.map +1 -0
  59. package/dist/schemas/extensions/document/x-scalar-ignore.js +8 -0
  60. package/dist/schemas/extensions/document/x-scalar-ignore.js.map +7 -0
  61. package/dist/schemas/extensions/document/x-scalar-sdk-installation.d.ts +8 -0
  62. package/dist/schemas/extensions/document/x-scalar-sdk-installation.d.ts.map +1 -0
  63. package/dist/schemas/extensions/document/x-scalar-sdk-installation.js +16 -0
  64. package/dist/schemas/extensions/document/x-scalar-sdk-installation.js.map +7 -0
  65. package/dist/schemas/extensions/operation/x-badge.d.ts +58 -0
  66. package/dist/schemas/extensions/operation/x-badge.d.ts.map +1 -0
  67. package/dist/schemas/extensions/operation/x-badge.js +41 -0
  68. package/dist/schemas/extensions/operation/x-badge.js.map +7 -0
  69. package/dist/schemas/extensions/operation/x-code-samples.d.ts +23 -0
  70. package/dist/schemas/extensions/operation/x-code-samples.d.ts.map +1 -0
  71. package/dist/schemas/extensions/operation/x-code-samples.js +16 -0
  72. package/dist/schemas/extensions/operation/x-code-samples.js.map +7 -0
  73. package/dist/schemas/extensions/operation/x-post-response.d.ts +19 -0
  74. package/dist/schemas/extensions/operation/x-post-response.d.ts.map +1 -0
  75. package/dist/schemas/extensions/operation/x-post-response.js +8 -0
  76. package/dist/schemas/extensions/operation/x-post-response.js.map +7 -0
  77. package/dist/schemas/extensions/operation/x-scalar-stability.d.ts +18 -0
  78. package/dist/schemas/extensions/operation/x-scalar-stability.d.ts.map +1 -0
  79. package/dist/schemas/extensions/operation/x-scalar-stability.js +16 -0
  80. package/dist/schemas/extensions/operation/x-scalar-stability.js.map +7 -0
  81. package/dist/schemas/extensions/schema/x-additional-properties-name.d.ts +11 -0
  82. package/dist/schemas/extensions/schema/x-additional-properties-name.d.ts.map +1 -0
  83. package/dist/schemas/extensions/schema/x-additional-properties-name.js +8 -0
  84. package/dist/schemas/extensions/schema/x-additional-properties-name.js.map +7 -0
  85. package/dist/schemas/extensions/schema/x-enum-descriptions.d.ts +17 -0
  86. package/dist/schemas/extensions/schema/x-enum-descriptions.d.ts.map +1 -0
  87. package/dist/schemas/extensions/schema/x-enum-descriptions.js +8 -0
  88. package/dist/schemas/extensions/schema/x-enum-descriptions.js.map +7 -0
  89. package/dist/schemas/extensions/schema/x-variable.d.ts +4 -0
  90. package/dist/schemas/extensions/schema/x-variable.d.ts.map +1 -0
  91. package/dist/schemas/extensions/schema/x-variable.js +8 -0
  92. package/dist/schemas/extensions/schema/x-variable.js.map +7 -0
  93. package/dist/schemas/extensions/security/x-scalar-credentials-location.d.ts +17 -0
  94. package/dist/schemas/extensions/security/x-scalar-credentials-location.d.ts.map +1 -0
  95. package/dist/schemas/extensions/security/x-scalar-credentials-location.js +8 -0
  96. package/dist/schemas/extensions/security/x-scalar-credentials-location.js.map +7 -0
  97. package/dist/schemas/extensions/security/x-scalar-redirect-uri.d.ts +4 -0
  98. package/dist/schemas/extensions/security/x-scalar-redirect-uri.d.ts.map +1 -0
  99. package/dist/schemas/extensions/security/x-scalar-redirect-uri.js +8 -0
  100. package/dist/schemas/extensions/security/x-scalar-redirect-uri.js.map +7 -0
  101. package/dist/schemas/extensions/security/x-scalar-security-body.d.ts +15 -0
  102. package/dist/schemas/extensions/security/x-scalar-security-body.d.ts.map +1 -0
  103. package/dist/schemas/extensions/security/x-scalar-security-body.js +8 -0
  104. package/dist/schemas/extensions/security/x-scalar-security-body.js.map +7 -0
  105. package/dist/schemas/extensions/security/x-scalar-security-query.d.ts +15 -0
  106. package/dist/schemas/extensions/security/x-scalar-security-query.d.ts.map +1 -0
  107. package/dist/schemas/extensions/security/x-scalar-security-query.js +8 -0
  108. package/dist/schemas/extensions/security/x-scalar-security-query.js.map +7 -0
  109. package/dist/schemas/extensions/security/x-scalar-security-secrets.d.ts +18 -0
  110. package/dist/schemas/extensions/security/x-scalar-security-secrets.d.ts.map +1 -0
  111. package/dist/schemas/extensions/security/x-scalar-security-secrets.js +13 -0
  112. package/dist/schemas/extensions/security/x-scalar-security-secrets.js.map +7 -0
  113. package/dist/schemas/extensions/security/x-tokenName.d.ts +12 -0
  114. package/dist/schemas/extensions/security/x-tokenName.d.ts.map +1 -0
  115. package/dist/schemas/extensions/security/x-tokenName.js +8 -0
  116. package/dist/schemas/extensions/security/x-tokenName.js.map +7 -0
  117. package/dist/schemas/extensions/security/x-use-pkce.d.ts +7 -0
  118. package/dist/schemas/extensions/security/x-use-pkce.d.ts.map +1 -0
  119. package/dist/schemas/extensions/security/x-use-pkce.js +13 -0
  120. package/dist/schemas/extensions/security/x-use-pkce.js.map +7 -0
  121. package/dist/schemas/extensions/tag/x-display-name.d.ts +12 -0
  122. package/dist/schemas/extensions/tag/x-display-name.d.ts.map +1 -0
  123. package/dist/schemas/extensions/tag/x-display-name.js +8 -0
  124. package/dist/schemas/extensions/tag/x-display-name.js.map +7 -0
  125. package/dist/schemas/extensions/tag/x-tag-groups.d.ts +28 -0
  126. package/dist/schemas/extensions/tag/x-tag-groups.d.ts.map +1 -0
  127. package/dist/schemas/extensions/tag/x-tag-groups.js +19 -0
  128. package/dist/schemas/extensions/tag/x-tag-groups.js.map +7 -0
  129. package/dist/schemas/inmemory-workspace.d.ts +48 -5545
  130. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  131. package/dist/schemas/inmemory-workspace.js +12 -3
  132. package/dist/schemas/inmemory-workspace.js.map +2 -2
  133. package/dist/schemas/reference-config/index.d.ts +12 -4
  134. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  135. package/dist/schemas/reference-config/index.js +0 -6
  136. package/dist/schemas/reference-config/index.js.map +2 -2
  137. package/dist/schemas/reference-config/settings.d.ts +12 -1
  138. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  139. package/dist/schemas/reference-config/settings.js +9 -2
  140. package/dist/schemas/reference-config/settings.js.map +2 -2
  141. package/dist/schemas/typebox-coerce.d.ts.map +1 -1
  142. package/dist/schemas/typebox-coerce.js +1 -3
  143. package/dist/schemas/typebox-coerce.js.map +2 -2
  144. package/dist/schemas/v3.1/loose/callback.d.ts +10 -0
  145. package/dist/schemas/v3.1/loose/callback.d.ts.map +1 -0
  146. package/dist/schemas/v3.1/loose/callback.js +11 -0
  147. package/dist/schemas/v3.1/loose/callback.js.map +7 -0
  148. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-cookies.d.ts +16 -0
  149. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-cookies.d.ts.map +1 -0
  150. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-cookies.js +13 -0
  151. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-cookies.js.map +7 -0
  152. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-environments.d.ts +27 -0
  153. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-environments.d.ts.map +1 -0
  154. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-environments.js +23 -0
  155. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-environments.js.map +7 -0
  156. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-request-example.d.ts +38 -0
  157. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-request-example.d.ts.map +1 -0
  158. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-request-example.js +45 -0
  159. package/dist/schemas/v3.1/loose/client-config-extensions/x-scalar-client-config-request-example.js.map +7 -0
  160. package/dist/schemas/v3.1/loose/components.d.ts +43 -0
  161. package/dist/schemas/v3.1/loose/components.d.ts.map +1 -0
  162. package/dist/schemas/v3.1/loose/components.js +41 -0
  163. package/dist/schemas/v3.1/loose/components.js.map +7 -0
  164. package/dist/schemas/v3.1/loose/contact.d.ts +10 -0
  165. package/dist/schemas/v3.1/loose/contact.d.ts.map +1 -0
  166. package/dist/schemas/v3.1/loose/contact.js +13 -0
  167. package/dist/schemas/v3.1/loose/contact.js.map +7 -0
  168. package/dist/schemas/v3.1/loose/discriminator.d.ts +12 -0
  169. package/dist/schemas/v3.1/loose/discriminator.d.ts.map +1 -0
  170. package/dist/schemas/v3.1/loose/discriminator.js +11 -0
  171. package/dist/schemas/v3.1/loose/discriminator.js.map +7 -0
  172. package/dist/schemas/v3.1/loose/encoding.d.ts +15 -0
  173. package/dist/schemas/v3.1/loose/encoding.d.ts.map +1 -0
  174. package/dist/schemas/v3.1/loose/encoding.js +12 -0
  175. package/dist/schemas/v3.1/loose/encoding.js.map +7 -0
  176. package/dist/schemas/v3.1/loose/example.d.ts +16 -0
  177. package/dist/schemas/v3.1/loose/example.d.ts.map +1 -0
  178. package/dist/schemas/v3.1/loose/example.js +15 -0
  179. package/dist/schemas/v3.1/loose/example.js.map +7 -0
  180. package/dist/schemas/v3.1/loose/external-documentation.d.ts +8 -0
  181. package/dist/schemas/v3.1/loose/external-documentation.d.ts.map +1 -0
  182. package/dist/schemas/v3.1/loose/external-documentation.js +11 -0
  183. package/dist/schemas/v3.1/loose/external-documentation.js.map +7 -0
  184. package/dist/schemas/v3.1/loose/header.d.ts +355 -0
  185. package/dist/schemas/v3.1/loose/header.d.ts.map +1 -0
  186. package/dist/schemas/v3.1/loose/header.js +43 -0
  187. package/dist/schemas/v3.1/loose/header.js.map +7 -0
  188. package/dist/schemas/v3.1/loose/info.d.ts +48 -0
  189. package/dist/schemas/v3.1/loose/info.d.ts.map +1 -0
  190. package/dist/schemas/v3.1/loose/info.js +29 -0
  191. package/dist/schemas/v3.1/loose/info.js.map +7 -0
  192. package/dist/schemas/v3.1/loose/license.d.ts +10 -0
  193. package/dist/schemas/v3.1/loose/license.d.ts.map +1 -0
  194. package/dist/schemas/v3.1/loose/license.js +13 -0
  195. package/dist/schemas/v3.1/loose/license.js.map +7 -0
  196. package/dist/schemas/v3.1/loose/link.d.ts +30 -0
  197. package/dist/schemas/v3.1/loose/link.d.ts.map +1 -0
  198. package/dist/schemas/v3.1/loose/link.js +20 -0
  199. package/dist/schemas/v3.1/loose/link.js.map +7 -0
  200. package/dist/schemas/v3.1/loose/media-header-encoding.d.ts +1012 -0
  201. package/dist/schemas/v3.1/loose/media-header-encoding.d.ts.map +1 -0
  202. package/dist/schemas/v3.1/loose/media-header-encoding.js +19 -0
  203. package/dist/schemas/v3.1/loose/media-header-encoding.js.map +7 -0
  204. package/dist/schemas/v3.1/loose/media-type.d.ts +161 -0
  205. package/dist/schemas/v3.1/loose/media-type.d.ts.map +1 -0
  206. package/dist/schemas/v3.1/loose/media-type.js +18 -0
  207. package/dist/schemas/v3.1/loose/media-type.js.map +7 -0
  208. package/dist/schemas/v3.1/loose/oauth-flow.d.ts +95 -0
  209. package/dist/schemas/v3.1/loose/oauth-flow.d.ts.map +1 -0
  210. package/dist/schemas/v3.1/loose/oauth-flow.js +57 -0
  211. package/dist/schemas/v3.1/loose/oauth-flow.js.map +7 -0
  212. package/dist/schemas/v3.1/loose/oauthflows.d.ts +43 -0
  213. package/dist/schemas/v3.1/loose/oauthflows.d.ts.map +1 -0
  214. package/dist/schemas/v3.1/loose/oauthflows.js +21 -0
  215. package/dist/schemas/v3.1/loose/oauthflows.js.map +7 -0
  216. package/dist/schemas/v3.1/loose/openapi-document.d.ts +115 -0
  217. package/dist/schemas/v3.1/loose/openapi-document.d.ts.map +1 -0
  218. package/dist/schemas/v3.1/loose/openapi-document.js +64 -0
  219. package/dist/schemas/v3.1/loose/openapi-document.js.map +7 -0
  220. package/dist/schemas/v3.1/loose/operation.d.ts +1645 -0
  221. package/dist/schemas/v3.1/loose/operation.d.ts.map +1 -0
  222. package/dist/schemas/v3.1/loose/operation.js +61 -0
  223. package/dist/schemas/v3.1/loose/operation.js.map +7 -0
  224. package/dist/schemas/v3.1/loose/parameter.d.ts +1074 -0
  225. package/dist/schemas/v3.1/loose/parameter.d.ts.map +1 -0
  226. package/dist/schemas/v3.1/loose/parameter.js +54 -0
  227. package/dist/schemas/v3.1/loose/parameter.js.map +7 -0
  228. package/dist/schemas/v3.1/loose/path-item.d.ts +551 -0
  229. package/dist/schemas/v3.1/loose/path-item.d.ts.map +1 -0
  230. package/dist/schemas/v3.1/loose/path-item.js +42 -0
  231. package/dist/schemas/v3.1/loose/path-item.js.map +7 -0
  232. package/dist/schemas/v3.1/loose/path-operations.d.ts +2196 -0
  233. package/dist/schemas/v3.1/loose/path-operations.d.ts.map +1 -0
  234. package/dist/schemas/v3.1/loose/path-operations.js +21 -0
  235. package/dist/schemas/v3.1/loose/path-operations.js.map +7 -0
  236. package/dist/schemas/v3.1/loose/paths.d.ts +20 -0
  237. package/dist/schemas/v3.1/loose/paths.d.ts.map +1 -0
  238. package/dist/schemas/v3.1/loose/paths.js +11 -0
  239. package/dist/schemas/v3.1/loose/paths.js.map +7 -0
  240. package/dist/schemas/v3.1/loose/reference.d.ts +26 -0
  241. package/dist/schemas/v3.1/loose/reference.d.ts.map +1 -0
  242. package/dist/schemas/v3.1/loose/reference.js +24 -0
  243. package/dist/schemas/v3.1/loose/reference.js.map +7 -0
  244. package/dist/schemas/v3.1/loose/request-body.d.ts +339 -0
  245. package/dist/schemas/v3.1/loose/request-body.d.ts.map +1 -0
  246. package/dist/schemas/v3.1/loose/request-body.js +14 -0
  247. package/dist/schemas/v3.1/loose/request-body.js.map +7 -0
  248. package/dist/schemas/v3.1/loose/response.d.ts +698 -0
  249. package/dist/schemas/v3.1/loose/response.d.ts.map +1 -0
  250. package/dist/schemas/v3.1/loose/response.js +18 -0
  251. package/dist/schemas/v3.1/loose/response.js.map +7 -0
  252. package/dist/schemas/v3.1/loose/responses.d.ts +710 -0
  253. package/dist/schemas/v3.1/loose/responses.d.ts.map +1 -0
  254. package/dist/schemas/v3.1/loose/responses.js +11 -0
  255. package/dist/schemas/v3.1/loose/responses.js.map +7 -0
  256. package/dist/schemas/v3.1/loose/schema.d.ts +373 -0
  257. package/dist/schemas/v3.1/loose/schema.d.ts.map +1 -0
  258. package/dist/schemas/v3.1/loose/schema.js +146 -0
  259. package/dist/schemas/v3.1/loose/schema.js.map +7 -0
  260. package/dist/schemas/v3.1/loose/security-requirement.d.ts +11 -0
  261. package/dist/schemas/v3.1/loose/security-requirement.d.ts.map +1 -0
  262. package/dist/schemas/v3.1/loose/security-requirement.js +10 -0
  263. package/dist/schemas/v3.1/loose/security-requirement.js.map +7 -0
  264. package/dist/schemas/v3.1/loose/security-scheme.d.ts +169 -0
  265. package/dist/schemas/v3.1/loose/security-scheme.d.ts.map +1 -0
  266. package/dist/schemas/v3.1/loose/security-scheme.js +64 -0
  267. package/dist/schemas/v3.1/loose/security-scheme.js.map +7 -0
  268. package/dist/schemas/v3.1/loose/server-variable.d.ts +10 -0
  269. package/dist/schemas/v3.1/loose/server-variable.d.ts.map +1 -0
  270. package/dist/schemas/v3.1/loose/server-variable.js +13 -0
  271. package/dist/schemas/v3.1/loose/server-variable.js.map +7 -0
  272. package/dist/schemas/v3.1/loose/server.d.ts +14 -0
  273. package/dist/schemas/v3.1/loose/server.d.ts.map +1 -0
  274. package/dist/schemas/v3.1/loose/server.js +14 -0
  275. package/dist/schemas/v3.1/loose/server.js.map +7 -0
  276. package/dist/schemas/v3.1/loose/tag.d.ts +19 -0
  277. package/dist/schemas/v3.1/loose/tag.d.ts.map +1 -0
  278. package/dist/schemas/v3.1/loose/tag.js +23 -0
  279. package/dist/schemas/v3.1/loose/tag.js.map +7 -0
  280. package/dist/schemas/v3.1/loose/xml.d.ts +18 -0
  281. package/dist/schemas/v3.1/loose/xml.d.ts.map +1 -0
  282. package/dist/schemas/v3.1/loose/xml.js +17 -0
  283. package/dist/schemas/v3.1/loose/xml.js.map +7 -0
  284. package/dist/schemas/v3.1/strict/callback.d.ts +1 -8
  285. package/dist/schemas/v3.1/strict/callback.d.ts.map +1 -1
  286. package/dist/schemas/v3.1/strict/callback.js +5 -10
  287. package/dist/schemas/v3.1/strict/callback.js.map +2 -2
  288. package/dist/schemas/v3.1/strict/components.d.ts +24 -28
  289. package/dist/schemas/v3.1/strict/components.d.ts.map +1 -1
  290. package/dist/schemas/v3.1/strict/components.js +35 -32
  291. package/dist/schemas/v3.1/strict/components.js.map +2 -2
  292. package/dist/schemas/v3.1/strict/contact.d.ts +2 -2
  293. package/dist/schemas/v3.1/strict/contact.d.ts.map +1 -1
  294. package/dist/schemas/v3.1/strict/contact.js +8 -13
  295. package/dist/schemas/v3.1/strict/contact.js.map +2 -2
  296. package/dist/schemas/v3.1/strict/discriminator.d.ts +2 -2
  297. package/dist/schemas/v3.1/strict/discriminator.d.ts.map +1 -1
  298. package/dist/schemas/v3.1/strict/discriminator.js +6 -11
  299. package/dist/schemas/v3.1/strict/discriminator.js.map +2 -2
  300. package/dist/schemas/v3.1/strict/encoding.d.ts +3 -10
  301. package/dist/schemas/v3.1/strict/encoding.d.ts.map +1 -1
  302. package/dist/schemas/v3.1/strict/encoding.js +7 -12
  303. package/dist/schemas/v3.1/strict/encoding.js.map +2 -2
  304. package/dist/schemas/v3.1/strict/example.d.ts +2 -2
  305. package/dist/schemas/v3.1/strict/example.d.ts.map +1 -1
  306. package/dist/schemas/v3.1/strict/example.js +10 -15
  307. package/dist/schemas/v3.1/strict/example.js.map +2 -2
  308. package/dist/schemas/v3.1/strict/external-documentation.d.ts +2 -2
  309. package/dist/schemas/v3.1/strict/external-documentation.d.ts.map +1 -1
  310. package/dist/schemas/v3.1/strict/external-documentation.js +6 -11
  311. package/dist/schemas/v3.1/strict/external-documentation.js.map +2 -2
  312. package/dist/schemas/v3.1/strict/header.d.ts +292 -54
  313. package/dist/schemas/v3.1/strict/header.d.ts.map +1 -1
  314. package/dist/schemas/v3.1/strict/header.js +14 -17
  315. package/dist/schemas/v3.1/strict/header.js.map +2 -2
  316. package/dist/schemas/v3.1/strict/info.d.ts +11 -5
  317. package/dist/schemas/v3.1/strict/info.d.ts.map +1 -1
  318. package/dist/schemas/v3.1/strict/info.js +2 -2
  319. package/dist/schemas/v3.1/strict/info.js.map +2 -2
  320. package/dist/schemas/v3.1/strict/license.d.ts +2 -2
  321. package/dist/schemas/v3.1/strict/license.d.ts.map +1 -1
  322. package/dist/schemas/v3.1/strict/license.js +8 -13
  323. package/dist/schemas/v3.1/strict/license.js.map +2 -2
  324. package/dist/schemas/v3.1/strict/link.d.ts +6 -6
  325. package/dist/schemas/v3.1/strict/link.d.ts.map +1 -1
  326. package/dist/schemas/v3.1/strict/link.js +14 -19
  327. package/dist/schemas/v3.1/strict/link.js.map +2 -2
  328. package/dist/schemas/v3.1/strict/media-header-encoding.d.ts +1389 -164
  329. package/dist/schemas/v3.1/strict/media-header-encoding.d.ts.map +1 -1
  330. package/dist/schemas/v3.1/strict/media-type.d.ts +145 -19
  331. package/dist/schemas/v3.1/strict/media-type.d.ts.map +1 -1
  332. package/dist/schemas/v3.1/strict/media-type.js +13 -20
  333. package/dist/schemas/v3.1/strict/media-type.js.map +2 -2
  334. package/dist/schemas/v3.1/strict/oauth-flow.d.ts +24 -8
  335. package/dist/schemas/v3.1/strict/oauth-flow.d.ts.map +1 -1
  336. package/dist/schemas/v3.1/strict/oauth-flow.js +9 -9
  337. package/dist/schemas/v3.1/strict/oauth-flow.js.map +2 -2
  338. package/dist/schemas/v3.1/strict/oauthflows.d.ts +12 -4
  339. package/dist/schemas/v3.1/strict/oauthflows.d.ts.map +1 -1
  340. package/dist/schemas/v3.1/strict/oauthflows.js +10 -13
  341. package/dist/schemas/v3.1/strict/oauthflows.js.map +2 -2
  342. package/dist/schemas/v3.1/strict/openapi-document.d.ts +7 -5
  343. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  344. package/dist/schemas/v3.1/strict/openapi-document.js +0 -2
  345. package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
  346. package/dist/schemas/v3.1/strict/operation.d.ts +4711 -343
  347. package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
  348. package/dist/schemas/v3.1/strict/operation.js +40 -35
  349. package/dist/schemas/v3.1/strict/operation.js.map +2 -2
  350. package/dist/schemas/v3.1/strict/parameter.d.ts +1226 -164
  351. package/dist/schemas/v3.1/strict/parameter.d.ts.map +1 -1
  352. package/dist/schemas/v3.1/strict/parameter.js +23 -25
  353. package/dist/schemas/v3.1/strict/parameter.js.map +2 -2
  354. package/dist/schemas/v3.1/strict/path-item.d.ts +1320 -102
  355. package/dist/schemas/v3.1/strict/path-item.d.ts.map +1 -1
  356. package/dist/schemas/v3.1/strict/path-item.js +35 -40
  357. package/dist/schemas/v3.1/strict/path-item.js.map +2 -2
  358. package/dist/schemas/v3.1/strict/path-operations.d.ts +10601 -11739
  359. package/dist/schemas/v3.1/strict/path-operations.d.ts.map +1 -1
  360. package/dist/schemas/v3.1/strict/path-operations.js +3 -1
  361. package/dist/schemas/v3.1/strict/path-operations.js.map +2 -2
  362. package/dist/schemas/v3.1/strict/paths.d.ts +3 -5514
  363. package/dist/schemas/v3.1/strict/paths.d.ts.map +1 -1
  364. package/dist/schemas/v3.1/strict/paths.js +4 -9
  365. package/dist/schemas/v3.1/strict/paths.js.map +2 -2
  366. package/dist/schemas/v3.1/strict/reference.d.ts +12 -5
  367. package/dist/schemas/v3.1/strict/reference.d.ts.map +1 -1
  368. package/dist/schemas/v3.1/strict/reference.js +4 -4
  369. package/dist/schemas/v3.1/strict/reference.js.map +2 -2
  370. package/dist/schemas/v3.1/strict/request-body.d.ts +468 -56
  371. package/dist/schemas/v3.1/strict/request-body.d.ts.map +1 -1
  372. package/dist/schemas/v3.1/strict/request-body.js +8 -13
  373. package/dist/schemas/v3.1/strict/request-body.js.map +2 -2
  374. package/dist/schemas/v3.1/strict/response.d.ts +1121 -130
  375. package/dist/schemas/v3.1/strict/response.d.ts.map +1 -1
  376. package/dist/schemas/v3.1/strict/response.js +11 -16
  377. package/dist/schemas/v3.1/strict/response.js.map +2 -2
  378. package/dist/schemas/v3.1/strict/responses.d.ts +2352 -139
  379. package/dist/schemas/v3.1/strict/responses.d.ts.map +1 -1
  380. package/dist/schemas/v3.1/strict/responses.js +4 -6
  381. package/dist/schemas/v3.1/strict/responses.js.map +2 -2
  382. package/dist/schemas/v3.1/strict/schema.d.ts +232 -15
  383. package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
  384. package/dist/schemas/v3.1/strict/schema.js +206 -31
  385. package/dist/schemas/v3.1/strict/schema.js.map +2 -2
  386. package/dist/schemas/v3.1/strict/security-requirement.d.ts +1 -1
  387. package/dist/schemas/v3.1/strict/security-requirement.d.ts.map +1 -1
  388. package/dist/schemas/v3.1/strict/security-requirement.js +4 -9
  389. package/dist/schemas/v3.1/strict/security-requirement.js.map +2 -2
  390. package/dist/schemas/v3.1/strict/security-scheme.d.ts +56 -26
  391. package/dist/schemas/v3.1/strict/security-scheme.d.ts.map +1 -1
  392. package/dist/schemas/v3.1/strict/security-scheme.js +11 -8
  393. package/dist/schemas/v3.1/strict/security-scheme.js.map +2 -2
  394. package/dist/schemas/v3.1/strict/server-variable.d.ts +2 -2
  395. package/dist/schemas/v3.1/strict/server-variable.d.ts.map +1 -1
  396. package/dist/schemas/v3.1/strict/server-variable.js +8 -13
  397. package/dist/schemas/v3.1/strict/server-variable.js.map +2 -2
  398. package/dist/schemas/v3.1/strict/server.d.ts +4 -4
  399. package/dist/schemas/v3.1/strict/server.d.ts.map +1 -1
  400. package/dist/schemas/v3.1/strict/server.js +8 -13
  401. package/dist/schemas/v3.1/strict/server.js.map +2 -2
  402. package/dist/schemas/v3.1/strict/tag.d.ts +7 -3
  403. package/dist/schemas/v3.1/strict/tag.d.ts.map +1 -1
  404. package/dist/schemas/v3.1/strict/tag.js +6 -8
  405. package/dist/schemas/v3.1/strict/tag.js.map +2 -2
  406. package/dist/schemas/v3.1/strict/xml.d.ts +2 -2
  407. package/dist/schemas/v3.1/strict/xml.d.ts.map +1 -1
  408. package/dist/schemas/v3.1/strict/xml.js +12 -17
  409. package/dist/schemas/v3.1/strict/xml.js.map +2 -2
  410. package/dist/schemas/workspace-specification/config.d.ts +10 -2
  411. package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
  412. package/dist/schemas/workspace-specification/index.d.ts +39 -13
  413. package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
  414. package/dist/schemas/workspace.d.ts +63 -34
  415. package/dist/schemas/workspace.d.ts.map +1 -1
  416. package/dist/schemas/workspace.js +1 -0
  417. package/dist/schemas/workspace.js.map +2 -2
  418. package/dist/server.d.ts +2 -3290
  419. package/dist/server.d.ts.map +1 -1
  420. package/dist/server.js.map +2 -2
  421. package/dist/types.d.ts +0 -6
  422. package/dist/types.d.ts.map +1 -1
  423. package/package.json +17 -11
  424. package/dist/schemas/v3.1/strict/extensions.d.ts +0 -4
  425. package/dist/schemas/v3.1/strict/extensions.d.ts.map +0 -1
  426. package/dist/schemas/v3.1/strict/extensions.js +0 -6
  427. package/dist/schemas/v3.1/strict/extensions.js.map +0 -7
  428. package/dist/schemas/v3.1/type-guard.d.ts +0 -10
  429. package/dist/schemas/v3.1/type-guard.d.ts.map +0 -1
  430. package/dist/schemas/v3.1/type-guard.js +0 -7
  431. package/dist/schemas/v3.1/type-guard.js.map +0 -7
package/dist/client.js CHANGED
@@ -1,21 +1,28 @@
1
- import YAML from "yaml";
2
- import { reactive } from "vue";
3
- import { upgrade } from "@scalar/openapi-parser";
4
1
  import { createMagicProxy, getRaw } from "@scalar/json-magic/magic-proxy";
2
+ import { upgrade } from "@scalar/openapi-parser";
3
+ import { reactive } from "vue";
4
+ import YAML from "yaml";
5
5
  import { applySelectiveUpdates } from "./helpers/apply-selective-updates.js";
6
- import { deepClone, isObject, safeAssign } from "./helpers/general.js";
6
+ import { deepClone } from "./helpers/deep-clone.js";
7
+ import { isObject, safeAssign } from "./helpers/general.js";
7
8
  import { getValueByPath } from "./helpers/json-path-utils.js";
8
9
  import { mergeObjects } from "./helpers/merge-object.js";
10
+ import { createOverridesProxy } from "./helpers/overrides-proxy.js";
9
11
  import { createNavigation } from "./navigation/index.js";
12
+ import { externalValueResolver, loadingStatus, refsEverywhere, restoreOriginalRefs } from "./plugins.js";
10
13
  import { extensions } from "./schemas/extensions.js";
11
- import { coerceValue } from "./schemas/typebox-coerce.js";
12
- import { OpenAPIDocumentSchema } from "./schemas/v3.1/strict/openapi-document.js";
13
- import { defaultReferenceConfig } from "./schemas/reference-config/index.js";
14
14
  import { InMemoryWorkspaceSchema } from "./schemas/inmemory-workspace.js";
15
- import { createOverridesProxy } from "./helpers/overrides-proxy.js";
15
+ import { defaultReferenceConfig } from "./schemas/reference-config/index.js";
16
+ import { coerceValue } from "./schemas/typebox-coerce.js";
17
+ import { OpenAPIDocumentSchema as OpenAPIDocumentSchemaLoose } from "./schemas/v3.1/loose/openapi-document.js";
18
+ import {
19
+ OpenAPIDocumentSchema as OpenAPIDocumentSchemaStrict
20
+ } from "./schemas/v3.1/strict/openapi-document.js";
21
+ import { measureAsync, measureSync } from "@scalar/helpers/testing/measure";
16
22
  import { bundle } from "@scalar/json-magic/bundle";
17
23
  import { fetchUrls } from "@scalar/json-magic/bundle/plugins/browser";
18
24
  import { apply, diff, merge } from "@scalar/json-magic/diff";
25
+ import { Value } from "@sinclair/typebox/value";
19
26
  const defaultConfig = {
20
27
  "x-scalar-reference-config": defaultReferenceConfig
21
28
  };
@@ -28,11 +35,19 @@ async function loadDocument(workspaceDocument) {
28
35
  data: workspaceDocument.document
29
36
  };
30
37
  }
38
+ const getDocumentSource = (input) => {
39
+ if ("url" in input) {
40
+ return input.url;
41
+ }
42
+ return void 0;
43
+ };
31
44
  const createWorkspaceStore = (workspaceProps) => {
32
45
  const originalDocuments = {};
33
46
  const intermediateDocuments = {};
34
47
  const documentConfigs = {};
35
48
  const overrides = {};
49
+ const documentMeta = {};
50
+ const extraDocumentConfigurations = {};
36
51
  const workspace = reactive({
37
52
  ...workspaceProps?.meta,
38
53
  documents: {},
@@ -51,7 +66,7 @@ const createWorkspaceStore = (workspaceProps) => {
51
66
  function getActiveDocumentName() {
52
67
  return workspace[extensions.workspace.activeDocument] ?? Object.keys(workspace.documents)[0] ?? "";
53
68
  }
54
- function saveDocument(documentName) {
69
+ async function saveDocument(documentName) {
55
70
  const intermediateDocument = intermediateDocuments[documentName];
56
71
  const workspaceDocument = workspace.documents[documentName];
57
72
  if (!workspaceDocument) {
@@ -61,87 +76,137 @@ const createWorkspaceStore = (workspaceProps) => {
61
76
  if (!intermediateDocument || !updatedDocument) {
62
77
  return;
63
78
  }
64
- const excludedDiffs = applySelectiveUpdates(intermediateDocument, updatedDocument);
79
+ const updatedWithOriginalRefs = await bundle(deepClone(updatedDocument), {
80
+ plugins: [restoreOriginalRefs()],
81
+ treeShake: false,
82
+ urlMap: true
83
+ });
84
+ const excludedDiffs = applySelectiveUpdates(intermediateDocument, updatedWithOriginalRefs);
65
85
  return excludedDiffs;
66
86
  }
67
87
  async function addInMemoryDocument(input) {
68
88
  const { name, meta } = input;
69
- const document = coerceValue(OpenAPIDocumentSchema, upgrade(input.document).specification);
70
- originalDocuments[name] = deepClone({ ...document, ...meta });
71
- intermediateDocuments[name] = deepClone({ ...document, ...meta });
72
- documentConfigs[name] = input.config ?? {};
73
- overrides[name] = input.overrides ?? {};
74
- if (document[extensions.document.navigation] === void 0) {
75
- document[extensions.document.navigation] = createNavigation(document, input.config ?? {}).entries;
89
+ const cloned = measureSync("deepClone", () => deepClone(input.document));
90
+ const inputDocument = measureSync("upgrade", () => upgrade(cloned).specification);
91
+ measureSync("initialize", () => {
92
+ if (input.initialize !== false) {
93
+ originalDocuments[name] = deepClone({ ...inputDocument });
94
+ intermediateDocuments[name] = deepClone({ ...inputDocument });
95
+ documentConfigs[name] = input.config ?? {};
96
+ overrides[name] = input.overrides ?? {};
97
+ documentMeta[name] = { documentSource: input.documentSource };
98
+ extraDocumentConfigurations[name] = { fetch: input.fetch };
99
+ }
100
+ });
101
+ const temporaryDocument = createMagicProxy({ ...inputDocument, ...meta });
102
+ if (temporaryDocument[extensions.document.navigation] === void 0) {
103
+ await measureAsync(
104
+ "bundle",
105
+ async () => await bundle(getRaw(temporaryDocument), {
106
+ treeShake: false,
107
+ plugins: [
108
+ fetchUrls({
109
+ fetch: extraDocumentConfigurations[name]?.fetch ?? workspaceProps?.fetch
110
+ }),
111
+ externalValueResolver(),
112
+ refsEverywhere()
113
+ // TODO: investigate problems with type: {} properties
114
+ // cleanUp(),
115
+ ],
116
+ urlMap: true,
117
+ origin: documentMeta[name]?.documentSource
118
+ // use the document origin (if provided) as the base URL for resolution
119
+ })
120
+ );
121
+ const coerced = measureSync(
122
+ "coerceValue",
123
+ () => coerceValue(OpenAPIDocumentSchemaStrict, deepClone(temporaryDocument))
124
+ );
125
+ measureAsync("mergeObjects", async () => mergeObjects(temporaryDocument, coerced));
126
+ }
127
+ const isValid = Value.Check(OpenAPIDocumentSchemaStrict, temporaryDocument);
128
+ let errors = null;
129
+ if (!isValid) {
130
+ const validationErrors = Array.from(Value.Errors(OpenAPIDocumentSchemaStrict, temporaryDocument));
131
+ errors = validationErrors.map((error) => ({
132
+ message: error.message,
133
+ path: error.path,
134
+ schema: error.schema,
135
+ value: error.value
136
+ }));
76
137
  }
77
- if (document[extensions.document.navigation] === void 0) {
78
- await bundle(input.document, { treeShake: false, plugins: [fetchUrls()] });
138
+ const strictDocument = isValid ? temporaryDocument : temporaryDocument;
139
+ if (strictDocument[extensions.document.navigation] === void 0) {
140
+ const showModels = input.config?.["x-scalar-reference-config"]?.features?.showModels;
141
+ strictDocument[extensions.document.navigation] = createNavigation(strictDocument, {
142
+ ...input.config?.["x-scalar-reference-config"] ?? {},
143
+ hideModels: showModels === void 0 ? void 0 : !showModels
144
+ }).entries;
79
145
  }
80
- workspace.documents[name] = createOverridesProxy(createMagicProxy({ ...document, ...meta }), input.overrides);
146
+ workspace.documents[name] = createOverridesProxy(strictDocument, input.overrides);
147
+ return {
148
+ errors,
149
+ document: workspace.documents[name]
150
+ };
81
151
  }
82
152
  async function addDocument(input) {
83
153
  const { name, meta } = input;
84
- const resolve = await loadDocument(input);
85
- if (!resolve.ok) {
86
- console.error(`Failed to fetch document '${name}': request was not successful`);
87
- workspace.documents[name] = {
88
- ...meta,
89
- openapi: "3.1.0",
90
- info: {
91
- title: `Document '${name}' could not be loaded`,
92
- version: "unknown"
93
- }
94
- };
95
- return;
96
- }
97
- if (!isObject(resolve.data)) {
98
- console.error(`Failed to load document '${name}': response data is not a valid object`);
99
- workspace.documents[name] = {
100
- ...meta,
101
- openapi: "3.1.0",
102
- info: {
103
- title: `Document '${name}' could not be loaded`,
104
- version: "unknown"
105
- }
106
- };
107
- return;
108
- }
109
- await addInMemoryDocument({ ...input, document: resolve.data });
154
+ const resolve = await measureAsync(
155
+ "loadDocument",
156
+ async () => await loadDocument({ ...input, fetch: input.fetch ?? workspaceProps?.fetch })
157
+ );
158
+ await measureAsync("addDocument", async () => {
159
+ if (!resolve.ok) {
160
+ console.error(`Failed to fetch document '${name}': request was not successful`);
161
+ workspace.documents[name] = {
162
+ ...meta,
163
+ openapi: "3.1.0",
164
+ info: {
165
+ title: `Document '${name}' could not be loaded`,
166
+ version: "unknown"
167
+ }
168
+ };
169
+ return;
170
+ }
171
+ if (!isObject(resolve.data)) {
172
+ console.error(`Failed to load document '${name}': response data is not a valid object`);
173
+ workspace.documents[name] = {
174
+ ...meta,
175
+ openapi: "3.1.0",
176
+ info: {
177
+ title: `Document '${name}' could not be loaded`,
178
+ version: "unknown"
179
+ }
180
+ };
181
+ return;
182
+ }
183
+ const { errors } = await addInMemoryDocument({
184
+ ...input,
185
+ document: resolve.data,
186
+ documentSource: getDocumentSource(input)
187
+ });
188
+ if (errors) {
189
+ console.warn("OpenAPI Document Validation Errors", errors);
190
+ }
191
+ });
110
192
  }
193
+ const getDocumentConfiguration = (name) => {
194
+ return mergeObjects(
195
+ mergeObjects(defaultConfig, workspaceProps?.config ?? {}),
196
+ documentConfigs[name] ?? {}
197
+ );
198
+ };
111
199
  const visitedNodesCache = /* @__PURE__ */ new Set();
112
200
  return {
113
- /**
114
- * Returns the reactive workspace object with an additional activeDocument getter
115
- */
116
201
  get workspace() {
117
202
  return workspace;
118
203
  },
119
- /**
120
- * Updates a specific metadata field in the workspace
121
- * @param key - The metadata field to update
122
- * @param value - The new value for the field
123
- * @example
124
- * // Update the workspace title
125
- * update('x-scalar-active-document', 'document-name')
126
- */
127
204
  update(key, value) {
128
205
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
129
206
  throw new Error("Invalid key: cannot modify prototype");
130
207
  }
131
208
  Object.assign(workspace, { [key]: value });
132
209
  },
133
- /**
134
- * Updates a specific metadata field in a document
135
- * @param name - The name of the document to update ('active' or a specific document name)
136
- * @param key - The metadata field to update
137
- * @param value - The new value for the field
138
- * @throws Error if the specified document doesn't exist
139
- * @example
140
- * // Update the auth of the active document
141
- * updateDocument('active', 'x-scalar-active-auth', 'Bearer')
142
- * // Update the auth of a specific document
143
- * updateDocument('document-name', 'x-scalar-active-auth', 'Bearer')
144
- */
145
210
  updateDocument(name, key, value) {
146
211
  const currentDocument = workspace.documents[name === "active" ? getActiveDocumentName() : name];
147
212
  if (!currentDocument) {
@@ -149,41 +214,25 @@ const createWorkspaceStore = (workspaceProps) => {
149
214
  }
150
215
  Object.assign(currentDocument, { [key]: value });
151
216
  },
152
- /**
153
- * Replaces the content of a specific document in the workspace with the provided input.
154
- * This method computes the difference between the current document and the new input,
155
- * then applies only the necessary changes in place. The updates are applied atomically,
156
- * ensuring the document is updated in a single operation.
157
- *
158
- * @param documentName - The name of the document to update.
159
- * @param input - The new content to apply to the document (as a plain object).
160
- * @example
161
- * // Replace the content of the 'api' document with new data
162
- * store.replaceDocument('api', {
163
- * openapi: '3.1.0',
164
- * info: { title: 'Updated API', version: '1.0.1' },
165
- * paths: {},
166
- * })
167
- */
168
- replaceDocument(documentName, input) {
217
+ async replaceDocument(documentName, input) {
169
218
  const currentDocument = workspace.documents[documentName];
170
219
  if (!currentDocument) {
171
220
  return console.error(`Document '${documentName}' does not exist in the workspace.`);
172
221
  }
173
- const newDocument = coerceValue(OpenAPIDocumentSchema, upgrade(input).specification);
174
- applySelectiveUpdates(currentDocument, newDocument);
222
+ const { errors } = await addInMemoryDocument({
223
+ name: documentName,
224
+ document: input,
225
+ // Preserve the current metadata
226
+ meta: {
227
+ "x-scalar-active-auth": currentDocument["x-scalar-active-auth"],
228
+ "x-scalar-active-server": currentDocument["x-scalar-active-server"]
229
+ },
230
+ initialize: false
231
+ });
232
+ if (errors) {
233
+ console.warn("OpenAPI Document Validation Errors", errors);
234
+ }
175
235
  },
176
- /**
177
- * Resolves a reference in the active document by following the provided path and resolving any external $ref references.
178
- * This method traverses the document structure following the given path and resolves any $ref references it encounters.
179
- * During resolution, it sets a loading status and updates the reference with the resolved content.
180
- *
181
- * @param path - Array of strings representing the path to the reference (e.g. ['paths', '/users', 'get', 'responses', '200'])
182
- * @throws Error if the path is invalid or empty
183
- * @example
184
- * // Resolve a reference in the active document
185
- * resolve(['paths', '/users', 'get', 'responses', '200'])
186
- */
187
236
  resolve: async (path) => {
188
237
  const activeDocument = workspace.activeDocument;
189
238
  const target = getValueByPath(activeDocument, path);
@@ -196,74 +245,15 @@ const createWorkspaceStore = (workspaceProps) => {
196
245
  return bundle(target, {
197
246
  root: activeDocument,
198
247
  treeShake: false,
199
- plugins: [fetchUrls()],
200
- urlMap: false,
201
- hooks: {
202
- onResolveStart: (node) => {
203
- node["$status"] = "loading";
204
- },
205
- onResolveError: (node) => {
206
- node["$status"] = "error";
207
- }
208
- },
248
+ plugins: [fetchUrls(), loadingStatus(), externalValueResolver()],
249
+ urlMap: true,
209
250
  visitedNodes: visitedNodesCache
210
251
  });
211
252
  },
212
- /**
213
- * Adds a new document to the workspace
214
- * @param document - The document content to add. This should be a valid OpenAPI/Swagger document or other supported format
215
- * @param meta - Metadata for the document, including its name and other properties defined in WorkspaceDocumentMeta
216
- * @example
217
- * // Add a new OpenAPI document to the workspace
218
- * store.addDocument({
219
- * name: 'name',
220
- * document: {
221
- * openapi: '3.0.0',
222
- * info: { title: 'title' },
223
- * },
224
- * meta: {
225
- * 'x-scalar-active-auth': 'Bearer',
226
- * 'x-scalar-active-server': 'production'
227
- * }
228
- * })
229
- */
230
253
  addDocument,
231
- /**
232
- * Returns the merged configuration for the active document.
233
- *
234
- * This getter merges configurations in the following order of precedence:
235
- * 1. Document-specific configuration (highest priority)
236
- * 2. Workspace-level configuration
237
- * 3. Default configuration (lowest priority)
238
- *
239
- * The active document is determined by the workspace's activeDocument extension,
240
- * falling back to the first document if none is specified.
241
- */
242
254
  get config() {
243
- return mergeObjects(
244
- mergeObjects(defaultConfig, workspaceProps?.config ?? {}),
245
- documentConfigs[getActiveDocumentName()] ?? {}
246
- );
255
+ return getDocumentConfiguration(getActiveDocumentName());
247
256
  },
248
- /**
249
- * Exports the specified document in the requested format.
250
- *
251
- * This method serializes the most recently saved local version of the document (from the intermediateDocuments map)
252
- * to either JSON or YAML. The exported document reflects the last locally saved state, including any edits
253
- * that have been saved but not yet synced to a remote registry. Runtime/in-memory changes that have not been saved
254
- * will not be included.
255
- *
256
- * @param documentName - The name of the document to export.
257
- * @param format - The output format: 'json' for a JSON string, or 'yaml' for a YAML string.
258
- * @returns The document as a string in the requested format, or undefined if the document does not exist.
259
- *
260
- * @example
261
- * // Export a document as JSON
262
- * const jsonString = store.exportDocument('api', 'json')
263
- *
264
- * // Export a document as YAML
265
- * const yamlString = store.exportDocument('api', 'yaml')
266
- */
267
257
  exportDocument: (documentName, format) => {
268
258
  const intermediateDocument = intermediateDocuments[documentName];
269
259
  if (!intermediateDocument) {
@@ -274,78 +264,25 @@ const createWorkspaceStore = (workspaceProps) => {
274
264
  }
275
265
  return YAML.stringify(intermediateDocument);
276
266
  },
277
- /**
278
- * Saves the current state of the specified document to the intermediate documents map.
279
- *
280
- * This function captures the latest (reactive) state of the document from the workspace and
281
- * applies its changes to the corresponding entry in the `intermediateDocuments` map.
282
- * The `intermediateDocuments` map represents the most recently "saved" local version of the document,
283
- * which may include edits not yet synced to the remote registry.
284
- *
285
- * The update is performed in-place. A deep clone of the current document
286
- * state is used to avoid mutating the reactive object directly.
287
- *
288
- * @param documentName - The name of the document to save.
289
- * @returns An array of diffs that were excluded from being applied (such as changes to ignored keys),
290
- * or undefined if the document does not exist or cannot be updated.
291
- *
292
- * @example
293
- * // Save the current state of the document named 'api'
294
- * const excludedDiffs = store.saveDocument('api')
295
- */
296
267
  saveDocument,
297
- /**
298
- * Restores the specified document to its last locally saved state.
299
- *
300
- * This method updates the current reactive document (in the workspace) with the contents of the
301
- * corresponding intermediate document (from the `intermediateDocuments` map), effectively discarding
302
- * any unsaved in-memory changes and reverting to the last saved version.
303
- * Vue reactivity is preserved by updating the existing reactive object in place.
304
- *
305
- * **Warning:** This operation will discard all unsaved (in-memory) changes to the specified document.
306
- *
307
- * @param documentName - The name of the document to restore.
308
- * @returns void
309
- *
310
- * @example
311
- * // Restore the document named 'api' to its last saved state
312
- * store.revertDocumentChanges('api')
313
- */
314
- revertDocumentChanges(documentName) {
268
+ async revertDocumentChanges(documentName) {
315
269
  const workspaceDocument = workspace.documents[documentName];
316
- if (!workspaceDocument) {
270
+ const intermediate = intermediateDocuments[documentName];
271
+ if (!workspaceDocument || !intermediate) {
317
272
  return;
318
273
  }
319
- const intermediateDocument = intermediateDocuments[documentName];
320
- const updatedDocument = getRaw(workspaceDocument);
321
- if (!intermediateDocument || !updatedDocument) {
322
- return;
274
+ const { errors } = await addInMemoryDocument({
275
+ name: documentName,
276
+ document: intermediate,
277
+ initialize: false
278
+ });
279
+ if (errors) {
280
+ console.warn("OpenAPI Document Validation Errors", errors);
323
281
  }
324
- applySelectiveUpdates(updatedDocument, intermediateDocument);
325
282
  },
326
- /**
327
- * Commits the specified document.
328
- *
329
- * This method is intended to finalize and persist the current state of the document,
330
- * potentially syncing it with a remote registry or marking it as the latest committed version.
331
- *
332
- * @param documentName - The name of the document to commit.
333
- * @remarks
334
- * The actual commit logic is not implemented yet.
335
- */
336
283
  commitDocument(documentName) {
337
284
  console.warn(`Commit operation for document '${documentName}' is not implemented yet.`);
338
285
  },
339
- /**
340
- * Serializes the current workspace state to a JSON string for backup, persistence, or sharing.
341
- *
342
- * This method exports all workspace documents (removing Vue reactivity proxies), workspace metadata,
343
- * document configurations, and both the original and intermediate document states. The resulting JSON
344
- * can be imported later to fully restore the workspace to this exact state, including all documents
345
- * and their configurations.
346
- *
347
- * @returns A JSON string representing the complete workspace state.
348
- */
349
286
  exportWorkspace() {
350
287
  return JSON.stringify({
351
288
  documents: {
@@ -354,7 +291,7 @@ const createWorkspaceStore = (workspaceProps) => {
354
291
  name,
355
292
  // Extract the raw document data for export, removing any Vue reactivity wrappers.
356
293
  // When importing, the document can be wrapped again in a magic proxy.
357
- createOverridesProxy(getRaw(doc), overrides[name])
294
+ getRaw(doc)
358
295
  ])
359
296
  )
360
297
  },
@@ -362,54 +299,28 @@ const createWorkspaceStore = (workspaceProps) => {
362
299
  documentConfigs,
363
300
  originalDocuments,
364
301
  intermediateDocuments,
365
- overrides
302
+ overrides,
303
+ documentMeta
366
304
  });
367
305
  },
368
- /**
369
- * Imports a workspace from a serialized JSON string.
370
- *
371
- * This method parses the input string using the InMemoryWorkspaceSchema,
372
- * then updates the current workspace state, including documents, metadata,
373
- * and configuration, with the imported values.
374
- *
375
- * @param input - The serialized workspace JSON string to import.
376
- */
377
306
  loadWorkspace(input) {
378
307
  const result = coerceValue(InMemoryWorkspaceSchema, JSON.parse(input));
379
308
  safeAssign(
380
309
  workspace.documents,
381
- Object.fromEntries(Object.entries(result.documents).map(([name, doc]) => [name, createMagicProxy(doc)]))
310
+ Object.fromEntries(
311
+ Object.entries(result.documents).map(([name, doc]) => [
312
+ name,
313
+ createOverridesProxy(createMagicProxy(doc), result.overrides[name])
314
+ ])
315
+ )
382
316
  );
383
317
  safeAssign(originalDocuments, result.originalDocuments);
384
318
  safeAssign(intermediateDocuments, result.intermediateDocuments);
385
319
  safeAssign(documentConfigs, result.documentConfigs);
386
320
  safeAssign(overrides, result.overrides);
387
321
  safeAssign(workspace, result.meta);
322
+ safeAssign(documentMeta, result.documentMeta);
388
323
  },
389
- /**
390
- * Imports a workspace from a WorkspaceSpecification object.
391
- *
392
- * This method assigns workspace metadata and adds all documents defined in the specification.
393
- * Each document is added using its $ref and optional overrides.
394
- *
395
- * @example
396
- * ```ts
397
- * await store.importWorkspaceFromSpecification({
398
- * documents: {
399
- * api: { $ref: '/specs/api.yaml' },
400
- * petstore: { $ref: '/specs/petstore.yaml' }
401
- * },
402
- * overrides: {
403
- * api: { config: { features: { showModels: true } } }
404
- * },
405
- * info: { title: 'My Workspace' },
406
- * workspace: 'v1',
407
- * "x-scalar-dark-mode": true
408
- * })
409
- * ```
410
- *
411
- * @param specification - The workspace specification to import.
412
- */
413
324
  importWorkspaceFromSpecification: (specification) => {
414
325
  const { documents, overrides: overrides2, info, workspace: workspaceVersion, ...meta } = specification;
415
326
  safeAssign(workspace, meta);
@@ -419,28 +330,8 @@ const createWorkspaceStore = (workspaceProps) => {
419
330
  )
420
331
  );
421
332
  },
422
- /**
423
- * Rebases a document in the workspace with a new origin, resolving conflicts if provided.
424
- *
425
- * This method is used to rebase a document (e.g., after pulling remote changes) by applying the changes
426
- * from the new origin and merging them with local edits. If there are conflicts, they can be resolved
427
- * by providing a list of resolved conflicts.
428
- *
429
- * @param documentName - The name of the document to rebase.
430
- * @param newDocumentOrigin - The new origin document (as an object) to rebase onto.
431
- * @param resolvedConflicts - (Optional) An array of resolved conflicts to apply.
432
- * @returns If there are unresolved conflicts and no resolution is provided, returns the list of conflicts.
433
- *
434
- * @example
435
- * // Example: Rebase a document with a new origin and resolve conflicts
436
- * const conflicts = store.rebaseDocument('api', newOriginDoc)
437
- * if (conflicts && conflicts.length > 0) {
438
- * // User resolves conflicts here...
439
- * store.rebaseDocument('api', newOriginDoc, userResolvedConflicts)
440
- * }
441
- */
442
333
  rebaseDocument: (documentName, newDocumentOrigin, resolvedConflicts) => {
443
- const newOrigin = coerceValue(OpenAPIDocumentSchema, upgrade(newDocumentOrigin).specification);
334
+ const newOrigin = coerceValue(OpenAPIDocumentSchemaLoose, upgrade(newDocumentOrigin).specification);
444
335
  const originalDocument = originalDocuments[documentName];
445
336
  const intermediateDocument = intermediateDocuments[documentName];
446
337
  const activeDocument = workspace.documents[documentName] ? getRaw(workspace.documents[documentName]) : void 0;
@@ -461,7 +352,10 @@ const createWorkspaceStore = (workspaceProps) => {
461
352
  const changelogBB = diff(intermediateDocument, activeDocument);
462
353
  const changesB = merge(changelogBA, changelogBB);
463
354
  const changesetB = changesB.diffs.concat(changesB.conflicts.flatMap((it) => it[0]));
464
- const newActiveDocument = apply(deepClone(newIntermediateDocument), changesetB);
355
+ const newActiveDocument = coerceValue(
356
+ OpenAPIDocumentSchemaStrict,
357
+ apply(deepClone(newIntermediateDocument), changesetB)
358
+ );
465
359
  workspace.documents[documentName] = createOverridesProxy(
466
360
  createMagicProxy({ ...newActiveDocument }),
467
361
  overrides[documentName]