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,70 @@
1
+ 'use strict';
2
+
3
+ const assertNever = require('../../../domain/assert-never.cjs');
4
+
5
+ function nameKey(name) {
6
+ return JSON.stringify(name.kind === "string" ? name.value : name.text);
7
+ }
8
+ function memberKey(member, typeKeyOf) {
9
+ if (member.kind === "indexSignature") {
10
+ const readonly2 = member.isReadonly ? "readonly " : "";
11
+ return `${readonly2}[${typeKeyOf(member.parameterType)}]:${typeKeyOf(member.type)}`;
12
+ }
13
+ const readonly = member.isReadonly ? "readonly " : "";
14
+ const optional = member.isOptional ? "?" : "";
15
+ return `${readonly}${nameKey(member.name)}${optional}:${typeKeyOf(member.type)}`;
16
+ }
17
+ function listKey(types, typeKeyOf) {
18
+ return types.map(typeKeyOf).join(",");
19
+ }
20
+ function elementKey(element, typeKeyOf) {
21
+ const prefix = element.isRest ? "..." : "";
22
+ return `${prefix}${typeKeyOf(element.type)}${element.isOptional ? "?" : ""}`;
23
+ }
24
+ function computeKey(type, typeKeyOf) {
25
+ switch (type.kind) {
26
+ case "keyword":
27
+ return type.keyword;
28
+ case "stringLiteral":
29
+ return JSON.stringify(type.value);
30
+ case "numberLiteral":
31
+ case "booleanLiteral":
32
+ return String(type.value);
33
+ case "reference":
34
+ return `${type.name}<${listKey(type.typeArguments, typeKeyOf)}>`;
35
+ case "array":
36
+ return `(${typeKeyOf(type.element)})[]`;
37
+ case "tuple":
38
+ return `[${type.elements.map((element) => elementKey(element, typeKeyOf)).join(",")}]`;
39
+ case "union":
40
+ return `union(${listKey(type.types, typeKeyOf)})`;
41
+ case "intersection":
42
+ return `intersection(${listKey(type.types, typeKeyOf)})`;
43
+ case "object":
44
+ return `{${type.members.map((member) => memberKey(member, typeKeyOf)).join(";")}}`;
45
+ case "indexedAccess":
46
+ return `${typeKeyOf(type.object)}[${typeKeyOf(type.index)}]`;
47
+ case "readonly":
48
+ return `readonly(${typeKeyOf(type.type)})`;
49
+ case "raw":
50
+ return `raw(${type.text})`;
51
+ default:
52
+ return assertNever.assertNever(type);
53
+ }
54
+ }
55
+ function createTypeKey() {
56
+ const keys = /* @__PURE__ */ new WeakMap();
57
+ const typeKeyOf = (type) => {
58
+ const known = keys.get(type);
59
+ if (known !== void 0) {
60
+ return known;
61
+ }
62
+ const key = computeKey(type, typeKeyOf);
63
+ keys.set(type, key);
64
+ return key;
65
+ };
66
+ return typeKeyOf;
67
+ }
68
+
69
+ exports.createTypeKey = createTypeKey;
70
+ //# sourceMappingURL=type-key.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-key.cjs","sources":["../../../../src/application/transform/document/type-key.ts"],"sourcesContent":["import { assertNever } from \"../../../domain/assert-never.js\";\nimport type { IrMember, IrPropertyName, IrTupleElement, IrType } from \"../../../domain/ir/nodes.js\";\n\n/**\n * A text that is the same for two types exactly when they are written the same, comments left\n * out: the overlap check accepts a type it does not model when it is the same as the other.\n */\n\nfunction nameKey(name: IrPropertyName): string {\n return JSON.stringify(name.kind === \"string\" ? name.value : name.text);\n}\n\nfunction memberKey(member: IrMember, typeKeyOf: TypeKey): string {\n if (member.kind === \"indexSignature\") {\n const readonly = member.isReadonly ? \"readonly \" : \"\";\n return `${readonly}[${typeKeyOf(member.parameterType)}]:${typeKeyOf(member.type)}`;\n }\n const readonly = member.isReadonly ? \"readonly \" : \"\";\n const optional = member.isOptional ? \"?\" : \"\";\n return `${readonly}${nameKey(member.name)}${optional}:${typeKeyOf(member.type)}`;\n}\n\nfunction listKey(types: readonly IrType[], typeKeyOf: TypeKey): string {\n return types.map(typeKeyOf).join(\",\");\n}\n\nfunction elementKey(element: IrTupleElement, typeKeyOf: TypeKey): string {\n const prefix = element.isRest ? \"...\" : \"\";\n return `${prefix}${typeKeyOf(element.type)}${element.isOptional ? \"?\" : \"\"}`;\n}\n\nfunction computeKey(type: IrType, typeKeyOf: TypeKey): string {\n switch (type.kind) {\n case \"keyword\":\n return type.keyword;\n case \"stringLiteral\":\n return JSON.stringify(type.value);\n case \"numberLiteral\":\n case \"booleanLiteral\":\n return String(type.value);\n case \"reference\":\n return `${type.name}<${listKey(type.typeArguments, typeKeyOf)}>`;\n case \"array\":\n return `(${typeKeyOf(type.element)})[]`;\n case \"tuple\":\n return `[${type.elements.map((element) => elementKey(element, typeKeyOf)).join(\",\")}]`;\n case \"union\":\n return `union(${listKey(type.types, typeKeyOf)})`;\n case \"intersection\":\n return `intersection(${listKey(type.types, typeKeyOf)})`;\n case \"object\":\n return `{${type.members.map((member) => memberKey(member, typeKeyOf)).join(\";\")}}`;\n case \"indexedAccess\":\n return `${typeKeyOf(type.object)}[${typeKeyOf(type.index)}]`;\n case \"readonly\":\n return `readonly(${typeKeyOf(type.type)})`;\n case \"raw\":\n return `raw(${type.text})`;\n default:\n return assertNever(type);\n }\n}\n\n/** The key of a type. */\nexport type TypeKey = (type: IrType) => string;\n\n/** A key function that computes each node's key once; one per comparison, not shared. */\nexport function createTypeKey(): TypeKey {\n const keys = new WeakMap<IrType, string>();\n const typeKeyOf: TypeKey = (type) => {\n const known = keys.get(type);\n if (known !== undefined) {\n return known;\n }\n const key = computeKey(type, typeKeyOf);\n keys.set(type, key);\n return key;\n };\n return typeKeyOf;\n}\n"],"names":["readonly","assertNever"],"mappings":";;;;AAQA,SAAS,QAAQ,IAAA,EAA8B;AAC7C,EAAA,OAAO,IAAA,CAAK,UAAU,IAAA,CAAK,IAAA,KAAS,WAAW,IAAA,CAAK,KAAA,GAAQ,KAAK,IAAI,CAAA;AACvE;AAEA,SAAS,SAAA,CAAU,QAAkB,SAAA,EAA4B;AAC/D,EAAA,IAAI,MAAA,CAAO,SAAS,gBAAA,EAAkB;AACpC,IAAA,MAAMA,SAAAA,GAAW,MAAA,CAAO,UAAA,GAAa,WAAA,GAAc,EAAA;AACnD,IAAA,OAAO,CAAA,EAAGA,SAAQ,CAAA,CAAA,EAAI,SAAA,CAAU,MAAA,CAAO,aAAa,CAAC,CAAA,EAAA,EAAK,SAAA,CAAU,MAAA,CAAO,IAAI,CAAC,CAAA,CAAA;AAAA,EAClF;AACA,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,UAAA,GAAa,WAAA,GAAc,EAAA;AACnD,EAAA,MAAM,QAAA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AA,CAAI,IAAI,CAAA;AAC3B,IAAA,IAAI,UAAU,MAAA,EAAW;AACvB,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,MAAM,GAAA,GAAM,UAAA,CAAW,IAAA,EAAM,SAAS,CAAA;AACtC,IAAA,IAAA,CAAK,GAAA,CAAI,MAAM,GAAG,CAAA;AAClB,IAAA,OAAO,GAAA;AAAA,EACT,CAAA;AACA,EAAA,OAAO,SAAA;AACT;;"}
@@ -0,0 +1,68 @@
1
+ import { assertNever } from '../../../domain/assert-never.mjs';
2
+
3
+ function nameKey(name) {
4
+ return JSON.stringify(name.kind === "string" ? name.value : name.text);
5
+ }
6
+ function memberKey(member, typeKeyOf) {
7
+ if (member.kind === "indexSignature") {
8
+ const readonly2 = member.isReadonly ? "readonly " : "";
9
+ return `${readonly2}[${typeKeyOf(member.parameterType)}]:${typeKeyOf(member.type)}`;
10
+ }
11
+ const readonly = member.isReadonly ? "readonly " : "";
12
+ const optional = member.isOptional ? "?" : "";
13
+ return `${readonly}${nameKey(member.name)}${optional}:${typeKeyOf(member.type)}`;
14
+ }
15
+ function listKey(types, typeKeyOf) {
16
+ return types.map(typeKeyOf).join(",");
17
+ }
18
+ function elementKey(element, typeKeyOf) {
19
+ const prefix = element.isRest ? "..." : "";
20
+ return `${prefix}${typeKeyOf(element.type)}${element.isOptional ? "?" : ""}`;
21
+ }
22
+ function computeKey(type, typeKeyOf) {
23
+ switch (type.kind) {
24
+ case "keyword":
25
+ return type.keyword;
26
+ case "stringLiteral":
27
+ return JSON.stringify(type.value);
28
+ case "numberLiteral":
29
+ case "booleanLiteral":
30
+ return String(type.value);
31
+ case "reference":
32
+ return `${type.name}<${listKey(type.typeArguments, typeKeyOf)}>`;
33
+ case "array":
34
+ return `(${typeKeyOf(type.element)})[]`;
35
+ case "tuple":
36
+ return `[${type.elements.map((element) => elementKey(element, typeKeyOf)).join(",")}]`;
37
+ case "union":
38
+ return `union(${listKey(type.types, typeKeyOf)})`;
39
+ case "intersection":
40
+ return `intersection(${listKey(type.types, typeKeyOf)})`;
41
+ case "object":
42
+ return `{${type.members.map((member) => memberKey(member, typeKeyOf)).join(";")}}`;
43
+ case "indexedAccess":
44
+ return `${typeKeyOf(type.object)}[${typeKeyOf(type.index)}]`;
45
+ case "readonly":
46
+ return `readonly(${typeKeyOf(type.type)})`;
47
+ case "raw":
48
+ return `raw(${type.text})`;
49
+ default:
50
+ return assertNever(type);
51
+ }
52
+ }
53
+ function createTypeKey() {
54
+ const keys = /* @__PURE__ */ new WeakMap();
55
+ const typeKeyOf = (type) => {
56
+ const known = keys.get(type);
57
+ if (known !== void 0) {
58
+ return known;
59
+ }
60
+ const key = computeKey(type, typeKeyOf);
61
+ keys.set(type, key);
62
+ return key;
63
+ };
64
+ return typeKeyOf;
65
+ }
66
+
67
+ export { createTypeKey };
68
+ //# sourceMappingURL=type-key.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-key.mjs","sources":["../../../../src/application/transform/document/type-key.ts"],"sourcesContent":["import { assertNever } from \"../../../domain/assert-never.js\";\nimport type { IrMember, IrPropertyName, IrTupleElement, IrType } from \"../../../domain/ir/nodes.js\";\n\n/**\n * A text that is the same for two types exactly when they are written the same, comments left\n * out: the overlap check accepts a type it does not model when it is the same as the other.\n */\n\nfunction nameKey(name: IrPropertyName): string {\n return JSON.stringify(name.kind === \"string\" ? name.value : name.text);\n}\n\nfunction memberKey(member: IrMember, typeKeyOf: TypeKey): string {\n if (member.kind === \"indexSignature\") {\n const readonly = member.isReadonly ? \"readonly \" : \"\";\n return `${readonly}[${typeKeyOf(member.parameterType)}]:${typeKeyOf(member.type)}`;\n }\n const readonly = member.isReadonly ? \"readonly \" : \"\";\n const optional = member.isOptional ? \"?\" : \"\";\n return `${readonly}${nameKey(member.name)}${optional}:${typeKeyOf(member.type)}`;\n}\n\nfunction listKey(types: readonly IrType[], typeKeyOf: TypeKey): string {\n return types.map(typeKeyOf).join(\",\");\n}\n\nfunction elementKey(element: IrTupleElement, typeKeyOf: TypeKey): string {\n const prefix = element.isRest ? \"...\" : \"\";\n return `${prefix}${typeKeyOf(element.type)}${element.isOptional ? \"?\" : \"\"}`;\n}\n\nfunction computeKey(type: IrType, typeKeyOf: TypeKey): string {\n switch (type.kind) {\n case \"keyword\":\n return type.keyword;\n case \"stringLiteral\":\n return JSON.stringify(type.value);\n case \"numberLiteral\":\n case \"booleanLiteral\":\n return String(type.value);\n case \"reference\":\n return `${type.name}<${listKey(type.typeArguments, typeKeyOf)}>`;\n case \"array\":\n return `(${typeKeyOf(type.element)})[]`;\n case \"tuple\":\n return `[${type.elements.map((element) => elementKey(element, typeKeyOf)).join(\",\")}]`;\n case \"union\":\n return `union(${listKey(type.types, typeKeyOf)})`;\n case \"intersection\":\n return `intersection(${listKey(type.types, typeKeyOf)})`;\n case \"object\":\n return `{${type.members.map((member) => memberKey(member, typeKeyOf)).join(\";\")}}`;\n case \"indexedAccess\":\n return `${typeKeyOf(type.object)}[${typeKeyOf(type.index)}]`;\n case \"readonly\":\n return `readonly(${typeKeyOf(type.type)})`;\n case \"raw\":\n return `raw(${type.text})`;\n default:\n return assertNever(type);\n }\n}\n\n/** The key of a type. */\nexport type TypeKey = (type: IrType) => string;\n\n/** A key function that computes each node's key once; one per comparison, not shared. */\nexport function createTypeKey(): TypeKey {\n const keys = new WeakMap<IrType, string>();\n const typeKeyOf: TypeKey = (type) => {\n const known = keys.get(type);\n if (known !== undefined) {\n return known;\n }\n const key = computeKey(type, typeKeyOf);\n keys.set(type, key);\n return key;\n };\n return typeKeyOf;\n}\n"],"names":["readonly"],"mappings":";;AAQA,SAAS,QAAQ,IAAA,EAA8B;AAC7C,EAAA,OAAO,IAAA,CAAK,UAAU,IAAA,CAAK,IAAA,KAAS,WAAW,IAAA,CAAK,KAAA,GAAQ,KAAK,IAAI,CAAA;AACvE;AAEA,SAAS,SAAA,CAAU,QAAkB,SAAA,EAA4B;AAC/D,EAAA,IAAI,MAAA,CAAO,SAAS,gBAAA,EAAkB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CAAC,CAAA,CAAA,CAAA;AAAA,IACzC,KAAK,KAAA;AACH,MAAA,OAAO,CAAA,IAAA,EAAO,KAAK,IAAI,CAAA,CAAA,CAAA;AAAA,IACzB;AACE,MAAA,OAAO,YAAY,IAAI,CAAA;AAAA;AAE7B;AAMO,SAAS,aAAA,GAAyB;AACvC,EAAA,MAAM,IAAA,uBAAW,OAAA,EAAwB;AACzC,EAAA,MAAM,SAAA,GAAqB,CAAC,IAAA,KAAS;AACnC,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,GAAA,CAAI,IAAI,CAAA;AAC3B,IAAA,IAAI,UAAU,MAAA,EAAW;AACvB,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,MAAM,GAAA,GAAM,UAAA,CAAW,IAAA,EAAM,SAAS,CAAA;AACtC,IAAA,IAAA,CAAK,GAAA,CAAI,MAAM,GAAG,CAAA;AAClB,IAAA,OAAO,GAAA;AAAA,EACT,CAAA;AACA,EAAA,OAAO,SAAA;AACT;;"}
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+
3
+ const UNDEFINED = { kind: "keyword", keyword: "undefined" };
4
+ function nameOf(member) {
5
+ return member.name.kind === "string" ? member.name.value : member.name.text;
6
+ }
7
+ function propertiesOf(type) {
8
+ const properties = type.members.filter(
9
+ (member) => member.kind === "property"
10
+ );
11
+ return new Map(properties.map((property) => [nameOf(property), property]));
12
+ }
13
+ function indexSignaturesOf(type) {
14
+ return type.members.filter(
15
+ (member) => member.kind === "indexSignature"
16
+ );
17
+ }
18
+ function readType(property) {
19
+ return property.isOptional ? { kind: "union", types: [property.type, UNDEFINED] } : property.type;
20
+ }
21
+ function arrayElement(type) {
22
+ const list = type.kind === "readonly" ? type.type : type;
23
+ return list.kind === "array" ? list.element : null;
24
+ }
25
+ function mergedProperty(first, second) {
26
+ return {
27
+ ...first,
28
+ type: { kind: "intersection", types: [first.type, second.type] },
29
+ isOptional: first.isOptional && second.isOptional,
30
+ isReadonly: first.isReadonly || second.isReadonly
31
+ };
32
+ }
33
+ class TypeResolution {
34
+ lookup;
35
+ resolvedTypes = /* @__PURE__ */ new Map();
36
+ constructor(lookup) {
37
+ this.lookup = lookup;
38
+ }
39
+ /** The type a reference names, followed through references to references; computed once. */
40
+ resolved(type) {
41
+ const known = this.resolvedTypes.get(type);
42
+ if (known !== void 0) {
43
+ return known;
44
+ }
45
+ this.resolvedTypes.set(type, type);
46
+ const seen = /* @__PURE__ */ new Set();
47
+ let current = type;
48
+ while (!seen.has(current)) {
49
+ seen.add(current);
50
+ const named = this.lookup(current) ?? this.indexedProperty(current);
51
+ if (named === null) {
52
+ break;
53
+ }
54
+ current = named;
55
+ }
56
+ const result = current.kind === "intersection" ? this.merged(current) ?? current : current;
57
+ this.resolvedTypes.set(type, result);
58
+ return result;
59
+ }
60
+ /**
61
+ * `T["key"]` read from the object type `T` resolves to, which the lookup does not do for an
62
+ * object it reached through another lookup (`paths["/a/{id}"]["get"]`). An optional property
63
+ * reads as `T | undefined`; `T[number]` is the element of the array `T`.
64
+ */
65
+ indexedProperty(type) {
66
+ if (type.kind !== "indexedAccess") {
67
+ return null;
68
+ }
69
+ const { index } = type;
70
+ if (index.kind === "keyword" && index.keyword === "number") {
71
+ return arrayElement(this.resolved(type.object));
72
+ }
73
+ const object = this.resolved(type.object);
74
+ if (index.kind !== "stringLiteral" || object.kind !== "object") {
75
+ return null;
76
+ }
77
+ const property = propertiesOf(object).get(index.value);
78
+ return property === void 0 ? null : readType(property);
79
+ }
80
+ /**
81
+ * An intersection of object types as the one object TypeScript makes of it: a property in
82
+ * several parts has the intersection of their types, and is optional only when it is in each.
83
+ * Null when a part is no object type.
84
+ */
85
+ merged(type) {
86
+ const parts = this.objectParts(type);
87
+ if (parts === null) {
88
+ return null;
89
+ }
90
+ const properties = /* @__PURE__ */ new Map();
91
+ const indexes = [];
92
+ for (const member of parts.flatMap((part) => part.members)) {
93
+ if (member.kind === "indexSignature") {
94
+ indexes.push(member);
95
+ continue;
96
+ }
97
+ const name = nameOf(member);
98
+ const other = properties.get(name);
99
+ properties.set(name, other === void 0 ? member : mergedProperty(other, member));
100
+ }
101
+ return { kind: "object", members: [...properties.values(), ...indexes] };
102
+ }
103
+ /**
104
+ * The object types an intersection is made of, nested ones flattened; null for any other, and
105
+ * for an intersection that contains itself, which TypeScript does not merge either.
106
+ */
107
+ objectParts(type, visiting = /* @__PURE__ */ new Set()) {
108
+ if (type.kind === "object") {
109
+ return [type];
110
+ }
111
+ if (type.kind !== "intersection" || visiting.has(type)) {
112
+ return null;
113
+ }
114
+ const parts = [];
115
+ for (const part of type.types) {
116
+ const objects = this.objectParts(this.resolved(part), /* @__PURE__ */ new Set([...visiting, type]));
117
+ if (objects === null) {
118
+ return null;
119
+ }
120
+ parts.push(...objects);
121
+ }
122
+ return parts;
123
+ }
124
+ }
125
+
126
+ exports.TypeResolution = TypeResolution;
127
+ exports.indexSignaturesOf = indexSignaturesOf;
128
+ exports.nameOf = nameOf;
129
+ exports.propertiesOf = propertiesOf;
130
+ exports.readType = readType;
131
+ //# sourceMappingURL=type-resolution.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-resolution.cjs","sources":["../../../../src/application/transform/document/type-resolution.ts"],"sourcesContent":["import type {\n IrIndexSignature,\n IrMember,\n IrObjectType,\n IrPropertySignature,\n IrType,\n} from \"../../../domain/ir/nodes.js\";\nimport type { DeclaredTypeLookup } from \"./declared-types.js\";\n\n/**\n * The types the `--path-params-as-types` overlap check compares, as TypeScript sees them:\n * references followed to the declarations of the document, `T[\"key\"]` and `T[number]` read from\n * `T`, and an intersection of object types merged into one object.\n */\n\nconst UNDEFINED: IrType = { kind: \"keyword\", keyword: \"undefined\" };\n\nexport function nameOf(member: IrPropertySignature): string {\n return member.name.kind === \"string\" ? member.name.value : member.name.text;\n}\n\nexport function propertiesOf(type: IrObjectType): Map<string, IrPropertySignature> {\n const properties = type.members.filter(\n (member: IrMember): member is IrPropertySignature => member.kind === \"property\",\n );\n return new Map(properties.map((property) => [nameOf(property), property]));\n}\n\nexport function indexSignaturesOf(type: IrObjectType): IrIndexSignature[] {\n return type.members.filter(\n (member: IrMember): member is IrIndexSignature => member.kind === \"indexSignature\",\n );\n}\n\n/** The type read from a property: an optional one may be `undefined`. */\nexport function readType(property: IrPropertySignature): IrType {\n return property.isOptional ? { kind: \"union\", types: [property.type, UNDEFINED] } : property.type;\n}\n\n/**\n * `T[number]` for an array `T`, as the generator writes for an item of an array response: the\n * element type, readonly or not. A tuple's is the union of its elements, which is not modelled.\n */\nfunction arrayElement(type: IrType): IrType | null {\n const list = type.kind === \"readonly\" ? type.type : type;\n return list.kind === \"array\" ? list.element : null;\n}\n\n/** One property for two of the same name in an intersection. */\nfunction mergedProperty(\n first: IrPropertySignature,\n second: IrPropertySignature,\n): IrPropertySignature {\n return {\n ...first,\n type: { kind: \"intersection\", types: [first.type, second.type] },\n isOptional: first.isOptional && second.isOptional,\n isReadonly: first.isReadonly || second.isReadonly,\n };\n}\n\n/** Resolves types once each, for one comparison. */\nexport class TypeResolution {\n private readonly lookup: DeclaredTypeLookup;\n private readonly resolvedTypes = new Map<IrType, IrType>();\n\n constructor(lookup: DeclaredTypeLookup) {\n this.lookup = lookup;\n }\n\n /** The type a reference names, followed through references to references; computed once. */\n resolved(type: IrType): IrType {\n const known = this.resolvedTypes.get(type);\n if (known !== undefined) {\n return known;\n }\n // A type that reaches itself while it is resolved stays as it is written there.\n this.resolvedTypes.set(type, type);\n const seen = new Set<IrType>();\n let current = type;\n while (!seen.has(current)) {\n seen.add(current);\n const named = this.lookup(current) ?? this.indexedProperty(current);\n if (named === null) {\n break;\n }\n current = named;\n }\n const result = current.kind === \"intersection\" ? (this.merged(current) ?? current) : current;\n this.resolvedTypes.set(type, result);\n return result;\n }\n\n /**\n * `T[\"key\"]` read from the object type `T` resolves to, which the lookup does not do for an\n * object it reached through another lookup (`paths[\"/a/{id}\"][\"get\"]`). An optional property\n * reads as `T | undefined`; `T[number]` is the element of the array `T`.\n */\n private indexedProperty(type: IrType): IrType | null {\n if (type.kind !== \"indexedAccess\") {\n return null;\n }\n const { index } = type;\n if (index.kind === \"keyword\" && index.keyword === \"number\") {\n return arrayElement(this.resolved(type.object));\n }\n const object = this.resolved(type.object);\n if (index.kind !== \"stringLiteral\" || object.kind !== \"object\") {\n return null;\n }\n const property = propertiesOf(object).get(index.value);\n return property === undefined ? null : readType(property);\n }\n\n /**\n * An intersection of object types as the one object TypeScript makes of it: a property in\n * several parts has the intersection of their types, and is optional only when it is in each.\n * Null when a part is no object type.\n */\n private merged(type: IrType): IrObjectType | null {\n const parts = this.objectParts(type);\n if (parts === null) {\n return null;\n }\n const properties = new Map<string, IrPropertySignature>();\n const indexes: IrIndexSignature[] = [];\n for (const member of parts.flatMap((part) => part.members)) {\n if (member.kind === \"indexSignature\") {\n indexes.push(member);\n continue;\n }\n const name = nameOf(member);\n const other = properties.get(name);\n properties.set(name, other === undefined ? member : mergedProperty(other, member));\n }\n return { kind: \"object\", members: [...properties.values(), ...indexes] };\n }\n\n /**\n * The object types an intersection is made of, nested ones flattened; null for any other, and\n * for an intersection that contains itself, which TypeScript does not merge either.\n */\n private objectParts(\n type: IrType,\n visiting: ReadonlySet<IrType> = new Set(),\n ): IrObjectType[] | null {\n if (type.kind === \"object\") {\n return [type];\n }\n if (type.kind !== \"intersection\" || visiting.has(type)) {\n return null;\n }\n const parts: IrObjectType[] = [];\n for (const part of type.types) {\n const objects = this.objectParts(this.resolved(part), new Set([...visiting, type]));\n if (objects === null) {\n return null;\n }\n parts.push(...objects);\n }\n return parts;\n }\n}\n"],"names":[],"mappings":";;AAeA,MAAM,SAAA,GAAoB,EAAE,IAAA,EAAM,SAAA,EAAW,SAAS,WAAA,EAAY;AAE3D,SAAS,OAAO,MAAA,EAAqC;AAC1D,EAAA,OAAO,MAAA,CAAO,KAAK,IAAA,KAAS,QAAA,GAAW,OAAO,IAAA,CAAK,KAAA,GAAQ,OAAO,IAAA,CAAK,IAAA;AACzE;AAEO,SAAS,aAA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AA;AAAA,IACnF;AACA,IAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,OAAA,EAAS,CAAC,GAAG,UAAA,CAAW,MAAA,EAAO,EAAG,GAAG,OAAO,CAAA,EAAE;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,WAAA,CACN,IAAA,EACA,QAAA,mBAAgC,IAAI,KAAI,EACjB;AACvB,IAAA,IAAI,IAAA,CAAK,SAAS,QAAA,EAAU;AAC1B,MAAA,OAAO,CAAC,IAAI,CAAA;AAAA,IACd;AACA,IAAA,IAAI,KAAK,IAAA,KAAS,cAAA,IAAkB,QAAA,CAAS,GAAA,CAAI,IAAI,CAAA,EAAG;AACtD,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,MAAM,QAAwB,EAAC;AAC/B,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAK,KAAA,EAAO;AAC7B,MAAA,MAAM,OAAA,GAAU,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,SAAS,IAAI,CAAA,kBAAG,IAAI,GAAA,CAAI,CAAC,GAAG,QAAA,EAAU,IAAI,CAAC,CAAC,CAAA;AAClF,MAAA,IAAI,YAAY,IAAA,EAAM;AACpB,QAAA,OAAO,IAAA;AAAA,MACT;AACA,MAAA,KAAA,CAAM,IAAA,CAAK,GAAG,OAAO,CAAA;AAAA,IACvB;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACF;;;;;;"}
@@ -0,0 +1,125 @@
1
+ const UNDEFINED = { kind: "keyword", keyword: "undefined" };
2
+ function nameOf(member) {
3
+ return member.name.kind === "string" ? member.name.value : member.name.text;
4
+ }
5
+ function propertiesOf(type) {
6
+ const properties = type.members.filter(
7
+ (member) => member.kind === "property"
8
+ );
9
+ return new Map(properties.map((property) => [nameOf(property), property]));
10
+ }
11
+ function indexSignaturesOf(type) {
12
+ return type.members.filter(
13
+ (member) => member.kind === "indexSignature"
14
+ );
15
+ }
16
+ function readType(property) {
17
+ return property.isOptional ? { kind: "union", types: [property.type, UNDEFINED] } : property.type;
18
+ }
19
+ function arrayElement(type) {
20
+ const list = type.kind === "readonly" ? type.type : type;
21
+ return list.kind === "array" ? list.element : null;
22
+ }
23
+ function mergedProperty(first, second) {
24
+ return {
25
+ ...first,
26
+ type: { kind: "intersection", types: [first.type, second.type] },
27
+ isOptional: first.isOptional && second.isOptional,
28
+ isReadonly: first.isReadonly || second.isReadonly
29
+ };
30
+ }
31
+ class TypeResolution {
32
+ lookup;
33
+ resolvedTypes = /* @__PURE__ */ new Map();
34
+ constructor(lookup) {
35
+ this.lookup = lookup;
36
+ }
37
+ /** The type a reference names, followed through references to references; computed once. */
38
+ resolved(type) {
39
+ const known = this.resolvedTypes.get(type);
40
+ if (known !== void 0) {
41
+ return known;
42
+ }
43
+ this.resolvedTypes.set(type, type);
44
+ const seen = /* @__PURE__ */ new Set();
45
+ let current = type;
46
+ while (!seen.has(current)) {
47
+ seen.add(current);
48
+ const named = this.lookup(current) ?? this.indexedProperty(current);
49
+ if (named === null) {
50
+ break;
51
+ }
52
+ current = named;
53
+ }
54
+ const result = current.kind === "intersection" ? this.merged(current) ?? current : current;
55
+ this.resolvedTypes.set(type, result);
56
+ return result;
57
+ }
58
+ /**
59
+ * `T["key"]` read from the object type `T` resolves to, which the lookup does not do for an
60
+ * object it reached through another lookup (`paths["/a/{id}"]["get"]`). An optional property
61
+ * reads as `T | undefined`; `T[number]` is the element of the array `T`.
62
+ */
63
+ indexedProperty(type) {
64
+ if (type.kind !== "indexedAccess") {
65
+ return null;
66
+ }
67
+ const { index } = type;
68
+ if (index.kind === "keyword" && index.keyword === "number") {
69
+ return arrayElement(this.resolved(type.object));
70
+ }
71
+ const object = this.resolved(type.object);
72
+ if (index.kind !== "stringLiteral" || object.kind !== "object") {
73
+ return null;
74
+ }
75
+ const property = propertiesOf(object).get(index.value);
76
+ return property === void 0 ? null : readType(property);
77
+ }
78
+ /**
79
+ * An intersection of object types as the one object TypeScript makes of it: a property in
80
+ * several parts has the intersection of their types, and is optional only when it is in each.
81
+ * Null when a part is no object type.
82
+ */
83
+ merged(type) {
84
+ const parts = this.objectParts(type);
85
+ if (parts === null) {
86
+ return null;
87
+ }
88
+ const properties = /* @__PURE__ */ new Map();
89
+ const indexes = [];
90
+ for (const member of parts.flatMap((part) => part.members)) {
91
+ if (member.kind === "indexSignature") {
92
+ indexes.push(member);
93
+ continue;
94
+ }
95
+ const name = nameOf(member);
96
+ const other = properties.get(name);
97
+ properties.set(name, other === void 0 ? member : mergedProperty(other, member));
98
+ }
99
+ return { kind: "object", members: [...properties.values(), ...indexes] };
100
+ }
101
+ /**
102
+ * The object types an intersection is made of, nested ones flattened; null for any other, and
103
+ * for an intersection that contains itself, which TypeScript does not merge either.
104
+ */
105
+ objectParts(type, visiting = /* @__PURE__ */ new Set()) {
106
+ if (type.kind === "object") {
107
+ return [type];
108
+ }
109
+ if (type.kind !== "intersection" || visiting.has(type)) {
110
+ return null;
111
+ }
112
+ const parts = [];
113
+ for (const part of type.types) {
114
+ const objects = this.objectParts(this.resolved(part), /* @__PURE__ */ new Set([...visiting, type]));
115
+ if (objects === null) {
116
+ return null;
117
+ }
118
+ parts.push(...objects);
119
+ }
120
+ return parts;
121
+ }
122
+ }
123
+
124
+ export { TypeResolution, indexSignaturesOf, nameOf, propertiesOf, readType };
125
+ //# sourceMappingURL=type-resolution.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-resolution.mjs","sources":["../../../../src/application/transform/document/type-resolution.ts"],"sourcesContent":["import type {\n IrIndexSignature,\n IrMember,\n IrObjectType,\n IrPropertySignature,\n IrType,\n} from \"../../../domain/ir/nodes.js\";\nimport type { DeclaredTypeLookup } from \"./declared-types.js\";\n\n/**\n * The types the `--path-params-as-types` overlap check compares, as TypeScript sees them:\n * references followed to the declarations of the document, `T[\"key\"]` and `T[number]` read from\n * `T`, and an intersection of object types merged into one object.\n */\n\nconst UNDEFINED: IrType = { kind: \"keyword\", keyword: \"undefined\" };\n\nexport function nameOf(member: IrPropertySignature): string {\n return member.name.kind === \"string\" ? member.name.value : member.name.text;\n}\n\nexport function propertiesOf(type: IrObjectType): Map<string, IrPropertySignature> {\n const properties = type.members.filter(\n (member: IrMember): member is IrPropertySignature => member.kind === \"property\",\n );\n return new Map(properties.map((property) => [nameOf(property), property]));\n}\n\nexport function indexSignaturesOf(type: IrObjectType): IrIndexSignature[] {\n return type.members.filter(\n (member: IrMember): member is IrIndexSignature => member.kind === \"indexSignature\",\n );\n}\n\n/** The type read from a property: an optional one may be `undefined`. */\nexport function readType(property: IrPropertySignature): IrType {\n return property.isOptional ? { kind: \"union\", types: [property.type, UNDEFINED] } : property.type;\n}\n\n/**\n * `T[number]` for an array `T`, as the generator writes for an item of an array response: the\n * element type, readonly or not. A tuple's is the union of its elements, which is not modelled.\n */\nfunction arrayElement(type: IrType): IrType | null {\n const list = type.kind === \"readonly\" ? type.type : type;\n return list.kind === \"array\" ? list.element : null;\n}\n\n/** One property for two of the same name in an intersection. */\nfunction mergedProperty(\n first: IrPropertySignature,\n second: IrPropertySignature,\n): IrPropertySignature {\n return {\n ...first,\n type: { kind: \"intersection\", types: [first.type, second.type] },\n isOptional: first.isOptional && second.isOptional,\n isReadonly: first.isReadonly || second.isReadonly,\n };\n}\n\n/** Resolves types once each, for one comparison. */\nexport class TypeResolution {\n private readonly lookup: DeclaredTypeLookup;\n private readonly resolvedTypes = new Map<IrType, IrType>();\n\n constructor(lookup: DeclaredTypeLookup) {\n this.lookup = lookup;\n }\n\n /** The type a reference names, followed through references to references; computed once. */\n resolved(type: IrType): IrType {\n const known = this.resolvedTypes.get(type);\n if (known !== undefined) {\n return known;\n }\n // A type that reaches itself while it is resolved stays as it is written there.\n this.resolvedTypes.set(type, type);\n const seen = new Set<IrType>();\n let current = type;\n while (!seen.has(current)) {\n seen.add(current);\n const named = this.lookup(current) ?? this.indexedProperty(current);\n if (named === null) {\n break;\n }\n current = named;\n }\n const result = current.kind === \"intersection\" ? (this.merged(current) ?? current) : current;\n this.resolvedTypes.set(type, result);\n return result;\n }\n\n /**\n * `T[\"key\"]` read from the object type `T` resolves to, which the lookup does not do for an\n * object it reached through another lookup (`paths[\"/a/{id}\"][\"get\"]`). An optional property\n * reads as `T | undefined`; `T[number]` is the element of the array `T`.\n */\n private indexedProperty(type: IrType): IrType | null {\n if (type.kind !== \"indexedAccess\") {\n return null;\n }\n const { index } = type;\n if (index.kind === \"keyword\" && index.keyword === \"number\") {\n return arrayElement(this.resolved(type.object));\n }\n const object = this.resolved(type.object);\n if (index.kind !== \"stringLiteral\" || object.kind !== \"object\") {\n return null;\n }\n const property = propertiesOf(object).get(index.value);\n return property === undefined ? null : readType(property);\n }\n\n /**\n * An intersection of object types as the one object TypeScript makes of it: a property in\n * several parts has the intersection of their types, and is optional only when it is in each.\n * Null when a part is no object type.\n */\n private merged(type: IrType): IrObjectType | null {\n const parts = this.objectParts(type);\n if (parts === null) {\n return null;\n }\n const properties = new Map<string, IrPropertySignature>();\n const indexes: IrIndexSignature[] = [];\n for (const member of parts.flatMap((part) => part.members)) {\n if (member.kind === \"indexSignature\") {\n indexes.push(member);\n continue;\n }\n const name = nameOf(member);\n const other = properties.get(name);\n properties.set(name, other === undefined ? member : mergedProperty(other, member));\n }\n return { kind: \"object\", members: [...properties.values(), ...indexes] };\n }\n\n /**\n * The object types an intersection is made of, nested ones flattened; null for any other, and\n * for an intersection that contains itself, which TypeScript does not merge either.\n */\n private objectParts(\n type: IrType,\n visiting: ReadonlySet<IrType> = new Set(),\n ): IrObjectType[] | null {\n if (type.kind === \"object\") {\n return [type];\n }\n if (type.kind !== \"intersection\" || visiting.has(type)) {\n return null;\n }\n const parts: IrObjectType[] = [];\n for (const part of type.types) {\n const objects = this.objectParts(this.resolved(part), new Set([...visiting, type]));\n if (objects === null) {\n return null;\n }\n parts.push(...objects);\n }\n return parts;\n }\n}\n"],"names":[],"mappings":"AAeA,MAAM,SAAA,GAAoB,EAAE,IAAA,EAAM,SAAA,EAAW,SAAS,WAAA,EAA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,MAAA,MAAM,KAAA,GAAQ,UAAA,CAAW,GAAA,CAAI,IAAI,CAAA;AACjC,MAAA,UAAA,CAAW,GAAA,CAAI,MAAM,KAAA,KAAU,MAAA,GAAY,SAAS,cAAA,CAAe,KAAA,EAAO,MAAM,CAAC,CAAA;AAAA,IACnF;AACA,IAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,OAAA,EAAS,CAAC,GAAG,UAAA,CAAW,MAAA,EAAO,EAAG,GAAG,OAAO,CAAA,EAAE;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,WAAA,CACN,IAAA,EACA,QAAA,mBAAgC,IAAI,KAAI,EACjB;AACvB,IAAA,IAAI,IAAA,CAAK,SAAS,QAAA,EAAU;AAC1B,MAAA,OAAO,CAAC,IAAI,CAAA;AAAA,IACd;AACA,IAAA,IAAI,KAAK,IAAA,KAAS,cAAA,IAAkB,QAAA,CAAS,GAAA,CAAI,IAAI,CAAA,EAAG;AACtD,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,MAAM,QAAwB,EAAC;AAC/B,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAK,KAAA,EAAO;AAC7B,MAAA,MAAM,OAAA,GAAU,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,SAAS,IAAI,CAAA,kBAAG,IAAI,GAAA,CAAI,CAAC,GAAG,QAAA,EAAU,IAAI,CAAC,CAAC,CAAA;AAClF,MAAA,IAAI,YAAY,IAAA,EAAM;AACpB,QAAA,OAAO,IAAA;AAAA,MACT;AACA,MAAA,KAAA,CAAM,IAAA,CAAK,GAAG,OAAO,CAAA;AAAA,IACvB;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACF;;"}
@@ -3,6 +3,7 @@
3
3
  const constructors = require('../../../domain/ir/constructors.cjs');
4
4
  const helperTypes = require('../helper-types.cjs');
5
5
  const enumNaming = require('./enum-naming.cjs');
6
+ const sharedEnumNames = require('./shared-enum-names.cjs');
6
7
 
7
8
  function dedupeKey(request) {
8
9
  return [...request.values].sort(compareAsStrings).map((value, index) => metadataKey(String(value), request.metadata[index])).join(",");
@@ -18,6 +19,7 @@ function compareAsStrings(left, right) {
18
19
  function metadataKey(value, metadata) {
19
20
  return `${metadata?.name ?? value}:${metadata?.description || ""}`;
20
21
  }
22
+ const ENUM_VALUES_NUMBER_SEPARATOR = "_";
21
23
  function declarationKey(name, request) {
22
24
  return JSON.stringify([name, request.values, request.metadata]);
23
25
  }
@@ -26,15 +28,26 @@ class RunFooter {
26
28
  enumNamesByKey = /* @__PURE__ */ new Map();
27
29
  /** Declarations added already: the same one twice fails with "Duplicate identifier". */
28
30
  declaredEnums = /* @__PURE__ */ new Set();
31
+ /** The member names of each declared enum, by value. */
32
+ membersByEnum = /* @__PURE__ */ new Map();
33
+ /** The members of each declared enum name, by member name. */
34
+ declaredMembers = /* @__PURE__ */ new Map();
35
+ /** `--enum-values` arrays added already: their declared name by name, type and values. */
36
+ declaredEnumValues = /* @__PURE__ */ new Map();
37
+ /** The declared `--enum-values` array names. */
38
+ enumValuesNames = /* @__PURE__ */ new Set();
29
39
  sink;
30
40
  isDedupingEnums;
31
- constructor(sink, isDedupingEnums) {
41
+ sharedNames;
42
+ constructor(sink, isDedupingEnums, sharedNames = sharedEnumNames.FIRST_SCHEMA_NAMES) {
32
43
  this.sink = sink;
33
44
  this.isDedupingEnums = isDedupingEnums;
45
+ this.sharedNames = sharedNames;
34
46
  }
35
47
  addEnum(request) {
36
- const name = this.naming.enumName(request.name);
48
+ const ownName = this.naming.enumName(request.name);
37
49
  const key = this.isDedupingEnums ? dedupeKey(request) : null;
50
+ const name = key === null ? ownName : this.sharedNames.nameOf(key, ownName, request);
38
51
  const known = key === null ? void 0 : this.enumNamesByKey.get(key);
39
52
  if (known !== void 0) {
40
53
  return known;
@@ -46,14 +59,50 @@ class RunFooter {
46
59
  if (declared !== null) {
47
60
  this.declaredEnums.add(declared);
48
61
  }
49
- this.sink.add(enumNaming.enumDeclaration(name, request, this.naming));
62
+ const declaration = this.withoutRepeats(enumNaming.enumDeclaration(name, request, this.naming));
63
+ if (declaration !== null) {
64
+ this.record(declaration);
65
+ this.sink.add(declaration);
66
+ }
50
67
  if (key !== null) {
51
68
  this.enumNamesByKey.set(key, name);
52
69
  }
53
70
  return name;
54
71
  }
72
+ /** The declaration without members an earlier one of the name has; null when none is left. */
73
+ withoutRepeats(declaration) {
74
+ const earlier = this.declaredMembers.get(declaration.name);
75
+ if (earlier === void 0) {
76
+ return declaration;
77
+ }
78
+ const merged = enumNaming.withoutDeclaredMembers(declaration, earlier);
79
+ return merged.members.length === 0 && declaration.members.length > 0 ? null : merged;
80
+ }
81
+ /** The members of a declaration; the first member of a value names it. */
82
+ record(declaration) {
83
+ const byName = this.declaredMembers.get(declaration.name) ?? /* @__PURE__ */ new Map();
84
+ const byValue = this.membersByEnum.get(declaration.name) ?? /* @__PURE__ */ new Map();
85
+ for (const member of declaration.members) {
86
+ byName.set(member.name, member.value);
87
+ if (!byValue.has(member.value)) {
88
+ byValue.set(member.value, member.name);
89
+ }
90
+ }
91
+ this.declaredMembers.set(declaration.name, byName);
92
+ this.membersByEnum.set(declaration.name, byValue);
93
+ }
94
+ enumMembers(name) {
95
+ return this.membersByEnum.get(name) ?? /* @__PURE__ */ new Map();
96
+ }
55
97
  addEnumValues(request) {
56
- const name = this.naming.arrayName(request.name);
98
+ const baseName = this.naming.arrayName(request.name);
99
+ const declared = JSON.stringify([baseName, request.type, request.values]);
100
+ if (this.declaredEnumValues.has(declared)) {
101
+ return;
102
+ }
103
+ const name = this.freeEnumValuesName(baseName);
104
+ this.declaredEnumValues.set(declared, name);
105
+ this.enumValuesNames.add(name);
57
106
  this.require(helperTypes.HELPER_TYPES.flattenedDeepRequired);
58
107
  this.require(helperTypes.HELPER_TYPES.readonlyArray);
59
108
  this.sink.add({
@@ -65,6 +114,19 @@ class RunFooter {
65
114
  comments: []
66
115
  });
67
116
  }
117
+ /**
118
+ * Another array may have the name: `Discount/type` and `discount/type`, or a property and an
119
+ * inline `allOf` item of one schema, typed at one location. A redeclared `const` does not
120
+ * compile, so a later one gets the next number (`discountTypeValues_2`). Every unnumbered name
121
+ * ends with `Values`, so a number never takes a name that a later array needs.
122
+ */
123
+ freeEnumValuesName(name) {
124
+ let candidate = name;
125
+ for (let count = 2; this.enumValuesNames.has(candidate); count++) {
126
+ candidate = `${name}${ENUM_VALUES_NUMBER_SEPARATOR}${count}`;
127
+ }
128
+ return candidate;
129
+ }
68
130
  requireWithRequired() {
69
131
  this.require(helperTypes.HELPER_TYPES.withRequired);
70
132
  }
@@ -1 +1 @@
1
- {"version":3,"file":"document-footer.cjs","sources":["../../../../src/application/transform/footer/document-footer.ts"],"sourcesContent":["import { irReference } from \"../../../domain/ir/constructors.js\";\nimport type { IrDeclaration, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { HELPER_TYPES, type HelperType } from \"../helper-types.js\";\nimport type {\n EnumDeclarationRequest,\n EnumMemberMetadata,\n EnumValuesRequest,\n} from \"../schema/schema-context.js\";\nimport type { DocumentFooter } from \"../transform-context.js\";\nimport { EnumNaming, enumDeclaration } from \"./enum-naming.js\";\n\n/** Where footer declarations go, in order: the run's `ctx.injectFooter`, open to user code. */\nexport interface FooterSink {\n /** Whether a type alias with this name is declared already (by the generator or a user). */\n hasTypeAlias(name: string): boolean;\n add(declaration: IrDeclaration): void;\n /** Add a member to the `operations` interface, declared first if needed; see `DocumentFooter`. */\n addOperation(build: () => IrPropertySignature): void;\n}\n\n/**\n * The `--dedupe-enums` key of the original: the values in default sort order, each paired with\n * the metadata at its sorted position (not the value's own metadata), as the original does.\n */\nfunction dedupeKey(request: EnumDeclarationRequest): string {\n return [...request.values]\n .sort(compareAsStrings)\n .map((value, index) => metadataKey(String(value), request.metadata[index]))\n .join(\",\");\n}\n\n/** `Array.prototype.sort` without a comparator: compares the values as strings. */\nfunction compareAsStrings(left: string | number, right: string | number): number {\n const leftText = String(left);\n const rightText = String(right);\n if (leftText === rightText) {\n return 0;\n }\n return leftText < rightText ? -1 : 1;\n}\n\nfunction metadataKey(value: string, metadata: EnumMemberMetadata | undefined): string {\n return `${metadata?.name ?? value}:${metadata?.description || \"\"}`;\n}\n\n/** The whole declaration: an equal key means the same enum, member for member. */\nfunction declarationKey(name: string, request: EnumDeclarationRequest): string {\n return JSON.stringify([name, request.values, request.metadata]);\n}\n\n/**\n * The footer of one run: enums (deduplicated with `--dedupe-enums`), `--enum-values` arrays, the\n * helper types they need, and the `operations` interface. Replaces the original's module-level\n * `enumCache`, so runs no longer share enums (research/legacy-bugs.md, item 3).\n */\nexport class RunFooter implements DocumentFooter {\n private readonly naming = new EnumNaming();\n private readonly enumNamesByKey = new Map<string, string>();\n /** Declarations added already: the same one twice fails with \"Duplicate identifier\". */\n private readonly declaredEnums = new Set<string>();\n private readonly sink: FooterSink;\n private readonly isDedupingEnums: boolean;\n\n constructor(sink: FooterSink, isDedupingEnums: boolean) {\n this.sink = sink;\n this.isDedupingEnums = isDedupingEnums;\n }\n\n addEnum(request: EnumDeclarationRequest): string {\n // The name is built before the cache lookup: it advances the naming state either way.\n const name = this.naming.enumName(request.name);\n const key = this.isDedupingEnums ? dedupeKey(request) : null;\n const known = key === null ? undefined : this.enumNamesByKey.get(key);\n if (known !== undefined) {\n return known;\n }\n // Only a repeated member fails to compile; two empty declarations merge, so they stay.\n const declared = request.values.length > 0 ? declarationKey(name, request) : null;\n if (declared !== null && this.declaredEnums.has(declared)) {\n return name;\n }\n if (declared !== null) {\n this.declaredEnums.add(declared);\n }\n this.sink.add(enumDeclaration(name, request, this.naming));\n if (key !== null) {\n this.enumNamesByKey.set(key, name);\n }\n return name;\n }\n\n addEnumValues(request: EnumValuesRequest): void {\n const name = this.naming.arrayName(request.name);\n this.require(HELPER_TYPES.flattenedDeepRequired);\n this.require(HELPER_TYPES.readonlyArray);\n this.sink.add({\n kind: \"constArray\",\n name,\n isExported: true,\n type: readonlyArrayOf(request.type),\n values: request.values,\n comments: [],\n });\n }\n\n requireWithRequired(): void {\n this.require(HELPER_TYPES.withRequired);\n }\n\n requirePropertyValues(): void {\n this.require(HELPER_TYPES.propertyValues);\n }\n\n addOperation(build: () => IrPropertySignature): void {\n this.sink.addOperation(build);\n }\n\n private require(helper: HelperType): void {\n if (!this.sink.hasTypeAlias(helper.name)) {\n this.sink.add({ kind: \"rawDeclaration\", name: helper.name, text: helper.text });\n }\n }\n}\n\nfunction readonlyArrayOf(type: IrType): IrType {\n return irReference(HELPER_TYPES.readonlyArray.name, [type]);\n}\n"],"names":["EnumNaming","enumDeclaration","HELPER_TYPES","irReference"],"mappings":";;;;;;AAwBA,SAAS,UAAU,OAAA,EAAyC;AAC1D,EAAA,OAAO,CAAC,GAAG,OAAA,CAAQ,MAAM,EACtB,IAAA,CAAK,gBAAgB,CAAA,CACrB,GAAA,CAAI,CAAC,KAAA,EAAO,UAAU,WAAA,CAAY,MAAA,CAAO,KAAK,CAAA,EAAG,OAAA,CAAQ,QAAA,CAAS,KAAK,CAAC,CAAC,CAAA,CACzE,IAAA,CAAK,GAAG,CAAA;AACb;AAGA,SAAS,gBAAA,CAAiB,MAAuB,KAAA,EAAgC;AAC/E,EAAA,MAAM,QAAA,GAAW,OAAO,IAAI,CAAA;AAC5B,EAAA,MAAM,SAAA,GAAY,OAAO,KAAK,CAAA;AAC9B,EAAA,IAAI,aAAa,SAAA,EAAW;AAC1B,IAAA,OAAO,CAAA;AAAA,EACT;AACA,EAAA,OAAO,QAAA,GAAW,YAAY,EAAA,GAAK,CAAA;AACrC;AAEA,SAAS,WAAA,CAAY,OAAe,QAAA,EAAkD;AACpF,EAAA,OAAO,GAAG,QAAA,EAAU,IAAA,IAAQ,KAAK,CAAA,CAAA,EAAI,QAAA,EAAU,eAAe,EAAE,CAAA,CAAA;AAClE;AAGA,SAAS,cAAA,CAAe,MAAc,OAAA,EAAyC;AAC7E,EAAA,OAAO,IAAA,CAAK,UAAU,CAAC,IAAA,EAAM,QAAQ,MAAA,EAAQ,OAAA,CAA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AS,gBAAgB,IAAA,EAAsB;AAC7C,EAAA,OAAOC,yBAAYD,wBAAA,CAAa,aAAA,CAAc,IAAA,EAAM,CAAC,IAAI,CAAC,CAAA;AAC5D;;"}
1
+ {"version":3,"file":"document-footer.cjs","sources":["../../../../src/application/transform/footer/document-footer.ts"],"sourcesContent":["import { irReference } from \"../../../domain/ir/constructors.js\";\nimport type {\n IrDeclaration,\n IrEnumDeclaration,\n IrPropertySignature,\n IrType,\n} from \"../../../domain/ir/nodes.js\";\nimport { HELPER_TYPES, type HelperType } from \"../helper-types.js\";\nimport type {\n EnumDeclarationRequest,\n EnumMemberMetadata,\n EnumValuesRequest,\n} from \"../schema/schema-context.js\";\nimport type { DocumentFooter } from \"../transform-context.js\";\nimport {\n type DeclaredMembers,\n EnumNaming,\n enumDeclaration,\n withoutDeclaredMembers,\n} from \"./enum-naming.js\";\nimport { FIRST_SCHEMA_NAMES, type SharedEnumNames } from \"./shared-enum-names.js\";\n\n/** Where footer declarations go, in order: the run's `ctx.injectFooter`, open to user code. */\nexport interface FooterSink {\n /** Whether a type alias with this name is declared already (by the generator or a user). */\n hasTypeAlias(name: string): boolean;\n add(declaration: IrDeclaration): void;\n /** Add a member to the `operations` interface, declared first if needed; see `DocumentFooter`. */\n addOperation(build: () => IrPropertySignature): void;\n}\n\n/**\n * The `--dedupe-enums` key of the original: the values in default sort order, each paired with\n * the metadata at its sorted position (not the value's own metadata), as the original does.\n */\nfunction dedupeKey(request: EnumDeclarationRequest): string {\n return [...request.values]\n .sort(compareAsStrings)\n .map((value, index) => metadataKey(String(value), request.metadata[index]))\n .join(\",\");\n}\n\n/** `Array.prototype.sort` without a comparator: compares the values as strings. */\nfunction compareAsStrings(left: string | number, right: string | number): number {\n const leftText = String(left);\n const rightText = String(right);\n if (leftText === rightText) {\n return 0;\n }\n return leftText < rightText ? -1 : 1;\n}\n\nfunction metadataKey(value: string, metadata: EnumMemberMetadata | undefined): string {\n return `${metadata?.name ?? value}:${metadata?.description || \"\"}`;\n}\n\n/** Separates a repeated `--enum-values` array name from its number, as root type aliases do. */\nconst ENUM_VALUES_NUMBER_SEPARATOR = \"_\";\n\n/** The whole declaration: an equal key means the same enum, member for member. */\nfunction declarationKey(name: string, request: EnumDeclarationRequest): string {\n return JSON.stringify([name, request.values, request.metadata]);\n}\n\n/**\n * The footer of one run: enums (deduplicated with `--dedupe-enums`), `--enum-values` arrays, the\n * helper types they need, and the `operations` interface. Replaces the original's module-level\n * `enumCache`, so runs no longer share enums (research/legacy-bugs.md, item 3).\n */\nexport class RunFooter implements DocumentFooter {\n private readonly naming = new EnumNaming();\n private readonly enumNamesByKey = new Map<string, string>();\n /** Declarations added already: the same one twice fails with \"Duplicate identifier\". */\n private readonly declaredEnums = new Set<string>();\n /** The member names of each declared enum, by value. */\n private readonly membersByEnum = new Map<string, Map<string | number, string>>();\n /** The members of each declared enum name, by member name. */\n private readonly declaredMembers = new Map<string, Map<string, string | number>>();\n /** `--enum-values` arrays added already: their declared name by name, type and values. */\n private readonly declaredEnumValues = new Map<string, string>();\n /** The declared `--enum-values` array names. */\n private readonly enumValuesNames = new Set<string>();\n private readonly sink: FooterSink;\n private readonly isDedupingEnums: boolean;\n private readonly sharedNames: SharedEnumNames;\n\n constructor(\n sink: FooterSink,\n isDedupingEnums: boolean,\n sharedNames: SharedEnumNames = FIRST_SCHEMA_NAMES,\n ) {\n this.sink = sink;\n this.isDedupingEnums = isDedupingEnums;\n this.sharedNames = sharedNames;\n }\n\n addEnum(request: EnumDeclarationRequest): string {\n // The name is built before the cache lookup: it advances the naming state either way.\n const ownName = this.naming.enumName(request.name);\n const key = this.isDedupingEnums ? dedupeKey(request) : null;\n // Every schema of a shared enum goes to `sharedNames`, the later ones too.\n const name = key === null ? ownName : this.sharedNames.nameOf(key, ownName, request);\n const known = key === null ? undefined : this.enumNamesByKey.get(key);\n if (known !== undefined) {\n return known;\n }\n // Only a repeated member fails to compile; two empty declarations merge, so they stay.\n const declared = request.values.length > 0 ? declarationKey(name, request) : null;\n if (declared !== null && this.declaredEnums.has(declared)) {\n return name;\n }\n if (declared !== null) {\n this.declaredEnums.add(declared);\n }\n const declaration = this.withoutRepeats(enumDeclaration(name, request, this.naming));\n if (declaration !== null) {\n this.record(declaration);\n this.sink.add(declaration);\n }\n if (key !== null) {\n this.enumNamesByKey.set(key, name);\n }\n return name;\n }\n\n /** The declaration without members an earlier one of the name has; null when none is left. */\n private withoutRepeats(declaration: IrEnumDeclaration): IrEnumDeclaration | null {\n const earlier: DeclaredMembers | undefined = this.declaredMembers.get(declaration.name);\n if (earlier === undefined) {\n return declaration;\n }\n const merged = withoutDeclaredMembers(declaration, earlier);\n // Two empty declarations merge into one empty enum, which compiles, so the second stays.\n return merged.members.length === 0 && declaration.members.length > 0 ? null : merged;\n }\n\n /** The members of a declaration; the first member of a value names it. */\n private record(declaration: IrEnumDeclaration): void {\n const byName = this.declaredMembers.get(declaration.name) ?? new Map();\n const byValue = this.membersByEnum.get(declaration.name) ?? new Map();\n for (const member of declaration.members) {\n byName.set(member.name, member.value);\n if (!byValue.has(member.value)) {\n byValue.set(member.value, member.name);\n }\n }\n this.declaredMembers.set(declaration.name, byName);\n this.membersByEnum.set(declaration.name, byValue);\n }\n\n enumMembers(name: string): ReadonlyMap<string | number, string> {\n return this.membersByEnum.get(name) ?? new Map();\n }\n\n addEnumValues(request: EnumValuesRequest): void {\n const baseName = this.naming.arrayName(request.name);\n // The same array twice fails with \"Cannot redeclare\"; a schema typed twice adds it twice.\n const declared = JSON.stringify([baseName, request.type, request.values]);\n if (this.declaredEnumValues.has(declared)) {\n return;\n }\n const name = this.freeEnumValuesName(baseName);\n this.declaredEnumValues.set(declared, name);\n this.enumValuesNames.add(name);\n this.require(HELPER_TYPES.flattenedDeepRequired);\n this.require(HELPER_TYPES.readonlyArray);\n this.sink.add({\n kind: \"constArray\",\n name,\n isExported: true,\n type: readonlyArrayOf(request.type),\n values: request.values,\n comments: [],\n });\n }\n\n /**\n * Another array may have the name: `Discount/type` and `discount/type`, or a property and an\n * inline `allOf` item of one schema, typed at one location. A redeclared `const` does not\n * compile, so a later one gets the next number (`discountTypeValues_2`). Every unnumbered name\n * ends with `Values`, so a number never takes a name that a later array needs.\n */\n private freeEnumValuesName(name: string): string {\n let candidate = name;\n for (let count = 2; this.enumValuesNames.has(candidate); count++) {\n candidate = `${name}${ENUM_VALUES_NUMBER_SEPARATOR}${count}`;\n }\n return candidate;\n }\n\n requireWithRequired(): void {\n this.require(HELPER_TYPES.withRequired);\n }\n\n requirePropertyValues(): void {\n this.require(HELPER_TYPES.propertyValues);\n }\n\n addOperation(build: () => IrPropertySignature): void {\n this.sink.addOperation(build);\n }\n\n private require(helper: HelperType): void {\n if (!this.sink.hasTypeAlias(helper.name)) {\n this.sink.add({ kind: \"rawDeclaration\", name: helper.name, text: helper.text });\n }\n }\n}\n\nfunction readonlyArrayOf(type: IrType): IrType {\n return irReference(HELPER_TYPES.readonlyArray.name, [type]);\n}\n"],"names":["EnumNaming","FIRST_SCHEMA_NAMES","enumDeclaration","withoutDeclaredMembers","HELPER_TYPES","irReference"],"mappings":";;;;;;;AAmCA,SAAS,UAAU,OAAA,EAAyC;AAC1D,EAAA,OAAO,CAAC,GAAG,OAAA,CAAQ,MAAM,EACtB,IAAA,CAAK,gBAAgB,CAAA,CACrB,GAAA,CAAI,CAAC,KAAA,EAAO,UAAU,WAAA,CAAY,MAAA,CAAO,KAAK,CAAA,EAAG,OAAA,CAAQ,QAAA,CAAS,KAAK,CAAC,CAAC,CAAA,CACzE,IAAA,CAAK,GAAG,CAAA;AACb;AAGA,SAAS,gBAAA,CAAiB,MAAuB,KAAA,EAAgC;AAC/E,EAAA,MAAM,QAAA,GAAW,OAAO,IAAI,CAAA;AAC5B,EAAA,MAAM,SAAA,GAAY,OAAO,KAAK,CAAA;AAC9B,EAAA,IAAI,aAAa,SAAA,EAAW;AAC1B,IAAA,OAAO,CAAA;AAAA,EACT;AACA,EAAA,OAAO,QAAA,GAAW,YAAY,EAAA,GAAK,C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