openapi-typesafe 1.0.0-rc.3 → 1.0.0-rc.5

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 (596) hide show
  1. package/CHANGELOG.md +1972 -0
  2. package/dist/adapters/node-file-system/file-claims.cjs +105 -0
  3. package/dist/adapters/node-file-system/file-claims.cjs.map +1 -0
  4. package/dist/adapters/node-file-system/file-claims.mjs +95 -0
  5. package/dist/adapters/node-file-system/file-claims.mjs.map +1 -0
  6. package/dist/adapters/node-file-system/file-identity.cjs +82 -0
  7. package/dist/adapters/node-file-system/file-identity.cjs.map +1 -0
  8. package/dist/adapters/node-file-system/file-identity.mjs +74 -0
  9. package/dist/adapters/node-file-system/file-identity.mjs.map +1 -0
  10. package/dist/adapters/node-file-system/node-file-system.cjs +97 -14
  11. package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
  12. package/dist/adapters/node-file-system/node-file-system.mjs +97 -14
  13. package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
  14. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs +19 -0
  15. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs.map +1 -0
  16. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs +17 -0
  17. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs.map +1 -0
  18. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +48 -0
  19. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +45 -0
  21. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -0
  22. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs +1 -1
  23. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs.map +1 -1
  24. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs +2 -2
  25. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs.map +1 -1
  26. package/dist/adapters/redocly-loader/component-schemas.cjs +17 -0
  27. package/dist/adapters/redocly-loader/component-schemas.cjs.map +1 -0
  28. package/dist/adapters/redocly-loader/component-schemas.mjs +14 -0
  29. package/dist/adapters/redocly-loader/component-schemas.mjs.map +1 -0
  30. package/dist/adapters/redocly-loader/loaded-documents.cjs +28 -0
  31. package/dist/adapters/redocly-loader/loaded-documents.cjs.map +1 -0
  32. package/dist/adapters/redocly-loader/loaded-documents.mjs +21 -0
  33. package/dist/adapters/redocly-loader/loaded-documents.mjs.map +1 -0
  34. package/dist/adapters/redocly-loader/mapping-schema-names.cjs +22 -0
  35. package/dist/adapters/redocly-loader/mapping-schema-names.cjs.map +1 -0
  36. package/dist/adapters/redocly-loader/mapping-schema-names.mjs +20 -0
  37. package/dist/adapters/redocly-loader/mapping-schema-names.mjs.map +1 -0
  38. package/dist/adapters/redocly-loader/query-named-components.cjs +137 -0
  39. package/dist/adapters/redocly-loader/query-named-components.cjs.map +1 -0
  40. package/dist/adapters/redocly-loader/query-named-components.mjs +134 -0
  41. package/dist/adapters/redocly-loader/query-named-components.mjs.map +1 -0
  42. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +40 -29
  43. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  44. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +38 -27
  45. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  46. package/dist/adapters/redocly-loader/ref-access.cjs +45 -4
  47. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  48. package/dist/adapters/redocly-loader/ref-access.mjs +45 -4
  49. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  50. package/dist/adapters/redocly-loader/ref-holders.cjs +52 -10
  51. package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
  52. package/dist/adapters/redocly-loader/ref-holders.mjs +53 -12
  53. package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
  54. package/dist/adapters/redocly-loader/remote-body-limit.cjs +50 -0
  55. package/dist/adapters/redocly-loader/remote-body-limit.cjs.map +1 -0
  56. package/dist/adapters/redocly-loader/remote-body-limit.mjs +48 -0
  57. package/dist/adapters/redocly-loader/remote-body-limit.mjs.map +1 -0
  58. package/dist/adapters/redocly-loader/remote-fetch.cjs +40 -9
  59. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  60. package/dist/adapters/redocly-loader/remote-fetch.mjs +40 -9
  61. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  62. package/dist/adapters/redocly-loader/remote-node-limit.cjs +61 -0
  63. package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -0
  64. package/dist/adapters/redocly-loader/remote-node-limit.mjs +58 -0
  65. package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -0
  66. package/dist/adapters/redocly-loader/schema-load-errors.cjs +32 -8
  67. package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
  68. package/dist/adapters/redocly-loader/schema-load-errors.mjs +32 -9
  69. package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
  70. package/dist/adapters/redocly-loader/schema-source.cjs +18 -9
  71. package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
  72. package/dist/adapters/redocly-loader/schema-source.mjs +20 -11
  73. package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
  74. package/dist/adapters/redocly-loader/unsupported-keys.cjs +3 -5
  75. package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
  76. package/dist/adapters/redocly-loader/unsupported-keys.mjs +3 -5
  77. package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
  78. package/dist/adapters/terminal-logger/terminal-logger.cjs +10 -4
  79. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  80. package/dist/adapters/terminal-logger/terminal-logger.mjs +10 -4
  81. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  82. package/dist/api/default-ports.cjs +14 -2
  83. package/dist/api/default-ports.cjs.map +1 -1
  84. package/dist/api/default-ports.mjs +14 -2
  85. package/dist/api/default-ports.mjs.map +1 -1
  86. package/dist/api/discriminator-enum-parent.cjs +2 -2
  87. package/dist/api/discriminator-enum-parent.cjs.map +1 -1
  88. package/dist/api/discriminator-enum-parent.mjs +3 -3
  89. package/dist/api/discriminator-enum-parent.mjs.map +1 -1
  90. package/dist/api/discriminator-other-owners.cjs +5 -3
  91. package/dist/api/discriminator-other-owners.cjs.map +1 -1
  92. package/dist/api/discriminator-other-owners.mjs +5 -3
  93. package/dist/api/discriminator-other-owners.mjs.map +1 -1
  94. package/dist/api/discriminator-patch.cjs +5 -1
  95. package/dist/api/discriminator-patch.cjs.map +1 -1
  96. package/dist/api/discriminator-patch.mjs +5 -1
  97. package/dist/api/discriminator-patch.mjs.map +1 -1
  98. package/dist/api/discriminator-scan.cjs +15 -8
  99. package/dist/api/discriminator-scan.cjs.map +1 -1
  100. package/dist/api/discriminator-scan.mjs +15 -8
  101. package/dist/api/discriminator-scan.mjs.map +1 -1
  102. package/dist/api/document-refs.cjs +16 -1
  103. package/dist/api/document-refs.cjs.map +1 -1
  104. package/dist/api/document-refs.mjs +16 -1
  105. package/dist/api/document-refs.mjs.map +1 -1
  106. package/dist/api/document-run.cjs +6 -12
  107. package/dist/api/document-run.cjs.map +1 -1
  108. package/dist/api/document-run.mjs +6 -12
  109. package/dist/api/document-run.mjs.map +1 -1
  110. package/dist/api/legacy-utils.cjs.map +1 -1
  111. package/dist/api/legacy-utils.mjs.map +1 -1
  112. package/dist/api/openapi-ts.cjs +9 -6
  113. package/dist/api/openapi-ts.cjs.map +1 -1
  114. package/dist/api/openapi-ts.mjs +10 -8
  115. package/dist/api/openapi-ts.mjs.map +1 -1
  116. package/dist/api/ref-limit-options.cjs +63 -0
  117. package/dist/api/ref-limit-options.cjs.map +1 -0
  118. package/dist/api/ref-limit-options.mjs +57 -0
  119. package/dist/api/ref-limit-options.mjs.map +1 -0
  120. package/dist/api/schema-callbacks.cjs +36 -12
  121. package/dist/api/schema-callbacks.cjs.map +1 -1
  122. package/dist/api/schema-callbacks.mjs +36 -12
  123. package/dist/api/schema-callbacks.mjs.map +1 -1
  124. package/dist/api/transform-context.cjs +7 -3
  125. package/dist/api/transform-context.cjs.map +1 -1
  126. package/dist/api/transform-context.mjs +7 -3
  127. package/dist/api/transform-context.mjs.map +1 -1
  128. package/dist/api/transform-schema.cjs +47 -10
  129. package/dist/api/transform-schema.cjs.map +1 -1
  130. package/dist/api/transform-schema.mjs +48 -11
  131. package/dist/api/transform-schema.mjs.map +1 -1
  132. package/dist/application/print/text-writer.cjs +10 -3
  133. package/dist/application/print/text-writer.cjs.map +1 -1
  134. package/dist/application/print/text-writer.mjs +10 -3
  135. package/dist/application/print/text-writer.mjs.map +1 -1
  136. package/dist/application/stack-overflow.cjs +2 -1
  137. package/dist/application/stack-overflow.cjs.map +1 -1
  138. package/dist/application/stack-overflow.mjs +2 -1
  139. package/dist/application/stack-overflow.mjs.map +1 -1
  140. package/dist/application/transform/declared-value-types.cjs +36 -0
  141. package/dist/application/transform/declared-value-types.cjs.map +1 -0
  142. package/dist/application/transform/declared-value-types.mjs +34 -0
  143. package/dist/application/transform/declared-value-types.mjs.map +1 -0
  144. package/dist/application/transform/document/components.cjs +1 -1
  145. package/dist/application/transform/document/components.cjs.map +1 -1
  146. package/dist/application/transform/document/components.mjs +2 -2
  147. package/dist/application/transform/document/components.mjs.map +1 -1
  148. package/dist/application/transform/document/declared-type-names.cjs +23 -0
  149. package/dist/application/transform/document/declared-type-names.cjs.map +1 -0
  150. package/dist/application/transform/document/declared-type-names.mjs +20 -0
  151. package/dist/application/transform/document/declared-type-names.mjs.map +1 -0
  152. package/dist/application/transform/document/defs-root.cjs +1 -1
  153. package/dist/application/transform/document/defs-root.cjs.map +1 -1
  154. package/dist/application/transform/document/defs-root.mjs +2 -2
  155. package/dist/application/transform/document/defs-root.mjs.map +1 -1
  156. package/dist/application/transform/document/document.cjs +7 -2
  157. package/dist/application/transform/document/document.cjs.map +1 -1
  158. package/dist/application/transform/document/document.mjs +6 -3
  159. package/dist/application/transform/document/document.mjs.map +1 -1
  160. package/dist/application/transform/document/enum-names-given-back.cjs +62 -0
  161. package/dist/application/transform/document/enum-names-given-back.cjs.map +1 -0
  162. package/dist/application/transform/document/enum-names-given-back.mjs +58 -0
  163. package/dist/application/transform/document/enum-names-given-back.mjs.map +1 -0
  164. package/dist/application/transform/document/exploded-query-values.cjs +63 -0
  165. package/dist/application/transform/document/exploded-query-values.cjs.map +1 -0
  166. package/dist/application/transform/document/exploded-query-values.mjs +59 -0
  167. package/dist/application/transform/document/exploded-query-values.mjs.map +1 -0
  168. package/dist/application/transform/document/global-type-references.cjs +1 -0
  169. package/dist/application/transform/document/global-type-references.cjs.map +1 -1
  170. package/dist/application/transform/document/global-type-references.mjs +1 -1
  171. package/dist/application/transform/document/global-type-references.mjs.map +1 -1
  172. package/dist/application/transform/document/header.cjs +11 -3
  173. package/dist/application/transform/document/header.cjs.map +1 -1
  174. package/dist/application/transform/document/header.mjs +10 -2
  175. package/dist/application/transform/document/header.mjs.map +1 -1
  176. package/dist/application/transform/document/media-type.cjs +2 -2
  177. package/dist/application/transform/document/media-type.cjs.map +1 -1
  178. package/dist/application/transform/document/media-type.mjs +3 -3
  179. package/dist/application/transform/document/media-type.mjs.map +1 -1
  180. package/dist/application/transform/document/operation-keys-written.cjs +26 -0
  181. package/dist/application/transform/document/operation-keys-written.cjs.map +1 -0
  182. package/dist/application/transform/document/operation-keys-written.mjs +24 -0
  183. package/dist/application/transform/document/operation-keys-written.mjs.map +1 -0
  184. package/dist/application/transform/document/operation.cjs +1 -1
  185. package/dist/application/transform/document/operation.cjs.map +1 -1
  186. package/dist/application/transform/document/operation.mjs +2 -2
  187. package/dist/application/transform/document/operation.mjs.map +1 -1
  188. package/dist/application/transform/document/parameter-entries.cjs +34 -0
  189. package/dist/application/transform/document/parameter-entries.cjs.map +1 -0
  190. package/dist/application/transform/document/parameter-entries.mjs +30 -0
  191. package/dist/application/transform/document/parameter-entries.mjs.map +1 -0
  192. package/dist/application/transform/document/parameter.cjs +12 -4
  193. package/dist/application/transform/document/parameter.cjs.map +1 -1
  194. package/dist/application/transform/document/parameter.mjs +13 -5
  195. package/dist/application/transform/document/parameter.mjs.map +1 -1
  196. package/dist/application/transform/document/parameters.cjs +29 -34
  197. package/dist/application/transform/document/parameters.cjs.map +1 -1
  198. package/dist/application/transform/document/parameters.mjs +29 -34
  199. package/dist/application/transform/document/parameters.mjs.map +1 -1
  200. package/dist/application/transform/document/path-item.cjs +15 -17
  201. package/dist/application/transform/document/path-item.cjs.map +1 -1
  202. package/dist/application/transform/document/path-item.mjs +15 -19
  203. package/dist/application/transform/document/path-item.mjs.map +1 -1
  204. package/dist/application/transform/document/path-template-key.cjs +84 -0
  205. package/dist/application/transform/document/path-template-key.cjs.map +1 -0
  206. package/dist/application/transform/document/path-template-key.mjs +79 -0
  207. package/dist/application/transform/document/path-template-key.mjs.map +1 -0
  208. package/dist/application/transform/document/path-template-refs.cjs +70 -0
  209. package/dist/application/transform/document/path-template-refs.cjs.map +1 -0
  210. package/dist/application/transform/document/path-template-refs.mjs +67 -0
  211. package/dist/application/transform/document/path-template-refs.mjs.map +1 -0
  212. package/dist/application/transform/document/paths-enum.cjs +8 -6
  213. package/dist/application/transform/document/paths-enum.cjs.map +1 -1
  214. package/dist/application/transform/document/paths-enum.mjs +8 -7
  215. package/dist/application/transform/document/paths-enum.mjs.map +1 -1
  216. package/dist/application/transform/document/paths.cjs +43 -67
  217. package/dist/application/transform/document/paths.cjs.map +1 -1
  218. package/dist/application/transform/document/paths.mjs +42 -68
  219. package/dist/application/transform/document/paths.mjs.map +1 -1
  220. package/dist/application/transform/document/referenced-parameter.cjs +80 -0
  221. package/dist/application/transform/document/referenced-parameter.cjs.map +1 -0
  222. package/dist/application/transform/document/referenced-parameter.mjs +78 -0
  223. package/dist/application/transform/document/referenced-parameter.mjs.map +1 -0
  224. package/dist/application/transform/document/request-body.cjs +1 -1
  225. package/dist/application/transform/document/request-body.cjs.map +1 -1
  226. package/dist/application/transform/document/request-body.mjs +2 -2
  227. package/dist/application/transform/document/request-body.mjs.map +1 -1
  228. package/dist/application/transform/document/response.cjs +2 -2
  229. package/dist/application/transform/document/response.cjs.map +1 -1
  230. package/dist/application/transform/document/response.mjs +3 -3
  231. package/dist/application/transform/document/response.mjs.map +1 -1
  232. package/dist/application/transform/document/responses.cjs +1 -1
  233. package/dist/application/transform/document/responses.cjs.map +1 -1
  234. package/dist/application/transform/document/responses.mjs +2 -2
  235. package/dist/application/transform/document/responses.mjs.map +1 -1
  236. package/dist/application/transform/document/root-type-aliases.cjs +8 -23
  237. package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
  238. package/dist/application/transform/document/root-type-aliases.mjs +8 -24
  239. package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
  240. package/dist/application/transform/document/type-resolution.cjs +3 -1
  241. package/dist/application/transform/document/type-resolution.cjs.map +1 -1
  242. package/dist/application/transform/document/type-resolution.mjs +3 -1
  243. package/dist/application/transform/document/type-resolution.mjs.map +1 -1
  244. package/dist/application/transform/document/webhooks.cjs +10 -3
  245. package/dist/application/transform/document/webhooks.cjs.map +1 -1
  246. package/dist/application/transform/document/webhooks.mjs +10 -3
  247. package/dist/application/transform/document/webhooks.mjs.map +1 -1
  248. package/dist/application/transform/footer/document-footer.cjs +16 -5
  249. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  250. package/dist/application/transform/footer/document-footer.mjs +16 -5
  251. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  252. package/dist/application/transform/footer/enum-name-claims.cjs +48 -0
  253. package/dist/application/transform/footer/enum-name-claims.cjs.map +1 -0
  254. package/dist/application/transform/footer/enum-name-claims.mjs +46 -0
  255. package/dist/application/transform/footer/enum-name-claims.mjs.map +1 -0
  256. package/dist/application/transform/footer/operation-keys.cjs +23 -0
  257. package/dist/application/transform/footer/operation-keys.cjs.map +1 -0
  258. package/dist/application/transform/footer/operation-keys.mjs +21 -0
  259. package/dist/application/transform/footer/operation-keys.mjs.map +1 -0
  260. package/dist/application/transform/footer/type-evaluation.cjs +4 -4
  261. package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
  262. package/dist/application/transform/footer/type-evaluation.mjs +4 -4
  263. package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
  264. package/dist/application/transform/helper-types.cjs +3 -3
  265. package/dist/application/transform/helper-types.cjs.map +1 -1
  266. package/dist/application/transform/helper-types.mjs +3 -3
  267. package/dist/application/transform/helper-types.mjs.map +1 -1
  268. package/dist/application/transform/numbered-names.cjs +9 -0
  269. package/dist/application/transform/numbered-names.cjs.map +1 -1
  270. package/dist/application/transform/numbered-names.mjs +9 -1
  271. package/dist/application/transform/numbered-names.mjs.map +1 -1
  272. package/dist/application/transform/ref-pointer/generated-location.cjs +5 -5
  273. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
  274. package/dist/application/transform/ref-pointer/generated-location.mjs +3 -3
  275. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
  276. package/dist/application/transform/ref-pointer/generated-shape.cjs +47 -66
  277. package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -1
  278. package/dist/application/transform/ref-pointer/generated-shape.mjs +36 -50
  279. package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -1
  280. package/dist/application/transform/ref-pointer/inline-cycles.cjs +2 -2
  281. package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -1
  282. package/dist/application/transform/ref-pointer/inline-cycles.mjs +1 -1
  283. package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -1
  284. package/dist/application/transform/ref-pointer/located-node.cjs +23 -0
  285. package/dist/application/transform/ref-pointer/located-node.cjs.map +1 -0
  286. package/dist/application/transform/ref-pointer/located-node.mjs +18 -0
  287. package/dist/application/transform/ref-pointer/located-node.mjs.map +1 -0
  288. package/dist/application/transform/ref-pointer/original-index.cjs +68 -13
  289. package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -1
  290. package/dist/application/transform/ref-pointer/original-index.mjs +70 -15
  291. package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -1
  292. package/dist/application/transform/ref-pointer/pointer-type.cjs +2 -2
  293. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  294. package/dist/application/transform/ref-pointer/pointer-type.mjs +1 -1
  295. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  296. package/dist/application/transform/ref-pointer/pointer-walk.cjs +54 -13
  297. package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -1
  298. package/dist/application/transform/ref-pointer/pointer-walk.mjs +46 -7
  299. package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -1
  300. package/dist/application/transform/ref-pointer/property-shape.cjs +52 -0
  301. package/dist/application/transform/ref-pointer/property-shape.cjs.map +1 -0
  302. package/dist/application/transform/ref-pointer/property-shape.mjs +45 -0
  303. package/dist/application/transform/ref-pointer/property-shape.mjs.map +1 -0
  304. package/dist/application/transform/ref-pointer/typed-walk.cjs +79 -21
  305. package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -1
  306. package/dist/application/transform/ref-pointer/typed-walk.mjs +76 -18
  307. package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -1
  308. package/dist/application/transform/ref-type.cjs +2 -1
  309. package/dist/application/transform/ref-type.cjs.map +1 -1
  310. package/dist/application/transform/ref-type.mjs +2 -1
  311. package/dist/application/transform/ref-type.mjs.map +1 -1
  312. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  313. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  314. package/dist/application/transform/schema/composition-type.cjs +1 -1
  315. package/dist/application/transform/schema/composition-type.cjs.map +1 -1
  316. package/dist/application/transform/schema/composition-type.mjs +2 -2
  317. package/dist/application/transform/schema/composition-type.mjs.map +1 -1
  318. package/dist/application/transform/schema/enum-rule.cjs +1 -1
  319. package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
  320. package/dist/application/transform/schema/enum-rule.mjs +2 -2
  321. package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
  322. package/dist/application/transform/schema/index-signature-type.cjs +21 -0
  323. package/dist/application/transform/schema/index-signature-type.cjs.map +1 -0
  324. package/dist/application/transform/schema/index-signature-type.mjs +19 -0
  325. package/dist/application/transform/schema/index-signature-type.mjs.map +1 -0
  326. package/dist/application/transform/schema/input-location.cjs +23 -0
  327. package/dist/application/transform/schema/input-location.cjs.map +1 -0
  328. package/dist/application/transform/schema/input-location.mjs +21 -0
  329. package/dist/application/transform/schema/input-location.mjs.map +1 -0
  330. package/dist/application/transform/schema/object-type.cjs +18 -8
  331. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  332. package/dist/application/transform/schema/object-type.mjs +19 -9
  333. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  334. package/dist/application/transform/schema/ref-siblings.cjs +47 -0
  335. package/dist/application/transform/schema/ref-siblings.cjs.map +1 -0
  336. package/dist/application/transform/schema/ref-siblings.mjs +45 -0
  337. package/dist/application/transform/schema/ref-siblings.mjs.map +1 -0
  338. package/dist/application/transform/schema/schema-transform.cjs +6 -3
  339. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  340. package/dist/application/transform/schema/schema-transform.mjs +6 -3
  341. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  342. package/dist/application/transform/schema/unevaluated-properties.cjs +2 -30
  343. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  344. package/dist/application/transform/schema/unevaluated-properties.mjs +3 -31
  345. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  346. package/dist/application/transform/schema-comment.cjs +5 -1
  347. package/dist/application/transform/schema-comment.cjs.map +1 -1
  348. package/dist/application/transform/schema-comment.mjs +5 -1
  349. package/dist/application/transform/schema-comment.mjs.map +1 -1
  350. package/dist/cli/api-logger.cjs +13 -0
  351. package/dist/cli/api-logger.cjs.map +1 -0
  352. package/dist/cli/api-logger.mjs +11 -0
  353. package/dist/cli/api-logger.mjs.map +1 -0
  354. package/dist/cli/api-settings.cjs +57 -9
  355. package/dist/cli/api-settings.cjs.map +1 -1
  356. package/dist/cli/api-settings.mjs +56 -11
  357. package/dist/cli/api-settings.mjs.map +1 -1
  358. package/dist/cli/api-writes.cjs +72 -0
  359. package/dist/cli/api-writes.cjs.map +1 -0
  360. package/dist/cli/api-writes.mjs +69 -0
  361. package/dist/cli/api-writes.mjs.map +1 -0
  362. package/dist/cli/cli-arguments.cjs +51 -11
  363. package/dist/cli/cli-arguments.cjs.map +1 -1
  364. package/dist/cli/cli-arguments.mjs +51 -11
  365. package/dist/cli/cli-arguments.mjs.map +1 -1
  366. package/dist/cli/cli-errors.cjs +29 -1
  367. package/dist/cli/cli-errors.cjs.map +1 -1
  368. package/dist/cli/cli-errors.mjs +29 -2
  369. package/dist/cli/cli-errors.mjs.map +1 -1
  370. package/dist/cli/cli-output.cjs +111 -4
  371. package/dist/cli/cli-output.cjs.map +1 -1
  372. package/dist/cli/cli-output.mjs +104 -5
  373. package/dist/cli/cli-output.mjs.map +1 -1
  374. package/dist/cli/main.cjs +13 -3
  375. package/dist/cli/main.cjs.map +1 -1
  376. package/dist/cli/main.mjs +14 -4
  377. package/dist/cli/main.mjs.map +1 -1
  378. package/dist/cli/redocly-apis.cjs +94 -37
  379. package/dist/cli/redocly-apis.cjs.map +1 -1
  380. package/dist/cli/redocly-apis.mjs +99 -42
  381. package/dist/cli/redocly-apis.mjs.map +1 -1
  382. package/dist/cli/ref-limits.cjs +15 -1
  383. package/dist/cli/ref-limits.cjs.map +1 -1
  384. package/dist/cli/ref-limits.mjs +15 -2
  385. package/dist/cli/ref-limits.mjs.map +1 -1
  386. package/dist/cli/run-cli.cjs +37 -14
  387. package/dist/cli/run-cli.cjs.map +1 -1
  388. package/dist/cli/run-cli.mjs +39 -16
  389. package/dist/cli/run-cli.mjs.map +1 -1
  390. package/dist/domain/append-all.cjs +10 -0
  391. package/dist/domain/append-all.cjs.map +1 -0
  392. package/dist/domain/append-all.mjs +8 -0
  393. package/dist/domain/append-all.mjs.map +1 -0
  394. package/dist/domain/cause-secrets.cjs +52 -0
  395. package/dist/domain/cause-secrets.cjs.map +1 -0
  396. package/dist/domain/cause-secrets.mjs +50 -0
  397. package/dist/domain/cause-secrets.mjs.map +1 -0
  398. package/dist/domain/errors.cjs +11 -3
  399. package/dist/domain/errors.cjs.map +1 -1
  400. package/dist/domain/errors.mjs +11 -3
  401. package/dist/domain/errors.mjs.map +1 -1
  402. package/dist/domain/ir/identifier-text.cjs.map +1 -1
  403. package/dist/domain/ir/identifier-text.mjs +1 -1
  404. package/dist/domain/ir/identifier-text.mjs.map +1 -1
  405. package/dist/domain/ir/ir-shape.cjs +187 -0
  406. package/dist/domain/ir/ir-shape.cjs.map +1 -0
  407. package/dist/domain/ir/ir-shape.mjs +184 -0
  408. package/dist/domain/ir/ir-shape.mjs.map +1 -0
  409. package/dist/domain/ir/newer-identifier-ranges.cjs +182 -29
  410. package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -1
  411. package/dist/domain/ir/newer-identifier-ranges.mjs +182 -29
  412. package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -1
  413. package/dist/domain/location-text.cjs +9 -0
  414. package/dist/domain/location-text.cjs.map +1 -0
  415. package/dist/domain/location-text.mjs +7 -0
  416. package/dist/domain/location-text.mjs.map +1 -0
  417. package/dist/domain/openapi/alias-expansion.cjs +3 -1
  418. package/dist/domain/openapi/alias-expansion.cjs.map +1 -1
  419. package/dist/domain/openapi/alias-expansion.mjs +3 -1
  420. package/dist/domain/openapi/alias-expansion.mjs.map +1 -1
  421. package/dist/domain/openapi/discriminated-union.cjs +3 -3
  422. package/dist/domain/openapi/discriminated-union.cjs.map +1 -1
  423. package/dist/domain/openapi/discriminated-union.mjs +4 -4
  424. package/dist/domain/openapi/discriminated-union.mjs.map +1 -1
  425. package/dist/domain/openapi/discriminator-conflicts.cjs +10 -6
  426. package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -1
  427. package/dist/domain/openapi/discriminator-conflicts.mjs +11 -7
  428. package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -1
  429. package/dist/domain/openapi/document-places.cjs +55 -0
  430. package/dist/domain/openapi/document-places.cjs.map +1 -0
  431. package/dist/domain/openapi/document-places.mjs +53 -0
  432. package/dist/domain/openapi/document-places.mjs.map +1 -0
  433. package/dist/domain/openapi/json-pointer.cjs +43 -1
  434. package/dist/domain/openapi/json-pointer.cjs.map +1 -1
  435. package/dist/domain/openapi/json-pointer.mjs +40 -2
  436. package/dist/domain/openapi/json-pointer.mjs.map +1 -1
  437. package/dist/domain/openapi/schema-dialect.cjs +15 -0
  438. package/dist/domain/openapi/schema-dialect.cjs.map +1 -0
  439. package/dist/domain/openapi/schema-dialect.mjs +12 -0
  440. package/dist/domain/openapi/schema-dialect.mjs.map +1 -0
  441. package/dist/domain/openapi/unsupported-features.cjs +1 -1
  442. package/dist/domain/openapi/unsupported-features.cjs.map +1 -1
  443. package/dist/domain/openapi/unsupported-features.mjs +2 -2
  444. package/dist/domain/openapi/unsupported-features.mjs.map +1 -1
  445. package/dist/domain/output-fixes.cjs +20 -0
  446. package/dist/domain/output-fixes.cjs.map +1 -1
  447. package/dist/domain/output-fixes.mjs +20 -0
  448. package/dist/domain/output-fixes.mjs.map +1 -1
  449. package/dist/domain/terminal-text.cjs +31 -0
  450. package/dist/domain/terminal-text.cjs.map +1 -0
  451. package/dist/domain/terminal-text.mjs +29 -0
  452. package/dist/domain/terminal-text.mjs.map +1 -0
  453. package/dist/domain/url-secrets.cjs +48 -0
  454. package/dist/domain/url-secrets.cjs.map +1 -0
  455. package/dist/domain/url-secrets.mjs +45 -0
  456. package/dist/domain/url-secrets.mjs.map +1 -0
  457. package/dist/domain/warnings.cjs +1 -0
  458. package/dist/domain/warnings.cjs.map +1 -1
  459. package/dist/domain/warnings.mjs +1 -0
  460. package/dist/domain/warnings.mjs.map +1 -1
  461. package/dist/index.d.cts +46 -20
  462. package/dist/index.d.mts +46 -20
  463. package/dist/index.d.ts +46 -20
  464. package/package.json +4 -5
  465. package/src/adapters/node-file-system/file-claims.ts +138 -0
  466. package/src/adapters/node-file-system/file-identity.ts +137 -0
  467. package/src/adapters/node-file-system/node-file-system.ts +158 -18
  468. package/src/adapters/pipe-safe-writer/pipe-safe-writer.ts +29 -0
  469. package/src/adapters/redocly-loader/bundled-mapping-copies.ts +60 -0
  470. package/src/adapters/redocly-loader/bundled-ref-repair.ts +2 -2
  471. package/src/adapters/redocly-loader/component-schemas.ts +19 -0
  472. package/src/adapters/redocly-loader/loaded-documents.ts +46 -0
  473. package/src/adapters/redocly-loader/mapping-schema-names.ts +25 -0
  474. package/src/adapters/redocly-loader/query-named-components.ts +201 -0
  475. package/src/adapters/redocly-loader/redocly-schema-loader.ts +64 -38
  476. package/src/adapters/redocly-loader/ref-access.ts +51 -4
  477. package/src/adapters/redocly-loader/ref-holders.ts +76 -15
  478. package/src/adapters/redocly-loader/remote-body-limit.ts +66 -0
  479. package/src/adapters/redocly-loader/remote-fetch.ts +85 -13
  480. package/src/adapters/redocly-loader/remote-node-limit.ts +102 -0
  481. package/src/adapters/redocly-loader/schema-load-errors.ts +52 -13
  482. package/src/adapters/redocly-loader/schema-source.ts +35 -11
  483. package/src/adapters/redocly-loader/unsupported-keys.ts +3 -7
  484. package/src/adapters/terminal-logger/terminal-logger.ts +17 -6
  485. package/src/api/default-ports.ts +33 -4
  486. package/src/api/discriminator-enum-parent.ts +3 -3
  487. package/src/api/discriminator-other-owners.ts +5 -3
  488. package/src/api/discriminator-patch.ts +5 -1
  489. package/src/api/discriminator-scan.ts +16 -8
  490. package/src/api/document-refs.ts +29 -1
  491. package/src/api/document-run.ts +10 -19
  492. package/src/api/legacy-utils.ts +5 -1
  493. package/src/api/openapi-ts.ts +26 -8
  494. package/src/api/ref-limit-options.ts +76 -0
  495. package/src/api/run-context.ts +3 -0
  496. package/src/api/schema-callbacks.ts +60 -17
  497. package/src/api/transform-context.ts +7 -3
  498. package/src/api/transform-schema.ts +79 -12
  499. package/src/application/ports/file-system.ts +47 -0
  500. package/src/application/ports/schema-loader.ts +11 -1
  501. package/src/application/print/text-writer.ts +10 -3
  502. package/src/application/stack-overflow.ts +9 -5
  503. package/src/application/transform/declared-value-types.ts +42 -0
  504. package/src/application/transform/document/components.ts +2 -2
  505. package/src/application/transform/document/declared-type-names.ts +36 -0
  506. package/src/application/transform/document/defs-root.ts +2 -2
  507. package/src/application/transform/document/document.ts +8 -5
  508. package/src/application/transform/document/enum-names-given-back.ts +91 -0
  509. package/src/application/transform/document/exploded-query-values.ts +88 -0
  510. package/src/application/transform/document/global-type-references.ts +1 -1
  511. package/src/application/transform/document/header.ts +25 -5
  512. package/src/application/transform/document/media-type.ts +4 -3
  513. package/src/application/transform/document/operation-keys-written.ts +27 -0
  514. package/src/application/transform/document/operation.ts +2 -2
  515. package/src/application/transform/document/parameter-entries.ts +70 -0
  516. package/src/application/transform/document/parameter.ts +21 -9
  517. package/src/application/transform/document/parameters.ts +56 -66
  518. package/src/application/transform/document/path-item.ts +16 -34
  519. package/src/application/transform/document/path-template-key.ts +152 -0
  520. package/src/application/transform/document/path-template-refs.ts +106 -0
  521. package/src/application/transform/document/paths-enum.ts +24 -10
  522. package/src/application/transform/document/paths.ts +59 -125
  523. package/src/application/transform/document/referenced-parameter.ts +146 -0
  524. package/src/application/transform/document/request-body.ts +2 -2
  525. package/src/application/transform/document/response.ts +3 -3
  526. package/src/application/transform/document/responses.ts +2 -2
  527. package/src/application/transform/document/root-type-aliases.ts +17 -38
  528. package/src/application/transform/document/type-resolution.ts +2 -1
  529. package/src/application/transform/document/webhooks.ts +19 -6
  530. package/src/application/transform/footer/document-footer.ts +36 -9
  531. package/src/application/transform/footer/enum-name-claims.ts +62 -0
  532. package/src/application/transform/footer/operation-keys.ts +28 -0
  533. package/src/application/transform/footer/type-evaluation.ts +4 -4
  534. package/src/application/transform/helper-types.ts +8 -7
  535. package/src/application/transform/numbered-names.ts +15 -0
  536. package/src/application/transform/ref-pointer/generated-location.ts +3 -3
  537. package/src/application/transform/ref-pointer/generated-shape.ts +67 -78
  538. package/src/application/transform/ref-pointer/inline-cycles.ts +1 -1
  539. package/src/application/transform/ref-pointer/located-node.ts +38 -0
  540. package/src/application/transform/ref-pointer/original-index.ts +100 -17
  541. package/src/application/transform/ref-pointer/pointer-type.ts +1 -1
  542. package/src/application/transform/ref-pointer/pointer-walk.ts +82 -8
  543. package/src/application/transform/ref-pointer/property-shape.ts +97 -0
  544. package/src/application/transform/ref-pointer/typed-walk.ts +117 -25
  545. package/src/application/transform/ref-type.ts +2 -1
  546. package/src/application/transform/schema/access-flags.ts +5 -2
  547. package/src/application/transform/schema/composition-type.ts +2 -2
  548. package/src/application/transform/schema/enum-rule.ts +6 -2
  549. package/src/application/transform/schema/index-signature-type.ts +31 -0
  550. package/src/application/transform/schema/input-location.ts +35 -0
  551. package/src/application/transform/schema/object-type.ts +22 -12
  552. package/src/application/transform/schema/ref-siblings.ts +76 -0
  553. package/src/application/transform/schema/schema-context.ts +3 -0
  554. package/src/application/transform/schema/schema-transform.ts +6 -3
  555. package/src/application/transform/schema/unevaluated-properties.ts +4 -44
  556. package/src/application/transform/schema-comment.ts +5 -1
  557. package/src/application/transform/transform-context.ts +5 -0
  558. package/src/cli/api-logger.ts +17 -0
  559. package/src/cli/api-settings.ts +80 -13
  560. package/src/cli/api-writes.ts +117 -0
  561. package/src/cli/cli-arguments.ts +90 -14
  562. package/src/cli/cli-dependencies.ts +26 -4
  563. package/src/cli/cli-errors.ts +42 -1
  564. package/src/cli/cli-output.ts +195 -15
  565. package/src/cli/main.ts +14 -5
  566. package/src/cli/redocly-apis.ts +177 -52
  567. package/src/cli/ref-limits.ts +21 -2
  568. package/src/cli/run-cli.ts +76 -15
  569. package/src/domain/append-all.ts +10 -0
  570. package/src/domain/cause-secrets.ts +86 -0
  571. package/src/domain/errors.ts +16 -5
  572. package/src/domain/ir/identifier-text.ts +6 -5
  573. package/src/domain/ir/ir-shape.ts +299 -0
  574. package/src/domain/ir/newer-identifier-ranges.ts +183 -30
  575. package/src/domain/location-text.ts +12 -0
  576. package/src/domain/openapi/alias-expansion.ts +4 -1
  577. package/src/domain/openapi/discriminated-union.ts +6 -4
  578. package/src/domain/openapi/discriminator-conflicts.ts +21 -7
  579. package/src/domain/openapi/document-object.ts +2 -0
  580. package/src/domain/openapi/document-places.ts +78 -0
  581. package/src/domain/openapi/json-pointer.ts +96 -7
  582. package/src/domain/openapi/schema-dialect.ts +22 -0
  583. package/src/domain/openapi/unsupported-features.ts +2 -2
  584. package/src/domain/output-fixes.ts +28 -2
  585. package/src/domain/terminal-text.ts +44 -0
  586. package/src/domain/url-secrets.ts +72 -0
  587. package/src/domain/warnings.ts +1 -0
  588. package/src/types/generator-options.ts +1 -1
  589. package/dist/cli/main.d.cts +0 -2
  590. package/dist/cli/main.d.mts +0 -2
  591. package/dist/cli/main.d.ts +0 -2
  592. package/dist/domain/url-credentials.cjs +0 -10
  593. package/dist/domain/url-credentials.cjs.map +0 -1
  594. package/dist/domain/url-credentials.mjs +0 -8
  595. package/dist/domain/url-credentials.mjs.map +0 -1
  596. package/src/domain/url-credentials.ts +0 -18
@@ -1 +1 @@
1
- {"version":3,"file":"response.mjs","sources":["../../../../src/application/transform/document/response.ts"],"sourcesContent":["import {\n irKeyword,\n irObject,\n irProperty,\n irStringIndexSignature,\n} from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport {\n isMediaTypeComponentRef,\n type MediaTypeObject,\n} from \"../../../domain/openapi/media-type-object.js\";\nimport type { ResponseObject } from \"../../../domain/openapi/response-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { headerType } from \"./header.js\";\nimport { contentEntryType, itemContentMember, mediaTypeType } from \"./media-type.js\";\n\ntype HeaderEntry = NonNullable<ResponseObject[\"headers\"]>[string];\n\nfunction headerMember(\n name: string,\n header: HeaderEntry,\n location: SchemaLocation,\n context: SchemaContext,\n): IrPropertySignature {\n // A referenced header counts as required: the reference does not say otherwise.\n const isReference = \"$ref\" in header;\n const type = isReference\n ? refType(header.$ref)\n : headerType(\n header,\n { ...location, path: createRef([location.path, \"headers\", name]) },\n context,\n );\n return documentMember(name, type, header, {\n isReadonly: context.options.immutable,\n isOptional: !isReference && !header.required,\n });\n}\n\n/** The listed headers, then `[name: string]: unknown`, because servers may send others. */\nfunction headersMember(\n response: ResponseObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrPropertySignature {\n const entries = documentEntries(response.headers ?? {}, context.options);\n const members: IrMember[] = entries.map(([name, header]) =>\n headerMember(name, header, location, context),\n );\n members.push(irStringIndexSignature(\"name\", UNKNOWN_TYPE, context.options.immutable));\n return irProperty(toPropertyName(\"headers\"), irObject(members));\n}\n\n/**\n * One media type of a response. The original reads a `$ref` entry as a media type without a\n * schema, so it is `unknown`; a `$ref` to an OpenAPI 3.2 media type component is typed as it.\n */\nfunction mediaTypeEntryType(\n entry: NonNullable<ResponseObject[\"content\"]>[string],\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n return \"$ref\" in entry && isMediaTypeComponentRef(entry.$ref)\n ? contentEntryType(entry, location, context)\n : mediaTypeType(entry as MediaTypeObject, location, context);\n}\n\n/** `content` with one member per media type, or `content?: never` when there are none. */\nfunction contentMember(\n response: ResponseObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrPropertySignature {\n const entries = documentEntries(response.content ?? {}, context.options);\n const members = entries.map(([contentType, entry]) => {\n const path = createRef([location.path, \"content\", contentType]);\n const type = mediaTypeEntryType(entry, { ...location, path }, context);\n return documentMember(contentType, type, entry, { isReadonly: context.options.immutable });\n });\n const name = toPropertyName(\"content\");\n return members.length > 0\n ? irProperty(name, irObject(members))\n : irProperty(name, irKeyword(\"never\"), { isOptional: true });\n}\n\n/**\n * A response (OpenAPI 3.2 §4.8.17): `{ headers: {…}; content: {…} }`, and `itemContent` when a\n * media type has an `itemSchema`. No member is readonly, even with --immutable, as in the original.\n */\nexport function responseType(\n response: ResponseObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n const itemContent = itemContentMember(response.content ?? {}, location, context, {\n isReadonly: false,\n });\n return irObject([\n headersMember(response, location, context),\n contentMember(response, location, context),\n ...(itemContent ? [itemContent] : []),\n ]);\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAwBA,SAAS,YAAA,CACP,IAAA,EACA,MAAA,EACA,QAAA,EACA,OAAA,EACqB;AAErB,EAAA,MAAM,cAAc,MAAA,IAAU,MAAA;AAC9B,EAAA,MAAM,IAAA,GAAO,WAAA,GACT,OAAA,CAAQ,MAAA,CAAO,IAAI,CAAA,GACnB,UAAA;AAAA,IACE,MAAA;AAAA,IACA,EAAE,GAAG,QAAA,EAAU,IAAA,EAAM,SAAA,CAAU,CAAC,QAAA,CAAS,IAAA,EAAM,SAAA,EAAW,IAAI,CAAC,CAAA,EAAE;AAAA,IACjE;AAAA,GACF;AACJ,EAAA,OAAO,cAAA,CAAe,IAAA,EAAM,IAAA,EAAM,MAAA,EAAQ;AAAA,IACxC,UAAA,EAAY,QAAQ,OAAA,CAAQ,SAAA;AAAA,IAC5B,UAAA,EAAY,CAAC,WAAA,IAAe,CAAC,MAAA,CAAO;AAAA,GACrC,CAAA;AACH;AAGA,SAAS,aAAA,CACP,QAAA,EACA,QAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,UAAU,eAAA,CAAgB,QAAA,CAAS,WAAW,EAAC,EAAG,QAAQ,OAAO,CAAA;AACvE,EAAA,MAAM,UAAsB,OAAA,CAAQ,GAAA;AAAA,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AA,CAAW,IAAA,EAAM,SAAS,OAAO,CAAC,CAAA,GAClC,UAAA,CAAW,MAAM,SAAA,CAAU,OAAO,GAAG,EAAE,UAAA,EAAY,MAAM,CAAA;AAC/D;AAMO,SAAS,YAAA,CACd,QAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,cAAc,iBAAA,CAAkB,QAAA,CAAS,WAAW,EAAC,EAAG,UAAU,OAAA,EAAS;AAAA,IAC/E,UAAA,EAAY;AAAA,GACb,CAAA;AACD,EAAA,OAAO,QAAA,CAAS;AAAA,IACd,aAAA,CAAc,QAAA,EAAU,QAAA,EAAU,OAAO,CAAA;AAAA,IACzC,aAAA,CAAc,QAAA,EAAU,QAAA,EAAU,OAAO,CAAA;AAAA,IACzC,GAAI,WAAA,GAAc,CAAC,WAAW,IAAI;AAAC,GACpC,CAAA;AACH;;"}
1
+ {"version":3,"file":"response.mjs","sources":["../../../../src/application/transform/document/response.ts"],"sourcesContent":["import {\n irKeyword,\n irObject,\n irProperty,\n irStringIndexSignature,\n} from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport {\n isMediaTypeComponentRef,\n type MediaTypeObject,\n} from \"../../../domain/openapi/media-type-object.js\";\nimport type { ResponseObject } from \"../../../domain/openapi/response-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { headerType } from \"./header.js\";\nimport { contentEntryType, itemContentMember, mediaTypeType } from \"./media-type.js\";\n\ntype HeaderEntry = NonNullable<ResponseObject[\"headers\"]>[string];\n\nfunction headerMember(\n name: string,\n header: HeaderEntry,\n location: SchemaLocation,\n context: SchemaContext,\n): IrPropertySignature {\n // A referenced header counts as required: the reference does not say otherwise.\n const isReference = \"$ref\" in header;\n const type = isReference\n ? refType(header.$ref)\n : headerType(\n header,\n { ...location, path: appendPointer(location.path, [\"headers\", name]) },\n context,\n );\n return documentMember(name, type, header, {\n isReadonly: context.options.immutable,\n isOptional: !isReference && !header.required,\n });\n}\n\n/** The listed headers, then `[name: string]: unknown`, because servers may send others. */\nfunction headersMember(\n response: ResponseObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrPropertySignature {\n const entries = documentEntries(response.headers ?? {}, context.options);\n const members: IrMember[] = entries.map(([name, header]) =>\n headerMember(name, header, location, context),\n );\n members.push(irStringIndexSignature(\"name\", UNKNOWN_TYPE, context.options.immutable));\n return irProperty(toPropertyName(\"headers\"), irObject(members));\n}\n\n/**\n * One media type of a response. The original reads a `$ref` entry as a media type without a\n * schema, so it is `unknown`; a `$ref` to an OpenAPI 3.2 media type component is typed as it.\n */\nfunction mediaTypeEntryType(\n entry: NonNullable<ResponseObject[\"content\"]>[string],\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n return \"$ref\" in entry && isMediaTypeComponentRef(entry.$ref)\n ? contentEntryType(entry, location, context)\n : mediaTypeType(entry as MediaTypeObject, location, context);\n}\n\n/** `content` with one member per media type, or `content?: never` when there are none. */\nfunction contentMember(\n response: ResponseObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrPropertySignature {\n const entries = documentEntries(response.content ?? {}, context.options);\n const members = entries.map(([contentType, entry]) => {\n const path = appendPointer(location.path, [\"content\", contentType]);\n const type = mediaTypeEntryType(entry, { ...location, path }, context);\n return documentMember(contentType, type, entry, { isReadonly: context.options.immutable });\n });\n const name = toPropertyName(\"content\");\n return members.length > 0\n ? irProperty(name, irObject(members))\n : irProperty(name, irKeyword(\"never\"), { isOptional: true });\n}\n\n/**\n * A response (OpenAPI 3.2 §4.8.17): `{ headers: {…}; content: {…} }`, and `itemContent` when a\n * media type has an `itemSchema`. No member is readonly, even with --immutable, as in the original.\n */\nexport function responseType(\n response: ResponseObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n const itemContent = itemContentMember(response.content ?? {}, location, context, {\n isReadonly: false,\n });\n return irObject([\n headersMember(response, location, context),\n contentMember(response, location, context),\n ...(itemContent ? [itemContent] : []),\n ]);\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAwBA,SAAS,YAAA,CACP,IAAA,EACA,MAAA,EACA,QAAA,EACA,OAAA,EACqB;AAErB,EAAA,MAAM,cAAc,MAAA,IAAU,MAAA;AAC9B,EAAA,MAAM,IAAA,GAAO,WAAA,GACT,OAAA,CAAQ,MAAA,CAAO,IAAI,CAAA,GACnB,UAAA;AAAA,IACE,MAAA;AAAA,IACA,EAAE,GAAG,QAAA,EAAU,IAAA,EAAM,aAAA,CAAc,QAAA,CAAS,IAAA,EAAM,CAAC,SAAA,EAAW,IAAI,CAAC,CAAA,EAAE;AAAA,IACrE;AAAA,GACF;AACJ,EAAA,OAAO,cAAA,CAAe,IAAA,EAAM,IAAA,EAAM,MAAA,EAAQ;AAAA,IACxC,UAAA,EAAY,QAAQ,OAAA,CAAQ,SAAA;AAAA,IAC5B,UAAA,EAAY,CAAC,WAAA,IAAe,CAAC,MAAA,CAAO;AAAA,GACrC,CAAA;AACH;AAGA,SAAS,aAAA,CACP,QAAA,EACA,QAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,UAAU,eAAA,CAAgB,QAAA,CAAS,WAAW,EAAC,EAAG,QAAQ,OAAO,CAAA;AACvE,EAAA,MAAM,UAAsB,OAAA,CAAQ,GAAA;AAAA,IAAI,CAAC,CAAC,IAAA,EAAM,MAAM,MACpD,YAAA,CAAa,IAAA,EAAM,MAAA,EAAQ,QAAA,EAAU,OAAO;AAAA,GAC9C;AACA,EAAA,OAAA,CAAQ,KAAK,sBAAA,CAAuB,MAAA,EAAQ,cAAc,OAAA,CAAQ,OAAA,CAAQ,SAAS,CAAC,CAAA;AACpF,EAAA,OAA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,WAAW,EAAC,EAAG,UAAU,OAAA,EAAS;AAAA,IAC/E,UAAA,EAAY;AAAA,GACb,CAAA;AACD,EAAA,OAAO,QAAA,CAAS;AAAA,IACd,aAAA,CAAc,QAAA,EAAU,QAAA,EAAU,OAAO,CAAA;AAAA,IACzC,aAAA,CAAc,QAAA,EAAU,QAAA,EAAU,OAAO,CAAA;AAAA,IACzC,GAAI,WAAA,GAAc,CAAC,WAAW,IAAI;AAAC,GACpC,CAAA;AACH;;"}
@@ -11,7 +11,7 @@ function responsesType(responses, location, context) {
11
11
  const members = documentEntries.documentEntries(responses, context.options).map(([code, response$1]) => {
12
12
  const type = "$ref" in response$1 ? refType.refType(response$1.$ref) : response.responseType(
13
13
  response$1,
14
- { ...location, path: jsonPointer.createRef([location.path, "responses", code]) },
14
+ { ...location, path: jsonPointer.appendPointer(location.path, ["responses", code]) },
15
15
  context
16
16
  );
17
17
  return documentMember.documentMember(code, type, response$1, { isReadonly: context.options.immutable });
@@ -1 +1 @@
1
- {"version":3,"file":"responses.cjs","sources":["../../../../src/application/transform/document/responses.ts"],"sourcesContent":["import { irKeyword, irObject } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport type { ResponsesObject } from \"../../../domain/openapi/response-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { responseType } from \"./response.js\";\n\n/** Responses by status code (OpenAPI 3.1 §4.8.16), or `never` when there are none. */\nexport function responsesType(\n responses: ResponsesObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n const members = documentEntries(responses, context.options).map(([code, response]) => {\n const type =\n \"$ref\" in response\n ? refType(response.$ref)\n : responseType(\n response,\n { ...location, path: createRef([location.path, \"responses\", code]) },\n context,\n );\n return documentMember(code, type, response, { isReadonly: context.options.immutable });\n });\n return members.length > 0 ? irObject(members) : irKeyword(\"never\");\n}\n"],"names":["documentEntries","response","refType","responseType","createRef","documentMember","irObject","irKeyword"],"mappings":";;;;;;;;;AAWO,SAAS,aAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,OAAA,GAAUA,+BAAA,CAAgB,SAAA,EAAW,OAAA,CAAQ,OAAO,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,IAAA,EAAMC,UAAQ,CAAA,KAAM;AACpF,IAAA,MAAM,OACJ,MAAA,IAAUA,UAAA,GACNC,eAAA,CAAQD,UAAA,CAAS,IAAI,CAAA,GACrBE,qBAAA;AAAA,MACEF,UAAA;AAAA,MACA,EAAE,GAAG,QAAA,EAAU,IAAA,EAAMG,qBAAA,CAAU,CAAC,QAAA,CAAS,IAAA,EAAM,WAAA,EAAa,IAAI,CAAC,CAAA,EAAE;AAAA,MACnE;AAAA,KACF;AACN,IAAA,OAAOC,6BAAA,CAAe,MAAM,IAAA,EAAMJ,UAAA,EAAU,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW,CAAA;AAAA,EACvF,CAAC,CAAA;AACD,EAAA,OAAO,QAAQ,MAAA,GAAS,CAAA,GAAIK,sBAAS,OAAO,CAAA,GAAIC,uBAAU,OAAO,CAAA;AACnE;;"}
1
+ {"version":3,"file":"responses.cjs","sources":["../../../../src/application/transform/document/responses.ts"],"sourcesContent":["import { irKeyword, irObject } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { appendPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport type { ResponsesObject } from \"../../../domain/openapi/response-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { responseType } from \"./response.js\";\n\n/** Responses by status code (OpenAPI 3.1 §4.8.16), or `never` when there are none. */\nexport function responsesType(\n responses: ResponsesObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n const members = documentEntries(responses, context.options).map(([code, response]) => {\n const type =\n \"$ref\" in response\n ? refType(response.$ref)\n : responseType(\n response,\n { ...location, path: appendPointer(location.path, [\"responses\", code]) },\n context,\n );\n return documentMember(code, type, response, { isReadonly: context.options.immutable });\n });\n return members.length > 0 ? irObject(members) : irKeyword(\"never\");\n}\n"],"names":["documentEntries","response","refType","responseType","appendPointer","documentMember","irObject","irKeyword"],"mappings":";;;;;;;;;AAWO,SAAS,aAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,OAAA,GAAUA,+BAAA,CAAgB,SAAA,EAAW,OAAA,CAAQ,OAAO,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,IAAA,EAAMC,UAAQ,CAAA,KAAM;AACpF,IAAA,MAAM,OACJ,MAAA,IAAUA,UAAA,GACNC,eAAA,CAAQD,UAAA,CAAS,IAAI,CAAA,GACrBE,qBAAA;AAAA,MACEF,UAAA;AAAA,MACA,EAAE,GAAG,QAAA,EAAU,IAAA,EAAMG,yBAAA,CAAc,QAAA,CAAS,IAAA,EAAM,CAAC,WAAA,EAAa,IAAI,CAAC,CAAA,EAAE;AAAA,MACvE;AAAA,KACF;AACN,IAAA,OAAOC,6BAAA,CAAe,MAAM,IAAA,EAAMJ,UAAA,EAAU,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW,CAAA;AAAA,EACvF,CAAC,CAAA;AACD,EAAA,OAAO,QAAQ,MAAA,GAAS,CAAA,GAAIK,sBAAS,OAAO,CAAA,GAAIC,uBAAU,OAAO,CAAA;AACnE;;"}
@@ -1,5 +1,5 @@
1
1
  import { irObject, irKeyword } from '../../../domain/ir/constructors.mjs';
2
- import { createRef } from '../../../domain/openapi/json-pointer.mjs';
2
+ import { appendPointer } from '../../../domain/openapi/json-pointer.mjs';
3
3
  import { documentEntries } from '../document-entries.mjs';
4
4
  import { refType } from '../ref-type.mjs';
5
5
  import { documentMember } from './document-member.mjs';
@@ -9,7 +9,7 @@ function responsesType(responses, location, context) {
9
9
  const members = documentEntries(responses, context.options).map(([code, response]) => {
10
10
  const type = "$ref" in response ? refType(response.$ref) : responseType(
11
11
  response,
12
- { ...location, path: createRef([location.path, "responses", code]) },
12
+ { ...location, path: appendPointer(location.path, ["responses", code]) },
13
13
  context
14
14
  );
15
15
  return documentMember(code, type, response, { isReadonly: context.options.immutable });
@@ -1 +1 @@
1
- {"version":3,"file":"responses.mjs","sources":["../../../../src/application/transform/document/responses.ts"],"sourcesContent":["import { irKeyword, irObject } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport type { ResponsesObject } from \"../../../domain/openapi/response-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { responseType } from \"./response.js\";\n\n/** Responses by status code (OpenAPI 3.1 §4.8.16), or `never` when there are none. */\nexport function responsesType(\n responses: ResponsesObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n const members = documentEntries(responses, context.options).map(([code, response]) => {\n const type =\n \"$ref\" in response\n ? refType(response.$ref)\n : responseType(\n response,\n { ...location, path: createRef([location.path, \"responses\", code]) },\n context,\n );\n return documentMember(code, type, response, { isReadonly: context.options.immutable });\n });\n return members.length > 0 ? irObject(members) : irKeyword(\"never\");\n}\n"],"names":[],"mappings":";;;;;;;AAWO,SAAS,aAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,OAAA,GAAU,eAAA,CAAgB,SAAA,EAAW,OAAA,CAAQ,OAAO,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,IAAA,EAAM,QAAQ,CAAA,KAAM;AACpF,IAAA,MAAM,OACJ,MAAA,IAAU,QAAA,GACN,OAAA,CAAQ,QAAA,CAAS,IAAI,CAAA,GACrB,YAAA;AAAA,MACE,QAAA;AAAA,MACA,EAAE,GAAG,QAAA,EAAU,IAAA,EAAM,SAAA,CAAU,CAAC,QAAA,CAAS,IAAA,EAAM,WAAA,EAAa,IAAI,CAAC,CAAA,EAAE;AAAA,MACnE;AAAA,KACF;AACN,IAAA,OAAO,cAAA,CAAe,MAAM,IAAA,EAAM,QAAA,EAAU,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW,CAAA;AAAA,EACvF,CAAC,CAAA;AACD,EAAA,OAAO,QAAQ,MAAA,GAAS,CAAA,GAAI,SAAS,OAAO,CAAA,GAAI,UAAU,OAAO,CAAA;AACnE;;"}
1
+ {"version":3,"file":"responses.mjs","sources":["../../../../src/application/transform/document/responses.ts"],"sourcesContent":["import { irKeyword, irObject } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { appendPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport type { ResponsesObject } from \"../../../domain/openapi/response-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaContext, SchemaLocation } from \"../schema/schema-context.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { responseType } from \"./response.js\";\n\n/** Responses by status code (OpenAPI 3.1 §4.8.16), or `never` when there are none. */\nexport function responsesType(\n responses: ResponsesObject,\n location: SchemaLocation,\n context: SchemaContext,\n): IrType {\n const members = documentEntries(responses, context.options).map(([code, response]) => {\n const type =\n \"$ref\" in response\n ? refType(response.$ref)\n : responseType(\n response,\n { ...location, path: appendPointer(location.path, [\"responses\", code]) },\n context,\n );\n return documentMember(code, type, response, { isReadonly: context.options.immutable });\n });\n return members.length > 0 ? irObject(members) : irKeyword(\"never\");\n}\n"],"names":[],"mappings":";;;;;;;AAWO,SAAS,aAAA,CACd,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,OAAA,GAAU,eAAA,CAAgB,SAAA,EAAW,OAAA,CAAQ,OAAO,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,IAAA,EAAM,QAAQ,CAAA,KAAM;AACpF,IAAA,MAAM,OACJ,MAAA,IAAU,QAAA,GACN,OAAA,CAAQ,QAAA,CAAS,IAAI,CAAA,GACrB,YAAA;AAAA,MACE,QAAA;AAAA,MACA,EAAE,GAAG,QAAA,EAAU,IAAA,EAAM,aAAA,CAAc,QAAA,CAAS,IAAA,EAAM,CAAC,WAAA,EAAa,IAAI,CAAC,CAAA,EAAE;AAAA,MACvE;AAAA,KACF;AACN,IAAA,OAAO,cAAA,CAAe,MAAM,IAAA,EAAM,QAAA,EAAU,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW,CAAA;AAAA,EACvF,CAAC,CAAA;AACD,EAAA,OAAO,QAAQ,MAAA,GAAS,CAAA,GAAI,SAAS,OAAO,CAAA,GAAI,UAAU,OAAO,CAAA;AACnE;;"}
@@ -2,6 +2,8 @@
2
2
 
3
3
  const constructors = require('../../../domain/ir/constructors.cjs');
4
4
  const rawTextEscapes = require('../../../domain/ir/raw-text-escapes.cjs');
5
+ const numberedNames = require('../numbered-names.cjs');
6
+ const declaredTypeNames = require('./declared-type-names.cjs');
5
7
  const globalTypeReferences = require('./global-type-references.cjs');
6
8
 
7
9
  const REFERENCE_PREFIX = "components['";
@@ -19,16 +21,6 @@ function rootTypeAlias(name, kind, item) {
19
21
  function isRootTypeAlias(declaration) {
20
22
  return declaration.kind === "typeAlias" && declaration.type.kind === "raw" && declaration.type.text.startsWith(REFERENCE_PREFIX);
21
23
  }
22
- function footerTypeNames(declarations) {
23
- return new Set(
24
- declarations.flatMap((declaration) => {
25
- if (declaration.kind === "enum") {
26
- return [declaration.name];
27
- }
28
- return declaration.kind === "rawDeclaration" && declaration.name !== void 0 ? [declaration.name] : [];
29
- })
30
- );
31
- }
32
24
  function declaredNames(declarations) {
33
25
  return new Set(
34
26
  declarations.flatMap(
@@ -36,19 +28,11 @@ function declaredNames(declarations) {
36
28
  )
37
29
  );
38
30
  }
39
- function freeName(name, taken) {
40
- let candidate = `${name}_2`;
41
- for (let counter = 3; taken.has(candidate); counter++) {
42
- candidate = `${name}_${counter}`;
43
- }
44
- return candidate;
45
- }
46
31
  function renameTakenAliases(body, footer, closing = []) {
47
- const reserved = footerTypeNames(footer);
48
- for (const name of globalTypeReferences.globalTypeReferences([...body, ...footer, ...closing])) {
49
- reserved.add(name);
50
- }
51
- const taken = declaredNames([...body, ...footer, ...closing]);
32
+ const all = [...body, ...footer, ...closing];
33
+ const others = all.filter((declaration) => !isRootTypeAlias(declaration));
34
+ const reserved = /* @__PURE__ */ new Set([...declaredTypeNames.typeNamesDeclaredBy(others), ...globalTypeReferences.globalTypeReferences(all)]);
35
+ const taken = /* @__PURE__ */ new Set([...declaredNames(all), ...declaredTypeNames.typeNamesDeclaredBy(all)]);
52
36
  const aliasNames = /* @__PURE__ */ new Set();
53
37
  return body.map((declaration) => {
54
38
  if (!isRootTypeAlias(declaration)) {
@@ -59,12 +43,13 @@ function renameTakenAliases(body, footer, closing = []) {
59
43
  if (!isRepeated && !reserved.has(declaration.name)) {
60
44
  return declaration;
61
45
  }
62
- const name = freeName(declaration.name, taken);
46
+ const name = numberedNames.freeNumberedName(declaration.name, taken);
63
47
  taken.add(name);
64
48
  return { ...declaration, name };
65
49
  });
66
50
  }
67
51
 
52
+ exports.isRootTypeAlias = isRootTypeAlias;
68
53
  exports.renameTakenAliases = renameTakenAliases;
69
54
  exports.rootTypeAlias = rootTypeAlias;
70
55
  //# sourceMappingURL=root-type-aliases.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"root-type-aliases.cjs","sources":["../../../../src/application/transform/document/root-type-aliases.ts"],"sourcesContent":["import { irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrDeclaration, IrTypeAliasDeclaration } from \"../../../domain/ir/nodes.js\";\nimport { escapeSingleQuotedText } from \"../../../domain/ir/raw-text-escapes.js\";\nimport type { ComponentKind } from \"../../../domain/openapi/components-object.js\";\nimport { globalTypeReferences } from \"./global-type-references.js\";\n\n/** The `--root-types` aliases: `export type Pet = components['schemas']['Pet'];`. */\n\nconst REFERENCE_PREFIX = \"components['\";\n\n/** The alias of one component. */\nexport function rootTypeAlias(\n name: string,\n kind: ComponentKind,\n item: string,\n): IrTypeAliasDeclaration {\n return {\n kind: \"typeAlias\",\n name,\n isExported: true,\n // The original writes the reference as text, with single quotes, and did not escape the\n // name: a quote in it could add code to the generated file (intentional fix).\n type: irRaw(`${REFERENCE_PREFIX}${kind}']['${escapeSingleQuotedText(item)}']`),\n comments: [],\n };\n}\n\nfunction isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAliasDeclaration {\n return (\n declaration.kind === \"typeAlias\" &&\n declaration.type.kind === \"raw\" &&\n declaration.type.text.startsWith(REFERENCE_PREFIX)\n );\n}\n\n/**\n * The type names the footer declares that an alias must not take: enums, and helper types such as\n * `WithRequired`. Value declarations (`--enum-values` arrays) live in another namespace.\n */\nfunction footerTypeNames(declarations: readonly IrDeclaration[]): Set<string> {\n return new Set(\n declarations.flatMap((declaration) => {\n if (declaration.kind === \"enum\") {\n return [declaration.name];\n }\n return declaration.kind === \"rawDeclaration\" && declaration.name !== undefined\n ? [declaration.name]\n : [];\n }),\n );\n}\n\nfunction declaredNames(declarations: readonly IrDeclaration[]): Set<string> {\n return new Set(\n declarations.flatMap((declaration) =>\n \"name\" in declaration && declaration.name !== undefined ? [declaration.name] : [],\n ),\n );\n}\n\nfunction freeName(name: string, taken: ReadonlySet<string>): string {\n let candidate = `${name}_2`;\n for (let counter = 3; taken.has(candidate); counter++) {\n candidate = `${name}_${counter}`;\n }\n return candidate;\n}\n\n/**\n * Rename each root alias whose name an enum or a helper type of the footer also declares, or that\n * shadows a TypeScript global type the output refers to (`Record` in `Record<string, never>`), to\n * the next free `Name_2`, `Name_3`, … (the suffix `--root-types` uses for its own conflicts). The\n * footer and the globals keep their names, because the generated types refer to them. Before, the\n * output did not compile (enums: upstream #2099, #2341, #2206; helpers: a schema named\n * `WithRequired`, roadmap R11; globals: TS2315). Other declarations are returned unchanged.\n *\n * With the `root-type-numbering` fix (ADR-021, roadmap R13, backlog 30) the body also holds the\n * aliases a later schema of one exported name took the name from, after the other aliases and\n * under that same name. Each gets the next free number in body order, after the alias that kept\n * the name got its own: so the fix only adds exports, and every other alias keeps the name it has\n * without the fix.\n */\nexport function renameTakenAliases<T extends IrDeclaration>(\n body: readonly T[],\n footer: readonly IrDeclaration[],\n closing: readonly IrDeclaration[] = [],\n): T[] {\n const reserved = footerTypeNames(footer);\n for (const name of globalTypeReferences([...body, ...footer, ...closing])) {\n reserved.add(name);\n }\n const taken = declaredNames([...body, ...footer, ...closing]);\n const aliasNames = new Set<string>();\n return body.map((declaration) => {\n if (!isRootTypeAlias(declaration)) {\n return declaration;\n }\n const isRepeated = aliasNames.has(declaration.name);\n aliasNames.add(declaration.name);\n if (!isRepeated && !reserved.has(declaration.name)) {\n return declaration;\n }\n const name = freeName(declaration.name, taken);\n taken.add(name);\n return { ...declaration, name };\n });\n}\n"],"names":["irRaw","escapeSingleQuotedText","globalTypeReferences"],"mappings":";;;;;;AAQA,MAAM,gBAAA,GAAmB,cAAA;AAGlB,SAAS,aAAA,CACd,IAAA,EACA,IAAA,EACA,IAAA,EACwB;AACxB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,WAAA;AAAA,IACN,IAAA;AAAA,IACA,UAAA,EAAY,IAAA;AAAA;AAAA;AAAA,IAGZ,IAAA,EAAMA,kBAAA,CAAM,CAAA,EAAG,gBAAgB,CAAA,EAAG,IAAI,CAAA,IAAA,EAAOC,qCAAA,CAAuB,IAAI,CAAC,CAAA,EAAA,CAAI,CAAA;AAAA,IAC7E,UAAU;AAAC,GACb;AACF;AAEA,SAAS,gBAAgB,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BAAgB,MAAM,CAAA;AACvC,EAAA,KAAA,MAAW,IAAA,IAAQC,yCAAA,CAAqB,CAAC,GAAG,IAAA,EAAM,GAAG,MAAA,EAAQ,GAAG,OAAO,CAAC,CAAA,EAAG;AACzE,IAAA,QAAA,CAAS,IAAI,IAAI,CAAA;AAAA,EACnB;AACA,EAAA,MAAM,KAAA,GAAQ,cAAc,CAAC,GAAG,MAAM,GAAG,MAAA,EAAQ,GAAG,OAAO,CAAC,CAAA;AAC5D,EAAA,MAAM,UAAA,uBAAiB,GAAA,EAAY;AACnC,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,CAAC,WAAA,KAAgB;AAC/B,IAAA,IAAI,CAAC,eAAA,CAAgB,WAAW,CAAA,EAAG;AACjC,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,MAAM,UAAA,GAAa,UAAA,CAAW,GAAA,CAAI,WAAA,CAAY,IAAI,CAAA;AAClD,IAAA,UAAA,CAAW,GAAA,CAAI,YAAY,IAAI,CAAA;AAC/B,IAAA,IAAI,CAAC,UAAA,IAAc,CAAC,SAAS,GAAA,CAAI,WAAA,CAAY,IAAI,CAAA,EAAG;AAClD,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,MAAM,IAAA,GAAO,QAAA,CAAS,WAAA,CAAY,IAAA,EAAM,KAAK,CAAA;AAC7C,IAAA,KAAA,CAAM,IAAI,IAAI,CAAA;AACd,IAAA,OAAO,EAAE,GAAG,WAAA,EAAa,IAAA,EAAK;AAAA,EAChC,CAAC,CAAA;AACH;;;"}
1
+ {"version":3,"file":"root-type-aliases.cjs","sources":["../../../../src/application/transform/document/root-type-aliases.ts"],"sourcesContent":["import { irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrDeclaration, IrTypeAliasDeclaration } from \"../../../domain/ir/nodes.js\";\nimport { escapeSingleQuotedText } from \"../../../domain/ir/raw-text-escapes.js\";\nimport type { ComponentKind } from \"../../../domain/openapi/components-object.js\";\nimport { freeNumberedName } from \"../numbered-names.js\";\nimport { typeNamesDeclaredBy } from \"./declared-type-names.js\";\nimport { globalTypeReferences } from \"./global-type-references.js\";\n\n/** The `--root-types` aliases: `export type Pet = components['schemas']['Pet'];`. */\n\nconst REFERENCE_PREFIX = \"components['\";\n\n/** The alias of one component. */\nexport function rootTypeAlias(\n name: string,\n kind: ComponentKind,\n item: string,\n): IrTypeAliasDeclaration {\n return {\n kind: \"typeAlias\",\n name,\n isExported: true,\n // The original writes the reference as text, with single quotes, and did not escape the\n // name: a quote in it could add code to the generated file (intentional fix).\n type: irRaw(`${REFERENCE_PREFIX}${kind}']['${escapeSingleQuotedText(item)}']`),\n comments: [],\n };\n}\n\n/** Whether the declaration is a `--root-types` alias, which gives way to every other name. */\nexport function isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAliasDeclaration {\n return (\n declaration.kind === \"typeAlias\" &&\n declaration.type.kind === \"raw\" &&\n declaration.type.text.startsWith(REFERENCE_PREFIX)\n );\n}\n\nfunction declaredNames(declarations: readonly IrDeclaration[]): Set<string> {\n return new Set(\n declarations.flatMap((declaration) =>\n \"name\" in declaration && declaration.name !== undefined ? [declaration.name] : [],\n ),\n );\n}\n\n/**\n * Rename each root alias whose name another declaration of the output also takes (an enum, a\n * helper type, the `--make-paths-enum` enum `ApiPaths`, a root interface, `--read-write-markers`\n * or `inject` types), or that shadows a TypeScript global type the output refers to (`Record` in\n * `Record<string, never>`), to the next free `Name_2`, `Name_3`, … (the suffix `--root-types` uses\n * for its own conflicts). The others and the globals keep their names, because the generated\n * types refer to them. Before, the output did not compile (enums: upstream #2099, #2341, #2206;\n * helpers: a schema named `WithRequired`, roadmap R11; globals: TS2315; `ApiPaths`: TS2567).\n * Other declarations are returned unchanged.\n *\n * With the `root-type-numbering` fix (ADR-021, roadmap R13, backlog 30) the body also holds the\n * aliases a later schema of one exported name took the name from, after the other aliases and\n * under that same name. Each gets the next free number in body order, after the alias that kept\n * the name got its own: so the fix only adds exports, and every other alias keeps the name it has\n * without the fix.\n */\nexport function renameTakenAliases<T extends IrDeclaration>(\n body: readonly T[],\n footer: readonly IrDeclaration[],\n closing: readonly IrDeclaration[] = [],\n): T[] {\n const all = [...body, ...footer, ...closing];\n const others = all.filter((declaration) => !isRootTypeAlias(declaration));\n const reserved = new Set([...typeNamesDeclaredBy(others), ...globalTypeReferences(all)]);\n const taken = new Set([...declaredNames(all), ...typeNamesDeclaredBy(all)]);\n const aliasNames = new Set<string>();\n return body.map((declaration) => {\n if (!isRootTypeAlias(declaration)) {\n return declaration;\n }\n const isRepeated = aliasNames.has(declaration.name);\n aliasNames.add(declaration.name);\n if (!isRepeated && !reserved.has(declaration.name)) {\n return declaration;\n }\n const name = freeNumberedName(declaration.name, taken);\n taken.add(name);\n return { ...declaration, name };\n });\n}\n"],"names":["irRaw","escapeSingleQuotedText","typeNamesDeclaredBy","globalTypeReferences","freeNumberedName"],"mappings":";;;;;;;;AAUA,MAAM,gBAAA,GAAmB,cAAA;AAGlB,SAAS,aAAA,CACd,IAAA,EACA,IAAA,EACA,IAAA,EACwB;AACxB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,WAAA;AAAA,IACN,IAAA;AAAA,IACA,UAAA,EAAY,IAAA;AAAA;AAAA;AAAA,IAGZ,IAAA,EAAMA,kBAAA,CAAM,CAAA,EAAG,gBAAgB,CAAA,EAAG,IAAI,CAAA,IAAA,EAAOC,qCAAA,CAAuB,IAAI,CAAC,CAAA,EAAA,CAAI,CAAA;AAAA,IAC7E,UAAU;AAAC,GACb;AACF;AAGO,SAAS,gBAAgB,WAAA,EAAmE;AACjG,EAAA,OACE,WAAA,CAAY,IAAA,KAAS,WAAA,IACrB,WAAA,CAAY,IAAA,CAAK,IAAA,KAAS,KAAA,IAC1B,WAAA,CAAY,IAAA,CAAK,IAAA,CAAK,UAAA,CAAW,gBAAgB,CAAA;AAErD;AAEA,SAAS,cAAc,YAAA,EAAqD;AAC1E,EAAA,OAAO,IAAI,GAAA;AAAA,IACT,YAAA,CAAa,O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,KAAA,CAAM,IAAI,IAAI,CAAA;AACd,IAAA,OAAO,EAAE,GAAG,WAAA,EAAa,IAAA,EAAK;AAAA,EAChC,CAAC,CAAA;AACH;;;;"}
@@ -1,5 +1,7 @@
1
1
  import { irRaw } from '../../../domain/ir/constructors.mjs';
2
2
  import { escapeSingleQuotedText } from '../../../domain/ir/raw-text-escapes.mjs';
3
+ import { freeNumberedName } from '../numbered-names.mjs';
4
+ import { typeNamesDeclaredBy } from './declared-type-names.mjs';
3
5
  import { globalTypeReferences } from './global-type-references.mjs';
4
6
 
5
7
  const REFERENCE_PREFIX = "components['";
@@ -17,16 +19,6 @@ function rootTypeAlias(name, kind, item) {
17
19
  function isRootTypeAlias(declaration) {
18
20
  return declaration.kind === "typeAlias" && declaration.type.kind === "raw" && declaration.type.text.startsWith(REFERENCE_PREFIX);
19
21
  }
20
- function footerTypeNames(declarations) {
21
- return new Set(
22
- declarations.flatMap((declaration) => {
23
- if (declaration.kind === "enum") {
24
- return [declaration.name];
25
- }
26
- return declaration.kind === "rawDeclaration" && declaration.name !== void 0 ? [declaration.name] : [];
27
- })
28
- );
29
- }
30
22
  function declaredNames(declarations) {
31
23
  return new Set(
32
24
  declarations.flatMap(
@@ -34,19 +26,11 @@ function declaredNames(declarations) {
34
26
  )
35
27
  );
36
28
  }
37
- function freeName(name, taken) {
38
- let candidate = `${name}_2`;
39
- for (let counter = 3; taken.has(candidate); counter++) {
40
- candidate = `${name}_${counter}`;
41
- }
42
- return candidate;
43
- }
44
29
  function renameTakenAliases(body, footer, closing = []) {
45
- const reserved = footerTypeNames(footer);
46
- for (const name of globalTypeReferences([...body, ...footer, ...closing])) {
47
- reserved.add(name);
48
- }
49
- const taken = declaredNames([...body, ...footer, ...closing]);
30
+ const all = [...body, ...footer, ...closing];
31
+ const others = all.filter((declaration) => !isRootTypeAlias(declaration));
32
+ const reserved = /* @__PURE__ */ new Set([...typeNamesDeclaredBy(others), ...globalTypeReferences(all)]);
33
+ const taken = /* @__PURE__ */ new Set([...declaredNames(all), ...typeNamesDeclaredBy(all)]);
50
34
  const aliasNames = /* @__PURE__ */ new Set();
51
35
  return body.map((declaration) => {
52
36
  if (!isRootTypeAlias(declaration)) {
@@ -57,11 +41,11 @@ function renameTakenAliases(body, footer, closing = []) {
57
41
  if (!isRepeated && !reserved.has(declaration.name)) {
58
42
  return declaration;
59
43
  }
60
- const name = freeName(declaration.name, taken);
44
+ const name = freeNumberedName(declaration.name, taken);
61
45
  taken.add(name);
62
46
  return { ...declaration, name };
63
47
  });
64
48
  }
65
49
 
66
- export { renameTakenAliases, rootTypeAlias };
50
+ export { isRootTypeAlias, renameTakenAliases, rootTypeAlias };
67
51
  //# sourceMappingURL=root-type-aliases.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"root-type-aliases.mjs","sources":["../../../../src/application/transform/document/root-type-aliases.ts"],"sourcesContent":["import { irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrDeclaration, IrTypeAliasDeclaration } from \"../../../domain/ir/nodes.js\";\nimport { escapeSingleQuotedText } from \"../../../domain/ir/raw-text-escapes.js\";\nimport type { ComponentKind } from \"../../../domain/openapi/components-object.js\";\nimport { globalTypeReferences } from \"./global-type-references.js\";\n\n/** The `--root-types` aliases: `export type Pet = components['schemas']['Pet'];`. */\n\nconst REFERENCE_PREFIX = \"components['\";\n\n/** The alias of one component. */\nexport function rootTypeAlias(\n name: string,\n kind: ComponentKind,\n item: string,\n): IrTypeAliasDeclaration {\n return {\n kind: \"typeAlias\",\n name,\n isExported: true,\n // The original writes the reference as text, with single quotes, and did not escape the\n // name: a quote in it could add code to the generated file (intentional fix).\n type: irRaw(`${REFERENCE_PREFIX}${kind}']['${escapeSingleQuotedText(item)}']`),\n comments: [],\n };\n}\n\nfunction isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAliasDeclaration {\n return (\n declaration.kind === \"typeAlias\" &&\n declaration.type.kind === \"raw\" &&\n declaration.type.text.startsWith(REFERENCE_PREFIX)\n );\n}\n\n/**\n * The type names the footer declares that an alias must not take: enums, and helper types such as\n * `WithRequired`. Value declarations (`--enum-values` arrays) live in another namespace.\n */\nfunction footerTypeNames(declarations: readonly IrDeclaration[]): Set<string> {\n return new Set(\n declarations.flatMap((declaration) => {\n if (declaration.kind === \"enum\") {\n return [declaration.name];\n }\n return declaration.kind === \"rawDeclaration\" && declaration.name !== undefined\n ? [declaration.name]\n : [];\n }),\n );\n}\n\nfunction declaredNames(declarations: readonly IrDeclaration[]): Set<string> {\n return new Set(\n declarations.flatMap((declaration) =>\n \"name\" in declaration && declaration.name !== undefined ? [declaration.name] : [],\n ),\n );\n}\n\nfunction freeName(name: string, taken: ReadonlySet<string>): string {\n let candidate = `${name}_2`;\n for (let counter = 3; taken.has(candidate); counter++) {\n candidate = `${name}_${counter}`;\n }\n return candidate;\n}\n\n/**\n * Rename each root alias whose name an enum or a helper type of the footer also declares, or that\n * shadows a TypeScript global type the output refers to (`Record` in `Record<string, never>`), to\n * the next free `Name_2`, `Name_3`, … (the suffix `--root-types` uses for its own conflicts). The\n * footer and the globals keep their names, because the generated types refer to them. Before, the\n * output did not compile (enums: upstream #2099, #2341, #2206; helpers: a schema named\n * `WithRequired`, roadmap R11; globals: TS2315). Other declarations are returned unchanged.\n *\n * With the `root-type-numbering` fix (ADR-021, roadmap R13, backlog 30) the body also holds the\n * aliases a later schema of one exported name took the name from, after the other aliases and\n * under that same name. Each gets the next free number in body order, after the alias that kept\n * the name got its own: so the fix only adds exports, and every other alias keeps the name it has\n * without the fix.\n */\nexport function renameTakenAliases<T extends IrDeclaration>(\n body: readonly T[],\n footer: readonly IrDeclaration[],\n closing: readonly IrDeclaration[] = [],\n): T[] {\n const reserved = footerTypeNames(footer);\n for (const name of globalTypeReferences([...body, ...footer, ...closing])) {\n reserved.add(name);\n }\n const taken = declaredNames([...body, ...footer, ...closing]);\n const aliasNames = new Set<string>();\n return body.map((declaration) => {\n if (!isRootTypeAlias(declaration)) {\n return declaration;\n }\n const isRepeated = aliasNames.has(declaration.name);\n aliasNames.add(declaration.name);\n if (!isRepeated && !reserved.has(declaration.name)) {\n return declaration;\n }\n const name = freeName(declaration.name, taken);\n taken.add(name);\n return { ...declaration, name };\n });\n}\n"],"names":[],"mappings":";;;;AAQA,MAAM,gBAAA,GAAmB,cAAA;AAGlB,SAAS,aAAA,CACd,IAAA,EACA,IAAA,EACA,IAAA,EACwB;AACxB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,WAAA;AAAA,IACN,IAAA;AAAA,IACA,UAAA,EAAY,IAAA;AAAA;AAAA;AAAA,IAGZ,IAAA,EAAM,KAAA,CAAM,CAAA,EAAG,gBAAgB,CAAA,EAAG,IAAI,CAAA,IAAA,EAAO,sBAAA,CAAuB,IAAI,CAAC,CAAA,EAAA,CAAI,CAAA;AAAA,IAC7E,UAAU;AAAC,GACb;AACF;AAEA,SAAS,gBAAgB,WAAA,EAAmE;AAC1F,EAAA,OACE,WAAA,CAAY,IAAA,KAAS,WAAA,IACrB,WAAA,CAAY,IAAA,CAAK,IAAA,KAAS,KAAA,IAC1B,WAAA,CAAY,IAAA,CAAK,IAAA,CAAK,UAAA,CAAW,gBAAgB,CAAA;AAErD;AAMA,SAAS,gBAAgB,YAAA,EAAqD;AAC5E,EAAA,OAAO,IAAI,GAAA;AAAA,IACT,YAAA,CAAa,OAAA,CAAQ,CAAC,WAAA,KAAgB;AACpC,MAAA,IAAI,WAAA,CAAY,SAAS,MAAA,EAAQ;AAC/B,QAAA,OAAO,CAAC,YAAY,IAAI,CAAA;AAAA,MAC1B;AACA,MAAA,OAAO,WAAA,CAAY,IAAA,KAAS,gBAAA,IAAoB,WAAA,CAAY,IAAA,KAAS,SACjE,CAAC,WAAA,CAAY,IAAI,CAAA,GACjB,EAAC;AAAA,IACP,CAAC;AAAA,GACH;AACF;AAEA,SAAS,cAAc,YAAA,EAAqD;AAC1E,EAAA,OAAO,IAAI,GAAA;AAAA,IACT,YAAA,CAAa,OAAA;AAAA,MAAQ,CAAC,WAAA,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AAA,CAAY,IAAI,CAAA,EAAG;AAClD,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,MAAM,IAAA,GAAO,QAAA,CAAS,WAAA,CAAY,IAAA,EAAM,KAAK,CAAA;AAC7C,IAAA,KAAA,CAAM,IAAI,IAAI,CAAA;AACd,IAAA,OAAO,EAAE,GAAG,WAAA,EAAa,IAAA,EAAK;AAAA,EAChC,CAAC,CAAA;AACH;;"}
1
+ {"version":3,"file":"root-type-aliases.mjs","sources":["../../../../src/application/transform/document/root-type-aliases.ts"],"sourcesContent":["import { irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrDeclaration, IrTypeAliasDeclaration } from \"../../../domain/ir/nodes.js\";\nimport { escapeSingleQuotedText } from \"../../../domain/ir/raw-text-escapes.js\";\nimport type { ComponentKind } from \"../../../domain/openapi/components-object.js\";\nimport { freeNumberedName } from \"../numbered-names.js\";\nimport { typeNamesDeclaredBy } from \"./declared-type-names.js\";\nimport { globalTypeReferences } from \"./global-type-references.js\";\n\n/** The `--root-types` aliases: `export type Pet = components['schemas']['Pet'];`. */\n\nconst REFERENCE_PREFIX = \"components['\";\n\n/** The alias of one component. */\nexport function rootTypeAlias(\n name: string,\n kind: ComponentKind,\n item: string,\n): IrTypeAliasDeclaration {\n return {\n kind: \"typeAlias\",\n name,\n isExported: true,\n // The original writes the reference as text, with single quotes, and did not escape the\n // name: a quote in it could add code to the generated file (intentional fix).\n type: irRaw(`${REFERENCE_PREFIX}${kind}']['${escapeSingleQuotedText(item)}']`),\n comments: [],\n };\n}\n\n/** Whether the declaration is a `--root-types` alias, which gives way to every other name. */\nexport function isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAliasDeclaration {\n return (\n declaration.kind === \"typeAlias\" &&\n declaration.type.kind === \"raw\" &&\n declaration.type.text.startsWith(REFERENCE_PREFIX)\n );\n}\n\nfunction declaredNames(declarations: readonly IrDeclaration[]): Set<string> {\n return new Set(\n declarations.flatMap((declaration) =>\n \"name\" in declaration && declaration.name !== undefined ? [declaration.name] : [],\n ),\n );\n}\n\n/**\n * Rename each root alias whose name another declaration of the output also takes (an enum, a\n * helper type, the `--make-paths-enum` enum `ApiPaths`, a root interface, `--read-write-markers`\n * or `inject` types), or that shadows a TypeScript global type the output refers to (`Record` in\n * `Record<string, never>`), to the next free `Name_2`, `Name_3`, … (the suffix `--root-types` uses\n * for its own conflicts). The others and the globals keep their names, because the generated\n * types refer to them. Before, the output did not compile (enums: upstream #2099, #2341, #2206;\n * helpers: a schema named `WithRequired`, roadmap R11; globals: TS2315; `ApiPaths`: TS2567).\n * Other declarations are returned unchanged.\n *\n * With the `root-type-numbering` fix (ADR-021, roadmap R13, backlog 30) the body also holds the\n * aliases a later schema of one exported name took the name from, after the other aliases and\n * under that same name. Each gets the next free number in body order, after the alias that kept\n * the name got its own: so the fix only adds exports, and every other alias keeps the name it has\n * without the fix.\n */\nexport function renameTakenAliases<T extends IrDeclaration>(\n body: readonly T[],\n footer: readonly IrDeclaration[],\n closing: readonly IrDeclaration[] = [],\n): T[] {\n const all = [...body, ...footer, ...closing];\n const others = all.filter((declaration) => !isRootTypeAlias(declaration));\n const reserved = new Set([...typeNamesDeclaredBy(others), ...globalTypeReferences(all)]);\n const taken = new Set([...declaredNames(all), ...typeNamesDeclaredBy(all)]);\n const aliasNames = new Set<string>();\n return body.map((declaration) => {\n if (!isRootTypeAlias(declaration)) {\n return declaration;\n }\n const isRepeated = aliasNames.has(declaration.name);\n aliasNames.add(declaration.name);\n if (!isRepeated && !reserved.has(declaration.name)) {\n return declaration;\n }\n const name = freeNumberedName(declaration.name, taken);\n taken.add(name);\n return { ...declaration, name };\n });\n}\n"],"names":[],"mappings":";;;;;;AAUA,MAAM,gBAAA,GAAmB,cAAA;AAGlB,SAAS,aAAA,CACd,IAAA,EACA,IAAA,EACA,IAAA,EACwB;AACxB,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,WAAA;AAAA,IACN,IAAA;AAAA,IACA,UAAA,EAAY,IAAA;AA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AAK,GAAA,CAAI,CAAC,WAAA,KAAgB;AAC/B,IAAA,IAAI,CAAC,eAAA,CAAgB,WAAW,CAAA,EAAG;AACjC,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,MAAM,UAAA,GAAa,UAAA,CAAW,GAAA,CAAI,WAAA,CAAY,IAAI,CAAA;AAClD,IAAA,UAAA,CAAW,GAAA,CAAI,YAAY,IAAI,CAAA;AAC/B,IAAA,IAAI,CAAC,UAAA,IAAc,CAAC,SAAS,GAAA,CAAI,WAAA,CAAY,IAAI,CAAA,EAAG;AAClD,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,MAAM,IAAA,GAAO,gBAAA,CAAiB,WAAA,CAAY,IAAA,EAAM,KAAK,CAAA;AACrD,IAAA,KAAA,CAAM,IAAI,IAAI,CAAA;AACd,IAAA,OAAO,EAAE,GAAG,WAAA,EAAa,IAAA,EAAK;AAAA,EAChC,CAAC,CAAA;AACH;;"}
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const appendAll = require('../../../domain/append-all.cjs');
4
+
3
5
  const UNDEFINED = { kind: "keyword", keyword: "undefined" };
4
6
  function nameOf(member) {
5
7
  return member.name.kind === "string" ? member.name.value : member.name.text;
@@ -117,7 +119,7 @@ class TypeResolution {
117
119
  if (objects === null) {
118
120
  return null;
119
121
  }
120
- parts.push(...objects);
122
+ appendAll.appendAll(parts, objects);
121
123
  }
122
124
  return parts;
123
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"type-resolution.cjs","sources":["../../../../src/application/transform/document/type-resolution.ts"],"sourcesContent":["import type {\n IrIndexSignature,\n IrMember,\n IrObjectType,\n IrPropertySignature,\n IrType,\n} from \"../../../domain/ir/nodes.js\";\nimport type { DeclaredTypeLookup } from \"./declared-types.js\";\n\n/**\n * The types the `--path-params-as-types` overlap check compares, as TypeScript sees them:\n * references followed to the declarations of the document, `T[\"key\"]` and `T[number]` read from\n * `T`, and an intersection of object types merged into one object.\n */\n\nconst UNDEFINED: IrType = { kind: \"keyword\", keyword: \"undefined\" };\n\nexport function nameOf(member: IrPropertySignature): string {\n return member.name.kind === \"string\" ? member.name.value : member.name.text;\n}\n\nexport function propertiesOf(type: IrObjectType): Map<string, IrPropertySignature> {\n const properties = type.members.filter(\n (member: IrMember): member is IrPropertySignature => member.kind === \"property\",\n );\n return new Map(properties.map((property) => [nameOf(property), property]));\n}\n\nexport function indexSignaturesOf(type: IrObjectType): IrIndexSignature[] {\n return type.members.filter(\n (member: IrMember): member is IrIndexSignature => member.kind === \"indexSignature\",\n );\n}\n\n/** The type read from a property: an optional one may be `undefined`. */\nexport function readType(property: IrPropertySignature): IrType {\n return property.isOptional ? { kind: \"union\", types: [property.type, UNDEFINED] } : property.type;\n}\n\n/**\n * `T[number]` for an array `T`, as the generator writes for an item of an array response: the\n * element type, readonly or not. A tuple's is the union of its elements, which is not modelled.\n */\nfunction arrayElement(type: IrType): IrType | null {\n const list = type.kind === \"readonly\" ? type.type : type;\n return list.kind === \"array\" ? list.element : null;\n}\n\n/** One property for two of the same name in an intersection. */\nfunction mergedProperty(\n first: IrPropertySignature,\n second: IrPropertySignature,\n): IrPropertySignature {\n return {\n ...first,\n type: { kind: \"intersection\", types: [first.type, second.type] },\n isOptional: first.isOptional && second.isOptional,\n isReadonly: first.isReadonly || second.isReadonly,\n };\n}\n\n/** Resolves types once each, for one comparison. */\nexport class TypeResolution {\n private readonly lookup: DeclaredTypeLookup;\n private readonly resolvedTypes = new Map<IrType, IrType>();\n\n constructor(lookup: DeclaredTypeLookup) {\n this.lookup = lookup;\n }\n\n /** The type a reference names, followed through references to references; computed once. */\n resolved(type: IrType): IrType {\n const known = this.resolvedTypes.get(type);\n if (known !== undefined) {\n return known;\n }\n // A type that reaches itself while it is resolved stays as it is written there.\n this.resolvedTypes.set(type, type);\n const seen = new Set<IrType>();\n let current = type;\n while (!seen.has(current)) {\n seen.add(current);\n const named = this.lookup(current) ?? this.indexedProperty(current);\n if (named === null) {\n break;\n }\n current = named;\n }\n const result = current.kind === \"intersection\" ? (this.merged(current) ?? current) : current;\n this.resolvedTypes.set(type, result);\n return result;\n }\n\n /**\n * `T[\"key\"]` read from the object type `T` resolves to, which the lookup does not do for an\n * object it reached through another lookup (`paths[\"/a/{id}\"][\"get\"]`). An optional property\n * reads as `T | undefined`; `T[number]` is the element of the array `T`.\n */\n private indexedProperty(type: IrType): IrType | null {\n if (type.kind !== \"indexedAccess\") {\n return null;\n }\n const { index } = type;\n if (index.kind === \"keyword\" && index.keyword === \"number\") {\n return arrayElement(this.resolved(type.object));\n }\n const object = this.resolved(type.object);\n if (index.kind !== \"stringLiteral\" || object.kind !== \"object\") {\n return null;\n }\n const property = propertiesOf(object).get(index.value);\n return property === undefined ? null : readType(property);\n }\n\n /**\n * An intersection of object types as the one object TypeScript makes of it: a property in\n * several parts has the intersection of their types, and is optional only when it is in each.\n * Null when a part is no object type.\n */\n private merged(type: IrType): IrObjectType | null {\n const parts = this.objectParts(type);\n if (parts === null) {\n return null;\n }\n const properties = new Map<string, IrPropertySignature>();\n const indexes: IrIndexSignature[] = [];\n for (const member of parts.flatMap((part) => part.members)) {\n if (member.kind === \"indexSignature\") {\n indexes.push(member);\n continue;\n }\n const name = nameOf(member);\n const other = properties.get(name);\n properties.set(name, other === undefined ? member : mergedProperty(other, member));\n }\n return { kind: \"object\", members: [...properties.values(), ...indexes] };\n }\n\n /**\n * The object types an intersection is made of, nested ones flattened; null for any other, and\n * for an intersection that contains itself, which TypeScript does not merge either.\n */\n private objectParts(\n type: IrType,\n visiting: ReadonlySet<IrType> = new Set(),\n ): IrObjectType[] | null {\n if (type.kind === \"object\") {\n return [type];\n }\n if (type.kind !== \"intersection\" || visiting.has(type)) {\n return null;\n }\n const parts: IrObjectType[] = [];\n for (const part of type.types) {\n const objects = this.objectParts(this.resolved(part), new Set([...visiting, type]));\n if (objects === null) {\n return null;\n }\n parts.push(...objects);\n }\n return parts;\n }\n}\n"],"names":[],"mappings":";;AAeA,MAAM,SAAA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;AACA,MAAA,MAAM,IAAA,GAAO,OAAO,MAAM,CAAA;AAC1B,MAAA,MAAM,KAAA,GAAQ,UAAA,CAAW,GAAA,CAAI,IAAI,CAAA;AACjC,MAAA,UAAA,CAAW,GAAA,CAAI,MAAM,KAAA,KAAU,MAAA,GAAY,SAAS,cAAA,CAAe,KAAA,EAAO,MAAM,CAAC,CAAA;AAAA,IACnF;AACA,IAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,OAAA,EAAS,CAAC,GAAG,UAAA,CAAW,MAAA,EAAO,EAAG,GAAG,OAAO,CAAA,EAAE;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,WAAA,CACN,IAAA,EACA,QAAA,mBAAgC,IAAI,KAAI,EACjB;AACvB,IAAA,IAAI,IAAA,CAAK,SAAS,QAAA,EAAU;AAC1B,MAAA,OAAO,CAAC,IAAI,CAAA;AAAA,IACd;AACA,IAAA,IAAI,KAAK,IAAA,KAAS,cAAA,IAAkB,QAAA,CAAS,GAAA,CAAI,IAAI,CAAA,EAAG;AACtD,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,MAAM,QAAwB,EAAC;AAC/B,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAK,KAAA,EAAO;AAC7B,MAAA,MAAM,OAAA,GAAU,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,SAAS,IAAI,CAAA,kBAAG,IAAI,GAAA,CAAI,CAAC,GAAG,QAAA,EAAU,IAAI,CAAC,CAAC,CAAA;AAClF,MAAA,IAAI,YAAY,IAAA,EAAM;AACpB,QAAA,OAAO,IAAA;AAAA,MACT;AACA,MAAA,KAAA,CAAM,IAAA,CAAK,GAAG,OAAO,CAAA;AAAA,IACvB;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACF;;;;;;"}
1
+ {"version":3,"file":"type-resolution.cjs","sources":["../../../../src/application/transform/document/type-resolution.ts"],"sourcesContent":["import { appendAll } from \"../../../domain/append-all.js\";\nimport type {\n IrIndexSignature,\n IrMember,\n IrObjectType,\n IrPropertySignature,\n IrType,\n} from \"../../../domain/ir/nodes.js\";\nimport type { DeclaredTypeLookup } from \"./declared-types.js\";\n\n/**\n * The types the `--path-params-as-types` overlap check compares, as TypeScript sees them:\n * references followed to the declarations of the document, `T[\"key\"]` and `T[number]` read from\n * `T`, and an intersection of object types merged into one object.\n */\n\nconst UNDEFINED: IrType = { kind: \"keyword\", keyword: \"undefined\" };\n\nexport function nameOf(member: IrPropertySignature): string {\n return member.name.kind === \"string\" ? member.name.value : member.name.text;\n}\n\nexport function propertiesOf(type: IrObjectType): Map<string, IrPropertySignature> {\n const properties = type.members.filter(\n (member: IrMember): member is IrPropertySignature => member.kind === \"property\",\n );\n return new Map(properties.map((property) => [nameOf(property), property]));\n}\n\nexport function indexSignaturesOf(type: IrObjectType): IrIndexSignature[] {\n return type.members.filter(\n (member: IrMember): member is IrIndexSignature => member.kind === \"indexSignature\",\n );\n}\n\n/** The type read from a property: an optional one may be `undefined`. */\nexport function readType(property: IrPropertySignature): IrType {\n return property.isOptional ? { kind: \"union\", types: [property.type, UNDEFINED] } : property.type;\n}\n\n/**\n * `T[number]` for an array `T`, as the generator writes for an item of an array response: the\n * element type, readonly or not. A tuple's is the union of its elements, which is not modelled.\n */\nfunction arrayElement(type: IrType): IrType | null {\n const list = type.kind === \"readonly\" ? type.type : type;\n return list.kind === \"array\" ? list.element : null;\n}\n\n/** One property for two of the same name in an intersection. */\nfunction mergedProperty(\n first: IrPropertySignature,\n second: IrPropertySignature,\n): IrPropertySignature {\n return {\n ...first,\n type: { kind: \"intersection\", types: [first.type, second.type] },\n isOptional: first.isOptional && second.isOptional,\n isReadonly: first.isReadonly || second.isReadonly,\n };\n}\n\n/** Resolves types once each, for one comparison. */\nexport class TypeResolution {\n private readonly lookup: DeclaredTypeLookup;\n private readonly resolvedTypes = new Map<IrType, IrType>();\n\n constructor(lookup: DeclaredTypeLookup) {\n this.lookup = lookup;\n }\n\n /** The type a reference names, followed through references to references; computed once. */\n resolved(type: IrType): IrType {\n const known = this.resolvedTypes.get(type);\n if (known !== undefined) {\n return known;\n }\n // A type that reaches itself while it is resolved stays as it is written there.\n this.resolvedTypes.set(type, type);\n const seen = new Set<IrType>();\n let current = type;\n while (!seen.has(current)) {\n seen.add(current);\n const named = this.lookup(current) ?? this.indexedProperty(current);\n if (named === null) {\n break;\n }\n current = named;\n }\n const result = current.kind === \"intersection\" ? (this.merged(current) ?? current) : current;\n this.resolvedTypes.set(type, result);\n return result;\n }\n\n /**\n * `T[\"key\"]` read from the object type `T` resolves to, which the lookup does not do for an\n * object it reached through another lookup (`paths[\"/a/{id}\"][\"get\"]`). An optional property\n * reads as `T | undefined`; `T[number]` is the element of the array `T`.\n */\n private indexedProperty(type: IrType): IrType | null {\n if (type.kind !== \"indexedAccess\") {\n return null;\n }\n const { index } = type;\n if (index.kind === \"keyword\" && index.keyword === \"number\") {\n return arrayElement(this.resolved(type.object));\n }\n const object = this.resolved(type.object);\n if (index.kind !== \"stringLiteral\" || object.kind !== \"object\") {\n return null;\n }\n const property = propertiesOf(object).get(index.value);\n return property === undefined ? null : readType(property);\n }\n\n /**\n * An intersection of object types as the one object TypeScript makes of it: a property in\n * several parts has the intersection of their types, and is optional only when it is in each.\n * Null when a part is no object type.\n */\n private merged(type: IrType): IrObjectType | null {\n const parts = this.objectParts(type);\n if (parts === null) {\n return null;\n }\n const properties = new Map<string, IrPropertySignature>();\n const indexes: IrIndexSignature[] = [];\n for (const member of parts.flatMap((part) => part.members)) {\n if (member.kind === \"indexSignature\") {\n indexes.push(member);\n continue;\n }\n const name = nameOf(member);\n const other = properties.get(name);\n properties.set(name, other === undefined ? member : mergedProperty(other, member));\n }\n return { kind: \"object\", members: [...properties.values(), ...indexes] };\n }\n\n /**\n * The object types an intersection is made of, nested ones flattened; null for any other, and\n * for an intersection that contains itself, which TypeScript does not merge either.\n */\n private objectParts(\n type: IrType,\n visiting: ReadonlySet<IrType> = new Set(),\n ): IrObjectType[] | null {\n if (type.kind === \"object\") {\n return [type];\n }\n if (type.kind !== \"intersection\" || visiting.has(type)) {\n return null;\n }\n const parts: IrObjectType[] = [];\n for (const part of type.types) {\n const objects = this.objectParts(this.resolved(part), new Set([...visiting, type]));\n if (objects === null) {\n return null;\n }\n appendAll(parts, objects);\n }\n return parts;\n }\n}\n"],"names":["appendAll"],"mappings":";;;;AAgBA,MAAM,SAAA,GAAoB,EAAE,IAAA,EAAM,SAAA,EAAW,SAAS,WAAA,EAAY;AAE3D,SAAS,OAAO,MAAA,EAAqC;AAC1D,EAAA,OAAO,MAAA,CAAO,KAAK,IAAA,KAAS,QAAA,GAAW,OAAO,IAAA,CAAK,KAAA,GAAQ,OAAO,IAAA,CAAK,IAAA;AACzE;AAEO,SAAS,aAAa,IAAA,EAAsD;AACjF,EAAA,MAAM,UAAA,GAAa,KAAK,OAAA,CAAQ,MAAA;AAAA,IAC9B,CAAC,MAAA,KAAoD,MAAA,CAAO,IAAA,KAAS;AAAA,GACvE;AACA,EAAA,OAAO,IAAI,GAAA,CAAI,UAAA,CAAW,GAAA,CAAI,CAAC,QAAA,KAAa,CAAC,MAAA,CAAO,QAAQ,CAAA,EAAG,QAAQ,CAAC,CAAC,CAAA;AAC3E;AAEO,SAAS,kBAAkB,IAAA,EAAwC;AACxE,EAAA,OAAO,KAAK,OAAA,CAAQ,MAAA;AAAA,IAClB,CAAC,MAAA,KAAiD,MAAA,CAAO,IAAA,KAAS;AAAA,GACpE;AACF;AAGO,SAAS,SAAS,QAAA,EAAuC;AAC9D,EAAA,OAAO,QAAA,CAAS,UAAA,GAAa,EAAE,IAAA,EAAM,OAAA,EAAS,KAAA,EAAO,CAAC,QAAA,CAAS,IAAA,EAAM,SAAS,CAAA,EAAE,GAAI,QAAA,CAAS,IAAA;AAC/F;AAMA,SAAS,aAAa,IAAA,EAA6B;AACjD,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,IAAA,KAAS,UAAA,GAAa,KAAK,IAAA,GAAO,IAAA;A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AAA,OAAO,IAAA;AAAA,MACT;AACA,MAAAA,mBAAA,CAAU,OAAO,OAAO,CAAA;AAAA,IAC1B;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACF;;;;;;"}
@@ -1,3 +1,5 @@
1
+ import { appendAll } from '../../../domain/append-all.mjs';
2
+
1
3
  const UNDEFINED = { kind: "keyword", keyword: "undefined" };
2
4
  function nameOf(member) {
3
5
  return member.name.kind === "string" ? member.name.value : member.name.text;
@@ -115,7 +117,7 @@ class TypeResolution {
115
117
  if (objects === null) {
116
118
  return null;
117
119
  }
118
- parts.push(...objects);
120
+ appendAll(parts, objects);
119
121
  }
120
122
  return parts;
121
123
  }
@@ -1 +1 @@
1
- {"version":3,"file":"type-resolution.mjs","sources":["../../../../src/application/transform/document/type-resolution.ts"],"sourcesContent":["import type {\n IrIndexSignature,\n IrMember,\n IrObjectType,\n IrPropertySignature,\n IrType,\n} from \"../../../domain/ir/nodes.js\";\nimport type { DeclaredTypeLookup } from \"./declared-types.js\";\n\n/**\n * The types the `--path-params-as-types` overlap check compares, as TypeScript sees them:\n * references followed to the declarations of the document, `T[\"key\"]` and `T[number]` read from\n * `T`, and an intersection of object types merged into one object.\n */\n\nconst UNDEFINED: IrType = { kind: \"keyword\", keyword: \"undefined\" };\n\nexport function nameOf(member: IrPropertySignature): string {\n return member.name.kind === \"string\" ? member.name.value : member.name.text;\n}\n\nexport function propertiesOf(type: IrObjectType): Map<string, IrPropertySignature> {\n const properties = type.members.filter(\n (member: IrMember): member is IrPropertySignature => member.kind === \"property\",\n );\n return new Map(properties.map((property) => [nameOf(property), property]));\n}\n\nexport function indexSignaturesOf(type: IrObjectType): IrIndexSignature[] {\n return type.members.filter(\n (member: IrMember): member is IrIndexSignature => member.kind === \"indexSignature\",\n );\n}\n\n/** The type read from a property: an optional one may be `undefined`. */\nexport function readType(property: IrPropertySignature): IrType {\n return property.isOptional ? { kind: \"union\", types: [property.type, UNDEFINED] } : property.type;\n}\n\n/**\n * `T[number]` for an array `T`, as the generator writes for an item of an array response: the\n * element type, readonly or not. A tuple's is the union of its elements, which is not modelled.\n */\nfunction arrayElement(type: IrType): IrType | null {\n const list = type.kind === \"readonly\" ? type.type : type;\n return list.kind === \"array\" ? list.element : null;\n}\n\n/** One property for two of the same name in an intersection. */\nfunction mergedProperty(\n first: IrPropertySignature,\n second: IrPropertySignature,\n): IrPropertySignature {\n return {\n ...first,\n type: { kind: \"intersection\", types: [first.type, second.type] },\n isOptional: first.isOptional && second.isOptional,\n isReadonly: first.isReadonly || second.isReadonly,\n };\n}\n\n/** Resolves types once each, for one comparison. */\nexport class TypeResolution {\n private readonly lookup: DeclaredTypeLookup;\n private readonly resolvedTypes = new Map<IrType, IrType>();\n\n constructor(lookup: DeclaredTypeLookup) {\n this.lookup = lookup;\n }\n\n /** The type a reference names, followed through references to references; computed once. */\n resolved(type: IrType): IrType {\n const known = this.resolvedTypes.get(type);\n if (known !== undefined) {\n return known;\n }\n // A type that reaches itself while it is resolved stays as it is written there.\n this.resolvedTypes.set(type, type);\n const seen = new Set<IrType>();\n let current = type;\n while (!seen.has(current)) {\n seen.add(current);\n const named = this.lookup(current) ?? this.indexedProperty(current);\n if (named === null) {\n break;\n }\n current = named;\n }\n const result = current.kind === \"intersection\" ? (this.merged(current) ?? current) : current;\n this.resolvedTypes.set(type, result);\n return result;\n }\n\n /**\n * `T[\"key\"]` read from the object type `T` resolves to, which the lookup does not do for an\n * object it reached through another lookup (`paths[\"/a/{id}\"][\"get\"]`). An optional property\n * reads as `T | undefined`; `T[number]` is the element of the array `T`.\n */\n private indexedProperty(type: IrType): IrType | null {\n if (type.kind !== \"indexedAccess\") {\n return null;\n }\n const { index } = type;\n if (index.kind === \"keyword\" && index.keyword === \"number\") {\n return arrayElement(this.resolved(type.object));\n }\n const object = this.resolved(type.object);\n if (index.kind !== \"stringLiteral\" || object.kind !== \"object\") {\n return null;\n }\n const property = propertiesOf(object).get(index.value);\n return property === undefined ? null : readType(property);\n }\n\n /**\n * An intersection of object types as the one object TypeScript makes of it: a property in\n * several parts has the intersection of their types, and is optional only when it is in each.\n * Null when a part is no object type.\n */\n private merged(type: IrType): IrObjectType | null {\n const parts = this.objectParts(type);\n if (parts === null) {\n return null;\n }\n const properties = new Map<string, IrPropertySignature>();\n const indexes: IrIndexSignature[] = [];\n for (const member of parts.flatMap((part) => part.members)) {\n if (member.kind === \"indexSignature\") {\n indexes.push(member);\n continue;\n }\n const name = nameOf(member);\n const other = properties.get(name);\n properties.set(name, other === undefined ? member : mergedProperty(other, member));\n }\n return { kind: \"object\", members: [...properties.values(), ...indexes] };\n }\n\n /**\n * The object types an intersection is made of, nested ones flattened; null for any other, and\n * for an intersection that contains itself, which TypeScript does not merge either.\n */\n private objectParts(\n type: IrType,\n visiting: ReadonlySet<IrType> = new Set(),\n ): IrObjectType[] | null {\n if (type.kind === \"object\") {\n return [type];\n }\n if (type.kind !== \"intersection\" || visiting.has(type)) {\n return null;\n }\n const parts: IrObjectType[] = [];\n for (const part of type.types) {\n const objects = this.objectParts(this.resolved(part), new Set([...visiting, type]));\n if (objects === null) {\n return null;\n }\n parts.push(...objects);\n }\n return parts;\n }\n}\n"],"names":[],"mappings":"AAeA,MAAM,SAAA,GAAoB,EAAE,IAAA,EAAM,SAAA,EAAW,SAAS,WAAA,EAAY;AAE3D,SAAS,OAAO,MAAA,EAAqC;AAC1D,EAAA,OAAO,MAAA,CAAO,KAAK,IAAA,KAAS,QAAA,GAAW,OAAO,IAAA,CAAK,KAAA,GAAQ,OAAO,IAAA,CAAK,IAAA;AACzE;AAEO,SAAS,aAAa,IAAA,EAAsD;AACjF,EAAA,MAAM,UAAA,GAAa,KAAK,OAAA,CAAQ,MAAA;AAAA,IAC9B,CAAC,MAAA,KAAoD,MAAA,CAAO,IAAA,KAAS;AAAA,GACvE;AACA,EAAA,OAAO,IAAI,GAAA,CAAI,UAAA,CAAW,GAAA,CAAI,CAAC,QAAA,KAAa,CAAC,MAAA,CAAO,QAAQ,CAAA,EAAG,QAAQ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I,IAAA,CAAK,SAAS,QAAA,EAAU;AAC1B,MAAA,OAAO,CAAC,IAAI,CAAA;AAAA,IACd;AACA,IAAA,IAAI,KAAK,IAAA,KAAS,cAAA,IAAkB,QAAA,CAAS,GAAA,CAAI,IAAI,CAAA,EAAG;AACtD,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,MAAM,QAAwB,EAAC;AAC/B,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAK,KAAA,EAAO;AAC7B,MAAA,MAAM,OAAA,GAAU,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,SAAS,IAAI,CAAA,kBAAG,IAAI,GAAA,CAAI,CAAC,GAAG,QAAA,EAAU,IAAI,CAAC,CAAC,CAAA;AAClF,MAAA,IAAI,YAAY,IAAA,EAAM;AACpB,QAAA,OAAO,IAAA;AAAA,MACT;AACA,MAAA,KAAA,CAAM,IAAA,CAAK,GAAG,OAAO,CAAA;AAAA,IACvB;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACF;;"}
1
+ {"version":3,"file":"type-resolution.mjs","sources":["../../../../src/application/transform/document/type-resolution.ts"],"sourcesContent":["import { appendAll } from \"../../../domain/append-all.js\";\nimport type {\n IrIndexSignature,\n IrMember,\n IrObjectType,\n IrPropertySignature,\n IrType,\n} from \"../../../domain/ir/nodes.js\";\nimport type { DeclaredTypeLookup } from \"./declared-types.js\";\n\n/**\n * The types the `--path-params-as-types` overlap check compares, as TypeScript sees them:\n * references followed to the declarations of the document, `T[\"key\"]` and `T[number]` read from\n * `T`, and an intersection of object types merged into one object.\n */\n\nconst UNDEFINED: IrType = { kind: \"keyword\", keyword: \"undefined\" };\n\nexport function nameOf(member: IrPropertySignature): string {\n return member.name.kind === \"string\" ? member.name.value : member.name.text;\n}\n\nexport function propertiesOf(type: IrObjectType): Map<string, IrPropertySignature> {\n const properties = type.members.filter(\n (member: IrMember): member is IrPropertySignature => member.kind === \"property\",\n );\n return new Map(properties.map((property) => [nameOf(property), property]));\n}\n\nexport function indexSignaturesOf(type: IrObjectType): IrIndexSignature[] {\n return type.members.filter(\n (member: IrMember): member is IrIndexSignature => member.kind === \"indexSignature\",\n );\n}\n\n/** The type read from a property: an optional one may be `undefined`. */\nexport function readType(property: IrPropertySignature): IrType {\n return property.isOptional ? { kind: \"union\", types: [property.type, UNDEFINED] } : property.type;\n}\n\n/**\n * `T[number]` for an array `T`, as the generator writes for an item of an array response: the\n * element type, readonly or not. A tuple's is the union of its elements, which is not modelled.\n */\nfunction arrayElement(type: IrType): IrType | null {\n const list = type.kind === \"readonly\" ? type.type : type;\n return list.kind === \"array\" ? list.element : null;\n}\n\n/** One property for two of the same name in an intersection. */\nfunction mergedProperty(\n first: IrPropertySignature,\n second: IrPropertySignature,\n): IrPropertySignature {\n return {\n ...first,\n type: { kind: \"intersection\", types: [first.type, second.type] },\n isOptional: first.isOptional && second.isOptional,\n isReadonly: first.isReadonly || second.isReadonly,\n };\n}\n\n/** Resolves types once each, for one comparison. */\nexport class TypeResolution {\n private readonly lookup: DeclaredTypeLookup;\n private readonly resolvedTypes = new Map<IrType, IrType>();\n\n constructor(lookup: DeclaredTypeLookup) {\n this.lookup = lookup;\n }\n\n /** The type a reference names, followed through references to references; computed once. */\n resolved(type: IrType): IrType {\n const known = this.resolvedTypes.get(type);\n if (known !== undefined) {\n return known;\n }\n // A type that reaches itself while it is resolved stays as it is written there.\n this.resolvedTypes.set(type, type);\n const seen = new Set<IrType>();\n let current = type;\n while (!seen.has(current)) {\n seen.add(current);\n const named = this.lookup(current) ?? this.indexedProperty(current);\n if (named === null) {\n break;\n }\n current = named;\n }\n const result = current.kind === \"intersection\" ? (this.merged(current) ?? current) : current;\n this.resolvedTypes.set(type, result);\n return result;\n }\n\n /**\n * `T[\"key\"]` read from the object type `T` resolves to, which the lookup does not do for an\n * object it reached through another lookup (`paths[\"/a/{id}\"][\"get\"]`). An optional property\n * reads as `T | undefined`; `T[number]` is the element of the array `T`.\n */\n private indexedProperty(type: IrType): IrType | null {\n if (type.kind !== \"indexedAccess\") {\n return null;\n }\n const { index } = type;\n if (index.kind === \"keyword\" && index.keyword === \"number\") {\n return arrayElement(this.resolved(type.object));\n }\n const object = this.resolved(type.object);\n if (index.kind !== \"stringLiteral\" || object.kind !== \"object\") {\n return null;\n }\n const property = propertiesOf(object).get(index.value);\n return property === undefined ? null : readType(property);\n }\n\n /**\n * An intersection of object types as the one object TypeScript makes of it: a property in\n * several parts has the intersection of their types, and is optional only when it is in each.\n * Null when a part is no object type.\n */\n private merged(type: IrType): IrObjectType | null {\n const parts = this.objectParts(type);\n if (parts === null) {\n return null;\n }\n const properties = new Map<string, IrPropertySignature>();\n const indexes: IrIndexSignature[] = [];\n for (const member of parts.flatMap((part) => part.members)) {\n if (member.kind === \"indexSignature\") {\n indexes.push(member);\n continue;\n }\n const name = nameOf(member);\n const other = properties.get(name);\n properties.set(name, other === undefined ? member : mergedProperty(other, member));\n }\n return { kind: \"object\", members: [...properties.values(), ...indexes] };\n }\n\n /**\n * The object types an intersection is made of, nested ones flattened; null for any other, and\n * for an intersection that contains itself, which TypeScript does not merge either.\n */\n private objectParts(\n type: IrType,\n visiting: ReadonlySet<IrType> = new Set(),\n ): IrObjectType[] | null {\n if (type.kind === \"object\") {\n return [type];\n }\n if (type.kind !== \"intersection\" || visiting.has(type)) {\n return null;\n }\n const parts: IrObjectType[] = [];\n for (const part of type.types) {\n const objects = this.objectParts(this.resolved(part), new Set([...visiting, type]));\n if (objects === null) {\n return null;\n }\n appendAll(parts, objects);\n }\n return parts;\n }\n}\n"],"names":[],"mappings":";;AAgBA,MAAM,SAAA,GAAoB,EAAE,IAAA,EAAM,SAAA,EAAW,SAAS,WAAA,EAAY;AAE3D,SAAS,OAAO,MAAA,EAAqC;AAC1D,EAAA,OAAO,MAAA,CAAO,KAAK,IAAA,KAAS,QAAA,GAAW,OAAO,IAAA,CAAK,KAAA,GAAQ,OAAO,IAAA,CAAK,IAAA;AACzE;AAEO,SAAS,aAAa,IAAA,EAAsD;AACjF,E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AA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,OAAA,EAAS,CAAC,GAAG,UAAA,CAAW,MAAA,EAAO,EAAG,GAAG,OAAO,CAAA,EAAE;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,WAAA,CACN,IAAA,EACA,QAAA,mBAAgC,IAAI,KAAI,EACjB;AACvB,IAAA,IAAI,IAAA,CAAK,SAAS,QAAA,EAAU;AAC1B,MAAA,OAAO,CAAC,IAAI,CAAA;AAAA,IACd;AACA,IAAA,IAAI,KAAK,IAAA,KAAS,cAAA,IAAkB,QAAA,CAAS,GAAA,CAAI,IAAI,CAAA,EAAG;AACtD,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,MAAM,QAAwB,EAAC;AAC/B,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAK,KAAA,EAAO;AAC7B,MAAA,MAAM,OAAA,GAAU,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,SAAS,IAAI,CAAA,kBAAG,IAAI,GAAA,CAAI,CAAC,GAAG,QAAA,EAAU,IAAI,CAAC,CAAC,CAAA;AAClF,MAAA,IAAI,YAAY,IAAA,EAAM;AACpB,QAAA,OAAO,IAAA;AAAA,MACT;AACA,MAAA,SAAA,CAAU,OAAO,OAAO,CAAA;AAAA,IAC1B;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACF;;"}
@@ -4,16 +4,23 @@ const constructors = require('../../../domain/ir/constructors.cjs');
4
4
  const propertyName = require('../../../domain/ir/property-name.cjs');
5
5
  const jsonPointer = require('../../../domain/openapi/json-pointer.cjs');
6
6
  const documentEntries = require('../document-entries.cjs');
7
+ const refType = require('../ref-type.cjs');
7
8
  const pathItem = require('./path-item.cjs');
8
9
 
9
10
  function webhooksType(webhooks, context) {
10
- const members = documentEntries.documentEntries(webhooks, context.options).map(([name, pathItem$1]) => {
11
- const location = { path: jsonPointer.createRef(["webhooks", name]) };
12
- const type = pathItem.pathItemType(pathItem$1, location, context);
11
+ const members = documentEntries.documentEntries(webhooks, context.options).map(([name, pathItem]) => {
12
+ const type = webhookType(name, pathItem, context);
13
13
  return constructors.irProperty(propertyName.toPropertyName(name), type, { isReadonly: context.options.immutable });
14
14
  });
15
15
  return constructors.irObject(members);
16
16
  }
17
+ function webhookType(name, pathItem$1, context) {
18
+ if (typeof pathItem$1 === "object" && pathItem$1 !== null && "$ref" in pathItem$1) {
19
+ return refType.refType(pathItem$1.$ref);
20
+ }
21
+ const location = { path: jsonPointer.appendPointer(jsonPointer.ROOT_POINTER, ["webhooks", name]) };
22
+ return pathItem.pathItemType(pathItem$1, location, context);
23
+ }
17
24
 
18
25
  exports.webhooksType = webhooksType;
19
26
  //# sourceMappingURL=webhooks.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.cjs","sources":["../../../../src/application/transform/document/webhooks.ts"],"sourcesContent":["import { irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport type { PathItemObject, PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { pathItemType } from \"./path-item.js\";\n\n/**\n * The `webhooks` interface body (OpenAPI 3.1 §4.8.1): one path item per webhook name. Unlike\n * `paths`, a `$ref` entry is read as a path item (so every method is `never`), as in the original,\n * and members carry no JSDoc.\n */\nexport function webhooksType(webhooks: PathsObject, context: TransformContext): IrType {\n const members = documentEntries(webhooks, context.options).map(([name, pathItem]) => {\n const location = { path: createRef([\"webhooks\", name]) };\n const type = pathItemType(pathItem as PathItemObject, location, context);\n return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });\n });\n return irObject(members);\n}\n"],"names":["documentEntries","pathItem","createRef","pathItemType","irProperty","toPropertyName","irObject"],"mappings":";;;;;;;;AAcO,SAAS,YAAA,CAAa,UAAuB,OAAA,EAAmC;AACrF,EAAA,MAAM,OAAA,GAAUA,+BAAA,CAAgB,QAAA,EAAU,OAAA,CAAQ,OAAO,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,IAAA,EAAMC,UAAQ,CAAA,KAAM;AACnF,IAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAMC,qBAAA,CAAU,CAAC,UAAA,EAAY,IAAI,CAAC,CAAA,EAAE;AACvD,IAAA,MAAM,IAAA,GAAOC,qBAAA,CAAaF,UAAA,EAA4B,QAAA,EAAU,OAAO,CAAA;AACvE,IAAA,OAAOG,uBAAA,CAAWC,2BAAA,CAAe,IAAI,CAAA,EAAG,IAAA,EAAM,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW,CAAA;AAAA,EACzF,CAAC,CAAA;AACD,EAAA,OAAOC,sBAAS,OAAO,CAAA;AACzB;;"}
1
+ {"version":3,"file":"webhooks.cjs","sources":["../../../../src/application/transform/document/webhooks.ts"],"sourcesContent":["import { irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { PathItemObject, PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { pathItemType } from \"./path-item.js\";\n\n/**\n * The `webhooks` interface body (OpenAPI 3.1 §4.8.1): one path item per webhook name. A `$ref`\n * entry (often to `components/pathItems`) is the type it points at, as in `paths`; the original\n * read it as a path item, so every method was `never`. Members carry no JSDoc.\n */\nexport function webhooksType(webhooks: PathsObject, context: TransformContext): IrType {\n const members = documentEntries(webhooks, context.options).map(([name, pathItem]) => {\n const type = webhookType(name, pathItem, context);\n return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });\n });\n return irObject(members);\n}\n\nfunction webhookType(\n name: string,\n pathItem: PathsObject[string],\n context: TransformContext,\n): IrType {\n // A document may hold any value here; one that is no object is read as a path item, as before.\n if (typeof pathItem === \"object\" && pathItem !== null && \"$ref\" in pathItem) {\n return refType(pathItem.$ref);\n }\n const location = { path: appendPointer(ROOT_POINTER, [\"webhooks\", name]) };\n return pathItemType(pathItem as PathItemObject, location, context);\n}\n"],"names":["documentEntries","irProperty","toPropertyName","irObject","pathItem","refType","appendPointer","ROOT_POINTER","pathItemType"],"mappings":";;;;;;;;;AAeO,SAAS,YAAA,CAAa,UAAuB,OAAA,EAAmC;AACrF,EAAA,MAAM,OAAA,GAAUA,+BAAA,CAAgB,QAAA,EAAU,OAAA,CAAQ,OAAO,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,IAAA,EAAM,QAAQ,CAAA,KAAM;AACnF,IAAA,MAAM,IAAA,GAAO,WAAA,CAAY,IAAA,EAAM,QAAA,EAAU,OAAO,CAAA;AAChD,IAAA,OAAOC,uBAAA,CAAWC,2BAAA,CAAe,IAAI,CAAA,EAAG,IAAA,EAAM,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW,CAAA;AAAA,EACzF,CAAC,CAAA;AACD,EAAA,OAAOC,sBAAS,OAAO,CAAA;AACzB;AAEA,SAAS,WAAA,CACP,IAAA,EACAC,UAAA,EACA,OAAA,EACQ;AAER,EAAA,IAAI,OAAOA,UAAA,KAAa,QAAA,IAAYA,UAAA,KAAa,IAAA,IAAQ,UAAUA,UAAA,EAAU;AAC3E,IAAA,OAAOC,eAAA,CAAQD,WAAS,IAAI,CAAA;AAAA,EAC9B;AACA,EAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAME,yBAAA,CAAcC,0BAAc,CAAC,UAAA,EAAY,IAAI,CAAC,CAAA,EAAE;AACzE,EAAA,OAAOC,qBAAA,CAAaJ,UAAA,EAA4B,QAAA,EAAU,OAAO,CAAA;AACnE;;"}
@@ -1,17 +1,24 @@
1
1
  import { irProperty, irObject } from '../../../domain/ir/constructors.mjs';
2
2
  import { toPropertyName } from '../../../domain/ir/property-name.mjs';
3
- import { createRef } from '../../../domain/openapi/json-pointer.mjs';
3
+ import { appendPointer, ROOT_POINTER } from '../../../domain/openapi/json-pointer.mjs';
4
4
  import { documentEntries } from '../document-entries.mjs';
5
+ import { refType } from '../ref-type.mjs';
5
6
  import { pathItemType } from './path-item.mjs';
6
7
 
7
8
  function webhooksType(webhooks, context) {
8
9
  const members = documentEntries(webhooks, context.options).map(([name, pathItem]) => {
9
- const location = { path: createRef(["webhooks", name]) };
10
- const type = pathItemType(pathItem, location, context);
10
+ const type = webhookType(name, pathItem, context);
11
11
  return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });
12
12
  });
13
13
  return irObject(members);
14
14
  }
15
+ function webhookType(name, pathItem, context) {
16
+ if (typeof pathItem === "object" && pathItem !== null && "$ref" in pathItem) {
17
+ return refType(pathItem.$ref);
18
+ }
19
+ const location = { path: appendPointer(ROOT_POINTER, ["webhooks", name]) };
20
+ return pathItemType(pathItem, location, context);
21
+ }
15
22
 
16
23
  export { webhooksType };
17
24
  //# sourceMappingURL=webhooks.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.mjs","sources":["../../../../src/application/transform/document/webhooks.ts"],"sourcesContent":["import { irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport type { PathItemObject, PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { pathItemType } from \"./path-item.js\";\n\n/**\n * The `webhooks` interface body (OpenAPI 3.1 §4.8.1): one path item per webhook name. Unlike\n * `paths`, a `$ref` entry is read as a path item (so every method is `never`), as in the original,\n * and members carry no JSDoc.\n */\nexport function webhooksType(webhooks: PathsObject, context: TransformContext): IrType {\n const members = documentEntries(webhooks, context.options).map(([name, pathItem]) => {\n const location = { path: createRef([\"webhooks\", name]) };\n const type = pathItemType(pathItem as PathItemObject, location, context);\n return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });\n });\n return irObject(members);\n}\n"],"names":[],"mappings":";;;;;;AAcO,SAAS,YAAA,CAAa,UAAuB,OAAA,EAAmC;AACrF,EAAA,MAAM,OAAA,GAAU,eAAA,CAAgB,QAAA,EAAU,OAAA,CAAQ,OAAO,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,IAAA,EAAM,QAAQ,CAAA,KAAM;AACnF,IAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAM,SAAA,CAAU,CAAC,UAAA,EAAY,IAAI,CAAC,CAAA,EAAE;AACvD,IAAA,MAAM,IAAA,GAAO,YAAA,CAAa,QAAA,EAA4B,QAAA,EAAU,OAAO,CAAA;AACvE,IAAA,OAAO,UAAA,CAAW,cAAA,CAAe,IAAI,CAAA,EAAG,IAAA,EAAM,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW,CAAA;AAAA,EACzF,CAAC,CAAA;AACD,EAAA,OAAO,SAAS,OAAO,CAAA;AACzB;;"}
1
+ {"version":3,"file":"webhooks.mjs","sources":["../../../../src/application/transform/document/webhooks.ts"],"sourcesContent":["import { irObject, irProperty } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { PathItemObject, PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { pathItemType } from \"./path-item.js\";\n\n/**\n * The `webhooks` interface body (OpenAPI 3.1 §4.8.1): one path item per webhook name. A `$ref`\n * entry (often to `components/pathItems`) is the type it points at, as in `paths`; the original\n * read it as a path item, so every method was `never`. Members carry no JSDoc.\n */\nexport function webhooksType(webhooks: PathsObject, context: TransformContext): IrType {\n const members = documentEntries(webhooks, context.options).map(([name, pathItem]) => {\n const type = webhookType(name, pathItem, context);\n return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });\n });\n return irObject(members);\n}\n\nfunction webhookType(\n name: string,\n pathItem: PathsObject[string],\n context: TransformContext,\n): IrType {\n // A document may hold any value here; one that is no object is read as a path item, as before.\n if (typeof pathItem === \"object\" && pathItem !== null && \"$ref\" in pathItem) {\n return refType(pathItem.$ref);\n }\n const location = { path: appendPointer(ROOT_POINTER, [\"webhooks\", name]) };\n return pathItemType(pathItem as PathItemObject, location, context);\n}\n"],"names":[],"mappings":";;;;;;;AAeO,SAAS,YAAA,CAAa,UAAuB,OAAA,EAAmC;AACrF,EAAA,MAAM,OAAA,GAAU,eAAA,CAAgB,QAAA,EAAU,OAAA,CAAQ,OAAO,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,IAAA,EAAM,QAAQ,CAAA,KAAM;AACnF,IAAA,MAAM,IAAA,GAAO,WAAA,CAAY,IAAA,EAAM,QAAA,EAAU,OAAO,CAAA;AAChD,IAAA,OAAO,UAAA,CAAW,cAAA,CAAe,IAAI,CAAA,EAAG,IAAA,EAAM,EAAE,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,SAAA,EAAW,CAAA;AAAA,EACzF,CAAC,CAAA;AACD,EAAA,OAAO,SAAS,OAAO,CAAA;AACzB;AAEA,SAAS,WAAA,CACP,IAAA,EACA,QAAA,EACA,OAAA,EACQ;AAER,EAAA,IAAI,OAAO,QAAA,KAAa,QAAA,IAAY,QAAA,KAAa,IAAA,IAAQ,UAAU,QAAA,EAAU;AAC3E,IAAA,OAAO,OAAA,CAAQ,SAAS,IAAI,CAAA;AAAA,EAC9B;AACA,EAAA,MAAM,QAAA,GAAW,EAAE,IAAA,EAAM,aAAA,CAAc,cAAc,CAAC,UAAA,EAAY,IAAI,CAAC,CAAA,EAAE;AACzE,EAAA,OAAO,YAAA,CAAa,QAAA,EAA4B,QAAA,EAAU,OAAO,CAAA;AACnE;;"}
@@ -2,11 +2,16 @@
2
2
 
3
3
  const constructors = require('../../../domain/ir/constructors.cjs');
4
4
  const helperTypes = require('../helper-types.cjs');
5
+ const enumNameClaims = require('./enum-name-claims.cjs');
5
6
  const enumNaming = require('./enum-naming.cjs');
7
+ const operationKeys = require('./operation-keys.cjs');
6
8
  const sharedEnumNames = require('./shared-enum-names.cjs');
7
9
 
8
10
  function dedupeKey(request) {
9
- return [...request.values].sort(compareAsStrings).map((value, index) => metadataKey(String(value), request.metadata[index])).join(",");
11
+ const sorted = [...request.values].sort(compareAsStrings);
12
+ const originalPairs = sorted.map((value, index) => memberKey(value, request.metadata[index]));
13
+ const ownPairs = request.values.map((value, index) => ({ value, member: memberKey(value, request.metadata[index]) })).sort((left, right) => compareAsStrings(left.value, right.value)).map(({ member }) => member);
14
+ return JSON.stringify([originalPairs, ownPairs]);
10
15
  }
11
16
  function compareAsStrings(left, right) {
12
17
  const leftText = String(left);
@@ -16,8 +21,8 @@ function compareAsStrings(left, right) {
16
21
  }
17
22
  return leftText < rightText ? -1 : 1;
18
23
  }
19
- function metadataKey(value, metadata) {
20
- return `${metadata?.name ?? value}:${metadata?.description || ""}`;
24
+ function memberKey(value, metadata) {
25
+ return [value, metadata?.name ?? null, metadata?.description || null];
21
26
  }
22
27
  const ENUM_VALUES_NUMBER_SEPARATOR = "_";
23
28
  function declarationKey(name, request) {
@@ -39,19 +44,22 @@ class RunFooter {
39
44
  sink;
40
45
  isDedupingEnums;
41
46
  sharedNames;
42
- constructor(sink, isDedupingEnums, sharedNames = sharedEnumNames.FIRST_SCHEMA_NAMES) {
47
+ names;
48
+ constructor(sink, isDedupingEnums, sharedNames = sharedEnumNames.FIRST_SCHEMA_NAMES, names = { enums: new enumNameClaims.EnumNameClaims(), operations: new operationKeys.OperationKeys() }) {
43
49
  this.sink = sink;
44
50
  this.isDedupingEnums = isDedupingEnums;
45
51
  this.sharedNames = sharedNames;
52
+ this.names = names;
46
53
  }
47
54
  addEnum(request) {
48
55
  const ownName = this.naming.enumName(request.name);
49
56
  const key = this.isDedupingEnums ? dedupeKey(request) : null;
50
- const name = key === null ? ownName : this.sharedNames.nameOf(key, ownName, request);
57
+ const sharedName = key === null ? ownName : this.sharedNames.nameOf(key, ownName, request);
51
58
  const known = key === null ? void 0 : this.enumNamesByKey.get(key);
52
59
  if (known !== void 0) {
53
60
  return known;
54
61
  }
62
+ const name = this.names.enums.nameFor(sharedName, request.name);
55
63
  const declared = request.values.length > 0 ? declarationKey(name, request) : null;
56
64
  if (declared !== null && this.declaredEnums.has(declared)) {
57
65
  return name;
@@ -136,6 +144,9 @@ class RunFooter {
136
144
  addOperation(build) {
137
145
  this.sink.addOperation(build);
138
146
  }
147
+ operationKey(operationId) {
148
+ return this.names.operations.keyFor(operationId);
149
+ }
139
150
  require(helper) {
140
151
  if (!this.sink.hasTypeAlias(helper.name)) {
141
152
  this.sink.add({ kind: "rawDeclaration", name: helper.name, text: helper.text });