@scalar/workspace-store 0.40.2 → 0.40.4

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 (368) hide show
  1. package/CHANGELOG.md +13 -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.d.ts +10 -0
  7. package/dist/entities/auth/schema.d.ts.map +1 -1
  8. package/dist/entities/auth/schema.js +42 -116
  9. package/dist/entities/history/index.js +80 -60
  10. package/dist/entities/history/schema.js +94 -88
  11. package/dist/events/bus.js +146 -93
  12. package/dist/events/definitions/analytics.js +1 -1
  13. package/dist/events/definitions/auth.js +1 -1
  14. package/dist/events/definitions/common.js +1 -1
  15. package/dist/events/definitions/cookie.js +1 -1
  16. package/dist/events/definitions/document.js +1 -1
  17. package/dist/events/definitions/environment.js +1 -1
  18. package/dist/events/definitions/hooks.js +1 -1
  19. package/dist/events/definitions/index.js +1 -1
  20. package/dist/events/definitions/meta.js +1 -1
  21. package/dist/events/definitions/operation.js +1 -1
  22. package/dist/events/definitions/server.js +1 -1
  23. package/dist/events/definitions/tabs.js +1 -1
  24. package/dist/events/definitions/tag.js +1 -1
  25. package/dist/events/definitions/ui.js +1 -1
  26. package/dist/events/definitions/workspace.js +1 -1
  27. package/dist/events/index.js +3 -9
  28. package/dist/events/listeners.js +20 -22
  29. package/dist/events/old-definitions.js +15 -12
  30. package/dist/helpers/deep-clone.js +33 -17
  31. package/dist/helpers/detect-changes-proxy.js +95 -57
  32. package/dist/helpers/general.js +78 -23
  33. package/dist/helpers/generate-unique-value.js +77 -45
  34. package/dist/helpers/get-fetch.js +12 -10
  35. package/dist/helpers/get-resolved-ref.js +11 -10
  36. package/dist/helpers/is-non-optional-security-requirement.js +3 -6
  37. package/dist/helpers/merge-object.js +71 -30
  38. package/dist/helpers/overrides-proxy.js +98 -58
  39. package/dist/helpers/unpack-proxy.js +60 -58
  40. package/dist/mutators/auth.js +358 -230
  41. package/dist/mutators/cookie.js +59 -42
  42. package/dist/mutators/document.js +104 -66
  43. package/dist/mutators/environment.js +97 -72
  44. package/dist/mutators/helpers.js +9 -13
  45. package/dist/mutators/index.js +62 -49
  46. package/dist/mutators/operation/body.js +88 -57
  47. package/dist/mutators/operation/extensions.js +20 -12
  48. package/dist/mutators/operation/helpers/fetch-request-to-har.js +144 -107
  49. package/dist/mutators/operation/helpers/fetch-response-to-har.js +143 -95
  50. package/dist/mutators/operation/helpers/get-parameter-position.js +12 -12
  51. package/dist/mutators/operation/helpers/har-to-operation.js +169 -132
  52. package/dist/mutators/operation/helpers/sync-path-parameters.js +109 -60
  53. package/dist/mutators/operation/history.js +60 -64
  54. package/dist/mutators/operation/index.js +25 -49
  55. package/dist/mutators/operation/operation.js +349 -240
  56. package/dist/mutators/operation/parameters.js +157 -93
  57. package/dist/mutators/server.js +213 -152
  58. package/dist/mutators/tabs.js +173 -130
  59. package/dist/mutators/tag.js +131 -97
  60. package/dist/mutators/workspace.js +72 -42
  61. package/dist/navigation/get-navigation-options.js +97 -84
  62. package/dist/navigation/helpers/get-openapi-object.js +46 -29
  63. package/dist/navigation/helpers/get-operation-entries.js +72 -32
  64. package/dist/navigation/helpers/get-parent-entry.js +16 -12
  65. package/dist/navigation/helpers/get-tag-entries.js +56 -29
  66. package/dist/navigation/helpers/get-tag.js +22 -23
  67. package/dist/navigation/helpers/get-x-keys.js +13 -9
  68. package/dist/navigation/helpers/traverse-description.js +90 -72
  69. package/dist/navigation/helpers/traverse-document.js +111 -98
  70. package/dist/navigation/helpers/traverse-examples.js +35 -31
  71. package/dist/navigation/helpers/traverse-paths.js +118 -106
  72. package/dist/navigation/helpers/traverse-schemas.js +65 -64
  73. package/dist/navigation/helpers/traverse-tags.js +158 -129
  74. package/dist/navigation/helpers/traverse-webhooks.js +96 -90
  75. package/dist/navigation/helpers/update-order-ids.js +59 -51
  76. package/dist/navigation/helpers/utils.js +71 -21
  77. package/dist/navigation/index.js +5 -13
  78. package/dist/navigation/types.js +1 -1
  79. package/dist/persistence/index.js +283 -285
  80. package/dist/persistence/indexdb.js +263 -126
  81. package/dist/plugins/bundler/helpers.js +21 -12
  82. package/dist/plugins/bundler/index.d.ts +7 -0
  83. package/dist/plugins/bundler/index.d.ts.map +1 -1
  84. package/dist/plugins/bundler/index.js +305 -171
  85. package/dist/plugins/client/index.js +1 -5
  86. package/dist/plugins/client/persistence.js +95 -90
  87. package/dist/resolve.js +18 -25
  88. package/dist/schemas/compose.js +6 -7
  89. package/dist/schemas/extensions/document/x-internal.js +3 -7
  90. package/dist/schemas/extensions/document/x-scalar-environments.js +16 -22
  91. package/dist/schemas/extensions/document/x-scalar-icon.js +3 -7
  92. package/dist/schemas/extensions/document/x-scalar-ignore.js +3 -7
  93. package/dist/schemas/extensions/document/x-scalar-is-dirty.js +21 -8
  94. package/dist/schemas/extensions/document/x-scalar-original-document-hash.js +17 -8
  95. package/dist/schemas/extensions/document/x-scalar-registry-meta.js +15 -21
  96. package/dist/schemas/extensions/document/x-scalar-sdk-installation.js +5 -13
  97. package/dist/schemas/extensions/document/x-scalar-watch-mode.js +4 -8
  98. package/dist/schemas/extensions/document/x-tags.js +3 -7
  99. package/dist/schemas/extensions/example/x-disabled.js +17 -7
  100. package/dist/schemas/extensions/general/x-scalar-active-environment.js +4 -7
  101. package/dist/schemas/extensions/general/x-scalar-cookies.js +9 -14
  102. package/dist/schemas/extensions/general/x-scalar-order.js +8 -7
  103. package/dist/schemas/extensions/operation/index.js +4 -23
  104. package/dist/schemas/extensions/operation/x-badge.js +42 -50
  105. package/dist/schemas/extensions/operation/x-code-samples.js +8 -12
  106. package/dist/schemas/extensions/operation/x-draft-examples.js +3 -7
  107. package/dist/schemas/extensions/operation/x-post-response.js +18 -7
  108. package/dist/schemas/extensions/operation/x-scalar-disable-parameters.js +57 -13
  109. package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js +9 -7
  110. package/dist/schemas/extensions/operation/x-scalar-stability.js +15 -14
  111. package/dist/schemas/extensions/parameter/x-global.js +12 -7
  112. package/dist/schemas/extensions/schema/x-additional-properties-name.js +10 -7
  113. package/dist/schemas/extensions/schema/x-enum-descriptions.js +17 -12
  114. package/dist/schemas/extensions/schema/x-enum-varnames.js +21 -8
  115. package/dist/schemas/extensions/schema/x-examples.js +3 -7
  116. package/dist/schemas/extensions/schema/x-variable.js +3 -7
  117. package/dist/schemas/extensions/security/index.js +1 -1
  118. package/dist/schemas/extensions/security/x-default-scopes.js +16 -7
  119. package/dist/schemas/extensions/security/x-scalar-credentials-location.js +16 -7
  120. package/dist/schemas/extensions/security/x-scalar-security-body.js +14 -7
  121. package/dist/schemas/extensions/security/x-scalar-security-query.js +14 -7
  122. package/dist/schemas/extensions/security/x-scalar-security-secrets.js +66 -37
  123. package/dist/schemas/extensions/security/x-tokenName.js +11 -7
  124. package/dist/schemas/extensions/security/x-use-pkce.js +6 -10
  125. package/dist/schemas/extensions/server/x-scalar-selected-server.js +3 -7
  126. package/dist/schemas/extensions/tag/index.js +1 -1
  127. package/dist/schemas/extensions/tag/x-display-name.js +11 -7
  128. package/dist/schemas/extensions/tag/x-tag-groups.js +13 -15
  129. package/dist/schemas/extensions/workspace/index.js +2 -11
  130. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js +13 -7
  131. package/dist/schemas/extensions/workspace/x-scalar-tabs.js +15 -13
  132. package/dist/schemas/extensions.js +11 -15
  133. package/dist/schemas/inmemory-workspace.d.ts +6 -0
  134. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  135. package/dist/schemas/inmemory-workspace.js +13 -21
  136. package/dist/schemas/navigation.js +48 -85
  137. package/dist/schemas/reference-config/appearance.js +15 -22
  138. package/dist/schemas/reference-config/features.js +14 -21
  139. package/dist/schemas/reference-config/index.d.ts +2 -0
  140. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  141. package/dist/schemas/reference-config/index.js +42 -44
  142. package/dist/schemas/reference-config/meta.js +11 -18
  143. package/dist/schemas/reference-config/routing.js +7 -14
  144. package/dist/schemas/reference-config/settings.d.ts +2 -0
  145. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  146. package/dist/schemas/reference-config/settings.js +10 -17
  147. package/dist/schemas/typebox-coerce.js +23 -6
  148. package/dist/schemas/v3.1/strict/callback.js +6 -12
  149. package/dist/schemas/v3.1/strict/components.js +26 -48
  150. package/dist/schemas/v3.1/strict/contact.js +9 -12
  151. package/dist/schemas/v3.1/strict/discriminator.js +11 -10
  152. package/dist/schemas/v3.1/strict/encoding.js +15 -12
  153. package/dist/schemas/v3.1/strict/example.js +11 -13
  154. package/dist/schemas/v3.1/strict/external-documentation.js +7 -10
  155. package/dist/schemas/v3.1/strict/header.js +27 -28
  156. package/dist/schemas/v3.1/strict/info.js +10 -16
  157. package/dist/schemas/v3.1/strict/license.js +9 -12
  158. package/dist/schemas/v3.1/strict/link.js +22 -19
  159. package/dist/schemas/v3.1/strict/media-type.js +17 -16
  160. package/dist/schemas/v3.1/strict/oauth-flow.js +28 -62
  161. package/dist/schemas/v3.1/strict/oauthflows.js +14 -20
  162. package/dist/schemas/v3.1/strict/openapi-document.d.ts +70 -0
  163. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  164. package/dist/schemas/v3.1/strict/openapi-document.js +126 -210
  165. package/dist/schemas/v3.1/strict/operation.js +16 -43
  166. package/dist/schemas/v3.1/strict/parameter.d.ts +6 -0
  167. package/dist/schemas/v3.1/strict/parameter.d.ts.map +1 -1
  168. package/dist/schemas/v3.1/strict/parameter.js +29 -35
  169. package/dist/schemas/v3.1/strict/path-item.js +36 -40
  170. package/dist/schemas/v3.1/strict/paths.js +8 -11
  171. package/dist/schemas/v3.1/strict/ref-definitions.js +76 -100
  172. package/dist/schemas/v3.1/strict/reference.js +18 -21
  173. package/dist/schemas/v3.1/strict/request-body.js +8 -16
  174. package/dist/schemas/v3.1/strict/response.js +12 -16
  175. package/dist/schemas/v3.1/strict/responses.js +13 -11
  176. package/dist/schemas/v3.1/strict/schema.js +149 -157
  177. package/dist/schemas/v3.1/strict/security-requirement.js +13 -12
  178. package/dist/schemas/v3.1/strict/security-scheme.js +29 -41
  179. package/dist/schemas/v3.1/strict/server-variable.js +9 -12
  180. package/dist/schemas/v3.1/strict/server.js +10 -13
  181. package/dist/schemas/v3.1/strict/tag.js +11 -20
  182. package/dist/schemas/v3.1/strict/type-guards.js +20 -20
  183. package/dist/schemas/v3.1/strict/xml.js +17 -16
  184. package/dist/schemas/workspace-specification/index.js +11 -23
  185. package/dist/schemas/workspace-specification/info.js +4 -8
  186. package/dist/schemas/workspace.d.ts +6 -0
  187. package/dist/schemas/workspace.d.ts.map +1 -1
  188. package/dist/schemas/workspace.js +25 -51
  189. package/dist/schemas.js +2 -6
  190. package/dist/server.js +286 -176
  191. package/dist/workspace-plugin.js +1 -1
  192. package/package.json +13 -19
  193. package/dist/client.js.map +0 -7
  194. package/dist/entities/auth/index.js.map +0 -7
  195. package/dist/entities/auth/schema.js.map +0 -7
  196. package/dist/entities/history/index.js.map +0 -7
  197. package/dist/entities/history/schema.js.map +0 -7
  198. package/dist/events/bus.js.map +0 -7
  199. package/dist/events/definitions/analytics.js.map +0 -7
  200. package/dist/events/definitions/auth.js.map +0 -7
  201. package/dist/events/definitions/common.js.map +0 -7
  202. package/dist/events/definitions/cookie.js.map +0 -7
  203. package/dist/events/definitions/document.js.map +0 -7
  204. package/dist/events/definitions/environment.js.map +0 -7
  205. package/dist/events/definitions/hooks.js.map +0 -7
  206. package/dist/events/definitions/index.js.map +0 -7
  207. package/dist/events/definitions/meta.js.map +0 -7
  208. package/dist/events/definitions/operation.js.map +0 -7
  209. package/dist/events/definitions/server.js.map +0 -7
  210. package/dist/events/definitions/tabs.js.map +0 -7
  211. package/dist/events/definitions/tag.js.map +0 -7
  212. package/dist/events/definitions/ui.js.map +0 -7
  213. package/dist/events/definitions/workspace.js.map +0 -7
  214. package/dist/events/index.js.map +0 -7
  215. package/dist/events/listeners.js.map +0 -7
  216. package/dist/events/old-definitions.js.map +0 -7
  217. package/dist/helpers/apply-selective-updates.d.ts +0 -19
  218. package/dist/helpers/apply-selective-updates.d.ts.map +0 -1
  219. package/dist/helpers/apply-selective-updates.js +0 -37
  220. package/dist/helpers/apply-selective-updates.js.map +0 -7
  221. package/dist/helpers/deep-clone.js.map +0 -7
  222. package/dist/helpers/detect-changes-proxy.js.map +0 -7
  223. package/dist/helpers/general.js.map +0 -7
  224. package/dist/helpers/generate-unique-value.js.map +0 -7
  225. package/dist/helpers/get-fetch.js.map +0 -7
  226. package/dist/helpers/get-resolved-ref.js.map +0 -7
  227. package/dist/helpers/is-non-optional-security-requirement.js.map +0 -7
  228. package/dist/helpers/merge-object.js.map +0 -7
  229. package/dist/helpers/overrides-proxy.js.map +0 -7
  230. package/dist/helpers/unpack-proxy.js.map +0 -7
  231. package/dist/mutators/auth.js.map +0 -7
  232. package/dist/mutators/cookie.js.map +0 -7
  233. package/dist/mutators/document.js.map +0 -7
  234. package/dist/mutators/environment.js.map +0 -7
  235. package/dist/mutators/helpers.js.map +0 -7
  236. package/dist/mutators/index.js.map +0 -7
  237. package/dist/mutators/operation/body.js.map +0 -7
  238. package/dist/mutators/operation/extensions.js.map +0 -7
  239. package/dist/mutators/operation/helpers/fetch-request-to-har.js.map +0 -7
  240. package/dist/mutators/operation/helpers/fetch-response-to-har.js.map +0 -7
  241. package/dist/mutators/operation/helpers/get-parameter-position.js.map +0 -7
  242. package/dist/mutators/operation/helpers/har-to-operation.js.map +0 -7
  243. package/dist/mutators/operation/helpers/sync-path-parameters.js.map +0 -7
  244. package/dist/mutators/operation/history.js.map +0 -7
  245. package/dist/mutators/operation/index.js.map +0 -7
  246. package/dist/mutators/operation/operation.js.map +0 -7
  247. package/dist/mutators/operation/parameters.js.map +0 -7
  248. package/dist/mutators/server.js.map +0 -7
  249. package/dist/mutators/tabs.js.map +0 -7
  250. package/dist/mutators/tag.js.map +0 -7
  251. package/dist/mutators/workspace.js.map +0 -7
  252. package/dist/navigation/get-navigation-options.js.map +0 -7
  253. package/dist/navigation/helpers/get-openapi-object.js.map +0 -7
  254. package/dist/navigation/helpers/get-operation-entries.js.map +0 -7
  255. package/dist/navigation/helpers/get-parent-entry.js.map +0 -7
  256. package/dist/navigation/helpers/get-tag-entries.js.map +0 -7
  257. package/dist/navigation/helpers/get-tag.js.map +0 -7
  258. package/dist/navigation/helpers/get-x-keys.js.map +0 -7
  259. package/dist/navigation/helpers/traverse-description.js.map +0 -7
  260. package/dist/navigation/helpers/traverse-document.js.map +0 -7
  261. package/dist/navigation/helpers/traverse-examples.js.map +0 -7
  262. package/dist/navigation/helpers/traverse-paths.js.map +0 -7
  263. package/dist/navigation/helpers/traverse-schemas.js.map +0 -7
  264. package/dist/navigation/helpers/traverse-tags.js.map +0 -7
  265. package/dist/navigation/helpers/traverse-webhooks.js.map +0 -7
  266. package/dist/navigation/helpers/update-order-ids.js.map +0 -7
  267. package/dist/navigation/helpers/utils.js.map +0 -7
  268. package/dist/navigation/index.js.map +0 -7
  269. package/dist/navigation/types.js.map +0 -7
  270. package/dist/persistence/index.js.map +0 -7
  271. package/dist/persistence/indexdb.js.map +0 -7
  272. package/dist/plugins/bundler/helpers.js.map +0 -7
  273. package/dist/plugins/bundler/index.js.map +0 -7
  274. package/dist/plugins/client/index.js.map +0 -7
  275. package/dist/plugins/client/persistence.js.map +0 -7
  276. package/dist/resolve.js.map +0 -7
  277. package/dist/schemas/compose.js.map +0 -7
  278. package/dist/schemas/extensions/document/x-internal.js.map +0 -7
  279. package/dist/schemas/extensions/document/x-scalar-environments.js.map +0 -7
  280. package/dist/schemas/extensions/document/x-scalar-icon.js.map +0 -7
  281. package/dist/schemas/extensions/document/x-scalar-ignore.js.map +0 -7
  282. package/dist/schemas/extensions/document/x-scalar-is-dirty.js.map +0 -7
  283. package/dist/schemas/extensions/document/x-scalar-original-document-hash.js.map +0 -7
  284. package/dist/schemas/extensions/document/x-scalar-registry-meta.js.map +0 -7
  285. package/dist/schemas/extensions/document/x-scalar-sdk-installation.js.map +0 -7
  286. package/dist/schemas/extensions/document/x-scalar-watch-mode.js.map +0 -7
  287. package/dist/schemas/extensions/document/x-tags.js.map +0 -7
  288. package/dist/schemas/extensions/example/x-disabled.js.map +0 -7
  289. package/dist/schemas/extensions/general/x-scalar-active-environment.js.map +0 -7
  290. package/dist/schemas/extensions/general/x-scalar-cookies.js.map +0 -7
  291. package/dist/schemas/extensions/general/x-scalar-order.js.map +0 -7
  292. package/dist/schemas/extensions/operation/index.js.map +0 -7
  293. package/dist/schemas/extensions/operation/x-badge.js.map +0 -7
  294. package/dist/schemas/extensions/operation/x-code-samples.js.map +0 -7
  295. package/dist/schemas/extensions/operation/x-draft-examples.js.map +0 -7
  296. package/dist/schemas/extensions/operation/x-post-response.js.map +0 -7
  297. package/dist/schemas/extensions/operation/x-scalar-disable-parameters.js.map +0 -7
  298. package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js.map +0 -7
  299. package/dist/schemas/extensions/operation/x-scalar-stability.js.map +0 -7
  300. package/dist/schemas/extensions/parameter/x-global.js.map +0 -7
  301. package/dist/schemas/extensions/schema/x-additional-properties-name.js.map +0 -7
  302. package/dist/schemas/extensions/schema/x-enum-descriptions.js.map +0 -7
  303. package/dist/schemas/extensions/schema/x-enum-varnames.js.map +0 -7
  304. package/dist/schemas/extensions/schema/x-examples.js.map +0 -7
  305. package/dist/schemas/extensions/schema/x-variable.js.map +0 -7
  306. package/dist/schemas/extensions/security/index.js.map +0 -7
  307. package/dist/schemas/extensions/security/x-default-scopes.js.map +0 -7
  308. package/dist/schemas/extensions/security/x-scalar-credentials-location.js.map +0 -7
  309. package/dist/schemas/extensions/security/x-scalar-security-body.js.map +0 -7
  310. package/dist/schemas/extensions/security/x-scalar-security-query.js.map +0 -7
  311. package/dist/schemas/extensions/security/x-scalar-security-secrets.js.map +0 -7
  312. package/dist/schemas/extensions/security/x-tokenName.js.map +0 -7
  313. package/dist/schemas/extensions/security/x-use-pkce.js.map +0 -7
  314. package/dist/schemas/extensions/server/x-scalar-selected-server.js.map +0 -7
  315. package/dist/schemas/extensions/tag/index.js.map +0 -7
  316. package/dist/schemas/extensions/tag/x-display-name.js.map +0 -7
  317. package/dist/schemas/extensions/tag/x-tag-groups.js.map +0 -7
  318. package/dist/schemas/extensions/workspace/index.js.map +0 -7
  319. package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js.map +0 -7
  320. package/dist/schemas/extensions/workspace/x-scalar-tabs.js.map +0 -7
  321. package/dist/schemas/extensions.js.map +0 -7
  322. package/dist/schemas/inmemory-workspace.js.map +0 -7
  323. package/dist/schemas/navigation.js.map +0 -7
  324. package/dist/schemas/reference-config/appearance.js.map +0 -7
  325. package/dist/schemas/reference-config/features.js.map +0 -7
  326. package/dist/schemas/reference-config/index.js.map +0 -7
  327. package/dist/schemas/reference-config/meta.js.map +0 -7
  328. package/dist/schemas/reference-config/routing.js.map +0 -7
  329. package/dist/schemas/reference-config/settings.js.map +0 -7
  330. package/dist/schemas/typebox-coerce.js.map +0 -7
  331. package/dist/schemas/v3.1/strict/callback.js.map +0 -7
  332. package/dist/schemas/v3.1/strict/components.js.map +0 -7
  333. package/dist/schemas/v3.1/strict/contact.js.map +0 -7
  334. package/dist/schemas/v3.1/strict/discriminator.js.map +0 -7
  335. package/dist/schemas/v3.1/strict/encoding.js.map +0 -7
  336. package/dist/schemas/v3.1/strict/example.js.map +0 -7
  337. package/dist/schemas/v3.1/strict/external-documentation.js.map +0 -7
  338. package/dist/schemas/v3.1/strict/header.js.map +0 -7
  339. package/dist/schemas/v3.1/strict/info.js.map +0 -7
  340. package/dist/schemas/v3.1/strict/license.js.map +0 -7
  341. package/dist/schemas/v3.1/strict/link.js.map +0 -7
  342. package/dist/schemas/v3.1/strict/media-type.js.map +0 -7
  343. package/dist/schemas/v3.1/strict/oauth-flow.js.map +0 -7
  344. package/dist/schemas/v3.1/strict/oauthflows.js.map +0 -7
  345. package/dist/schemas/v3.1/strict/openapi-document.js.map +0 -7
  346. package/dist/schemas/v3.1/strict/operation.js.map +0 -7
  347. package/dist/schemas/v3.1/strict/parameter.js.map +0 -7
  348. package/dist/schemas/v3.1/strict/path-item.js.map +0 -7
  349. package/dist/schemas/v3.1/strict/paths.js.map +0 -7
  350. package/dist/schemas/v3.1/strict/ref-definitions.js.map +0 -7
  351. package/dist/schemas/v3.1/strict/reference.js.map +0 -7
  352. package/dist/schemas/v3.1/strict/request-body.js.map +0 -7
  353. package/dist/schemas/v3.1/strict/response.js.map +0 -7
  354. package/dist/schemas/v3.1/strict/responses.js.map +0 -7
  355. package/dist/schemas/v3.1/strict/schema.js.map +0 -7
  356. package/dist/schemas/v3.1/strict/security-requirement.js.map +0 -7
  357. package/dist/schemas/v3.1/strict/security-scheme.js.map +0 -7
  358. package/dist/schemas/v3.1/strict/server-variable.js.map +0 -7
  359. package/dist/schemas/v3.1/strict/server.js.map +0 -7
  360. package/dist/schemas/v3.1/strict/tag.js.map +0 -7
  361. package/dist/schemas/v3.1/strict/type-guards.js.map +0 -7
  362. package/dist/schemas/v3.1/strict/xml.js.map +0 -7
  363. package/dist/schemas/workspace-specification/index.js.map +0 -7
  364. package/dist/schemas/workspace-specification/info.js.map +0 -7
  365. package/dist/schemas/workspace.js.map +0 -7
  366. package/dist/schemas.js.map +0 -7
  367. package/dist/server.js.map +0 -7
  368. package/dist/workspace-plugin.js.map +0 -7
package/dist/server.js CHANGED
@@ -1,192 +1,302 @@
1
- import fs from "node:fs/promises";
2
- import { cwd } from "node:process";
3
- import { parseJsonPointerSegments } from "@scalar/helpers/json/parse-json-pointer-segments";
4
- import { getValueAtPath } from "@scalar/helpers/object/get-value-at-path";
5
- import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
6
- import { escapeJsonPointer } from "@scalar/json-magic/helpers/escape-json-pointer";
7
- import { upgrade } from "@scalar/openapi-upgrader";
8
- import { keyOf } from "./helpers/general.js";
9
- import { createNavigation } from "./navigation/index.js";
10
- import { extensions } from "./schemas/extensions.js";
11
- import { coerceValue } from "./schemas/typebox-coerce.js";
12
- import {
13
- OpenAPIDocumentSchema
14
- } from "./schemas/v3.1/strict/openapi-document.js";
15
- const DEFAULT_ASSETS_FOLDER = "assets";
16
- const WORKSPACE_FILE_NAME = "scalar-workspace.json";
17
- const httpMethods = /* @__PURE__ */ new Set(["get", "put", "post", "delete", "options", "head", "patch", "trace"]);
18
- function filterHttpMethodsOnly(paths) {
19
- const result = {};
20
- for (const [path, methods] of Object.entries(paths)) {
21
- if (!methods) {
22
- continue;
23
- }
24
- const filteredMethods = {};
25
- for (const [method, operation] of Object.entries(methods)) {
26
- if (httpMethods.has(method.toLowerCase())) {
27
- filteredMethods[method] = operation;
28
- }
29
- }
30
- if (Object.keys(filteredMethods).length > 0) {
31
- result[path] = filteredMethods;
32
- }
33
- }
34
- return result;
35
- }
36
- function escapePaths(paths) {
37
- const result = {};
38
- Object.keys(paths).forEach((path) => {
39
- if (paths[path]) {
40
- result[escapeJsonPointer(path)] = paths[path];
1
+ import fs from 'node:fs/promises';
2
+ import { cwd } from 'node:process';
3
+ import { parseJsonPointerSegments } from '@scalar/helpers/json/parse-json-pointer-segments';
4
+ import { getValueAtPath } from '@scalar/helpers/object/get-value-at-path';
5
+ import { fetchUrls, readFiles } from '@scalar/json-magic/bundle/plugins/node';
6
+ import { escapeJsonPointer } from '@scalar/json-magic/helpers/escape-json-pointer';
7
+ import { upgrade } from '@scalar/openapi-upgrader';
8
+ import { keyOf } from './helpers/general.js';
9
+ import { createNavigation } from './navigation/index.js';
10
+ 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
+ const DEFAULT_ASSETS_FOLDER = 'assets';
14
+ export const WORKSPACE_FILE_NAME = 'scalar-workspace.json';
15
+ const httpMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']);
16
+ /**
17
+ * Filters an OpenAPI PathsObject to only include standard HTTP methods.
18
+ * Removes any vendor extensions or other non-HTTP properties.
19
+ *
20
+ * @param paths - The OpenAPI PathsObject to filter
21
+ * @returns A new PathsObject containing only standard HTTP methods
22
+ *
23
+ * @example
24
+ * Input: {
25
+ * "/users": {
26
+ * "get": {...},
27
+ * "x-custom": {...},
28
+ * "post": {...}
29
+ * }
30
+ * }
31
+ * Output: {
32
+ * "/users": {
33
+ * "get": {...},
34
+ * "post": {...}
35
+ * }
36
+ * }
37
+ */
38
+ export function filterHttpMethodsOnly(paths) {
39
+ const result = {};
40
+ // Todo: skip extension properties
41
+ for (const [path, methods] of Object.entries(paths)) {
42
+ if (!methods) {
43
+ continue;
44
+ }
45
+ const filteredMethods = {};
46
+ for (const [method, operation] of Object.entries(methods)) {
47
+ if (httpMethods.has(method.toLowerCase())) {
48
+ filteredMethods[method] = operation;
49
+ }
50
+ }
51
+ if (Object.keys(filteredMethods).length > 0) {
52
+ result[path] = filteredMethods;
53
+ }
41
54
  }
42
- });
43
- return result;
55
+ return result;
44
56
  }
45
- function externalizeComponentReferences(document, meta) {
46
- const result = {};
47
- if (!document.components) {
57
+ /**
58
+ * Escapes path keys in an OpenAPI PathsObject to be JSON Pointer compatible.
59
+ * This is necessary because OpenAPI paths can contain characters that need to be escaped
60
+ * when used as JSON Pointer references (like '/' and '~').
61
+ *
62
+ * @example
63
+ * Input: { "/users/{id}": { ... } }
64
+ * Output: { "/users~1{id}": { ... } }
65
+ */
66
+ export function escapePaths(paths) {
67
+ const result = {};
68
+ Object.keys(paths).forEach((path) => {
69
+ if (paths[path]) {
70
+ result[escapeJsonPointer(path)] = paths[path];
71
+ }
72
+ });
48
73
  return result;
49
- }
50
- Object.entries(document.components).forEach(([type, component]) => {
51
- if (!component || typeof component !== "object") {
52
- return;
74
+ }
75
+ /**
76
+ * Externalizes components by turning them into refs.
77
+ */
78
+ export function externalizeComponentReferences(document, meta) {
79
+ const result = {};
80
+ if (!document.components) {
81
+ return result;
53
82
  }
54
- result[type] = {};
55
- Object.keys(component).forEach((name) => {
56
- const ref = meta.mode === "ssr" ? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#` : `./chunks/${meta.name}/components/${type}/${name}.json#`;
57
- result[type][name] = { "$ref": ref, $global: true };
83
+ Object.entries(document.components).forEach(([type, component]) => {
84
+ if (!component || typeof component !== 'object') {
85
+ return;
86
+ }
87
+ result[type] = {};
88
+ Object.keys(component).forEach((name) => {
89
+ const ref = meta.mode === 'ssr'
90
+ ? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#`
91
+ : `./chunks/${meta.name}/components/${type}/${name}.json#`;
92
+ result[type][name] = { '$ref': ref, $global: true };
93
+ });
58
94
  });
59
- });
60
- return result;
61
- }
62
- function externalizePathReferences(document, meta) {
63
- const result = {};
64
- if (!document.paths) {
65
95
  return result;
66
- }
67
- Object.entries(document.paths).forEach(([path, pathItem]) => {
68
- if (!pathItem || typeof pathItem !== "object") {
69
- return;
96
+ }
97
+ /**
98
+ * Externalizes paths operations by turning them into refs.
99
+ */
100
+ export function externalizePathReferences(document, meta) {
101
+ const result = {};
102
+ if (!document.paths) {
103
+ return result;
70
104
  }
71
- const pathItemRecord = pathItem;
72
- result[path] = {};
73
- const escapedPath = escapeJsonPointer(path);
74
- keyOf(pathItemRecord).forEach((type) => {
75
- if (httpMethods.has(type)) {
76
- const ref = meta.mode === "ssr" ? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${type}#` : `./chunks/${meta.name}/operations/${escapedPath}/${type}.json#`;
77
- result[path][type] = { "$ref": ref, $global: true };
78
- } else {
79
- result[path][type] = pathItemRecord[type];
80
- }
105
+ Object.entries(document.paths).forEach(([path, pathItem]) => {
106
+ if (!pathItem || typeof pathItem !== 'object') {
107
+ return;
108
+ }
109
+ const pathItemRecord = pathItem;
110
+ result[path] = {};
111
+ const escapedPath = escapeJsonPointer(path);
112
+ keyOf(pathItemRecord).forEach((type) => {
113
+ if (httpMethods.has(type)) {
114
+ const ref = meta.mode === 'ssr'
115
+ ? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${type}#`
116
+ : `./chunks/${meta.name}/operations/${escapedPath}/${type}.json#`;
117
+ result[path][type] = { '$ref': ref, $global: true };
118
+ }
119
+ else {
120
+ result[path][type] = pathItemRecord[type];
121
+ }
122
+ });
81
123
  });
82
- });
83
- return result;
124
+ return result;
84
125
  }
126
+ /**
127
+ * Resolves a workspace document from various input sources (URL, local file, or direct document object).
128
+ *
129
+ * @param workspaceDocument - The document input to resolve, which can be:
130
+ * - A URL to fetch the document from
131
+ * - A local file path to read the document from
132
+ * - A direct document object
133
+ * @returns A promise that resolves to an object containing:
134
+ * - ok: boolean indicating if the resolution was successful
135
+ * - data: The resolved document data
136
+ *
137
+ * @example
138
+ * // Resolve from URL
139
+ * const urlDoc = await loadDocument({ name: 'api', url: 'https://api.example.com/openapi.json' })
140
+ *
141
+ * // Resolve direct document
142
+ * const directDoc = await loadDocument({
143
+ * name: 'inline',
144
+ * document: { openapi: '3.0.0', paths: {} }
145
+ * })
146
+ */
85
147
  function loadDocument(workspaceDocument) {
86
- if ("url" in workspaceDocument) {
87
- return fetchUrls().exec(workspaceDocument.url);
88
- }
89
- if ("path" in workspaceDocument) {
90
- return readFiles().exec(workspaceDocument.path);
91
- }
92
- return Promise.resolve({
93
- ok: true,
94
- data: workspaceDocument.document,
95
- raw: JSON.stringify(workspaceDocument.document)
96
- });
148
+ if ('url' in workspaceDocument) {
149
+ return fetchUrls().exec(workspaceDocument.url);
150
+ }
151
+ if ('path' in workspaceDocument) {
152
+ return readFiles().exec(workspaceDocument.path);
153
+ }
154
+ return Promise.resolve({
155
+ ok: true,
156
+ data: workspaceDocument.document,
157
+ raw: JSON.stringify(workspaceDocument.document),
158
+ });
97
159
  }
98
- async function createServerWorkspaceStore(workspaceProps) {
99
- const workspace = {
100
- ...workspaceProps.meta,
101
- documents: {}
102
- };
103
- const assets = {};
104
- const addDocumentSync = (document, meta, navigationOptions) => {
105
- const { name, ...documentMeta } = meta;
106
- const documentV3 = coerceValue(OpenAPIDocumentSchema, upgrade(document, "3.1"));
107
- assets[meta.name] = {
108
- components: documentV3.components,
109
- operations: documentV3.paths && escapePaths(filterHttpMethodsOnly(documentV3.paths))
160
+ /**
161
+ * Create server state workspace store
162
+ */
163
+ export async function createServerWorkspaceStore(workspaceProps) {
164
+ /**
165
+ * Base workspace document containing essential metadata and document references.
166
+ *
167
+ * This workspace document provides the minimal information needed for initial rendering.
168
+ * All components and path operations are replaced with references to enable lazy loading.
169
+ *
170
+ * In SSR mode, references point to API endpoints.
171
+ * In static mode, references point to filesystem chunks.
172
+ */
173
+ const workspace = {
174
+ ...workspaceProps.meta,
175
+ documents: {},
110
176
  };
111
- const options = workspaceProps.mode === "ssr" ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl } : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER };
112
- const components = externalizeComponentReferences(documentV3, options);
113
- const paths = externalizePathReferences(documentV3, options);
114
- const navigation = createNavigation(name, documentV3, navigationOptions ?? workspaceProps.navigationOptions);
115
- workspace.documents[meta.name] = {
116
- ...documentMeta,
117
- ...documentV3,
118
- components,
119
- paths,
120
- [extensions.document.navigation]: navigation
177
+ /**
178
+ * A map of document chunks that can be loaded asynchronously by the client.
179
+ * Each document is split into components and operations to enable lazy loading.
180
+ * The keys are document names and values contain the components and operations
181
+ * for that document.
182
+ */
183
+ const assets = {};
184
+ /**
185
+ * Adds a new document to the workspace.
186
+ *
187
+ * This function processes an OpenAPI document by:
188
+ * 1. Converting it to OpenAPI 3.1 format if needed
189
+ * 2. Separating it into reusable components and path operations
190
+ * 3. Externalizing references based on the workspace mode (SSR or static)
191
+ * 4. Adding the processed document to the workspace with its metadata
192
+ *
193
+ * The resulting document contains minimal information with externalized references
194
+ * that will be resolved on-demand through the workspace's get() method.
195
+ *
196
+ * @param document - The OpenAPI document to process and add
197
+ * @param meta - Document metadata containing the required name and optional settings
198
+ */
199
+ const addDocumentSync = (document, meta, navigationOptions) => {
200
+ const { name, ...documentMeta } = meta;
201
+ const documentV3 = coerceValue(OpenAPIDocumentSchema, upgrade(document, '3.1'));
202
+ // add the assets
203
+ assets[meta.name] = {
204
+ components: documentV3.components,
205
+ operations: documentV3.paths && escapePaths(filterHttpMethodsOnly(documentV3.paths)),
206
+ };
207
+ const options = workspaceProps.mode === 'ssr'
208
+ ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl }
209
+ : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER };
210
+ const components = externalizeComponentReferences(documentV3, options);
211
+ const paths = externalizePathReferences(documentV3, options);
212
+ // Build the sidebar entries
213
+ const navigation = createNavigation(name, documentV3, navigationOptions ?? workspaceProps.navigationOptions);
214
+ // The document is now a minimal version with externalized references to components and operations.
215
+ // These references will be resolved asynchronously when needed through the workspace's get() method.
216
+ workspace.documents[meta.name] = {
217
+ ...documentMeta,
218
+ ...documentV3,
219
+ components,
220
+ paths,
221
+ [extensions.document.navigation]: navigation,
222
+ };
121
223
  };
122
- };
123
- const addDocument = async (input, navigationOptions) => {
124
- const document = await loadDocument(input);
125
- if (!document.ok) {
126
- console.warn(`Failed to load document "${input.name}`);
127
- return;
128
- }
129
- addDocumentSync(document.data, { name: input.name, ...input.meta }, navigationOptions);
130
- };
131
- await Promise.all(workspaceProps.documents.map((document) => addDocument(document)));
132
- return {
133
- generateWorkspaceChunks: async () => {
134
- if (workspaceProps.mode !== "static") {
135
- throw "Mode has to be set to `static` to generate filesystem workspace chunks";
136
- }
137
- const basePath = `${cwd()}/${workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER}`;
138
- await fs.mkdir(basePath, { recursive: true });
139
- await fs.writeFile(`${basePath}/${WORKSPACE_FILE_NAME}`, JSON.stringify(workspace));
140
- for (const [name, { components, operations }] of Object.entries(assets)) {
141
- if (components) {
142
- for (const [type, component] of Object.entries(components)) {
143
- const componentPath = `${basePath}/chunks/${name}/components/${type}`;
144
- await fs.mkdir(componentPath, { recursive: true });
145
- for (const [key, value] of Object.entries(component)) {
146
- await fs.writeFile(`${componentPath}/${key}.json`, JSON.stringify(value));
147
- }
148
- }
224
+ /**
225
+ * Adds a new document to the workspace asynchronously.
226
+ *
227
+ * This function:
228
+ * 1. Loads the document using the provided input
229
+ * 2. Checks if the document loaded successfully
230
+ * 3. If successful, adds the document to the workspace using addDocumentSync
231
+ *
232
+ * @param input - The document input containing the document source and metadata
233
+ */
234
+ const addDocument = async (input, navigationOptions) => {
235
+ const document = await loadDocument(input);
236
+ if (!document.ok) {
237
+ console.warn(`Failed to load document "${input.name}`);
238
+ return;
149
239
  }
150
- if (operations) {
151
- for (const [path, methods] of Object.entries(operations)) {
152
- const operationPath = `${basePath}/chunks/${name}/operations/${path}`;
153
- await fs.mkdir(operationPath, { recursive: true });
154
- for (const [method, operation] of Object.entries(methods)) {
155
- await fs.writeFile(`${operationPath}/${method}.json`, JSON.stringify(operation));
240
+ addDocumentSync(document.data, { name: input.name, ...input.meta }, navigationOptions);
241
+ };
242
+ // Load and process all initial documents in parallel
243
+ await Promise.all(workspaceProps.documents.map((document) => addDocument(document)));
244
+ return {
245
+ generateWorkspaceChunks: async () => {
246
+ if (workspaceProps.mode !== 'static') {
247
+ throw 'Mode has to be set to `static` to generate filesystem workspace chunks';
156
248
  }
157
- }
158
- }
159
- }
160
- },
161
- getWorkspace: () => {
162
- return workspace;
163
- },
164
- get: (pointer) => {
165
- const pointerPath = (() => {
166
- if (pointer.startsWith("#")) {
167
- return pointer.slice(1);
168
- }
169
- if (pointer.startsWith("/")) {
170
- return pointer;
171
- }
172
- try {
173
- return new URL(pointer).pathname;
174
- } catch {
175
- return pointer;
176
- }
177
- })();
178
- const path = parseJsonPointerSegments(pointerPath).map(escapeJsonPointer);
179
- return getValueAtPath(assets, path);
180
- },
181
- addDocument
182
- };
249
+ // Write the workspace document
250
+ const basePath = `${cwd()}/${workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER}`;
251
+ await fs.mkdir(basePath, { recursive: true });
252
+ // Write the workspace contents on the file system
253
+ await fs.writeFile(`${basePath}/${WORKSPACE_FILE_NAME}`, JSON.stringify(workspace));
254
+ // Write the chunks
255
+ for (const [name, { components, operations }] of Object.entries(assets)) {
256
+ // Write the components chunks
257
+ if (components) {
258
+ for (const [type, component] of Object.entries(components)) {
259
+ const componentPath = `${basePath}/chunks/${name}/components/${type}`;
260
+ await fs.mkdir(componentPath, { recursive: true });
261
+ for (const [key, value] of Object.entries(component)) {
262
+ await fs.writeFile(`${componentPath}/${key}.json`, JSON.stringify(value));
263
+ }
264
+ }
265
+ }
266
+ // Write the operations chunks
267
+ if (operations) {
268
+ for (const [path, methods] of Object.entries(operations)) {
269
+ const operationPath = `${basePath}/chunks/${name}/operations/${path}`;
270
+ await fs.mkdir(operationPath, { recursive: true });
271
+ for (const [method, operation] of Object.entries(methods)) {
272
+ await fs.writeFile(`${operationPath}/${method}.json`, JSON.stringify(operation));
273
+ }
274
+ }
275
+ }
276
+ }
277
+ },
278
+ getWorkspace: () => {
279
+ return workspace;
280
+ },
281
+ get: (pointer) => {
282
+ const pointerPath = (() => {
283
+ if (pointer.startsWith('#')) {
284
+ return pointer.slice(1);
285
+ }
286
+ if (pointer.startsWith('/')) {
287
+ return pointer;
288
+ }
289
+ try {
290
+ return new URL(pointer).pathname;
291
+ }
292
+ catch {
293
+ return pointer;
294
+ }
295
+ })();
296
+ // Keep the path segments escaped cuz we store them on the filesystem as escaped sequences
297
+ const path = parseJsonPointerSegments(pointerPath).map(escapeJsonPointer);
298
+ return getValueAtPath(assets, path);
299
+ },
300
+ addDocument,
301
+ };
183
302
  }
184
- export {
185
- WORKSPACE_FILE_NAME,
186
- createServerWorkspaceStore,
187
- escapePaths,
188
- externalizeComponentReferences,
189
- externalizePathReferences,
190
- filterHttpMethodsOnly
191
- };
192
- //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- //# sourceMappingURL=workspace-plugin.js.map
1
+ export {};
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "openapi",
17
17
  "scalar"
18
18
  ],
19
- "version": "0.40.2",
19
+ "version": "0.40.4",
20
20
  "engines": {
21
21
  "node": ">=22"
22
22
  },
@@ -138,31 +138,25 @@
138
138
  "type-fest": "^5.3.1",
139
139
  "vue": "^3.5.26",
140
140
  "yaml": "^2.8.0",
141
- "@scalar/helpers": "0.4.1",
142
- "@scalar/code-highlight": "0.3.0",
143
- "@scalar/json-magic": "0.12.3",
144
- "@scalar/openapi-upgrader": "0.2.0",
145
- "@scalar/snippetz": "0.7.4",
146
- "@scalar/types": "0.7.3",
147
- "@scalar/object-utils": "1.3.2"
141
+ "@scalar/code-highlight": "0.3.1",
142
+ "@scalar/helpers": "0.4.2",
143
+ "@scalar/json-magic": "0.12.4",
144
+ "@scalar/object-utils": "1.3.3",
145
+ "@scalar/snippetz": "0.7.6",
146
+ "@scalar/types": "0.7.4",
147
+ "@scalar/openapi-upgrader": "0.2.2"
148
148
  },
149
149
  "devDependencies": {
150
150
  "@google-cloud/storage": "7.16.0",
151
151
  "fake-indexeddb": "6.2.3",
152
152
  "fastify": "^5.3.3",
153
- "vite": "^7.3.1",
154
- "vitest": "4.0.16",
155
- "@scalar/build-tooling": "0.5.0"
153
+ "vite": "8.0.0",
154
+ "vitest": "4.1.0"
156
155
  },
157
156
  "scripts": {
158
- "build": "scalar-build-esbuild",
159
- "format": "scalar-format",
160
- "format:check": "scalar-format-check",
161
- "generate-json-schemas": "vite-node ./scripts/generate-json-schemas.ts",
162
- "lint:check": "scalar-lint-check",
163
- "lint:fix": "scalar-lint-fix",
157
+ "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
158
+ "generate-json-schemas": "tsx ./scripts/generate-json-schemas.ts",
164
159
  "test": "vitest",
165
- "types:build": "scalar-types-build",
166
- "types:check": "scalar-types-check"
160
+ "types:check": "tsc --noEmit"
167
161
  }
168
162
  }