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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (514) hide show
  1. package/CHANGELOG.md +1831 -0
  2. package/dist/adapters/node-deprecations/node-deprecations.cjs +14 -0
  3. package/dist/adapters/node-deprecations/node-deprecations.cjs.map +1 -0
  4. package/dist/adapters/node-deprecations/node-deprecations.mjs +12 -0
  5. package/dist/adapters/node-deprecations/node-deprecations.mjs.map +1 -0
  6. package/dist/adapters/node-file-system/file-claims.cjs +105 -0
  7. package/dist/adapters/node-file-system/file-claims.cjs.map +1 -0
  8. package/dist/adapters/node-file-system/file-claims.mjs +95 -0
  9. package/dist/adapters/node-file-system/file-claims.mjs.map +1 -0
  10. package/dist/adapters/node-file-system/file-identity.cjs +82 -0
  11. package/dist/adapters/node-file-system/file-identity.cjs.map +1 -0
  12. package/dist/adapters/node-file-system/file-identity.mjs +74 -0
  13. package/dist/adapters/node-file-system/file-identity.mjs.map +1 -0
  14. package/dist/adapters/node-file-system/node-file-system.cjs +90 -14
  15. package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
  16. package/dist/adapters/node-file-system/node-file-system.mjs +90 -14
  17. package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
  18. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +75 -0
  19. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +72 -0
  21. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -0
  22. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs +1 -1
  23. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs.map +1 -1
  24. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs +2 -2
  25. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs.map +1 -1
  26. package/dist/adapters/redocly-loader/loaded-documents.cjs +28 -0
  27. package/dist/adapters/redocly-loader/loaded-documents.cjs.map +1 -0
  28. package/dist/adapters/redocly-loader/loaded-documents.mjs +21 -0
  29. package/dist/adapters/redocly-loader/loaded-documents.mjs.map +1 -0
  30. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +14 -15
  31. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +12 -13
  33. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  34. package/dist/adapters/redocly-loader/ref-access.cjs +31 -3
  35. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  36. package/dist/adapters/redocly-loader/ref-access.mjs +31 -3
  37. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  38. package/dist/adapters/redocly-loader/ref-holders.cjs +2 -2
  39. package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
  40. package/dist/adapters/redocly-loader/ref-holders.mjs +3 -3
  41. package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
  42. package/dist/adapters/redocly-loader/remote-body-limit.cjs +50 -0
  43. package/dist/adapters/redocly-loader/remote-body-limit.cjs.map +1 -0
  44. package/dist/adapters/redocly-loader/remote-body-limit.mjs +48 -0
  45. package/dist/adapters/redocly-loader/remote-body-limit.mjs.map +1 -0
  46. package/dist/adapters/redocly-loader/remote-fetch.cjs +35 -6
  47. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  48. package/dist/adapters/redocly-loader/remote-fetch.mjs +35 -6
  49. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  50. package/dist/adapters/redocly-loader/remote-node-limit.cjs +47 -0
  51. package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -0
  52. package/dist/adapters/redocly-loader/remote-node-limit.mjs +44 -0
  53. package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -0
  54. package/dist/adapters/redocly-loader/schema-load-errors.cjs +32 -8
  55. package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
  56. package/dist/adapters/redocly-loader/schema-load-errors.mjs +32 -9
  57. package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
  58. package/dist/adapters/redocly-loader/schema-source.cjs +11 -7
  59. package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
  60. package/dist/adapters/redocly-loader/schema-source.mjs +12 -8
  61. package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
  62. package/dist/adapters/redocly-loader/unsupported-keys.cjs +3 -5
  63. package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
  64. package/dist/adapters/redocly-loader/unsupported-keys.mjs +3 -5
  65. package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
  66. package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
  67. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  68. package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
  69. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  70. package/dist/api/default-ports.cjs +19 -2
  71. package/dist/api/default-ports.cjs.map +1 -1
  72. package/dist/api/default-ports.mjs +19 -3
  73. package/dist/api/default-ports.mjs.map +1 -1
  74. package/dist/api/discriminator-conflict-warnings.cjs +1 -1
  75. package/dist/api/discriminator-conflict-warnings.cjs.map +1 -1
  76. package/dist/api/discriminator-conflict-warnings.mjs +2 -2
  77. package/dist/api/discriminator-conflict-warnings.mjs.map +1 -1
  78. package/dist/api/discriminator-enum-parent.cjs +2 -2
  79. package/dist/api/discriminator-enum-parent.cjs.map +1 -1
  80. package/dist/api/discriminator-enum-parent.mjs +3 -3
  81. package/dist/api/discriminator-enum-parent.mjs.map +1 -1
  82. package/dist/api/discriminator-other-owners.cjs +5 -3
  83. package/dist/api/discriminator-other-owners.cjs.map +1 -1
  84. package/dist/api/discriminator-other-owners.mjs +5 -3
  85. package/dist/api/discriminator-other-owners.mjs.map +1 -1
  86. package/dist/api/discriminator-patch.cjs +8 -4
  87. package/dist/api/discriminator-patch.cjs.map +1 -1
  88. package/dist/api/discriminator-patch.mjs +9 -5
  89. package/dist/api/discriminator-patch.mjs.map +1 -1
  90. package/dist/api/discriminator-scan.cjs +17 -10
  91. package/dist/api/discriminator-scan.cjs.map +1 -1
  92. package/dist/api/discriminator-scan.mjs +18 -11
  93. package/dist/api/discriminator-scan.mjs.map +1 -1
  94. package/dist/api/document-run.cjs +4 -3
  95. package/dist/api/document-run.cjs.map +1 -1
  96. package/dist/api/document-run.mjs +4 -3
  97. package/dist/api/document-run.mjs.map +1 -1
  98. package/dist/api/legacy-callback-warning.cjs +7 -4
  99. package/dist/api/legacy-callback-warning.cjs.map +1 -1
  100. package/dist/api/legacy-callback-warning.mjs +8 -5
  101. package/dist/api/legacy-callback-warning.mjs.map +1 -1
  102. package/dist/api/legacy-utils.cjs.map +1 -1
  103. package/dist/api/legacy-utils.mjs.map +1 -1
  104. package/dist/api/openapi-ts.cjs +9 -5
  105. package/dist/api/openapi-ts.cjs.map +1 -1
  106. package/dist/api/openapi-ts.mjs +10 -7
  107. package/dist/api/openapi-ts.mjs.map +1 -1
  108. package/dist/api/schema-callbacks.cjs +36 -12
  109. package/dist/api/schema-callbacks.cjs.map +1 -1
  110. package/dist/api/schema-callbacks.mjs +36 -12
  111. package/dist/api/schema-callbacks.mjs.map +1 -1
  112. package/dist/api/string-to-ast.cjs +7 -9
  113. package/dist/api/string-to-ast.cjs.map +1 -1
  114. package/dist/api/string-to-ast.mjs +8 -9
  115. package/dist/api/string-to-ast.mjs.map +1 -1
  116. package/dist/api/transform-context.cjs +7 -3
  117. package/dist/api/transform-context.cjs.map +1 -1
  118. package/dist/api/transform-context.mjs +7 -3
  119. package/dist/api/transform-context.mjs.map +1 -1
  120. package/dist/api/transform-schema.cjs +42 -12
  121. package/dist/api/transform-schema.cjs.map +1 -1
  122. package/dist/api/transform-schema.mjs +44 -14
  123. package/dist/api/transform-schema.mjs.map +1 -1
  124. package/dist/application/print/text-writer.cjs +10 -3
  125. package/dist/application/print/text-writer.cjs.map +1 -1
  126. package/dist/application/print/text-writer.mjs +10 -3
  127. package/dist/application/print/text-writer.mjs.map +1 -1
  128. package/dist/application/stack-overflow.cjs +2 -1
  129. package/dist/application/stack-overflow.cjs.map +1 -1
  130. package/dist/application/stack-overflow.mjs +2 -1
  131. package/dist/application/stack-overflow.mjs.map +1 -1
  132. package/dist/application/transform/document/components.cjs +2 -2
  133. package/dist/application/transform/document/components.cjs.map +1 -1
  134. package/dist/application/transform/document/components.mjs +4 -4
  135. package/dist/application/transform/document/components.mjs.map +1 -1
  136. package/dist/application/transform/document/declared-type-names.cjs +23 -0
  137. package/dist/application/transform/document/declared-type-names.cjs.map +1 -0
  138. package/dist/application/transform/document/declared-type-names.mjs +20 -0
  139. package/dist/application/transform/document/declared-type-names.mjs.map +1 -0
  140. package/dist/application/transform/document/defs-root.cjs +1 -1
  141. package/dist/application/transform/document/defs-root.cjs.map +1 -1
  142. package/dist/application/transform/document/defs-root.mjs +2 -2
  143. package/dist/application/transform/document/defs-root.mjs.map +1 -1
  144. package/dist/application/transform/document/document.cjs +4 -1
  145. package/dist/application/transform/document/document.cjs.map +1 -1
  146. package/dist/application/transform/document/document.mjs +3 -2
  147. package/dist/application/transform/document/document.mjs.map +1 -1
  148. package/dist/application/transform/document/enum-names-given-back.cjs +62 -0
  149. package/dist/application/transform/document/enum-names-given-back.cjs.map +1 -0
  150. package/dist/application/transform/document/enum-names-given-back.mjs +58 -0
  151. package/dist/application/transform/document/enum-names-given-back.mjs.map +1 -0
  152. package/dist/application/transform/document/global-type-references.cjs +1 -0
  153. package/dist/application/transform/document/global-type-references.cjs.map +1 -1
  154. package/dist/application/transform/document/global-type-references.mjs +1 -1
  155. package/dist/application/transform/document/global-type-references.mjs.map +1 -1
  156. package/dist/application/transform/document/media-type.cjs +2 -2
  157. package/dist/application/transform/document/media-type.cjs.map +1 -1
  158. package/dist/application/transform/document/media-type.mjs +3 -3
  159. package/dist/application/transform/document/media-type.mjs.map +1 -1
  160. package/dist/application/transform/document/operation-keys-written.cjs +26 -0
  161. package/dist/application/transform/document/operation-keys-written.cjs.map +1 -0
  162. package/dist/application/transform/document/operation-keys-written.mjs +24 -0
  163. package/dist/application/transform/document/operation-keys-written.mjs.map +1 -0
  164. package/dist/application/transform/document/operation.cjs +1 -1
  165. package/dist/application/transform/document/operation.cjs.map +1 -1
  166. package/dist/application/transform/document/operation.mjs +2 -2
  167. package/dist/application/transform/document/operation.mjs.map +1 -1
  168. package/dist/application/transform/document/parameter-entries.cjs +34 -0
  169. package/dist/application/transform/document/parameter-entries.cjs.map +1 -0
  170. package/dist/application/transform/document/parameter-entries.mjs +30 -0
  171. package/dist/application/transform/document/parameter-entries.mjs.map +1 -0
  172. package/dist/application/transform/document/parameter.cjs +12 -4
  173. package/dist/application/transform/document/parameter.cjs.map +1 -1
  174. package/dist/application/transform/document/parameter.mjs +13 -5
  175. package/dist/application/transform/document/parameter.mjs.map +1 -1
  176. package/dist/application/transform/document/parameters.cjs +7 -30
  177. package/dist/application/transform/document/parameters.cjs.map +1 -1
  178. package/dist/application/transform/document/parameters.mjs +8 -31
  179. package/dist/application/transform/document/parameters.mjs.map +1 -1
  180. package/dist/application/transform/document/path-item.cjs +11 -14
  181. package/dist/application/transform/document/path-item.cjs.map +1 -1
  182. package/dist/application/transform/document/path-item.mjs +12 -16
  183. package/dist/application/transform/document/path-item.mjs.map +1 -1
  184. package/dist/application/transform/document/paths-enum.cjs +1 -0
  185. package/dist/application/transform/document/paths-enum.cjs.map +1 -1
  186. package/dist/application/transform/document/paths-enum.mjs +1 -1
  187. package/dist/application/transform/document/paths-enum.mjs.map +1 -1
  188. package/dist/application/transform/document/paths.cjs +6 -2
  189. package/dist/application/transform/document/paths.cjs.map +1 -1
  190. package/dist/application/transform/document/paths.mjs +8 -4
  191. package/dist/application/transform/document/paths.mjs.map +1 -1
  192. package/dist/application/transform/document/referenced-parameter.cjs +80 -0
  193. package/dist/application/transform/document/referenced-parameter.cjs.map +1 -0
  194. package/dist/application/transform/document/referenced-parameter.mjs +78 -0
  195. package/dist/application/transform/document/referenced-parameter.mjs.map +1 -0
  196. package/dist/application/transform/document/request-body.cjs +1 -1
  197. package/dist/application/transform/document/request-body.cjs.map +1 -1
  198. package/dist/application/transform/document/request-body.mjs +2 -2
  199. package/dist/application/transform/document/request-body.mjs.map +1 -1
  200. package/dist/application/transform/document/response.cjs +2 -2
  201. package/dist/application/transform/document/response.cjs.map +1 -1
  202. package/dist/application/transform/document/response.mjs +3 -3
  203. package/dist/application/transform/document/response.mjs.map +1 -1
  204. package/dist/application/transform/document/responses.cjs +1 -1
  205. package/dist/application/transform/document/responses.cjs.map +1 -1
  206. package/dist/application/transform/document/responses.mjs +2 -2
  207. package/dist/application/transform/document/responses.mjs.map +1 -1
  208. package/dist/application/transform/document/root-type-aliases.cjs +8 -23
  209. package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
  210. package/dist/application/transform/document/root-type-aliases.mjs +8 -24
  211. package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
  212. package/dist/application/transform/document/type-resolution.cjs +3 -1
  213. package/dist/application/transform/document/type-resolution.cjs.map +1 -1
  214. package/dist/application/transform/document/type-resolution.mjs +3 -1
  215. package/dist/application/transform/document/type-resolution.mjs.map +1 -1
  216. package/dist/application/transform/document/webhooks.cjs +1 -1
  217. package/dist/application/transform/document/webhooks.cjs.map +1 -1
  218. package/dist/application/transform/document/webhooks.mjs +2 -2
  219. package/dist/application/transform/document/webhooks.mjs.map +1 -1
  220. package/dist/application/transform/footer/document-footer.cjs +10 -2
  221. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  222. package/dist/application/transform/footer/document-footer.mjs +10 -2
  223. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  224. package/dist/application/transform/footer/enum-name-claims.cjs +48 -0
  225. package/dist/application/transform/footer/enum-name-claims.cjs.map +1 -0
  226. package/dist/application/transform/footer/enum-name-claims.mjs +46 -0
  227. package/dist/application/transform/footer/enum-name-claims.mjs.map +1 -0
  228. package/dist/application/transform/footer/operation-keys.cjs +23 -0
  229. package/dist/application/transform/footer/operation-keys.cjs.map +1 -0
  230. package/dist/application/transform/footer/operation-keys.mjs +21 -0
  231. package/dist/application/transform/footer/operation-keys.mjs.map +1 -0
  232. package/dist/application/transform/footer/type-evaluation.cjs +4 -4
  233. package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
  234. package/dist/application/transform/footer/type-evaluation.mjs +4 -4
  235. package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
  236. package/dist/application/transform/helper-types.cjs +1 -1
  237. package/dist/application/transform/helper-types.cjs.map +1 -1
  238. package/dist/application/transform/helper-types.mjs +1 -1
  239. package/dist/application/transform/helper-types.mjs.map +1 -1
  240. package/dist/application/transform/numbered-names.cjs +9 -0
  241. package/dist/application/transform/numbered-names.cjs.map +1 -1
  242. package/dist/application/transform/numbered-names.mjs +9 -1
  243. package/dist/application/transform/numbered-names.mjs.map +1 -1
  244. package/dist/application/transform/ref-pointer/generated-location.cjs +1 -1
  245. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
  246. package/dist/application/transform/ref-pointer/generated-location.mjs +2 -2
  247. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
  248. package/dist/application/transform/ref-pointer/pointer-type.cjs +1 -1
  249. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  250. package/dist/application/transform/ref-pointer/pointer-type.mjs +2 -2
  251. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  252. package/dist/application/transform/ref-type.cjs +2 -1
  253. package/dist/application/transform/ref-type.cjs.map +1 -1
  254. package/dist/application/transform/ref-type.mjs +2 -1
  255. package/dist/application/transform/ref-type.mjs.map +1 -1
  256. package/dist/application/transform/schema/access-flags.cjs +1 -1
  257. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  258. package/dist/application/transform/schema/access-flags.mjs +2 -2
  259. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  260. package/dist/application/transform/schema/array-type.cjs +2 -2
  261. package/dist/application/transform/schema/array-type.cjs.map +1 -1
  262. package/dist/application/transform/schema/array-type.mjs +3 -3
  263. package/dist/application/transform/schema/array-type.mjs.map +1 -1
  264. package/dist/application/transform/schema/composition-type.cjs +4 -4
  265. package/dist/application/transform/schema/composition-type.cjs.map +1 -1
  266. package/dist/application/transform/schema/composition-type.mjs +6 -6
  267. package/dist/application/transform/schema/composition-type.mjs.map +1 -1
  268. package/dist/application/transform/schema/enum-rule.cjs +4 -6
  269. package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
  270. package/dist/application/transform/schema/enum-rule.mjs +6 -8
  271. package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
  272. package/dist/application/transform/schema/object-type.cjs +3 -3
  273. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  274. package/dist/application/transform/schema/object-type.mjs +4 -4
  275. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  276. package/dist/application/transform/schema/presence-members.cjs +1 -1
  277. package/dist/application/transform/schema/presence-members.cjs.map +1 -1
  278. package/dist/application/transform/schema/presence-members.mjs +2 -2
  279. package/dist/application/transform/schema/presence-members.mjs.map +1 -1
  280. package/dist/application/transform/schema/ref-siblings.cjs +47 -0
  281. package/dist/application/transform/schema/ref-siblings.cjs.map +1 -0
  282. package/dist/application/transform/schema/ref-siblings.mjs +45 -0
  283. package/dist/application/transform/schema/ref-siblings.mjs.map +1 -0
  284. package/dist/application/transform/schema/required-variants.cjs +2 -2
  285. package/dist/application/transform/schema/required-variants.cjs.map +1 -1
  286. package/dist/application/transform/schema/required-variants.mjs +3 -3
  287. package/dist/application/transform/schema/required-variants.mjs.map +1 -1
  288. package/dist/application/transform/schema/schema-transform.cjs +4 -2
  289. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  290. package/dist/application/transform/schema/schema-transform.mjs +4 -2
  291. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  292. package/dist/application/transform/schema/unevaluated-properties.cjs +1 -1
  293. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  294. package/dist/application/transform/schema/unevaluated-properties.mjs +2 -2
  295. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  296. package/dist/application/transform/schema-comment.cjs +6 -2
  297. package/dist/application/transform/schema-comment.cjs.map +1 -1
  298. package/dist/application/transform/schema-comment.mjs +7 -3
  299. package/dist/application/transform/schema-comment.mjs.map +1 -1
  300. package/dist/cli/api-settings.cjs +62 -6
  301. package/dist/cli/api-settings.cjs.map +1 -1
  302. package/dist/cli/api-settings.mjs +60 -7
  303. package/dist/cli/api-settings.mjs.map +1 -1
  304. package/dist/cli/api-writes.cjs +72 -0
  305. package/dist/cli/api-writes.cjs.map +1 -0
  306. package/dist/cli/api-writes.mjs +69 -0
  307. package/dist/cli/api-writes.mjs.map +1 -0
  308. package/dist/cli/cli-errors.cjs +12 -1
  309. package/dist/cli/cli-errors.cjs.map +1 -1
  310. package/dist/cli/cli-errors.mjs +12 -1
  311. package/dist/cli/cli-errors.mjs.map +1 -1
  312. package/dist/cli/cli-output.cjs +106 -1
  313. package/dist/cli/cli-output.cjs.map +1 -1
  314. package/dist/cli/cli-output.mjs +99 -2
  315. package/dist/cli/cli-output.mjs.map +1 -1
  316. package/dist/cli/main.cjs +5 -1
  317. package/dist/cli/main.cjs.map +1 -1
  318. package/dist/cli/main.mjs +6 -2
  319. package/dist/cli/main.mjs.map +1 -1
  320. package/dist/cli/redocly-apis.cjs +82 -36
  321. package/dist/cli/redocly-apis.cjs.map +1 -1
  322. package/dist/cli/redocly-apis.mjs +85 -39
  323. package/dist/cli/redocly-apis.mjs.map +1 -1
  324. package/dist/cli/run-cli.cjs +13 -7
  325. package/dist/cli/run-cli.cjs.map +1 -1
  326. package/dist/cli/run-cli.mjs +14 -8
  327. package/dist/cli/run-cli.mjs.map +1 -1
  328. package/dist/domain/append-all.cjs +10 -0
  329. package/dist/domain/append-all.cjs.map +1 -0
  330. package/dist/domain/append-all.mjs +8 -0
  331. package/dist/domain/append-all.mjs.map +1 -0
  332. package/dist/domain/cause-secrets.cjs +37 -0
  333. package/dist/domain/cause-secrets.cjs.map +1 -0
  334. package/dist/domain/cause-secrets.mjs +35 -0
  335. package/dist/domain/cause-secrets.mjs.map +1 -0
  336. package/dist/domain/deprecations.cjs +11 -0
  337. package/dist/domain/deprecations.cjs.map +1 -0
  338. package/dist/domain/deprecations.mjs +9 -0
  339. package/dist/domain/deprecations.mjs.map +1 -0
  340. package/dist/domain/errors.cjs +9 -3
  341. package/dist/domain/errors.cjs.map +1 -1
  342. package/dist/domain/errors.mjs +9 -3
  343. package/dist/domain/errors.mjs.map +1 -1
  344. package/dist/domain/ir/identifier-text.cjs.map +1 -1
  345. package/dist/domain/ir/identifier-text.mjs +1 -1
  346. package/dist/domain/ir/identifier-text.mjs.map +1 -1
  347. package/dist/domain/ir/ir-shape.cjs +187 -0
  348. package/dist/domain/ir/ir-shape.cjs.map +1 -0
  349. package/dist/domain/ir/ir-shape.mjs +184 -0
  350. package/dist/domain/ir/ir-shape.mjs.map +1 -0
  351. package/dist/domain/ir/newer-identifier-ranges.cjs +182 -29
  352. package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -1
  353. package/dist/domain/ir/newer-identifier-ranges.mjs +182 -29
  354. package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -1
  355. package/dist/domain/openapi/alias-expansion.cjs +3 -1
  356. package/dist/domain/openapi/alias-expansion.cjs.map +1 -1
  357. package/dist/domain/openapi/alias-expansion.mjs +3 -1
  358. package/dist/domain/openapi/alias-expansion.mjs.map +1 -1
  359. package/dist/domain/openapi/discriminated-union.cjs +3 -3
  360. package/dist/domain/openapi/discriminated-union.cjs.map +1 -1
  361. package/dist/domain/openapi/discriminated-union.mjs +4 -4
  362. package/dist/domain/openapi/discriminated-union.mjs.map +1 -1
  363. package/dist/domain/openapi/discriminator-conflicts.cjs +10 -6
  364. package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -1
  365. package/dist/domain/openapi/discriminator-conflicts.mjs +11 -7
  366. package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -1
  367. package/dist/domain/openapi/json-pointer.cjs +43 -1
  368. package/dist/domain/openapi/json-pointer.cjs.map +1 -1
  369. package/dist/domain/openapi/json-pointer.mjs +40 -2
  370. package/dist/domain/openapi/json-pointer.mjs.map +1 -1
  371. package/dist/domain/openapi/schema-dialect.cjs +15 -0
  372. package/dist/domain/openapi/schema-dialect.cjs.map +1 -0
  373. package/dist/domain/openapi/schema-dialect.mjs +12 -0
  374. package/dist/domain/openapi/schema-dialect.mjs.map +1 -0
  375. package/dist/domain/openapi/unsupported-features.cjs +1 -1
  376. package/dist/domain/openapi/unsupported-features.cjs.map +1 -1
  377. package/dist/domain/openapi/unsupported-features.mjs +2 -2
  378. package/dist/domain/openapi/unsupported-features.mjs.map +1 -1
  379. package/dist/domain/output-fixes.cjs +25 -14
  380. package/dist/domain/output-fixes.cjs.map +1 -1
  381. package/dist/domain/output-fixes.mjs +25 -13
  382. package/dist/domain/output-fixes.mjs.map +1 -1
  383. package/dist/domain/url-secrets.cjs +48 -0
  384. package/dist/domain/url-secrets.cjs.map +1 -0
  385. package/dist/domain/url-secrets.mjs +45 -0
  386. package/dist/domain/url-secrets.mjs.map +1 -0
  387. package/dist/domain/warnings.cjs +0 -1
  388. package/dist/domain/warnings.cjs.map +1 -1
  389. package/dist/domain/warnings.mjs +0 -1
  390. package/dist/domain/warnings.mjs.map +1 -1
  391. package/dist/index.cjs +2 -3
  392. package/dist/index.cjs.map +1 -1
  393. package/dist/index.d.cts +57 -20
  394. package/dist/index.d.mts +57 -20
  395. package/dist/index.d.ts +57 -20
  396. package/dist/index.mjs +3 -2
  397. package/dist/index.mjs.map +1 -1
  398. package/package.json +5 -6
  399. package/src/adapters/node-deprecations/node-deprecations.ts +14 -0
  400. package/src/adapters/node-file-system/file-claims.ts +138 -0
  401. package/src/adapters/node-file-system/file-identity.ts +137 -0
  402. package/src/adapters/node-file-system/node-file-system.ts +145 -18
  403. package/src/adapters/redocly-loader/bundled-mapping-copies.ts +95 -0
  404. package/src/adapters/redocly-loader/bundled-ref-repair.ts +2 -2
  405. package/src/adapters/redocly-loader/loaded-documents.ts +46 -0
  406. package/src/adapters/redocly-loader/redocly-schema-loader.ts +18 -24
  407. package/src/adapters/redocly-loader/ref-access.ts +37 -3
  408. package/src/adapters/redocly-loader/ref-holders.ts +3 -3
  409. package/src/adapters/redocly-loader/remote-body-limit.ts +66 -0
  410. package/src/adapters/redocly-loader/remote-fetch.ts +74 -11
  411. package/src/adapters/redocly-loader/remote-node-limit.ts +62 -0
  412. package/src/adapters/redocly-loader/schema-load-errors.ts +52 -13
  413. package/src/adapters/redocly-loader/schema-source.ts +20 -8
  414. package/src/adapters/redocly-loader/unsupported-keys.ts +3 -7
  415. package/src/adapters/terminal-logger/terminal-logger.ts +10 -5
  416. package/src/api/default-ports.ts +40 -4
  417. package/src/api/discriminator-conflict-warnings.ts +2 -2
  418. package/src/api/discriminator-enum-parent.ts +3 -3
  419. package/src/api/discriminator-other-owners.ts +5 -3
  420. package/src/api/discriminator-patch.ts +9 -6
  421. package/src/api/discriminator-scan.ts +19 -11
  422. package/src/api/document-run.ts +9 -3
  423. package/src/api/legacy-callback-warning.ts +13 -6
  424. package/src/api/legacy-utils.ts +5 -1
  425. package/src/api/openapi-ts.ts +26 -7
  426. package/src/api/run-context.ts +6 -0
  427. package/src/api/schema-callbacks.ts +60 -17
  428. package/src/api/string-to-ast.ts +11 -15
  429. package/src/api/transform-context.ts +7 -3
  430. package/src/api/transform-schema.ts +67 -15
  431. package/src/application/ports/deprecation-reporter.ts +9 -0
  432. package/src/application/ports/file-system.ts +39 -0
  433. package/src/application/ports/schema-loader.ts +11 -1
  434. package/src/application/print/text-writer.ts +10 -3
  435. package/src/application/stack-overflow.ts +9 -5
  436. package/src/application/transform/document/components.ts +4 -4
  437. package/src/application/transform/document/declared-type-names.ts +36 -0
  438. package/src/application/transform/document/defs-root.ts +2 -2
  439. package/src/application/transform/document/document.ts +4 -3
  440. package/src/application/transform/document/enum-names-given-back.ts +91 -0
  441. package/src/application/transform/document/global-type-references.ts +1 -1
  442. package/src/application/transform/document/media-type.ts +4 -3
  443. package/src/application/transform/document/operation-keys-written.ts +27 -0
  444. package/src/application/transform/document/operation.ts +2 -2
  445. package/src/application/transform/document/parameter-entries.ts +70 -0
  446. package/src/application/transform/document/parameter.ts +21 -9
  447. package/src/application/transform/document/parameters.ts +13 -58
  448. package/src/application/transform/document/path-item.ts +13 -31
  449. package/src/application/transform/document/paths-enum.ts +1 -1
  450. package/src/application/transform/document/paths.ts +8 -4
  451. package/src/application/transform/document/referenced-parameter.ts +146 -0
  452. package/src/application/transform/document/request-body.ts +2 -2
  453. package/src/application/transform/document/response.ts +3 -3
  454. package/src/application/transform/document/responses.ts +2 -2
  455. package/src/application/transform/document/root-type-aliases.ts +17 -38
  456. package/src/application/transform/document/type-resolution.ts +2 -1
  457. package/src/application/transform/document/webhooks.ts +2 -2
  458. package/src/application/transform/footer/document-footer.ts +18 -1
  459. package/src/application/transform/footer/enum-name-claims.ts +62 -0
  460. package/src/application/transform/footer/operation-keys.ts +28 -0
  461. package/src/application/transform/footer/type-evaluation.ts +4 -4
  462. package/src/application/transform/helper-types.ts +6 -5
  463. package/src/application/transform/numbered-names.ts +15 -0
  464. package/src/application/transform/ref-pointer/generated-location.ts +2 -2
  465. package/src/application/transform/ref-pointer/pointer-type.ts +2 -4
  466. package/src/application/transform/ref-type.ts +2 -1
  467. package/src/application/transform/schema/access-flags.ts +2 -2
  468. package/src/application/transform/schema/array-type.ts +3 -5
  469. package/src/application/transform/schema/composition-type.ts +6 -6
  470. package/src/application/transform/schema/enum-rule.ts +10 -8
  471. package/src/application/transform/schema/object-type.ts +4 -4
  472. package/src/application/transform/schema/presence-members.ts +2 -2
  473. package/src/application/transform/schema/ref-siblings.ts +76 -0
  474. package/src/application/transform/schema/required-variants.ts +3 -3
  475. package/src/application/transform/schema/schema-context.ts +3 -0
  476. package/src/application/transform/schema/schema-transform.ts +4 -2
  477. package/src/application/transform/schema/unevaluated-properties.ts +2 -2
  478. package/src/application/transform/schema-comment.ts +7 -3
  479. package/src/application/transform/transform-context.ts +5 -0
  480. package/src/cli/api-settings.ts +82 -7
  481. package/src/cli/api-writes.ts +117 -0
  482. package/src/cli/cli-dependencies.ts +21 -4
  483. package/src/cli/cli-errors.ts +20 -1
  484. package/src/cli/cli-output.ts +186 -7
  485. package/src/cli/main.ts +6 -3
  486. package/src/cli/redocly-apis.ts +153 -48
  487. package/src/cli/run-cli.ts +37 -8
  488. package/src/domain/append-all.ts +10 -0
  489. package/src/domain/cause-secrets.ts +52 -0
  490. package/src/domain/deprecations.ts +15 -0
  491. package/src/domain/errors.ts +22 -7
  492. package/src/domain/ir/identifier-text.ts +6 -5
  493. package/src/domain/ir/ir-shape.ts +299 -0
  494. package/src/domain/ir/newer-identifier-ranges.ts +183 -30
  495. package/src/domain/openapi/alias-expansion.ts +4 -1
  496. package/src/domain/openapi/discriminated-union.ts +6 -4
  497. package/src/domain/openapi/discriminator-conflicts.ts +21 -7
  498. package/src/domain/openapi/document-object.ts +2 -0
  499. package/src/domain/openapi/json-pointer.ts +96 -7
  500. package/src/domain/openapi/schema-dialect.ts +22 -0
  501. package/src/domain/openapi/unsupported-features.ts +2 -2
  502. package/src/domain/output-fixes.ts +37 -18
  503. package/src/domain/url-secrets.ts +72 -0
  504. package/src/domain/warnings.ts +0 -1
  505. package/src/index.ts +2 -6
  506. package/src/types/generator-options.ts +1 -1
  507. package/dist/cli/main.d.cts +0 -2
  508. package/dist/cli/main.d.mts +0 -2
  509. package/dist/cli/main.d.ts +0 -2
  510. package/dist/domain/url-credentials.cjs +0 -10
  511. package/dist/domain/url-credentials.cjs.map +0 -1
  512. package/dist/domain/url-credentials.mjs +0 -8
  513. package/dist/domain/url-credentials.mjs.map +0 -1
  514. package/src/domain/url-credentials.ts +0 -18
@@ -1 +1 @@
1
- {"version":3,"file":"terminal-logger.cjs","sources":["../../../src/adapters/terminal-logger/terminal-logger.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport type { DebugGroup, Logger } from \"../../application/ports/logger.js\";\nimport { redactUrlCredentials } from \"../../domain/url-credentials.js\";\n\n/**\n * The Logger port on a terminal, with the original output format: ` ⚠ ` warnings, ` ✘ `\n * errors, and `openapi-ts:<group>` debug lines filtered by `DEBUG` (ENGINEERING_PLAN 4.5). No\n * line shows the user info of a URL.\n */\n\n/** Where the lines go: `console` in production, a recording sink in tests. */\nexport interface TerminalSink {\n debug(line: string): void;\n warn(line: string): void;\n error(line: string): void;\n}\n\nexport interface TerminalLoggerOptions {\n /** Drop warnings (errors and debug lines are still written). */\n readonly silent: boolean;\n /** The value of `DEBUG`: `*`, `openapi-ts:*` or `openapi-ts:<group>` turn debug lines on. */\n readonly debugFilter: string | undefined;\n readonly useColors: boolean;\n readonly sink: TerminalSink;\n}\n\ntype Colors = ReturnType<typeof colors.create>;\n\nconst MILLISECONDS_PER_SECOND = 1000;\nconst MILLISECONDS_PER_MINUTE = 60_000;\n\n/** A duration as the original prints it: one decimal, in ms, s or m. */\nexport function formatDuration(milliseconds: number): string {\n if (milliseconds < MILLISECONDS_PER_SECOND) {\n return `${Math.round(10 * milliseconds) / 10}ms`;\n }\n if (milliseconds < MILLISECONDS_PER_MINUTE) {\n return `${Math.round(milliseconds / 100) / 10}s`;\n }\n return `${Math.round(milliseconds / 6000) / 10}m`;\n}\n\nfunction groupColor(palette: Colors, group: DebugGroup | undefined): (text: string) => string {\n const byGroup: Readonly<Partial<Record<DebugGroup, (text: string) => string>>> = {\n redoc: palette.cyanBright,\n lint: palette.yellowBright,\n bundle: palette.magentaBright,\n ts: palette.blueBright,\n };\n return (group && byGroup[group]) || palette.whiteBright;\n}\n\n/** Whether `DEBUG` asks for this group (the original check, case-insensitive for the group). */\nexport function isDebugEnabled(filter: string | undefined, group: DebugGroup | undefined): boolean {\n if (!filter) {\n return false;\n }\n return (\n !group ||\n filter === \"*\" ||\n filter === \"openapi-ts:*\" ||\n filter.toLocaleLowerCase() === `openapi-ts:${group.toLocaleLowerCase()}`\n );\n}\n\nclass TerminalLogger implements Logger {\n readonly #options: TerminalLoggerOptions;\n readonly #palette: Colors;\n\n constructor(options: TerminalLoggerOptions) {\n this.#options = options;\n this.#palette = colors.create();\n this.#palette.enabled = options.useColors;\n }\n\n debug(message: string, group?: DebugGroup, durationMs?: number): void {\n if (!isDebugEnabled(this.#options.debugFilter, group)) {\n return;\n }\n const name = groupColor(this.#palette, group)(`openapi-ts:${group ?? \"info\"}`);\n // The original wrote no space without a duration (`openapi-ts:lintIgnored …`).\n const time =\n durationMs === undefined ? \" \" : this.#palette.green(` ${formatDuration(durationMs)} `);\n const text = redactUrlCredentials(message);\n this.#options.sink.debug(` ${this.#palette.bold(name)}${time}${text}`);\n }\n\n warn(message: string): void {\n if (!this.#options.silent) {\n this.#options.sink.warn(this.#palette.yellow(` ⚠ ${redactUrlCredentials(message)}`));\n }\n }\n\n error(message: string): void {\n this.#options.sink.error(this.#palette.red(` ✘ ${redactUrlCredentials(message)}`));\n }\n}\n\n/** A Logger that writes to a terminal sink. */\nexport function createTerminalLogger(options: TerminalLoggerOptions): Logger {\n return new TerminalLogger(options);\n}\n"],"names":["colors","redactUrlCredentials"],"mappings":";;;;;;;;;AA4BA,MAAM,uBAAA,GAA0B,GAAA;AAChC,MAAM,uBAAA,GAA0B,GAAA;AAGzB,SAAS,eAAe,YAAA,EAA8B;AAC3D,EAAA,IAAI,eAAe,uBAAA,EAAyB;AAC1C,IAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,EAAA,GAAK,YAAY,IAAI,EAAE,CAAA,EAAA,CAAA;AAAA,EAC9C;AACA,EAAA,IAAI,eAAe,uBAAA,EAAyB;AAC1C,IAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,YAAA,GAAe,GAAG,IAAI,EAAE,CAAA,CAAA,CAAA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CAAA,CAAE,CAAA,WAAA,EAAc,KAAA,IAAS,MAAM,CAAA,CAAE,CAAA;AAE7E,IAAA,MAAM,IAAA,GACJ,UAAA,KAAe,MAAA,GAAY,GAAA,GAAM,IAAA,CAAK,QAAA,CAAS,KAAA,CAAM,CAAA,CAAA,EAAI,cAAA,CAAe,UAAU,CAAC,CAAA,CAAA,CAAG,CAAA;AACxF,IAAA,MAAM,IAAA,GAAOC,oCAAqB,OAAO,CAAA;AACzC,IAAA,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,KAAA,CAAM,CAAA,EAAA,EAAK,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,IAAI,CAAC,CAAA,EAAG,IAAI,CAAA,EAAG,IAAI,CAAA,CAAE,CAAA;AAAA,EACxE;AAAA,EAEA,KAAK,OAAA,EAAuB;AAC1B,IAAA,IAAI,CAAC,IAAA,CAAK,QAAA,CAAS,MAAA,EAAQ;AACzB,MAAA,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,QAAA,CAAS,MAAA,CAAO,CAAA,SAAA,EAAOA,mCAAA,CAAqB,OAAO,CAAC,CAAA,CAAE,CAAC,CAAA;AAAA,IACtF;AAAA,EACF;AAAA,EAEA,MAAM,OAAA,EAAuB;AAC3B,IAAA,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,CAAA,SAAA,EAAOA,mCAAA,CAAqB,OAAO,CAAC,CAAA,CAAE,CAAC,CAAA;AAAA,EACpF;AACF;AAGO,SAAS,qBAAqB,OAAA,EAAwC;AAC3E,EAAA,OAAO,IAAI,eAAe,OAAO,CAAA;AACnC;;;;"}
1
+ {"version":3,"file":"terminal-logger.cjs","sources":["../../../src/adapters/terminal-logger/terminal-logger.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport type { DebugGroup, Logger } from \"../../application/ports/logger.js\";\nimport { redactUrlSecrets } from \"../../domain/url-secrets.js\";\n\n/**\n * The Logger port on a terminal, with the original output format: ` ⚠ ` warnings, ` ✘ `\n * errors, and `openapi-ts:<group>` debug lines filtered by `DEBUG` (ENGINEERING_PLAN 4.5). No\n * line shows the user info of a URL.\n */\n\n/** Where the lines go: `console` in production, a recording sink in tests. */\nexport interface TerminalSink {\n debug(line: string): void;\n warn(line: string): void;\n error(line: string): void;\n}\n\nexport interface TerminalLoggerOptions {\n /**\n * Drop warnings and error lines; debug lines, which `DEBUG` asks for, are still written. The\n * error lines are the problems of a document that fails to load, which the thrown error lists.\n */\n readonly silent: boolean;\n /** The value of `DEBUG`: `*`, `openapi-ts:*` or `openapi-ts:<group>` turn debug lines on. */\n readonly debugFilter: string | undefined;\n readonly useColors: boolean;\n readonly sink: TerminalSink;\n}\n\ntype Colors = ReturnType<typeof colors.create>;\n\nconst MILLISECONDS_PER_SECOND = 1000;\nconst MILLISECONDS_PER_MINUTE = 60_000;\n\n/** A duration as the original prints it: one decimal, in ms, s or m. */\nexport function formatDuration(milliseconds: number): string {\n if (milliseconds < MILLISECONDS_PER_SECOND) {\n return `${Math.round(10 * milliseconds) / 10}ms`;\n }\n if (milliseconds < MILLISECONDS_PER_MINUTE) {\n return `${Math.round(milliseconds / 100) / 10}s`;\n }\n return `${Math.round(milliseconds / 6000) / 10}m`;\n}\n\nfunction groupColor(palette: Colors, group: DebugGroup | undefined): (text: string) => string {\n const byGroup: Readonly<Partial<Record<DebugGroup, (text: string) => string>>> = {\n redoc: palette.cyanBright,\n lint: palette.yellowBright,\n bundle: palette.magentaBright,\n ts: palette.blueBright,\n };\n return (group && byGroup[group]) || palette.whiteBright;\n}\n\n/** Whether `DEBUG` asks for this group (the original check, case-insensitive for the group). */\nexport function isDebugEnabled(filter: string | undefined, group: DebugGroup | undefined): boolean {\n if (!filter) {\n return false;\n }\n return (\n !group ||\n filter === \"*\" ||\n filter === \"openapi-ts:*\" ||\n filter.toLocaleLowerCase() === `openapi-ts:${group.toLocaleLowerCase()}`\n );\n}\n\nclass TerminalLogger implements Logger {\n readonly #options: TerminalLoggerOptions;\n readonly #palette: Colors;\n\n constructor(options: TerminalLoggerOptions) {\n this.#options = options;\n this.#palette = colors.create();\n this.#palette.enabled = options.useColors;\n }\n\n debug(message: string, group?: DebugGroup, durationMs?: number): void {\n if (!isDebugEnabled(this.#options.debugFilter, group)) {\n return;\n }\n const name = groupColor(this.#palette, group)(`openapi-ts:${group ?? \"info\"}`);\n // The original wrote no space without a duration (`openapi-ts:lintIgnored …`).\n const time =\n durationMs === undefined ? \" \" : this.#palette.green(` ${formatDuration(durationMs)} `);\n const text = redactUrlSecrets(message);\n this.#options.sink.debug(` ${this.#palette.bold(name)}${time}${text}`);\n }\n\n warn(message: string): void {\n if (!this.#options.silent) {\n this.#options.sink.warn(this.#palette.yellow(` ⚠ ${redactUrlSecrets(message)}`));\n }\n }\n\n error(message: string): void {\n if (!this.#options.silent) {\n this.#options.sink.error(this.#palette.red(` ✘ ${redactUrlSecrets(message)}`));\n }\n }\n}\n\n/** A Logger that writes to a terminal sink. */\nexport function createTerminalLogger(options: TerminalLoggerOptions): Logger {\n return new TerminalLogger(options);\n}\n"],"names":["colors","redactUrlSecrets"],"mappings":";;;;;;;;;AA+BA,MAAM,uBAAA,GAA0B,GAAA;AAChC,MAAM,uBAAA,GAA0B,GAAA;AAGzB,SAAS,eAAe,YAAA,EAA8B;AAC3D,EAAA,IAAI,eAAe,uBAAA,EAAyB;AAC1C,IAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,EAAA,GAAK,YAAY,IAAI,EAAE,CAAA,EAAA,CAAA;AAAA,EAC9C;AACA,EAAA,IAAI,eAAe,uBAAA,EAAyB;AAC1C,IAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,YAAA,GAAe,GAAG,IAAI,EAAE,CAAA,CAAA,CAAA;AAAA,EAC/C;AACA,EAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,YAAA,GAAe,GAAI,IAAI,EAAE,CAAA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,UAAA,KAAe,MAAA,GAAY,GAAA,GAAM,IAAA,CAAK,QAAA,CAAS,KAAA,CAAM,CAAA,CAAA,EAAI,cAAA,CAAe,UAAU,CAAC,CAAA,CAAA,CAAG,CAAA;AACxF,IAAA,MAAM,IAAA,GAAOC,4BAAiB,OAAO,CAAA;AACrC,IAAA,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,KAAA,CAAM,CAAA,EAAA,EAAK,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,IAAI,CAAC,CAAA,EAAG,IAAI,CAAA,EAAG,IAAI,CAAA,CAAE,CAAA;AAAA,EACxE;AAAA,EAEA,KAAK,OAAA,EAAuB;AAC1B,IAAA,IAAI,CAAC,IAAA,CAAK,QAAA,CAAS,MAAA,EAAQ;AACzB,MAAA,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,QAAA,CAAS,MAAA,CAAO,CAAA,SAAA,EAAOA,2BAAA,CAAiB,OAAO,CAAC,CAAA,CAAE,CAAC,CAAA;AAAA,IAClF;AAAA,EACF;AAAA,EAEA,MAAM,OAAA,EAAuB;AAC3B,IAAA,IAAI,CAAC,IAAA,CAAK,QAAA,CAAS,MAAA,EAAQ;AACzB,MAAA,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,CAAA,SAAA,EAAOA,2BAAA,CAAiB,OAAO,CAAC,CAAA,CAAE,CAAC,CAAA;AAAA,IAChF;AAAA,EACF;AACF;AAGO,SAAS,qBAAqB,OAAA,EAAwC;AAC3E,EAAA,OAAO,IAAI,eAAe,OAAO,CAAA;AACnC;;;;"}
@@ -1,5 +1,5 @@
1
1
  import colors from 'ansi-colors';
2
- import { redactUrlCredentials } from '../../domain/url-credentials.mjs';
2
+ import { redactUrlSecrets } from '../../domain/url-secrets.mjs';
3
3
 
4
4
  const MILLISECONDS_PER_SECOND = 1e3;
5
5
  const MILLISECONDS_PER_MINUTE = 6e4;
@@ -41,16 +41,18 @@ class TerminalLogger {
41
41
  }
42
42
  const name = groupColor(this.#palette, group)(`openapi-ts:${group ?? "info"}`);
43
43
  const time = durationMs === void 0 ? " " : this.#palette.green(` ${formatDuration(durationMs)} `);
44
- const text = redactUrlCredentials(message);
44
+ const text = redactUrlSecrets(message);
45
45
  this.#options.sink.debug(` ${this.#palette.bold(name)}${time}${text}`);
46
46
  }
47
47
  warn(message) {
48
48
  if (!this.#options.silent) {
49
- this.#options.sink.warn(this.#palette.yellow(` \u26A0 ${redactUrlCredentials(message)}`));
49
+ this.#options.sink.warn(this.#palette.yellow(` \u26A0 ${redactUrlSecrets(message)}`));
50
50
  }
51
51
  }
52
52
  error(message) {
53
- this.#options.sink.error(this.#palette.red(` \u2718 ${redactUrlCredentials(message)}`));
53
+ if (!this.#options.silent) {
54
+ this.#options.sink.error(this.#palette.red(` \u2718 ${redactUrlSecrets(message)}`));
55
+ }
54
56
  }
55
57
  }
56
58
  function createTerminalLogger(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"terminal-logger.mjs","sources":["../../../src/adapters/terminal-logger/terminal-logger.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport type { DebugGroup, Logger } from \"../../application/ports/logger.js\";\nimport { redactUrlCredentials } from \"../../domain/url-credentials.js\";\n\n/**\n * The Logger port on a terminal, with the original output format: ` ⚠ ` warnings, ` ✘ `\n * errors, and `openapi-ts:<group>` debug lines filtered by `DEBUG` (ENGINEERING_PLAN 4.5). No\n * line shows the user info of a URL.\n */\n\n/** Where the lines go: `console` in production, a recording sink in tests. */\nexport interface TerminalSink {\n debug(line: string): void;\n warn(line: string): void;\n error(line: string): void;\n}\n\nexport interface TerminalLoggerOptions {\n /** Drop warnings (errors and debug lines are still written). */\n readonly silent: boolean;\n /** The value of `DEBUG`: `*`, `openapi-ts:*` or `openapi-ts:<group>` turn debug lines on. */\n readonly debugFilter: string | undefined;\n readonly useColors: boolean;\n readonly sink: TerminalSink;\n}\n\ntype Colors = ReturnType<typeof colors.create>;\n\nconst MILLISECONDS_PER_SECOND = 1000;\nconst MILLISECONDS_PER_MINUTE = 60_000;\n\n/** A duration as the original prints it: one decimal, in ms, s or m. */\nexport function formatDuration(milliseconds: number): string {\n if (milliseconds < MILLISECONDS_PER_SECOND) {\n return `${Math.round(10 * milliseconds) / 10}ms`;\n }\n if (milliseconds < MILLISECONDS_PER_MINUTE) {\n return `${Math.round(milliseconds / 100) / 10}s`;\n }\n return `${Math.round(milliseconds / 6000) / 10}m`;\n}\n\nfunction groupColor(palette: Colors, group: DebugGroup | undefined): (text: string) => string {\n const byGroup: Readonly<Partial<Record<DebugGroup, (text: string) => string>>> = {\n redoc: palette.cyanBright,\n lint: palette.yellowBright,\n bundle: palette.magentaBright,\n ts: palette.blueBright,\n };\n return (group && byGroup[group]) || palette.whiteBright;\n}\n\n/** Whether `DEBUG` asks for this group (the original check, case-insensitive for the group). */\nexport function isDebugEnabled(filter: string | undefined, group: DebugGroup | undefined): boolean {\n if (!filter) {\n return false;\n }\n return (\n !group ||\n filter === \"*\" ||\n filter === \"openapi-ts:*\" ||\n filter.toLocaleLowerCase() === `openapi-ts:${group.toLocaleLowerCase()}`\n );\n}\n\nclass TerminalLogger implements Logger {\n readonly #options: TerminalLoggerOptions;\n readonly #palette: Colors;\n\n constructor(options: TerminalLoggerOptions) {\n this.#options = options;\n this.#palette = colors.create();\n this.#palette.enabled = options.useColors;\n }\n\n debug(message: string, group?: DebugGroup, durationMs?: number): void {\n if (!isDebugEnabled(this.#options.debugFilter, group)) {\n return;\n }\n const name = groupColor(this.#palette, group)(`openapi-ts:${group ?? \"info\"}`);\n // The original wrote no space without a duration (`openapi-ts:lintIgnored …`).\n const time =\n durationMs === undefined ? \" \" : this.#palette.green(` ${formatDuration(durationMs)} `);\n const text = redactUrlCredentials(message);\n this.#options.sink.debug(` ${this.#palette.bold(name)}${time}${text}`);\n }\n\n warn(message: string): void {\n if (!this.#options.silent) {\n this.#options.sink.warn(this.#palette.yellow(` ⚠ ${redactUrlCredentials(message)}`));\n }\n }\n\n error(message: string): void {\n this.#options.sink.error(this.#palette.red(` ✘ ${redactUrlCredentials(message)}`));\n }\n}\n\n/** A Logger that writes to a terminal sink. */\nexport function createTerminalLogger(options: TerminalLoggerOptions): Logger {\n return new TerminalLogger(options);\n}\n"],"names":[],"mappings":";;;AA4BA,MAAM,uBAAA,GAA0B,GAAA;AAChC,MAAM,uBAAA,GAA0B,GAAA;AAGzB,SAAS,eAAe,YAAA,EAA8B;AAC3D,EAAA,IAAI,eAAe,uBAAA,EAAyB;AAC1C,IAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,EAAA,GAAK,YAAY,IAAI,EAAE,CAAA,EAAA,CAAA;AAAA,EAC9C;AACA,EAAA,IAAI,eAAe,uBAAA,EAAyB;AAC1C,IAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,YAAA,GAAe,GAAG,IAAI,EAAE,CAAA,CAAA,CAAA;AAAA,EAC/C;AACA,EAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,YAAA,GAAe,GAAI,IAAI,EAAE,CAAA,CAAA,CAAA;AAChD;AAEA,SAAS,UAAA,CAAW,SAAiB,KAAA,EAAyD;AAC5F,EAAA,MAAM,OAAA,GAA2E;AAAA,IAC/E,OAAO,OAAA,CAAQ,UAAA;AAAA,IACf,MAAM,OAAA,CAAQ,YAAA;AAAA,IACd,QAAQ,OAAA,CAAQ,aAAA;AAAA,IAChB,IAAI,OAAA,CAAQ;AAAA,GACd;AACA,EAAA,OAAQ,KAAA,IAAS,OAAA,CAAQ,KAAK,CAAA,IAAM,OAAA,CAAQ,WAAA;AAC9C;AAGO,SAAS,cAAA,CAAe,QAA4B,KAAA,EAAwC;AACjG,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OACE,CAAC,KAAA,IACD,MAAA,KAAW,GAAA,IACX,MAAA,KAAW,cAAA,IAC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AAK,IAAA,CAAK,QAAA,CAAS,MAAA,CAAO,CAAA,SAAA,EAAO,oBAAA,CAAqB,OAAO,CAAC,CAAA,CAAE,CAAC,CAAA;AAAA,IACtF;AAAA,EACF;AAAA,EAEA,MAAM,OAAA,EAAuB;AAC3B,IAAA,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,CAAA,SAAA,EAAO,oBAAA,CAAqB,OAAO,CAAC,CAAA,CAAE,CAAC,CAAA;AAAA,EACpF;AACF;AAGO,SAAS,qBAAqB,OAAA,EAAwC;AAC3E,EAAA,OAAO,IAAI,eAAe,OAAO,CAAA;AACnC;;"}
1
+ {"version":3,"file":"terminal-logger.mjs","sources":["../../../src/adapters/terminal-logger/terminal-logger.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport type { DebugGroup, Logger } from \"../../application/ports/logger.js\";\nimport { redactUrlSecrets } from \"../../domain/url-secrets.js\";\n\n/**\n * The Logger port on a terminal, with the original output format: ` ⚠ ` warnings, ` ✘ `\n * errors, and `openapi-ts:<group>` debug lines filtered by `DEBUG` (ENGINEERING_PLAN 4.5). No\n * line shows the user info of a URL.\n */\n\n/** Where the lines go: `console` in production, a recording sink in tests. */\nexport interface TerminalSink {\n debug(line: string): void;\n warn(line: string): void;\n error(line: string): void;\n}\n\nexport interface TerminalLoggerOptions {\n /**\n * Drop warnings and error lines; debug lines, which `DEBUG` asks for, are still written. The\n * error lines are the problems of a document that fails to load, which the thrown error lists.\n */\n readonly silent: boolean;\n /** The value of `DEBUG`: `*`, `openapi-ts:*` or `openapi-ts:<group>` turn debug lines on. */\n readonly debugFilter: string | undefined;\n readonly useColors: boolean;\n readonly sink: TerminalSink;\n}\n\ntype Colors = ReturnType<typeof colors.create>;\n\nconst MILLISECONDS_PER_SECOND = 1000;\nconst MILLISECONDS_PER_MINUTE = 60_000;\n\n/** A duration as the original prints it: one decimal, in ms, s or m. */\nexport function formatDuration(milliseconds: number): string {\n if (milliseconds < MILLISECONDS_PER_SECOND) {\n return `${Math.round(10 * milliseconds) / 10}ms`;\n }\n if (milliseconds < MILLISECONDS_PER_MINUTE) {\n return `${Math.round(milliseconds / 100) / 10}s`;\n }\n return `${Math.round(milliseconds / 6000) / 10}m`;\n}\n\nfunction groupColor(palette: Colors, group: DebugGroup | undefined): (text: string) => string {\n const byGroup: Readonly<Partial<Record<DebugGroup, (text: string) => string>>> = {\n redoc: palette.cyanBright,\n lint: palette.yellowBright,\n bundle: palette.magentaBright,\n ts: palette.blueBright,\n };\n return (group && byGroup[group]) || palette.whiteBright;\n}\n\n/** Whether `DEBUG` asks for this group (the original check, case-insensitive for the group). */\nexport function isDebugEnabled(filter: string | undefined, group: DebugGroup | undefined): boolean {\n if (!filter) {\n return false;\n }\n return (\n !group ||\n filter === \"*\" ||\n filter === \"openapi-ts:*\" ||\n filter.toLocaleLowerCase() === `openapi-ts:${group.toLocaleLowerCase()}`\n );\n}\n\nclass TerminalLogger implements Logger {\n readonly #options: TerminalLoggerOptions;\n readonly #palette: Colors;\n\n constructor(options: TerminalLoggerOptions) {\n this.#options = options;\n this.#palette = colors.create();\n this.#palette.enabled = options.useColors;\n }\n\n debug(message: string, group?: DebugGroup, durationMs?: number): void {\n if (!isDebugEnabled(this.#options.debugFilter, group)) {\n return;\n }\n const name = groupColor(this.#palette, group)(`openapi-ts:${group ?? \"info\"}`);\n // The original wrote no space without a duration (`openapi-ts:lintIgnored …`).\n const time =\n durationMs === undefined ? \" \" : this.#palette.green(` ${formatDuration(durationMs)} `);\n const text = redactUrlSecrets(message);\n this.#options.sink.debug(` ${this.#palette.bold(name)}${time}${text}`);\n }\n\n warn(message: string): void {\n if (!this.#options.silent) {\n this.#options.sink.warn(this.#palette.yellow(` ⚠ ${redactUrlSecrets(message)}`));\n }\n }\n\n error(message: string): void {\n if (!this.#options.silent) {\n this.#options.sink.error(this.#palette.red(` ✘ ${redactUrlSecrets(message)}`));\n }\n }\n}\n\n/** A Logger that writes to a terminal sink. */\nexport function createTerminalLogger(options: TerminalLoggerOptions): Logger {\n return new TerminalLogger(options);\n}\n"],"names":[],"mappings":";;;AA+BA,MAAM,uBAAA,GAA0B,GAAA;AAChC,MAAM,uBAAA,GAA0B,GAAA;AAGzB,SAAS,eAAe,YAAA,EAA8B;AAC3D,EAAA,IAAI,eAAe,uBAAA,EAAyB;AAC1C,IAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,EAAA,GAAK,YAAY,IAAI,EAAE,CAAA,EAAA,CAAA;AAAA,EAC9C;AACA,EAAA,IAAI,eAAe,uBAAA,EAAyB;AAC1C,IAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,YAAA,GAAe,GAAG,IAAI,EAAE,CAAA,CAAA,CAAA;AAAA,EAC/C;AACA,EAAA,OAAO,GAAG,IAAA,CAAK,KAAA,CAAM,YAAA,GAAe,GAAI,IAAI,EAAE,CAAA,CAAA,CAAA;AAChD;AAEA,SAAS,UAAA,CAAW,SAAiB,KAAA,EAAyD;AAC5F,EAAA,MAAM,OAAA,GAA2E;AAAA,IAC/E,OAAO,OAAA,CAAQ,UAAA;AAAA,IACf,MAAM,OAAA,CAAQ,YAAA;AAAA,IACd,QAAQ,OAAA,CAAQ,aAAA;AAAA,IAChB,IAAI,OAAA,CAAQ;AAAA,GACd;AACA,EAAA,OAAQ,KAAA,IAAS,OAAA,CAAQ,KAAK,CAAA,IAAM,OAAA,CAAQ,WAAA;AAC9C;AAGO,SAAS,cAAA,CAAe,QAA4B,KAAA,EAAwC;AACjG,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OACE,CAAC,KAAA,IACD,MAAA,KAAW,GAAA,IACX,MAAA,KAAW,cAAA,IACX,MAAA,CAAO,iBAAA,EAAkB,KAAM,CAAA,WAAA,EAAc,KAAA,CAAM,iBAAA,EAAmB,CAAA,CAAA;AAE1E;AAEA,MAAM,cAAA,CAAiC;AAA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EACF;AAAA,EAEA,MAAM,OAAA,EAAuB;AAC3B,IAAA,IAAI,CAAC,IAAA,CAAK,QAAA,CAAS,MAAA,EAAQ;AACzB,MAAA,IAAA,CAAK,QAAA,CAAS,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,CAAA,SAAA,EAAO,gBAAA,CAAiB,OAAO,CAAC,CAAA,CAAE,CAAC,CAAA;AAAA,IAChF;AAAA,EACF;AACF;AAGO,SAAS,qBAAqB,OAAA,EAAwC;AAC3E,EAAA,OAAO,IAAI,eAAe,OAAO,CAAA;AACnC;;"}
@@ -3,6 +3,7 @@
3
3
  const node_perf_hooks = require('node:perf_hooks');
4
4
  const openapiCore = require('@redocly/openapi-core');
5
5
  const supportsColor = require('supports-color');
6
+ const nodeDeprecations = require('../adapters/node-deprecations/node-deprecations.cjs');
6
7
  const terminalLogger = require('../adapters/terminal-logger/terminal-logger.cjs');
7
8
 
8
9
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
@@ -13,18 +14,33 @@ function terminalSupportsColor() {
13
14
  const stdout = supportsColor__default.stdout;
14
15
  return Boolean(stdout) && stdout !== false && stdout.hasBasic !== false;
15
16
  }
17
+ const STDERR_SINK = {
18
+ // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
19
+ debug: (line) => console.error(line),
20
+ // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
21
+ warn: (line) => console.warn(line),
22
+ // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
23
+ error: (line) => console.error(line)
24
+ };
16
25
  function defaultLogger(silent) {
17
26
  return terminalLogger.createTerminalLogger({
18
27
  silent,
19
28
  debugFilter: process.env.DEBUG,
20
29
  useColors: terminalSupportsColor(),
21
- sink: console
30
+ sink: STDERR_SINK
22
31
  });
23
32
  }
33
+ function defaultDeprecationReporter() {
34
+ return nodeDeprecations.createNodeDeprecationReporter();
35
+ }
24
36
  const REMOTE_REF_TIMEOUT_MS = 6e4;
37
+ const MEBIBYTE = 1024 * 1024;
25
38
  const DEFAULT_REMOTE_DOCUMENT_LIMITS = {
26
39
  maxDocuments: 1e4,
27
- maxParallelFetches: 16
40
+ maxParallelFetches: 16,
41
+ maxDocumentBytes: 128 * MEBIBYTE,
42
+ maxTotalBytes: 256 * MEBIBYTE,
43
+ maxNodes: 8e6
28
44
  };
29
45
  function processCwd() {
30
46
  return process.cwd();
@@ -39,6 +55,7 @@ function defaultRedoclyConfig() {
39
55
 
40
56
  exports.DEFAULT_REMOTE_DOCUMENT_LIMITS = DEFAULT_REMOTE_DOCUMENT_LIMITS;
41
57
  exports.REMOTE_REF_TIMEOUT_MS = REMOTE_REF_TIMEOUT_MS;
58
+ exports.defaultDeprecationReporter = defaultDeprecationReporter;
42
59
  exports.defaultLogger = defaultLogger;
43
60
  exports.defaultRedoclyConfig = defaultRedoclyConfig;
44
61
  exports.monotonicNow = monotonicNow;
@@ -1 +1 @@
1
- {"version":3,"file":"default-ports.cjs","sources":["../../src/api/default-ports.ts"],"sourcesContent":["import { performance } from \"node:perf_hooks\";\nimport { createConfig, type Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport supportsColor from \"supports-color\";\nimport type { RemoteDocumentLimits } from \"../adapters/redocly-loader/remote-fetch.js\";\nimport { createTerminalLogger } from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\n\n/**\n * The default adapters of the Node API (ENGINEERING_PLAN 4.5): this module and the CLI's\n * composition root are where the process environment is read.\n */\n\n/** Colors when the terminal supports them, as the original decided. */\nexport function terminalSupportsColor(): boolean {\n const stdout = supportsColor.stdout;\n return Boolean(stdout) && stdout !== false && stdout.hasBasic !== false;\n}\n\n/** The terminal logger with `DEBUG` from the environment, writing to the console. */\nexport function defaultLogger(silent: boolean): Logger {\n return createTerminalLogger({\n silent,\n debugFilter: process.env.DEBUG,\n useColors: terminalSupportsColor(),\n sink: console,\n });\n}\n\n/**\n * How long one remote `$ref` (or a remote source) may take to load. Large documents (the 27 MB\n * Cloudflare spec) download in seconds; a minute covers slow hosts, while Node's own fetch would\n * wait five minutes for a server that never answers (ENGINEERING_PLAN 8.5).\n */\nexport const REMOTE_REF_TIMEOUT_MS = 60_000;\n\n/**\n * Bounds on the remote documents of one run (ADR-033). Large split documents have a few thousand\n * files, so 10,000 leaves room and still ends an endless fan-out. 16 parallel fetches keep a\n * multi-file document fast without exhausting local ports.\n */\nexport const DEFAULT_REMOTE_DOCUMENT_LIMITS: RemoteDocumentLimits = {\n maxDocuments: 10_000,\n maxParallelFetches: 16,\n};\n\n/** The working directory of the process: the default `cwd` of an inline source. */\nexport function processCwd(): string {\n return process.cwd();\n}\n\n/** A monotonic clock in milliseconds, for debug durations. */\nexport function monotonicNow(): number {\n return performance.now();\n}\n\n/** The default Redocly config: minimal rules, and duplicate operation IDs are an error. */\nexport function defaultRedoclyConfig(): Promise<RedoclyConfig> {\n const rules = { \"operation-operationId-unique\": { severity: \"error\" as const } };\n return createConfig({ rules }, { extends: [\"minimal\"] });\n}\n"],"names":["supportsColor","createTerminalLogger","performance","createConfig"],"mappings":";;;;;;;;;;;AAaO,SAAS,qBAAA,GAAiC;AAC/C,EAAA,MAAM,SAASA,sBAAA,CAAc,MAAA;AAC7B,EAAA,OAAO,QAAQ,MAAM,CAAA,IAAK,MAAA,KAAW,KAAA,IAAS,OAAO,QAAA,KAAa,KAAA;AACpE;AAGO,SAAS,cAAc,MAAA,EAAyB;AACrD,EAAA,OAAOC,mCAAA,CAAqB;AAAA,IAC1B,MAAA;AAAA,IACA,WAAA,EAAa,QAAQ,GAAA,CAAI,KAAA;AAAA,IACzB,WAAW,qBAAA,EAAsB;AAAA,IACjC,IAAA,EAAM;AAAA,GACP,CAAA;AACH;AAOO,MAAM,qBAAA,GAAwB;AAO9B,MAAM,8BAAA,GAAuD;AAAA,EAClE,YAAA,EAAc,GAAA;AAAA,EACd,kBAAA,EAAoB;AACtB;AAGO,SAAS,UAAA,GAAqB;AACnC,EAAA,OAAO,QAAQ,GAAA,EAAI;AACrB;AAGO,SAAS,YAAA,GAAuB;AACrC,EAAA,OAAOC,4BAAY,GAAA,EAAI;AACzB;AAGO,SAAS,oBAAA,GAA+C;AAC7D,EAAA,MAAM,QAAQ,EAAE,8BAAA,EAAgC,EAAE,QAAA,EAAU,SAAiB,EAAE;AAC/E,EAAA,OAAOC,wBAAA,CAAa,EAAE,KAAA,EAAM,EAAG,EAAE,OAAA,EAAS,CAAC,SAAS,CAAA,EAAG,CAAA;AACzD;;;;;;;;"}
1
+ {"version":3,"file":"default-ports.cjs","sources":["../../src/api/default-ports.ts"],"sourcesContent":["import { performance } from \"node:perf_hooks\";\nimport { createConfig, type Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport supportsColor from \"supports-color\";\nimport { createNodeDeprecationReporter } from \"../adapters/node-deprecations/node-deprecations.js\";\nimport type { RemoteDocumentLimits } from \"../adapters/redocly-loader/remote-fetch.js\";\nimport {\n createTerminalLogger,\n type TerminalSink,\n} from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DeprecationReporter } from \"../application/ports/deprecation-reporter.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\n\n/**\n * The default adapters of the Node API (ENGINEERING_PLAN 4.5): this module and the CLI's\n * composition root are where the process environment is read.\n */\n\n/** Colors when the terminal supports them, as the original decided. */\nexport function terminalSupportsColor(): boolean {\n const stdout = supportsColor.stdout;\n return Boolean(stdout) && stdout !== false && stdout.hasBasic !== false;\n}\n\n/**\n * Every line of the logger goes to stderr: the CLI writes the types to stdout, and `console.debug`\n * writes there too, so debug lines would end up inside the generated file.\n */\nconst STDERR_SINK: TerminalSink = {\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n debug: (line) => console.error(line),\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n warn: (line) => console.warn(line),\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n error: (line) => console.error(line),\n};\n\n/** The terminal logger with `DEBUG` from the environment, writing to stderr. */\nexport function defaultLogger(silent: boolean): Logger {\n return createTerminalLogger({\n silent,\n debugFilter: process.env.DEBUG,\n useColors: terminalSupportsColor(),\n sink: STDERR_SINK,\n });\n}\n\n/** Deprecations as Node.js `DeprecationWarning`s, each code once per process. */\nexport function defaultDeprecationReporter(): DeprecationReporter {\n return createNodeDeprecationReporter();\n}\n\n/**\n * How long one remote `$ref` (or a remote source) may take to load. Large documents (the 27 MB\n * Cloudflare spec) download in seconds; a minute covers slow hosts, while Node's own fetch would\n * wait five minutes for a server that never answers (ENGINEERING_PLAN 8.5).\n */\nexport const REMOTE_REF_TIMEOUT_MS = 60_000;\n\nconst MEBIBYTE = 1024 * 1024;\n\n/**\n * Bounds on the remote documents of one schema (ADR-033). Large split documents have a few thousand\n * files, so 10,000 leaves room and still ends an endless fan-out. 16 parallel fetches keep a\n * multi-file document fast without exhausting local ports.\n *\n * The size limits count decoded bytes and parsed nodes (threat model T2, ADR-033 decision 6).\n * The largest document of the 1,820-entry compatibility corpus is Microsoft Graph beta: 71 MiB,\n * 2.65 million nodes (keys and values), 1.6 GB peak memory when loaded from a URL. A remote body\n * took about 7 bytes of memory per byte of text and 110 per node in our measurements, so 128 MiB\n * per document (1.8 times Graph beta), 256 MiB per schema (a split document may be twice as\n * large) and 8 million nodes per schema (3 times Graph beta) let crafted documents finish within\n * a heap of 2 GB; with the default heap of 4 GB they peak at about 1.2 to 2.3 GB.\n */\nexport const DEFAULT_REMOTE_DOCUMENT_LIMITS: RemoteDocumentLimits = {\n maxDocuments: 10_000,\n maxParallelFetches: 16,\n maxDocumentBytes: 128 * MEBIBYTE,\n maxTotalBytes: 256 * MEBIBYTE,\n maxNodes: 8_000_000,\n};\n\n/** The working directory of the process: the default `cwd` of an inline source. */\nexport function processCwd(): string {\n return process.cwd();\n}\n\n/** A monotonic clock in milliseconds, for debug durations. */\nexport function monotonicNow(): number {\n return performance.now();\n}\n\n/** The default Redocly config: minimal rules, and duplicate operation IDs are an error. */\nexport function defaultRedoclyConfig(): Promise<RedoclyConfig> {\n const rules = { \"operation-operationId-unique\": { severity: \"error\" as const } };\n return createConfig({ rules }, { extends: [\"minimal\"] });\n}\n"],"names":["supportsColor","createTerminalLogger","createNodeDeprecationReporter","performance","createConfig"],"mappings":";;;;;;;;;;;;AAkBO,SAAS,qBAAA,GAAiC;AAC/C,EAAA,MAAM,SAASA,sBAAA,CAAc,MAAA;AAC7B,EAAA,OAAO,QAAQ,MAAM,CAAA,IAAK,MAAA,KAAW,KAAA,IAAS,OAAO,QAAA,KAAa,KAAA;AACpE;AAMA,MAAM,WAAA,GAA4B;AAAA;AAAA,EAEhC,KAAA,EAAO,CAAC,IAAA,KAAS,OAAA,CAAQ,MAAM,IAAI,CAAA;AAAA;AAAA,EAEnC,IAAA,EAAM,CAAC,IAAA,KAAS,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA;AAAA,EAEjC,KAAA,EAAO,CAAC,IAAA,KAAS,OAAA,CAAQ,MAAM,IAAI;AACrC,CAAA;AAGO,SAAS,cAAc,MAAA,EAAyB;AACrD,EAAA,OAAOC,mCAAA,CAAqB;AAAA,IAC1B,MAAA;AAAA,IACA,WAAA,EAAa,QAAQ,GAAA,CAAI,KAAA;AAAA,IACzB,WAAW,qBAAA,EAAsB;AAAA,IACjC,IAAA,EAAM;AAAA,GACP,CAAA;AACH;AAGO,SAAS,0BAAA,GAAkD;AAChE,EAAA,OAAOC,8CAAA,EAA8B;AACvC;AAOO,MAAM,qBAAA,GAAwB;AAErC,MAAM,WAAW,IAAA,GAAO,IAAA;AAejB,MAAM,8BAAA,GAAuD;AAAA,EAClE,YAAA,EAAc,GAAA;AAAA,EACd,kBAAA,EAAoB,EAAA;AAAA,EACpB,kBAAkB,GAAA,GAAM,QAAA;AAAA,EACxB,eAAe,GAAA,GAAM,QAAA;AAAA,EACrB,QAAA,EAAU;AACZ;AAGO,SAAS,UAAA,GAAqB;AACnC,EAAA,OAAO,QAAQ,GAAA,EAAI;AACrB;AAGO,SAAS,YAAA,GAAuB;AACrC,EAAA,OAAOC,4BAAY,GAAA,EAAI;AACzB;AAGO,SAAS,oBAAA,GAA+C;AAC7D,EAAA,MAAM,QAAQ,EAAE,8BAAA,EAAgC,EAAE,QAAA,EAAU,SAAiB,EAAE;AAC/E,EAAA,OAAOC,wBAAA,CAAa,EAAE,KAAA,EAAM,EAAG,EAAE,OAAA,EAAS,CAAC,SAAS,CAAA,EAAG,CAAA;AACzD;;;;;;;;;"}
@@ -1,24 +1,40 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { createConfig } from '@redocly/openapi-core';
3
3
  import supportsColor from 'supports-color';
4
+ import { createNodeDeprecationReporter } from '../adapters/node-deprecations/node-deprecations.mjs';
4
5
  import { createTerminalLogger } from '../adapters/terminal-logger/terminal-logger.mjs';
5
6
 
6
7
  function terminalSupportsColor() {
7
8
  const stdout = supportsColor.stdout;
8
9
  return Boolean(stdout) && stdout !== false && stdout.hasBasic !== false;
9
10
  }
11
+ const STDERR_SINK = {
12
+ // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
13
+ debug: (line) => console.error(line),
14
+ // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
15
+ warn: (line) => console.warn(line),
16
+ // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
17
+ error: (line) => console.error(line)
18
+ };
10
19
  function defaultLogger(silent) {
11
20
  return createTerminalLogger({
12
21
  silent,
13
22
  debugFilter: process.env.DEBUG,
14
23
  useColors: terminalSupportsColor(),
15
- sink: console
24
+ sink: STDERR_SINK
16
25
  });
17
26
  }
27
+ function defaultDeprecationReporter() {
28
+ return createNodeDeprecationReporter();
29
+ }
18
30
  const REMOTE_REF_TIMEOUT_MS = 6e4;
31
+ const MEBIBYTE = 1024 * 1024;
19
32
  const DEFAULT_REMOTE_DOCUMENT_LIMITS = {
20
33
  maxDocuments: 1e4,
21
- maxParallelFetches: 16
34
+ maxParallelFetches: 16,
35
+ maxDocumentBytes: 128 * MEBIBYTE,
36
+ maxTotalBytes: 256 * MEBIBYTE,
37
+ maxNodes: 8e6
22
38
  };
23
39
  function processCwd() {
24
40
  return process.cwd();
@@ -31,5 +47,5 @@ function defaultRedoclyConfig() {
31
47
  return createConfig({ rules }, { extends: ["minimal"] });
32
48
  }
33
49
 
34
- export { DEFAULT_REMOTE_DOCUMENT_LIMITS, REMOTE_REF_TIMEOUT_MS, defaultLogger, defaultRedoclyConfig, monotonicNow, processCwd, terminalSupportsColor };
50
+ export { DEFAULT_REMOTE_DOCUMENT_LIMITS, REMOTE_REF_TIMEOUT_MS, defaultDeprecationReporter, defaultLogger, defaultRedoclyConfig, monotonicNow, processCwd, terminalSupportsColor };
35
51
  //# sourceMappingURL=default-ports.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-ports.mjs","sources":["../../src/api/default-ports.ts"],"sourcesContent":["import { performance } from \"node:perf_hooks\";\nimport { createConfig, type Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport supportsColor from \"supports-color\";\nimport type { RemoteDocumentLimits } from \"../adapters/redocly-loader/remote-fetch.js\";\nimport { createTerminalLogger } from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\n\n/**\n * The default adapters of the Node API (ENGINEERING_PLAN 4.5): this module and the CLI's\n * composition root are where the process environment is read.\n */\n\n/** Colors when the terminal supports them, as the original decided. */\nexport function terminalSupportsColor(): boolean {\n const stdout = supportsColor.stdout;\n return Boolean(stdout) && stdout !== false && stdout.hasBasic !== false;\n}\n\n/** The terminal logger with `DEBUG` from the environment, writing to the console. */\nexport function defaultLogger(silent: boolean): Logger {\n return createTerminalLogger({\n silent,\n debugFilter: process.env.DEBUG,\n useColors: terminalSupportsColor(),\n sink: console,\n });\n}\n\n/**\n * How long one remote `$ref` (or a remote source) may take to load. Large documents (the 27 MB\n * Cloudflare spec) download in seconds; a minute covers slow hosts, while Node's own fetch would\n * wait five minutes for a server that never answers (ENGINEERING_PLAN 8.5).\n */\nexport const REMOTE_REF_TIMEOUT_MS = 60_000;\n\n/**\n * Bounds on the remote documents of one run (ADR-033). Large split documents have a few thousand\n * files, so 10,000 leaves room and still ends an endless fan-out. 16 parallel fetches keep a\n * multi-file document fast without exhausting local ports.\n */\nexport const DEFAULT_REMOTE_DOCUMENT_LIMITS: RemoteDocumentLimits = {\n maxDocuments: 10_000,\n maxParallelFetches: 16,\n};\n\n/** The working directory of the process: the default `cwd` of an inline source. */\nexport function processCwd(): string {\n return process.cwd();\n}\n\n/** A monotonic clock in milliseconds, for debug durations. */\nexport function monotonicNow(): number {\n return performance.now();\n}\n\n/** The default Redocly config: minimal rules, and duplicate operation IDs are an error. */\nexport function defaultRedoclyConfig(): Promise<RedoclyConfig> {\n const rules = { \"operation-operationId-unique\": { severity: \"error\" as const } };\n return createConfig({ rules }, { extends: [\"minimal\"] });\n}\n"],"names":[],"mappings":";;;;;AAaO,SAAS,qBAAA,GAAiC;AAC/C,EAAA,MAAM,SAAS,aAAA,CAAc,MAAA;AAC7B,EAAA,OAAO,QAAQ,MAAM,CAAA,IAAK,MAAA,KAAW,KAAA,IAAS,OAAO,QAAA,KAAa,KAAA;AACpE;AAGO,SAAS,cAAc,MAAA,EAAyB;AACrD,EAAA,OAAO,oBAAA,CAAqB;AAAA,IAC1B,MAAA;AAAA,IACA,WAAA,EAAa,QAAQ,GAAA,CAAI,KAAA;AAAA,IACzB,WAAW,qBAAA,EAAsB;AAAA,IACjC,IAAA,EAAM;AAAA,GACP,CAAA;AACH;AAOO,MAAM,qBAAA,GAAwB;AAO9B,MAAM,8BAAA,GAAuD;AAAA,EAClE,YAAA,EAAc,GAAA;AAAA,EACd,kBAAA,EAAoB;AACtB;AAGO,SAAS,UAAA,GAAqB;AACnC,EAAA,OAAO,QAAQ,GAAA,EAAI;AACrB;AAGO,SAAS,YAAA,GAAuB;AACrC,EAAA,OAAO,YAAY,GAAA,EAAI;AACzB;AAGO,SAAS,oBAAA,GAA+C;AAC7D,EAAA,MAAM,QAAQ,EAAE,8BAAA,EAAgC,EAAE,QAAA,EAAU,SAAiB,EAAE;AAC/E,EAAA,OAAO,YAAA,CAAa,EAAE,KAAA,EAAM,EAAG,EAAE,OAAA,EAAS,CAAC,SAAS,CAAA,EAAG,CAAA;AACzD;;"}
1
+ {"version":3,"file":"default-ports.mjs","sources":["../../src/api/default-ports.ts"],"sourcesContent":["import { performance } from \"node:perf_hooks\";\nimport { createConfig, type Config as RedoclyConfig } from \"@redocly/openapi-core\";\nimport supportsColor from \"supports-color\";\nimport { createNodeDeprecationReporter } from \"../adapters/node-deprecations/node-deprecations.js\";\nimport type { RemoteDocumentLimits } from \"../adapters/redocly-loader/remote-fetch.js\";\nimport {\n createTerminalLogger,\n type TerminalSink,\n} from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DeprecationReporter } from \"../application/ports/deprecation-reporter.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\n\n/**\n * The default adapters of the Node API (ENGINEERING_PLAN 4.5): this module and the CLI's\n * composition root are where the process environment is read.\n */\n\n/** Colors when the terminal supports them, as the original decided. */\nexport function terminalSupportsColor(): boolean {\n const stdout = supportsColor.stdout;\n return Boolean(stdout) && stdout !== false && stdout.hasBasic !== false;\n}\n\n/**\n * Every line of the logger goes to stderr: the CLI writes the types to stdout, and `console.debug`\n * writes there too, so debug lines would end up inside the generated file.\n */\nconst STDERR_SINK: TerminalSink = {\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n debug: (line) => console.error(line),\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n warn: (line) => console.warn(line),\n // biome-ignore lint/suspicious/noConsole: the terminal logger's own channel\n error: (line) => console.error(line),\n};\n\n/** The terminal logger with `DEBUG` from the environment, writing to stderr. */\nexport function defaultLogger(silent: boolean): Logger {\n return createTerminalLogger({\n silent,\n debugFilter: process.env.DEBUG,\n useColors: terminalSupportsColor(),\n sink: STDERR_SINK,\n });\n}\n\n/** Deprecations as Node.js `DeprecationWarning`s, each code once per process. */\nexport function defaultDeprecationReporter(): DeprecationReporter {\n return createNodeDeprecationReporter();\n}\n\n/**\n * How long one remote `$ref` (or a remote source) may take to load. Large documents (the 27 MB\n * Cloudflare spec) download in seconds; a minute covers slow hosts, while Node's own fetch would\n * wait five minutes for a server that never answers (ENGINEERING_PLAN 8.5).\n */\nexport const REMOTE_REF_TIMEOUT_MS = 60_000;\n\nconst MEBIBYTE = 1024 * 1024;\n\n/**\n * Bounds on the remote documents of one schema (ADR-033). Large split documents have a few thousand\n * files, so 10,000 leaves room and still ends an endless fan-out. 16 parallel fetches keep a\n * multi-file document fast without exhausting local ports.\n *\n * The size limits count decoded bytes and parsed nodes (threat model T2, ADR-033 decision 6).\n * The largest document of the 1,820-entry compatibility corpus is Microsoft Graph beta: 71 MiB,\n * 2.65 million nodes (keys and values), 1.6 GB peak memory when loaded from a URL. A remote body\n * took about 7 bytes of memory per byte of text and 110 per node in our measurements, so 128 MiB\n * per document (1.8 times Graph beta), 256 MiB per schema (a split document may be twice as\n * large) and 8 million nodes per schema (3 times Graph beta) let crafted documents finish within\n * a heap of 2 GB; with the default heap of 4 GB they peak at about 1.2 to 2.3 GB.\n */\nexport const DEFAULT_REMOTE_DOCUMENT_LIMITS: RemoteDocumentLimits = {\n maxDocuments: 10_000,\n maxParallelFetches: 16,\n maxDocumentBytes: 128 * MEBIBYTE,\n maxTotalBytes: 256 * MEBIBYTE,\n maxNodes: 8_000_000,\n};\n\n/** The working directory of the process: the default `cwd` of an inline source. */\nexport function processCwd(): string {\n return process.cwd();\n}\n\n/** A monotonic clock in milliseconds, for debug durations. */\nexport function monotonicNow(): number {\n return performance.now();\n}\n\n/** The default Redocly config: minimal rules, and duplicate operation IDs are an error. */\nexport function defaultRedoclyConfig(): Promise<RedoclyConfig> {\n const rules = { \"operation-operationId-unique\": { severity: \"error\" as const } };\n return createConfig({ rules }, { extends: [\"minimal\"] });\n}\n"],"names":[],"mappings":";;;;;;AAkBO,SAAS,qBAAA,GAAiC;AAC/C,EAAA,MAAM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A,EAAS,CAAC,SAAS,CAAA,EAAG,CAAA;AACzD;;"}
@@ -15,7 +15,7 @@ function warningOf(conflict) {
15
15
  return `${member}: the discriminator "${propertyName}" of ${owner} gives this schema the value ${listed(values)}, which its "${propertyName}" property does not allow (${listed(allowed)}), so no value of the schema matches the discriminator. ${rule} See ${DOCS_URL}`;
16
16
  }
17
17
  function warnDiscriminatorValueConflicts(document, fixes, logger) {
18
- const isUnionReused = fixes.includes(outputFixes.OutputFix.ALLOF_DISCRIMINATED_UNION);
18
+ const isUnionReused = fixes.includes(outputFixes.FIX.ALLOF_DISCRIMINATED_UNION);
19
19
  for (const conflict of discriminatorConflicts.findDiscriminatorValueConflicts(document, { isUnionReused })) {
20
20
  logger.warn(warnings.warningText(warningOf(conflict), warnings.WARNING_CODES.DISCRIMINATOR_VALUE_NOT_ALLOWED));
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"discriminator-conflict-warnings.cjs","sources":["../../src/api/discriminator-conflict-warnings.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport {\n type DiscriminatorValueConflict,\n findDiscriminatorValueConflicts,\n} from \"../domain/openapi/discriminator-conflicts.js\";\nimport { OutputFix } from \"../domain/output-fixes.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\n\nconst DOCS_BASE_URL = \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs\";\nconst DOCS_URL = `${DOCS_BASE_URL}/advanced.md#discriminator-values`;\n\nfunction listed(values: readonly unknown[]): string {\n return values.map((value) => JSON.stringify(value)).join(\", \");\n}\n\nfunction warningOf(conflict: DiscriminatorValueConflict): string {\n const { member, owner, propertyName, values, allowed, isImplicit } = conflict;\n const rule = isImplicit\n ? \"A Discriminator Object without a mapping entry for a schema gives it its schema name as \" +\n `the value; add a mapping entry such as ${JSON.stringify(allowed[0])}: \"${member}\".`\n : \"The Discriminator Object maps these values to the schema; map the values it allows.\";\n return (\n `${member}: the discriminator \"${propertyName}\" of ${owner} gives this schema the value ` +\n `${listed(values)}, which its \"${propertyName}\" property does not allow ` +\n `(${listed(allowed)}), so no value of the schema matches the discriminator. ${rule} ` +\n `See ${DOCS_URL}`\n );\n}\n\n/**\n * Warn once per discriminator member whose value its own property does not allow. The members\n * depend on the run's fixes (`allof-discriminated-union`).\n */\nexport function warnDiscriminatorValueConflicts(\n document: unknown,\n fixes: readonly OutputFix[],\n logger: Logger,\n): void {\n const isUnionReused = fixes.includes(OutputFix.ALLOF_DISCRIMINATED_UNION);\n for (const conflict of findDiscriminatorValueConflicts(document, { isUnionReused })) {\n logger.warn(warningText(warningOf(conflict), WARNING_CODES.DISCRIMINATOR_VALUE_NOT_ALLOWED));\n }\n}\n"],"names":["OutputFix","findDiscriminatorValueConflicts","warningText","WARNING_CODES"],"mappings":";;;;;;AAQA,MAAM,aAAA,GAAgB,qEAAA;AACtB,MAAM,QAAA,GAAW,GAAG,aAAa,CAAA,iCAAA,CAAA;AAEjC,SAAS,OAAO,MAAA,EAAoC;AAClD,EAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAU,IAAA,CAAK,UAAU,KAAK,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA;AAC/D;AAEA,SAAS,UAAU,QAAA,EAA8C;AAC/D,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,EAAO,cAAc,MAAA,EAAQ,OAAA,EAAS,YAAW,GAAI,QAAA;AACrE,EAAA,MAAM,IAAA,GAAO,UAAA,GACT,CAAA,+HAAA,EAC0C,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,CAAC,CAAC,CAAC,CAAA,GAAA,EAAM,MAAM,CAAA,EAAA,CAAA,GAChF,qFAAA;AACJ,EAAA,OACE,GAAG,MAAM,CAAA,qBAAA,EAAwB,YAAY,CAAA,KAAA,EAAQ,KAAK,gCACvD,MAAA,CAAO,MAAM,CAAC,CAAA,aAAA,EAAgB,YAAY,8BACzC,MAAA,CAAO,OAAO,CAAC,CAAA,wDAAA,EAA2D,IAAI,QAC3E,QAAQ,CAAA,CAAA;AAEnB;AAMO,SAAS,+BAAA,CACd,QAAA,EACA,KAAA,EACA,MAAA,EACM;AACN,EAAA,MAAM,aAAA,GAAgB,KAAA,CAAM,QAAA,CAASA,qBAAA,CAAU,yBAAyB,CAAA;AACxE,EAAA,KAAA,MAAW,YAAYC,sDAAA,CAAgC,QAAA,EAAU,EAAE,aAAA,EAAe,CAAA,EAAG;AACnF,IAAA,MAAA,CAAO,KAAKC,oBAAA,CAAY,SAAA,CAAU,QAAQ,CAAA,EAAGC,sBAAA,CAAc,+BAA+B,CAAC,CAAA;AAAA,EAC7F;AACF;;"}
1
+ {"version":3,"file":"discriminator-conflict-warnings.cjs","sources":["../../src/api/discriminator-conflict-warnings.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport {\n type DiscriminatorValueConflict,\n findDiscriminatorValueConflicts,\n} from \"../domain/openapi/discriminator-conflicts.js\";\nimport { FIX, type OutputFix } from \"../domain/output-fixes.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\n\nconst DOCS_BASE_URL = \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs\";\nconst DOCS_URL = `${DOCS_BASE_URL}/advanced.md#discriminator-values`;\n\nfunction listed(values: readonly unknown[]): string {\n return values.map((value) => JSON.stringify(value)).join(\", \");\n}\n\nfunction warningOf(conflict: DiscriminatorValueConflict): string {\n const { member, owner, propertyName, values, allowed, isImplicit } = conflict;\n const rule = isImplicit\n ? \"A Discriminator Object without a mapping entry for a schema gives it its schema name as \" +\n `the value; add a mapping entry such as ${JSON.stringify(allowed[0])}: \"${member}\".`\n : \"The Discriminator Object maps these values to the schema; map the values it allows.\";\n return (\n `${member}: the discriminator \"${propertyName}\" of ${owner} gives this schema the value ` +\n `${listed(values)}, which its \"${propertyName}\" property does not allow ` +\n `(${listed(allowed)}), so no value of the schema matches the discriminator. ${rule} ` +\n `See ${DOCS_URL}`\n );\n}\n\n/**\n * Warn once per discriminator member whose value its own property does not allow. The members\n * depend on the run's fixes (`allof-discriminated-union`).\n */\nexport function warnDiscriminatorValueConflicts(\n document: unknown,\n fixes: readonly OutputFix[],\n logger: Logger,\n): void {\n const isUnionReused = fixes.includes(FIX.ALLOF_DISCRIMINATED_UNION);\n for (const conflict of findDiscriminatorValueConflicts(document, { isUnionReused })) {\n logger.warn(warningText(warningOf(conflict), WARNING_CODES.DISCRIMINATOR_VALUE_NOT_ALLOWED));\n }\n}\n"],"names":["FIX","findDiscriminatorValueConflicts","warningText","WARNING_CODES"],"mappings":";;;;;;AAQA,MAAM,aAAA,GAAgB,qEAAA;AACtB,MAAM,QAAA,GAAW,GAAG,aAAa,CAAA,iCAAA,CAAA;AAEjC,SAAS,OAAO,MAAA,EAAoC;AAClD,EAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAU,IAAA,CAAK,UAAU,KAAK,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA;AAC/D;AAEA,SAAS,UAAU,QAAA,EAA8C;AAC/D,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,EAAO,cAAc,MAAA,EAAQ,OAAA,EAAS,YAAW,GAAI,QAAA;AACrE,EAAA,MAAM,IAAA,GAAO,UAAA,GACT,CAAA,+HAAA,EAC0C,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,CAAC,CAAC,CAAC,CAAA,GAAA,EAAM,MAAM,CAAA,EAAA,CAAA,GAChF,qFAAA;AACJ,EAAA,OACE,GAAG,MAAM,CAAA,qBAAA,EAAwB,YAAY,CAAA,KAAA,EAAQ,KAAK,gCACvD,MAAA,CAAO,MAAM,CAAC,CAAA,aAAA,EAAgB,YAAY,8BACzC,MAAA,CAAO,OAAO,CAAC,CAAA,wDAAA,EAA2D,IAAI,QAC3E,QAAQ,CAAA,CAAA;AAEnB;AAMO,SAAS,+BAAA,CACd,QAAA,EACA,KAAA,EACA,MAAA,EACM;AACN,EAAA,MAAM,aAAA,GAAgB,KAAA,CAAM,QAAA,CAASA,eAAA,CAAI,yBAAyB,CAAA;AAClE,EAAA,KAAA,MAAW,YAAYC,sDAAA,CAAgC,QAAA,EAAU,EAAE,aAAA,EAAe,CAAA,EAAG;AACnF,IAAA,MAAA,CAAO,KAAKC,oBAAA,CAAY,SAAA,CAAU,QAAQ,CAAA,EAAGC,sBAAA,CAAc,+BAA+B,CAAC,CAAA;AAAA,EAC7F;AACF;;"}
@@ -1,5 +1,5 @@
1
1
  import { findDiscriminatorValueConflicts } from '../domain/openapi/discriminator-conflicts.mjs';
2
- import { OutputFix } from '../domain/output-fixes.mjs';
2
+ import { FIX } from '../domain/output-fixes.mjs';
3
3
  import { warningText, WARNING_CODES } from '../domain/warnings.mjs';
4
4
 
5
5
  const DOCS_BASE_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs";
@@ -13,7 +13,7 @@ function warningOf(conflict) {
13
13
  return `${member}: the discriminator "${propertyName}" of ${owner} gives this schema the value ${listed(values)}, which its "${propertyName}" property does not allow (${listed(allowed)}), so no value of the schema matches the discriminator. ${rule} See ${DOCS_URL}`;
14
14
  }
15
15
  function warnDiscriminatorValueConflicts(document, fixes, logger) {
16
- const isUnionReused = fixes.includes(OutputFix.ALLOF_DISCRIMINATED_UNION);
16
+ const isUnionReused = fixes.includes(FIX.ALLOF_DISCRIMINATED_UNION);
17
17
  for (const conflict of findDiscriminatorValueConflicts(document, { isUnionReused })) {
18
18
  logger.warn(warningText(warningOf(conflict), WARNING_CODES.DISCRIMINATOR_VALUE_NOT_ALLOWED));
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"discriminator-conflict-warnings.mjs","sources":["../../src/api/discriminator-conflict-warnings.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport {\n type DiscriminatorValueConflict,\n findDiscriminatorValueConflicts,\n} from \"../domain/openapi/discriminator-conflicts.js\";\nimport { OutputFix } from \"../domain/output-fixes.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\n\nconst DOCS_BASE_URL = \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs\";\nconst DOCS_URL = `${DOCS_BASE_URL}/advanced.md#discriminator-values`;\n\nfunction listed(values: readonly unknown[]): string {\n return values.map((value) => JSON.stringify(value)).join(\", \");\n}\n\nfunction warningOf(conflict: DiscriminatorValueConflict): string {\n const { member, owner, propertyName, values, allowed, isImplicit } = conflict;\n const rule = isImplicit\n ? \"A Discriminator Object without a mapping entry for a schema gives it its schema name as \" +\n `the value; add a mapping entry such as ${JSON.stringify(allowed[0])}: \"${member}\".`\n : \"The Discriminator Object maps these values to the schema; map the values it allows.\";\n return (\n `${member}: the discriminator \"${propertyName}\" of ${owner} gives this schema the value ` +\n `${listed(values)}, which its \"${propertyName}\" property does not allow ` +\n `(${listed(allowed)}), so no value of the schema matches the discriminator. ${rule} ` +\n `See ${DOCS_URL}`\n );\n}\n\n/**\n * Warn once per discriminator member whose value its own property does not allow. The members\n * depend on the run's fixes (`allof-discriminated-union`).\n */\nexport function warnDiscriminatorValueConflicts(\n document: unknown,\n fixes: readonly OutputFix[],\n logger: Logger,\n): void {\n const isUnionReused = fixes.includes(OutputFix.ALLOF_DISCRIMINATED_UNION);\n for (const conflict of findDiscriminatorValueConflicts(document, { isUnionReused })) {\n logger.warn(warningText(warningOf(conflict), WARNING_CODES.DISCRIMINATOR_VALUE_NOT_ALLOWED));\n }\n}\n"],"names":[],"mappings":";;;;AAQA,MAAM,aAAA,GAAgB,qEAAA;AACtB,MAAM,QAAA,GAAW,GAAG,aAAa,CAAA,iCAAA,CAAA;AAEjC,SAAS,OAAO,MAAA,EAAoC;AAClD,EAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAU,IAAA,CAAK,UAAU,KAAK,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA;AAC/D;AAEA,SAAS,UAAU,QAAA,EAA8C;AAC/D,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,EAAO,cAAc,MAAA,EAAQ,OAAA,EAAS,YAAW,GAAI,QAAA;AACrE,EAAA,MAAM,IAAA,GAAO,UAAA,GACT,CAAA,+HAAA,EAC0C,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,CAAC,CAAC,CAAC,CAAA,GAAA,EAAM,MAAM,CAAA,EAAA,CAAA,GAChF,qFAAA;AACJ,EAAA,OACE,GAAG,MAAM,CAAA,qBAAA,EAAwB,YAAY,CAAA,KAAA,EAAQ,KAAK,gCACvD,MAAA,CAAO,MAAM,CAAC,CAAA,aAAA,EAAgB,YAAY,8BACzC,MAAA,CAAO,OAAO,CAAC,CAAA,wDAAA,EAA2D,IAAI,QAC3E,QAAQ,CAAA,CAAA;AAEnB;AAMO,SAAS,+BAAA,CACd,QAAA,EACA,KAAA,EACA,MAAA,EACM;AACN,EAAA,MAAM,aAAA,GAAgB,KAAA,CAAM,QAAA,CAAS,SAAA,CAAU,yBAAyB,CAAA;AACxE,EAAA,KAAA,MAAW,YAAY,+BAAA,CAAgC,QAAA,EAAU,EAAE,aAAA,EAAe,CAAA,EAAG;AACnF,IAAA,MAAA,CAAO,KAAK,WAAA,CAAY,SAAA,CAAU,QAAQ,CAAA,EAAG,aAAA,CAAc,+BAA+B,CAAC,CAAA;AAAA,EAC7F;AACF;;"}
1
+ {"version":3,"file":"discriminator-conflict-warnings.mjs","sources":["../../src/api/discriminator-conflict-warnings.ts"],"sourcesContent":["import type { Logger } from \"../application/ports/logger.js\";\nimport {\n type DiscriminatorValueConflict,\n findDiscriminatorValueConflicts,\n} from \"../domain/openapi/discriminator-conflicts.js\";\nimport { FIX, type OutputFix } from \"../domain/output-fixes.js\";\nimport { WARNING_CODES, warningText } from \"../domain/warnings.js\";\n\nconst DOCS_BASE_URL = \"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs\";\nconst DOCS_URL = `${DOCS_BASE_URL}/advanced.md#discriminator-values`;\n\nfunction listed(values: readonly unknown[]): string {\n return values.map((value) => JSON.stringify(value)).join(\", \");\n}\n\nfunction warningOf(conflict: DiscriminatorValueConflict): string {\n const { member, owner, propertyName, values, allowed, isImplicit } = conflict;\n const rule = isImplicit\n ? \"A Discriminator Object without a mapping entry for a schema gives it its schema name as \" +\n `the value; add a mapping entry such as ${JSON.stringify(allowed[0])}: \"${member}\".`\n : \"The Discriminator Object maps these values to the schema; map the values it allows.\";\n return (\n `${member}: the discriminator \"${propertyName}\" of ${owner} gives this schema the value ` +\n `${listed(values)}, which its \"${propertyName}\" property does not allow ` +\n `(${listed(allowed)}), so no value of the schema matches the discriminator. ${rule} ` +\n `See ${DOCS_URL}`\n );\n}\n\n/**\n * Warn once per discriminator member whose value its own property does not allow. The members\n * depend on the run's fixes (`allof-discriminated-union`).\n */\nexport function warnDiscriminatorValueConflicts(\n document: unknown,\n fixes: readonly OutputFix[],\n logger: Logger,\n): void {\n const isUnionReused = fixes.includes(FIX.ALLOF_DISCRIMINATED_UNION);\n for (const conflict of findDiscriminatorValueConflicts(document, { isUnionReused })) {\n logger.warn(warningText(warningOf(conflict), WARNING_CODES.DISCRIMINATOR_VALUE_NOT_ALLOWED));\n }\n}\n"],"names":[],"mappings":";;;;AAQA,MAAM,aAAA,GAAgB,qEAAA;AACtB,MAAM,QAAA,GAAW,GAAG,aAAa,CAAA,iCAAA,CAAA;AAEjC,SAAS,OAAO,MAAA,EAAoC;AAClD,EAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAU,IAAA,CAAK,UAAU,KAAK,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA;AAC/D;AAEA,SAAS,UAAU,QAAA,EAA8C;AAC/D,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,EAAO,cAAc,MAAA,EAAQ,OAAA,EAAS,YAAW,GAAI,QAAA;AACrE,EAAA,MAAM,IAAA,GAAO,UAAA,GACT,CAAA,+HAAA,EAC0C,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,CAAC,CAAC,CAAC,CAAA,GAAA,EAAM,MAAM,CAAA,EAAA,CAAA,GAChF,qFAAA;AACJ,EAAA,OACE,GAAG,MAAM,CAAA,qBAAA,EAAwB,YAAY,CAAA,KAAA,EAAQ,KAAK,gCACvD,MAAA,CAAO,MAAM,CAAC,CAAA,aAAA,EAAgB,YAAY,8BACzC,MAAA,CAAO,OAAO,CAAC,CAAA,wDAAA,EAA2D,IAAI,QAC3E,QAAQ,CAAA,CAAA;AAEnB;AAMO,SAAS,+BAAA,CACd,QAAA,EACA,KAAA,EACA,MAAA,EACM;AACN,EAAA,MAAM,aAAA,GAAgB,KAAA,CAAM,QAAA,CAAS,GAAA,CAAI,yBAAyB,CAAA;AAClE,EAAA,KAAA,MAAW,YAAY,+BAAA,CAAgC,QAAA,EAAU,EAAE,aAAA,EAAe,CAAA,EAAG;AACnF,IAAA,MAAA,CAAO,KAAK,WAAA,CAAY,SAAA,CAAU,QAAQ,CAAA,EAAG,aAAA,CAAc,+BAA+B,CAAC,CAAA;AAAA,EAC7F;AACF;;"}
@@ -7,14 +7,14 @@ const ROOT_SEGMENTS = 3;
7
7
  function typedAt(ref) {
8
8
  const segments = jsonPointer.parseRefPointer(ref);
9
9
  const nested = segments.slice(ROOT_SEGMENTS).filter((segment) => segment !== PROPERTIES_KEYWORD);
10
- return jsonPointer.createRef([...segments.slice(0, ROOT_SEGMENTS), ...nested]);
10
+ return jsonPointer.appendPointer(jsonPointer.ROOT_POINTER, [...segments.slice(0, ROOT_SEGMENTS), ...nested]);
11
11
  }
12
12
  function isSchemaObject(value) {
13
13
  return typeof value === "object" && value !== null && !Array.isArray(value);
14
14
  }
15
15
  function ownProperty(item, ref, name) {
16
16
  const property = ("properties" in item ? item.properties : void 0)?.[name];
17
- return property === void 0 ? void 0 : { property, path: jsonPointer.createRef([ref, name]) };
17
+ return property === void 0 ? void 0 : { property, path: jsonPointer.appendPointer(ref, [name]) };
18
18
  }
19
19
  function declaredProperty(ref, name, resolve, visited) {
20
20
  const schema = resolve(ref);
@@ -1 +1 @@
1
- {"version":3,"file":"discriminator-enum-parent.cjs","sources":["../../src/api/discriminator-enum-parent.ts"],"sourcesContent":["import { createRef, parseRefPointer } from \"../domain/openapi/json-pointer.js\";\nimport type { SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\n\n/**\n * The `discriminator-values` fix (#1700). With `--enum`, the enum the scan adds to a member\n * (`petType: \"Cat\"`) is declared as an enum of its own (`CatPetType`), which is not assignable to\n * the parent's enum (`PetType`). The parent's enum is found here, so the member's property can be\n * typed with its members (`PetType.Cat`).\n */\n\n/** The parent's enum schema and the location it is typed at, which gives the enum its name. */\nexport interface EnumParent {\n readonly schema: SchemaObject;\n readonly path: string;\n}\n\ntype ResolveSchemaRef = (ref: string) => unknown;\n\n/** A declared property schema and the location the transformer types it at. */\ninterface DeclaredProperty {\n readonly property: unknown;\n readonly path: string;\n}\n\nconst PROPERTIES_KEYWORD = \"properties\";\n/** `components`, `schemas` and the schema name: the segments before the schema's own keywords. */\nconst ROOT_SEGMENTS = 3;\n\n/** The location a `$ref` is typed at: object properties are nested without `properties`. */\nfunction typedAt(ref: string): string {\n const segments = parseRefPointer(ref);\n const nested = segments.slice(ROOT_SEGMENTS).filter((segment) => segment !== PROPERTIES_KEYWORD);\n return createRef([...segments.slice(0, ROOT_SEGMENTS), ...nested]);\n}\n\nfunction isSchemaObject(value: unknown): value is SchemaObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The property `name` of a schema object typed at `ref`. */\nfunction ownProperty(item: SchemaObject, ref: string, name: string): DeclaredProperty | undefined {\n const property = (\"properties\" in item ? item.properties : undefined)?.[name];\n return property === undefined ? undefined : { property, path: createRef([ref, name]) };\n}\n\n/** The property `name` of the schema at `ref`, its own or from an `allOf` item, depth first. */\nfunction declaredProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n visited: Set<string>,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n if (visited.has(ref) || !isSchemaObject(schema)) {\n return undefined;\n }\n visited.add(ref);\n // An inline `allOf` item is typed at its parent's location, so both share the path.\n for (const item of [schema, ...(schema.allOf ?? [])]) {\n if (!isSchemaObject(item)) {\n continue;\n }\n const found =\n \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : ownProperty(item, ref, name);\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * A discriminator and the `$ref` of the schema that declares its property; `ref` is the member\n * whose value the discriminator gives, where there is one.\n */\nexport type DiscriminatorOwner = Pick<EnumPatch, \"discriminator\" | \"discriminatorRef\"> &\n Partial<Pick<EnumPatch, \"ref\">>;\n\n/**\n * The property `name` that the member at `ref` inherits through its `allOf` `$ref`s. Its own\n * keywords and inline items are left out: the scan writes the added value there.\n */\nfunction inheritedProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n const visited = new Set([ref]);\n for (const item of isSchemaObject(schema) ? (schema.allOf ?? []) : []) {\n const found =\n isSchemaObject(item) && \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : undefined;\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * The enum of the property that the discriminator owner declares, if it is one. An owner that\n * declares no such property (a `oneOf` with a mapping) leaves the member's type to the property\n * the member inherits, so that property's enum is the one.\n */\nexport function enumParentOf(\n patch: DiscriminatorOwner,\n resolve: ResolveSchemaRef,\n): EnumParent | undefined {\n const name = patch.discriminator.propertyName;\n const declared =\n declaredProperty(patch.discriminatorRef, name, resolve, new Set()) ??\n (patch.ref === undefined ? undefined : inheritedProperty(patch.ref, name, resolve));\n if (declared === undefined || !isSchemaObject(declared.property)) {\n return undefined;\n }\n const ref = (declared.property as { readonly $ref?: unknown }).$ref;\n const parent =\n typeof ref === \"string\"\n ? { schema: resolve(ref), path: typedAt(ref) }\n : { schema: declared.property, path: declared.path };\n return isSchemaObject(parent.schema) && Array.isArray(parent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Y,MAAA,GAAY,kBAAkB,KAAA,CAAM,GAAA,EAAK,MAAM,OAAO,CAAA,CAAA;AACnF,EAAA,IAAI,aAAa,MAAA,IAAa,CAAC,cAAA,CAAe,QAAA,CAAS,QAAQ,CAAA,EAAG;AAChE,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,MAAM,GAAA,GAAO,SAAS,QAAA,CAAyC,IAAA;AAC/D,EAAA,MAAM,MAAA,GACJ,OAAO,GAAA,KAAQ,QAAA,GACX,EAAE,MAAA,EAAQ,OAAA,CAAQ,GAAG,CAAA,EAAG,IAAA,EAAM,QAAQ,GAAG,CAAA,KACzC,EAAE,MAAA,EAAQ,SAAS,QAAA,EAAU,IAAA,EAAM,SAAS,IAAA,EAAK;AACvD,EAAA,OAAO,eAAe,MAAA,CAAO,MAAM,CAAA,IAAK,KAAA,CAAM,QAAQ,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,GACpE,EAAE,MAAA,EAAQ,MAAA,CAAO,QAAQ,IAAA,EAAM,MAAA,CAAO,MAAK,GAC3C,MAAA;AACN;;"}
1
+ {"version":3,"file":"discriminator-enum-parent.cjs","sources":["../../src/api/discriminator-enum-parent.ts"],"sourcesContent":["import { appendPointer, parseRefPointer, ROOT_POINTER } from \"../domain/openapi/json-pointer.js\";\nimport type { SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\n\n/**\n * The `discriminator-values` fix (#1700). With `--enum`, the enum the scan adds to a member\n * (`petType: \"Cat\"`) is declared as an enum of its own (`CatPetType`), which is not assignable to\n * the parent's enum (`PetType`). The parent's enum is found here, so the member's property can be\n * typed with its members (`PetType.Cat`).\n */\n\n/** The parent's enum schema and the location it is typed at, which gives the enum its name. */\nexport interface EnumParent {\n readonly schema: SchemaObject;\n readonly path: string;\n}\n\ntype ResolveSchemaRef = (ref: string) => unknown;\n\n/** A declared property schema and the location the transformer types it at. */\ninterface DeclaredProperty {\n readonly property: unknown;\n readonly path: string;\n}\n\nconst PROPERTIES_KEYWORD = \"properties\";\n/** `components`, `schemas` and the schema name: the segments before the schema's own keywords. */\nconst ROOT_SEGMENTS = 3;\n\n/** The location a `$ref` is typed at: object properties are nested without `properties`. */\nfunction typedAt(ref: string): string {\n const segments = parseRefPointer(ref);\n const nested = segments.slice(ROOT_SEGMENTS).filter((segment) => segment !== PROPERTIES_KEYWORD);\n return appendPointer(ROOT_POINTER, [...segments.slice(0, ROOT_SEGMENTS), ...nested]);\n}\n\nfunction isSchemaObject(value: unknown): value is SchemaObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The property `name` of a schema object typed at `ref`. */\nfunction ownProperty(item: SchemaObject, ref: string, name: string): DeclaredProperty | undefined {\n const property = (\"properties\" in item ? item.properties : undefined)?.[name];\n return property === undefined ? undefined : { property, path: appendPointer(ref, [name]) };\n}\n\n/** The property `name` of the schema at `ref`, its own or from an `allOf` item, depth first. */\nfunction declaredProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n visited: Set<string>,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n if (visited.has(ref) || !isSchemaObject(schema)) {\n return undefined;\n }\n visited.add(ref);\n // An inline `allOf` item is typed at its parent's location, so both share the path.\n for (const item of [schema, ...(schema.allOf ?? [])]) {\n if (!isSchemaObject(item)) {\n continue;\n }\n const found =\n \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : ownProperty(item, ref, name);\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * A discriminator and the `$ref` of the schema that declares its property; `ref` is the member\n * whose value the discriminator gives, where there is one.\n */\nexport type DiscriminatorOwner = Pick<EnumPatch, \"discriminator\" | \"discriminatorRef\"> &\n Partial<Pick<EnumPatch, \"ref\">>;\n\n/**\n * The property `name` that the member at `ref` inherits through its `allOf` `$ref`s. Its own\n * keywords and inline items are left out: the scan writes the added value there.\n */\nfunction inheritedProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n const visited = new Set([ref]);\n for (const item of isSchemaObject(schema) ? (schema.allOf ?? []) : []) {\n const found =\n isSchemaObject(item) && \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : undefined;\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * The enum of the property that the discriminator owner declares, if it is one. An owner that\n * declares no such property (a `oneOf` with a mapping) leaves the member's type to the property\n * the member inherits, so that property's enum is the one.\n */\nexport function enumParentOf(\n patch: DiscriminatorOwner,\n resolve: ResolveSchemaRef,\n): EnumParent | undefined {\n const name = patch.discriminator.propertyName;\n const declared =\n declaredProperty(patch.discriminatorRef, name, resolve, new Set()) ??\n (patch.ref === undefined ? undefined : inheritedProperty(patch.ref, name, resolve));\n if (declared === undefined || !isSchemaObject(declared.property)) {\n return undefined;\n }\n const ref = (declared.property as { readonly $ref?: unknown }).$ref;\n const parent =\n typeof ref === \"string\"\n ? { schema: resolve(ref), path: typedAt(ref) }\n : { schema: declared.property, path: declared.path };\n return isSchemaObject(parent.schema) && Array.isArray(parent.schema.enum)\n ? { schema: parent.schema, path: parent.path }\n : undefined;\n}\n"],"names":["parseRefPointer","appendPointer","ROOT_POINTER"],"mappings":";;;;AAyBA,MAAM,kBAAA,GAAqB,YAAA;AAE3B,MAAM,aAAA,GAAgB,CAAA;AAGtB,SAAS,QAAQ,GAAA,EAAqB;AACpC,EAAA,MAAM,QAAA,GAAWA,4BAAgB,GAAG,CAAA;AACpC,EAAA,MAAM,MAAA,GAAS,SAAS,KAAA,CAAM,aAAa,EAAE,MAAA,CAAO,CAAC,OAAA,KAAY,OAAA,KAAY,kBAAkB,CAAA;AAC/F,EAAA,OAAOC,yBAAA,CAAcC,wBAAA,EAAc,CAAC,GAAG,QAAA,CAAS,KAAA,CAAM,CAAA,EAAG,aAAa,CAAA,EAAG,GAAG,MAAM,CAAC,CAAA;AACrF;AAEA,SAAS,eAAe,KAAA,EAAuC;AA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AA,IAAK,KAAA,CAAM,QAAQ,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,GACpE,EAAE,MAAA,EAAQ,MAAA,CAAO,QAAQ,IAAA,EAAM,MAAA,CAAO,MAAK,GAC3C,MAAA;AACN;;"}
@@ -1,18 +1,18 @@
1
- import { parseRefPointer, createRef } from '../domain/openapi/json-pointer.mjs';
1
+ import { parseRefPointer, appendPointer, ROOT_POINTER } from '../domain/openapi/json-pointer.mjs';
2
2
 
3
3
  const PROPERTIES_KEYWORD = "properties";
4
4
  const ROOT_SEGMENTS = 3;
5
5
  function typedAt(ref) {
6
6
  const segments = parseRefPointer(ref);
7
7
  const nested = segments.slice(ROOT_SEGMENTS).filter((segment) => segment !== PROPERTIES_KEYWORD);
8
- return createRef([...segments.slice(0, ROOT_SEGMENTS), ...nested]);
8
+ return appendPointer(ROOT_POINTER, [...segments.slice(0, ROOT_SEGMENTS), ...nested]);
9
9
  }
10
10
  function isSchemaObject(value) {
11
11
  return typeof value === "object" && value !== null && !Array.isArray(value);
12
12
  }
13
13
  function ownProperty(item, ref, name) {
14
14
  const property = ("properties" in item ? item.properties : void 0)?.[name];
15
- return property === void 0 ? void 0 : { property, path: createRef([ref, name]) };
15
+ return property === void 0 ? void 0 : { property, path: appendPointer(ref, [name]) };
16
16
  }
17
17
  function declaredProperty(ref, name, resolve, visited) {
18
18
  const schema = resolve(ref);
@@ -1 +1 @@
1
- {"version":3,"file":"discriminator-enum-parent.mjs","sources":["../../src/api/discriminator-enum-parent.ts"],"sourcesContent":["import { createRef, parseRefPointer } from \"../domain/openapi/json-pointer.js\";\nimport type { SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\n\n/**\n * The `discriminator-values` fix (#1700). With `--enum`, the enum the scan adds to a member\n * (`petType: \"Cat\"`) is declared as an enum of its own (`CatPetType`), which is not assignable to\n * the parent's enum (`PetType`). The parent's enum is found here, so the member's property can be\n * typed with its members (`PetType.Cat`).\n */\n\n/** The parent's enum schema and the location it is typed at, which gives the enum its name. */\nexport interface EnumParent {\n readonly schema: SchemaObject;\n readonly path: string;\n}\n\ntype ResolveSchemaRef = (ref: string) => unknown;\n\n/** A declared property schema and the location the transformer types it at. */\ninterface DeclaredProperty {\n readonly property: unknown;\n readonly path: string;\n}\n\nconst PROPERTIES_KEYWORD = \"properties\";\n/** `components`, `schemas` and the schema name: the segments before the schema's own keywords. */\nconst ROOT_SEGMENTS = 3;\n\n/** The location a `$ref` is typed at: object properties are nested without `properties`. */\nfunction typedAt(ref: string): string {\n const segments = parseRefPointer(ref);\n const nested = segments.slice(ROOT_SEGMENTS).filter((segment) => segment !== PROPERTIES_KEYWORD);\n return createRef([...segments.slice(0, ROOT_SEGMENTS), ...nested]);\n}\n\nfunction isSchemaObject(value: unknown): value is SchemaObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The property `name` of a schema object typed at `ref`. */\nfunction ownProperty(item: SchemaObject, ref: string, name: string): DeclaredProperty | undefined {\n const property = (\"properties\" in item ? item.properties : undefined)?.[name];\n return property === undefined ? undefined : { property, path: createRef([ref, name]) };\n}\n\n/** The property `name` of the schema at `ref`, its own or from an `allOf` item, depth first. */\nfunction declaredProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n visited: Set<string>,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n if (visited.has(ref) || !isSchemaObject(schema)) {\n return undefined;\n }\n visited.add(ref);\n // An inline `allOf` item is typed at its parent's location, so both share the path.\n for (const item of [schema, ...(schema.allOf ?? [])]) {\n if (!isSchemaObject(item)) {\n continue;\n }\n const found =\n \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : ownProperty(item, ref, name);\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * A discriminator and the `$ref` of the schema that declares its property; `ref` is the member\n * whose value the discriminator gives, where there is one.\n */\nexport type DiscriminatorOwner = Pick<EnumPatch, \"discriminator\" | \"discriminatorRef\"> &\n Partial<Pick<EnumPatch, \"ref\">>;\n\n/**\n * The property `name` that the member at `ref` inherits through its `allOf` `$ref`s. Its own\n * keywords and inline items are left out: the scan writes the added value there.\n */\nfunction inheritedProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n const visited = new Set([ref]);\n for (const item of isSchemaObject(schema) ? (schema.allOf ?? []) : []) {\n const found =\n isSchemaObject(item) && \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : undefined;\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * The enum of the property that the discriminator owner declares, if it is one. An owner that\n * declares no such property (a `oneOf` with a mapping) leaves the member's type to the property\n * the member inherits, so that property's enum is the one.\n */\nexport function enumParentOf(\n patch: DiscriminatorOwner,\n resolve: ResolveSchemaRef,\n): EnumParent | undefined {\n const name = patch.discriminator.propertyName;\n const declared =\n declaredProperty(patch.discriminatorRef, name, resolve, new Set()) ??\n (patch.ref === undefined ? undefined : inheritedProperty(patch.ref, name, resolve));\n if (declared === undefined || !isSchemaObject(declared.property)) {\n return undefined;\n }\n const ref = (declared.property as { readonly $ref?: unknown }).$ref;\n const parent =\n typeof ref === \"string\"\n ? { schema: resolve(ref), path: typedAt(ref) }\n : { schema: declared.property, path: declared.path };\n return isSchemaObject(parent.schema) && Array.isArray(parent.schema.enum)\n ? { schema: parent.schema, path: parent.path }\n : undefined;\n}\n"],"names":[],"mappings":";;AAyBA,MAAM,kBAAA,GAAqB,YAAA;AAE3B,MAAM,aAAA,GAAgB,CAAA;AAGtB,SAAS,QAAQ,GAAA,EAAqB;AACpC,EAAA,MAAM,QAAA,GAAW,gBAAgB,GAAG,CAAA;AACpC,EAAA,MAAM,MAAA,GAAS,SAAS,KAAA,CAAM,aAAa,EAAE,MAAA,CAAO,CAAC,OAAA,KAAY,OAAA,KAAY,kBAAkB,CAAA;AAC/F,EAAA,OAAO,SAAA,CAAU,CAAC,GAA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AAE,MAAA,EAAQ,SAAS,QAAA,EAAU,IAAA,EAAM,SAAS,IAAA,EAAK;AACvD,EAAA,OAAO,eAAe,MAAA,CAAO,MAAM,CAAA,IAAK,KAAA,CAAM,QAAQ,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,GACpE,EAAE,MAAA,EAAQ,MAAA,CAAO,QAAQ,IAAA,EAAM,MAAA,CAAO,MAAK,GAC3C,MAAA;AACN;;"}
1
+ {"version":3,"file":"discriminator-enum-parent.mjs","sources":["../../src/api/discriminator-enum-parent.ts"],"sourcesContent":["import { appendPointer, parseRefPointer, ROOT_POINTER } from \"../domain/openapi/json-pointer.js\";\nimport type { SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\n\n/**\n * The `discriminator-values` fix (#1700). With `--enum`, the enum the scan adds to a member\n * (`petType: \"Cat\"`) is declared as an enum of its own (`CatPetType`), which is not assignable to\n * the parent's enum (`PetType`). The parent's enum is found here, so the member's property can be\n * typed with its members (`PetType.Cat`).\n */\n\n/** The parent's enum schema and the location it is typed at, which gives the enum its name. */\nexport interface EnumParent {\n readonly schema: SchemaObject;\n readonly path: string;\n}\n\ntype ResolveSchemaRef = (ref: string) => unknown;\n\n/** A declared property schema and the location the transformer types it at. */\ninterface DeclaredProperty {\n readonly property: unknown;\n readonly path: string;\n}\n\nconst PROPERTIES_KEYWORD = \"properties\";\n/** `components`, `schemas` and the schema name: the segments before the schema's own keywords. */\nconst ROOT_SEGMENTS = 3;\n\n/** The location a `$ref` is typed at: object properties are nested without `properties`. */\nfunction typedAt(ref: string): string {\n const segments = parseRefPointer(ref);\n const nested = segments.slice(ROOT_SEGMENTS).filter((segment) => segment !== PROPERTIES_KEYWORD);\n return appendPointer(ROOT_POINTER, [...segments.slice(0, ROOT_SEGMENTS), ...nested]);\n}\n\nfunction isSchemaObject(value: unknown): value is SchemaObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** The property `name` of a schema object typed at `ref`. */\nfunction ownProperty(item: SchemaObject, ref: string, name: string): DeclaredProperty | undefined {\n const property = (\"properties\" in item ? item.properties : undefined)?.[name];\n return property === undefined ? undefined : { property, path: appendPointer(ref, [name]) };\n}\n\n/** The property `name` of the schema at `ref`, its own or from an `allOf` item, depth first. */\nfunction declaredProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n visited: Set<string>,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n if (visited.has(ref) || !isSchemaObject(schema)) {\n return undefined;\n }\n visited.add(ref);\n // An inline `allOf` item is typed at its parent's location, so both share the path.\n for (const item of [schema, ...(schema.allOf ?? [])]) {\n if (!isSchemaObject(item)) {\n continue;\n }\n const found =\n \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : ownProperty(item, ref, name);\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * A discriminator and the `$ref` of the schema that declares its property; `ref` is the member\n * whose value the discriminator gives, where there is one.\n */\nexport type DiscriminatorOwner = Pick<EnumPatch, \"discriminator\" | \"discriminatorRef\"> &\n Partial<Pick<EnumPatch, \"ref\">>;\n\n/**\n * The property `name` that the member at `ref` inherits through its `allOf` `$ref`s. Its own\n * keywords and inline items are left out: the scan writes the added value there.\n */\nfunction inheritedProperty(\n ref: string,\n name: string,\n resolve: ResolveSchemaRef,\n): DeclaredProperty | undefined {\n const schema = resolve(ref);\n const visited = new Set([ref]);\n for (const item of isSchemaObject(schema) ? (schema.allOf ?? []) : []) {\n const found =\n isSchemaObject(item) && \"$ref\" in item\n ? declaredProperty(item.$ref as string, name, resolve, visited)\n : undefined;\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * The enum of the property that the discriminator owner declares, if it is one. An owner that\n * declares no such property (a `oneOf` with a mapping) leaves the member's type to the property\n * the member inherits, so that property's enum is the one.\n */\nexport function enumParentOf(\n patch: DiscriminatorOwner,\n resolve: ResolveSchemaRef,\n): EnumParent | undefined {\n const name = patch.discriminator.propertyName;\n const declared =\n declaredProperty(patch.discriminatorRef, name, resolve, new Set()) ??\n (patch.ref === undefined ? undefined : inheritedProperty(patch.ref, name, resolve));\n if (declared === undefined || !isSchemaObject(declared.property)) {\n return undefined;\n }\n const ref = (declared.property as { readonly $ref?: unknown }).$ref;\n const parent =\n typeof ref === \"string\"\n ? { schema: resolve(ref), path: typedAt(ref) }\n : { schema: declared.property, path: declared.path };\n return isSchemaObject(parent.schema) && Array.isArray(parent.schema.enum)\n ? { schema: parent.schema, path: parent.path }\n : undefined;\n}\n"],"names":[],"mappings":";;AAyBA,MAAM,kBAAA,GAAqB,YAAA;AAE3B,MAAM,aAAA,GAAgB,CAAA;AAGtB,SAAS,QAAQ,GAAA,EAAqB;AACpC,EAAA,MAAM,QAAA,GAAW,gBAAgB,GAAG,CAAA;AACpC,EAAA,MAAM,MAAA,GAAS,SAAS,KAAA,CAAM,aAAa,EAAE,MAAA,CAAO,CAAC,OAAA,KAAY,OAAA,KAAY,kBAAkB,CAAA;AAC/F,EAAA,OAAO,aAAA,CAAc,YAAA,EAAc,CAAC,GAAG,QAAA,CAAS,KAAA,CAAM,CAAA,EAAG,aAAa,CAAA,EAAG,GAAG,MAAM,CAAC,CAAA;AACrF;AAEA,SAAS,eAAe,KAAA,EAAuC;AAC7D,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAGA,SAAS,WAAA,CAAY,IAAA,EAAoB,GAAA,EAAa,IAAA,EAA4C;AAChG,EAAA,MAAM,YAAY,YAAA,IAAgB,IAAA,GAAO,IAAA,CAAK,UAAA,GAAa,UAAa,IAAI,CAAA;AAC5E,EAAA,OAAO,QAAA,KAAa,MAAA,GAAY,MAAA,GAAY,EAAE,QAAA,EAAU,IAAA,EAAM,aAAA,CAAc,GAAA,EAAK,CAAC,IAAI,CAAC,CAAA,EAAE;AAC3F;AAGA,SAAS,gBAAA,CACP,GAA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AO,KAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT;AAOO,SAAS,YAAA,CACd,OACA,OAAA,EACwB;AACxB,EAAA,MAAM,IAAA,GAAO,MAAM,aAAA,CAAc,YAAA;AACjC,EAAA,MAAM,WACJ,gBAAA,CAAiB,KAAA,CAAM,kBAAkB,IAAA,EAAM,OAAA,sBAAa,GAAA,EAAK,CAAA,KAChE,KAAA,CAAM,QAAQ,MAAA,GAAY,MAAA,GAAY,kBAAkB,KAAA,CAAM,GAAA,EAAK,MAAM,OAAO,CAAA,CAAA;AACnF,EAAA,IAAI,aAAa,MAAA,IAAa,CAAC,cAAA,CAAe,QAAA,CAAS,QAAQ,CAAA,EAAG;AAChE,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,MAAM,GAAA,GAAO,SAAS,QAAA,CAAyC,IAAA;AAC/D,EAAA,MAAM,MAAA,GACJ,OAAO,GAAA,KAAQ,QAAA,GACX,EAAE,MAAA,EAAQ,OAAA,CAAQ,GAAG,CAAA,EAAG,IAAA,EAAM,QAAQ,GAAG,CAAA,KACzC,EAAE,MAAA,EAAQ,SAAS,QAAA,EAAU,IAAA,EAAM,SAAS,IAAA,EAAK;AACvD,EAAA,OAAO,eAAe,MAAA,CAAO,MAAM,CAAA,IAAK,KAAA,CAAM,QAAQ,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,GACpE,EAAE,MAAA,EAAQ,MAAA,CAAO,QAAQ,IAAA,EAAM,MAAA,CAAO,MAAK,GAC3C,MAAA;AACN;;"}
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const appendAll = require('../domain/append-all.cjs');
4
+ const jsonPointer = require('../domain/openapi/json-pointer.cjs');
3
5
  const discriminatorPatch = require('./discriminator-patch.cjs');
4
6
  const documentRefs = require('./document-refs.cjs');
5
7
 
@@ -8,7 +10,7 @@ function allOfRefs(state, ref) {
8
10
  const schema = documentRefs.resolveDocumentRef(state.schema, ref, { silent, logger });
9
11
  const items = schema?.allOf ?? [];
10
12
  return items.flatMap(
11
- (item) => "$ref" in item && typeof item.$ref === "string" ? [item.$ref] : []
13
+ (item) => "$ref" in item && typeof item.$ref === "string" ? [jsonPointer.canonicalRef(item.$ref)] : []
12
14
  );
13
15
  }
14
16
  function otherOwners(state, parentRef) {
@@ -26,7 +28,7 @@ function otherOwners(state, parentRef) {
26
28
  if (discriminator && name !== void 0 && name !== own && !found.has(name)) {
27
29
  found.set(name, { discriminator, ownerRef: ref });
28
30
  }
29
- queue.push(...allOfRefs(state, ref));
31
+ appendAll.appendAll(queue, allOfRefs(state, ref));
30
32
  }
31
33
  return [...found.values()];
32
34
  }
@@ -44,7 +46,7 @@ function inheritOtherOwners(state, parentRef, ref) {
44
46
  continue;
45
47
  }
46
48
  recordOtherProperty(state, ref, discriminator.propertyName);
47
- const mapped = Object.entries(discriminator.mapping ?? {}).filter(([, target]) => target === ref).map(([value]) => value);
49
+ const mapped = Object.entries(discriminator.mapping ?? {}).filter(([, target]) => jsonPointer.canonicalRef(target) === ref).map(([value]) => value);
48
50
  const name = ref.slice(ref.lastIndexOf("/") + 1);
49
51
  const patch = { ref, values: mapped, discriminator, discriminatorRef: ownerRef };
50
52
  if (mapped.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"discriminator-other-owners.cjs","sources":["../../src/api/discriminator-other-owners.ts"],"sourcesContent":["import type { DiscriminatorObject, ReferenceObject, SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\nimport { enumKey, patchDiscriminatorEnum, type ScanState } from \"./discriminator-patch.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\n\n/**\n * The `discriminator-values` fix: a schema inherits one discriminator per property. A schema that\n * owns a discriminator keeps its own (#2200), so the scan does not record the one it inherits for\n * another property (`Content` owns `subtype` and `allOf`s `Element`, which owns `contentType`).\n * Its members (`Video`) still get a value of that property, found here from the owners above.\n */\n\n/** A discriminator and the schema that defines it. */\ninterface OtherOwner {\n readonly discriminator: DiscriminatorObject;\n readonly ownerRef: string;\n}\n\n/** The `$ref`s of a schema's `allOf` items. */\nfunction allOfRefs(state: ScanState, ref: string): string[] {\n const { silent, logger } = state;\n const schema = resolveDocumentRef<SchemaObject>(state.schema, ref, { silent, logger });\n const items = (schema?.allOf ?? []) as (SchemaObject | ReferenceObject)[];\n return items.flatMap((item) =>\n \"$ref\" in item && typeof item.$ref === \"string\" ? [item.$ref] : [],\n );\n}\n\n/**\n * The owners' discriminators that the schema at `parentRef` and its `allOf` parents define, the\n * nearest one per property, except the property of `parentRef`'s own discriminator.\n */\nfunction otherOwners(state: ScanState, parentRef: string): OtherOwner[] {\n const own = state.objects[parentRef]?.propertyName;\n const found = new Map<string, OtherOwner>();\n const visited = new Set<string>();\n const queue = [parentRef];\n for (let ref = queue.shift(); ref !== undefined; ref = queue.shift()) {\n if (visited.has(ref)) {\n continue;\n }\n visited.add(ref);\n const discriminator = state.owners.has(ref) ? state.objects[ref] : undefined;\n const name = discriminator?.propertyName;\n if (discriminator && name !== undefined && name !== own && !found.has(name)) {\n found.set(name, { discriminator, ownerRef: ref });\n }\n queue.push(...allOfRefs(state, ref));\n }\n return [...found.values()];\n}\n\n/**\n * The child redefines this property, so its `allOf` items omit it: a parent may have a value of\n * its own, as `Content` has when `Element`'s mapping names it.\n */\nfunction recordOtherProperty(state: ScanState, ref: string, propertyName: string): void {\n const names = state.otherProperties[ref] ?? [];\n if (!names.includes(propertyName)) {\n names.push(propertyName);\n }\n state.otherProperties[ref] = names;\n}\n\n/**\n * The child at `ref` of the schema at `parentRef` gets a value of each other property: a mapped\n * one at once, else its schema name after both passes, where no mapping gives one. The schema's\n * own discriminator property is still added, so these patches do not mark it handled.\n */\nexport function inheritOtherOwners(state: ScanState, parentRef: string, ref: string): void {\n const childProperty = state.objects[ref]?.propertyName;\n for (const { discriminator, ownerRef } of otherOwners(state, parentRef)) {\n if (discriminator.propertyName === childProperty) {\n continue;\n }\n recordOtherProperty(state, ref, discriminator.propertyName);\n const mapped = Object.entries(discriminator.mapping ?? {})\n .filter(([, target]) => target === ref)\n .map(([value]) => value);\n const name = ref.slice(ref.lastIndexOf(\"/\") + 1);\n const patch: EnumPatch = { ref, values: mapped, discriminator, discriminatorRef: ownerRef };\n if (mapped.length > 0) {\n patchDiscriminatorEnum(state, patch);\n } else {\n state.otherInferredPatches.push({ ...patch, values: [name] });\n }\n }\n}\n\n/** The deferred schema-name values of other properties; see `inheritOtherOwners`. */\nexport function applyOtherInferredPatches(state: ScanState, mapped: ReadonlySet<string>): void {\n for (const patch of state.otherInferredPatches) {\n if (!mapped.has(enumKey(patch))) {\n patchDiscriminatorEnum(state, patch);\n }\n }\n}\n"],"names":["resolveDocumentRef","patchDiscriminatorEnum","enumKey"],"mappings":";;;;;AAmBA,SAAS,SAAA,CAAU,OAAkB,GAAA,EAAuB;AAC1D,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAO,GAAI,KAAA;AAC3B,EAAA,MAAM,MAAA,GAASA,gCAAiC,KAAA,CAAM,MAAA,EAAQ,KAAK,EAAE,MAAA,EAAQ,QAAQ,CAAA;AACrF,EAAA,MAAM,KAAA,GAAS,MAAA,EAAQ,KAAA,IAAS,EAAC;AACjC,EAAA,OAAO,KAAA,CAAM,OAAA;AAAA,IAAQ,CAAC,IAAA,KACpB,MAAA,IAAU,IAAA,IAAQ,OAAO,IAAA,CAAK,IAAA,KAAS,QAAA,GAAW,CAAC,IAAA,CAAK,IAAI,CAAA,GAAI;AAAC,GACnE;AACF;AAMA,SAAS,WAAA,CAAY,OAAkB,SAAA,EAAiC;AACtE,EAAA,MAAM,GAAA,GAAM,KAAA,CAAM,OAAA,CAAQ,SAAS,CAAA,EAAG,YAAA;AACtC,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAwB;AAC1C,EAAA,MAAM,OAAA,uBAAc,GAAA,EAAY;AAChC,EAAA,MAAM,KAAA,GAAQ,CAAC,SAAS,CAAA;AACxB,EAAA,KAAA,IAAS,GAAA,G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cesContent":["import { appendAll } from \"../domain/append-all.js\";\nimport { canonicalRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject, ReferenceObject, SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\nimport { enumKey, patchDiscriminatorEnum, type ScanState } from \"./discriminator-patch.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\n\n/**\n * The `discriminator-values` fix: a schema inherits one discriminator per property. A schema that\n * owns a discriminator keeps its own (#2200), so the scan does not record the one it inherits for\n * another property (`Content` owns `subtype` and `allOf`s `Element`, which owns `contentType`).\n * Its members (`Video`) still get a value of that property, found here from the owners above.\n */\n\n/** A discriminator and the schema that defines it. */\ninterface OtherOwner {\n readonly discriminator: DiscriminatorObject;\n readonly ownerRef: string;\n}\n\n/** The `$ref`s of a schema's `allOf` items. */\nfunction allOfRefs(state: ScanState, ref: string): string[] {\n const { silent, logger } = state;\n const schema = resolveDocumentRef<SchemaObject>(state.schema, ref, { silent, logger });\n const items = (schema?.allOf ?? []) as (SchemaObject | ReferenceObject)[];\n return items.flatMap((item) =>\n \"$ref\" in item && typeof item.$ref === \"string\" ? [canonicalRef(item.$ref)] : [],\n );\n}\n\n/**\n * The owners' discriminators that the schema at `parentRef` and its `allOf` parents define, the\n * nearest one per property, except the property of `parentRef`'s own discriminator.\n */\nfunction otherOwners(state: ScanState, parentRef: string): OtherOwner[] {\n const own = state.objects[parentRef]?.propertyName;\n const found = new Map<string, OtherOwner>();\n const visited = new Set<string>();\n const queue = [parentRef];\n for (let ref = queue.shift(); ref !== undefined; ref = queue.shift()) {\n if (visited.has(ref)) {\n continue;\n }\n visited.add(ref);\n const discriminator = state.owners.has(ref) ? state.objects[ref] : undefined;\n const name = discriminator?.propertyName;\n if (discriminator && name !== undefined && name !== own && !found.has(name)) {\n found.set(name, { discriminator, ownerRef: ref });\n }\n appendAll(queue, allOfRefs(state, ref));\n }\n return [...found.values()];\n}\n\n/**\n * The child redefines this property, so its `allOf` items omit it: a parent may have a value of\n * its own, as `Content` has when `Element`'s mapping names it.\n */\nfunction recordOtherProperty(state: ScanState, ref: string, propertyName: string): void {\n const names = state.otherProperties[ref] ?? [];\n if (!names.includes(propertyName)) {\n names.push(propertyName);\n }\n state.otherProperties[ref] = names;\n}\n\n/**\n * The child at `ref` of the schema at `parentRef` gets a value of each other property: a mapped\n * one at once, else its schema name after both passes, where no mapping gives one. The schema's\n * own discriminator property is still added, so these patches do not mark it handled.\n */\nexport function inheritOtherOwners(state: ScanState, parentRef: string, ref: string): void {\n const childProperty = state.objects[ref]?.propertyName;\n for (const { discriminator, ownerRef } of otherOwners(state, parentRef)) {\n if (discriminator.propertyName === childProperty) {\n continue;\n }\n recordOtherProperty(state, ref, discriminator.propertyName);\n const mapped = Object.entries(discriminator.mapping ?? {})\n .filter(([, target]) => canonicalRef(target) === ref)\n .map(([value]) => value);\n const name = ref.slice(ref.lastIndexOf(\"/\") + 1);\n const patch: EnumPatch = { ref, values: mapped, discriminator, discriminatorRef: ownerRef };\n if (mapped.length > 0) {\n patchDiscriminatorEnum(state, patch);\n } else {\n state.otherInferredPatches.push({ ...patch, values: [name] });\n }\n }\n}\n\n/** The deferred schema-name values of other properties; see `inheritOtherOwners`. */\nexport function applyOtherInferredPatches(state: ScanState, mapped: ReadonlySet<string>): void {\n for (const patch of state.otherInferredPatches) {\n if (!mapped.has(enumKey(patch))) {\n patchDiscriminatorEnum(state, patch);\n }\n }\n}\n"],"names":["resolveDocumentRef","canonicalRef","appendAll","patchDiscriminatorEnum","enumKey"],"mappings":";;;;;;;AAqBA,SAAS,SAAA,CAAU,OAAkB,GAAA,EAAuB;AAC1D,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAO,GAAI,KAAA;AAC3B,EAAA,MAAM,MAAA,GAASA,gCAAiC,KAAA,CAAM,MAAA,EAAQ,KAAK,EAAE,MAAA,EAAQ,QAAQ,CAAA;AACrF,EAAA,MAAM,KAAA,GAAS,MAAA,EAAQ,KAAA,I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B,MAAAE,yCAAA,CAAuB,OAAO,KAAK,CAAA;AAAA,IACrC,CAAA,MAAO;AACL,MAAA,KAAA,CAAM,oBAAA,CAAqB,KAAK,EAAE,GAAG,OAAO,MAAA,EAAQ,CAAC,IAAI,CAAA,EAAG,CAAA;AAAA,IAC9D;AAAA,EACF;AACF;AAGO,SAAS,yBAAA,CAA0B,OAAkB,MAAA,EAAmC;AAC7F,EAAA,KAAA,MAAW,KAAA,IAAS,MAAM,oBAAA,EAAsB;AAC9C,IAAA,IAAI,CAAC,MAAA,CAAO,GAAA,CAAIC,0BAAA,CAAQ,KAAK,CAAC,CAAA,EAAG;AAC/B,MAAAD,yCAAA,CAAuB,OAAO,KAAK,CAAA;AAAA,IACrC;AAAA,EACF;AACF;;;"}
@@ -1,3 +1,5 @@
1
+ import { appendAll } from '../domain/append-all.mjs';
2
+ import { canonicalRef } from '../domain/openapi/json-pointer.mjs';
1
3
  import { enumKey, patchDiscriminatorEnum } from './discriminator-patch.mjs';
2
4
  import { resolveDocumentRef } from './document-refs.mjs';
3
5
 
@@ -6,7 +8,7 @@ function allOfRefs(state, ref) {
6
8
  const schema = resolveDocumentRef(state.schema, ref, { silent, logger });
7
9
  const items = schema?.allOf ?? [];
8
10
  return items.flatMap(
9
- (item) => "$ref" in item && typeof item.$ref === "string" ? [item.$ref] : []
11
+ (item) => "$ref" in item && typeof item.$ref === "string" ? [canonicalRef(item.$ref)] : []
10
12
  );
11
13
  }
12
14
  function otherOwners(state, parentRef) {
@@ -24,7 +26,7 @@ function otherOwners(state, parentRef) {
24
26
  if (discriminator && name !== void 0 && name !== own && !found.has(name)) {
25
27
  found.set(name, { discriminator, ownerRef: ref });
26
28
  }
27
- queue.push(...allOfRefs(state, ref));
29
+ appendAll(queue, allOfRefs(state, ref));
28
30
  }
29
31
  return [...found.values()];
30
32
  }
@@ -42,7 +44,7 @@ function inheritOtherOwners(state, parentRef, ref) {
42
44
  continue;
43
45
  }
44
46
  recordOtherProperty(state, ref, discriminator.propertyName);
45
- const mapped = Object.entries(discriminator.mapping ?? {}).filter(([, target]) => target === ref).map(([value]) => value);
47
+ const mapped = Object.entries(discriminator.mapping ?? {}).filter(([, target]) => canonicalRef(target) === ref).map(([value]) => value);
46
48
  const name = ref.slice(ref.lastIndexOf("/") + 1);
47
49
  const patch = { ref, values: mapped, discriminator, discriminatorRef: ownerRef };
48
50
  if (mapped.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"discriminator-other-owners.mjs","sources":["../../src/api/discriminator-other-owners.ts"],"sourcesContent":["import type { DiscriminatorObject, ReferenceObject, SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\nimport { enumKey, patchDiscriminatorEnum, type ScanState } from \"./discriminator-patch.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\n\n/**\n * The `discriminator-values` fix: a schema inherits one discriminator per property. A schema that\n * owns a discriminator keeps its own (#2200), so the scan does not record the one it inherits for\n * another property (`Content` owns `subtype` and `allOf`s `Element`, which owns `contentType`).\n * Its members (`Video`) still get a value of that property, found here from the owners above.\n */\n\n/** A discriminator and the schema that defines it. */\ninterface OtherOwner {\n readonly discriminator: DiscriminatorObject;\n readonly ownerRef: string;\n}\n\n/** The `$ref`s of a schema's `allOf` items. */\nfunction allOfRefs(state: ScanState, ref: string): string[] {\n const { silent, logger } = state;\n const schema = resolveDocumentRef<SchemaObject>(state.schema, ref, { silent, logger });\n const items = (schema?.allOf ?? []) as (SchemaObject | ReferenceObject)[];\n return items.flatMap((item) =>\n \"$ref\" in item && typeof item.$ref === \"string\" ? [item.$ref] : [],\n );\n}\n\n/**\n * The owners' discriminators that the schema at `parentRef` and its `allOf` parents define, the\n * nearest one per property, except the property of `parentRef`'s own discriminator.\n */\nfunction otherOwners(state: ScanState, parentRef: string): OtherOwner[] {\n const own = state.objects[parentRef]?.propertyName;\n const found = new Map<string, OtherOwner>();\n const visited = new Set<string>();\n const queue = [parentRef];\n for (let ref = queue.shift(); ref !== undefined; ref = queue.shift()) {\n if (visited.has(ref)) {\n continue;\n }\n visited.add(ref);\n const discriminator = state.owners.has(ref) ? state.objects[ref] : undefined;\n const name = discriminator?.propertyName;\n if (discriminator && name !== undefined && name !== own && !found.has(name)) {\n found.set(name, { discriminator, ownerRef: ref });\n }\n queue.push(...allOfRefs(state, ref));\n }\n return [...found.values()];\n}\n\n/**\n * The child redefines this property, so its `allOf` items omit it: a parent may have a value of\n * its own, as `Content` has when `Element`'s mapping names it.\n */\nfunction recordOtherProperty(state: ScanState, ref: string, propertyName: string): void {\n const names = state.otherProperties[ref] ?? [];\n if (!names.includes(propertyName)) {\n names.push(propertyName);\n }\n state.otherProperties[ref] = names;\n}\n\n/**\n * The child at `ref` of the schema at `parentRef` gets a value of each other property: a mapped\n * one at once, else its schema name after both passes, where no mapping gives one. The schema's\n * own discriminator property is still added, so these patches do not mark it handled.\n */\nexport function inheritOtherOwners(state: ScanState, parentRef: string, ref: string): void {\n const childProperty = state.objects[ref]?.propertyName;\n for (const { discriminator, ownerRef } of otherOwners(state, parentRef)) {\n if (discriminator.propertyName === childProperty) {\n continue;\n }\n recordOtherProperty(state, ref, discriminator.propertyName);\n const mapped = Object.entries(discriminator.mapping ?? {})\n .filter(([, target]) => target === ref)\n .map(([value]) => value);\n const name = ref.slice(ref.lastIndexOf(\"/\") + 1);\n const patch: EnumPatch = { ref, values: mapped, discriminator, discriminatorRef: ownerRef };\n if (mapped.length > 0) {\n patchDiscriminatorEnum(state, patch);\n } else {\n state.otherInferredPatches.push({ ...patch, values: [name] });\n }\n }\n}\n\n/** The deferred schema-name values of other properties; see `inheritOtherOwners`. */\nexport function applyOtherInferredPatches(state: ScanState, mapped: ReadonlySet<string>): void {\n for (const patch of state.otherInferredPatches) {\n if (!mapped.has(enumKey(patch))) {\n patchDiscriminatorEnum(state, patch);\n }\n }\n}\n"],"names":[],"mappings":";;;AAmBA,SAAS,SAAA,CAAU,OAAkB,GAAA,EAAuB;AAC1D,EAAA,MAAM,EAAE,MAAA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,MAAM,QAAmB,EAAE,GAAA,EAAK,QAAQ,MAAA,EAAQ,aAAA,EAAe,kBAAkB,QAAA,EAAS;AAC1F,IAAA,IAAI,MAAA,CAAO,SAAS,CAAA,EAAG;AACrB,MAAA,sBAAA,CAAuB,OAAO,KAAK,CAAA;AAAA,IACrC,CAAA,MAAO;AACL,MAAA,KAAA,CAAM,oBAAA,CAAqB,KAAK,EAAE,GAAG,OAAO,MAAA,EAAQ,CAAC,IAAI,CAAA,EAAG,CAAA;AAAA,IAC9D;AAAA,EACF;AACF;AAGO,SAAS,yBAAA,CAA0B,OAAkB,MAAA,EAAmC;AAC7F,EAAA,KAAA,MAAW,KAAA,IAAS,MAAM,oBAAA,EAAsB;AAC9C,IAAA,IAAI,CAAC,MAAA,CAAO,GAAA,CAAI,OAAA,CAAQ,KAAK,CAAC,CAAA,EAAG;AAC/B,MAAA,sBAAA,CAAuB,OAAO,KAAK,CAAA;AAAA,IACrC;AAAA,EACF;AACF;;"}
1
+ {"version":3,"file":"discriminator-other-owners.mjs","sources":["../../src/api/discriminator-other-owners.ts"],"sourcesContent":["import { appendAll } from \"../domain/append-all.js\";\nimport { canonicalRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject, ReferenceObject, SchemaObject } from \"../types.js\";\nimport type { EnumPatch } from \"./discriminator-enum.js\";\nimport { enumKey, patchDiscriminatorEnum, type ScanState } from \"./discriminator-patch.js\";\nimport { resolveDocumentRef } from \"./document-refs.js\";\n\n/**\n * The `discriminator-values` fix: a schema inherits one discriminator per property. A schema that\n * owns a discriminator keeps its own (#2200), so the scan does not record the one it inherits for\n * another property (`Content` owns `subtype` and `allOf`s `Element`, which owns `contentType`).\n * Its members (`Video`) still get a value of that property, found here from the owners above.\n */\n\n/** A discriminator and the schema that defines it. */\ninterface OtherOwner {\n readonly discriminator: DiscriminatorObject;\n readonly ownerRef: string;\n}\n\n/** The `$ref`s of a schema's `allOf` items. */\nfunction allOfRefs(state: ScanState, ref: string): string[] {\n const { silent, logger } = state;\n const schema = resolveDocumentRef<SchemaObject>(state.schema, ref, { silent, logger });\n const items = (schema?.allOf ?? []) as (SchemaObject | ReferenceObject)[];\n return items.flatMap((item) =>\n \"$ref\" in item && typeof item.$ref === \"string\" ? [canonicalRef(item.$ref)] : [],\n );\n}\n\n/**\n * The owners' discriminators that the schema at `parentRef` and its `allOf` parents define, the\n * nearest one per property, except the property of `parentRef`'s own discriminator.\n */\nfunction otherOwners(state: ScanState, parentRef: string): OtherOwner[] {\n const own = state.objects[parentRef]?.propertyName;\n const found = new Map<string, OtherOwner>();\n const visited = new Set<string>();\n const queue = [parentRef];\n for (let ref = queue.shift(); ref !== undefined; ref = queue.shift()) {\n if (visited.has(ref)) {\n continue;\n }\n visited.add(ref);\n const discriminator = state.owners.has(ref) ? state.objects[ref] : undefined;\n const name = discriminator?.propertyName;\n if (discriminator && name !== undefined && name !== own && !found.has(name)) {\n found.set(name, { discriminator, ownerRef: ref });\n }\n appendAll(queue, allOfRefs(state, ref));\n }\n return [...found.values()];\n}\n\n/**\n * The child redefines this property, so its `allOf` items omit it: a parent may have a value of\n * its own, as `Content` has when `Element`'s mapping names it.\n */\nfunction recordOtherProperty(state: ScanState, ref: string, propertyName: string): void {\n const names = state.otherProperties[ref] ?? [];\n if (!names.includes(propertyName)) {\n names.push(propertyName);\n }\n state.otherProperties[ref] = names;\n}\n\n/**\n * The child at `ref` of the schema at `parentRef` gets a value of each other property: a mapped\n * one at once, else its schema name after both passes, where no mapping gives one. The schema's\n * own discriminator property is still added, so these patches do not mark it handled.\n */\nexport function inheritOtherOwners(state: ScanState, parentRef: string, ref: string): void {\n const childProperty = state.objects[ref]?.propertyName;\n for (const { discriminator, ownerRef } of otherOwners(state, parentRef)) {\n if (discriminator.propertyName === childProperty) {\n continue;\n }\n recordOtherProperty(state, ref, discriminator.propertyName);\n const mapped = Object.entries(discriminator.mapping ?? {})\n .filter(([, target]) => canonicalRef(target) === ref)\n .map(([value]) => value);\n const name = ref.slice(ref.lastIndexOf(\"/\") + 1);\n const patch: EnumPatch = { ref, values: mapped, discriminator, discriminatorRef: ownerRef };\n if (mapped.length > 0) {\n patchDiscriminatorEnum(state, patch);\n } else {\n state.otherInferredPatches.push({ ...patch, values: [name] });\n }\n }\n}\n\n/** The deferred schema-name values of other properties; see `inheritOtherOwners`. */\nexport function applyOtherInferredPatches(state: ScanState, mapped: ReadonlySet<string>): void {\n for (const patch of state.otherInferredPatches) {\n if (!mapped.has(enumKey(patch))) {\n patchDiscriminatorEnum(state, patch);\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAqBA,SAAS,SAAA,CAAU,OAAkB,GAAA,EAAuB;AAC1D,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAO,GAAI,KAAA;AAC3B,EAAA,MAAM,MAAA,GAAS,mBAAiC,KAAA,CAAM,MAAA,EAAQ,KAAK,EAAE,MAAA,EAAQ,QAAQ,CAAA;AACrF,EAAA,MAAM,KAAA,GAAS,MAAA,EAAQ,KAAA,IAAS,EAAC;AACjC,EAAA,OAAO,KAAA,CAAM,OAAA;AAAA,IAAQ,CAAC,IAAA,KACpB,MAAA,IAAU,IAAA,IAAQ,OAAO,IAAA,CAAK,IAAA,KAAS,QAAA,GAAW,CAAC,YAAA,CAAa,IAAA,CAAK,IAAI,CAAC,IAAI;AAAC,GACjF;AACF;AAMA,SAAS,WAAA,CAAY,OAAkB,SAAA,EAAiC;AACtE,EAAA,MAAM,GAAA,GAAM,KAAA,CAAM,OAAA,CAAQ,SAAS,CAAA,EAAG,YAAA;AACtC,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAwB;AAC1C,EAAA,MAAM,OAAA,uBAAc,GAAA,EAAY;AAChC,EAAA,MAAM,KAAA,GAAQ,CAAC,SAAS,CAAA;AACxB,EAAA,KAAA,IAAS,GAAA,GAAM,MAAM,KAAA,EAAM,EAAG,QAAQ,MAAA,EAAW,GAAA,GAAM,KAAA,CAAM,KAAA,EAAM,EAAG;AACpE,IAAA,IAA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