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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (514) hide show
  1. package/CHANGELOG.md +1831 -0
  2. package/dist/adapters/node-deprecations/node-deprecations.cjs +14 -0
  3. package/dist/adapters/node-deprecations/node-deprecations.cjs.map +1 -0
  4. package/dist/adapters/node-deprecations/node-deprecations.mjs +12 -0
  5. package/dist/adapters/node-deprecations/node-deprecations.mjs.map +1 -0
  6. package/dist/adapters/node-file-system/file-claims.cjs +105 -0
  7. package/dist/adapters/node-file-system/file-claims.cjs.map +1 -0
  8. package/dist/adapters/node-file-system/file-claims.mjs +95 -0
  9. package/dist/adapters/node-file-system/file-claims.mjs.map +1 -0
  10. package/dist/adapters/node-file-system/file-identity.cjs +82 -0
  11. package/dist/adapters/node-file-system/file-identity.cjs.map +1 -0
  12. package/dist/adapters/node-file-system/file-identity.mjs +74 -0
  13. package/dist/adapters/node-file-system/file-identity.mjs.map +1 -0
  14. package/dist/adapters/node-file-system/node-file-system.cjs +90 -14
  15. package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
  16. package/dist/adapters/node-file-system/node-file-system.mjs +90 -14
  17. package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
  18. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +75 -0
  19. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +72 -0
  21. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -0
  22. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs +1 -1
  23. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs.map +1 -1
  24. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs +2 -2
  25. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs.map +1 -1
  26. package/dist/adapters/redocly-loader/loaded-documents.cjs +28 -0
  27. package/dist/adapters/redocly-loader/loaded-documents.cjs.map +1 -0
  28. package/dist/adapters/redocly-loader/loaded-documents.mjs +21 -0
  29. package/dist/adapters/redocly-loader/loaded-documents.mjs.map +1 -0
  30. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +14 -15
  31. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +12 -13
  33. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  34. package/dist/adapters/redocly-loader/ref-access.cjs +31 -3
  35. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  36. package/dist/adapters/redocly-loader/ref-access.mjs +31 -3
  37. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  38. package/dist/adapters/redocly-loader/ref-holders.cjs +2 -2
  39. package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
  40. package/dist/adapters/redocly-loader/ref-holders.mjs +3 -3
  41. package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
  42. package/dist/adapters/redocly-loader/remote-body-limit.cjs +50 -0
  43. package/dist/adapters/redocly-loader/remote-body-limit.cjs.map +1 -0
  44. package/dist/adapters/redocly-loader/remote-body-limit.mjs +48 -0
  45. package/dist/adapters/redocly-loader/remote-body-limit.mjs.map +1 -0
  46. package/dist/adapters/redocly-loader/remote-fetch.cjs +35 -6
  47. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  48. package/dist/adapters/redocly-loader/remote-fetch.mjs +35 -6
  49. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  50. package/dist/adapters/redocly-loader/remote-node-limit.cjs +47 -0
  51. package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -0
  52. package/dist/adapters/redocly-loader/remote-node-limit.mjs +44 -0
  53. package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -0
  54. package/dist/adapters/redocly-loader/schema-load-errors.cjs +32 -8
  55. package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
  56. package/dist/adapters/redocly-loader/schema-load-errors.mjs +32 -9
  57. package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
  58. package/dist/adapters/redocly-loader/schema-source.cjs +11 -7
  59. package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
  60. package/dist/adapters/redocly-loader/schema-source.mjs +12 -8
  61. package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
  62. package/dist/adapters/redocly-loader/unsupported-keys.cjs +3 -5
  63. package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
  64. package/dist/adapters/redocly-loader/unsupported-keys.mjs +3 -5
  65. package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
  66. package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
  67. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  68. package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
  69. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  70. package/dist/api/default-ports.cjs +19 -2
  71. package/dist/api/default-ports.cjs.map +1 -1
  72. package/dist/api/default-ports.mjs +19 -3
  73. package/dist/api/default-ports.mjs.map +1 -1
  74. package/dist/api/discriminator-conflict-warnings.cjs +1 -1
  75. package/dist/api/discriminator-conflict-warnings.cjs.map +1 -1
  76. package/dist/api/discriminator-conflict-warnings.mjs +2 -2
  77. package/dist/api/discriminator-conflict-warnings.mjs.map +1 -1
  78. package/dist/api/discriminator-enum-parent.cjs +2 -2
  79. package/dist/api/discriminator-enum-parent.cjs.map +1 -1
  80. package/dist/api/discriminator-enum-parent.mjs +3 -3
  81. package/dist/api/discriminator-enum-parent.mjs.map +1 -1
  82. package/dist/api/discriminator-other-owners.cjs +5 -3
  83. package/dist/api/discriminator-other-owners.cjs.map +1 -1
  84. package/dist/api/discriminator-other-owners.mjs +5 -3
  85. package/dist/api/discriminator-other-owners.mjs.map +1 -1
  86. package/dist/api/discriminator-patch.cjs +8 -4
  87. package/dist/api/discriminator-patch.cjs.map +1 -1
  88. package/dist/api/discriminator-patch.mjs +9 -5
  89. package/dist/api/discriminator-patch.mjs.map +1 -1
  90. package/dist/api/discriminator-scan.cjs +17 -10
  91. package/dist/api/discriminator-scan.cjs.map +1 -1
  92. package/dist/api/discriminator-scan.mjs +18 -11
  93. package/dist/api/discriminator-scan.mjs.map +1 -1
  94. package/dist/api/document-run.cjs +4 -3
  95. package/dist/api/document-run.cjs.map +1 -1
  96. package/dist/api/document-run.mjs +4 -3
  97. package/dist/api/document-run.mjs.map +1 -1
  98. package/dist/api/legacy-callback-warning.cjs +7 -4
  99. package/dist/api/legacy-callback-warning.cjs.map +1 -1
  100. package/dist/api/legacy-callback-warning.mjs +8 -5
  101. package/dist/api/legacy-callback-warning.mjs.map +1 -1
  102. package/dist/api/legacy-utils.cjs.map +1 -1
  103. package/dist/api/legacy-utils.mjs.map +1 -1
  104. package/dist/api/openapi-ts.cjs +9 -5
  105. package/dist/api/openapi-ts.cjs.map +1 -1
  106. package/dist/api/openapi-ts.mjs +10 -7
  107. package/dist/api/openapi-ts.mjs.map +1 -1
  108. package/dist/api/schema-callbacks.cjs +36 -12
  109. package/dist/api/schema-callbacks.cjs.map +1 -1
  110. package/dist/api/schema-callbacks.mjs +36 -12
  111. package/dist/api/schema-callbacks.mjs.map +1 -1
  112. package/dist/api/string-to-ast.cjs +7 -9
  113. package/dist/api/string-to-ast.cjs.map +1 -1
  114. package/dist/api/string-to-ast.mjs +8 -9
  115. package/dist/api/string-to-ast.mjs.map +1 -1
  116. package/dist/api/transform-context.cjs +7 -3
  117. package/dist/api/transform-context.cjs.map +1 -1
  118. package/dist/api/transform-context.mjs +7 -3
  119. package/dist/api/transform-context.mjs.map +1 -1
  120. package/dist/api/transform-schema.cjs +42 -12
  121. package/dist/api/transform-schema.cjs.map +1 -1
  122. package/dist/api/transform-schema.mjs +44 -14
  123. package/dist/api/transform-schema.mjs.map +1 -1
  124. package/dist/application/print/text-writer.cjs +10 -3
  125. package/dist/application/print/text-writer.cjs.map +1 -1
  126. package/dist/application/print/text-writer.mjs +10 -3
  127. package/dist/application/print/text-writer.mjs.map +1 -1
  128. package/dist/application/stack-overflow.cjs +2 -1
  129. package/dist/application/stack-overflow.cjs.map +1 -1
  130. package/dist/application/stack-overflow.mjs +2 -1
  131. package/dist/application/stack-overflow.mjs.map +1 -1
  132. package/dist/application/transform/document/components.cjs +2 -2
  133. package/dist/application/transform/document/components.cjs.map +1 -1
  134. package/dist/application/transform/document/components.mjs +4 -4
  135. package/dist/application/transform/document/components.mjs.map +1 -1
  136. package/dist/application/transform/document/declared-type-names.cjs +23 -0
  137. package/dist/application/transform/document/declared-type-names.cjs.map +1 -0
  138. package/dist/application/transform/document/declared-type-names.mjs +20 -0
  139. package/dist/application/transform/document/declared-type-names.mjs.map +1 -0
  140. package/dist/application/transform/document/defs-root.cjs +1 -1
  141. package/dist/application/transform/document/defs-root.cjs.map +1 -1
  142. package/dist/application/transform/document/defs-root.mjs +2 -2
  143. package/dist/application/transform/document/defs-root.mjs.map +1 -1
  144. package/dist/application/transform/document/document.cjs +4 -1
  145. package/dist/application/transform/document/document.cjs.map +1 -1
  146. package/dist/application/transform/document/document.mjs +3 -2
  147. package/dist/application/transform/document/document.mjs.map +1 -1
  148. package/dist/application/transform/document/enum-names-given-back.cjs +62 -0
  149. package/dist/application/transform/document/enum-names-given-back.cjs.map +1 -0
  150. package/dist/application/transform/document/enum-names-given-back.mjs +58 -0
  151. package/dist/application/transform/document/enum-names-given-back.mjs.map +1 -0
  152. package/dist/application/transform/document/global-type-references.cjs +1 -0
  153. package/dist/application/transform/document/global-type-references.cjs.map +1 -1
  154. package/dist/application/transform/document/global-type-references.mjs +1 -1
  155. package/dist/application/transform/document/global-type-references.mjs.map +1 -1
  156. package/dist/application/transform/document/media-type.cjs +2 -2
  157. package/dist/application/transform/document/media-type.cjs.map +1 -1
  158. package/dist/application/transform/document/media-type.mjs +3 -3
  159. package/dist/application/transform/document/media-type.mjs.map +1 -1
  160. package/dist/application/transform/document/operation-keys-written.cjs +26 -0
  161. package/dist/application/transform/document/operation-keys-written.cjs.map +1 -0
  162. package/dist/application/transform/document/operation-keys-written.mjs +24 -0
  163. package/dist/application/transform/document/operation-keys-written.mjs.map +1 -0
  164. package/dist/application/transform/document/operation.cjs +1 -1
  165. package/dist/application/transform/document/operation.cjs.map +1 -1
  166. package/dist/application/transform/document/operation.mjs +2 -2
  167. package/dist/application/transform/document/operation.mjs.map +1 -1
  168. package/dist/application/transform/document/parameter-entries.cjs +34 -0
  169. package/dist/application/transform/document/parameter-entries.cjs.map +1 -0
  170. package/dist/application/transform/document/parameter-entries.mjs +30 -0
  171. package/dist/application/transform/document/parameter-entries.mjs.map +1 -0
  172. package/dist/application/transform/document/parameter.cjs +12 -4
  173. package/dist/application/transform/document/parameter.cjs.map +1 -1
  174. package/dist/application/transform/document/parameter.mjs +13 -5
  175. package/dist/application/transform/document/parameter.mjs.map +1 -1
  176. package/dist/application/transform/document/parameters.cjs +7 -30
  177. package/dist/application/transform/document/parameters.cjs.map +1 -1
  178. package/dist/application/transform/document/parameters.mjs +8 -31
  179. package/dist/application/transform/document/parameters.mjs.map +1 -1
  180. package/dist/application/transform/document/path-item.cjs +11 -14
  181. package/dist/application/transform/document/path-item.cjs.map +1 -1
  182. package/dist/application/transform/document/path-item.mjs +12 -16
  183. package/dist/application/transform/document/path-item.mjs.map +1 -1
  184. package/dist/application/transform/document/paths-enum.cjs +1 -0
  185. package/dist/application/transform/document/paths-enum.cjs.map +1 -1
  186. package/dist/application/transform/document/paths-enum.mjs +1 -1
  187. package/dist/application/transform/document/paths-enum.mjs.map +1 -1
  188. package/dist/application/transform/document/paths.cjs +6 -2
  189. package/dist/application/transform/document/paths.cjs.map +1 -1
  190. package/dist/application/transform/document/paths.mjs +8 -4
  191. package/dist/application/transform/document/paths.mjs.map +1 -1
  192. package/dist/application/transform/document/referenced-parameter.cjs +80 -0
  193. package/dist/application/transform/document/referenced-parameter.cjs.map +1 -0
  194. package/dist/application/transform/document/referenced-parameter.mjs +78 -0
  195. package/dist/application/transform/document/referenced-parameter.mjs.map +1 -0
  196. package/dist/application/transform/document/request-body.cjs +1 -1
  197. package/dist/application/transform/document/request-body.cjs.map +1 -1
  198. package/dist/application/transform/document/request-body.mjs +2 -2
  199. package/dist/application/transform/document/request-body.mjs.map +1 -1
  200. package/dist/application/transform/document/response.cjs +2 -2
  201. package/dist/application/transform/document/response.cjs.map +1 -1
  202. package/dist/application/transform/document/response.mjs +3 -3
  203. package/dist/application/transform/document/response.mjs.map +1 -1
  204. package/dist/application/transform/document/responses.cjs +1 -1
  205. package/dist/application/transform/document/responses.cjs.map +1 -1
  206. package/dist/application/transform/document/responses.mjs +2 -2
  207. package/dist/application/transform/document/responses.mjs.map +1 -1
  208. package/dist/application/transform/document/root-type-aliases.cjs +8 -23
  209. package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
  210. package/dist/application/transform/document/root-type-aliases.mjs +8 -24
  211. package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
  212. package/dist/application/transform/document/type-resolution.cjs +3 -1
  213. package/dist/application/transform/document/type-resolution.cjs.map +1 -1
  214. package/dist/application/transform/document/type-resolution.mjs +3 -1
  215. package/dist/application/transform/document/type-resolution.mjs.map +1 -1
  216. package/dist/application/transform/document/webhooks.cjs +1 -1
  217. package/dist/application/transform/document/webhooks.cjs.map +1 -1
  218. package/dist/application/transform/document/webhooks.mjs +2 -2
  219. package/dist/application/transform/document/webhooks.mjs.map +1 -1
  220. package/dist/application/transform/footer/document-footer.cjs +10 -2
  221. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  222. package/dist/application/transform/footer/document-footer.mjs +10 -2
  223. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  224. package/dist/application/transform/footer/enum-name-claims.cjs +48 -0
  225. package/dist/application/transform/footer/enum-name-claims.cjs.map +1 -0
  226. package/dist/application/transform/footer/enum-name-claims.mjs +46 -0
  227. package/dist/application/transform/footer/enum-name-claims.mjs.map +1 -0
  228. package/dist/application/transform/footer/operation-keys.cjs +23 -0
  229. package/dist/application/transform/footer/operation-keys.cjs.map +1 -0
  230. package/dist/application/transform/footer/operation-keys.mjs +21 -0
  231. package/dist/application/transform/footer/operation-keys.mjs.map +1 -0
  232. package/dist/application/transform/footer/type-evaluation.cjs +4 -4
  233. package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
  234. package/dist/application/transform/footer/type-evaluation.mjs +4 -4
  235. package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
  236. package/dist/application/transform/helper-types.cjs +1 -1
  237. package/dist/application/transform/helper-types.cjs.map +1 -1
  238. package/dist/application/transform/helper-types.mjs +1 -1
  239. package/dist/application/transform/helper-types.mjs.map +1 -1
  240. package/dist/application/transform/numbered-names.cjs +9 -0
  241. package/dist/application/transform/numbered-names.cjs.map +1 -1
  242. package/dist/application/transform/numbered-names.mjs +9 -1
  243. package/dist/application/transform/numbered-names.mjs.map +1 -1
  244. package/dist/application/transform/ref-pointer/generated-location.cjs +1 -1
  245. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
  246. package/dist/application/transform/ref-pointer/generated-location.mjs +2 -2
  247. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
  248. package/dist/application/transform/ref-pointer/pointer-type.cjs +1 -1
  249. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  250. package/dist/application/transform/ref-pointer/pointer-type.mjs +2 -2
  251. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  252. package/dist/application/transform/ref-type.cjs +2 -1
  253. package/dist/application/transform/ref-type.cjs.map +1 -1
  254. package/dist/application/transform/ref-type.mjs +2 -1
  255. package/dist/application/transform/ref-type.mjs.map +1 -1
  256. package/dist/application/transform/schema/access-flags.cjs +1 -1
  257. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  258. package/dist/application/transform/schema/access-flags.mjs +2 -2
  259. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  260. package/dist/application/transform/schema/array-type.cjs +2 -2
  261. package/dist/application/transform/schema/array-type.cjs.map +1 -1
  262. package/dist/application/transform/schema/array-type.mjs +3 -3
  263. package/dist/application/transform/schema/array-type.mjs.map +1 -1
  264. package/dist/application/transform/schema/composition-type.cjs +4 -4
  265. package/dist/application/transform/schema/composition-type.cjs.map +1 -1
  266. package/dist/application/transform/schema/composition-type.mjs +6 -6
  267. package/dist/application/transform/schema/composition-type.mjs.map +1 -1
  268. package/dist/application/transform/schema/enum-rule.cjs +4 -6
  269. package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
  270. package/dist/application/transform/schema/enum-rule.mjs +6 -8
  271. package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
  272. package/dist/application/transform/schema/object-type.cjs +3 -3
  273. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  274. package/dist/application/transform/schema/object-type.mjs +4 -4
  275. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  276. package/dist/application/transform/schema/presence-members.cjs +1 -1
  277. package/dist/application/transform/schema/presence-members.cjs.map +1 -1
  278. package/dist/application/transform/schema/presence-members.mjs +2 -2
  279. package/dist/application/transform/schema/presence-members.mjs.map +1 -1
  280. package/dist/application/transform/schema/ref-siblings.cjs +47 -0
  281. package/dist/application/transform/schema/ref-siblings.cjs.map +1 -0
  282. package/dist/application/transform/schema/ref-siblings.mjs +45 -0
  283. package/dist/application/transform/schema/ref-siblings.mjs.map +1 -0
  284. package/dist/application/transform/schema/required-variants.cjs +2 -2
  285. package/dist/application/transform/schema/required-variants.cjs.map +1 -1
  286. package/dist/application/transform/schema/required-variants.mjs +3 -3
  287. package/dist/application/transform/schema/required-variants.mjs.map +1 -1
  288. package/dist/application/transform/schema/schema-transform.cjs +4 -2
  289. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  290. package/dist/application/transform/schema/schema-transform.mjs +4 -2
  291. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  292. package/dist/application/transform/schema/unevaluated-properties.cjs +1 -1
  293. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  294. package/dist/application/transform/schema/unevaluated-properties.mjs +2 -2
  295. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  296. package/dist/application/transform/schema-comment.cjs +6 -2
  297. package/dist/application/transform/schema-comment.cjs.map +1 -1
  298. package/dist/application/transform/schema-comment.mjs +7 -3
  299. package/dist/application/transform/schema-comment.mjs.map +1 -1
  300. package/dist/cli/api-settings.cjs +62 -6
  301. package/dist/cli/api-settings.cjs.map +1 -1
  302. package/dist/cli/api-settings.mjs +60 -7
  303. package/dist/cli/api-settings.mjs.map +1 -1
  304. package/dist/cli/api-writes.cjs +72 -0
  305. package/dist/cli/api-writes.cjs.map +1 -0
  306. package/dist/cli/api-writes.mjs +69 -0
  307. package/dist/cli/api-writes.mjs.map +1 -0
  308. package/dist/cli/cli-errors.cjs +12 -1
  309. package/dist/cli/cli-errors.cjs.map +1 -1
  310. package/dist/cli/cli-errors.mjs +12 -1
  311. package/dist/cli/cli-errors.mjs.map +1 -1
  312. package/dist/cli/cli-output.cjs +106 -1
  313. package/dist/cli/cli-output.cjs.map +1 -1
  314. package/dist/cli/cli-output.mjs +99 -2
  315. package/dist/cli/cli-output.mjs.map +1 -1
  316. package/dist/cli/main.cjs +5 -1
  317. package/dist/cli/main.cjs.map +1 -1
  318. package/dist/cli/main.mjs +6 -2
  319. package/dist/cli/main.mjs.map +1 -1
  320. package/dist/cli/redocly-apis.cjs +82 -36
  321. package/dist/cli/redocly-apis.cjs.map +1 -1
  322. package/dist/cli/redocly-apis.mjs +85 -39
  323. package/dist/cli/redocly-apis.mjs.map +1 -1
  324. package/dist/cli/run-cli.cjs +13 -7
  325. package/dist/cli/run-cli.cjs.map +1 -1
  326. package/dist/cli/run-cli.mjs +14 -8
  327. package/dist/cli/run-cli.mjs.map +1 -1
  328. package/dist/domain/append-all.cjs +10 -0
  329. package/dist/domain/append-all.cjs.map +1 -0
  330. package/dist/domain/append-all.mjs +8 -0
  331. package/dist/domain/append-all.mjs.map +1 -0
  332. package/dist/domain/cause-secrets.cjs +37 -0
  333. package/dist/domain/cause-secrets.cjs.map +1 -0
  334. package/dist/domain/cause-secrets.mjs +35 -0
  335. package/dist/domain/cause-secrets.mjs.map +1 -0
  336. package/dist/domain/deprecations.cjs +11 -0
  337. package/dist/domain/deprecations.cjs.map +1 -0
  338. package/dist/domain/deprecations.mjs +9 -0
  339. package/dist/domain/deprecations.mjs.map +1 -0
  340. package/dist/domain/errors.cjs +9 -3
  341. package/dist/domain/errors.cjs.map +1 -1
  342. package/dist/domain/errors.mjs +9 -3
  343. package/dist/domain/errors.mjs.map +1 -1
  344. package/dist/domain/ir/identifier-text.cjs.map +1 -1
  345. package/dist/domain/ir/identifier-text.mjs +1 -1
  346. package/dist/domain/ir/identifier-text.mjs.map +1 -1
  347. package/dist/domain/ir/ir-shape.cjs +187 -0
  348. package/dist/domain/ir/ir-shape.cjs.map +1 -0
  349. package/dist/domain/ir/ir-shape.mjs +184 -0
  350. package/dist/domain/ir/ir-shape.mjs.map +1 -0
  351. package/dist/domain/ir/newer-identifier-ranges.cjs +182 -29
  352. package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -1
  353. package/dist/domain/ir/newer-identifier-ranges.mjs +182 -29
  354. package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -1
  355. package/dist/domain/openapi/alias-expansion.cjs +3 -1
  356. package/dist/domain/openapi/alias-expansion.cjs.map +1 -1
  357. package/dist/domain/openapi/alias-expansion.mjs +3 -1
  358. package/dist/domain/openapi/alias-expansion.mjs.map +1 -1
  359. package/dist/domain/openapi/discriminated-union.cjs +3 -3
  360. package/dist/domain/openapi/discriminated-union.cjs.map +1 -1
  361. package/dist/domain/openapi/discriminated-union.mjs +4 -4
  362. package/dist/domain/openapi/discriminated-union.mjs.map +1 -1
  363. package/dist/domain/openapi/discriminator-conflicts.cjs +10 -6
  364. package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -1
  365. package/dist/domain/openapi/discriminator-conflicts.mjs +11 -7
  366. package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -1
  367. package/dist/domain/openapi/json-pointer.cjs +43 -1
  368. package/dist/domain/openapi/json-pointer.cjs.map +1 -1
  369. package/dist/domain/openapi/json-pointer.mjs +40 -2
  370. package/dist/domain/openapi/json-pointer.mjs.map +1 -1
  371. package/dist/domain/openapi/schema-dialect.cjs +15 -0
  372. package/dist/domain/openapi/schema-dialect.cjs.map +1 -0
  373. package/dist/domain/openapi/schema-dialect.mjs +12 -0
  374. package/dist/domain/openapi/schema-dialect.mjs.map +1 -0
  375. package/dist/domain/openapi/unsupported-features.cjs +1 -1
  376. package/dist/domain/openapi/unsupported-features.cjs.map +1 -1
  377. package/dist/domain/openapi/unsupported-features.mjs +2 -2
  378. package/dist/domain/openapi/unsupported-features.mjs.map +1 -1
  379. package/dist/domain/output-fixes.cjs +25 -14
  380. package/dist/domain/output-fixes.cjs.map +1 -1
  381. package/dist/domain/output-fixes.mjs +25 -13
  382. package/dist/domain/output-fixes.mjs.map +1 -1
  383. package/dist/domain/url-secrets.cjs +48 -0
  384. package/dist/domain/url-secrets.cjs.map +1 -0
  385. package/dist/domain/url-secrets.mjs +45 -0
  386. package/dist/domain/url-secrets.mjs.map +1 -0
  387. package/dist/domain/warnings.cjs +0 -1
  388. package/dist/domain/warnings.cjs.map +1 -1
  389. package/dist/domain/warnings.mjs +0 -1
  390. package/dist/domain/warnings.mjs.map +1 -1
  391. package/dist/index.cjs +2 -3
  392. package/dist/index.cjs.map +1 -1
  393. package/dist/index.d.cts +57 -20
  394. package/dist/index.d.mts +57 -20
  395. package/dist/index.d.ts +57 -20
  396. package/dist/index.mjs +3 -2
  397. package/dist/index.mjs.map +1 -1
  398. package/package.json +5 -6
  399. package/src/adapters/node-deprecations/node-deprecations.ts +14 -0
  400. package/src/adapters/node-file-system/file-claims.ts +138 -0
  401. package/src/adapters/node-file-system/file-identity.ts +137 -0
  402. package/src/adapters/node-file-system/node-file-system.ts +145 -18
  403. package/src/adapters/redocly-loader/bundled-mapping-copies.ts +95 -0
  404. package/src/adapters/redocly-loader/bundled-ref-repair.ts +2 -2
  405. package/src/adapters/redocly-loader/loaded-documents.ts +46 -0
  406. package/src/adapters/redocly-loader/redocly-schema-loader.ts +18 -24
  407. package/src/adapters/redocly-loader/ref-access.ts +37 -3
  408. package/src/adapters/redocly-loader/ref-holders.ts +3 -3
  409. package/src/adapters/redocly-loader/remote-body-limit.ts +66 -0
  410. package/src/adapters/redocly-loader/remote-fetch.ts +74 -11
  411. package/src/adapters/redocly-loader/remote-node-limit.ts +62 -0
  412. package/src/adapters/redocly-loader/schema-load-errors.ts +52 -13
  413. package/src/adapters/redocly-loader/schema-source.ts +20 -8
  414. package/src/adapters/redocly-loader/unsupported-keys.ts +3 -7
  415. package/src/adapters/terminal-logger/terminal-logger.ts +10 -5
  416. package/src/api/default-ports.ts +40 -4
  417. package/src/api/discriminator-conflict-warnings.ts +2 -2
  418. package/src/api/discriminator-enum-parent.ts +3 -3
  419. package/src/api/discriminator-other-owners.ts +5 -3
  420. package/src/api/discriminator-patch.ts +9 -6
  421. package/src/api/discriminator-scan.ts +19 -11
  422. package/src/api/document-run.ts +9 -3
  423. package/src/api/legacy-callback-warning.ts +13 -6
  424. package/src/api/legacy-utils.ts +5 -1
  425. package/src/api/openapi-ts.ts +26 -7
  426. package/src/api/run-context.ts +6 -0
  427. package/src/api/schema-callbacks.ts +60 -17
  428. package/src/api/string-to-ast.ts +11 -15
  429. package/src/api/transform-context.ts +7 -3
  430. package/src/api/transform-schema.ts +67 -15
  431. package/src/application/ports/deprecation-reporter.ts +9 -0
  432. package/src/application/ports/file-system.ts +39 -0
  433. package/src/application/ports/schema-loader.ts +11 -1
  434. package/src/application/print/text-writer.ts +10 -3
  435. package/src/application/stack-overflow.ts +9 -5
  436. package/src/application/transform/document/components.ts +4 -4
  437. package/src/application/transform/document/declared-type-names.ts +36 -0
  438. package/src/application/transform/document/defs-root.ts +2 -2
  439. package/src/application/transform/document/document.ts +4 -3
  440. package/src/application/transform/document/enum-names-given-back.ts +91 -0
  441. package/src/application/transform/document/global-type-references.ts +1 -1
  442. package/src/application/transform/document/media-type.ts +4 -3
  443. package/src/application/transform/document/operation-keys-written.ts +27 -0
  444. package/src/application/transform/document/operation.ts +2 -2
  445. package/src/application/transform/document/parameter-entries.ts +70 -0
  446. package/src/application/transform/document/parameter.ts +21 -9
  447. package/src/application/transform/document/parameters.ts +13 -58
  448. package/src/application/transform/document/path-item.ts +13 -31
  449. package/src/application/transform/document/paths-enum.ts +1 -1
  450. package/src/application/transform/document/paths.ts +8 -4
  451. package/src/application/transform/document/referenced-parameter.ts +146 -0
  452. package/src/application/transform/document/request-body.ts +2 -2
  453. package/src/application/transform/document/response.ts +3 -3
  454. package/src/application/transform/document/responses.ts +2 -2
  455. package/src/application/transform/document/root-type-aliases.ts +17 -38
  456. package/src/application/transform/document/type-resolution.ts +2 -1
  457. package/src/application/transform/document/webhooks.ts +2 -2
  458. package/src/application/transform/footer/document-footer.ts +18 -1
  459. package/src/application/transform/footer/enum-name-claims.ts +62 -0
  460. package/src/application/transform/footer/operation-keys.ts +28 -0
  461. package/src/application/transform/footer/type-evaluation.ts +4 -4
  462. package/src/application/transform/helper-types.ts +6 -5
  463. package/src/application/transform/numbered-names.ts +15 -0
  464. package/src/application/transform/ref-pointer/generated-location.ts +2 -2
  465. package/src/application/transform/ref-pointer/pointer-type.ts +2 -4
  466. package/src/application/transform/ref-type.ts +2 -1
  467. package/src/application/transform/schema/access-flags.ts +2 -2
  468. package/src/application/transform/schema/array-type.ts +3 -5
  469. package/src/application/transform/schema/composition-type.ts +6 -6
  470. package/src/application/transform/schema/enum-rule.ts +10 -8
  471. package/src/application/transform/schema/object-type.ts +4 -4
  472. package/src/application/transform/schema/presence-members.ts +2 -2
  473. package/src/application/transform/schema/ref-siblings.ts +76 -0
  474. package/src/application/transform/schema/required-variants.ts +3 -3
  475. package/src/application/transform/schema/schema-context.ts +3 -0
  476. package/src/application/transform/schema/schema-transform.ts +4 -2
  477. package/src/application/transform/schema/unevaluated-properties.ts +2 -2
  478. package/src/application/transform/schema-comment.ts +7 -3
  479. package/src/application/transform/transform-context.ts +5 -0
  480. package/src/cli/api-settings.ts +82 -7
  481. package/src/cli/api-writes.ts +117 -0
  482. package/src/cli/cli-dependencies.ts +21 -4
  483. package/src/cli/cli-errors.ts +20 -1
  484. package/src/cli/cli-output.ts +186 -7
  485. package/src/cli/main.ts +6 -3
  486. package/src/cli/redocly-apis.ts +153 -48
  487. package/src/cli/run-cli.ts +37 -8
  488. package/src/domain/append-all.ts +10 -0
  489. package/src/domain/cause-secrets.ts +52 -0
  490. package/src/domain/deprecations.ts +15 -0
  491. package/src/domain/errors.ts +22 -7
  492. package/src/domain/ir/identifier-text.ts +6 -5
  493. package/src/domain/ir/ir-shape.ts +299 -0
  494. package/src/domain/ir/newer-identifier-ranges.ts +183 -30
  495. package/src/domain/openapi/alias-expansion.ts +4 -1
  496. package/src/domain/openapi/discriminated-union.ts +6 -4
  497. package/src/domain/openapi/discriminator-conflicts.ts +21 -7
  498. package/src/domain/openapi/document-object.ts +2 -0
  499. package/src/domain/openapi/json-pointer.ts +96 -7
  500. package/src/domain/openapi/schema-dialect.ts +22 -0
  501. package/src/domain/openapi/unsupported-features.ts +2 -2
  502. package/src/domain/output-fixes.ts +37 -18
  503. package/src/domain/url-secrets.ts +72 -0
  504. package/src/domain/warnings.ts +0 -1
  505. package/src/index.ts +2 -6
  506. package/src/types/generator-options.ts +1 -1
  507. package/dist/cli/main.d.cts +0 -2
  508. package/dist/cli/main.d.mts +0 -2
  509. package/dist/cli/main.d.ts +0 -2
  510. package/dist/domain/url-credentials.cjs +0 -10
  511. package/dist/domain/url-credentials.cjs.map +0 -1
  512. package/dist/domain/url-credentials.mjs +0 -8
  513. package/dist/domain/url-credentials.mjs.map +0 -1
  514. package/src/domain/url-credentials.ts +0 -18
@@ -0,0 +1,146 @@
1
+ import { irReference } from "../../../domain/ir/constructors.js";
2
+ import type { IrType } from "../../../domain/ir/nodes.js";
3
+ import {
4
+ appendPointer,
5
+ parseRefPointer,
6
+ ROOT_POINTER,
7
+ } from "../../../domain/openapi/json-pointer.js";
8
+ import type { OperationObject } from "../../../domain/openapi/operation-object.js";
9
+ import {
10
+ type ParameterObject,
11
+ type ParameterOrReference,
12
+ QUERYSTRING_LOCATION,
13
+ } from "../../../domain/openapi/parameter-object.js";
14
+ import {
15
+ ADDITIONAL_OPERATIONS_KEY,
16
+ HTTP_METHODS,
17
+ type PathItemObject,
18
+ QUERY_METHOD,
19
+ } from "../../../domain/openapi/path-item-object.js";
20
+ import { indexBy, refType } from "../ref-type.js";
21
+ import type { RefResolver } from "../schema/schema-context.js";
22
+ import type { TransformContext } from "../transform-context.js";
23
+ import { mergedParameters, type ParameterEntry, parameterEntries } from "./parameter-entries.js";
24
+
25
+ /**
26
+ * The type of a parameter `$ref`. The original indexed the parameter's location and name
27
+ * (`refType`): `#/paths/~1a/get/parameters/0` gave
28
+ * `paths["/a"]["get"]["parameters"]["query"]["q"]`.
29
+ * Where the generated type differs, that does not compile, and only there it changes:
30
+ *
31
+ * - A location whose parameters are all optional is an optional member (`query?:`), so indexing it
32
+ * fails (TS2339); it is wrapped in `NonNullable` before the name is indexed.
33
+ * - An OpenAPI 3.2 `in: querystring` parameter is the whole `query` member (ADR-020), not a member
34
+ * `querystring`, so the pointer reads `["query"]`.
35
+ *
36
+ * A `$ref` to a component parameter, or into a list the generator types elsewhere (a `$ref` path
37
+ * item or operation, a callback), keeps the original type.
38
+ */
39
+
40
+ const INDEX_RE = /^\d+$/;
41
+ const OPERATION_KEYS: ReadonlySet<string> = new Set([...HTTP_METHODS, QUERY_METHOD]);
42
+
43
+ /** A `parameters/N` pointer, split into its root and the segments of the list's owner. */
44
+ interface ParameterListPointer {
45
+ readonly root: string;
46
+ readonly owner: readonly string[];
47
+ }
48
+
49
+ function listPointerOf(ref: string): ParameterListPointer | null {
50
+ if (!ref.startsWith(`${ROOT_POINTER}/`)) {
51
+ return null;
52
+ }
53
+ const [root, ...segments] = parseRefPointer(ref);
54
+ const [list, position] = segments.slice(-2);
55
+ const isList = list === "parameters" && position !== undefined && INDEX_RE.test(position);
56
+ return root !== undefined && isList ? { root, owner: segments.slice(0, -2) } : null;
57
+ }
58
+
59
+ function pointerTo(root: string, segments: readonly string[]): string {
60
+ return appendPointer(ROOT_POINTER, [root, ...segments]);
61
+ }
62
+
63
+ /** Whether the segments name a path item that `pathItemType` types in place. */
64
+ function isPathItemAt(root: string, segments: readonly string[]): boolean {
65
+ const isNamedRoot = root === "paths" || root === "webhooks";
66
+ return (
67
+ (isNamedRoot && segments.length === 1) ||
68
+ (root === "components" && segments[0] === "pathItems" && segments.length === 2)
69
+ );
70
+ }
71
+
72
+ /** The segments of the path item that holds the operation at `owner`, or null. */
73
+ function pathItemOfOperation(root: string, owner: readonly string[]): readonly string[] | null {
74
+ const method = owner.at(-1) ?? "";
75
+ if (OPERATION_KEYS.has(method) && isPathItemAt(root, owner.slice(0, -1))) {
76
+ return owner.slice(0, -1);
77
+ }
78
+ const isAdditional = owner.at(-2) === ADDITIONAL_OPERATIONS_KEY;
79
+ return isAdditional && isPathItemAt(root, owner.slice(0, -2)) ? owner.slice(0, -2) : null;
80
+ }
81
+
82
+ function documentNode<T>(refs: RefResolver, root: string, segments: readonly string[]): T | null {
83
+ const node = refs.resolve(pointerTo(root, segments));
84
+ const isTypedHere = typeof node === "object" && node !== null && !("$ref" in node);
85
+ return isTypedHere ? (node as T) : null;
86
+ }
87
+
88
+ /** The parameters the generator types at the list's owner; null where it types them elsewhere. */
89
+ function typedParameters(
90
+ pointer: ParameterListPointer,
91
+ refs: RefResolver,
92
+ ): readonly ParameterOrReference[] | null {
93
+ const { root, owner } = pointer;
94
+ if (isPathItemAt(root, owner)) {
95
+ return documentNode<PathItemObject>(refs, root, owner)?.parameters ?? null;
96
+ }
97
+ const pathItemSegments = pathItemOfOperation(root, owner);
98
+ const pathItem = pathItemSegments && documentNode<PathItemObject>(refs, root, pathItemSegments);
99
+ const operation = pathItem && documentNode<OperationObject>(refs, root, owner);
100
+ return pathItem && operation ? mergedParameters(pathItem, operation, refs) : null;
101
+ }
102
+
103
+ /** A location member is optional when none of its parameters is required (`locationParts`). */
104
+ function isLocationOptional(entries: readonly ParameterEntry[], location: string): boolean {
105
+ return entries
106
+ .filter((entry) => entry.resolved?.in === location)
107
+ .every((entry) => location !== "path" && !entry.resolved?.required);
108
+ }
109
+
110
+ /** The corrected type, or null where the original type compiles or no correction applies. */
111
+ function correctedType(
112
+ listType: IrType,
113
+ entries: readonly ParameterEntry[],
114
+ parameter: ParameterObject,
115
+ ): IrType | null {
116
+ if (parameter.in === QUERYSTRING_LOCATION) {
117
+ // Next to `in: query` parameters it is not in the generated types (QUERYSTRING_NEXT_TO_QUERY).
118
+ const isTyped = !entries.some((entry) => entry.resolved?.in === "query");
119
+ return isTyped ? indexBy(listType, "query") : null;
120
+ }
121
+ if (!isLocationOptional(entries, parameter.in)) {
122
+ return null;
123
+ }
124
+ const location = irReference("NonNullable", [indexBy(listType, parameter.in)]);
125
+ return indexBy(location, parameter.name);
126
+ }
127
+
128
+ /** The type of a parameter `$ref` whose target resolved to `resolved`; see the module comment. */
129
+ export function referencedParameterType(
130
+ ref: string,
131
+ resolved: ParameterObject,
132
+ context: TransformContext,
133
+ ): IrType {
134
+ // A `$ref` that resolves to another `$ref` is not a parameter object yet: index it as a path.
135
+ if ((resolved as { $ref?: unknown }).$ref) {
136
+ return refType(ref, { parameter: null });
137
+ }
138
+ const original = refType(ref, { parameter: { in: resolved.in, name: resolved.name } });
139
+ const pointer = listPointerOf(ref);
140
+ const parameters = pointer && typedParameters(pointer, context.refs);
141
+ if (pointer === null || parameters === null) {
142
+ return original;
143
+ }
144
+ const listType = refType(pointerTo(pointer.root, [...pointer.owner, "parameters"]));
145
+ return correctedType(listType, parameterEntries(parameters, context), resolved) ?? original;
146
+ }
@@ -1,7 +1,7 @@
1
1
  import { irKeyword, irObject, irProperty } from "../../../domain/ir/constructors.js";
2
2
  import type { IrMember, IrType } from "../../../domain/ir/nodes.js";
3
3
  import { toPropertyName } from "../../../domain/ir/property-name.js";
4
- import { createRef } from "../../../domain/openapi/json-pointer.js";
4
+ import { appendPointer } from "../../../domain/openapi/json-pointer.js";
5
5
  import type { RequestBodyObject } from "../../../domain/openapi/request-body-object.js";
6
6
  import { documentEntries } from "../document-entries.js";
7
7
  import type { SchemaContext, SchemaLocation } from "../schema/schema-context.js";
@@ -18,7 +18,7 @@ function contentMembers(
18
18
  ): IrMember[] {
19
19
  const entries = documentEntries(requestBody.content ?? {}, context.options);
20
20
  return entries.map(([contentType, entry]) => {
21
- const path = createRef([location.path, "content", contentType]);
21
+ const path = appendPointer(location.path, ["content", contentType]);
22
22
  const type = contentEntryType(entry, { ...location, path }, context);
23
23
  return documentMember(contentType, type, entry, { isReadonly: context.options.immutable });
24
24
  });
@@ -6,7 +6,7 @@ import {
6
6
  } from "../../../domain/ir/constructors.js";
7
7
  import type { IrMember, IrPropertySignature, IrType } from "../../../domain/ir/nodes.js";
8
8
  import { toPropertyName } from "../../../domain/ir/property-name.js";
9
- import { createRef } from "../../../domain/openapi/json-pointer.js";
9
+ import { appendPointer } from "../../../domain/openapi/json-pointer.js";
10
10
  import {
11
11
  isMediaTypeComponentRef,
12
12
  type MediaTypeObject,
@@ -34,7 +34,7 @@ function headerMember(
34
34
  ? refType(header.$ref)
35
35
  : headerType(
36
36
  header,
37
- { ...location, path: createRef([location.path, "headers", name]) },
37
+ { ...location, path: appendPointer(location.path, ["headers", name]) },
38
38
  context,
39
39
  );
40
40
  return documentMember(name, type, header, {
@@ -79,7 +79,7 @@ function contentMember(
79
79
  ): IrPropertySignature {
80
80
  const entries = documentEntries(response.content ?? {}, context.options);
81
81
  const members = entries.map(([contentType, entry]) => {
82
- const path = createRef([location.path, "content", contentType]);
82
+ const path = appendPointer(location.path, ["content", contentType]);
83
83
  const type = mediaTypeEntryType(entry, { ...location, path }, context);
84
84
  return documentMember(contentType, type, entry, { isReadonly: context.options.immutable });
85
85
  });
@@ -1,6 +1,6 @@
1
1
  import { irKeyword, irObject } from "../../../domain/ir/constructors.js";
2
2
  import type { IrType } from "../../../domain/ir/nodes.js";
3
- import { createRef } from "../../../domain/openapi/json-pointer.js";
3
+ import { appendPointer } from "../../../domain/openapi/json-pointer.js";
4
4
  import type { ResponsesObject } from "../../../domain/openapi/response-object.js";
5
5
  import { documentEntries } from "../document-entries.js";
6
6
  import { refType } from "../ref-type.js";
@@ -20,7 +20,7 @@ export function responsesType(
20
20
  ? refType(response.$ref)
21
21
  : responseType(
22
22
  response,
23
- { ...location, path: createRef([location.path, "responses", code]) },
23
+ { ...location, path: appendPointer(location.path, ["responses", code]) },
24
24
  context,
25
25
  );
26
26
  return documentMember(code, type, response, { isReadonly: context.options.immutable });
@@ -2,6 +2,8 @@ import { irRaw } from "../../../domain/ir/constructors.js";
2
2
  import type { IrDeclaration, IrTypeAliasDeclaration } from "../../../domain/ir/nodes.js";
3
3
  import { escapeSingleQuotedText } from "../../../domain/ir/raw-text-escapes.js";
4
4
  import type { ComponentKind } from "../../../domain/openapi/components-object.js";
5
+ import { freeNumberedName } from "../numbered-names.js";
6
+ import { typeNamesDeclaredBy } from "./declared-type-names.js";
5
7
  import { globalTypeReferences } from "./global-type-references.js";
6
8
 
7
9
  /** The `--root-types` aliases: `export type Pet = components['schemas']['Pet'];`. */
@@ -25,7 +27,8 @@ export function rootTypeAlias(
25
27
  };
26
28
  }
27
29
 
28
- function isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAliasDeclaration {
30
+ /** Whether the declaration is a `--root-types` alias, which gives way to every other name. */
31
+ export function isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAliasDeclaration {
29
32
  return (
30
33
  declaration.kind === "typeAlias" &&
31
34
  declaration.type.kind === "raw" &&
@@ -33,23 +36,6 @@ function isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAlias
33
36
  );
34
37
  }
35
38
 
36
- /**
37
- * The type names the footer declares that an alias must not take: enums, and helper types such as
38
- * `WithRequired`. Value declarations (`--enum-values` arrays) live in another namespace.
39
- */
40
- function footerTypeNames(declarations: readonly IrDeclaration[]): Set<string> {
41
- return new Set(
42
- declarations.flatMap((declaration) => {
43
- if (declaration.kind === "enum") {
44
- return [declaration.name];
45
- }
46
- return declaration.kind === "rawDeclaration" && declaration.name !== undefined
47
- ? [declaration.name]
48
- : [];
49
- }),
50
- );
51
- }
52
-
53
39
  function declaredNames(declarations: readonly IrDeclaration[]): Set<string> {
54
40
  return new Set(
55
41
  declarations.flatMap((declaration) =>
@@ -58,21 +44,15 @@ function declaredNames(declarations: readonly IrDeclaration[]): Set<string> {
58
44
  );
59
45
  }
60
46
 
61
- function freeName(name: string, taken: ReadonlySet<string>): string {
62
- let candidate = `${name}_2`;
63
- for (let counter = 3; taken.has(candidate); counter++) {
64
- candidate = `${name}_${counter}`;
65
- }
66
- return candidate;
67
- }
68
-
69
47
  /**
70
- * Rename each root alias whose name an enum or a helper type of the footer also declares, or that
71
- * shadows a TypeScript global type the output refers to (`Record` in `Record<string, never>`), to
72
- * the next free `Name_2`, `Name_3`, … (the suffix `--root-types` uses for its own conflicts). The
73
- * footer and the globals keep their names, because the generated types refer to them. Before, the
74
- * output did not compile (enums: upstream #2099, #2341, #2206; helpers: a schema named
75
- * `WithRequired`, roadmap R11; globals: TS2315). Other declarations are returned unchanged.
48
+ * Rename each root alias whose name another declaration of the output also takes (an enum, a
49
+ * helper type, the `--make-paths-enum` enum `ApiPaths`, a root interface, `--read-write-markers`
50
+ * or `inject` types), or that shadows a TypeScript global type the output refers to (`Record` in
51
+ * `Record<string, never>`), to the next free `Name_2`, `Name_3`, … (the suffix `--root-types` uses
52
+ * for its own conflicts). The others and the globals keep their names, because the generated
53
+ * types refer to them. Before, the output did not compile (enums: upstream #2099, #2341, #2206;
54
+ * helpers: a schema named `WithRequired`, roadmap R11; globals: TS2315; `ApiPaths`: TS2567).
55
+ * Other declarations are returned unchanged.
76
56
  *
77
57
  * With the `root-type-numbering` fix (ADR-021, roadmap R13, backlog 30) the body also holds the
78
58
  * aliases a later schema of one exported name took the name from, after the other aliases and
@@ -85,11 +65,10 @@ export function renameTakenAliases<T extends IrDeclaration>(
85
65
  footer: readonly IrDeclaration[],
86
66
  closing: readonly IrDeclaration[] = [],
87
67
  ): T[] {
88
- const reserved = footerTypeNames(footer);
89
- for (const name of globalTypeReferences([...body, ...footer, ...closing])) {
90
- reserved.add(name);
91
- }
92
- const taken = declaredNames([...body, ...footer, ...closing]);
68
+ const all = [...body, ...footer, ...closing];
69
+ const others = all.filter((declaration) => !isRootTypeAlias(declaration));
70
+ const reserved = new Set([...typeNamesDeclaredBy(others), ...globalTypeReferences(all)]);
71
+ const taken = new Set([...declaredNames(all), ...typeNamesDeclaredBy(all)]);
93
72
  const aliasNames = new Set<string>();
94
73
  return body.map((declaration) => {
95
74
  if (!isRootTypeAlias(declaration)) {
@@ -100,7 +79,7 @@ export function renameTakenAliases<T extends IrDeclaration>(
100
79
  if (!isRepeated && !reserved.has(declaration.name)) {
101
80
  return declaration;
102
81
  }
103
- const name = freeName(declaration.name, taken);
82
+ const name = freeNumberedName(declaration.name, taken);
104
83
  taken.add(name);
105
84
  return { ...declaration, name };
106
85
  });
@@ -1,3 +1,4 @@
1
+ import { appendAll } from "../../../domain/append-all.js";
1
2
  import type {
2
3
  IrIndexSignature,
3
4
  IrMember,
@@ -156,7 +157,7 @@ export class TypeResolution {
156
157
  if (objects === null) {
157
158
  return null;
158
159
  }
159
- parts.push(...objects);
160
+ appendAll(parts, objects);
160
161
  }
161
162
  return parts;
162
163
  }
@@ -1,7 +1,7 @@
1
1
  import { irObject, irProperty } from "../../../domain/ir/constructors.js";
2
2
  import type { IrType } from "../../../domain/ir/nodes.js";
3
3
  import { toPropertyName } from "../../../domain/ir/property-name.js";
4
- import { createRef } from "../../../domain/openapi/json-pointer.js";
4
+ import { appendPointer, ROOT_POINTER } from "../../../domain/openapi/json-pointer.js";
5
5
  import type { PathItemObject, PathsObject } from "../../../domain/openapi/path-item-object.js";
6
6
  import { documentEntries } from "../document-entries.js";
7
7
  import type { TransformContext } from "../transform-context.js";
@@ -14,7 +14,7 @@ import { pathItemType } from "./path-item.js";
14
14
  */
15
15
  export function webhooksType(webhooks: PathsObject, context: TransformContext): IrType {
16
16
  const members = documentEntries(webhooks, context.options).map(([name, pathItem]) => {
17
- const location = { path: createRef(["webhooks", name]) };
17
+ const location = { path: appendPointer(ROOT_POINTER, ["webhooks", name]) };
18
18
  const type = pathItemType(pathItem as PathItemObject, location, context);
19
19
  return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });
20
20
  });
@@ -12,12 +12,14 @@ import type {
12
12
  EnumValuesRequest,
13
13
  } from "../schema/schema-context.js";
14
14
  import type { DocumentFooter } from "../transform-context.js";
15
+ import { EnumNameClaims } from "./enum-name-claims.js";
15
16
  import {
16
17
  type DeclaredMembers,
17
18
  EnumNaming,
18
19
  enumDeclaration,
19
20
  withoutDeclaredMembers,
20
21
  } from "./enum-naming.js";
22
+ import { OperationKeys } from "./operation-keys.js";
21
23
  import { FIRST_SCHEMA_NAMES, type SharedEnumNames } from "./shared-enum-names.js";
22
24
 
23
25
  /** Where footer declarations go, in order: the run's `ctx.injectFooter`, open to user code. */
@@ -62,6 +64,12 @@ function declarationKey(name: string, request: EnumDeclarationRequest): string {
62
64
  return JSON.stringify([name, request.values, request.metadata]);
63
65
  }
64
66
 
67
+ /** The naming state a run's footer shares with the rest of the run. */
68
+ export interface RunFooterNames {
69
+ readonly enums: EnumNameClaims;
70
+ readonly operations: OperationKeys;
71
+ }
72
+
65
73
  /**
66
74
  * The footer of one run: enums (deduplicated with `--dedupe-enums`), `--enum-values` arrays, the
67
75
  * helper types they need, and the `operations` interface. Replaces the original's module-level
@@ -83,15 +91,18 @@ export class RunFooter implements DocumentFooter {
83
91
  private readonly sink: FooterSink;
84
92
  private readonly isDedupingEnums: boolean;
85
93
  private readonly sharedNames: SharedEnumNames;
94
+ private readonly names: RunFooterNames;
86
95
 
87
96
  constructor(
88
97
  sink: FooterSink,
89
98
  isDedupingEnums: boolean,
90
99
  sharedNames: SharedEnumNames = FIRST_SCHEMA_NAMES,
100
+ names: RunFooterNames = { enums: new EnumNameClaims(), operations: new OperationKeys() },
91
101
  ) {
92
102
  this.sink = sink;
93
103
  this.isDedupingEnums = isDedupingEnums;
94
104
  this.sharedNames = sharedNames;
105
+ this.names = names;
95
106
  }
96
107
 
97
108
  addEnum(request: EnumDeclarationRequest): string {
@@ -99,11 +110,13 @@ export class RunFooter implements DocumentFooter {
99
110
  const ownName = this.naming.enumName(request.name);
100
111
  const key = this.isDedupingEnums ? dedupeKey(request) : null;
101
112
  // Every schema of a shared enum goes to `sharedNames`, the later ones too.
102
- const name = key === null ? ownName : this.sharedNames.nameOf(key, ownName, request);
113
+ const sharedName = key === null ? ownName : this.sharedNames.nameOf(key, ownName, request);
103
114
  const known = key === null ? undefined : this.enumNamesByKey.get(key);
104
115
  if (known !== undefined) {
105
116
  return known;
106
117
  }
118
+ // The owner is the schema location: its requests share one enum, with `--dedupe-enums` too.
119
+ const name = this.names.enums.nameFor(sharedName, request.name);
107
120
  // Only a repeated member fails to compile; two empty declarations merge, so they stay.
108
121
  const declared = request.values.length > 0 ? declarationKey(name, request) : null;
109
122
  if (declared !== null && this.declaredEnums.has(declared)) {
@@ -200,6 +213,10 @@ export class RunFooter implements DocumentFooter {
200
213
  this.sink.addOperation(build);
201
214
  }
202
215
 
216
+ operationKey(operationId: string): string {
217
+ return this.names.operations.keyFor(operationId);
218
+ }
219
+
203
220
  private require(helper: HelperType): void {
204
221
  if (!this.sink.hasTypeAlias(helper.name)) {
205
222
  this.sink.add({ kind: "rawDeclaration", name: helper.name, text: helper.text });
@@ -0,0 +1,62 @@
1
+ import { freeNumberedName } from "../numbered-names.js";
2
+
3
+ /**
4
+ * The names of the `--enum` declarations of one run, unique across the enums and apart from the
5
+ * names the rest of the output may need.
6
+ *
7
+ * Every enum has an owner: the schema location it is named after, or with `--dedupe-enums` its
8
+ * members. Two owners whose names come out the same (`status` and `Status`) merged into one enum
9
+ * before, so each accepted the values of the other (upstream behavior). Now the first owner keeps
10
+ * the name and each later one gets the next free `Name_2`, `Name_3`, …; requests of one owner (a
11
+ * property and an inline `allOf` item of one schema) still share one enum.
12
+ *
13
+ * An enum also gives way to a name the output may need, which is only known at the end: a global
14
+ * type the output refers to (the `Blob` of `--binary-as-blob`, the `Record` of
15
+ * `Record<string, never>`), a helper type, or `ApiPaths`. Until then it takes the numbered name;
16
+ * `givenBack` lists the ones whose own name the output turned out not to need, so output that
17
+ * compiled before keeps its names (ADR-021).
18
+ */
19
+ export class EnumNameClaims {
20
+ private readonly mayBeNeeded: ReadonlySet<string>;
21
+ /** The first owner of each name an enum asked for. */
22
+ private readonly owners = new Map<string, string>();
23
+ /** The name given to each owner, by name asked for and owner. */
24
+ private readonly given = new Map<string, string>();
25
+ /** Every name given, and every name the output may need. */
26
+ private readonly taken: Set<string>;
27
+ /** A numbered name given only because the output may need the name asked for: that name. */
28
+ private readonly standIns = new Map<string, string>();
29
+
30
+ /** `mayBeNeeded`: the names an enum avoids until the end of the run; empty outside a run. */
31
+ constructor(mayBeNeeded: ReadonlySet<string> = new Set()) {
32
+ this.mayBeNeeded = mayBeNeeded;
33
+ this.taken = new Set(mayBeNeeded);
34
+ }
35
+
36
+ /** The declaration name of the enum `owner` asks to name `name`; the same for every request. */
37
+ nameFor(name: string, owner: string): string {
38
+ const key = JSON.stringify([name, owner]);
39
+ const known = this.given.get(key);
40
+ if (known !== undefined) {
41
+ return known;
42
+ }
43
+ const isFirstOwner = (this.owners.get(name) ?? owner) === owner;
44
+ this.owners.set(name, this.owners.get(name) ?? owner);
45
+ const isFree = isFirstOwner && !this.taken.has(name);
46
+ const declared = isFree ? name : freeNumberedName(name, this.taken);
47
+ if (isFirstOwner && this.mayBeNeeded.has(name)) {
48
+ this.standIns.set(declared, name);
49
+ }
50
+ this.taken.add(declared);
51
+ this.given.set(key, declared);
52
+ return declared;
53
+ }
54
+
55
+ /**
56
+ * The numbered names to rename back to the name asked for, because `needed` (the names the
57
+ * finished output declares or refers to) does not hold that name.
58
+ */
59
+ givenBack(needed: ReadonlySet<string>): ReadonlyMap<string, string> {
60
+ return new Map([...this.standIns].filter(([, name]) => !needed.has(name)));
61
+ }
62
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The keys of the `operations` interface in one run. A repeated `operationId` (Redocly warns
3
+ * about it) gave the interface two members of one name, which did not compile (TS2300). Now the
4
+ * first operation with an ID keeps it, and each later one gets the lowest number from 2 whose key
5
+ * no operation of the document has: the second `listItems` is `listItems2`, the name
6
+ * `--make-paths-enum` gives it in `ApiPaths` too. Keys follow the order the operations are
7
+ * transformed in, which is the document order (or the `--alphabetize` order).
8
+ */
9
+ export class OperationKeys {
10
+ private readonly written: ReadonlySet<string>;
11
+ private readonly taken = new Set<string>();
12
+
13
+ /** `written`: every operation key of the document; empty outside a document run. */
14
+ constructor(written: ReadonlySet<string> = new Set()) {
15
+ this.written = written;
16
+ }
17
+
18
+ /** The key of the next operation with this key, written or numbered. */
19
+ keyFor(key: string): string {
20
+ let unique = key;
21
+ for (let count = 2; this.taken.has(unique); count += 1) {
22
+ const candidate = `${key}${count}`;
23
+ unique = this.written.has(candidate) ? unique : candidate;
24
+ }
25
+ this.taken.add(unique);
26
+ return unique;
27
+ }
28
+ }
@@ -22,7 +22,7 @@ import { extracted, markerObject, omitted } from "./type-rules.js";
22
22
 
23
23
  /** How many references one evaluation expands; a deeper one is opaque. */
24
24
  const MAX_EXPANSIONS = 200;
25
- const DEEP_PREFIX = "FlattenedDeepRequired<";
25
+ const DEEP_HELPER = "FlattenedDeepRequired";
26
26
  /** How many members distributing an intersection may give; more is opaque. */
27
27
  const MAX_DISTRIBUTED = 64;
28
28
 
@@ -75,15 +75,15 @@ export class TypeEvaluator {
75
75
  if (this.expansions++ > MAX_EXPANSIONS) {
76
76
  return OPAQUE;
77
77
  }
78
- if (name.startsWith(DEEP_PREFIX) && name.endsWith(">")) {
79
- const root = this.declared.get(name.slice(DEEP_PREFIX.length, -1));
78
+ const [first, second] = args;
79
+ if (name === DEEP_HELPER && first?.kind === "reference" && first.typeArguments.length === 0) {
80
+ const root = this.declared.get(first.name);
80
81
  return root === undefined ? OPAQUE : this.expand({ kind: "type", type: root, deep: true });
81
82
  }
82
83
  const declared = args.length === 0 ? this.declared.get(name) : undefined;
83
84
  if (declared !== undefined) {
84
85
  return this.expand({ ...value, type: declared });
85
86
  }
86
- const [first, second] = args;
87
87
  if (first === undefined) {
88
88
  return OPAQUE;
89
89
  }
@@ -51,9 +51,10 @@ export const HELPER_TYPES = {
51
51
  /**
52
52
  * The `--read-write-markers` helper types, written before the root types. Task 7.6 replaces the
53
53
  * original text on purpose (ADR-014): primitives (also branded), readonly arrays, tuples,
54
- * intersected arrays and null-only properties keep their types (upstream #2615, #2620, #2632,
55
- * #2717, #2765). The declarations equal `Readable` / `Writable` of openapi-typesafe-helpers
56
- * (`test/api/read-write-marker-types.test.ts`); the text is what the TypeScript printer prints.
54
+ * intersected arrays, null-only and `any` properties keep their types (upstream #2615, #2620,
55
+ * #2632, #2717, #2765). The declarations equal the `Readable` / `Writable` that
56
+ * openapi-typesafe-fetch declares (`test/api/read-write-marker-types.test.ts`); the text is what
57
+ * the TypeScript printer prints.
57
58
  */
58
59
  export const READ_WRITE_MARKER_TYPES = lines(
59
60
  "export type $Read<T> = {",
@@ -65,8 +66,8 @@ export const READ_WRITE_MARKER_TYPES = lines(
65
66
  "type ReadWritePrimitive = string | number | boolean | bigint | symbol | null | undefined;",
66
67
  "type ReadWriteLeaf = ReadWritePrimitive | ((...args: never) => unknown);",
67
68
  "type ReadWriteMarkedKeys<T, Marker> = {",
68
- " [K in keyof T]-?: NonNullable<T[K]> extends never ? never : NonNullable<T[K]> " +
69
- "extends Marker ? K : never;",
69
+ " [K in keyof T]-?: 0 extends 1 & T[K] ? never : NonNullable<T[K]> extends never ? never : " +
70
+ "NonNullable<T[K]> extends Marker ? K : never;",
70
71
  "}[keyof T];",
71
72
  'type ReadWriteResolveArray<T extends readonly unknown[], Resolved extends "read" | ' +
72
73
  '"write"> = T[number][] extends T ? T extends unknown[] ? ReadWriteResolve<T[number], ' +
@@ -18,3 +18,18 @@ export function withNumberedRepeats(names: readonly string[], numbered: Numbered
18
18
  return unique;
19
19
  });
20
20
  }
21
+
22
+ /** Separates a repeated declaration name from its number: `Status` → `Status_2`. */
23
+ const DECLARATION_NUMBER_SEPARATOR = "_";
24
+
25
+ /**
26
+ * The first of `Name_2`, `Name_3`, … that `taken` does not hold: the suffix `--root-types` uses for
27
+ * its own conflicts, and every other declaration that must give way to another name.
28
+ */
29
+ export function freeNumberedName(name: string, taken: ReadonlySet<string>): string {
30
+ let count = 2;
31
+ while (taken.has(`${name}${DECLARATION_NUMBER_SEPARATOR}${count}`)) {
32
+ count += 1;
33
+ }
34
+ return `${name}${DECLARATION_NUMBER_SEPARATOR}${count}`;
35
+ }
@@ -1,4 +1,4 @@
1
- import { createRef } from "../../../domain/openapi/json-pointer.js";
1
+ import { appendPointer, ROOT_POINTER } from "../../../domain/openapi/json-pointer.js";
2
2
  import type { RefResolver } from "../schema/schema-context.js";
3
3
  import { isJsonObject } from "./generated-shape.js";
4
4
  import {
@@ -205,7 +205,7 @@ function walkTo(ref: string, refs: RefResolver, seen: readonly string[]): Locati
205
205
  export function generatedLocationOf(ref: string, refs: RefResolver): GeneratedLocation {
206
206
  const walk = walkTo(ref, refs, []);
207
207
  return {
208
- path: walk === null ? ref : createRef(walk.path),
208
+ path: walk === null ? ref : appendPointer(ROOT_POINTER, walk.path),
209
209
  isFromAdditionalProperties: walk?.isFromAdditionalProperties ?? false,
210
210
  };
211
211
  }
@@ -1,6 +1,6 @@
1
1
  import { irReference } from "../../../domain/ir/constructors.js";
2
2
  import type { IrType } from "../../../domain/ir/nodes.js";
3
- import { OutputFix } from "../../../domain/output-fixes.js";
3
+ import { FIX } from "../../../domain/output-fixes.js";
4
4
  import { InvalidRefError, refType } from "../ref-type.js";
5
5
  import type { SchemaRequest } from "../schema/schema-rule.js";
6
6
  import { generatedLocationOf } from "./generated-location.js";
@@ -62,9 +62,7 @@ function correctedType(
62
62
 
63
63
  function isCorrected(pointer: RefPointer, request: SchemaRequest): boolean {
64
64
  const { options, refs } = request.context;
65
- return (
66
- options.fixes.has(OutputFix.REF_POINTERS) || originalIndexFails({ pointer, options, refs })
67
- );
65
+ return options.fixes.has(FIX.REF_POINTERS) || originalIndexFails({ pointer, options, refs });
68
66
  }
69
67
 
70
68
  /** The type of a schema `$ref`. Throws InvalidRefError when the `$ref` has no pointer. */
@@ -68,7 +68,8 @@ export function indexKeyword(type: IrType, segment: string, isLast: boolean): Ir
68
68
  }
69
69
 
70
70
  export function rootType(rootSegment: string, isDeep: boolean): IrType {
71
- return irReference(isDeep ? `FlattenedDeepRequired<${rootSegment}>` : rootSegment);
71
+ const root = irReference(rootSegment);
72
+ return isDeep ? irReference("FlattenedDeepRequired", [root]) : root;
72
73
  }
73
74
 
74
75
  /**
@@ -1,5 +1,5 @@
1
1
  import type { Schema, SchemaObject } from "../../../domain/openapi/schema-object.js";
2
- import { OutputFix } from "../../../domain/output-fixes.js";
2
+ import { FIX } from "../../../domain/output-fixes.js";
3
3
  import type { SchemaContext } from "./schema-context.js";
4
4
 
5
5
  /** Whether a property is `readOnly` or `writeOnly` (JSON Schema 2020-12 Validation §9.4). */
@@ -56,7 +56,7 @@ export function propertyAccessFlags(value: Schema, context: SchemaContext): Acce
56
56
  if (typeof value !== "object") {
57
57
  return NO_FLAGS;
58
58
  }
59
- if (!context.options.fixes.has(OutputFix.READ_WRITE_REFS)) {
59
+ if (!context.options.fixes.has(FIX.READ_WRITE_REFS)) {
60
60
  return ownFlags(value as SchemaObject);
61
61
  }
62
62
  return appliedFlags(value, context, new Set());