@scalar/blocks 0.4.3 → 0.5.0

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 (341) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +45 -0
  3. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
  4. package/dist/code-example/helpers/operation-to-har/operation-to-har.js +1 -0
  5. package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
  6. package/dist/code-example/helpers/operation-to-har/process-body.d.ts.map +1 -1
  7. package/dist/code-example/helpers/operation-to-har/process-body.js +51 -45
  8. package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
  9. package/dist/constants.js +1 -1
  10. package/dist/schema/LinkButton.vue.d.ts +14 -0
  11. package/dist/schema/LinkButton.vue.d.ts.map +1 -0
  12. package/dist/schema/LinkButton.vue.js +15 -0
  13. package/dist/schema/LinkButton.vue.js.map +1 -0
  14. package/dist/schema/RenderString.vue.d.ts +7 -0
  15. package/dist/schema/RenderString.vue.d.ts.map +1 -0
  16. package/dist/schema/RenderString.vue.js +7 -0
  17. package/dist/schema/RenderString.vue.js.map +1 -0
  18. package/dist/schema/RenderString.vue.script.js +14 -0
  19. package/dist/schema/RenderString.vue.script.js.map +1 -0
  20. package/dist/schema/Schema.vue.d.ts +50 -0
  21. package/dist/schema/Schema.vue.d.ts.map +1 -0
  22. package/dist/schema/Schema.vue.js +9 -0
  23. package/dist/schema/Schema.vue.js.map +1 -0
  24. package/dist/schema/Schema.vue.script.js +234 -0
  25. package/dist/schema/Schema.vue.script.js.map +1 -0
  26. package/dist/schema/SchemaCollapsedPreview.vue.d.ts +17 -0
  27. package/dist/schema/SchemaCollapsedPreview.vue.d.ts.map +1 -0
  28. package/dist/schema/SchemaCollapsedPreview.vue.js +7 -0
  29. package/dist/schema/SchemaCollapsedPreview.vue.js.map +1 -0
  30. package/dist/schema/SchemaCollapsedPreview.vue.script.js +28 -0
  31. package/dist/schema/SchemaCollapsedPreview.vue.script.js.map +1 -0
  32. package/dist/schema/SchemaComposition.vue.d.ts +42 -0
  33. package/dist/schema/SchemaComposition.vue.d.ts.map +1 -0
  34. package/dist/schema/SchemaComposition.vue.js +9 -0
  35. package/dist/schema/SchemaComposition.vue.js.map +1 -0
  36. package/dist/schema/SchemaComposition.vue.script.js +231 -0
  37. package/dist/schema/SchemaComposition.vue.script.js.map +1 -0
  38. package/dist/schema/SchemaEnumPropertyItem.vue.d.ts +8 -0
  39. package/dist/schema/SchemaEnumPropertyItem.vue.d.ts.map +1 -0
  40. package/dist/schema/SchemaEnumPropertyItem.vue.js +7 -0
  41. package/dist/schema/SchemaEnumPropertyItem.vue.js.map +1 -0
  42. package/dist/schema/SchemaEnumPropertyItem.vue.script.js +24 -0
  43. package/dist/schema/SchemaEnumPropertyItem.vue.script.js.map +1 -0
  44. package/dist/schema/SchemaEnums.vue.d.ts +11 -0
  45. package/dist/schema/SchemaEnums.vue.d.ts.map +1 -0
  46. package/dist/schema/SchemaEnums.vue.js +9 -0
  47. package/dist/schema/SchemaEnums.vue.js.map +1 -0
  48. package/dist/schema/SchemaEnums.vue.script.js +78 -0
  49. package/dist/schema/SchemaEnums.vue.script.js.map +1 -0
  50. package/dist/schema/SchemaGlyphPuck.vue.d.ts +33 -0
  51. package/dist/schema/SchemaGlyphPuck.vue.d.ts.map +1 -0
  52. package/dist/schema/SchemaGlyphPuck.vue.js +7 -0
  53. package/dist/schema/SchemaGlyphPuck.vue.js.map +1 -0
  54. package/dist/schema/SchemaGlyphPuck.vue.script.js +30 -0
  55. package/dist/schema/SchemaGlyphPuck.vue.script.js.map +1 -0
  56. package/dist/schema/SchemaGutterToggle.vue.d.ts +32 -0
  57. package/dist/schema/SchemaGutterToggle.vue.d.ts.map +1 -0
  58. package/dist/schema/SchemaGutterToggle.vue.js +7 -0
  59. package/dist/schema/SchemaGutterToggle.vue.js.map +1 -0
  60. package/dist/schema/SchemaGutterToggle.vue.script.js +43 -0
  61. package/dist/schema/SchemaGutterToggle.vue.script.js.map +1 -0
  62. package/dist/schema/SchemaHeading.vue.d.ts +9 -0
  63. package/dist/schema/SchemaHeading.vue.d.ts.map +1 -0
  64. package/dist/schema/SchemaHeading.vue.js +9 -0
  65. package/dist/schema/SchemaHeading.vue.js.map +1 -0
  66. package/dist/schema/SchemaHeading.vue.script.js +35 -0
  67. package/dist/schema/SchemaHeading.vue.script.js.map +1 -0
  68. package/dist/schema/SchemaObjectExampleCodeBlock.vue.d.ts +8 -0
  69. package/dist/schema/SchemaObjectExampleCodeBlock.vue.d.ts.map +1 -0
  70. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js +7 -0
  71. package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -0
  72. package/dist/schema/SchemaObjectExampleCodeBlock.vue.script.js +48 -0
  73. package/dist/schema/SchemaObjectExampleCodeBlock.vue.script.js.map +1 -0
  74. package/dist/schema/SchemaObjectProperties.vue.d.ts +22 -0
  75. package/dist/schema/SchemaObjectProperties.vue.d.ts.map +1 -0
  76. package/dist/schema/SchemaObjectProperties.vue.js +7 -0
  77. package/dist/schema/SchemaObjectProperties.vue.js.map +1 -0
  78. package/dist/schema/SchemaObjectProperties.vue.script.js +207 -0
  79. package/dist/schema/SchemaObjectProperties.vue.script.js.map +1 -0
  80. package/dist/schema/SchemaProperty.vue.d.ts +88 -0
  81. package/dist/schema/SchemaProperty.vue.d.ts.map +1 -0
  82. package/dist/schema/SchemaProperty.vue.js +9 -0
  83. package/dist/schema/SchemaProperty.vue.js.map +1 -0
  84. package/dist/schema/SchemaProperty.vue.script.js +456 -0
  85. package/dist/schema/SchemaProperty.vue.script.js.map +1 -0
  86. package/dist/schema/SchemaPropertyDefault.vue.d.ts +7 -0
  87. package/dist/schema/SchemaPropertyDefault.vue.d.ts.map +1 -0
  88. package/dist/schema/SchemaPropertyDefault.vue.js +9 -0
  89. package/dist/schema/SchemaPropertyDefault.vue.js.map +1 -0
  90. package/dist/schema/SchemaPropertyDefault.vue.script.js +64 -0
  91. package/dist/schema/SchemaPropertyDefault.vue.script.js.map +1 -0
  92. package/dist/schema/SchemaPropertyDetail.vue.d.ts +22 -0
  93. package/dist/schema/SchemaPropertyDetail.vue.d.ts.map +1 -0
  94. package/dist/schema/SchemaPropertyDetail.vue.js +9 -0
  95. package/dist/schema/SchemaPropertyDetail.vue.js.map +1 -0
  96. package/dist/schema/SchemaPropertyDetail.vue.script.js +25 -0
  97. package/dist/schema/SchemaPropertyDetail.vue.script.js.map +1 -0
  98. package/dist/schema/SchemaPropertyExamples.vue.d.ts +8 -0
  99. package/dist/schema/SchemaPropertyExamples.vue.d.ts.map +1 -0
  100. package/dist/schema/SchemaPropertyExamples.vue.js +9 -0
  101. package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -0
  102. package/dist/schema/SchemaPropertyExamples.vue.script.js +125 -0
  103. package/dist/schema/SchemaPropertyExamples.vue.script.js.map +1 -0
  104. package/dist/schema/SchemaPropertyHeading.vue.d.ts +59 -0
  105. package/dist/schema/SchemaPropertyHeading.vue.d.ts.map +1 -0
  106. package/dist/schema/SchemaPropertyHeading.vue.js +9 -0
  107. package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -0
  108. package/dist/schema/SchemaPropertyHeading.vue.script.js +270 -0
  109. package/dist/schema/SchemaPropertyHeading.vue.script.js.map +1 -0
  110. package/dist/schema/SchemaPropertyPattern.vue.d.ts +7 -0
  111. package/dist/schema/SchemaPropertyPattern.vue.d.ts.map +1 -0
  112. package/dist/schema/SchemaPropertyPattern.vue.js +9 -0
  113. package/dist/schema/SchemaPropertyPattern.vue.js.map +1 -0
  114. package/dist/schema/SchemaPropertyPattern.vue.script.js +45 -0
  115. package/dist/schema/SchemaPropertyPattern.vue.script.js.map +1 -0
  116. package/dist/schema/SchemaRailPanel.vue.d.ts +35 -0
  117. package/dist/schema/SchemaRailPanel.vue.d.ts.map +1 -0
  118. package/dist/schema/SchemaRailPanel.vue.js +7 -0
  119. package/dist/schema/SchemaRailPanel.vue.js.map +1 -0
  120. package/dist/schema/SchemaRailPanel.vue.script.js +49 -0
  121. package/dist/schema/SchemaRailPanel.vue.script.js.map +1 -0
  122. package/dist/schema/components/CopyLinkButton.vue.d.ts +27 -0
  123. package/dist/schema/components/CopyLinkButton.vue.d.ts.map +1 -0
  124. package/dist/schema/components/CopyLinkButton.vue.js +7 -0
  125. package/dist/schema/components/CopyLinkButton.vue.js.map +1 -0
  126. package/dist/schema/components/CopyLinkButton.vue.script.js +26 -0
  127. package/dist/schema/components/CopyLinkButton.vue.script.js.map +1 -0
  128. package/dist/schema/components/WithBreadcrumb.vue.d.ts +19 -0
  129. package/dist/schema/components/WithBreadcrumb.vue.d.ts.map +1 -0
  130. package/dist/schema/components/WithBreadcrumb.vue.js +7 -0
  131. package/dist/schema/components/WithBreadcrumb.vue.js.map +1 -0
  132. package/dist/schema/components/WithBreadcrumb.vue.script.js +18 -0
  133. package/dist/schema/components/WithBreadcrumb.vue.script.js.map +1 -0
  134. package/dist/schema/expansion/index.d.ts +2 -0
  135. package/dist/schema/expansion/index.d.ts.map +1 -0
  136. package/dist/schema/expansion/index.js +2 -0
  137. package/dist/schema/helpers/dynamic-scope.d.ts +27 -0
  138. package/dist/schema/helpers/dynamic-scope.d.ts.map +1 -0
  139. package/dist/schema/helpers/dynamic-scope.js +8 -0
  140. package/dist/schema/helpers/dynamic-scope.js.map +1 -0
  141. package/dist/schema/helpers/format-example.d.ts +5 -0
  142. package/dist/schema/helpers/format-example.d.ts.map +1 -0
  143. package/dist/schema/helpers/format-example.js +12 -0
  144. package/dist/schema/helpers/format-example.js.map +1 -0
  145. package/dist/schema/helpers/format-value.d.ts +5 -0
  146. package/dist/schema/helpers/format-value.d.ts.map +1 -0
  147. package/dist/schema/helpers/format-value.js +8 -0
  148. package/dist/schema/helpers/format-value.js.map +1 -0
  149. package/dist/schema/helpers/get-compositions-to-render.d.ts +33 -0
  150. package/dist/schema/helpers/get-compositions-to-render.d.ts.map +1 -0
  151. package/dist/schema/helpers/get-compositions-to-render.js +39 -0
  152. package/dist/schema/helpers/get-compositions-to-render.js.map +1 -0
  153. package/dist/schema/helpers/get-discriminator-values.d.ts +4 -0
  154. package/dist/schema/helpers/get-discriminator-values.d.ts.map +1 -0
  155. package/dist/schema/helpers/get-discriminator-values.js +6 -0
  156. package/dist/schema/helpers/get-discriminator-values.js.map +1 -0
  157. package/dist/schema/helpers/get-enum-values.d.ts +9 -0
  158. package/dist/schema/helpers/get-enum-values.d.ts.map +1 -0
  159. package/dist/schema/helpers/get-enum-values.js +16 -0
  160. package/dist/schema/helpers/get-enum-values.js.map +1 -0
  161. package/dist/schema/helpers/get-property-description.d.ts +9 -0
  162. package/dist/schema/helpers/get-property-description.d.ts.map +1 -0
  163. package/dist/schema/helpers/get-property-description.js +27 -0
  164. package/dist/schema/helpers/get-property-description.js.map +1 -0
  165. package/dist/schema/helpers/get-ref-name.d.ts +24 -0
  166. package/dist/schema/helpers/get-ref-name.d.ts.map +1 -0
  167. package/dist/schema/helpers/get-ref-name.js +15 -0
  168. package/dist/schema/helpers/get-ref-name.js.map +1 -0
  169. package/dist/schema/helpers/get-schema-type.d.ts +13 -0
  170. package/dist/schema/helpers/get-schema-type.d.ts.map +1 -0
  171. package/dist/schema/helpers/get-schema-type.js +24 -0
  172. package/dist/schema/helpers/get-schema-type.js.map +1 -0
  173. package/dist/schema/helpers/get-type-signature-tokens.d.ts +48 -0
  174. package/dist/schema/helpers/get-type-signature-tokens.d.ts.map +1 -0
  175. package/dist/schema/helpers/get-type-signature-tokens.js +62 -0
  176. package/dist/schema/helpers/get-type-signature-tokens.js.map +1 -0
  177. package/dist/schema/helpers/has-complex-array-items.d.ts +10 -0
  178. package/dist/schema/helpers/has-complex-array-items.d.ts.map +1 -0
  179. package/dist/schema/helpers/has-complex-array-items.js +22 -0
  180. package/dist/schema/helpers/has-complex-array-items.js.map +1 -0
  181. package/dist/schema/helpers/index.d.ts +12 -0
  182. package/dist/schema/helpers/index.d.ts.map +1 -0
  183. package/dist/schema/helpers/index.js +12 -0
  184. package/dist/schema/helpers/is-empty-schema-object.d.ts +8 -0
  185. package/dist/schema/helpers/is-empty-schema-object.d.ts.map +1 -0
  186. package/dist/schema/helpers/is-empty-schema-object.js +11 -0
  187. package/dist/schema/helpers/is-empty-schema-object.js.map +1 -0
  188. package/dist/schema/helpers/is-model-linkable.d.ts +15 -0
  189. package/dist/schema/helpers/is-model-linkable.d.ts.map +1 -0
  190. package/dist/schema/helpers/is-model-linkable.js +13 -0
  191. package/dist/schema/helpers/is-model-linkable.js.map +1 -0
  192. package/dist/schema/helpers/is-on-schema-target-path.d.ts +3 -0
  193. package/dist/schema/helpers/is-on-schema-target-path.d.ts.map +1 -0
  194. package/dist/schema/helpers/is-on-schema-target-path.js +6 -0
  195. package/dist/schema/helpers/is-on-schema-target-path.js.map +1 -0
  196. package/dist/schema/helpers/is-type-object.d.ts +5 -0
  197. package/dist/schema/helpers/is-type-object.d.ts.map +1 -0
  198. package/dist/schema/helpers/is-type-object.js +15 -0
  199. package/dist/schema/helpers/is-type-object.js.map +1 -0
  200. package/dist/schema/helpers/merge-all-of-schemas.d.ts +12 -0
  201. package/dist/schema/helpers/merge-all-of-schemas.d.ts.map +1 -0
  202. package/dist/schema/helpers/merge-all-of-schemas.js +151 -0
  203. package/dist/schema/helpers/merge-all-of-schemas.js.map +1 -0
  204. package/dist/schema/helpers/normalize-object-composition.d.ts +9 -0
  205. package/dist/schema/helpers/normalize-object-composition.d.ts.map +1 -0
  206. package/dist/schema/helpers/normalize-object-composition.js +29 -0
  207. package/dist/schema/helpers/normalize-object-composition.js.map +1 -0
  208. package/dist/schema/helpers/optimize-value-for-display.d.ts +13 -0
  209. package/dist/schema/helpers/optimize-value-for-display.d.ts.map +1 -0
  210. package/dist/schema/helpers/optimize-value-for-display.js +64 -0
  211. package/dist/schema/helpers/optimize-value-for-display.js.map +1 -0
  212. package/dist/schema/helpers/partition-all-of-compositions.d.ts +32 -0
  213. package/dist/schema/helpers/partition-all-of-compositions.d.ts.map +1 -0
  214. package/dist/schema/helpers/partition-all-of-compositions.js +67 -0
  215. package/dist/schema/helpers/partition-all-of-compositions.js.map +1 -0
  216. package/dist/schema/helpers/schema-composition.d.ts +4 -0
  217. package/dist/schema/helpers/schema-composition.d.ts.map +1 -0
  218. package/dist/schema/helpers/schema-composition.js +11 -0
  219. package/dist/schema/helpers/schema-composition.js.map +1 -0
  220. package/dist/schema/helpers/schema-cycle.d.ts +31 -0
  221. package/dist/schema/helpers/schema-cycle.d.ts.map +1 -0
  222. package/dist/schema/helpers/schema-cycle.js +8 -0
  223. package/dist/schema/helpers/schema-cycle.js.map +1 -0
  224. package/dist/schema/helpers/schema-expansion.d.ts +89 -0
  225. package/dist/schema/helpers/schema-expansion.d.ts.map +1 -0
  226. package/dist/schema/helpers/schema-expansion.js +93 -0
  227. package/dist/schema/helpers/schema-expansion.js.map +1 -0
  228. package/dist/schema/helpers/schema-keyboard-nav.d.ts +23 -0
  229. package/dist/schema/helpers/schema-keyboard-nav.d.ts.map +1 -0
  230. package/dist/schema/helpers/schema-keyboard-nav.js +36 -0
  231. package/dist/schema/helpers/schema-keyboard-nav.js.map +1 -0
  232. package/dist/schema/helpers/schema-name.d.ts +27 -0
  233. package/dist/schema/helpers/schema-name.d.ts.map +1 -0
  234. package/dist/schema/helpers/schema-name.js +40 -0
  235. package/dist/schema/helpers/schema-name.js.map +1 -0
  236. package/dist/schema/helpers/should-display-description.d.ts +10 -0
  237. package/dist/schema/helpers/should-display-description.d.ts.map +1 -0
  238. package/dist/schema/helpers/should-display-description.js +6 -0
  239. package/dist/schema/helpers/should-display-description.js.map +1 -0
  240. package/dist/schema/helpers/should-display-heading.d.ts +11 -0
  241. package/dist/schema/helpers/should-display-heading.d.ts.map +1 -0
  242. package/dist/schema/helpers/should-display-heading.js +6 -0
  243. package/dist/schema/helpers/should-display-heading.js.map +1 -0
  244. package/dist/schema/helpers/should-render-array-item-composition.d.ts +10 -0
  245. package/dist/schema/helpers/should-render-array-item-composition.d.ts.map +1 -0
  246. package/dist/schema/helpers/should-render-array-item-composition.js +12 -0
  247. package/dist/schema/helpers/should-render-array-item-composition.js.map +1 -0
  248. package/dist/schema/helpers/sort-property-names.d.ts +23 -0
  249. package/dist/schema/helpers/sort-property-names.d.ts.map +1 -0
  250. package/dist/schema/helpers/sort-property-names.js +55 -0
  251. package/dist/schema/helpers/sort-property-names.js.map +1 -0
  252. package/dist/schema/helpers/unwrap-for-read.d.ts +48 -0
  253. package/dist/schema/helpers/unwrap-for-read.d.ts.map +1 -0
  254. package/dist/schema/helpers/unwrap-for-read.js +8 -0
  255. package/dist/schema/helpers/unwrap-for-read.js.map +1 -0
  256. package/dist/schema/index.d.ts +12 -0
  257. package/dist/schema/index.d.ts.map +1 -0
  258. package/dist/schema/index.js +11 -0
  259. package/dist/schema/localization/index.d.ts +59 -0
  260. package/dist/schema/localization/index.d.ts.map +1 -0
  261. package/dist/schema/localization/index.js +18 -0
  262. package/dist/schema/localization/index.js.map +1 -0
  263. package/dist/schema/localization/locales/ar.d.ts +58 -0
  264. package/dist/schema/localization/locales/ar.d.ts.map +1 -0
  265. package/dist/schema/localization/locales/ar.js +60 -0
  266. package/dist/schema/localization/locales/ar.js.map +1 -0
  267. package/dist/schema/localization/locales/de.d.ts +58 -0
  268. package/dist/schema/localization/locales/de.d.ts.map +1 -0
  269. package/dist/schema/localization/locales/de.js +60 -0
  270. package/dist/schema/localization/locales/de.js.map +1 -0
  271. package/dist/schema/localization/locales/en.d.ts +58 -0
  272. package/dist/schema/localization/locales/en.d.ts.map +1 -0
  273. package/dist/schema/localization/locales/en.js +60 -0
  274. package/dist/schema/localization/locales/en.js.map +1 -0
  275. package/dist/schema/localization/locales/es.d.ts +58 -0
  276. package/dist/schema/localization/locales/es.d.ts.map +1 -0
  277. package/dist/schema/localization/locales/es.js +60 -0
  278. package/dist/schema/localization/locales/es.js.map +1 -0
  279. package/dist/schema/localization/locales/fr.d.ts +58 -0
  280. package/dist/schema/localization/locales/fr.d.ts.map +1 -0
  281. package/dist/schema/localization/locales/fr.js +60 -0
  282. package/dist/schema/localization/locales/fr.js.map +1 -0
  283. package/dist/schema/localization/locales/pt.d.ts +58 -0
  284. package/dist/schema/localization/locales/pt.d.ts.map +1 -0
  285. package/dist/schema/localization/locales/pt.js +60 -0
  286. package/dist/schema/localization/locales/pt.js.map +1 -0
  287. package/dist/schema/localization/locales/ru.d.ts +58 -0
  288. package/dist/schema/localization/locales/ru.d.ts.map +1 -0
  289. package/dist/schema/localization/locales/ru.js +60 -0
  290. package/dist/schema/localization/locales/ru.js.map +1 -0
  291. package/dist/schema/localization/locales/zh-cn.d.ts +58 -0
  292. package/dist/schema/localization/locales/zh-cn.d.ts.map +1 -0
  293. package/dist/schema/localization/locales/zh-cn.js +60 -0
  294. package/dist/schema/localization/locales/zh-cn.js.map +1 -0
  295. package/dist/schema/localization/translations.d.ts +460 -0
  296. package/dist/schema/localization/translations.d.ts.map +1 -0
  297. package/dist/schema/localization/translations.js +23 -0
  298. package/dist/schema/localization/translations.js.map +1 -0
  299. package/dist/schema/request-body-composition-index.d.ts +8 -0
  300. package/dist/schema/request-body-composition-index.d.ts.map +1 -0
  301. package/dist/schema/request-body-composition-index.js +6 -0
  302. package/dist/schema/request-body-composition-index.js.map +1 -0
  303. package/dist/schema/schema-tree.bench.d.ts +2 -0
  304. package/dist/schema/schema-tree.bench.d.ts.map +1 -0
  305. package/dist/schema/types.d.ts +51 -0
  306. package/dist/schema/types.d.ts.map +1 -0
  307. package/dist/shared/Badge.vue.d.ts +17 -0
  308. package/dist/shared/Badge.vue.d.ts.map +1 -0
  309. package/dist/shared/Badge.vue.js +9 -0
  310. package/dist/shared/Badge.vue.js.map +1 -0
  311. package/dist/shared/Badge.vue.script.js +16 -0
  312. package/dist/shared/Badge.vue.script.js.map +1 -0
  313. package/dist/shared/ScreenReader.vue.d.ts +21 -0
  314. package/dist/shared/ScreenReader.vue.d.ts.map +1 -0
  315. package/dist/shared/ScreenReader.vue.js +7 -0
  316. package/dist/shared/ScreenReader.vue.js.map +1 -0
  317. package/dist/shared/ScreenReader.vue.script.js +19 -0
  318. package/dist/shared/ScreenReader.vue.script.js.map +1 -0
  319. package/dist/shared/index.d.ts +3 -0
  320. package/dist/shared/index.d.ts.map +1 -0
  321. package/dist/shared/index.js +3 -0
  322. package/dist/specification-extensions/ExtensionValue.vue.d.ts +13 -0
  323. package/dist/specification-extensions/ExtensionValue.vue.d.ts.map +1 -0
  324. package/dist/specification-extensions/ExtensionValue.vue.js +7 -0
  325. package/dist/specification-extensions/ExtensionValue.vue.js.map +1 -0
  326. package/dist/specification-extensions/ExtensionValue.vue.script.js +84 -0
  327. package/dist/specification-extensions/ExtensionValue.vue.script.js.map +1 -0
  328. package/dist/specification-extensions/SpecificationExtensions.vue.d.ts +9 -0
  329. package/dist/specification-extensions/SpecificationExtensions.vue.d.ts.map +1 -0
  330. package/dist/specification-extensions/SpecificationExtensions.vue.js +7 -0
  331. package/dist/specification-extensions/SpecificationExtensions.vue.js.map +1 -0
  332. package/dist/specification-extensions/SpecificationExtensions.vue.script.js +21 -0
  333. package/dist/specification-extensions/SpecificationExtensions.vue.script.js.map +1 -0
  334. package/dist/specification-extensions/index.d.ts +2 -0
  335. package/dist/specification-extensions/index.d.ts.map +1 -0
  336. package/dist/specification-extensions/index.js +2 -0
  337. package/dist/style.css +576 -15
  338. package/dist/styles/schema-tree.css +91 -0
  339. package/dist/styles/tailwind.config.css +22 -0
  340. package/dist/vue-styles.css +1 -1
  341. package/package.json +45 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @scalar/blocks
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#10443](https://github.com/scalar/scalar/pull/10443): Add a showExtensions allowlist to display OpenAPI extensions on operations, parameters, response headers, and schema fields without a custom plugin, with a schema-style value tree from the blocks package.
8
+ - [#10397](https://github.com/scalar/scalar/pull/10397): Extract the schema renderer into @scalar/blocks so other Scalar surfaces can reuse the schema tree while preserving API Reference behavior.
9
+
10
+ Keep the public API Reference Schema and SchemaProperty exports connected to extension plugins and deep-link navigation when mounted outside ApiReference.
11
+
12
+ Expose shared presentation components through @scalar/blocks/shared, group host integration APIs under schema/helpers and schema/expansion, and keep schema stories and visual regression coverage with Blocks.
13
+
14
+ Preserve literal toolbar icon types so Storybook previews can be type checked.
15
+
16
+ Pass schema navigation, extension rendering, and shared expansion state explicitly through props instead of providing or injecting host context.
17
+
18
+ ### Patch Changes
19
+
20
+ - [#10460](https://github.com/scalar/scalar/pull/10460): Preserve multipart file metadata in generated code examples, including arrays and composed schemas, read actual file bytes across code example targets, let HTTP clients set the multipart boundary, and preserve typed text fields without turning them into file attachments.
21
+ - [#10468](https://github.com/scalar/scalar/pull/10468): Stop the schema property copy-link button from taking width from a collapsed preview such as `{ compound, percentage }`. Its 24px hit box now overhangs the end of the line, so the row gives up only the icon and its gap, however the consuming app orders its stylesheets.
22
+
3
23
  ## 0.4.3
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -44,3 +44,48 @@ createCodeExample('#block', {
44
44
  },
45
45
  })
46
46
  ```
47
+
48
+ ## Schema tree
49
+
50
+ Render an OpenAPI schema in a Vue application using the same tree as API Reference:
51
+
52
+ ```vue
53
+ <script setup lang="ts">
54
+ import { Schema } from '@scalar/blocks/schema'
55
+ import { useSchemaExpansion } from '@scalar/blocks/schema/expansion'
56
+ import { ref } from 'vue'
57
+ import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'
58
+ import '@scalar/blocks/style.css'
59
+
60
+ const { schema } = defineProps<{ schema: SchemaObject }>()
61
+ const scrollTargetId = ref('')
62
+ const expansion = useSchemaExpansion(scrollTargetId)
63
+ </script>
64
+
65
+ <template>
66
+ <div class="scalar-app">
67
+ <Schema :schema="schema" :eventBus="null" :options="{ hideModels: true }" :scrollTargetId="scrollTargetId" :expansion="expansion" />
68
+ </div>
69
+ </template>
70
+ ```
71
+
72
+ The tree supports nested properties, composition selectors, constraints, examples, and keyboard navigation. Pass schemas from the workspace store to retain resolved references. Display options are typed by `SchemaOptions`.
73
+
74
+ Translations inherit the host's `@scalar/localization` provider, including locale and custom overrides. Without a provider, labels use English.
75
+
76
+ Hosts pass `scrollTargetId`, `specificationExtension`, and `expansion` as props. Create a shared store with `useSchemaExpansion(scrollTargetId)` from `@scalar/blocks/schema/expansion` inside the host’s setup and pass it to each tree. Without an expansion prop, a standalone tree owns its own store. The extension component receives the schema through its `value` prop. Request-body composition selectors share selections with code samples through `REQUEST_BODY_COMPOSITION_INDEX_SYMBOL`.
77
+
78
+ ### Entry points
79
+
80
+ - `@scalar/blocks/schema` exposes the schema renderers, rail controls, `SchemaOptions`, translations, `SchemaRenderingProps`, and the composition-selection key.
81
+ - `@scalar/blocks/schema/expansion` exposes `useSchemaExpansion`, the expansion store and its controls, and breadcrumb node keys for hosts that render their own schema rows.
82
+ - `@scalar/blocks/schema/helpers` exposes the schema classification, composition, naming, ordering, and keyboard helpers shared with those host rows.
83
+ - `@scalar/blocks/shared` exposes the general-purpose `Badge` and `ScreenReader` components.
84
+
85
+ These entry points are supported package APIs. Implementation components such as composition selectors, enum lists, breadcrumbs, and copy-link buttons stay private to the schema renderer.
86
+
87
+ ### Schema workbench and snapshots
88
+
89
+ From the repository root, build the dependencies with `pnpm turbo --filter @scalar/blocks build`, then run `pnpm --filter @scalar/blocks dev:storybook` to browse the schema stories.
90
+
91
+ The stories, interactive snapshot tests, and checked-in baselines live together in `src/schema`. Run `pnpm --filter @scalar/blocks build:storybook` followed by `pnpm --filter @scalar/blocks test:e2e:storybook` with Docker running. The browser runs in the same Linux image as CI so snapshots compare consistently across host platforms. Use `test:e2e:storybook:update-snapshots` only for intentional visual changes.
@@ -1 +1 @@
1
- {"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AACjH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AASvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC9C,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B;;;OAGG;IACH,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxD;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,+LAa5B,mBAAmB,KAAG,UAyJxB,CAAA"}
1
+ {"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AACjH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AASvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC9C,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B;;;OAGG;IACH,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxD;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,+LAa5B,mBAAmB,KAAG,UAkKxB,CAAA"}
@@ -82,6 +82,7 @@ var u = ({ includeDefaultHeaders: u = !1, operation: d, contentType: f, method:
82
82
  let e = w.url.indexOf("#"), t = e === -1 ? "" : w.url.slice(e), n = e === -1 ? w.url : w.url.slice(0, e), r = w.queryString.map(({ name: e, value: t }) => `${encodeURIComponent(e)}=${t}`).join("&");
83
83
  w.url = `${n}${n.includes("?") ? "&" : "?"}${r}${t}`, w.queryString = [];
84
84
  }
85
+ w.postData?.mimeType === "multipart/form-data" && w.postData.params?.some((e) => e.fileName !== void 0) && (w.headers = w.headers.filter((e) => e.name.toLowerCase() !== "content-type"));
85
86
  let A = 0;
86
87
  for (let e of w.headers) A += (e.name?.length ?? 0) + 2 + (e.value?.length ?? 0) + 2;
87
88
  return w.headersSize = A, w;
@@ -1 +1 @@
1
- {"version":3,"file":"operation-to-har.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"sourcesContent":["import { isElectron } from '@scalar/helpers/general/is-electron'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n type SecuritySchemeObjectSecret,\n filterGlobalCookie,\n getDefaultHeaders,\n restoreConventionalDefaultHeaderNames,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { APP_VERSION } from '@/constants'\n\nimport { processBody } from './process-body'\nimport { processParameters } from './process-parameters'\nimport { processSecuritySchemes } from './process-security-schemes'\nimport { processServerUrl } from './process-server-url'\n\nexport type OperationToHarProps = {\n /** OpenAPI Operation object */\n operation: OperationObject\n /** HTTP method of the operation */\n method: string\n /** Path of the operation */\n path: string\n /**\n * Name of the currently selected operation example\n *\n * Applies to both the body and the parameters\n */\n example?: string\n /**\n * Content type of the operation\n *\n * Applies to both the body and the parameters (if applicable)\n * @defaults to the first content type in the MediaTypeObject\n */\n contentType?: string\n /** OpenAPI Server object */\n server?: ServerObject | null\n /** OpenAPI SecurityScheme objects which are applicable to the operation */\n securitySchemes?: SecuritySchemeObjectSecret[]\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /**\n * Whether to include default headers (e.g., Accept, Content-Type) automatically.\n * If false, default headers will be omitted from the HAR request.\n * @default true\n */\n includeDefaultHeaders?: boolean\n /**\n * Selected oneOf/anyOf variants for nested request body example generation\n * (e.g. from the schema dropdowns in the API reference).\n */\n /** Originating OpenAPI version, used for XML mapping rules. */\n openapiVersion?: string\n requestBodyCompositionSelection?: Record<string, number>\n /**\n * Whether to disable parameters by default.\n * @default false\n */\n defaultDisabledParameters?: boolean\n}\n\n/**\n * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.\n *\n * This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,\n * which can be used to generate code snippets for various programming languages and HTTP clients.\n *\n * The conversion handles:\n * - Server URL processing and path parameter substitution\n * - Query parameter formatting based on OpenAPI parameter styles\n * - Request body processing with content type handling\n * - Security scheme integration (API keys, etc.)\n *\n * The resulting HarRequest object follows the HAR specification and includes:\n * - HTTP method and URL\n * - Headers and query parameters\n * - Request body (if present)\n * - Cookie information\n * - Size calculations for headers and body\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const operationToHar = ({\n includeDefaultHeaders = false,\n operation,\n contentType,\n method,\n path,\n server = null,\n example,\n securitySchemes,\n globalCookies,\n openapiVersion,\n requestBodyCompositionSelection,\n defaultDisabledParameters = false,\n}: OperationToHarProps): HarRequest => {\n const defaultHeaders = includeDefaultHeaders\n ? getDefaultHeaders({\n method,\n operation,\n exampleName: example ?? 'default',\n hideDisabledHeaders: true,\n hideOverriddenHeaders: true,\n options: { isElectron: isElectron(), appVersion: APP_VERSION },\n })\n : {}\n const defaultHeadersWithConventionalNames = restoreConventionalDefaultHeaderNames(defaultHeaders)\n\n const disabledGlobalCookies =\n operation['x-scalar-disable-parameters']?.['global-cookies']?.[example ?? 'default'] ?? {}\n\n const serverUrl = processServerUrl(server, path)\n\n // Initialize the HAR request with basic properties\n const harRequest: HarRequest = {\n method,\n url: serverUrl,\n headers: Object.entries(defaultHeadersWithConventionalNames).map(([name, value]) => ({ name, value })),\n queryString: [],\n postData: undefined,\n httpVersion: 'HTTP/1.1',\n cookies: [],\n headersSize: -1,\n bodySize: -1,\n }\n\n let hasCookieStyleEntries = false\n let hasSerializedQuery = false\n\n // Handle parameters\n if (operation.parameters) {\n const {\n url,\n headers,\n queryString,\n cookies,\n hasCookieStyleEntries: processedCookieStyleEntries,\n hasSerializedQuery: processedSerializedQuery,\n } = processParameters({\n harRequest,\n parameters: operation.parameters,\n example,\n defaultDisabled: defaultDisabledParameters,\n })\n\n // Correctly filter the global cookies by the processed url\n const filteredGlobalCookies =\n globalCookies\n ?.filter((cookie) => filterGlobalCookie({ cookie, url, disabledGlobalCookies }))\n ?.map((cookie) => ({ name: cookie.name, value: cookie.value })) ?? []\n\n hasCookieStyleEntries = processedCookieStyleEntries\n hasSerializedQuery = processedSerializedQuery ?? false\n harRequest.url = url\n harRequest.headers = headers\n harRequest.queryString = queryString\n harRequest.cookies = [...filteredGlobalCookies, ...cookies]\n }\n\n const body = getResolvedRef(operation.requestBody)\n\n // Handle request body\n if (body?.content) {\n const postData = processBody({\n requestBody: body,\n contentType,\n example,\n openapiVersion,\n requestBodyCompositionSelection,\n })\n\n if (postData) {\n harRequest.postData = postData\n harRequest.bodySize = postData.text?.length ?? -1\n\n // Add or update Content-Type header\n if (postData.mimeType) {\n const existingContentTypeHeader = harRequest.headers.find(\n (header) => header.name.toLowerCase() === 'content-type',\n )\n // Update existing header if it has an empty value\n if (\n existingContentTypeHeader &&\n (!existingContentTypeHeader.value ||\n (postData.mimeType.startsWith('multipart/') &&\n postData.mimeType.includes('boundary=') &&\n postData.text !== undefined))\n ) {\n existingContentTypeHeader.value = postData.mimeType\n }\n // Add new header if none exists\n else if (!existingContentTypeHeader) {\n harRequest.headers.push({\n name: 'Content-Type',\n value: postData.mimeType,\n })\n }\n }\n }\n }\n\n const hasUriReadyQuery =\n hasSerializedQuery || operation.parameters?.some((parameter) => getResolvedRef(parameter)?.in === 'querystring')\n\n // Handle security schemes\n if (securitySchemes) {\n const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes)\n harRequest.headers.push(...headers)\n // Named parameter values are already serialized, but authentication values are still raw.\n harRequest.queryString.push(\n ...queryString.map((parameter) =>\n hasUriReadyQuery ? { ...parameter, value: encodeURIComponent(parameter.value) } : parameter,\n ),\n )\n harRequest.cookies.push(...cookies)\n }\n\n // Keep authentication and global cookies in the explicit header as well, so\n // snippet generators cannot replace cookie-style parameters with their own header.\n const cookieHeader = harRequest.headers.find((header) => header.name.toLowerCase() === 'cookie')\n if (hasCookieStyleEntries && cookieHeader && harRequest.cookies.length) {\n const extraCookies = harRequest.cookies\n .map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`)\n .join('; ')\n cookieHeader.value = cookieHeader.value ? `${cookieHeader.value}; ${extraCookies}` : extraCookies\n harRequest.cookies = []\n }\n\n // Whole-query content and serialized examples must retain their authored URI encoding.\n // Keeping all query data in the URL avoids snippet generators introducing a second question mark.\n if (hasUriReadyQuery && harRequest.queryString.length) {\n const hashIndex = harRequest.url.indexOf('#')\n const hash = hashIndex === -1 ? '' : harRequest.url.slice(hashIndex)\n const url = hashIndex === -1 ? harRequest.url : harRequest.url.slice(0, hashIndex)\n const query = harRequest.queryString.map(({ name, value }) => `${encodeURIComponent(name)}=${value}`).join('&')\n harRequest.url = `${url}${url.includes('?') ? '&' : '?'}${query}${hash}`\n harRequest.queryString = []\n }\n\n // Calculate headers size without allocating a large joined string\n let headersSize = 0\n for (const h of harRequest.headers) {\n // name + \": \" + value + \"\\r\\n\"\n headersSize += (h.name?.length ?? 0) + 2 + (h.value?.length ?? 0) + 2\n }\n harRequest.headersSize = headersSize\n\n return harRequest\n}\n"],"mappings":";;;;;;;;;AAuFA,IAAa,KAAkB,EAC7B,2BAAwB,IACxB,cACA,gBACA,WACA,SACA,YAAS,MACT,YACA,oBACA,kBACA,mBACA,oCACA,+BAA4B,SACS;CAWrC,IAAM,IAAsC,EAVrB,IACnB,EAAkB;EAChB;EACA;EACA,aAAa,KAAW;EACxB,qBAAqB;EACrB,uBAAuB;EACvB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AS,GAAG,IAAI,MAAM,MAAM,IAAQ,KAClE,EAAW,cAAc,CAAC;CAC5B;CAGA,IAAI,IAAc;CAClB,KAAK,IAAM,KAAK,EAAW,SAEzB,MAAgB,EAAE,MAAM,UAAU,KAAK,KAAK,EAAE,OAAO,UAAU,KAAK;CAItE,OAFA,EAAW,cAAc,GAElB;AACT"}
1
+ {"version":3,"file":"operation-to-har.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"sourcesContent":["import { isElectron } from '@scalar/helpers/general/is-electron'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n type SecuritySchemeObjectSecret,\n filterGlobalCookie,\n getDefaultHeaders,\n restoreConventionalDefaultHeaderNames,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { APP_VERSION } from '@/constants'\n\nimport { processBody } from './process-body'\nimport { processParameters } from './process-parameters'\nimport { processSecuritySchemes } from './process-security-schemes'\nimport { processServerUrl } from './process-server-url'\n\nexport type OperationToHarProps = {\n /** OpenAPI Operation object */\n operation: OperationObject\n /** HTTP method of the operation */\n method: string\n /** Path of the operation */\n path: string\n /**\n * Name of the currently selected operation example\n *\n * Applies to both the body and the parameters\n */\n example?: string\n /**\n * Content type of the operation\n *\n * Applies to both the body and the parameters (if applicable)\n * @defaults to the first content type in the MediaTypeObject\n */\n contentType?: string\n /** OpenAPI Server object */\n server?: ServerObject | null\n /** OpenAPI SecurityScheme objects which are applicable to the operation */\n securitySchemes?: SecuritySchemeObjectSecret[]\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /**\n * Whether to include default headers (e.g., Accept, Content-Type) automatically.\n * If false, default headers will be omitted from the HAR request.\n * @default true\n */\n includeDefaultHeaders?: boolean\n /**\n * Selected oneOf/anyOf variants for nested request body example generation\n * (e.g. from the schema dropdowns in the API reference).\n */\n /** Originating OpenAPI version, used for XML mapping rules. */\n openapiVersion?: string\n requestBodyCompositionSelection?: Record<string, number>\n /**\n * Whether to disable parameters by default.\n * @default false\n */\n defaultDisabledParameters?: boolean\n}\n\n/**\n * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.\n *\n * This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,\n * which can be used to generate code snippets for various programming languages and HTTP clients.\n *\n * The conversion handles:\n * - Server URL processing and path parameter substitution\n * - Query parameter formatting based on OpenAPI parameter styles\n * - Request body processing with content type handling\n * - Security scheme integration (API keys, etc.)\n *\n * The resulting HarRequest object follows the HAR specification and includes:\n * - HTTP method and URL\n * - Headers and query parameters\n * - Request body (if present)\n * - Cookie information\n * - Size calculations for headers and body\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const operationToHar = ({\n includeDefaultHeaders = false,\n operation,\n contentType,\n method,\n path,\n server = null,\n example,\n securitySchemes,\n globalCookies,\n openapiVersion,\n requestBodyCompositionSelection,\n defaultDisabledParameters = false,\n}: OperationToHarProps): HarRequest => {\n const defaultHeaders = includeDefaultHeaders\n ? getDefaultHeaders({\n method,\n operation,\n exampleName: example ?? 'default',\n hideDisabledHeaders: true,\n hideOverriddenHeaders: true,\n options: { isElectron: isElectron(), appVersion: APP_VERSION },\n })\n : {}\n const defaultHeadersWithConventionalNames = restoreConventionalDefaultHeaderNames(defaultHeaders)\n\n const disabledGlobalCookies =\n operation['x-scalar-disable-parameters']?.['global-cookies']?.[example ?? 'default'] ?? {}\n\n const serverUrl = processServerUrl(server, path)\n\n // Initialize the HAR request with basic properties\n const harRequest: HarRequest = {\n method,\n url: serverUrl,\n headers: Object.entries(defaultHeadersWithConventionalNames).map(([name, value]) => ({ name, value })),\n queryString: [],\n postData: undefined,\n httpVersion: 'HTTP/1.1',\n cookies: [],\n headersSize: -1,\n bodySize: -1,\n }\n\n let hasCookieStyleEntries = false\n let hasSerializedQuery = false\n\n // Handle parameters\n if (operation.parameters) {\n const {\n url,\n headers,\n queryString,\n cookies,\n hasCookieStyleEntries: processedCookieStyleEntries,\n hasSerializedQuery: processedSerializedQuery,\n } = processParameters({\n harRequest,\n parameters: operation.parameters,\n example,\n defaultDisabled: defaultDisabledParameters,\n })\n\n // Correctly filter the global cookies by the processed url\n const filteredGlobalCookies =\n globalCookies\n ?.filter((cookie) => filterGlobalCookie({ cookie, url, disabledGlobalCookies }))\n ?.map((cookie) => ({ name: cookie.name, value: cookie.value })) ?? []\n\n hasCookieStyleEntries = processedCookieStyleEntries\n hasSerializedQuery = processedSerializedQuery ?? false\n harRequest.url = url\n harRequest.headers = headers\n harRequest.queryString = queryString\n harRequest.cookies = [...filteredGlobalCookies, ...cookies]\n }\n\n const body = getResolvedRef(operation.requestBody)\n\n // Handle request body\n if (body?.content) {\n const postData = processBody({\n requestBody: body,\n contentType,\n example,\n openapiVersion,\n requestBodyCompositionSelection,\n })\n\n if (postData) {\n harRequest.postData = postData\n harRequest.bodySize = postData.text?.length ?? -1\n\n // Add or update Content-Type header\n if (postData.mimeType) {\n const existingContentTypeHeader = harRequest.headers.find(\n (header) => header.name.toLowerCase() === 'content-type',\n )\n // Update existing header if it has an empty value\n if (\n existingContentTypeHeader &&\n (!existingContentTypeHeader.value ||\n (postData.mimeType.startsWith('multipart/') &&\n postData.mimeType.includes('boundary=') &&\n postData.text !== undefined))\n ) {\n existingContentTypeHeader.value = postData.mimeType\n }\n // Add new header if none exists\n else if (!existingContentTypeHeader) {\n harRequest.headers.push({\n name: 'Content-Type',\n value: postData.mimeType,\n })\n }\n }\n }\n }\n\n const hasUriReadyQuery =\n hasSerializedQuery || operation.parameters?.some((parameter) => getResolvedRef(parameter)?.in === 'querystring')\n\n // Handle security schemes\n if (securitySchemes) {\n const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes)\n harRequest.headers.push(...headers)\n // Named parameter values are already serialized, but authentication values are still raw.\n harRequest.queryString.push(\n ...queryString.map((parameter) =>\n hasUriReadyQuery ? { ...parameter, value: encodeURIComponent(parameter.value) } : parameter,\n ),\n )\n harRequest.cookies.push(...cookies)\n }\n\n // Keep authentication and global cookies in the explicit header as well, so\n // snippet generators cannot replace cookie-style parameters with their own header.\n const cookieHeader = harRequest.headers.find((header) => header.name.toLowerCase() === 'cookie')\n if (hasCookieStyleEntries && cookieHeader && harRequest.cookies.length) {\n const extraCookies = harRequest.cookies\n .map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`)\n .join('; ')\n cookieHeader.value = cookieHeader.value ? `${cookieHeader.value}; ${extraCookies}` : extraCookies\n harRequest.cookies = []\n }\n\n // Whole-query content and serialized examples must retain their authored URI encoding.\n // Keeping all query data in the URL avoids snippet generators introducing a second question mark.\n if (hasUriReadyQuery && harRequest.queryString.length) {\n const hashIndex = harRequest.url.indexOf('#')\n const hash = hashIndex === -1 ? '' : harRequest.url.slice(hashIndex)\n const url = hashIndex === -1 ? harRequest.url : harRequest.url.slice(0, hashIndex)\n const query = harRequest.queryString.map(({ name, value }) => `${encodeURIComponent(name)}=${value}`).join('&')\n harRequest.url = `${url}${url.includes('?') ? '&' : '?'}${query}${hash}`\n harRequest.queryString = []\n }\n\n // Multipart file parts are encoded by the HTTP client, which owns the boundary.\n // Raw multipart text already has its boundary and must retain its Content-Type.\n if (\n harRequest.postData?.mimeType === 'multipart/form-data' &&\n harRequest.postData.params?.some((param) => param.fileName !== undefined)\n ) {\n harRequest.headers = harRequest.headers.filter((header) => header.name.toLowerCase() !== 'content-type')\n }\n\n // Calculate headers size without allocating a large joined string\n let headersSize = 0\n for (const h of harRequest.headers) {\n // name + \": \" + value + \"\\r\\n\"\n headersSize += (h.name?.length ?? 0) + 2 + (h.value?.length ?? 0) + 2\n }\n harRequest.headersSize = headersSize\n\n return harRequest\n}\n"],"mappings":";;;;;;;;;AAu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M,MAAc,KAAK,EAAW,MAAM,EAAW,IAAI,MAAM,GAAG,CAAS,GAC3E,IAAQ,EAAW,YAAY,KAAK,EAAE,SAAM,eAAY,GAAG,mBAAmB,CAAI,EAAE,GAAG,GAAO,CAAC,CAAC,KAAK,GAAG;EAE9G,AADA,EAAW,MAAM,GAAG,IAAM,EAAI,SAAS,GAAG,IAAI,MAAM,MAAM,IAAQ,KAClE,EAAW,cAAc,CAAC;CAC5B;CAIA,AACE,EAAW,UAAU,aAAa,yBAClC,EAAW,SAAS,QAAQ,MAAM,MAAU,EAAM,aAAa,KAAA,CAAS,MAExE,EAAW,UAAU,EAAW,QAAQ,QAAQ,MAAW,EAAO,KAAK,YAAY,MAAM,cAAc;CAIzG,IAAI,IAAc;CAClB,KAAK,IAAM,KAAK,EAAW,SAEzB,MAAgB,EAAE,MAAM,UAAU,KAAK,KAAK,EAAE,OAAO,UAAU,KAAK;CAItE,OAFA,EAAW,cAAc,GAElB;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"process-body.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,KAAK,gBAAgB,GAAG,IAAI,CAC1B,mBAAmB,EACnB,aAAa,GAAG,SAAS,GAAG,iCAAiC,GAAG,gBAAgB,CACjF,GAAG;IACF,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AA8JD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,yFAMzB,gBAAgB,KAAG,QAAQ,GAAG,SA0HhC,CAAA"}
1
+ {"version":3,"file":"process-body.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,KAAK,gBAAgB,GAAG,IAAI,CAC1B,mBAAmB,EACnB,aAAa,GAAG,SAAS,GAAG,iCAAiC,GAAG,gBAAgB,CACjF,GAAG;IACF,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AA0LD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,yFAMzB,gBAAgB,KAAG,QAAQ,GAAG,SAiIhC,CAAA"}
@@ -6,7 +6,12 @@ import { getExampleValue as m, getExplicitExampleText as h } from "@scalar/works
6
6
  import { serializeStreamExample as g } from "@scalar/workspace-store/helpers/serialize-stream-example";
7
7
  import { unpackProxyObject as _ } from "@scalar/workspace-store/helpers/unpack-proxy";
8
8
  //#region src/code-example/helpers/operation-to-har/process-body.ts
9
- var v = (e, t, n, r = !1, a) => {
9
+ var v = (e, t, n) => ({
10
+ name: e,
11
+ value: `@${t}`,
12
+ fileName: t,
13
+ ...n ? { contentType: n } : {}
14
+ }), y = (e) => !!e && "type" in e && e.type === "string" && "format" in e && e.format === "binary", b = (e, t) => typeof e == "string" && e.startsWith("@") && y(t) ? e.slice(1) : void 0, x = (e, t, n, r = !1, a) => {
10
15
  let o = [], s = Array.isArray(e) ? e.filter((e) => !e.isDisabled).map((e) => [String(e.name), e.value]) : Object.entries(e);
11
16
  for (let [c, f] of s) {
12
17
  if (f == null) continue;
@@ -14,27 +19,30 @@ var v = (e, t, n, r = !1, a) => {
14
19
  if (r && !n) {
15
20
  let t = Array.isArray(e) ? i(f, l(a, [c])) : f, n = d(c, Array.isArray(t) ? t : f, s);
16
21
  if (n) {
17
- for (let e of n) o.push({
18
- name: e.key,
19
- value: e.value instanceof File ? `@${e.value.name}` : e.value,
20
- ...e.contentType ? { contentType: e.contentType } : {}
21
- });
22
+ for (let e of n) {
23
+ if (e.value instanceof File) {
24
+ o.push(v(e.key, e.value.name, e.contentType ?? e.value.type));
25
+ continue;
26
+ }
27
+ o.push({
28
+ name: e.key,
29
+ value: e.value,
30
+ ...e.contentType ? { contentType: e.contentType } : {}
31
+ });
32
+ }
22
33
  continue;
23
34
  }
24
35
  }
25
- let p = s && (s.style !== void 0 || s.explode !== void 0 || s.allowReserved !== void 0), m = p || !r ? void 0 : s?.contentType, h = n ? null : u(c, f, s);
26
- if (h) for (let e of h) o.push({
36
+ let p = s && (s.style !== void 0 || s.explode !== void 0 || s.allowReserved !== void 0), m = p || !r ? void 0 : s?.contentType, h = r && !n ? b(f, l(a, [c])) : void 0, g = n ? null : u(c, f, s);
37
+ if (g) for (let e of g) o.push({
27
38
  name: e.key,
28
39
  value: e.value
29
40
  });
30
41
  else if (f instanceof File) {
31
42
  let e = _(f);
32
- o.push({
33
- name: c,
34
- value: `@${e.name}`,
35
- ...m ? { contentType: m } : {}
36
- });
37
- } else if (m && typeof f == "object") o.push({
43
+ o.push(v(c, e.name, m ?? (r ? e.type : void 0)));
44
+ } else if (h !== void 0) o.push(v(c, h, m));
45
+ else if (m && typeof f == "object") o.push({
38
46
  name: c,
39
47
  value: JSON.stringify(_(f)),
40
48
  contentType: m
@@ -46,16 +54,13 @@ var v = (e, t, n, r = !1, a) => {
46
54
  });
47
55
  else if (Array.isArray(f)) for (let e of f) if (e instanceof File) {
48
56
  let t = _(e);
49
- o.push({
50
- name: c,
51
- value: `@${t.name}`
52
- });
57
+ o.push(v(c, t.name, r ? t.type : void 0));
53
58
  } else o.push({
54
59
  name: c,
55
60
  value: String(e)
56
61
  });
57
62
  else if (typeof f == "object") {
58
- let e = v(f, void 0, c);
63
+ let e = x(f, void 0, c);
59
64
  for (let t of e) o.push({
60
65
  name: `${c}.${t.name}`,
61
66
  value: t.value
@@ -67,13 +72,13 @@ var v = (e, t, n, r = !1, a) => {
67
72
  });
68
73
  }
69
74
  return o;
70
- }, y = ({ requestBody: i, contentType: l, example: u, openapiVersion: d, requestBodyCompositionSelection: y }) => {
71
- let b = l || Object.keys(i.content)[0] || "", x = b === "other" ? "" : b, S = (e) => `@${_(e).name || "filename"}`, C = i.content[b]?.encoding, w = i.content[b];
72
- if (w && c(b, w)) {
75
+ }, S = ({ requestBody: i, contentType: l, example: u, openapiVersion: d, requestBodyCompositionSelection: v }) => {
76
+ let y = l || Object.keys(i.content)[0] || "", b = y === "other" ? "" : y, S = (e) => `@${_(e).name || "filename"}`, C = i.content[y]?.encoding, w = i.content[y];
77
+ if (w && c(y, w)) {
73
78
  let e = u ?? Object.keys(w.examples ?? {})[0] ?? "default", t = r({
74
79
  ...i,
75
- "x-scalar-selected-content-type": { [e]: b }
76
- }, e, y);
80
+ "x-scalar-selected-content-type": { [e]: y }
81
+ }, e, v);
77
82
  if (t?.mode === "multipart") {
78
83
  let e = f(t.value, t.contentType);
79
84
  return {
@@ -82,49 +87,50 @@ var v = (e, t, n, r = !1, a) => {
82
87
  };
83
88
  }
84
89
  }
85
- let T = b === "multipart/form-data" || b === "application/x-www-form-urlencoded";
86
- if (p(b)) {
87
- let e = o(i, b, u ?? "", y, d);
90
+ let T = y === "multipart/form-data" || y === "application/x-www-form-urlencoded";
91
+ if (p(y)) {
92
+ let e = o(i, y, u ?? "", v, d);
88
93
  return e ? {
89
- mimeType: x,
94
+ mimeType: b,
90
95
  text: e.value
91
96
  } : void 0;
92
97
  }
93
- let E = m(a(i, u, l)), D = h(E, b);
98
+ let E = m(a(i, u, l)), D = h(E, y);
94
99
  if (D !== void 0) return {
95
- mimeType: x,
100
+ mimeType: b,
96
101
  text: D
97
102
  };
98
103
  let O = E?.value;
99
104
  if (O !== void 0) {
100
105
  let e = typeof O == "object" && O ? _(O) : O;
101
106
  return T && typeof e == "object" && e ? {
102
- mimeType: x,
103
- params: v(e, C, void 0, b === "multipart/form-data", t(i.content[b]?.schema, n))
107
+ mimeType: b,
108
+ params: x(e, C, void 0, y === "multipart/form-data", t(i.content[y]?.schema, n))
104
109
  } : e instanceof File ? {
105
- mimeType: x,
110
+ mimeType: b,
106
111
  text: S(e)
107
112
  } : {
108
- mimeType: x,
109
- text: typeof e == "string" ? e : g(e, b, !1) ?? JSON.stringify(e)
113
+ mimeType: b,
114
+ text: typeof e == "string" ? e : g(e, y, !1) ?? JSON.stringify(e)
110
115
  };
111
116
  }
112
- let k = i.content[b], A = t(k?.schema ?? k?.itemSchema);
117
+ let k = i.content[y], A = t(k?.schema ?? k?.itemSchema);
113
118
  if (A !== void 0) {
114
- let t = s(e(A), {
115
- compositionSelection: y,
116
- mode: "write"
119
+ let t = e(A), n = s(t, {
120
+ compositionSelection: v,
121
+ mode: "write",
122
+ binaryAsFile: y === "multipart/form-data"
117
123
  }, { schemaPath: ["requestBody"] });
118
- if (t !== void 0) return T && typeof t == "object" && t ? {
119
- mimeType: x,
120
- params: v(t, C, void 0, b === "multipart/form-data")
124
+ if (n !== void 0) return T && typeof n == "object" && n ? {
125
+ mimeType: b,
126
+ params: x(n, C, void 0, y === "multipart/form-data", t)
121
127
  } : {
122
- mimeType: x,
123
- text: g(t, b, k?.schema === void 0) ?? (typeof t == "string" ? t : JSON.stringify(t))
128
+ mimeType: b,
129
+ text: g(n, y, k?.schema === void 0) ?? (typeof n == "string" ? n : JSON.stringify(n))
124
130
  };
125
131
  }
126
132
  };
127
133
  //#endregion
128
- export { y as processBody };
134
+ export { S as processBody };
129
135
 
130
136
  //# sourceMappingURL=process-body.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-body.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"sourcesContent":["import { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type'\nimport { getExampleValue, getExplicitExampleText } from '@scalar/workspace-store/helpers/get-example-value'\nimport { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { getResolvedRefDeep } from '@scalar/workspace-store/helpers/get-resolved-ref-deep'\nimport { serializeStreamExample } from '@scalar/workspace-store/helpers/serialize-stream-example'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport {\n buildRequestBody,\n coerceLeafValueToSchemaType,\n getExample,\n getExampleFromBody,\n getExampleFromSchema,\n needsMultipartEncoding,\n resolveLeafSchema,\n serializeFormPropertyWithEncoding,\n serializeMultipartArray,\n serializeMultipartBody,\n} from '@scalar/workspace-store/request-example'\nimport type {\n MediaTypeObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Param, PostData } from 'har-format'\n\nimport type { OperationToHarProps } from './operation-to-har'\n\ntype ProcessBodyProps = Pick<\n OperationToHarProps,\n 'contentType' | 'example' | 'requestBodyCompositionSelection' | 'openapiVersion'\n> & {\n requestBody: RequestBodyObject\n}\n\ntype MultipartEncodingMap = MediaTypeObject['encoding']\n\n/**\n * Converts a form-data body into HAR `Param[]` entries for `multipart/form-data`\n * and `application/x-www-form-urlencoded` requests.\n *\n * Per OpenAPI 3.1.x Encoding Object, each property's serialization is governed\n * by an optional Encoding entry. When `style` / `explode` / `allowReserved` is\n * set, the value is serialized RFC6570-style and `contentType` is ignored.\n * Multipart arrays apply the encoding to each item and repeat the property name.\n * Object items default to JSON, and uploaded files retain their filename references.\n *\n * @param obj - The form-data payload, either an object keyed by property name\n * or a HAR-style `{ name, value, isDisabled }[]` array.\n * @param encoding - The `encoding` map from the Media Type Object, if any.\n * Used only at the top level (`parentKey` undefined).\n * @param parentKey - When set, we are flattening a nested object inside another\n * property; encoding is ignored and keys are joined with `.` (legacy default).\n * @param isMultipart - True for `multipart/form-data`. Gates the spec defaults\n * for object properties and array items. Urlencoded bodies retain their existing\n * serialization and flattening behavior.\n */\nconst objectToFormParams = (\n obj: object | { name: string; value: unknown; isDisabled: boolean }[],\n encoding?: MultipartEncodingMap,\n parentKey?: string,\n isMultipart = false,\n schema?: SchemaObject,\n): Param[] => {\n const params: Param[] = []\n\n /** Ensure we do not include disabled items */\n const entries: [string, unknown][] = Array.isArray(obj)\n ? obj.filter((item) => !item.isDisabled).map((item) => [String(item.name), item.value])\n : Object.entries(obj)\n\n for (const [key, value] of entries) {\n if (value === undefined || value === null) {\n continue\n }\n\n const partEncoding = parentKey ? undefined : encoding?.[key]\n\n if (isMultipart && !parentKey) {\n const restored = Array.isArray(obj) ? coerceLeafValueToSchemaType(value, resolveLeafSchema(schema, [key])) : value\n const arrayParts = serializeMultipartArray(key, Array.isArray(restored) ? restored : value, partEncoding)\n if (arrayParts) {\n for (const part of arrayParts) {\n params.push({\n name: part.key,\n value: part.value instanceof File ? `@${part.value.name}` : part.value,\n ...(part.contentType ? { contentType: part.contentType } : {}),\n })\n }\n continue\n }\n }\n /**\n * Per OpenAPI 3.1.1: when style, explode, or allowReserved is explicitly set on the\n * encoding entry, contentType (implicit or explicit) is ignored and the value is\n * serialized as if it were a query-style parameter.\n */\n const hasFormStyle =\n partEncoding &&\n (partEncoding.style !== undefined ||\n partEncoding.explode !== undefined ||\n partEncoding.allowReserved !== undefined)\n /**\n * Per OAS 3.1.x Encoding Object: `contentType` SHALL be ignored if the request body\n * media type is not a multipart. For `application/x-www-form-urlencoded` we still\n * honor `style`/`explode`/`allowReserved` (handled above), but a `contentType`-only\n * entry has no effect — values fall through to the dotted-key flattening default.\n */\n const explicitContentType = hasFormStyle || !isMultipart ? undefined : partEncoding?.contentType\n\n /**\n * When the encoding sets style/explode/allowReserved, serialize the value RFC6570-style\n * (bracket/exploded notation) and ignore contentType. See `serializeFormPropertyWithEncoding`\n * for the per-style rules; it returns null for primitives, Files, and arrays of Files, which\n * then fall through to the dedicated branches below. HAR represents multipart and urlencoded\n * the same way via `PostData.params`, so the resulting parts work for both.\n */\n const styleParams = parentKey ? null : serializeFormPropertyWithEncoding(key, value, partEncoding)\n if (styleParams) {\n for (const param of styleParams) {\n params.push({ name: param.key, value: param.value })\n }\n } else if (value instanceof File) {\n /**\n * File values render as `@filename` references, the conventional cURL syntax for an\n * attached file. Picked up by snippet renderers downstream (e.g. `--form 'x=@file.png'`).\n */\n const file = unpackProxyObject(value)\n params.push({\n name: key,\n value: `@${file.name}`,\n ...(explicitContentType ? { contentType: explicitContentType } : {}),\n })\n } else if (explicitContentType && typeof value === 'object') {\n /**\n * Per OAS 3.1.x Encoding Object: an explicit `encoding[key].contentType` on a\n * complex value overrides the default and emits a single part containing the value\n * JSON-stringified into that media type. Only reachable when style/explode/allowReserved\n * are unset (otherwise contentType is ignored — see the style branch above).\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: explicitContentType,\n })\n } else if (isMultipart && !parentKey && !hasFormStyle && typeof value === 'object' && !Array.isArray(value)) {\n /**\n * Per OpenAPI 3.x: a top-level multipart property whose value is an object (and not a File)\n * defaults to a single part encoded as application/json, rather than being flattened\n * into multiple parts with dotted keys.\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: 'application/json',\n })\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (item instanceof File) {\n const file = unpackProxyObject(item)\n params.push({ name: key, value: `@${file.name}` })\n } else {\n params.push({ name: key, value: String(item) })\n }\n }\n } else if (typeof value === 'object') {\n /**\n * Legacy fallback: flatten nested objects into dotted-key parts. Reached when the\n * multipart JSON-default branches above don't apply — i.e. either inside a recursive\n * call (`parentKey` set) or on `application/x-www-form-urlencoded` bodies without an\n * explicit encoding entry. Strict OAS 3.1.x would use `style: form, explode: true` as\n * the urlencoded default (inner keys become top-level params); we keep dotted keys for\n * backwards compatibility with consumers that already parse this shape.\n */\n const nestedParams = objectToFormParams(value, undefined, key)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({\n name: key,\n value: String(value),\n ...(explicitContentType ? { contentType: explicitContentType } : {}),\n })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n * Returns undefined if no example is found\n */\nexport const processBody = ({\n requestBody,\n contentType,\n example,\n openapiVersion,\n requestBodyCompositionSelection,\n}: ProcessBodyProps): PostData | undefined => {\n const _contentType = contentType || Object.keys(requestBody.content)[0] || ''\n /** Empty when \"Other\" is selected so snippets do not inject `Content-Type: other`. */\n const harMimeType = _contentType === 'other' ? '' : _contentType\n const formatBinaryFile = (file: File) => {\n const unwrappedFile = unpackProxyObject(file)\n return `@${unwrappedFile.name || 'filename'}`\n }\n const encoding = requestBody.content[_contentType]?.encoding\n\n const media = requestBody.content[_contentType]\n if (media && needsMultipartEncoding(_contentType, media)) {\n const exampleName = example ?? Object.keys(media.examples ?? {})[0] ?? 'default'\n const body = buildRequestBody(\n { ...requestBody, 'x-scalar-selected-content-type': { [exampleName]: _contentType } },\n exampleName,\n requestBodyCompositionSelection,\n )\n if (body?.mode === 'multipart') {\n const encoded = serializeMultipartBody(body.value, body.contentType)\n return {\n mimeType: encoded.contentType,\n // HAR text cannot embed file bytes synchronously. Keep visible file placeholders.\n text: encoded.chunks\n .map((chunk) =>\n chunk instanceof File ? formatBinaryFile(chunk) : chunk instanceof Blob ? 'BINARY' : String(chunk),\n )\n .join(''),\n }\n }\n }\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n if (isXmlMediaType(_contentType)) {\n const xmlExample = getExampleFromBody(\n requestBody,\n _contentType,\n example ?? '',\n requestBodyCompositionSelection,\n openapiVersion,\n )\n return xmlExample ? { mimeType: harMimeType, text: xmlExample.value as string } : undefined\n }\n\n // Get the example value\n const selected = getExampleValue(getExample(requestBody, example, contentType))\n const explicitText = getExplicitExampleText(selected, _contentType)\n if (explicitText !== undefined) {\n return { mimeType: harMimeType, text: explicitText }\n }\n const _example = selected?.value\n\n // Return the provided top level example\n if (typeof _example !== 'undefined') {\n const exampleValue = _example !== null && typeof _example === 'object' ? unpackProxyObject(_example) : _example\n\n if (isFormData && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n exampleValue,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n getResolvedRef(requestBody.content[_contentType]?.schema, mergeSiblingReferences),\n ),\n }\n }\n\n if (exampleValue instanceof File) {\n return {\n mimeType: harMimeType,\n text: formatBinaryFile(exampleValue),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n typeof exampleValue === 'string'\n ? exampleValue\n : (serializeStreamExample(exampleValue, _contentType, false) ?? JSON.stringify(exampleValue)),\n }\n }\n\n // Try to extract examples from the schema\n const mediaType = requestBody.content[_contentType]\n const contentSchema = getResolvedRef(mediaType?.schema ?? mediaType?.itemSchema)\n if (typeof contentSchema !== 'undefined') {\n const resolvedContentSchema = getResolvedRefDeep(contentSchema) as SchemaObject\n const extractedExample = getExampleFromSchema(\n resolvedContentSchema,\n {\n compositionSelection: requestBodyCompositionSelection,\n mode: 'write',\n },\n {\n schemaPath: ['requestBody'],\n },\n )\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(extractedExample, encoding, undefined, _contentType === 'multipart/form-data'),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n serializeStreamExample(extractedExample, _contentType, mediaType?.schema === undefined) ??\n (typeof extractedExample === 'string' ? extractedExample : JSON.stringify(extractedExample)),\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;AAwDA,IAAM,KACJ,GACA,GACA,GACA,IAAc,IACd,MACY;CACZ,IAAM,IAAkB,CAAC,GAGnB,IAA+B,MAAM,QAAQ,CAAG,IAClD,EAAI,QAAQ,MAAS,CAAC,EAAK,UAAU,CAAC,CAAC,KAAK,MAAS,CAAC,OAAO,EAAK,IAAI,GAAG,EAAK,KAAK,CAAC,IACpF,OAAO,QAAQ,CAAG;CAEtB,KAAK,IAAM,CAAC,GAAK,MAAU,GAAS;EAClC,IAAI,KAAiC,MACnC;EAGF,IAAM,IAAe,IAAY,KA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,qBAAqB;EAC1G,IAGK;GACL,UAAU;GACV,MACE,EAAuB,GAAkB,GAAc,GAAW,WAAW,KAAA,CAAS,MACrF,OAAO,KAAqB,WAAW,IAAmB,KAAK,UAAU,CAAgB;EAC9F;CAEJ;AAGF"}
1
+ {"version":3,"file":"process-body.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"sourcesContent":["import { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type'\nimport { getExampleValue, getExplicitExampleText } from '@scalar/workspace-store/helpers/get-example-value'\nimport { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { getResolvedRefDeep } from '@scalar/workspace-store/helpers/get-resolved-ref-deep'\nimport { serializeStreamExample } from '@scalar/workspace-store/helpers/serialize-stream-example'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport {\n buildRequestBody,\n coerceLeafValueToSchemaType,\n getExample,\n getExampleFromBody,\n getExampleFromSchema,\n needsMultipartEncoding,\n resolveLeafSchema,\n serializeFormPropertyWithEncoding,\n serializeMultipartArray,\n serializeMultipartBody,\n} from '@scalar/workspace-store/request-example'\nimport type {\n MediaTypeObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Param, PostData } from 'har-format'\n\nimport type { OperationToHarProps } from './operation-to-har'\n\ntype ProcessBodyProps = Pick<\n OperationToHarProps,\n 'contentType' | 'example' | 'requestBodyCompositionSelection' | 'openapiVersion'\n> & {\n requestBody: RequestBodyObject\n}\n\ntype MultipartEncodingMap = MediaTypeObject['encoding']\n\n/**\n * Builds a HAR param for an uploaded file. `fileName` is what snippet generators read to emit real\n * file handling (for example `files=` in Python or `new Blob` in fetch). `value` keeps the\n * `@filename` placeholder for consumers that only read the text value.\n */\nconst buildFileParam = (name: string, fileName: string, contentType?: string): Param => ({\n name,\n value: `@${fileName}`,\n fileName,\n ...(contentType ? { contentType } : {}),\n})\n\n/** True when the schema describes a binary file (`type: string, format: binary`). */\nconst isBinarySchema = (schema: SchemaObject | undefined): boolean =>\n !!schema && 'type' in schema && schema.type === 'string' && 'format' in schema && schema.format === 'binary'\n\n/**\n * Example generation turns a binary property into the `@filename` placeholder string.\n * Use the schema to tell that apart from a normal text field that happens to start with `@`.\n */\nconst getBinaryPlaceholderFileName = (value: unknown, schema: SchemaObject | undefined): string | undefined =>\n typeof value === 'string' && value.startsWith('@') && isBinarySchema(schema) ? value.slice(1) : undefined\n\n/**\n * Converts a form-data body into HAR `Param[]` entries for `multipart/form-data`\n * and `application/x-www-form-urlencoded` requests.\n *\n * Per OpenAPI 3.1.x Encoding Object, each property's serialization is governed\n * by an optional Encoding entry. When `style` / `explode` / `allowReserved` is\n * set, the value is serialized RFC6570-style and `contentType` is ignored.\n * Multipart arrays apply the encoding to each item and repeat the property name.\n * Object items default to JSON, and uploaded files retain their filename references.\n *\n * @param obj - The form-data payload, either an object keyed by property name\n * or a HAR-style `{ name, value, isDisabled }[]` array.\n * @param encoding - The `encoding` map from the Media Type Object, if any.\n * Used only at the top level (`parentKey` undefined).\n * @param parentKey - When set, we are flattening a nested object inside another\n * property; encoding is ignored and keys are joined with `.` (legacy default).\n * @param isMultipart - True for `multipart/form-data`. Gates the spec defaults\n * for object properties and array items. Urlencoded bodies retain their existing\n * serialization and flattening behavior.\n */\nconst objectToFormParams = (\n obj: object | { name: string; value: unknown; isDisabled: boolean }[],\n encoding?: MultipartEncodingMap,\n parentKey?: string,\n isMultipart = false,\n schema?: SchemaObject,\n): Param[] => {\n const params: Param[] = []\n\n /** Ensure we do not include disabled items */\n const entries: [string, unknown][] = Array.isArray(obj)\n ? obj.filter((item) => !item.isDisabled).map((item) => [String(item.name), item.value])\n : Object.entries(obj)\n\n for (const [key, value] of entries) {\n if (value === undefined || value === null) {\n continue\n }\n\n const partEncoding = parentKey ? undefined : encoding?.[key]\n\n if (isMultipart && !parentKey) {\n const restored = Array.isArray(obj) ? coerceLeafValueToSchemaType(value, resolveLeafSchema(schema, [key])) : value\n const arrayParts = serializeMultipartArray(key, Array.isArray(restored) ? restored : value, partEncoding)\n if (arrayParts) {\n for (const part of arrayParts) {\n if (part.value instanceof File) {\n params.push(buildFileParam(part.key, part.value.name, part.contentType ?? part.value.type))\n continue\n }\n params.push({\n name: part.key,\n value: part.value,\n ...(part.contentType ? { contentType: part.contentType } : {}),\n })\n }\n continue\n }\n }\n /**\n * Per OpenAPI 3.1.1: when style, explode, or allowReserved is explicitly set on the\n * encoding entry, contentType (implicit or explicit) is ignored and the value is\n * serialized as if it were a query-style parameter.\n */\n const hasFormStyle =\n partEncoding &&\n (partEncoding.style !== undefined ||\n partEncoding.explode !== undefined ||\n partEncoding.allowReserved !== undefined)\n /**\n * Per OAS 3.1.x Encoding Object: `contentType` SHALL be ignored if the request body\n * media type is not a multipart. For `application/x-www-form-urlencoded` we still\n * honor `style`/`explode`/`allowReserved` (handled above), but a `contentType`-only\n * entry has no effect — values fall through to the dotted-key flattening default.\n */\n const explicitContentType = hasFormStyle || !isMultipart ? undefined : partEncoding?.contentType\n\n /**\n * When the encoding sets style/explode/allowReserved, serialize the value RFC6570-style\n * (bracket/exploded notation) and ignore contentType. See `serializeFormPropertyWithEncoding`\n * for the per-style rules; it returns null for primitives, Files, and arrays of Files, which\n * then fall through to the dedicated branches below. HAR represents multipart and urlencoded\n * the same way via `PostData.params`, so the resulting parts work for both.\n */\n const binaryPlaceholderFileName =\n isMultipart && !parentKey ? getBinaryPlaceholderFileName(value, resolveLeafSchema(schema, [key])) : undefined\n const styleParams = parentKey ? null : serializeFormPropertyWithEncoding(key, value, partEncoding)\n if (styleParams) {\n for (const param of styleParams) {\n params.push({ name: param.key, value: param.value })\n }\n } else if (value instanceof File) {\n /**\n * File values render as `@filename` references, the conventional cURL syntax for an\n * attached file. Picked up by snippet renderers downstream (e.g. `--form 'x=@file.png'`).\n */\n const file = unpackProxyObject(value)\n params.push(buildFileParam(key, file.name, explicitContentType ?? (isMultipart ? file.type : undefined)))\n } else if (binaryPlaceholderFileName !== undefined) {\n /** A binary property filled in by example generation, so it is a file and not a text field. */\n params.push(buildFileParam(key, binaryPlaceholderFileName, explicitContentType))\n } else if (explicitContentType && typeof value === 'object') {\n /**\n * Per OAS 3.1.x Encoding Object: an explicit `encoding[key].contentType` on a\n * complex value overrides the default and emits a single part containing the value\n * JSON-stringified into that media type. Only reachable when style/explode/allowReserved\n * are unset (otherwise contentType is ignored — see the style branch above).\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: explicitContentType,\n })\n } else if (isMultipart && !parentKey && !hasFormStyle && typeof value === 'object' && !Array.isArray(value)) {\n /**\n * Per OpenAPI 3.x: a top-level multipart property whose value is an object (and not a File)\n * defaults to a single part encoded as application/json, rather than being flattened\n * into multiple parts with dotted keys.\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: 'application/json',\n })\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (item instanceof File) {\n const file = unpackProxyObject(item)\n params.push(buildFileParam(key, file.name, isMultipart ? file.type : undefined))\n } else {\n params.push({ name: key, value: String(item) })\n }\n }\n } else if (typeof value === 'object') {\n /**\n * Legacy fallback: flatten nested objects into dotted-key parts. Reached when the\n * multipart JSON-default branches above don't apply — i.e. either inside a recursive\n * call (`parentKey` set) or on `application/x-www-form-urlencoded` bodies without an\n * explicit encoding entry. Strict OAS 3.1.x would use `style: form, explode: true` as\n * the urlencoded default (inner keys become top-level params); we keep dotted keys for\n * backwards compatibility with consumers that already parse this shape.\n */\n const nestedParams = objectToFormParams(value, undefined, key)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({\n name: key,\n value: String(value),\n ...(explicitContentType ? { contentType: explicitContentType } : {}),\n })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n * Returns undefined if no example is found\n */\nexport const processBody = ({\n requestBody,\n contentType,\n example,\n openapiVersion,\n requestBodyCompositionSelection,\n}: ProcessBodyProps): PostData | undefined => {\n const _contentType = contentType || Object.keys(requestBody.content)[0] || ''\n /** Empty when \"Other\" is selected so snippets do not inject `Content-Type: other`. */\n const harMimeType = _contentType === 'other' ? '' : _contentType\n const formatBinaryFile = (file: File) => {\n const unwrappedFile = unpackProxyObject(file)\n return `@${unwrappedFile.name || 'filename'}`\n }\n const encoding = requestBody.content[_contentType]?.encoding\n\n const media = requestBody.content[_contentType]\n if (media && needsMultipartEncoding(_contentType, media)) {\n const exampleName = example ?? Object.keys(media.examples ?? {})[0] ?? 'default'\n const body = buildRequestBody(\n { ...requestBody, 'x-scalar-selected-content-type': { [exampleName]: _contentType } },\n exampleName,\n requestBodyCompositionSelection,\n )\n if (body?.mode === 'multipart') {\n const encoded = serializeMultipartBody(body.value, body.contentType)\n return {\n mimeType: encoded.contentType,\n // HAR text cannot embed file bytes synchronously. Keep visible file placeholders.\n text: encoded.chunks\n .map((chunk) =>\n chunk instanceof File ? formatBinaryFile(chunk) : chunk instanceof Blob ? 'BINARY' : String(chunk),\n )\n .join(''),\n }\n }\n }\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n if (isXmlMediaType(_contentType)) {\n const xmlExample = getExampleFromBody(\n requestBody,\n _contentType,\n example ?? '',\n requestBodyCompositionSelection,\n openapiVersion,\n )\n return xmlExample ? { mimeType: harMimeType, text: xmlExample.value as string } : undefined\n }\n\n // Get the example value\n const selected = getExampleValue(getExample(requestBody, example, contentType))\n const explicitText = getExplicitExampleText(selected, _contentType)\n if (explicitText !== undefined) {\n return { mimeType: harMimeType, text: explicitText }\n }\n const _example = selected?.value\n\n // Return the provided top level example\n if (typeof _example !== 'undefined') {\n const exampleValue = _example !== null && typeof _example === 'object' ? unpackProxyObject(_example) : _example\n\n if (isFormData && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n exampleValue,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n getResolvedRef(requestBody.content[_contentType]?.schema, mergeSiblingReferences),\n ),\n }\n }\n\n if (exampleValue instanceof File) {\n return {\n mimeType: harMimeType,\n text: formatBinaryFile(exampleValue),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n typeof exampleValue === 'string'\n ? exampleValue\n : (serializeStreamExample(exampleValue, _contentType, false) ?? JSON.stringify(exampleValue)),\n }\n }\n\n // Try to extract examples from the schema\n const mediaType = requestBody.content[_contentType]\n const contentSchema = getResolvedRef(mediaType?.schema ?? mediaType?.itemSchema)\n if (typeof contentSchema !== 'undefined') {\n const resolvedContentSchema = getResolvedRefDeep(contentSchema) as SchemaObject\n const extractedExample = getExampleFromSchema(\n resolvedContentSchema,\n {\n compositionSelection: requestBodyCompositionSelection,\n mode: 'write',\n binaryAsFile: _contentType === 'multipart/form-data',\n },\n {\n schemaPath: ['requestBody'],\n },\n )\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n extractedExample,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n resolvedContentSchema,\n ),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n serializeStreamExample(extractedExample, _contentType, mediaType?.schema === undefined) ??\n (typeof extractedExample === 'string' ? extractedExample : JSON.stringify(extractedExample)),\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;AAyCA,IAAM,KAAkB,GAAc,GAAkB,OAAiC;CACvF;CACA,OAAO,IAAI;CACX;CACA,GAAI,IAAc,EAAE,eAAY,IAAI,CAAC;AACvC,IAGM,KAAkB,MACtB,CAAC,CAAC,KAAU,UAAU,KAAU,EAAO,SAAS,YAAY,YAAY,KAAU,EAAO,WAAW,UAMhG,KAAgC,GAAgB,MACpD,OAAO,KAAU,YAAY,EAAM,WAAW,GAAG,KAAK,EAAe,CAAM,IAAI,EAAM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ACV,QAAQ,EACN,GACA,GACA,KAAA,GACA,MAAiB,uBACjB,EAAe,EAAY,QAAQ,EAAa,EAAE,QAAQ,CAAsB,CAClF;EACF,IAGE,aAAwB,OACnB;GACL,UAAU;GACV,MAAM,EAAiB,CAAY;EACrC,IAGK;GACL,UAAU;GACV,MACE,OAAO,KAAiB,WACpB,IACC,EAAuB,GAAc,GAAc,EAAK,KAAK,KAAK,UAAU,CAAY;EACjG;CACF;CAGA,IAAM,IAAY,EAAY,QAAQ,IAChC,IAAgB,EAAe,GAAW,UAAU,GAAW,UAAU;CAC/E,IAAW,MAAkB,QAAa;EACxC,IAAM,IAAwB,EAAmB,CAAa,GACxD,IAAmB,EACvB,GACA;GACE,sBAAsB;GACtB,MAAM;GACN,cAAc,MAAiB;EACjC,GACA,EACE,YAAY,CAAC,aAAa,EAC5B,CACF;EAEA,IAAI,MAAqB,KAAA,GAcvB,OAbI,KAAc,OAAO,KAAqB,YAAY,IACjD;GACL,UAAU;GACV,QAAQ,EACN,GACA,GACA,KAAA,GACA,MAAiB,uBACjB,CACF;EACF,IAGK;GACL,UAAU;GACV,MACE,EAAuB,GAAkB,GAAc,GAAW,WAAW,KAAA,CAAS,MACrF,OAAO,KAAqB,WAAW,IAAmB,KAAK,UAAU,CAAgB;EAC9F;CAEJ;AAGF"}
package/dist/constants.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/constants.ts
2
- var e = typeof OVERRIDE_PACKAGE_VERSION < "u" ? OVERRIDE_PACKAGE_VERSION : "0.4.3";
2
+ var e = typeof OVERRIDE_PACKAGE_VERSION < "u" ? OVERRIDE_PACKAGE_VERSION : "0.5.0";
3
3
  //#endregion
4
4
  export { e as APP_VERSION };
5
5
 
@@ -0,0 +1,14 @@
1
+ declare var __VLS_1: {};
2
+ type __VLS_Slots = {} & {
3
+ default?: (props: typeof __VLS_1) => any;
4
+ };
5
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
6
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ type __VLS_WithSlots<T, S> = T & {
10
+ new (): {
11
+ $slots: S;
12
+ };
13
+ };
14
+ //# sourceMappingURL=LinkButton.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkButton.vue.d.ts","sourceRoot":"","sources":["../../src/schema/LinkButton.vue"],"names":[],"mappings":"AA4BA,QAAA,IAAI,OAAO,IAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU,+QACd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,15 @@
1
+ import e from "../_virtual/_plugin-vue_export-helper.js";
2
+ import { createElementBlock as t, openBlock as n, renderSlot as r } from "vue";
3
+ //#region src/schema/LinkButton.vue
4
+ var i = {}, a = {
5
+ class: "text-c-2 hover:text-c-1 underline",
6
+ type: "button"
7
+ };
8
+ function o(e, i) {
9
+ return n(), t("button", a, [r(e.$slots, "default")]);
10
+ }
11
+ var s = /*#__PURE__*/ e(i, [["render", o]]);
12
+ //#endregion
13
+ export { s as default };
14
+
15
+ //# sourceMappingURL=LinkButton.vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkButton.vue.js","names":[],"sources":["../../src/schema/LinkButton.vue"],"sourcesContent":["<template>\n <button\n class=\"text-c-2 hover:text-c-1 underline\"\n type=\"button\">\n <slot />\n </button>\n</template>\n"],"mappings":";;;;CAEI,OAAM;CACN,MAAK;;;aAFP,EAIS,UAJT,GAIS,CADP,EAAQ,EAAA,QAAA,SAAA,CAAA,CAAA"}
@@ -0,0 +1,7 @@
1
+ type __VLS_Props = {
2
+ value: any;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const _default: typeof __VLS_export;
6
+ export default _default;
7
+ //# sourceMappingURL=RenderString.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenderString.vue.d.ts","sourceRoot":"","sources":["../../src/schema/RenderString.vue"],"names":[],"mappings":"AA+DA,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,GAAG,CAAA;CACX,CAAC;AAyCF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,7 @@
1
+ import e from "./RenderString.vue.script.js";
2
+ //#region src/schema/RenderString.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=RenderString.vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenderString.vue.js","names":[],"sources":["../../src/schema/RenderString.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Give this component any data, and it tries to render a meaningful string.\n *\n * @example\n * <RenderString :value=\"1\" /> => \"1\"\n * <RenderString :value=\"true\" /> => \"true\"\n * <RenderString :value=\"false\" /> => \"false\"\n * <RenderString :value=\"null\" /> => \"null\"\n * <RenderString :value=\"undefined\" /> => \"undefined\"\n * <RenderString :value=\"{}\" /> => \"{}\"\n * <RenderString :value=\"[]\" /> => \"[]\"\n * <RenderString :value=\"['a', 'b', 'c']\" /> => \"['a', 'b', 'c']\"\n * <RenderString :value=\"() => 'hello'\" /> => \"() => 'hello'\"\n * <RenderString :value=\"Symbol('test')\" /> => \"Symbol(test)\"\n **/\nimport { computed } from 'vue'\n\nconst { value } = defineProps<{\n value: any\n}>()\n\nconst valueAsString = computed(() => {\n if (value === '') {\n return `''`\n }\n\n if (value === null) {\n return 'null'\n }\n\n if (value === undefined) {\n return 'undefined'\n }\n\n // We don't need to cover all cases, Vue does a good job of rendering objects, arrays and functions.\n return value\n})\n</script>\n\n<template>\n {{ valueAsString }}\n</template>\n"],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { computed as e, defineComponent as t, toDisplayString as n } from "vue";
2
+ //#region src/schema/RenderString.vue?vue&type=script&setup=true&lang.ts
3
+ var r = /*@__PURE__*/ t({
4
+ __name: "RenderString",
5
+ props: { value: {} },
6
+ setup(t) {
7
+ let r = e(() => t.value === "" ? "''" : t.value === null ? "null" : t.value === void 0 ? "undefined" : t.value);
8
+ return (e, t) => n(r.value);
9
+ }
10
+ });
11
+ //#endregion
12
+ export { r as default };
13
+
14
+ //# sourceMappingURL=RenderString.vue.script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenderString.vue.script.js","names":[],"sources":["../../src/schema/RenderString.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * Give this component any data, and it tries to render a meaningful string.\n *\n * @example\n * <RenderString :value=\"1\" /> => \"1\"\n * <RenderString :value=\"true\" /> => \"true\"\n * <RenderString :value=\"false\" /> => \"false\"\n * <RenderString :value=\"null\" /> => \"null\"\n * <RenderString :value=\"undefined\" /> => \"undefined\"\n * <RenderString :value=\"{}\" /> => \"{}\"\n * <RenderString :value=\"[]\" /> => \"[]\"\n * <RenderString :value=\"['a', 'b', 'c']\" /> => \"['a', 'b', 'c']\"\n * <RenderString :value=\"() => 'hello'\" /> => \"() => 'hello'\"\n * <RenderString :value=\"Symbol('test')\" /> => \"Symbol(test)\"\n **/\nimport { computed } from 'vue'\n\nconst { value } = defineProps<{\n value: any\n}>()\n\nconst valueAsString = computed(() => {\n if (value === '') {\n return `''`\n }\n\n if (value === null) {\n return 'null'\n }\n\n if (value === undefined) {\n return 'undefined'\n }\n\n // We don't need to cover all cases, Vue does a good job of rendering objects, arrays and functions.\n return value\n})\n</script>\n\n<template>\n {{ valueAsString }}\n</template>\n"],"mappings":";;;;;;EAsBA,IAAM,IAAgB,QAChB,EAAA,UAAU,KACL,OAGL,EAAA,UAAU,OACL,SAGL,EAAA,UAAU,KAAA,IACL,cAIF,EAAA,KACR;qBAII,EAAA,KAAa"}
@@ -0,0 +1,50 @@
1
+ import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
2
+ import type { DiscriminatorObject, SchemaObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
3
+ import type { SchemaOptions, SchemaRenderingProps } from './types';
4
+ type __VLS_Props = {
5
+ schema?: SchemaObject;
6
+ /** Track how deep we've gone */
7
+ level?: number;
8
+ /**
9
+ * Real nesting depth. Not derived from `level`, whose stride differs per
10
+ * edge (object +2, composition +1, non-object root +0).
11
+ */
12
+ depth?: number;
13
+ name?: string;
14
+ /** A tighter layout with less borders and without a heading */
15
+ compact?: boolean;
16
+ /** Shows a toggle to hide/show children */
17
+ noncollapsible?: boolean;
18
+ /** Hide the heading */
19
+ hideHeading?: boolean;
20
+ /** Hide the schema description */
21
+ hideDescription?: boolean;
22
+ /** Show a special one way toggle for additional properties, also has a top border when open */
23
+ additionalProperties?: boolean;
24
+ /** Number of request body properties hidden behind the overflow control. */
25
+ additionalPropertyCount?: number;
26
+ /** Hide model names in type display */
27
+ hideModelNames?: boolean;
28
+ /** Discriminator object */
29
+ discriminator?: DiscriminatorObject;
30
+ /** Breadcrumb for the schema */
31
+ breadcrumb?: string[];
32
+ /** Event bus emitting actions */
33
+ eventBus: WorkspaceEventBus | null;
34
+ /** Move the options into a single prop so they are easy to pass around */
35
+ options: SchemaOptions;
36
+ /** When "requestBody", composition dropdown selection is synced with the example snippet */
37
+ schemaContext?: string;
38
+ /** Internal path used to sync nested request body compositions with the code sample */
39
+ compositionPath?: string[];
40
+ /**
41
+ * Stable identity of this schema node, derived from its raw (unresolved)
42
+ * value by the parent. Used to detect self-referential cycles. See
43
+ * {@link getCycleKey}.
44
+ */
45
+ cycleKey?: unknown;
46
+ } & SchemaRenderingProps;
47
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
48
+ declare const _default: typeof __VLS_export;
49
+ export default _default;
50
+ //# sourceMappingURL=Schema.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Schema.vue.d.ts","sourceRoot":"","sources":["../../src/schema/Schema.vue"],"names":[],"mappings":"AAqqBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAGvE,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACb,MAAM,8DAA8D,CAAA;AA4BrE,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAElE,KAAK,WAAW,GAAG;IACf,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,2CAA2C;IAC3C,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,uBAAuB;IACvB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,kCAAkC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,+FAA+F;IAC/F,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,4EAA4E;IAC5E,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,uCAAuC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,2BAA2B;IAC3B,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,iCAAiC;IACjC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,0EAA0E;IAC1E,OAAO,EAAE,aAAa,CAAA;IACtB,4FAA4F;IAC5F,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,GAAG,oBAAoB,CAAC;AAmqB3B,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,9 @@
1
+ import e from "../_virtual/_plugin-vue_export-helper.js";
2
+ import t from "./Schema.vue.script.js";
3
+ /* empty css */
4
+ //#region src/schema/Schema.vue
5
+ var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-8f822427"]]);
6
+ //#endregion
7
+ export { n as default };
8
+
9
+ //# sourceMappingURL=Schema.vue.js.map