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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (596) hide show
  1. package/CHANGELOG.md +1972 -0
  2. package/dist/adapters/node-file-system/file-claims.cjs +105 -0
  3. package/dist/adapters/node-file-system/file-claims.cjs.map +1 -0
  4. package/dist/adapters/node-file-system/file-claims.mjs +95 -0
  5. package/dist/adapters/node-file-system/file-claims.mjs.map +1 -0
  6. package/dist/adapters/node-file-system/file-identity.cjs +82 -0
  7. package/dist/adapters/node-file-system/file-identity.cjs.map +1 -0
  8. package/dist/adapters/node-file-system/file-identity.mjs +74 -0
  9. package/dist/adapters/node-file-system/file-identity.mjs.map +1 -0
  10. package/dist/adapters/node-file-system/node-file-system.cjs +97 -14
  11. package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
  12. package/dist/adapters/node-file-system/node-file-system.mjs +97 -14
  13. package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
  14. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs +19 -0
  15. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs.map +1 -0
  16. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs +17 -0
  17. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs.map +1 -0
  18. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +48 -0
  19. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +45 -0
  21. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -0
  22. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs +1 -1
  23. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs.map +1 -1
  24. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs +2 -2
  25. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs.map +1 -1
  26. package/dist/adapters/redocly-loader/component-schemas.cjs +17 -0
  27. package/dist/adapters/redocly-loader/component-schemas.cjs.map +1 -0
  28. package/dist/adapters/redocly-loader/component-schemas.mjs +14 -0
  29. package/dist/adapters/redocly-loader/component-schemas.mjs.map +1 -0
  30. package/dist/adapters/redocly-loader/loaded-documents.cjs +28 -0
  31. package/dist/adapters/redocly-loader/loaded-documents.cjs.map +1 -0
  32. package/dist/adapters/redocly-loader/loaded-documents.mjs +21 -0
  33. package/dist/adapters/redocly-loader/loaded-documents.mjs.map +1 -0
  34. package/dist/adapters/redocly-loader/mapping-schema-names.cjs +22 -0
  35. package/dist/adapters/redocly-loader/mapping-schema-names.cjs.map +1 -0
  36. package/dist/adapters/redocly-loader/mapping-schema-names.mjs +20 -0
  37. package/dist/adapters/redocly-loader/mapping-schema-names.mjs.map +1 -0
  38. package/dist/adapters/redocly-loader/query-named-components.cjs +137 -0
  39. package/dist/adapters/redocly-loader/query-named-components.cjs.map +1 -0
  40. package/dist/adapters/redocly-loader/query-named-components.mjs +134 -0
  41. package/dist/adapters/redocly-loader/query-named-components.mjs.map +1 -0
  42. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +40 -29
  43. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  44. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +38 -27
  45. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  46. package/dist/adapters/redocly-loader/ref-access.cjs +45 -4
  47. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  48. package/dist/adapters/redocly-loader/ref-access.mjs +45 -4
  49. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  50. package/dist/adapters/redocly-loader/ref-holders.cjs +52 -10
  51. package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
  52. package/dist/adapters/redocly-loader/ref-holders.mjs +53 -12
  53. package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
  54. package/dist/adapters/redocly-loader/remote-body-limit.cjs +50 -0
  55. package/dist/adapters/redocly-loader/remote-body-limit.cjs.map +1 -0
  56. package/dist/adapters/redocly-loader/remote-body-limit.mjs +48 -0
  57. package/dist/adapters/redocly-loader/remote-body-limit.mjs.map +1 -0
  58. package/dist/adapters/redocly-loader/remote-fetch.cjs +40 -9
  59. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  60. package/dist/adapters/redocly-loader/remote-fetch.mjs +40 -9
  61. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  62. package/dist/adapters/redocly-loader/remote-node-limit.cjs +61 -0
  63. package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -0
  64. package/dist/adapters/redocly-loader/remote-node-limit.mjs +58 -0
  65. package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -0
  66. package/dist/adapters/redocly-loader/schema-load-errors.cjs +32 -8
  67. package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
  68. package/dist/adapters/redocly-loader/schema-load-errors.mjs +32 -9
  69. package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
  70. package/dist/adapters/redocly-loader/schema-source.cjs +18 -9
  71. package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
  72. package/dist/adapters/redocly-loader/schema-source.mjs +20 -11
  73. package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
  74. package/dist/adapters/redocly-loader/unsupported-keys.cjs +3 -5
  75. package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
  76. package/dist/adapters/redocly-loader/unsupported-keys.mjs +3 -5
  77. package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
  78. package/dist/adapters/terminal-logger/terminal-logger.cjs +10 -4
  79. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  80. package/dist/adapters/terminal-logger/terminal-logger.mjs +10 -4
  81. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  82. package/dist/api/default-ports.cjs +14 -2
  83. package/dist/api/default-ports.cjs.map +1 -1
  84. package/dist/api/default-ports.mjs +14 -2
  85. package/dist/api/default-ports.mjs.map +1 -1
  86. package/dist/api/discriminator-enum-parent.cjs +2 -2
  87. package/dist/api/discriminator-enum-parent.cjs.map +1 -1
  88. package/dist/api/discriminator-enum-parent.mjs +3 -3
  89. package/dist/api/discriminator-enum-parent.mjs.map +1 -1
  90. package/dist/api/discriminator-other-owners.cjs +5 -3
  91. package/dist/api/discriminator-other-owners.cjs.map +1 -1
  92. package/dist/api/discriminator-other-owners.mjs +5 -3
  93. package/dist/api/discriminator-other-owners.mjs.map +1 -1
  94. package/dist/api/discriminator-patch.cjs +5 -1
  95. package/dist/api/discriminator-patch.cjs.map +1 -1
  96. package/dist/api/discriminator-patch.mjs +5 -1
  97. package/dist/api/discriminator-patch.mjs.map +1 -1
  98. package/dist/api/discriminator-scan.cjs +15 -8
  99. package/dist/api/discriminator-scan.cjs.map +1 -1
  100. package/dist/api/discriminator-scan.mjs +15 -8
  101. package/dist/api/discriminator-scan.mjs.map +1 -1
  102. package/dist/api/document-refs.cjs +16 -1
  103. package/dist/api/document-refs.cjs.map +1 -1
  104. package/dist/api/document-refs.mjs +16 -1
  105. package/dist/api/document-refs.mjs.map +1 -1
  106. package/dist/api/document-run.cjs +6 -12
  107. package/dist/api/document-run.cjs.map +1 -1
  108. package/dist/api/document-run.mjs +6 -12
  109. package/dist/api/document-run.mjs.map +1 -1
  110. package/dist/api/legacy-utils.cjs.map +1 -1
  111. package/dist/api/legacy-utils.mjs.map +1 -1
  112. package/dist/api/openapi-ts.cjs +9 -6
  113. package/dist/api/openapi-ts.cjs.map +1 -1
  114. package/dist/api/openapi-ts.mjs +10 -8
  115. package/dist/api/openapi-ts.mjs.map +1 -1
  116. package/dist/api/ref-limit-options.cjs +63 -0
  117. package/dist/api/ref-limit-options.cjs.map +1 -0
  118. package/dist/api/ref-limit-options.mjs +57 -0
  119. package/dist/api/ref-limit-options.mjs.map +1 -0
  120. package/dist/api/schema-callbacks.cjs +36 -12
  121. package/dist/api/schema-callbacks.cjs.map +1 -1
  122. package/dist/api/schema-callbacks.mjs +36 -12
  123. package/dist/api/schema-callbacks.mjs.map +1 -1
  124. package/dist/api/transform-context.cjs +7 -3
  125. package/dist/api/transform-context.cjs.map +1 -1
  126. package/dist/api/transform-context.mjs +7 -3
  127. package/dist/api/transform-context.mjs.map +1 -1
  128. package/dist/api/transform-schema.cjs +47 -10
  129. package/dist/api/transform-schema.cjs.map +1 -1
  130. package/dist/api/transform-schema.mjs +48 -11
  131. package/dist/api/transform-schema.mjs.map +1 -1
  132. package/dist/application/print/text-writer.cjs +10 -3
  133. package/dist/application/print/text-writer.cjs.map +1 -1
  134. package/dist/application/print/text-writer.mjs +10 -3
  135. package/dist/application/print/text-writer.mjs.map +1 -1
  136. package/dist/application/stack-overflow.cjs +2 -1
  137. package/dist/application/stack-overflow.cjs.map +1 -1
  138. package/dist/application/stack-overflow.mjs +2 -1
  139. package/dist/application/stack-overflow.mjs.map +1 -1
  140. package/dist/application/transform/declared-value-types.cjs +36 -0
  141. package/dist/application/transform/declared-value-types.cjs.map +1 -0
  142. package/dist/application/transform/declared-value-types.mjs +34 -0
  143. package/dist/application/transform/declared-value-types.mjs.map +1 -0
  144. package/dist/application/transform/document/components.cjs +1 -1
  145. package/dist/application/transform/document/components.cjs.map +1 -1
  146. package/dist/application/transform/document/components.mjs +2 -2
  147. package/dist/application/transform/document/components.mjs.map +1 -1
  148. package/dist/application/transform/document/declared-type-names.cjs +23 -0
  149. package/dist/application/transform/document/declared-type-names.cjs.map +1 -0
  150. package/dist/application/transform/document/declared-type-names.mjs +20 -0
  151. package/dist/application/transform/document/declared-type-names.mjs.map +1 -0
  152. package/dist/application/transform/document/defs-root.cjs +1 -1
  153. package/dist/application/transform/document/defs-root.cjs.map +1 -1
  154. package/dist/application/transform/document/defs-root.mjs +2 -2
  155. package/dist/application/transform/document/defs-root.mjs.map +1 -1
  156. package/dist/application/transform/document/document.cjs +7 -2
  157. package/dist/application/transform/document/document.cjs.map +1 -1
  158. package/dist/application/transform/document/document.mjs +6 -3
  159. package/dist/application/transform/document/document.mjs.map +1 -1
  160. package/dist/application/transform/document/enum-names-given-back.cjs +62 -0
  161. package/dist/application/transform/document/enum-names-given-back.cjs.map +1 -0
  162. package/dist/application/transform/document/enum-names-given-back.mjs +58 -0
  163. package/dist/application/transform/document/enum-names-given-back.mjs.map +1 -0
  164. package/dist/application/transform/document/exploded-query-values.cjs +63 -0
  165. package/dist/application/transform/document/exploded-query-values.cjs.map +1 -0
  166. package/dist/application/transform/document/exploded-query-values.mjs +59 -0
  167. package/dist/application/transform/document/exploded-query-values.mjs.map +1 -0
  168. package/dist/application/transform/document/global-type-references.cjs +1 -0
  169. package/dist/application/transform/document/global-type-references.cjs.map +1 -1
  170. package/dist/application/transform/document/global-type-references.mjs +1 -1
  171. package/dist/application/transform/document/global-type-references.mjs.map +1 -1
  172. package/dist/application/transform/document/header.cjs +11 -3
  173. package/dist/application/transform/document/header.cjs.map +1 -1
  174. package/dist/application/transform/document/header.mjs +10 -2
  175. package/dist/application/transform/document/header.mjs.map +1 -1
  176. package/dist/application/transform/document/media-type.cjs +2 -2
  177. package/dist/application/transform/document/media-type.cjs.map +1 -1
  178. package/dist/application/transform/document/media-type.mjs +3 -3
  179. package/dist/application/transform/document/media-type.mjs.map +1 -1
  180. package/dist/application/transform/document/operation-keys-written.cjs +26 -0
  181. package/dist/application/transform/document/operation-keys-written.cjs.map +1 -0
  182. package/dist/application/transform/document/operation-keys-written.mjs +24 -0
  183. package/dist/application/transform/document/operation-keys-written.mjs.map +1 -0
  184. package/dist/application/transform/document/operation.cjs +1 -1
  185. package/dist/application/transform/document/operation.cjs.map +1 -1
  186. package/dist/application/transform/document/operation.mjs +2 -2
  187. package/dist/application/transform/document/operation.mjs.map +1 -1
  188. package/dist/application/transform/document/parameter-entries.cjs +34 -0
  189. package/dist/application/transform/document/parameter-entries.cjs.map +1 -0
  190. package/dist/application/transform/document/parameter-entries.mjs +30 -0
  191. package/dist/application/transform/document/parameter-entries.mjs.map +1 -0
  192. package/dist/application/transform/document/parameter.cjs +12 -4
  193. package/dist/application/transform/document/parameter.cjs.map +1 -1
  194. package/dist/application/transform/document/parameter.mjs +13 -5
  195. package/dist/application/transform/document/parameter.mjs.map +1 -1
  196. package/dist/application/transform/document/parameters.cjs +29 -34
  197. package/dist/application/transform/document/parameters.cjs.map +1 -1
  198. package/dist/application/transform/document/parameters.mjs +29 -34
  199. package/dist/application/transform/document/parameters.mjs.map +1 -1
  200. package/dist/application/transform/document/path-item.cjs +15 -17
  201. package/dist/application/transform/document/path-item.cjs.map +1 -1
  202. package/dist/application/transform/document/path-item.mjs +15 -19
  203. package/dist/application/transform/document/path-item.mjs.map +1 -1
  204. package/dist/application/transform/document/path-template-key.cjs +84 -0
  205. package/dist/application/transform/document/path-template-key.cjs.map +1 -0
  206. package/dist/application/transform/document/path-template-key.mjs +79 -0
  207. package/dist/application/transform/document/path-template-key.mjs.map +1 -0
  208. package/dist/application/transform/document/path-template-refs.cjs +70 -0
  209. package/dist/application/transform/document/path-template-refs.cjs.map +1 -0
  210. package/dist/application/transform/document/path-template-refs.mjs +67 -0
  211. package/dist/application/transform/document/path-template-refs.mjs.map +1 -0
  212. package/dist/application/transform/document/paths-enum.cjs +8 -6
  213. package/dist/application/transform/document/paths-enum.cjs.map +1 -1
  214. package/dist/application/transform/document/paths-enum.mjs +8 -7
  215. package/dist/application/transform/document/paths-enum.mjs.map +1 -1
  216. package/dist/application/transform/document/paths.cjs +43 -67
  217. package/dist/application/transform/document/paths.cjs.map +1 -1
  218. package/dist/application/transform/document/paths.mjs +42 -68
  219. package/dist/application/transform/document/paths.mjs.map +1 -1
  220. package/dist/application/transform/document/referenced-parameter.cjs +80 -0
  221. package/dist/application/transform/document/referenced-parameter.cjs.map +1 -0
  222. package/dist/application/transform/document/referenced-parameter.mjs +78 -0
  223. package/dist/application/transform/document/referenced-parameter.mjs.map +1 -0
  224. package/dist/application/transform/document/request-body.cjs +1 -1
  225. package/dist/application/transform/document/request-body.cjs.map +1 -1
  226. package/dist/application/transform/document/request-body.mjs +2 -2
  227. package/dist/application/transform/document/request-body.mjs.map +1 -1
  228. package/dist/application/transform/document/response.cjs +2 -2
  229. package/dist/application/transform/document/response.cjs.map +1 -1
  230. package/dist/application/transform/document/response.mjs +3 -3
  231. package/dist/application/transform/document/response.mjs.map +1 -1
  232. package/dist/application/transform/document/responses.cjs +1 -1
  233. package/dist/application/transform/document/responses.cjs.map +1 -1
  234. package/dist/application/transform/document/responses.mjs +2 -2
  235. package/dist/application/transform/document/responses.mjs.map +1 -1
  236. package/dist/application/transform/document/root-type-aliases.cjs +8 -23
  237. package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
  238. package/dist/application/transform/document/root-type-aliases.mjs +8 -24
  239. package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
  240. package/dist/application/transform/document/type-resolution.cjs +3 -1
  241. package/dist/application/transform/document/type-resolution.cjs.map +1 -1
  242. package/dist/application/transform/document/type-resolution.mjs +3 -1
  243. package/dist/application/transform/document/type-resolution.mjs.map +1 -1
  244. package/dist/application/transform/document/webhooks.cjs +10 -3
  245. package/dist/application/transform/document/webhooks.cjs.map +1 -1
  246. package/dist/application/transform/document/webhooks.mjs +10 -3
  247. package/dist/application/transform/document/webhooks.mjs.map +1 -1
  248. package/dist/application/transform/footer/document-footer.cjs +16 -5
  249. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  250. package/dist/application/transform/footer/document-footer.mjs +16 -5
  251. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  252. package/dist/application/transform/footer/enum-name-claims.cjs +48 -0
  253. package/dist/application/transform/footer/enum-name-claims.cjs.map +1 -0
  254. package/dist/application/transform/footer/enum-name-claims.mjs +46 -0
  255. package/dist/application/transform/footer/enum-name-claims.mjs.map +1 -0
  256. package/dist/application/transform/footer/operation-keys.cjs +23 -0
  257. package/dist/application/transform/footer/operation-keys.cjs.map +1 -0
  258. package/dist/application/transform/footer/operation-keys.mjs +21 -0
  259. package/dist/application/transform/footer/operation-keys.mjs.map +1 -0
  260. package/dist/application/transform/footer/type-evaluation.cjs +4 -4
  261. package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
  262. package/dist/application/transform/footer/type-evaluation.mjs +4 -4
  263. package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
  264. package/dist/application/transform/helper-types.cjs +3 -3
  265. package/dist/application/transform/helper-types.cjs.map +1 -1
  266. package/dist/application/transform/helper-types.mjs +3 -3
  267. package/dist/application/transform/helper-types.mjs.map +1 -1
  268. package/dist/application/transform/numbered-names.cjs +9 -0
  269. package/dist/application/transform/numbered-names.cjs.map +1 -1
  270. package/dist/application/transform/numbered-names.mjs +9 -1
  271. package/dist/application/transform/numbered-names.mjs.map +1 -1
  272. package/dist/application/transform/ref-pointer/generated-location.cjs +5 -5
  273. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
  274. package/dist/application/transform/ref-pointer/generated-location.mjs +3 -3
  275. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
  276. package/dist/application/transform/ref-pointer/generated-shape.cjs +47 -66
  277. package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -1
  278. package/dist/application/transform/ref-pointer/generated-shape.mjs +36 -50
  279. package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -1
  280. package/dist/application/transform/ref-pointer/inline-cycles.cjs +2 -2
  281. package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -1
  282. package/dist/application/transform/ref-pointer/inline-cycles.mjs +1 -1
  283. package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -1
  284. package/dist/application/transform/ref-pointer/located-node.cjs +23 -0
  285. package/dist/application/transform/ref-pointer/located-node.cjs.map +1 -0
  286. package/dist/application/transform/ref-pointer/located-node.mjs +18 -0
  287. package/dist/application/transform/ref-pointer/located-node.mjs.map +1 -0
  288. package/dist/application/transform/ref-pointer/original-index.cjs +68 -13
  289. package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -1
  290. package/dist/application/transform/ref-pointer/original-index.mjs +70 -15
  291. package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -1
  292. package/dist/application/transform/ref-pointer/pointer-type.cjs +2 -2
  293. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  294. package/dist/application/transform/ref-pointer/pointer-type.mjs +1 -1
  295. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  296. package/dist/application/transform/ref-pointer/pointer-walk.cjs +54 -13
  297. package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -1
  298. package/dist/application/transform/ref-pointer/pointer-walk.mjs +46 -7
  299. package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -1
  300. package/dist/application/transform/ref-pointer/property-shape.cjs +52 -0
  301. package/dist/application/transform/ref-pointer/property-shape.cjs.map +1 -0
  302. package/dist/application/transform/ref-pointer/property-shape.mjs +45 -0
  303. package/dist/application/transform/ref-pointer/property-shape.mjs.map +1 -0
  304. package/dist/application/transform/ref-pointer/typed-walk.cjs +79 -21
  305. package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -1
  306. package/dist/application/transform/ref-pointer/typed-walk.mjs +76 -18
  307. package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -1
  308. package/dist/application/transform/ref-type.cjs +2 -1
  309. package/dist/application/transform/ref-type.cjs.map +1 -1
  310. package/dist/application/transform/ref-type.mjs +2 -1
  311. package/dist/application/transform/ref-type.mjs.map +1 -1
  312. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  313. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  314. package/dist/application/transform/schema/composition-type.cjs +1 -1
  315. package/dist/application/transform/schema/composition-type.cjs.map +1 -1
  316. package/dist/application/transform/schema/composition-type.mjs +2 -2
  317. package/dist/application/transform/schema/composition-type.mjs.map +1 -1
  318. package/dist/application/transform/schema/enum-rule.cjs +1 -1
  319. package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
  320. package/dist/application/transform/schema/enum-rule.mjs +2 -2
  321. package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
  322. package/dist/application/transform/schema/index-signature-type.cjs +21 -0
  323. package/dist/application/transform/schema/index-signature-type.cjs.map +1 -0
  324. package/dist/application/transform/schema/index-signature-type.mjs +19 -0
  325. package/dist/application/transform/schema/index-signature-type.mjs.map +1 -0
  326. package/dist/application/transform/schema/input-location.cjs +23 -0
  327. package/dist/application/transform/schema/input-location.cjs.map +1 -0
  328. package/dist/application/transform/schema/input-location.mjs +21 -0
  329. package/dist/application/transform/schema/input-location.mjs.map +1 -0
  330. package/dist/application/transform/schema/object-type.cjs +18 -8
  331. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  332. package/dist/application/transform/schema/object-type.mjs +19 -9
  333. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  334. package/dist/application/transform/schema/ref-siblings.cjs +47 -0
  335. package/dist/application/transform/schema/ref-siblings.cjs.map +1 -0
  336. package/dist/application/transform/schema/ref-siblings.mjs +45 -0
  337. package/dist/application/transform/schema/ref-siblings.mjs.map +1 -0
  338. package/dist/application/transform/schema/schema-transform.cjs +6 -3
  339. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  340. package/dist/application/transform/schema/schema-transform.mjs +6 -3
  341. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  342. package/dist/application/transform/schema/unevaluated-properties.cjs +2 -30
  343. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  344. package/dist/application/transform/schema/unevaluated-properties.mjs +3 -31
  345. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  346. package/dist/application/transform/schema-comment.cjs +5 -1
  347. package/dist/application/transform/schema-comment.cjs.map +1 -1
  348. package/dist/application/transform/schema-comment.mjs +5 -1
  349. package/dist/application/transform/schema-comment.mjs.map +1 -1
  350. package/dist/cli/api-logger.cjs +13 -0
  351. package/dist/cli/api-logger.cjs.map +1 -0
  352. package/dist/cli/api-logger.mjs +11 -0
  353. package/dist/cli/api-logger.mjs.map +1 -0
  354. package/dist/cli/api-settings.cjs +57 -9
  355. package/dist/cli/api-settings.cjs.map +1 -1
  356. package/dist/cli/api-settings.mjs +56 -11
  357. package/dist/cli/api-settings.mjs.map +1 -1
  358. package/dist/cli/api-writes.cjs +72 -0
  359. package/dist/cli/api-writes.cjs.map +1 -0
  360. package/dist/cli/api-writes.mjs +69 -0
  361. package/dist/cli/api-writes.mjs.map +1 -0
  362. package/dist/cli/cli-arguments.cjs +51 -11
  363. package/dist/cli/cli-arguments.cjs.map +1 -1
  364. package/dist/cli/cli-arguments.mjs +51 -11
  365. package/dist/cli/cli-arguments.mjs.map +1 -1
  366. package/dist/cli/cli-errors.cjs +29 -1
  367. package/dist/cli/cli-errors.cjs.map +1 -1
  368. package/dist/cli/cli-errors.mjs +29 -2
  369. package/dist/cli/cli-errors.mjs.map +1 -1
  370. package/dist/cli/cli-output.cjs +111 -4
  371. package/dist/cli/cli-output.cjs.map +1 -1
  372. package/dist/cli/cli-output.mjs +104 -5
  373. package/dist/cli/cli-output.mjs.map +1 -1
  374. package/dist/cli/main.cjs +13 -3
  375. package/dist/cli/main.cjs.map +1 -1
  376. package/dist/cli/main.mjs +14 -4
  377. package/dist/cli/main.mjs.map +1 -1
  378. package/dist/cli/redocly-apis.cjs +94 -37
  379. package/dist/cli/redocly-apis.cjs.map +1 -1
  380. package/dist/cli/redocly-apis.mjs +99 -42
  381. package/dist/cli/redocly-apis.mjs.map +1 -1
  382. package/dist/cli/ref-limits.cjs +15 -1
  383. package/dist/cli/ref-limits.cjs.map +1 -1
  384. package/dist/cli/ref-limits.mjs +15 -2
  385. package/dist/cli/ref-limits.mjs.map +1 -1
  386. package/dist/cli/run-cli.cjs +37 -14
  387. package/dist/cli/run-cli.cjs.map +1 -1
  388. package/dist/cli/run-cli.mjs +39 -16
  389. package/dist/cli/run-cli.mjs.map +1 -1
  390. package/dist/domain/append-all.cjs +10 -0
  391. package/dist/domain/append-all.cjs.map +1 -0
  392. package/dist/domain/append-all.mjs +8 -0
  393. package/dist/domain/append-all.mjs.map +1 -0
  394. package/dist/domain/cause-secrets.cjs +52 -0
  395. package/dist/domain/cause-secrets.cjs.map +1 -0
  396. package/dist/domain/cause-secrets.mjs +50 -0
  397. package/dist/domain/cause-secrets.mjs.map +1 -0
  398. package/dist/domain/errors.cjs +11 -3
  399. package/dist/domain/errors.cjs.map +1 -1
  400. package/dist/domain/errors.mjs +11 -3
  401. package/dist/domain/errors.mjs.map +1 -1
  402. package/dist/domain/ir/identifier-text.cjs.map +1 -1
  403. package/dist/domain/ir/identifier-text.mjs +1 -1
  404. package/dist/domain/ir/identifier-text.mjs.map +1 -1
  405. package/dist/domain/ir/ir-shape.cjs +187 -0
  406. package/dist/domain/ir/ir-shape.cjs.map +1 -0
  407. package/dist/domain/ir/ir-shape.mjs +184 -0
  408. package/dist/domain/ir/ir-shape.mjs.map +1 -0
  409. package/dist/domain/ir/newer-identifier-ranges.cjs +182 -29
  410. package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -1
  411. package/dist/domain/ir/newer-identifier-ranges.mjs +182 -29
  412. package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -1
  413. package/dist/domain/location-text.cjs +9 -0
  414. package/dist/domain/location-text.cjs.map +1 -0
  415. package/dist/domain/location-text.mjs +7 -0
  416. package/dist/domain/location-text.mjs.map +1 -0
  417. package/dist/domain/openapi/alias-expansion.cjs +3 -1
  418. package/dist/domain/openapi/alias-expansion.cjs.map +1 -1
  419. package/dist/domain/openapi/alias-expansion.mjs +3 -1
  420. package/dist/domain/openapi/alias-expansion.mjs.map +1 -1
  421. package/dist/domain/openapi/discriminated-union.cjs +3 -3
  422. package/dist/domain/openapi/discriminated-union.cjs.map +1 -1
  423. package/dist/domain/openapi/discriminated-union.mjs +4 -4
  424. package/dist/domain/openapi/discriminated-union.mjs.map +1 -1
  425. package/dist/domain/openapi/discriminator-conflicts.cjs +10 -6
  426. package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -1
  427. package/dist/domain/openapi/discriminator-conflicts.mjs +11 -7
  428. package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -1
  429. package/dist/domain/openapi/document-places.cjs +55 -0
  430. package/dist/domain/openapi/document-places.cjs.map +1 -0
  431. package/dist/domain/openapi/document-places.mjs +53 -0
  432. package/dist/domain/openapi/document-places.mjs.map +1 -0
  433. package/dist/domain/openapi/json-pointer.cjs +43 -1
  434. package/dist/domain/openapi/json-pointer.cjs.map +1 -1
  435. package/dist/domain/openapi/json-pointer.mjs +40 -2
  436. package/dist/domain/openapi/json-pointer.mjs.map +1 -1
  437. package/dist/domain/openapi/schema-dialect.cjs +15 -0
  438. package/dist/domain/openapi/schema-dialect.cjs.map +1 -0
  439. package/dist/domain/openapi/schema-dialect.mjs +12 -0
  440. package/dist/domain/openapi/schema-dialect.mjs.map +1 -0
  441. package/dist/domain/openapi/unsupported-features.cjs +1 -1
  442. package/dist/domain/openapi/unsupported-features.cjs.map +1 -1
  443. package/dist/domain/openapi/unsupported-features.mjs +2 -2
  444. package/dist/domain/openapi/unsupported-features.mjs.map +1 -1
  445. package/dist/domain/output-fixes.cjs +20 -0
  446. package/dist/domain/output-fixes.cjs.map +1 -1
  447. package/dist/domain/output-fixes.mjs +20 -0
  448. package/dist/domain/output-fixes.mjs.map +1 -1
  449. package/dist/domain/terminal-text.cjs +31 -0
  450. package/dist/domain/terminal-text.cjs.map +1 -0
  451. package/dist/domain/terminal-text.mjs +29 -0
  452. package/dist/domain/terminal-text.mjs.map +1 -0
  453. package/dist/domain/url-secrets.cjs +48 -0
  454. package/dist/domain/url-secrets.cjs.map +1 -0
  455. package/dist/domain/url-secrets.mjs +45 -0
  456. package/dist/domain/url-secrets.mjs.map +1 -0
  457. package/dist/domain/warnings.cjs +1 -0
  458. package/dist/domain/warnings.cjs.map +1 -1
  459. package/dist/domain/warnings.mjs +1 -0
  460. package/dist/domain/warnings.mjs.map +1 -1
  461. package/dist/index.d.cts +46 -20
  462. package/dist/index.d.mts +46 -20
  463. package/dist/index.d.ts +46 -20
  464. package/package.json +4 -5
  465. package/src/adapters/node-file-system/file-claims.ts +138 -0
  466. package/src/adapters/node-file-system/file-identity.ts +137 -0
  467. package/src/adapters/node-file-system/node-file-system.ts +158 -18
  468. package/src/adapters/pipe-safe-writer/pipe-safe-writer.ts +29 -0
  469. package/src/adapters/redocly-loader/bundled-mapping-copies.ts +60 -0
  470. package/src/adapters/redocly-loader/bundled-ref-repair.ts +2 -2
  471. package/src/adapters/redocly-loader/component-schemas.ts +19 -0
  472. package/src/adapters/redocly-loader/loaded-documents.ts +46 -0
  473. package/src/adapters/redocly-loader/mapping-schema-names.ts +25 -0
  474. package/src/adapters/redocly-loader/query-named-components.ts +201 -0
  475. package/src/adapters/redocly-loader/redocly-schema-loader.ts +64 -38
  476. package/src/adapters/redocly-loader/ref-access.ts +51 -4
  477. package/src/adapters/redocly-loader/ref-holders.ts +76 -15
  478. package/src/adapters/redocly-loader/remote-body-limit.ts +66 -0
  479. package/src/adapters/redocly-loader/remote-fetch.ts +85 -13
  480. package/src/adapters/redocly-loader/remote-node-limit.ts +102 -0
  481. package/src/adapters/redocly-loader/schema-load-errors.ts +52 -13
  482. package/src/adapters/redocly-loader/schema-source.ts +35 -11
  483. package/src/adapters/redocly-loader/unsupported-keys.ts +3 -7
  484. package/src/adapters/terminal-logger/terminal-logger.ts +17 -6
  485. package/src/api/default-ports.ts +33 -4
  486. package/src/api/discriminator-enum-parent.ts +3 -3
  487. package/src/api/discriminator-other-owners.ts +5 -3
  488. package/src/api/discriminator-patch.ts +5 -1
  489. package/src/api/discriminator-scan.ts +16 -8
  490. package/src/api/document-refs.ts +29 -1
  491. package/src/api/document-run.ts +10 -19
  492. package/src/api/legacy-utils.ts +5 -1
  493. package/src/api/openapi-ts.ts +26 -8
  494. package/src/api/ref-limit-options.ts +76 -0
  495. package/src/api/run-context.ts +3 -0
  496. package/src/api/schema-callbacks.ts +60 -17
  497. package/src/api/transform-context.ts +7 -3
  498. package/src/api/transform-schema.ts +79 -12
  499. package/src/application/ports/file-system.ts +47 -0
  500. package/src/application/ports/schema-loader.ts +11 -1
  501. package/src/application/print/text-writer.ts +10 -3
  502. package/src/application/stack-overflow.ts +9 -5
  503. package/src/application/transform/declared-value-types.ts +42 -0
  504. package/src/application/transform/document/components.ts +2 -2
  505. package/src/application/transform/document/declared-type-names.ts +36 -0
  506. package/src/application/transform/document/defs-root.ts +2 -2
  507. package/src/application/transform/document/document.ts +8 -5
  508. package/src/application/transform/document/enum-names-given-back.ts +91 -0
  509. package/src/application/transform/document/exploded-query-values.ts +88 -0
  510. package/src/application/transform/document/global-type-references.ts +1 -1
  511. package/src/application/transform/document/header.ts +25 -5
  512. package/src/application/transform/document/media-type.ts +4 -3
  513. package/src/application/transform/document/operation-keys-written.ts +27 -0
  514. package/src/application/transform/document/operation.ts +2 -2
  515. package/src/application/transform/document/parameter-entries.ts +70 -0
  516. package/src/application/transform/document/parameter.ts +21 -9
  517. package/src/application/transform/document/parameters.ts +56 -66
  518. package/src/application/transform/document/path-item.ts +16 -34
  519. package/src/application/transform/document/path-template-key.ts +152 -0
  520. package/src/application/transform/document/path-template-refs.ts +106 -0
  521. package/src/application/transform/document/paths-enum.ts +24 -10
  522. package/src/application/transform/document/paths.ts +59 -125
  523. package/src/application/transform/document/referenced-parameter.ts +146 -0
  524. package/src/application/transform/document/request-body.ts +2 -2
  525. package/src/application/transform/document/response.ts +3 -3
  526. package/src/application/transform/document/responses.ts +2 -2
  527. package/src/application/transform/document/root-type-aliases.ts +17 -38
  528. package/src/application/transform/document/type-resolution.ts +2 -1
  529. package/src/application/transform/document/webhooks.ts +19 -6
  530. package/src/application/transform/footer/document-footer.ts +36 -9
  531. package/src/application/transform/footer/enum-name-claims.ts +62 -0
  532. package/src/application/transform/footer/operation-keys.ts +28 -0
  533. package/src/application/transform/footer/type-evaluation.ts +4 -4
  534. package/src/application/transform/helper-types.ts +8 -7
  535. package/src/application/transform/numbered-names.ts +15 -0
  536. package/src/application/transform/ref-pointer/generated-location.ts +3 -3
  537. package/src/application/transform/ref-pointer/generated-shape.ts +67 -78
  538. package/src/application/transform/ref-pointer/inline-cycles.ts +1 -1
  539. package/src/application/transform/ref-pointer/located-node.ts +38 -0
  540. package/src/application/transform/ref-pointer/original-index.ts +100 -17
  541. package/src/application/transform/ref-pointer/pointer-type.ts +1 -1
  542. package/src/application/transform/ref-pointer/pointer-walk.ts +82 -8
  543. package/src/application/transform/ref-pointer/property-shape.ts +97 -0
  544. package/src/application/transform/ref-pointer/typed-walk.ts +117 -25
  545. package/src/application/transform/ref-type.ts +2 -1
  546. package/src/application/transform/schema/access-flags.ts +5 -2
  547. package/src/application/transform/schema/composition-type.ts +2 -2
  548. package/src/application/transform/schema/enum-rule.ts +6 -2
  549. package/src/application/transform/schema/index-signature-type.ts +31 -0
  550. package/src/application/transform/schema/input-location.ts +35 -0
  551. package/src/application/transform/schema/object-type.ts +22 -12
  552. package/src/application/transform/schema/ref-siblings.ts +76 -0
  553. package/src/application/transform/schema/schema-context.ts +3 -0
  554. package/src/application/transform/schema/schema-transform.ts +6 -3
  555. package/src/application/transform/schema/unevaluated-properties.ts +4 -44
  556. package/src/application/transform/schema-comment.ts +5 -1
  557. package/src/application/transform/transform-context.ts +5 -0
  558. package/src/cli/api-logger.ts +17 -0
  559. package/src/cli/api-settings.ts +80 -13
  560. package/src/cli/api-writes.ts +117 -0
  561. package/src/cli/cli-arguments.ts +90 -14
  562. package/src/cli/cli-dependencies.ts +26 -4
  563. package/src/cli/cli-errors.ts +42 -1
  564. package/src/cli/cli-output.ts +195 -15
  565. package/src/cli/main.ts +14 -5
  566. package/src/cli/redocly-apis.ts +177 -52
  567. package/src/cli/ref-limits.ts +21 -2
  568. package/src/cli/run-cli.ts +76 -15
  569. package/src/domain/append-all.ts +10 -0
  570. package/src/domain/cause-secrets.ts +86 -0
  571. package/src/domain/errors.ts +16 -5
  572. package/src/domain/ir/identifier-text.ts +6 -5
  573. package/src/domain/ir/ir-shape.ts +299 -0
  574. package/src/domain/ir/newer-identifier-ranges.ts +183 -30
  575. package/src/domain/location-text.ts +12 -0
  576. package/src/domain/openapi/alias-expansion.ts +4 -1
  577. package/src/domain/openapi/discriminated-union.ts +6 -4
  578. package/src/domain/openapi/discriminator-conflicts.ts +21 -7
  579. package/src/domain/openapi/document-object.ts +2 -0
  580. package/src/domain/openapi/document-places.ts +78 -0
  581. package/src/domain/openapi/json-pointer.ts +96 -7
  582. package/src/domain/openapi/schema-dialect.ts +22 -0
  583. package/src/domain/openapi/unsupported-features.ts +2 -2
  584. package/src/domain/output-fixes.ts +28 -2
  585. package/src/domain/terminal-text.ts +44 -0
  586. package/src/domain/url-secrets.ts +72 -0
  587. package/src/domain/warnings.ts +1 -0
  588. package/src/types/generator-options.ts +1 -1
  589. package/dist/cli/main.d.cts +0 -2
  590. package/dist/cli/main.d.mts +0 -2
  591. package/dist/cli/main.d.ts +0 -2
  592. package/dist/domain/url-credentials.cjs +0 -10
  593. package/dist/domain/url-credentials.cjs.map +0 -1
  594. package/dist/domain/url-credentials.mjs +0 -8
  595. package/dist/domain/url-credentials.mjs.map +0 -1
  596. package/src/domain/url-credentials.ts +0 -18
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-signature-type.cjs","sources":["../../../../src/application/transform/schema/index-signature-type.ts"],"sourcesContent":["import type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { NO_DECLARED_TYPES } from \"../document/declared-types.js\";\nimport { assignabilityProof } from \"../document/type-assignability.js\";\nimport { unionOf } from \"../type-combinators.js\";\n\n/**\n * The index signature type with the property types it does not admit. TypeScript checks an index\n * signature against every key of a value, declared ones too, so `{ total: number } & { [key:\n * string]: string }` admits no value with `total` (with a required `total`, none at all). The\n * signature takes those property types too, as `unevaluated-properties` does. A property type\n * proven assignable adds nothing, so output that admitted its values stays; one the proof cannot\n * decide (a `$ref`) is added, member by member, so the union stays flat. `$defs` is a keyword, not\n * data, so it is not read.\n */\nexport function withPropertyTypes(indexType: IrType, propertyTypes: readonly IrType[]): IrType {\n const relate = assignabilityProof(NO_DECLARED_TYPES);\n const members = unionMembers(indexType);\n const added: IrType[] = [];\n // Each member of a property type joins the union on its own, unless the union admits it\n // already: `(string | null) | (string | null)` is written `string | null`.\n for (const member of propertyTypes.flatMap(unionMembers)) {\n if (relate(member, unionOf([...members, ...added])) !== \"assignable\") {\n added.push(member);\n }\n }\n // Without an added member the index type stays as printed before, repeats and all.\n return added.length === 0 ? indexType : unionOf([...members, ...added]);\n}\n\nconst unionMembers = (type: IrType): readonly IrType[] =>\n type.kind === \"union\" ? type.types : [type];\n"],"names":["assignabilityProof","NO_DECLARED_TYPES","unionOf"],"mappings":";;;;;;AAcO,SAAS,iBAAA,CAAkB,WAAmB,aAAA,EAA0C;AAC7F,EAAA,MAAM,MAAA,GAASA,qCAAmBC,+BAAiB,CAAA;AACnD,EAAA,MAAM,OAAA,GAAU,aAAa,SAAS,CAAA;AACtC,EAAA,MAAM,QAAkB,EAAC;AAGzB,EAAA,KAAA,MAAW,MAAA,IAAU,aAAA,CAAc,OAAA,CAAQ,YAAY,CAAA,EAAG;AACxD,IAAA,IAAI,MAAA,CAAO,MAAA,EAAQC,uBAAA,CAAQ,CAAC,GAAG,OAAA,EAAS,GAAG,KAAK,CAAC,CAAC,CAAA,KAAM,YAAA,EAAc;AACpE,MAAA,KAAA,CAAM,KAAK,MAAM,CAAA;AAAA,IACnB;AAAA,EACF;AAEA,EAAA,OAAO,KAAA,CAAM,MAAA,KAAW,CAAA,GAAI,SAAA,GAAYA,uBAAA,CAAQ,CAAC,GAAG,OAAA,EAAS,GAAG,KAAK,CAAC,CAAA;AACxE;AAEA,MAAM,YAAA,GAAe,CAAC,IAAA,KACpB,IAAA,CAAK,SAAS,OAAA,GAAU,IAAA,CAAK,KAAA,GAAQ,CAAC,IAAI,CAAA;;"}
@@ -0,0 +1,19 @@
1
+ import { NO_DECLARED_TYPES } from '../document/declared-types.mjs';
2
+ import { assignabilityProof } from '../document/type-assignability.mjs';
3
+ import { unionOf } from '../type-combinators.mjs';
4
+
5
+ function withPropertyTypes(indexType, propertyTypes) {
6
+ const relate = assignabilityProof(NO_DECLARED_TYPES);
7
+ const members = unionMembers(indexType);
8
+ const added = [];
9
+ for (const member of propertyTypes.flatMap(unionMembers)) {
10
+ if (relate(member, unionOf([...members, ...added])) !== "assignable") {
11
+ added.push(member);
12
+ }
13
+ }
14
+ return added.length === 0 ? indexType : unionOf([...members, ...added]);
15
+ }
16
+ const unionMembers = (type) => type.kind === "union" ? type.types : [type];
17
+
18
+ export { withPropertyTypes };
19
+ //# sourceMappingURL=index-signature-type.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-signature-type.mjs","sources":["../../../../src/application/transform/schema/index-signature-type.ts"],"sourcesContent":["import type { IrType } from \"../../../domain/ir/nodes.js\";\nimport { NO_DECLARED_TYPES } from \"../document/declared-types.js\";\nimport { assignabilityProof } from \"../document/type-assignability.js\";\nimport { unionOf } from \"../type-combinators.js\";\n\n/**\n * The index signature type with the property types it does not admit. TypeScript checks an index\n * signature against every key of a value, declared ones too, so `{ total: number } & { [key:\n * string]: string }` admits no value with `total` (with a required `total`, none at all). The\n * signature takes those property types too, as `unevaluated-properties` does. A property type\n * proven assignable adds nothing, so output that admitted its values stays; one the proof cannot\n * decide (a `$ref`) is added, member by member, so the union stays flat. `$defs` is a keyword, not\n * data, so it is not read.\n */\nexport function withPropertyTypes(indexType: IrType, propertyTypes: readonly IrType[]): IrType {\n const relate = assignabilityProof(NO_DECLARED_TYPES);\n const members = unionMembers(indexType);\n const added: IrType[] = [];\n // Each member of a property type joins the union on its own, unless the union admits it\n // already: `(string | null) | (string | null)` is written `string | null`.\n for (const member of propertyTypes.flatMap(unionMembers)) {\n if (relate(member, unionOf([...members, ...added])) !== \"assignable\") {\n added.push(member);\n }\n }\n // Without an added member the index type stays as printed before, repeats and all.\n return added.length === 0 ? indexType : unionOf([...members, ...added]);\n}\n\nconst unionMembers = (type: IrType): readonly IrType[] =>\n type.kind === \"union\" ? type.types : [type];\n"],"names":[],"mappings":";;;;AAcO,SAAS,iBAAA,CAAkB,WAAmB,aAAA,EAA0C;AAC7F,EAAA,MAAM,MAAA,GAAS,mBAAmB,iBAAiB,CAAA;AACnD,EAAA,MAAM,OAAA,GAAU,aAAa,SAAS,CAAA;AACtC,EAAA,MAAM,QAAkB,EAAC;AAGzB,EAAA,KAAA,MAAW,MAAA,IAAU,aAAA,CAAc,OAAA,CAAQ,YAAY,CAAA,EAAG;AACxD,IAAA,IAAI,MAAA,CAAO,MAAA,EAAQ,OAAA,CAAQ,CAAC,GAAG,OAAA,EAAS,GAAG,KAAK,CAAC,CAAC,CAAA,KAAM,YAAA,EAAc;AACpE,MAAA,KAAA,CAAM,KAAK,MAAM,CAAA;AAAA,IACnB;AAAA,EACF;AAEA,EAAA,OAAO,KAAA,CAAM,MAAA,KAAW,CAAA,GAAI,SAAA,GAAY,OAAA,CAAQ,CAAC,GAAG,OAAA,EAAS,GAAG,KAAK,CAAC,CAAA;AACxE;AAEA,MAAM,YAAA,GAAe,CAAC,IAAA,KACpB,IAAA,CAAK,SAAS,OAAA,GAAU,IAAA,CAAK,KAAA,GAAQ,CAAC,IAAI,CAAA;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ const documentPlaces = require('../../../domain/openapi/document-places.cjs');
4
+ const jsonPointer = require('../../../domain/openapi/json-pointer.cjs');
5
+ const outputFixes = require('../../../domain/output-fixes.cjs');
6
+
7
+ const ORIGINAL_INPUT_WORDS = ["parameters", "requestBody", "requestBodies"];
8
+ function isInputLocation(path, fixes) {
9
+ if (path === void 0) {
10
+ return false;
11
+ }
12
+ return fixes.has(outputFixes.FIX.DEFAULT_INPUT_LOCATIONS) ? isStructuralInput(path) : namesInput(path);
13
+ }
14
+ function namesInput(path) {
15
+ return ORIGINAL_INPUT_WORDS.some((word) => path.includes(word));
16
+ }
17
+ function isStructuralInput(path) {
18
+ const place = documentPlaces.placeOf(jsonPointer.parseRefPointer(path));
19
+ return place === "outside" ? namesInput(path) : place === "input";
20
+ }
21
+
22
+ exports.isInputLocation = isInputLocation;
23
+ //# sourceMappingURL=input-location.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-location.cjs","sources":["../../../../src/application/transform/schema/input-location.ts"],"sourcesContent":["import { placeOf } from \"../../../domain/openapi/document-places.js\";\nimport { parseRefPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport { FIX, type OutputFix } from \"../../../domain/output-fixes.js\";\n\n/** The words that mark an input anywhere in a location, as the original reads them. */\nconst ORIGINAL_INPUT_WORDS = [\"parameters\", \"requestBody\", \"requestBodies\"] as const;\n\n/**\n * Whether a schema location describes an input: a parameter or a request body. A client may\n * leave out an input property that has a `default`, so the default makes no such property\n * required. The original tests the location text for a word, so a schema or path that is only\n * named so (`#/components/schemas/Job/properties/parameters`, `/system-parameters`) counts as an\n * input too. The `default-input-locations` fix reads a pointer into the document by the\n * document's structure instead (ADR-021).\n */\nexport function isInputLocation(path: string | undefined, fixes: ReadonlySet<OutputFix>): boolean {\n if (path === undefined) {\n return false;\n }\n return fixes.has(FIX.DEFAULT_INPUT_LOCATIONS) ? isStructuralInput(path) : namesInput(path);\n}\n\nfunction namesInput(path: string): boolean {\n return ORIGINAL_INPUT_WORDS.some((word) => path.includes(word));\n}\n\n/**\n * Whether the document's structure makes the pointer an input. A path an exported transformer was\n * given that is no pointer into the document (`/items/{id}`) has no known structure, so the\n * original's words still mark an input there.\n */\nfunction isStructuralInput(path: string): boolean {\n const place = placeOf(parseRefPointer(path));\n return place === \"outside\" ? namesInput(path) : place === \"input\";\n}\n"],"names":["FIX","placeOf","parseRefPointer"],"mappings":";;;;;;AAKA,MAAM,oBAAA,GAAuB,CAAC,YAAA,EAAc,aAAA,EAAe,eAAe,CAAA;AAUnE,SAAS,eAAA,CAAgB,MAA0B,KAAA,EAAwC;AAChG,EAAA,IAAI,SAAS,MAAA,EAAW;AACtB,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA,CAAM,IAAIA,eAAA,CAAI,uBAAuB,IAAI,iBAAA,CAAkB,IAAI,CAAA,GAAI,UAAA,CAAW,IAAI,CAAA;AAC3F;AAEA,SAAS,WAAW,IAAA,EAAuB;AACzC,EAAA,OAAO,qBAAqB,IAAA,CAAK,CAAC,SAAS,IAAA,CAAK,QAAA,CAAS,IAAI,CAAC,CAAA;AAChE;AAOA,SAAS,kBAAkB,IAAA,EAAuB;AAChD,EAAA,MAAM,KAAA,GAAQC,sBAAA,CAAQC,2BAAA,CAAgB,IAAI,CAAC,CAAA;AAC3C,EAAA,OAAO,KAAA,KAAU,SAAA,GAAY,UAAA,CAAW,IAAI,IAAI,KAAA,KAAU,OAAA;AAC5D;;"}
@@ -0,0 +1,21 @@
1
+ import { placeOf } from '../../../domain/openapi/document-places.mjs';
2
+ import { parseRefPointer } from '../../../domain/openapi/json-pointer.mjs';
3
+ import { FIX } from '../../../domain/output-fixes.mjs';
4
+
5
+ const ORIGINAL_INPUT_WORDS = ["parameters", "requestBody", "requestBodies"];
6
+ function isInputLocation(path, fixes) {
7
+ if (path === void 0) {
8
+ return false;
9
+ }
10
+ return fixes.has(FIX.DEFAULT_INPUT_LOCATIONS) ? isStructuralInput(path) : namesInput(path);
11
+ }
12
+ function namesInput(path) {
13
+ return ORIGINAL_INPUT_WORDS.some((word) => path.includes(word));
14
+ }
15
+ function isStructuralInput(path) {
16
+ const place = placeOf(parseRefPointer(path));
17
+ return place === "outside" ? namesInput(path) : place === "input";
18
+ }
19
+
20
+ export { isInputLocation };
21
+ //# sourceMappingURL=input-location.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-location.mjs","sources":["../../../../src/application/transform/schema/input-location.ts"],"sourcesContent":["import { placeOf } from \"../../../domain/openapi/document-places.js\";\nimport { parseRefPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport { FIX, type OutputFix } from \"../../../domain/output-fixes.js\";\n\n/** The words that mark an input anywhere in a location, as the original reads them. */\nconst ORIGINAL_INPUT_WORDS = [\"parameters\", \"requestBody\", \"requestBodies\"] as const;\n\n/**\n * Whether a schema location describes an input: a parameter or a request body. A client may\n * leave out an input property that has a `default`, so the default makes no such property\n * required. The original tests the location text for a word, so a schema or path that is only\n * named so (`#/components/schemas/Job/properties/parameters`, `/system-parameters`) counts as an\n * input too. The `default-input-locations` fix reads a pointer into the document by the\n * document's structure instead (ADR-021).\n */\nexport function isInputLocation(path: string | undefined, fixes: ReadonlySet<OutputFix>): boolean {\n if (path === undefined) {\n return false;\n }\n return fixes.has(FIX.DEFAULT_INPUT_LOCATIONS) ? isStructuralInput(path) : namesInput(path);\n}\n\nfunction namesInput(path: string): boolean {\n return ORIGINAL_INPUT_WORDS.some((word) => path.includes(word));\n}\n\n/**\n * Whether the document's structure makes the pointer an input. A path an exported transformer was\n * given that is no pointer into the document (`/items/{id}`) has no known structure, so the\n * original's words still mark an input there.\n */\nfunction isStructuralInput(path: string): boolean {\n const place = placeOf(parseRefPointer(path));\n return place === \"outside\" ? namesInput(path) : place === \"input\";\n}\n"],"names":[],"mappings":";;;;AAKA,MAAM,oBAAA,GAAuB,CAAC,YAAA,EAAc,aAAA,EAAe,eAAe,CAAA;AAUnE,SAAS,eAAA,CAAgB,MAA0B,KAAA,EAAwC;AAChG,EAAA,IAAI,SAAS,MAAA,EAAW;AACtB,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA,CAAM,IAAI,GAAA,CAAI,uBAAuB,IAAI,iBAAA,CAAkB,IAAI,CAAA,GAAI,UAAA,CAAW,IAAI,CAAA;AAC3F;AAEA,SAAS,WAAW,IAAA,EAAuB;AACzC,EAAA,OAAO,qBAAqB,IAAA,CAAK,CAAC,SAAS,IAAA,CAAK,QAAA,CAAS,IAAI,CAAC,CAAA;AAChE;AAOA,SAAS,kBAAkB,IAAA,EAAuB;AAChD,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,eAAA,CAAgB,IAAI,CAAC,CAAA;AAC3C,EAAA,OAAO,KAAA,KAAU,SAAA,GAAY,UAAA,CAAW,IAAI,IAAI,KAAA,KAAU,OAAA;AAC5D;;"}
@@ -10,9 +10,11 @@ const schemaComment = require('../schema-comment.cjs');
10
10
  const sharedTypes = require('../shared-types.cjs');
11
11
  const typeCombinators = require('../type-combinators.cjs');
12
12
  const accessFlags = require('./access-flags.cjs');
13
+ const indexSignatureType = require('./index-signature-type.cjs');
13
14
  const inheritedDiscriminator = require('./inherited-discriminator.cjs');
15
+ const inputLocation = require('./input-location.cjs');
16
+ const refSiblings = require('./ref-siblings.cjs');
14
17
 
15
- const INPUT_PATH_PARTS = ["parameters", "requestBody", "requestBodies"];
16
18
  class InvalidPropertyError extends errors.OpenAPITypesafeError {
17
19
  constructor(path, key, value) {
18
20
  const received = Array.isArray(value) ? "Array" : typeof value;
@@ -49,8 +51,7 @@ function propertyFacts(value, request) {
49
51
  }
50
52
  function isOptionalProperty(key, facts, schema, request) {
51
53
  const { options } = request.context;
52
- const path = request.location.path;
53
- const isDefaultRequired = facts.hasDefault && options.defaultNonNullable && !INPUT_PATH_PARTS.some((part) => path?.includes(part));
54
+ const isDefaultRequired = facts.hasDefault && options.defaultNonNullable && !inputLocation.isInputLocation(request.location.path, options.fixes);
54
55
  const isRequired = schema.required?.includes(key) || schema.required === void 0 && options.propertiesRequiredByDefault || isDefaultRequired;
55
56
  return !isRequired;
56
57
  }
@@ -61,9 +62,14 @@ function isExcluded(value, facts, request) {
61
62
  const resolved = facts.ref ? request.context.refs.resolve(facts.ref) : value;
62
63
  return Boolean(resolved?.deprecated);
63
64
  }
65
+ function plainRef({ ref }, value, request) {
66
+ const isAllOf = ref && refSiblings.refWithSiblingsAsAllOf(value, request.context.options);
67
+ return isAllOf ? void 0 : ref;
68
+ }
64
69
  function propertyType(key, value, facts, request) {
65
- const path = jsonPointer.createRef([request.location.path, key]);
66
- const type = facts.ref ? pointerType.schemaRefType(facts.ref, request) : request.transformNested(value, { ...request.location, path });
70
+ const path = jsonPointer.appendPointer(request.location.path, [key]);
71
+ const ref = plainRef(facts, value, request);
72
+ const type = ref ? pointerType.schemaRefType(ref, request) : request.transformNested(value, { ...request.location, path });
67
73
  const custom = request.context.callbacks.transform(value, request.location);
68
74
  return custom === null ? { type, isOptional: null } : { type: custom.type, isOptional: custom.isOptional || null };
69
75
  }
@@ -86,7 +92,7 @@ function propertyMember(key, value, schema, request) {
86
92
  isReadonly: options.immutable || !options.readWriteMarkers && facts.flags.isReadOnly
87
93
  }
88
94
  );
89
- return finishProperty(property, value, jsonPointer.createRef([request.location.path, key]), request);
95
+ return finishProperty(property, value, jsonPointer.appendPointer(request.location.path, [key]), request);
90
96
  }
91
97
  function propertyMembers(schema, request) {
92
98
  const members = [];
@@ -101,7 +107,7 @@ function propertyMembers(schema, request) {
101
107
  function defsMember(defs, request) {
102
108
  const { options } = request.context;
103
109
  const members = Object.entries(defs).map(([key, value]) => {
104
- const path = jsonPointer.createRef([request.location.path, "$defs", key]);
110
+ const path = jsonPointer.appendPointer(request.location.path, ["$defs", key]);
105
111
  const flags = accessFlags.propertyAccessFlags(value, request.context);
106
112
  const type = withReadWriteMarker(
107
113
  request.transformNested(value, { ...request.location, path }),
@@ -167,6 +173,9 @@ function objectType(schema, request) {
167
173
  return inherited ? constructors.irObject([inheritedDiscriminator.discriminatorMember(inherited, request)]) : null;
168
174
  }
169
175
  const members = discriminatorAndPropertyMembers(schema, request);
176
+ const propertyTypes = members.flatMap(
177
+ (member) => member.kind === "property" ? [member.type] : []
178
+ );
170
179
  if ("$defs" in schema && typeof schema.$defs === "object" && Object.keys(schema.$defs).length > 0) {
171
180
  members.push(defsMember(schema.$defs, request));
172
181
  }
@@ -174,8 +183,9 @@ function objectType(schema, request) {
174
183
  if (valueTypes.length === 0) {
175
184
  return members.length > 0 ? constructors.irObject(members) : null;
176
185
  }
186
+ const indexType = indexSignatureType.withPropertyTypes(typeCombinators.unionOf(valueTypes), propertyTypes);
177
187
  const index = constructors.irObject([
178
- constructors.irStringIndexSignature("key", typeCombinators.unionOf(valueTypes), request.context.options.immutable)
188
+ constructors.irStringIndexSignature("key", indexType, request.context.options.immutable)
179
189
  ]);
180
190
  return typeCombinators.intersectionOf([...members.length > 0 ? [constructors.irObject(members)] : [], index]);
181
191
  }
@@ -1 +1 @@
1
- {"version":3,"file":"object-type.cjs","sources":["../../../../src/application/transform/schema/object-type.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../../../domain/errors.js\";\nimport {\n irObject,\n irProperty,\n irReference,\n irStringIndexSignature,\n} from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { schemaRefType } from \"../ref-pointer/pointer-type.js\";\nimport { schemaCommentOptionsOf, withSchemaComment } from \"../schema-comment.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { intersectionOf, unionOf } from \"../type-combinators.js\";\nimport { type AccessFlags, propertyAccessFlags } from \"./access-flags.js\";\nimport { discriminatorMember, inheritedDiscriminator } from \"./inherited-discriminator.js\";\nimport type { SchemaOptions } from \"./schema-context.js\";\nimport type { SchemaRequest } from \"./schema-rule.js\";\n\n/** Path parts where a default value cannot make a property required (inputs may omit it). */\nconst INPUT_PATH_PARTS = [\"parameters\", \"requestBody\", \"requestBodies\"] as const;\n\nexport class InvalidPropertyError extends OpenAPITypesafeError {\n constructor(path: string | undefined, key: string, value: unknown) {\n const received = Array.isArray(value) ? \"Array\" : typeof value;\n super({\n code: ERROR_CODES.SCHEMA_PROPERTY_INVALID,\n message:\n `${path}: invalid property ${key}. ` + `Expected Schema Object or boolean, got ${received}`,\n details: { path, property: key, received },\n });\n this.name = \"InvalidPropertyError\";\n }\n}\n\n/** `--read-write-markers`: `$Read<T>` / `$Write<T>`, unless the property is both or neither. */\nfunction withReadWriteMarker(type: IrType, flags: AccessFlags, options: SchemaOptions): IrType {\n if (!options.readWriteMarkers || flags.isReadOnly === flags.isWriteOnly) {\n return type;\n }\n return irReference(flags.isReadOnly ? \"$Read\" : \"$Write\", [type]);\n}\n\n/** Apply `transformProperty`, then the schema's JSDoc. */\nfunction finishProperty(\n property: IrPropertySignature,\n schema: Schema,\n path: string,\n request: SchemaRequest,\n): IrPropertySignature {\n const location = { ...request.location, path };\n const transformed =\n request.context.callbacks.transformProperty(property, schema, location) ?? property;\n // The original adds the schema's comment after any comment the callback set.\n return withSchemaComment(\n transformed,\n schema,\n schemaCommentOptionsOf(request.context.options.fixes),\n );\n}\n\n/** What the property loop reads from a property schema, in the original order. */\ninterface PropertyFacts {\n readonly ref: string | undefined;\n readonly flags: AccessFlags;\n readonly hasDefault: boolean;\n}\n\nfunction propertyFacts(value: Schema, request: SchemaRequest): PropertyFacts {\n if (typeof value !== \"object\") {\n return { ref: undefined, flags: { isReadOnly: false, isWriteOnly: false }, hasDefault: false };\n }\n // `in` throws for a null value, as in the original (which also reads `$ref` first).\n const ref = \"$ref\" in value && value.$ref ? value.$ref : undefined;\n const flags = propertyAccessFlags(value, request.context);\n return { ref, flags, hasDefault: \"default\" in value && value.default !== undefined };\n}\n\nfunction isOptionalProperty(\n key: string,\n facts: PropertyFacts,\n schema: SchemaObject,\n request: SchemaRequest,\n): boolean {\n const { options } = request.context;\n const path = request.location.path;\n const isDefaultRequired =\n facts.hasDefault &&\n options.defaultNonNullable &&\n !INPUT_PATH_PARTS.some((part) => path?.includes(part));\n const isRequired =\n schema.required?.includes(key) ||\n (schema.required === undefined && options.propertiesRequiredByDefault) ||\n isDefaultRequired;\n return !isRequired;\n}\n\nfunction isExcluded(value: Schema, facts: PropertyFacts, request: SchemaRequest): boolean {\n if (!request.context.options.excludeDeprecated) {\n return false;\n }\n const resolved = facts.ref ? request.context.refs.resolve(facts.ref) : value;\n return Boolean((resolved as SchemaObject | undefined)?.deprecated);\n}\n\n/** A type, and whether a callback forced the property optional (null: no override). */\ninterface CustomResult {\n readonly type: IrType;\n readonly isOptional: true | null;\n}\n\nfunction propertyType(\n key: string,\n value: Schema,\n facts: PropertyFacts,\n request: SchemaRequest,\n): CustomResult {\n const path = createRef([request.location.path, key]);\n const type = facts.ref\n ? schemaRefType(facts.ref, request)\n : request.transformNested(value, { ...request.location, path });\n const custom = request.context.callbacks.transform(value, request.location);\n return custom === null\n ? { type, isOptional: null }\n : { type: custom.type, isOptional: custom.isOptional || null };\n}\n\nfunction propertyMember(\n key: string,\n value: Schema,\n schema: SchemaObject,\n request: SchemaRequest,\n): IrMember | null {\n if ((typeof value !== \"object\" && typeof value !== \"boolean\") || Array.isArray(value)) {\n throw new InvalidPropertyError(request.location.path, key, value);\n }\n const facts = propertyFacts(value, request);\n if (isExcluded(value, facts, request)) {\n return null;\n }\n const { options } = request.context;\n const isOptional = isOptionalProperty(key, facts, schema, request);\n const result = propertyType(key, value, facts, request);\n const property = irProperty(\n toPropertyName(key),\n withReadWriteMarker(result.type, facts.flags, options),\n {\n isOptional: result.isOptional ?? isOptional,\n isReadonly: options.immutable || (!options.readWriteMarkers && facts.flags.isReadOnly),\n },\n );\n return finishProperty(property, value, createRef([request.location.path, key]), request);\n}\n\nfunction propertyMembers(schema: SchemaObject, request: SchemaRequest): IrMember[] {\n const members: IrMember[] = [];\n for (const [key, value] of documentEntries(schema.properties ?? {}, request.context.options)) {\n const member = propertyMember(key, value, schema, request);\n if (member !== null) {\n members.push(member);\n }\n }\n return members;\n}\n\n/**\n * `$defs` as a nested `$defs?: { … }` member, in document order (never alphabetized). It is\n * optional because `$defs` is a schema keyword, not data: the original made it required, so a\n * value of the type needed a `$defs` key (research/legacy-bugs.md, item 17, upstream #2664).\n */\nfunction defsMember(\n defs: Readonly<Record<string, SchemaObject>>,\n request: SchemaRequest,\n): IrMember {\n const { options } = request.context;\n const members = Object.entries(defs).map(([key, value]) => {\n const path = createRef([request.location.path, \"$defs\", key]);\n const flags = propertyAccessFlags(value, request.context);\n const type = withReadWriteMarker(\n request.transformNested(value, { ...request.location, path }),\n flags,\n options,\n );\n const property = irProperty(toPropertyName(key), type, {\n isReadonly: options.immutable || (!options.readWriteMarkers && flags.isReadOnly),\n });\n return finishProperty(property, value, path, request);\n });\n return irProperty(toPropertyName(\"$defs\"), irObject(members), { isOptional: true });\n}\n\nfunction hasObjectKeywords(schema: SchemaObject): boolean {\n const hasProperties = Boolean(schema.properties && Object.keys(schema.properties).length);\n return (\n hasProperties ||\n Boolean(schema.additionalProperties || schema.patternProperties || schema.$defs)\n );\n}\n\n/** Value types of the `[key: string]` index signature, in the original order. */\nfunction indexValueTypes(schema: SchemaObject, request: SchemaRequest): IrType[] {\n const { additionalProperties } = schema;\n const isObject = typeof additionalProperties === \"object\";\n const hasExplicit = isObject && Object.keys(additionalProperties).length > 0;\n const hasImplicit =\n additionalProperties === true || (isObject && Object.keys(additionalProperties).length === 0);\n const types: IrType[] = [];\n if (hasExplicit) {\n types.push(request.transformNested(additionalProperties as Schema, request.location, true));\n }\n if (hasImplicit || (!additionalProperties && request.context.options.additionalProperties)) {\n types.push(UNKNOWN_TYPE);\n }\n const patterns = schema.patternProperties;\n if (typeof patterns === \"object\" && patterns !== null && Object.keys(patterns).length > 0) {\n for (const [, value] of documentEntries(patterns, request.context.options)) {\n types.push(request.transformNested(value, request.location));\n }\n }\n return types;\n}\n\n/**\n * Whether the schema declares property `key` and the type keeps it: `--exclude-deprecated` drops\n * a deprecated one.\n */\nexport function isKeptProperty(schema: SchemaObject, key: string, request: SchemaRequest): boolean {\n const properties = schema.properties ?? {};\n if (!Object.hasOwn(properties, key)) {\n return false;\n }\n const value = properties[key] as Schema;\n const isExcludable = request.context.options.excludeDeprecated && typeof value === \"object\";\n return !isExcludable || !isExcluded(value, propertyFacts(value, request), request);\n}\n\n/**\n * The members for the discriminator and `properties`. A schema that declares the discriminator\n * property itself keeps its own declaration, required as the discriminator needs: both in one\n * object type do not compile (TS2300, the Apple SiriKit Cloud Media API). A declaration that\n * `--exclude-deprecated` drops does not count, so the discriminator property stays.\n */\nfunction discriminatorAndPropertyMembers(schema: SchemaObject, request: SchemaRequest): IrMember[] {\n const inherited = inheritedDiscriminator(schema, request);\n if (inherited === undefined) {\n return propertyMembers(schema, request);\n }\n const name = inherited.discriminator.propertyName;\n if (!isKeptProperty(schema, name, request)) {\n return [discriminatorMember(inherited, request), ...propertyMembers(schema, request)];\n }\n // Without `required`, `--properties-required-by-default` requires every property already; a\n // list of one would make the others optional.\n const isAllRequired =\n schema.required === undefined && request.context.options.propertiesRequiredByDefault;\n const required = isAllRequired ? undefined : [...(schema.required ?? []), name];\n return propertyMembers({ ...schema, required } as SchemaObject, request);\n}\n\n/**\n * Object keywords: discriminator, `properties`, `$defs`, and an index signature for\n * `additionalProperties` / `patternProperties` (or `--additional-properties`). Null when the schema\n * has none of them.\n */\nexport function objectType(schema: SchemaObject, request: SchemaRequest): IrType | null {\n if (!hasObjectKeywords(schema)) {\n const inherited = inheritedDiscriminator(schema, request);\n return inherited ? irObject([discriminatorMember(inherited, request)]) : null;\n }\n const members = discriminatorAndPropertyMembers(schema, request);\n // As in the original, a null `$defs` throws here (Object.keys) instead of being skipped.\n if (\n \"$defs\" in schema &&\n typeof schema.$defs === \"object\" &&\n Object.keys(schema.$defs).length > 0\n ) {\n members.push(defsMember(schema.$defs, request));\n }\n const valueTypes = indexValueTypes(schema, request);\n if (valueTypes.length === 0) {\n return members.length > 0 ? irObject(members) : null;\n }\n const index = irObject([\n irStringIndexSignature(\"key\", unionOf(valueTypes), request.context.options.immutable),\n ]);\n return intersectionOf([...(members.length > 0 ? [irObject(members)] : []), index]);\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES","irReference","withSchemaComment","schemaCommentOptionsOf","propertyAccessFlags","createRef","schemaRefType","irProperty","toPropertyName","documentEntries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;"}
1
+ {"version":3,"file":"object-type.cjs","sources":["../../../../src/application/transform/schema/object-type.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../../../domain/errors.js\";\nimport {\n irObject,\n irProperty,\n irReference,\n irStringIndexSignature,\n} from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { schemaRefType } from \"../ref-pointer/pointer-type.js\";\nimport { schemaCommentOptionsOf, withSchemaComment } from \"../schema-comment.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { intersectionOf, unionOf } from \"../type-combinators.js\";\nimport { type AccessFlags, propertyAccessFlags } from \"./access-flags.js\";\nimport { withPropertyTypes } from \"./index-signature-type.js\";\nimport { discriminatorMember, inheritedDiscriminator } from \"./inherited-discriminator.js\";\nimport { isInputLocation } from \"./input-location.js\";\nimport { refWithSiblingsAsAllOf } from \"./ref-siblings.js\";\nimport type { SchemaOptions } from \"./schema-context.js\";\nimport type { SchemaRequest } from \"./schema-rule.js\";\n\nexport class InvalidPropertyError extends OpenAPITypesafeError {\n constructor(path: string | undefined, key: string, value: unknown) {\n const received = Array.isArray(value) ? \"Array\" : typeof value;\n super({\n code: ERROR_CODES.SCHEMA_PROPERTY_INVALID,\n message:\n `${path}: invalid property ${key}. ` + `Expected Schema Object or boolean, got ${received}`,\n details: { path, property: key, received },\n });\n this.name = \"InvalidPropertyError\";\n }\n}\n\n/** `--read-write-markers`: `$Read<T>` / `$Write<T>`, unless the property is both or neither. */\nfunction withReadWriteMarker(type: IrType, flags: AccessFlags, options: SchemaOptions): IrType {\n if (!options.readWriteMarkers || flags.isReadOnly === flags.isWriteOnly) {\n return type;\n }\n return irReference(flags.isReadOnly ? \"$Read\" : \"$Write\", [type]);\n}\n\n/** Apply `transformProperty`, then the schema's JSDoc. */\nfunction finishProperty(\n property: IrPropertySignature,\n schema: Schema,\n path: string,\n request: SchemaRequest,\n): IrPropertySignature {\n const location = { ...request.location, path };\n const transformed =\n request.context.callbacks.transformProperty(property, schema, location) ?? property;\n // The original adds the schema's comment after any comment the callback set.\n return withSchemaComment(\n transformed,\n schema,\n schemaCommentOptionsOf(request.context.options.fixes),\n );\n}\n\n/** What the property loop reads from a property schema, in the original order. */\ninterface PropertyFacts {\n readonly ref: string | undefined;\n readonly flags: AccessFlags;\n readonly hasDefault: boolean;\n}\n\nfunction propertyFacts(value: Schema, request: SchemaRequest): PropertyFacts {\n if (typeof value !== \"object\") {\n return { ref: undefined, flags: { isReadOnly: false, isWriteOnly: false }, hasDefault: false };\n }\n // `in` throws for a null value, as in the original (which also reads `$ref` first).\n const ref = \"$ref\" in value && value.$ref ? value.$ref : undefined;\n const flags = propertyAccessFlags(value, request.context);\n return { ref, flags, hasDefault: \"default\" in value && value.default !== undefined };\n}\n\nfunction isOptionalProperty(\n key: string,\n facts: PropertyFacts,\n schema: SchemaObject,\n request: SchemaRequest,\n): boolean {\n const { options } = request.context;\n const isDefaultRequired =\n facts.hasDefault &&\n options.defaultNonNullable &&\n !isInputLocation(request.location.path, options.fixes);\n const isRequired =\n schema.required?.includes(key) ||\n (schema.required === undefined && options.propertiesRequiredByDefault) ||\n isDefaultRequired;\n return !isRequired;\n}\n\nfunction isExcluded(value: Schema, facts: PropertyFacts, request: SchemaRequest): boolean {\n if (!request.context.options.excludeDeprecated) {\n return false;\n }\n const resolved = facts.ref ? request.context.refs.resolve(facts.ref) : value;\n return Boolean((resolved as SchemaObject | undefined)?.deprecated);\n}\n\n/** A type, and whether a callback forced the property optional (null: no override). */\ninterface CustomResult {\n readonly type: IrType;\n readonly isOptional: true | null;\n}\n\n/** A `$ref` with siblings that `ref-siblings` types as an `allOf` is typed as a schema. */\nfunction plainRef({ ref }: PropertyFacts, value: Schema, request: SchemaRequest) {\n const isAllOf = ref && refWithSiblingsAsAllOf(value as SchemaObject, request.context.options);\n return isAllOf ? undefined : ref;\n}\n\nfunction propertyType(\n key: string,\n value: Schema,\n facts: PropertyFacts,\n request: SchemaRequest,\n): CustomResult {\n const path = appendPointer(request.location.path, [key]);\n const ref = plainRef(facts, value, request);\n const type = ref\n ? schemaRefType(ref, request)\n : request.transformNested(value, { ...request.location, path });\n const custom = request.context.callbacks.transform(value, request.location);\n return custom === null\n ? { type, isOptional: null }\n : { type: custom.type, isOptional: custom.isOptional || null };\n}\n\nfunction propertyMember(\n key: string,\n value: Schema,\n schema: SchemaObject,\n request: SchemaRequest,\n): IrMember | null {\n if ((typeof value !== \"object\" && typeof value !== \"boolean\") || Array.isArray(value)) {\n throw new InvalidPropertyError(request.location.path, key, value);\n }\n const facts = propertyFacts(value, request);\n if (isExcluded(value, facts, request)) {\n return null;\n }\n const { options } = request.context;\n const isOptional = isOptionalProperty(key, facts, schema, request);\n const result = propertyType(key, value, facts, request);\n const property = irProperty(\n toPropertyName(key),\n withReadWriteMarker(result.type, facts.flags, options),\n {\n isOptional: result.isOptional ?? isOptional,\n isReadonly: options.immutable || (!options.readWriteMarkers && facts.flags.isReadOnly),\n },\n );\n return finishProperty(property, value, appendPointer(request.location.path, [key]), request);\n}\n\nfunction propertyMembers(schema: SchemaObject, request: SchemaRequest): IrMember[] {\n const members: IrMember[] = [];\n for (const [key, value] of documentEntries(schema.properties ?? {}, request.context.options)) {\n const member = propertyMember(key, value, schema, request);\n if (member !== null) {\n members.push(member);\n }\n }\n return members;\n}\n\n/**\n * `$defs` as a nested `$defs?: { … }` member, in document order (never alphabetized). It is\n * optional because `$defs` is a schema keyword, not data: the original made it required, so a\n * value of the type needed a `$defs` key (research/legacy-bugs.md, item 17, upstream #2664).\n */\nfunction defsMember(\n defs: Readonly<Record<string, SchemaObject>>,\n request: SchemaRequest,\n): IrMember {\n const { options } = request.context;\n const members = Object.entries(defs).map(([key, value]) => {\n const path = appendPointer(request.location.path, [\"$defs\", key]);\n const flags = propertyAccessFlags(value, request.context);\n const type = withReadWriteMarker(\n request.transformNested(value, { ...request.location, path }),\n flags,\n options,\n );\n const property = irProperty(toPropertyName(key), type, {\n isReadonly: options.immutable || (!options.readWriteMarkers && flags.isReadOnly),\n });\n return finishProperty(property, value, path, request);\n });\n return irProperty(toPropertyName(\"$defs\"), irObject(members), { isOptional: true });\n}\n\nfunction hasObjectKeywords(schema: SchemaObject): boolean {\n const hasProperties = Boolean(schema.properties && Object.keys(schema.properties).length);\n return (\n hasProperties ||\n Boolean(schema.additionalProperties || schema.patternProperties || schema.$defs)\n );\n}\n\n/** Value types of the `[key: string]` index signature, in the original order. */\nfunction indexValueTypes(schema: SchemaObject, request: SchemaRequest): IrType[] {\n const { additionalProperties } = schema;\n const isObject = typeof additionalProperties === \"object\";\n const hasExplicit = isObject && Object.keys(additionalProperties).length > 0;\n const hasImplicit =\n additionalProperties === true || (isObject && Object.keys(additionalProperties).length === 0);\n const types: IrType[] = [];\n if (hasExplicit) {\n types.push(request.transformNested(additionalProperties as Schema, request.location, true));\n }\n if (hasImplicit || (!additionalProperties && request.context.options.additionalProperties)) {\n types.push(UNKNOWN_TYPE);\n }\n const patterns = schema.patternProperties;\n if (typeof patterns === \"object\" && patterns !== null && Object.keys(patterns).length > 0) {\n for (const [, value] of documentEntries(patterns, request.context.options)) {\n types.push(request.transformNested(value, request.location));\n }\n }\n return types;\n}\n\n/**\n * Whether the schema declares property `key` and the type keeps it: `--exclude-deprecated` drops\n * a deprecated one.\n */\nexport function isKeptProperty(schema: SchemaObject, key: string, request: SchemaRequest): boolean {\n const properties = schema.properties ?? {};\n if (!Object.hasOwn(properties, key)) {\n return false;\n }\n const value = properties[key] as Schema;\n const isExcludable = request.context.options.excludeDeprecated && typeof value === \"object\";\n return !isExcludable || !isExcluded(value, propertyFacts(value, request), request);\n}\n\n/**\n * The members for the discriminator and `properties`. A schema that declares the discriminator\n * property itself keeps its own declaration, required as the discriminator needs: both in one\n * object type do not compile (TS2300, the Apple SiriKit Cloud Media API). A declaration that\n * `--exclude-deprecated` drops does not count, so the discriminator property stays.\n */\nfunction discriminatorAndPropertyMembers(schema: SchemaObject, request: SchemaRequest): IrMember[] {\n const inherited = inheritedDiscriminator(schema, request);\n if (inherited === undefined) {\n return propertyMembers(schema, request);\n }\n const name = inherited.discriminator.propertyName;\n if (!isKeptProperty(schema, name, request)) {\n return [discriminatorMember(inherited, request), ...propertyMembers(schema, request)];\n }\n // Without `required`, `--properties-required-by-default` requires every property already; a\n // list of one would make the others optional.\n const isAllRequired =\n schema.required === undefined && request.context.options.propertiesRequiredByDefault;\n const required = isAllRequired ? undefined : [...(schema.required ?? []), name];\n return propertyMembers({ ...schema, required } as SchemaObject, request);\n}\n\n/**\n * Object keywords: discriminator, `properties`, `$defs`, and an index signature for\n * `additionalProperties` / `patternProperties` (or `--additional-properties`). Null when the schema\n * has none of them.\n */\nexport function objectType(schema: SchemaObject, request: SchemaRequest): IrType | null {\n if (!hasObjectKeywords(schema)) {\n const inherited = inheritedDiscriminator(schema, request);\n return inherited ? irObject([discriminatorMember(inherited, request)]) : null;\n }\n const members = discriminatorAndPropertyMembers(schema, request);\n const propertyTypes = members.flatMap((member) =>\n member.kind === \"property\" ? [member.type] : [],\n );\n // As in the original, a null `$defs` throws here (Object.keys) instead of being skipped.\n if (\n \"$defs\" in schema &&\n typeof schema.$defs === \"object\" &&\n Object.keys(schema.$defs).length > 0\n ) {\n members.push(defsMember(schema.$defs, request));\n }\n const valueTypes = indexValueTypes(schema, request);\n if (valueTypes.length === 0) {\n return members.length > 0 ? irObject(members) : null;\n }\n const indexType = withPropertyTypes(unionOf(valueTypes), propertyTypes);\n const index = irObject([\n irStringIndexSignature(\"key\", indexType, request.context.options.immutable),\n ]);\n return intersectionOf([...(members.length > 0 ? [irObject(members)] : []), index]);\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES","irReference","withSchemaComment","schemaCommentOptionsOf","propertyAccessFlags","isInputLocation","refWithSiblingsAsAllOf","appendPointer","schemaRefType","irProperty","toPropertyName","documentEntries","irObject","UNKNOWN_TYPE","inheritedDiscriminator","discriminatorMember","withPropertyTypes","unionOf","irStringIndexSignature","intersectionOf"],"mappings":";;;;;;;;;;;;;;;;;AAwBO,MAAM,6BAA6BA,2BAAA,CAAqB;AAAA,EAC7D,WAAA,CAAY,IAAA,EAA0B,GAAA,EAAa,KAAA,EAAgB;AACjE,IAAA,MAAM,WAAW,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,GAAI,UAAU,OAAO,KAAA;AACzD,IAAA,KAAA,CAAM;AAAA,MACJ,MAAMC,kBAAA,CAAY,uBAAA;AAAA,MAClB,SACE,CAAA,EAAG,IAAI,CAAA,mBAAA,EAAsB,GAAG,4CAAiD,QAAQ,CAAA,CAAA;AAAA,MAC3F,OAAA,EAAS,EAAE,IAAA,EAAM,QAAA,EAAU,KAAK,QAAA;AAAS,KAC1C,CAAA;AACD,IAAA,IAAA,CAAK,IAAA,GAAO,sBAAA;AAAA,EACd;AACF;AAGA,SAAS,mBAAA,CAAoB,IAAA,EAAc,KAAA,EAAoB,OAAA,EAAgC;AAC7F,EAAA,IAAI,CAAC,OAAA,CAAQ,gBAAA,IAAoB,KAAA,CAAM,UAAA,KAAe,MAAM,WAAA,EAAa;AACvE,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAOC,yBAAY,KAAA,CAAM,UAAA,GAAa,UAAU,QAAA,EAAU,CAAC,IAAI,CAAC,CAAA;AAClE;AAGA,SAAS,cAAA,CACP,QAAA,EACA,MAAA,EACA,IAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,QAAA,GAAW,EAAE,GAAG,OAAA,CAAQ,UAAU,IAAA,EAAK;AAC7C,EAAA,MAAM,WAAA,GACJ,QAAQ,OAAA,CAAQ,SAAA,CAAU,kBAAkB,QAAA,EAAU,MAAA,EAAQ,QAAQ,CAAA,IAAK,QAAA;AAE7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A,CAAQ,MAAA,GAAS,CAAA,GAAIH,qBAAA,CAAS,OAAO,CAAA,GAAI,IAAA;AAAA,EAClD;AACA,EAAA,MAAM,SAAA,GAAYI,oCAAA,CAAkBC,uBAAA,CAAQ,UAAU,GAAG,aAAa,CAAA;AACtE,EAAA,MAAM,QAAQL,qBAAA,CAAS;AAAA,IACrBM,oCAAuB,KAAA,EAAO,SAAA,EAAW,OAAA,CAAQ,OAAA,CAAQ,QAAQ,SAAS;AAAA,GAC3E,CAAA;AACD,EAAA,OAAOC,8BAAA,CAAe,CAAC,GAAI,OAAA,CAAQ,SAAS,CAAA,GAAI,CAACP,qBAAA,CAAS,OAAO,CAAC,CAAA,GAAI,EAAC,EAAI,KAAK,CAAC,CAAA;AACnF;;;;"}
@@ -1,16 +1,18 @@
1
1
  import { OpenAPITypesafeError, ERROR_CODES } from '../../../domain/errors.mjs';
2
2
  import { irObject, irStringIndexSignature, irProperty, irReference } from '../../../domain/ir/constructors.mjs';
3
3
  import { toPropertyName } from '../../../domain/ir/property-name.mjs';
4
- import { createRef } from '../../../domain/openapi/json-pointer.mjs';
4
+ import { appendPointer } from '../../../domain/openapi/json-pointer.mjs';
5
5
  import { documentEntries } from '../document-entries.mjs';
6
6
  import { schemaRefType } from '../ref-pointer/pointer-type.mjs';
7
7
  import { withSchemaComment, schemaCommentOptionsOf } from '../schema-comment.mjs';
8
8
  import { UNKNOWN_TYPE } from '../shared-types.mjs';
9
9
  import { unionOf, intersectionOf } from '../type-combinators.mjs';
10
10
  import { propertyAccessFlags } from './access-flags.mjs';
11
+ import { withPropertyTypes } from './index-signature-type.mjs';
11
12
  import { inheritedDiscriminator, discriminatorMember } from './inherited-discriminator.mjs';
13
+ import { isInputLocation } from './input-location.mjs';
14
+ import { refWithSiblingsAsAllOf } from './ref-siblings.mjs';
12
15
 
13
- const INPUT_PATH_PARTS = ["parameters", "requestBody", "requestBodies"];
14
16
  class InvalidPropertyError extends OpenAPITypesafeError {
15
17
  constructor(path, key, value) {
16
18
  const received = Array.isArray(value) ? "Array" : typeof value;
@@ -47,8 +49,7 @@ function propertyFacts(value, request) {
47
49
  }
48
50
  function isOptionalProperty(key, facts, schema, request) {
49
51
  const { options } = request.context;
50
- const path = request.location.path;
51
- const isDefaultRequired = facts.hasDefault && options.defaultNonNullable && !INPUT_PATH_PARTS.some((part) => path?.includes(part));
52
+ const isDefaultRequired = facts.hasDefault && options.defaultNonNullable && !isInputLocation(request.location.path, options.fixes);
52
53
  const isRequired = schema.required?.includes(key) || schema.required === void 0 && options.propertiesRequiredByDefault || isDefaultRequired;
53
54
  return !isRequired;
54
55
  }
@@ -59,9 +60,14 @@ function isExcluded(value, facts, request) {
59
60
  const resolved = facts.ref ? request.context.refs.resolve(facts.ref) : value;
60
61
  return Boolean(resolved?.deprecated);
61
62
  }
63
+ function plainRef({ ref }, value, request) {
64
+ const isAllOf = ref && refWithSiblingsAsAllOf(value, request.context.options);
65
+ return isAllOf ? void 0 : ref;
66
+ }
62
67
  function propertyType(key, value, facts, request) {
63
- const path = createRef([request.location.path, key]);
64
- const type = facts.ref ? schemaRefType(facts.ref, request) : request.transformNested(value, { ...request.location, path });
68
+ const path = appendPointer(request.location.path, [key]);
69
+ const ref = plainRef(facts, value, request);
70
+ const type = ref ? schemaRefType(ref, request) : request.transformNested(value, { ...request.location, path });
65
71
  const custom = request.context.callbacks.transform(value, request.location);
66
72
  return custom === null ? { type, isOptional: null } : { type: custom.type, isOptional: custom.isOptional || null };
67
73
  }
@@ -84,7 +90,7 @@ function propertyMember(key, value, schema, request) {
84
90
  isReadonly: options.immutable || !options.readWriteMarkers && facts.flags.isReadOnly
85
91
  }
86
92
  );
87
- return finishProperty(property, value, createRef([request.location.path, key]), request);
93
+ return finishProperty(property, value, appendPointer(request.location.path, [key]), request);
88
94
  }
89
95
  function propertyMembers(schema, request) {
90
96
  const members = [];
@@ -99,7 +105,7 @@ function propertyMembers(schema, request) {
99
105
  function defsMember(defs, request) {
100
106
  const { options } = request.context;
101
107
  const members = Object.entries(defs).map(([key, value]) => {
102
- const path = createRef([request.location.path, "$defs", key]);
108
+ const path = appendPointer(request.location.path, ["$defs", key]);
103
109
  const flags = propertyAccessFlags(value, request.context);
104
110
  const type = withReadWriteMarker(
105
111
  request.transformNested(value, { ...request.location, path }),
@@ -165,6 +171,9 @@ function objectType(schema, request) {
165
171
  return inherited ? irObject([discriminatorMember(inherited, request)]) : null;
166
172
  }
167
173
  const members = discriminatorAndPropertyMembers(schema, request);
174
+ const propertyTypes = members.flatMap(
175
+ (member) => member.kind === "property" ? [member.type] : []
176
+ );
168
177
  if ("$defs" in schema && typeof schema.$defs === "object" && Object.keys(schema.$defs).length > 0) {
169
178
  members.push(defsMember(schema.$defs, request));
170
179
  }
@@ -172,8 +181,9 @@ function objectType(schema, request) {
172
181
  if (valueTypes.length === 0) {
173
182
  return members.length > 0 ? irObject(members) : null;
174
183
  }
184
+ const indexType = withPropertyTypes(unionOf(valueTypes), propertyTypes);
175
185
  const index = irObject([
176
- irStringIndexSignature("key", unionOf(valueTypes), request.context.options.immutable)
186
+ irStringIndexSignature("key", indexType, request.context.options.immutable)
177
187
  ]);
178
188
  return intersectionOf([...members.length > 0 ? [irObject(members)] : [], index]);
179
189
  }
@@ -1 +1 @@
1
- {"version":3,"file":"object-type.mjs","sources":["../../../../src/application/transform/schema/object-type.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../../../domain/errors.js\";\nimport {\n irObject,\n irProperty,\n irReference,\n irStringIndexSignature,\n} from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { createRef } from \"../../../domain/openapi/json-pointer.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { schemaRefType } from \"../ref-pointer/pointer-type.js\";\nimport { schemaCommentOptionsOf, withSchemaComment } from \"../schema-comment.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { intersectionOf, unionOf } from \"../type-combinators.js\";\nimport { type AccessFlags, propertyAccessFlags } from \"./access-flags.js\";\nimport { discriminatorMember, inheritedDiscriminator } from \"./inherited-discriminator.js\";\nimport type { SchemaOptions } from \"./schema-context.js\";\nimport type { SchemaRequest } from \"./schema-rule.js\";\n\n/** Path parts where a default value cannot make a property required (inputs may omit it). */\nconst INPUT_PATH_PARTS = [\"parameters\", \"requestBody\", \"requestBodies\"] as const;\n\nexport class InvalidPropertyError extends OpenAPITypesafeError {\n constructor(path: string | undefined, key: string, value: unknown) {\n const received = Array.isArray(value) ? \"Array\" : typeof value;\n super({\n code: ERROR_CODES.SCHEMA_PROPERTY_INVALID,\n message:\n `${path}: invalid property ${key}. ` + `Expected Schema Object or boolean, got ${received}`,\n details: { path, property: key, received },\n });\n this.name = \"InvalidPropertyError\";\n }\n}\n\n/** `--read-write-markers`: `$Read<T>` / `$Write<T>`, unless the property is both or neither. */\nfunction withReadWriteMarker(type: IrType, flags: AccessFlags, options: SchemaOptions): IrType {\n if (!options.readWriteMarkers || flags.isReadOnly === flags.isWriteOnly) {\n return type;\n }\n return irReference(flags.isReadOnly ? \"$Read\" : \"$Write\", [type]);\n}\n\n/** Apply `transformProperty`, then the schema's JSDoc. */\nfunction finishProperty(\n property: IrPropertySignature,\n schema: Schema,\n path: string,\n request: SchemaRequest,\n): IrPropertySignature {\n const location = { ...request.location, path };\n const transformed =\n request.context.callbacks.transformProperty(property, schema, location) ?? property;\n // The original adds the schema's comment after any comment the callback set.\n return withSchemaComment(\n transformed,\n schema,\n schemaCommentOptionsOf(request.context.options.fixes),\n );\n}\n\n/** What the property loop reads from a property schema, in the original order. */\ninterface PropertyFacts {\n readonly ref: string | undefined;\n readonly flags: AccessFlags;\n readonly hasDefault: boolean;\n}\n\nfunction propertyFacts(value: Schema, request: SchemaRequest): PropertyFacts {\n if (typeof value !== \"object\") {\n return { ref: undefined, flags: { isReadOnly: false, isWriteOnly: false }, hasDefault: false };\n }\n // `in` throws for a null value, as in the original (which also reads `$ref` first).\n const ref = \"$ref\" in value && value.$ref ? value.$ref : undefined;\n const flags = propertyAccessFlags(value, request.context);\n return { ref, flags, hasDefault: \"default\" in value && value.default !== undefined };\n}\n\nfunction isOptionalProperty(\n key: string,\n facts: PropertyFacts,\n schema: SchemaObject,\n request: SchemaRequest,\n): boolean {\n const { options } = request.context;\n const path = request.location.path;\n const isDefaultRequired =\n facts.hasDefault &&\n options.defaultNonNullable &&\n !INPUT_PATH_PARTS.some((part) => path?.includes(part));\n const isRequired =\n schema.required?.includes(key) ||\n (schema.required === undefined && options.propertiesRequiredByDefault) ||\n isDefaultRequired;\n return !isRequired;\n}\n\nfunction isExcluded(value: Schema, facts: PropertyFacts, request: SchemaRequest): boolean {\n if (!request.context.options.excludeDeprecated) {\n return false;\n }\n const resolved = facts.ref ? request.context.refs.resolve(facts.ref) : value;\n return Boolean((resolved as SchemaObject | undefined)?.deprecated);\n}\n\n/** A type, and whether a callback forced the property optional (null: no override). */\ninterface CustomResult {\n readonly type: IrType;\n readonly isOptional: true | null;\n}\n\nfunction propertyType(\n key: string,\n value: Schema,\n facts: PropertyFacts,\n request: SchemaRequest,\n): CustomResult {\n const path = createRef([request.location.path, key]);\n const type = facts.ref\n ? schemaRefType(facts.ref, request)\n : request.transformNested(value, { ...request.location, path });\n const custom = request.context.callbacks.transform(value, request.location);\n return custom === null\n ? { type, isOptional: null }\n : { type: custom.type, isOptional: custom.isOptional || null };\n}\n\nfunction propertyMember(\n key: string,\n value: Schema,\n schema: SchemaObject,\n request: SchemaRequest,\n): IrMember | null {\n if ((typeof value !== \"object\" && typeof value !== \"boolean\") || Array.isArray(value)) {\n throw new InvalidPropertyError(request.location.path, key, value);\n }\n const facts = propertyFacts(value, request);\n if (isExcluded(value, facts, request)) {\n return null;\n }\n const { options } = request.context;\n const isOptional = isOptionalProperty(key, facts, schema, request);\n const result = propertyType(key, value, facts, request);\n const property = irProperty(\n toPropertyName(key),\n withReadWriteMarker(result.type, facts.flags, options),\n {\n isOptional: result.isOptional ?? isOptional,\n isReadonly: options.immutable || (!options.readWriteMarkers && facts.flags.isReadOnly),\n },\n );\n return finishProperty(property, value, createRef([request.location.path, key]), request);\n}\n\nfunction propertyMembers(schema: SchemaObject, request: SchemaRequest): IrMember[] {\n const members: IrMember[] = [];\n for (const [key, value] of documentEntries(schema.properties ?? {}, request.context.options)) {\n const member = propertyMember(key, value, schema, request);\n if (member !== null) {\n members.push(member);\n }\n }\n return members;\n}\n\n/**\n * `$defs` as a nested `$defs?: { … }` member, in document order (never alphabetized). It is\n * optional because `$defs` is a schema keyword, not data: the original made it required, so a\n * value of the type needed a `$defs` key (research/legacy-bugs.md, item 17, upstream #2664).\n */\nfunction defsMember(\n defs: Readonly<Record<string, SchemaObject>>,\n request: SchemaRequest,\n): IrMember {\n const { options } = request.context;\n const members = Object.entries(defs).map(([key, value]) => {\n const path = createRef([request.location.path, \"$defs\", key]);\n const flags = propertyAccessFlags(value, request.context);\n const type = withReadWriteMarker(\n request.transformNested(value, { ...request.location, path }),\n flags,\n options,\n );\n const property = irProperty(toPropertyName(key), type, {\n isReadonly: options.immutable || (!options.readWriteMarkers && flags.isReadOnly),\n });\n return finishProperty(property, value, path, request);\n });\n return irProperty(toPropertyName(\"$defs\"), irObject(members), { isOptional: true });\n}\n\nfunction hasObjectKeywords(schema: SchemaObject): boolean {\n const hasProperties = Boolean(schema.properties && Object.keys(schema.properties).length);\n return (\n hasProperties ||\n Boolean(schema.additionalProperties || schema.patternProperties || schema.$defs)\n );\n}\n\n/** Value types of the `[key: string]` index signature, in the original order. */\nfunction indexValueTypes(schema: SchemaObject, request: SchemaRequest): IrType[] {\n const { additionalProperties } = schema;\n const isObject = typeof additionalProperties === \"object\";\n const hasExplicit = isObject && Object.keys(additionalProperties).length > 0;\n const hasImplicit =\n additionalProperties === true || (isObject && Object.keys(additionalProperties).length === 0);\n const types: IrType[] = [];\n if (hasExplicit) {\n types.push(request.transformNested(additionalProperties as Schema, request.location, true));\n }\n if (hasImplicit || (!additionalProperties && request.context.options.additionalProperties)) {\n types.push(UNKNOWN_TYPE);\n }\n const patterns = schema.patternProperties;\n if (typeof patterns === \"object\" && patterns !== null && Object.keys(patterns).length > 0) {\n for (const [, value] of documentEntries(patterns, request.context.options)) {\n types.push(request.transformNested(value, request.location));\n }\n }\n return types;\n}\n\n/**\n * Whether the schema declares property `key` and the type keeps it: `--exclude-deprecated` drops\n * a deprecated one.\n */\nexport function isKeptProperty(schema: SchemaObject, key: string, request: SchemaRequest): boolean {\n const properties = schema.properties ?? {};\n if (!Object.hasOwn(properties, key)) {\n return false;\n }\n const value = properties[key] as Schema;\n const isExcludable = request.context.options.excludeDeprecated && typeof value === \"object\";\n return !isExcludable || !isExcluded(value, propertyFacts(value, request), request);\n}\n\n/**\n * The members for the discriminator and `properties`. A schema that declares the discriminator\n * property itself keeps its own declaration, required as the discriminator needs: both in one\n * object type do not compile (TS2300, the Apple SiriKit Cloud Media API). A declaration that\n * `--exclude-deprecated` drops does not count, so the discriminator property stays.\n */\nfunction discriminatorAndPropertyMembers(schema: SchemaObject, request: SchemaRequest): IrMember[] {\n const inherited = inheritedDiscriminator(schema, request);\n if (inherited === undefined) {\n return propertyMembers(schema, request);\n }\n const name = inherited.discriminator.propertyName;\n if (!isKeptProperty(schema, name, request)) {\n return [discriminatorMember(inherited, request), ...propertyMembers(schema, request)];\n }\n // Without `required`, `--properties-required-by-default` requires every property already; a\n // list of one would make the others optional.\n const isAllRequired =\n schema.required === undefined && request.context.options.propertiesRequiredByDefault;\n const required = isAllRequired ? undefined : [...(schema.required ?? []), name];\n return propertyMembers({ ...schema, required } as SchemaObject, request);\n}\n\n/**\n * Object keywords: discriminator, `properties`, `$defs`, and an index signature for\n * `additionalProperties` / `patternProperties` (or `--additional-properties`). Null when the schema\n * has none of them.\n */\nexport function objectType(schema: SchemaObject, request: SchemaRequest): IrType | null {\n if (!hasObjectKeywords(schema)) {\n const inherited = inheritedDiscriminator(schema, request);\n return inherited ? irObject([discriminatorMember(inherited, request)]) : null;\n }\n const members = discriminatorAndPropertyMembers(schema, request);\n // As in the original, a null `$defs` throws here (Object.keys) instead of being skipped.\n if (\n \"$defs\" in schema &&\n typeof schema.$defs === \"object\" &&\n Object.keys(schema.$defs).length > 0\n ) {\n members.push(defsMember(schema.$defs, request));\n }\n const valueTypes = indexValueTypes(schema, request);\n if (valueTypes.length === 0) {\n return members.length > 0 ? irObject(members) : null;\n }\n const index = irObject([\n irStringIndexSignature(\"key\", unionOf(valueTypes), request.context.options.immutable),\n ]);\n return intersectionOf([...(members.length > 0 ? [irObject(members)] : []), index]);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAsBA,MAAM,gBAAA,GAAmB,CAAC,YAAA,EAAc,aAAA,EAAe,eAAe,CAAA;AAE/D,MAAM,6BAA6B,oBAAA,CAAqB;AAAA,EAC7D,WAAA,CAAY,IAAA,EAA0B,GAAA,EAAa,KAAA,EAAgB;AACjE,IAAA,MAAM,WAAW,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,GAAI,UAAU,OAAO,KAAA;AACzD,IAAA,KAAA,CAAM;AAAA,MACJ,MAAM,WAAA,CAAY,uBAAA;AAAA,MAClB,SACE,CAAA,EAAG,IAAI,CAAA,mBAAA,EAAsB,GAAG,4CAAiD,QAAQ,CAAA,CAAA;AAAA,MAC3F,OAAA,EAAS,EAAE,IAAA,EAAM,QAAA,EAAU,KAAK,QAAA;AAAS,KAC1C,CAAA;AACD,IAAA,IAAA,CAAK,IAAA,GAAO,sBAAA;AAAA,EACd;AACF;AAGA,SAAS,mBAAA,CAAoB,IAAA,EAAc,KAAA,EAAoB,OAAA,EAAgC;AAC7F,EAAA,IAAI,CAAC,OAAA,CAAQ,gBAAA,IAAoB,KAAA,CAAM,UAAA,KAAe,MAAM,WAAA,EAAa;AACvE,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,YAAY,KA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AClD;AACA,EAAA,MAAM,QAAQ,QAAA,CAAS;AAAA,IACrB,sBAAA,CAAuB,OAAO,OAAA,CAAQ,UAAU,GAAG,OAAA,CAAQ,OAAA,CAAQ,QAAQ,SAAS;AAAA,GACrF,CAAA;AACD,EAAA,OAAO,cAAA,CAAe,CAAC,GAAI,OAAA,CAAQ,SAAS,CAAA,GAAI,CAAC,QAAA,CAAS,OAAO,CAAC,CAAA,GAAI,EAAC,EAAI,KAAK,CAAC,CAAA;AACnF;;"}
1
+ {"version":3,"file":"object-type.mjs","sources":["../../../../src/application/transform/schema/object-type.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../../../domain/errors.js\";\nimport {\n irObject,\n irProperty,\n irReference,\n irStringIndexSignature,\n} from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrPropertySignature, IrType } from \"../../../domain/ir/nodes.js\";\nimport { toPropertyName } from \"../../../domain/ir/property-name.js\";\nimport { appendPointer } from \"../../../domain/openapi/json-pointer.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { documentEntries } from \"../document-entries.js\";\nimport { schemaRefType } from \"../ref-pointer/pointer-type.js\";\nimport { schemaCommentOptionsOf, withSchemaComment } from \"../schema-comment.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { intersectionOf, unionOf } from \"../type-combinators.js\";\nimport { type AccessFlags, propertyAccessFlags } from \"./access-flags.js\";\nimport { withPropertyTypes } from \"./index-signature-type.js\";\nimport { discriminatorMember, inheritedDiscriminator } from \"./inherited-discriminator.js\";\nimport { isInputLocation } from \"./input-location.js\";\nimport { refWithSiblingsAsAllOf } from \"./ref-siblings.js\";\nimport type { SchemaOptions } from \"./schema-context.js\";\nimport type { SchemaRequest } from \"./schema-rule.js\";\n\nexport class InvalidPropertyError extends OpenAPITypesafeError {\n constructor(path: string | undefined, key: string, value: unknown) {\n const received = Array.isArray(value) ? \"Array\" : typeof value;\n super({\n code: ERROR_CODES.SCHEMA_PROPERTY_INVALID,\n message:\n `${path}: invalid property ${key}. ` + `Expected Schema Object or boolean, got ${received}`,\n details: { path, property: key, received },\n });\n this.name = \"InvalidPropertyError\";\n }\n}\n\n/** `--read-write-markers`: `$Read<T>` / `$Write<T>`, unless the property is both or neither. */\nfunction withReadWriteMarker(type: IrType, flags: AccessFlags, options: SchemaOptions): IrType {\n if (!options.readWriteMarkers || flags.isReadOnly === flags.isWriteOnly) {\n return type;\n }\n return irReference(flags.isReadOnly ? \"$Read\" : \"$Write\", [type]);\n}\n\n/** Apply `transformProperty`, then the schema's JSDoc. */\nfunction finishProperty(\n property: IrPropertySignature,\n schema: Schema,\n path: string,\n request: SchemaRequest,\n): IrPropertySignature {\n const location = { ...request.location, path };\n const transformed =\n request.context.callbacks.transformProperty(property, schema, location) ?? property;\n // The original adds the schema's comment after any comment the callback set.\n return withSchemaComment(\n transformed,\n schema,\n schemaCommentOptionsOf(request.context.options.fixes),\n );\n}\n\n/** What the property loop reads from a property schema, in the original order. */\ninterface PropertyFacts {\n readonly ref: string | undefined;\n readonly flags: AccessFlags;\n readonly hasDefault: boolean;\n}\n\nfunction propertyFacts(value: Schema, request: SchemaRequest): PropertyFacts {\n if (typeof value !== \"object\") {\n return { ref: undefined, flags: { isReadOnly: false, isWriteOnly: false }, hasDefault: false };\n }\n // `in` throws for a null value, as in the original (which also reads `$ref` first).\n const ref = \"$ref\" in value && value.$ref ? value.$ref : undefined;\n const flags = propertyAccessFlags(value, request.context);\n return { ref, flags, hasDefault: \"default\" in value && value.default !== undefined };\n}\n\nfunction isOptionalProperty(\n key: string,\n facts: PropertyFacts,\n schema: SchemaObject,\n request: SchemaRequest,\n): boolean {\n const { options } = request.context;\n const isDefaultRequired =\n facts.hasDefault &&\n options.defaultNonNullable &&\n !isInputLocation(request.location.path, options.fixes);\n const isRequired =\n schema.required?.includes(key) ||\n (schema.required === undefined && options.propertiesRequiredByDefault) ||\n isDefaultRequired;\n return !isRequired;\n}\n\nfunction isExcluded(value: Schema, facts: PropertyFacts, request: SchemaRequest): boolean {\n if (!request.context.options.excludeDeprecated) {\n return false;\n }\n const resolved = facts.ref ? request.context.refs.resolve(facts.ref) : value;\n return Boolean((resolved as SchemaObject | undefined)?.deprecated);\n}\n\n/** A type, and whether a callback forced the property optional (null: no override). */\ninterface CustomResult {\n readonly type: IrType;\n readonly isOptional: true | null;\n}\n\n/** A `$ref` with siblings that `ref-siblings` types as an `allOf` is typed as a schema. */\nfunction plainRef({ ref }: PropertyFacts, value: Schema, request: SchemaRequest) {\n const isAllOf = ref && refWithSiblingsAsAllOf(value as SchemaObject, request.context.options);\n return isAllOf ? undefined : ref;\n}\n\nfunction propertyType(\n key: string,\n value: Schema,\n facts: PropertyFacts,\n request: SchemaRequest,\n): CustomResult {\n const path = appendPointer(request.location.path, [key]);\n const ref = plainRef(facts, value, request);\n const type = ref\n ? schemaRefType(ref, request)\n : request.transformNested(value, { ...request.location, path });\n const custom = request.context.callbacks.transform(value, request.location);\n return custom === null\n ? { type, isOptional: null }\n : { type: custom.type, isOptional: custom.isOptional || null };\n}\n\nfunction propertyMember(\n key: string,\n value: Schema,\n schema: SchemaObject,\n request: SchemaRequest,\n): IrMember | null {\n if ((typeof value !== \"object\" && typeof value !== \"boolean\") || Array.isArray(value)) {\n throw new InvalidPropertyError(request.location.path, key, value);\n }\n const facts = propertyFacts(value, request);\n if (isExcluded(value, facts, request)) {\n return null;\n }\n const { options } = request.context;\n const isOptional = isOptionalProperty(key, facts, schema, request);\n const result = propertyType(key, value, facts, request);\n const property = irProperty(\n toPropertyName(key),\n withReadWriteMarker(result.type, facts.flags, options),\n {\n isOptional: result.isOptional ?? isOptional,\n isReadonly: options.immutable || (!options.readWriteMarkers && facts.flags.isReadOnly),\n },\n );\n return finishProperty(property, value, appendPointer(request.location.path, [key]), request);\n}\n\nfunction propertyMembers(schema: SchemaObject, request: SchemaRequest): IrMember[] {\n const members: IrMember[] = [];\n for (const [key, value] of documentEntries(schema.properties ?? {}, request.context.options)) {\n const member = propertyMember(key, value, schema, request);\n if (member !== null) {\n members.push(member);\n }\n }\n return members;\n}\n\n/**\n * `$defs` as a nested `$defs?: { … }` member, in document order (never alphabetized). It is\n * optional because `$defs` is a schema keyword, not data: the original made it required, so a\n * value of the type needed a `$defs` key (research/legacy-bugs.md, item 17, upstream #2664).\n */\nfunction defsMember(\n defs: Readonly<Record<string, SchemaObject>>,\n request: SchemaRequest,\n): IrMember {\n const { options } = request.context;\n const members = Object.entries(defs).map(([key, value]) => {\n const path = appendPointer(request.location.path, [\"$defs\", key]);\n const flags = propertyAccessFlags(value, request.context);\n const type = withReadWriteMarker(\n request.transformNested(value, { ...request.location, path }),\n flags,\n options,\n );\n const property = irProperty(toPropertyName(key), type, {\n isReadonly: options.immutable || (!options.readWriteMarkers && flags.isReadOnly),\n });\n return finishProperty(property, value, path, request);\n });\n return irProperty(toPropertyName(\"$defs\"), irObject(members), { isOptional: true });\n}\n\nfunction hasObjectKeywords(schema: SchemaObject): boolean {\n const hasProperties = Boolean(schema.properties && Object.keys(schema.properties).length);\n return (\n hasProperties ||\n Boolean(schema.additionalProperties || schema.patternProperties || schema.$defs)\n );\n}\n\n/** Value types of the `[key: string]` index signature, in the original order. */\nfunction indexValueTypes(schema: SchemaObject, request: SchemaRequest): IrType[] {\n const { additionalProperties } = schema;\n const isObject = typeof additionalProperties === \"object\";\n const hasExplicit = isObject && Object.keys(additionalProperties).length > 0;\n const hasImplicit =\n additionalProperties === true || (isObject && Object.keys(additionalProperties).length === 0);\n const types: IrType[] = [];\n if (hasExplicit) {\n types.push(request.transformNested(additionalProperties as Schema, request.location, true));\n }\n if (hasImplicit || (!additionalProperties && request.context.options.additionalProperties)) {\n types.push(UNKNOWN_TYPE);\n }\n const patterns = schema.patternProperties;\n if (typeof patterns === \"object\" && patterns !== null && Object.keys(patterns).length > 0) {\n for (const [, value] of documentEntries(patterns, request.context.options)) {\n types.push(request.transformNested(value, request.location));\n }\n }\n return types;\n}\n\n/**\n * Whether the schema declares property `key` and the type keeps it: `--exclude-deprecated` drops\n * a deprecated one.\n */\nexport function isKeptProperty(schema: SchemaObject, key: string, request: SchemaRequest): boolean {\n const properties = schema.properties ?? {};\n if (!Object.hasOwn(properties, key)) {\n return false;\n }\n const value = properties[key] as Schema;\n const isExcludable = request.context.options.excludeDeprecated && typeof value === \"object\";\n return !isExcludable || !isExcluded(value, propertyFacts(value, request), request);\n}\n\n/**\n * The members for the discriminator and `properties`. A schema that declares the discriminator\n * property itself keeps its own declaration, required as the discriminator needs: both in one\n * object type do not compile (TS2300, the Apple SiriKit Cloud Media API). A declaration that\n * `--exclude-deprecated` drops does not count, so the discriminator property stays.\n */\nfunction discriminatorAndPropertyMembers(schema: SchemaObject, request: SchemaRequest): IrMember[] {\n const inherited = inheritedDiscriminator(schema, request);\n if (inherited === undefined) {\n return propertyMembers(schema, request);\n }\n const name = inherited.discriminator.propertyName;\n if (!isKeptProperty(schema, name, request)) {\n return [discriminatorMember(inherited, request), ...propertyMembers(schema, request)];\n }\n // Without `required`, `--properties-required-by-default` requires every property already; a\n // list of one would make the others optional.\n const isAllRequired =\n schema.required === undefined && request.context.options.propertiesRequiredByDefault;\n const required = isAllRequired ? undefined : [...(schema.required ?? []), name];\n return propertyMembers({ ...schema, required } as SchemaObject, request);\n}\n\n/**\n * Object keywords: discriminator, `properties`, `$defs`, and an index signature for\n * `additionalProperties` / `patternProperties` (or `--additional-properties`). Null when the schema\n * has none of them.\n */\nexport function objectType(schema: SchemaObject, request: SchemaRequest): IrType | null {\n if (!hasObjectKeywords(schema)) {\n const inherited = inheritedDiscriminator(schema, request);\n return inherited ? irObject([discriminatorMember(inherited, request)]) : null;\n }\n const members = discriminatorAndPropertyMembers(schema, request);\n const propertyTypes = members.flatMap((member) =>\n member.kind === \"property\" ? [member.type] : [],\n );\n // As in the original, a null `$defs` throws here (Object.keys) instead of being skipped.\n if (\n \"$defs\" in schema &&\n typeof schema.$defs === \"object\" &&\n Object.keys(schema.$defs).length > 0\n ) {\n members.push(defsMember(schema.$defs, request));\n }\n const valueTypes = indexValueTypes(schema, request);\n if (valueTypes.length === 0) {\n return members.length > 0 ? irObject(members) : null;\n }\n const indexType = withPropertyTypes(unionOf(valueTypes), propertyTypes);\n const index = irObject([\n irStringIndexSignature(\"key\", indexType, request.context.options.immutable),\n ]);\n return intersectionOf([...(members.length > 0 ? [irObject(members)] : []), index]);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAwBO,MAAM,6BAA6B,oBAAA,CAAqB;AAAA,EAC7D,WAAA,CAAY,IAAA,EAA0B,GAAA,EAAa,KAAA,EAAgB;AACjE,IAAA,MAAM,WAAW,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,GAAI,UAAU,OAAO,KAAA;AACzD,IAAA,KAAA,CAAM;AAAA,MACJ,MAAM,WAAA,CAAY,uBAAA;AAAA,MAClB,SACE,CAAA,EAAG,IAAI,CAAA,mBAAA,EAAsB,GAAG,4CAAiD,QAAQ,CAAA,CAAA;AAAA,MAC3F,OAAA,EAAS,EAAE,IAAA,EAAM,QAAA,EAAU,KAAK,QAAA;AAAS,KAC1C,CAAA;AACD,IAAA,IAAA,CAAK,IAAA,GAAO,sBAAA;AAAA,EACd;AACF;AAGA,SAAS,mBAAA,CAAoB,IAAA,EAAc,KAAA,EAAoB,OAAA,EAAgC;AAC7F,EAAA,IAAI,CAAC,OAAA,CAAQ,gBAAA,IAAoB,KAAA,CAAM,UAAA,KAAe,MAAM,WAAA,EAAa;AACvE,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,YAAY,KAAA,CAAM,UAAA,GAAa,UAAU,QAAA,EAAU,CAAC,IAAI,CAAC,CAAA;AAClE;AAGA,SAAS,cAAA,CACP,QAAA,EACA,MAAA,EACA,IAAA,EACA,OAAA,EACqB;AACrB,EAAA,MAAM,QAAA,GAAW,EAAE,GAAG,OAAA,CAAQ,UAAU,IAAA,EAAK;AAC7C,EAAA,MAAM,WAAA,GACJ,QAAQ,OA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W,WAAW,CAAA,EAAG;AAC3B,IAAA,OAAO,OAAA,CAAQ,MAAA,GAAS,CAAA,GAAI,QAAA,CAAS,OAAO,CAAA,GAAI,IAAA;AAAA,EAClD;AACA,EAAA,MAAM,SAAA,GAAY,iBAAA,CAAkB,OAAA,CAAQ,UAAU,GAAG,aAAa,CAAA;AACtE,EAAA,MAAM,QAAQ,QAAA,CAAS;AAAA,IACrB,uBAAuB,KAAA,EAAO,SAAA,EAAW,OAAA,CAAQ,OAAA,CAAQ,QAAQ,SAAS;AAAA,GAC3E,CAAA;AACD,EAAA,OAAO,cAAA,CAAe,CAAC,GAAI,OAAA,CAAQ,SAAS,CAAA,GAAI,CAAC,QAAA,CAAS,OAAO,CAAC,CAAA,GAAI,EAAC,EAAI,KAAK,CAAC,CAAA;AACnF;;"}
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ const schemaDialect = require('../../../domain/openapi/schema-dialect.cjs');
4
+ const outputFixes = require('../../../domain/output-fixes.cjs');
5
+
6
+ const ANNOTATION_KEYWORDS = /* @__PURE__ */ new Set([
7
+ "$anchor",
8
+ "$comment",
9
+ "$defs",
10
+ "$dynamicAnchor",
11
+ "$id",
12
+ "$ref",
13
+ "$schema",
14
+ "contentEncoding",
15
+ "contentMediaType",
16
+ "default",
17
+ "deprecated",
18
+ "description",
19
+ "discriminator",
20
+ "example",
21
+ "examples",
22
+ "externalDocs",
23
+ "format",
24
+ "readOnly",
25
+ "title",
26
+ "writeOnly",
27
+ "xml"
28
+ ]);
29
+ const EXTENSION_PREFIX = "x-";
30
+ function hasRef(schema) {
31
+ return typeof schema.$ref === "string";
32
+ }
33
+ function isTypeKeyword(keyword) {
34
+ return !ANNOTATION_KEYWORDS.has(keyword) && !keyword.startsWith(EXTENSION_PREFIX);
35
+ }
36
+ function refWithSiblingsAsAllOf(schema, options) {
37
+ const isApplied = options.fixes.has(outputFixes.FIX.REF_SIBLINGS) && options.schemaDialect === schemaDialect.SCHEMA_DIALECTS.JSON_SCHEMA_2020_12;
38
+ if (!isApplied || !hasRef(schema) || !Object.keys(schema).some(isTypeKeyword)) {
39
+ return null;
40
+ }
41
+ const { $ref, allOf = [], ...siblings } = schema;
42
+ const members = [{ $ref }, ...allOf];
43
+ return { ...siblings, allOf: members };
44
+ }
45
+
46
+ exports.refWithSiblingsAsAllOf = refWithSiblingsAsAllOf;
47
+ //# sourceMappingURL=ref-siblings.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-siblings.cjs","sources":["../../../../src/application/transform/schema/ref-siblings.ts"],"sourcesContent":["import { SCHEMA_DIALECTS } from \"../../../domain/openapi/schema-dialect.js\";\nimport type {\n ReferenceSchema,\n Schema,\n SchemaObject,\n} from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport type { SchemaOptions } from \"./schema-context.js\";\n\n/**\n * The `ref-siblings` fix (ADR-021 amendment 2, RC4 G16): in JSON Schema 2020-12 (OpenAPI 3.1 and\n * 3.2) the keywords next to a `$ref` apply too, so `{ $ref: Base, required: [extra], properties:\n * { extra } }` is a `Base` that also has a required `extra`. That is what `allOf: [{ $ref: Base }]`\n * next to the same keywords means, so the schema is typed as that `allOf`, with every rule the\n * generator has for `allOf` and its siblings (`WithRequired`, intersections).\n */\n\n/**\n * Keywords that only annotate (JSON Schema 2020-12 meta-data, format-annotation and content\n * vocabularies, OpenAPI fixed fields), or that change no type on their own (`discriminator`\n * without `oneOf`). Next to a `$ref` they stay where they were, so the output keeps the plain\n * reference with its comment. Extension keywords (`x-…`) count as annotations too.\n */\nconst ANNOTATION_KEYWORDS: ReadonlySet<string> = new Set([\n \"$anchor\",\n \"$comment\",\n \"$defs\",\n \"$dynamicAnchor\",\n \"$id\",\n \"$ref\",\n \"$schema\",\n \"contentEncoding\",\n \"contentMediaType\",\n \"default\",\n \"deprecated\",\n \"description\",\n \"discriminator\",\n \"example\",\n \"examples\",\n \"externalDocs\",\n \"format\",\n \"readOnly\",\n \"title\",\n \"writeOnly\",\n \"xml\",\n]);\n\nconst EXTENSION_PREFIX = \"x-\";\n\nfunction hasRef(schema: SchemaObject): schema is SchemaObject & ReferenceSchema {\n return typeof (schema as Partial<ReferenceSchema>).$ref === \"string\";\n}\n\nfunction isTypeKeyword(keyword: string): boolean {\n return !ANNOTATION_KEYWORDS.has(keyword) && !keyword.startsWith(EXTENSION_PREFIX);\n}\n\n/**\n * A `$ref` schema as the `allOf` it means, or null where nothing changes: a schema without `$ref`,\n * no fix, an OpenAPI 3.0 document, or no sibling that changes the type. The result has no\n * `$ref`, so the shape rules type it as `enum`, `const` or a composition.\n */\nexport function refWithSiblingsAsAllOf(\n schema: SchemaObject,\n options: SchemaOptions,\n): SchemaObject | null {\n const isApplied =\n options.fixes.has(FIX.REF_SIBLINGS) &&\n options.schemaDialect === SCHEMA_DIALECTS.JSON_SCHEMA_2020_12;\n if (!isApplied || !hasRef(schema) || !Object.keys(schema).some(isTypeKeyword)) {\n return null;\n }\n const { $ref, allOf = [], ...siblings } = schema;\n const members: readonly Schema[] = [{ $ref }, ...allOf];\n return { ...siblings, allOf: members };\n}\n"],"names":["FIX","SCHEMA_DIALECTS"],"mappings":";;;;;AAuBA,MAAM,mBAAA,uBAA+C,GAAA,CAAI;AAAA,EACvD,SAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,gBAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA,SAAA;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,MAAM,gBAAA,GAAmB,IAAA;AAEzB,SAAS,OAAO,MAAA,EAAgE;AAC9E,EAAA,OAAO,OAAQ,OAAoC,IAAA,KAAS,QAAA;AAC9D;AAEA,SAAS,cAAc,OAAA,EAA0B;AAC/C,EAAA,OAAO,CAAC,oBAAoB,GAAA,CAAI,OAAO,KAAK,CAAC,OAAA,CAAQ,WAAW,gBAAgB,CAAA;AAClF;AAOO,SAAS,sBAAA,CACd,QACA,OAAA,EACqB;AACrB,EAAA,MAAM,SAAA,GACJ,QAAQ,KAAA,CAAM,GAAA,CAAIA,gBAAI,YAAY,CAAA,IAClC,OAAA,CAAQ,aAAA,KAAkBC,6BAAA,CAAgB,mBAAA;AAC5C,EAAA,IAAI,CAAC,SAAA,IAAa,CAAC,MAAA,CAAO,MAAM,CAAA,IAAK,CAAC,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAAE,IAAA,CAAK,aAAa,CAAA,EAAG;AAC7E,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,EAAE,IAAA,EAAM,KAAA,GAAQ,EAAC,EAAG,GAAG,UAAS,GAAI,MAAA;AAC1C,EAAA,MAAM,UAA6B,CAAC,EAAE,IAAA,EAAK,EAAG,GAAG,KAAK,CAAA;AACtD,EAAA,OAAO,EAAE,GAAG,QAAA,EAAU,KAAA,EAAO,OAAA,EAAQ;AACvC;;"}
@@ -0,0 +1,45 @@
1
+ import { SCHEMA_DIALECTS } from '../../../domain/openapi/schema-dialect.mjs';
2
+ import { FIX } from '../../../domain/output-fixes.mjs';
3
+
4
+ const ANNOTATION_KEYWORDS = /* @__PURE__ */ new Set([
5
+ "$anchor",
6
+ "$comment",
7
+ "$defs",
8
+ "$dynamicAnchor",
9
+ "$id",
10
+ "$ref",
11
+ "$schema",
12
+ "contentEncoding",
13
+ "contentMediaType",
14
+ "default",
15
+ "deprecated",
16
+ "description",
17
+ "discriminator",
18
+ "example",
19
+ "examples",
20
+ "externalDocs",
21
+ "format",
22
+ "readOnly",
23
+ "title",
24
+ "writeOnly",
25
+ "xml"
26
+ ]);
27
+ const EXTENSION_PREFIX = "x-";
28
+ function hasRef(schema) {
29
+ return typeof schema.$ref === "string";
30
+ }
31
+ function isTypeKeyword(keyword) {
32
+ return !ANNOTATION_KEYWORDS.has(keyword) && !keyword.startsWith(EXTENSION_PREFIX);
33
+ }
34
+ function refWithSiblingsAsAllOf(schema, options) {
35
+ const isApplied = options.fixes.has(FIX.REF_SIBLINGS) && options.schemaDialect === SCHEMA_DIALECTS.JSON_SCHEMA_2020_12;
36
+ if (!isApplied || !hasRef(schema) || !Object.keys(schema).some(isTypeKeyword)) {
37
+ return null;
38
+ }
39
+ const { $ref, allOf = [], ...siblings } = schema;
40
+ const members = [{ $ref }, ...allOf];
41
+ return { ...siblings, allOf: members };
42
+ }
43
+
44
+ export { refWithSiblingsAsAllOf };
45
+ //# sourceMappingURL=ref-siblings.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-siblings.mjs","sources":["../../../../src/application/transform/schema/ref-siblings.ts"],"sourcesContent":["import { SCHEMA_DIALECTS } from \"../../../domain/openapi/schema-dialect.js\";\nimport type {\n ReferenceSchema,\n Schema,\n SchemaObject,\n} from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport type { SchemaOptions } from \"./schema-context.js\";\n\n/**\n * The `ref-siblings` fix (ADR-021 amendment 2, RC4 G16): in JSON Schema 2020-12 (OpenAPI 3.1 and\n * 3.2) the keywords next to a `$ref` apply too, so `{ $ref: Base, required: [extra], properties:\n * { extra } }` is a `Base` that also has a required `extra`. That is what `allOf: [{ $ref: Base }]`\n * next to the same keywords means, so the schema is typed as that `allOf`, with every rule the\n * generator has for `allOf` and its siblings (`WithRequired`, intersections).\n */\n\n/**\n * Keywords that only annotate (JSON Schema 2020-12 meta-data, format-annotation and content\n * vocabularies, OpenAPI fixed fields), or that change no type on their own (`discriminator`\n * without `oneOf`). Next to a `$ref` they stay where they were, so the output keeps the plain\n * reference with its comment. Extension keywords (`x-…`) count as annotations too.\n */\nconst ANNOTATION_KEYWORDS: ReadonlySet<string> = new Set([\n \"$anchor\",\n \"$comment\",\n \"$defs\",\n \"$dynamicAnchor\",\n \"$id\",\n \"$ref\",\n \"$schema\",\n \"contentEncoding\",\n \"contentMediaType\",\n \"default\",\n \"deprecated\",\n \"description\",\n \"discriminator\",\n \"example\",\n \"examples\",\n \"externalDocs\",\n \"format\",\n \"readOnly\",\n \"title\",\n \"writeOnly\",\n \"xml\",\n]);\n\nconst EXTENSION_PREFIX = \"x-\";\n\nfunction hasRef(schema: SchemaObject): schema is SchemaObject & ReferenceSchema {\n return typeof (schema as Partial<ReferenceSchema>).$ref === \"string\";\n}\n\nfunction isTypeKeyword(keyword: string): boolean {\n return !ANNOTATION_KEYWORDS.has(keyword) && !keyword.startsWith(EXTENSION_PREFIX);\n}\n\n/**\n * A `$ref` schema as the `allOf` it means, or null where nothing changes: a schema without `$ref`,\n * no fix, an OpenAPI 3.0 document, or no sibling that changes the type. The result has no\n * `$ref`, so the shape rules type it as `enum`, `const` or a composition.\n */\nexport function refWithSiblingsAsAllOf(\n schema: SchemaObject,\n options: SchemaOptions,\n): SchemaObject | null {\n const isApplied =\n options.fixes.has(FIX.REF_SIBLINGS) &&\n options.schemaDialect === SCHEMA_DIALECTS.JSON_SCHEMA_2020_12;\n if (!isApplied || !hasRef(schema) || !Object.keys(schema).some(isTypeKeyword)) {\n return null;\n }\n const { $ref, allOf = [], ...siblings } = schema;\n const members: readonly Schema[] = [{ $ref }, ...allOf];\n return { ...siblings, allOf: members };\n}\n"],"names":[],"mappings":";;;AAuBA,MAAM,mBAAA,uBAA+C,GAAA,CAAI;AAAA,EACvD,SAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,gBAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA,SAAA;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AA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