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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (514) hide show
  1. package/CHANGELOG.md +1831 -0
  2. package/dist/adapters/node-deprecations/node-deprecations.cjs +14 -0
  3. package/dist/adapters/node-deprecations/node-deprecations.cjs.map +1 -0
  4. package/dist/adapters/node-deprecations/node-deprecations.mjs +12 -0
  5. package/dist/adapters/node-deprecations/node-deprecations.mjs.map +1 -0
  6. package/dist/adapters/node-file-system/file-claims.cjs +105 -0
  7. package/dist/adapters/node-file-system/file-claims.cjs.map +1 -0
  8. package/dist/adapters/node-file-system/file-claims.mjs +95 -0
  9. package/dist/adapters/node-file-system/file-claims.mjs.map +1 -0
  10. package/dist/adapters/node-file-system/file-identity.cjs +82 -0
  11. package/dist/adapters/node-file-system/file-identity.cjs.map +1 -0
  12. package/dist/adapters/node-file-system/file-identity.mjs +74 -0
  13. package/dist/adapters/node-file-system/file-identity.mjs.map +1 -0
  14. package/dist/adapters/node-file-system/node-file-system.cjs +90 -14
  15. package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
  16. package/dist/adapters/node-file-system/node-file-system.mjs +90 -14
  17. package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
  18. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +75 -0
  19. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +72 -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/loaded-documents.cjs +28 -0
  27. package/dist/adapters/redocly-loader/loaded-documents.cjs.map +1 -0
  28. package/dist/adapters/redocly-loader/loaded-documents.mjs +21 -0
  29. package/dist/adapters/redocly-loader/loaded-documents.mjs.map +1 -0
  30. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +14 -15
  31. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +12 -13
  33. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  34. package/dist/adapters/redocly-loader/ref-access.cjs +31 -3
  35. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  36. package/dist/adapters/redocly-loader/ref-access.mjs +31 -3
  37. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  38. package/dist/adapters/redocly-loader/ref-holders.cjs +2 -2
  39. package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
  40. package/dist/adapters/redocly-loader/ref-holders.mjs +3 -3
  41. package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
  42. package/dist/adapters/redocly-loader/remote-body-limit.cjs +50 -0
  43. package/dist/adapters/redocly-loader/remote-body-limit.cjs.map +1 -0
  44. package/dist/adapters/redocly-loader/remote-body-limit.mjs +48 -0
  45. package/dist/adapters/redocly-loader/remote-body-limit.mjs.map +1 -0
  46. package/dist/adapters/redocly-loader/remote-fetch.cjs +35 -6
  47. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  48. package/dist/adapters/redocly-loader/remote-fetch.mjs +35 -6
  49. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  50. package/dist/adapters/redocly-loader/remote-node-limit.cjs +47 -0
  51. package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -0
  52. package/dist/adapters/redocly-loader/remote-node-limit.mjs +44 -0
  53. package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -0
  54. package/dist/adapters/redocly-loader/schema-load-errors.cjs +32 -8
  55. package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
  56. package/dist/adapters/redocly-loader/schema-load-errors.mjs +32 -9
  57. package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
  58. package/dist/adapters/redocly-loader/schema-source.cjs +11 -7
  59. package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
  60. package/dist/adapters/redocly-loader/schema-source.mjs +12 -8
  61. package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
  62. package/dist/adapters/redocly-loader/unsupported-keys.cjs +3 -5
  63. package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
  64. package/dist/adapters/redocly-loader/unsupported-keys.mjs +3 -5
  65. package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
  66. package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
  67. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  68. package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
  69. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  70. package/dist/api/default-ports.cjs +19 -2
  71. package/dist/api/default-ports.cjs.map +1 -1
  72. package/dist/api/default-ports.mjs +19 -3
  73. package/dist/api/default-ports.mjs.map +1 -1
  74. package/dist/api/discriminator-conflict-warnings.cjs +1 -1
  75. package/dist/api/discriminator-conflict-warnings.cjs.map +1 -1
  76. package/dist/api/discriminator-conflict-warnings.mjs +2 -2
  77. package/dist/api/discriminator-conflict-warnings.mjs.map +1 -1
  78. package/dist/api/discriminator-enum-parent.cjs +2 -2
  79. package/dist/api/discriminator-enum-parent.cjs.map +1 -1
  80. package/dist/api/discriminator-enum-parent.mjs +3 -3
  81. package/dist/api/discriminator-enum-parent.mjs.map +1 -1
  82. package/dist/api/discriminator-other-owners.cjs +5 -3
  83. package/dist/api/discriminator-other-owners.cjs.map +1 -1
  84. package/dist/api/discriminator-other-owners.mjs +5 -3
  85. package/dist/api/discriminator-other-owners.mjs.map +1 -1
  86. package/dist/api/discriminator-patch.cjs +8 -4
  87. package/dist/api/discriminator-patch.cjs.map +1 -1
  88. package/dist/api/discriminator-patch.mjs +9 -5
  89. package/dist/api/discriminator-patch.mjs.map +1 -1
  90. package/dist/api/discriminator-scan.cjs +17 -10
  91. package/dist/api/discriminator-scan.cjs.map +1 -1
  92. package/dist/api/discriminator-scan.mjs +18 -11
  93. package/dist/api/discriminator-scan.mjs.map +1 -1
  94. package/dist/api/document-run.cjs +4 -3
  95. package/dist/api/document-run.cjs.map +1 -1
  96. package/dist/api/document-run.mjs +4 -3
  97. package/dist/api/document-run.mjs.map +1 -1
  98. package/dist/api/legacy-callback-warning.cjs +7 -4
  99. package/dist/api/legacy-callback-warning.cjs.map +1 -1
  100. package/dist/api/legacy-callback-warning.mjs +8 -5
  101. package/dist/api/legacy-callback-warning.mjs.map +1 -1
  102. package/dist/api/legacy-utils.cjs.map +1 -1
  103. package/dist/api/legacy-utils.mjs.map +1 -1
  104. package/dist/api/openapi-ts.cjs +9 -5
  105. package/dist/api/openapi-ts.cjs.map +1 -1
  106. package/dist/api/openapi-ts.mjs +10 -7
  107. package/dist/api/openapi-ts.mjs.map +1 -1
  108. package/dist/api/schema-callbacks.cjs +36 -12
  109. package/dist/api/schema-callbacks.cjs.map +1 -1
  110. package/dist/api/schema-callbacks.mjs +36 -12
  111. package/dist/api/schema-callbacks.mjs.map +1 -1
  112. package/dist/api/string-to-ast.cjs +7 -9
  113. package/dist/api/string-to-ast.cjs.map +1 -1
  114. package/dist/api/string-to-ast.mjs +8 -9
  115. package/dist/api/string-to-ast.mjs.map +1 -1
  116. package/dist/api/transform-context.cjs +7 -3
  117. package/dist/api/transform-context.cjs.map +1 -1
  118. package/dist/api/transform-context.mjs +7 -3
  119. package/dist/api/transform-context.mjs.map +1 -1
  120. package/dist/api/transform-schema.cjs +42 -12
  121. package/dist/api/transform-schema.cjs.map +1 -1
  122. package/dist/api/transform-schema.mjs +44 -14
  123. package/dist/api/transform-schema.mjs.map +1 -1
  124. package/dist/application/print/text-writer.cjs +10 -3
  125. package/dist/application/print/text-writer.cjs.map +1 -1
  126. package/dist/application/print/text-writer.mjs +10 -3
  127. package/dist/application/print/text-writer.mjs.map +1 -1
  128. package/dist/application/stack-overflow.cjs +2 -1
  129. package/dist/application/stack-overflow.cjs.map +1 -1
  130. package/dist/application/stack-overflow.mjs +2 -1
  131. package/dist/application/stack-overflow.mjs.map +1 -1
  132. package/dist/application/transform/document/components.cjs +2 -2
  133. package/dist/application/transform/document/components.cjs.map +1 -1
  134. package/dist/application/transform/document/components.mjs +4 -4
  135. package/dist/application/transform/document/components.mjs.map +1 -1
  136. package/dist/application/transform/document/declared-type-names.cjs +23 -0
  137. package/dist/application/transform/document/declared-type-names.cjs.map +1 -0
  138. package/dist/application/transform/document/declared-type-names.mjs +20 -0
  139. package/dist/application/transform/document/declared-type-names.mjs.map +1 -0
  140. package/dist/application/transform/document/defs-root.cjs +1 -1
  141. package/dist/application/transform/document/defs-root.cjs.map +1 -1
  142. package/dist/application/transform/document/defs-root.mjs +2 -2
  143. package/dist/application/transform/document/defs-root.mjs.map +1 -1
  144. package/dist/application/transform/document/document.cjs +4 -1
  145. package/dist/application/transform/document/document.cjs.map +1 -1
  146. package/dist/application/transform/document/document.mjs +3 -2
  147. package/dist/application/transform/document/document.mjs.map +1 -1
  148. package/dist/application/transform/document/enum-names-given-back.cjs +62 -0
  149. package/dist/application/transform/document/enum-names-given-back.cjs.map +1 -0
  150. package/dist/application/transform/document/enum-names-given-back.mjs +58 -0
  151. package/dist/application/transform/document/enum-names-given-back.mjs.map +1 -0
  152. package/dist/application/transform/document/global-type-references.cjs +1 -0
  153. package/dist/application/transform/document/global-type-references.cjs.map +1 -1
  154. package/dist/application/transform/document/global-type-references.mjs +1 -1
  155. package/dist/application/transform/document/global-type-references.mjs.map +1 -1
  156. package/dist/application/transform/document/media-type.cjs +2 -2
  157. package/dist/application/transform/document/media-type.cjs.map +1 -1
  158. package/dist/application/transform/document/media-type.mjs +3 -3
  159. package/dist/application/transform/document/media-type.mjs.map +1 -1
  160. package/dist/application/transform/document/operation-keys-written.cjs +26 -0
  161. package/dist/application/transform/document/operation-keys-written.cjs.map +1 -0
  162. package/dist/application/transform/document/operation-keys-written.mjs +24 -0
  163. package/dist/application/transform/document/operation-keys-written.mjs.map +1 -0
  164. package/dist/application/transform/document/operation.cjs +1 -1
  165. package/dist/application/transform/document/operation.cjs.map +1 -1
  166. package/dist/application/transform/document/operation.mjs +2 -2
  167. package/dist/application/transform/document/operation.mjs.map +1 -1
  168. package/dist/application/transform/document/parameter-entries.cjs +34 -0
  169. package/dist/application/transform/document/parameter-entries.cjs.map +1 -0
  170. package/dist/application/transform/document/parameter-entries.mjs +30 -0
  171. package/dist/application/transform/document/parameter-entries.mjs.map +1 -0
  172. package/dist/application/transform/document/parameter.cjs +12 -4
  173. package/dist/application/transform/document/parameter.cjs.map +1 -1
  174. package/dist/application/transform/document/parameter.mjs +13 -5
  175. package/dist/application/transform/document/parameter.mjs.map +1 -1
  176. package/dist/application/transform/document/parameters.cjs +7 -30
  177. package/dist/application/transform/document/parameters.cjs.map +1 -1
  178. package/dist/application/transform/document/parameters.mjs +8 -31
  179. package/dist/application/transform/document/parameters.mjs.map +1 -1
  180. package/dist/application/transform/document/path-item.cjs +11 -14
  181. package/dist/application/transform/document/path-item.cjs.map +1 -1
  182. package/dist/application/transform/document/path-item.mjs +12 -16
  183. package/dist/application/transform/document/path-item.mjs.map +1 -1
  184. package/dist/application/transform/document/paths-enum.cjs +1 -0
  185. package/dist/application/transform/document/paths-enum.cjs.map +1 -1
  186. package/dist/application/transform/document/paths-enum.mjs +1 -1
  187. package/dist/application/transform/document/paths-enum.mjs.map +1 -1
  188. package/dist/application/transform/document/paths.cjs +6 -2
  189. package/dist/application/transform/document/paths.cjs.map +1 -1
  190. package/dist/application/transform/document/paths.mjs +8 -4
  191. package/dist/application/transform/document/paths.mjs.map +1 -1
  192. package/dist/application/transform/document/referenced-parameter.cjs +80 -0
  193. package/dist/application/transform/document/referenced-parameter.cjs.map +1 -0
  194. package/dist/application/transform/document/referenced-parameter.mjs +78 -0
  195. package/dist/application/transform/document/referenced-parameter.mjs.map +1 -0
  196. package/dist/application/transform/document/request-body.cjs +1 -1
  197. package/dist/application/transform/document/request-body.cjs.map +1 -1
  198. package/dist/application/transform/document/request-body.mjs +2 -2
  199. package/dist/application/transform/document/request-body.mjs.map +1 -1
  200. package/dist/application/transform/document/response.cjs +2 -2
  201. package/dist/application/transform/document/response.cjs.map +1 -1
  202. package/dist/application/transform/document/response.mjs +3 -3
  203. package/dist/application/transform/document/response.mjs.map +1 -1
  204. package/dist/application/transform/document/responses.cjs +1 -1
  205. package/dist/application/transform/document/responses.cjs.map +1 -1
  206. package/dist/application/transform/document/responses.mjs +2 -2
  207. package/dist/application/transform/document/responses.mjs.map +1 -1
  208. package/dist/application/transform/document/root-type-aliases.cjs +8 -23
  209. package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
  210. package/dist/application/transform/document/root-type-aliases.mjs +8 -24
  211. package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
  212. package/dist/application/transform/document/type-resolution.cjs +3 -1
  213. package/dist/application/transform/document/type-resolution.cjs.map +1 -1
  214. package/dist/application/transform/document/type-resolution.mjs +3 -1
  215. package/dist/application/transform/document/type-resolution.mjs.map +1 -1
  216. package/dist/application/transform/document/webhooks.cjs +1 -1
  217. package/dist/application/transform/document/webhooks.cjs.map +1 -1
  218. package/dist/application/transform/document/webhooks.mjs +2 -2
  219. package/dist/application/transform/document/webhooks.mjs.map +1 -1
  220. package/dist/application/transform/footer/document-footer.cjs +10 -2
  221. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  222. package/dist/application/transform/footer/document-footer.mjs +10 -2
  223. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  224. package/dist/application/transform/footer/enum-name-claims.cjs +48 -0
  225. package/dist/application/transform/footer/enum-name-claims.cjs.map +1 -0
  226. package/dist/application/transform/footer/enum-name-claims.mjs +46 -0
  227. package/dist/application/transform/footer/enum-name-claims.mjs.map +1 -0
  228. package/dist/application/transform/footer/operation-keys.cjs +23 -0
  229. package/dist/application/transform/footer/operation-keys.cjs.map +1 -0
  230. package/dist/application/transform/footer/operation-keys.mjs +21 -0
  231. package/dist/application/transform/footer/operation-keys.mjs.map +1 -0
  232. package/dist/application/transform/footer/type-evaluation.cjs +4 -4
  233. package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
  234. package/dist/application/transform/footer/type-evaluation.mjs +4 -4
  235. package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
  236. package/dist/application/transform/helper-types.cjs +1 -1
  237. package/dist/application/transform/helper-types.cjs.map +1 -1
  238. package/dist/application/transform/helper-types.mjs +1 -1
  239. package/dist/application/transform/helper-types.mjs.map +1 -1
  240. package/dist/application/transform/numbered-names.cjs +9 -0
  241. package/dist/application/transform/numbered-names.cjs.map +1 -1
  242. package/dist/application/transform/numbered-names.mjs +9 -1
  243. package/dist/application/transform/numbered-names.mjs.map +1 -1
  244. package/dist/application/transform/ref-pointer/generated-location.cjs +1 -1
  245. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
  246. package/dist/application/transform/ref-pointer/generated-location.mjs +2 -2
  247. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
  248. package/dist/application/transform/ref-pointer/pointer-type.cjs +1 -1
  249. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  250. package/dist/application/transform/ref-pointer/pointer-type.mjs +2 -2
  251. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  252. package/dist/application/transform/ref-type.cjs +2 -1
  253. package/dist/application/transform/ref-type.cjs.map +1 -1
  254. package/dist/application/transform/ref-type.mjs +2 -1
  255. package/dist/application/transform/ref-type.mjs.map +1 -1
  256. package/dist/application/transform/schema/access-flags.cjs +1 -1
  257. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  258. package/dist/application/transform/schema/access-flags.mjs +2 -2
  259. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  260. package/dist/application/transform/schema/array-type.cjs +2 -2
  261. package/dist/application/transform/schema/array-type.cjs.map +1 -1
  262. package/dist/application/transform/schema/array-type.mjs +3 -3
  263. package/dist/application/transform/schema/array-type.mjs.map +1 -1
  264. package/dist/application/transform/schema/composition-type.cjs +4 -4
  265. package/dist/application/transform/schema/composition-type.cjs.map +1 -1
  266. package/dist/application/transform/schema/composition-type.mjs +6 -6
  267. package/dist/application/transform/schema/composition-type.mjs.map +1 -1
  268. package/dist/application/transform/schema/enum-rule.cjs +4 -6
  269. package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
  270. package/dist/application/transform/schema/enum-rule.mjs +6 -8
  271. package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
  272. package/dist/application/transform/schema/object-type.cjs +3 -3
  273. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  274. package/dist/application/transform/schema/object-type.mjs +4 -4
  275. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  276. package/dist/application/transform/schema/presence-members.cjs +1 -1
  277. package/dist/application/transform/schema/presence-members.cjs.map +1 -1
  278. package/dist/application/transform/schema/presence-members.mjs +2 -2
  279. package/dist/application/transform/schema/presence-members.mjs.map +1 -1
  280. package/dist/application/transform/schema/ref-siblings.cjs +47 -0
  281. package/dist/application/transform/schema/ref-siblings.cjs.map +1 -0
  282. package/dist/application/transform/schema/ref-siblings.mjs +45 -0
  283. package/dist/application/transform/schema/ref-siblings.mjs.map +1 -0
  284. package/dist/application/transform/schema/required-variants.cjs +2 -2
  285. package/dist/application/transform/schema/required-variants.cjs.map +1 -1
  286. package/dist/application/transform/schema/required-variants.mjs +3 -3
  287. package/dist/application/transform/schema/required-variants.mjs.map +1 -1
  288. package/dist/application/transform/schema/schema-transform.cjs +4 -2
  289. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  290. package/dist/application/transform/schema/schema-transform.mjs +4 -2
  291. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  292. package/dist/application/transform/schema/unevaluated-properties.cjs +1 -1
  293. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  294. package/dist/application/transform/schema/unevaluated-properties.mjs +2 -2
  295. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  296. package/dist/application/transform/schema-comment.cjs +6 -2
  297. package/dist/application/transform/schema-comment.cjs.map +1 -1
  298. package/dist/application/transform/schema-comment.mjs +7 -3
  299. package/dist/application/transform/schema-comment.mjs.map +1 -1
  300. package/dist/cli/api-settings.cjs +62 -6
  301. package/dist/cli/api-settings.cjs.map +1 -1
  302. package/dist/cli/api-settings.mjs +60 -7
  303. package/dist/cli/api-settings.mjs.map +1 -1
  304. package/dist/cli/api-writes.cjs +72 -0
  305. package/dist/cli/api-writes.cjs.map +1 -0
  306. package/dist/cli/api-writes.mjs +69 -0
  307. package/dist/cli/api-writes.mjs.map +1 -0
  308. package/dist/cli/cli-errors.cjs +12 -1
  309. package/dist/cli/cli-errors.cjs.map +1 -1
  310. package/dist/cli/cli-errors.mjs +12 -1
  311. package/dist/cli/cli-errors.mjs.map +1 -1
  312. package/dist/cli/cli-output.cjs +106 -1
  313. package/dist/cli/cli-output.cjs.map +1 -1
  314. package/dist/cli/cli-output.mjs +99 -2
  315. package/dist/cli/cli-output.mjs.map +1 -1
  316. package/dist/cli/main.cjs +5 -1
  317. package/dist/cli/main.cjs.map +1 -1
  318. package/dist/cli/main.mjs +6 -2
  319. package/dist/cli/main.mjs.map +1 -1
  320. package/dist/cli/redocly-apis.cjs +82 -36
  321. package/dist/cli/redocly-apis.cjs.map +1 -1
  322. package/dist/cli/redocly-apis.mjs +85 -39
  323. package/dist/cli/redocly-apis.mjs.map +1 -1
  324. package/dist/cli/run-cli.cjs +13 -7
  325. package/dist/cli/run-cli.cjs.map +1 -1
  326. package/dist/cli/run-cli.mjs +14 -8
  327. package/dist/cli/run-cli.mjs.map +1 -1
  328. package/dist/domain/append-all.cjs +10 -0
  329. package/dist/domain/append-all.cjs.map +1 -0
  330. package/dist/domain/append-all.mjs +8 -0
  331. package/dist/domain/append-all.mjs.map +1 -0
  332. package/dist/domain/cause-secrets.cjs +37 -0
  333. package/dist/domain/cause-secrets.cjs.map +1 -0
  334. package/dist/domain/cause-secrets.mjs +35 -0
  335. package/dist/domain/cause-secrets.mjs.map +1 -0
  336. package/dist/domain/deprecations.cjs +11 -0
  337. package/dist/domain/deprecations.cjs.map +1 -0
  338. package/dist/domain/deprecations.mjs +9 -0
  339. package/dist/domain/deprecations.mjs.map +1 -0
  340. package/dist/domain/errors.cjs +9 -3
  341. package/dist/domain/errors.cjs.map +1 -1
  342. package/dist/domain/errors.mjs +9 -3
  343. package/dist/domain/errors.mjs.map +1 -1
  344. package/dist/domain/ir/identifier-text.cjs.map +1 -1
  345. package/dist/domain/ir/identifier-text.mjs +1 -1
  346. package/dist/domain/ir/identifier-text.mjs.map +1 -1
  347. package/dist/domain/ir/ir-shape.cjs +187 -0
  348. package/dist/domain/ir/ir-shape.cjs.map +1 -0
  349. package/dist/domain/ir/ir-shape.mjs +184 -0
  350. package/dist/domain/ir/ir-shape.mjs.map +1 -0
  351. package/dist/domain/ir/newer-identifier-ranges.cjs +182 -29
  352. package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -1
  353. package/dist/domain/ir/newer-identifier-ranges.mjs +182 -29
  354. package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -1
  355. package/dist/domain/openapi/alias-expansion.cjs +3 -1
  356. package/dist/domain/openapi/alias-expansion.cjs.map +1 -1
  357. package/dist/domain/openapi/alias-expansion.mjs +3 -1
  358. package/dist/domain/openapi/alias-expansion.mjs.map +1 -1
  359. package/dist/domain/openapi/discriminated-union.cjs +3 -3
  360. package/dist/domain/openapi/discriminated-union.cjs.map +1 -1
  361. package/dist/domain/openapi/discriminated-union.mjs +4 -4
  362. package/dist/domain/openapi/discriminated-union.mjs.map +1 -1
  363. package/dist/domain/openapi/discriminator-conflicts.cjs +10 -6
  364. package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -1
  365. package/dist/domain/openapi/discriminator-conflicts.mjs +11 -7
  366. package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -1
  367. package/dist/domain/openapi/json-pointer.cjs +43 -1
  368. package/dist/domain/openapi/json-pointer.cjs.map +1 -1
  369. package/dist/domain/openapi/json-pointer.mjs +40 -2
  370. package/dist/domain/openapi/json-pointer.mjs.map +1 -1
  371. package/dist/domain/openapi/schema-dialect.cjs +15 -0
  372. package/dist/domain/openapi/schema-dialect.cjs.map +1 -0
  373. package/dist/domain/openapi/schema-dialect.mjs +12 -0
  374. package/dist/domain/openapi/schema-dialect.mjs.map +1 -0
  375. package/dist/domain/openapi/unsupported-features.cjs +1 -1
  376. package/dist/domain/openapi/unsupported-features.cjs.map +1 -1
  377. package/dist/domain/openapi/unsupported-features.mjs +2 -2
  378. package/dist/domain/openapi/unsupported-features.mjs.map +1 -1
  379. package/dist/domain/output-fixes.cjs +25 -14
  380. package/dist/domain/output-fixes.cjs.map +1 -1
  381. package/dist/domain/output-fixes.mjs +25 -13
  382. package/dist/domain/output-fixes.mjs.map +1 -1
  383. package/dist/domain/url-secrets.cjs +48 -0
  384. package/dist/domain/url-secrets.cjs.map +1 -0
  385. package/dist/domain/url-secrets.mjs +45 -0
  386. package/dist/domain/url-secrets.mjs.map +1 -0
  387. package/dist/domain/warnings.cjs +0 -1
  388. package/dist/domain/warnings.cjs.map +1 -1
  389. package/dist/domain/warnings.mjs +0 -1
  390. package/dist/domain/warnings.mjs.map +1 -1
  391. package/dist/index.cjs +2 -3
  392. package/dist/index.cjs.map +1 -1
  393. package/dist/index.d.cts +57 -20
  394. package/dist/index.d.mts +57 -20
  395. package/dist/index.d.ts +57 -20
  396. package/dist/index.mjs +3 -2
  397. package/dist/index.mjs.map +1 -1
  398. package/package.json +5 -6
  399. package/src/adapters/node-deprecations/node-deprecations.ts +14 -0
  400. package/src/adapters/node-file-system/file-claims.ts +138 -0
  401. package/src/adapters/node-file-system/file-identity.ts +137 -0
  402. package/src/adapters/node-file-system/node-file-system.ts +145 -18
  403. package/src/adapters/redocly-loader/bundled-mapping-copies.ts +95 -0
  404. package/src/adapters/redocly-loader/bundled-ref-repair.ts +2 -2
  405. package/src/adapters/redocly-loader/loaded-documents.ts +46 -0
  406. package/src/adapters/redocly-loader/redocly-schema-loader.ts +18 -24
  407. package/src/adapters/redocly-loader/ref-access.ts +37 -3
  408. package/src/adapters/redocly-loader/ref-holders.ts +3 -3
  409. package/src/adapters/redocly-loader/remote-body-limit.ts +66 -0
  410. package/src/adapters/redocly-loader/remote-fetch.ts +74 -11
  411. package/src/adapters/redocly-loader/remote-node-limit.ts +62 -0
  412. package/src/adapters/redocly-loader/schema-load-errors.ts +52 -13
  413. package/src/adapters/redocly-loader/schema-source.ts +20 -8
  414. package/src/adapters/redocly-loader/unsupported-keys.ts +3 -7
  415. package/src/adapters/terminal-logger/terminal-logger.ts +10 -5
  416. package/src/api/default-ports.ts +40 -4
  417. package/src/api/discriminator-conflict-warnings.ts +2 -2
  418. package/src/api/discriminator-enum-parent.ts +3 -3
  419. package/src/api/discriminator-other-owners.ts +5 -3
  420. package/src/api/discriminator-patch.ts +9 -6
  421. package/src/api/discriminator-scan.ts +19 -11
  422. package/src/api/document-run.ts +9 -3
  423. package/src/api/legacy-callback-warning.ts +13 -6
  424. package/src/api/legacy-utils.ts +5 -1
  425. package/src/api/openapi-ts.ts +26 -7
  426. package/src/api/run-context.ts +6 -0
  427. package/src/api/schema-callbacks.ts +60 -17
  428. package/src/api/string-to-ast.ts +11 -15
  429. package/src/api/transform-context.ts +7 -3
  430. package/src/api/transform-schema.ts +67 -15
  431. package/src/application/ports/deprecation-reporter.ts +9 -0
  432. package/src/application/ports/file-system.ts +39 -0
  433. package/src/application/ports/schema-loader.ts +11 -1
  434. package/src/application/print/text-writer.ts +10 -3
  435. package/src/application/stack-overflow.ts +9 -5
  436. package/src/application/transform/document/components.ts +4 -4
  437. package/src/application/transform/document/declared-type-names.ts +36 -0
  438. package/src/application/transform/document/defs-root.ts +2 -2
  439. package/src/application/transform/document/document.ts +4 -3
  440. package/src/application/transform/document/enum-names-given-back.ts +91 -0
  441. package/src/application/transform/document/global-type-references.ts +1 -1
  442. package/src/application/transform/document/media-type.ts +4 -3
  443. package/src/application/transform/document/operation-keys-written.ts +27 -0
  444. package/src/application/transform/document/operation.ts +2 -2
  445. package/src/application/transform/document/parameter-entries.ts +70 -0
  446. package/src/application/transform/document/parameter.ts +21 -9
  447. package/src/application/transform/document/parameters.ts +13 -58
  448. package/src/application/transform/document/path-item.ts +13 -31
  449. package/src/application/transform/document/paths-enum.ts +1 -1
  450. package/src/application/transform/document/paths.ts +8 -4
  451. package/src/application/transform/document/referenced-parameter.ts +146 -0
  452. package/src/application/transform/document/request-body.ts +2 -2
  453. package/src/application/transform/document/response.ts +3 -3
  454. package/src/application/transform/document/responses.ts +2 -2
  455. package/src/application/transform/document/root-type-aliases.ts +17 -38
  456. package/src/application/transform/document/type-resolution.ts +2 -1
  457. package/src/application/transform/document/webhooks.ts +2 -2
  458. package/src/application/transform/footer/document-footer.ts +18 -1
  459. package/src/application/transform/footer/enum-name-claims.ts +62 -0
  460. package/src/application/transform/footer/operation-keys.ts +28 -0
  461. package/src/application/transform/footer/type-evaluation.ts +4 -4
  462. package/src/application/transform/helper-types.ts +6 -5
  463. package/src/application/transform/numbered-names.ts +15 -0
  464. package/src/application/transform/ref-pointer/generated-location.ts +2 -2
  465. package/src/application/transform/ref-pointer/pointer-type.ts +2 -4
  466. package/src/application/transform/ref-type.ts +2 -1
  467. package/src/application/transform/schema/access-flags.ts +2 -2
  468. package/src/application/transform/schema/array-type.ts +3 -5
  469. package/src/application/transform/schema/composition-type.ts +6 -6
  470. package/src/application/transform/schema/enum-rule.ts +10 -8
  471. package/src/application/transform/schema/object-type.ts +4 -4
  472. package/src/application/transform/schema/presence-members.ts +2 -2
  473. package/src/application/transform/schema/ref-siblings.ts +76 -0
  474. package/src/application/transform/schema/required-variants.ts +3 -3
  475. package/src/application/transform/schema/schema-context.ts +3 -0
  476. package/src/application/transform/schema/schema-transform.ts +4 -2
  477. package/src/application/transform/schema/unevaluated-properties.ts +2 -2
  478. package/src/application/transform/schema-comment.ts +7 -3
  479. package/src/application/transform/transform-context.ts +5 -0
  480. package/src/cli/api-settings.ts +82 -7
  481. package/src/cli/api-writes.ts +117 -0
  482. package/src/cli/cli-dependencies.ts +21 -4
  483. package/src/cli/cli-errors.ts +20 -1
  484. package/src/cli/cli-output.ts +186 -7
  485. package/src/cli/main.ts +6 -3
  486. package/src/cli/redocly-apis.ts +153 -48
  487. package/src/cli/run-cli.ts +37 -8
  488. package/src/domain/append-all.ts +10 -0
  489. package/src/domain/cause-secrets.ts +52 -0
  490. package/src/domain/deprecations.ts +15 -0
  491. package/src/domain/errors.ts +22 -7
  492. package/src/domain/ir/identifier-text.ts +6 -5
  493. package/src/domain/ir/ir-shape.ts +299 -0
  494. package/src/domain/ir/newer-identifier-ranges.ts +183 -30
  495. package/src/domain/openapi/alias-expansion.ts +4 -1
  496. package/src/domain/openapi/discriminated-union.ts +6 -4
  497. package/src/domain/openapi/discriminator-conflicts.ts +21 -7
  498. package/src/domain/openapi/document-object.ts +2 -0
  499. package/src/domain/openapi/json-pointer.ts +96 -7
  500. package/src/domain/openapi/schema-dialect.ts +22 -0
  501. package/src/domain/openapi/unsupported-features.ts +2 -2
  502. package/src/domain/output-fixes.ts +37 -18
  503. package/src/domain/url-secrets.ts +72 -0
  504. package/src/domain/warnings.ts +0 -1
  505. package/src/index.ts +2 -6
  506. package/src/types/generator-options.ts +1 -1
  507. package/dist/cli/main.d.cts +0 -2
  508. package/dist/cli/main.d.mts +0 -2
  509. package/dist/cli/main.d.ts +0 -2
  510. package/dist/domain/url-credentials.cjs +0 -10
  511. package/dist/domain/url-credentials.cjs.map +0 -1
  512. package/dist/domain/url-credentials.mjs +0 -8
  513. package/dist/domain/url-credentials.mjs.map +0 -1
  514. package/src/domain/url-credentials.ts +0 -18
@@ -1,14 +1,18 @@
1
1
  import { irObject, irProperty, irKeyword } 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 { HTTP_METHODS, QUERY_METHOD, ADDITIONAL_OPERATIONS_KEY } from '../../../domain/openapi/path-item-object.mjs';
5
5
  import { documentEntries } from '../document-entries.mjs';
6
6
  import { refType } from '../ref-type.mjs';
7
7
  import { documentMember } from './document-member.mjs';
8
8
  import { operationMembers } from './operation.mjs';
9
+ import { mergedParameters } from './parameter-entries.mjs';
9
10
  import { parametersMember } from './parameters.mjs';
10
11
 
11
12
  const HASH_RE = /#/g;
13
+ function operationKeyOf(operationId) {
14
+ return operationId.replace(HASH_RE, "/");
15
+ }
12
16
  function isIncluded(operation, context) {
13
17
  if (!operation) {
14
18
  return false;
@@ -16,26 +20,18 @@ function isIncluded(operation, context) {
16
20
  const resolved = "$ref" in operation ? context.refs.resolve(operation.$ref) : operation;
17
21
  return !(context.options.excludeDeprecated && resolved?.deprecated);
18
22
  }
19
- function mergedParameters(pathItem, operation, context) {
20
- const byKey = /* @__PURE__ */ new Map();
21
- for (const parameter of [...pathItem.parameters ?? [], ...operation.parameters ?? []]) {
22
- const resolved = "$ref" in parameter ? context.refs.resolve(parameter.$ref) : parameter;
23
- byKey.set(`${resolved?.in}-${resolved?.name}`, parameter);
24
- }
25
- return [...byKey.values()];
26
- }
27
23
  function operationType(pathItem, operation, location, context) {
28
- const merged = { ...operation, parameters: mergedParameters(pathItem, operation, context) };
24
+ const merged = { ...operation, parameters: mergedParameters(pathItem, operation, context.refs) };
29
25
  if (!operation.operationId) {
30
26
  return irObject(operationMembers(merged, location, context));
31
27
  }
32
- const operationId = operation.operationId.replace(HASH_RE, "/");
28
+ const operationId = context.footer.operationKey(operationKeyOf(operation.operationId));
33
29
  context.footer.addOperation(
34
30
  () => irProperty(toPropertyName(operationId), irObject(operationMembers(merged, location, context)), {
35
31
  isReadonly: context.options.immutable
36
32
  })
37
33
  );
38
- return refType(createRef(["operations", operationId]));
34
+ return refType(appendPointer(ROOT_POINTER, ["operations", operationId]));
39
35
  }
40
36
  function operationMember({ name, operation, path }, pathItem, location, context) {
41
37
  const type = "$ref" in operation ? refType(operation.$ref) : operationType(pathItem, operation, { ...location, path }, context);
@@ -47,13 +43,13 @@ function methodMember(method, pathItem, location, context) {
47
43
  const isReadonly = context.options.immutable;
48
44
  return irProperty(toPropertyName(method), irKeyword("never"), { isOptional: true, isReadonly });
49
45
  }
50
- const path = createRef([location.path, method]);
46
+ const path = appendPointer(location.path, [method]);
51
47
  return operationMember({ name: method, operation, path }, pathItem, location, context);
52
48
  }
53
49
  function additionalOperationsMember(pathItem, location, context) {
54
50
  const entries = documentEntries(pathItem.additionalOperations ?? {}, context.options);
55
51
  const members = entries.filter(([, operation]) => isIncluded(operation, context)).map(([method, operation]) => {
56
- const path = createRef([location.path, ADDITIONAL_OPERATIONS_KEY, method]);
52
+ const path = appendPointer(location.path, [ADDITIONAL_OPERATIONS_KEY, method]);
57
53
  return operationMember({ name: method, operation, path }, pathItem, location, context);
58
54
  });
59
55
  return members.length > 0 ? irProperty(toPropertyName(ADDITIONAL_OPERATIONS_KEY), irObject(members), {
@@ -61,7 +57,7 @@ function additionalOperationsMember(pathItem, location, context) {
61
57
  }) : null;
62
58
  }
63
59
  function pathItemType(pathItem, location, context) {
64
- const parametersLocation = { ...location, path: createRef([location.path, "parameters"]) };
60
+ const parametersLocation = { ...location, path: appendPointer(location.path, ["parameters"]) };
65
61
  const members = [
66
62
  parametersMember(pathItem.parameters ?? [], parametersLocation, context),
67
63
  ...HTTP_METHODS.map((method) => methodMember(method, pathItem, location, context))
@@ -76,5 +72,5 @@ function pathItemType(pathItem, location, context) {
76
72
  return irObject(members);
77
73
  }
78
74
 
79
- export { pathItemType };
75
+ export { operationKeyOf, pathItemType };
80
76
  //# sourceMappingURL=path-item.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-item.mjs","sources":["../../../../src/application/transform/document/path-item.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } 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 type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type {\n ParameterObject,\n ParameterOrReference,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type OperationEntry,\n type PathItemMethod,\n type PathItemObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { operationMembers } from \"./operation.js\";\nimport { parametersMember } from \"./parameters.js\";\n\n/** Redocly reads `#` in an operation ID as a pointer, so it is replaced (upstream issue #1542). */\nconst HASH_RE = /#/g;\n\n/** Whether the method has an operation, not removed by `--exclude-deprecated`. */\nfunction isIncluded(\n operation: OperationEntry | undefined,\n context: TransformContext,\n): operation is OperationEntry {\n if (!operation) {\n return false;\n }\n const resolved =\n \"$ref\" in operation\n ? (context.refs.resolve(operation.$ref) as OperationObject | undefined)\n : operation;\n return !(context.options.excludeDeprecated && resolved?.deprecated);\n}\n\n/**\n * Path item parameters followed by the operation's, keyed by location and name, so an operation\n * parameter replaces the path item parameter it redefines (upstream issue #1798).\n */\nfunction mergedParameters(\n pathItem: PathItemObject,\n operation: OperationObject,\n context: TransformContext,\n): ParameterOrReference[] {\n const byKey = new Map<string, ParameterOrReference>();\n for (const parameter of [...(pathItem.parameters ?? []), ...(operation.parameters ?? [])]) {\n const resolved =\n \"$ref\" in parameter\n ? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)\n : parameter;\n byKey.set(`${resolved?.in}-${resolved?.name}`, parameter);\n }\n return [...byKey.values()];\n}\n\n/**\n * An operation with an `operationId` goes into the `operations` interface and is referenced from\n * the path item; others are written inline.\n */\nfunction operationType(\n pathItem: PathItemObject,\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const merged = { ...operation, parameters: mergedParameters(pathItem, operation, context) };\n if (!operation.operationId) {\n return irObject(operationMembers(merged, location, context));\n }\n const operationId = operation.operationId.replace(HASH_RE, \"/\");\n context.footer.addOperation(() =>\n irProperty(toPropertyName(operationId), irObject(operationMembers(merged, location, context)), {\n isReadonly: context.options.immutable,\n }),\n );\n return refType(createRef([\"operations\", operationId]));\n}\n\n/** An included operation, the member name it gets and its location below the path item. */\ninterface DeclaredOperation {\n readonly name: string;\n readonly operation: OperationEntry;\n readonly path: string;\n}\n\nfunction operationMember(\n { name, operation, path }: DeclaredOperation,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const type =\n \"$ref\" in operation\n ? refType(operation.$ref)\n : operationType(pathItem, operation, { ...location, path }, context);\n return documentMember(name, type, operation, { isReadonly: context.options.immutable });\n}\n\n/** A method member: the operation, or `?: never` when there is none or it is excluded. */\nfunction methodMember(\n method: PathItemMethod,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const operation = pathItem[method];\n if (!isIncluded(operation, context)) {\n const isReadonly = context.options.immutable;\n return irProperty(toPropertyName(method), irKeyword(\"never\"), { isOptional: true, isReadonly });\n }\n const path = createRef([location.path, method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n}\n\n/**\n * `additionalOperations` (OpenAPI 3.2): the included operations keyed by their exact method name,\n * or null when the path item has none left.\n */\nfunction additionalOperationsMember(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature | null {\n const entries = documentEntries(pathItem.additionalOperations ?? {}, context.options);\n const members = entries\n .filter(([, operation]) => isIncluded(operation, context))\n .map(([method, operation]) => {\n const path = createRef([location.path, ADDITIONAL_OPERATIONS_KEY, method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n });\n return members.length > 0\n ? irProperty(toPropertyName(ADDITIONAL_OPERATIONS_KEY), irObject(members), {\n isReadonly: context.options.immutable,\n })\n : null;\n}\n\n/**\n * A path item (OpenAPI 3.2 §4.8.9): its `parameters`, one member per HTTP method, then `query` and\n * `additionalOperations` when the path item declares them (ADR-020).\n */\nexport function pathItemType(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const parametersLocation = { ...location, path: createRef([location.path, \"parameters\"]) };\n const members: IrMember[] = [\n parametersMember(pathItem.parameters ?? [], parametersLocation, context),\n ...HTTP_METHODS.map((method) => methodMember(method, pathItem, location, context)),\n ];\n if (pathItem[QUERY_METHOD] !== undefined) {\n members.push(methodMember(QUERY_METHOD, pathItem, location, context));\n }\n const additionalOperations = additionalOperationsMember(pathItem, location, context);\n if (additionalOperations) {\n members.push(additionalOperations);\n }\n return irObject(members);\n}\n"],"names":[],"mappings":";;;;;;;;;;AA0BA,MAAM,OAAA,GAAU,IAAA;AAGhB,SAAS,UAAA,CACP,WACA,OAAA,EAC6B;AAC7B,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,QAAA,GACJ,UAAU,SAAA,GACL,OAAA,CAAQ,KAAK,OAAA,CAAQ,SAAA,CAAU,IAAI,CAAA,GACpC,SAAA;AACN,EAAA,OAAO,EAAE,OAAA,CAAQ,OAAA,CAAQ,iBAAA,IAAqB,QAAA,EAAU,UAAA,CAAA;AAC1D;AAMA,SAAS,gBAAA,CACP,QAAA,EACA,SAAA,EACA,OAAA,EACwB;AACxB,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAkC;AAC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ACnC;AACA,EAAA,OAAO,SAAS,OAAO,CAAA;AACzB;;"}
1
+ {"version":3,"file":"path-item.mjs","sources":["../../../../src/application/transform/document/path-item.ts"],"sourcesContent":["import { irKeyword, irObject, irProperty } 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, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type OperationEntry,\n type PathItemMethod,\n type PathItemObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { SchemaLocation } from \"../schema/schema-context.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { operationMembers } from \"./operation.js\";\nimport { mergedParameters } from \"./parameter-entries.js\";\nimport { parametersMember } from \"./parameters.js\";\n\n/** Redocly reads `#` in an operation ID as a pointer, so it is replaced (upstream issue #1542). */\nconst HASH_RE = /#/g;\n\n/** The `operations` key an `operationId` asks for, before a repeated one gets a number. */\nexport function operationKeyOf(operationId: string): string {\n return operationId.replace(HASH_RE, \"/\");\n}\n\n/** Whether the method has an operation, not removed by `--exclude-deprecated`. */\nfunction isIncluded(\n operation: OperationEntry | undefined,\n context: TransformContext,\n): operation is OperationEntry {\n if (!operation) {\n return false;\n }\n const resolved =\n \"$ref\" in operation\n ? (context.refs.resolve(operation.$ref) as OperationObject | undefined)\n : operation;\n return !(context.options.excludeDeprecated && resolved?.deprecated);\n}\n\n/**\n * An operation with an `operationId` goes into the `operations` interface and is referenced from\n * the path item; others are written inline.\n */\nfunction operationType(\n pathItem: PathItemObject,\n operation: OperationObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const merged = { ...operation, parameters: mergedParameters(pathItem, operation, context.refs) };\n if (!operation.operationId) {\n return irObject(operationMembers(merged, location, context));\n }\n const operationId = context.footer.operationKey(operationKeyOf(operation.operationId));\n context.footer.addOperation(() =>\n irProperty(toPropertyName(operationId), irObject(operationMembers(merged, location, context)), {\n isReadonly: context.options.immutable,\n }),\n );\n return refType(appendPointer(ROOT_POINTER, [\"operations\", operationId]));\n}\n\n/** An included operation, the member name it gets and its location below the path item. */\ninterface DeclaredOperation {\n readonly name: string;\n readonly operation: OperationEntry;\n readonly path: string;\n}\n\nfunction operationMember(\n { name, operation, path }: DeclaredOperation,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const type =\n \"$ref\" in operation\n ? refType(operation.$ref)\n : operationType(pathItem, operation, { ...location, path }, context);\n return documentMember(name, type, operation, { isReadonly: context.options.immutable });\n}\n\n/** A method member: the operation, or `?: never` when there is none or it is excluded. */\nfunction methodMember(\n method: PathItemMethod,\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature {\n const operation = pathItem[method];\n if (!isIncluded(operation, context)) {\n const isReadonly = context.options.immutable;\n return irProperty(toPropertyName(method), irKeyword(\"never\"), { isOptional: true, isReadonly });\n }\n const path = appendPointer(location.path, [method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n}\n\n/**\n * `additionalOperations` (OpenAPI 3.2): the included operations keyed by their exact method name,\n * or null when the path item has none left.\n */\nfunction additionalOperationsMember(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrPropertySignature | null {\n const entries = documentEntries(pathItem.additionalOperations ?? {}, context.options);\n const members = entries\n .filter(([, operation]) => isIncluded(operation, context))\n .map(([method, operation]) => {\n const path = appendPointer(location.path, [ADDITIONAL_OPERATIONS_KEY, method]);\n return operationMember({ name: method, operation, path }, pathItem, location, context);\n });\n return members.length > 0\n ? irProperty(toPropertyName(ADDITIONAL_OPERATIONS_KEY), irObject(members), {\n isReadonly: context.options.immutable,\n })\n : null;\n}\n\n/**\n * A path item (OpenAPI 3.2 §4.8.9): its `parameters`, one member per HTTP method, then `query` and\n * `additionalOperations` when the path item declares them (ADR-020).\n */\nexport function pathItemType(\n pathItem: PathItemObject,\n location: SchemaLocation,\n context: TransformContext,\n): IrType {\n const parametersLocation = { ...location, path: appendPointer(location.path, [\"parameters\"]) };\n const members: IrMember[] = [\n parametersMember(pathItem.parameters ?? [], parametersLocation, context),\n ...HTTP_METHODS.map((method) => methodMember(method, pathItem, location, context)),\n ];\n if (pathItem[QUERY_METHOD] !== undefined) {\n members.push(methodMember(QUERY_METHOD, pathItem, location, context));\n }\n const additionalOperations = additionalOperationsMember(pathItem, location, context);\n if (additionalOperations) {\n members.push(additionalOperations);\n }\n return irObject(members);\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAuBA,MAAM,OAAA,GAAU,IAAA;AAGT,SAAS,eAAe,WAAA,EAA6B;AAC1D,EAAA,OAAO,WAAA,CAAY,OAAA,CAAQ,OAAA,EAAS,GAAG,CAAA;AACzC;AAGA,SAAS,UAAA,CACP,WACA,OAAA,EAC6B;AAC7B,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,QAAA,GACJ,UAAU,SAAA,GACL,OAAA,CAAQ,KAAK,OAAA,CAAQ,SAAA,CAAU,IAAI,CAAA,GACpC,SAAA;AACN,EAAA,OAAO,EAAE,OAAA,CAAQ,OAAA,CAAQ,iBAAA,IAAqB,QAAA,EAAU,UAAA,CAAA;AAC1D;AAMA,SAAS,aAAA,CACP,QAAA,EACA,SAAA,EACA,QAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,MAAA,GAAS,EAAE,GAAG,SAAA,EAAW,UAAA,EAAY,iBAAiB,QAAA,EAAU,SAAA,EAAW,OAAA,CAAQ,IAAI,CAAA,EAAE;AAC/F,EAAA,IAAI,CAAC,UAAU,WAAA,EAAa;AAC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,YAAY,CAAC,CAAA,EAAE;AAC7F,EAAA,MAAM,OAAA,GAAsB;AAAA,IAC1B,iBAAiB,QAAA,CAAS,UAAA,IAAc,EAAC,EAAG,oBAAoB,OAAO,CAAA;AAAA,IACvE,GAAG,YAAA,CAAa,GAAA,CAAI,CAAC,MAAA,KAAW,aAAa,MAAA,EAAQ,QAAA,EAAU,QAAA,EAAU,OAAO,CAAC;AAAA,GACnF;AACA,EAAA,IAAI,QAAA,CAAS,YAAY,CAAA,KAAM,MAAA,EAAW;AACxC,IAAA,OAAA,CAAQ,KAAK,YAAA,CAAa,YAAA,EAAc,QAAA,EAAU,QAAA,EAAU,OAAO,CAAC,CAAA;AAAA,EACtE;AACA,EAAA,MAAM,oBAAA,GAAuB,0BAAA,CAA2B,QAAA,EAAU,QAAA,EAAU,OAAO,CAAA;AACnF,EAAA,IAAI,oBAAA,EAAsB;AACxB,IAAA,OAAA,CAAQ,KAAK,oBAAoB,CAAA;AAAA,EACnC;AACA,EAAA,OAAO,SAAS,OAAO,CAAA;AACzB;;"}
@@ -70,6 +70,7 @@ function apiPathsEnumDeclaration(paths) {
70
70
  return enumNaming.enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths), naming);
71
71
  }
72
72
 
73
+ exports.API_PATHS_NAME = API_PATHS_NAME;
73
74
  exports.apiPathsEnum = apiPathsEnum;
74
75
  exports.apiPathsEnumDeclaration = apiPathsEnumDeclaration;
75
76
  //# sourceMappingURL=paths-enum.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths-enum.cjs","sources":["../../../../src/application/transform/document/paths-enum.ts"],"sourcesContent":["import type { IrEnumDeclaration } from \"../../../domain/ir/nodes.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type PathItemMethod,\n type PathsObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { EnumNaming, enumDeclaration } from \"../footer/enum-naming.js\";\nimport { withNumberedRepeats } from \"../numbered-names.js\";\nimport type { EnumMemberMetadata } from \"../schema/schema-context.js\";\n\n/** A path segment that is one parameter: `{user_id}` or `:user_id`. */\nconst PARAMETER_SEGMENT_RE = /^(?:{(.+)}|:(.+))$/;\n/** Characters not allowed in an enum key, or a `{param}` / `:param` part (first match only). */\nconst INVALID_KEY_PART_RE = /{.*}|:.*|[^a-zA-Z\\d_]+/;\nconst API_PATHS_NAME = \"ApiPaths\";\nconst METHODS: ReadonlySet<string> = new Set<PathItemMethod>([...HTTP_METHODS, QUERY_METHOD]);\n\n/** The members of the `ApiPaths` enum (`--make-paths-enum`). */\nexport interface ApiPathsEnum {\n readonly values: readonly string[];\n readonly metadata: readonly EnumMemberMetadata[];\n}\n\n/** `getUsersById` style key from the method and URL, when the operation has no ID. */\nfunction keyFromUrl(method: string, url: string): string {\n return `${method}${url}`\n .split(\"/\")\n .map((part) => {\n const capitalized = part.charAt(0).toUpperCase() + part.slice(1);\n return capitalized.replace(INVALID_KEY_PART_RE, \"\");\n })\n .join(\"\");\n}\n\n/** `user_id` and `order-id` as `UserId` and `OrderId`. */\nfunction parameterWord(name: string): string {\n return name\n .split(/[^a-zA-Z\\d]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\"\");\n}\n\n/** The key with parameters named, `GetUserByUserId`, for keys that collide without them. */\nfunction keyWithParameters(method: string, url: string): string {\n const parts = url.split(\"/\").map((part) => {\n const parameter = PARAMETER_SEGMENT_RE.exec(part);\n const name = parameter?.[1] ?? parameter?.[2];\n return name === undefined ? part : `By${parameterWord(name)}`;\n });\n return keyFromUrl(method, parts.join(\"/\"));\n}\n\ninterface PathOperation {\n readonly url: string;\n readonly method: string;\n readonly operationId: string | undefined;\n}\n\n/**\n * The operations of one path item in document order; `additionalOperations` (OpenAPI 3.2) adds\n * its methods where the key stands.\n */\nfunction pathItemEntries(pathItem: object): [string, unknown][] {\n return Object.entries(pathItem).flatMap(([key, value]): [string, unknown][] => {\n if (key === ADDITIONAL_OPERATIONS_KEY) {\n return typeof value === \"object\" && value !== null ? Object.entries(value) : [];\n }\n return METHODS.has(key) ? [[key, value]] : [];\n });\n}\n\nfunction pathOperations(paths: PathsObject): PathOperation[] {\n return Object.entries(paths).flatMap(([url, pathItem]) =>\n pathItemEntries(pathItem).map(([method, operation]) => {\n const operationId = (operation as OperationObject).operationId || undefined;\n return { url, method, operationId };\n }),\n );\n}\n\nfunction countOf(names: readonly string[]): Map<string, number> {\n const counts = new Map<string, number>();\n for (const name of names) {\n counts.set(name, (counts.get(name) ?? 0) + 1);\n }\n return counts;\n}\n\n/**\n * Names that are unique, so the enum compiles (upstream #2194). A URL key that collides names\n * its parameters; a name that still collides gets 2, 3… after its first use.\n */\nfunction uniqueNames(operations: readonly PathOperation[]): string[] {\n const keys = operations.map((op) => op.operationId ?? keyFromUrl(op.method, op.url));\n const counts = countOf(keys);\n const named = operations.map((op, index) => {\n const isCollidingUrlKey =\n op.operationId === undefined && (counts.get(keys[index] as string) ?? 0) > 1;\n return isCollidingUrlKey ? keyWithParameters(op.method, op.url) : (keys[index] as string);\n });\n return withNumberedRepeats(named, (name, count) => `${name}${count}`);\n}\n\n/**\n * One enum member per operation: the URL as the value, the operation ID (or a key built from the\n * method and URL) as the name. Paths are in document order; `--alphabetize` does not apply.\n */\nexport function apiPathsEnum(paths: PathsObject): ApiPathsEnum {\n const operations = pathOperations(paths);\n const names = uniqueNames(operations);\n return {\n values: operations.map((operation) => operation.url),\n metadata: names.map((name) => ({ name, description: undefined })),\n };\n}\n\n/**\n * The `ApiPaths` enum declaration. Its own naming state is equivalent to the run's: the name is a\n * valid identifier, and member names only reset the state, never read it.\n */\nexport function apiPathsEnumDeclaration(paths: PathsObject): IrEnumDeclaration {\n const naming = new EnumNaming();\n return enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths), naming);\n}\n"],"names":["HTTP_METHODS","QUERY_METHOD","ADDITIONAL_OPERATIONS_KEY","with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AAO,QAAA,CAAS,cAAc,GAAG,YAAA,CAAa,KAAK,GAAG,MAAM,CAAA;AACrF;;;"}
1
+ {"version":3,"file":"paths-enum.cjs","sources":["../../../../src/application/transform/document/paths-enum.ts"],"sourcesContent":["import type { IrEnumDeclaration } from \"../../../domain/ir/nodes.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type PathItemMethod,\n type PathsObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { EnumNaming, enumDeclaration } from \"../footer/enum-naming.js\";\nimport { withNumberedRepeats } from \"../numbered-names.js\";\nimport type { EnumMemberMetadata } from \"../schema/schema-context.js\";\n\n/** A path segment that is one parameter: `{user_id}` or `:user_id`. */\nconst PARAMETER_SEGMENT_RE = /^(?:{(.+)}|:(.+))$/;\n/** Characters not allowed in an enum key, or a `{param}` / `:param` part (first match only). */\nconst INVALID_KEY_PART_RE = /{.*}|:.*|[^a-zA-Z\\d_]+/;\nexport const API_PATHS_NAME = \"ApiPaths\";\nconst METHODS: ReadonlySet<string> = new Set<PathItemMethod>([...HTTP_METHODS, QUERY_METHOD]);\n\n/** The members of the `ApiPaths` enum (`--make-paths-enum`). */\nexport interface ApiPathsEnum {\n readonly values: readonly string[];\n readonly metadata: readonly EnumMemberMetadata[];\n}\n\n/** `getUsersById` style key from the method and URL, when the operation has no ID. */\nfunction keyFromUrl(method: string, url: string): string {\n return `${method}${url}`\n .split(\"/\")\n .map((part) => {\n const capitalized = part.charAt(0).toUpperCase() + part.slice(1);\n return capitalized.replace(INVALID_KEY_PART_RE, \"\");\n })\n .join(\"\");\n}\n\n/** `user_id` and `order-id` as `UserId` and `OrderId`. */\nfunction parameterWord(name: string): string {\n return name\n .split(/[^a-zA-Z\\d]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\"\");\n}\n\n/** The key with parameters named, `GetUserByUserId`, for keys that collide without them. */\nfunction keyWithParameters(method: string, url: string): string {\n const parts = url.split(\"/\").map((part) => {\n const parameter = PARAMETER_SEGMENT_RE.exec(part);\n const name = parameter?.[1] ?? parameter?.[2];\n return name === undefined ? part : `By${parameterWord(name)}`;\n });\n return keyFromUrl(method, parts.join(\"/\"));\n}\n\ninterface PathOperation {\n readonly url: string;\n readonly method: string;\n readonly operationId: string | undefined;\n}\n\n/**\n * The operations of one path item in document order; `additionalOperations` (OpenAPI 3.2) adds\n * its methods where the key stands.\n */\nfunction pathItemEntries(pathItem: object): [string, unknown][] {\n return Object.entries(pathItem).flatMap(([key, value]): [string, unknown][] => {\n if (key === ADDITIONAL_OPERATIONS_KEY) {\n return typeof value === \"object\" && value !== null ? Object.entries(value) : [];\n }\n return METHODS.has(key) ? [[key, value]] : [];\n });\n}\n\nfunction pathOperations(paths: PathsObject): PathOperation[] {\n return Object.entries(paths).flatMap(([url, pathItem]) =>\n pathItemEntries(pathItem).map(([method, operation]) => {\n const operationId = (operation as OperationObject).operationId || undefined;\n return { url, method, operationId };\n }),\n );\n}\n\nfunction countOf(names: readonly string[]): Map<string, number> {\n const counts = new Map<string, number>();\n for (const name of names) {\n counts.set(name, (counts.get(name) ?? 0) + 1);\n }\n return counts;\n}\n\n/**\n * Names that are unique, so the enum compiles (upstream #2194). A URL key that collides names\n * its parameters; a name that still collides gets 2, 3… after its first use.\n */\nfunction uniqueNames(operations: readonly PathOperation[]): string[] {\n const keys = operations.map((op) => op.operationId ?? keyFromUrl(op.method, op.url));\n const counts = countOf(keys);\n const named = operations.map((op, index) => {\n const isCollidingUrlKey =\n op.operationId === undefined && (counts.get(keys[index] as string) ?? 0) > 1;\n return isCollidingUrlKey ? keyWithParameters(op.method, op.url) : (keys[index] as string);\n });\n return withNumberedRepeats(named, (name, count) => `${name}${count}`);\n}\n\n/**\n * One enum member per operation: the URL as the value, the operation ID (or a key built from the\n * method and URL) as the name. Paths are in document order; `--alphabetize` does not apply.\n */\nexport function apiPathsEnum(paths: PathsObject): ApiPathsEnum {\n const operations = pathOperations(paths);\n const names = uniqueNames(operations);\n return {\n values: operations.map((operation) => operation.url),\n metadata: names.map((name) => ({ name, description: undefined })),\n };\n}\n\n/**\n * The `ApiPaths` enum declaration. Its own naming state is equivalent to the run's: the name is a\n * valid identifier, and member names only reset the state, never read it.\n */\nexport function apiPathsEnumDeclaration(paths: PathsObject): IrEnumDeclaration {\n const naming = new EnumNaming();\n return enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths), naming);\n}\n"],"names":["HTTP_METHODS","QUERY_METHOD","ADDITIONAL_OPERATIONS_KEY","withNumberedRepeats","EnumNaming","enumDeclaration"],"mappings":";;;;;;AAcA,MAAM,oBAAA,GAAuB,oBAAA;AAE7B,MAAM,mBAAA,GAAsB,wBAAA;AACrB,MAAM,cAAA,GAAiB;AAC9B,MAAM,0BAA+B,IAAI,GAAA,CAAoB,CAAC,GAAGA,2BAAA,EAAcC,2BAAY,CAAC,CAAA;AAS5F,SAAS,UAAA,CAAW,QAAgB,GAAA,EAAqB;AACvD,EAAA,OAAO,CAAA,EAAG,MAAM,CAAA,EAAG,GAAG,CAAA,CAAA,CACnB,MAAM,GAAG,CAAA,CACT,GAAA,CAAI,CAAC,IAAA,KAAS;AACb,IAAA,MAAM,WAAA,GAAc,KAAK,MAAA,CAAO,CAAC,EAAE,WAAA,EAAY,GAAI,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AAC/D,IAAA,OAAO,WAAA,CAAY,OAAA,CAAQ,mBAAA,EAAqB,EAAE,CAAA;AAAA,EACpD,CAAC,CAAA,CACA,IAAA,CAAK,EAAE,CAAA;AACZ;AAGA,SAAS,cAAc,IAAA,EAAsB;AAC3C,EAAA,OAAO,KACJ,KAAA,CAAM,cAAc,EACpB,GAAA,CAAI,CAAC,SAAS,IAAA,CAAK,MAAA,CAAO,CAAC,CAAA,CAAE,WAAA,KAAgB,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA,CAC1D,KAAK,E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M,KAAA,GAAQ,YAAY,UAAU,CAAA;AACpC,EAAA,OAAO;AAAA,IACL,QAAQ,UAAA,CAAW,GAAA,CAAI,CAAC,SAAA,KAAc,UAAU,GAAG,CAAA;AAAA,IACnD,QAAA,EAAU,MAAM,GAAA,CAAI,CAAC,UAAU,EAAE,IAAA,EAAM,WAAA,EAAa,MAAA,EAAU,CAAE;AAAA,GAClE;AACF;AAMO,SAAS,wBAAwB,KAAA,EAAuC;AAC7E,EAAA,MAAM,MAAA,GAAS,IAAIC,qBAAA,EAAW;AAC9B,EAAA,OAAOC,0BAAA,CAAgB,OAAO,QAAA,CAAS,cAAc,GAAG,YAAA,CAAa,KAAK,GAAG,MAAM,CAAA;AACrF;;;;"}
@@ -68,5 +68,5 @@ function apiPathsEnumDeclaration(paths) {
68
68
  return enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths), naming);
69
69
  }
70
70
 
71
- export { apiPathsEnum, apiPathsEnumDeclaration };
71
+ export { API_PATHS_NAME, apiPathsEnum, apiPathsEnumDeclaration };
72
72
  //# sourceMappingURL=paths-enum.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths-enum.mjs","sources":["../../../../src/application/transform/document/paths-enum.ts"],"sourcesContent":["import type { IrEnumDeclaration } from \"../../../domain/ir/nodes.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type PathItemMethod,\n type PathsObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { EnumNaming, enumDeclaration } from \"../footer/enum-naming.js\";\nimport { withNumberedRepeats } from \"../numbered-names.js\";\nimport type { EnumMemberMetadata } from \"../schema/schema-context.js\";\n\n/** A path segment that is one parameter: `{user_id}` or `:user_id`. */\nconst PARAMETER_SEGMENT_RE = /^(?:{(.+)}|:(.+))$/;\n/** Characters not allowed in an enum key, or a `{param}` / `:param` part (first match only). */\nconst INVALID_KEY_PART_RE = /{.*}|:.*|[^a-zA-Z\\d_]+/;\nconst API_PATHS_NAME = \"ApiPaths\";\nconst METHODS: ReadonlySet<string> = new Set<PathItemMethod>([...HTTP_METHODS, QUERY_METHOD]);\n\n/** The members of the `ApiPaths` enum (`--make-paths-enum`). */\nexport interface ApiPathsEnum {\n readonly values: readonly string[];\n readonly metadata: readonly EnumMemberMetadata[];\n}\n\n/** `getUsersById` style key from the method and URL, when the operation has no ID. */\nfunction keyFromUrl(method: string, url: string): string {\n return `${method}${url}`\n .split(\"/\")\n .map((part) => {\n const capitalized = part.charAt(0).toUpperCase() + part.slice(1);\n return capitalized.replace(INVALID_KEY_PART_RE, \"\");\n })\n .join(\"\");\n}\n\n/** `user_id` and `order-id` as `UserId` and `OrderId`. */\nfunction parameterWord(name: string): string {\n return name\n .split(/[^a-zA-Z\\d]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\"\");\n}\n\n/** The key with parameters named, `GetUserByUserId`, for keys that collide without them. */\nfunction keyWithParameters(method: string, url: string): string {\n const parts = url.split(\"/\").map((part) => {\n const parameter = PARAMETER_SEGMENT_RE.exec(part);\n const name = parameter?.[1] ?? parameter?.[2];\n return name === undefined ? part : `By${parameterWord(name)}`;\n });\n return keyFromUrl(method, parts.join(\"/\"));\n}\n\ninterface PathOperation {\n readonly url: string;\n readonly method: string;\n readonly operationId: string | undefined;\n}\n\n/**\n * The operations of one path item in document order; `additionalOperations` (OpenAPI 3.2) adds\n * its methods where the key stands.\n */\nfunction pathItemEntries(pathItem: object): [string, unknown][] {\n return Object.entries(pathItem).flatMap(([key, value]): [string, unknown][] => {\n if (key === ADDITIONAL_OPERATIONS_KEY) {\n return typeof value === \"object\" && value !== null ? Object.entries(value) : [];\n }\n return METHODS.has(key) ? [[key, value]] : [];\n });\n}\n\nfunction pathOperations(paths: PathsObject): PathOperation[] {\n return Object.entries(paths).flatMap(([url, pathItem]) =>\n pathItemEntries(pathItem).map(([method, operation]) => {\n const operationId = (operation as OperationObject).operationId || undefined;\n return { url, method, operationId };\n }),\n );\n}\n\nfunction countOf(names: readonly string[]): Map<string, number> {\n const counts = new Map<string, number>();\n for (const name of names) {\n counts.set(name, (counts.get(name) ?? 0) + 1);\n }\n return counts;\n}\n\n/**\n * Names that are unique, so the enum compiles (upstream #2194). A URL key that collides names\n * its parameters; a name that still collides gets 2, 3… after its first use.\n */\nfunction uniqueNames(operations: readonly PathOperation[]): string[] {\n const keys = operations.map((op) => op.operationId ?? keyFromUrl(op.method, op.url));\n const counts = countOf(keys);\n const named = operations.map((op, index) => {\n const isCollidingUrlKey =\n op.operationId === undefined && (counts.get(keys[index] as string) ?? 0) > 1;\n return isCollidingUrlKey ? keyWithParameters(op.method, op.url) : (keys[index] as string);\n });\n return withNumberedRepeats(named, (name, count) => `${name}${count}`);\n}\n\n/**\n * One enum member per operation: the URL as the value, the operation ID (or a key built from the\n * method and URL) as the name. Paths are in document order; `--alphabetize` does not apply.\n */\nexport function apiPathsEnum(paths: PathsObject): ApiPathsEnum {\n const operations = pathOperations(paths);\n const names = uniqueNames(operations);\n return {\n values: operations.map((operation) => operation.url),\n metadata: names.map((name) => ({ name, description: undefined })),\n };\n}\n\n/**\n * The `ApiPaths` enum declaration. Its own naming state is equivalent to the run's: the name is a\n * valid identifier, and member names only reset the state, never read it.\n */\nexport function apiPathsEnumDeclaration(paths: PathsObject): IrEnumDeclaration {\n const naming = new EnumNaming();\n return enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths), naming);\n}\n"],"names":[],"mappings":";;;;AAcA,MAAM,oBAAA,GAAuB,oBAAA;AAE7B,MAAM,mBAAA,GAAsB,wBAAA;AAC5B,MAAM,cAAA,GAAiB,UAAA;AACvB,MAAM,0BAA+B,IAAI,GAAA,CAAoB,CAAC,GAAG,YAAA,EAAc,YAAY,CAAC,CAAA;AAS5F,SAAS,UAAA,CAAW,QAAgB,GAAA,EAAqB;AACvD,EAAA,OAAO,CAAA,EAAG,MAAM,CAAA,EAAG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GAAA,CAAI,CAAC,IAAI,KAAA,KAAU;AAC1C,IAAA,MAAM,iBAAA,GACJ,EAAA,CAAG,WAAA,KAAgB,MAAA,IAAA,CAAc,MAAA,CAAO,IAAI,IAAA,CAAK,KAAK,CAAW,CAAA,IAAK,CAAA,IAAK,CAAA;AAC7E,IAAA,OAAO,iBAAA,GAAoB,kBAAkB,EAAA,CAAG,MAAA,EAAQ,GAAG,GAAG,CAAA,GAAK,KAAK,KAAK,CAAA;AAAA,EAC/E,CAAC,CAAA;AACD,EAAA,OAAO,mBAAA,CAAoB,OAAO,CAAC,IAAA,EAAM,UAAU,CAAA,EAAG,IAAI,CAAA,EAAG,KAAK,CAAA,CAAE,CAAA;AACtE;AAMO,SAAS,aAAa,KAAA,EAAkC;AAC7D,EAAA,MAAM,UAAA,GAAa,eAAe,KAAK,CAAA;AACvC,EAAA,MAAM,KAAA,GAAQ,YAAY,UAAU,CAAA;AACpC,EAAA,OAAO;AAAA,IACL,QAAQ,UAAA,CAAW,GAAA,CAAI,CAAC,SAAA,KAAc,UAAU,GAAG,CAAA;AAAA,IACnD,QAAA,EAAU,MAAM,GAAA,CAAI,CAAC,UAAU,EAAE,IAAA,EAAM,WAAA,EAAa,MAAA,EAAU,CAAE;AAAA,GAClE;AACF;AAMO,SAAS,wBAAwB,KAAA,EAAuC;AAC7E,EAAA,MAAM,MAAA,GAAS,IAAI,UAAA,EAAW;AAC9B,EAAA,OAAO,eAAA,CAAgB,OAAO,QAAA,CAAS,cAAc,GAAG,YAAA,CAAa,KAAK,GAAG,MAAM,CAAA;AACrF;;"}
1
+ {"version":3,"file":"paths-enum.mjs","sources":["../../../../src/application/transform/document/paths-enum.ts"],"sourcesContent":["import type { IrEnumDeclaration } from \"../../../domain/ir/nodes.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type PathItemMethod,\n type PathsObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { EnumNaming, enumDeclaration } from \"../footer/enum-naming.js\";\nimport { withNumberedRepeats } from \"../numbered-names.js\";\nimport type { EnumMemberMetadata } from \"../schema/schema-context.js\";\n\n/** A path segment that is one parameter: `{user_id}` or `:user_id`. */\nconst PARAMETER_SEGMENT_RE = /^(?:{(.+)}|:(.+))$/;\n/** Characters not allowed in an enum key, or a `{param}` / `:param` part (first match only). */\nconst INVALID_KEY_PART_RE = /{.*}|:.*|[^a-zA-Z\\d_]+/;\nexport const API_PATHS_NAME = \"ApiPaths\";\nconst METHODS: ReadonlySet<string> = new Set<PathItemMethod>([...HTTP_METHODS, QUERY_METHOD]);\n\n/** The members of the `ApiPaths` enum (`--make-paths-enum`). */\nexport interface ApiPathsEnum {\n readonly values: readonly string[];\n readonly metadata: readonly EnumMemberMetadata[];\n}\n\n/** `getUsersById` style key from the method and URL, when the operation has no ID. */\nfunction keyFromUrl(method: string, url: string): string {\n return `${method}${url}`\n .split(\"/\")\n .map((part) => {\n const capitalized = part.charAt(0).toUpperCase() + part.slice(1);\n return capitalized.replace(INVALID_KEY_PART_RE, \"\");\n })\n .join(\"\");\n}\n\n/** `user_id` and `order-id` as `UserId` and `OrderId`. */\nfunction parameterWord(name: string): string {\n return name\n .split(/[^a-zA-Z\\d]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\"\");\n}\n\n/** The key with parameters named, `GetUserByUserId`, for keys that collide without them. */\nfunction keyWithParameters(method: string, url: string): string {\n const parts = url.split(\"/\").map((part) => {\n const parameter = PARAMETER_SEGMENT_RE.exec(part);\n const name = parameter?.[1] ?? parameter?.[2];\n return name === undefined ? part : `By${parameterWord(name)}`;\n });\n return keyFromUrl(method, parts.join(\"/\"));\n}\n\ninterface PathOperation {\n readonly url: string;\n readonly method: string;\n readonly operationId: string | undefined;\n}\n\n/**\n * The operations of one path item in document order; `additionalOperations` (OpenAPI 3.2) adds\n * its methods where the key stands.\n */\nfunction pathItemEntries(pathItem: object): [string, unknown][] {\n return Object.entries(pathItem).flatMap(([key, value]): [string, unknown][] => {\n if (key === ADDITIONAL_OPERATIONS_KEY) {\n return typeof value === \"object\" && value !== null ? Object.entries(value) : [];\n }\n return METHODS.has(key) ? [[key, value]] : [];\n });\n}\n\nfunction pathOperations(paths: PathsObject): PathOperation[] {\n return Object.entries(paths).flatMap(([url, pathItem]) =>\n pathItemEntries(pathItem).map(([method, operation]) => {\n const operationId = (operation as OperationObject).operationId || undefined;\n return { url, method, operationId };\n }),\n );\n}\n\nfunction countOf(names: readonly string[]): Map<string, number> {\n const counts = new Map<string, number>();\n for (const name of names) {\n counts.set(name, (counts.get(name) ?? 0) + 1);\n }\n return counts;\n}\n\n/**\n * Names that are unique, so the enum compiles (upstream #2194). A URL key that collides names\n * its parameters; a name that still collides gets 2, 3… after its first use.\n */\nfunction uniqueNames(operations: readonly PathOperation[]): string[] {\n const keys = operations.map((op) => op.operationId ?? keyFromUrl(op.method, op.url));\n const counts = countOf(keys);\n const named = operations.map((op, index) => {\n const isCollidingUrlKey =\n op.operationId === undefined && (counts.get(keys[index] as string) ?? 0) > 1;\n return isCollidingUrlKey ? keyWithParameters(op.method, op.url) : (keys[index] as string);\n });\n return withNumberedRepeats(named, (name, count) => `${name}${count}`);\n}\n\n/**\n * One enum member per operation: the URL as the value, the operation ID (or a key built from the\n * method and URL) as the name. Paths are in document order; `--alphabetize` does not apply.\n */\nexport function apiPathsEnum(paths: PathsObject): ApiPathsEnum {\n const operations = pathOperations(paths);\n const names = uniqueNames(operations);\n return {\n values: operations.map((operation) => operation.url),\n metadata: names.map((name) => ({ name, description: undefined })),\n };\n}\n\n/**\n * The `ApiPaths` enum declaration. Its own naming state is equivalent to the run's: the name is a\n * valid identifier, and member names only reset the state, never read it.\n */\nexport function apiPathsEnumDeclaration(paths: PathsObject): IrEnumDeclaration {\n const naming = new EnumNaming();\n return enumDeclaration(naming.enumName(API_PATHS_NAME), apiPathsEnum(paths), naming);\n}\n"],"names":[],"mapp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MAAM,CAAA;AACrF;;"}
@@ -59,7 +59,7 @@ function pathTemplateParts(url, pathItem, context) {
59
59
  const schema = parameters.get(match.slice(1, -1))?.schema;
60
60
  return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };
61
61
  });
62
- return context.options.fixes.has(outputFixes.OutputFix.PATH_PARAM_TYPE_NAMES) ? splitTemplateParts(url, matches) : pathTemplateReplace.replacedTemplateParts(url, matches);
62
+ return context.options.fixes.has(outputFixes.FIX.PATH_PARAM_TYPE_NAMES) ? splitTemplateParts(url, matches) : pathTemplateReplace.replacedTemplateParts(url, matches);
63
63
  }
64
64
  function templateText(parts) {
65
65
  const text = parts.map(
@@ -69,7 +69,11 @@ function templateText(parts) {
69
69
  }
70
70
  function pathItemMember(url, pathItem$1, context) {
71
71
  const isReadonly = context.options.immutable;
72
- const type = pathItem.pathItemType(pathItem$1, { path: jsonPointer.createRef(["paths", url]) }, context);
72
+ const type = pathItem.pathItemType(
73
+ pathItem$1,
74
+ { path: jsonPointer.appendPointer(jsonPointer.ROOT_POINTER, ["paths", url]) },
75
+ context
76
+ );
73
77
  const parts = context.options.pathParamsAsTypes && url.includes("{") ? pathTemplateParts(url, pathItem$1, context) : null;
74
78
  if (parts === null) {
75
79
  const member2 = constructors.irProperty(propertyName.toPropertyName(url), type, { isReadonly });
@@ -1 +1 @@
1
- {"version":3,"file":"paths.cjs","sources":["../../../../src/application/transform/document/paths.ts"],"sourcesContent":["import { irIntersection, irObject, irProperty, irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { escapeTemplateText } from \"../../../domain/ir/raw-text-escapes.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type {\n ParameterObject,\n ParameterOrReference,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport {\n type PathItemObject,\n type PathsObject,\n pathItemOperations,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport type { ReferenceSchema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { OutputFix } from \"../../../domain/output-fixes.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { type DeclaredTypeLookup, NO_DECLARED_TYPES } from \"./declared-types.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport {\n type CoverRejection,\n coveringTemplateKeys,\n type PathKey,\n type PathKeyPart,\n type PathPlaceholder,\n} from \"./path-key-overlaps.js\";\nimport {\n type PathParameterMatch,\n placeholderText,\n replacedTemplateParts,\n} from \"./path-template-replace.js\";\nimport { assignabilityProof } from \"./type-assignability.js\";\n\n/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */\nconst PATH_PARAMETER_RE = /\\{[^{}]+\\}/g;\n\n/** Placeholders by parameter schema type; anything else is a string placeholder. */\nconst PLACEHOLDERS: ReadonlyMap<unknown, PathPlaceholder> = new Map([\n [\"number\", \"number\"],\n [\"integer\", \"number\"],\n [\"boolean\", \"boolean\"],\n]);\nconst STRING_PLACEHOLDER: PathPlaceholder = \"string\";\n\nfunction resolvedParameter(\n parameter: ParameterOrReference,\n context: TransformContext,\n): ParameterObject | undefined {\n return \"$ref\" in parameter && parameter.$ref\n ? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)\n : (parameter as ParameterObject);\n}\n\nfunction addPathParameters(\n parameters: readonly ParameterOrReference[],\n byName: Map<string, ParameterObject>,\n context: TransformContext,\n): void {\n for (const parameter of parameters) {\n const resolved = resolvedParameter(parameter, context);\n if (resolved && resolved.in === \"path\") {\n byName.set(resolved.name, resolved);\n }\n }\n}\n\n/** Path parameters of the path item and of its operations; later definitions win. */\nfunction pathParameters(\n pathItem: PathItemObject,\n context: TransformContext,\n): Map<string, ParameterObject> {\n const byName = new Map<string, ParameterObject>();\n addPathParameters(pathItem.parameters ?? [], byName, context);\n for (const { operation: entry } of pathItemOperations(pathItem)) {\n const operation = (entry as ReferenceSchema).$ref\n ? (context.refs.resolve((entry as ReferenceSchema).$ref) as OperationObject | undefined)\n : (entry as OperationObject);\n addPathParameters(operation?.parameters ?? [], byName, context);\n }\n return byName;\n}\n\n/** Each `{name}` of the URL and its own placeholder, from the URL split at the matches. */\nfunction splitTemplateParts(url: string, matches: readonly PathParameterMatch[]): PathKeyPart[] {\n return url.split(PATH_PARAMETER_RE).flatMap((text, index): PathKeyPart[] => {\n const type = matches[index]?.type;\n const textPart: PathKeyPart = { kind: \"text\", text };\n return type === undefined ? [textPart] : [textPart, { kind: \"placeholder\", type }];\n });\n}\n\n/**\n * `--path-params-as-types`: the URL as template parts, each `{name}` replaced by a placeholder for\n * its parameter's type, the way the original replaces them unless the `path-param-type-names` fix\n * is on (see `replacedTemplateParts`). Null when the URL has no complete `{…}` placeholder.\n */\nfunction pathTemplateParts(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathKeyPart[] | null {\n const found = url.match(PATH_PARAMETER_RE);\n if (!found) {\n return null;\n }\n const parameters = pathParameters(pathItem, context);\n const matches = found.map((match): PathParameterMatch => {\n const schema = parameters.get(match.slice(1, -1))?.schema as SchemaObject | undefined;\n return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };\n });\n return context.options.fixes.has(OutputFix.PATH_PARAM_TYPE_NAMES)\n ? splitTemplateParts(url, matches)\n : replacedTemplateParts(url, matches);\n}\n\n/**\n * The template literal type of the parts. The original escaped only backticks: a backslash or\n * `${` in the URL could end the literal or open a placeholder, and add code to the generated file\n * (intentional fix). So the text parts are escaped.\n */\nfunction templateText(parts: readonly PathKeyPart[]): string {\n const text = parts\n .map((part) =>\n part.kind === \"text\" ? escapeTemplateText(part.text) : placeholderText(part.type),\n )\n .join(\"\");\n return `\\`${text}\\``;\n}\n\n/** A path's member, its key and its path item type for the overlap check. */\nexport interface PathMember {\n readonly url: string;\n readonly member: IrMember;\n readonly key: PathKey;\n readonly type: IrType;\n}\n\nfunction pathItemMember(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathMember {\n const isReadonly = context.options.immutable;\n const type = pathItemType(pathItem, { path: createRef([\"paths\", url]) }, context);\n const parts =\n context.options.pathParamsAsTypes && url.includes(\"{\")\n ? pathTemplateParts(url, pathItem, context)\n : null;\n if (parts === null) {\n const member = irProperty(toPropertyName(url), type, { isReadonly });\n return { url, member, key: literalKey(url), type };\n }\n const member: IrMember = {\n kind: \"indexSignature\",\n parameterName: \"path\",\n parameterType: irRaw(templateText(parts)),\n type,\n isReadonly,\n comments: [],\n };\n return { url, member, key: { kind: \"template\", parts }, type };\n}\n\nfunction literalKey(url: string): PathKey {\n return { kind: \"literal\", url };\n}\n\nconst PATHS_TYPE_NAME = \"paths\";\n\n/** The URL of `paths[\"/apps/{id}\"]`, or null for any other type. */\nfunction pathsIndexOf(type: IrType): string | null {\n if (type.kind !== \"indexedAccess\" || type.index.kind !== \"stringLiteral\") {\n return null;\n }\n const { object } = type;\n const isPaths =\n object.kind === \"reference\" &&\n object.name === PATHS_TYPE_NAME &&\n object.typeArguments.length === 0;\n return isPaths ? type.index.value : null;\n}\n\n/**\n * The lookup, and `paths[\"/apps/{id}\"]` as that path's item. The declarations cannot read it: a\n * templated path is no property of `paths`, and TypeScript finds it through the signature.\n */\nfunction withPathItems(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup,\n): DeclaredTypeLookup {\n const byUrl = new Map(paths.map((path) => [path.url, path.type]));\n return (type) => {\n const url = pathsIndexOf(type);\n return (url === null ? undefined : byUrl.get(url)) ?? lookup(type);\n };\n}\n\n/**\n * The rejection of a covered path item: only one proven not assignable to the signature's type\n * counts (ADR-028). A pair the proof cannot decide keeps the original output, which may well\n * compile (`Record<string, never>` fits `{ [key: string]: unknown }`).\n */\nfunction rejectionOf(paths: readonly PathMember[], lookup: DeclaredTypeLookup): CoverRejection {\n const relate = assignabilityProof(withPathItems(paths, lookup));\n return (coveringIndex, coveredIndex) => {\n const coveringPath = paths[coveringIndex];\n const coveredPath = paths[coveredIndex];\n return (\n coveringPath !== undefined &&\n coveredPath !== undefined &&\n relate(coveredPath.type, coveringPath.type) === \"rejected\"\n );\n };\n}\n\n/**\n * The members as one object type. When an index signature covers another key, TypeScript checks\n * the covered key's type against it. Where that check surely fails (TS2411, TS2413), each such\n * signature gets an object of its own in an intersection: an intersection does not check its parts\n * against each other, and every key has the type it had in the one object. Output that compiles\n * keeps the one object. The lookup reads the types that path items reference; without it, a\n * reference decides nothing.\n */\nexport function pathsObjectType(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup = NO_DECLARED_TYPES,\n): IrType {\n const keys = paths.map(({ key }) => key);\n const covering = coveringTemplateKeys(keys, rejectionOf(paths, lookup));\n if (covering.size === 0) {\n return irObject(paths.map(({ member }) => member));\n }\n const rest = paths.filter((_, index) => !covering.has(index)).map(({ member }) => member);\n const own = paths\n .filter((_, index) => covering.has(index))\n .map(({ member }) => irObject([member]));\n return irIntersection([irObject(rest), ...own]);\n}\n\n/** The members of the `paths` interface (OpenAPI 3.1 §4.8.8): one per path, by URL. */\nexport function pathMembers(paths: PathsObject, context: TransformContext): PathMember[] {\n const members: PathMember[] = [];\n for (const [url, pathItem] of documentEntries(paths, context.options)) {\n if (!pathItem || typeof pathItem !== \"object\") {\n continue;\n }\n if (\"$ref\" in pathItem) {\n const options = { isReadonly: context.options.immutable };\n const member = documentMember(url, refType(pathItem.$ref), pathItem, options);\n members.push({ url, member, key: literalKey(url), type: member.type });\n continue;\n }\n const startedAt = context.diagnostics.now();\n const path = pathItemMember(url, pathItem, context);\n members.push(path);\n // The original reports only paths written as properties.\n if (path.member.kind === \"property\") {\n context.diagnostics.debug(`Transformed path \"${url}\"`, context.diagnostics.now() - startedAt);\n }\n }\n return members;\n}\n\n/**\n * The `paths` interface body, with only the path items' own types for the overlap check. The\n * document transform checks the overlaps again once the referenced types are declared.\n */\nexport function pathsType(paths: PathsObject, context: TransformContext): IrType {\n return pathsObjectType(pathMembers(paths, context));\n}\n"],"names":["pathItemOperations","OutputFix","replacedTemplateParts","escapeTemplateText","placeholderText","pathItem","pathItemType","createRef","member","irProperty","toPropertyName","irRaw","assignabilityProof","NO_DECLARED_TYPES","coveringTemplateKeys","irObject","irIntersection","documentEntries","documentMember","refType"],"mappings":";;;;;;;;;;;;;;;;;AAsCA,MAAM,iBAAA,GAAoB,aAAA;AAG1B,MAAM,YAAA,uBAA0D,GAAA,CAAI;AAAA,EAClE,CAAC,UAAU,QAAQ,CAAA;AAAA,EACnB,CAAC,WAAW,QAAQ,CAAA;AAAA,EACpB,CAAC,WAAW,SAAS;AACvB,CAAC,CAAA;AACD,MAAM,kBAAA,GAAsC,QAAA;AAE5C,SAAS,iBAAA,CACP,WACA,OAAA,EAC6B;AAC7B,EAAA,OAAO,MAAA,IAAU,aAAa,SAAA,CAAU,IAAA,GACnC,QAAQ,IAAA,CAAK,OAAA,CAAQ,SAAA,CAAU,IAAI,CAAA,GACnC,SAAA;AACP;AAEA,SAAS,iBAAA,CACP,UAAA,EACA,MAAA,EACA,OAAA,EACM;AACN,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,MAAM,QAAA,GAAW,iBAAA,CAAkB,SAAA,EAAW,OAAO,CAAA;AACrD,IAAA,IAAI,QAAA,IAAY,QAAA,CAAS,EAAA,KAAO,MAAA,EAAQ;AACtC,MAAA,MAAA,CAAO,GAAA,CAAI,QAAA,CAAS,IAAA,EAAM,QAAQ,CAAA;AAAA,IACpC;AAAA,EACF;AACF;AAGA,SAAS,cAAA,CACP,UACA,OAAA,EAC8B;AAC9B,EAAA,MAAM,MAAA,uBAAa,GAAA,EAA6B;AAChD,EAAA,iBAAA,CAAkB,QAAA,CAAS,UAAA,IAAc,EAAC,EAAG,QAAQ,OAAO,CAAA;AAC5D,EAAA,KAAA,MAAW,EAAE,SAAA,E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O,OAAA;AACT;AAMO,SAAS,SAAA,CAAU,OAAoB,OAAA,EAAmC;AAC/E,EAAA,OAAO,eAAA,CAAgB,WAAA,CAAY,KAAA,EAAO,OAAO,CAAC,CAAA;AACpD;;;;"}
1
+ {"version":3,"file":"paths.cjs","sources":["../../../../src/application/transform/document/paths.ts"],"sourcesContent":["import { irIntersection, irObject, irProperty, irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { escapeTemplateText } from \"../../../domain/ir/raw-text-escapes.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type {\n ParameterObject,\n ParameterOrReference,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport {\n type PathItemObject,\n type PathsObject,\n pathItemOperations,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport type { ReferenceSchema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { type DeclaredTypeLookup, NO_DECLARED_TYPES } from \"./declared-types.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport {\n type CoverRejection,\n coveringTemplateKeys,\n type PathKey,\n type PathKeyPart,\n type PathPlaceholder,\n} from \"./path-key-overlaps.js\";\nimport {\n type PathParameterMatch,\n placeholderText,\n replacedTemplateParts,\n} from \"./path-template-replace.js\";\nimport { assignabilityProof } from \"./type-assignability.js\";\n\n/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */\nconst PATH_PARAMETER_RE = /\\{[^{}]+\\}/g;\n\n/** Placeholders by parameter schema type; anything else is a string placeholder. */\nconst PLACEHOLDERS: ReadonlyMap<unknown, PathPlaceholder> = new Map([\n [\"number\", \"number\"],\n [\"integer\", \"number\"],\n [\"boolean\", \"boolean\"],\n]);\nconst STRING_PLACEHOLDER: PathPlaceholder = \"string\";\n\nfunction resolvedParameter(\n parameter: ParameterOrReference,\n context: TransformContext,\n): ParameterObject | undefined {\n return \"$ref\" in parameter && parameter.$ref\n ? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)\n : (parameter as ParameterObject);\n}\n\nfunction addPathParameters(\n parameters: readonly ParameterOrReference[],\n byName: Map<string, ParameterObject>,\n context: TransformContext,\n): void {\n for (const parameter of parameters) {\n const resolved = resolvedParameter(parameter, context);\n if (resolved && resolved.in === \"path\") {\n byName.set(resolved.name, resolved);\n }\n }\n}\n\n/** Path parameters of the path item and of its operations; later definitions win. */\nfunction pathParameters(\n pathItem: PathItemObject,\n context: TransformContext,\n): Map<string, ParameterObject> {\n const byName = new Map<string, ParameterObject>();\n addPathParameters(pathItem.parameters ?? [], byName, context);\n for (const { operation: entry } of pathItemOperations(pathItem)) {\n const operation = (entry as ReferenceSchema).$ref\n ? (context.refs.resolve((entry as ReferenceSchema).$ref) as OperationObject | undefined)\n : (entry as OperationObject);\n addPathParameters(operation?.parameters ?? [], byName, context);\n }\n return byName;\n}\n\n/** Each `{name}` of the URL and its own placeholder, from the URL split at the matches. */\nfunction splitTemplateParts(url: string, matches: readonly PathParameterMatch[]): PathKeyPart[] {\n return url.split(PATH_PARAMETER_RE).flatMap((text, index): PathKeyPart[] => {\n const type = matches[index]?.type;\n const textPart: PathKeyPart = { kind: \"text\", text };\n return type === undefined ? [textPart] : [textPart, { kind: \"placeholder\", type }];\n });\n}\n\n/**\n * `--path-params-as-types`: the URL as template parts, each `{name}` replaced by a placeholder for\n * its parameter's type, the way the original replaces them unless the `path-param-type-names` fix\n * is on (see `replacedTemplateParts`). Null when the URL has no complete `{…}` placeholder.\n */\nfunction pathTemplateParts(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathKeyPart[] | null {\n const found = url.match(PATH_PARAMETER_RE);\n if (!found) {\n return null;\n }\n const parameters = pathParameters(pathItem, context);\n const matches = found.map((match): PathParameterMatch => {\n const schema = parameters.get(match.slice(1, -1))?.schema as SchemaObject | undefined;\n return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };\n });\n return context.options.fixes.has(FIX.PATH_PARAM_TYPE_NAMES)\n ? splitTemplateParts(url, matches)\n : replacedTemplateParts(url, matches);\n}\n\n/**\n * The template literal type of the parts. The original escaped only backticks: a backslash or\n * `${` in the URL could end the literal or open a placeholder, and add code to the generated file\n * (intentional fix). So the text parts are escaped.\n */\nfunction templateText(parts: readonly PathKeyPart[]): string {\n const text = parts\n .map((part) =>\n part.kind === \"text\" ? escapeTemplateText(part.text) : placeholderText(part.type),\n )\n .join(\"\");\n return `\\`${text}\\``;\n}\n\n/** A path's member, its key and its path item type for the overlap check. */\nexport interface PathMember {\n readonly url: string;\n readonly member: IrMember;\n readonly key: PathKey;\n readonly type: IrType;\n}\n\nfunction pathItemMember(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathMember {\n const isReadonly = context.options.immutable;\n const type = pathItemType(\n pathItem,\n { path: appendPointer(ROOT_POINTER, [\"paths\", url]) },\n context,\n );\n const parts =\n context.options.pathParamsAsTypes && url.includes(\"{\")\n ? pathTemplateParts(url, pathItem, context)\n : null;\n if (parts === null) {\n const member = irProperty(toPropertyName(url), type, { isReadonly });\n return { url, member, key: literalKey(url), type };\n }\n const member: IrMember = {\n kind: \"indexSignature\",\n parameterName: \"path\",\n parameterType: irRaw(templateText(parts)),\n type,\n isReadonly,\n comments: [],\n };\n return { url, member, key: { kind: \"template\", parts }, type };\n}\n\nfunction literalKey(url: string): PathKey {\n return { kind: \"literal\", url };\n}\n\nconst PATHS_TYPE_NAME = \"paths\";\n\n/** The URL of `paths[\"/apps/{id}\"]`, or null for any other type. */\nfunction pathsIndexOf(type: IrType): string | null {\n if (type.kind !== \"indexedAccess\" || type.index.kind !== \"stringLiteral\") {\n return null;\n }\n const { object } = type;\n const isPaths =\n object.kind === \"reference\" &&\n object.name === PATHS_TYPE_NAME &&\n object.typeArguments.length === 0;\n return isPaths ? type.index.value : null;\n}\n\n/**\n * The lookup, and `paths[\"/apps/{id}\"]` as that path's item. The declarations cannot read it: a\n * templated path is no property of `paths`, and TypeScript finds it through the signature.\n */\nfunction withPathItems(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup,\n): DeclaredTypeLookup {\n const byUrl = new Map(paths.map((path) => [path.url, path.type]));\n return (type) => {\n const url = pathsIndexOf(type);\n return (url === null ? undefined : byUrl.get(url)) ?? lookup(type);\n };\n}\n\n/**\n * The rejection of a covered path item: only one proven not assignable to the signature's type\n * counts (ADR-028). A pair the proof cannot decide keeps the original output, which may well\n * compile (`Record<string, never>` fits `{ [key: string]: unknown }`).\n */\nfunction rejectionOf(paths: readonly PathMember[], lookup: DeclaredTypeLookup): CoverRejection {\n const relate = assignabilityProof(withPathItems(paths, lookup));\n return (coveringIndex, coveredIndex) => {\n const coveringPath = paths[coveringIndex];\n const coveredPath = paths[coveredIndex];\n return (\n coveringPath !== undefined &&\n coveredPath !== undefined &&\n relate(coveredPath.type, coveringPath.type) === \"rejected\"\n );\n };\n}\n\n/**\n * The members as one object type. When an index signature covers another key, TypeScript checks\n * the covered key's type against it. Where that check surely fails (TS2411, TS2413), each such\n * signature gets an object of its own in an intersection: an intersection does not check its parts\n * against each other, and every key has the type it had in the one object. Output that compiles\n * keeps the one object. The lookup reads the types that path items reference; without it, a\n * reference decides nothing.\n */\nexport function pathsObjectType(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup = NO_DECLARED_TYPES,\n): IrType {\n const keys = paths.map(({ key }) => key);\n const covering = coveringTemplateKeys(keys, rejectionOf(paths, lookup));\n if (covering.size === 0) {\n return irObject(paths.map(({ member }) => member));\n }\n const rest = paths.filter((_, index) => !covering.has(index)).map(({ member }) => member);\n const own = paths\n .filter((_, index) => covering.has(index))\n .map(({ member }) => irObject([member]));\n return irIntersection([irObject(rest), ...own]);\n}\n\n/** The members of the `paths` interface (OpenAPI 3.1 §4.8.8): one per path, by URL. */\nexport function pathMembers(paths: PathsObject, context: TransformContext): PathMember[] {\n const members: PathMember[] = [];\n for (const [url, pathItem] of documentEntries(paths, context.options)) {\n if (!pathItem || typeof pathItem !== \"object\") {\n continue;\n }\n if (\"$ref\" in pathItem) {\n const options = { isReadonly: context.options.immutable };\n const member = documentMember(url, refType(pathItem.$ref), pathItem, options);\n members.push({ url, member, key: literalKey(url), type: member.type });\n continue;\n }\n const startedAt = context.diagnostics.now();\n const path = pathItemMember(url, pathItem, context);\n members.push(path);\n // The original reports only paths written as properties.\n if (path.member.kind === \"property\") {\n context.diagnostics.debug(`Transformed path \"${url}\"`, context.diagnostics.now() - startedAt);\n }\n }\n return members;\n}\n\n/**\n * The `paths` interface body, with only the path items' own types for the overlap check. The\n * document transform checks the overlaps again once the referenced types are declared.\n */\nexport function pathsType(paths: PathsObject, context: TransformContext): IrType {\n return pathsObjectType(pathMembers(paths, context));\n}\n"],"names":["pathItemOperations","FIX","replacedTemplateParts","escapeTemplateText","placeholderText","pathItem","pathItemType","appendPointer","ROOT_POINTER","member","irProperty","toPropertyName","irRaw","assignabilityProof","NO_DECLARED_TYPES","coveringTemplateKeys","irObject","irIntersection","documentEntries","documentMember","refType"],"mappings":";;;;;;;;;;;;;;;;;AAsCA,MAAM,iBAAA,GAAoB,aAAA;AAG1B,MAAM,YAAA,uBAA0D,GAAA,CAAI;AAAA,EAClE,CAAC,UAAU,QAAQ,CAAA;AAAA,EACnB,CAAC,WAAW,QAAQ,CAAA;AAAA,EACpB,CAAC,WAAW,SAAS;AACvB,CAAC,CAAA;AACD,MAAM,kBAAA,GAAsC,QAAA;AAE5C,SAAS,iBAAA,CACP,WACA,OAAA,EAC6B;AAC7B,EAAA,OAAO,MAAA,IAAU,aAAa,SAAA,CAAU,IAAA,GACnC,QAAQ,IAAA,CAAK,OAAA,CAAQ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;AAC5E,MAAA,OAAA,CAAQ,IAAA,CAAK,EAAE,GAAA,EAAK,MAAA,EAAQ,GAAA,EAAK,UAAA,CAAW,GAAG,CAAA,EAAG,IAAA,EAAM,MAAA,CAAO,IAAA,EAAM,CAAA;AACrE,MAAA;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,OAAA,CAAQ,WAAA,CAAY,GAAA,EAAI;AAC1C,IAAA,MAAM,IAAA,GAAO,cAAA,CAAe,GAAA,EAAK,QAAA,EAAU,OAAO,CAAA;AAClD,IAAA,OAAA,CAAQ,KAAK,IAAI,CAAA;AAEjB,IAAA,IAAI,IAAA,CAAK,MAAA,CAAO,IAAA,KAAS,UAAA,EAAY;AACnC,MAAA,OAAA,CAAQ,WAAA,CAAY,MAAM,CAAA,kBAAA,EAAqB,GAAG,KAAK,OAAA,CAAQ,WAAA,CAAY,GAAA,EAAI,GAAI,SAAS,CAAA;AAAA,IAC9F;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAMO,SAAS,SAAA,CAAU,OAAoB,OAAA,EAAmC;AAC/E,EAAA,OAAO,eAAA,CAAgB,WAAA,CAAY,KAAA,EAAO,OAAO,CAAC,CAAA;AACpD;;;;"}
@@ -1,9 +1,9 @@
1
1
  import { irObject, irIntersection, irProperty, irRaw } from '../../../domain/ir/constructors.mjs';
2
2
  import { toPropertyName } from '../../../domain/ir/property-name.mjs';
3
3
  import { escapeTemplateText } from '../../../domain/ir/raw-text-escapes.mjs';
4
- import { createRef } from '../../../domain/openapi/json-pointer.mjs';
4
+ import { appendPointer, ROOT_POINTER } from '../../../domain/openapi/json-pointer.mjs';
5
5
  import { pathItemOperations } from '../../../domain/openapi/path-item-object.mjs';
6
- import { OutputFix } from '../../../domain/output-fixes.mjs';
6
+ import { FIX } from '../../../domain/output-fixes.mjs';
7
7
  import { documentEntries } from '../document-entries.mjs';
8
8
  import { refType } from '../ref-type.mjs';
9
9
  import { NO_DECLARED_TYPES } from './declared-types.mjs';
@@ -57,7 +57,7 @@ function pathTemplateParts(url, pathItem, context) {
57
57
  const schema = parameters.get(match.slice(1, -1))?.schema;
58
58
  return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };
59
59
  });
60
- return context.options.fixes.has(OutputFix.PATH_PARAM_TYPE_NAMES) ? splitTemplateParts(url, matches) : replacedTemplateParts(url, matches);
60
+ return context.options.fixes.has(FIX.PATH_PARAM_TYPE_NAMES) ? splitTemplateParts(url, matches) : replacedTemplateParts(url, matches);
61
61
  }
62
62
  function templateText(parts) {
63
63
  const text = parts.map(
@@ -67,7 +67,11 @@ function templateText(parts) {
67
67
  }
68
68
  function pathItemMember(url, pathItem, context) {
69
69
  const isReadonly = context.options.immutable;
70
- const type = pathItemType(pathItem, { path: createRef(["paths", url]) }, context);
70
+ const type = pathItemType(
71
+ pathItem,
72
+ { path: appendPointer(ROOT_POINTER, ["paths", url]) },
73
+ context
74
+ );
71
75
  const parts = context.options.pathParamsAsTypes && url.includes("{") ? pathTemplateParts(url, pathItem, context) : null;
72
76
  if (parts === null) {
73
77
  const member2 = irProperty(toPropertyName(url), type, { isReadonly });
@@ -1 +1 @@
1
- {"version":3,"file":"paths.mjs","sources":["../../../../src/application/transform/document/paths.ts"],"sourcesContent":["import { irIntersection, irObject, irProperty, irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { escapeTemplateText } from \"../../../domain/ir/raw-text-escapes.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type {\n ParameterObject,\n ParameterOrReference,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport {\n type PathItemObject,\n type PathsObject,\n pathItemOperations,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport type { ReferenceSchema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { OutputFix } from \"../../../domain/output-fixes.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { type DeclaredTypeLookup, NO_DECLARED_TYPES } from \"./declared-types.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport {\n type CoverRejection,\n coveringTemplateKeys,\n type PathKey,\n type PathKeyPart,\n type PathPlaceholder,\n} from \"./path-key-overlaps.js\";\nimport {\n type PathParameterMatch,\n placeholderText,\n replacedTemplateParts,\n} from \"./path-template-replace.js\";\nimport { assignabilityProof } from \"./type-assignability.js\";\n\n/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */\nconst PATH_PARAMETER_RE = /\\{[^{}]+\\}/g;\n\n/** Placeholders by parameter schema type; anything else is a string placeholder. */\nconst PLACEHOLDERS: ReadonlyMap<unknown, PathPlaceholder> = new Map([\n [\"number\", \"number\"],\n [\"integer\", \"number\"],\n [\"boolean\", \"boolean\"],\n]);\nconst STRING_PLACEHOLDER: PathPlaceholder = \"string\";\n\nfunction resolvedParameter(\n parameter: ParameterOrReference,\n context: TransformContext,\n): ParameterObject | undefined {\n return \"$ref\" in parameter && parameter.$ref\n ? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)\n : (parameter as ParameterObject);\n}\n\nfunction addPathParameters(\n parameters: readonly ParameterOrReference[],\n byName: Map<string, ParameterObject>,\n context: TransformContext,\n): void {\n for (const parameter of parameters) {\n const resolved = resolvedParameter(parameter, context);\n if (resolved && resolved.in === \"path\") {\n byName.set(resolved.name, resolved);\n }\n }\n}\n\n/** Path parameters of the path item and of its operations; later definitions win. */\nfunction pathParameters(\n pathItem: PathItemObject,\n context: TransformContext,\n): Map<string, ParameterObject> {\n const byName = new Map<string, ParameterObject>();\n addPathParameters(pathItem.parameters ?? [], byName, context);\n for (const { operation: entry } of pathItemOperations(pathItem)) {\n const operation = (entry as ReferenceSchema).$ref\n ? (context.refs.resolve((entry as ReferenceSchema).$ref) as OperationObject | undefined)\n : (entry as OperationObject);\n addPathParameters(operation?.parameters ?? [], byName, context);\n }\n return byName;\n}\n\n/** Each `{name}` of the URL and its own placeholder, from the URL split at the matches. */\nfunction splitTemplateParts(url: string, matches: readonly PathParameterMatch[]): PathKeyPart[] {\n return url.split(PATH_PARAMETER_RE).flatMap((text, index): PathKeyPart[] => {\n const type = matches[index]?.type;\n const textPart: PathKeyPart = { kind: \"text\", text };\n return type === undefined ? [textPart] : [textPart, { kind: \"placeholder\", type }];\n });\n}\n\n/**\n * `--path-params-as-types`: the URL as template parts, each `{name}` replaced by a placeholder for\n * its parameter's type, the way the original replaces them unless the `path-param-type-names` fix\n * is on (see `replacedTemplateParts`). Null when the URL has no complete `{…}` placeholder.\n */\nfunction pathTemplateParts(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathKeyPart[] | null {\n const found = url.match(PATH_PARAMETER_RE);\n if (!found) {\n return null;\n }\n const parameters = pathParameters(pathItem, context);\n const matches = found.map((match): PathParameterMatch => {\n const schema = parameters.get(match.slice(1, -1))?.schema as SchemaObject | undefined;\n return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };\n });\n return context.options.fixes.has(OutputFix.PATH_PARAM_TYPE_NAMES)\n ? splitTemplateParts(url, matches)\n : replacedTemplateParts(url, matches);\n}\n\n/**\n * The template literal type of the parts. The original escaped only backticks: a backslash or\n * `${` in the URL could end the literal or open a placeholder, and add code to the generated file\n * (intentional fix). So the text parts are escaped.\n */\nfunction templateText(parts: readonly PathKeyPart[]): string {\n const text = parts\n .map((part) =>\n part.kind === \"text\" ? escapeTemplateText(part.text) : placeholderText(part.type),\n )\n .join(\"\");\n return `\\`${text}\\``;\n}\n\n/** A path's member, its key and its path item type for the overlap check. */\nexport interface PathMember {\n readonly url: string;\n readonly member: IrMember;\n readonly key: PathKey;\n readonly type: IrType;\n}\n\nfunction pathItemMember(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathMember {\n const isReadonly = context.options.immutable;\n const type = pathItemType(pathItem, { path: createRef([\"paths\", url]) }, context);\n const parts =\n context.options.pathParamsAsTypes && url.includes(\"{\")\n ? pathTemplateParts(url, pathItem, context)\n : null;\n if (parts === null) {\n const member = irProperty(toPropertyName(url), type, { isReadonly });\n return { url, member, key: literalKey(url), type };\n }\n const member: IrMember = {\n kind: \"indexSignature\",\n parameterName: \"path\",\n parameterType: irRaw(templateText(parts)),\n type,\n isReadonly,\n comments: [],\n };\n return { url, member, key: { kind: \"template\", parts }, type };\n}\n\nfunction literalKey(url: string): PathKey {\n return { kind: \"literal\", url };\n}\n\nconst PATHS_TYPE_NAME = \"paths\";\n\n/** The URL of `paths[\"/apps/{id}\"]`, or null for any other type. */\nfunction pathsIndexOf(type: IrType): string | null {\n if (type.kind !== \"indexedAccess\" || type.index.kind !== \"stringLiteral\") {\n return null;\n }\n const { object } = type;\n const isPaths =\n object.kind === \"reference\" &&\n object.name === PATHS_TYPE_NAME &&\n object.typeArguments.length === 0;\n return isPaths ? type.index.value : null;\n}\n\n/**\n * The lookup, and `paths[\"/apps/{id}\"]` as that path's item. The declarations cannot read it: a\n * templated path is no property of `paths`, and TypeScript finds it through the signature.\n */\nfunction withPathItems(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup,\n): DeclaredTypeLookup {\n const byUrl = new Map(paths.map((path) => [path.url, path.type]));\n return (type) => {\n const url = pathsIndexOf(type);\n return (url === null ? undefined : byUrl.get(url)) ?? lookup(type);\n };\n}\n\n/**\n * The rejection of a covered path item: only one proven not assignable to the signature's type\n * counts (ADR-028). A pair the proof cannot decide keeps the original output, which may well\n * compile (`Record<string, never>` fits `{ [key: string]: unknown }`).\n */\nfunction rejectionOf(paths: readonly PathMember[], lookup: DeclaredTypeLookup): CoverRejection {\n const relate = assignabilityProof(withPathItems(paths, lookup));\n return (coveringIndex, coveredIndex) => {\n const coveringPath = paths[coveringIndex];\n const coveredPath = paths[coveredIndex];\n return (\n coveringPath !== undefined &&\n coveredPath !== undefined &&\n relate(coveredPath.type, coveringPath.type) === \"rejected\"\n );\n };\n}\n\n/**\n * The members as one object type. When an index signature covers another key, TypeScript checks\n * the covered key's type against it. Where that check surely fails (TS2411, TS2413), each such\n * signature gets an object of its own in an intersection: an intersection does not check its parts\n * against each other, and every key has the type it had in the one object. Output that compiles\n * keeps the one object. The lookup reads the types that path items reference; without it, a\n * reference decides nothing.\n */\nexport function pathsObjectType(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup = NO_DECLARED_TYPES,\n): IrType {\n const keys = paths.map(({ key }) => key);\n const covering = coveringTemplateKeys(keys, rejectionOf(paths, lookup));\n if (covering.size === 0) {\n return irObject(paths.map(({ member }) => member));\n }\n const rest = paths.filter((_, index) => !covering.has(index)).map(({ member }) => member);\n const own = paths\n .filter((_, index) => covering.has(index))\n .map(({ member }) => irObject([member]));\n return irIntersection([irObject(rest), ...own]);\n}\n\n/** The members of the `paths` interface (OpenAPI 3.1 §4.8.8): one per path, by URL. */\nexport function pathMembers(paths: PathsObject, context: TransformContext): PathMember[] {\n const members: PathMember[] = [];\n for (const [url, pathItem] of documentEntries(paths, context.options)) {\n if (!pathItem || typeof pathItem !== \"object\") {\n continue;\n }\n if (\"$ref\" in pathItem) {\n const options = { isReadonly: context.options.immutable };\n const member = documentMember(url, refType(pathItem.$ref), pathItem, options);\n members.push({ url, member, key: literalKey(url), type: member.type });\n continue;\n }\n const startedAt = context.diagnostics.now();\n const path = pathItemMember(url, pathItem, context);\n members.push(path);\n // The original reports only paths written as properties.\n if (path.member.kind === \"property\") {\n context.diagnostics.debug(`Transformed path \"${url}\"`, context.diagnostics.now() - startedAt);\n }\n }\n return members;\n}\n\n/**\n * The `paths` interface body, with only the path items' own types for the overlap check. The\n * document transform checks the overlaps again once the referenced types are declared.\n */\nexport function pathsType(paths: PathsObject, context: TransformContext): IrType {\n return pathsObjectType(pathMembers(paths, context));\n}\n"],"names":["member"],"mappings":";;;;;;;;;;;;;;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;AACrE,IAAA,IAAI,CAAC,QAAA,IAAY,OAAO,QAAA,KAAa,QAAA,EAAU;AAC7C,MAAA;AAAA,IACF;AACA,IAAA,IAAI,UAAU,QAAA,EAAU;AACtB,MAAA,MAAM,OAAA,GAAU,EAAE,UAAA,EAAY,OAAA,CAAQ,QAAQ,SAAA,EAAU;AACxD,MAAA,MAAM,MAAA,GAAS,eAAe,GAAA,EAAK,OAAA,CAAQ,SAAS,IAAI,CAAA,EAAG,UAAU,OAAO,CAAA;AAC5E,MAAA,OAAA,CAAQ,IAAA,CAAK,EAAE,GAAA,EAAK,MAAA,EAAQ,GAAA,EAAK,UAAA,CAAW,GAAG,CAAA,EAAG,IAAA,EAAM,MAAA,CAAO,IAAA,EAAM,CAAA;AACrE,MAAA;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,OAAA,CAAQ,WAAA,CAAY,GAAA,EAAI;AAC1C,IAAA,MAAM,IAAA,GAAO,cAAA,CAAe,GAAA,EAAK,QAAA,EAAU,OAAO,CAAA;AAClD,IAAA,OAAA,CAAQ,KAAK,IAAI,CAAA;AAEjB,IAAA,IAAI,IAAA,CAAK,MAAA,CAAO,IAAA,KAAS,UAAA,EAAY;AACnC,MAAA,OAAA,CAAQ,WAAA,CAAY,MAAM,CAAA,kBAAA,EAAqB,GAAG,KAAK,OAAA,CAAQ,WAAA,CAAY,GAAA,EAAI,GAAI,SAAS,CAAA;AAAA,IAC9F;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAMO,SAAS,SAAA,CAAU,OAAoB,OAAA,EAAmC;AAC/E,EAAA,OAAO,eAAA,CAAgB,WAAA,CAAY,KAAA,EAAO,OAAO,CAAC,CAAA;AACpD;;"}
1
+ {"version":3,"file":"paths.mjs","sources":["../../../../src/application/transform/document/paths.ts"],"sourcesContent":["import { irIntersection, irObject, irProperty, irRaw } from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { escapeTemplateText } from \"../../../domain/ir/raw-text-escapes.js\";\nimport { appendPointer, ROOT_POINTER } from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport type {\n ParameterObject,\n ParameterOrReference,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport {\n type PathItemObject,\n type PathsObject,\n pathItemOperations,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport type { ReferenceSchema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { refType } from \"../ref-type.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { type DeclaredTypeLookup, NO_DECLARED_TYPES } from \"./declared-types.js\";\nimport { documentMember } from \"./document-member.js\";\nimport { pathItemType } from \"./path-item.js\";\nimport {\n type CoverRejection,\n coveringTemplateKeys,\n type PathKey,\n type PathKeyPart,\n type PathPlaceholder,\n} from \"./path-key-overlaps.js\";\nimport {\n type PathParameterMatch,\n placeholderText,\n replacedTemplateParts,\n} from \"./path-template-replace.js\";\nimport { assignabilityProof } from \"./type-assignability.js\";\n\n/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */\nconst PATH_PARAMETER_RE = /\\{[^{}]+\\}/g;\n\n/** Placeholders by parameter schema type; anything else is a string placeholder. */\nconst PLACEHOLDERS: ReadonlyMap<unknown, PathPlaceholder> = new Map([\n [\"number\", \"number\"],\n [\"integer\", \"number\"],\n [\"boolean\", \"boolean\"],\n]);\nconst STRING_PLACEHOLDER: PathPlaceholder = \"string\";\n\nfunction resolvedParameter(\n parameter: ParameterOrReference,\n context: TransformContext,\n): ParameterObject | undefined {\n return \"$ref\" in parameter && parameter.$ref\n ? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)\n : (parameter as ParameterObject);\n}\n\nfunction addPathParameters(\n parameters: readonly ParameterOrReference[],\n byName: Map<string, ParameterObject>,\n context: TransformContext,\n): void {\n for (const parameter of parameters) {\n const resolved = resolvedParameter(parameter, context);\n if (resolved && resolved.in === \"path\") {\n byName.set(resolved.name, resolved);\n }\n }\n}\n\n/** Path parameters of the path item and of its operations; later definitions win. */\nfunction pathParameters(\n pathItem: PathItemObject,\n context: TransformContext,\n): Map<string, ParameterObject> {\n const byName = new Map<string, ParameterObject>();\n addPathParameters(pathItem.parameters ?? [], byName, context);\n for (const { operation: entry } of pathItemOperations(pathItem)) {\n const operation = (entry as ReferenceSchema).$ref\n ? (context.refs.resolve((entry as ReferenceSchema).$ref) as OperationObject | undefined)\n : (entry as OperationObject);\n addPathParameters(operation?.parameters ?? [], byName, context);\n }\n return byName;\n}\n\n/** Each `{name}` of the URL and its own placeholder, from the URL split at the matches. */\nfunction splitTemplateParts(url: string, matches: readonly PathParameterMatch[]): PathKeyPart[] {\n return url.split(PATH_PARAMETER_RE).flatMap((text, index): PathKeyPart[] => {\n const type = matches[index]?.type;\n const textPart: PathKeyPart = { kind: \"text\", text };\n return type === undefined ? [textPart] : [textPart, { kind: \"placeholder\", type }];\n });\n}\n\n/**\n * `--path-params-as-types`: the URL as template parts, each `{name}` replaced by a placeholder for\n * its parameter's type, the way the original replaces them unless the `path-param-type-names` fix\n * is on (see `replacedTemplateParts`). Null when the URL has no complete `{…}` placeholder.\n */\nfunction pathTemplateParts(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathKeyPart[] | null {\n const found = url.match(PATH_PARAMETER_RE);\n if (!found) {\n return null;\n }\n const parameters = pathParameters(pathItem, context);\n const matches = found.map((match): PathParameterMatch => {\n const schema = parameters.get(match.slice(1, -1))?.schema as SchemaObject | undefined;\n return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };\n });\n return context.options.fixes.has(FIX.PATH_PARAM_TYPE_NAMES)\n ? splitTemplateParts(url, matches)\n : replacedTemplateParts(url, matches);\n}\n\n/**\n * The template literal type of the parts. The original escaped only backticks: a backslash or\n * `${` in the URL could end the literal or open a placeholder, and add code to the generated file\n * (intentional fix). So the text parts are escaped.\n */\nfunction templateText(parts: readonly PathKeyPart[]): string {\n const text = parts\n .map((part) =>\n part.kind === \"text\" ? escapeTemplateText(part.text) : placeholderText(part.type),\n )\n .join(\"\");\n return `\\`${text}\\``;\n}\n\n/** A path's member, its key and its path item type for the overlap check. */\nexport interface PathMember {\n readonly url: string;\n readonly member: IrMember;\n readonly key: PathKey;\n readonly type: IrType;\n}\n\nfunction pathItemMember(\n url: string,\n pathItem: PathItemObject,\n context: TransformContext,\n): PathMember {\n const isReadonly = context.options.immutable;\n const type = pathItemType(\n pathItem,\n { path: appendPointer(ROOT_POINTER, [\"paths\", url]) },\n context,\n );\n const parts =\n context.options.pathParamsAsTypes && url.includes(\"{\")\n ? pathTemplateParts(url, pathItem, context)\n : null;\n if (parts === null) {\n const member = irProperty(toPropertyName(url), type, { isReadonly });\n return { url, member, key: literalKey(url), type };\n }\n const member: IrMember = {\n kind: \"indexSignature\",\n parameterName: \"path\",\n parameterType: irRaw(templateText(parts)),\n type,\n isReadonly,\n comments: [],\n };\n return { url, member, key: { kind: \"template\", parts }, type };\n}\n\nfunction literalKey(url: string): PathKey {\n return { kind: \"literal\", url };\n}\n\nconst PATHS_TYPE_NAME = \"paths\";\n\n/** The URL of `paths[\"/apps/{id}\"]`, or null for any other type. */\nfunction pathsIndexOf(type: IrType): string | null {\n if (type.kind !== \"indexedAccess\" || type.index.kind !== \"stringLiteral\") {\n return null;\n }\n const { object } = type;\n const isPaths =\n object.kind === \"reference\" &&\n object.name === PATHS_TYPE_NAME &&\n object.typeArguments.length === 0;\n return isPaths ? type.index.value : null;\n}\n\n/**\n * The lookup, and `paths[\"/apps/{id}\"]` as that path's item. The declarations cannot read it: a\n * templated path is no property of `paths`, and TypeScript finds it through the signature.\n */\nfunction withPathItems(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup,\n): DeclaredTypeLookup {\n const byUrl = new Map(paths.map((path) => [path.url, path.type]));\n return (type) => {\n const url = pathsIndexOf(type);\n return (url === null ? undefined : byUrl.get(url)) ?? lookup(type);\n };\n}\n\n/**\n * The rejection of a covered path item: only one proven not assignable to the signature's type\n * counts (ADR-028). A pair the proof cannot decide keeps the original output, which may well\n * compile (`Record<string, never>` fits `{ [key: string]: unknown }`).\n */\nfunction rejectionOf(paths: readonly PathMember[], lookup: DeclaredTypeLookup): CoverRejection {\n const relate = assignabilityProof(withPathItems(paths, lookup));\n return (coveringIndex, coveredIndex) => {\n const coveringPath = paths[coveringIndex];\n const coveredPath = paths[coveredIndex];\n return (\n coveringPath !== undefined &&\n coveredPath !== undefined &&\n relate(coveredPath.type, coveringPath.type) === \"rejected\"\n );\n };\n}\n\n/**\n * The members as one object type. When an index signature covers another key, TypeScript checks\n * the covered key's type against it. Where that check surely fails (TS2411, TS2413), each such\n * signature gets an object of its own in an intersection: an intersection does not check its parts\n * against each other, and every key has the type it had in the one object. Output that compiles\n * keeps the one object. The lookup reads the types that path items reference; without it, a\n * reference decides nothing.\n */\nexport function pathsObjectType(\n paths: readonly PathMember[],\n lookup: DeclaredTypeLookup = NO_DECLARED_TYPES,\n): IrType {\n const keys = paths.map(({ key }) => key);\n const covering = coveringTemplateKeys(keys, rejectionOf(paths, lookup));\n if (covering.size === 0) {\n return irObject(paths.map(({ member }) => member));\n }\n const rest = paths.filter((_, index) => !covering.has(index)).map(({ member }) => member);\n const own = paths\n .filter((_, index) => covering.has(index))\n .map(({ member }) => irObject([member]));\n return irIntersection([irObject(rest), ...own]);\n}\n\n/** The members of the `paths` interface (OpenAPI 3.1 §4.8.8): one per path, by URL. */\nexport function pathMembers(paths: PathsObject, context: TransformContext): PathMember[] {\n const members: PathMember[] = [];\n for (const [url, pathItem] of documentEntries(paths, context.options)) {\n if (!pathItem || typeof pathItem !== \"object\") {\n continue;\n }\n if (\"$ref\" in pathItem) {\n const options = { isReadonly: context.options.immutable };\n const member = documentMember(url, refType(pathItem.$ref), pathItem, options);\n members.push({ url, member, key: literalKey(url), type: member.type });\n continue;\n }\n const startedAt = context.diagnostics.now();\n const path = pathItemMember(url, pathItem, context);\n members.push(path);\n // The original reports only paths written as properties.\n if (path.member.kind === \"property\") {\n context.diagnostics.debug(`Transformed path \"${url}\"`, context.diagnostics.now() - startedAt);\n }\n }\n return members;\n}\n\n/**\n * The `paths` interface body, with only the path items' own types for the overlap check. The\n * document transform checks the overlaps again once the referenced types are declared.\n */\nexport function pathsType(paths: PathsObject, context: TransformContext): IrType {\n return pathsObjectType(pathMembers(paths, context));\n}\n"],"names":["member"],"mappings":";;;;;;;;;;;;;;;AAsCA,MAAM,iBAAA,GAAoB,aAAA;AAG1B,MAAM,YAAA,uBAA0D,GAAA,CAAI;AAAA,EAClE,CAAC,UAAU,QAAQ,CAAA;AAAA,EACnB,CAAC,WAAW,QAAQ,CAAA;AAAA,EACpB,CAAC,WAAW,SAAS;AACvB,CAAC,CAAA;AACD,MAAM,kBAAA,GAAsC,QAAA;AAE5C,SAAS,iBAAA,CACP,WACA,OAAA,EAC6B;AAC7B,EAAA,OAAO,MAAA,IAAU,aAAa,SAAA,CAAU,IAAA,GACnC,QAAQ,IAAA,CAAK,OAAA,CAAQ,SAAA,CAAU,IAAI,CAAA,GACnC,SAAA;AACP;AAEA,SAAS,iBAAA,CACP,UAAA,EACA,MAAA,EACA,OAAA,EACM;AACN,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,MAAM,QAAA,GAAW,iBAAA,CAAkB,SAAA,EAAW,OAAO,CAAA;AACrD,IAAA,IAAI,QAAA,IAAY,QAAA,CAAS,EAAA,KAAO,MAAA,EAAQ;AACtC,MAAA,MAAA,CAAO,GAAA,CAAI,QAAA,CAAS,IAAA,EAAM,QAAQ,CAAA;AAAA,IACpC;AAAA,EACF;AACF;AAGA,SAAS,cAAA,CACP,UACA,OAAA,EAC8B;AAC9B,EAAA,MAAM,MAAA,uBAAa,GAAA,EAA6B;AAChD,EAAA,iBAAA,CAAkB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AA,CAAY,GAAA,EAAI,GAAI,SAAS,CAAA;AAAA,IAC9F;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAMO,SAAS,SAAA,CAAU,OAAoB,OAAA,EAAmC;AAC/E,EAAA,OAAO,eAAA,CAAgB,WAAA,CAAY,KAAA,EAAO,OAAO,CAAC,CAAA;AACpD;;"}
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ const constructors = require('../../../domain/ir/constructors.cjs');
4
+ const jsonPointer = require('../../../domain/openapi/json-pointer.cjs');
5
+ const parameterObject = require('../../../domain/openapi/parameter-object.cjs');
6
+ const pathItemObject = require('../../../domain/openapi/path-item-object.cjs');
7
+ const refType = require('../ref-type.cjs');
8
+ const parameterEntries = require('./parameter-entries.cjs');
9
+
10
+ const INDEX_RE = /^\d+$/;
11
+ const OPERATION_KEYS = /* @__PURE__ */ new Set([...pathItemObject.HTTP_METHODS, pathItemObject.QUERY_METHOD]);
12
+ function listPointerOf(ref) {
13
+ if (!ref.startsWith(`${jsonPointer.ROOT_POINTER}/`)) {
14
+ return null;
15
+ }
16
+ const [root, ...segments] = jsonPointer.parseRefPointer(ref);
17
+ const [list, position] = segments.slice(-2);
18
+ const isList = list === "parameters" && position !== void 0 && INDEX_RE.test(position);
19
+ return root !== void 0 && isList ? { root, owner: segments.slice(0, -2) } : null;
20
+ }
21
+ function pointerTo(root, segments) {
22
+ return jsonPointer.appendPointer(jsonPointer.ROOT_POINTER, [root, ...segments]);
23
+ }
24
+ function isPathItemAt(root, segments) {
25
+ const isNamedRoot = root === "paths" || root === "webhooks";
26
+ return isNamedRoot && segments.length === 1 || root === "components" && segments[0] === "pathItems" && segments.length === 2;
27
+ }
28
+ function pathItemOfOperation(root, owner) {
29
+ const method = owner.at(-1) ?? "";
30
+ if (OPERATION_KEYS.has(method) && isPathItemAt(root, owner.slice(0, -1))) {
31
+ return owner.slice(0, -1);
32
+ }
33
+ const isAdditional = owner.at(-2) === pathItemObject.ADDITIONAL_OPERATIONS_KEY;
34
+ return isAdditional && isPathItemAt(root, owner.slice(0, -2)) ? owner.slice(0, -2) : null;
35
+ }
36
+ function documentNode(refs, root, segments) {
37
+ const node = refs.resolve(pointerTo(root, segments));
38
+ const isTypedHere = typeof node === "object" && node !== null && !("$ref" in node);
39
+ return isTypedHere ? node : null;
40
+ }
41
+ function typedParameters(pointer, refs) {
42
+ const { root, owner } = pointer;
43
+ if (isPathItemAt(root, owner)) {
44
+ return documentNode(refs, root, owner)?.parameters ?? null;
45
+ }
46
+ const pathItemSegments = pathItemOfOperation(root, owner);
47
+ const pathItem = pathItemSegments && documentNode(refs, root, pathItemSegments);
48
+ const operation = pathItem && documentNode(refs, root, owner);
49
+ return pathItem && operation ? parameterEntries.mergedParameters(pathItem, operation, refs) : null;
50
+ }
51
+ function isLocationOptional(entries, location) {
52
+ return entries.filter((entry) => entry.resolved?.in === location).every((entry) => location !== "path" && !entry.resolved?.required);
53
+ }
54
+ function correctedType(listType, entries, parameter) {
55
+ if (parameter.in === parameterObject.QUERYSTRING_LOCATION) {
56
+ const isTyped = !entries.some((entry) => entry.resolved?.in === "query");
57
+ return isTyped ? refType.indexBy(listType, "query") : null;
58
+ }
59
+ if (!isLocationOptional(entries, parameter.in)) {
60
+ return null;
61
+ }
62
+ const location = constructors.irReference("NonNullable", [refType.indexBy(listType, parameter.in)]);
63
+ return refType.indexBy(location, parameter.name);
64
+ }
65
+ function referencedParameterType(ref, resolved, context) {
66
+ if (resolved.$ref) {
67
+ return refType.refType(ref, { parameter: null });
68
+ }
69
+ const original = refType.refType(ref, { parameter: { in: resolved.in, name: resolved.name } });
70
+ const pointer = listPointerOf(ref);
71
+ const parameters = pointer && typedParameters(pointer, context.refs);
72
+ if (pointer === null || parameters === null) {
73
+ return original;
74
+ }
75
+ const listType = refType.refType(pointerTo(pointer.root, [...pointer.owner, "parameters"]));
76
+ return correctedType(listType, parameterEntries.parameterEntries(parameters, context), resolved) ?? original;
77
+ }
78
+
79
+ exports.referencedParameterType = referencedParameterType;
80
+ //# sourceMappingURL=referenced-parameter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"referenced-parameter.cjs","sources":["../../../../src/application/transform/document/referenced-parameter.ts"],"sourcesContent":["import { irReference } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport {\n appendPointer,\n parseRefPointer,\n ROOT_POINTER,\n} from \"../../../domain/openapi/json-pointer.js\";\nimport type { OperationObject } from \"../../../domain/openapi/operation-object.js\";\nimport {\n type ParameterObject,\n type ParameterOrReference,\n QUERYSTRING_LOCATION,\n} from \"../../../domain/openapi/parameter-object.js\";\nimport {\n ADDITIONAL_OPERATIONS_KEY,\n HTTP_METHODS,\n type PathItemObject,\n QUERY_METHOD,\n} from \"../../../domain/openapi/path-item-object.js\";\nimport { indexBy, refType } from \"../ref-type.js\";\nimport type { RefResolver } from \"../schema/schema-context.js\";\nimport type { TransformContext } from \"../transform-context.js\";\nimport { mergedParameters, type ParameterEntry, parameterEntries } from \"./parameter-entries.js\";\n\n/**\n * The type of a parameter `$ref`. The original indexed the parameter's location and name\n * (`refType`): `#/paths/~1a/get/parameters/0` gave\n * `paths[\"/a\"][\"get\"][\"parameters\"][\"query\"][\"q\"]`.\n * Where the generated type differs, that does not compile, and only there it changes:\n *\n * - A location whose parameters are all optional is an optional member (`query?:`), so indexing it\n * fails (TS2339); it is wrapped in `NonNullable` before the name is indexed.\n * - An OpenAPI 3.2 `in: querystring` parameter is the whole `query` member (ADR-020), not a member\n * `querystring`, so the pointer reads `[\"query\"]`.\n *\n * A `$ref` to a component parameter, or into a list the generator types elsewhere (a `$ref` path\n * item or operation, a callback), keeps the original type.\n */\n\nconst INDEX_RE = /^\\d+$/;\nconst OPERATION_KEYS: ReadonlySet<string> = new Set([...HTTP_METHODS, QUERY_METHOD]);\n\n/** A `parameters/N` pointer, split into its root and the segments of the list's owner. */\ninterface ParameterListPointer {\n readonly root: string;\n readonly owner: readonly string[];\n}\n\nfunction listPointerOf(ref: string): ParameterListPointer | null {\n if (!ref.startsWith(`${ROOT_POINTER}/`)) {\n return null;\n }\n const [root, ...segments] = parseRefPointer(ref);\n const [list, position] = segments.slice(-2);\n const isList = list === \"parameters\" && position !== undefined && INDEX_RE.test(position);\n return root !== undefined && isList ? { root, owner: segments.slice(0, -2) } : null;\n}\n\nfunction pointerTo(root: string, segments: readonly string[]): string {\n return appendPointer(ROOT_POINTER, [root, ...segments]);\n}\n\n/** Whether the segments name a path item that `pathItemType` types in place. */\nfunction isPathItemAt(root: string, segments: readonly string[]): boolean {\n const isNamedRoot = root === \"paths\" || root === \"webhooks\";\n return (\n (isNamedRoot && segments.length === 1) ||\n (root === \"components\" && segments[0] === \"pathItems\" && segments.length === 2)\n );\n}\n\n/** The segments of the path item that holds the operation at `owner`, or null. */\nfunction pathItemOfOperation(root: string, owner: readonly string[]): readonly string[] | null {\n const method = owner.at(-1) ?? \"\";\n if (OPERATION_KEYS.has(method) && isPathItemAt(root, owner.slice(0, -1))) {\n return owner.slice(0, -1);\n }\n const isAdditional = owner.at(-2) === ADDITIONAL_OPERATIONS_KEY;\n return isAdditional && isPathItemAt(root, owner.slice(0, -2)) ? owner.slice(0, -2) : null;\n}\n\nfunction documentNode<T>(refs: RefResolver, root: string, segments: readonly string[]): T | null {\n const node = refs.resolve(pointerTo(root, segments));\n const isTypedHere = typeof node === \"object\" && node !== null && !(\"$ref\" in node);\n return isTypedHere ? (node as T) : null;\n}\n\n/** The parameters the generator types at the list's owner; null where it types them elsewhere. */\nfunction typedParameters(\n pointer: ParameterListPointer,\n refs: RefResolver,\n): readonly ParameterOrReference[] | null {\n const { root, owner } = pointer;\n if (isPathItemAt(root, owner)) {\n return documentNode<PathItemObject>(refs, root, owner)?.parameters ?? null;\n }\n const pathItemSegments = pathItemOfOperation(root, owner);\n const pathItem = pathItemSegments && documentNode<PathItemObject>(refs, root, pathItemSegments);\n const operation = pathItem && documentNode<OperationObject>(refs, root, owner);\n return pathItem && operation ? mergedParameters(pathItem, operation, refs) : null;\n}\n\n/** A location member is optional when none of its parameters is required (`locationParts`). */\nfunction isLocationOptional(entries: readonly ParameterEntry[], location: string): boolean {\n return entries\n .filter((entry) => entry.resolved?.in === location)\n .every((entry) => location !== \"path\" && !entry.resolved?.required);\n}\n\n/** The corrected type, or null where the original type compiles or no correction applies. */\nfunction correctedType(\n listType: IrType,\n entries: readonly ParameterEntry[],\n parameter: ParameterObject,\n): IrType | null {\n if (parameter.in === QUERYSTRING_LOCATION) {\n // Next to `in: query` parameters it is not in the generated types (QUERYSTRING_NEXT_TO_QUERY).\n const isTyped = !entries.some((entry) => entry.resolved?.in === \"query\");\n return isTyped ? indexBy(listType, \"query\") : null;\n }\n if (!isLocationOptional(entries, parameter.in)) {\n return null;\n }\n const location = irReference(\"NonNullable\", [indexBy(listType, parameter.in)]);\n return indexBy(location, parameter.name);\n}\n\n/** The type of a parameter `$ref` whose target resolved to `resolved`; see the module comment. */\nexport function referencedParameterType(\n ref: string,\n resolved: ParameterObject,\n context: TransformContext,\n): IrType {\n // A `$ref` that resolves to another `$ref` is not a parameter object yet: index it as a path.\n if ((resolved as { $ref?: unknown }).$ref) {\n return refType(ref, { parameter: null });\n }\n const original = refType(ref, { parameter: { in: resolved.in, name: resolved.name } });\n const pointer = listPointerOf(ref);\n const parameters = pointer && typedParameters(pointer, context.refs);\n if (pointer === null || parameters === null) {\n return original;\n }\n const listType = refType(pointerTo(pointer.root, [...pointer.owner, \"parameters\"]));\n return correctedType(listType, parameterEntries(parameters, context), resolved) ?? original;\n}\n"],"names":["HTTP_METHODS","QUERY_METHOD","ROOT_POINTER","parseRefPointer","appendPointer","ADDITIONAL_OPERATIONS_KEY","mergedParameters","QUERYSTRING_LOCATION","indexBy","irReference","refType","parameterEntries"],"mappings":";;;;;;;;;AAuCA,MAAM,QAAA,GAAW,OAAA;AACjB,MAAM,iCAAsC,IAAI,GAAA,CAAI,CAAC,GAAGA,2BAAA,EAAcC,2BAAY,CAAC,CAAA;AAQ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