openapi-typesafe 1.0.0-rc.4 → 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 (320) hide show
  1. package/CHANGELOG.md +141 -0
  2. package/dist/adapters/node-file-system/node-file-system.cjs +7 -0
  3. package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
  4. package/dist/adapters/node-file-system/node-file-system.mjs +7 -0
  5. package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
  6. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs +19 -0
  7. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs.map +1 -0
  8. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs +17 -0
  9. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs.map +1 -0
  10. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +5 -32
  11. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -1
  12. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +6 -33
  13. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -1
  14. package/dist/adapters/redocly-loader/component-schemas.cjs +17 -0
  15. package/dist/adapters/redocly-loader/component-schemas.cjs.map +1 -0
  16. package/dist/adapters/redocly-loader/component-schemas.mjs +14 -0
  17. package/dist/adapters/redocly-loader/component-schemas.mjs.map +1 -0
  18. package/dist/adapters/redocly-loader/mapping-schema-names.cjs +22 -0
  19. package/dist/adapters/redocly-loader/mapping-schema-names.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/mapping-schema-names.mjs +20 -0
  21. package/dist/adapters/redocly-loader/mapping-schema-names.mjs.map +1 -0
  22. package/dist/adapters/redocly-loader/query-named-components.cjs +137 -0
  23. package/dist/adapters/redocly-loader/query-named-components.cjs.map +1 -0
  24. package/dist/adapters/redocly-loader/query-named-components.mjs +134 -0
  25. package/dist/adapters/redocly-loader/query-named-components.mjs.map +1 -0
  26. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +26 -14
  27. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  28. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +26 -14
  29. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  30. package/dist/adapters/redocly-loader/ref-access.cjs +16 -3
  31. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/ref-access.mjs +16 -3
  33. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  34. package/dist/adapters/redocly-loader/ref-holders.cjs +52 -10
  35. package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
  36. package/dist/adapters/redocly-loader/ref-holders.mjs +52 -11
  37. package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
  38. package/dist/adapters/redocly-loader/remote-fetch.cjs +5 -3
  39. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  40. package/dist/adapters/redocly-loader/remote-fetch.mjs +5 -3
  41. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  42. package/dist/adapters/redocly-loader/remote-node-limit.cjs +17 -3
  43. package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -1
  44. package/dist/adapters/redocly-loader/remote-node-limit.mjs +17 -3
  45. package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -1
  46. package/dist/adapters/redocly-loader/schema-source.cjs +7 -2
  47. package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
  48. package/dist/adapters/redocly-loader/schema-source.mjs +8 -3
  49. package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
  50. package/dist/adapters/terminal-logger/terminal-logger.cjs +7 -3
  51. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  52. package/dist/adapters/terminal-logger/terminal-logger.mjs +7 -3
  53. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  54. package/dist/api/document-refs.cjs +16 -1
  55. package/dist/api/document-refs.cjs.map +1 -1
  56. package/dist/api/document-refs.mjs +16 -1
  57. package/dist/api/document-refs.mjs.map +1 -1
  58. package/dist/api/document-run.cjs +4 -10
  59. package/dist/api/document-run.cjs.map +1 -1
  60. package/dist/api/document-run.mjs +4 -10
  61. package/dist/api/document-run.mjs.map +1 -1
  62. package/dist/api/openapi-ts.cjs +1 -2
  63. package/dist/api/openapi-ts.cjs.map +1 -1
  64. package/dist/api/openapi-ts.mjs +2 -3
  65. package/dist/api/openapi-ts.mjs.map +1 -1
  66. package/dist/api/ref-limit-options.cjs +63 -0
  67. package/dist/api/ref-limit-options.cjs.map +1 -0
  68. package/dist/api/ref-limit-options.mjs +57 -0
  69. package/dist/api/ref-limit-options.mjs.map +1 -0
  70. package/dist/api/transform-schema.cjs +12 -5
  71. package/dist/api/transform-schema.cjs.map +1 -1
  72. package/dist/api/transform-schema.mjs +12 -5
  73. package/dist/api/transform-schema.mjs.map +1 -1
  74. package/dist/application/transform/declared-value-types.cjs +36 -0
  75. package/dist/application/transform/declared-value-types.cjs.map +1 -0
  76. package/dist/application/transform/declared-value-types.mjs +34 -0
  77. package/dist/application/transform/declared-value-types.mjs.map +1 -0
  78. package/dist/application/transform/document/document.cjs +3 -1
  79. package/dist/application/transform/document/document.cjs.map +1 -1
  80. package/dist/application/transform/document/document.mjs +3 -1
  81. package/dist/application/transform/document/document.mjs.map +1 -1
  82. package/dist/application/transform/document/exploded-query-values.cjs +63 -0
  83. package/dist/application/transform/document/exploded-query-values.cjs.map +1 -0
  84. package/dist/application/transform/document/exploded-query-values.mjs +59 -0
  85. package/dist/application/transform/document/exploded-query-values.mjs.map +1 -0
  86. package/dist/application/transform/document/header.cjs +11 -3
  87. package/dist/application/transform/document/header.cjs.map +1 -1
  88. package/dist/application/transform/document/header.mjs +10 -2
  89. package/dist/application/transform/document/header.mjs.map +1 -1
  90. package/dist/application/transform/document/parameter.cjs +1 -1
  91. package/dist/application/transform/document/parameter.cjs.map +1 -1
  92. package/dist/application/transform/document/parameter.mjs +1 -1
  93. package/dist/application/transform/document/parameter.mjs.map +1 -1
  94. package/dist/application/transform/document/parameters.cjs +23 -5
  95. package/dist/application/transform/document/parameters.cjs.map +1 -1
  96. package/dist/application/transform/document/parameters.mjs +23 -5
  97. package/dist/application/transform/document/parameters.mjs.map +1 -1
  98. package/dist/application/transform/document/path-item.cjs +4 -3
  99. package/dist/application/transform/document/path-item.cjs.map +1 -1
  100. package/dist/application/transform/document/path-item.mjs +4 -4
  101. package/dist/application/transform/document/path-item.mjs.map +1 -1
  102. package/dist/application/transform/document/path-template-key.cjs +84 -0
  103. package/dist/application/transform/document/path-template-key.cjs.map +1 -0
  104. package/dist/application/transform/document/path-template-key.mjs +79 -0
  105. package/dist/application/transform/document/path-template-key.mjs.map +1 -0
  106. package/dist/application/transform/document/path-template-refs.cjs +70 -0
  107. package/dist/application/transform/document/path-template-refs.cjs.map +1 -0
  108. package/dist/application/transform/document/path-template-refs.mjs +67 -0
  109. package/dist/application/transform/document/path-template-refs.mjs.map +1 -0
  110. package/dist/application/transform/document/paths-enum.cjs +7 -6
  111. package/dist/application/transform/document/paths-enum.cjs.map +1 -1
  112. package/dist/application/transform/document/paths-enum.mjs +7 -6
  113. package/dist/application/transform/document/paths-enum.mjs.map +1 -1
  114. package/dist/application/transform/document/paths.cjs +38 -66
  115. package/dist/application/transform/document/paths.cjs.map +1 -1
  116. package/dist/application/transform/document/paths.mjs +36 -66
  117. package/dist/application/transform/document/paths.mjs.map +1 -1
  118. package/dist/application/transform/document/webhooks.cjs +10 -3
  119. package/dist/application/transform/document/webhooks.cjs.map +1 -1
  120. package/dist/application/transform/document/webhooks.mjs +9 -2
  121. package/dist/application/transform/document/webhooks.mjs.map +1 -1
  122. package/dist/application/transform/footer/document-footer.cjs +6 -3
  123. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  124. package/dist/application/transform/footer/document-footer.mjs +6 -3
  125. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  126. package/dist/application/transform/helper-types.cjs +3 -3
  127. package/dist/application/transform/helper-types.cjs.map +1 -1
  128. package/dist/application/transform/helper-types.mjs +3 -3
  129. package/dist/application/transform/helper-types.mjs.map +1 -1
  130. package/dist/application/transform/ref-pointer/generated-location.cjs +4 -4
  131. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
  132. package/dist/application/transform/ref-pointer/generated-location.mjs +1 -1
  133. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
  134. package/dist/application/transform/ref-pointer/generated-shape.cjs +47 -66
  135. package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -1
  136. package/dist/application/transform/ref-pointer/generated-shape.mjs +36 -50
  137. package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -1
  138. package/dist/application/transform/ref-pointer/inline-cycles.cjs +2 -2
  139. package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -1
  140. package/dist/application/transform/ref-pointer/inline-cycles.mjs +1 -1
  141. package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -1
  142. package/dist/application/transform/ref-pointer/located-node.cjs +23 -0
  143. package/dist/application/transform/ref-pointer/located-node.cjs.map +1 -0
  144. package/dist/application/transform/ref-pointer/located-node.mjs +18 -0
  145. package/dist/application/transform/ref-pointer/located-node.mjs.map +1 -0
  146. package/dist/application/transform/ref-pointer/original-index.cjs +68 -13
  147. package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -1
  148. package/dist/application/transform/ref-pointer/original-index.mjs +70 -15
  149. package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -1
  150. package/dist/application/transform/ref-pointer/pointer-type.cjs +2 -2
  151. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  152. package/dist/application/transform/ref-pointer/pointer-type.mjs +1 -1
  153. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  154. package/dist/application/transform/ref-pointer/pointer-walk.cjs +54 -13
  155. package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -1
  156. package/dist/application/transform/ref-pointer/pointer-walk.mjs +46 -7
  157. package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -1
  158. package/dist/application/transform/ref-pointer/property-shape.cjs +52 -0
  159. package/dist/application/transform/ref-pointer/property-shape.cjs.map +1 -0
  160. package/dist/application/transform/ref-pointer/property-shape.mjs +45 -0
  161. package/dist/application/transform/ref-pointer/property-shape.mjs.map +1 -0
  162. package/dist/application/transform/ref-pointer/typed-walk.cjs +79 -21
  163. package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -1
  164. package/dist/application/transform/ref-pointer/typed-walk.mjs +76 -18
  165. package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -1
  166. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  167. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  168. package/dist/application/transform/schema/index-signature-type.cjs +21 -0
  169. package/dist/application/transform/schema/index-signature-type.cjs.map +1 -0
  170. package/dist/application/transform/schema/index-signature-type.mjs +19 -0
  171. package/dist/application/transform/schema/index-signature-type.mjs.map +1 -0
  172. package/dist/application/transform/schema/input-location.cjs +23 -0
  173. package/dist/application/transform/schema/input-location.cjs.map +1 -0
  174. package/dist/application/transform/schema/input-location.mjs +21 -0
  175. package/dist/application/transform/schema/input-location.mjs.map +1 -0
  176. package/dist/application/transform/schema/object-type.cjs +15 -5
  177. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  178. package/dist/application/transform/schema/object-type.mjs +15 -5
  179. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  180. package/dist/application/transform/schema/schema-transform.cjs +2 -1
  181. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  182. package/dist/application/transform/schema/schema-transform.mjs +2 -1
  183. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  184. package/dist/application/transform/schema/unevaluated-properties.cjs +2 -30
  185. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  186. package/dist/application/transform/schema/unevaluated-properties.mjs +3 -31
  187. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  188. package/dist/cli/api-logger.cjs +13 -0
  189. package/dist/cli/api-logger.cjs.map +1 -0
  190. package/dist/cli/api-logger.mjs +11 -0
  191. package/dist/cli/api-logger.mjs.map +1 -0
  192. package/dist/cli/api-settings.cjs +7 -15
  193. package/dist/cli/api-settings.cjs.map +1 -1
  194. package/dist/cli/api-settings.mjs +8 -16
  195. package/dist/cli/api-settings.mjs.map +1 -1
  196. package/dist/cli/cli-arguments.cjs +51 -11
  197. package/dist/cli/cli-arguments.cjs.map +1 -1
  198. package/dist/cli/cli-arguments.mjs +51 -11
  199. package/dist/cli/cli-arguments.mjs.map +1 -1
  200. package/dist/cli/cli-errors.cjs +17 -0
  201. package/dist/cli/cli-errors.cjs.map +1 -1
  202. package/dist/cli/cli-errors.mjs +17 -1
  203. package/dist/cli/cli-errors.mjs.map +1 -1
  204. package/dist/cli/cli-output.cjs +6 -4
  205. package/dist/cli/cli-output.cjs.map +1 -1
  206. package/dist/cli/cli-output.mjs +7 -5
  207. package/dist/cli/cli-output.mjs.map +1 -1
  208. package/dist/cli/main.cjs +10 -4
  209. package/dist/cli/main.cjs.map +1 -1
  210. package/dist/cli/main.mjs +10 -4
  211. package/dist/cli/main.mjs.map +1 -1
  212. package/dist/cli/redocly-apis.cjs +20 -9
  213. package/dist/cli/redocly-apis.cjs.map +1 -1
  214. package/dist/cli/redocly-apis.mjs +22 -11
  215. package/dist/cli/redocly-apis.mjs.map +1 -1
  216. package/dist/cli/ref-limits.cjs +15 -1
  217. package/dist/cli/ref-limits.cjs.map +1 -1
  218. package/dist/cli/ref-limits.mjs +15 -2
  219. package/dist/cli/ref-limits.mjs.map +1 -1
  220. package/dist/cli/run-cli.cjs +24 -7
  221. package/dist/cli/run-cli.cjs.map +1 -1
  222. package/dist/cli/run-cli.mjs +25 -8
  223. package/dist/cli/run-cli.mjs.map +1 -1
  224. package/dist/domain/cause-secrets.cjs +31 -16
  225. package/dist/domain/cause-secrets.cjs.map +1 -1
  226. package/dist/domain/cause-secrets.mjs +31 -16
  227. package/dist/domain/cause-secrets.mjs.map +1 -1
  228. package/dist/domain/errors.cjs +2 -0
  229. package/dist/domain/errors.cjs.map +1 -1
  230. package/dist/domain/errors.mjs +2 -0
  231. package/dist/domain/errors.mjs.map +1 -1
  232. package/dist/domain/location-text.cjs +9 -0
  233. package/dist/domain/location-text.cjs.map +1 -0
  234. package/dist/domain/location-text.mjs +7 -0
  235. package/dist/domain/location-text.mjs.map +1 -0
  236. package/dist/domain/openapi/document-places.cjs +55 -0
  237. package/dist/domain/openapi/document-places.cjs.map +1 -0
  238. package/dist/domain/openapi/document-places.mjs +53 -0
  239. package/dist/domain/openapi/document-places.mjs.map +1 -0
  240. package/dist/domain/output-fixes.cjs +8 -2
  241. package/dist/domain/output-fixes.cjs.map +1 -1
  242. package/dist/domain/output-fixes.mjs +8 -2
  243. package/dist/domain/output-fixes.mjs.map +1 -1
  244. package/dist/domain/terminal-text.cjs +31 -0
  245. package/dist/domain/terminal-text.cjs.map +1 -0
  246. package/dist/domain/terminal-text.mjs +29 -0
  247. package/dist/domain/terminal-text.mjs.map +1 -0
  248. package/dist/domain/warnings.cjs +1 -0
  249. package/dist/domain/warnings.cjs.map +1 -1
  250. package/dist/domain/warnings.mjs +1 -0
  251. package/dist/domain/warnings.mjs.map +1 -1
  252. package/dist/index.d.cts +26 -18
  253. package/dist/index.d.mts +26 -18
  254. package/dist/index.d.ts +26 -18
  255. package/package.json +1 -1
  256. package/src/adapters/node-file-system/node-file-system.ts +14 -1
  257. package/src/adapters/pipe-safe-writer/pipe-safe-writer.ts +29 -0
  258. package/src/adapters/redocly-loader/bundled-mapping-copies.ts +7 -42
  259. package/src/adapters/redocly-loader/component-schemas.ts +19 -0
  260. package/src/adapters/redocly-loader/mapping-schema-names.ts +25 -0
  261. package/src/adapters/redocly-loader/query-named-components.ts +201 -0
  262. package/src/adapters/redocly-loader/redocly-schema-loader.ts +46 -14
  263. package/src/adapters/redocly-loader/ref-access.ts +16 -3
  264. package/src/adapters/redocly-loader/ref-holders.ts +75 -14
  265. package/src/adapters/redocly-loader/remote-fetch.ts +11 -2
  266. package/src/adapters/redocly-loader/remote-node-limit.ts +44 -4
  267. package/src/adapters/redocly-loader/schema-source.ts +15 -3
  268. package/src/adapters/terminal-logger/terminal-logger.ts +10 -4
  269. package/src/api/document-refs.ts +29 -1
  270. package/src/api/document-run.ts +6 -16
  271. package/src/api/openapi-ts.ts +6 -3
  272. package/src/api/ref-limit-options.ts +76 -0
  273. package/src/api/transform-schema.ts +20 -5
  274. package/src/application/ports/file-system.ts +8 -0
  275. package/src/application/transform/declared-value-types.ts +42 -0
  276. package/src/application/transform/document/document.ts +4 -2
  277. package/src/application/transform/document/exploded-query-values.ts +88 -0
  278. package/src/application/transform/document/header.ts +25 -5
  279. package/src/application/transform/document/parameter.ts +4 -4
  280. package/src/application/transform/document/parameters.ts +45 -10
  281. package/src/application/transform/document/path-item.ts +3 -3
  282. package/src/application/transform/document/path-template-key.ts +152 -0
  283. package/src/application/transform/document/path-template-refs.ts +106 -0
  284. package/src/application/transform/document/paths-enum.ts +23 -9
  285. package/src/application/transform/document/paths.ts +53 -123
  286. package/src/application/transform/document/webhooks.ts +18 -5
  287. package/src/application/transform/footer/document-footer.ts +18 -8
  288. package/src/application/transform/helper-types.ts +4 -4
  289. package/src/application/transform/ref-pointer/generated-location.ts +1 -1
  290. package/src/application/transform/ref-pointer/generated-shape.ts +67 -78
  291. package/src/application/transform/ref-pointer/inline-cycles.ts +1 -1
  292. package/src/application/transform/ref-pointer/located-node.ts +38 -0
  293. package/src/application/transform/ref-pointer/original-index.ts +100 -17
  294. package/src/application/transform/ref-pointer/pointer-type.ts +1 -1
  295. package/src/application/transform/ref-pointer/pointer-walk.ts +82 -8
  296. package/src/application/transform/ref-pointer/property-shape.ts +97 -0
  297. package/src/application/transform/ref-pointer/typed-walk.ts +117 -25
  298. package/src/application/transform/schema/access-flags.ts +5 -2
  299. package/src/application/transform/schema/index-signature-type.ts +31 -0
  300. package/src/application/transform/schema/input-location.ts +35 -0
  301. package/src/application/transform/schema/object-type.ts +18 -8
  302. package/src/application/transform/schema/schema-transform.ts +2 -1
  303. package/src/application/transform/schema/unevaluated-properties.ts +4 -44
  304. package/src/cli/api-logger.ts +17 -0
  305. package/src/cli/api-settings.ts +12 -20
  306. package/src/cli/cli-arguments.ts +90 -14
  307. package/src/cli/cli-dependencies.ts +7 -2
  308. package/src/cli/cli-errors.ts +22 -0
  309. package/src/cli/cli-output.ts +11 -10
  310. package/src/cli/main.ts +10 -4
  311. package/src/cli/redocly-apis.ts +37 -17
  312. package/src/cli/ref-limits.ts +21 -2
  313. package/src/cli/run-cli.ts +39 -7
  314. package/src/domain/cause-secrets.ts +59 -25
  315. package/src/domain/errors.ts +2 -0
  316. package/src/domain/location-text.ts +12 -0
  317. package/src/domain/openapi/document-places.ts +78 -0
  318. package/src/domain/output-fixes.ts +9 -2
  319. package/src/domain/terminal-text.ts +44 -0
  320. package/src/domain/warnings.ts +1 -0
@@ -8,9 +8,11 @@ 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
68
  const path = appendPointer(request.location.path, [key]);
64
- const type = facts.ref ? schemaRefType(facts.ref, request) : request.transformNested(value, { ...request.location, path });
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
  }
@@ -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 { 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 { 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 = appendPointer(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, 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 // 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,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AA,CAAoB,WAAW,OAAO,CAAC,CAAC,CAAA,GAAI,IAAA;AAAA,EAC3E;AACA,EAAA,MAAM,OAAA,GAAU,+BAAA,CAAgC,MAAA,EAAQ,OAAO,CAAA;AAE/D,EAAA,IACE,OAAA,IAAW,MAAA,IACX,OAAO,MAAA,CAAO,KAAA,KAAU,QAAA,IACxB,MAAA,CAAO,IAAA,CAAK,MAAA,CAAO,KAAK,CAAA,CAAE,MAAA,GAAS,CAAA,EACnC;AACA,IAAA,OAAA,CAAQ,IAAA,CAAK,UAAA,CAAW,MAAA,CAAO,KAAA,EAAO,OAAO,CAAC,CAAA;AAAA,EAChD;AACA,EAAA,MAAM,UAAA,GAAa,eAAA,CAAgB,MAAA,EAAQ,OAAO,CAAA;AAClD,EAAA,IAAI,UAAA,CAAW,WAAW,CAAA,EAAG;AAC3B,IAAA,OAAO,OAAA,CAAQ,MAAA,GAAS,CAAA,GAAI,QAAA,CAAS,OAAO,CAAA,GAAI,IAAA;AAAA,EAClD;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;AA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null (JSON Schema §6.1.3); the original read it as no `const`.
32
+ matches: (schema) => schema.const !== void 0,
32
33
  transform: (schema) => literalType.literalType(schema.const)
33
34
  },
34
35
  enumRule.enumRule
@@ -1 +1 @@
1
- {"version":3,"file":"schema-transform.cjs","sources":["../../../../src/application/transform/schema/schema-transform.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../../../domain/errors.js\";\nimport { irKeyword } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { literalType } from \"../literal-type.js\";\nimport { schemaRefType } from \"../ref-pointer/pointer-type.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { compositionType } from \"./composition-type.js\";\nimport { enumRule } from \"./enum-rule.js\";\nimport { refWithSiblingsAsAllOf } from \"./ref-siblings.js\";\nimport type { SchemaContext, SchemaLocation } from \"./schema-context.js\";\nimport type { SchemaRequest, SchemaRule } from \"./schema-rule.js\";\n\nexport class InvalidSchemaError extends OpenAPITypesafeError {\n constructor(schema: unknown, path: string | undefined) {\n const received = Array.isArray(schema) ? \"Array\" : typeof schema;\n super({\n code: ERROR_CODES.SCHEMA_OBJECT_INVALID,\n message: `Expected SchemaObject, received ${received} at ${path}`,\n details: { path, received },\n });\n this.name = \"InvalidSchemaError\";\n }\n}\n\n/** Shape rules in the original precedence; composition handles everything they do not match. */\nconst SHAPE_RULES: readonly SchemaRule[] = [\n {\n name: \"$ref\",\n matches: (schema) => \"$ref\" in schema,\n transform: (schema, request) => schemaRefType((schema as { $ref: string }).$ref, request),\n },\n {\n name: \"const\",\n matches: (schema) => schema.const !== null && schema.const !== undefined,\n transform: (schema) => literalType(schema.const),\n },\n enumRule,\n];\n\n/** A schema checked for its input shape, or the type of a non-object schema. */\ntype CheckedSchema = { readonly type: IrType } | { readonly schema: SchemaObject };\n\n/** A missing schema is `never`; `true` allows anything; other non-objects are invalid. */\nfunction checkSchema(schema: unknown, path: string | undefined): CheckedSchema {\n if (!schema) {\n return { type: irKeyword(\"never\") };\n }\n if (schema === true) {\n return { type: UNKNOWN_TYPE };\n }\n if (Array.isArray(schema) || typeof schema !== \"object\") {\n throw new InvalidSchemaError(schema, path);\n }\n return { schema: schema as SchemaObject };\n}\n\nfunction request(\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties: boolean,\n): SchemaRequest {\n return {\n location,\n context,\n isFromAdditionalProperties,\n transformNested: (schema, nestedLocation, isNestedFromAdditionalProperties = false) =>\n transformSchema(schema, nestedLocation, context, isNestedFromAdditionalProperties),\n };\n}\n\n/**\n * Transform a schema without the `postTransform` callback (the original\n * `transformSchemaObjectWithComposition`). Nested schemas still get `postTransform`.\n */\nexport function transformSchemaShape(\n schema: Schema | null | undefined,\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties = false,\n): IrType {\n const checked = checkSchema(schema, location.path);\n if (\"type\" in checked) {\n return checked.type;\n }\n const current = request(location, context, isFromAdditionalProperties);\n const shaped = refWithSiblingsAsAllOf(checked.schema, context.options) ?? checked.schema;\n const rule = SHAPE_RULES.find((candidate) => candidate.matches(shaped));\n return rule ? rule.transform(shaped, current) : compositionType(shaped, current);\n}\n\n/** Transform a schema to IR, then apply `postTransform` (the original `transformSchemaObject`). */\nexport function transformSchema(\n schema: Schema | null | undefined,\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties = false,\n): IrType {\n const type = transformSchemaShape(schema, location, context, isFromAdditionalProperties);\n return context.callbacks.postTransform(type, location) ?? type;\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES","request","schemaRefType","literalType","enumRule","irKeyword","UNKNOWN_TYPE","refWithSiblingsAsAllOf","compositionType"],"mappings":";;;;;;;;;;;AAaO,MAAM,2BAA2BA,2BAAA,CAAqB;AAAA,EAC3D,WAAA,CAAY,QAAiB,IAAA,EAA0B;AACrD,IAAA,MAAM,WAAW,KAAA,CAAM,OAAA,CA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":["../../../../src/application/transform/schema/schema-transform.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../../../domain/errors.js\";\nimport { irKeyword } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { literalType } from \"../literal-type.js\";\nimport { schemaRefType } from \"../ref-pointer/pointer-type.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { compositionType } from \"./composition-type.js\";\nimport { enumRule } from \"./enum-rule.js\";\nimport { refWithSiblingsAsAllOf } from \"./ref-siblings.js\";\nimport type { SchemaContext, SchemaLocation } from \"./schema-context.js\";\nimport type { SchemaRequest, SchemaRule } from \"./schema-rule.js\";\n\nexport class InvalidSchemaError extends OpenAPITypesafeError {\n constructor(schema: unknown, path: string | undefined) {\n const received = Array.isArray(schema) ? \"Array\" : typeof schema;\n super({\n code: ERROR_CODES.SCHEMA_OBJECT_INVALID,\n message: `Expected SchemaObject, received ${received} at ${path}`,\n details: { path, received },\n });\n this.name = \"InvalidSchemaError\";\n }\n}\n\n/** Shape rules in the original precedence; composition handles everything they do not match. */\nconst SHAPE_RULES: readonly SchemaRule[] = [\n {\n name: \"$ref\",\n matches: (schema) => \"$ref\" in schema,\n transform: (schema, request) => schemaRefType((schema as { $ref: string }).$ref, request),\n },\n {\n name: \"const\",\n // `const: null` is the value null (JSON Schema §6.1.3); the original read it as no `const`.\n matches: (schema) => schema.const !== undefined,\n transform: (schema) => literalType(schema.const),\n },\n enumRule,\n];\n\n/** A schema checked for its input shape, or the type of a non-object schema. */\ntype CheckedSchema = { readonly type: IrType } | { readonly schema: SchemaObject };\n\n/** A missing schema is `never`; `true` allows anything; other non-objects are invalid. */\nfunction checkSchema(schema: unknown, path: string | undefined): CheckedSchema {\n if (!schema) {\n return { type: irKeyword(\"never\") };\n }\n if (schema === true) {\n return { type: UNKNOWN_TYPE };\n }\n if (Array.isArray(schema) || typeof schema !== \"object\") {\n throw new InvalidSchemaError(schema, path);\n }\n return { schema: schema as SchemaObject };\n}\n\nfunction request(\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties: boolean,\n): SchemaRequest {\n return {\n location,\n context,\n isFromAdditionalProperties,\n transformNested: (schema, nestedLocation, isNestedFromAdditionalProperties = false) =>\n transformSchema(schema, nestedLocation, context, isNestedFromAdditionalProperties),\n };\n}\n\n/**\n * Transform a schema without the `postTransform` callback (the original\n * `transformSchemaObjectWithComposition`). Nested schemas still get `postTransform`.\n */\nexport function transformSchemaShape(\n schema: Schema | null | undefined,\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties = false,\n): IrType {\n const checked = checkSchema(schema, location.path);\n if (\"type\" in checked) {\n return checked.type;\n }\n const current = request(location, context, isFromAdditionalProperties);\n const shaped = refWithSiblingsAsAllOf(checked.schema, context.options) ?? checked.schema;\n const rule = SHAPE_RULES.find((candidate) => candidate.matches(shaped));\n return rule ? rule.transform(shaped, current) : compositionType(shaped, current);\n}\n\n/** Transform a schema to IR, then apply `postTransform` (the original `transformSchemaObject`). */\nexport function transformSchema(\n schema: Schema | null | undefined,\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties = false,\n): IrType {\n const type = transformSchemaShape(schema, location, context, isFromAdditionalProperties);\n return context.callbacks.postTransform(type, location) ?? type;\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES","request","schemaRefType","literalType","enumRule","irKeyword","UNKNOWN_TYPE","refWithSiblingsAsAllOf","compositionType"],"mappings":";;;;;;;;;;;AAaO,MAAM,2BAA2BA,2BAAA,CAAqB;AAAA,EAC3D,WAAA,CAAY,QAAiB,IAAA,EAA0B;AACrD,IAAA,MAAM,WAAW,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,GAAI,UAAU,OAAO,MAAA;AAC1D,IAAA,KAAA,CAAM;AAAA,MACJ,MAAMC,kBAAA,CAAY,qBAAA;AAAA,MAClB,OAAA,EAAS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EAAiB,CAAC,MAAA,EAAQ,cAAA,EAAgB,gCAAA,GAAmC,UAC3E,eAAA,CAAgB,MAAA,EAAQ,cAAA,EAAgB,OAAA,EAAS,gCAAgC;AAAA,GACrF;AACF;AAMO,SAAS,oBAAA,CACd,MAAA,EACA,QAAA,EACA,OAAA,EACA,6BAA6B,KAAA,EACrB;AACR,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,MAAA,EAAQ,QAAA,CAAS,IAAI,CAAA;AACjD,EAAA,IAAI,UAAU,OAAA,EAAS;AACrB,IAAA,OAAO,OAAA,CAAQ,IAAA;AAAA,EACjB;AACA,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,QAAA,EAAU,OAAA,EAAS,0BAA0B,CAAA;AACrE,EAAA,MAAM,SAASC,kCAAA,CAAuB,OAAA,CAAQ,QAAQ,OAAA,CAAQ,OAAO,KAAK,OAAA,CAAQ,MAAA;AAClF,EAAA,MAAM,IAAA,GAAO,YAAY,IAAA,CAAK,CAAC,cAAc,SAAA,CAAU,OAAA,CAAQ,MAAM,CAAC,CAAA;AACtE,EAAA,OAAO,IAAA,GAAO,KAAK,SAAA,CAAU,MAAA,EAAQ,OAAO,CAAA,GAAIC,+BAAA,CAAgB,QAAQ,OAAO,CAAA;AACjF;AAGO,SAAS,eAAA,CACd,MAAA,EACA,QAAA,EACA,OAAA,EACA,6BAA6B,KAAA,EACrB;AACR,EAAA,MAAM,IAAA,GAAO,oBAAA,CAAqB,MAAA,EAAQ,QAAA,EAAU,SAAS,0BAA0B,CAAA;AACvF,EAAA,OAAO,OAAA,CAAQ,SAAA,CAAU,aAAA,CAAc,IAAA,EAAM,QAAQ,CAAA,IAAK,IAAA;AAC5D;;;;"}
@@ -26,7 +26,8 @@ const SHAPE_RULES = [
26
26
  },
27
27
  {
28
28
  name: "const",
29
- matches: (schema) => schema.const !== null && schema.const !== void 0,
29
+ // `const: null` is the value null (JSON Schema §6.1.3); the original read it as no `const`.
30
+ matches: (schema) => schema.const !== void 0,
30
31
  transform: (schema) => literalType(schema.const)
31
32
  },
32
33
  enumRule
@@ -1 +1 @@
1
- {"version":3,"file":"schema-transform.mjs","sources":["../../../../src/application/transform/schema/schema-transform.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../../../domain/errors.js\";\nimport { irKeyword } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { literalType } from \"../literal-type.js\";\nimport { schemaRefType } from \"../ref-pointer/pointer-type.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { compositionType } from \"./composition-type.js\";\nimport { enumRule } from \"./enum-rule.js\";\nimport { refWithSiblingsAsAllOf } from \"./ref-siblings.js\";\nimport type { SchemaContext, SchemaLocation } from \"./schema-context.js\";\nimport type { SchemaRequest, SchemaRule } from \"./schema-rule.js\";\n\nexport class InvalidSchemaError extends OpenAPITypesafeError {\n constructor(schema: unknown, path: string | undefined) {\n const received = Array.isArray(schema) ? \"Array\" : typeof schema;\n super({\n code: ERROR_CODES.SCHEMA_OBJECT_INVALID,\n message: `Expected SchemaObject, received ${received} at ${path}`,\n details: { path, received },\n });\n this.name = \"InvalidSchemaError\";\n }\n}\n\n/** Shape rules in the original precedence; composition handles everything they do not match. */\nconst SHAPE_RULES: readonly SchemaRule[] = [\n {\n name: \"$ref\",\n matches: (schema) => \"$ref\" in schema,\n transform: (schema, request) => schemaRefType((schema as { $ref: string }).$ref, request),\n },\n {\n name: \"const\",\n matches: (schema) => schema.const !== null && schema.const !== undefined,\n transform: (schema) => literalType(schema.const),\n },\n enumRule,\n];\n\n/** A schema checked for its input shape, or the type of a non-object schema. */\ntype CheckedSchema = { readonly type: IrType } | { readonly schema: SchemaObject };\n\n/** A missing schema is `never`; `true` allows anything; other non-objects are invalid. */\nfunction checkSchema(schema: unknown, path: string | undefined): CheckedSchema {\n if (!schema) {\n return { type: irKeyword(\"never\") };\n }\n if (schema === true) {\n return { type: UNKNOWN_TYPE };\n }\n if (Array.isArray(schema) || typeof schema !== \"object\") {\n throw new InvalidSchemaError(schema, path);\n }\n return { schema: schema as SchemaObject };\n}\n\nfunction request(\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties: boolean,\n): SchemaRequest {\n return {\n location,\n context,\n isFromAdditionalProperties,\n transformNested: (schema, nestedLocation, isNestedFromAdditionalProperties = false) =>\n transformSchema(schema, nestedLocation, context, isNestedFromAdditionalProperties),\n };\n}\n\n/**\n * Transform a schema without the `postTransform` callback (the original\n * `transformSchemaObjectWithComposition`). Nested schemas still get `postTransform`.\n */\nexport function transformSchemaShape(\n schema: Schema | null | undefined,\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties = false,\n): IrType {\n const checked = checkSchema(schema, location.path);\n if (\"type\" in checked) {\n return checked.type;\n }\n const current = request(location, context, isFromAdditionalProperties);\n const shaped = refWithSiblingsAsAllOf(checked.schema, context.options) ?? checked.schema;\n const rule = SHAPE_RULES.find((candidate) => candidate.matches(shaped));\n return rule ? rule.transform(shaped, current) : compositionType(shaped, current);\n}\n\n/** Transform a schema to IR, then apply `postTransform` (the original `transformSchemaObject`). */\nexport function transformSchema(\n schema: Schema | null | undefined,\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties = false,\n): IrType {\n const type = transformSchemaShape(schema, location, context, isFromAdditionalProperties);\n return context.callbacks.postTransform(type, location) ?? type;\n}\n"],"names":["request"],"mappings":";;;;;;;;;AAaO,MAAM,2BAA2B,oBAAA,CAAqB;AAAA,EAC3D,WAAA,CAAY,QAAiB,IAAA,EAA0B;AACrD,IAAA,MAAM,WAAW,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,GAAI,UAAU,OAAO,MAAA;AAC1D,IAAA,KAAA,CAAM;AAAA,MACJ,MAAM,WAAA,CAAY,qBAAA;AAAA,MAClB,OAAA,EAAS,CAAA,gCAAA,EAAmC,QAAQ,CAAA,I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AAgB,gCAAA,GAAmC,UAC3E,eAAA,CAAgB,MAAA,EAAQ,cAAA,EAAgB,OAAA,EAAS,gCAAgC;AAAA,GACrF;AACF;AAMO,SAAS,oBAAA,CACd,MAAA,EACA,QAAA,EACA,OAAA,EACA,6BAA6B,KAAA,EACrB;AACR,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,MAAA,EAAQ,QAAA,CAAS,IAAI,CAAA;AACjD,EAAA,IAAI,UAAU,OAAA,EAAS;AACrB,IAAA,OAAO,OAAA,CAAQ,IAAA;AAAA,EACjB;AACA,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,QAAA,EAAU,OAAA,EAAS,0BAA0B,CAAA;AACrE,EAAA,MAAM,SAAS,sBAAA,CAAuB,OAAA,CAAQ,QAAQ,OAAA,CAAQ,OAAO,KAAK,OAAA,CAAQ,MAAA;AAClF,EAAA,MAAM,IAAA,GAAO,YAAY,IAAA,CAAK,CAAC,cAAc,SAAA,CAAU,OAAA,CAAQ,MAAM,CAAC,CAAA;AACtE,EAAA,OAAO,IAAA,GAAO,KAAK,SAAA,CAAU,MAAA,EAAQ,OAAO,CAAA,GAAI,eAAA,CAAgB,QAAQ,OAAO,CAAA;AACjF;AAGO,SAAS,eAAA,CACd,MAAA,EACA,QAAA,EACA,OAAA,EACA,6BAA6B,KAAA,EACrB;AACR,EAAA,MAAM,IAAA,GAAO,oBAAA,CAAqB,MAAA,EAAQ,QAAA,EAAU,SAAS,0BAA0B,CAAA;AACvF,EAAA,OAAO,OAAA,CAAQ,SAAA,CAAU,aAAA,CAAc,IAAA,EAAM,QAAQ,CAAA,IAAK,IAAA;AAC5D;;"}
1
+ {"version":3,"file":"schema-transform.mjs","sources":["../../../../src/application/transform/schema/schema-transform.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../../../domain/errors.js\";\nimport { irKeyword } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { literalType } from \"../literal-type.js\";\nimport { schemaRefType } from \"../ref-pointer/pointer-type.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { compositionType } from \"./composition-type.js\";\nimport { enumRule } from \"./enum-rule.js\";\nimport { refWithSiblingsAsAllOf } from \"./ref-siblings.js\";\nimport type { SchemaContext, SchemaLocation } from \"./schema-context.js\";\nimport type { SchemaRequest, SchemaRule } from \"./schema-rule.js\";\n\nexport class InvalidSchemaError extends OpenAPITypesafeError {\n constructor(schema: unknown, path: string | undefined) {\n const received = Array.isArray(schema) ? \"Array\" : typeof schema;\n super({\n code: ERROR_CODES.SCHEMA_OBJECT_INVALID,\n message: `Expected SchemaObject, received ${received} at ${path}`,\n details: { path, received },\n });\n this.name = \"InvalidSchemaError\";\n }\n}\n\n/** Shape rules in the original precedence; composition handles everything they do not match. */\nconst SHAPE_RULES: readonly SchemaRule[] = [\n {\n name: \"$ref\",\n matches: (schema) => \"$ref\" in schema,\n transform: (schema, request) => schemaRefType((schema as { $ref: string }).$ref, request),\n },\n {\n name: \"const\",\n // `const: null` is the value null (JSON Schema §6.1.3); the original read it as no `const`.\n matches: (schema) => schema.const !== undefined,\n transform: (schema) => literalType(schema.const),\n },\n enumRule,\n];\n\n/** A schema checked for its input shape, or the type of a non-object schema. */\ntype CheckedSchema = { readonly type: IrType } | { readonly schema: SchemaObject };\n\n/** A missing schema is `never`; `true` allows anything; other non-objects are invalid. */\nfunction checkSchema(schema: unknown, path: string | undefined): CheckedSchema {\n if (!schema) {\n return { type: irKeyword(\"never\") };\n }\n if (schema === true) {\n return { type: UNKNOWN_TYPE };\n }\n if (Array.isArray(schema) || typeof schema !== \"object\") {\n throw new InvalidSchemaError(schema, path);\n }\n return { schema: schema as SchemaObject };\n}\n\nfunction request(\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties: boolean,\n): SchemaRequest {\n return {\n location,\n context,\n isFromAdditionalProperties,\n transformNested: (schema, nestedLocation, isNestedFromAdditionalProperties = false) =>\n transformSchema(schema, nestedLocation, context, isNestedFromAdditionalProperties),\n };\n}\n\n/**\n * Transform a schema without the `postTransform` callback (the original\n * `transformSchemaObjectWithComposition`). Nested schemas still get `postTransform`.\n */\nexport function transformSchemaShape(\n schema: Schema | null | undefined,\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties = false,\n): IrType {\n const checked = checkSchema(schema, location.path);\n if (\"type\" in checked) {\n return checked.type;\n }\n const current = request(location, context, isFromAdditionalProperties);\n const shaped = refWithSiblingsAsAllOf(checked.schema, context.options) ?? checked.schema;\n const rule = SHAPE_RULES.find((candidate) => candidate.matches(shaped));\n return rule ? rule.transform(shaped, current) : compositionType(shaped, current);\n}\n\n/** Transform a schema to IR, then apply `postTransform` (the original `transformSchemaObject`). */\nexport function transformSchema(\n schema: Schema | null | undefined,\n location: SchemaLocation,\n context: SchemaContext,\n isFromAdditionalProperties = false,\n): IrType {\n const type = transformSchemaShape(schema, location, context, isFromAdditionalProperties);\n return context.callbacks.postTransform(type, location) ?? type;\n}\n"],"names":["request"],"mappings":";;;;;;;;;AAaO,MAAM,2BAA2B,oBAAA,CAAqB;AAAA,EAC3D,WAAA,CAAY,QAAiB,IAAA,EAA0B;AACrD,IAAA,MAAM,WAAW,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,GAAI,UAAU,OAAO,MAAA;AAC1D,IAAA,KAAA,CAAM;AAAA,MACJ,MAAM,WAAA,CAAY,qBAAA;AAAA,MAClB,OAAA,EAAS,CAAA,gCAAA,EAAmC,QAAQ,CAAA,IAAA,EAAO,IAAI,CAAA,CAAA;AAAA,MAC/D,OAAA,EAAS,EAAE,IAAA,EAAM,QAAA;AAAS,KAC3B,CAAA;AACD,IAAA,IAAA,CAAK,IAAA,GAAO,oBAAA;AAAA,EACd;AACF;AAGA,MAAM,WAAA,GAAqC;AAAA,EACzC;AAAA,IACE,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAA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AAA;AACjD,EAAA,IAAI,UAAU,OAAA,EAAS;AACrB,IAAA,OAAO,OAAA,CAAQ,IAAA;AAAA,EACjB;AACA,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,QAAA,EAAU,OAAA,EAAS,0BAA0B,CAAA;AACrE,EAAA,MAAM,SAAS,sBAAA,CAAuB,OAAA,CAAQ,QAAQ,OAAA,CAAQ,OAAO,KAAK,OAAA,CAAQ,MAAA;AAClF,EAAA,MAAM,IAAA,GAAO,YAAY,IAAA,CAAK,CAAC,cAAc,SAAA,CAAU,OAAA,CAAQ,MAAM,CAAC,CAAA;AACtE,EAAA,OAAO,IAAA,GAAO,KAAK,SAAA,CAAU,MAAA,EAAQ,OAAO,CAAA,GAAI,eAAA,CAAgB,QAAQ,OAAO,CAAA;AACjF;AAGO,SAAS,eAAA,CACd,MAAA,EACA,QAAA,EACA,OAAA,EACA,6BAA6B,KAAA,EACrB;AACR,EAAA,MAAM,IAAA,GAAO,oBAAA,CAAqB,MAAA,EAAQ,QAAA,EAAU,SAAS,0BAA0B,CAAA;AACvF,EAAA,OAAO,OAAA,CAAQ,SAAA,CAAU,aAAA,CAAc,IAAA,EAAM,QAAQ,CAAA,IAAK,IAAA;AAC5D;;"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  const constructors = require('../../../domain/ir/constructors.cjs');
4
4
  const outputFixes = require('../../../domain/output-fixes.cjs');
5
- const helperTypes = require('../helper-types.cjs');
5
+ const declaredValueTypes = require('../declared-value-types.cjs');
6
6
  const sharedTypes = require('../shared-types.cjs');
7
7
  const typeCombinators = require('../type-combinators.cjs');
8
8
 
@@ -16,34 +16,6 @@ function unevaluatedSchemaOf(schema, request) {
16
16
  function isAnySchema(schema) {
17
17
  return schema === true || typeof schema === "object" && Object.keys(schema).length === 0;
18
18
  }
19
- function memberValueTypes(member) {
20
- if (member.kind === "indexSignature") {
21
- return [member.type];
22
- }
23
- return member.isOptional ? [member.type, constructors.irKeyword("undefined")] : [member.type];
24
- }
25
- function declaredValueTypes(type, request) {
26
- switch (type.kind) {
27
- case "object":
28
- return type.members.flatMap(memberValueTypes);
29
- case "union":
30
- case "intersection":
31
- return type.types.flatMap((member) => declaredValueTypes(member, request));
32
- case "reference":
33
- case "indexedAccess":
34
- case "raw":
35
- request.context.footer.requirePropertyValues();
36
- return [constructors.irReference(helperTypes.HELPER_TYPES.propertyValues.name, [type])];
37
- case "keyword":
38
- case "stringLiteral":
39
- case "numberLiteral":
40
- case "booleanLiteral":
41
- case "array":
42
- case "tuple":
43
- case "readonly":
44
- return [];
45
- }
46
- }
47
19
  function unevaluatedPropertiesType(schema, composed, request) {
48
20
  const unevaluated = unevaluatedSchemaOf(schema, request);
49
21
  if (unevaluated === null) {
@@ -51,7 +23,7 @@ function unevaluatedPropertiesType(schema, composed, request) {
51
23
  }
52
24
  const valueTypes = isAnySchema(unevaluated) ? [sharedTypes.UNKNOWN_TYPE] : [
53
25
  request.transformNested(unevaluated, request.location, true),
54
- ...composed === null ? [] : declaredValueTypes(composed, request)
26
+ ...composed === null ? [] : declaredValueTypes.declaredValueTypes(composed, request.context.footer)
55
27
  ];
56
28
  const { immutable } = request.context.options;
57
29
  return constructors.irObject([constructors.irStringIndexSignature("key", typeCombinators.unionOf(valueTypes), immutable)]);
@@ -1 +1 @@
1
- {"version":3,"file":"unevaluated-properties.cjs","sources":["../../../../src/application/transform/schema/unevaluated-properties.ts"],"sourcesContent":["import {\n irKeyword,\n irObject,\n irReference,\n irStringIndexSignature,\n} from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrType } from \"../../../domain/ir/nodes.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport { HELPER_TYPES } from \"../helper-types.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { unionOf } from \"../type-combinators.js\";\nimport type { SchemaRequest } from \"./schema-rule.js\";\n\n/**\n * The `unevaluated-properties` fix (ADR-021, roadmap R11; upstream #2839, #2880). Without it\n * `unevaluatedProperties` is ignored, so its value type is lost and an object with only that\n * keyword is `Record<string, never>`. With it the composed type is intersected with an index\n * signature, as `additionalProperties` gives: every key that no other keyword declares has the\n * `unevaluatedProperties` type. TypeScript checks that index signature against every key of a\n * value, declared ones included, so its type also holds the types of the declared properties\n * (of this schema and of its `allOf`, `anyOf` and `oneOf` members); otherwise a valid value would\n * not be assignable. `false` adds nothing, like `additionalProperties: false`: TypeScript has no\n * closed object type.\n */\n\n/**\n * Whether `unevaluatedProperties` applies. It types the keys left over at this level, so it\n * does nothing next to `additionalProperties` (which already types them all), and only an object\n * schema has keys. A `type` list is typed one listed type at a time, so its object gets it.\n */\nfunction unevaluatedSchemaOf(schema: SchemaObject, request: SchemaRequest): Schema | null {\n const { unevaluatedProperties } = schema;\n if (\n !request.context.options.fixes.has(FIX.UNEVALUATED_PROPERTIES) ||\n unevaluatedProperties === undefined ||\n unevaluatedProperties === false ||\n schema.additionalProperties !== undefined\n ) {\n return null;\n }\n return schema.type === undefined || schema.type === \"object\" ? unevaluatedProperties : null;\n}\n\nfunction isAnySchema(schema: Schema): boolean {\n return schema === true || (typeof schema === \"object\" && Object.keys(schema).length === 0);\n}\n\nfunction memberValueTypes(member: IrMember): IrType[] {\n if (member.kind === \"indexSignature\") {\n return [member.type];\n }\n return member.isOptional ? [member.type, irKeyword(\"undefined\")] : [member.type];\n}\n\n/**\n * The value types a key of the composed type can have, read from its IR: the members of object\n * types, through unions and intersections. A reference (a `$ref`, `Omit`, `WithRequired`) or a raw\n * type is read with `PropertyValues`. Primitives, literals and arrays declare no keys.\n */\nfunction declaredValueTypes(type: IrType, request: SchemaRequest): IrType[] {\n switch (type.kind) {\n case \"object\":\n return type.members.flatMap(memberValueTypes);\n case \"union\":\n case \"intersection\":\n return type.types.flatMap((member) => declaredValueTypes(member, request));\n case \"reference\":\n case \"indexedAccess\":\n case \"raw\":\n request.context.footer.requirePropertyValues();\n return [irReference(HELPER_TYPES.propertyValues.name, [type])];\n case \"keyword\":\n case \"stringLiteral\":\n case \"numberLiteral\":\n case \"booleanLiteral\":\n case \"array\":\n case \"tuple\":\n case \"readonly\":\n return [];\n }\n}\n\n/**\n * The index signature object for `unevaluatedProperties`, given the composed type of the other\n * keywords (null when there is none). Null when the fix is off or the keyword does not apply.\n */\nexport function unevaluatedPropertiesType(\n schema: SchemaObject,\n composed: IrType | null,\n request: SchemaRequest,\n): IrType | null {\n const unevaluated = unevaluatedSchemaOf(schema, request);\n if (unevaluated === null) {\n return null;\n }\n const valueTypes = isAnySchema(unevaluated)\n ? [UNKNOWN_TYPE]\n : [\n request.transformNested(unevaluated, request.location, true),\n ...(composed === null ? [] : declaredValueTypes(composed, request)),\n ];\n const { immutable } = request.context.options;\n return irObject([irStringIndexSignature(\"key\", unionOf(valueTypes), immutable)]);\n}\n"],"names":["FIX","irKeyword","irReference","HELPER_TYPES","UNKNOWN_TYPE","irObject","irStringIndexSignature","unionOf"],"mappings":";;;;;;;;AA+BA,SAAS,mBAAA,CAAoB,QAAsB,OAAA,EAAuC;AACxF,EAAA,MAAM,EAAE,uBAAsB,GAAI,MAAA;AAClC,EAAA,IACE,CAAC,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,MAAM,GAAA,CAAIA,eAAA,CAAI,sBAAsB,CAAA,IAC7D,0BAA0B,MAAA,IAC1B,qBAAA,KAA0B,KAAA,IAC1B,MAAA,CAAO,yBAAyB,MAAA,EAChC;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,OAAO,IAAA,KAAS,MAAA,IAAa,MAAA,CAAO,IAAA,KAAS,WAAW,qBAAA,GAAwB,IAAA;AACzF;AAEA,SAAS,YAAY,MAAA,EAAyB;AAC5C,EAAA,OAAO,MAAA,KAAW,QAAS,OAAO,MAAA,KAAW,YAAY,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAAE,MAAA,KAAW,CAAA;AAC1F;AAEA,SAAS,iBAAiB,MAAA,EAA4B;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WAAW,CAAA,GACtC,CAACC,wBAAY,CAAA,GACb;AAAA,IACE,OAAA,CAAQ,eAAA,CAAgB,WAAA,EAAa,OAAA,CAAQ,UAAU,IAAI,CAAA;AAAA,IAC3D,GAAI,QAAA,KAAa,IAAA,GAAO,EAAC,GAAI,kBAAA,CAAmB,UAAU,OAAO;AAAA,GACnE;AACJ,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,OAAA,CAAQ,OAAA,CAAQ,OAAA;AACtC,EAAA,OAAOC,qBAAA,CAAS,CAACC,mCAAA,CAAuB,KAAA,EAAOC,wBAAQ,UAAU,CAAA,EAAG,SAAS,CAAC,CAAC,CAAA;AACjF;;"}
1
+ {"version":3,"file":"unevaluated-properties.cjs","sources":["../../../../src/application/transform/schema/unevaluated-properties.ts"],"sourcesContent":["import { irObject, irStringIndexSignature } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport { declaredValueTypes } from \"../declared-value-types.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { unionOf } from \"../type-combinators.js\";\nimport type { SchemaRequest } from \"./schema-rule.js\";\n\n/**\n * The `unevaluated-properties` fix (ADR-021, roadmap R11; upstream #2839, #2880). Without it\n * `unevaluatedProperties` is ignored, so its value type is lost and an object with only that\n * keyword is `Record<string, never>`. With it the composed type is intersected with an index\n * signature, as `additionalProperties` gives: every key that no other keyword declares has the\n * `unevaluatedProperties` type. TypeScript checks that index signature against every key of a\n * value, declared ones included, so its type also holds the types of the declared properties\n * (of this schema and of its `allOf`, `anyOf` and `oneOf` members); otherwise a valid value would\n * not be assignable. `false` adds nothing, like `additionalProperties: false`: TypeScript has no\n * closed object type.\n */\n\n/**\n * Whether `unevaluatedProperties` applies. It types the keys left over at this level, so it\n * does nothing next to `additionalProperties` (which already types them all), and only an object\n * schema has keys. A `type` list is typed one listed type at a time, so its object gets it.\n */\nfunction unevaluatedSchemaOf(schema: SchemaObject, request: SchemaRequest): Schema | null {\n const { unevaluatedProperties } = schema;\n if (\n !request.context.options.fixes.has(FIX.UNEVALUATED_PROPERTIES) ||\n unevaluatedProperties === undefined ||\n unevaluatedProperties === false ||\n schema.additionalProperties !== undefined\n ) {\n return null;\n }\n return schema.type === undefined || schema.type === \"object\" ? unevaluatedProperties : null;\n}\n\nfunction isAnySchema(schema: Schema): boolean {\n return schema === true || (typeof schema === \"object\" && Object.keys(schema).length === 0);\n}\n\n/**\n * The index signature object for `unevaluatedProperties`, given the composed type of the other\n * keywords (null when there is none). Null when the fix is off or the keyword does not apply.\n */\nexport function unevaluatedPropertiesType(\n schema: SchemaObject,\n composed: IrType | null,\n request: SchemaRequest,\n): IrType | null {\n const unevaluated = unevaluatedSchemaOf(schema, request);\n if (unevaluated === null) {\n return null;\n }\n const valueTypes = isAnySchema(unevaluated)\n ? [UNKNOWN_TYPE]\n : [\n request.transformNested(unevaluated, request.location, true),\n ...(composed === null ? [] : declaredValueTypes(composed, request.context.footer)),\n ];\n const { immutable } = request.context.options;\n return irObject([irStringIndexSignature(\"key\", unionOf(valueTypes), immutable)]);\n}\n"],"names":["FIX","UNKNOWN_TYPE","declaredValueTypes","irObject","irStringIndexSignature","unionOf"],"mappings":";;;;;;;;AA0BA,SAAS,mBAAA,CAAoB,QAAsB,OAAA,EAAuC;AACxF,EAAA,MAAM,EAAE,uBAAsB,GAAI,MAAA;AAClC,EAAA,IACE,CAAC,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,MAAM,GAAA,CAAIA,eAAA,CAAI,sBAAsB,CAAA,IAC7D,0BAA0B,MAAA,IAC1B,qBAAA,KAA0B,KAAA,IAC1B,MAAA,CAAO,yBAAyB,MAAA,EAChC;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,OAAO,IAAA,KAAS,MAAA,IAAa,MAAA,CAAO,IAAA,KAAS,WAAW,qBAAA,GAAwB,IAAA;AACzF;AAEA,SAAS,YAAY,MAAA,EAAyB;AAC5C,EAAA,OAAO,MAAA,KAAW,QAAS,OAAO,MAAA,KAAW,YAAY,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAAE,MAAA,KAAW,CAAA;AAC1F;AAMO,SAAS,yBAAA,CACd,MAAA,EACA,QAAA,EACA,OAAA,EACe;AACf,EAAA,MAAM,WAAA,GAAc,mBAAA,CAAoB,MAAA,EAAQ,OAAO,CAAA;AACvD,EAAA,IAAI,gBAAgB,IAAA,EAAM;AACxB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,aAAa,WAAA,CAAY,WAAW,CAAA,GACtC,CAACC,wBAAY,CAAA,GACb;AAAA,IACE,OAAA,CAAQ,eAAA,CAAgB,WAAA,EAAa,OAAA,CAAQ,UAAU,IAAI,CAAA;AAAA,IAC3D,GAAI,aAAa,IAAA,GAAO,KAAKC,qCAAA,CAAmB,QAAA,EAAU,OAAA,CAAQ,OAAA,CAAQ,MAAM;AAAA,GAClF;AACJ,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,OAAA,CAAQ,OAAA,CAAQ,OAAA;AACtC,EAAA,OAAOC,qBAAA,CAAS,CAACC,mCAAA,CAAuB,KAAA,EAAOC,wBAAQ,UAAU,CAAA,EAAG,SAAS,CAAC,CAAC,CAAA;AACjF;;"}
@@ -1,6 +1,6 @@
1
- import { irObject, irStringIndexSignature, irReference, irKeyword } from '../../../domain/ir/constructors.mjs';
1
+ import { irObject, irStringIndexSignature } from '../../../domain/ir/constructors.mjs';
2
2
  import { FIX } from '../../../domain/output-fixes.mjs';
3
- import { HELPER_TYPES } from '../helper-types.mjs';
3
+ import { declaredValueTypes } from '../declared-value-types.mjs';
4
4
  import { UNKNOWN_TYPE } from '../shared-types.mjs';
5
5
  import { unionOf } from '../type-combinators.mjs';
6
6
 
@@ -14,34 +14,6 @@ function unevaluatedSchemaOf(schema, request) {
14
14
  function isAnySchema(schema) {
15
15
  return schema === true || typeof schema === "object" && Object.keys(schema).length === 0;
16
16
  }
17
- function memberValueTypes(member) {
18
- if (member.kind === "indexSignature") {
19
- return [member.type];
20
- }
21
- return member.isOptional ? [member.type, irKeyword("undefined")] : [member.type];
22
- }
23
- function declaredValueTypes(type, request) {
24
- switch (type.kind) {
25
- case "object":
26
- return type.members.flatMap(memberValueTypes);
27
- case "union":
28
- case "intersection":
29
- return type.types.flatMap((member) => declaredValueTypes(member, request));
30
- case "reference":
31
- case "indexedAccess":
32
- case "raw":
33
- request.context.footer.requirePropertyValues();
34
- return [irReference(HELPER_TYPES.propertyValues.name, [type])];
35
- case "keyword":
36
- case "stringLiteral":
37
- case "numberLiteral":
38
- case "booleanLiteral":
39
- case "array":
40
- case "tuple":
41
- case "readonly":
42
- return [];
43
- }
44
- }
45
17
  function unevaluatedPropertiesType(schema, composed, request) {
46
18
  const unevaluated = unevaluatedSchemaOf(schema, request);
47
19
  if (unevaluated === null) {
@@ -49,7 +21,7 @@ function unevaluatedPropertiesType(schema, composed, request) {
49
21
  }
50
22
  const valueTypes = isAnySchema(unevaluated) ? [UNKNOWN_TYPE] : [
51
23
  request.transformNested(unevaluated, request.location, true),
52
- ...composed === null ? [] : declaredValueTypes(composed, request)
24
+ ...composed === null ? [] : declaredValueTypes(composed, request.context.footer)
53
25
  ];
54
26
  const { immutable } = request.context.options;
55
27
  return irObject([irStringIndexSignature("key", unionOf(valueTypes), immutable)]);
@@ -1 +1 @@
1
- {"version":3,"file":"unevaluated-properties.mjs","sources":["../../../../src/application/transform/schema/unevaluated-properties.ts"],"sourcesContent":["import {\n irKeyword,\n irObject,\n irReference,\n irStringIndexSignature,\n} from \"../../../domain/ir/constructors.js\";\nimport type { IrMember, IrType } from \"../../../domain/ir/nodes.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport { HELPER_TYPES } from \"../helper-types.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { unionOf } from \"../type-combinators.js\";\nimport type { SchemaRequest } from \"./schema-rule.js\";\n\n/**\n * The `unevaluated-properties` fix (ADR-021, roadmap R11; upstream #2839, #2880). Without it\n * `unevaluatedProperties` is ignored, so its value type is lost and an object with only that\n * keyword is `Record<string, never>`. With it the composed type is intersected with an index\n * signature, as `additionalProperties` gives: every key that no other keyword declares has the\n * `unevaluatedProperties` type. TypeScript checks that index signature against every key of a\n * value, declared ones included, so its type also holds the types of the declared properties\n * (of this schema and of its `allOf`, `anyOf` and `oneOf` members); otherwise a valid value would\n * not be assignable. `false` adds nothing, like `additionalProperties: false`: TypeScript has no\n * closed object type.\n */\n\n/**\n * Whether `unevaluatedProperties` applies. It types the keys left over at this level, so it\n * does nothing next to `additionalProperties` (which already types them all), and only an object\n * schema has keys. A `type` list is typed one listed type at a time, so its object gets it.\n */\nfunction unevaluatedSchemaOf(schema: SchemaObject, request: SchemaRequest): Schema | null {\n const { unevaluatedProperties } = schema;\n if (\n !request.context.options.fixes.has(FIX.UNEVALUATED_PROPERTIES) ||\n unevaluatedProperties === undefined ||\n unevaluatedProperties === false ||\n schema.additionalProperties !== undefined\n ) {\n return null;\n }\n return schema.type === undefined || schema.type === \"object\" ? unevaluatedProperties : null;\n}\n\nfunction isAnySchema(schema: Schema): boolean {\n return schema === true || (typeof schema === \"object\" && Object.keys(schema).length === 0);\n}\n\nfunction memberValueTypes(member: IrMember): IrType[] {\n if (member.kind === \"indexSignature\") {\n return [member.type];\n }\n return member.isOptional ? [member.type, irKeyword(\"undefined\")] : [member.type];\n}\n\n/**\n * The value types a key of the composed type can have, read from its IR: the members of object\n * types, through unions and intersections. A reference (a `$ref`, `Omit`, `WithRequired`) or a raw\n * type is read with `PropertyValues`. Primitives, literals and arrays declare no keys.\n */\nfunction declaredValueTypes(type: IrType, request: SchemaRequest): IrType[] {\n switch (type.kind) {\n case \"object\":\n return type.members.flatMap(memberValueTypes);\n case \"union\":\n case \"intersection\":\n return type.types.flatMap((member) => declaredValueTypes(member, request));\n case \"reference\":\n case \"indexedAccess\":\n case \"raw\":\n request.context.footer.requirePropertyValues();\n return [irReference(HELPER_TYPES.propertyValues.name, [type])];\n case \"keyword\":\n case \"stringLiteral\":\n case \"numberLiteral\":\n case \"booleanLiteral\":\n case \"array\":\n case \"tuple\":\n case \"readonly\":\n return [];\n }\n}\n\n/**\n * The index signature object for `unevaluatedProperties`, given the composed type of the other\n * keywords (null when there is none). Null when the fix is off or the keyword does not apply.\n */\nexport function unevaluatedPropertiesType(\n schema: SchemaObject,\n composed: IrType | null,\n request: SchemaRequest,\n): IrType | null {\n const unevaluated = unevaluatedSchemaOf(schema, request);\n if (unevaluated === null) {\n return null;\n }\n const valueTypes = isAnySchema(unevaluated)\n ? [UNKNOWN_TYPE]\n : [\n request.transformNested(unevaluated, request.location, true),\n ...(composed === null ? [] : declaredValueTypes(composed, request)),\n ];\n const { immutable } = request.context.options;\n return irObject([irStringIndexSignature(\"key\", unionOf(valueTypes), immutable)]);\n}\n"],"names":[],"mappings":";;;;;;AA+BA,SAAS,mBAAA,CAAoB,QAAsB,OAAA,EAAuC;AACxF,EAAA,MAAM,EAAE,uBAAsB,GAAI,MAAA;AAClC,EAAA,IACE,CAAC,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,MAAM,GAAA,CAAI,GAAA,CAAI,sBAAsB,CAAA,IAC7D,0BAA0B,MAAA,IAC1B,qBAAA,KAA0B,KAAA,IAC1B,MAAA,CAAO,yBAAyB,MAAA,EAChC;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,OAAO,IAAA,KAAS,MAAA,IAAa,MAAA,CAAO,IAAA,KAAS,WAAW,qBAAA,GAAwB,IAAA;AACzF;AAEA,SAAS,YAAY,MAAA,EAAyB;AAC5C,EAAA,OAAO,MAAA,KAAW,QAAS,OAAO,MAAA,KAAW,YAAY,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAAE,MAAA,KAAW,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,EACT;AACA,EAAA,MAAM,aAAa,WAAA,CAAY,WAAW,CAAA,GACtC,CAAC,YAAY,CAAA,GACb;AAAA,IACE,OAAA,CAAQ,eAAA,CAAgB,WAAA,EAAa,OAAA,CAAQ,UAAU,IAAI,CAAA;AAAA,IAC3D,GAAI,QAAA,KAAa,IAAA,GAAO,EAAC,GAAI,kBAAA,CAAmB,UAAU,OAAO;AAAA,GACnE;AACJ,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,OAAA,CAAQ,OAAA,CAAQ,OAAA;AACtC,EAAA,OAAO,QAAA,CAAS,CAAC,sBAAA,CAAuB,KAAA,EAAO,QAAQ,UAAU,CAAA,EAAG,SAAS,CAAC,CAAC,CAAA;AACjF;;"}
1
+ {"version":3,"file":"unevaluated-properties.mjs","sources":["../../../../src/application/transform/schema/unevaluated-properties.ts"],"sourcesContent":["import { irObject, irStringIndexSignature } from \"../../../domain/ir/constructors.js\";\nimport type { IrType } from \"../../../domain/ir/nodes.js\";\nimport type { Schema, SchemaObject } from \"../../../domain/openapi/schema-object.js\";\nimport { FIX } from \"../../../domain/output-fixes.js\";\nimport { declaredValueTypes } from \"../declared-value-types.js\";\nimport { UNKNOWN_TYPE } from \"../shared-types.js\";\nimport { unionOf } from \"../type-combinators.js\";\nimport type { SchemaRequest } from \"./schema-rule.js\";\n\n/**\n * The `unevaluated-properties` fix (ADR-021, roadmap R11; upstream #2839, #2880). Without it\n * `unevaluatedProperties` is ignored, so its value type is lost and an object with only that\n * keyword is `Record<string, never>`. With it the composed type is intersected with an index\n * signature, as `additionalProperties` gives: every key that no other keyword declares has the\n * `unevaluatedProperties` type. TypeScript checks that index signature against every key of a\n * value, declared ones included, so its type also holds the types of the declared properties\n * (of this schema and of its `allOf`, `anyOf` and `oneOf` members); otherwise a valid value would\n * not be assignable. `false` adds nothing, like `additionalProperties: false`: TypeScript has no\n * closed object type.\n */\n\n/**\n * Whether `unevaluatedProperties` applies. It types the keys left over at this level, so it\n * does nothing next to `additionalProperties` (which already types them all), and only an object\n * schema has keys. A `type` list is typed one listed type at a time, so its object gets it.\n */\nfunction unevaluatedSchemaOf(schema: SchemaObject, request: SchemaRequest): Schema | null {\n const { unevaluatedProperties } = schema;\n if (\n !request.context.options.fixes.has(FIX.UNEVALUATED_PROPERTIES) ||\n unevaluatedProperties === undefined ||\n unevaluatedProperties === false ||\n schema.additionalProperties !== undefined\n ) {\n return null;\n }\n return schema.type === undefined || schema.type === \"object\" ? unevaluatedProperties : null;\n}\n\nfunction isAnySchema(schema: Schema): boolean {\n return schema === true || (typeof schema === \"object\" && Object.keys(schema).length === 0);\n}\n\n/**\n * The index signature object for `unevaluatedProperties`, given the composed type of the other\n * keywords (null when there is none). Null when the fix is off or the keyword does not apply.\n */\nexport function unevaluatedPropertiesType(\n schema: SchemaObject,\n composed: IrType | null,\n request: SchemaRequest,\n): IrType | null {\n const unevaluated = unevaluatedSchemaOf(schema, request);\n if (unevaluated === null) {\n return null;\n }\n const valueTypes = isAnySchema(unevaluated)\n ? [UNKNOWN_TYPE]\n : [\n request.transformNested(unevaluated, request.location, true),\n ...(composed === null ? [] : declaredValueTypes(composed, request.context.footer)),\n ];\n const { immutable } = request.context.options;\n return irObject([irStringIndexSignature(\"key\", unionOf(valueTypes), immutable)]);\n}\n"],"names":[],"mappings":";;;;;;AA0BA,SAAS,mBAAA,CAAoB,QAAsB,OAAA,EAAuC;AACxF,EAAA,MAAM,EAAE,uBAAsB,GAAI,MAAA;AAClC,EAAA,IACE,CAAC,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,MAAM,GAAA,CAAI,GAAA,CAAI,sBAAsB,CAAA,IAC7D,0BAA0B,MAAA,IAC1B,qBAAA,KAA0B,KAAA,IAC1B,MAAA,CAAO,yBAAyB,MAAA,EAChC;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,OAAO,IAAA,KAAS,MAAA,IAAa,MAAA,CAAO,IAAA,KAAS,WAAW,qBAAA,GAAwB,IAAA;AACzF;AAEA,SAAS,YAAY,MAAA,EAAyB;AAC5C,EAAA,OAAO,MAAA,KAAW,QAAS,OAAO,MAAA,KAAW,YAAY,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAAE,MAAA,KAAW,CAAA;AAC1F;AAMO,SAAS,yBAAA,CACd,MAAA,EACA,QAAA,EACA,OAAA,EACe;AACf,EAAA,MAAM,WAAA,GAAc,mBAAA,CAAoB,MAAA,EAAQ,OAAO,CAAA;AACvD,EAAA,IAAI,gBAAgB,IAAA,EAAM;AACxB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,aAAa,WAAA,CAAY,WAAW,CAAA,GACtC,CAAC,YAAY,CAAA,GACb;AAAA,IACE,OAAA,CAAQ,eAAA,CAAgB,WAAA,EAAa,OAAA,CAAQ,UAAU,IAAI,CAAA;AAAA,IAC3D,GAAI,aAAa,IAAA,GAAO,KAAK,kBAAA,CAAmB,QAAA,EAAU,OAAA,CAAQ,OAAA,CAAQ,MAAM;AAAA,GAClF;AACJ,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,OAAA,CAAQ,OAAA,CAAQ,OAAA;AACtC,EAAA,OAAO,QAAA,CAAS,CAAC,sBAAA,CAAuB,KAAA,EAAO,QAAQ,UAAU,CAAA,EAAG,SAAS,CAAC,CAAC,CAAA;AACjF;;"}
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ function apiLogger(logger, apiName) {
4
+ const prefix = `API ${apiName}: `;
5
+ return {
6
+ debug: (message, group, durationMs) => logger.debug(`${prefix}${message}`, group, durationMs),
7
+ warn: (message) => logger.warn(`${prefix}${message}`),
8
+ error: (message) => logger.error(`${prefix}${message}`)
9
+ };
10
+ }
11
+
12
+ exports.apiLogger = apiLogger;
13
+ //# sourceMappingURL=api-logger.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-logger.cjs","sources":["../../src/cli/api-logger.ts"],"sourcesContent":["import type { DebugGroup, Logger } from \"../application/ports/logger.js\";\n\n/**\n * A logger whose lines name the API they are about. With several APIs in `redocly.yaml`, each is\n * loaded and linted in turn, and a problem line such as \"Can't resolve $ref\" is the same for\n * each, so without the name the user cannot tell which API it belongs to. The summary of a\n * failed API names it the same way (`API a: …`).\n */\nexport function apiLogger(logger: Logger, apiName: string): Logger {\n const prefix = `API ${apiName}: `;\n return {\n debug: (message: string, group?: DebugGroup, durationMs?: number) =>\n logger.debug(`${prefix}${message}`, group, durationMs),\n warn: (message: string) => logger.warn(`${prefix}${message}`),\n error: (message: string) => logger.error(`${prefix}${message}`),\n };\n}\n"],"names":[],"mappings":";;AAQO,SAAS,SAAA,CAAU,QAAgB,OAAA,EAAyB;AACjE,EAAA,MAAM,MAAA,GAAS,OAAO,OAAO,CAAA,EAAA,CAAA;AAC7B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,CAAC,OAAA,EAAiB,KAAA,EAAoB,UAAA,KAC3C,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,MAAM,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,OAAO,UAAU,CAAA;AAAA,IACvD,IAAA,EAAM,CAAC,OAAA,KAAoB,MAAA,CAAO,KAAK,CAAA,EAAG,MAAM,CAAA,EAAG,OAAO,CAAA,CAAE,CAAA;AAAA,IAC5D,KAAA,EAAO,CAAC,OAAA,KAAoB,MAAA,CAAO,MAAM,CAAA,EAAG,MAAM,CAAA,EAAG,OAAO,CAAA,CAAE;AAAA,GAChE;AACF;;"}
@@ -0,0 +1,11 @@
1
+ function apiLogger(logger, apiName) {
2
+ const prefix = `API ${apiName}: `;
3
+ return {
4
+ debug: (message, group, durationMs) => logger.debug(`${prefix}${message}`, group, durationMs),
5
+ warn: (message) => logger.warn(`${prefix}${message}`),
6
+ error: (message) => logger.error(`${prefix}${message}`)
7
+ };
8
+ }
9
+
10
+ export { apiLogger };
11
+ //# sourceMappingURL=api-logger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-logger.mjs","sources":["../../src/cli/api-logger.ts"],"sourcesContent":["import type { DebugGroup, Logger } from \"../application/ports/logger.js\";\n\n/**\n * A logger whose lines name the API they are about. With several APIs in `redocly.yaml`, each is\n * loaded and linted in turn, and a problem line such as \"Can't resolve $ref\" is the same for\n * each, so without the name the user cannot tell which API it belongs to. The summary of a\n * failed API names it the same way (`API a: …`).\n */\nexport function apiLogger(logger: Logger, apiName: string): Logger {\n const prefix = `API ${apiName}: `;\n return {\n debug: (message: string, group?: DebugGroup, durationMs?: number) =>\n logger.debug(`${prefix}${message}`, group, durationMs),\n warn: (message: string) => logger.warn(`${prefix}${message}`),\n error: (message: string) => logger.error(`${prefix}${message}`),\n };\n}\n"],"names":[],"mappings":"AAQO,SAAS,SAAA,CAAU,QAAgB,OAAA,EAAyB;AACjE,EAAA,MAAM,MAAA,GAAS,OAAO,OAAO,CAAA,EAAA,CAAA;AAC7B,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,CAAC,OAAA,EAAiB,KAAA,EAAoB,UAAA,KAC3C,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,MAAM,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,OAAO,UAAU,CAAA;AAAA,IACvD,IAAA,EAAM,CAAC,OAAA,KAAoB,MAAA,CAAO,KAAK,CAAA,EAAG,MAAM,CAAA,EAAG,OAAO,CAAA,CAAE,CAAA;AAAA,IAC5D,KAAA,EAAO,CAAC,OAAA,KAAoB,MAAA,CAAO,MAAM,CAAA,EAAG,MAAM,CAAA,EAAG,OAAO,CAAA,CAAE;AAAA,GAChE;AACF;;"}
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  const scule = require('scule');
4
- const errors = require('../domain/errors.cjs');
5
4
  const warnings = require('../domain/warnings.cjs');
6
5
  const cliArguments = require('./cli-arguments.cjs');
7
6
  const cliErrors = require('./cli-errors.cjs');
8
- const cliOutput = require('./cli-output.cjs');
9
7
  const fixOption = require('./fix-option.cjs');
8
+ const refLimits = require('./ref-limits.cjs');
10
9
 
11
10
  const OUTPUT_SETTING = "output";
12
11
  const FIX_SETTING = "fix";
13
12
  const LOCAL_REF_ROOT_SETTING = "localRefRoot";
13
+ const LOCAL_ROOT_EXPECTED = "a directory path or a file: URL";
14
14
  const REMOTE_REF_HOSTS_SETTING = "remoteRefHosts";
15
15
  const IGNORED_SETTINGS = ["contentNever"];
16
16
  const CAMEL_CASE_SETTINGS = [
@@ -84,27 +84,19 @@ function apiFixNames(apiName, settings) {
84
84
  try {
85
85
  return fixOption.fixNamesOf(entries);
86
86
  } catch (error) {
87
- throw errors.isOpenAPITypesafeError(error) ? withApiName(apiName, error) : error;
87
+ throw new cliErrors.ApiFailure(apiName, error);
88
88
  }
89
89
  }
90
- function withApiName(apiName, error) {
91
- const { code, details, cause } = error;
92
- return new errors.OpenAPITypesafeError({
93
- code,
94
- message: `API ${apiName}: ${error.message}`,
95
- details,
96
- cause
97
- });
98
- }
99
90
  function localRefRootOf(apiName, settings, configRoot) {
100
91
  if (!hasSetting(settings, LOCAL_REF_ROOT_SETTING)) {
101
92
  return {};
102
93
  }
103
94
  const value = settingValue(settings, LOCAL_REF_ROOT_SETTING) ?? "";
104
- if (typeof value !== "string") {
105
- throw invalidSetting(apiName, settings, LOCAL_REF_ROOT_SETTING, "a directory path");
95
+ const localRoot = typeof value === "string" ? refLimits.localRootUrl(value, configRoot) : void 0;
96
+ if (localRoot === void 0) {
97
+ throw invalidSetting(apiName, settings, LOCAL_REF_ROOT_SETTING, LOCAL_ROOT_EXPECTED);
106
98
  }
107
- return { localRefRoot: cliOutput.resolveLocationUrl(value === "" ? "." : value, configRoot) };
99
+ return { localRefRoot: localRoot };
108
100
  }
109
101
  function remoteRefHostsOf(apiName, settings) {
110
102
  if (!hasSetting(settings, REMOTE_REF_HOSTS_SETTING)) {
@@ -1 +1 @@
1
- {"version":3,"file":"api-settings.cjs","sources":["../../src/cli/api-settings.ts"],"sourcesContent":["import { kebabCase } from \"scule\";\nimport { isOpenAPITypesafeError, OpenAPITypesafeError } from \"../domain/errors.js\";\nimport type { OutputFixName } from \"../domain/output-fixes.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\nimport { GENERATOR_FLAGS, type GeneratorFlags, hostList } from \"./cli-arguments.js\";\nimport { cliError } from \"./cli-errors.js\";\nimport { resolveLocationUrl } from \"./cli-output.js\";\nimport { fixNamesOf } from \"./fix-option.js\";\nimport type { RefLimitOptions } from \"./ref-limits.js\";\n\n/**\n * The settings of one API in `redocly.yaml` (`apis.<name>.x-openapi-ts`). A setting has the name\n * of its CLI flag, in kebab-case or camelCase (ADR-021, decision 1); a setting the CLI does not\n * read gets a warning, as an unknown flag gets a notice.\n */\n\nexport type ApiSettings = Readonly<Record<string, unknown>>;\n\n/** The setting that names the output file. */\nexport const OUTPUT_SETTING = \"output\";\n\n/** The setting that lists the API's output fixes. */\nexport const FIX_SETTING = \"fix\";\n\nconst LOCAL_REF_ROOT_SETTING = \"localRefRoot\";\nconst REMOTE_REF_HOSTS_SETTING = \"remoteRefHosts\";\n\n/** `--content-never` is accepted and has no effect, as on the command line. */\nconst IGNORED_SETTINGS = [\"contentNever\"] as const;\n\nconst CAMEL_CASE_SETTINGS = [\n OUTPUT_SETTING,\n FIX_SETTING,\n LOCAL_REF_ROOT_SETTING,\n REMOTE_REF_HOSTS_SETTING,\n ...GENERATOR_FLAGS,\n ...IGNORED_SETTINGS,\n];\n\nconst KNOWN_SETTINGS = new Set<string>([\n ...CAMEL_CASE_SETTINGS,\n ...CAMEL_CASE_SETTINGS.map((name) => kebabCase(name)),\n]);\n\n/** The warning for each setting of an API that no code reads. */\nexport function unknownSettingWarnings(apiName: string, settings: ApiSettings): string[] {\n return Object.keys(settings)\n .filter((key) => !KNOWN_SETTINGS.has(key))\n .map((key) =>\n warningText(\n `API ${apiName}: the setting \\`${key}\\` is not an openapi-typesafe option and is ignored`,\n WARNING_CODES.CONFIG_SETTING_UNKNOWN,\n ),\n );\n}\n\n/** The key a setting is written with: camelCase, else kebab-case; undefined when it is absent. */\nfunction settingKey(settings: ApiSettings, name: string): string | undefined {\n if (name in settings) {\n return name;\n }\n const kebabName = kebabCase(name);\n return kebabName in settings ? kebabName : undefined;\n}\n\n/** The value of a setting in camelCase, else in kebab-case; `undefined` when it is absent. */\nfunction settingValue(settings: ApiSettings, name: string): unknown {\n const key = settingKey(settings, name);\n return key === undefined ? undefined : settings[key];\n}\n\nfunction hasSetting(settings: ApiSettings, name: string): boolean {\n return settingKey(settings, name) !== undefined;\n}\n\n/** `CLI_CONFIG_INVALID` for the setting `name` of an API, named as the user wrote it. */\nfunction invalidSetting(apiName: string, settings: ApiSettings, name: string, expected: string) {\n const key = settingKey(settings, name) ?? kebabCase(name);\n return cliError(\n \"CLI_CONFIG_INVALID\",\n `API ${apiName}: \\`${key}\\` in x-openapi-ts must be ${expected}`,\n );\n}\n\n/**\n * The boolean flags an API sets, in camelCase or kebab-case; they win over the CLI's flags. A\n * value of another type (`root-types: \"true\"`) fails with `CLI_CONFIG_INVALID`: ignoring it\n * would generate other types than the config asks for, without a word.\n */\nexport function apiFlags(apiName: string, settings: ApiSettings): GeneratorFlags {\n const flags: Partial<Record<(typeof GENERATOR_FLAGS)[number], boolean>> = {};\n for (const name of GENERATOR_FLAGS) {\n const value = settingValue(settings, name);\n if (typeof value === \"boolean\") {\n flags[name] = value;\n } else if (hasSetting(settings, name)) {\n throw invalidSetting(apiName, settings, name, \"true or false\");\n }\n }\n return flags;\n}\n\n/** The API's `output` file as written; fails with `CLI_CONFIG_INVALID` when it is not text. */\nexport function apiOutputOf(apiName: string, settings: ApiSettings): string {\n const output = settings[OUTPUT_SETTING];\n if (typeof output !== \"string\") {\n throw invalidSetting(apiName, settings, OUTPUT_SETTING, \"a file path\");\n }\n return output;\n}\n\n/**\n * The API's `fix` names, which replace the CLI's `--fix` (ADR-021). An entry that is not text\n * fails with `CLI_CONFIG_INVALID`; an unknown name with `OPTION_FIX_UNKNOWN`, naming the API.\n */\nexport function apiFixNames(\n apiName: string,\n settings: ApiSettings,\n): readonly OutputFixName[] | undefined {\n if (!hasSetting(settings, FIX_SETTING)) {\n return undefined;\n }\n const entries = [settingValue(settings, FIX_SETTING)].flat();\n if (entries.some((entry) => typeof entry !== \"string\")) {\n throw invalidSetting(apiName, settings, FIX_SETTING, \"a list of fix names or a comma list\");\n }\n try {\n return fixNamesOf(entries);\n } catch (error) {\n throw isOpenAPITypesafeError(error) ? withApiName(apiName, error) : error;\n }\n}\n\n/** The same error, with the API named first in its message. */\nfunction withApiName(apiName: string, error: OpenAPITypesafeError): OpenAPITypesafeError {\n const { code, details, cause } = error;\n return new OpenAPITypesafeError({\n code,\n message: `API ${apiName}: ${error.message}`,\n details,\n cause,\n });\n}\n\n/** `local-ref-root: dir`, relative to the config file; empty means the config file's directory. */\nfunction localRefRootOf(apiName: string, settings: ApiSettings, configRoot: URL): RefLimitOptions {\n if (!hasSetting(settings, LOCAL_REF_ROOT_SETTING)) {\n return {};\n }\n const value = settingValue(settings, LOCAL_REF_ROOT_SETTING) ?? \"\";\n if (typeof value !== \"string\") {\n throw invalidSetting(apiName, settings, LOCAL_REF_ROOT_SETTING, \"a directory path\");\n }\n return { localRefRoot: resolveLocationUrl(value === \"\" ? \".\" : value, configRoot) };\n}\n\n/** `remote-ref-hosts: [a, b]` or `a,b`; an empty list or value allows no host. */\nfunction remoteRefHostsOf(apiName: string, settings: ApiSettings): RefLimitOptions {\n if (!hasSetting(settings, REMOTE_REF_HOSTS_SETTING)) {\n return {};\n }\n const value = settingValue(settings, REMOTE_REF_HOSTS_SETTING) ?? [];\n const entries = [value].flat();\n if (entries.some((entry) => typeof entry !== \"string\")) {\n throw invalidSetting(apiName, settings, REMOTE_REF_HOSTS_SETTING, \"a host list\");\n }\n return { remoteRefHosts: hostList(entries) ?? [] };\n}\n\n/**\n * The `$ref` limits an API sets (threat model R1, R2). Each one replaces the CLI flag of the same\n * name for this API, as its boolean settings and `fix` do; fails with `CLI_CONFIG_INVALID` for a\n * value of another type.\n */\nexport function apiRefLimitOptions(\n apiName: string,\n settings: ApiSettings,\n configRoot: URL,\n): RefLimitOptions {\n return {\n ...localRefRootOf(apiName, settings, configRoot),\n ...remoteRefHostsOf(apiName, settings),\n };\n}\n"],"names":["GENERATOR_FLAGS","kebabCase","warningText","WARNING_CODES","cliError","fixNamesOf","isOpenAPITypesafeError","OpenAPITypesafeError","resolveLocationUrl","hostList"],"mappings":";;;;;;;;;;AAmBO,MAAM,cAAA,GAAiB;AAGvB,MAAM,WAAA,GAAc;AAE3B,MAAM,sBAAA,GAAyB,cAAA;AAC/B,MAAM,wBAAA,GAA2B,gBAAA;AAGjC,MAAM,gBAAA,GAAmB,CAAC,cAAc,CAAA;AAExC,MAAM,mBAAA,GAAsB;AAAA,EAC1B,cAAA;AAAA,EACA,WAAA;AAAA,EACA,sBAAA;AAAA,EACA,wBAAA;AAAA,EACA,GAAGA,4BAAA;AAAA,EACH,GAAG;AACL,CAAA;AAEA,MAAM,cAAA,uBAAqB,GAAA,CAAY;AAAA,EACrC,GAAG,mBAAA;AAAA,EACH,GAAG,mBAAA,CAAoB,GAAA,CAAI,CAAC,IAAA,KAASC,eAAA,CAAU,IAAI,CAAC;AACtD,CAAC,CAAA;AAGM,SAAS,sBAAA,CAAuB,SAAiB,QAAA,EAAiC;AACvF,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,QAAQ,CAAA,CACxB,MAAA,CAAO,CAAC,GAAA,KAAQ,CAAC,cAAA,CAAe,GAAA,CAAI,GAAG,CAAC,CAAA,CACxC,GAAA;AAAA,IAAI,CAAC,GAAA,KACJC,oBAAA;AAAA,MACE,CAAA,IAAA,EAAO,OAAO,CAAA,gBAAA,EAAmB,GAAG,CAAA,mDAAA,CAAA;AAAA,MACpCC,sBAAA,CAAc;AAAA;AAChB,GACF;AACJ;AAGA,SAAS,UAAA,CAAW,UAAuB,IAAA,EAAkC;AAC3E,EAAA,IAAI,QAAQ,QAAA,EAAU;AACpB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA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ts"],"sourcesContent":["import { kebabCase } from \"scule\";\nimport type { OutputFixName } from \"../domain/output-fixes.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\nimport { GENERATOR_FLAGS, type GeneratorFlags, hostList } from \"./cli-arguments.js\";\nimport { ApiFailure, cliError } from \"./cli-errors.js\";\nimport { fixNamesOf } from \"./fix-option.js\";\nimport { localRootUrl, type RefLimitOptions } from \"./ref-limits.js\";\n\n/**\n * The settings of one API in `redocly.yaml` (`apis.<name>.x-openapi-ts`). A setting has the name\n * of its CLI flag, in kebab-case or camelCase (ADR-021, decision 1); a setting the CLI does not\n * read gets a warning, as an unknown flag gets a notice.\n */\n\nexport type ApiSettings = Readonly<Record<string, unknown>>;\n\n/** The setting that names the output file. */\nexport const OUTPUT_SETTING = \"output\";\n\n/** The setting that lists the API's output fixes. */\nexport const FIX_SETTING = \"fix\";\n\nconst LOCAL_REF_ROOT_SETTING = \"localRefRoot\";\nconst LOCAL_ROOT_EXPECTED = \"a directory path or a file: URL\";\nconst REMOTE_REF_HOSTS_SETTING = \"remoteRefHosts\";\n\n/** `--content-never` is accepted and has no effect, as on the command line. */\nconst IGNORED_SETTINGS = [\"contentNever\"] as const;\n\nconst CAMEL_CASE_SETTINGS = [\n OUTPUT_SETTING,\n FIX_SETTING,\n LOCAL_REF_ROOT_SETTING,\n REMOTE_REF_HOSTS_SETTING,\n ...GENERATOR_FLAGS,\n ...IGNORED_SETTINGS,\n];\n\nconst KNOWN_SETTINGS = new Set<string>([\n ...CAMEL_CASE_SETTINGS,\n ...CAMEL_CASE_SETTINGS.map((name) => kebabCase(name)),\n]);\n\n/** The warning for each setting of an API that no code reads. */\nexport function unknownSettingWarnings(apiName: string, settings: ApiSettings): string[] {\n return Object.keys(settings)\n .filter((key) => !KNOWN_SETTINGS.has(key))\n .map((key) =>\n warningText(\n `API ${apiName}: the setting \\`${key}\\` is not an openapi-typesafe option and is ignored`,\n WARNING_CODES.CONFIG_SETTING_UNKNOWN,\n ),\n );\n}\n\n/** The key a setting is written with: camelCase, else kebab-case; undefined when it is absent. */\nfunction settingKey(settings: ApiSettings, name: string): string | undefined {\n if (name in settings) {\n return name;\n }\n const kebabName = kebabCase(name);\n return kebabName in settings ? kebabName : undefined;\n}\n\n/** The value of a setting in camelCase, else in kebab-case; `undefined` when it is absent. */\nfunction settingValue(settings: ApiSettings, name: string): unknown {\n const key = settingKey(settings, name);\n return key === undefined ? undefined : settings[key];\n}\n\nfunction hasSetting(settings: ApiSettings, name: string): boolean {\n return settingKey(settings, name) !== undefined;\n}\n\n/** `CLI_CONFIG_INVALID` for the setting `name` of an API, named as the user wrote it. */\nfunction invalidSetting(apiName: string, settings: ApiSettings, name: string, expected: string) {\n const key = settingKey(settings, name) ?? kebabCase(name);\n return cliError(\n \"CLI_CONFIG_INVALID\",\n `API ${apiName}: \\`${key}\\` in x-openapi-ts must be ${expected}`,\n );\n}\n\n/**\n * The boolean flags an API sets, in camelCase or kebab-case; they win over the CLI's flags. A\n * value of another type (`root-types: \"true\"`) fails with `CLI_CONFIG_INVALID`: ignoring it\n * would generate other types than the config asks for, without a word.\n */\nexport function apiFlags(apiName: string, settings: ApiSettings): GeneratorFlags {\n const flags: Partial<Record<(typeof GENERATOR_FLAGS)[number], boolean>> = {};\n for (const name of GENERATOR_FLAGS) {\n const value = settingValue(settings, name);\n if (typeof value === \"boolean\") {\n flags[name] = value;\n } else if (hasSetting(settings, name)) {\n throw invalidSetting(apiName, settings, name, \"true or false\");\n }\n }\n return flags;\n}\n\n/** The API's `output` file as written; fails with `CLI_CONFIG_INVALID` when it is not text. */\nexport function apiOutputOf(apiName: string, settings: ApiSettings): string {\n const output = settings[OUTPUT_SETTING];\n if (typeof output !== \"string\") {\n throw invalidSetting(apiName, settings, OUTPUT_SETTING, \"a file path\");\n }\n return output;\n}\n\n/**\n * The API's `fix` names, which replace the CLI's `--fix` (ADR-021). An entry that is not text\n * fails with `CLI_CONFIG_INVALID`; an unknown name with `OPTION_FIX_UNKNOWN`, naming the API.\n */\nexport function apiFixNames(\n apiName: string,\n settings: ApiSettings,\n): readonly OutputFixName[] | undefined {\n if (!hasSetting(settings, FIX_SETTING)) {\n return undefined;\n }\n const entries = [settingValue(settings, FIX_SETTING)].flat();\n if (entries.some((entry) => typeof entry !== \"string\")) {\n throw invalidSetting(apiName, settings, FIX_SETTING, \"a list of fix names or a comma list\");\n }\n try {\n return fixNamesOf(entries);\n } catch (error) {\n throw new ApiFailure(apiName, error);\n }\n}\n\n/**\n * `local-ref-root: dir`, relative to the config file; empty means the config file's directory. A\n * value that is no text or a URL of another protocol fails with `CLI_CONFIG_INVALID`.\n */\nfunction localRefRootOf(apiName: string, settings: ApiSettings, configRoot: URL): RefLimitOptions {\n if (!hasSetting(settings, LOCAL_REF_ROOT_SETTING)) {\n return {};\n }\n const value = settingValue(settings, LOCAL_REF_ROOT_SETTING) ?? \"\";\n const localRoot = typeof value === \"string\" ? localRootUrl(value, configRoot) : undefined;\n if (localRoot === undefined) {\n throw invalidSetting(apiName, settings, LOCAL_REF_ROOT_SETTING, LOCAL_ROOT_EXPECTED);\n }\n return { localRefRoot: localRoot };\n}\n\n/** `remote-ref-hosts: [a, b]` or `a,b`; an empty list or value allows no host. */\nfunction remoteRefHostsOf(apiName: string, settings: ApiSettings): RefLimitOptions {\n if (!hasSetting(settings, REMOTE_REF_HOSTS_SETTING)) {\n return {};\n }\n const value = settingValue(settings, REMOTE_REF_HOSTS_SETTING) ?? [];\n const entries = [value].flat();\n if (entries.some((entry) => typeof entry !== \"string\")) {\n throw invalidSetting(apiName, settings, REMOTE_REF_HOSTS_SETTING, \"a host list\");\n }\n return { remoteRefHosts: hostList(entries) ?? [] };\n}\n\n/**\n * The `$ref` limits an API sets (threat model R1, R2). Each one replaces the CLI flag of the same\n * name for this API, as its boolean settings and `fix` do; fails with `CLI_CONFIG_INVALID` for a\n * value of another type.\n */\nexport function apiRefLimitOptions(\n apiName: string,\n settings: ApiSettings,\n configRoot: URL,\n): RefLimitOptions {\n return {\n ...localRefRootOf(apiName, settings, configRoot),\n ...remoteRefHostsOf(apiName, settings),\n };\n}\n"],"names":["GENERATOR_FLAGS","kebabCase","warningText","WARNING_CODES","cliError","fixNamesOf","ApiFailure","localRootUrl","hostList"],"mappings":";;;;;;;;;AAiBO,MAAM,cAAA,GAAiB;AAGvB,MAAM,WAAA,GAAc;AAE3B,MAAM,sBAAA,GAAyB,cAAA;AAC/B,MAAM,mBAAA,GAAsB,iCAAA;AAC5B,MAAM,wBAAA,GAA2B,gBAAA;AAGjC,MAAM,gBAAA,GAAmB,CAAC,cAAc,CAAA;AAExC,MAAM,mBAAA,GAAsB;AAAA,EAC1B,cAAA;AAAA,EACA,WAAA;AAAA,EACA,sBAAA;AAAA,EACA,wBAAA;AAAA,EACA,GAAGA,4BAAA;AAAA,EACH,GAAG;AACL,CAAA;AAEA,MAAM,cAAA,uBAAqB,GAAA,CAAY;AAAA,EACrC,GAAG,mBAAA;AAAA,EACH,GAAG,mBAAA,CAAoB,GAAA,CAAI,CAAC,IAAA,KAASC,eAAA,CAAU,IAAI,CAAC;AACtD,CAAC,CAAA;AAGM,SAAS,sBAAA,CAAuB,SAAiB,QAAA,EAAiC;AACvF,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,QAAQ,CAAA,CACxB,MAAA,CAAO,CAAC,GAAA,KAAQ,CAAC,cAAA,CAAe,GAAA,CAAI,GAAG,CAAC,CAAA,CACxC,GAAA;AAAA,IAAI,CAAC,GAAA,KACJC,oBAAA;AAAA,MACE,CAAA,IAAA,EAAO,OAAO,CAAA,gBAAA,EAAmB,GAAG,CAAA,mDAAA,CAAA;AAAA,MACpCC,sBAAA,CAAc;AAAA;AAChB,GACF;AACJ;AAGA,SAAS,UAAA,CAAW,UAAuB,IAAA,EAAkC;AAC3E,EAAA,IAAI,QAAQ,QAAA,EAAU;AACpB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,SAAA,GAAYF,gBAAU,IAAI,CAAA;AAChC,EAAA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