openapi-typesafe 1.0.0-rc.4 → 1.0.0-rc.6

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 (366) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/dist/adapters/node-file-system/node-file-system.cjs +7 -0
  3. package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
  4. package/dist/adapters/node-file-system/node-file-system.mjs +7 -0
  5. package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
  6. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs +19 -0
  7. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs.map +1 -0
  8. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs +17 -0
  9. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs.map +1 -0
  10. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +5 -32
  11. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -1
  12. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +6 -33
  13. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -1
  14. package/dist/adapters/redocly-loader/component-schemas.cjs +17 -0
  15. package/dist/adapters/redocly-loader/component-schemas.cjs.map +1 -0
  16. package/dist/adapters/redocly-loader/component-schemas.mjs +14 -0
  17. package/dist/adapters/redocly-loader/component-schemas.mjs.map +1 -0
  18. package/dist/adapters/redocly-loader/mapping-schema-names.cjs +22 -0
  19. package/dist/adapters/redocly-loader/mapping-schema-names.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/mapping-schema-names.mjs +20 -0
  21. package/dist/adapters/redocly-loader/mapping-schema-names.mjs.map +1 -0
  22. package/dist/adapters/redocly-loader/query-document-names.cjs +50 -0
  23. package/dist/adapters/redocly-loader/query-document-names.cjs.map +1 -0
  24. package/dist/adapters/redocly-loader/query-document-names.mjs +48 -0
  25. package/dist/adapters/redocly-loader/query-document-names.mjs.map +1 -0
  26. package/dist/adapters/redocly-loader/query-named-components.cjs +129 -0
  27. package/dist/adapters/redocly-loader/query-named-components.cjs.map +1 -0
  28. package/dist/adapters/redocly-loader/query-named-components.mjs +126 -0
  29. package/dist/adapters/redocly-loader/query-named-components.mjs.map +1 -0
  30. package/dist/adapters/redocly-loader/redocly-config-source.cjs +3 -0
  31. package/dist/adapters/redocly-loader/redocly-config-source.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/redocly-config-source.mjs +4 -1
  33. package/dist/adapters/redocly-loader/redocly-config-source.mjs.map +1 -1
  34. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +39 -18
  35. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  36. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +40 -19
  37. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  38. package/dist/adapters/redocly-loader/ref-access.cjs +25 -4
  39. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  40. package/dist/adapters/redocly-loader/ref-access.mjs +26 -5
  41. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  42. package/dist/adapters/redocly-loader/ref-holders.cjs +52 -10
  43. package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
  44. package/dist/adapters/redocly-loader/ref-holders.mjs +52 -11
  45. package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
  46. package/dist/adapters/redocly-loader/remote-fetch.cjs +20 -3
  47. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  48. package/dist/adapters/redocly-loader/remote-fetch.mjs +20 -4
  49. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  50. package/dist/adapters/redocly-loader/remote-node-limit.cjs +17 -3
  51. package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -1
  52. package/dist/adapters/redocly-loader/remote-node-limit.mjs +17 -3
  53. package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -1
  54. package/dist/adapters/redocly-loader/schema-source.cjs +7 -2
  55. package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
  56. package/dist/adapters/redocly-loader/schema-source.mjs +8 -3
  57. package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
  58. package/dist/adapters/terminal-logger/terminal-logger.cjs +7 -3
  59. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  60. package/dist/adapters/terminal-logger/terminal-logger.mjs +7 -3
  61. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  62. package/dist/api/cwd-option.cjs +58 -0
  63. package/dist/api/cwd-option.cjs.map +1 -0
  64. package/dist/api/cwd-option.mjs +52 -0
  65. package/dist/api/cwd-option.mjs.map +1 -0
  66. package/dist/api/default-ports.cjs +15 -7
  67. package/dist/api/default-ports.cjs.map +1 -1
  68. package/dist/api/default-ports.mjs +14 -8
  69. package/dist/api/default-ports.mjs.map +1 -1
  70. package/dist/api/document-refs.cjs +16 -1
  71. package/dist/api/document-refs.cjs.map +1 -1
  72. package/dist/api/document-refs.mjs +16 -1
  73. package/dist/api/document-refs.mjs.map +1 -1
  74. package/dist/api/document-run.cjs +6 -26
  75. package/dist/api/document-run.cjs.map +1 -1
  76. package/dist/api/document-run.mjs +5 -21
  77. package/dist/api/document-run.mjs.map +1 -1
  78. package/dist/api/legacy-utils.cjs +1 -1
  79. package/dist/api/legacy-utils.cjs.map +1 -1
  80. package/dist/api/legacy-utils.mjs +1 -1
  81. package/dist/api/legacy-utils.mjs.map +1 -1
  82. package/dist/api/openapi-ts.cjs +1 -2
  83. package/dist/api/openapi-ts.cjs.map +1 -1
  84. package/dist/api/openapi-ts.mjs +2 -3
  85. package/dist/api/openapi-ts.mjs.map +1 -1
  86. package/dist/api/option-errors.cjs +24 -0
  87. package/dist/api/option-errors.cjs.map +1 -0
  88. package/dist/api/option-errors.mjs +21 -0
  89. package/dist/api/option-errors.mjs.map +1 -0
  90. package/dist/api/ref-limit-options.cjs +58 -0
  91. package/dist/api/ref-limit-options.cjs.map +1 -0
  92. package/dist/api/ref-limit-options.mjs +52 -0
  93. package/dist/api/ref-limit-options.mjs.map +1 -0
  94. package/dist/api/transform-schema.cjs +12 -5
  95. package/dist/api/transform-schema.cjs.map +1 -1
  96. package/dist/api/transform-schema.mjs +12 -5
  97. package/dist/api/transform-schema.mjs.map +1 -1
  98. package/dist/application/transform/declared-value-types.cjs +36 -0
  99. package/dist/application/transform/declared-value-types.cjs.map +1 -0
  100. package/dist/application/transform/declared-value-types.mjs +34 -0
  101. package/dist/application/transform/declared-value-types.mjs.map +1 -0
  102. package/dist/application/transform/document/document.cjs +3 -1
  103. package/dist/application/transform/document/document.cjs.map +1 -1
  104. package/dist/application/transform/document/document.mjs +3 -1
  105. package/dist/application/transform/document/document.mjs.map +1 -1
  106. package/dist/application/transform/document/exploded-query-values.cjs +63 -0
  107. package/dist/application/transform/document/exploded-query-values.cjs.map +1 -0
  108. package/dist/application/transform/document/exploded-query-values.mjs +59 -0
  109. package/dist/application/transform/document/exploded-query-values.mjs.map +1 -0
  110. package/dist/application/transform/document/header.cjs +11 -3
  111. package/dist/application/transform/document/header.cjs.map +1 -1
  112. package/dist/application/transform/document/header.mjs +10 -2
  113. package/dist/application/transform/document/header.mjs.map +1 -1
  114. package/dist/application/transform/document/parameter.cjs +1 -1
  115. package/dist/application/transform/document/parameter.cjs.map +1 -1
  116. package/dist/application/transform/document/parameter.mjs +1 -1
  117. package/dist/application/transform/document/parameter.mjs.map +1 -1
  118. package/dist/application/transform/document/parameters.cjs +23 -5
  119. package/dist/application/transform/document/parameters.cjs.map +1 -1
  120. package/dist/application/transform/document/parameters.mjs +23 -5
  121. package/dist/application/transform/document/parameters.mjs.map +1 -1
  122. package/dist/application/transform/document/path-item.cjs +4 -3
  123. package/dist/application/transform/document/path-item.cjs.map +1 -1
  124. package/dist/application/transform/document/path-item.mjs +4 -4
  125. package/dist/application/transform/document/path-item.mjs.map +1 -1
  126. package/dist/application/transform/document/path-template-key.cjs +84 -0
  127. package/dist/application/transform/document/path-template-key.cjs.map +1 -0
  128. package/dist/application/transform/document/path-template-key.mjs +79 -0
  129. package/dist/application/transform/document/path-template-key.mjs.map +1 -0
  130. package/dist/application/transform/document/path-template-refs.cjs +80 -0
  131. package/dist/application/transform/document/path-template-refs.cjs.map +1 -0
  132. package/dist/application/transform/document/path-template-refs.mjs +77 -0
  133. package/dist/application/transform/document/path-template-refs.mjs.map +1 -0
  134. package/dist/application/transform/document/paths-enum.cjs +7 -6
  135. package/dist/application/transform/document/paths-enum.cjs.map +1 -1
  136. package/dist/application/transform/document/paths-enum.mjs +7 -6
  137. package/dist/application/transform/document/paths-enum.mjs.map +1 -1
  138. package/dist/application/transform/document/paths.cjs +38 -66
  139. package/dist/application/transform/document/paths.cjs.map +1 -1
  140. package/dist/application/transform/document/paths.mjs +36 -66
  141. package/dist/application/transform/document/paths.mjs.map +1 -1
  142. package/dist/application/transform/document/webhooks.cjs +10 -3
  143. package/dist/application/transform/document/webhooks.cjs.map +1 -1
  144. package/dist/application/transform/document/webhooks.mjs +9 -2
  145. package/dist/application/transform/document/webhooks.mjs.map +1 -1
  146. package/dist/application/transform/footer/document-footer.cjs +6 -3
  147. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  148. package/dist/application/transform/footer/document-footer.mjs +6 -3
  149. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  150. package/dist/application/transform/helper-types.cjs +3 -3
  151. package/dist/application/transform/helper-types.cjs.map +1 -1
  152. package/dist/application/transform/helper-types.mjs +3 -3
  153. package/dist/application/transform/helper-types.mjs.map +1 -1
  154. package/dist/application/transform/ref-pointer/generated-location.cjs +4 -4
  155. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
  156. package/dist/application/transform/ref-pointer/generated-location.mjs +1 -1
  157. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
  158. package/dist/application/transform/ref-pointer/generated-shape.cjs +63 -64
  159. package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -1
  160. package/dist/application/transform/ref-pointer/generated-shape.mjs +57 -53
  161. package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -1
  162. package/dist/application/transform/ref-pointer/inline-cycles.cjs +2 -2
  163. package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -1
  164. package/dist/application/transform/ref-pointer/inline-cycles.mjs +1 -1
  165. package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -1
  166. package/dist/application/transform/ref-pointer/located-node.cjs +23 -0
  167. package/dist/application/transform/ref-pointer/located-node.cjs.map +1 -0
  168. package/dist/application/transform/ref-pointer/located-node.mjs +18 -0
  169. package/dist/application/transform/ref-pointer/located-node.mjs.map +1 -0
  170. package/dist/application/transform/ref-pointer/original-index.cjs +69 -14
  171. package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -1
  172. package/dist/application/transform/ref-pointer/original-index.mjs +71 -16
  173. package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -1
  174. package/dist/application/transform/ref-pointer/pointer-type.cjs +2 -2
  175. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  176. package/dist/application/transform/ref-pointer/pointer-type.mjs +1 -1
  177. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  178. package/dist/application/transform/ref-pointer/pointer-walk.cjs +54 -13
  179. package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -1
  180. package/dist/application/transform/ref-pointer/pointer-walk.mjs +46 -7
  181. package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -1
  182. package/dist/application/transform/ref-pointer/property-shape.cjs +57 -0
  183. package/dist/application/transform/ref-pointer/property-shape.cjs.map +1 -0
  184. package/dist/application/transform/ref-pointer/property-shape.mjs +49 -0
  185. package/dist/application/transform/ref-pointer/property-shape.mjs.map +1 -0
  186. package/dist/application/transform/ref-pointer/typed-walk.cjs +90 -22
  187. package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -1
  188. package/dist/application/transform/ref-pointer/typed-walk.mjs +87 -19
  189. package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -1
  190. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  191. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  192. package/dist/application/transform/schema/index-signature-type.cjs +21 -0
  193. package/dist/application/transform/schema/index-signature-type.cjs.map +1 -0
  194. package/dist/application/transform/schema/index-signature-type.mjs +19 -0
  195. package/dist/application/transform/schema/index-signature-type.mjs.map +1 -0
  196. package/dist/application/transform/schema/input-location.cjs +23 -0
  197. package/dist/application/transform/schema/input-location.cjs.map +1 -0
  198. package/dist/application/transform/schema/input-location.mjs +21 -0
  199. package/dist/application/transform/schema/input-location.mjs.map +1 -0
  200. package/dist/application/transform/schema/object-type.cjs +15 -5
  201. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  202. package/dist/application/transform/schema/object-type.mjs +15 -5
  203. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  204. package/dist/application/transform/schema/schema-transform.cjs +2 -1
  205. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  206. package/dist/application/transform/schema/schema-transform.mjs +2 -1
  207. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  208. package/dist/application/transform/schema/unevaluated-properties.cjs +2 -30
  209. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  210. package/dist/application/transform/schema/unevaluated-properties.mjs +3 -31
  211. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  212. package/dist/cli/api-logger.cjs +13 -0
  213. package/dist/cli/api-logger.cjs.map +1 -0
  214. package/dist/cli/api-logger.mjs +11 -0
  215. package/dist/cli/api-logger.mjs.map +1 -0
  216. package/dist/cli/api-settings.cjs +10 -17
  217. package/dist/cli/api-settings.cjs.map +1 -1
  218. package/dist/cli/api-settings.mjs +10 -17
  219. package/dist/cli/api-settings.mjs.map +1 -1
  220. package/dist/cli/api-writes.cjs +7 -1
  221. package/dist/cli/api-writes.cjs.map +1 -1
  222. package/dist/cli/api-writes.mjs +7 -1
  223. package/dist/cli/api-writes.mjs.map +1 -1
  224. package/dist/cli/cli-arguments.cjs +32 -74
  225. package/dist/cli/cli-arguments.cjs.map +1 -1
  226. package/dist/cli/cli-arguments.mjs +28 -70
  227. package/dist/cli/cli-arguments.mjs.map +1 -1
  228. package/dist/cli/cli-errors.cjs +18 -0
  229. package/dist/cli/cli-errors.cjs.map +1 -1
  230. package/dist/cli/cli-errors.mjs +18 -1
  231. package/dist/cli/cli-errors.mjs.map +1 -1
  232. package/dist/cli/cli-flag-names.cjs +77 -0
  233. package/dist/cli/cli-flag-names.cjs.map +1 -0
  234. package/dist/cli/cli-flag-names.mjs +64 -0
  235. package/dist/cli/cli-flag-names.mjs.map +1 -0
  236. package/dist/cli/cli-output.cjs +13 -6
  237. package/dist/cli/cli-output.cjs.map +1 -1
  238. package/dist/cli/cli-output.mjs +14 -7
  239. package/dist/cli/cli-output.mjs.map +1 -1
  240. package/dist/cli/main.cjs +11 -5
  241. package/dist/cli/main.cjs.map +1 -1
  242. package/dist/cli/main.mjs +11 -5
  243. package/dist/cli/main.mjs.map +1 -1
  244. package/dist/cli/redocly-apis.cjs +33 -12
  245. package/dist/cli/redocly-apis.cjs.map +1 -1
  246. package/dist/cli/redocly-apis.mjs +35 -14
  247. package/dist/cli/redocly-apis.mjs.map +1 -1
  248. package/dist/cli/ref-limits.cjs +15 -1
  249. package/dist/cli/ref-limits.cjs.map +1 -1
  250. package/dist/cli/ref-limits.mjs +15 -2
  251. package/dist/cli/ref-limits.mjs.map +1 -1
  252. package/dist/cli/run-cli.cjs +24 -7
  253. package/dist/cli/run-cli.cjs.map +1 -1
  254. package/dist/cli/run-cli.mjs +25 -8
  255. package/dist/cli/run-cli.mjs.map +1 -1
  256. package/dist/cli/written-flags.cjs +83 -0
  257. package/dist/cli/written-flags.cjs.map +1 -0
  258. package/dist/cli/written-flags.mjs +77 -0
  259. package/dist/cli/written-flags.mjs.map +1 -0
  260. package/dist/domain/cause-secrets.cjs +31 -16
  261. package/dist/domain/cause-secrets.cjs.map +1 -1
  262. package/dist/domain/cause-secrets.mjs +31 -16
  263. package/dist/domain/cause-secrets.mjs.map +1 -1
  264. package/dist/domain/errors.cjs +3 -0
  265. package/dist/domain/errors.cjs.map +1 -1
  266. package/dist/domain/errors.mjs +3 -0
  267. package/dist/domain/errors.mjs.map +1 -1
  268. package/dist/domain/location-text.cjs +15 -0
  269. package/dist/domain/location-text.cjs.map +1 -0
  270. package/dist/domain/location-text.mjs +13 -0
  271. package/dist/domain/location-text.mjs.map +1 -0
  272. package/dist/domain/openapi/document-places.cjs +55 -0
  273. package/dist/domain/openapi/document-places.cjs.map +1 -0
  274. package/dist/domain/openapi/document-places.mjs +53 -0
  275. package/dist/domain/openapi/document-places.mjs.map +1 -0
  276. package/dist/domain/output-fixes.cjs +8 -2
  277. package/dist/domain/output-fixes.cjs.map +1 -1
  278. package/dist/domain/output-fixes.mjs +8 -2
  279. package/dist/domain/output-fixes.mjs.map +1 -1
  280. package/dist/domain/terminal-text.cjs +31 -0
  281. package/dist/domain/terminal-text.cjs.map +1 -0
  282. package/dist/domain/terminal-text.mjs +29 -0
  283. package/dist/domain/terminal-text.mjs.map +1 -0
  284. package/dist/domain/warnings.cjs +1 -0
  285. package/dist/domain/warnings.cjs.map +1 -1
  286. package/dist/domain/warnings.mjs +1 -0
  287. package/dist/domain/warnings.mjs.map +1 -1
  288. package/dist/index.d.cts +29 -18
  289. package/dist/index.d.mts +29 -18
  290. package/dist/index.d.ts +29 -18
  291. package/package.json +1 -1
  292. package/src/adapters/node-file-system/node-file-system.ts +14 -1
  293. package/src/adapters/pipe-safe-writer/pipe-safe-writer.ts +29 -0
  294. package/src/adapters/redocly-loader/bundled-mapping-copies.ts +7 -42
  295. package/src/adapters/redocly-loader/component-schemas.ts +19 -0
  296. package/src/adapters/redocly-loader/mapping-schema-names.ts +25 -0
  297. package/src/adapters/redocly-loader/query-document-names.ts +79 -0
  298. package/src/adapters/redocly-loader/query-named-components.ts +200 -0
  299. package/src/adapters/redocly-loader/redocly-config-source.ts +11 -1
  300. package/src/adapters/redocly-loader/redocly-schema-loader.ts +63 -17
  301. package/src/adapters/redocly-loader/ref-access.ts +32 -5
  302. package/src/adapters/redocly-loader/ref-holders.ts +75 -14
  303. package/src/adapters/redocly-loader/remote-fetch.ts +37 -2
  304. package/src/adapters/redocly-loader/remote-node-limit.ts +44 -4
  305. package/src/adapters/redocly-loader/schema-source.ts +15 -3
  306. package/src/adapters/terminal-logger/terminal-logger.ts +10 -4
  307. package/src/api/cwd-option.ts +76 -0
  308. package/src/api/default-ports.ts +33 -10
  309. package/src/api/document-refs.ts +29 -1
  310. package/src/api/document-run.ts +7 -32
  311. package/src/api/legacy-utils.ts +1 -1
  312. package/src/api/openapi-ts.ts +20 -4
  313. package/src/api/option-errors.ts +22 -0
  314. package/src/api/ref-limit-options.ts +69 -0
  315. package/src/api/transform-schema.ts +20 -5
  316. package/src/application/ports/file-system.ts +8 -0
  317. package/src/application/ports/redocly-config-source.ts +5 -0
  318. package/src/application/transform/declared-value-types.ts +42 -0
  319. package/src/application/transform/document/document.ts +4 -2
  320. package/src/application/transform/document/exploded-query-values.ts +88 -0
  321. package/src/application/transform/document/header.ts +25 -5
  322. package/src/application/transform/document/parameter.ts +4 -4
  323. package/src/application/transform/document/parameters.ts +45 -10
  324. package/src/application/transform/document/path-item.ts +3 -3
  325. package/src/application/transform/document/path-template-key.ts +152 -0
  326. package/src/application/transform/document/path-template-refs.ts +127 -0
  327. package/src/application/transform/document/paths-enum.ts +23 -9
  328. package/src/application/transform/document/paths.ts +53 -123
  329. package/src/application/transform/document/webhooks.ts +18 -5
  330. package/src/application/transform/footer/document-footer.ts +18 -8
  331. package/src/application/transform/helper-types.ts +4 -4
  332. package/src/application/transform/ref-pointer/generated-location.ts +1 -1
  333. package/src/application/transform/ref-pointer/generated-shape.ts +115 -83
  334. package/src/application/transform/ref-pointer/inline-cycles.ts +1 -1
  335. package/src/application/transform/ref-pointer/located-node.ts +38 -0
  336. package/src/application/transform/ref-pointer/original-index.ts +106 -20
  337. package/src/application/transform/ref-pointer/pointer-type.ts +1 -1
  338. package/src/application/transform/ref-pointer/pointer-walk.ts +82 -8
  339. package/src/application/transform/ref-pointer/property-shape.ts +106 -0
  340. package/src/application/transform/ref-pointer/typed-walk.ts +143 -29
  341. package/src/application/transform/schema/access-flags.ts +5 -2
  342. package/src/application/transform/schema/index-signature-type.ts +31 -0
  343. package/src/application/transform/schema/input-location.ts +35 -0
  344. package/src/application/transform/schema/object-type.ts +18 -8
  345. package/src/application/transform/schema/schema-transform.ts +2 -1
  346. package/src/application/transform/schema/unevaluated-properties.ts +4 -44
  347. package/src/cli/api-logger.ts +17 -0
  348. package/src/cli/api-settings.ts +12 -20
  349. package/src/cli/api-writes.ts +11 -3
  350. package/src/cli/cli-arguments.ts +57 -92
  351. package/src/cli/cli-dependencies.ts +7 -2
  352. package/src/cli/cli-errors.ts +23 -0
  353. package/src/cli/cli-flag-names.ts +99 -0
  354. package/src/cli/cli-output.ts +31 -16
  355. package/src/cli/main.ts +12 -5
  356. package/src/cli/redocly-apis.ts +56 -20
  357. package/src/cli/ref-limits.ts +21 -2
  358. package/src/cli/run-cli.ts +39 -7
  359. package/src/cli/written-flags.ts +131 -0
  360. package/src/domain/cause-secrets.ts +59 -25
  361. package/src/domain/errors.ts +3 -0
  362. package/src/domain/location-text.ts +27 -0
  363. package/src/domain/openapi/document-places.ts +78 -0
  364. package/src/domain/output-fixes.ts +9 -2
  365. package/src/domain/terminal-text.ts +44 -0
  366. package/src/domain/warnings.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,220 @@
2
2
 
3
3
  This package is a fork of `openapi-typescript`. The entries above `7.13.0` are releases of openapi-typesafe; `7.13.0` and the entries below it are the upstream history up to the fork point (upstream commit `d46a319a`), with `openapi-typescript` versions.
4
4
 
5
+ ## 1.0.0-rc.6
6
+
7
+ ### Patch Changes
8
+
9
+ - [#91](https://github.com/openapi-typesafe/openapi-typesafe/pull/91) [`b3fcff5`](https://github.com/openapi-typesafe/openapi-typesafe/commit/b3fcff541be5f8ddd0bbea19b95a60df26fda92e) Thanks [@fedorello](https://github.com/fedorello)! - A `$ref` to the `additionalProperties` of an object that also has `properties`
10
+ (`#/components/schemas/Stats/additionalProperties`) is typed as that schema again. Since the index
11
+ signature also takes the property types, `Stats["additionalProperties"]` read
12
+ `number | { count?: number }`, which accepted `5`, and a `$ref` one level deeper
13
+ (`.../additionalProperties/properties/count`) did not compile, also with `--fix ref-pointers`.
14
+
15
+ - [#92](https://github.com/openapi-typesafe/openapi-typesafe/pull/92) [`cf9c4db`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cf9c4db102193818022a30b46d6476bef2f98a93) Thanks [@fedorello](https://github.com/fedorello)! - With several APIs in `redocly.yaml`, an error about an output file (`OUTPUT_STALE`,
16
+ `OUTPUT_READ_FAILED`, `OUTPUT_WRITE_FAILED`, `CLI_OUTPUT_INVALID`, `CLI_OUTPUT_IS_INPUT`,
17
+ `CLI_OUTPUT_DUPLICATE`) starts with `API <name>:`, as the other errors of an API do.
18
+
19
+ - [#92](https://github.com/openapi-typesafe/openapi-typesafe/pull/92) [`cf9c4db`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cf9c4db102193818022a30b46d6476bef2f98a93) Thanks [@fedorello](https://github.com/fedorello)! - `--check` compares lines, not line ends: an output that Git checked out with CRLF line ends
20
+ (`core.autocrlf` on Windows) is no longer reported as stale (`OUTPUT_STALE`).
21
+
22
+ - [#92](https://github.com/openapi-typesafe/openapi-typesafe/pull/92) [`cf9c4db`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cf9c4db102193818022a30b46d6476bef2f98a93) Thanks [@fedorello](https://github.com/fedorello)! - A path with a colon in its name, such as `-o out:v2.ts` or the schema `spec:v2.yaml`, is read as a
23
+ file path. Any text before a colon was taken as a URL scheme, so the output failed with
24
+ `CLI_OUTPUT_INVALID`. A location is a URL when it starts with `http:`, `https:` or `file:`, or with
25
+ a scheme and `//`.
26
+
27
+ - [#92](https://github.com/openapi-typesafe/openapi-typesafe/pull/92) [`cf9c4db`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cf9c4db102193818022a30b46d6476bef2f98a93) Thanks [@fedorello](https://github.com/fedorello)! - Warnings and errors on stderr get colors only when stderr is a terminal. A log file that stderr
28
+ was redirected to got color escape sequences whenever stdout was a terminal.
29
+
30
+ - [#92](https://github.com/openapi-typesafe/openapi-typesafe/pull/92) [`cf9c4db`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cf9c4db102193818022a30b46d6476bef2f98a93) Thanks [@fedorello](https://github.com/fedorello)! - The Node API's `cwd` option is read like `localRefRoot`: a string such as `"file:///app/specs/"` is
31
+ a URL, where it was read as a relative path. A `cwd` of another type (a number), a URL of another
32
+ scheme, or a relative `localRefRoot` with an `http:` `cwd` rejects with `OPTION_INVALID` instead of
33
+ resolving a wrong directory or throwing a plain `TypeError`.
34
+
35
+ - [#91](https://github.com/openapi-typesafe/openapi-typesafe/pull/91) [`b3fcff5`](https://github.com/openapi-typesafe/openapi-typesafe/commit/b3fcff541be5f8ddd0bbea19b95a60df26fda92e) Thanks [@fedorello](https://github.com/fedorello)! - `--enum-values` with `--path-params-as-types`: the arrays of a path with a `number` or `boolean`
36
+ path parameter compile. Their type indexed `FlattenedDeepRequired<paths>["/items/{id}"]`, a key
37
+ the type does not have (TS2339); it is now indexed by the path's template
38
+ (``FlattenedDeepRequired<paths>[`/items/${number}`]``), as a `$ref` into that path already was.
39
+
40
+ - [#91](https://github.com/openapi-typesafe/openapi-typesafe/pull/91) [`b3fcff5`](https://github.com/openapi-typesafe/openapi-typesafe/commit/b3fcff541be5f8ddd0bbea19b95a60df26fda92e) Thanks [@fedorello](https://github.com/fedorello)! - With `--exclude-deprecated`, a `$ref` to a property it leaves out is typed as that property's
41
+ schema also when the object has `additionalProperties`. It was read through the index signature,
42
+ so a `type: string` property was typed as the `additionalProperties` type (`number`), without an
43
+ error.
44
+
45
+ - [#92](https://github.com/openapi-typesafe/openapi-typesafe/pull/92) [`cf9c4db`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cf9c4db102193818022a30b46d6476bef2f98a93) Thanks [@fedorello](https://github.com/fedorello)! - A second schema argument fails with the new error `CLI_INPUT_EXTRA` (exit code 2). Only the first
46
+ one was generated, so an unquoted glob that the shell expanded (`g/*.yaml`) generated one schema and
47
+ passed.
48
+
49
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - Inline `postTransform` and `transformProperty` callbacks in `openapiTS(source, { … })` without
50
+ `irCallbacks` get their parameter types again (`ts.TypeNode`, `ts.PropertySignature`) instead of
51
+ an implicit `any` that `strict` rejects (TS7006), as with openapi-typescript 7.
52
+
53
+ - [#92](https://github.com/openapi-typesafe/openapi-typesafe/pull/92) [`cf9c4db`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cf9c4db102193818022a30b46d6476bef2f98a93) Thanks [@fedorello](https://github.com/fedorello)! - The `--no-` form of a flag that takes a value (`--no-output`, `--no-redocly`, `--no-fix`,
54
+ `--no-local-ref-root`, `--no-remote-ref-hosts`) fails with `CLI_FLAG_INVALID`. It used the text
55
+ `false` as the value: `--no-output` wrote the types to a file named `false`.
56
+
57
+ - [#91](https://github.com/openapi-typesafe/openapi-typesafe/pull/91) [`b3fcff5`](https://github.com/openapi-typesafe/openapi-typesafe/commit/b3fcff541be5f8ddd0bbea19b95a60df26fda92e) Thanks [@fedorello](https://github.com/fedorello)! - A `$ref` to one pattern of `patternProperties`
58
+ (`#/components/schemas/Labels/patternProperties/^label_`) compiles without `--fix`: it is typed as
59
+ that pattern's schema instead of `components["schemas"]["Labels"]["patternProperties"]["^label_"]`
60
+ (TS2339).
61
+
62
+ - [#92](https://github.com/openapi-typesafe/openapi-typesafe/pull/92) [`cf9c4db`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cf9c4db102193818022a30b46d6476bef2f98a93) Thanks [@fedorello](https://github.com/fedorello)! - With several APIs in `redocly.yaml`, each API is linted with its own `rules` (and other lint
63
+ settings) from `apis.<name>`, as `redocly lint <name>` lints it. Every API was linted with the
64
+ root rules only.
65
+
66
+ - [#92](https://github.com/openapi-typesafe/openapi-typesafe/pull/92) [`cf9c4db`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cf9c4db102193818022a30b46d6476bef2f98a93) Thanks [@fedorello](https://github.com/fedorello)! - Remote `$ref` documents whose queries end in the same text after a `/` (a branch such as
67
+ `?ref=feature/new-api`) are each named after their own file. The pet document was named after the
68
+ owner document (`components["schemas"]["owner"]`), and the owner one `owner-2`.
69
+
70
+ - [#92](https://github.com/openapi-typesafe/openapi-typesafe/pull/92) [`cf9c4db`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cf9c4db102193818022a30b46d6476bef2f98a93) Thanks [@fedorello](https://github.com/fedorello)! - Relative `$ref`s of a remote document that redirects resolve from the URL it was redirected to.
71
+ A spec URL `https://host/latest` that redirects to `/static/v1/root.yaml` loaded `./pet.yaml` from
72
+ `https://host/pet.yaml`, which gave the types of another file or failed with a 404.
73
+
74
+ - [#92](https://github.com/openapi-typesafe/openapi-typesafe/pull/92) [`cf9c4db`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cf9c4db102193818022a30b46d6476bef2f98a93) Thanks [@fedorello](https://github.com/fedorello)! - An unknown flag before the schema no longer takes the schema path as its value:
75
+ `--alphabetise api.yaml -o out.ts` prints the notice for the flag and generates `api.yaml`, where it
76
+ read stdin instead. A schema path that looks like a number (`1.10`, `0x10`) is read as written.
77
+
78
+ ## 1.0.0-rc.5
79
+
80
+ ### Patch Changes
81
+
82
+ - [#70](https://github.com/openapi-typesafe/openapi-typesafe/pull/70) [`d732870`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d732870a9e1d207761c88614a95b778c4f0ebe9d) Thanks [@fedorello](https://github.com/fedorello)! - With several APIs in `redocly.yaml`, an error while an API is loaded or generated starts with
83
+ `API <name>:`, as its config errors do, so it tells which API failed. The code and the exit code
84
+ stay the same. Every warning, problem and debug line of an API's generation (a `$ref` it cannot
85
+ resolve, a lint problem) starts with `API <name>:` too. A notice that a root-types flag has no
86
+ effect follows the CLI flags together with each API's settings and names the API, and an invalid
87
+ `--local-ref-root` fails the run once instead of once for each API.
88
+
89
+ - [#70](https://github.com/openapi-typesafe/openapi-typesafe/pull/70) [`d732870`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d732870a9e1d207761c88614a95b778c4f0ebe9d) Thanks [@fedorello](https://github.com/fedorello)! - Types piped to a reader that stops early (`openapi-typesafe api.yaml | head`) no longer crash the
90
+ CLI with `EPIPE` and exit code `1`; the rest is dropped and the exit code stays `0`.
91
+
92
+ - [#70](https://github.com/openapi-typesafe/openapi-typesafe/pull/70) [`d732870`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d732870a9e1d207761c88614a95b778c4f0ebe9d) Thanks [@fedorello](https://github.com/fedorello)! - CLI flags are read by their names:
93
+ - A removed flag fails with `CLI_FLAG_REMOVED` written with a value too (`--redoc=redocly.yaml`),
94
+ in camelCase (`--immutableTypes`) and with `--no-` (`--no-immutable-types`).
95
+ - The boolean alias `-t` (`--export-type`) takes `=true` and `=false` as the flag does; another
96
+ value fails with `CLI_FLAG_INVALID`.
97
+ - A boolean flag takes no value, or `=true` or `=false`. Another value (`--enum=1`,
98
+ `--no-enum=true`) fails with `CLI_FLAG_INVALID` (exit code `2`) instead of turning the flag off.
99
+ - A flag given more than once takes the last value; `--output` and `--redocly` no longer fail with
100
+ a list.
101
+ - The notice that a root-types flag has no effect without `--root-types` follows the parsed flags:
102
+ `--rootTypes` and `--root-types=true` count, `--root-types=false` does not.
103
+
104
+ - [#76](https://github.com/openapi-typesafe/openapi-typesafe/pull/76) [`e464bc3`](https://github.com/openapi-typesafe/openapi-typesafe/commit/e464bc3c9dcb243a4259307d6b667bde134d8468) Thanks [@fedorello](https://github.com/fedorello)! - A schema argument is a glob pattern, which fails with `CLI_GLOB_UNSUPPORTED`, only when it is a
105
+ path with a `*` that names no file. A URL with a `*` in its query (`…/openapi?fields=*`) and an
106
+ existing file whose name has a `*` are read as any other schema.
107
+
108
+ - [#70](https://github.com/openapi-typesafe/openapi-typesafe/pull/70) [`d732870`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d732870a9e1d207761c88614a95b778c4f0ebe9d) Thanks [@fedorello](https://github.com/fedorello)! - `--output` together with the APIs of `redocly.yaml` warns with `CLI_OUTPUT_IGNORED`: each API is
109
+ written to its `x-openapi-ts.output`, and the `--output` path was ignored without a word.
110
+
111
+ - [#76](https://github.com/openapi-typesafe/openapi-typesafe/pull/76) [`e464bc3`](https://github.com/openapi-typesafe/openapi-typesafe/commit/e464bc3c9dcb243a4259307d6b667bde134d8468) Thanks [@fedorello](https://github.com/fedorello)! - The line for a written file and the notices about flags show a line break or an escape sequence in
112
+ a file name, a flag or an API name as an escape (`\n`, `\u001b`), as warnings and errors already
113
+ do, so a name cannot start a forged line in a CI log.
114
+
115
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `const: null` is typed `null`; it was `unknown`, as if the schema had no `const`.
116
+
117
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `--enum --dedupe-enums` no longer merges enums with other values. Their key joined the member
118
+ names and descriptions as text, and a member name stood in for its value, so `Flag` (`1`, `0`)
119
+ became the `Status` enum (`"A"`, `"I"`) when both named their members `Active` and `Inactive`, and
120
+ `["1", "2"]` and `[1, 2]`, or `["a", "b"]` and `["a:,b"]`, shared one enum. The key also paired
121
+ the values in sorted order with the names in document order, so `[desc, asc]` and `[asc, desc]`,
122
+ both named `[Desc, Asc]`, shared one enum and one of them typed `asc` as `Desc = "desc"`. Enums
123
+ with the same values and member names are still merged.
124
+
125
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - The new fix `default-input-locations` finds parameters and request bodies by the document's
126
+ structure for `--default-non-nullable` (on by default). Without it, as in openapi-typescript, a
127
+ defaulted property stays optional wherever its location holds the word `parameters` or
128
+ `requestBody`, such as a response of `/system-parameters` or a property named `hyperparameters`.
129
+ It changes nothing with `--default-non-nullable=false`, so naming it then prints the warning
130
+ `FIX_NEEDS_OPTION`, as other fixes that need a flag do (`--fix all` does not).
131
+
132
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - With `--exclude-deprecated`, a `$ref` to a property it leaves out
133
+ (`#/components/schemas/A/properties/old`) is typed as that property's schema, instead of naming a
134
+ key the type no longer has. The same holds for a `$ref` into a deprecated operation or response
135
+ header, and a `$ref` through another `$ref` (`Wrap/properties/o/properties/v`, where `o` is a
136
+ `$ref`) no longer warns `REF_NOT_FOUND`. With `--make-paths-enum`, `ApiPaths` lists only the
137
+ operations that `paths` keeps.
138
+
139
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `--fix exploded-query-objects`: an exploded object with `additionalProperties` next to other query
140
+ parameters no longer makes the whole `query` type unusable. Its index signature also takes the
141
+ value types of the other query keys (`{ page?: number } & Partial<{ [key: string]: string | number
142
+ | undefined }>`), since TypeScript checks it against `page` too. A `$ref` to such an object is
143
+ written out in place when other query keys are next to it.
144
+
145
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - An index signature from `additionalProperties` or `patternProperties` also takes the types of the
146
+ properties next to it that it does not admit (`{ total: number } & { [key: string]: string |
147
+ number }`). TypeScript checks the signature against the declared keys too, so the old type took no
148
+ value with those properties.
149
+
150
+ - [#76](https://github.com/openapi-typesafe/openapi-typesafe/pull/76) [`e464bc3`](https://github.com/openapi-typesafe/openapi-typesafe/commit/e464bc3c9dcb243a4259307d6b667bde134d8468) Thanks [@fedorello](https://github.com/fedorello)! - A YAML parse error of a string source or a stream (stdin in the CLI) names it `the schema string`
151
+ or `the schema stream`. It named `<cwd>/inline-source`, a file that does not exist.
152
+
153
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - A discriminator `mapping` value that names a schema (`cat: Cat`), as OpenAPI allows, is read as
154
+ `#/components/schemas/Cat`, also in a document a `$ref` loads, where it names that document's
155
+ schemas. It failed with "Can't resolve $ref"; any other value is still a URI reference. A `mapping`
156
+ inside `example`, `examples`, `default`, `const`, `enum` or an `x-` value is data and stays as
157
+ written. A problem in a document other than the root now names that document: its path, or its URL
158
+ without the query.
159
+
160
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - The `parameter-content` fix is now `parameter-header-content` and types a response header with
161
+ `content` by the schema of its media type too (`"X-Rate": { limit: number }`), not as a map of
162
+ media types. Configs that name `parameter-content` fail with `OPTION_FIX_UNKNOWN` until renamed.
163
+
164
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `--path-params-as-types` with only `boolean` path parameters in a path compiles:
165
+ ``[path: `/flags/${boolean}`]`` is no valid index signature (TS1337), so such a path is written as
166
+ the keys `"/flags/true"` and `"/flags/false"`, with the same path item type (2ⁿ keys for n boolean
167
+ parameters). A key that the document already has as a path is left out. Next to another parameter
168
+ (`` `/a/${number}/${boolean}` ``) the signature is valid and stays as it was.
169
+
170
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `--path-params-as-types`: a `$ref` into a path with a `number` or `boolean` path parameter
171
+ compiles. It was typed as `paths["/pets/{id}"]`, which names no key of
172
+ ``[path: `/pets/${number}`]`` (TS2339); it is now ``paths[`/pets/${number}`]``. A boolean path
173
+ is indexed by the keys it is written with (`paths["/flags/true" | "/flags/false"]`), without the
174
+ one a path of the document takes, so the `$ref` no longer gets that path's type too. With only
175
+ string parameters the URL matches the template, so that output stays as it was.
176
+
177
+ - [#75](https://github.com/openapi-typesafe/openapi-typesafe/pull/75) [`a74608e`](https://github.com/openapi-typesafe/openapi-typesafe/commit/a74608ec36b0a938594e0d0fac10c9fb222c1742) Thanks [@fedorello](https://github.com/fedorello)! - `Readable` and `Writable` find the `$Read` and `$Write` properties of an object with an index
178
+ signature (`additionalProperties`). The keys were read through the index signature, so no
179
+ property was marked: a request body required the `readOnly` `id`, and a response kept the
180
+ `writeOnly` password. The helper types that `--read-write-markers` writes are fixed the same way.
181
+
182
+ - [#70](https://github.com/openapi-typesafe/openapi-typesafe/pull/70) [`d732870`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d732870a9e1d207761c88614a95b778c4f0ebe9d) Thanks [@fedorello](https://github.com/fedorello)! - The `$ref` limits are checked before anything loads:
183
+ - In the Node API, a `remoteRefHosts` that is no list of strings, or a `localRefRoot` that is no
184
+ path or `file:` URL, fails with `OPTION_INVALID` and `details.option`. It failed later as an error
185
+ of the document, such as `hosts.map is not a function`.
186
+ - `--local-ref-root https://…` fails with `CLI_FLAG_INVALID` (exit code `2`) instead of exit code
187
+ `3`, and a `local-ref-root` URL of another protocol in `redocly.yaml` with `CLI_CONFIG_INVALID`.
188
+ - In the Node API, a `localRefRoot` string with a scheme is a URL, as for `--local-ref-root`:
189
+ `"file:///specs/"` is that directory, not a path below `cwd`, and `"https://…"` fails with
190
+ `OPTION_INVALID`.
191
+
192
+ - [#75](https://github.com/openapi-typesafe/openapi-typesafe/pull/75) [`a74608e`](https://github.com/openapi-typesafe/openapi-typesafe/commit/a74608ec36b0a938594e0d0fac10c9fb222c1742) Thanks [@fedorello](https://github.com/fedorello)! - More `$ref`s into a schema compile and get the type they point at:
193
+ - A `$ref` into the `content` of a header or parameter follows the generated type: the media type
194
+ member of a header (`components["headers"]["H"]["text/plain"]`), or with the
195
+ `parameter-header-content` fix the media type's type itself. A parameter typed `string` and
196
+ `content` next to a `schema` are typed in place. Before, `["content"]["text/plain"]["schema"]`
197
+ did not compile (TS2339).
198
+ - With `--read-write-markers`, a `$ref` through an optional property gets `NonNullable` as
199
+ without the flag; one through a `$Read` or `$Write` property is typed in place.
200
+ - A `$ref` through a property with a `default` that the output makes optional (in a request body,
201
+ or under a property named `hyperparameters`) gets `NonNullable`: the property is read as
202
+ optional or required by where it is, not where the `$ref` is.
203
+
204
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - `--fix ref-siblings` also reads the keywords next to the `$ref` of an object property
205
+ (`owner: { $ref: Base, required: [id] }` is `WithRequired<Base, "id">`); it read them only for
206
+ components, array items, bodies and parameters.
207
+
208
+ - [#66](https://github.com/openapi-typesafe/openapi-typesafe/pull/66) [`15344bf`](https://github.com/openapi-typesafe/openapi-typesafe/commit/15344bfb803ff9872a6d3f79b8279fbbbbfd14ea) Thanks [@fedorello](https://github.com/fedorello)! - A remote `$ref` to a document served as `text/plain` loads when its URL has a query after the
209
+ extension (`pet.yaml?token=…`), no extension at all (`/schemas/pet`) or a dot that names no text
210
+ format (`/schemas/v1.0`, `/schemas/pet.v2`); before, it was kept as text and failed with
211
+ `Expected SchemaObject, received string`. A URL whose extension or type names a text format
212
+ (`.md`, `.markdown`, `.txt`, `.html`, `.htm`, `text/markdown`, `text/html`) stays text, as a
213
+ Markdown `description` does.
214
+
215
+ - [#71](https://github.com/openapi-typesafe/openapi-typesafe/pull/71) [`2a03b07`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2a03b072bf201e5e6eeec9ad9744a3f9d513b78a) Thanks [@fedorello](https://github.com/fedorello)! - A webhook that is a `$ref` (often to `components/pathItems`) is typed as the path item it points
216
+ at, as a `$ref` in `paths` is: `petAdded: components["pathItems"]["PetEvent"]`. Every method of
217
+ such a webhook was `never`.
218
+
5
219
  ## 1.0.0-rc.4
6
220
 
7
221
  ### Minor Changes
@@ -100,6 +100,13 @@ class NodeFileSystem {
100
100
  return false;
101
101
  }
102
102
  }
103
+ isFile(file) {
104
+ try {
105
+ return fs__default.statSync(file).isFile();
106
+ } catch {
107
+ return false;
108
+ }
109
+ }
103
110
  isSameFile(left, right) {
104
111
  const leftPath = node_url.fileURLToPath(left);
105
112
  const rightPath = node_url.fileURLToPath(right);
@@ -1 +1 @@
1
- {"version":3,"file":"node-file-system.cjs","sources":["../../../src/adapters/node-file-system/node-file-system.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n ClaimedFile,\n DirectoryCheck,\n FileClaims,\n FileIdentity,\n FileReader,\n FileWriter,\n} from \"../../application/ports/file-system.js\";\nimport { ERROR_CODES, type ErrorCode, OpenAPITypesafeError } from \"../../domain/errors.js\";\nimport { claimFileAt, writeFileAt } from \"./file-claims.js\";\nimport {\n type FileNumber,\n fileIdentityKey,\n isSameFileNumber,\n type PathQueries,\n} from \"./file-identity.js\";\n\n/** The file ports on Node's `fs`, with the failures as typed errors (ADR-011). */\n\nfunction causeMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause);\n}\n\n/**\n * The file number of a path, or undefined when it cannot be read. A missing output is the common\n * case; any other failure (no access, a file used as a directory) is reported by the read or write\n * that follows, so the identity check does not report it a second time.\n */\nfunction statusOf(filePath: string): FileNumber | undefined {\n try {\n const status = fs.statSync(filePath, { bigint: true });\n return { device: status.dev, file: status.ino };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The native `realpath` resolves symbolic links and returns the letter case stored on disk, which\n * the JavaScript one does not do on a case-insensitive file system. A path that vanished since its\n * status was read keeps its own spelling.\n */\nfunction realPathOf(filePath: string): string {\n try {\n return fs.realpathSync.native(filePath);\n } catch {\n return filePath;\n }\n}\n\n/** A directory that cannot be listed has no entry to tell its letter case rules by. */\nfunction entriesOf(directory: string): readonly string[] {\n try {\n return fs.readdirSync(directory);\n } catch {\n return [];\n }\n}\n\n/**\n * The target of a symbolic link, as written in it; undefined for a path that is no link or cannot\n * be read. The key then treats the path as missing, and the claim at write time decides.\n */\nfunction linkTargetOf(filePath: string): string | undefined {\n try {\n return fs.readlinkSync(filePath);\n } catch {\n return undefined;\n }\n}\n\nconst NODE_PATH_QUERIES: PathQueries = {\n status: statusOf,\n realPath: realPathOf,\n entries: entriesOf,\n linkTarget: linkTargetOf,\n};\n\n/** The path of a `file:` URL, or undefined for a URL that names no file on this platform. */\nfunction localPathOf(file: URL): string | undefined {\n try {\n return fileURLToPath(file);\n } catch {\n return undefined;\n }\n}\n\n/**\n * A failed read or write as a typed error. The location is named by its path, or by the URL when\n * it names no local file: computing the path must not throw a second, untyped error here.\n */\nfunction fileError(code: ErrorCode, verb: string, file: URL, cause: unknown): OpenAPITypesafeError {\n const name = localPathOf(file) ?? file.href;\n return new OpenAPITypesafeError({\n code,\n message: `Cannot ${verb} ${name}: ${causeMessage(cause)}`,\n details: { file: name },\n cause,\n });\n}\n\n/** Run a step that writes `file`, with its failure as `OUTPUT_WRITE_FAILED`. */\nfunction typedWrite<T>(file: URL, step: () => T): T {\n try {\n return step();\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n}\n\nclass NodeFileSystem implements FileReader, FileWriter, FileIdentity, DirectoryCheck, FileClaims {\n readText(file: URL): string {\n try {\n return fs.readFileSync(file, \"utf8\");\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_READ_FAILED, \"read\", file, cause);\n }\n }\n\n writeText(file: URL, contents: string): void {\n try {\n writeFileAt(fileURLToPath(file), contents, NODE_PATH_QUERIES);\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n }\n\n claimFile(file: URL): ClaimedFile {\n const claim = typedWrite(file, () => claimFileAt(fileURLToPath(file), NODE_PATH_QUERIES));\n return {\n identity: claim.identity,\n release: () => typedWrite(file, () => claim.release()),\n };\n }\n\n isDirectory(file: URL): boolean {\n try {\n return fs.statSync(file).isDirectory();\n } catch {\n // Missing or unreadable: not a directory; the write that follows reports a failure.\n return false;\n }\n }\n\n isSameFile(left: URL, right: URL): boolean {\n const leftPath = fileURLToPath(left);\n const rightPath = fileURLToPath(right);\n if (leftPath === rightPath) {\n return true;\n }\n const leftStatus = statusOf(leftPath);\n const rightStatus = statusOf(rightPath);\n if (leftStatus && rightStatus && isSameFileNumber(leftStatus, rightStatus)) {\n return true;\n }\n return (\n fileIdentityKey(leftPath, NODE_PATH_QUERIES) === fileIdentityKey(rightPath, NODE_PATH_QUERIES)\n );\n }\n}\n\n/** File access for the CLI. */\nexport function createNodeFileSystem(): FileReader &\n FileWriter &\n FileIdentity &\n DirectoryCheck &\n FileClaims {\n return new NodeFileSystem();\n}\n"],"names":["fs","fileURLToPath","OpenAPITypesafeError","ERROR_CODES","writeFileAt","claimFileAt","isSameFileNumber","fileIdentityKey"],"mappings":";;;;;;;;;;;;AAqBA,SAAS,aAAa,KAAA,EAAwB;AAC5C,EAAA,OAAO,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AAC9D;AAOA,SAAS,SAAS,QAAA,EAA0C;AAC1D,EAAA,IAAI;AACF,IAAA,MAAM,SAASA,WAAA,CAAG,QAAA,CAAS,UAAU,EAAE,MAAA,EAAQ,MAAM,CAAA;AACrD,IAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,CAAO,GAAA,EAAK,IAAA,EAAM,OAAO,GAAA,EAAI;AAAA,EAChD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAOA,SAAS,WAAW,QAAA,EAA0B;AAC5C,EAAA,IAAI;AACF,IAAA,OAAOA,WAAA,CAAG,YAAA,CAAa,MAAA,CAAO,QAAQ,CAAA;AAAA,EACxC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,QAAA;AAAA,EACT;AACF;AAGA,SAAS,UAAU,SAAA,EAAsC;AACvD,EAAA,IAAI;AACF,IAAA,OAAOA,WAAA,CAAG,YAAY,SAAS,CAAA;AAAA,EACjC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAC;AAAA,EACV;AACF;AAMA,SAAS,aAAa,QAAA,EAAsC;AAC1D,EAAA,IAAI;AACF,IAAA,OAAOA,WAAA,CAAG,aAAa,QAAQ,CAAA;AAAA,EACjC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAEA,MAAM,iBAAA,GAAiC;AAAA,EACrC,MAAA,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,CAAgB,WAAW,iBAAiB,CAAA;AAAA,EAEjG;AACF;AAGO,SAAS,oBAAA,GAIH;AACX,EAAA,OAAO,IAAI,cAAA,EAAe;AAC5B;;"}
1
+ {"version":3,"file":"node-file-system.cjs","sources":["../../../src/adapters/node-file-system/node-file-system.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n ClaimedFile,\n DirectoryCheck,\n FileCheck,\n FileClaims,\n FileIdentity,\n FileReader,\n FileWriter,\n} from \"../../application/ports/file-system.js\";\nimport { ERROR_CODES, type ErrorCode, OpenAPITypesafeError } from \"../../domain/errors.js\";\nimport { claimFileAt, writeFileAt } from \"./file-claims.js\";\nimport {\n type FileNumber,\n fileIdentityKey,\n isSameFileNumber,\n type PathQueries,\n} from \"./file-identity.js\";\n\n/** The file ports on Node's `fs`, with the failures as typed errors (ADR-011). */\n\nfunction causeMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause);\n}\n\n/**\n * The file number of a path, or undefined when it cannot be read. A missing output is the common\n * case; any other failure (no access, a file used as a directory) is reported by the read or write\n * that follows, so the identity check does not report it a second time.\n */\nfunction statusOf(filePath: string): FileNumber | undefined {\n try {\n const status = fs.statSync(filePath, { bigint: true });\n return { device: status.dev, file: status.ino };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The native `realpath` resolves symbolic links and returns the letter case stored on disk, which\n * the JavaScript one does not do on a case-insensitive file system. A path that vanished since its\n * status was read keeps its own spelling.\n */\nfunction realPathOf(filePath: string): string {\n try {\n return fs.realpathSync.native(filePath);\n } catch {\n return filePath;\n }\n}\n\n/** A directory that cannot be listed has no entry to tell its letter case rules by. */\nfunction entriesOf(directory: string): readonly string[] {\n try {\n return fs.readdirSync(directory);\n } catch {\n return [];\n }\n}\n\n/**\n * The target of a symbolic link, as written in it; undefined for a path that is no link or cannot\n * be read. The key then treats the path as missing, and the claim at write time decides.\n */\nfunction linkTargetOf(filePath: string): string | undefined {\n try {\n return fs.readlinkSync(filePath);\n } catch {\n return undefined;\n }\n}\n\nconst NODE_PATH_QUERIES: PathQueries = {\n status: statusOf,\n realPath: realPathOf,\n entries: entriesOf,\n linkTarget: linkTargetOf,\n};\n\n/** The path of a `file:` URL, or undefined for a URL that names no file on this platform. */\nfunction localPathOf(file: URL): string | undefined {\n try {\n return fileURLToPath(file);\n } catch {\n return undefined;\n }\n}\n\n/**\n * A failed read or write as a typed error. The location is named by its path, or by the URL when\n * it names no local file: computing the path must not throw a second, untyped error here.\n */\nfunction fileError(code: ErrorCode, verb: string, file: URL, cause: unknown): OpenAPITypesafeError {\n const name = localPathOf(file) ?? file.href;\n return new OpenAPITypesafeError({\n code,\n message: `Cannot ${verb} ${name}: ${causeMessage(cause)}`,\n details: { file: name },\n cause,\n });\n}\n\n/** Run a step that writes `file`, with its failure as `OUTPUT_WRITE_FAILED`. */\nfunction typedWrite<T>(file: URL, step: () => T): T {\n try {\n return step();\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n}\n\nclass NodeFileSystem\n implements FileReader, FileWriter, FileIdentity, DirectoryCheck, FileCheck, FileClaims\n{\n readText(file: URL): string {\n try {\n return fs.readFileSync(file, \"utf8\");\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_READ_FAILED, \"read\", file, cause);\n }\n }\n\n writeText(file: URL, contents: string): void {\n try {\n writeFileAt(fileURLToPath(file), contents, NODE_PATH_QUERIES);\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n }\n\n claimFile(file: URL): ClaimedFile {\n const claim = typedWrite(file, () => claimFileAt(fileURLToPath(file), NODE_PATH_QUERIES));\n return {\n identity: claim.identity,\n release: () => typedWrite(file, () => claim.release()),\n };\n }\n\n isDirectory(file: URL): boolean {\n try {\n return fs.statSync(file).isDirectory();\n } catch {\n // Missing or unreadable: not a directory; the write that follows reports a failure.\n return false;\n }\n }\n\n isFile(file: URL): boolean {\n try {\n return fs.statSync(file).isFile();\n } catch {\n // Missing or unreadable: no file; the read that follows reports a failure.\n return false;\n }\n }\n\n isSameFile(left: URL, right: URL): boolean {\n const leftPath = fileURLToPath(left);\n const rightPath = fileURLToPath(right);\n if (leftPath === rightPath) {\n return true;\n }\n const leftStatus = statusOf(leftPath);\n const rightStatus = statusOf(rightPath);\n if (leftStatus && rightStatus && isSameFileNumber(leftStatus, rightStatus)) {\n return true;\n }\n return (\n fileIdentityKey(leftPath, NODE_PATH_QUERIES) === fileIdentityKey(rightPath, NODE_PATH_QUERIES)\n );\n }\n}\n\n/** File access for the CLI. */\nexport function createNodeFileSystem(): FileReader &\n FileWriter &\n FileIdentity &\n DirectoryCheck &\n FileCheck &\n FileClaims {\n return new NodeFileSystem();\n}\n"],"names":["fs","fileURLToPath","OpenAPITypesafeError","ERROR_CODES","writeFileAt","claimFileAt","isSameFileNumber","fileIdentityKey"],"mappings":";;;;;;;;;;;;AAsBA,SAAS,aAAa,KAAA,EAAwB;AAC5C,EAAA,OAAO,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AAC9D;AAOA,SAAS,SAAS,QAAA,EAA0C;AAC1D,EAAA,IAAI;AACF,IAAA,MAAM,SAASA,WAAA,CAAG,QAAA,CAAS,UAAU,EAAE,MAAA,EAAQ,MAAM,CAAA;AACrD,IAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,CAAO,GAAA,EAAK,IAAA,EAAM,OAAO,GAAA,EAAI;AAAA,EAChD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAOA,SAAS,WAAW,QAAA,EAA0B;AAC5C,EAAA,IAAI;AACF,IAAA,OAAOA,WAAA,CAAG,YAAA,CAAa,MAAA,CAAO,QAAQ,CAAA;AAAA,EACxC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,QAAA;AAAA,EACT;AACF;AAGA,SAAS,UAAU,SAAA,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AQ;AAEN,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,UAAA,CAAW,MAAW,KAAA,EAAqB;AACzC,IAAA,MAAM,QAAA,GAAWC,uBAAc,IAAI,CAAA;AACnC,IAAA,MAAM,SAAA,GAAYA,uBAAc,KAAK,CAAA;AACrC,IAAA,IAAI,aAAa,SAAA,EAAW;AAC1B,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,MAAM,UAAA,GAAa,SAAS,QAAQ,CAAA;AACpC,IAAA,MAAM,WAAA,GAAc,SAAS,SAAS,CAAA;AACtC,IAAA,IAAI,UAAA,IAAc,WAAA,IAAeK,6BAAA,CAAiB,UAAA,EAAY,WAAW,CAAA,EAAG;AAC1E,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,OACEC,6BAAgB,QAAA,EAAU,iBAAiB,CAAA,KAAMA,4BAAA,CAAgB,WAAW,iBAAiB,CAAA;AAAA,EAEjG;AACF;AAGO,SAAS,oBAAA,GAKH;AACX,EAAA,OAAO,IAAI,cAAA,EAAe;AAC5B;;"}
@@ -94,6 +94,13 @@ class NodeFileSystem {
94
94
  return false;
95
95
  }
96
96
  }
97
+ isFile(file) {
98
+ try {
99
+ return fs.statSync(file).isFile();
100
+ } catch {
101
+ return false;
102
+ }
103
+ }
97
104
  isSameFile(left, right) {
98
105
  const leftPath = fileURLToPath(left);
99
106
  const rightPath = fileURLToPath(right);
@@ -1 +1 @@
1
- {"version":3,"file":"node-file-system.mjs","sources":["../../../src/adapters/node-file-system/node-file-system.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n ClaimedFile,\n DirectoryCheck,\n FileClaims,\n FileIdentity,\n FileReader,\n FileWriter,\n} from \"../../application/ports/file-system.js\";\nimport { ERROR_CODES, type ErrorCode, OpenAPITypesafeError } from \"../../domain/errors.js\";\nimport { claimFileAt, writeFileAt } from \"./file-claims.js\";\nimport {\n type FileNumber,\n fileIdentityKey,\n isSameFileNumber,\n type PathQueries,\n} from \"./file-identity.js\";\n\n/** The file ports on Node's `fs`, with the failures as typed errors (ADR-011). */\n\nfunction causeMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause);\n}\n\n/**\n * The file number of a path, or undefined when it cannot be read. A missing output is the common\n * case; any other failure (no access, a file used as a directory) is reported by the read or write\n * that follows, so the identity check does not report it a second time.\n */\nfunction statusOf(filePath: string): FileNumber | undefined {\n try {\n const status = fs.statSync(filePath, { bigint: true });\n return { device: status.dev, file: status.ino };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The native `realpath` resolves symbolic links and returns the letter case stored on disk, which\n * the JavaScript one does not do on a case-insensitive file system. A path that vanished since its\n * status was read keeps its own spelling.\n */\nfunction realPathOf(filePath: string): string {\n try {\n return fs.realpathSync.native(filePath);\n } catch {\n return filePath;\n }\n}\n\n/** A directory that cannot be listed has no entry to tell its letter case rules by. */\nfunction entriesOf(directory: string): readonly string[] {\n try {\n return fs.readdirSync(directory);\n } catch {\n return [];\n }\n}\n\n/**\n * The target of a symbolic link, as written in it; undefined for a path that is no link or cannot\n * be read. The key then treats the path as missing, and the claim at write time decides.\n */\nfunction linkTargetOf(filePath: string): string | undefined {\n try {\n return fs.readlinkSync(filePath);\n } catch {\n return undefined;\n }\n}\n\nconst NODE_PATH_QUERIES: PathQueries = {\n status: statusOf,\n realPath: realPathOf,\n entries: entriesOf,\n linkTarget: linkTargetOf,\n};\n\n/** The path of a `file:` URL, or undefined for a URL that names no file on this platform. */\nfunction localPathOf(file: URL): string | undefined {\n try {\n return fileURLToPath(file);\n } catch {\n return undefined;\n }\n}\n\n/**\n * A failed read or write as a typed error. The location is named by its path, or by the URL when\n * it names no local file: computing the path must not throw a second, untyped error here.\n */\nfunction fileError(code: ErrorCode, verb: string, file: URL, cause: unknown): OpenAPITypesafeError {\n const name = localPathOf(file) ?? file.href;\n return new OpenAPITypesafeError({\n code,\n message: `Cannot ${verb} ${name}: ${causeMessage(cause)}`,\n details: { file: name },\n cause,\n });\n}\n\n/** Run a step that writes `file`, with its failure as `OUTPUT_WRITE_FAILED`. */\nfunction typedWrite<T>(file: URL, step: () => T): T {\n try {\n return step();\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n}\n\nclass NodeFileSystem implements FileReader, FileWriter, FileIdentity, DirectoryCheck, FileClaims {\n readText(file: URL): string {\n try {\n return fs.readFileSync(file, \"utf8\");\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_READ_FAILED, \"read\", file, cause);\n }\n }\n\n writeText(file: URL, contents: string): void {\n try {\n writeFileAt(fileURLToPath(file), contents, NODE_PATH_QUERIES);\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n }\n\n claimFile(file: URL): ClaimedFile {\n const claim = typedWrite(file, () => claimFileAt(fileURLToPath(file), NODE_PATH_QUERIES));\n return {\n identity: claim.identity,\n release: () => typedWrite(file, () => claim.release()),\n };\n }\n\n isDirectory(file: URL): boolean {\n try {\n return fs.statSync(file).isDirectory();\n } catch {\n // Missing or unreadable: not a directory; the write that follows reports a failure.\n return false;\n }\n }\n\n isSameFile(left: URL, right: URL): boolean {\n const leftPath = fileURLToPath(left);\n const rightPath = fileURLToPath(right);\n if (leftPath === rightPath) {\n return true;\n }\n const leftStatus = statusOf(leftPath);\n const rightStatus = statusOf(rightPath);\n if (leftStatus && rightStatus && isSameFileNumber(leftStatus, rightStatus)) {\n return true;\n }\n return (\n fileIdentityKey(leftPath, NODE_PATH_QUERIES) === fileIdentityKey(rightPath, NODE_PATH_QUERIES)\n );\n }\n}\n\n/** File access for the CLI. */\nexport function createNodeFileSystem(): FileReader &\n FileWriter &\n FileIdentity &\n DirectoryCheck &\n FileClaims {\n return new NodeFileSystem();\n}\n"],"names":[],"mappings":";;;;;;AAqBA,SAAS,aAAa,KAAA,EAAwB;AAC5C,EAAA,OAAO,KAAA,YAAiB,KA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YAAY,aAAA,CAAc,IAAI,CAAA,EAAG,iBAAiB,CAAC,CAAA;AACxF,IAAA,OAAO;AAAA,MACL,UAAU,KAAA,CAAM,QAAA;AAAA,MAChB,SAAS,MAAM,UAAA,CAAW,MAAM,MAAM,KAAA,CAAM,SAAS;AAAA,KACvD;AAAA,EACF;AAAA,EAEA,YAAY,IAAA,EAAoB;AAC9B,IAAA,IAAI;AACF,MAAA,OAAO,EAAA,CAAG,QAAA,CAAS,IAAI,CAAA,CAAE,WAAA,EAAY;AAAA,IACvC,CAAA,CAAA,MAAQ;AAEN,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,UAAA,CAAW,MAAW,KAAA,EAAqB;AACzC,IAAA,MAAM,QAAA,GAAW,cAAc,IAAI,CAAA;AACnC,IAAA,MAAM,SAAA,GAAY,cAAc,KAAK,CAAA;AACrC,IAAA,IAAI,aAAa,SAAA,EAAW;AAC1B,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,MAAM,UAAA,GAAa,SAAS,QAAQ,CAAA;AACpC,IAAA,MAAM,WAAA,GAAc,SAAS,SAAS,CAAA;AACtC,IAAA,IAAI,UAAA,IAAc,WAAA,IAAe,gBAAA,CAAiB,UAAA,EAAY,WAAW,CAAA,EAAG;AAC1E,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,OACE,gBAAgB,QAAA,EAAU,iBAAiB,CAAA,KAAM,eAAA,CAAgB,WAAW,iBAAiB,CAAA;AAAA,EAEjG;AACF;AAGO,SAAS,oBAAA,GAIH;AACX,EAAA,OAAO,IAAI,cAAA,EAAe;AAC5B;;"}
1
+ {"version":3,"file":"node-file-system.mjs","sources":["../../../src/adapters/node-file-system/node-file-system.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n ClaimedFile,\n DirectoryCheck,\n FileCheck,\n FileClaims,\n FileIdentity,\n FileReader,\n FileWriter,\n} from \"../../application/ports/file-system.js\";\nimport { ERROR_CODES, type ErrorCode, OpenAPITypesafeError } from \"../../domain/errors.js\";\nimport { claimFileAt, writeFileAt } from \"./file-claims.js\";\nimport {\n type FileNumber,\n fileIdentityKey,\n isSameFileNumber,\n type PathQueries,\n} from \"./file-identity.js\";\n\n/** The file ports on Node's `fs`, with the failures as typed errors (ADR-011). */\n\nfunction causeMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause);\n}\n\n/**\n * The file number of a path, or undefined when it cannot be read. A missing output is the common\n * case; any other failure (no access, a file used as a directory) is reported by the read or write\n * that follows, so the identity check does not report it a second time.\n */\nfunction statusOf(filePath: string): FileNumber | undefined {\n try {\n const status = fs.statSync(filePath, { bigint: true });\n return { device: status.dev, file: status.ino };\n } catch {\n return undefined;\n }\n}\n\n/**\n * The native `realpath` resolves symbolic links and returns the letter case stored on disk, which\n * the JavaScript one does not do on a case-insensitive file system. A path that vanished since its\n * status was read keeps its own spelling.\n */\nfunction realPathOf(filePath: string): string {\n try {\n return fs.realpathSync.native(filePath);\n } catch {\n return filePath;\n }\n}\n\n/** A directory that cannot be listed has no entry to tell its letter case rules by. */\nfunction entriesOf(directory: string): readonly string[] {\n try {\n return fs.readdirSync(directory);\n } catch {\n return [];\n }\n}\n\n/**\n * The target of a symbolic link, as written in it; undefined for a path that is no link or cannot\n * be read. The key then treats the path as missing, and the claim at write time decides.\n */\nfunction linkTargetOf(filePath: string): string | undefined {\n try {\n return fs.readlinkSync(filePath);\n } catch {\n return undefined;\n }\n}\n\nconst NODE_PATH_QUERIES: PathQueries = {\n status: statusOf,\n realPath: realPathOf,\n entries: entriesOf,\n linkTarget: linkTargetOf,\n};\n\n/** The path of a `file:` URL, or undefined for a URL that names no file on this platform. */\nfunction localPathOf(file: URL): string | undefined {\n try {\n return fileURLToPath(file);\n } catch {\n return undefined;\n }\n}\n\n/**\n * A failed read or write as a typed error. The location is named by its path, or by the URL when\n * it names no local file: computing the path must not throw a second, untyped error here.\n */\nfunction fileError(code: ErrorCode, verb: string, file: URL, cause: unknown): OpenAPITypesafeError {\n const name = localPathOf(file) ?? file.href;\n return new OpenAPITypesafeError({\n code,\n message: `Cannot ${verb} ${name}: ${causeMessage(cause)}`,\n details: { file: name },\n cause,\n });\n}\n\n/** Run a step that writes `file`, with its failure as `OUTPUT_WRITE_FAILED`. */\nfunction typedWrite<T>(file: URL, step: () => T): T {\n try {\n return step();\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n}\n\nclass NodeFileSystem\n implements FileReader, FileWriter, FileIdentity, DirectoryCheck, FileCheck, FileClaims\n{\n readText(file: URL): string {\n try {\n return fs.readFileSync(file, \"utf8\");\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_READ_FAILED, \"read\", file, cause);\n }\n }\n\n writeText(file: URL, contents: string): void {\n try {\n writeFileAt(fileURLToPath(file), contents, NODE_PATH_QUERIES);\n } catch (cause) {\n throw fileError(ERROR_CODES.OUTPUT_WRITE_FAILED, \"write\", file, cause);\n }\n }\n\n claimFile(file: URL): ClaimedFile {\n const claim = typedWrite(file, () => claimFileAt(fileURLToPath(file), NODE_PATH_QUERIES));\n return {\n identity: claim.identity,\n release: () => typedWrite(file, () => claim.release()),\n };\n }\n\n isDirectory(file: URL): boolean {\n try {\n return fs.statSync(file).isDirectory();\n } catch {\n // Missing or unreadable: not a directory; the write that follows reports a failure.\n return false;\n }\n }\n\n isFile(file: URL): boolean {\n try {\n return fs.statSync(file).isFile();\n } catch {\n // Missing or unreadable: no file; the read that follows reports a failure.\n return false;\n }\n }\n\n isSameFile(left: URL, right: URL): boolean {\n const leftPath = fileURLToPath(left);\n const rightPath = fileURLToPath(right);\n if (leftPath === rightPath) {\n return true;\n }\n const leftStatus = statusOf(leftPath);\n const rightStatus = statusOf(rightPath);\n if (leftStatus && rightStatus && isSameFileNumber(leftStatus, rightStatus)) {\n return true;\n }\n return (\n fileIdentityKey(leftPath, NODE_PATH_QUERIES) === fileIdentityKey(rightPath, NODE_PATH_QUERIES)\n );\n }\n}\n\n/** File access for the CLI. */\nexport function createNodeFileSystem(): FileReader &\n FileWriter &\n FileIdentity &\n DirectoryCheck &\n FileCheck &\n FileClaims {\n return new NodeFileSystem();\n}\n"],"names":[],"mappings":";;;;;;AAsBA,SAAS,aAAa,KAAA,EAAwB;AAC5C,EAAA,OAAO,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AAC9D;AAOA,SAAS,SAAS,QAAA,EAA0C;AAC1D,EAAA,IAAI;AACF,IAAA,MAAM,SAAS,EAAA,CAAG,QAAA,CAAS,UAAU,EAAE,MAAA,EAAQ,MAAM,CAAA;AACrD,IAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,CAAO,GAAA,EAAK,IAAA,EAAM,OAAO,GAAA,EAAI;AAAA,EAChD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAOA,SAAS,WAAW,QAAA,EAA0B;AAC5C,EAAA,IAAI;AACF,IAAA,OAAO,EAAA,CAAG,YAAA,CAAa,MAAA,CAAO,QAAQ,CAAA;AAAA,EACxC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,QAAA;AAAA,EACT;AACF;AAGA,SAAS,UAAU,SAAA,EAAsC;AACvD,EAAA,IAAI;AACF,IAAA,OAAO,EAAA,CAAG,YAAY,SAAS,CAAA;AAAA,EACjC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAC;AAAA,EACV;AACF;AAMA,SAAS,aAAa,QAAA,EAAsC;AAC1D,EAAA,IAAI;AACF,IAAA,OAAO,EAAA,CAAG,aAAa,QAAQ,CAAA;AAAA,EACjC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAEA,MAAM,iBAAA,GAAiC;AAAA,EACrC,MAAA,EAAQ,QAAA;AAAA,EACR,QAAA,EAAU,UAAA;AAAA,EACV,OAAA,EAAS,SAAA;AA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AA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,OACE,gBAAgB,QAAA,EAAU,iBAAiB,CAAA,KAAM,eAAA,CAAgB,WAAW,iBAAiB,CAAA;AAAA,EAEjG;AACF;AAGO,SAAS,oBAAA,GAKH;AACX,EAAA,OAAO,IAAI,cAAA,EAAe;AAC5B;;"}
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const BROKEN_PIPE = "EPIPE";
4
+ function isBrokenPipe(error) {
5
+ return error.code === BROKEN_PIPE;
6
+ }
7
+ function createPipeSafeWriter(stream) {
8
+ stream.on("error", (error) => {
9
+ if (!isBrokenPipe(error)) {
10
+ throw error;
11
+ }
12
+ });
13
+ return (text) => {
14
+ stream.write(text);
15
+ };
16
+ }
17
+
18
+ exports.createPipeSafeWriter = createPipeSafeWriter;
19
+ //# sourceMappingURL=pipe-safe-writer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe-safe-writer.cjs","sources":["../../../src/adapters/pipe-safe-writer/pipe-safe-writer.ts"],"sourcesContent":["import type { Writable } from \"node:stream\";\n\n/**\n * A writer for the CLI's stdout that stops when the reader closes the pipe (`| head`): the write\n * fails with `EPIPE`, which Node raises as an unhandled `error` event and a crash with exit code\n * 1. The reader has all it wanted, so the rest is dropped and the run ends as it would have.\n * Every other write error is thrown again, as before.\n */\n\nconst BROKEN_PIPE = \"EPIPE\";\n\nfunction isBrokenPipe(error: Error): boolean {\n return (error as NodeJS.ErrnoException).code === BROKEN_PIPE;\n}\n\n/**\n * The text writer of the stream. After `EPIPE` the stream is destroyed, so later writes are\n * dropped by the stream itself and raise no second error.\n */\nexport function createPipeSafeWriter(stream: Writable): (text: string) => void {\n stream.on(\"error\", (error: Error) => {\n if (!isBrokenPipe(error)) {\n throw error;\n }\n });\n return (text) => {\n stream.write(text);\n };\n}\n"],"names":[],"mappings":";;AASA,MAAM,WAAA,GAAc,OAAA;AAEpB,SAAS,aAAa,KAAA,EAAuB;AAC3C,EAAA,OAAQ,MAAgC,IAAA,KAAS,WAAA;AACnD;AAMO,SAAS,qBAAqB,MAAA,EAA0C;AAC7E,EAAA,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,CAAC,KAAA,KAAiB;AACnC,IAAA,IAAI,CAAC,YAAA,CAAa,KAAK,CAAA,EAAG;AACxB,MAAA,MAAM,KAAA;AAAA,IACR;AAAA,EACF,CAAC,CAAA;AACD,EAAA,OAAO,CAAC,IAAA,KAAS;AACf,IAAA,MAAA,CAAO,MAAM,IAAI,CAAA;AAAA,EACnB,CAAA;AACF;;"}
@@ -0,0 +1,17 @@
1
+ const BROKEN_PIPE = "EPIPE";
2
+ function isBrokenPipe(error) {
3
+ return error.code === BROKEN_PIPE;
4
+ }
5
+ function createPipeSafeWriter(stream) {
6
+ stream.on("error", (error) => {
7
+ if (!isBrokenPipe(error)) {
8
+ throw error;
9
+ }
10
+ });
11
+ return (text) => {
12
+ stream.write(text);
13
+ };
14
+ }
15
+
16
+ export { createPipeSafeWriter };
17
+ //# sourceMappingURL=pipe-safe-writer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe-safe-writer.mjs","sources":["../../../src/adapters/pipe-safe-writer/pipe-safe-writer.ts"],"sourcesContent":["import type { Writable } from \"node:stream\";\n\n/**\n * A writer for the CLI's stdout that stops when the reader closes the pipe (`| head`): the write\n * fails with `EPIPE`, which Node raises as an unhandled `error` event and a crash with exit code\n * 1. The reader has all it wanted, so the rest is dropped and the run ends as it would have.\n * Every other write error is thrown again, as before.\n */\n\nconst BROKEN_PIPE = \"EPIPE\";\n\nfunction isBrokenPipe(error: Error): boolean {\n return (error as NodeJS.ErrnoException).code === BROKEN_PIPE;\n}\n\n/**\n * The text writer of the stream. After `EPIPE` the stream is destroyed, so later writes are\n * dropped by the stream itself and raise no second error.\n */\nexport function createPipeSafeWriter(stream: Writable): (text: string) => void {\n stream.on(\"error\", (error: Error) => {\n if (!isBrokenPipe(error)) {\n throw error;\n }\n });\n return (text) => {\n stream.write(text);\n };\n}\n"],"names":[],"mappings":"AASA,MAAM,WAAA,GAAc,OAAA;AAEpB,SAAS,aAAa,KAAA,EAAuB;AAC3C,EAAA,OAAQ,MAAgC,IAAA,KAAS,WAAA;AACnD;AAMO,SAAS,qBAAqB,MAAA,EAA0C;AAC7E,EAAA,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,CAAC,KAAA,KAAiB;AACnC,IAAA,IAAI,CAAC,YAAA,CAAa,KAAK,CAAA,EAAG;AACxB,MAAA,MAAM,KAAA;AAAA,IACR;AAAA,EACF,CAAC,CAAA;AACD,EAAA,OAAO,CAAC,IAAA,KAAS;AACf,IAAA,MAAA,CAAO,MAAM,IAAI,CAAA;AAAA,EACnB,CAAA;AACF;;"}
@@ -1,19 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const jsonPointer = require('../../domain/openapi/json-pointer.cjs');
4
+ const componentSchemas = require('./component-schemas.cjs');
4
5
  const refHolders = require('./ref-holders.cjs');
5
6
 
6
- const SCHEMAS_POINTER = jsonPointer.childPointer(jsonPointer.childPointer(jsonPointer.ROOT_POINTER, "components"), "schemas");
7
- function isContainer(value) {
8
- return typeof value === "object" && value !== null;
9
- }
10
- function schemasOf(document) {
11
- const components = isContainer(document) ? document.components : void 0;
12
- const schemas = isContainer(components) ? components.schemas : void 0;
13
- return isContainer(schemas) ? schemas : void 0;
14
- }
15
7
  function schemaKeysOf(document) {
16
- return new Set(Object.keys(schemasOf(document) ?? {}));
8
+ return new Set(Object.keys(componentSchemas.componentSchemasOf(document) ?? {}));
17
9
  }
18
10
  function copiesIn(schemas, keysBefore) {
19
11
  const originals = /* @__PURE__ */ new Map();
@@ -26,38 +18,19 @@ function copiesIn(schemas, keysBefore) {
26
18
  for (const [key, value] of Object.entries(schemas)) {
27
19
  const original = keysBefore.has(key) ? void 0 : originals.get(value);
28
20
  if (original !== void 0) {
29
- copies.set(`${SCHEMAS_POINTER}/${key}`, jsonPointer.childPointer(SCHEMAS_POINTER, original));
21
+ copies.set(`${componentSchemas.SCHEMAS_POINTER}/${key}`, jsonPointer.childPointer(componentSchemas.SCHEMAS_POINTER, original));
30
22
  delete schemas[key];
31
23
  }
32
24
  }
33
25
  return copies;
34
26
  }
35
- function mappingsOf(document) {
36
- const mappings = [];
37
- const visited = /* @__PURE__ */ new WeakSet();
38
- const pending = [document];
39
- for (let next = pending.pop(); next !== void 0; next = pending.pop()) {
40
- if (!isContainer(next) || visited.has(next)) {
41
- continue;
42
- }
43
- visited.add(next);
44
- const mapping = isContainer(next.discriminator) ? next.discriminator.mapping : void 0;
45
- if (isContainer(mapping)) {
46
- mappings.push(mapping);
47
- }
48
- for (const child of Object.values(next)) {
49
- pending.push(child);
50
- }
51
- }
52
- return mappings;
53
- }
54
27
  function removeBundledMappingCopies(bundled, keysBefore) {
55
- const schemas = schemasOf(bundled);
28
+ const schemas = componentSchemas.componentSchemasOf(bundled);
56
29
  const copies = schemas === void 0 ? /* @__PURE__ */ new Map() : copiesIn(schemas, keysBefore);
57
30
  if (copies.size === 0) {
58
31
  return;
59
32
  }
60
- for (const mapping of mappingsOf(bundled)) {
33
+ for (const mapping of refHolders.findMappings(bundled)) {
61
34
  for (const [name, value] of Object.entries(mapping)) {
62
35
  const original = typeof value === "string" ? copies.get(value) : void 0;
63
36
  if (original !== void 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"bundled-mapping-copies.cjs","sources":["../../../src/adapters/redocly-loader/bundled-mapping-copies.ts"],"sourcesContent":["import { childPointer, ROOT_POINTER } from \"../../domain/openapi/json-pointer.js\";\nimport { findRefHolders } from \"./ref-holders.js\";\n\n/**\n * Redocly 1.x bundles every discriminator `mapping` value as if it were an external `$ref`: it\n * stores the target schema under the raw last segment of the pointer. For a local schema whose\n * key needs an escape (`a~b`, written `a~0b`; `c/d`, written `c~1d`) that segment is no existing\n * key, so the bundle added `a~0b` and `c~1d` to `components.schemas` as copies of `a~b` and\n * `c/d`, and the generator wrote each type twice. A copy is the very object of the schema it\n * copies, so a key the bundle added whose value is the value of a key the document had is removed,\n * and the mapping values and `$ref`s that name it point at the original.\n */\n\ntype Schemas = Record<string, unknown>;\n\nconst SCHEMAS_POINTER = childPointer(childPointer(ROOT_POINTER, \"components\"), \"schemas\");\n\nfunction isContainer(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction schemasOf(document: unknown): Schemas | undefined {\n const components = isContainer(document) ? document.components : undefined;\n const schemas = isContainer(components) ? components.schemas : undefined;\n return isContainer(schemas) ? schemas : undefined;\n}\n\n/** The keys of `components.schemas` before bundling: the bundle edits the document in place. */\nexport function schemaKeysOf(document: unknown): ReadonlySet<string> {\n return new Set(Object.keys(schemasOf(document) ?? {}));\n}\n\n/** Each key the bundle added as a copy, with the pointer of the schema it copies. */\nfunction copiesIn(schemas: Schemas, keysBefore: ReadonlySet<string>): Map<string, string> {\n const originals = new Map<unknown, string>();\n for (const key of keysBefore) {\n if (Object.hasOwn(schemas, key) && !originals.has(schemas[key])) {\n originals.set(schemas[key], key);\n }\n }\n const copies = new Map<string, string>();\n for (const [key, value] of Object.entries(schemas)) {\n const original = keysBefore.has(key) ? undefined : originals.get(value);\n if (original !== undefined) {\n copies.set(`${SCHEMAS_POINTER}/${key}`, childPointer(SCHEMAS_POINTER, original));\n delete schemas[key];\n }\n }\n return copies;\n}\n\n/** Every `discriminator.mapping` object of the document; the walk has its own stack. */\nfunction mappingsOf(document: unknown): Record<string, unknown>[] {\n const mappings: Record<string, unknown>[] = [];\n const visited = new WeakSet<object>();\n const pending: unknown[] = [document];\n for (let next = pending.pop(); next !== undefined; next = pending.pop()) {\n if (!isContainer(next) || visited.has(next)) {\n continue;\n }\n visited.add(next);\n const mapping = isContainer(next.discriminator) ? next.discriminator.mapping : undefined;\n if (isContainer(mapping)) {\n mappings.push(mapping);\n }\n // One push per child: spreading an array of millions of children overflows the stack.\n for (const child of Object.values(next)) {\n pending.push(child);\n }\n }\n return mappings;\n}\n\n/** Remove the bundle's copies of the document's own schemas, in place. */\nexport function removeBundledMappingCopies(\n bundled: unknown,\n keysBefore: ReadonlySet<string>,\n): void {\n const schemas = schemasOf(bundled);\n const copies = schemas === undefined ? new Map<string, string>() : copiesIn(schemas, keysBefore);\n if (copies.size === 0) {\n return;\n }\n for (const mapping of mappingsOf(bundled)) {\n for (const [name, value] of Object.entries(mapping)) {\n const original = typeof value === \"string\" ? copies.get(value) : undefined;\n if (original !== undefined) {\n mapping[name] = original;\n }\n }\n }\n for (const { node } of findRefHolders(bundled)) {\n node.$ref = copies.get(node.$ref) ?? node.$ref;\n }\n}\n"],"names":["childPointer","ROOT_POINTER","findRefHolders"],"mappings":";;;;;AAeA,MAAM,kBAAkBA,wBAAA,CAAaA,wBAAA,CAAaC,wBAAA,EAAc,YAAY,GAAG,SAAS,CAAA;AAExF,SAAS,YAAY,KAAA,EAAkD;AACrE,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA;AAChD;AAEA,SAAS,UAAU,QAAA,EAAwC;AACzD,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,QAAQ,CAAA,GAAI,SAAS,UAAA,GAAa,MAAA;AACjE,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,UAAU,CAAA,GAAI,WAAW,OAAA,GAAU,MAAA;AAC/D,EAAA,OAAO,WAAA,CAAY,OAAO,CAAA,GAAI,OAAA,GAAU,MAAA;AAC1C;AAGO,SAAS,aAAa,QAAA,EAAwC;AACnE,EAAA,OAAO,IAAI,IAAI,MAAA,CAAO,IAAA,CAAK,UAAU,QAAQ,CAAA,IAAK,EAAE,CAAC,CAAA;AACvD;AAGA,SAAS,QAAA,CAAS,SAAkB,UAAA,EAAsD;AACxF,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAqB;AAC3C,EAAA,KAAA,MAAW,OAAO,UAAA,EAAY;AAC5B,IAAA,IAAI,MAAA,CAAO,MAAA,CAAO,OAAA,EAAS,GAAG,CAAA,IAAK,CAAC,SAAA,CAAU,GAA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,CAAA,EAAG;AACxB,MAAA,QAAA,CAAS,KAAK,OAAO,CAAA;AAAA,IACvB;AAEA,IAAA,KAAA,MAAW,KAAA,IAAS,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,EAAG;AACvC,MAAA,OAAA,CAAQ,KAAK,KAAK,CAAA;AAAA,IACpB;AAAA,EACF;AACA,EAAA,OAAO,QAAA;AACT;AAGO,SAAS,0BAAA,CACd,SACA,UAAA,EACM;AACN,EAAA,MAAM,OAAA,GAAU,UAAU,OAAO,CAAA;AACjC,EAAA,MAAM,MAAA,GAAS,YAAY,MAAA,mBAAY,IAAI,KAAoB,GAAI,QAAA,CAAS,SAAS,UAAU,CAAA;AAC/F,EAAA,IAAI,MAAA,CAAO,SAAS,CAAA,EAAG;AACrB,IAAA;AAAA,EACF;AACA,EAAA,KAAA,MAAW,OAAA,IAAW,UAAA,CAAW,OAAO,CAAA,EAAG;AACzC,IAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AACnD,MAAA,MAAM,WAAW,OAAO,KAAA,KAAU,WAAW,MAAA,CAAO,GAAA,CAAI,KAAK,CAAA,GAAI,MAAA;AACjE,MAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,QAAA,OAAA,CAAQ,IAAI,CAAA,GAAI,QAAA;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACA,EAAA,KAAA,MAAW,EAAE,IAAA,EAAK,IAAKE,yBAAA,CAAe,OAAO,CAAA,EAAG;AAC9C,IAAA,IAAA,CAAK,OAAO,MAAA,CAAO,GAAA,CAAI,IAAA,CAAK,IAAI,KAAK,IAAA,CAAK,IAAA;AAAA,EAC5C;AACF;;;"}
1
+ {"version":3,"file":"bundled-mapping-copies.cjs","sources":["../../../src/adapters/redocly-loader/bundled-mapping-copies.ts"],"sourcesContent":["import { childPointer } from \"../../domain/openapi/json-pointer.js\";\nimport { type ComponentSchemas, componentSchemasOf, SCHEMAS_POINTER } from \"./component-schemas.js\";\nimport { findMappings, findRefHolders } from \"./ref-holders.js\";\n\n/**\n * Redocly 1.x bundles every discriminator `mapping` value as if it were an external `$ref`: it\n * stores the target schema under the raw last segment of the pointer. For a local schema whose\n * key needs an escape (`a~b`, written `a~0b`; `c/d`, written `c~1d`) that segment is no existing\n * key, so the bundle added `a~0b` and `c~1d` to `components.schemas` as copies of `a~b` and\n * `c/d`, and the generator wrote each type twice. A copy is the very object of the schema it\n * copies, so a key the bundle added whose value is the value of a key the document had is removed,\n * and the mapping values and `$ref`s that name it point at the original.\n */\n\n/** The keys of `components.schemas` before bundling: the bundle edits the document in place. */\nexport function schemaKeysOf(document: unknown): ReadonlySet<string> {\n return new Set(Object.keys(componentSchemasOf(document) ?? {}));\n}\n\n/** Each key the bundle added as a copy, with the pointer of the schema it copies. */\nfunction copiesIn(schemas: ComponentSchemas, keysBefore: ReadonlySet<string>): Map<string, string> {\n const originals = new Map<unknown, string>();\n for (const key of keysBefore) {\n if (Object.hasOwn(schemas, key) && !originals.has(schemas[key])) {\n originals.set(schemas[key], key);\n }\n }\n const copies = new Map<string, string>();\n for (const [key, value] of Object.entries(schemas)) {\n const original = keysBefore.has(key) ? undefined : originals.get(value);\n if (original !== undefined) {\n copies.set(`${SCHEMAS_POINTER}/${key}`, childPointer(SCHEMAS_POINTER, original));\n delete schemas[key];\n }\n }\n return copies;\n}\n\n/** Remove the bundle's copies of the document's own schemas, in place. */\nexport function removeBundledMappingCopies(\n bundled: unknown,\n keysBefore: ReadonlySet<string>,\n): void {\n const schemas = componentSchemasOf(bundled);\n const copies = schemas === undefined ? new Map<string, string>() : copiesIn(schemas, keysBefore);\n if (copies.size === 0) {\n return;\n }\n for (const mapping of findMappings(bundled)) {\n for (const [name, value] of Object.entries(mapping)) {\n const original = typeof value === \"string\" ? copies.get(value) : undefined;\n if (original !== undefined) {\n mapping[name] = original;\n }\n }\n }\n for (const { node } of findRefHolders(bundled)) {\n node.$ref = copies.get(node.$ref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,GAAS,YAAY,MAAA,mBAAY,IAAI,KAAoB,GAAI,QAAA,CAAS,SAAS,UAAU,CAAA;AAC/F,EAAA,IAAI,MAAA,CAAO,SAAS,CAAA,EAAG;AACrB,IAAA;AAAA,EACF;AACA,EAAA,KAAA,MAAW,OAAA,IAAWG,uBAAA,CAAa,OAAO,CAAA,EAAG;AAC3C,IAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AACnD,MAAA,MAAM,WAAW,OAAO,KAAA,KAAU,WAAW,MAAA,CAAO,GAAA,CAAI,KAAK,CAAA,GAAI,MAAA;AACjE,MAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,QAAA,OAAA,CAAQ,IAAI,CAAA,GAAI,QAAA;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACA,EAAA,KAAA,MAAW,EAAE,IAAA,EAAK,IAAKC,yBAAA,CAAe,OAAO,CAAA,EAAG;AAC9C,IAAA,IAAA,CAAK,OAAO,MAAA,CAAO,GAAA,CAAI,IAAA,CAAK,IAAI,KAAK,IAAA,CAAK,IAAA;AAAA,EAC5C;AACF;;;"}
@@ -1,17 +1,9 @@
1
- import { childPointer, ROOT_POINTER } from '../../domain/openapi/json-pointer.mjs';
2
- import { findRefHolders } from './ref-holders.mjs';
1
+ import { childPointer } from '../../domain/openapi/json-pointer.mjs';
2
+ import { componentSchemasOf, SCHEMAS_POINTER } from './component-schemas.mjs';
3
+ import { findMappings, findRefHolders } from './ref-holders.mjs';
3
4
 
4
- const SCHEMAS_POINTER = childPointer(childPointer(ROOT_POINTER, "components"), "schemas");
5
- function isContainer(value) {
6
- return typeof value === "object" && value !== null;
7
- }
8
- function schemasOf(document) {
9
- const components = isContainer(document) ? document.components : void 0;
10
- const schemas = isContainer(components) ? components.schemas : void 0;
11
- return isContainer(schemas) ? schemas : void 0;
12
- }
13
5
  function schemaKeysOf(document) {
14
- return new Set(Object.keys(schemasOf(document) ?? {}));
6
+ return new Set(Object.keys(componentSchemasOf(document) ?? {}));
15
7
  }
16
8
  function copiesIn(schemas, keysBefore) {
17
9
  const originals = /* @__PURE__ */ new Map();
@@ -30,32 +22,13 @@ function copiesIn(schemas, keysBefore) {
30
22
  }
31
23
  return copies;
32
24
  }
33
- function mappingsOf(document) {
34
- const mappings = [];
35
- const visited = /* @__PURE__ */ new WeakSet();
36
- const pending = [document];
37
- for (let next = pending.pop(); next !== void 0; next = pending.pop()) {
38
- if (!isContainer(next) || visited.has(next)) {
39
- continue;
40
- }
41
- visited.add(next);
42
- const mapping = isContainer(next.discriminator) ? next.discriminator.mapping : void 0;
43
- if (isContainer(mapping)) {
44
- mappings.push(mapping);
45
- }
46
- for (const child of Object.values(next)) {
47
- pending.push(child);
48
- }
49
- }
50
- return mappings;
51
- }
52
25
  function removeBundledMappingCopies(bundled, keysBefore) {
53
- const schemas = schemasOf(bundled);
26
+ const schemas = componentSchemasOf(bundled);
54
27
  const copies = schemas === void 0 ? /* @__PURE__ */ new Map() : copiesIn(schemas, keysBefore);
55
28
  if (copies.size === 0) {
56
29
  return;
57
30
  }
58
- for (const mapping of mappingsOf(bundled)) {
31
+ for (const mapping of findMappings(bundled)) {
59
32
  for (const [name, value] of Object.entries(mapping)) {
60
33
  const original = typeof value === "string" ? copies.get(value) : void 0;
61
34
  if (original !== void 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"bundled-mapping-copies.mjs","sources":["../../../src/adapters/redocly-loader/bundled-mapping-copies.ts"],"sourcesContent":["import { childPointer, ROOT_POINTER } from \"../../domain/openapi/json-pointer.js\";\nimport { findRefHolders } from \"./ref-holders.js\";\n\n/**\n * Redocly 1.x bundles every discriminator `mapping` value as if it were an external `$ref`: it\n * stores the target schema under the raw last segment of the pointer. For a local schema whose\n * key needs an escape (`a~b`, written `a~0b`; `c/d`, written `c~1d`) that segment is no existing\n * key, so the bundle added `a~0b` and `c~1d` to `components.schemas` as copies of `a~b` and\n * `c/d`, and the generator wrote each type twice. A copy is the very object of the schema it\n * copies, so a key the bundle added whose value is the value of a key the document had is removed,\n * and the mapping values and `$ref`s that name it point at the original.\n */\n\ntype Schemas = Record<string, unknown>;\n\nconst SCHEMAS_POINTER = childPointer(childPointer(ROOT_POINTER, \"components\"), \"schemas\");\n\nfunction isContainer(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction schemasOf(document: unknown): Schemas | undefined {\n const components = isContainer(document) ? document.components : undefined;\n const schemas = isContainer(components) ? components.schemas : undefined;\n return isContainer(schemas) ? schemas : undefined;\n}\n\n/** The keys of `components.schemas` before bundling: the bundle edits the document in place. */\nexport function schemaKeysOf(document: unknown): ReadonlySet<string> {\n return new Set(Object.keys(schemasOf(document) ?? {}));\n}\n\n/** Each key the bundle added as a copy, with the pointer of the schema it copies. */\nfunction copiesIn(schemas: Schemas, keysBefore: ReadonlySet<string>): Map<string, string> {\n const originals = new Map<unknown, string>();\n for (const key of keysBefore) {\n if (Object.hasOwn(schemas, key) && !originals.has(schemas[key])) {\n originals.set(schemas[key], key);\n }\n }\n const copies = new Map<string, string>();\n for (const [key, value] of Object.entries(schemas)) {\n const original = keysBefore.has(key) ? undefined : originals.get(value);\n if (original !== undefined) {\n copies.set(`${SCHEMAS_POINTER}/${key}`, childPointer(SCHEMAS_POINTER, original));\n delete schemas[key];\n }\n }\n return copies;\n}\n\n/** Every `discriminator.mapping` object of the document; the walk has its own stack. */\nfunction mappingsOf(document: unknown): Record<string, unknown>[] {\n const mappings: Record<string, unknown>[] = [];\n const visited = new WeakSet<object>();\n const pending: unknown[] = [document];\n for (let next = pending.pop(); next !== undefined; next = pending.pop()) {\n if (!isContainer(next) || visited.has(next)) {\n continue;\n }\n visited.add(next);\n const mapping = isContainer(next.discriminator) ? next.discriminator.mapping : undefined;\n if (isContainer(mapping)) {\n mappings.push(mapping);\n }\n // One push per child: spreading an array of millions of children overflows the stack.\n for (const child of Object.values(next)) {\n pending.push(child);\n }\n }\n return mappings;\n}\n\n/** Remove the bundle's copies of the document's own schemas, in place. */\nexport function removeBundledMappingCopies(\n bundled: unknown,\n keysBefore: ReadonlySet<string>,\n): void {\n const schemas = schemasOf(bundled);\n const copies = schemas === undefined ? new Map<string, string>() : copiesIn(schemas, keysBefore);\n if (copies.size === 0) {\n return;\n }\n for (const mapping of mappingsOf(bundled)) {\n for (const [name, value] of Object.entries(mapping)) {\n const original = typeof value === \"string\" ? copies.get(value) : undefined;\n if (original !== undefined) {\n mapping[name] = original;\n }\n }\n }\n for (const { node } of findRefHolders(bundled)) {\n node.$ref = copies.get(node.$ref) ?? node.$ref;\n }\n}\n"],"names":[],"mappings":";;;AAeA,MAAM,kBAAkB,YAAA,CAAa,YAAA,CAAa,YAAA,EAAc,YAAY,GAAG,SAAS,CAAA;AAExF,SAAS,YAAY,KAAA,EAAkD;AACrE,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA;AAChD;AAEA,SAAS,UAAU,QAAA,EAAwC;AACzD,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,QAAQ,CAAA,GAAI,SAAS,UAAA,GAAa,MAAA;AACjE,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,UAAU,CAAA,GAAI,WAAW,OAAA,GAAU,MAAA;AAC/D,EAAA,OAAO,WAAA,CAAY,OAAO,CAAA,GAAI,OAAA,GAAU,MAAA;AAC1C;AAGO,SAAS,aAAa,QAAA,EAAwC;AACnE,EAAA,OAAO,IAAI,IAAI,MAAA,CAAO,IAAA,CAAK,UAAU,QAAQ,CAAA,IAAK,EAAE,CAAC,CAAA;AACvD;AAGA,SAAS,QAAA,CAAS,SAAkB,UAAA,EAAsD;AACxF,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAqB;AAC3C,EAAA,KAAA,MAAW,OAAO,UAAA,EAAY;AAC5B,IAAA,IAAI,MAAA,CAAO,MAAA,CAAO,OAAA,EAAS,GAAG,CAAA,IAAK,CAAC,SAAA,CAAU,GAAA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AAA,EAAG;AACxB,MAAA,QAAA,CAAS,KAAK,OAAO,CAAA;AAAA,IACvB;AAEA,IAAA,KAAA,MAAW,KAAA,IAAS,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,EAAG;AACvC,MAAA,OAAA,CAAQ,KAAK,KAAK,CAAA;AAAA,IACpB;AAAA,EACF;AACA,EAAA,OAAO,QAAA;AACT;AAGO,SAAS,0BAAA,CACd,SACA,UAAA,EACM;AACN,EAAA,MAAM,OAAA,GAAU,UAAU,OAAO,CAAA;AACjC,EAAA,MAAM,MAAA,GAAS,YAAY,MAAA,mBAAY,IAAI,KAAoB,GAAI,QAAA,CAAS,SAAS,UAAU,CAAA;AAC/F,EAAA,IAAI,MAAA,CAAO,SAAS,CAAA,EAAG;AACrB,IAAA;AAAA,EACF;AACA,EAAA,KAAA,MAAW,OAAA,IAAW,UAAA,CAAW,OAAO,CAAA,EAAG;AACzC,IAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AACnD,MAAA,MAAM,WAAW,OAAO,KAAA,KAAU,WAAW,MAAA,CAAO,GAAA,CAAI,KAAK,CAAA,GAAI,MAAA;AACjE,MAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,QAAA,OAAA,CAAQ,IAAI,CAAA,GAAI,QAAA;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACA,EAAA,KAAA,MAAW,EAAE,IAAA,EAAK,IAAK,cAAA,CAAe,OAAO,CAAA,EAAG;AAC9C,IAAA,IAAA,CAAK,OAAO,MAAA,CAAO,GAAA,CAAI,IAAA,CAAK,IAAI,KAAK,IAAA,CAAK,IAAA;AAAA,EAC5C;AACF;;"}
1
+ {"version":3,"file":"bundled-mapping-copies.mjs","sources":["../../../src/adapters/redocly-loader/bundled-mapping-copies.ts"],"sourcesContent":["import { childPointer } from \"../../domain/openapi/json-pointer.js\";\nimport { type ComponentSchemas, componentSchemasOf, SCHEMAS_POINTER } from \"./component-schemas.js\";\nimport { findMappings, findRefHolders } from \"./ref-holders.js\";\n\n/**\n * Redocly 1.x bundles every discriminator `mapping` value as if it were an external `$ref`: it\n * stores the target schema under the raw last segment of the pointer. For a local schema whose\n * key needs an escape (`a~b`, written `a~0b`; `c/d`, written `c~1d`) that segment is no existing\n * key, so the bundle added `a~0b` and `c~1d` to `components.schemas` as copies of `a~b` and\n * `c/d`, and the generator wrote each type twice. A copy is the very object of the schema it\n * copies, so a key the bundle added whose value is the value of a key the document had is removed,\n * and the mapping values and `$ref`s that name it point at the original.\n */\n\n/** The keys of `components.schemas` before bundling: the bundle edits the document in place. */\nexport function schemaKeysOf(document: unknown): ReadonlySet<string> {\n return new Set(Object.keys(componentSchemasOf(document) ?? {}));\n}\n\n/** Each key the bundle added as a copy, with the pointer of the schema it copies. */\nfunction copiesIn(schemas: ComponentSchemas, keysBefore: ReadonlySet<string>): Map<string, string> {\n const originals = new Map<unknown, string>();\n for (const key of keysBefore) {\n if (Object.hasOwn(schemas, key) && !originals.has(schemas[key])) {\n originals.set(schemas[key], key);\n }\n }\n const copies = new Map<string, string>();\n for (const [key, value] of Object.entries(schemas)) {\n const original = keysBefore.has(key) ? undefined : originals.get(value);\n if (original !== undefined) {\n copies.set(`${SCHEMAS_POINTER}/${key}`, childPointer(SCHEMAS_POINTER, original));\n delete schemas[key];\n }\n }\n return copies;\n}\n\n/** Remove the bundle's copies of the document's own schemas, in place. */\nexport function removeBundledMappingCopies(\n bundled: unknown,\n keysBefore: ReadonlySet<string>,\n): void {\n const schemas = componentSchemasOf(bundled);\n const copies = schemas === undefined ? new Map<string, string>() : copiesIn(schemas, keysBefore);\n if (copies.size === 0) {\n return;\n }\n for (const mapping of findMappings(bundled)) {\n for (const [name, value] of Object.entries(mapping)) {\n const original = typeof value === \"string\" ? copies.get(value) : undefined;\n if (original !== undefined) {\n mapping[name] = original;\n }\n }\n }\n for (const { node } of findRefHolders(bundled)) {\n node.$ref = copies.get(node.$ref) ?? node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AAU,CAAA;AAC/F,EAAA,IAAI,MAAA,CAAO,SAAS,CAAA,EAAG;AACrB,IAAA;AAAA,EACF;AACA,EAAA,KAAA,MAAW,OAAA,IAAW,YAAA,CAAa,OAAO,CAAA,EAAG;AAC3C,IAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AACnD,MAAA,MAAM,WAAW,OAAO,KAAA,KAAU,WAAW,MAAA,CAAO,GAAA,CAAI,KAAK,CAAA,GAAI,MAAA;AACjE,MAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,QAAA,OAAA,CAAQ,IAAI,CAAA,GAAI,QAAA;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACA,EAAA,KAAA,MAAW,EAAE,IAAA,EAAK,IAAK,cAAA,CAAe,OAAO,CAAA,EAAG;AAC9C,IAAA,IAAA,CAAK,OAAO,MAAA,CAAO,GAAA,CAAI,IAAA,CAAK,IAAI,KAAK,IAAA,CAAK,IAAA;AAAA,EAC5C;AACF;;"}
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ const jsonPointer = require('../../domain/openapi/json-pointer.cjs');
4
+
5
+ const SCHEMAS_POINTER = jsonPointer.childPointer(jsonPointer.childPointer(jsonPointer.ROOT_POINTER, "components"), "schemas");
6
+ function isContainer(value) {
7
+ return typeof value === "object" && value !== null;
8
+ }
9
+ function componentSchemasOf(document) {
10
+ const components = isContainer(document) ? document.components : void 0;
11
+ const schemas = isContainer(components) ? components.schemas : void 0;
12
+ return isContainer(schemas) ? schemas : void 0;
13
+ }
14
+
15
+ exports.SCHEMAS_POINTER = SCHEMAS_POINTER;
16
+ exports.componentSchemasOf = componentSchemasOf;
17
+ //# sourceMappingURL=component-schemas.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-schemas.cjs","sources":["../../../src/adapters/redocly-loader/component-schemas.ts"],"sourcesContent":["import { childPointer, ROOT_POINTER } from \"../../domain/openapi/json-pointer.js\";\n\n/** `components.schemas` of a parsed document, which the loader repairs in place. */\n\nexport type ComponentSchemas = Record<string, unknown>;\n\n/** `#/components/schemas`. */\nexport const SCHEMAS_POINTER = childPointer(childPointer(ROOT_POINTER, \"components\"), \"schemas\");\n\nfunction isContainer(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\n/** The `components.schemas` object of a document, when it has one. */\nexport function componentSchemasOf(document: unknown): ComponentSchemas | undefined {\n const components = isContainer(document) ? document.components : undefined;\n const schemas = isContainer(components) ? components.schemas : undefined;\n return isContainer(schemas) ? schemas : undefined;\n}\n"],"names":["childPointer","ROOT_POINTER"],"mappings":";;;;AAOO,MAAM,kBAAkBA,wBAAA,CAAaA,wBAAA,CAAaC,wBAAA,EAAc,YAAY,GAAG,SAAS;AAE/F,SAAS,YAAY,KAAA,EAAkD;AACrE,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA;AAChD;AAGO,SAAS,mBAAmB,QAAA,EAAiD;AAClF,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,QAAQ,CAAA,GAAI,SAAS,UAAA,GAAa,MAAA;AACjE,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,UAAU,CAAA,GAAI,WAAW,OAAA,GAAU,MAAA;AAC/D,EAAA,OAAO,WAAA,CAAY,OAAO,CAAA,GAAI,OAAA,GAAU,MAAA;AAC1C;;;"}