openapi-typesafe 1.0.0-rc.0 → 1.0.0-rc.1

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 (404) hide show
  1. package/dist/adapters/redocly-loader/redocly-config-source.cjs +21 -2
  2. package/dist/adapters/redocly-loader/redocly-config-source.cjs.map +1 -1
  3. package/dist/adapters/redocly-loader/redocly-config-source.mjs +22 -3
  4. package/dist/adapters/redocly-loader/redocly-config-source.mjs.map +1 -1
  5. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +15 -5
  6. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  7. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +15 -5
  8. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  9. package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs +3 -0
  10. package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs.map +1 -1
  11. package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs +3 -0
  12. package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs.map +1 -1
  13. package/dist/adapters/type-ast-bridge/typescript-to-ir.cjs +15 -9
  14. package/dist/adapters/type-ast-bridge/typescript-to-ir.cjs.map +1 -1
  15. package/dist/adapters/type-ast-bridge/typescript-to-ir.mjs +15 -9
  16. package/dist/adapters/type-ast-bridge/typescript-to-ir.mjs.map +1 -1
  17. package/dist/api/discriminator-conflict-warnings.cjs +25 -0
  18. package/dist/api/discriminator-conflict-warnings.cjs.map +1 -0
  19. package/dist/api/discriminator-conflict-warnings.mjs +23 -0
  20. package/dist/api/discriminator-conflict-warnings.mjs.map +1 -0
  21. package/dist/api/discriminator-enum-names.cjs +19 -0
  22. package/dist/api/discriminator-enum-names.cjs.map +1 -0
  23. package/dist/api/discriminator-enum-names.mjs +17 -0
  24. package/dist/api/discriminator-enum-names.mjs.map +1 -0
  25. package/dist/api/discriminator-enum-parent.cjs +59 -0
  26. package/dist/api/discriminator-enum-parent.cjs.map +1 -0
  27. package/dist/api/discriminator-enum-parent.mjs +57 -0
  28. package/dist/api/discriminator-enum-parent.mjs.map +1 -0
  29. package/dist/api/discriminator-enum.cjs +25 -0
  30. package/dist/api/discriminator-enum.cjs.map +1 -1
  31. package/dist/api/discriminator-enum.mjs +25 -1
  32. package/dist/api/discriminator-enum.mjs.map +1 -1
  33. package/dist/api/discriminator-other-owners.cjs +67 -0
  34. package/dist/api/discriminator-other-owners.cjs.map +1 -0
  35. package/dist/api/discriminator-other-owners.mjs +64 -0
  36. package/dist/api/discriminator-other-owners.mjs.map +1 -0
  37. package/dist/api/discriminator-patch.cjs +88 -0
  38. package/dist/api/discriminator-patch.cjs.map +1 -0
  39. package/dist/api/discriminator-patch.mjs +82 -0
  40. package/dist/api/discriminator-patch.mjs.map +1 -0
  41. package/dist/api/discriminator-scan.cjs +50 -65
  42. package/dist/api/discriminator-scan.cjs.map +1 -1
  43. package/dist/api/discriminator-scan.mjs +44 -59
  44. package/dist/api/discriminator-scan.mjs.map +1 -1
  45. package/dist/api/document-run.cjs +18 -3
  46. package/dist/api/document-run.cjs.map +1 -1
  47. package/dist/api/document-run.mjs +19 -4
  48. package/dist/api/document-run.mjs.map +1 -1
  49. package/dist/api/enum-values-warnings.cjs +16 -0
  50. package/dist/api/enum-values-warnings.cjs.map +1 -0
  51. package/dist/api/enum-values-warnings.mjs +14 -0
  52. package/dist/api/enum-values-warnings.mjs.map +1 -0
  53. package/dist/api/path-template-warnings.cjs +21 -0
  54. package/dist/api/path-template-warnings.cjs.map +1 -0
  55. package/dist/api/path-template-warnings.mjs +19 -0
  56. package/dist/api/path-template-warnings.mjs.map +1 -0
  57. package/dist/api/transform-context.cjs +3 -1
  58. package/dist/api/transform-context.cjs.map +1 -1
  59. package/dist/api/transform-context.mjs +3 -1
  60. package/dist/api/transform-context.mjs.map +1 -1
  61. package/dist/api/transform-schema.cjs +52 -3
  62. package/dist/api/transform-schema.cjs.map +1 -1
  63. package/dist/api/transform-schema.mjs +53 -4
  64. package/dist/api/transform-schema.mjs.map +1 -1
  65. package/dist/api/unsupported-feature-warnings.cjs +6 -1
  66. package/dist/api/unsupported-feature-warnings.cjs.map +1 -1
  67. package/dist/api/unsupported-feature-warnings.mjs +6 -1
  68. package/dist/api/unsupported-feature-warnings.mjs.map +1 -1
  69. package/dist/application/print/type-printer.cjs +5 -0
  70. package/dist/application/print/type-printer.cjs.map +1 -1
  71. package/dist/application/print/type-printer.mjs +5 -0
  72. package/dist/application/print/type-printer.mjs.map +1 -1
  73. package/dist/application/transform/document/assignability.cjs +144 -0
  74. package/dist/application/transform/document/assignability.cjs.map +1 -0
  75. package/dist/application/transform/document/assignability.mjs +138 -0
  76. package/dist/application/transform/document/assignability.mjs.map +1 -0
  77. package/dist/application/transform/document/components.cjs +2 -2
  78. package/dist/application/transform/document/components.cjs.map +1 -1
  79. package/dist/application/transform/document/components.mjs +4 -4
  80. package/dist/application/transform/document/components.mjs.map +1 -1
  81. package/dist/application/transform/document/declared-types.cjs +66 -0
  82. package/dist/application/transform/document/declared-types.cjs.map +1 -0
  83. package/dist/application/transform/document/declared-types.mjs +63 -0
  84. package/dist/application/transform/document/declared-types.mjs.map +1 -0
  85. package/dist/application/transform/document/document.cjs +32 -9
  86. package/dist/application/transform/document/document.cjs.map +1 -1
  87. package/dist/application/transform/document/document.mjs +34 -11
  88. package/dist/application/transform/document/document.mjs.map +1 -1
  89. package/dist/application/transform/document/exploded-query.cjs +46 -0
  90. package/dist/application/transform/document/exploded-query.cjs.map +1 -0
  91. package/dist/application/transform/document/exploded-query.mjs +43 -0
  92. package/dist/application/transform/document/exploded-query.mjs.map +1 -0
  93. package/dist/application/transform/document/global-type-references.cjs +63 -0
  94. package/dist/application/transform/document/global-type-references.cjs.map +1 -0
  95. package/dist/application/transform/document/global-type-references.mjs +61 -0
  96. package/dist/application/transform/document/global-type-references.mjs.map +1 -0
  97. package/dist/application/transform/document/list-assignability.cjs +54 -0
  98. package/dist/application/transform/document/list-assignability.cjs.map +1 -0
  99. package/dist/application/transform/document/list-assignability.mjs +52 -0
  100. package/dist/application/transform/document/list-assignability.mjs.map +1 -0
  101. package/dist/application/transform/document/parameters.cjs +40 -8
  102. package/dist/application/transform/document/parameters.cjs.map +1 -1
  103. package/dist/application/transform/document/parameters.mjs +41 -9
  104. package/dist/application/transform/document/parameters.mjs.map +1 -1
  105. package/dist/application/transform/document/path-key-overlaps.cjs +83 -33
  106. package/dist/application/transform/document/path-key-overlaps.cjs.map +1 -1
  107. package/dist/application/transform/document/path-key-overlaps.mjs +83 -33
  108. package/dist/application/transform/document/path-key-overlaps.mjs.map +1 -1
  109. package/dist/application/transform/document/path-template-replace.cjs +48 -0
  110. package/dist/application/transform/document/path-template-replace.cjs.map +1 -0
  111. package/dist/application/transform/document/path-template-replace.mjs +45 -0
  112. package/dist/application/transform/document/path-template-replace.mjs.map +1 -0
  113. package/dist/application/transform/document/paths.cjs +54 -28
  114. package/dist/application/transform/document/paths.cjs.map +1 -1
  115. package/dist/application/transform/document/paths.mjs +53 -29
  116. package/dist/application/transform/document/paths.mjs.map +1 -1
  117. package/dist/application/transform/document/root-type-aliases.cjs +15 -14
  118. package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
  119. package/dist/application/transform/document/root-type-aliases.mjs +15 -13
  120. package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
  121. package/dist/application/transform/document/template-key-match.cjs +128 -0
  122. package/dist/application/transform/document/template-key-match.cjs.map +1 -0
  123. package/dist/application/transform/document/template-key-match.mjs +125 -0
  124. package/dist/application/transform/document/template-key-match.mjs.map +1 -0
  125. package/dist/application/transform/document/type-assignability.cjs +192 -0
  126. package/dist/application/transform/document/type-assignability.cjs.map +1 -0
  127. package/dist/application/transform/document/type-assignability.mjs +190 -0
  128. package/dist/application/transform/document/type-assignability.mjs.map +1 -0
  129. package/dist/application/transform/document/type-key.cjs +70 -0
  130. package/dist/application/transform/document/type-key.cjs.map +1 -0
  131. package/dist/application/transform/document/type-key.mjs +68 -0
  132. package/dist/application/transform/document/type-key.mjs.map +1 -0
  133. package/dist/application/transform/document/type-resolution.cjs +131 -0
  134. package/dist/application/transform/document/type-resolution.cjs.map +1 -0
  135. package/dist/application/transform/document/type-resolution.mjs +125 -0
  136. package/dist/application/transform/document/type-resolution.mjs.map +1 -0
  137. package/dist/application/transform/footer/document-footer.cjs +66 -4
  138. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  139. package/dist/application/transform/footer/document-footer.mjs +67 -5
  140. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  141. package/dist/application/transform/footer/enum-naming.cjs +17 -0
  142. package/dist/application/transform/footer/enum-naming.cjs.map +1 -1
  143. package/dist/application/transform/footer/enum-naming.mjs +17 -1
  144. package/dist/application/transform/footer/enum-naming.mjs.map +1 -1
  145. package/dist/application/transform/footer/enum-values-check.cjs +129 -0
  146. package/dist/application/transform/footer/enum-values-check.cjs.map +1 -0
  147. package/dist/application/transform/footer/enum-values-check.mjs +127 -0
  148. package/dist/application/transform/footer/enum-values-check.mjs.map +1 -0
  149. package/dist/application/transform/footer/evaluation.cjs +33 -0
  150. package/dist/application/transform/footer/evaluation.cjs.map +1 -0
  151. package/dist/application/transform/footer/evaluation.mjs +26 -0
  152. package/dist/application/transform/footer/evaluation.mjs.map +1 -0
  153. package/dist/application/transform/footer/shared-enum-names.cjs +60 -0
  154. package/dist/application/transform/footer/shared-enum-names.cjs.map +1 -0
  155. package/dist/application/transform/footer/shared-enum-names.mjs +57 -0
  156. package/dist/application/transform/footer/shared-enum-names.mjs.map +1 -0
  157. package/dist/application/transform/footer/type-evaluation.cjs +246 -0
  158. package/dist/application/transform/footer/type-evaluation.cjs.map +1 -0
  159. package/dist/application/transform/footer/type-evaluation.mjs +244 -0
  160. package/dist/application/transform/footer/type-evaluation.mjs.map +1 -0
  161. package/dist/application/transform/footer/type-rules.cjs +172 -0
  162. package/dist/application/transform/footer/type-rules.cjs.map +1 -0
  163. package/dist/application/transform/footer/type-rules.mjs +166 -0
  164. package/dist/application/transform/footer/type-rules.mjs.map +1 -0
  165. package/dist/application/transform/ref-pointer/generated-location.cjs +138 -0
  166. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -0
  167. package/dist/application/transform/ref-pointer/generated-location.mjs +136 -0
  168. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -0
  169. package/dist/application/transform/ref-pointer/generated-shape.cjs +171 -0
  170. package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -0
  171. package/dist/application/transform/ref-pointer/generated-shape.mjs +162 -0
  172. package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -0
  173. package/dist/application/transform/ref-pointer/inline-cycles.cjs +44 -0
  174. package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -0
  175. package/dist/application/transform/ref-pointer/inline-cycles.mjs +42 -0
  176. package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -0
  177. package/dist/application/transform/ref-pointer/original-index.cjs +62 -0
  178. package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -0
  179. package/dist/application/transform/ref-pointer/original-index.mjs +60 -0
  180. package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -0
  181. package/dist/application/transform/ref-pointer/pointer-type.cjs +60 -0
  182. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -0
  183. package/dist/application/transform/ref-pointer/pointer-type.mjs +57 -0
  184. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -0
  185. package/dist/application/transform/ref-pointer/pointer-walk.cjs +66 -0
  186. package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -0
  187. package/dist/application/transform/ref-pointer/pointer-walk.mjs +56 -0
  188. package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -0
  189. package/dist/application/transform/ref-pointer/typed-walk.cjs +124 -0
  190. package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -0
  191. package/dist/application/transform/ref-pointer/typed-walk.mjs +122 -0
  192. package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -0
  193. package/dist/application/transform/ref-type.cjs +7 -2
  194. package/dist/application/transform/ref-type.cjs.map +1 -1
  195. package/dist/application/transform/ref-type.mjs +3 -2
  196. package/dist/application/transform/ref-type.mjs.map +1 -1
  197. package/dist/application/transform/schema/access-flags.cjs +38 -0
  198. package/dist/application/transform/schema/access-flags.cjs.map +1 -0
  199. package/dist/application/transform/schema/access-flags.mjs +36 -0
  200. package/dist/application/transform/schema/access-flags.mjs.map +1 -0
  201. package/dist/application/transform/schema/array-type.cjs +32 -1
  202. package/dist/application/transform/schema/array-type.cjs.map +1 -1
  203. package/dist/application/transform/schema/array-type.mjs +33 -2
  204. package/dist/application/transform/schema/array-type.mjs.map +1 -1
  205. package/dist/application/transform/schema/composition-type.cjs +50 -15
  206. package/dist/application/transform/schema/composition-type.cjs.map +1 -1
  207. package/dist/application/transform/schema/composition-type.mjs +50 -15
  208. package/dist/application/transform/schema/composition-type.mjs.map +1 -1
  209. package/dist/application/transform/schema/core-type.cjs +3 -1
  210. package/dist/application/transform/schema/core-type.cjs.map +1 -1
  211. package/dist/application/transform/schema/core-type.mjs +3 -1
  212. package/dist/application/transform/schema/core-type.mjs.map +1 -1
  213. package/dist/application/transform/schema/discriminated-union.cjs +30 -0
  214. package/dist/application/transform/schema/discriminated-union.cjs.map +1 -0
  215. package/dist/application/transform/schema/discriminated-union.mjs +27 -0
  216. package/dist/application/transform/schema/discriminated-union.mjs.map +1 -0
  217. package/dist/application/transform/schema/discriminator-property.cjs +3 -2
  218. package/dist/application/transform/schema/discriminator-property.cjs.map +1 -1
  219. package/dist/application/transform/schema/discriminator-property.mjs +3 -2
  220. package/dist/application/transform/schema/discriminator-property.mjs.map +1 -1
  221. package/dist/application/transform/schema/enum-rule.cjs +66 -10
  222. package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
  223. package/dist/application/transform/schema/enum-rule.mjs +67 -12
  224. package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
  225. package/dist/application/transform/schema/inherited-discriminator.cjs +29 -0
  226. package/dist/application/transform/schema/inherited-discriminator.cjs.map +1 -0
  227. package/dist/application/transform/schema/inherited-discriminator.mjs +26 -0
  228. package/dist/application/transform/schema/inherited-discriminator.mjs.map +1 -0
  229. package/dist/application/transform/schema/object-type.cjs +38 -25
  230. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  231. package/dist/application/transform/schema/object-type.mjs +39 -27
  232. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  233. package/dist/application/transform/schema/required-variants.cjs +45 -0
  234. package/dist/application/transform/schema/required-variants.cjs.map +1 -0
  235. package/dist/application/transform/schema/required-variants.mjs +42 -0
  236. package/dist/application/transform/schema/required-variants.mjs.map +1 -0
  237. package/dist/application/transform/schema/schema-transform.cjs +2 -2
  238. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  239. package/dist/application/transform/schema/schema-transform.mjs +2 -2
  240. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  241. package/dist/application/transform/schema-comment.cjs +51 -5
  242. package/dist/application/transform/schema-comment.cjs.map +1 -1
  243. package/dist/application/transform/schema-comment.mjs +50 -6
  244. package/dist/application/transform/schema-comment.mjs.map +1 -1
  245. package/dist/application/transform/type-combinators.mjs +1 -1
  246. package/dist/cli/cli-arguments.cjs +11 -3
  247. package/dist/cli/cli-arguments.cjs.map +1 -1
  248. package/dist/cli/cli-arguments.mjs +11 -3
  249. package/dist/cli/cli-arguments.mjs.map +1 -1
  250. package/dist/cli/cli-errors.cjs +3 -2
  251. package/dist/cli/cli-errors.cjs.map +1 -1
  252. package/dist/cli/cli-errors.mjs +3 -2
  253. package/dist/cli/cli-errors.mjs.map +1 -1
  254. package/dist/cli/cli-output.cjs +8 -3
  255. package/dist/cli/cli-output.cjs.map +1 -1
  256. package/dist/cli/cli-output.mjs +9 -4
  257. package/dist/cli/cli-output.mjs.map +1 -1
  258. package/dist/cli/main.cjs +5 -0
  259. package/dist/cli/main.cjs.map +1 -1
  260. package/dist/cli/main.mjs +5 -0
  261. package/dist/cli/main.mjs.map +1 -1
  262. package/dist/cli/redocly-apis.cjs +7 -3
  263. package/dist/cli/redocly-apis.cjs.map +1 -1
  264. package/dist/cli/redocly-apis.mjs +8 -4
  265. package/dist/cli/redocly-apis.mjs.map +1 -1
  266. package/dist/cli/ref-limits.cjs +1 -1
  267. package/dist/cli/ref-limits.cjs.map +1 -1
  268. package/dist/cli/ref-limits.mjs +2 -2
  269. package/dist/cli/ref-limits.mjs.map +1 -1
  270. package/dist/cli/run-cli.cjs +15 -2
  271. package/dist/cli/run-cli.cjs.map +1 -1
  272. package/dist/cli/run-cli.mjs +16 -3
  273. package/dist/cli/run-cli.mjs.map +1 -1
  274. package/dist/domain/errors.cjs +2 -0
  275. package/dist/domain/errors.cjs.map +1 -1
  276. package/dist/domain/errors.mjs +2 -0
  277. package/dist/domain/errors.mjs.map +1 -1
  278. package/dist/domain/ir/constructors.cjs +5 -1
  279. package/dist/domain/ir/constructors.cjs.map +1 -1
  280. package/dist/domain/ir/constructors.mjs +5 -2
  281. package/dist/domain/ir/constructors.mjs.map +1 -1
  282. package/dist/domain/openapi/admitted-values.cjs +75 -0
  283. package/dist/domain/openapi/admitted-values.cjs.map +1 -0
  284. package/dist/domain/openapi/admitted-values.mjs +72 -0
  285. package/dist/domain/openapi/admitted-values.mjs.map +1 -0
  286. package/dist/domain/openapi/discriminated-union.cjs +68 -0
  287. package/dist/domain/openapi/discriminated-union.cjs.map +1 -0
  288. package/dist/domain/openapi/discriminated-union.mjs +62 -0
  289. package/dist/domain/openapi/discriminated-union.mjs.map +1 -0
  290. package/dist/domain/openapi/discriminator-conflicts.cjs +143 -0
  291. package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -0
  292. package/dist/domain/openapi/discriminator-conflicts.mjs +141 -0
  293. package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -0
  294. package/dist/domain/openapi/parameter-object.cjs.map +1 -1
  295. package/dist/domain/openapi/parameter-object.mjs.map +1 -1
  296. package/dist/domain/openapi/path-templates.cjs +23 -0
  297. package/dist/domain/openapi/path-templates.cjs.map +1 -0
  298. package/dist/domain/openapi/path-templates.mjs +21 -0
  299. package/dist/domain/openapi/path-templates.mjs.map +1 -0
  300. package/dist/domain/output-fixes.cjs +36 -1
  301. package/dist/domain/output-fixes.cjs.map +1 -1
  302. package/dist/domain/output-fixes.mjs +36 -1
  303. package/dist/domain/output-fixes.mjs.map +1 -1
  304. package/dist/domain/warnings.cjs +15 -0
  305. package/dist/domain/warnings.cjs.map +1 -0
  306. package/dist/domain/warnings.mjs +12 -0
  307. package/dist/domain/warnings.mjs.map +1 -0
  308. package/dist/index.d.cts +29 -0
  309. package/dist/index.d.mts +29 -0
  310. package/dist/index.d.ts +29 -0
  311. package/dist/transform/components-object.cjs +2 -1
  312. package/dist/transform/components-object.cjs.map +1 -1
  313. package/dist/transform/components-object.mjs +2 -1
  314. package/dist/transform/components-object.mjs.map +1 -1
  315. package/package.json +1 -1
  316. package/src/adapters/redocly-loader/redocly-config-source.ts +41 -6
  317. package/src/adapters/redocly-loader/redocly-schema-loader.ts +22 -6
  318. package/src/adapters/type-ast-bridge/ir-to-typescript.ts +3 -0
  319. package/src/adapters/type-ast-bridge/typescript-to-ir.ts +26 -12
  320. package/src/api/discriminator-conflict-warnings.ts +43 -0
  321. package/src/api/discriminator-enum-names.ts +26 -0
  322. package/src/api/discriminator-enum-parent.ts +129 -0
  323. package/src/api/discriminator-enum.ts +39 -0
  324. package/src/api/discriminator-other-owners.ts +97 -0
  325. package/src/api/discriminator-patch.ts +147 -0
  326. package/src/api/discriminator-scan.ts +78 -90
  327. package/src/api/document-run.ts +24 -6
  328. package/src/api/enum-values-warnings.ts +21 -0
  329. package/src/api/path-template-warnings.ts +27 -0
  330. package/src/api/transform-context.ts +7 -1
  331. package/src/api/transform-schema.ts +88 -4
  332. package/src/api/unsupported-feature-warnings.ts +8 -1
  333. package/src/application/ports/redocly-config-source.ts +5 -1
  334. package/src/application/print/type-printer.ts +6 -0
  335. package/src/application/transform/document/assignability.ts +203 -0
  336. package/src/application/transform/document/components.ts +6 -6
  337. package/src/application/transform/document/declared-types.ts +93 -0
  338. package/src/application/transform/document/document.ts +71 -13
  339. package/src/application/transform/document/exploded-query.ts +91 -0
  340. package/src/application/transform/document/global-type-references.ts +78 -0
  341. package/src/application/transform/document/list-assignability.ts +87 -0
  342. package/src/application/transform/document/parameters.ts +76 -11
  343. package/src/application/transform/document/path-key-overlaps.ts +148 -59
  344. package/src/application/transform/document/path-template-replace.ts +90 -0
  345. package/src/application/transform/document/paths.ts +99 -37
  346. package/src/application/transform/document/root-type-aliases.ts +29 -28
  347. package/src/application/transform/document/template-key-match.ts +183 -0
  348. package/src/application/transform/document/type-assignability.ts +268 -0
  349. package/src/application/transform/document/type-key.ts +80 -0
  350. package/src/application/transform/document/type-resolution.ts +163 -0
  351. package/src/application/transform/footer/document-footer.ts +91 -6
  352. package/src/application/transform/footer/enum-naming.ts +29 -0
  353. package/src/application/transform/footer/enum-values-check.ts +171 -0
  354. package/src/application/transform/footer/evaluation.ts +47 -0
  355. package/src/application/transform/footer/shared-enum-names.ts +86 -0
  356. package/src/application/transform/footer/type-evaluation.ts +294 -0
  357. package/src/application/transform/footer/type-rules.ts +269 -0
  358. package/src/application/transform/ref-pointer/generated-location.ts +211 -0
  359. package/src/application/transform/ref-pointer/generated-shape.ts +275 -0
  360. package/src/application/transform/ref-pointer/inline-cycles.ts +56 -0
  361. package/src/application/transform/ref-pointer/original-index.ts +95 -0
  362. package/src/application/transform/ref-pointer/pointer-type.ts +92 -0
  363. package/src/application/transform/ref-pointer/pointer-walk.ts +96 -0
  364. package/src/application/transform/ref-pointer/typed-walk.ts +192 -0
  365. package/src/application/transform/ref-type.ts +11 -6
  366. package/src/application/transform/schema/access-flags.ts +63 -0
  367. package/src/application/transform/schema/array-type.ts +66 -5
  368. package/src/application/transform/schema/composition-type.ts +96 -24
  369. package/src/application/transform/schema/core-type.ts +8 -4
  370. package/src/application/transform/schema/discriminated-union.ts +58 -0
  371. package/src/application/transform/schema/discriminator-property.ts +8 -3
  372. package/src/application/transform/schema/enum-rule.ts +136 -13
  373. package/src/application/transform/schema/inherited-discriminator.ts +54 -0
  374. package/src/application/transform/schema/object-type.ts +51 -33
  375. package/src/application/transform/schema/required-variants.ts +88 -0
  376. package/src/application/transform/schema/schema-context.ts +26 -0
  377. package/src/application/transform/schema/schema-transform.ts +2 -2
  378. package/src/application/transform/schema-comment.ts +84 -4
  379. package/src/cli/cli-arguments.ts +13 -3
  380. package/src/cli/cli-dependencies.ts +5 -0
  381. package/src/cli/cli-errors.ts +4 -2
  382. package/src/cli/cli-output.ts +18 -4
  383. package/src/cli/main.ts +6 -0
  384. package/src/cli/redocly-apis.ts +8 -4
  385. package/src/cli/ref-limits.ts +2 -2
  386. package/src/cli/run-cli.ts +20 -3
  387. package/src/domain/errors.ts +2 -0
  388. package/src/domain/ir/constructors.ts +6 -1
  389. package/src/domain/ir/nodes.ts +2 -1
  390. package/src/domain/openapi/admitted-values.ts +113 -0
  391. package/src/domain/openapi/discriminated-union.ts +109 -0
  392. package/src/domain/openapi/discriminator-conflicts.ts +251 -0
  393. package/src/domain/openapi/parameter-object.ts +4 -0
  394. package/src/domain/openapi/path-templates.ts +31 -0
  395. package/src/domain/openapi/schema-object.ts +2 -0
  396. package/src/domain/output-fixes.ts +43 -2
  397. package/src/domain/warnings.ts +20 -0
  398. package/src/transform/components-object.ts +3 -1
  399. package/src/types/generator-options.ts +11 -0
  400. package/dist/application/transform/document/path-item-conflicts.cjs +0 -51
  401. package/dist/application/transform/document/path-item-conflicts.cjs.map +0 -1
  402. package/dist/application/transform/document/path-item-conflicts.mjs +0 -49
  403. package/dist/application/transform/document/path-item-conflicts.mjs.map +0 -1
  404. package/src/application/transform/document/path-item-conflicts.ts +0 -79
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ const NO_DECLARED_TYPES = () => null;
4
+ function indexedNameOf(type) {
5
+ if (type.kind === "reference") {
6
+ return type.typeArguments.length === 0 ? { name: type.name, keys: [] } : null;
7
+ }
8
+ if (type.kind !== "indexedAccess" || type.index.kind !== "stringLiteral") {
9
+ return null;
10
+ }
11
+ const object = indexedNameOf(type.object);
12
+ return object === null ? null : { ...object, keys: [...object.keys, type.index.value] };
13
+ }
14
+ function memberName(member) {
15
+ if (member.kind !== "property") {
16
+ return null;
17
+ }
18
+ return member.name.kind === "string" ? member.name.value : member.name.text;
19
+ }
20
+ function propertyType(type, key) {
21
+ if (type.kind !== "object") {
22
+ return null;
23
+ }
24
+ const member = type.members.find((candidate) => memberName(candidate) === key);
25
+ return member?.kind === "property" && !member.isOptional ? member.type : null;
26
+ }
27
+ function declarationType(declaration) {
28
+ switch (declaration.kind) {
29
+ case "interface":
30
+ return { kind: "object", members: declaration.members };
31
+ case "typeAlias":
32
+ return declaration.type;
33
+ case "enum":
34
+ case "constArray":
35
+ case "rawDeclaration":
36
+ return null;
37
+ }
38
+ }
39
+ function declaredTypeLookup(declarations) {
40
+ const byName = /* @__PURE__ */ new Map();
41
+ for (const declaration of declarations) {
42
+ if ("name" in declaration && declaration.name !== void 0) {
43
+ const isRepeated = byName.has(declaration.name);
44
+ byName.set(declaration.name, isRepeated ? null : declarationType(declaration));
45
+ }
46
+ }
47
+ const resolving = /* @__PURE__ */ new Set();
48
+ const lookup = (type) => {
49
+ const indexed = indexedNameOf(type);
50
+ if (indexed === null || indexed.keys.length === 0 || resolving.has(type)) {
51
+ return null;
52
+ }
53
+ resolving.add(type);
54
+ const declared = indexed.keys.reduce((object, key) => {
55
+ const named = object === null || object.kind === "object" ? object : lookup(object);
56
+ return named === null ? null : propertyType(named, key);
57
+ }, byName.get(indexed.name) ?? null);
58
+ resolving.delete(type);
59
+ return declared;
60
+ };
61
+ return lookup;
62
+ }
63
+
64
+ exports.NO_DECLARED_TYPES = NO_DECLARED_TYPES;
65
+ exports.declaredTypeLookup = declaredTypeLookup;
66
+ //# sourceMappingURL=declared-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declared-types.cjs","sources":["../../../../src/application/transform/document/declared-types.ts"],"sourcesContent":["import type { IrDeclaration, IrMember, IrType } from \"../../../domain/ir/nodes.js\";\n\n/**\n * The type a reference of the generated file names, read from the file's declarations: the\n * `--path-params-as-types` overlap check compares two path items through the operations and\n * components they reference (upstream #1752).\n */\n\n/** The declared type a reference names, or null when the type is no such reference. */\nexport type DeclaredTypeLookup = (type: IrType) => IrType | null;\n\n/** Knows no declaration: every reference stays unresolved. */\nexport const NO_DECLARED_TYPES: DeclaredTypeLookup = () => null;\n\n/** A reference without type arguments and the string keys indexing it: `components[\"schemas\"]`. */\ninterface IndexedName {\n readonly name: string;\n readonly keys: readonly string[];\n}\n\nfunction indexedNameOf(type: IrType): IndexedName | null {\n if (type.kind === \"reference\") {\n return type.typeArguments.length === 0 ? { name: type.name, keys: [] } : null;\n }\n if (type.kind !== \"indexedAccess\" || type.index.kind !== \"stringLiteral\") {\n return null;\n }\n const object = indexedNameOf(type.object);\n return object === null ? null : { ...object, keys: [...object.keys, type.index.value] };\n}\n\nfunction memberName(member: IrMember): string | null {\n if (member.kind !== \"property\") {\n return null;\n }\n return member.name.kind === \"string\" ? member.name.value : member.name.text;\n}\n\n/**\n * The type of the required property `key`. An optional one is `T | undefined` when indexed, which\n * is not the declared type, so it is not followed.\n */\nfunction propertyType(type: IrType, key: string): IrType | null {\n if (type.kind !== \"object\") {\n return null;\n }\n const member = type.members.find((candidate) => memberName(candidate) === key);\n return member?.kind === \"property\" && !member.isOptional ? member.type : null;\n}\n\nfunction declarationType(declaration: IrDeclaration): IrType | null {\n switch (declaration.kind) {\n case \"interface\":\n return { kind: \"object\", members: declaration.members };\n case \"typeAlias\":\n return declaration.type;\n case \"enum\":\n case \"constArray\":\n case \"rawDeclaration\":\n return null;\n }\n}\n\n/**\n * A lookup over the declarations. Only a name declared once is read: a second declaration of an\n * interface merges with the first, which this lookup does not model.\n */\nexport function declaredTypeLookup(declarations: readonly IrDeclaration[]): DeclaredTypeLookup {\n const byName = new Map<string, IrType | null>();\n for (const declaration of declarations) {\n if (\"name\" in declaration && declaration.name !== undefined) {\n const isRepeated = byName.has(declaration.name);\n byName.set(declaration.name, isRepeated ? null : declarationType(declaration));\n }\n }\n // References being resolved: a reference that indexes into itself names no type.\n const resolving = new Set<IrType>();\n const lookup: DeclaredTypeLookup = (type) => {\n const indexed = indexedNameOf(type);\n if (indexed === null || indexed.keys.length === 0 || resolving.has(type)) {\n return null;\n }\n resolving.add(type);\n // A key may index a property whose type is a reference again (`paths[\"/a\"][\"get\"]`).\n const declared = indexed.keys.reduce<IrType | null>((object, key) => {\n const named = object === null || object.kind === \"object\" ? object : lookup(object);\n return named === null ? null : propertyType(named, key);\n }, byName.get(indexed.name) ?? null);\n resolving.delete(type);\n return declared;\n };\n return lookup;\n}\n"],"names":[],"mappings":";;AAYO,MAAM,oBAAwC,MAAM;AAQ3D,SAAS,cAAc,IAAA,EAAkC;AACvD,EAAA,IAAI,IAAA,CAAK,SAAS,WAAA,EAAa;AAC7B,IAAA,OAAO,IAAA,CAAK,aAAA,CAAc,MAAA,KAAW,CAAA,GAAI,EAAE,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,IAAA,EAAM,EAAC,EAAE,GAAI,IAAA;AAAA,EAC3E;AACA,EAAA,IAAI,KAAK,IAAA,KAAS,eAAA,IAAmB,IAAA,CAAK,KAAA,CAAM,SAAS,eAAA,EAAiB;AACxE,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,MAAA,GAAS,aAAA,CAAc,IAAA,CAAK,MAAM,CAAA;AACxC,EAAA,OAAO,MAAA,KAAW,IAAA,GAAO,IAAA,GAAO,EAAE,GAAG,MAAA,EAAQ,IAAA,EAAM,CAAC,GAAG,MAAA,CAAO,IAAA,EAAM,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA,EAAE;AACxF;AAEA,SAAS,WAAW,MAAA,EAAiC;AACnD,EAAA,IAAI,MAA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AA,CAAgB,WAAW,CAAC,CAAA;AAAA,IAC/E;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAY;AAClC,EAAA,MAAM,MAAA,GAA6B,CAAC,IAAA,KAAS;AAC3C,IAAA,MAAM,OAAA,GAAU,cAAc,IAAI,CAAA;AAClC,IAAA,IAAI,OAAA,KAAY,QAAQ,OAAA,CAAQ,IAAA,CAAK,WAAW,CAAA,IAAK,SAAA,CAAU,GAAA,CAAI,IAAI,CAAA,EAAG;AACxE,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,SAAA,CAAU,IAAI,IAAI,CAAA;AAElB,IAAA,MAAM,WAAW,OAAA,CAAQ,IAAA,CAAK,MAAA,CAAsB,CAAC,QAAQ,GAAA,KAAQ;AACnE,MAAA,MAAM,KAAA,GAAQ,WAAW,IAAA,IAAQ,MAAA,CAAO,SAAS,QAAA,GAAW,MAAA,GAAS,OAAO,MAAM,CAAA;AAClF,MAAA,OAAO,KAAA,KAAU,IAAA,GAAO,IAAA,GAAO,YAAA,CAAa,OAAO,GAAG,CAAA;AAAA,IACxD,GAAG,MAAA,CAAO,GAAA,CAAI,OAAA,CAAQ,IAAI,KAAK,IAAI,CAAA;AACnC,IAAA,SAAA,CAAU,OAAO,IAAI,CAAA;AACrB,IAAA,OAAO,QAAA;AAAA,EACT,CAAA;AACA,EAAA,OAAO,MAAA;AACT;;;"}
@@ -0,0 +1,63 @@
1
+ const NO_DECLARED_TYPES = () => null;
2
+ function indexedNameOf(type) {
3
+ if (type.kind === "reference") {
4
+ return type.typeArguments.length === 0 ? { name: type.name, keys: [] } : null;
5
+ }
6
+ if (type.kind !== "indexedAccess" || type.index.kind !== "stringLiteral") {
7
+ return null;
8
+ }
9
+ const object = indexedNameOf(type.object);
10
+ return object === null ? null : { ...object, keys: [...object.keys, type.index.value] };
11
+ }
12
+ function memberName(member) {
13
+ if (member.kind !== "property") {
14
+ return null;
15
+ }
16
+ return member.name.kind === "string" ? member.name.value : member.name.text;
17
+ }
18
+ function propertyType(type, key) {
19
+ if (type.kind !== "object") {
20
+ return null;
21
+ }
22
+ const member = type.members.find((candidate) => memberName(candidate) === key);
23
+ return member?.kind === "property" && !member.isOptional ? member.type : null;
24
+ }
25
+ function declarationType(declaration) {
26
+ switch (declaration.kind) {
27
+ case "interface":
28
+ return { kind: "object", members: declaration.members };
29
+ case "typeAlias":
30
+ return declaration.type;
31
+ case "enum":
32
+ case "constArray":
33
+ case "rawDeclaration":
34
+ return null;
35
+ }
36
+ }
37
+ function declaredTypeLookup(declarations) {
38
+ const byName = /* @__PURE__ */ new Map();
39
+ for (const declaration of declarations) {
40
+ if ("name" in declaration && declaration.name !== void 0) {
41
+ const isRepeated = byName.has(declaration.name);
42
+ byName.set(declaration.name, isRepeated ? null : declarationType(declaration));
43
+ }
44
+ }
45
+ const resolving = /* @__PURE__ */ new Set();
46
+ const lookup = (type) => {
47
+ const indexed = indexedNameOf(type);
48
+ if (indexed === null || indexed.keys.length === 0 || resolving.has(type)) {
49
+ return null;
50
+ }
51
+ resolving.add(type);
52
+ const declared = indexed.keys.reduce((object, key) => {
53
+ const named = object === null || object.kind === "object" ? object : lookup(object);
54
+ return named === null ? null : propertyType(named, key);
55
+ }, byName.get(indexed.name) ?? null);
56
+ resolving.delete(type);
57
+ return declared;
58
+ };
59
+ return lookup;
60
+ }
61
+
62
+ export { NO_DECLARED_TYPES, declaredTypeLookup };
63
+ //# sourceMappingURL=declared-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declared-types.mjs","sources":["../../../../src/application/transform/document/declared-types.ts"],"sourcesContent":["import type { IrDeclaration, IrMember, IrType } from \"../../../domain/ir/nodes.js\";\n\n/**\n * The type a reference of the generated file names, read from the file's declarations: the\n * `--path-params-as-types` overlap check compares two path items through the operations and\n * components they reference (upstream #1752).\n */\n\n/** The declared type a reference names, or null when the type is no such reference. */\nexport type DeclaredTypeLookup = (type: IrType) => IrType | null;\n\n/** Knows no declaration: every reference stays unresolved. */\nexport const NO_DECLARED_TYPES: DeclaredTypeLookup = () => null;\n\n/** A reference without type arguments and the string keys indexing it: `components[\"schemas\"]`. */\ninterface IndexedName {\n readonly name: string;\n readonly keys: readonly string[];\n}\n\nfunction indexedNameOf(type: IrType): IndexedName | null {\n if (type.kind === \"reference\") {\n return type.typeArguments.length === 0 ? { name: type.name, keys: [] } : null;\n }\n if (type.kind !== \"indexedAccess\" || type.index.kind !== \"stringLiteral\") {\n return null;\n }\n const object = indexedNameOf(type.object);\n return object === null ? null : { ...object, keys: [...object.keys, type.index.value] };\n}\n\nfunction memberName(member: IrMember): string | null {\n if (member.kind !== \"property\") {\n return null;\n }\n return member.name.kind === \"string\" ? member.name.value : member.name.text;\n}\n\n/**\n * The type of the required property `key`. An optional one is `T | undefined` when indexed, which\n * is not the declared type, so it is not followed.\n */\nfunction propertyType(type: IrType, key: string): IrType | null {\n if (type.kind !== \"object\") {\n return null;\n }\n const member = type.members.find((candidate) => memberName(candidate) === key);\n return member?.kind === \"property\" && !member.isOptional ? member.type : null;\n}\n\nfunction declarationType(declaration: IrDeclaration): IrType | null {\n switch (declaration.kind) {\n case \"interface\":\n return { kind: \"object\", members: declaration.members };\n case \"typeAlias\":\n return declaration.type;\n case \"enum\":\n case \"constArray\":\n case \"rawDeclaration\":\n return null;\n }\n}\n\n/**\n * A lookup over the declarations. Only a name declared once is read: a second declaration of an\n * interface merges with the first, which this lookup does not model.\n */\nexport function declaredTypeLookup(declarations: readonly IrDeclaration[]): DeclaredTypeLookup {\n const byName = new Map<string, IrType | null>();\n for (const declaration of declarations) {\n if (\"name\" in declaration && declaration.name !== undefined) {\n const isRepeated = byName.has(declaration.name);\n byName.set(declaration.name, isRepeated ? null : declarationType(declaration));\n }\n }\n // References being resolved: a reference that indexes into itself names no type.\n const resolving = new Set<IrType>();\n const lookup: DeclaredTypeLookup = (type) => {\n const indexed = indexedNameOf(type);\n if (indexed === null || indexed.keys.length === 0 || resolving.has(type)) {\n return null;\n }\n resolving.add(type);\n // A key may index a property whose type is a reference again (`paths[\"/a\"][\"get\"]`).\n const declared = indexed.keys.reduce<IrType | null>((object, key) => {\n const named = object === null || object.kind === \"object\" ? object : lookup(object);\n return named === null ? null : propertyType(named, key);\n }, byName.get(indexed.name) ?? null);\n resolving.delete(type);\n return declared;\n };\n return lookup;\n}\n"],"names":[],"mappings":"AAYO,MAAM,oBAAwC,MAAM;AAQ3D,SAAS,cAAc,IAAA,EAAkC;AACvD,EAAA,IAAI,IAAA,CAAK,SAAS,WAAA,EAAa;AAC7B,IAAA,OAAO,IAAA,CAAK,aAAA,CAAc,MAAA,KAAW,CAAA,GAAI,EAAE,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,IAAA,EAAM,EAAC,EAAE,GAAI,IAAA;AAAA,EAC3E;AACA,EAAA,IAAI,KAAK,IAAA,KAAS,eAAA,IAAmB,IAAA,CAAK,KAAA,CAAM,SAAS,eAAA,EAAiB;AACxE,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,MAAA,GAAS,aAAA,CAAc,IAAA,CAAK,MAAM,CAAA;AACxC,EAAA,OAAO,MAAA,KAAW,IAAA,GAAO,IAAA,GAAO,EAAE,GAAG,MAAA,EAAQ,IAAA,EAAM,CAAC,GAAG,MAAA,CAAO,IAAA,EAAM,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA,EAAE;AACxF;AAEA,SAAS,WAAW,MAAA,EAAiC;AACnD,EAAA,IAAI,MAAA,CAAO,SAAS,UAAA,EAAY;AAC9B,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,MAAA,CAAO,KAAK,IAAA,KAAS,QAAA,GAAW,OAAO,IAAA,CAAK,KAAA,GAAQ,OAAO,IAAA,CAAK,IAAA;AACzE;AAMA,SAAS,YAAA,CAAa,MAAc,GAAA,EAA4B;AAC9D,EAAA,IAAI,IAAA,CAAK,SAAS,QAAA,EAAU;AAC1B,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA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xE,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,SAAA,CAAU,IAAI,IAAI,CAAA;AAElB,IAAA,MAAM,WAAW,OAAA,CAAQ,IAAA,CAAK,MAAA,CAAsB,CAAC,QAAQ,GAAA,KAAQ;AACnE,MAAA,MAAM,KAAA,GAAQ,WAAW,IAAA,IAAQ,MAAA,CAAO,SAAS,QAAA,GAAW,MAAA,GAAS,OAAO,MAAM,CAAA;AAClF,MAAA,OAAO,KAAA,KAAU,IAAA,GAAO,IAAA,GAAO,YAAA,CAAa,OAAO,GAAG,CAAA;AAAA,IACxD,GAAG,MAAA,CAAO,GAAA,CAAI,OAAA,CAAQ,IAAI,KAAK,IAAI,CAAA;AACnC,IAAA,SAAA,CAAU,OAAO,IAAI,CAAA;AACrB,IAAA,OAAO,QAAA;AAAA,EACT,CAAA;AACA,EAAA,OAAO,MAAA;AACT;;"}
@@ -3,6 +3,7 @@
3
3
  const constructors = require('../../../domain/ir/constructors.cjs');
4
4
  const helperTypes = require('../helper-types.cjs');
5
5
  const components = require('./components.cjs');
6
+ const declaredTypes = require('./declared-types.cjs');
6
7
  const defsRoot = require('./defs-root.cjs');
7
8
  const keptDeprecated$1 = require('./kept-deprecated.cjs');
8
9
  const paths = require('./paths.cjs');
@@ -16,7 +17,14 @@ function keptDeprecated(document, context) {
16
17
  return context.options.excludeDeprecated ? keptDeprecated$1.keptDeprecatedComponents(document, context.refs) : /* @__PURE__ */ new Set();
17
18
  }
18
19
  const ROOT_TRANSFORMS = {
19
- paths: (node, context) => ({ type: paths.pathsType(node, context), aliases: [] }),
20
+ paths: (node, context) => {
21
+ const members = paths.pathMembers(node, context);
22
+ return {
23
+ type: constructors.irObject(members.map(({ member }) => member)),
24
+ aliases: [],
25
+ withDeclaredTypes: (lookup) => paths.pathsObjectType(members, lookup)
26
+ };
27
+ },
20
28
  webhooks: (node, context) => ({ type: webhooks.webhooksType(node, context), aliases: [] }),
21
29
  components: (node, context, document) => {
22
30
  const kept = keptDeprecated(document, context);
@@ -41,22 +49,39 @@ function rootDeclarations(root, document, context) {
41
49
  const node = document[root];
42
50
  if (!node || typeof node !== "object") {
43
51
  context.diagnostics.debug(`${root} done (skipped)`, 0);
44
- return [emptyAlias(root)];
52
+ return { declarations: [emptyAlias(root)] };
45
53
  }
46
54
  const startedAt = context.diagnostics.now();
47
- const { type, aliases } = ROOT_TRANSFORMS[root](node, context, document);
55
+ const { type, aliases, withDeclaredTypes } = ROOT_TRANSFORMS[root](node, context, document);
48
56
  if (!isRootBody(type)) {
49
57
  context.diagnostics.debug(`${root} done (skipped)`, 0);
50
- return [emptyAlias(root), ...aliases];
58
+ return { declarations: [emptyAlias(root), ...aliases] };
51
59
  }
52
60
  const declaration = rootDeclaration(root, type, context.options);
53
61
  context.diagnostics.debug(`${root} done`, context.diagnostics.now() - startedAt);
54
- return [declaration, ...aliases];
62
+ const finish = withDeclaredTypes && ((lookup) => {
63
+ const finished = withDeclaredTypes(lookup);
64
+ return isRootBody(finished) ? rootDeclaration(root, finished, context.options) : declaration;
65
+ });
66
+ return { declarations: [declaration, ...aliases], ...finish ? { finish } : {} };
67
+ }
68
+ function rootsDeclarations(document, context, footer) {
69
+ const roots = ROOT_KEYS.map((root) => rootDeclarations(root, document, context));
70
+ const transformed = roots.flatMap(({ declarations }) => declarations);
71
+ if (roots.every(({ finish }) => finish === void 0)) {
72
+ return transformed;
73
+ }
74
+ const lookup = declaredTypes.declaredTypeLookup([...transformed, ...footer()]);
75
+ return roots.flatMap(({ declarations, finish }) => {
76
+ const [declaration, ...aliases] = declarations;
77
+ return finish === void 0 || declaration === void 0 ? declarations : [finish(lookup), ...aliases];
78
+ });
55
79
  }
56
80
  function withoutBlankLinesAround(text) {
57
81
  return text.replace(/^(?:[ \t]*\r?\n)+/, "").trimEnd();
58
82
  }
59
- function documentBody(document, context) {
83
+ const NO_FOOTER = () => [];
84
+ function documentBody(document, context, footer = NO_FOOTER) {
60
85
  const declarations = [];
61
86
  if (context.options.readWriteMarkers) {
62
87
  declarations.push({ kind: "rawDeclaration", text: helperTypes.READ_WRITE_MARKER_TYPES });
@@ -65,9 +90,7 @@ function documentBody(document, context) {
65
90
  if (inject !== "") {
66
91
  declarations.push({ kind: "rawDeclaration", text: inject });
67
92
  }
68
- for (const root of ROOT_KEYS) {
69
- declarations.push(...rootDeclarations(root, document, context));
70
- }
93
+ declarations.push(...rootsDeclarations(document, context, footer));
71
94
  return declarations;
72
95
  }
73
96
  function documentClosing(document, context, hasOperations) {
@@ -1 +1 @@
1
- {"version":3,"file":"document.cjs","sources":["../../../../src/application/transform/document/document.ts"],"sourcesContent":["import { irKeyword, irRecord } from \"../../../domain/ir/constructors.js\";\nimport type {\n IrDeclaration,\n IrIntersectionType,\n IrObjectType,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport type { ComponentsObject } from \"../../../domain/openapi/components-object.js\";\nimport type { DocumentObject } from \"../../../domain/openapi/document-object.js\";\nimport type { PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { READ_WRITE_MARKER_TYPES } from \"../helper-types.js\";\nimport type { TransformContext, TransformOptions } from \"../transform-context.js\";\nimport { componentsType } from \"./components.js\";\nimport { defsRootType } from \"./defs-root.js\";\nimport { keptDeprecatedComponents } from \"./kept-deprecated.js\";\nimport { pathsType } from \"./paths.js\";\nimport { apiPathsEnumDeclaration } from \"./paths-enum.js\";\nimport { webhooksType } from \"./webhooks.js\";\n\n/** The root types, in output order. */\nconst ROOT_KEYS = Object.freeze([\"paths\", \"webhooks\", \"components\", \"$defs\"] as const);\ntype RootKey = (typeof ROOT_KEYS)[number];\n\nconst OPERATIONS_NAME = \"operations\";\n/** The type of a root without members: `Record<string, never>`. */\nconst EMPTY_ROOT_TYPE = irRecord(irKeyword(\"string\"), irKeyword(\"never\"));\n\n/** A root's type and the declarations that follow it (the `--root-types` aliases). */\ninterface RootResult {\n readonly type: IrType;\n readonly aliases: readonly IrTypeAliasDeclaration[];\n}\n\ntype RootTransform = (\n node: object,\n context: TransformContext,\n document: DocumentObject,\n) => RootResult;\n\n/** Without `--exclude-deprecated` nothing is left out, so the scan is skipped. */\nfunction keptDeprecated(document: DocumentObject, context: TransformContext): ReadonlySet<object> {\n return context.options.excludeDeprecated\n ? keptDeprecatedComponents(document, context.refs)\n : new Set();\n}\n\nconst ROOT_TRANSFORMS: Readonly<Record<RootKey, RootTransform>> = {\n paths: (node, context) => ({ type: pathsType(node as PathsObject, context), aliases: [] }),\n webhooks: (node, context) => ({ type: webhooksType(node as PathsObject, context), aliases: [] }),\n components: (node, context, document) => {\n const kept = keptDeprecated(document, context);\n const { type, rootTypes } = componentsType(node as ComponentsObject, context, kept);\n return { type, aliases: rootTypes };\n },\n $defs: (node, context) => ({\n type: defsRootType(node as NonNullable<DocumentObject[\"$defs\"]>, context),\n aliases: [],\n }),\n};\n\nfunction emptyAlias(name: string): IrTypeAliasDeclaration {\n return { kind: \"typeAlias\", name, isExported: true, type: EMPTY_ROOT_TYPE, comments: [] };\n}\n\n/** A root type that declares something: an object with members, or an intersection of them. */\ntype RootBodyType = IrObjectType | IrIntersectionType;\n\nfunction isRootBody(type: IrType): type is RootBodyType {\n return (type.kind === \"object\" && type.members.length > 0) || type.kind === \"intersection\";\n}\n\n/**\n * A root with members: an interface, or a type alias with `--export-type`. An intersection (the\n * `paths` of overlapping `--path-params-as-types` keys) can only be a type alias.\n */\nfunction rootDeclaration(\n name: RootKey,\n type: RootBodyType,\n options: TransformOptions,\n): IrDeclaration {\n return options.exportType || type.kind === \"intersection\"\n ? { kind: \"typeAlias\", name, isExported: true, type, comments: [] }\n : { kind: \"interface\", name, isExported: true, members: type.members, comments: [] };\n}\n\n/**\n * The declarations of one root. A root that is missing, or whose type has no members, is\n * `Record<string, never>`. Only an object type (or the `paths` intersection) counts as having\n * members: a callback type the IR keeps as raw text does not (ADR-004).\n */\nfunction rootDeclarations(\n root: RootKey,\n document: DocumentObject,\n context: TransformContext,\n): IrDeclaration[] {\n const node: unknown = document[root];\n if (!node || typeof node !== \"object\") {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return [emptyAlias(root)];\n }\n const startedAt = context.diagnostics.now();\n const { type, aliases } = ROOT_TRANSFORMS[root](node, context, document);\n if (!isRootBody(type)) {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return [emptyAlias(root), ...aliases];\n }\n const declaration = rootDeclaration(root, type, context.options);\n context.diagnostics.debug(`${root} done`, context.diagnostics.now() - startedAt);\n return [declaration, ...aliases];\n}\n\n/**\n * The `inject` text as written (ADR-010, decision 4), without the blank lines around it. The\n * original reprinted it with the TypeScript printer; text without code printed nothing then.\n */\nfunction withoutBlankLinesAround(text: string): string {\n return text.replace(/^(?:[ \\t]*\\r?\\n)+/, \"\").trimEnd();\n}\n\n/**\n * The document's declarations before the footer: helper types, injected code, then one root type\n * per root key with the aliases that follow it.\n */\nexport function documentBody(document: DocumentObject, context: TransformContext): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (context.options.readWriteMarkers) {\n declarations.push({ kind: \"rawDeclaration\", text: READ_WRITE_MARKER_TYPES });\n }\n const inject = withoutBlankLinesAround(context.options.inject ?? \"\");\n if (inject !== \"\") {\n declarations.push({ kind: \"rawDeclaration\", text: inject });\n }\n for (const root of ROOT_KEYS) {\n declarations.push(...rootDeclarations(root, document, context));\n }\n return declarations;\n}\n\n/**\n * The declarations after the footer: an empty `operations` type when the footer has no\n * operations, and the `--make-paths-enum` enum.\n */\nexport function documentClosing(\n document: DocumentObject,\n context: TransformContext,\n hasOperations: boolean,\n): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (!hasOperations) {\n declarations.push(emptyAlias(OPERATIONS_NAME));\n }\n if (context.options.makePathsEnum && document.paths) {\n declarations.push(apiPathsEnumDeclaration(document.paths));\n }\n return declarations;\n}\n"],"names":["irRecord","irKeyword","keptDeprecatedComponents","pathsType","webhooksType","componentsType","defsRootType","READ_WRITE_MARKER_TYPES","apiPathsEnumDeclaration"],"mappings":";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A,EACA,aAAA,EACiB;AACjB,EAAA,MAAM,eAAgC,EAAC;AACvC,EAAA,IAAI,CAAC,aAAA,EAAe;AAClB,IAAA,YAAA,CAAa,IAAA,CAAK,UAAA,CAAW,eAAe,CAAC,CAAA;AAAA,EAC/C;AACA,EAAA,IAAI,OAAA,CAAQ,OAAA,CAAQ,aAAA,IAAiB,QAAA,CAAS,KAAA,EAAO;AACnD,IAAA,YAAA,CAAa,IAAA,CAAKC,iCAAA,CAAwB,QAAA,CAAS,KAAK,CAAC,CAAA;AAAA,EAC3D;AACA,EAAA,OAAO,YAAA;AACT;;;"}
1
+ {"version":3,"file":"document.cjs","sources":["../../../../src/application/transform/document/document.ts"],"sourcesContent":["import { irKeyword, irObject, irRecord } from \"../../../domain/ir/constructors.js\";\nimport type {\n IrDeclaration,\n IrIntersectionType,\n IrObjectType,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport type { ComponentsObject } from \"../../../domain/openapi/components-object.js\";\nimport type { DocumentObject } from \"../../../domain/openapi/document-object.js\";\nimport type { PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { READ_WRITE_MARKER_TYPES } from \"../helper-types.js\";\nimport type { TransformContext, TransformOptions } from \"../transform-context.js\";\nimport { componentsType } from \"./components.js\";\nimport { type DeclaredTypeLookup, declaredTypeLookup } from \"./declared-types.js\";\nimport { defsRootType } from \"./defs-root.js\";\nimport { keptDeprecatedComponents } from \"./kept-deprecated.js\";\nimport { pathMembers, pathsObjectType } from \"./paths.js\";\nimport { apiPathsEnumDeclaration } from \"./paths-enum.js\";\nimport { webhooksType } from \"./webhooks.js\";\n\n/** The root types, in output order. */\nconst ROOT_KEYS = Object.freeze([\"paths\", \"webhooks\", \"components\", \"$defs\"] as const);\ntype RootKey = (typeof ROOT_KEYS)[number];\n\nconst OPERATIONS_NAME = \"operations\";\n/** The type of a root without members: `Record<string, never>`. */\nconst EMPTY_ROOT_TYPE = irRecord(irKeyword(\"string\"), irKeyword(\"never\"));\n\n/** A root's type and the declarations that follow it (the `--root-types` aliases). */\ninterface RootResult {\n readonly type: IrType;\n readonly aliases: readonly IrTypeAliasDeclaration[];\n /**\n * The root's final type, for a root that reads the types the whole file declares (`paths`, whose\n * overlap check follows references). `type` then only tells whether the root has members.\n */\n readonly withDeclaredTypes?: (lookup: DeclaredTypeLookup) => IrType;\n}\n\ntype RootTransform = (\n node: object,\n context: TransformContext,\n document: DocumentObject,\n) => RootResult;\n\n/** Without `--exclude-deprecated` nothing is left out, so the scan is skipped. */\nfunction keptDeprecated(document: DocumentObject, context: TransformContext): ReadonlySet<object> {\n return context.options.excludeDeprecated\n ? keptDeprecatedComponents(document, context.refs)\n : new Set();\n}\n\nconst ROOT_TRANSFORMS: Readonly<Record<RootKey, RootTransform>> = {\n paths: (node, context) => {\n const members = pathMembers(node as PathsObject, context);\n return {\n type: irObject(members.map(({ member }) => member)),\n aliases: [],\n withDeclaredTypes: (lookup) => pathsObjectType(members, lookup),\n };\n },\n webhooks: (node, context) => ({ type: webhooksType(node as PathsObject, context), aliases: [] }),\n components: (node, context, document) => {\n const kept = keptDeprecated(document, context);\n const { type, rootTypes } = componentsType(node as ComponentsObject, context, kept);\n return { type, aliases: rootTypes };\n },\n $defs: (node, context) => ({\n type: defsRootType(node as NonNullable<DocumentObject[\"$defs\"]>, context),\n aliases: [],\n }),\n};\n\nfunction emptyAlias(name: string): IrTypeAliasDeclaration {\n return { kind: \"typeAlias\", name, isExported: true, type: EMPTY_ROOT_TYPE, comments: [] };\n}\n\n/** A root type that declares something: an object with members, or an intersection of them. */\ntype RootBodyType = IrObjectType | IrIntersectionType;\n\nfunction isRootBody(type: IrType): type is RootBodyType {\n return (type.kind === \"object\" && type.members.length > 0) || type.kind === \"intersection\";\n}\n\n/**\n * A root with members: an interface, or a type alias with `--export-type`. An intersection (the\n * `paths` of overlapping `--path-params-as-types` keys) can only be a type alias.\n */\nfunction rootDeclaration(\n name: RootKey,\n type: RootBodyType,\n options: TransformOptions,\n): IrDeclaration {\n return options.exportType || type.kind === \"intersection\"\n ? { kind: \"typeAlias\", name, isExported: true, type, comments: [] }\n : { kind: \"interface\", name, isExported: true, members: type.members, comments: [] };\n}\n\n/**\n * The declarations of one root: its type, then its aliases. `finish` gives the root's declaration\n * again from the types the whole file declares, for a root with `withDeclaredTypes`.\n */\ninterface RootDeclarations {\n readonly declarations: readonly IrDeclaration[];\n readonly finish?: (lookup: DeclaredTypeLookup) => IrDeclaration;\n}\n\n/**\n * The declarations of one root. A root that is missing, or whose type has no members, is\n * `Record<string, never>`. Only an object type (or the `paths` intersection) counts as having\n * members: a callback type the IR keeps as raw text does not (ADR-004).\n */\nfunction rootDeclarations(\n root: RootKey,\n document: DocumentObject,\n context: TransformContext,\n): RootDeclarations {\n const node: unknown = document[root];\n if (!node || typeof node !== \"object\") {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return { declarations: [emptyAlias(root)] };\n }\n const startedAt = context.diagnostics.now();\n const { type, aliases, withDeclaredTypes } = ROOT_TRANSFORMS[root](node, context, document);\n if (!isRootBody(type)) {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return { declarations: [emptyAlias(root), ...aliases] };\n }\n const declaration = rootDeclaration(root, type, context.options);\n context.diagnostics.debug(`${root} done`, context.diagnostics.now() - startedAt);\n const finish =\n withDeclaredTypes &&\n ((lookup: DeclaredTypeLookup) => {\n const finished = withDeclaredTypes(lookup);\n return isRootBody(finished) ? rootDeclaration(root, finished, context.options) : declaration;\n });\n return { declarations: [declaration, ...aliases], ...(finish ? { finish } : {}) };\n}\n\n/**\n * Every root's declarations in output order. A root with `finish` gets its declaration from the\n * types of the other roots and of the footer (the `operations` interface), which exist only once\n * every root is transformed.\n */\nfunction rootsDeclarations(\n document: DocumentObject,\n context: TransformContext,\n footer: () => readonly IrDeclaration[],\n): IrDeclaration[] {\n const roots = ROOT_KEYS.map((root) => rootDeclarations(root, document, context));\n const transformed = roots.flatMap(({ declarations }) => declarations);\n if (roots.every(({ finish }) => finish === undefined)) {\n return transformed;\n }\n const lookup = declaredTypeLookup([...transformed, ...footer()]);\n return roots.flatMap(({ declarations, finish }) => {\n const [declaration, ...aliases] = declarations;\n return finish === undefined || declaration === undefined\n ? declarations\n : [finish(lookup), ...aliases];\n });\n}\n\n/**\n * The `inject` text as written (ADR-010, decision 4), without the blank lines around it. The\n * original reprinted it with the TypeScript printer; text without code printed nothing then.\n */\nfunction withoutBlankLinesAround(text: string): string {\n return text.replace(/^(?:[ \\t]*\\r?\\n)+/, \"\").trimEnd();\n}\n\n/** No footer declarations: the roots' references to `operations` stay unresolved. */\nconst NO_FOOTER = (): readonly IrDeclaration[] => [];\n\n/**\n * The document's declarations before the footer: helper types, injected code, then one root type\n * per root key with the aliases that follow it. `footer` reads the footer's declarations once the\n * roots are transformed.\n */\nexport function documentBody(\n document: DocumentObject,\n context: TransformContext,\n footer: () => readonly IrDeclaration[] = NO_FOOTER,\n): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (context.options.readWriteMarkers) {\n declarations.push({ kind: \"rawDeclaration\", text: READ_WRITE_MARKER_TYPES });\n }\n const inject = withoutBlankLinesAround(context.options.inject ?? \"\");\n if (inject !== \"\") {\n declarations.push({ kind: \"rawDeclaration\", text: inject });\n }\n declarations.push(...rootsDeclarations(document, context, footer));\n return declarations;\n}\n\n/**\n * The declarations after the footer: an empty `operations` type when the footer has no\n * operations, and the `--make-paths-enum` enum.\n */\nexport function documentClosing(\n document: DocumentObject,\n context: TransformContext,\n hasOperations: boolean,\n): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (!hasOperations) {\n declarations.push(emptyAlias(OPERATIONS_NAME));\n }\n if (context.options.makePathsEnum && document.paths) {\n declarations.push(apiPathsEnumDeclaration(document.paths));\n }\n return declarations;\n}\n"],"names":["irRecord","irKeyword","keptDeprecatedComponents","pathMembers","irObject","pathsObjectType","webhooksType","componentsType","defsRootType","declaredTypeLookup","READ_WRITE_MARKER_TYPES","apiPathsEnumD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,EAAM,QAAQ,CAAA;AAAA,EAC5D;AACA,EAAA,YAAA,CAAa,KAAK,GAAG,iBAAA,CAAkB,QAAA,EAAU,OAAA,EAAS,MAAM,CAAC,CAAA;AACjE,EAAA,OAAO,YAAA;AACT;AAMO,SAAS,eAAA,CACd,QAAA,EACA,OAAA,EACA,aAAA,EACiB;AACjB,EAAA,MAAM,eAAgC,EAAC;AACvC,EAAA,IAAI,CAAC,aAAA,EAAe;AAClB,IAAA,YAAA,CAAa,IAAA,CAAK,UAAA,CAAW,eAAe,CAAC,CAAA;AAAA,EAC/C;AACA,EAAA,IAAI,OAAA,CAAQ,OAAA,CAAQ,aAAA,IAAiB,QAAA,CAAS,KAAA,EAAO;AACnD,IAAA,YAAA,CAAa,IAAA,CAAKC,iCAAA,CAAwB,QAAA,CAAS,KAAK,CAAC,CAAA;AAAA,EAC3D;AACA,EAAA,OAAO,YAAA;AACT;;;"}
@@ -1,9 +1,10 @@
1
- import { irRecord, irKeyword } from '../../../domain/ir/constructors.mjs';
1
+ import { irRecord, irObject, irKeyword } from '../../../domain/ir/constructors.mjs';
2
2
  import { READ_WRITE_MARKER_TYPES } from '../helper-types.mjs';
3
3
  import { componentsType } from './components.mjs';
4
+ import { declaredTypeLookup } from './declared-types.mjs';
4
5
  import { defsRootType } from './defs-root.mjs';
5
6
  import { keptDeprecatedComponents } from './kept-deprecated.mjs';
6
- import { pathsType } from './paths.mjs';
7
+ import { pathMembers, pathsObjectType } from './paths.mjs';
7
8
  import { apiPathsEnumDeclaration } from './paths-enum.mjs';
8
9
  import { webhooksType } from './webhooks.mjs';
9
10
 
@@ -14,7 +15,14 @@ function keptDeprecated(document, context) {
14
15
  return context.options.excludeDeprecated ? keptDeprecatedComponents(document, context.refs) : /* @__PURE__ */ new Set();
15
16
  }
16
17
  const ROOT_TRANSFORMS = {
17
- paths: (node, context) => ({ type: pathsType(node, context), aliases: [] }),
18
+ paths: (node, context) => {
19
+ const members = pathMembers(node, context);
20
+ return {
21
+ type: irObject(members.map(({ member }) => member)),
22
+ aliases: [],
23
+ withDeclaredTypes: (lookup) => pathsObjectType(members, lookup)
24
+ };
25
+ },
18
26
  webhooks: (node, context) => ({ type: webhooksType(node, context), aliases: [] }),
19
27
  components: (node, context, document) => {
20
28
  const kept = keptDeprecated(document, context);
@@ -39,22 +47,39 @@ function rootDeclarations(root, document, context) {
39
47
  const node = document[root];
40
48
  if (!node || typeof node !== "object") {
41
49
  context.diagnostics.debug(`${root} done (skipped)`, 0);
42
- return [emptyAlias(root)];
50
+ return { declarations: [emptyAlias(root)] };
43
51
  }
44
52
  const startedAt = context.diagnostics.now();
45
- const { type, aliases } = ROOT_TRANSFORMS[root](node, context, document);
53
+ const { type, aliases, withDeclaredTypes } = ROOT_TRANSFORMS[root](node, context, document);
46
54
  if (!isRootBody(type)) {
47
55
  context.diagnostics.debug(`${root} done (skipped)`, 0);
48
- return [emptyAlias(root), ...aliases];
56
+ return { declarations: [emptyAlias(root), ...aliases] };
49
57
  }
50
58
  const declaration = rootDeclaration(root, type, context.options);
51
59
  context.diagnostics.debug(`${root} done`, context.diagnostics.now() - startedAt);
52
- return [declaration, ...aliases];
60
+ const finish = withDeclaredTypes && ((lookup) => {
61
+ const finished = withDeclaredTypes(lookup);
62
+ return isRootBody(finished) ? rootDeclaration(root, finished, context.options) : declaration;
63
+ });
64
+ return { declarations: [declaration, ...aliases], ...finish ? { finish } : {} };
65
+ }
66
+ function rootsDeclarations(document, context, footer) {
67
+ const roots = ROOT_KEYS.map((root) => rootDeclarations(root, document, context));
68
+ const transformed = roots.flatMap(({ declarations }) => declarations);
69
+ if (roots.every(({ finish }) => finish === void 0)) {
70
+ return transformed;
71
+ }
72
+ const lookup = declaredTypeLookup([...transformed, ...footer()]);
73
+ return roots.flatMap(({ declarations, finish }) => {
74
+ const [declaration, ...aliases] = declarations;
75
+ return finish === void 0 || declaration === void 0 ? declarations : [finish(lookup), ...aliases];
76
+ });
53
77
  }
54
78
  function withoutBlankLinesAround(text) {
55
79
  return text.replace(/^(?:[ \t]*\r?\n)+/, "").trimEnd();
56
80
  }
57
- function documentBody(document, context) {
81
+ const NO_FOOTER = () => [];
82
+ function documentBody(document, context, footer = NO_FOOTER) {
58
83
  const declarations = [];
59
84
  if (context.options.readWriteMarkers) {
60
85
  declarations.push({ kind: "rawDeclaration", text: READ_WRITE_MARKER_TYPES });
@@ -63,9 +88,7 @@ function documentBody(document, context) {
63
88
  if (inject !== "") {
64
89
  declarations.push({ kind: "rawDeclaration", text: inject });
65
90
  }
66
- for (const root of ROOT_KEYS) {
67
- declarations.push(...rootDeclarations(root, document, context));
68
- }
91
+ declarations.push(...rootsDeclarations(document, context, footer));
69
92
  return declarations;
70
93
  }
71
94
  function documentClosing(document, context, hasOperations) {
@@ -1 +1 @@
1
- {"version":3,"file":"document.mjs","sources":["../../../../src/application/transform/document/document.ts"],"sourcesContent":["import { irKeyword, irRecord } from \"../../../domain/ir/constructors.js\";\nimport type {\n IrDeclaration,\n IrIntersectionType,\n IrObjectType,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport type { ComponentsObject } from \"../../../domain/openapi/components-object.js\";\nimport type { DocumentObject } from \"../../../domain/openapi/document-object.js\";\nimport type { PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { READ_WRITE_MARKER_TYPES } from \"../helper-types.js\";\nimport type { TransformContext, TransformOptions } from \"../transform-context.js\";\nimport { componentsType } from \"./components.js\";\nimport { defsRootType } from \"./defs-root.js\";\nimport { keptDeprecatedComponents } from \"./kept-deprecated.js\";\nimport { pathsType } from \"./paths.js\";\nimport { apiPathsEnumDeclaration } from \"./paths-enum.js\";\nimport { webhooksType } from \"./webhooks.js\";\n\n/** The root types, in output order. */\nconst ROOT_KEYS = Object.freeze([\"paths\", \"webhooks\", \"components\", \"$defs\"] as const);\ntype RootKey = (typeof ROOT_KEYS)[number];\n\nconst OPERATIONS_NAME = \"operations\";\n/** The type of a root without members: `Record<string, never>`. */\nconst EMPTY_ROOT_TYPE = irRecord(irKeyword(\"string\"), irKeyword(\"never\"));\n\n/** A root's type and the declarations that follow it (the `--root-types` aliases). */\ninterface RootResult {\n readonly type: IrType;\n readonly aliases: readonly IrTypeAliasDeclaration[];\n}\n\ntype RootTransform = (\n node: object,\n context: TransformContext,\n document: DocumentObject,\n) => RootResult;\n\n/** Without `--exclude-deprecated` nothing is left out, so the scan is skipped. */\nfunction keptDeprecated(document: DocumentObject, context: TransformContext): ReadonlySet<object> {\n return context.options.excludeDeprecated\n ? keptDeprecatedComponents(document, context.refs)\n : new Set();\n}\n\nconst ROOT_TRANSFORMS: Readonly<Record<RootKey, RootTransform>> = {\n paths: (node, context) => ({ type: pathsType(node as PathsObject, context), aliases: [] }),\n webhooks: (node, context) => ({ type: webhooksType(node as PathsObject, context), aliases: [] }),\n components: (node, context, document) => {\n const kept = keptDeprecated(document, context);\n const { type, rootTypes } = componentsType(node as ComponentsObject, context, kept);\n return { type, aliases: rootTypes };\n },\n $defs: (node, context) => ({\n type: defsRootType(node as NonNullable<DocumentObject[\"$defs\"]>, context),\n aliases: [],\n }),\n};\n\nfunction emptyAlias(name: string): IrTypeAliasDeclaration {\n return { kind: \"typeAlias\", name, isExported: true, type: EMPTY_ROOT_TYPE, comments: [] };\n}\n\n/** A root type that declares something: an object with members, or an intersection of them. */\ntype RootBodyType = IrObjectType | IrIntersectionType;\n\nfunction isRootBody(type: IrType): type is RootBodyType {\n return (type.kind === \"object\" && type.members.length > 0) || type.kind === \"intersection\";\n}\n\n/**\n * A root with members: an interface, or a type alias with `--export-type`. An intersection (the\n * `paths` of overlapping `--path-params-as-types` keys) can only be a type alias.\n */\nfunction rootDeclaration(\n name: RootKey,\n type: RootBodyType,\n options: TransformOptions,\n): IrDeclaration {\n return options.exportType || type.kind === \"intersection\"\n ? { kind: \"typeAlias\", name, isExported: true, type, comments: [] }\n : { kind: \"interface\", name, isExported: true, members: type.members, comments: [] };\n}\n\n/**\n * The declarations of one root. A root that is missing, or whose type has no members, is\n * `Record<string, never>`. Only an object type (or the `paths` intersection) counts as having\n * members: a callback type the IR keeps as raw text does not (ADR-004).\n */\nfunction rootDeclarations(\n root: RootKey,\n document: DocumentObject,\n context: TransformContext,\n): IrDeclaration[] {\n const node: unknown = document[root];\n if (!node || typeof node !== \"object\") {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return [emptyAlias(root)];\n }\n const startedAt = context.diagnostics.now();\n const { type, aliases } = ROOT_TRANSFORMS[root](node, context, document);\n if (!isRootBody(type)) {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return [emptyAlias(root), ...aliases];\n }\n const declaration = rootDeclaration(root, type, context.options);\n context.diagnostics.debug(`${root} done`, context.diagnostics.now() - startedAt);\n return [declaration, ...aliases];\n}\n\n/**\n * The `inject` text as written (ADR-010, decision 4), without the blank lines around it. The\n * original reprinted it with the TypeScript printer; text without code printed nothing then.\n */\nfunction withoutBlankLinesAround(text: string): string {\n return text.replace(/^(?:[ \\t]*\\r?\\n)+/, \"\").trimEnd();\n}\n\n/**\n * The document's declarations before the footer: helper types, injected code, then one root type\n * per root key with the aliases that follow it.\n */\nexport function documentBody(document: DocumentObject, context: TransformContext): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (context.options.readWriteMarkers) {\n declarations.push({ kind: \"rawDeclaration\", text: READ_WRITE_MARKER_TYPES });\n }\n const inject = withoutBlankLinesAround(context.options.inject ?? \"\");\n if (inject !== \"\") {\n declarations.push({ kind: \"rawDeclaration\", text: inject });\n }\n for (const root of ROOT_KEYS) {\n declarations.push(...rootDeclarations(root, document, context));\n }\n return declarations;\n}\n\n/**\n * The declarations after the footer: an empty `operations` type when the footer has no\n * operations, and the `--make-paths-enum` enum.\n */\nexport function documentClosing(\n document: DocumentObject,\n context: TransformContext,\n hasOperations: boolean,\n): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (!hasOperations) {\n declarations.push(emptyAlias(OPERATIONS_NAME));\n }\n if (context.options.makePathsEnum && document.paths)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YAAA;AACT;AAMO,SAAS,eAAA,CACd,QAAA,EACA,OAAA,EACA,aAAA,EACiB;AACjB,EAAA,MAAM,eAAgC,EAAC;AACvC,EAAA,IAAI,CAAC,aAAA,EAAe;AAClB,IAAA,YAAA,CAAa,IAAA,CAAK,UAAA,CAAW,eAAe,CAAC,CAAA;AAAA,EAC/C;AACA,EAAA,IAAI,OAAA,CAAQ,OAAA,CAAQ,aAAA,IAAiB,QAAA,CAAS,KAAA,EAAO;AACnD,IAAA,YAAA,CAAa,IAAA,CAAK,uBAAA,CAAwB,QAAA,CAAS,KAAK,CAAC,CAAA;AAAA,EAC3D;AACA,EAAA,OAAO,YAAA;AACT;;"}
1
+ {"version":3,"file":"document.mjs","sources":["../../../../src/application/transform/document/document.ts"],"sourcesContent":["import { irKeyword, irObject, irRecord } from \"../../../domain/ir/constructors.js\";\nimport type {\n IrDeclaration,\n IrIntersectionType,\n IrObjectType,\n IrType,\n IrTypeAliasDeclaration,\n} from \"../../../domain/ir/nodes.js\";\nimport type { ComponentsObject } from \"../../../domain/openapi/components-object.js\";\nimport type { DocumentObject } from \"../../../domain/openapi/document-object.js\";\nimport type { PathsObject } from \"../../../domain/openapi/path-item-object.js\";\nimport { READ_WRITE_MARKER_TYPES } from \"../helper-types.js\";\nimport type { TransformContext, TransformOptions } from \"../transform-context.js\";\nimport { componentsType } from \"./components.js\";\nimport { type DeclaredTypeLookup, declaredTypeLookup } from \"./declared-types.js\";\nimport { defsRootType } from \"./defs-root.js\";\nimport { keptDeprecatedComponents } from \"./kept-deprecated.js\";\nimport { pathMembers, pathsObjectType } from \"./paths.js\";\nimport { apiPathsEnumDeclaration } from \"./paths-enum.js\";\nimport { webhooksType } from \"./webhooks.js\";\n\n/** The root types, in output order. */\nconst ROOT_KEYS = Object.freeze([\"paths\", \"webhooks\", \"components\", \"$defs\"] as const);\ntype RootKey = (typeof ROOT_KEYS)[number];\n\nconst OPERATIONS_NAME = \"operations\";\n/** The type of a root without members: `Record<string, never>`. */\nconst EMPTY_ROOT_TYPE = irRecord(irKeyword(\"string\"), irKeyword(\"never\"));\n\n/** A root's type and the declarations that follow it (the `--root-types` aliases). */\ninterface RootResult {\n readonly type: IrType;\n readonly aliases: readonly IrTypeAliasDeclaration[];\n /**\n * The root's final type, for a root that reads the types the whole file declares (`paths`, whose\n * overlap check follows references). `type` then only tells whether the root has members.\n */\n readonly withDeclaredTypes?: (lookup: DeclaredTypeLookup) => IrType;\n}\n\ntype RootTransform = (\n node: object,\n context: TransformContext,\n document: DocumentObject,\n) => RootResult;\n\n/** Without `--exclude-deprecated` nothing is left out, so the scan is skipped. */\nfunction keptDeprecated(document: DocumentObject, context: TransformContext): ReadonlySet<object> {\n return context.options.excludeDeprecated\n ? keptDeprecatedComponents(document, context.refs)\n : new Set();\n}\n\nconst ROOT_TRANSFORMS: Readonly<Record<RootKey, RootTransform>> = {\n paths: (node, context) => {\n const members = pathMembers(node as PathsObject, context);\n return {\n type: irObject(members.map(({ member }) => member)),\n aliases: [],\n withDeclaredTypes: (lookup) => pathsObjectType(members, lookup),\n };\n },\n webhooks: (node, context) => ({ type: webhooksType(node as PathsObject, context), aliases: [] }),\n components: (node, context, document) => {\n const kept = keptDeprecated(document, context);\n const { type, rootTypes } = componentsType(node as ComponentsObject, context, kept);\n return { type, aliases: rootTypes };\n },\n $defs: (node, context) => ({\n type: defsRootType(node as NonNullable<DocumentObject[\"$defs\"]>, context),\n aliases: [],\n }),\n};\n\nfunction emptyAlias(name: string): IrTypeAliasDeclaration {\n return { kind: \"typeAlias\", name, isExported: true, type: EMPTY_ROOT_TYPE, comments: [] };\n}\n\n/** A root type that declares something: an object with members, or an intersection of them. */\ntype RootBodyType = IrObjectType | IrIntersectionType;\n\nfunction isRootBody(type: IrType): type is RootBodyType {\n return (type.kind === \"object\" && type.members.length > 0) || type.kind === \"intersection\";\n}\n\n/**\n * A root with members: an interface, or a type alias with `--export-type`. An intersection (the\n * `paths` of overlapping `--path-params-as-types` keys) can only be a type alias.\n */\nfunction rootDeclaration(\n name: RootKey,\n type: RootBodyType,\n options: TransformOptions,\n): IrDeclaration {\n return options.exportType || type.kind === \"intersection\"\n ? { kind: \"typeAlias\", name, isExported: true, type, comments: [] }\n : { kind: \"interface\", name, isExported: true, members: type.members, comments: [] };\n}\n\n/**\n * The declarations of one root: its type, then its aliases. `finish` gives the root's declaration\n * again from the types the whole file declares, for a root with `withDeclaredTypes`.\n */\ninterface RootDeclarations {\n readonly declarations: readonly IrDeclaration[];\n readonly finish?: (lookup: DeclaredTypeLookup) => IrDeclaration;\n}\n\n/**\n * The declarations of one root. A root that is missing, or whose type has no members, is\n * `Record<string, never>`. Only an object type (or the `paths` intersection) counts as having\n * members: a callback type the IR keeps as raw text does not (ADR-004).\n */\nfunction rootDeclarations(\n root: RootKey,\n document: DocumentObject,\n context: TransformContext,\n): RootDeclarations {\n const node: unknown = document[root];\n if (!node || typeof node !== \"object\") {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return { declarations: [emptyAlias(root)] };\n }\n const startedAt = context.diagnostics.now();\n const { type, aliases, withDeclaredTypes } = ROOT_TRANSFORMS[root](node, context, document);\n if (!isRootBody(type)) {\n context.diagnostics.debug(`${root} done (skipped)`, 0);\n return { declarations: [emptyAlias(root), ...aliases] };\n }\n const declaration = rootDeclaration(root, type, context.options);\n context.diagnostics.debug(`${root} done`, context.diagnostics.now() - startedAt);\n const finish =\n withDeclaredTypes &&\n ((lookup: DeclaredTypeLookup) => {\n const finished = withDeclaredTypes(lookup);\n return isRootBody(finished) ? rootDeclaration(root, finished, context.options) : declaration;\n });\n return { declarations: [declaration, ...aliases], ...(finish ? { finish } : {}) };\n}\n\n/**\n * Every root's declarations in output order. A root with `finish` gets its declaration from the\n * types of the other roots and of the footer (the `operations` interface), which exist only once\n * every root is transformed.\n */\nfunction rootsDeclarations(\n document: DocumentObject,\n context: TransformContext,\n footer: () => readonly IrDeclaration[],\n): IrDeclaration[] {\n const roots = ROOT_KEYS.map((root) => rootDeclarations(root, document, context));\n const transformed = roots.flatMap(({ declarations }) => declarations);\n if (roots.every(({ finish }) => finish === undefined)) {\n return transformed;\n }\n const lookup = declaredTypeLookup([...transformed, ...footer()]);\n return roots.flatMap(({ declarations, finish }) => {\n const [declaration, ...aliases] = declarations;\n return finish === undefined || declaration === undefined\n ? declarations\n : [finish(lookup), ...aliases];\n });\n}\n\n/**\n * The `inject` text as written (ADR-010, decision 4), without the blank lines around it. The\n * original reprinted it with the TypeScript printer; text without code printed nothing then.\n */\nfunction withoutBlankLinesAround(text: string): string {\n return text.replace(/^(?:[ \\t]*\\r?\\n)+/, \"\").trimEnd();\n}\n\n/** No footer declarations: the roots' references to `operations` stay unresolved. */\nconst NO_FOOTER = (): readonly IrDeclaration[] => [];\n\n/**\n * The document's declarations before the footer: helper types, injected code, then one root type\n * per root key with the aliases that follow it. `footer` reads the footer's declarations once the\n * roots are transformed.\n */\nexport function documentBody(\n document: DocumentObject,\n context: TransformContext,\n footer: () => readonly IrDeclaration[] = NO_FOOTER,\n): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (context.options.readWriteMarkers) {\n declarations.push({ kind: \"rawDeclaration\", text: READ_WRITE_MARKER_TYPES });\n }\n const inject = withoutBlankLinesAround(context.options.inject ?? \"\");\n if (inject !== \"\") {\n declarations.push({ kind: \"rawDeclaration\", text: inject });\n }\n declarations.push(...rootsDeclarations(document, context, footer));\n return declarations;\n}\n\n/**\n * The declarations after the footer: an empty `operations` type when the footer has no\n * operations, and the `--make-paths-enum` enum.\n */\nexport function documentClosing(\n document: DocumentObject,\n context: TransformContext,\n hasOperations: boolean,\n): IrDeclaration[] {\n const declarations: IrDeclaration[] = [];\n if (!hasOperations) {\n declarations.push(emptyAlias(OPERATIONS_NAME));\n }\n if (context.options.makePathsEnum && document.paths) {\n declarations.push(apiPathsEnumDeclaration(document.paths));\n }\n return declarations;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAsBA,MAAM,SAAA,GAAY,OAAO,MAAA,CAAO,CAAC,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,EAAS,MAAM,CAAC,CAAA;AACjE,EAAA,OAAO,YAAA;AACT;AAMO,SAAS,eAAA,CACd,QAAA,EACA,OAAA,EACA,aAAA,EACiB;AACjB,EAAA,MAAM,eAAgC,EAAC;AACvC,EAAA,IAAI,CAAC,aAAA,EAAe;AAClB,IAAA,YAAA,CAAa,IAAA,CAAK,UAAA,CAAW,eAAe,CAAC,CAAA;AAAA,EAC/C;AACA,EAAA,IAAI,OAAA,CAAQ,OAAA,CAAQ,aAAA,IAAiB,QAAA,CAAS,KAAA,EAAO;AACnD,IAAA,YAAA,CAAa,IAAA,CAAK,uBAAA,CAAwB,QAAA,CAAS,KAAK,CAAC,CAAA;AAAA,EAC3D;AACA,EAAA,OAAO,YAAA;AACT;;"}
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ const FORM_STYLE = "form";
4
+ function resolvedSchema(schema, refs, seen) {
5
+ if (typeof schema !== "object" || schema === null) {
6
+ return null;
7
+ }
8
+ if (!("$ref" in schema)) {
9
+ return schema;
10
+ }
11
+ if (seen.has(schema.$ref)) {
12
+ return null;
13
+ }
14
+ const target = refs.resolve(schema.$ref);
15
+ return target === void 0 ? null : resolvedSchema(target, refs, /* @__PURE__ */ new Set([...seen, schema.$ref]));
16
+ }
17
+ function nonNullTypes(schema) {
18
+ const types = Array.isArray(schema.type) ? schema.type : [schema.type];
19
+ return types.filter((type) => type !== void 0 && type !== null && type !== "null");
20
+ }
21
+ function isObjectComposition(members, refs, seen) {
22
+ return members !== void 0 && members.length > 0 && members.every((member) => isObjectSchemaWith(member, refs, seen));
23
+ }
24
+ function isObjectSchemaWith(schema, refs, seen) {
25
+ const resolved = resolvedSchema(schema, refs, seen);
26
+ if (resolved === null) {
27
+ return false;
28
+ }
29
+ const types = nonNullTypes(resolved);
30
+ if (types.length > 0) {
31
+ return types.every((type) => type === "object");
32
+ }
33
+ return resolved.properties !== void 0 || resolved.additionalProperties !== void 0 || resolved.patternProperties !== void 0 || isObjectComposition(resolved.allOf, refs, seen) || isObjectComposition(resolved.oneOf, refs, seen) || isObjectComposition(resolved.anyOf, refs, seen);
34
+ }
35
+ function isObjectSchema(schema, refs) {
36
+ return isObjectSchemaWith(schema, refs, /* @__PURE__ */ new Set());
37
+ }
38
+ function isExplodedQueryObject(parameter, refs) {
39
+ const style = parameter.style ?? FORM_STYLE;
40
+ const explode = parameter.explode ?? style === FORM_STYLE;
41
+ return parameter.in === "query" && style === FORM_STYLE && explode && parameter.schema !== void 0 && isObjectSchema(parameter.schema, refs);
42
+ }
43
+
44
+ exports.isExplodedQueryObject = isExplodedQueryObject;
45
+ exports.isObjectSchema = isObjectSchema;
46
+ //# sourceMappingURL=exploded-query.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exploded-query.cjs","sources":["../../../../src/application/transform/document/exploded-query.ts"],"sourcesContent":["import type { ParameterObject } from \"../../../domain/openapi/parameter-object.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport type { RefResolver } from \"../schema/schema-context.js\";\n\n/**\n * Exploded object query parameters (OpenAPI 3.2 §4.8.12.4, upstream #2361). A query parameter has\n * `style: form` and, with it, `explode: true` by default. An object value is then sent as its own\n * `key=value` pairs, `?page=1&limit=10`: the parameter's name is not in the URL. So with the\n * `exploded-query-objects` fix, the object's properties are keys of `query`, not one key named\n * after the parameter.\n */\n\nconst FORM_STYLE = \"form\";\n\n/** Whether a `$ref` chain has been followed already, so a cycle ends. */\ntype SeenRefs = ReadonlySet<string>;\n\nfunction resolvedSchema(schema: Schema, refs: RefResolver, seen: SeenRefs): SchemaObject | null {\n if (typeof schema !== \"object\" || schema === null) {\n return null;\n }\n if (!(\"$ref\" in schema)) {\n return schema;\n }\n if (seen.has(schema.$ref)) {\n return null;\n }\n const target = refs.resolve(schema.$ref) as Schema | undefined;\n return target === undefined\n ? null\n : resolvedSchema(target, refs, new Set([...seen, schema.$ref]));\n}\n\n/** The types of a `type` keyword other than `null`; empty when it has none. */\nfunction nonNullTypes(schema: SchemaObject): readonly unknown[] {\n const types = Array.isArray(schema.type) ? schema.type : [schema.type];\n return types.filter((type) => type !== undefined && type !== null && type !== \"null\");\n}\n\n/** Whether every member of a composition is an object schema; false for an empty list. */\nfunction isObjectComposition(\n members: readonly Schema[] | undefined,\n refs: RefResolver,\n seen: SeenRefs,\n): boolean {\n return (\n members !== undefined &&\n members.length > 0 &&\n members.every((member) => isObjectSchemaWith(member, refs, seen))\n );\n}\n\nfunction isObjectSchemaWith(schema: Schema, refs: RefResolver, seen: SeenRefs): boolean {\n const resolved = resolvedSchema(schema, refs, seen);\n if (resolved === null) {\n return false;\n }\n const types = nonNullTypes(resolved);\n if (types.length > 0) {\n return types.every((type) => type === \"object\");\n }\n return (\n resolved.properties !== undefined ||\n resolved.additionalProperties !== undefined ||\n resolved.patternProperties !== undefined ||\n isObjectComposition(resolved.allOf, refs, seen) ||\n isObjectComposition(resolved.oneOf, refs, seen) ||\n isObjectComposition(resolved.anyOf, refs, seen)\n );\n}\n\n/**\n * Whether the schema describes only objects: `type: object` (with `null` or not), or no `type`\n * and object keywords, or a composition of such schemas. A `$ref` is followed.\n */\nexport function isObjectSchema(schema: Schema, refs: RefResolver): boolean {\n return isObjectSchemaWith(schema, refs, new Set());\n}\n\n/** Whether an `in: query` parameter sends its object value as the object's own keys. */\nexport function isExplodedQueryObject(parameter: ParameterObject, refs: RefResolver): boolean {\n const style = parameter.style ?? FORM_STYLE;\n const explode = parameter.explode ?? style === FORM_STYLE;\n return (\n parameter.in === \"query\" &&\n style === FORM_STYLE &&\n explode &&\n parameter.schema !== undefined &&\n isObjectSchema(parameter.schema, refs)\n );\n}\n"],"names":[],"mappings":";;AAYA,MAAM,UAAA,GAAa,MAAA;AAKnB,SAAS,cAAA,CAAe,MAAA,EAAgB,IAAA,EAAmB,IAAA,EAAqC;AAC9F,EAAA,IAAI,OAAO,MAAA,KAAW,QAAA,IAAY,MAAA,KAAW,IAAA,EAAM;AACjD,IAAA,OAAO,IAAA;AAAA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AQ,CAAA;AACnC,EAAA,IAAI,KAAA,CAAM,SAAS,CAAA,EAAG;AACpB,IAAA,OAAO,KAAA,CAAM,KAAA,CAAM,CAAC,IAAA,KAAS,SAAS,QAAQ,CAAA;AAAA,EAChD;AACA,EAAA,OACE,QAAA,CAAS,UAAA,KAAe,MAAA,IACxB,QAAA,CAAS,oBAAA,KAAyB,UAClC,QAAA,CAAS,iBAAA,KAAsB,MAAA,IAC/B,mBAAA,CAAoB,QAAA,CAAS,KAAA,EAAO,MAAM,IAAI,CAAA,IAC9C,mBAAA,CAAoB,QAAA,CAAS,KAAA,EAAO,IAAA,EAAM,IAAI,CAAA,IAC9C,mBAAA,CAAoB,QAAA,CAAS,KAAA,EAAO,IAAA,EAAM,IAAI,CAAA;AAElD;AAMO,SAAS,cAAA,CAAe,QAAgB,IAAA,EAA4B;AACzE,EAAA,OAAO,kBAAA,CAAmB,MAAA,EAAQ,IAAA,kBAAM,IAAI,KAAK,CAAA;AACnD;AAGO,SAAS,qBAAA,CAAsB,WAA4B,IAAA,EAA4B;AAC5F,EAAA,MAAM,KAAA,GAAQ,UAAU,KAAA,IAAS,UAAA;AACjC,EAAA,MAAM,OAAA,GAAU,SAAA,CAAU,OAAA,IAAW,KAAA,KAAU,UAAA;AAC/C,EAAA,OACE,SAAA,CAAU,EAAA,KAAO,OAAA,IACjB,KAAA,KAAU,UAAA,IACV,OAAA,IACA,SAAA,CAAU,MAAA,KAAW,MAAA,IACrB,cAAA,CAAe,SAAA,CAAU,MAAA,EAAQ,IAAI,CAAA;AAEzC;;;"}
@@ -0,0 +1,43 @@
1
+ const FORM_STYLE = "form";
2
+ function resolvedSchema(schema, refs, seen) {
3
+ if (typeof schema !== "object" || schema === null) {
4
+ return null;
5
+ }
6
+ if (!("$ref" in schema)) {
7
+ return schema;
8
+ }
9
+ if (seen.has(schema.$ref)) {
10
+ return null;
11
+ }
12
+ const target = refs.resolve(schema.$ref);
13
+ return target === void 0 ? null : resolvedSchema(target, refs, /* @__PURE__ */ new Set([...seen, schema.$ref]));
14
+ }
15
+ function nonNullTypes(schema) {
16
+ const types = Array.isArray(schema.type) ? schema.type : [schema.type];
17
+ return types.filter((type) => type !== void 0 && type !== null && type !== "null");
18
+ }
19
+ function isObjectComposition(members, refs, seen) {
20
+ return members !== void 0 && members.length > 0 && members.every((member) => isObjectSchemaWith(member, refs, seen));
21
+ }
22
+ function isObjectSchemaWith(schema, refs, seen) {
23
+ const resolved = resolvedSchema(schema, refs, seen);
24
+ if (resolved === null) {
25
+ return false;
26
+ }
27
+ const types = nonNullTypes(resolved);
28
+ if (types.length > 0) {
29
+ return types.every((type) => type === "object");
30
+ }
31
+ return resolved.properties !== void 0 || resolved.additionalProperties !== void 0 || resolved.patternProperties !== void 0 || isObjectComposition(resolved.allOf, refs, seen) || isObjectComposition(resolved.oneOf, refs, seen) || isObjectComposition(resolved.anyOf, refs, seen);
32
+ }
33
+ function isObjectSchema(schema, refs) {
34
+ return isObjectSchemaWith(schema, refs, /* @__PURE__ */ new Set());
35
+ }
36
+ function isExplodedQueryObject(parameter, refs) {
37
+ const style = parameter.style ?? FORM_STYLE;
38
+ const explode = parameter.explode ?? style === FORM_STYLE;
39
+ return parameter.in === "query" && style === FORM_STYLE && explode && parameter.schema !== void 0 && isObjectSchema(parameter.schema, refs);
40
+ }
41
+
42
+ export { isExplodedQueryObject, isObjectSchema };
43
+ //# sourceMappingURL=exploded-query.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exploded-query.mjs","sources":["../../../../src/application/transform/document/exploded-query.ts"],"sourcesContent":["import type { ParameterObject } from \"../../../domain/openapi/parameter-object.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport type { RefResolver } from \"../schema/schema-context.js\";\n\n/**\n * Exploded object query parameters (OpenAPI 3.2 §4.8.12.4, upstream #2361). A query parameter has\n * `style: form` and, with it, `explode: true` by default. An object value is then sent as its own\n * `key=value` pairs, `?page=1&limit=10`: the parameter's name is not in the URL. So with the\n * `exploded-query-objects` fix, the object's properties are keys of `query`, not one key named\n * after the parameter.\n */\n\nconst FORM_STYLE = \"form\";\n\n/** Whether a `$ref` chain has been followed already, so a cycle ends. */\ntype SeenRefs = ReadonlySet<string>;\n\nfunction resolvedSchema(schema: Schema, refs: RefResolver, seen: SeenRefs): SchemaObject | null {\n if (typeof schema !== \"object\" || schema === null) {\n return null;\n }\n if (!(\"$ref\" in schema)) {\n return schema;\n }\n if (seen.has(schema.$ref)) {\n return null;\n }\n const target = refs.resolve(schema.$ref) as Schema | undefined;\n return target === undefined\n ? null\n : resolvedSchema(target, refs, new Set([...seen, schema.$ref]));\n}\n\n/** The types of a `type` keyword other than `null`; empty when it has none. */\nfunction nonNullTypes(schema: SchemaObject): readonly unknown[] {\n const types = Array.isArray(schema.type) ? schema.type : [schema.type];\n return types.filter((type) => type !== undefined && type !== null && type !== \"null\");\n}\n\n/** Whether every member of a composition is an object schema; false for an empty list. */\nfunction isObjectComposition(\n members: readonly Schema[] | undefined,\n refs: RefResolver,\n seen: SeenRefs,\n): boolean {\n return (\n members !== undefined &&\n members.length > 0 &&\n members.every((member) => isObjectSchemaWith(member, refs, seen))\n );\n}\n\nfunction isObjectSchemaWith(schema: Schema, refs: RefResolver, seen: SeenRefs): boolean {\n const resolved = resolvedSchema(schema, refs, seen);\n if (resolved === null) {\n return false;\n }\n const types = nonNullTypes(resolved);\n if (types.length > 0) {\n return types.every((type) => type === \"object\");\n }\n return (\n resolved.properties !== undefined ||\n resolved.additionalProperties !== undefined ||\n resolved.patternProperties !== undefined ||\n isObjectComposition(resolved.allOf, refs, seen) ||\n isObjectComposition(resolved.oneOf, refs, seen) ||\n isObjectComposition(resolved.anyOf, refs, seen)\n );\n}\n\n/**\n * Whether the schema describes only objects: `type: object` (with `null` or not), or no `type`\n * and object keywords, or a composition of such schemas. A `$ref` is followed.\n */\nexport function isObjectSchema(schema: Schema, refs: RefResolver): boolean {\n return isObjectSchemaWith(schema, refs, new Set());\n}\n\n/** Whether an `in: query` parameter sends its object value as the object's own keys. */\nexport function isExplodedQueryObject(parameter: ParameterObject, refs: RefResolver): boolean {\n const style = parameter.style ?? FORM_STYLE;\n const explode = parameter.explode ?? style === FORM_STYLE;\n return (\n parameter.in === \"query\" &&\n style === FORM_STYLE &&\n explode &&\n parameter.schema !== undefined &&\n isObjectSchema(parameter.schema, refs)\n );\n}\n"],"names":[],"mappings":"AAYA,MAAM,UAAA,GAAa,MAAA;AAKnB,SAAS,cAAA,CAAe,MAAA,EAAgB,IAAA,EAAmB,IAAA,EAAqC;AAC9F,EAAA,IAAI,OAAO,MAAA,KAAW,QAAA,IAAY,MAAA,KAAW,IAAA,EAAM;AACjD,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,IAAI,EAAE,UAAU,MAAA,CAAA,EAAS;AACvB,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,IAAI,IAAA,CAAK,GAAA,CAAI,MAAA,CAAO,IAAI,CAAA,EAAG;AACzB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,OAAA,CAAQ,MAAA,CAAO,IAAI,CAAA;AACvC,EAAA,OAAO,MAAA,KAAW,MAAA,GACd,IAAA,GACA,cAAA,CAAe,QAAQ,IAAA,kBAAM,IAAI,GAAA,CAAI,CAAC,GAAG,IAAA,EAAM,MAAA,CAAO,IAAI,CAAC,CAAC,CAAA;AAClE;AAGA,SAAS,aAAa,MAAA,EAA0C;AAC9D,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO,IAAI,IAAI,MAAA,CAAO,IAAA,GAAO,CAAC,MAAA,CAAO,IAAI,CAAA;AACrE,EAAA,OAAO,KAAA,CAAM,OAAO,CAAC,IAAA,KAAS,SAAS,MAAA,IAAa,IAAA,KAAS,IAAA,IAAQ,IAAA,KAAS,MAAM,CAAA;AACtF;AAGA,SAAS,mBAAA,CACP,OAAA,EACA,IAAA,EACA,IA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/C,EAAA,OACE,SAAA,CAAU,EAAA,KAAO,OAAA,IACjB,KAAA,KAAU,UAAA,IACV,OAAA,IACA,SAAA,CAAU,MAAA,KAAW,MAAA,IACrB,cAAA,CAAe,SAAA,CAAU,MAAA,EAAQ,IAAI,CAAA;AAEzC;;"}
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ const GLOBAL_TYPE_NAMES = /* @__PURE__ */ new Set([
4
+ "Array",
5
+ "Blob",
6
+ "Exclude",
7
+ "Extract",
8
+ "NonNullable",
9
+ "Omit",
10
+ "Partial",
11
+ "Pick",
12
+ "Readonly",
13
+ "ReadonlyArray",
14
+ "Record",
15
+ "Required"
16
+ ]);
17
+ const GENERIC_USE = /\b([A-Z][A-Za-z]*)\s*</g;
18
+ const SKIPPED_KEYS = /* @__PURE__ */ new Set(["origin", "comments"]);
19
+ function isObject(value) {
20
+ return typeof value === "object" && value !== null;
21
+ }
22
+ function addTextUses(text, used) {
23
+ for (const match of text.matchAll(GENERIC_USE)) {
24
+ const name = match[1] ?? "";
25
+ if (GLOBAL_TYPE_NAMES.has(name)) {
26
+ used.add(name);
27
+ }
28
+ }
29
+ }
30
+ function addNodeUses(node, used) {
31
+ if (node.kind === "reference" && typeof node.name === "string") {
32
+ if (GLOBAL_TYPE_NAMES.has(node.name)) {
33
+ used.add(node.name);
34
+ }
35
+ } else if ((node.kind === "raw" || node.kind === "rawDeclaration") && typeof node.text === "string") {
36
+ addTextUses(node.text, used);
37
+ }
38
+ }
39
+ function visit(value, used) {
40
+ if (Array.isArray(value)) {
41
+ for (const item of value) {
42
+ visit(item, used);
43
+ }
44
+ return;
45
+ }
46
+ if (!isObject(value)) {
47
+ return;
48
+ }
49
+ addNodeUses(value, used);
50
+ for (const [key, child] of Object.entries(value)) {
51
+ if (!SKIPPED_KEYS.has(key)) {
52
+ visit(child, used);
53
+ }
54
+ }
55
+ }
56
+ function globalTypeReferences(declarations) {
57
+ const used = /* @__PURE__ */ new Set();
58
+ visit(declarations, used);
59
+ return used;
60
+ }
61
+
62
+ exports.globalTypeReferences = globalTypeReferences;
63
+ //# sourceMappingURL=global-type-references.cjs.map