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

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 (366) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/dist/adapters/node-file-system/node-file-system.cjs +7 -0
  3. package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
  4. package/dist/adapters/node-file-system/node-file-system.mjs +7 -0
  5. package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
  6. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs +19 -0
  7. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs.map +1 -0
  8. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs +17 -0
  9. package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs.map +1 -0
  10. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +5 -32
  11. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -1
  12. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +6 -33
  13. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -1
  14. package/dist/adapters/redocly-loader/component-schemas.cjs +17 -0
  15. package/dist/adapters/redocly-loader/component-schemas.cjs.map +1 -0
  16. package/dist/adapters/redocly-loader/component-schemas.mjs +14 -0
  17. package/dist/adapters/redocly-loader/component-schemas.mjs.map +1 -0
  18. package/dist/adapters/redocly-loader/mapping-schema-names.cjs +22 -0
  19. package/dist/adapters/redocly-loader/mapping-schema-names.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/mapping-schema-names.mjs +20 -0
  21. package/dist/adapters/redocly-loader/mapping-schema-names.mjs.map +1 -0
  22. package/dist/adapters/redocly-loader/query-document-names.cjs +50 -0
  23. package/dist/adapters/redocly-loader/query-document-names.cjs.map +1 -0
  24. package/dist/adapters/redocly-loader/query-document-names.mjs +48 -0
  25. package/dist/adapters/redocly-loader/query-document-names.mjs.map +1 -0
  26. package/dist/adapters/redocly-loader/query-named-components.cjs +129 -0
  27. package/dist/adapters/redocly-loader/query-named-components.cjs.map +1 -0
  28. package/dist/adapters/redocly-loader/query-named-components.mjs +126 -0
  29. package/dist/adapters/redocly-loader/query-named-components.mjs.map +1 -0
  30. package/dist/adapters/redocly-loader/redocly-config-source.cjs +3 -0
  31. package/dist/adapters/redocly-loader/redocly-config-source.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/redocly-config-source.mjs +4 -1
  33. package/dist/adapters/redocly-loader/redocly-config-source.mjs.map +1 -1
  34. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +39 -18
  35. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  36. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +40 -19
  37. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  38. package/dist/adapters/redocly-loader/ref-access.cjs +25 -4
  39. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  40. package/dist/adapters/redocly-loader/ref-access.mjs +26 -5
  41. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  42. package/dist/adapters/redocly-loader/ref-holders.cjs +52 -10
  43. package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
  44. package/dist/adapters/redocly-loader/ref-holders.mjs +52 -11
  45. package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
  46. package/dist/adapters/redocly-loader/remote-fetch.cjs +20 -3
  47. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  48. package/dist/adapters/redocly-loader/remote-fetch.mjs +20 -4
  49. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  50. package/dist/adapters/redocly-loader/remote-node-limit.cjs +17 -3
  51. package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -1
  52. package/dist/adapters/redocly-loader/remote-node-limit.mjs +17 -3
  53. package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -1
  54. package/dist/adapters/redocly-loader/schema-source.cjs +7 -2
  55. package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
  56. package/dist/adapters/redocly-loader/schema-source.mjs +8 -3
  57. package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
  58. package/dist/adapters/terminal-logger/terminal-logger.cjs +7 -3
  59. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  60. package/dist/adapters/terminal-logger/terminal-logger.mjs +7 -3
  61. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  62. package/dist/api/cwd-option.cjs +58 -0
  63. package/dist/api/cwd-option.cjs.map +1 -0
  64. package/dist/api/cwd-option.mjs +52 -0
  65. package/dist/api/cwd-option.mjs.map +1 -0
  66. package/dist/api/default-ports.cjs +15 -7
  67. package/dist/api/default-ports.cjs.map +1 -1
  68. package/dist/api/default-ports.mjs +14 -8
  69. package/dist/api/default-ports.mjs.map +1 -1
  70. package/dist/api/document-refs.cjs +16 -1
  71. package/dist/api/document-refs.cjs.map +1 -1
  72. package/dist/api/document-refs.mjs +16 -1
  73. package/dist/api/document-refs.mjs.map +1 -1
  74. package/dist/api/document-run.cjs +6 -26
  75. package/dist/api/document-run.cjs.map +1 -1
  76. package/dist/api/document-run.mjs +5 -21
  77. package/dist/api/document-run.mjs.map +1 -1
  78. package/dist/api/legacy-utils.cjs +1 -1
  79. package/dist/api/legacy-utils.cjs.map +1 -1
  80. package/dist/api/legacy-utils.mjs +1 -1
  81. package/dist/api/legacy-utils.mjs.map +1 -1
  82. package/dist/api/openapi-ts.cjs +1 -2
  83. package/dist/api/openapi-ts.cjs.map +1 -1
  84. package/dist/api/openapi-ts.mjs +2 -3
  85. package/dist/api/openapi-ts.mjs.map +1 -1
  86. package/dist/api/option-errors.cjs +24 -0
  87. package/dist/api/option-errors.cjs.map +1 -0
  88. package/dist/api/option-errors.mjs +21 -0
  89. package/dist/api/option-errors.mjs.map +1 -0
  90. package/dist/api/ref-limit-options.cjs +58 -0
  91. package/dist/api/ref-limit-options.cjs.map +1 -0
  92. package/dist/api/ref-limit-options.mjs +52 -0
  93. package/dist/api/ref-limit-options.mjs.map +1 -0
  94. package/dist/api/transform-schema.cjs +12 -5
  95. package/dist/api/transform-schema.cjs.map +1 -1
  96. package/dist/api/transform-schema.mjs +12 -5
  97. package/dist/api/transform-schema.mjs.map +1 -1
  98. package/dist/application/transform/declared-value-types.cjs +36 -0
  99. package/dist/application/transform/declared-value-types.cjs.map +1 -0
  100. package/dist/application/transform/declared-value-types.mjs +34 -0
  101. package/dist/application/transform/declared-value-types.mjs.map +1 -0
  102. package/dist/application/transform/document/document.cjs +3 -1
  103. package/dist/application/transform/document/document.cjs.map +1 -1
  104. package/dist/application/transform/document/document.mjs +3 -1
  105. package/dist/application/transform/document/document.mjs.map +1 -1
  106. package/dist/application/transform/document/exploded-query-values.cjs +63 -0
  107. package/dist/application/transform/document/exploded-query-values.cjs.map +1 -0
  108. package/dist/application/transform/document/exploded-query-values.mjs +59 -0
  109. package/dist/application/transform/document/exploded-query-values.mjs.map +1 -0
  110. package/dist/application/transform/document/header.cjs +11 -3
  111. package/dist/application/transform/document/header.cjs.map +1 -1
  112. package/dist/application/transform/document/header.mjs +10 -2
  113. package/dist/application/transform/document/header.mjs.map +1 -1
  114. package/dist/application/transform/document/parameter.cjs +1 -1
  115. package/dist/application/transform/document/parameter.cjs.map +1 -1
  116. package/dist/application/transform/document/parameter.mjs +1 -1
  117. package/dist/application/transform/document/parameter.mjs.map +1 -1
  118. package/dist/application/transform/document/parameters.cjs +23 -5
  119. package/dist/application/transform/document/parameters.cjs.map +1 -1
  120. package/dist/application/transform/document/parameters.mjs +23 -5
  121. package/dist/application/transform/document/parameters.mjs.map +1 -1
  122. package/dist/application/transform/document/path-item.cjs +4 -3
  123. package/dist/application/transform/document/path-item.cjs.map +1 -1
  124. package/dist/application/transform/document/path-item.mjs +4 -4
  125. package/dist/application/transform/document/path-item.mjs.map +1 -1
  126. package/dist/application/transform/document/path-template-key.cjs +84 -0
  127. package/dist/application/transform/document/path-template-key.cjs.map +1 -0
  128. package/dist/application/transform/document/path-template-key.mjs +79 -0
  129. package/dist/application/transform/document/path-template-key.mjs.map +1 -0
  130. package/dist/application/transform/document/path-template-refs.cjs +80 -0
  131. package/dist/application/transform/document/path-template-refs.cjs.map +1 -0
  132. package/dist/application/transform/document/path-template-refs.mjs +77 -0
  133. package/dist/application/transform/document/path-template-refs.mjs.map +1 -0
  134. package/dist/application/transform/document/paths-enum.cjs +7 -6
  135. package/dist/application/transform/document/paths-enum.cjs.map +1 -1
  136. package/dist/application/transform/document/paths-enum.mjs +7 -6
  137. package/dist/application/transform/document/paths-enum.mjs.map +1 -1
  138. package/dist/application/transform/document/paths.cjs +38 -66
  139. package/dist/application/transform/document/paths.cjs.map +1 -1
  140. package/dist/application/transform/document/paths.mjs +36 -66
  141. package/dist/application/transform/document/paths.mjs.map +1 -1
  142. package/dist/application/transform/document/webhooks.cjs +10 -3
  143. package/dist/application/transform/document/webhooks.cjs.map +1 -1
  144. package/dist/application/transform/document/webhooks.mjs +9 -2
  145. package/dist/application/transform/document/webhooks.mjs.map +1 -1
  146. package/dist/application/transform/footer/document-footer.cjs +6 -3
  147. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  148. package/dist/application/transform/footer/document-footer.mjs +6 -3
  149. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  150. package/dist/application/transform/helper-types.cjs +3 -3
  151. package/dist/application/transform/helper-types.cjs.map +1 -1
  152. package/dist/application/transform/helper-types.mjs +3 -3
  153. package/dist/application/transform/helper-types.mjs.map +1 -1
  154. package/dist/application/transform/ref-pointer/generated-location.cjs +4 -4
  155. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
  156. package/dist/application/transform/ref-pointer/generated-location.mjs +1 -1
  157. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
  158. package/dist/application/transform/ref-pointer/generated-shape.cjs +63 -64
  159. package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -1
  160. package/dist/application/transform/ref-pointer/generated-shape.mjs +57 -53
  161. package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -1
  162. package/dist/application/transform/ref-pointer/inline-cycles.cjs +2 -2
  163. package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -1
  164. package/dist/application/transform/ref-pointer/inline-cycles.mjs +1 -1
  165. package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -1
  166. package/dist/application/transform/ref-pointer/located-node.cjs +23 -0
  167. package/dist/application/transform/ref-pointer/located-node.cjs.map +1 -0
  168. package/dist/application/transform/ref-pointer/located-node.mjs +18 -0
  169. package/dist/application/transform/ref-pointer/located-node.mjs.map +1 -0
  170. package/dist/application/transform/ref-pointer/original-index.cjs +69 -14
  171. package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -1
  172. package/dist/application/transform/ref-pointer/original-index.mjs +71 -16
  173. package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -1
  174. package/dist/application/transform/ref-pointer/pointer-type.cjs +2 -2
  175. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  176. package/dist/application/transform/ref-pointer/pointer-type.mjs +1 -1
  177. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  178. package/dist/application/transform/ref-pointer/pointer-walk.cjs +54 -13
  179. package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -1
  180. package/dist/application/transform/ref-pointer/pointer-walk.mjs +46 -7
  181. package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -1
  182. package/dist/application/transform/ref-pointer/property-shape.cjs +57 -0
  183. package/dist/application/transform/ref-pointer/property-shape.cjs.map +1 -0
  184. package/dist/application/transform/ref-pointer/property-shape.mjs +49 -0
  185. package/dist/application/transform/ref-pointer/property-shape.mjs.map +1 -0
  186. package/dist/application/transform/ref-pointer/typed-walk.cjs +90 -22
  187. package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -1
  188. package/dist/application/transform/ref-pointer/typed-walk.mjs +87 -19
  189. package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -1
  190. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  191. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  192. package/dist/application/transform/schema/index-signature-type.cjs +21 -0
  193. package/dist/application/transform/schema/index-signature-type.cjs.map +1 -0
  194. package/dist/application/transform/schema/index-signature-type.mjs +19 -0
  195. package/dist/application/transform/schema/index-signature-type.mjs.map +1 -0
  196. package/dist/application/transform/schema/input-location.cjs +23 -0
  197. package/dist/application/transform/schema/input-location.cjs.map +1 -0
  198. package/dist/application/transform/schema/input-location.mjs +21 -0
  199. package/dist/application/transform/schema/input-location.mjs.map +1 -0
  200. package/dist/application/transform/schema/object-type.cjs +15 -5
  201. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  202. package/dist/application/transform/schema/object-type.mjs +15 -5
  203. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  204. package/dist/application/transform/schema/schema-transform.cjs +2 -1
  205. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  206. package/dist/application/transform/schema/schema-transform.mjs +2 -1
  207. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  208. package/dist/application/transform/schema/unevaluated-properties.cjs +2 -30
  209. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  210. package/dist/application/transform/schema/unevaluated-properties.mjs +3 -31
  211. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  212. package/dist/cli/api-logger.cjs +13 -0
  213. package/dist/cli/api-logger.cjs.map +1 -0
  214. package/dist/cli/api-logger.mjs +11 -0
  215. package/dist/cli/api-logger.mjs.map +1 -0
  216. package/dist/cli/api-settings.cjs +10 -17
  217. package/dist/cli/api-settings.cjs.map +1 -1
  218. package/dist/cli/api-settings.mjs +10 -17
  219. package/dist/cli/api-settings.mjs.map +1 -1
  220. package/dist/cli/api-writes.cjs +7 -1
  221. package/dist/cli/api-writes.cjs.map +1 -1
  222. package/dist/cli/api-writes.mjs +7 -1
  223. package/dist/cli/api-writes.mjs.map +1 -1
  224. package/dist/cli/cli-arguments.cjs +32 -74
  225. package/dist/cli/cli-arguments.cjs.map +1 -1
  226. package/dist/cli/cli-arguments.mjs +28 -70
  227. package/dist/cli/cli-arguments.mjs.map +1 -1
  228. package/dist/cli/cli-errors.cjs +18 -0
  229. package/dist/cli/cli-errors.cjs.map +1 -1
  230. package/dist/cli/cli-errors.mjs +18 -1
  231. package/dist/cli/cli-errors.mjs.map +1 -1
  232. package/dist/cli/cli-flag-names.cjs +77 -0
  233. package/dist/cli/cli-flag-names.cjs.map +1 -0
  234. package/dist/cli/cli-flag-names.mjs +64 -0
  235. package/dist/cli/cli-flag-names.mjs.map +1 -0
  236. package/dist/cli/cli-output.cjs +13 -6
  237. package/dist/cli/cli-output.cjs.map +1 -1
  238. package/dist/cli/cli-output.mjs +14 -7
  239. package/dist/cli/cli-output.mjs.map +1 -1
  240. package/dist/cli/main.cjs +11 -5
  241. package/dist/cli/main.cjs.map +1 -1
  242. package/dist/cli/main.mjs +11 -5
  243. package/dist/cli/main.mjs.map +1 -1
  244. package/dist/cli/redocly-apis.cjs +33 -12
  245. package/dist/cli/redocly-apis.cjs.map +1 -1
  246. package/dist/cli/redocly-apis.mjs +35 -14
  247. package/dist/cli/redocly-apis.mjs.map +1 -1
  248. package/dist/cli/ref-limits.cjs +15 -1
  249. package/dist/cli/ref-limits.cjs.map +1 -1
  250. package/dist/cli/ref-limits.mjs +15 -2
  251. package/dist/cli/ref-limits.mjs.map +1 -1
  252. package/dist/cli/run-cli.cjs +24 -7
  253. package/dist/cli/run-cli.cjs.map +1 -1
  254. package/dist/cli/run-cli.mjs +25 -8
  255. package/dist/cli/run-cli.mjs.map +1 -1
  256. package/dist/cli/written-flags.cjs +83 -0
  257. package/dist/cli/written-flags.cjs.map +1 -0
  258. package/dist/cli/written-flags.mjs +77 -0
  259. package/dist/cli/written-flags.mjs.map +1 -0
  260. package/dist/domain/cause-secrets.cjs +31 -16
  261. package/dist/domain/cause-secrets.cjs.map +1 -1
  262. package/dist/domain/cause-secrets.mjs +31 -16
  263. package/dist/domain/cause-secrets.mjs.map +1 -1
  264. package/dist/domain/errors.cjs +3 -0
  265. package/dist/domain/errors.cjs.map +1 -1
  266. package/dist/domain/errors.mjs +3 -0
  267. package/dist/domain/errors.mjs.map +1 -1
  268. package/dist/domain/location-text.cjs +15 -0
  269. package/dist/domain/location-text.cjs.map +1 -0
  270. package/dist/domain/location-text.mjs +13 -0
  271. package/dist/domain/location-text.mjs.map +1 -0
  272. package/dist/domain/openapi/document-places.cjs +55 -0
  273. package/dist/domain/openapi/document-places.cjs.map +1 -0
  274. package/dist/domain/openapi/document-places.mjs +53 -0
  275. package/dist/domain/openapi/document-places.mjs.map +1 -0
  276. package/dist/domain/output-fixes.cjs +8 -2
  277. package/dist/domain/output-fixes.cjs.map +1 -1
  278. package/dist/domain/output-fixes.mjs +8 -2
  279. package/dist/domain/output-fixes.mjs.map +1 -1
  280. package/dist/domain/terminal-text.cjs +31 -0
  281. package/dist/domain/terminal-text.cjs.map +1 -0
  282. package/dist/domain/terminal-text.mjs +29 -0
  283. package/dist/domain/terminal-text.mjs.map +1 -0
  284. package/dist/domain/warnings.cjs +1 -0
  285. package/dist/domain/warnings.cjs.map +1 -1
  286. package/dist/domain/warnings.mjs +1 -0
  287. package/dist/domain/warnings.mjs.map +1 -1
  288. package/dist/index.d.cts +29 -18
  289. package/dist/index.d.mts +29 -18
  290. package/dist/index.d.ts +29 -18
  291. package/package.json +1 -1
  292. package/src/adapters/node-file-system/node-file-system.ts +14 -1
  293. package/src/adapters/pipe-safe-writer/pipe-safe-writer.ts +29 -0
  294. package/src/adapters/redocly-loader/bundled-mapping-copies.ts +7 -42
  295. package/src/adapters/redocly-loader/component-schemas.ts +19 -0
  296. package/src/adapters/redocly-loader/mapping-schema-names.ts +25 -0
  297. package/src/adapters/redocly-loader/query-document-names.ts +79 -0
  298. package/src/adapters/redocly-loader/query-named-components.ts +200 -0
  299. package/src/adapters/redocly-loader/redocly-config-source.ts +11 -1
  300. package/src/adapters/redocly-loader/redocly-schema-loader.ts +63 -17
  301. package/src/adapters/redocly-loader/ref-access.ts +32 -5
  302. package/src/adapters/redocly-loader/ref-holders.ts +75 -14
  303. package/src/adapters/redocly-loader/remote-fetch.ts +37 -2
  304. package/src/adapters/redocly-loader/remote-node-limit.ts +44 -4
  305. package/src/adapters/redocly-loader/schema-source.ts +15 -3
  306. package/src/adapters/terminal-logger/terminal-logger.ts +10 -4
  307. package/src/api/cwd-option.ts +76 -0
  308. package/src/api/default-ports.ts +33 -10
  309. package/src/api/document-refs.ts +29 -1
  310. package/src/api/document-run.ts +7 -32
  311. package/src/api/legacy-utils.ts +1 -1
  312. package/src/api/openapi-ts.ts +20 -4
  313. package/src/api/option-errors.ts +22 -0
  314. package/src/api/ref-limit-options.ts +69 -0
  315. package/src/api/transform-schema.ts +20 -5
  316. package/src/application/ports/file-system.ts +8 -0
  317. package/src/application/ports/redocly-config-source.ts +5 -0
  318. package/src/application/transform/declared-value-types.ts +42 -0
  319. package/src/application/transform/document/document.ts +4 -2
  320. package/src/application/transform/document/exploded-query-values.ts +88 -0
  321. package/src/application/transform/document/header.ts +25 -5
  322. package/src/application/transform/document/parameter.ts +4 -4
  323. package/src/application/transform/document/parameters.ts +45 -10
  324. package/src/application/transform/document/path-item.ts +3 -3
  325. package/src/application/transform/document/path-template-key.ts +152 -0
  326. package/src/application/transform/document/path-template-refs.ts +127 -0
  327. package/src/application/transform/document/paths-enum.ts +23 -9
  328. package/src/application/transform/document/paths.ts +53 -123
  329. package/src/application/transform/document/webhooks.ts +18 -5
  330. package/src/application/transform/footer/document-footer.ts +18 -8
  331. package/src/application/transform/helper-types.ts +4 -4
  332. package/src/application/transform/ref-pointer/generated-location.ts +1 -1
  333. package/src/application/transform/ref-pointer/generated-shape.ts +115 -83
  334. package/src/application/transform/ref-pointer/inline-cycles.ts +1 -1
  335. package/src/application/transform/ref-pointer/located-node.ts +38 -0
  336. package/src/application/transform/ref-pointer/original-index.ts +106 -20
  337. package/src/application/transform/ref-pointer/pointer-type.ts +1 -1
  338. package/src/application/transform/ref-pointer/pointer-walk.ts +82 -8
  339. package/src/application/transform/ref-pointer/property-shape.ts +106 -0
  340. package/src/application/transform/ref-pointer/typed-walk.ts +143 -29
  341. package/src/application/transform/schema/access-flags.ts +5 -2
  342. package/src/application/transform/schema/index-signature-type.ts +31 -0
  343. package/src/application/transform/schema/input-location.ts +35 -0
  344. package/src/application/transform/schema/object-type.ts +18 -8
  345. package/src/application/transform/schema/schema-transform.ts +2 -1
  346. package/src/application/transform/schema/unevaluated-properties.ts +4 -44
  347. package/src/cli/api-logger.ts +17 -0
  348. package/src/cli/api-settings.ts +12 -20
  349. package/src/cli/api-writes.ts +11 -3
  350. package/src/cli/cli-arguments.ts +57 -92
  351. package/src/cli/cli-dependencies.ts +7 -2
  352. package/src/cli/cli-errors.ts +23 -0
  353. package/src/cli/cli-flag-names.ts +99 -0
  354. package/src/cli/cli-output.ts +31 -16
  355. package/src/cli/main.ts +12 -5
  356. package/src/cli/redocly-apis.ts +56 -20
  357. package/src/cli/ref-limits.ts +21 -2
  358. package/src/cli/run-cli.ts +39 -7
  359. package/src/cli/written-flags.ts +131 -0
  360. package/src/domain/cause-secrets.ts +59 -25
  361. package/src/domain/errors.ts +3 -0
  362. package/src/domain/location-text.ts +27 -0
  363. package/src/domain/openapi/document-places.ts +78 -0
  364. package/src/domain/output-fixes.ts +9 -2
  365. package/src/domain/terminal-text.ts +44 -0
  366. package/src/domain/warnings.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-utils.cjs","sources":["../../src/api/legacy-utils.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport { formatDuration } from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DebugGroup } from \"../application/ports/logger.js\";\nimport { discriminatorProperty } from \"../application/transform/schema/discriminator-property.js\";\nimport type { IrPropertySignature } from \"../domain/ir/nodes.js\";\nimport { createRef as createDomainRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject } from \"../types.js\";\nimport { defaultLogger, terminalSupportsColor } from \"./default-ports.js\";\nimport { type ResolveRefOptions, resolveDocumentRef, walkDocument } from \"./document-refs.js\";\n\n/**\n * The original's exported utilities, kept for 1.x (ADR-004, decision 9). The generator itself\n * logs through the Logger port; `debug`, `warn` and `error` here write through the default one.\n */\n\n// The exported `c` is the shared ansi-colors instance, switched off at import when the terminal has\n// no colors, as the original did. The generator's own logger uses a separate instance.\nif (!terminalSupportsColor()) {\n colors.enabled = false;\n}\n\n/**\n * The shared ansi-colors instance.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9). Use a color library directly.\n */\nexport const c = colors;\n\n/**\n * The discriminator property of a schema at `path`, typed as its discriminator value. Returns IR\n * (task 6.2), like the exported transformers.\n */\nexport function createDiscriminatorProperty(\n discriminator: DiscriminatorObject,\n { path, readonly = false }: { path: string; readonly?: boolean },\n): IrPropertySignature {\n return discriminatorProperty(discriminator, path, readonly);\n}\n\n/**\n * Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`\n * and contributes its decoded segments, so it throws URIError for a malformed percent escape; any\n * other part is one segment. To append raw document keys, escape each one instead.\n */\nexport function createRef(parts: (number | string | undefined | null)[]): string {\n return createDomainRef(parts);\n}\n\n/**\n * Print debug message (cribbed from the `debug` package, but without all the bells & whistles\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function debug(msg: string, group?: string, time?: number) {\n // Any group name was accepted; one the logger does not know prints in white, as before.\n defaultLogger(false).debug(msg, group as DebugGroup | undefined, time);\n}\n\n/**\n * Print error message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function error(msg: string) {\n defaultLogger(false).error(msg);\n}\n\n/** Format a performance log in a friendly format */\nexport function formatTime(t: number) {\n return typeof t === \"number\" ? formatDuration(t) : t;\n}\n\n/** Call Object.entries() and optionally sort */\nexport function getEntries<T>(\n obj: ArrayLike<T> | Record<string, T>,\n options?: {\n alphabetize?: boolean;\n excludeDeprecated?: boolean;\n },\n) {\n let entries = Object.entries(obj);\n if (options?.alphabetize) {\n entries.sort(([a], [b]) => a.localeCompare(b, \"en-us\", { numeric: true }));\n }\n if (options?.excludeDeprecated) {\n entries = entries.filter(\n ([, v]) => !(v && typeof v === \"object\" && \"deprecated\" in v && v.deprecated),\n );\n }\n return entries;\n}\n\nexport type { ResolveRefOptions } from \"./document-refs.js\";\n\n/**\n * resolve a $ref in a schema\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function resolveRef<T>(\n schema: unknown,\n $ref: string,\n options: ResolveRefOptions,\n): T | undefined {\n return resolveDocumentRef<T>(schema, $ref, options);\n}\n\n/**\n * Walk through any JSON-serializable (i.e. non-circular) object\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function walk(\n obj: unknown,\n cb: (value: Record<string, unknown>, path: (string | number)[]) => void,\n path: (string | number)[] = [],\n): void {\n walkDocument(obj, cb, path);\n}\n\n/**\n * Print warning message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function warn(msg: string, silent = false) {\n defaultLogger(silent).warn(msg);\n}\n"],"names":["terminalSupportsColor","colors","discriminatorProperty","createDomainRef","defaultLogger","formatDuration","resolveDocumentRef","walkDocument"],"mappings":";;;;;;;;;;;;;AAiBA,IAAI,CAACA,oCAAsB,EAAG;AAC5B,EAAAC,eAAA,CAAO,OAAA,GAAU,KAAA;AACnB;AAMO,MAAM,CAAA,GAAIA;AAMV,SAAS,4BACd,aAAA,EACA,EAAE,IAAA,EAAM,QAAA,GAAW,OAAM,EACJ;AACrB,EAAA,OAAOC,2CAAA,CAAsB,aAAA,EAAe,IAAA,EAAM,QAAQ,CAAA;AAC5D;AAOO,SAAS,UAAU,KAAA,EAAuD;AAC/E,EAAA,OAAOC,sBAAgB,KAAK,CAAA;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CAAA;AAC5B;AAMO,SAAS,IAAA,CAAK,GAAA,EAAa,MAAA,GAAS,KAAA,EAAO;AAChD,EAAAH,0BAAA,CAAc,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAChC;;;;;;;;;;;"}
1
+ {"version":3,"file":"legacy-utils.cjs","sources":["../../src/api/legacy-utils.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport { formatDuration } from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DebugGroup } from \"../application/ports/logger.js\";\nimport { discriminatorProperty } from \"../application/transform/schema/discriminator-property.js\";\nimport type { IrPropertySignature } from \"../domain/ir/nodes.js\";\nimport { createRef as createDomainRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject } from \"../types.js\";\nimport { defaultLogger, terminalSupportsColor } from \"./default-ports.js\";\nimport { type ResolveRefOptions, resolveDocumentRef, walkDocument } from \"./document-refs.js\";\n\n/**\n * The original's exported utilities, kept for 1.x (ADR-004, decision 9). The generator itself\n * logs through the Logger port; `debug`, `warn` and `error` here write through the default one.\n */\n\n// The exported `c` is the shared ansi-colors instance, switched off at import when the terminal has\n// no colors, as the original did. The generator's own logger uses a separate instance.\nif (!terminalSupportsColor(\"stdout\")) {\n colors.enabled = false;\n}\n\n/**\n * The shared ansi-colors instance.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9). Use a color library directly.\n */\nexport const c = colors;\n\n/**\n * The discriminator property of a schema at `path`, typed as its discriminator value. Returns IR\n * (task 6.2), like the exported transformers.\n */\nexport function createDiscriminatorProperty(\n discriminator: DiscriminatorObject,\n { path, readonly = false }: { path: string; readonly?: boolean },\n): IrPropertySignature {\n return discriminatorProperty(discriminator, path, readonly);\n}\n\n/**\n * Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`\n * and contributes its decoded segments, so it throws URIError for a malformed percent escape; any\n * other part is one segment. To append raw document keys, escape each one instead.\n */\nexport function createRef(parts: (number | string | undefined | null)[]): string {\n return createDomainRef(parts);\n}\n\n/**\n * Print debug message (cribbed from the `debug` package, but without all the bells & whistles\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function debug(msg: string, group?: string, time?: number) {\n // Any group name was accepted; one the logger does not know prints in white, as before.\n defaultLogger(false).debug(msg, group as DebugGroup | undefined, time);\n}\n\n/**\n * Print error message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function error(msg: string) {\n defaultLogger(false).error(msg);\n}\n\n/** Format a performance log in a friendly format */\nexport function formatTime(t: number) {\n return typeof t === \"number\" ? formatDuration(t) : t;\n}\n\n/** Call Object.entries() and optionally sort */\nexport function getEntries<T>(\n obj: ArrayLike<T> | Record<string, T>,\n options?: {\n alphabetize?: boolean;\n excludeDeprecated?: boolean;\n },\n) {\n let entries = Object.entries(obj);\n if (options?.alphabetize) {\n entries.sort(([a], [b]) => a.localeCompare(b, \"en-us\", { numeric: true }));\n }\n if (options?.excludeDeprecated) {\n entries = entries.filter(\n ([, v]) => !(v && typeof v === \"object\" && \"deprecated\" in v && v.deprecated),\n );\n }\n return entries;\n}\n\nexport type { ResolveRefOptions } from \"./document-refs.js\";\n\n/**\n * resolve a $ref in a schema\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function resolveRef<T>(\n schema: unknown,\n $ref: string,\n options: ResolveRefOptions,\n): T | undefined {\n return resolveDocumentRef<T>(schema, $ref, options);\n}\n\n/**\n * Walk through any JSON-serializable (i.e. non-circular) object\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function walk(\n obj: unknown,\n cb: (value: Record<string, unknown>, path: (string | number)[]) => void,\n path: (string | number)[] = [],\n): void {\n walkDocument(obj, cb, path);\n}\n\n/**\n * Print warning message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function warn(msg: string, silent = false) {\n defaultLogger(silent).warn(msg);\n}\n"],"names":["terminalSupportsColor","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,MAChB,CAAC,GAAG,CAAC,CAAA,KAAM,EAAE,CAAA,IAAK,OAAO,CAAA,KAAM,QAAA,IAAY,YAAA,IAAgB,CAAA,IAAK,CAAA,CAAE,UAAA;AAAA,KACpE;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAQO,SAAS,UAAA,CACd,MAAA,EACA,IAAA,EACA,OAAA,EACe;AACf,EAAA,OAAOC,+BAAA,CAAsB,MAAA,EAAQ,IAAA,EAAM,OAAO,CAAA;AACpD;AAMO,SAAS,IAAA,CACd,GAAA,EACA,EAAA,EACA,IAAA,GAA4B,EAAC,EACvB;AACN,EAAAC,yBAAA,CAAa,GAAA,EAAK,IAAI,IAAI,CAAA;AAC5B;AAMO,SAAS,IAAA,CAAK,GAAA,EAAa,MAAA,GAAS,KAAA,EAAO;AAChD,EAAAH,0BAAA,CAAc,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAChC;;;;;;;;;;;"}
@@ -5,7 +5,7 @@ import { createRef as createRef$1 } from '../domain/openapi/json-pointer.mjs';
5
5
  import { terminalSupportsColor, defaultLogger } from './default-ports.mjs';
6
6
  import { resolveDocumentRef, walkDocument } from './document-refs.mjs';
7
7
 
8
- if (!terminalSupportsColor()) {
8
+ if (!terminalSupportsColor("stdout")) {
9
9
  colors.enabled = false;
10
10
  }
11
11
  const c = colors;
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-utils.mjs","sources":["../../src/api/legacy-utils.ts"],"sourcesContent":["import colors from \"ansi-colors\";\nimport { formatDuration } from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DebugGroup } from \"../application/ports/logger.js\";\nimport { discriminatorProperty } from \"../application/transform/schema/discriminator-property.js\";\nimport type { IrPropertySignature } from \"../domain/ir/nodes.js\";\nimport { createRef as createDomainRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject } from \"../types.js\";\nimport { defaultLogger, terminalSupportsColor } from \"./default-ports.js\";\nimport { type ResolveRefOptions, resolveDocumentRef, walkDocument } from \"./document-refs.js\";\n\n/**\n * The original's exported utilities, kept for 1.x (ADR-004, decision 9). The generator itself\n * logs through the Logger port; `debug`, `warn` and `error` here write through the default one.\n */\n\n// The exported `c` is the shared ansi-colors instance, switched off at import when the terminal has\n// no colors, as the original did. The generator's own logger uses a separate instance.\nif (!terminalSupportsColor()) {\n colors.enabled = false;\n}\n\n/**\n * The shared ansi-colors instance.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9). Use a color library directly.\n */\nexport const c = colors;\n\n/**\n * The discriminator property of a schema at `path`, typed as its discriminator value. Returns IR\n * (task 6.2), like the exported transformers.\n */\nexport function createDiscriminatorProperty(\n discriminator: DiscriminatorObject,\n { path, readonly = false }: { path: string; readonly?: boolean },\n): IrPropertySignature {\n return discriminatorProperty(discriminator, path, readonly);\n}\n\n/**\n * Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`\n * and contributes its decoded segments, so it throws URIError for a malformed percent escape; any\n * other part is one segment. To append raw document keys, escape each one instead.\n */\nexport function createRef(parts: (number | string | undefined | null)[]): string {\n return createDomainRef(parts);\n}\n\n/**\n * Print debug message (cribbed from the `debug` package, but without all the bells & whistles\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function debug(msg: string, group?: string, time?: number) {\n // Any group name was accepted; one the logger does not know prints in white, as before.\n defaultLogger(false).debug(msg, group as DebugGroup | undefined, time);\n}\n\n/**\n * Print error message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function error(msg: string) {\n defaultLogger(false).error(msg);\n}\n\n/** Format a performance log in a friendly format */\nexport function formatTime(t: number) {\n return typeof t === \"number\" ? formatDuration(t) : t;\n}\n\n/** Call Object.entries() and optionally sort */\nexport function getEntries<T>(\n obj: ArrayLike<T> | Record<string, T>,\n options?: {\n alphabetize?: boolean;\n excludeDeprecated?: boolean;\n },\n) {\n let entries = Object.entries(obj);\n if (options?.alphabetize) {\n entries.sort(([a], [b]) => a.localeCompare(b, \"en-us\", { numeric: true }));\n }\n if (options?.excludeDeprecated) {\n entries = entries.filter(\n ([, v]) => !(v && typeof v === \"object\" && \"deprecated\" in v && v.deprecated),\n );\n }\n return entries;\n}\n\nexport type { ResolveRefOptions } from \"./document-refs.js\";\n\n/**\n * resolve a $ref in a schema\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function resolveRef<T>(\n schema: unknown,\n $ref: string,\n options: ResolveRefOptions,\n): T | undefined {\n return resolveDocumentRef<T>(schema, $ref, options);\n}\n\n/**\n * Walk through any JSON-serializable (i.e. non-circular) object\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function walk(\n obj: unknown,\n cb: (value: Record<string, unknown>, path: (string | number)[]) => void,\n path: (string | number)[] = [],\n): void {\n walkDocument(obj, cb, path);\n}\n\n/**\n * Print warning message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function warn(msg: string, silent = false) {\n defaultLogger(silent).warn(msg);\n}\n"],"names":["createDomainRef"],"mappings":";;;;;;;AAiBA,IAAI,CAAC,uBAAsB,EAAG;AAC5B,EAAA,MAAA,CAAO,OAAA,GAAU,KAAA;AACnB;AAMO,MAAM,CAAA,GAAI;AAMV,SAAS,4BACd,aAAA,EACA,EAAE,IAAA,EAAM,QAAA,GAAW,OAAM,EACJ;AACrB,EAAA,OAAO,qBAAA,CAAsB,aAAA,EAAe,IAAA,EAAM,QAAQ,CAAA;AAC5D;AAOO,SAAS,UAAU,KAAA,EAAuD;AAC/E,EAAA,OAAOA,YAAgB,KAAK,CAAA;AAC9B;AAMO,SAAS,KAAA,CAAM,GAAA,EAAa,KAAA,EAAgB,IAAA,EAAe;AAEhE,EAAA,aAAA,CAAc,KAAK,CAAA,CAAE,KAAA,CAAM,GAAA,EAAK,OAAiC,IAAI,CAAA;AACvE;AAMO,SAAS,MAAM,GAAA,EAAa;AACjC,EAAA,aAAA,CAAc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ansi-colors\";\nimport { formatDuration } from \"../adapters/terminal-logger/terminal-logger.js\";\nimport type { DebugGroup } from \"../application/ports/logger.js\";\nimport { discriminatorProperty } from \"../application/transform/schema/discriminator-property.js\";\nimport type { IrPropertySignature } from \"../domain/ir/nodes.js\";\nimport { createRef as createDomainRef } from \"../domain/openapi/json-pointer.js\";\nimport type { DiscriminatorObject } from \"../types.js\";\nimport { defaultLogger, terminalSupportsColor } from \"./default-ports.js\";\nimport { type ResolveRefOptions, resolveDocumentRef, walkDocument } from \"./document-refs.js\";\n\n/**\n * The original's exported utilities, kept for 1.x (ADR-004, decision 9). The generator itself\n * logs through the Logger port; `debug`, `warn` and `error` here write through the default one.\n */\n\n// The exported `c` is the shared ansi-colors instance, switched off at import when the terminal has\n// no colors, as the original did. The generator's own logger uses a separate instance.\nif (!terminalSupportsColor(\"stdout\")) {\n colors.enabled = false;\n}\n\n/**\n * The shared ansi-colors instance.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9). Use a color library directly.\n */\nexport const c = colors;\n\n/**\n * The discriminator property of a schema at `path`, typed as its discriminator value. Returns IR\n * (task 6.2), like the exported transformers.\n */\nexport function createDiscriminatorProperty(\n discriminator: DiscriminatorObject,\n { path, readonly = false }: { path: string; readonly?: boolean },\n): IrPropertySignature {\n return discriminatorProperty(discriminator, path, readonly);\n}\n\n/**\n * Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`\n * and contributes its decoded segments, so it throws URIError for a malformed percent escape; any\n * other part is one segment. To append raw document keys, escape each one instead.\n */\nexport function createRef(parts: (number | string | undefined | null)[]): string {\n return createDomainRef(parts);\n}\n\n/**\n * Print debug message (cribbed from the `debug` package, but without all the bells & whistles\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function debug(msg: string, group?: string, time?: number) {\n // Any group name was accepted; one the logger does not know prints in white, as before.\n defaultLogger(false).debug(msg, group as DebugGroup | undefined, time);\n}\n\n/**\n * Print error message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function error(msg: string) {\n defaultLogger(false).error(msg);\n}\n\n/** Format a performance log in a friendly format */\nexport function formatTime(t: number) {\n return typeof t === \"number\" ? formatDuration(t) : t;\n}\n\n/** Call Object.entries() and optionally sort */\nexport function getEntries<T>(\n obj: ArrayLike<T> | Record<string, T>,\n options?: {\n alphabetize?: boolean;\n excludeDeprecated?: boolean;\n },\n) {\n let entries = Object.entries(obj);\n if (options?.alphabetize) {\n entries.sort(([a], [b]) => a.localeCompare(b, \"en-us\", { numeric: true }));\n }\n if (options?.excludeDeprecated) {\n entries = entries.filter(\n ([, v]) => !(v && typeof v === \"object\" && \"deprecated\" in v && v.deprecated),\n );\n }\n return entries;\n}\n\nexport type { ResolveRefOptions } from \"./document-refs.js\";\n\n/**\n * resolve a $ref in a schema\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function resolveRef<T>(\n schema: unknown,\n $ref: string,\n options: ResolveRefOptions,\n): T | undefined {\n return resolveDocumentRef<T>(schema, $ref, options);\n}\n\n/**\n * Walk through any JSON-serializable (i.e. non-circular) object\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function walk(\n obj: unknown,\n cb: (value: Record<string, unknown>, path: (string | number)[]) => void,\n path: (string | number)[] = [],\n): void {\n walkDocument(obj, cb, path);\n}\n\n/**\n * Print warning message\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function warn(msg: string, silent = false) {\n defaultLogger(silent).warn(msg);\n}\n"],"names":["createDomainRef"],"mappings":";;;;;;;AAiBA,IAAI,CAAC,qBAAA,CAAsB,QAAQ,CAAA,EAAG;AACpC,EAAA,MAAA,CAAO,OAAA,GAAU,KAAA;AACnB;AAMO,MAAM,CAAA,GAAI;AAMV,SAAS,4BACd,aAAA,EACA,EAAE,IAAA,EAAM,QAAA,GAAW,OAAM,EACJ;AACrB,EAAA,OAAO,qBAAA,CAAs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S,IAAA,CACd,GAAA,EACA,EAAA,EACA,IAAA,GAA4B,EAAC,EACvB;AACN,EAAA,YAAA,CAAa,GAAA,EAAK,IAAI,IAAI,CAAA;AAC5B;AAMO,SAAS,IAAA,CAAK,GAAA,EAAa,MAAA,GAAS,KAAA,EAAO;AAChD,EAAA,aAAA,CAAc,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAChC;;"}
@@ -22,8 +22,7 @@ async function generateDocument(source, options, ports) {
22
22
  async function generateDeclarations(source, options, ports) {
23
23
  return (await generateDocument(source, options, ports)).declarations;
24
24
  }
25
- async function defaultGeneratorPorts(options) {
26
- const logger = defaultPorts.defaultLogger(options.silent ?? false);
25
+ async function defaultGeneratorPorts(options, logger = defaultPorts.defaultLogger(options.silent ?? false)) {
27
26
  const redoc = options.redocly ?? await defaultPorts.defaultRedoclyConfig();
28
27
  const loader = redoclySchemaLoader.createRedoclySchemaLoader({
29
28
  redoc,
@@ -1 +1 @@
1
- {"version":3,"file":"openapi-ts.cjs","sources":["../../src/api/openapi-ts.ts"],"sourcesContent":["import { createRedoclySchemaLoader } from \"../adapters/redocly-loader/redocly-schema-loader.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { GeneratorOptions, SchemaSource } from \"../types.js\";\nimport {\n DEFAULT_REMOTE_DOCUMENT_LIMITS,\n defaultDeprecationReporter,\n defaultLogger,\n defaultRedoclyConfig,\n monotonicNow,\n REMOTE_REF_TIMEOUT_MS,\n} from \"./default-ports.js\";\nimport { createDocumentRun, type GeneratorPorts } from \"./document-run.js\";\nimport transformSchema from \"./transform-schema.js\";\n\n/**\n * The Node API's composition root (ENGINEERING_PLAN 4.5): `openapiTS` wires the default adapters;\n * `generateDeclarations` runs with any ports, which is how the CLI calls it.\n */\n\n/** The declarations of one document, and the local files it was read from. */\nexport interface GeneratedDocument {\n readonly declarations: IrDeclaration[];\n readonly localFiles: readonly URL[];\n}\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDocument(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<GeneratedDocument> {\n const { schema, localFiles, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const declarations = withStackOverflowReported(\"transform\", () => transformSchema(schema, ctx));\n ports.logger.debug(\n \"Completed AST transformation for entire document\",\n \"ts\",\n ports.now() - startedAt,\n );\n return { declarations, localFiles };\n}\n\n/** As `generateDocument`, the declarations only. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n return (await generateDocument(source, options, ports)).declarations;\n}\n\n/**\n * The default ports: the terminal logger, Node.js deprecation warnings, the given or default\n * Redocly config, Redocly loading.\n */\nexport async function defaultGeneratorPorts(options: GeneratorOptions): Promise<GeneratorPorts> {\n const logger = defaultLogger(options.silent ?? false);\n const redoc = options.redocly ?? (await defaultRedoclyConfig());\n const loader = createRedoclySchemaLoader({\n redoc,\n logger,\n now: monotonicNow,\n remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,\n remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,\n });\n return { loader, logger, deprecations: defaultDeprecationReporter(), redoc, now: monotonicNow };\n}\n\n/**\n * Convert an OpenAPI schema to TypeScript declarations (IR nodes; print them with `astToString`)\n * @param {string|URL|object|Readable} source OpenAPI schema source:\n * - YAML: string\n * - JSON: parsed object\n * - URL: URL to a YAML or JSON file (local or remote)\n * - Readable: Readable stream of YAML or JSON\n */\nexport default async function openapiTS(\n source: SchemaSource,\n options: GeneratorOptions = {},\n): Promise<IrDeclaration[]> {\n return generateDeclarations(source, options, await defaultGeneratorPorts(options));\n}\n"],"names":["createDocumentRun","withStackOverflowReported","transformSchema","defaultLogger","defaultRedoclyConfig","createRedoclySchemaLoader","monotonicNow","REMOTE_REF_TIMEOUT_MS","DEFAULT_REMOTE_DOCUM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AAA,EACA,OAAA,GAA4B,EAAC,EACH;AAC1B,EAAA,OAAO,qBAAqB,MAAA,EAAQ,OAAA,EAAS,MAAM,qBAAA,CAAsB,OAAO,CAAC,CAAA;AACnF;;;;;"}
1
+ {"version":3,"file":"openapi-ts.cjs","sources":["../../src/api/openapi-ts.ts"],"sourcesContent":["import { createRedoclySchemaLoader } from \"../adapters/redocly-loader/redocly-schema-loader.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { GeneratorOptions, OpenAPITSOptions, SchemaSource } from \"../types.js\";\nimport {\n DEFAULT_REMOTE_DOCUMENT_LIMITS,\n defaultDeprecationReporter,\n defaultLogger,\n defaultRedoclyConfig,\n monotonicNow,\n REMOTE_REF_TIMEOUT_MS,\n} from \"./default-ports.js\";\nimport { createDocumentRun, type GeneratorPorts } from \"./document-run.js\";\nimport transformSchema from \"./transform-schema.js\";\n\n/**\n * The Node API's composition root (ENGINEERING_PLAN 4.5): `openapiTS` wires the default adapters;\n * `generateDeclarations` runs with any ports, which is how the CLI calls it.\n */\n\n/** The declarations of one document, and the local files it was read from. */\nexport interface GeneratedDocument {\n readonly declarations: IrDeclaration[];\n readonly localFiles: readonly URL[];\n}\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDocument(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<GeneratedDocument> {\n const { schema, localFiles, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const declarations = withStackOverflowReported(\"transform\", () => transformSchema(schema, ctx));\n ports.logger.debug(\n \"Completed AST transformation for entire document\",\n \"ts\",\n ports.now() - startedAt,\n );\n return { declarations, localFiles };\n}\n\n/** As `generateDocument`, the declarations only. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n return (await generateDocument(source, options, ports)).declarations;\n}\n\n/**\n * The default ports: the terminal logger, Node.js deprecation warnings, the given or default\n * Redocly config, Redocly loading. A given `logger` takes every line, the loader's included.\n */\nexport async function defaultGeneratorPorts(\n options: GeneratorOptions,\n logger: Logger = defaultLogger(options.silent ?? false),\n): Promise<GeneratorPorts> {\n const redoc = options.redocly ?? (await defaultRedoclyConfig());\n const loader = createRedoclySchemaLoader({\n redoc,\n logger,\n now: monotonicNow,\n remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,\n remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,\n });\n return { loader, logger, deprecations: defaultDeprecationReporter(), redoc, now: monotonicNow };\n}\n\n/**\n * Convert an OpenAPI schema to TypeScript declarations (IR nodes; print them with `astToString`)\n * @param {string|URL|object|Readable} source OpenAPI schema source:\n * - YAML: string\n * - JSON: parsed object\n * - URL: URL to a YAML or JSON file (local or remote)\n * - Readable: Readable stream of YAML or JSON\n */\nexport default function openapiTS(\n source: SchemaSource,\n options?: OpenAPITSOptions,\n): Promise<IrDeclaration[]>;\n// The options without `irCallbacks` get their own signature: TypeScript does not pick a member of\n// `GeneratorOptions | undefined` (an optional parameter) by a key that the object leaves out, so\n// inline callbacks had implicit `any` parameters (TS7006). `irCallbacks: true` picks the member\n// here. This signature is last, so `Parameters<typeof openapiTS>` reads it.\n/** Convert an OpenAPI schema to IR declarations, with either form of the options. */\nexport default function openapiTS(\n source: SchemaSource,\n options?: GeneratorOptions,\n): Promise<IrDeclaration[]>;\nexport default async function openapiTS(\n source: SchemaSource,\n options: GeneratorOptions = {},\n): Promise<IrDeclaration[]> {\n return generateDeclarations(source, options, await defaultGeneratorPorts(options));\n}\n"],"names":["createDocumentRun","withStackOverflowReported","transformSchema","defaultLogger","defaultRedoclyConfig","createRedoclySchemaLoader","monotonicNow","REMOTE_REF_TIMEOUT_MS","DEFAULT_REMOTE_DOCUMENT_LIMITS","defaultDeprecationReporter"],"mappings":";;;;;;;;;;AA4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,EAAQ,OAAA,EAAS,MAAM,qBAAA,CAAsB,OAAO,CAAC,CAAA;AACnF;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { createRedoclySchemaLoader } from '../adapters/redocly-loader/redocly-schema-loader.mjs';
2
2
  import { withStackOverflowReported } from '../application/stack-overflow.mjs';
3
- import { defaultLogger, defaultRedoclyConfig, monotonicNow, defaultDeprecationReporter, DEFAULT_REMOTE_DOCUMENT_LIMITS, REMOTE_REF_TIMEOUT_MS } from './default-ports.mjs';
3
+ import { defaultRedoclyConfig, monotonicNow, defaultDeprecationReporter, defaultLogger, DEFAULT_REMOTE_DOCUMENT_LIMITS, REMOTE_REF_TIMEOUT_MS } from './default-ports.mjs';
4
4
  import { createDocumentRun } from './document-run.mjs';
5
5
  import transformSchema from './transform-schema.mjs';
6
6
 
@@ -18,8 +18,7 @@ async function generateDocument(source, options, ports) {
18
18
  async function generateDeclarations(source, options, ports) {
19
19
  return (await generateDocument(source, options, ports)).declarations;
20
20
  }
21
- async function defaultGeneratorPorts(options) {
22
- const logger = defaultLogger(options.silent ?? false);
21
+ async function defaultGeneratorPorts(options, logger = defaultLogger(options.silent ?? false)) {
23
22
  const redoc = options.redocly ?? await defaultRedoclyConfig();
24
23
  const loader = createRedoclySchemaLoader({
25
24
  redoc,
@@ -1 +1 @@
1
- {"version":3,"file":"openapi-ts.mjs","sources":["../../src/api/openapi-ts.ts"],"sourcesContent":["import { createRedoclySchemaLoader } from \"../adapters/redocly-loader/redocly-schema-loader.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { GeneratorOptions, SchemaSource } from \"../types.js\";\nimport {\n DEFAULT_REMOTE_DOCUMENT_LIMITS,\n defaultDeprecationReporter,\n defaultLogger,\n defaultRedoclyConfig,\n monotonicNow,\n REMOTE_REF_TIMEOUT_MS,\n} from \"./default-ports.js\";\nimport { createDocumentRun, type GeneratorPorts } from \"./document-run.js\";\nimport transformSchema from \"./transform-schema.js\";\n\n/**\n * The Node API's composition root (ENGINEERING_PLAN 4.5): `openapiTS` wires the default adapters;\n * `generateDeclarations` runs with any ports, which is how the CLI calls it.\n */\n\n/** The declarations of one document, and the local files it was read from. */\nexport interface GeneratedDocument {\n readonly declarations: IrDeclaration[];\n readonly localFiles: readonly URL[];\n}\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDocument(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<GeneratedDocument> {\n const { schema, localFiles, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const declarations = withStackOverflowReported(\"transform\", () => transformSchema(schema, ctx));\n ports.logger.debug(\n \"Completed AST transformation for entire document\",\n \"ts\",\n ports.now() - startedAt,\n );\n return { declarations, localFiles };\n}\n\n/** As `generateDocument`, the declarations only. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n return (await generateDocument(source, options, ports)).declarations;\n}\n\n/**\n * The default ports: the terminal logger, Node.js deprecation warnings, the given or default\n * Redocly config, Redocly loading.\n */\nexport async function defaultGeneratorPorts(options: GeneratorOptions): Promise<GeneratorPorts> {\n const logger = defaultLogger(options.silent ?? false);\n const redoc = options.redocly ?? (await defaultRedoclyConfig());\n const loader = createRedoclySchemaLoader({\n redoc,\n logger,\n now: monotonicNow,\n remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,\n remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,\n });\n return { loader, logger, deprecations: defaultDeprecationReporter(), redoc, now: monotonicNow };\n}\n\n/**\n * Convert an OpenAPI schema to TypeScript declarations (IR nodes; print them with `astToString`)\n * @param {string|URL|object|Readable} source OpenAPI schema source:\n * - YAML: string\n * - JSON: parsed object\n * - URL: URL to a YAML or JSON file (local or remote)\n * - Readable: Readable stream of YAML or JSON\n */\nexport default async function openapiTS(\n source: SchemaSource,\n options: GeneratorOptions = {},\n): Promise<IrDeclaration[]> {\n return generateDeclarations(source, options, await defaultGeneratorPorts(options));\n}\n"],"names":[],"mappings":";;;;;;AA2BA,eAAsB,gBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC4B;AAC5B,EAAA,MAAM,EAAE,QAAQ,UAAA,EAAY,GAAA,KAAQ,MAAM,iBAAA,CAAkB,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA;AAClF,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,eAAe,yBAAA,CAA0B,WAAA,EAAa,MAAM,eAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC9F,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,EAAE,cAAc,UAAA,EAAW;AACpC;AAGA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,OAAA,CAAQ,MAAM,gBAAA,CAAiB,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA,EAAG,YAAA;AAC1D;AAMA,eAAsB,sBAAsB,OAAA,EAAoD;AAC9F,EAAA,MAAM,MAAA,GAAS,aAAA,CAAc,OAAA,CAAQ,MAAA,IAAU,KAAK,CAAA;AACpD,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,OAAA,IAAY,MAAM,oBAAA,EAAqB;AAC7D,EAAA,MAAM,SAAS,yBAAA,CAA0B;AAAA,IACvC,KAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAA,EAAK,YAAA;AAAA,IACL,kBAAA,EAAoB,qBAAA;AAAA,IACpB,oBAAA,EAAsB;AAAA,GACvB,CAAA;AACD,EAAA,OAAO,EAAE,QAAQ,MAAA,EAAQ,YAAA,EAAc,4BAA2B,EAAG,KAAA,EAAO,KAAK,YAAA,EAAa;AAChG;AAUA,eAA8B,SAAA,CAC5B,MAAA,EACA,OAAA,GAA4B,EAAC,EACH;AAC1B,EAAA,OAAO,qBAAqB,MAAA,EAAQ,OAAA,EAAS,MAAM,qBAAA,CAAsB,OAAO,CAAC,CAAA;AACnF;;"}
1
+ {"version":3,"file":"openapi-ts.mjs","sources":["../../src/api/openapi-ts.ts"],"sourcesContent":["import { createRedoclySchemaLoader } from \"../adapters/redocly-loader/redocly-schema-loader.js\";\nimport type { Logger } from \"../application/ports/logger.js\";\nimport { withStackOverflowReported } from \"../application/stack-overflow.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { GeneratorOptions, OpenAPITSOptions, SchemaSource } from \"../types.js\";\nimport {\n DEFAULT_REMOTE_DOCUMENT_LIMITS,\n defaultDeprecationReporter,\n defaultLogger,\n defaultRedoclyConfig,\n monotonicNow,\n REMOTE_REF_TIMEOUT_MS,\n} from \"./default-ports.js\";\nimport { createDocumentRun, type GeneratorPorts } from \"./document-run.js\";\nimport transformSchema from \"./transform-schema.js\";\n\n/**\n * The Node API's composition root (ENGINEERING_PLAN 4.5): `openapiTS` wires the default adapters;\n * `generateDeclarations` runs with any ports, which is how the CLI calls it.\n */\n\n/** The declarations of one document, and the local files it was read from. */\nexport interface GeneratedDocument {\n readonly declarations: IrDeclaration[];\n readonly localFiles: readonly URL[];\n}\n\n/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDocument(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<GeneratedDocument> {\n const { schema, localFiles, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const declarations = withStackOverflowReported(\"transform\", () => transformSchema(schema, ctx));\n ports.logger.debug(\n \"Completed AST transformation for entire document\",\n \"ts\",\n ports.now() - startedAt,\n );\n return { declarations, localFiles };\n}\n\n/** As `generateDocument`, the declarations only. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n return (await generateDocument(source, options, ports)).declarations;\n}\n\n/**\n * The default ports: the terminal logger, Node.js deprecation warnings, the given or default\n * Redocly config, Redocly loading. A given `logger` takes every line, the loader's included.\n */\nexport async function defaultGeneratorPorts(\n options: GeneratorOptions,\n logger: Logger = defaultLogger(options.silent ?? false),\n): Promise<GeneratorPorts> {\n const redoc = options.redocly ?? (await defaultRedoclyConfig());\n const loader = createRedoclySchemaLoader({\n redoc,\n logger,\n now: monotonicNow,\n remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,\n remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,\n });\n return { loader, logger, deprecations: defaultDeprecationReporter(), redoc, now: monotonicNow };\n}\n\n/**\n * Convert an OpenAPI schema to TypeScript declarations (IR nodes; print them with `astToString`)\n * @param {string|URL|object|Readable} source OpenAPI schema source:\n * - YAML: string\n * - JSON: parsed object\n * - URL: URL to a YAML or JSON file (local or remote)\n * - Readable: Readable stream of YAML or JSON\n */\nexport default function openapiTS(\n source: SchemaSource,\n options?: OpenAPITSOptions,\n): Promise<IrDeclaration[]>;\n// The options without `irCallbacks` get their own signature: TypeScript does not pick a member of\n// `GeneratorOptions | undefined` (an optional parameter) by a key that the object leaves out, so\n// inline callbacks had implicit `any` parameters (TS7006). `irCallbacks: true` picks the member\n// here. This signature is last, so `Parameters<typeof openapiTS>` reads it.\n/** Convert an OpenAPI schema to IR declarations, with either form of the options. */\nexport default function openapiTS(\n source: SchemaSource,\n options?: GeneratorOptions,\n): Promise<IrDeclaration[]>;\nexport default async function openapiTS(\n source: SchemaSource,\n options: GeneratorOptions = {},\n): Promise<IrDeclaration[]> {\n return generateDeclarations(source, options, await defaultGeneratorPorts(options));\n}\n"],"names":[],"mappings":";;;;;;AA4BA,eAAsB,gBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC4B;AAC5B,EAAA,MAAM,EAAE,QAAQ,UAAA,EAAY,GAAA,KA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js');
4
+
5
+ function kindOf(value) {
6
+ if (value instanceof URL) {
7
+ return `a ${value.protocol} URL`;
8
+ }
9
+ if (Array.isArray(value)) {
10
+ return "a list";
11
+ }
12
+ return value === null ? "null" : `a ${typeof value}`;
13
+ }
14
+ function optionInvalid(option, expected, got) {
15
+ return new errors.OpenAPITypesafeError({
16
+ code: errors.ERROR_CODES.OPTION_INVALID,
17
+ message: `The ${option} option must be ${expected}; got ${got}.`,
18
+ details: { option }
19
+ });
20
+ }
21
+
22
+ exports.kindOf = kindOf;
23
+ exports.optionInvalid = optionInvalid;
24
+ //# sourceMappingURL=option-errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-errors.cjs","sources":["../../src/api/option-errors.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../domain/errors.js\";\n\n/** The `OPTION_INVALID` errors of the Node API's options, checked before anything loads. */\n\n/** What a value is, for the error; a URL is named by its protocol only, as it may hold secrets. */\nexport function kindOf(value: unknown): string {\n if (value instanceof URL) {\n return `a ${value.protocol} URL`;\n }\n if (Array.isArray(value)) {\n return \"a list\";\n }\n return value === null ? \"null\" : `a ${typeof value}`;\n}\n\nexport function optionInvalid(option: string, expected: string, got: string): OpenAPITypesafeError {\n return new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_INVALID,\n message: `The ${option} option must be ${expected}; got ${got}.`,\n details: { option },\n });\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES"],"mappings":";;;;AAKO,SAAS,OAAO,KAAA,EAAwB;AAC7C,EAAA,IAAI,iBAAiB,GAAA,EAAK;AACxB,IAAA,OAAO,CAAA,EAAA,EAAK,MAAM,QAAQ,CAAA,IAAA,CAAA;AAAA,EAC5B;AACA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA,KAAU,IAAA,GAAO,MAAA,GAAS,CAAA,EAAA,EAAK,OAAO,KAAK,CAAA,CAAA;AACpD;AAEO,SAAS,aAAA,CAAc,MAAA,EAAgB,QAAA,EAAkB,GAAA,EAAmC;AACjG,EAAA,OAAO,IAAIA,2BAAA,CAAqB;AAAA,IAC9B,MAAMC,kBAAA,CAAY,cAAA;AAAA,IAClB,SAAS,CAAA,IAAA,EAAO,MAAM,CAAA,gBAAA,EAAmB,QAAQ,SAAS,GAAG,CAAA,CAAA,CAAA;AAAA,IAC7D,OAAA,EAAS,EAAE,MAAA;AAAO,GACnB,CAAA;AACH;;;"}
@@ -0,0 +1,21 @@
1
+ import { OpenAPITypesafeError, ERROR_CODES } from '../domain/errors.mjs';
2
+
3
+ function kindOf(value) {
4
+ if (value instanceof URL) {
5
+ return `a ${value.protocol} URL`;
6
+ }
7
+ if (Array.isArray(value)) {
8
+ return "a list";
9
+ }
10
+ return value === null ? "null" : `a ${typeof value}`;
11
+ }
12
+ function optionInvalid(option, expected, got) {
13
+ return new OpenAPITypesafeError({
14
+ code: ERROR_CODES.OPTION_INVALID,
15
+ message: `The ${option} option must be ${expected}; got ${got}.`,
16
+ details: { option }
17
+ });
18
+ }
19
+
20
+ export { kindOf, optionInvalid };
21
+ //# sourceMappingURL=option-errors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-errors.mjs","sources":["../../src/api/option-errors.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"../domain/errors.js\";\n\n/** The `OPTION_INVALID` errors of the Node API's options, checked before anything loads. */\n\n/** What a value is, for the error; a URL is named by its protocol only, as it may hold secrets. */\nexport function kindOf(value: unknown): string {\n if (value instanceof URL) {\n return `a ${value.protocol} URL`;\n }\n if (Array.isArray(value)) {\n return \"a list\";\n }\n return value === null ? \"null\" : `a ${typeof value}`;\n}\n\nexport function optionInvalid(option: string, expected: string, got: string): OpenAPITypesafeError {\n return new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_INVALID,\n message: `The ${option} option must be ${expected}; got ${got}.`,\n details: { option },\n });\n}\n"],"names":[],"mappings":";;AAKO,SAAS,OAAO,KAAA,EAAwB;AAC7C,EAAA,IAAI,iBAAiB,GAAA,EAAK;AACxB,IAAA,OAAO,CAAA,EAAA,EAAK,MAAM,QAAQ,CAAA,IAAA,CAAA;AAAA,EAC5B;AACA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA,KAAU,IAAA,GAAO,MAAA,GAAS,CAAA,EAAA,EAAK,OAAO,KAAK,CAAA,CAAA;AACpD;AAEO,SAAS,aAAA,CAAc,MAAA,EAAgB,QAAA,EAAkB,GAAA,EAAmC;AACjG,EAAA,OAAO,IAAI,oBAAA,CAAqB;AAAA,IAC9B,MAAM,WAAA,CAAY,cAAA;AAAA,IAClB,SAAS,CAAA,IAAA,EAAO,MAAM,CAAA,gBAAA,EAAmB,QAAQ,SAAS,GAAG,CAAA,CAAA,CAAA;AAAA,IAC7D,OAAA,EAAS,EAAE,MAAA;AAAO,GACnB,CAAA;AACH;;"}
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ const path = require('node:path');
4
+ const node_url = require('node:url');
5
+ const locationText = require('../domain/location-text.cjs');
6
+ const optionErrors = require('./option-errors.cjs');
7
+
8
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
9
+
10
+ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
11
+
12
+ const FILE_PROTOCOL = "file:";
13
+ const LOCAL_ROOT_EXPECTED = "a directory path or a file: URL";
14
+ const RELATIVE_ROOT_EXPECTED = "an absolute path or a file: URL when cwd is no file: URL";
15
+ function localRootUrlOf(value, cwd) {
16
+ if (locationText.hasUrlScheme(value)) {
17
+ return URL.parse(value, cwd.href) ?? void 0;
18
+ }
19
+ if (path__default.isAbsolute(value)) {
20
+ return node_url.pathToFileURL(value);
21
+ }
22
+ if (cwd.protocol !== FILE_PROTOCOL) {
23
+ throw optionErrors.optionInvalid(
24
+ "localRefRoot",
25
+ RELATIVE_ROOT_EXPECTED,
26
+ `a relative path, and cwd is ${optionErrors.kindOf(cwd)}`
27
+ );
28
+ }
29
+ return node_url.pathToFileURL(path__default.resolve(node_url.fileURLToPath(cwd), value));
30
+ }
31
+ function localRootOf(value, cwd) {
32
+ const root = typeof value === "string" ? localRootUrlOf(value, cwd) : value;
33
+ if (root instanceof URL && root.protocol === FILE_PROTOCOL) {
34
+ return root;
35
+ }
36
+ const got = root === void 0 ? "a string that is no valid URL" : optionErrors.kindOf(root);
37
+ throw optionErrors.optionInvalid("localRefRoot", LOCAL_ROOT_EXPECTED, got);
38
+ }
39
+ function remoteHostsOf(value) {
40
+ if (!Array.isArray(value)) {
41
+ throw optionErrors.optionInvalid("remoteRefHosts", "a list of hosts", optionErrors.kindOf(value));
42
+ }
43
+ const other = value.find((entry) => typeof entry !== "string");
44
+ if (other !== void 0) {
45
+ throw optionErrors.optionInvalid("remoteRefHosts", "a list of hosts", `a list with ${optionErrors.kindOf(other)}`);
46
+ }
47
+ return value;
48
+ }
49
+ function refAccessOf(options, cwd) {
50
+ const { localRefRoot, remoteRefHosts } = options;
51
+ return {
52
+ ...localRefRoot === void 0 ? {} : { localRoot: localRootOf(localRefRoot, cwd) },
53
+ ...remoteRefHosts === void 0 ? {} : { remoteHosts: remoteHostsOf(remoteRefHosts) }
54
+ };
55
+ }
56
+
57
+ exports.refAccessOf = refAccessOf;
58
+ //# sourceMappingURL=ref-limit-options.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-limit-options.cjs","sources":["../../src/api/ref-limit-options.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { RefAccess } from \"../application/ports/schema-loader.js\";\nimport { hasUrlScheme } from \"../domain/location-text.js\";\nimport type { GeneratorOptions } from \"../types.js\";\nimport { kindOf, optionInvalid } from \"./option-errors.js\";\n\n/**\n * The `$ref` limits of the options (threat model R1, R2, ADR-017), checked before anything loads.\n * A value of another type from JavaScript (`remoteRefHosts: \"a.com\"`, `localRefRoot: new\n * URL(\"https://…\")`) used to fail later as an error of the document.\n */\n\nconst FILE_PROTOCOL = \"file:\";\n\nconst LOCAL_ROOT_EXPECTED = \"a directory path or a file: URL\";\nconst RELATIVE_ROOT_EXPECTED = \"an absolute path or a file: URL when cwd is no file: URL\";\n\n/**\n * A string as the CLI reads `--local-ref-root`: a URL when it has a scheme (`file:///specs/`),\n * else a path that resolves against the cwd. Undefined when it does not parse as a URL. A\n * relative path needs a local cwd: with an `http:` cwd it names no local directory.\n */\nfunction localRootUrlOf(value: string, cwd: URL): URL | undefined {\n if (hasUrlScheme(value)) {\n return URL.parse(value, cwd.href) ?? undefined;\n }\n if (path.isAbsolute(value)) {\n return pathToFileURL(value);\n }\n if (cwd.protocol !== FILE_PROTOCOL) {\n throw optionInvalid(\n \"localRefRoot\",\n RELATIVE_ROOT_EXPECTED,\n `a relative path, and cwd is ${kindOf(cwd)}`,\n );\n }\n return pathToFileURL(path.resolve(fileURLToPath(cwd), value));\n}\n\n/** The local root as a `file:` URL; the option is set, so it is not undefined. */\nfunction localRootOf(value: unknown, cwd: URL): URL {\n const root = typeof value === \"string\" ? localRootUrlOf(value, cwd) : value;\n if (root instanceof URL && root.protocol === FILE_PROTOCOL) {\n return root;\n }\n const got = root === undefined ? \"a string that is no valid URL\" : kindOf(root);\n throw optionInvalid(\"localRefRoot\", LOCAL_ROOT_EXPECTED, got);\n}\n\nfunction remoteHostsOf(value: unknown): readonly string[] {\n if (!Array.isArray(value)) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", kindOf(value));\n }\n const other = value.find((entry) => typeof entry !== \"string\");\n if (other !== undefined) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", `a list with ${kindOf(other)}`);\n }\n return value;\n}\n\n/** The limits of the options; fails with `OPTION_INVALID` for a value of another type. */\nexport function refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {\n const { localRefRoot, remoteRefHosts } = options;\n return {\n ...(localRefRoot === undefined ? {} : { localRoot: localRootOf(localRefRoot, cwd) }),\n ...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteHostsOf(remoteRefHosts) }),\n };\n}\n"],"names":["hasUrlScheme","path","pathToFileURL","optionInvalid","kindOf","fileURLToPath"],"mappings":";;;;;;;;;;;AAaA,MAAM,aAAA,GAAgB,OAAA;AAEtB,MAAM,mBAAA,GAAsB,iCAAA;AAC5B,MAAM,sBAAA,GAAyB,0DAAA;AAO/B,SAAS,cAAA,CAAe,OAAe,GAAA,EAA2B;AAChE,EAAA,IAAIA,yBAAA,CAAa,KAAK,CAAA,EAAG;AACvB,IAAA,OAAO,GAAA,CAAI,KAAA,CAAM,KAAA,EAAO,GAAA,CAAI,IAAI,CAAA,IAAK,MAAA;AAAA,EACvC;AACA,EAAA,IAAIC,aAAA,CAAK,UAAA,CAAW,KAAK,CAAA,EAAG;AAC1B,IAAA,OAAOC,uBAAc,KAAK,CAAA;AAAA,EAC5B;AACA,EAAA,IAAI,GAAA,CAAI,aAAa,aAAA,EAAe;AAClC,IAAA,MAAMC,0BAAA;AAAA,MACJ,cAAA;AAAA,MACA,sBAAA;AAAA,MACA,CAAA,4BAAA,EAA+BC,mBAAA,CAAO,GAAG,CAAC,CAAA;AAAA,KAC5C;AAAA,EACF;AACA,EAAA,OAAOF,uBAAcD,aAAA,CAAK,OAAA,CAAQI,uBAAc,GAAG,CAAA,EAAG,KAAK,CAAC,CAAA;AAC9D;AAGA,SAAS,WAAA,CAAY,OAAgB,GAAA,EAAe;AAClD,EAAA,MAAM,OAAO,OAAO,KAAA,KAAU,WAAW,cAAA,CAAe,KAAA,EAAO,GAAG,CAAA,GAAI,KAAA;AACtE,EAAA,IAAI,IAAA,YAAgB,GAAA,IAAO,IAAA,CAAK,QAAA,KAAa,aAAA,EAAe;AAC1D,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,GAAA,GAAM,IAAA,KAAS,MAAA,GAAY,+BAAA,GAAkCD,oBAAO,IAAI,CAAA;AAC9E,EAAA,MAAMD,0BAAA,CAAc,cAAA,EAAgB,mBAAA,EAAqB,GAAG,CAAA;AAC9D;AAEA,SAAS,cAAc,KAAA,EAAmC;AACxD,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACzB,IAAA,MAAMA,0BAAA,CAAc,gBAAA,EAAkB,iBAAA,EAAmBC,mBAAA,CAAO,KAAK,CAAC,CAAA;AAAA,EACxE;AACA,EAAA,MAAM,QAAQ,KAAA,CAAM,IAAA,CAAK,CAAC,KAAA,KAAU,OAAO,UAAU,QAAQ,CAAA;AAC7D,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,MAAMD,2BAAc,gBAAA,EAAkB,iBAAA,EAAmB,eAAeC,mBAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EACzF;AACA,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,WAAA,CAAY,SAA2B,GAAA,EAAqB;AAC1E,EAAA,MAAM,EAAE,YAAA,EAAc,cAAA,EAAe,GAAI,OAAA;AACzC,EAAA,OAAO;AAAA,IACL,GAAI,YAAA,KAAiB,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAW,WAAA,CAAY,YAAA,EAAc,GAAG,CAAA,EAAE;AAAA,IAClF,GAAI,mBAAmB,MAAA,GAAY,KAAK,EAAE,WAAA,EAAa,aAAA,CAAc,cAAc,CAAA;AAAE,GACvF;AACF;;"}
@@ -0,0 +1,52 @@
1
+ import path from 'node:path';
2
+ import { pathToFileURL, fileURLToPath } from 'node:url';
3
+ import { hasUrlScheme } from '../domain/location-text.mjs';
4
+ import { optionInvalid, kindOf } from './option-errors.mjs';
5
+
6
+ const FILE_PROTOCOL = "file:";
7
+ const LOCAL_ROOT_EXPECTED = "a directory path or a file: URL";
8
+ const RELATIVE_ROOT_EXPECTED = "an absolute path or a file: URL when cwd is no file: URL";
9
+ function localRootUrlOf(value, cwd) {
10
+ if (hasUrlScheme(value)) {
11
+ return URL.parse(value, cwd.href) ?? void 0;
12
+ }
13
+ if (path.isAbsolute(value)) {
14
+ return pathToFileURL(value);
15
+ }
16
+ if (cwd.protocol !== FILE_PROTOCOL) {
17
+ throw optionInvalid(
18
+ "localRefRoot",
19
+ RELATIVE_ROOT_EXPECTED,
20
+ `a relative path, and cwd is ${kindOf(cwd)}`
21
+ );
22
+ }
23
+ return pathToFileURL(path.resolve(fileURLToPath(cwd), value));
24
+ }
25
+ function localRootOf(value, cwd) {
26
+ const root = typeof value === "string" ? localRootUrlOf(value, cwd) : value;
27
+ if (root instanceof URL && root.protocol === FILE_PROTOCOL) {
28
+ return root;
29
+ }
30
+ const got = root === void 0 ? "a string that is no valid URL" : kindOf(root);
31
+ throw optionInvalid("localRefRoot", LOCAL_ROOT_EXPECTED, got);
32
+ }
33
+ function remoteHostsOf(value) {
34
+ if (!Array.isArray(value)) {
35
+ throw optionInvalid("remoteRefHosts", "a list of hosts", kindOf(value));
36
+ }
37
+ const other = value.find((entry) => typeof entry !== "string");
38
+ if (other !== void 0) {
39
+ throw optionInvalid("remoteRefHosts", "a list of hosts", `a list with ${kindOf(other)}`);
40
+ }
41
+ return value;
42
+ }
43
+ function refAccessOf(options, cwd) {
44
+ const { localRefRoot, remoteRefHosts } = options;
45
+ return {
46
+ ...localRefRoot === void 0 ? {} : { localRoot: localRootOf(localRefRoot, cwd) },
47
+ ...remoteRefHosts === void 0 ? {} : { remoteHosts: remoteHostsOf(remoteRefHosts) }
48
+ };
49
+ }
50
+
51
+ export { refAccessOf };
52
+ //# sourceMappingURL=ref-limit-options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-limit-options.mjs","sources":["../../src/api/ref-limit-options.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { RefAccess } from \"../application/ports/schema-loader.js\";\nimport { hasUrlScheme } from \"../domain/location-text.js\";\nimport type { GeneratorOptions } from \"../types.js\";\nimport { kindOf, optionInvalid } from \"./option-errors.js\";\n\n/**\n * The `$ref` limits of the options (threat model R1, R2, ADR-017), checked before anything loads.\n * A value of another type from JavaScript (`remoteRefHosts: \"a.com\"`, `localRefRoot: new\n * URL(\"https://…\")`) used to fail later as an error of the document.\n */\n\nconst FILE_PROTOCOL = \"file:\";\n\nconst LOCAL_ROOT_EXPECTED = \"a directory path or a file: URL\";\nconst RELATIVE_ROOT_EXPECTED = \"an absolute path or a file: URL when cwd is no file: URL\";\n\n/**\n * A string as the CLI reads `--local-ref-root`: a URL when it has a scheme (`file:///specs/`),\n * else a path that resolves against the cwd. Undefined when it does not parse as a URL. A\n * relative path needs a local cwd: with an `http:` cwd it names no local directory.\n */\nfunction localRootUrlOf(value: string, cwd: URL): URL | undefined {\n if (hasUrlScheme(value)) {\n return URL.parse(value, cwd.href) ?? undefined;\n }\n if (path.isAbsolute(value)) {\n return pathToFileURL(value);\n }\n if (cwd.protocol !== FILE_PROTOCOL) {\n throw optionInvalid(\n \"localRefRoot\",\n RELATIVE_ROOT_EXPECTED,\n `a relative path, and cwd is ${kindOf(cwd)}`,\n );\n }\n return pathToFileURL(path.resolve(fileURLToPath(cwd), value));\n}\n\n/** The local root as a `file:` URL; the option is set, so it is not undefined. */\nfunction localRootOf(value: unknown, cwd: URL): URL {\n const root = typeof value === \"string\" ? localRootUrlOf(value, cwd) : value;\n if (root instanceof URL && root.protocol === FILE_PROTOCOL) {\n return root;\n }\n const got = root === undefined ? \"a string that is no valid URL\" : kindOf(root);\n throw optionInvalid(\"localRefRoot\", LOCAL_ROOT_EXPECTED, got);\n}\n\nfunction remoteHostsOf(value: unknown): readonly string[] {\n if (!Array.isArray(value)) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", kindOf(value));\n }\n const other = value.find((entry) => typeof entry !== \"string\");\n if (other !== undefined) {\n throw optionInvalid(\"remoteRefHosts\", \"a list of hosts\", `a list with ${kindOf(other)}`);\n }\n return value;\n}\n\n/** The limits of the options; fails with `OPTION_INVALID` for a value of another type. */\nexport function refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {\n const { localRefRoot, remoteRefHosts } = options;\n return {\n ...(localRefRoot === undefined ? {} : { localRoot: localRootOf(localRefRoot, cwd) }),\n ...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteHostsOf(remoteRefHosts) }),\n };\n}\n"],"names":[],"mappings":";;;;;AAaA,MAAM,aAAA,GAAgB,OAAA;AAEtB,MAAM,mBAAA,GAAsB,iCAAA;AAC5B,MAAM,sBAAA,GAAyB,0DAAA;AAO/B,SAAS,cAAA,CAAe,OAAe,GAAA,EAA2B;AAChE,EAAA,IAAI,YAAA,CAAa,KAAK,CAAA,EAAG;AACvB,IAAA,OAAO,GAAA,CAAI,KAAA,CAAM,KAAA,EAAO,GAAA,CAAI,IAAI,CAAA,IAAK,MAAA;AAAA,EACvC;AACA,EAAA,IAAI,IAAA,CAAK,UAAA,CAAW,KAAK,CAAA,EAAG;AAC1B,IAAA,OAAO,cAAc,KAAK,CAAA;AAAA,EAC5B;AACA,EAAA,IAAI,GAAA,CAAI,aAAa,aAAA,EAAe;AAClC,IAAA,MAAM,aAAA;AAAA,MACJ,cAAA;AAAA,MACA,sBAAA;AAAA,MACA,CAAA,4BAAA,EAA+B,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,KAC5C;AAAA,EACF;AACA,EAAA,OAAO,cAAc,IAAA,CAAK,OAAA,CAAQ,cAAc,GAAG,CAAA,EAAG,KAAK,CAAC,CAAA;AAC9D;AAGA,SAAS,WAAA,CAAY,OAAgB,GAAA,EAAe;AAClD,EAAA,MAAM,OAAO,OAAO,KAAA,KAAU,WAAW,cAAA,CAAe,KAAA,EAAO,GAAG,CAAA,GAAI,KAAA;AACtE,EAAA,IAAI,IAAA,YAAgB,GAAA,IAAO,IAAA,CAAK,QAAA,KAAa,aAAA,EAAe;AAC1D,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,GAAA,GAAM,IAAA,KAAS,MAAA,GAAY,+BAAA,GAAkC,OAAO,IAAI,CAAA;AAC9E,EAAA,MAAM,aAAA,CAAc,cAAA,EAAgB,mBAAA,EAAqB,GAAG,CAAA;AAC9D;AAEA,SAAS,cAAc,KAAA,EAAmC;AACxD,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACzB,IAAA,MAAM,aAAA,CAAc,gBAAA,EAAkB,iBAAA,EAAmB,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,EACxE;AACA,EAAA,MAAM,QAAQ,KAAA,CAAM,IAAA,CAAK,CAAC,KAAA,KAAU,OAAO,UAAU,QAAQ,CAAA;AAC7D,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,MAAM,cAAc,gBAAA,EAAkB,iBAAA,EAAmB,eAAe,MAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EACzF;AACA,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,WAAA,CAAY,SAA2B,GAAA,EAAqB;AAC1E,EAAA,MAAM,EAAE,YAAA,EAAc,cAAA,EAAe,GAAI,OAAA;AACzC,EAAA,OAAO;AAAA,IACL,GAAI,YAAA,KAAiB,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAW,WAAA,CAAY,YAAA,EAAc,GAAG,CAAA,EAAE;AAAA,IAClF,GAAI,mBAAmB,MAAA,GAAY,KAAK,EAAE,WAAA,EAAa,aAAA,CAAc,cAAc,CAAA;AAAE,GACvF;AACF;;"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const document = require('../application/transform/document/document.cjs');
6
6
  const enumNamesGivenBack = require('../application/transform/document/enum-names-given-back.cjs');
7
7
  const operationKeysWritten = require('../application/transform/document/operation-keys-written.cjs');
8
+ const pathTemplateRefs = require('../application/transform/document/path-template-refs.cjs');
8
9
  const rootTypeAliases = require('../application/transform/document/root-type-aliases.cjs');
9
10
  const documentFooter = require('../application/transform/footer/document-footer.cjs');
10
11
  const enumNameClaims = require('../application/transform/footer/enum-name-claims.cjs');
@@ -81,6 +82,15 @@ function enumValuesChecked(body, footer, ctx) {
81
82
  }
82
83
  return checked.footer;
83
84
  }
85
+ function withTemplateRefs({ body, footer, closing }, keys) {
86
+ return {
87
+ body: pathTemplateRefs.withTemplatePathRefs(body, keys),
88
+ footer: footer.map(
89
+ (entry) => footerEntry.isIrDeclaration(entry) ? pathTemplateRefs.withTemplatePathRefs([entry], keys)[0] ?? entry : entry
90
+ ),
91
+ closing: pathTemplateRefs.withTemplatePathRefs(closing, keys)
92
+ };
93
+ }
84
94
  function transformDocument(schema, ctx) {
85
95
  const document$1 = schema;
86
96
  ctx.schemaDialect = schemaDialect.schemaDialectOf(document$1.openapi);
@@ -95,11 +105,8 @@ function transformDocument(schema, ctx) {
95
105
  const rawClosing = document.documentClosing(document$1, context, rawFooter.some(isOperations));
96
106
  const parts = { body: rawBody, footer: rawFooter, closing: rawClosing };
97
107
  const { body, footer, closing } = withEnumNamesGivenBack(parts, names);
98
- return {
99
- body: rootTypeAliases.renameTakenAliases(body, footer.filter(footerEntry.isIrDeclaration), closing),
100
- footer,
101
- closing
102
- };
108
+ const named = { body: rootTypeAliases.renameTakenAliases(body, footer.filter(footerEntry.isIrDeclaration), closing), footer };
109
+ return withTemplateRefs({ ...named, closing }, pathTemplateRefs.unmatchedTemplateKeys(document$1.paths, context));
103
110
  }
104
111
  function transformSchema(schema, ctx) {
105
112
  return documentDeclarations.documentDeclarations(transformDocument(schema, ctx));
@@ -1 +1 @@
1
- {"version":3,"file":"transform-schema.cjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport {\n NAMES_THE_OUTPUT_MAY_NEED,\n namesTheOutputNeeds,\n withEnumsRenamed,\n} from \"../application/transform/document/enum-names-given-back.js\";\nimport { operationKeysWritten } from \"../application/transform/document/operation-keys-written.js\";\nimport { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter, type RunFooterNames } from \"../application/transform/footer/document-footer.js\";\nimport { EnumNameClaims } from \"../application/transform/footer/enum-name-claims.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport { OperationKeys } from \"../application/transform/footer/operation-keys.js\";\nimport {\n FIRST_SCHEMA_NAMES,\n SharedEnumNameRecorder,\n type SharedEnumNames,\n} from \"../application/transform/footer/shared-enum-names.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport { schemaDialectOf } from \"../domain/openapi/schema-dialect.js\";\nimport { FIX } from \"../domain/output-fixes.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { FirstSchemaNameRecorder } from \"./discriminator-enum-names.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { excludedValuesWarning } from \"./enum-values-warnings.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { createTransformContext } from \"./transform-context.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/** Whether a footer entry is named `operations` (any declaration kind, as in the original). */\nfunction isOperations(entry: FooterEntry): boolean {\n const name = isIrDeclaration(entry)\n ? (entry as { name?: string }).name\n : (entry as Partial<ts.InterfaceDeclaration>).name?.escapedText;\n return name === OPERATIONS_NAME;\n}\n\n/** Drops a message: the first pass must not repeat the run's warnings or debug lines. */\nconst dropMessage = (): void => undefined;\nconst DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };\n\n/** A shared enum name recorder of a first pass, and the names it gives the second. */\ninterface EnumNameRecorder extends SharedEnumNames {\n chosenNames(): SharedEnumNames;\n}\n\n/**\n * The names of shared enums, known only at the end: a first pass transforms the document into a\n * scratch footer that `recorder` watches; its output is dropped. User callbacks run in both\n * passes. The `dedupe-enum-names` fix (ADR-021, upstream #1683) names an enum by all of its\n * schemas; `discriminator-values` keeps the first declaring schema's name\n * (`FirstSchemaNameRecorder`).\n */\nfunction sharedEnumNamesOf(\n document: DocumentObject,\n ctx: RunContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: RunContext = {\n ...ctx,\n injectFooter,\n runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),\n logger: DROPPED_MESSAGES,\n legacyCallbackWarnings: new Set(),\n };\n const scratchContext = createTransformContext(scratch);\n documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));\n return recorder.chosenNames();\n}\n\n/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */\nfunction enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {\n if (ctx.fix?.includes(FIX.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(FIX.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/**\n * The run's footer: with a naming fix, `--enum` and `--dedupe-enums` it names shared enums. A\n * footer that a call before created on the context is kept.\n */\nfunction withRunFooter(document: DocumentObject, ctx: RunContext, names: RunFooterNames): void {\n if (ctx.runFooter !== undefined) {\n return;\n }\n const recorder = enumNameRecorderOf(ctx);\n const shared =\n recorder === null || !ctx.enum || !ctx.dedupeEnums\n ? null\n : sharedEnumNamesOf(document, ctx, recorder);\n const sink = new ContextFooterSink(ctx.injectFooter);\n ctx.runFooter =\n shared === null\n ? new RunFooter(sink, ctx.dedupeEnums, FIRST_SCHEMA_NAMES, names)\n : new RunFooter(sink, true, shared, names);\n}\n\n/**\n * The document with the enums renamed that gave way to a name the output turned out not to need\n * (`EnumNameClaims`): they get that name back, as before.\n */\nfunction withEnumNamesGivenBack(\n parts: TransformedDocument,\n names: RunFooterNames,\n): TransformedDocument {\n const footer = parts.footer.filter(isIrDeclaration);\n const renames = names.enums.givenBack(namesTheOutputNeeds({ ...parts, footer }));\n if (renames.size === 0) {\n return parts;\n }\n return {\n body: withEnumsRenamed(parts.body, renames),\n footer: parts.footer.map((entry) =>\n isIrDeclaration(entry) ? (withEnumsRenamed([entry], renames)[0] ?? entry) : entry,\n ),\n closing: withEnumsRenamed(parts.closing, renames),\n };\n}\n\n/**\n * With `--enum-values`, arrays whose location type does not hold their values are typed by their\n * values (ADR-027); a location that excludes listed values is a contradiction of the document.\n */\nfunction enumValuesChecked(\n body: readonly IrDeclaration[],\n footer: FooterEntry[],\n ctx: RunContext,\n): FooterEntry[] {\n if (!ctx.enumValues) {\n return footer;\n }\n const checked = checkedEnumValues(footer, body, isIrDeclaration);\n for (const retype of checked.retyped) {\n if (retype.kind === \"excluded\") {\n ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));\n }\n }\n return checked.footer;\n}\n\n/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */\nexport function transformDocument(schema: OpenAPI3, ctx: RunContext): TransformedDocument {\n const document = schema as DocumentObject;\n ctx.schemaDialect = schemaDialectOf(document.openapi);\n const names: RunFooterNames = {\n enums: new EnumNameClaims(NAMES_THE_OUTPUT_MAY_NEED),\n operations: new OperationKeys(operationKeysWritten(document)),\n };\n withRunFooter(document, ctx, names);\n const context = createTransformContext(ctx);\n // documentBody registers the enums in the footer, so the footer is read after it.\n const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));\n const rawFooter = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const rawClosing = documentClosing(document, context, rawFooter.some(isOperations));\n const parts = { body: rawBody, footer: rawFooter, closing: rawClosing };\n const { body, footer, closing } = withEnumNamesGivenBack(parts, names);\n return {\n body: renameTakenAliases(body, footer.filter(isIrDeclaration), closing),\n footer,\n closing,\n };\n}\n\n/**\n * The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same\n * for a loaded document.\n */\nexport default function transformSchema(schema: OpenAPI3, ctx: GlobalContext): IrDeclaration[] {\n return documentDeclarations(transformDocument(schema, ctx));\n}\n"],"names":["isIrDeclaration","document","RunFooter","ContextFooterSink","createTransformContext","documentBody","FIX","SharedEnumNameRecorder","FirstSchemaNameRecorder","FIRST_SCHEMA_NAMES","namesTheOutputNeeds","withEnumsRenamed","checkedEnumValues","excludedValuesWarning","schemaDialectOf","EnumNameClaims","NAMES_THE_OUTPUT_MAY_NEED","OperationKeys","operationKeysWritten","documentClosing","renameTakenAliases","documentDeclarations"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,aAAa,KAAA,EAA6B;AACjD,EAAA,MAAM,OAAOA,2BAAA,CAAgB,KAAK,IAC7B,KAAA,CAA4B,IAAA,GAC5B,MAA2C,IAAA,EAAM,WAAA;AACtD,EAAA,OAAO,IAAA,KAAS,eAAA;AAClB;AAGA,MAAM,cAAc,MAAY,MAAA;AAChC,MAAM,mBAAmB,EAAE,KAAA,EAAO,aAAa,IAAA,EAAM,WAAA,EAAa,OAAO,WAAA,EAAY;AAcrF,SAAS,iBAAA,CACPC,UAAA,EACA,GAAA,EACA,QAAA,EACiB;AACjB,EAAA,MAAM,eAA8B,EAAC;AACrC,EAAA,MAAM,OAAA,GAAsB;AAAA,IAC1B,GAAG,GAAA;AAAA,IACH,YAAA;AAAA,IACA,SAAA,EAAW,IAAIC,wBAAA,CAAU,IAAIC,6BAAkB,YAAY,CAAA,EAAG,MAAM,QAAQ,CAAA;AAAA,IAC5E,MAAA,EAAQ,gBAAA;AAAA,IACR,sBAAA,sBAA4B,GAAA;AAAI,GAClC;AACA,EAAA,MAAM,cAAA,GAAiBC,wCAAuB,OAAO,CAAA;AACrD,EAAAC,qBAAA,CAAaJ,YAAU,cAAA,EAAgB,MAAM,YAAA,CAAa,MAAA,CAAOD,2BAAe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ACnD,UAAA,EAAY,IAAIC,2BAAA,CAAcC,yCAAA,CAAqBjB,UAAQ,CAAC;AAAA,GAC9D;AACA,EAAA,aAAA,CAAcA,UAAA,EAAU,KAAK,KAAK,CAAA;AAClC,EAAA,MAAM,OAAA,GAAUG,wCAAuB,GAAG,CAAA;AAE1C,EAAA,MAAM,OAAA,GAAUC,sBAAaJ,UAAA,EAAU,OAAA,EAAS,MAAM,GAAA,CAAI,YAAA,CAAa,MAAA,CAAOD,2BAAe,CAAC,CAAA;AAC9F,EAAA,MAAM,SAAA,GAAY,kBAAkB,OAAA,EAAS,CAAC,GAAG,GAAA,CAAI,YAAY,GAAG,GAAG,CAAA;AACvE,EAAA,MAAM,aAAamB,wBAAA,CAAgBlB,UAAA,EAAU,SAAS,SAAA,CAAU,IAAA,CAAK,YAAY,CAAC,CAAA;AAClF,EAAA,MAAM,QAAQ,EAAE,IAAA,EAAM,SAAS,MAAA,EAAQ,SAAA,EAAW,SAAS,UAAA,EAAW;AACtE,EAAA,MAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAQ,GAAI,sBAAA,CAAuB,OAAO,KAAK,CAAA;AACrE,EAAA,OAAO;AAAA,IACL,MAAMmB,kCAAA,CAAmB,IAAA,EAAM,OAAO,MAAA,CAAOpB,2BAAe,GAAG,OAAO,CAAA;AAAA,IACtE,MAAA;AAAA,IACA;AAAA,GACF;AACF;AAMA,SAAwB,eAAA,CAAgB,QAAkB,GAAA,EAAqC;AAC7F,EAAA,OAAOqB,yCAAA,CAAqB,iBAAA,CAAkB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC5D;;;"}
1
+ {"version":3,"file":"transform-schema.cjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport {\n NAMES_THE_OUTPUT_MAY_NEED,\n namesTheOutputNeeds,\n withEnumsRenamed,\n} from \"../application/transform/document/enum-names-given-back.js\";\nimport { operationKeysWritten } from \"../application/transform/document/operation-keys-written.js\";\nimport {\n unmatchedTemplateKeys,\n withTemplatePathRefs,\n} from \"../application/transform/document/path-template-refs.js\";\nimport { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter, type RunFooterNames } from \"../application/transform/footer/document-footer.js\";\nimport { EnumNameClaims } from \"../application/transform/footer/enum-name-claims.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport { OperationKeys } from \"../application/transform/footer/operation-keys.js\";\nimport {\n FIRST_SCHEMA_NAMES,\n SharedEnumNameRecorder,\n type SharedEnumNames,\n} from \"../application/transform/footer/shared-enum-names.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport { schemaDialectOf } from \"../domain/openapi/schema-dialect.js\";\nimport { FIX } from \"../domain/output-fixes.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { FirstSchemaNameRecorder } from \"./discriminator-enum-names.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { excludedValuesWarning } from \"./enum-values-warnings.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { createTransformContext } from \"./transform-context.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/** Whether a footer entry is named `operations` (any declaration kind, as in the original). */\nfunction isOperations(entry: FooterEntry): boolean {\n const name = isIrDeclaration(entry)\n ? (entry as { name?: string }).name\n : (entry as Partial<ts.InterfaceDeclaration>).name?.escapedText;\n return name === OPERATIONS_NAME;\n}\n\n/** Drops a message: the first pass must not repeat the run's warnings or debug lines. */\nconst dropMessage = (): void => undefined;\nconst DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };\n\n/** A shared enum name recorder of a first pass, and the names it gives the second. */\ninterface EnumNameRecorder extends SharedEnumNames {\n chosenNames(): SharedEnumNames;\n}\n\n/**\n * The names of shared enums, known only at the end: a first pass transforms the document into a\n * scratch footer that `recorder` watches; its output is dropped. User callbacks run in both\n * passes. The `dedupe-enum-names` fix (ADR-021, upstream #1683) names an enum by all of its\n * schemas; `discriminator-values` keeps the first declaring schema's name\n * (`FirstSchemaNameRecorder`).\n */\nfunction sharedEnumNamesOf(\n document: DocumentObject,\n ctx: RunContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: RunContext = {\n ...ctx,\n injectFooter,\n runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),\n logger: DROPPED_MESSAGES,\n legacyCallbackWarnings: new Set(),\n };\n const scratchContext = createTransformContext(scratch);\n documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));\n return recorder.chosenNames();\n}\n\n/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */\nfunction enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {\n if (ctx.fix?.includes(FIX.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(FIX.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/**\n * The run's footer: with a naming fix, `--enum` and `--dedupe-enums` it names shared enums. A\n * footer that a call before created on the context is kept.\n */\nfunction withRunFooter(document: DocumentObject, ctx: RunContext, names: RunFooterNames): void {\n if (ctx.runFooter !== undefined) {\n return;\n }\n const recorder = enumNameRecorderOf(ctx);\n const shared =\n recorder === null || !ctx.enum || !ctx.dedupeEnums\n ? null\n : sharedEnumNamesOf(document, ctx, recorder);\n const sink = new ContextFooterSink(ctx.injectFooter);\n ctx.runFooter =\n shared === null\n ? new RunFooter(sink, ctx.dedupeEnums, FIRST_SCHEMA_NAMES, names)\n : new RunFooter(sink, true, shared, names);\n}\n\n/**\n * The document with the enums renamed that gave way to a name the output turned out not to need\n * (`EnumNameClaims`): they get that name back, as before.\n */\nfunction withEnumNamesGivenBack(\n parts: TransformedDocument,\n names: RunFooterNames,\n): TransformedDocument {\n const footer = parts.footer.filter(isIrDeclaration);\n const renames = names.enums.givenBack(namesTheOutputNeeds({ ...parts, footer }));\n if (renames.size === 0) {\n return parts;\n }\n return {\n body: withEnumsRenamed(parts.body, renames),\n footer: parts.footer.map((entry) =>\n isIrDeclaration(entry) ? (withEnumsRenamed([entry], renames)[0] ?? entry) : entry,\n ),\n closing: withEnumsRenamed(parts.closing, renames),\n };\n}\n\n/**\n * With `--enum-values`, arrays whose location type does not hold their values are typed by their\n * values (ADR-027); a location that excludes listed values is a contradiction of the document.\n */\nfunction enumValuesChecked(\n body: readonly IrDeclaration[],\n footer: FooterEntry[],\n ctx: RunContext,\n): FooterEntry[] {\n if (!ctx.enumValues) {\n return footer;\n }\n const checked = checkedEnumValues(footer, body, isIrDeclaration);\n for (const retype of checked.retyped) {\n if (retype.kind === \"excluded\") {\n ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));\n }\n }\n return checked.footer;\n}\n\n/** The document with its references into templated paths indexed by their templates. */\nfunction withTemplateRefs(\n { body, footer, closing }: TransformedDocument,\n keys: ReadonlyMap<string, string>,\n): TransformedDocument {\n return {\n body: withTemplatePathRefs(body, keys),\n footer: footer.map((entry) =>\n isIrDeclaration(entry) ? (withTemplatePathRefs([entry], keys)[0] ?? entry) : entry,\n ),\n closing: withTemplatePathRefs(closing, keys),\n };\n}\n\n/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */\nexport function transformDocument(schema: OpenAPI3, ctx: RunContext): TransformedDocument {\n const document = schema as DocumentObject;\n ctx.schemaDialect = schemaDialectOf(document.openapi);\n const names: RunFooterNames = {\n enums: new EnumNameClaims(NAMES_THE_OUTPUT_MAY_NEED),\n operations: new OperationKeys(operationKeysWritten(document)),\n };\n withRunFooter(document, ctx, names);\n const context = createTransformContext(ctx);\n // documentBody registers the enums in the footer, so the footer is read after it.\n const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));\n const rawFooter = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const rawClosing = documentClosing(document, context, rawFooter.some(isOperations));\n const parts = { body: rawBody, footer: rawFooter, closing: rawClosing };\n const { body, footer, closing } = withEnumNamesGivenBack(parts, names);\n const named = { body: renameTakenAliases(body, footer.filter(isIrDeclaration), closing), footer };\n return withTemplateRefs({ ...named, closing }, unmatchedTemplateKeys(document.paths, context));\n}\n\n/**\n * The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same\n * for a loaded document.\n */\nexport default function transformSchema(schema: OpenAPI3, ctx: GlobalContext): IrDeclaration[] {\n return documentDeclarations(transformDocument(schema, ctx));\n}\n"],"names":["isIrDeclaration","document","RunFooter","ContextFooterSink","createTransformContext","documentBody","FIX","SharedEnumNameRecorder","FirstSchemaNameRecorder","FIRST_SCHEMA_NAMES","namesTheOutputNeeds","withEnumsRenamed","checkedEnumValues","excludedValuesWarning","withTemplatePathRefs","schemaDialectOf","EnumNameClaims","NAMES_THE_OUTPUT_MAY_NEED","OperationKeys","operationKeysWritten","documentClosing","renameTakenAliases","unmatchedTemplateKeys","documentDeclarations"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,aAAa,KAAA,EAA6B;AACjD,EAAA,MAAM,OAAOA,2BAAA,CAAgB,KAAK,IAC7B,KAAA,CAA4B,IAAA,GAC5B,MAA2C,IAAA,EAAM,WAAA;AACtD,EAAA,OAAO,IAAA,KAAS,eAAA;AAClB;AAGA,MAAM,cAAc,MAAY,MAAA;AAChC,MAAM,mBAAmB,EAAE,KAAA,EAAO,aAAa,IAAA,EAAM,WAAA,EAAa,OAAO,WAAA,EAAY;AAcrF,SAAS,iBAAA,CACPC,UAAA,EACA,GAAA,EACA,QAAA,EACiB;AACjB,EAAA,MAAM,eAA8B,EAAC;AACrC,EAAA,MAAM,OA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AAA,CAAgBnB,UAAA,EAAU,SAAS,SAAA,CAAU,IAAA,CAAK,YAAY,CAAC,CAAA;AAClF,EAAA,MAAM,QAAQ,EAAE,IAAA,EAAM,SAAS,MAAA,EAAQ,SAAA,EAAW,SAAS,UAAA,EAAW;AACtE,EAAA,MAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAQ,GAAI,sBAAA,CAAuB,OAAO,KAAK,CAAA;AACrE,EAAA,MAAM,KAAA,GAAQ,EAAE,IAAA,EAAMoB,kCAAA,CAAmB,IAAA,EAAM,MAAA,CAAO,MAAA,CAAOrB,2BAAe,CAAA,EAAG,OAAO,CAAA,EAAG,MAAA,EAAO;AAChG,EAAA,OAAO,gBAAA,CAAiB,EAAE,GAAG,KAAA,EAAO,OAAA,IAAWsB,sCAAA,CAAsBrB,UAAA,CAAS,KAAA,EAAO,OAAO,CAAC,CAAA;AAC/F;AAMA,SAAwB,eAAA,CAAgB,QAAkB,GAAA,EAAqC;AAC7F,EAAA,OAAOsB,yCAAA,CAAqB,iBAAA,CAAkB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC5D;;;"}
@@ -1,6 +1,7 @@
1
1
  import { documentBody, documentClosing } from '../application/transform/document/document.mjs';
2
2
  import { NAMES_THE_OUTPUT_MAY_NEED, namesTheOutputNeeds, withEnumsRenamed } from '../application/transform/document/enum-names-given-back.mjs';
3
3
  import { operationKeysWritten } from '../application/transform/document/operation-keys-written.mjs';
4
+ import { unmatchedTemplateKeys, withTemplatePathRefs } from '../application/transform/document/path-template-refs.mjs';
4
5
  import { renameTakenAliases } from '../application/transform/document/root-type-aliases.mjs';
5
6
  import { RunFooter } from '../application/transform/footer/document-footer.mjs';
6
7
  import { EnumNameClaims } from '../application/transform/footer/enum-name-claims.mjs';
@@ -77,6 +78,15 @@ function enumValuesChecked(body, footer, ctx) {
77
78
  }
78
79
  return checked.footer;
79
80
  }
81
+ function withTemplateRefs({ body, footer, closing }, keys) {
82
+ return {
83
+ body: withTemplatePathRefs(body, keys),
84
+ footer: footer.map(
85
+ (entry) => isIrDeclaration(entry) ? withTemplatePathRefs([entry], keys)[0] ?? entry : entry
86
+ ),
87
+ closing: withTemplatePathRefs(closing, keys)
88
+ };
89
+ }
80
90
  function transformDocument(schema, ctx) {
81
91
  const document = schema;
82
92
  ctx.schemaDialect = schemaDialectOf(document.openapi);
@@ -91,11 +101,8 @@ function transformDocument(schema, ctx) {
91
101
  const rawClosing = documentClosing(document, context, rawFooter.some(isOperations));
92
102
  const parts = { body: rawBody, footer: rawFooter, closing: rawClosing };
93
103
  const { body, footer, closing } = withEnumNamesGivenBack(parts, names);
94
- return {
95
- body: renameTakenAliases(body, footer.filter(isIrDeclaration), closing),
96
- footer,
97
- closing
98
- };
104
+ const named = { body: renameTakenAliases(body, footer.filter(isIrDeclaration), closing), footer };
105
+ return withTemplateRefs({ ...named, closing }, unmatchedTemplateKeys(document.paths, context));
99
106
  }
100
107
  function transformSchema(schema, ctx) {
101
108
  return documentDeclarations(transformDocument(schema, ctx));
@@ -1 +1 @@
1
- {"version":3,"file":"transform-schema.mjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport {\n NAMES_THE_OUTPUT_MAY_NEED,\n namesTheOutputNeeds,\n withEnumsRenamed,\n} from \"../application/transform/document/enum-names-given-back.js\";\nimport { operationKeysWritten } from \"../application/transform/document/operation-keys-written.js\";\nimport { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter, type RunFooterNames } from \"../application/transform/footer/document-footer.js\";\nimport { EnumNameClaims } from \"../application/transform/footer/enum-name-claims.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport { OperationKeys } from \"../application/transform/footer/operation-keys.js\";\nimport {\n FIRST_SCHEMA_NAMES,\n SharedEnumNameRecorder,\n type SharedEnumNames,\n} from \"../application/transform/footer/shared-enum-names.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport { schemaDialectOf } from \"../domain/openapi/schema-dialect.js\";\nimport { FIX } from \"../domain/output-fixes.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { FirstSchemaNameRecorder } from \"./discriminator-enum-names.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { excludedValuesWarning } from \"./enum-values-warnings.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { createTransformContext } from \"./transform-context.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/** Whether a footer entry is named `operations` (any declaration kind, as in the original). */\nfunction isOperations(entry: FooterEntry): boolean {\n const name = isIrDeclaration(entry)\n ? (entry as { name?: string }).name\n : (entry as Partial<ts.InterfaceDeclaration>).name?.escapedText;\n return name === OPERATIONS_NAME;\n}\n\n/** Drops a message: the first pass must not repeat the run's warnings or debug lines. */\nconst dropMessage = (): void => undefined;\nconst DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };\n\n/** A shared enum name recorder of a first pass, and the names it gives the second. */\ninterface EnumNameRecorder extends SharedEnumNames {\n chosenNames(): SharedEnumNames;\n}\n\n/**\n * The names of shared enums, known only at the end: a first pass transforms the document into a\n * scratch footer that `recorder` watches; its output is dropped. User callbacks run in both\n * passes. The `dedupe-enum-names` fix (ADR-021, upstream #1683) names an enum by all of its\n * schemas; `discriminator-values` keeps the first declaring schema's name\n * (`FirstSchemaNameRecorder`).\n */\nfunction sharedEnumNamesOf(\n document: DocumentObject,\n ctx: RunContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: RunContext = {\n ...ctx,\n injectFooter,\n runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),\n logger: DROPPED_MESSAGES,\n legacyCallbackWarnings: new Set(),\n };\n const scratchContext = createTransformContext(scratch);\n documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));\n return recorder.chosenNames();\n}\n\n/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */\nfunction enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {\n if (ctx.fix?.includes(FIX.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(FIX.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/**\n * The run's footer: with a naming fix, `--enum` and `--dedupe-enums` it names shared enums. A\n * footer that a call before created on the context is kept.\n */\nfunction withRunFooter(document: DocumentObject, ctx: RunContext, names: RunFooterNames): void {\n if (ctx.runFooter !== undefined) {\n return;\n }\n const recorder = enumNameRecorderOf(ctx);\n const shared =\n recorder === null || !ctx.enum || !ctx.dedupeEnums\n ? null\n : sharedEnumNamesOf(document, ctx, recorder);\n const sink = new ContextFooterSink(ctx.injectFooter);\n ctx.runFooter =\n shared === null\n ? new RunFooter(sink, ctx.dedupeEnums, FIRST_SCHEMA_NAMES, names)\n : new RunFooter(sink, true, shared, names);\n}\n\n/**\n * The document with the enums renamed that gave way to a name the output turned out not to need\n * (`EnumNameClaims`): they get that name back, as before.\n */\nfunction withEnumNamesGivenBack(\n parts: TransformedDocument,\n names: RunFooterNames,\n): TransformedDocument {\n const footer = parts.footer.filter(isIrDeclaration);\n const renames = names.enums.givenBack(namesTheOutputNeeds({ ...parts, footer }));\n if (renames.size === 0) {\n return parts;\n }\n return {\n body: withEnumsRenamed(parts.body, renames),\n footer: parts.footer.map((entry) =>\n isIrDeclaration(entry) ? (withEnumsRenamed([entry], renames)[0] ?? entry) : entry,\n ),\n closing: withEnumsRenamed(parts.closing, renames),\n };\n}\n\n/**\n * With `--enum-values`, arrays whose location type does not hold their values are typed by their\n * values (ADR-027); a location that excludes listed values is a contradiction of the document.\n */\nfunction enumValuesChecked(\n body: readonly IrDeclaration[],\n footer: FooterEntry[],\n ctx: RunContext,\n): FooterEntry[] {\n if (!ctx.enumValues) {\n return footer;\n }\n const checked = checkedEnumValues(footer, body, isIrDeclaration);\n for (const retype of checked.retyped) {\n if (retype.kind === \"excluded\") {\n ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));\n }\n }\n return checked.footer;\n}\n\n/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */\nexport function transformDocument(schema: OpenAPI3, ctx: RunContext): TransformedDocument {\n const document = schema as DocumentObject;\n ctx.schemaDialect = schemaDialectOf(document.openapi);\n const names: RunFooterNames = {\n enums: new EnumNameClaims(NAMES_THE_OUTPUT_MAY_NEED),\n operations: new OperationKeys(operationKeysWritten(document)),\n };\n withRunFooter(document, ctx, names);\n const context = createTransformContext(ctx);\n // documentBody registers the enums in the footer, so the footer is read after it.\n const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));\n const rawFooter = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const rawClosing = documentClosing(document, context, rawFooter.some(isOperations));\n const parts = { body: rawBody, footer: rawFooter, closing: rawClosing };\n const { body, footer, closing } = withEnumNamesGivenBack(parts, names);\n return {\n body: renameTakenAliases(body, footer.filter(isIrDeclaration), closing),\n footer,\n closing,\n };\n}\n\n/**\n * The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same\n * for a loaded document.\n */\nexport default function transformSchema(schema: OpenAPI3, ctx: GlobalContext): IrDeclaration[] {\n return documentDeclarations(transformDocument(schema, ctx));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,aAAa,KAAA,EAA6B;AACjD,EAAA,MAAM,OAAO,eAAA,CAAgB,KAAK,IAC7B,KAAA,CAA4B,IAAA,GAC5B,MAA2C,IAAA,EAAM,WAAA;AACtD,EAAA,OAAO,IAAA,KAAS,eAAA;AACl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AA;AACrE,EAAA,OAAO;AAAA,IACL,MAAM,kBAAA,CAAmB,IAAA,EAAM,OAAO,MAAA,CAAO,eAAe,GAAG,OAAO,CAAA;AAAA,IACtE,MAAA;AAAA,IACA;AAAA,GACF;AACF;AAMA,SAAwB,eAAA,CAAgB,QAAkB,GAAA,EAAqC;AAC7F,EAAA,OAAO,oBAAA,CAAqB,iBAAA,CAAkB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC5D;;"}
1
+ {"version":3,"file":"transform-schema.mjs","sources":["../../src/api/transform-schema.ts"],"sourcesContent":["import type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport { documentBody, documentClosing } from \"../application/transform/document/document.js\";\nimport {\n NAMES_THE_OUTPUT_MAY_NEED,\n namesTheOutputNeeds,\n withEnumsRenamed,\n} from \"../application/transform/document/enum-names-given-back.js\";\nimport { operationKeysWritten } from \"../application/transform/document/operation-keys-written.js\";\nimport {\n unmatchedTemplateKeys,\n withTemplatePathRefs,\n} from \"../application/transform/document/path-template-refs.js\";\nimport { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter, type RunFooterNames } from \"../application/transform/footer/document-footer.js\";\nimport { EnumNameClaims } from \"../application/transform/footer/enum-name-claims.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport { OperationKeys } from \"../application/transform/footer/operation-keys.js\";\nimport {\n FIRST_SCHEMA_NAMES,\n SharedEnumNameRecorder,\n type SharedEnumNames,\n} from \"../application/transform/footer/shared-enum-names.js\";\nimport type { IrDeclaration } from \"../domain/ir/nodes.js\";\nimport type { DocumentObject } from \"../domain/openapi/document-object.js\";\nimport { schemaDialectOf } from \"../domain/openapi/schema-dialect.js\";\nimport { FIX } from \"../domain/output-fixes.js\";\nimport type { GlobalContext, OpenAPI3 } from \"../types.js\";\nimport { FirstSchemaNameRecorder } from \"./discriminator-enum-names.js\";\nimport { documentDeclarations, type TransformedDocument } from \"./document-declarations.js\";\nimport { excludedValuesWarning } from \"./enum-values-warnings.js\";\nimport { type FooterEntry, isIrDeclaration } from \"./footer-entry.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { createTransformContext } from \"./transform-context.js\";\n\nconst OPERATIONS_NAME = \"operations\";\n\n/** Whether a footer entry is named `operations` (any declaration kind, as in the original). */\nfunction isOperations(entry: FooterEntry): boolean {\n const name = isIrDeclaration(entry)\n ? (entry as { name?: string }).name\n : (entry as Partial<ts.InterfaceDeclaration>).name?.escapedText;\n return name === OPERATIONS_NAME;\n}\n\n/** Drops a message: the first pass must not repeat the run's warnings or debug lines. */\nconst dropMessage = (): void => undefined;\nconst DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };\n\n/** A shared enum name recorder of a first pass, and the names it gives the second. */\ninterface EnumNameRecorder extends SharedEnumNames {\n chosenNames(): SharedEnumNames;\n}\n\n/**\n * The names of shared enums, known only at the end: a first pass transforms the document into a\n * scratch footer that `recorder` watches; its output is dropped. User callbacks run in both\n * passes. The `dedupe-enum-names` fix (ADR-021, upstream #1683) names an enum by all of its\n * schemas; `discriminator-values` keeps the first declaring schema's name\n * (`FirstSchemaNameRecorder`).\n */\nfunction sharedEnumNamesOf(\n document: DocumentObject,\n ctx: RunContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: RunContext = {\n ...ctx,\n injectFooter,\n runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),\n logger: DROPPED_MESSAGES,\n legacyCallbackWarnings: new Set(),\n };\n const scratchContext = createTransformContext(scratch);\n documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));\n return recorder.chosenNames();\n}\n\n/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */\nfunction enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {\n if (ctx.fix?.includes(FIX.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(FIX.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/**\n * The run's footer: with a naming fix, `--enum` and `--dedupe-enums` it names shared enums. A\n * footer that a call before created on the context is kept.\n */\nfunction withRunFooter(document: DocumentObject, ctx: RunContext, names: RunFooterNames): void {\n if (ctx.runFooter !== undefined) {\n return;\n }\n const recorder = enumNameRecorderOf(ctx);\n const shared =\n recorder === null || !ctx.enum || !ctx.dedupeEnums\n ? null\n : sharedEnumNamesOf(document, ctx, recorder);\n const sink = new ContextFooterSink(ctx.injectFooter);\n ctx.runFooter =\n shared === null\n ? new RunFooter(sink, ctx.dedupeEnums, FIRST_SCHEMA_NAMES, names)\n : new RunFooter(sink, true, shared, names);\n}\n\n/**\n * The document with the enums renamed that gave way to a name the output turned out not to need\n * (`EnumNameClaims`): they get that name back, as before.\n */\nfunction withEnumNamesGivenBack(\n parts: TransformedDocument,\n names: RunFooterNames,\n): TransformedDocument {\n const footer = parts.footer.filter(isIrDeclaration);\n const renames = names.enums.givenBack(namesTheOutputNeeds({ ...parts, footer }));\n if (renames.size === 0) {\n return parts;\n }\n return {\n body: withEnumsRenamed(parts.body, renames),\n footer: parts.footer.map((entry) =>\n isIrDeclaration(entry) ? (withEnumsRenamed([entry], renames)[0] ?? entry) : entry,\n ),\n closing: withEnumsRenamed(parts.closing, renames),\n };\n}\n\n/**\n * With `--enum-values`, arrays whose location type does not hold their values are typed by their\n * values (ADR-027); a location that excludes listed values is a contradiction of the document.\n */\nfunction enumValuesChecked(\n body: readonly IrDeclaration[],\n footer: FooterEntry[],\n ctx: RunContext,\n): FooterEntry[] {\n if (!ctx.enumValues) {\n return footer;\n }\n const checked = checkedEnumValues(footer, body, isIrDeclaration);\n for (const retype of checked.retyped) {\n if (retype.kind === \"excluded\") {\n ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));\n }\n }\n return checked.footer;\n}\n\n/** The document with its references into templated paths indexed by their templates. */\nfunction withTemplateRefs(\n { body, footer, closing }: TransformedDocument,\n keys: ReadonlyMap<string, string>,\n): TransformedDocument {\n return {\n body: withTemplatePathRefs(body, keys),\n footer: footer.map((entry) =>\n isIrDeclaration(entry) ? (withTemplatePathRefs([entry], keys)[0] ?? entry) : entry,\n ),\n closing: withTemplatePathRefs(closing, keys),\n };\n}\n\n/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */\nexport function transformDocument(schema: OpenAPI3, ctx: RunContext): TransformedDocument {\n const document = schema as DocumentObject;\n ctx.schemaDialect = schemaDialectOf(document.openapi);\n const names: RunFooterNames = {\n enums: new EnumNameClaims(NAMES_THE_OUTPUT_MAY_NEED),\n operations: new OperationKeys(operationKeysWritten(document)),\n };\n withRunFooter(document, ctx, names);\n const context = createTransformContext(ctx);\n // documentBody registers the enums in the footer, so the footer is read after it.\n const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));\n const rawFooter = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const rawClosing = documentClosing(document, context, rawFooter.some(isOperations));\n const parts = { body: rawBody, footer: rawFooter, closing: rawClosing };\n const { body, footer, closing } = withEnumNamesGivenBack(parts, names);\n const named = { body: renameTakenAliases(body, footer.filter(isIrDeclaration), closing), footer };\n return withTemplateRefs({ ...named, closing }, unmatchedTemplateKeys(document.paths, context));\n}\n\n/**\n * The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same\n * for a loaded document.\n */\nexport default function transformSchema(schema: OpenAPI3, ctx: GlobalContext): IrDeclaration[] {\n return documentDeclarations(transformDocument(schema, ctx));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,aAAa,KAAA,EAA6B;AACjD,EAAA,MAAM,OAAO,eAAA,CAAgB,KAAK,IAC7B,KAAA,CAA4B,IAAA,GAC5B,MAA2C,IAAA,EAAM,WAAA;AACtD,EAAA,OAAO,IAAA,KAAS,eAAA;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AAA,CAAa,MAAA,CAAO,eAAe,CAAC,CAAA;AAC9F,EAAA,MAAM,SAAA,GAAY,kBAAkB,OAAA,EAAS,CAAC,GAAG,GAAA,CAAI,YAAY,GAAG,GAAG,CAAA;AACvE,EAAA,MAAM,aAAa,eAAA,CAAgB,QAAA,EAAU,SAAS,SAAA,CAAU,IAAA,CAAK,YAAY,CAAC,CAAA;AAClF,EAAA,MAAM,QAAQ,EAAE,IAAA,EAAM,SAAS,MAAA,EAAQ,SAAA,EAAW,SAAS,UAAA,EAAW;AACtE,EAAA,MAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAQ,GAAI,sBAAA,CAAuB,OAAO,KAAK,CAAA;AACrE,EAAA,MAAM,KAAA,GAAQ,EAAE,IAAA,EAAM,kBAAA,CAAmB,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,eAAe,CAAA,EAAG,OAAO,CAAA,EAAG,MAAA,EAAO;AAChG,EAAA,OAAO,gBAAA,CAAiB,EAAE,GAAG,KAAA,EAAO,OAAA,IAAW,qBAAA,CAAsB,QAAA,CAAS,KAAA,EAAO,OAAO,CAAC,CAAA;AAC/F;AAMA,SAAwB,eAAA,CAAgB,QAAkB,GAAA,EAAqC;AAC7F,EAAA,OAAO,oBAAA,CAAqB,iBAAA,CAAkB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC5D;;"}
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ const constructors = require('../../domain/ir/constructors.cjs');
4
+ const helperTypes = require('./helper-types.cjs');
5
+
6
+ function memberValueTypes(member) {
7
+ if (member.kind === "indexSignature") {
8
+ return [member.type];
9
+ }
10
+ return member.isOptional ? [member.type, constructors.irKeyword("undefined")] : [member.type];
11
+ }
12
+ function declaredValueTypes(type, footer) {
13
+ switch (type.kind) {
14
+ case "object":
15
+ return type.members.flatMap(memberValueTypes);
16
+ case "union":
17
+ case "intersection":
18
+ return type.types.flatMap((member) => declaredValueTypes(member, footer));
19
+ case "reference":
20
+ case "indexedAccess":
21
+ case "raw":
22
+ footer.requirePropertyValues();
23
+ return [constructors.irReference(helperTypes.HELPER_TYPES.propertyValues.name, [type])];
24
+ case "keyword":
25
+ case "stringLiteral":
26
+ case "numberLiteral":
27
+ case "booleanLiteral":
28
+ case "array":
29
+ case "tuple":
30
+ case "readonly":
31
+ return [];
32
+ }
33
+ }
34
+
35
+ exports.declaredValueTypes = declaredValueTypes;
36
+ //# sourceMappingURL=declared-value-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declared-value-types.cjs","sources":["../../../src/application/transform/declared-value-types.ts"],"sourcesContent":["import { irKeyword, irReference } from \"../../domain/ir/constructors.js\";\nimport type { IrMember, IrType } from \"../../domain/ir/nodes.js\";\nimport { HELPER_TYPES } from \"./helper-types.js\";\nimport type { FooterDeclarations } from \"./schema/schema-context.js\";\n\n/** The footer part that declares the `PropertyValues` helper type. */\nexport type PropertyValuesFooter = Pick<FooterDeclarations, \"requirePropertyValues\">;\n\nfunction memberValueTypes(member: IrMember): IrType[] {\n if (member.kind === \"indexSignature\") {\n return [member.type];\n }\n return member.isOptional ? [member.type, irKeyword(\"undefined\")] : [member.type];\n}\n\n/**\n * The value types a key of the type can have, read from its IR: the members of object types,\n * through unions and intersections. A reference (a `$ref`, `Omit`, `WithRequired`) or a raw\n * type is read with `PropertyValues`. Primitives, literals and arrays declare no keys.\n */\nexport function declaredValueTypes(type: IrType, footer: PropertyValuesFooter): IrType[] {\n switch (type.kind) {\n case \"object\":\n return type.members.flatMap(memberValueTypes);\n case \"union\":\n case \"intersection\":\n return type.types.flatMap((member) => declaredValueTypes(member, footer));\n case \"reference\":\n case \"indexedAccess\":\n case \"raw\":\n footer.requirePropertyValues();\n return [irReference(HELPER_TYPES.propertyValues.name, [type])];\n case \"keyword\":\n case \"stringLiteral\":\n case \"numberLiteral\":\n case \"booleanLiteral\":\n case \"array\":\n case \"tuple\":\n case \"readonly\":\n return [];\n }\n}\n"],"names":["irKeyword","irReference","HELPER_TYPES"],"mappings":";;;;;AAQA,SAAS,iBAAiB,MAAA,EAA4B;AACpD,EAAA,IAAI,MAAA,CAAO,SAAS,gBAAA,EAAkB;AACpC,IAAA,OAAO,CAAC,OAAO,IAAI,CAAA;AAAA,EACrB;AACA,EAAA,OAAO,MAAA,CAAO,UAAA,GAAa,CAAC,MAAA,CAAO,IAAA,EAAMA,sBAAA,CAAU,WAAW,CAAC,CAAA,GAAI,CAAC,MAAA,CAAO,IAAI,CAAA;AACjF;AAOO,SAAS,kBAAA,CAAmB,MAAc,MAAA,EAAwC;AACvF,EAAA,QAAQ,KAAK,IAAA;AAAM,IACjB,KAAK,QAAA;AACH,MAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,gBAAgB,CAAA;AAAA,IAC9C,KAAK,OAAA;AAAA,IACL,KAAK,cAAA;AACH,MAAA,OAAO,IAAA,CAAK,MAAM,OAAA,CAAQ,CAAC,WAAW,kBAAA,CAAmB,MAAA,EAAQ,MAAM,CAAC,CAAA;AAAA,IAC1E,KAAK,WAAA;AAAA,IACL,KAAK,eAAA;AAAA,IACL,KAAK,KAAA;AACH,MAAA,MAAA,CAAO,qBAAA,EAAsB;AAC7B,MAAA,OAAO,CAACC,yBAAYC,wBAAA,CAAa,cAAA,CAAe,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;AAAA,IAC/D,KAAK,SAAA;AAAA,IACL,KAAK,eAAA;AAAA,IACL,KAAK,eAAA;AAAA,IACL,KAAK,gBAAA;AAAA,IACL,KAAK,OAAA;AAAA,IACL,KAAK,OAAA;AAAA,IACL,KAAK,UAAA;AACH,MAAA,OAAO,EAAC;AAAA;AAEd;;"}