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

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 (286) hide show
  1. package/README.md +12 -5
  2. package/dist/adapters/node-deprecations/node-deprecations.cjs +14 -0
  3. package/dist/adapters/node-deprecations/node-deprecations.cjs.map +1 -0
  4. package/dist/adapters/node-deprecations/node-deprecations.mjs +12 -0
  5. package/dist/adapters/node-deprecations/node-deprecations.mjs.map +1 -0
  6. package/dist/adapters/redocly-loader/configured-headers.cjs +32 -0
  7. package/dist/adapters/redocly-loader/configured-headers.cjs.map +1 -0
  8. package/dist/adapters/redocly-loader/configured-headers.mjs +30 -0
  9. package/dist/adapters/redocly-loader/configured-headers.mjs.map +1 -0
  10. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +19 -6
  11. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  12. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +18 -5
  13. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  14. package/dist/adapters/redocly-loader/ref-access.cjs +37 -4
  15. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  16. package/dist/adapters/redocly-loader/ref-access.mjs +37 -4
  17. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  18. package/dist/adapters/redocly-loader/ref-resolution-check.cjs +191 -0
  19. package/dist/adapters/redocly-loader/ref-resolution-check.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/ref-resolution-check.mjs +189 -0
  21. package/dist/adapters/redocly-loader/ref-resolution-check.mjs.map +1 -0
  22. package/dist/adapters/redocly-loader/ref-resolution-steps.cjs +73 -0
  23. package/dist/adapters/redocly-loader/ref-resolution-steps.cjs.map +1 -0
  24. package/dist/adapters/redocly-loader/ref-resolution-steps.mjs +60 -0
  25. package/dist/adapters/redocly-loader/ref-resolution-steps.mjs.map +1 -0
  26. package/dist/adapters/redocly-loader/remote-fetch.cjs +41 -14
  27. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  28. package/dist/adapters/redocly-loader/remote-fetch.mjs +40 -14
  29. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  30. package/dist/adapters/redocly-loader/schema-load-errors.cjs +23 -5
  31. package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/schema-load-errors.mjs +23 -5
  33. package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
  34. package/dist/adapters/redocly-loader/unsupported-keys.cjs +9 -1
  35. package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
  36. package/dist/adapters/redocly-loader/unsupported-keys.mjs +9 -1
  37. package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
  38. package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
  39. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  40. package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
  41. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  42. package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs +2 -1
  43. package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs.map +1 -1
  44. package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs +2 -1
  45. package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs.map +1 -1
  46. package/dist/adapters/type-ast-bridge/print-typescript.cjs.map +1 -1
  47. package/dist/adapters/type-ast-bridge/print-typescript.mjs.map +1 -1
  48. package/dist/api/default-ports.cjs +14 -0
  49. package/dist/api/default-ports.cjs.map +1 -1
  50. package/dist/api/default-ports.mjs +12 -1
  51. package/dist/api/default-ports.mjs.map +1 -1
  52. package/dist/api/discriminator-conflict-warnings.cjs +1 -1
  53. package/dist/api/discriminator-conflict-warnings.cjs.map +1 -1
  54. package/dist/api/discriminator-conflict-warnings.mjs +2 -2
  55. package/dist/api/discriminator-conflict-warnings.mjs.map +1 -1
  56. package/dist/api/discriminator-patch.cjs +8 -4
  57. package/dist/api/discriminator-patch.cjs.map +1 -1
  58. package/dist/api/discriminator-patch.mjs +9 -5
  59. package/dist/api/discriminator-patch.mjs.map +1 -1
  60. package/dist/api/discriminator-scan.cjs +2 -2
  61. package/dist/api/discriminator-scan.cjs.map +1 -1
  62. package/dist/api/discriminator-scan.mjs +3 -3
  63. package/dist/api/discriminator-scan.mjs.map +1 -1
  64. package/dist/api/document-refs.cjs +15 -12
  65. package/dist/api/document-refs.cjs.map +1 -1
  66. package/dist/api/document-refs.mjs +15 -12
  67. package/dist/api/document-refs.mjs.map +1 -1
  68. package/dist/api/document-run.cjs +6 -3
  69. package/dist/api/document-run.cjs.map +1 -1
  70. package/dist/api/document-run.mjs +6 -3
  71. package/dist/api/document-run.mjs.map +1 -1
  72. package/dist/api/footer-sink.cjs +25 -2
  73. package/dist/api/footer-sink.cjs.map +1 -1
  74. package/dist/api/footer-sink.mjs +25 -2
  75. package/dist/api/footer-sink.mjs.map +1 -1
  76. package/dist/api/legacy-callback-warning.cjs +7 -1
  77. package/dist/api/legacy-callback-warning.cjs.map +1 -1
  78. package/dist/api/legacy-callback-warning.mjs +8 -2
  79. package/dist/api/legacy-callback-warning.mjs.map +1 -1
  80. package/dist/api/legacy-ts-helpers.cjs.map +1 -1
  81. package/dist/api/legacy-ts-helpers.mjs.map +1 -1
  82. package/dist/api/legacy-utils.cjs.map +1 -1
  83. package/dist/api/legacy-utils.mjs.map +1 -1
  84. package/dist/api/openapi-ts.cjs +3 -2
  85. package/dist/api/openapi-ts.cjs.map +1 -1
  86. package/dist/api/openapi-ts.mjs +4 -3
  87. package/dist/api/openapi-ts.mjs.map +1 -1
  88. package/dist/api/string-to-ast.cjs +7 -9
  89. package/dist/api/string-to-ast.cjs.map +1 -1
  90. package/dist/api/string-to-ast.mjs +8 -9
  91. package/dist/api/string-to-ast.mjs.map +1 -1
  92. package/dist/api/transform-context.cjs +1 -1
  93. package/dist/api/transform-context.cjs.map +1 -1
  94. package/dist/api/transform-context.mjs +1 -1
  95. package/dist/api/transform-context.mjs.map +1 -1
  96. package/dist/api/transform-schema.cjs +2 -2
  97. package/dist/api/transform-schema.cjs.map +1 -1
  98. package/dist/api/transform-schema.mjs +3 -3
  99. package/dist/api/transform-schema.mjs.map +1 -1
  100. package/dist/application/print/type-printer.cjs +2 -1
  101. package/dist/application/print/type-printer.cjs.map +1 -1
  102. package/dist/application/print/type-printer.mjs +2 -1
  103. package/dist/application/print/type-printer.mjs.map +1 -1
  104. package/dist/application/transform/document/components.cjs +1 -1
  105. package/dist/application/transform/document/components.cjs.map +1 -1
  106. package/dist/application/transform/document/components.mjs +2 -2
  107. package/dist/application/transform/document/components.mjs.map +1 -1
  108. package/dist/application/transform/document/parameters.cjs +2 -2
  109. package/dist/application/transform/document/parameters.cjs.map +1 -1
  110. package/dist/application/transform/document/parameters.mjs +3 -3
  111. package/dist/application/transform/document/parameters.mjs.map +1 -1
  112. package/dist/application/transform/document/paths.cjs +2 -2
  113. package/dist/application/transform/document/paths.cjs.map +1 -1
  114. package/dist/application/transform/document/paths.mjs +3 -3
  115. package/dist/application/transform/document/paths.mjs.map +1 -1
  116. package/dist/application/transform/footer/evaluation.cjs +9 -0
  117. package/dist/application/transform/footer/evaluation.cjs.map +1 -1
  118. package/dist/application/transform/footer/evaluation.mjs +8 -1
  119. package/dist/application/transform/footer/evaluation.mjs.map +1 -1
  120. package/dist/application/transform/footer/type-evaluation.cjs +4 -112
  121. package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
  122. package/dist/application/transform/footer/type-evaluation.mjs +4 -112
  123. package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
  124. package/dist/application/transform/footer/type-indexing.cjs +107 -0
  125. package/dist/application/transform/footer/type-indexing.cjs.map +1 -0
  126. package/dist/application/transform/footer/type-indexing.mjs +105 -0
  127. package/dist/application/transform/footer/type-indexing.mjs.map +1 -0
  128. package/dist/application/transform/ref-pointer/pointer-type.cjs +1 -1
  129. package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
  130. package/dist/application/transform/ref-pointer/pointer-type.mjs +2 -2
  131. package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
  132. package/dist/application/transform/schema/access-flags.cjs +1 -1
  133. package/dist/application/transform/schema/access-flags.cjs.map +1 -1
  134. package/dist/application/transform/schema/access-flags.mjs +2 -2
  135. package/dist/application/transform/schema/access-flags.mjs.map +1 -1
  136. package/dist/application/transform/schema/array-type.cjs +2 -2
  137. package/dist/application/transform/schema/array-type.cjs.map +1 -1
  138. package/dist/application/transform/schema/array-type.mjs +3 -3
  139. package/dist/application/transform/schema/array-type.mjs.map +1 -1
  140. package/dist/application/transform/schema/composition-type.cjs +3 -3
  141. package/dist/application/transform/schema/composition-type.cjs.map +1 -1
  142. package/dist/application/transform/schema/composition-type.mjs +4 -4
  143. package/dist/application/transform/schema/composition-type.mjs.map +1 -1
  144. package/dist/application/transform/schema/enum-rule.cjs +3 -5
  145. package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
  146. package/dist/application/transform/schema/enum-rule.mjs +4 -6
  147. package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
  148. package/dist/application/transform/schema/presence-members.cjs +1 -1
  149. package/dist/application/transform/schema/presence-members.cjs.map +1 -1
  150. package/dist/application/transform/schema/presence-members.mjs +2 -2
  151. package/dist/application/transform/schema/presence-members.mjs.map +1 -1
  152. package/dist/application/transform/schema/required-variants.cjs +2 -2
  153. package/dist/application/transform/schema/required-variants.cjs.map +1 -1
  154. package/dist/application/transform/schema/required-variants.mjs +3 -3
  155. package/dist/application/transform/schema/required-variants.mjs.map +1 -1
  156. package/dist/application/transform/schema/unevaluated-properties.cjs +1 -1
  157. package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
  158. package/dist/application/transform/schema/unevaluated-properties.mjs +2 -2
  159. package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
  160. package/dist/application/transform/schema-comment.cjs +1 -1
  161. package/dist/application/transform/schema-comment.cjs.map +1 -1
  162. package/dist/application/transform/schema-comment.mjs +2 -2
  163. package/dist/application/transform/schema-comment.mjs.map +1 -1
  164. package/dist/cli/api-settings.cjs +78 -0
  165. package/dist/cli/api-settings.cjs.map +1 -0
  166. package/dist/cli/api-settings.mjs +73 -0
  167. package/dist/cli/api-settings.mjs.map +1 -0
  168. package/dist/cli/cli-arguments.cjs +1 -0
  169. package/dist/cli/cli-arguments.cjs.map +1 -1
  170. package/dist/cli/cli-arguments.mjs +1 -1
  171. package/dist/cli/cli-arguments.mjs.map +1 -1
  172. package/dist/cli/help-text.cjs +3 -3
  173. package/dist/cli/help-text.cjs.map +1 -1
  174. package/dist/cli/help-text.mjs +3 -3
  175. package/dist/cli/help-text.mjs.map +1 -1
  176. package/dist/cli/redocly-apis.cjs +8 -4
  177. package/dist/cli/redocly-apis.cjs.map +1 -1
  178. package/dist/cli/redocly-apis.mjs +7 -3
  179. package/dist/cli/redocly-apis.mjs.map +1 -1
  180. package/dist/cli/run-cli.cjs +5 -1
  181. package/dist/cli/run-cli.cjs.map +1 -1
  182. package/dist/cli/run-cli.mjs +5 -1
  183. package/dist/cli/run-cli.mjs.map +1 -1
  184. package/dist/domain/deprecations.cjs +11 -0
  185. package/dist/domain/deprecations.cjs.map +1 -0
  186. package/dist/domain/deprecations.mjs +9 -0
  187. package/dist/domain/deprecations.mjs.map +1 -0
  188. package/dist/domain/errors.cjs +4 -1
  189. package/dist/domain/errors.cjs.map +1 -1
  190. package/dist/domain/errors.mjs +4 -1
  191. package/dist/domain/errors.mjs.map +1 -1
  192. package/dist/domain/ir/constructors.cjs +2 -0
  193. package/dist/domain/ir/constructors.cjs.map +1 -1
  194. package/dist/domain/ir/constructors.mjs +2 -1
  195. package/dist/domain/ir/constructors.mjs.map +1 -1
  196. package/dist/domain/openapi/path-templates.cjs +1 -1
  197. package/dist/domain/openapi/path-templates.cjs.map +1 -1
  198. package/dist/domain/openapi/path-templates.mjs +1 -1
  199. package/dist/domain/openapi/path-templates.mjs.map +1 -1
  200. package/dist/domain/output-fixes.cjs +11 -14
  201. package/dist/domain/output-fixes.cjs.map +1 -1
  202. package/dist/domain/output-fixes.mjs +11 -13
  203. package/dist/domain/output-fixes.mjs.map +1 -1
  204. package/dist/domain/url-credentials.cjs +10 -0
  205. package/dist/domain/url-credentials.cjs.map +1 -0
  206. package/dist/domain/url-credentials.mjs +8 -0
  207. package/dist/domain/url-credentials.mjs.map +1 -0
  208. package/dist/domain/warnings.cjs +8 -1
  209. package/dist/domain/warnings.cjs.map +1 -1
  210. package/dist/domain/warnings.mjs +8 -1
  211. package/dist/domain/warnings.mjs.map +1 -1
  212. package/dist/index.cjs +4 -3
  213. package/dist/index.cjs.map +1 -1
  214. package/dist/index.d.cts +1185 -59
  215. package/dist/index.d.mts +1185 -59
  216. package/dist/index.d.ts +1185 -59
  217. package/dist/index.mjs +4 -2
  218. package/dist/index.mjs.map +1 -1
  219. package/dist/transform/path-item-object.cjs.map +1 -1
  220. package/dist/transform/path-item-object.mjs.map +1 -1
  221. package/package.json +5 -4
  222. package/src/adapters/node-deprecations/node-deprecations.ts +14 -0
  223. package/src/adapters/redocly-loader/configured-headers.ts +65 -0
  224. package/src/adapters/redocly-loader/redocly-schema-loader.ts +22 -7
  225. package/src/adapters/redocly-loader/ref-access.ts +60 -5
  226. package/src/adapters/redocly-loader/ref-resolution-check.ts +257 -0
  227. package/src/adapters/redocly-loader/ref-resolution-steps.ts +113 -0
  228. package/src/adapters/redocly-loader/remote-fetch.ts +77 -21
  229. package/src/adapters/redocly-loader/schema-load-errors.ts +33 -11
  230. package/src/adapters/redocly-loader/unsupported-keys.ts +17 -2
  231. package/src/adapters/terminal-logger/terminal-logger.ts +9 -5
  232. package/src/adapters/type-ast-bridge/ir-to-typescript.ts +2 -1
  233. package/src/adapters/type-ast-bridge/print-typescript.ts +3 -1
  234. package/src/adapters/type-ast-bridge/typescript-types.ts +57 -5
  235. package/src/api/default-ports.ts +23 -0
  236. package/src/api/discriminator-conflict-warnings.ts +2 -2
  237. package/src/api/discriminator-patch.ts +11 -7
  238. package/src/api/discriminator-scan.ts +3 -3
  239. package/src/api/document-refs.ts +19 -15
  240. package/src/api/document-run.ts +14 -6
  241. package/src/api/footer-sink.ts +34 -2
  242. package/src/api/legacy-callback-warning.ts +16 -5
  243. package/src/api/legacy-ts-helpers.ts +7 -5
  244. package/src/api/legacy-utils.ts +1 -1
  245. package/src/api/openapi-ts.ts +8 -2
  246. package/src/api/run-context.ts +37 -0
  247. package/src/api/string-to-ast.ts +11 -15
  248. package/src/api/transform-context.ts +10 -8
  249. package/src/api/transform-schema.ts +9 -8
  250. package/src/application/ports/deprecation-reporter.ts +9 -0
  251. package/src/application/print/type-printer.ts +2 -1
  252. package/src/application/transform/document/components.ts +2 -2
  253. package/src/application/transform/document/parameters.ts +4 -3
  254. package/src/application/transform/document/paths.ts +4 -3
  255. package/src/application/transform/footer/evaluation.ts +10 -0
  256. package/src/application/transform/footer/type-evaluation.ts +6 -133
  257. package/src/application/transform/footer/type-indexing.ts +152 -0
  258. package/src/application/transform/ref-pointer/pointer-type.ts +2 -4
  259. package/src/application/transform/schema/access-flags.ts +2 -2
  260. package/src/application/transform/schema/array-type.ts +3 -5
  261. package/src/application/transform/schema/composition-type.ts +4 -4
  262. package/src/application/transform/schema/enum-rule.ts +4 -6
  263. package/src/application/transform/schema/presence-members.ts +2 -2
  264. package/src/application/transform/schema/required-variants.ts +3 -3
  265. package/src/application/transform/schema/unevaluated-properties.ts +2 -2
  266. package/src/application/transform/schema-comment.ts +2 -2
  267. package/src/cli/api-settings.ts +109 -0
  268. package/src/cli/cli-arguments.ts +5 -2
  269. package/src/cli/help-text.ts +4 -4
  270. package/src/cli/redocly-apis.ts +13 -7
  271. package/src/cli/run-cli.ts +5 -1
  272. package/src/domain/deprecations.ts +15 -0
  273. package/src/domain/errors.ts +16 -4
  274. package/src/domain/ir/constructors.ts +3 -0
  275. package/src/domain/ir/nodes.ts +9 -6
  276. package/src/domain/openapi/path-templates.ts +2 -1
  277. package/src/domain/output-fixes.ts +16 -16
  278. package/src/domain/url-credentials.ts +18 -0
  279. package/src/domain/warnings.ts +7 -0
  280. package/src/index.ts +3 -6
  281. package/src/transform/path-item-object.ts +6 -2
  282. package/src/types/generator-options.ts +12 -32
  283. package/src/types/openapi-common.ts +1 -0
  284. package/src/types/openapi-request.ts +3 -0
  285. package/src/types/openapi-schema.ts +2 -0
  286. package/src/types/openapi-security.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/** Create a $ref pointer (even from other $refs) */\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: any,\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;AAGO,SAAS,UAAU,KAAA,EAAuD;AAC/E,EAAA,OAAOC,sBAAgB,KAAK,CAAA;AAC9B;AAMO,SAAS,KAAA,CAAM,GAAA,EAAa,KAAA,EAAgB,IAAA,EAAe;AAEhE,EAAAC,0BAAA,CAAc,KAAK,CAAA,CAAE,KAAA,CAAM,GAAA,EAAK,OAAiC,IAAI,CAAA;AACvE;AAMO,SAAS,MAAM,GAAA,EAAa;AACjC,EAAAA,0BAAA,CAAc,KAAK,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA;AAChC;AAGO,SAAS,WAAW,CAAA,EAAW;AACpC,EAAA,OAAO,OAAO,CAAA,KAAM,QAAA,GAAWC,6BAAA,CAAe,CAAC,CAAA,GAAI,CAAA;AACrD;AAGO,SAAS,UAAA,CACd,KACA,OAAA,EAIA;AACA,EAAA,IAAI,OAAA,GAAU,MAAA,CAAO,OAAA,CAAQ,GAAG,CAAA;AAChC,EAAA,IAAI,SAAS,WAAA,EAAa;AACxB,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAC,CAAC,CAAA,EAAG,CAAC,CAAC,CAAA,KAAM,CAAA,CAAE,aAAA,CAAc,GAAG,OAAA,EAAS,EAAE,OAAA,EAAS,IAAA,EAAM,CAAC,CAAA;AAAA,EAC3E;AACA,EAAA,IAAI,SAAS,iBAAA,EAAmB;AAC9B,IAAA,OAAA,GAAU,OAAA,CAAQ,MAAA;AAAA,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;;;;;;;;;;;"}
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/** Create a $ref pointer (even from other $refs) */\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;AAGO,SAAS,UAAU,KAAA,EAAuD;AAC/E,EAAA,OAAOC,sBAAgB,KAAK,CAAA;AAC9B;AAMO,SAAS,KAAA,CAAM,GAAA,EAAa,KAAA,EAAgB,IAAA,EAAe;AAEhE,EAAAC,0BAAA,CAAc,KAAK,CAAA,CAAE,KAAA,CAAM,GAAA,EAAK,OAAiC,IAAI,CAAA;AACvE;AAMO,SAAS,MAAM,GAAA,EAAa;AACjC,EAAAA,0BAAA,CAAc,KAAK,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA;AAChC;AAGO,SAAS,WAAW,CAAA,EAAW;AACpC,EAAA,OAAO,OAAO,CAAA,KAAM,QAAA,GAAWC,6BAAA,CAAe,CAAC,CAAA,GAAI,CAAA;AACrD;AAGO,SAAS,UAAA,CACd,KACA,OAAA,EAIA;AACA,EAAA,IAAI,OAAA,GAAU,MAAA,CAAO,OAAA,CAAQ,GAAG,CAAA;AAChC,EAAA,IAAI,SAAS,WAAA,EAAa;AACxB,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAC,CAAC,CAAA,EAAG,CAAC,CAAC,CAAA,KAAM,CAAA,CAAE,aAAA,CAAc,GAAG,OAAA,EAAS,EAAE,OAAA,EAAS,IAAA,EAAM,CAAC,CAAA;AAAA,EAC3E;AACA,EAAA,IAAI,SAAS,iBAAA,EAAmB;AAC9B,IAAA,OAAA,GAAU,OAAA,CAAQ,MAAA;AAAA,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;;;;;;;;;;;"}
@@ -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/** Create a $ref pointer (even from other $refs) */\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: any,\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;AAGO,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,CA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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()) {\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/** Create a $ref pointer (even from other $refs) */\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;AAGO,SAAS,UAAU,KAAA,EAAuD;AAC/E,EAAA,OAAOA,YAAgB,KAAK,CAAA;AA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AAMO,SAAS,IAAA,CAAK,GAAA,EAAa,MAAA,GAAS,KAAA,EAAO;AAChD,EAAA,aAAA,CAAc,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAChC;;"}
@@ -26,9 +26,10 @@ async function defaultGeneratorPorts(options) {
26
26
  redoc,
27
27
  logger,
28
28
  now: defaultPorts.monotonicNow,
29
- remoteRefTimeoutMs: defaultPorts.REMOTE_REF_TIMEOUT_MS
29
+ remoteRefTimeoutMs: defaultPorts.REMOTE_REF_TIMEOUT_MS,
30
+ remoteDocumentLimits: defaultPorts.DEFAULT_REMOTE_DOCUMENT_LIMITS
30
31
  });
31
- return { loader, logger, redoc, now: defaultPorts.monotonicNow };
32
+ return { loader, logger, deprecations: defaultPorts.defaultDeprecationReporter(), redoc, now: defaultPorts.monotonicNow };
32
33
  }
33
34
  async function openapiTS(source, options = {}) {
34
35
  return generateDeclarations(source, options, await defaultGeneratorPorts(options));
@@ -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 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/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n const { schema, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const result = 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 result;\n}\n\n/** The default ports: the terminal logger, the given or default Redocly config, Redocly loading. */\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 });\n return { loader, logger, 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"],"mappings":";;;;;;;;;;AAmBA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,MAAM,EAAE,QAAQ,GAAA,EAAI,GAAI,MAAMA,6BAAA,CAAkB,MAAA,EAAQ,SAAS,KAAK,CAAA;AACtE,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,SAASC,uCAAA,CAA0B,WAAA,EAAa,MAAMC,uBAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AACxF,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,MAAA;AACT;AAGA,eAAsB,sBAAsB,OAAA,EAAoD;AAC9F,EAAA,MAAM,MAAA,GAASC,0BAAA,CAAc,OAAA,CAAQ,MAAA,IAAU,KAAK,CAAA;AACpD,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,OAAA,IAAY,MAAMC,iCAAA,EAAqB;AAC7D,EAAA,MAAM,SAASC,6CAAA,CAA0B;AAAA,IACvC,KAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAA,EAAKC,yBAAA;AAAA,IACL,kBAAA,EAAoBC;AAAA,GACrB,CAAA;AACD,EAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,EAAQ,KAAA,EAAO,KAAKD,yBAAA,EAAa;AACpD;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.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/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n const { schema, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const result = 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 result;\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_DOCUMENT_LIMITS","defaultDeprecationReporter"],"mappings":";;;;;;;;;;AAqBA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,MAAM,EAAE,QAAQ,GAAA,EAAI,GAAI,MAAMA,6BAAA,CAAkB,MAAA,EAAQ,SAAS,KAAK,CAAA;AACtE,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,SAASC,uCAAA,CAA0B,WAAA,EAAa,MAAMC,uBAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AACxF,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,MAAA;AACT;AAMA,eAAsB,sBAAsB,OAAA,EAAoD;AAC9F,EAAA,MAAM,MAAA,GAASC,0BAAA,CAAc,OAAA,CAAQ,MAAA,IAAU,KAAK,CAAA;AACpD,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,OAAA,IAAY,MAAMC,iCAAA,EAAqB;AAC7D,EAAA,MAAM,SAASC,6CAAA,CAA0B;AAAA,IACvC,KAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAA,EAAKC,yBAAA;AAAA,IACL,kBAAA,EAAoBC,kCAAA;AAAA,IACpB,oBAAA,EAAsBC;AAAA,GACvB,CAAA;AACD,EAAA,OAAO,EAAE,QAAQ,MAAA,EAAQ,YAAA,EAAcC,yCAA2B,EAAG,KAAA,EAAO,KAAKH,yBAAA,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,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, REMOTE_REF_TIMEOUT_MS } from './default-ports.mjs';
3
+ import { defaultLogger, defaultRedoclyConfig, monotonicNow, defaultDeprecationReporter, 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
 
@@ -22,9 +22,10 @@ async function defaultGeneratorPorts(options) {
22
22
  redoc,
23
23
  logger,
24
24
  now: monotonicNow,
25
- remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS
25
+ remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,
26
+ remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS
26
27
  });
27
- return { loader, logger, redoc, now: monotonicNow };
28
+ return { loader, logger, deprecations: defaultDeprecationReporter(), redoc, now: monotonicNow };
28
29
  }
29
30
  async function openapiTS(source, options = {}) {
30
31
  return generateDeclarations(source, options, await defaultGeneratorPorts(options));
@@ -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 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/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n const { schema, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const result = 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 result;\n}\n\n/** The default ports: the terminal logger, the given or default Redocly config, Redocly loading. */\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 });\n return { loader, logger, 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":";;;;;;AAmBA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,MAAM,EAAE,QAAQ,GAAA,EAAI,GAAI,MAAM,iBAAA,CAAkB,MAAA,EAAQ,SAAS,KAAK,CAAA;AACtE,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,SAAS,yBAAA,CAA0B,WAAA,EAAa,MAAM,eAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AACxF,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,MAAA;AACT;AAGA,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;AAAA,GACrB,CAAA;AACD,EAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,EAAQ,KAAA,EAAO,KAAK,YAAA,EAAa;AACpD;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 { 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/** Load, validate and bundle the source, then transform it into IR declarations. */\nexport async function generateDeclarations(\n source: SchemaSource,\n options: GeneratorOptions,\n ports: GeneratorPorts,\n): Promise<IrDeclaration[]> {\n const { schema, ctx } = await createDocumentRun(source, options, ports);\n const startedAt = ports.now();\n const result = 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 result;\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":";;;;;;AAqBA,eAAsB,oBAAA,CACpB,MAAA,EACA,OAAA,EACA,KAAA,EAC0B;AAC1B,EAAA,MAAM,EAAE,QAAQ,GAAA,EAAI,GAAI,MAAM,iBAAA,CAAkB,MAAA,EAAQ,SAAS,KAAK,CAAA;AACtE,EAAA,MAAM,SAAA,GAAY,MAAM,GAAA,EAAI;AAC5B,EAAA,MAAM,SAAS,yBAAA,CAA0B,WAAA,EAAa,MAAM,eAAA,CAAgB,MAAA,EAAQ,GAAG,CAAC,CAAA;AACxF,EAAA,KAAA,CAAM,MAAA,CAAO,KAAA;AAAA,IACX,kDAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,CAAM,KAAI,GAAI;AAAA,GAChB;AACA,EAAA,OAAO,MAAA;AACT;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,21 +1,19 @@
1
1
  'use strict';
2
2
 
3
- const node_util = require('node:util');
4
3
  const irDeclarationsToTypescript = require('../adapters/type-ast-bridge/ir-declarations-to-typescript.cjs');
5
4
  const loadTypescript = require('../adapters/type-ast-bridge/load-typescript.cjs');
5
+ const deprecations = require('../domain/deprecations.cjs');
6
+ const defaultPorts = require('./default-ports.cjs');
6
7
  const legacyCallbackWarning = require('./legacy-callback-warning.cjs');
7
8
 
8
9
  const STRING_TO_AST_DEPRECATION = `stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR callback (irCallbacks: true) instead: ${legacyCallbackWarning.IR_CALLBACKS_GUIDE_URL}`;
9
- const STRING_TO_AST_DEPRECATION_CODE = "OPENAPI_TYPESAFE_DEP_STRING_TO_AST";
10
- function parseSource(source) {
10
+ function stringToAST(source) {
11
+ defaultPorts.defaultDeprecationReporter().report(
12
+ deprecations.DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_STRING_TO_AST,
13
+ STRING_TO_AST_DEPRECATION
14
+ );
11
15
  return [...irDeclarationsToTypescript.parseStatements(loadTypescript.loadTypeScript(), source)];
12
16
  }
13
- const stringToAST = node_util.deprecate(
14
- parseSource,
15
- STRING_TO_AST_DEPRECATION,
16
- STRING_TO_AST_DEPRECATION_CODE
17
- );
18
17
 
19
- exports.STRING_TO_AST_DEPRECATION_CODE = STRING_TO_AST_DEPRECATION_CODE;
20
18
  exports.stringToAST = stringToAST;
21
19
  //# sourceMappingURL=string-to-ast.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"string-to-ast.cjs","sources":["../../src/api/string-to-ast.ts"],"sourcesContent":["import { deprecate } from \"node:util\";\nimport { parseStatements } from \"../adapters/type-ast-bridge/ir-declarations-to-typescript.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport { IR_CALLBACKS_GUIDE_URL } from \"./legacy-callback-warning.js\";\n\nconst STRING_TO_AST_DEPRECATION =\n \"stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR \" +\n `callback (irCallbacks: true) instead: ${IR_CALLBACKS_GUIDE_URL}`;\n\n/** Node's deprecation code for `stringToAST`, so users can filter or trace the warning. */\nexport const STRING_TO_AST_DEPRECATION_CODE = \"OPENAPI_TYPESAFE_DEP_STRING_TO_AST\";\n\nfunction parseSource(source: string): unknown[] {\n return [...parseStatements(loadTypeScript(), source)];\n}\n\n/**\n * Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so\n * it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Node's `util.deprecate` warns\n * on the first call only.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.\n */\nexport const stringToAST: (source: string) => unknown[] = deprecate(\n parseSource,\n STRING_TO_AST_DEPRECATION,\n STRING_TO_AST_DEPRECATION_CODE,\n);\n"],"names":["IR_CALLBACKS_GUIDE_URL","parseStatements","loadTypeScript","deprecate"],"mappings":";;;;;;;AAKA,MAAM,yBAAA,GACJ,gIACyCA,4CAAsB,CAAA,CAAA;AAG1D,MAAM,8BAAA,GAAiC;AAE9C,SAAS,YAAY,MAAA,EAA2B;AAC9C,EAAA,OAAO,CAAC,GAAGC,0CAAA,CAAgBC,6BAAA,EAAe,EAAG,MAAM,CAAC,CAAA;AACtD;AAQO,MAAM,WAAA,GAA6CC,mBAAA;AAAA,EACxD,WAAA;AAAA,EACA,yBAAA;AAAA,EACA;AACF;;;"}
1
+ {"version":3,"file":"string-to-ast.cjs","sources":["../../src/api/string-to-ast.ts"],"sourcesContent":["import { parseStatements } from \"../adapters/type-ast-bridge/ir-declarations-to-typescript.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport { DEPRECATION_CODES } from \"../domain/deprecations.js\";\nimport { defaultDeprecationReporter } from \"./default-ports.js\";\nimport { IR_CALLBACKS_GUIDE_URL } from \"./legacy-callback-warning.js\";\n\nconst STRING_TO_AST_DEPRECATION =\n \"stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR \" +\n `callback (irCallbacks: true) instead: ${IR_CALLBACKS_GUIDE_URL}`;\n\n/**\n * Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so\n * it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Emits a Node.js\n * `DeprecationWarning` (`OPENAPI_TYPESAFE_DEP_STRING_TO_AST`) on the first call only.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.\n */\nexport function stringToAST(source: string): unknown[] {\n defaultDeprecationReporter().report(\n DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_STRING_TO_AST,\n STRING_TO_AST_DEPRECATION,\n );\n return [...parseStatements(loadTypeScript(), source)];\n}\n"],"names":["IR_CALLBACKS_GUIDE_URL","defaultDeprecationReporter","DEPRECATION_CODES","parseStatements","loadTypeScript"],"mappings":";;;;;;;;AAMA,MAAM,yBAAA,GACJ,gIACyCA,4CAAsB,CAAA,CAAA;AAQ1D,SAAS,YAAY,MAAA,EAA2B;AACrD,EAAAC,uCAAA,EAA2B,CAAE,MAAA;AAAA,IAC3BC,8BAAA,CAAkB,kCAAA;AAAA,IAClB;AAAA,GACF;AACA,EAAA,OAAO,CAAC,GAAGC,0CAAA,CAAgBC,6BAAA,EAAe,EAAG,MAAM,CAAC,CAAA;AACtD;;"}
@@ -1,18 +1,17 @@
1
- import { deprecate } from 'node:util';
2
1
  import { parseStatements } from '../adapters/type-ast-bridge/ir-declarations-to-typescript.mjs';
3
2
  import { loadTypeScript } from '../adapters/type-ast-bridge/load-typescript.mjs';
3
+ import { DEPRECATION_CODES } from '../domain/deprecations.mjs';
4
+ import { defaultDeprecationReporter } from './default-ports.mjs';
4
5
  import { IR_CALLBACKS_GUIDE_URL } from './legacy-callback-warning.mjs';
5
6
 
6
7
  const STRING_TO_AST_DEPRECATION = `stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR callback (irCallbacks: true) instead: ${IR_CALLBACKS_GUIDE_URL}`;
7
- const STRING_TO_AST_DEPRECATION_CODE = "OPENAPI_TYPESAFE_DEP_STRING_TO_AST";
8
- function parseSource(source) {
8
+ function stringToAST(source) {
9
+ defaultDeprecationReporter().report(
10
+ DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_STRING_TO_AST,
11
+ STRING_TO_AST_DEPRECATION
12
+ );
9
13
  return [...parseStatements(loadTypeScript(), source)];
10
14
  }
11
- const stringToAST = deprecate(
12
- parseSource,
13
- STRING_TO_AST_DEPRECATION,
14
- STRING_TO_AST_DEPRECATION_CODE
15
- );
16
15
 
17
- export { STRING_TO_AST_DEPRECATION_CODE, stringToAST };
16
+ export { stringToAST };
18
17
  //# sourceMappingURL=string-to-ast.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"string-to-ast.mjs","sources":["../../src/api/string-to-ast.ts"],"sourcesContent":["import { deprecate } from \"node:util\";\nimport { parseStatements } from \"../adapters/type-ast-bridge/ir-declarations-to-typescript.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport { IR_CALLBACKS_GUIDE_URL } from \"./legacy-callback-warning.js\";\n\nconst STRING_TO_AST_DEPRECATION =\n \"stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR \" +\n `callback (irCallbacks: true) instead: ${IR_CALLBACKS_GUIDE_URL}`;\n\n/** Node's deprecation code for `stringToAST`, so users can filter or trace the warning. */\nexport const STRING_TO_AST_DEPRECATION_CODE = \"OPENAPI_TYPESAFE_DEP_STRING_TO_AST\";\n\nfunction parseSource(source: string): unknown[] {\n return [...parseStatements(loadTypeScript(), source)];\n}\n\n/**\n * Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so\n * it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Node's `util.deprecate` warns\n * on the first call only.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.\n */\nexport const stringToAST: (source: string) => unknown[] = deprecate(\n parseSource,\n STRING_TO_AST_DEPRECATION,\n STRING_TO_AST_DEPRECATION_CODE,\n);\n"],"names":[],"mappings":";;;;;AAKA,MAAM,yBAAA,GACJ,gIACyC,sBAAsB,CAAA,CAAA;AAG1D,MAAM,8BAAA,GAAiC;AAE9C,SAAS,YAAY,MAAA,EAA2B;AAC9C,EAAA,OAAO,CAAC,GAAG,eAAA,CAAgB,cAAA,EAAe,EAAG,MAAM,CAAC,CAAA;AACtD;AAQO,MAAM,WAAA,GAA6C,SAAA;AAAA,EACxD,WAAA;AAAA,EACA,yBAAA;AAAA,EACA;AACF;;"}
1
+ {"version":3,"file":"string-to-ast.mjs","sources":["../../src/api/string-to-ast.ts"],"sourcesContent":["import { parseStatements } from \"../adapters/type-ast-bridge/ir-declarations-to-typescript.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport { DEPRECATION_CODES } from \"../domain/deprecations.js\";\nimport { defaultDeprecationReporter } from \"./default-ports.js\";\nimport { IR_CALLBACKS_GUIDE_URL } from \"./legacy-callback-warning.js\";\n\nconst STRING_TO_AST_DEPRECATION =\n \"stringToAST() is deprecated and removed in 2.0. Return TypeScript type text from an IR \" +\n `callback (irCallbacks: true) instead: ${IR_CALLBACKS_GUIDE_URL}`;\n\n/**\n * Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so\n * it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Emits a Node.js\n * `DeprecationWarning` (`OPENAPI_TYPESAFE_DEP_STRING_TO_AST`) on the first call only.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.\n */\nexport function stringToAST(source: string): unknown[] {\n defaultDeprecationReporter().report(\n DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_STRING_TO_AST,\n STRING_TO_AST_DEPRECATION,\n );\n return [...parseStatements(loadTypeScript(), source)];\n}\n"],"names":[],"mappings":";;;;;;AAMA,MAAM,yBAAA,GACJ,gIACyC,sBAAsB,CAAA,CAAA;AAQ1D,SAAS,YAAY,MAAA,EAA2B;AACrD,EAAA,0BAAA,EAA2B,CAAE,MAAA;AAAA,IAC3B,iBAAA,CAAkB,kCAAA;AAAA,IAClB;AAAA,GACF;AACA,EAAA,OAAO,CAAC,GAAG,eAAA,CAAgB,cAAA,EAAe,EAAG,MAAM,CAAC,CAAA;AACtD;;"}
@@ -25,7 +25,7 @@ function transformOptions(ctx) {
25
25
  additionalProperties: ctx.additionalProperties,
26
26
  alphabetize: ctx.alphabetize,
27
27
  arrayLength: ctx.arrayLength,
28
- binaryAsBlob: ctx.binaryAsBlob,
28
+ binaryAsBlob: ctx.binaryAsBlob ?? false,
29
29
  conditionalEnums: ctx.conditionalEnums,
30
30
  dedupeEnums: ctx.dedupeEnums,
31
31
  defaultNonNullable: ctx.defaultNonNullable,
@@ -1 +1 @@
1
- {"version":3,"file":"transform-context.cjs","sources":["../../src/api/transform-context.ts"],"sourcesContent":["import * as changeCase from \"change-case\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport type {\n DiscriminatorEnumParent,\n SchemaLocation,\n} from \"../application/transform/schema/schema-context.js\";\nimport type {\n DocumentFooter,\n NameCasing,\n TransformContext,\n TransformDiagnostics,\n TransformOptions,\n} from \"../application/transform/transform-context.js\";\nimport type { GlobalContext, TransformNodeOptions } from \"../types.js\";\nimport { defaultLogger, monotonicNow } from \"./default-ports.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport { schemaCallbacks } from \"./schema-callbacks.js\";\n\n/**\n * Builds the ported transformers' context from the original `GlobalContext`: options, refs,\n * discriminators, the run footer and the user callbacks (see `schema-callbacks.ts`).\n */\n\nfunction transformOptions(ctx: GlobalContext): TransformOptions {\n return {\n additionalProperties: ctx.additionalProperties,\n alphabetize: ctx.alphabetize,\n arrayLength: ctx.arrayLength,\n binaryAsBlob: ctx.binaryAsBlob,\n conditionalEnums: ctx.conditionalEnums,\n dedupeEnums: ctx.dedupeEnums,\n defaultNonNullable: ctx.defaultNonNullable,\n emptyObjectsUnknown: ctx.emptyObjectsUnknown,\n enum: ctx.enum,\n enumValues: ctx.enumValues,\n excludeDeprecated: ctx.excludeDeprecated,\n fixes: new Set(ctx.fix ?? []),\n immutable: ctx.immutable,\n propertiesRequiredByDefault: ctx.propertiesRequiredByDefault,\n readWriteMarkers: ctx.readWriteMarkers,\n generatePathParams: ctx.generatePathParams,\n pathParamsAsTypes: ctx.pathParamsAsTypes,\n rootTypes: ctx.rootTypes,\n rootTypesNoSchemaPrefix: ctx.rootTypesNoSchemaPrefix,\n rootTypesKeepCasing: ctx.rootTypesKeepCasing,\n exportType: ctx.exportType,\n inject: ctx.inject,\n makePathsEnum: ctx.makePathsEnum,\n };\n}\n\n/** One footer per run: it holds the enum registry, so it lives on the run's context. */\nfunction runFooter(ctx: GlobalContext): DocumentFooter {\n ctx.runFooter ??= new RunFooter(new ContextFooterSink(ctx.injectFooter), ctx.dedupeEnums);\n return ctx.runFooter;\n}\n\nconst CASING: NameCasing = { pascalCase: (text) => changeCase.pascalCase(text) };\n\n/**\n * A monotonic clock and the run's logger (the default one for a user's own context), \"ts\" group.\n */\nfunction diagnostics(ctx: GlobalContext): TransformDiagnostics {\n const logger = ctx.logger ?? defaultLogger(ctx.silent);\n return {\n now: monotonicNow,\n debug: (message, durationMs) => logger.debug(message, \"ts\", durationMs),\n };\n}\n\n/** The ported transformers' context for one call from a legacy transformer. */\nexport function createTransformContext(ctx: GlobalContext): TransformContext {\n return {\n options: transformOptions(ctx),\n refs: { resolve: (ref) => ctx.resolve(ref) },\n discriminators: {\n objectAt: (ref) => ctx.discriminators.objects[ref],\n isHandled: (ref) => ctx.discriminators.refsHandled.includes(ref),\n otherPropertiesAt: (ref) => ctx.discriminators.otherProperties?.[ref] ?? [],\n enumParentOf: (schema) =>\n ctx.discriminators.enumParents?.get(schema) as DiscriminatorEnumParent | undefined,\n },\n footer: runFooter(ctx),\n callbacks: schemaCallbacks(ctx),\n diagnostics: diagnostics(ctx),\n casing: CASING,\n };\n}\n\n/** The transformer's location for the original options object. */\nexport function schemaLocation(options: TransformNodeOptions): SchemaLocation {\n return { path: options.path, schema: options.schema };\n}\n"],"names":["RunFooter","ContextFooterSink","changeCase","defaultLogger","monotonicNow","schemaCallbacks"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAS,iBAAiB,GAAA,EAAsC;AAC9D,EAAA,OAAO;AAAA,IACL,sBAAsB,GAAA,CAAI,oBAAA;AAAA,IAC1B,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,cAAc,GAAA,CAAI,YAAA;AAAA,IAClB,kBAAkB,GAAA,CAAI,gBAAA;AAAA,IACtB,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,oBAAoB,GAAA,CAAI,kBAAA;AAAA,IACxB,qBAAqB,GAAA,CAAI,mBAAA;AAAA,IACzB,MAAM,GAAA,CAAI,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EAAS,iBAAiB,GAAG,CAAA;AAAA,IAC7B,IAAA,EAAM,EAAE,OAAA,EAAS,CAAC,QAAQ,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAA,EAAE;AAAA,IAC3C,cAAA,EAAgB;AAAA,MACd,UAAU,CAAC,GAAA,KAAQ,GAAA,CAAI,cAAA,CAAe,QAAQ,GAAG,CAAA;AAAA,MACjD,WAAW,CAAC,GAAA,KAAQ,IAAI,cAAA,CAAe,WAAA,CAAY,SAAS,GAAG,CAAA;AAAA,MAC/D,iBAAA,EAAmB,CAAC,GAAA,KAAQ,GAAA,CAAI,eAAe,eAAA,GAAkB,GAAG,KAAK,EAAC;AAAA,MAC1E,cAAc,CAAC,MAAA,KACb,IAAI,cAAA,CAAe,WAAA,EAAa,IAAI,MAAM;AAAA,KAC9C;AAAA,IACA,MAAA,EAAQ,UAAU,GAAG,CAAA;AAAA,IACrB,SAAA,EAAWC,gCAAgB,GAAG,CAAA;AAAA,IAC9B,WAAA,EAAa,YAAY,GAAG,CAAA;AAAA,IAC5B,MAAA,EAAQ;AAAA,GACV;AACF;AAGO,SAAS,eAAe,OAAA,EAA+C;AAC5E,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,CAAQ,IAAA,EAAM,MAAA,EAAQ,QAAQ,MAAA,EAAO;AACtD;;;"}
1
+ {"version":3,"file":"transform-context.cjs","sources":["../../src/api/transform-context.ts"],"sourcesContent":["import * as changeCase from \"change-case\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport type {\n DiscriminatorEnumParent,\n SchemaLocation,\n} from \"../application/transform/schema/schema-context.js\";\nimport type {\n DocumentFooter,\n NameCasing,\n TransformContext,\n TransformDiagnostics,\n TransformOptions,\n} from \"../application/transform/transform-context.js\";\nimport type { TransformNodeOptions } from \"../types.js\";\nimport { defaultLogger, monotonicNow } from \"./default-ports.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { schemaCallbacks } from \"./schema-callbacks.js\";\n\n/**\n * Builds the ported transformers' context from the original `GlobalContext` (in a run, a\n * `RunContext`): options, refs, discriminators, the run footer and the user callbacks (see\n * `schema-callbacks.ts`).\n */\n\nfunction transformOptions(ctx: RunContext): TransformOptions {\n return {\n additionalProperties: ctx.additionalProperties,\n alphabetize: ctx.alphabetize,\n arrayLength: ctx.arrayLength,\n binaryAsBlob: ctx.binaryAsBlob ?? false,\n conditionalEnums: ctx.conditionalEnums,\n dedupeEnums: ctx.dedupeEnums,\n defaultNonNullable: ctx.defaultNonNullable,\n emptyObjectsUnknown: ctx.emptyObjectsUnknown,\n enum: ctx.enum,\n enumValues: ctx.enumValues,\n excludeDeprecated: ctx.excludeDeprecated,\n fixes: new Set(ctx.fix ?? []),\n immutable: ctx.immutable,\n propertiesRequiredByDefault: ctx.propertiesRequiredByDefault,\n readWriteMarkers: ctx.readWriteMarkers,\n generatePathParams: ctx.generatePathParams,\n pathParamsAsTypes: ctx.pathParamsAsTypes,\n rootTypes: ctx.rootTypes,\n rootTypesNoSchemaPrefix: ctx.rootTypesNoSchemaPrefix,\n rootTypesKeepCasing: ctx.rootTypesKeepCasing,\n exportType: ctx.exportType,\n inject: ctx.inject,\n makePathsEnum: ctx.makePathsEnum,\n };\n}\n\n/** One footer per run: it holds the enum registry, so it lives on the run's context. */\nfunction runFooter(ctx: RunContext): DocumentFooter {\n ctx.runFooter ??= new RunFooter(new ContextFooterSink(ctx.injectFooter), ctx.dedupeEnums);\n return ctx.runFooter;\n}\n\nconst CASING: NameCasing = { pascalCase: (text) => changeCase.pascalCase(text) };\n\n/**\n * A monotonic clock and the run's logger (the default one for a user's own context), \"ts\" group.\n */\nfunction diagnostics(ctx: RunContext): TransformDiagnostics {\n const logger = ctx.logger ?? defaultLogger(ctx.silent);\n return {\n now: monotonicNow,\n debug: (message, durationMs) => logger.debug(message, \"ts\", durationMs),\n };\n}\n\n/** The ported transformers' context for one call from a legacy transformer. */\nexport function createTransformContext(ctx: RunContext): TransformContext {\n return {\n options: transformOptions(ctx),\n refs: { resolve: (ref) => ctx.resolve(ref) },\n discriminators: {\n objectAt: (ref) => ctx.discriminators.objects[ref],\n isHandled: (ref) => ctx.discriminators.refsHandled.includes(ref),\n otherPropertiesAt: (ref) => ctx.discriminators.otherProperties?.[ref] ?? [],\n enumParentOf: (schema) =>\n ctx.discriminators.enumParents?.get(schema) as DiscriminatorEnumParent | undefined,\n },\n footer: runFooter(ctx),\n callbacks: schemaCallbacks(ctx),\n diagnostics: diagnostics(ctx),\n casing: CASING,\n };\n}\n\n/** The transformer's location for the original options object. */\nexport function schemaLocation(options: TransformNodeOptions): SchemaLocation {\n return { path: options.path, schema: options.schema };\n}\n"],"names":["RunFooter","ContextFooterSink","changeCase","defaultLogger","monotonicNow","schemaCallbacks"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAS,iBAAiB,GAAA,EAAmC;AAC3D,EAAA,OAAO;AAAA,IACL,sBAAsB,GAAA,CAAI,oBAAA;AAAA,IAC1B,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,YAAA,EAAc,IAAI,YAAA,IAAgB,KAAA;AAAA,IAClC,kBAAkB,GAAA,CAAI,gBAAA;AAAA,IACtB,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,oBAAoB,GAAA,CAAI,kBAAA;AAAA,IACxB,qBAAqB,GAAA,CAAI,mBAAA;AAAA,IACzB,MAAM,GAAA,CAAI,IAAA;AAAA,IACV,YAAY,GAAA,CAAI,UAAA;AAAA,IAChB,mBAAmB,GAAA,CAAI,iBAAA;AAAA,IACvB,OAAO,IAAI,GAAA,CAAI,GAAA,CAAI,GAAA,IAAO,EAAE,CAAA;AAAA,IAC5B,WAAW,GAAA,CAAI,SAAA;AAAA,IACf,6BAA6B,GAAA,CAAI,2BAAA;AAAA,IACjC,kBAAkB,GAAA,CAAI,gBAAA;AAAA,IACtB,oBAAoB,GAAA,CAAI,kBAAA;AA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CAAA;AAAA,MAC/D,iBAAA,EAAmB,CAAC,GAAA,KAAQ,GAAA,CAAI,eAAe,eAAA,GAAkB,GAAG,KAAK,EAAC;AAAA,MAC1E,cAAc,CAAC,MAAA,KACb,IAAI,cAAA,CAAe,WAAA,EAAa,IAAI,MAAM;AAAA,KAC9C;AAAA,IACA,MAAA,EAAQ,UAAU,GAAG,CAAA;AAAA,IACrB,SAAA,EAAWC,gCAAgB,GAAG,CAAA;AAAA,IAC9B,WAAA,EAAa,YAAY,GAAG,CAAA;AAAA,IAC5B,MAAA,EAAQ;AAAA,GACV;AACF;AAGO,SAAS,eAAe,OAAA,EAA+C;AAC5E,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,CAAQ,IAAA,EAAM,MAAA,EAAQ,QAAQ,MAAA,EAAO;AACtD;;;"}
@@ -9,7 +9,7 @@ function transformOptions(ctx) {
9
9
  additionalProperties: ctx.additionalProperties,
10
10
  alphabetize: ctx.alphabetize,
11
11
  arrayLength: ctx.arrayLength,
12
- binaryAsBlob: ctx.binaryAsBlob,
12
+ binaryAsBlob: ctx.binaryAsBlob ?? false,
13
13
  conditionalEnums: ctx.conditionalEnums,
14
14
  dedupeEnums: ctx.dedupeEnums,
15
15
  defaultNonNullable: ctx.defaultNonNullable,
@@ -1 +1 @@
1
- {"version":3,"file":"transform-context.mjs","sources":["../../src/api/transform-context.ts"],"sourcesContent":["import * as changeCase from \"change-case\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport type {\n DiscriminatorEnumParent,\n SchemaLocation,\n} from \"../application/transform/schema/schema-context.js\";\nimport type {\n DocumentFooter,\n NameCasing,\n TransformContext,\n TransformDiagnostics,\n TransformOptions,\n} from \"../application/transform/transform-context.js\";\nimport type { GlobalContext, TransformNodeOptions } from \"../types.js\";\nimport { defaultLogger, monotonicNow } from \"./default-ports.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport { schemaCallbacks } from \"./schema-callbacks.js\";\n\n/**\n * Builds the ported transformers' context from the original `GlobalContext`: options, refs,\n * discriminators, the run footer and the user callbacks (see `schema-callbacks.ts`).\n */\n\nfunction transformOptions(ctx: GlobalContext): TransformOptions {\n return {\n additionalProperties: ctx.additionalProperties,\n alphabetize: ctx.alphabetize,\n arrayLength: ctx.arrayLength,\n binaryAsBlob: ctx.binaryAsBlob,\n conditionalEnums: ctx.conditionalEnums,\n dedupeEnums: ctx.dedupeEnums,\n defaultNonNullable: ctx.defaultNonNullable,\n emptyObjectsUnknown: ctx.emptyObjectsUnknown,\n enum: ctx.enum,\n enumValues: ctx.enumValues,\n excludeDeprecated: ctx.excludeDeprecated,\n fixes: new Set(ctx.fix ?? []),\n immutable: ctx.immutable,\n propertiesRequiredByDefault: ctx.propertiesRequiredByDefault,\n readWriteMarkers: ctx.readWriteMarkers,\n generatePathParams: ctx.generatePathParams,\n pathParamsAsTypes: ctx.pathParamsAsTypes,\n rootTypes: ctx.rootTypes,\n rootTypesNoSchemaPrefix: ctx.rootTypesNoSchemaPrefix,\n rootTypesKeepCasing: ctx.rootTypesKeepCasing,\n exportType: ctx.exportType,\n inject: ctx.inject,\n makePathsEnum: ctx.makePathsEnum,\n };\n}\n\n/** One footer per run: it holds the enum registry, so it lives on the run's context. */\nfunction runFooter(ctx: GlobalContext): DocumentFooter {\n ctx.runFooter ??= new RunFooter(new ContextFooterSink(ctx.injectFooter), ctx.dedupeEnums);\n return ctx.runFooter;\n}\n\nconst CASING: NameCasing = { pascalCase: (text) => changeCase.pascalCase(text) };\n\n/**\n * A monotonic clock and the run's logger (the default one for a user's own context), \"ts\" group.\n */\nfunction diagnostics(ctx: GlobalContext): TransformDiagnostics {\n const logger = ctx.logger ?? defaultLogger(ctx.silent);\n return {\n now: monotonicNow,\n debug: (message, durationMs) => logger.debug(message, \"ts\", durationMs),\n };\n}\n\n/** The ported transformers' context for one call from a legacy transformer. */\nexport function createTransformContext(ctx: GlobalContext): TransformContext {\n return {\n options: transformOptions(ctx),\n refs: { resolve: (ref) => ctx.resolve(ref) },\n discriminators: {\n objectAt: (ref) => ctx.discriminators.objects[ref],\n isHandled: (ref) => ctx.discriminators.refsHandled.includes(ref),\n otherPropertiesAt: (ref) => ctx.discriminators.otherProperties?.[ref] ?? [],\n enumParentOf: (schema) =>\n ctx.discriminators.enumParents?.get(schema) as DiscriminatorEnumParent | undefined,\n },\n footer: runFooter(ctx),\n callbacks: schemaCallbacks(ctx),\n diagnostics: diagnostics(ctx),\n casing: CASING,\n };\n}\n\n/** The transformer's location for the original options object. */\nexport function schemaLocation(options: TransformNodeOptions): SchemaLocation {\n return { path: options.path, schema: options.schema };\n}\n"],"names":[],"mappings":";;;;;;AAuBA,SAAS,iBAAiB,GAAA,EAAsC;AAC9D,EAAA,OAAO;AAAA,IACL,sBAAsB,GAAA,CAAI,oBAAA;AAAA,IAC1B,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,cAAc,GAAA,CAAI,YAAA;AAAA,IAClB,kBAAkB,GAAA,CAAI,gBAAA;AAAA,IACtB,aAAa,GAAA,CAAI,WAAA;AAAA,IACjB,oBAAoB,GAAA,CAAI,kBAAA;AAAA,IACxB,qBAAqB,GAAA,CAAI,mBAAA;AAAA,IACzB,MAAM,GAAA,CAAI,IAAA;AAAA,IACV,YAAY,GAAA,CAAI,UAAA;AAAA,IAChB,mBAAmB,GAAA,CAAI,iBAAA;AAAA,IACvB,OAAO,IAAI,GAAA,CAAI,GAAA,CAAI,GAAA,IAAO,EAAE,CAAA;AAAA,IAC5B,WAAW,GAAA,CAAI,SAAA;AAAA,IACf,6BAA6B,GAAA,CAAI,2BAAA;AAAA,IACjC,kBAAkB,GAAA,CAAI,gBAAA;AAAA,IACtB,oBAAoB,GAAA,CAAI,kBAAA;AAAA,IACxB,mBAAmB,GAAA,CAAI,iBAAA;AAAA,IACvB,WAAW,GAAA,CAAI,SAAA;AAAA,IACf,yBAAyB,GAAA,CAAI,uBAAA;AAAA,IAC7B,qBAAqB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AI,cAAA,CAAe,WAAA,EAAa,IAAI,MAAM;AAAA,KAC9C;AAAA,IACA,MAAA,EAAQ,UAAU,GAAG,CAAA;AAAA,IACrB,SAAA,EAAW,gBAAgB,GAAG,CAAA;AAAA,IAC9B,WAAA,EAAa,YAAY,GAAG,CAAA;AAAA,IAC5B,MAAA,EAAQ;AAAA,GACV;AACF;AAGO,SAAS,eAAe,OAAA,EAA+C;AAC5E,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,CAAQ,IAAA,EAAM,MAAA,EAAQ,QAAQ,MAAA,EAAO;AACtD;;"}
1
+ {"version":3,"file":"transform-context.mjs","sources":["../../src/api/transform-context.ts"],"sourcesContent":["import * as changeCase from \"change-case\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport type {\n DiscriminatorEnumParent,\n SchemaLocation,\n} from \"../application/transform/schema/schema-context.js\";\nimport type {\n DocumentFooter,\n NameCasing,\n TransformContext,\n TransformDiagnostics,\n TransformOptions,\n} from \"../application/transform/transform-context.js\";\nimport type { TransformNodeOptions } from \"../types.js\";\nimport { defaultLogger, monotonicNow } from \"./default-ports.js\";\nimport { ContextFooterSink } from \"./footer-sink.js\";\nimport type { RunContext } from \"./run-context.js\";\nimport { schemaCallbacks } from \"./schema-callbacks.js\";\n\n/**\n * Builds the ported transformers' context from the original `GlobalContext` (in a run, a\n * `RunContext`): options, refs, discriminators, the run footer and the user callbacks (see\n * `schema-callbacks.ts`).\n */\n\nfunction transformOptions(ctx: RunContext): TransformOptions {\n return {\n additionalProperties: ctx.additionalProperties,\n alphabetize: ctx.alphabetize,\n arrayLength: ctx.arrayLength,\n binaryAsBlob: ctx.binaryAsBlob ?? false,\n conditionalEnums: ctx.conditionalEnums,\n dedupeEnums: ctx.dedupeEnums,\n defaultNonNullable: ctx.defaultNonNullable,\n emptyObjectsUnknown: ctx.emptyObjectsUnknown,\n enum: ctx.enum,\n enumValues: ctx.enumValues,\n excludeDeprecated: ctx.excludeDeprecated,\n fixes: new Set(ctx.fix ?? []),\n immutable: ctx.immutable,\n propertiesRequiredByDefault: ctx.propertiesRequiredByDefault,\n readWriteMarkers: ctx.readWriteMarkers,\n generatePathParams: ctx.generatePathParams,\n pathParamsAsTypes: ctx.pathParamsAsTypes,\n rootTypes: ctx.rootTypes,\n rootTypesNoSchemaPrefix: ctx.rootTypesNoSchemaPrefix,\n rootTypesKeepCasing: ctx.rootTypesKeepCasing,\n exportType: ctx.exportType,\n inject: ctx.inject,\n makePathsEnum: ctx.makePathsEnum,\n };\n}\n\n/** One footer per run: it holds the enum registry, so it lives on the run's context. */\nfunction runFooter(ctx: RunContext): DocumentFooter {\n ctx.runFooter ??= new RunFooter(new ContextFooterSink(ctx.injectFooter), ctx.dedupeEnums);\n return ctx.runFooter;\n}\n\nconst CASING: NameCasing = { pascalCase: (text) => changeCase.pascalCase(text) };\n\n/**\n * A monotonic clock and the run's logger (the default one for a user's own context), \"ts\" group.\n */\nfunction diagnostics(ctx: RunContext): TransformDiagnostics {\n const logger = ctx.logger ?? defaultLogger(ctx.silent);\n return {\n now: monotonicNow,\n debug: (message, durationMs) => logger.debug(message, \"ts\", durationMs),\n };\n}\n\n/** The ported transformers' context for one call from a legacy transformer. */\nexport function createTransformContext(ctx: RunContext): TransformContext {\n return {\n options: transformOptions(ctx),\n refs: { resolve: (ref) => ctx.resolve(ref) },\n discriminators: {\n objectAt: (ref) => ctx.discriminators.objects[ref],\n isHandled: (ref) => ctx.discriminators.refsHandled.includes(ref),\n otherPropertiesAt: (ref) => ctx.discriminators.otherProperties?.[ref] ?? [],\n enumParentOf: (schema) =>\n ctx.discriminators.enumParents?.get(schema) as DiscriminatorEnumParent | undefined,\n },\n footer: runFooter(ctx),\n callbacks: schemaCallbacks(ctx),\n diagnostics: diagnostics(ctx),\n casing: CASING,\n };\n}\n\n/** The transformer's location for the original options object. */\nexport function schemaLocation(options: TransformNodeOptions): SchemaLocation {\n return { path: options.path, schema: options.schema };\n}\n"],"names":[],"mappings":";;;;;;AAyB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f(document$1, ctx, recorder) {
36
36
  return recorder.chosenNames();
37
37
  }
38
38
  function enumNameRecorderOf(ctx) {
39
- if (ctx.fix?.includes(outputFixes.OutputFix.DEDUPE_ENUM_NAMES)) {
39
+ if (ctx.fix?.includes(outputFixes.FIX.DEDUPE_ENUM_NAMES)) {
40
40
  return new sharedEnumNames.SharedEnumNameRecorder();
41
41
  }
42
- return ctx.fix?.includes(outputFixes.OutputFix.DISCRIMINATOR_VALUES) ? new discriminatorEnumNames.FirstSchemaNameRecorder() : null;
42
+ return ctx.fix?.includes(outputFixes.FIX.DISCRIMINATOR_VALUES) ? new discriminatorEnumNames.FirstSchemaNameRecorder() : null;
43
43
  }
44
44
  function withSharedEnumNames(document, ctx) {
45
45
  const recorder = ctx.runFooter === void 0 ? enumNameRecorderOf(ctx) : null;
@@ -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 { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport {\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 { OutputFix } 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 { 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: GlobalContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: GlobalContext = {\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(OutputFix.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(OutputFix.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/** With a naming fix, `--enum` and `--dedupe-enums`, the run's footer names shared enums. */\nfunction withSharedEnumNames(document: DocumentObject, ctx: GlobalContext): void {\n const recorder = ctx.runFooter === undefined ? enumNameRecorderOf(ctx) : null;\n if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {\n return;\n }\n const names = sharedEnumNamesOf(document, ctx, recorder);\n ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);\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: GlobalContext,\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: GlobalContext): TransformedDocument {\n const document = schema as DocumentObject;\n withSharedEnumNames(document, ctx);\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 footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const closing = documentClosing(document, context, footer.some(isOperations));\n const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);\n return { body, footer, closing };\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","OutputFix","SharedEnumNameRecorder","FirstSchemaNameRecorder","checkedEnumValues","excludedValuesWarning","documentClosing","renameTakenAliases","documentDeclarations"],"mappings":";;;;;;;;;;;;;;;;;AAo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OAAA,EAAS,CAAC,GAAG,GAAA,CAAI,YAAY,GAAG,GAAG,CAAA;AACpE,EAAA,MAAM,UAAUW,wBAAA,CAAgBV,UAAA,EAAU,SAAS,MAAA,CAAO,IAAA,CAAK,YAAY,CAAC,CAAA;AAC5E,EAAA,MAAM,OAAOW,kCAAA,CAAmB,OAAA,EAAS,OAAO,MAAA,CAAOZ,2BAAe,GAAG,OAAO,CAAA;AAChF,EAAA,OAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAQ;AACjC;AAMA,SAAwB,eAAA,CAAgB,QAAkB,GAAA,EAAqC;AAC7F,EAAA,OAAOa,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 { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport {\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 { 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/** With a naming fix, `--enum` and `--dedupe-enums`, the run's footer names shared enums. */\nfunction withSharedEnumNames(document: DocumentObject, ctx: RunContext): void {\n const recorder = ctx.runFooter === undefined ? enumNameRecorderOf(ctx) : null;\n if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {\n return;\n }\n const names = sharedEnumNamesOf(document, ctx, recorder);\n ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);\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 withSharedEnumNames(document, ctx);\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 footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const closing = documentClosing(document, context, footer.some(isOperations));\n const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);\n return { body, footer, closing };\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","checkedEnumValues","excludedValuesWarning","documentClosing","renameTakenAliases","documentDeclarations"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,a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,GAAG,CAAA;AACpE,EAAA,MAAM,UAAUW,wBAAA,CAAgBV,UAAA,EAAU,SAAS,MAAA,CAAO,IAAA,CAAK,YAAY,CAAC,CAAA;AAC5E,EAAA,MAAM,OAAOW,kCAAA,CAAmB,OAAA,EAAS,OAAO,MAAA,CAAOZ,2BAAe,GAAG,OAAO,CAAA;AAChF,EAAA,OAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAQ;AACjC;AAMA,SAAwB,eAAA,CAAgB,QAAkB,GAAA,EAAqC;AAC7F,EAAA,OAAOa,yCAAA,CAAqB,iBAAA,CAAkB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC5D;;;"}
@@ -3,7 +3,7 @@ import { renameTakenAliases } from '../application/transform/document/root-type-
3
3
  import { RunFooter } from '../application/transform/footer/document-footer.mjs';
4
4
  import { checkedEnumValues } from '../application/transform/footer/enum-values-check.mjs';
5
5
  import { SharedEnumNameRecorder } from '../application/transform/footer/shared-enum-names.mjs';
6
- import { OutputFix } from '../domain/output-fixes.mjs';
6
+ import { FIX } from '../domain/output-fixes.mjs';
7
7
  import { FirstSchemaNameRecorder } from './discriminator-enum-names.mjs';
8
8
  import { documentDeclarations } from './document-declarations.mjs';
9
9
  import { excludedValuesWarning } from './enum-values-warnings.mjs';
@@ -32,10 +32,10 @@ function sharedEnumNamesOf(document, ctx, recorder) {
32
32
  return recorder.chosenNames();
33
33
  }
34
34
  function enumNameRecorderOf(ctx) {
35
- if (ctx.fix?.includes(OutputFix.DEDUPE_ENUM_NAMES)) {
35
+ if (ctx.fix?.includes(FIX.DEDUPE_ENUM_NAMES)) {
36
36
  return new SharedEnumNameRecorder();
37
37
  }
38
- return ctx.fix?.includes(OutputFix.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;
38
+ return ctx.fix?.includes(FIX.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;
39
39
  }
40
40
  function withSharedEnumNames(document, ctx) {
41
41
  const recorder = ctx.runFooter === void 0 ? enumNameRecorderOf(ctx) : null;
@@ -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 { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport {\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 { OutputFix } 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 { 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: GlobalContext,\n recorder: EnumNameRecorder,\n): SharedEnumNames {\n const injectFooter: FooterEntry[] = [];\n const scratch: GlobalContext = {\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(OutputFix.DEDUPE_ENUM_NAMES)) {\n return new SharedEnumNameRecorder();\n }\n return ctx.fix?.includes(OutputFix.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;\n}\n\n/** With a naming fix, `--enum` and `--dedupe-enums`, the run's footer names shared enums. */\nfunction withSharedEnumNames(document: DocumentObject, ctx: GlobalContext): void {\n const recorder = ctx.runFooter === undefined ? enumNameRecorderOf(ctx) : null;\n if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {\n return;\n }\n const names = sharedEnumNamesOf(document, ctx, recorder);\n ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);\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: GlobalContext,\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: GlobalContext): TransformedDocument {\n const document = schema as DocumentObject;\n withSharedEnumNames(document, ctx);\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 footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const closing = documentClosing(document, context, footer.some(isOperations));\n const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);\n return { body, footer, closing };\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":";;;;;;;;;;;;;AAoBA,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;AAClB;AAGA,MAAM,cAAc,MAAY,MAAA;AAChC,MAAM,mBAAmB,EAAE,KAAA,EAAO,aAAa,IAAA,EAAM,WAAA,EAAa,OAAO,WAAA,EAAY;AAcrF,SAAS,iBAAA,CACP,QAAA,EACA,GAAA,EACA,QAAA,EACiB;AACjB,EAAA,MAAM,eAA8B,EAAC;AACrC,EAAA,MAAM,OAAA,GAAyB;AAAA,IAC7B,GAAG,GAAA;AAAA,IACH,YAAA;AAAA,IACA,SAAA,EAAW,IAAI,SAAA,CAAU,IAAI,kBAAkB,YAAY,CAAA,EAAG,MAAM,QAAQ,CAAA;AAAA,IAC5E,MAAA,EAAQ,gBAA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,QAAQ,OAAA,EAAS;AACpC,IAAA,IAAI,MAAA,CAAO,SAAS,UAAA,EAAY;AAC9B,MAAA,GAAA,CAAI,QAAQ,IAAA,CAAK,qBAAA,CAAsB,OAAO,IAAA,EAAM,MAAA,CAAO,QAAQ,CAAC,CAAA;AAAA,IACtE;AAAA,EACF;AACA,EAAA,OAAO,OAAA,CAAQ,MAAA;AACjB;AAGO,SAAS,iBAAA,CAAkB,QAAkB,GAAA,EAAyC;AAC3F,EAAA,MAAM,QAAA,GAAW,MAAA;AACjB,EAAA,mBAAA,CAAoB,UAAU,GAAG,CAAA;AACjC,EAAA,MAAM,OAAA,GAAU,uBAAuB,GAAG,CAAA;AAE1C,EAAA,MAAM,OAAA,GAAU,aAAa,QAAA,EAAU,OAAA,EAAS,MAAM,GAAA,CAAI,YAAA,CAAa,MAAA,CAAO,eAAe,CAAC,CAAA;AAC9F,EAAA,MAAM,MAAA,GAAS,kBAAkB,OAAA,EAAS,CAAC,GAAG,GAAA,CAAI,YAAY,GAAG,GAAG,CAAA;AACpE,EAAA,MAAM,UAAU,eAAA,CAAgB,QAAA,EAAU,SAAS,MAAA,CAAO,IAAA,CAAK,YAAY,CAAC,CAAA;AAC5E,EAAA,MAAM,OAAO,kBAAA,CAAmB,OAAA,EAAS,OAAO,MAAA,CAAO,eAAe,GAAG,OAAO,CAAA;AAChF,EAAA,OAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAQ;AACjC;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 { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport { RunFooter } from \"../application/transform/footer/document-footer.js\";\nimport { checkedEnumValues } from \"../application/transform/footer/enum-values-check.js\";\nimport {\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 { 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/** With a naming fix, `--enum` and `--dedupe-enums`, the run's footer names shared enums. */\nfunction withSharedEnumNames(document: DocumentObject, ctx: RunContext): void {\n const recorder = ctx.runFooter === undefined ? enumNameRecorderOf(ctx) : null;\n if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {\n return;\n }\n const names = sharedEnumNamesOf(document, ctx, recorder);\n ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);\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 withSharedEnumNames(document, ctx);\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 footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);\n const closing = documentClosing(document, context, footer.some(isOperations));\n const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);\n return { body, footer, closing };\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":";;;;;;;;;;;;;AAqBA,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;AAClB;AAGA,MAAM,cAAc,MAAY,MAAA;AAChC,MAAM,mBAAmB,EAAE,KAAA,EAAO,aAAa,IAAA,EAAM,WAAA,EAAa,OAAO,WAAA,EAAY;AAcrF,SAAS,iBAAA,CACP,QAAA,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,IAAI,SAAA,CAAU,IAAI,kBAAkB,YAAY,CAAA,EAAG,MAAM,QAAQ,CAAA;AAAA,IAC5E,MAAA,EAAQ,gBAAA;AAAA,IACR,sBAAA,sBAA4B,GAAA;AAAI,GAClC;AACA,EAAA,MAAM,cAAA,GAAiB,uBAAuB,OAAO,CAAA;AACrD,EAAA,YAAA,CAAa,UAAU,cAAA,EAAgB,MAAM,YAAA,CAAa,MAAA,CAAO,eAAe,CAAC,CAAA;AACjF,EAAA,OAAO,SAAS,WAAA,EAAY;AAC9B;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AA;AACjB;AAGO,SAAS,iBAAA,CAAkB,QAAkB,GAAA,EAAsC;AACxF,EAAA,MAAM,QAAA,GAAW,MAAA;AACjB,EAAA,mBAAA,CAAoB,UAAU,GAAG,CAAA;AACjC,EAAA,MAAM,OAAA,GAAU,uBAAuB,GAAG,CAAA;AAE1C,EAAA,MAAM,OAAA,GAAU,aAAa,QAAA,EAAU,OAAA,EAAS,MAAM,GAAA,CAAI,YAAA,CAAa,MAAA,CAAO,eAAe,CAAC,CAAA;AAC9F,EAAA,MAAM,MAAA,GAAS,kBAAkB,OAAA,EAAS,CAAC,GAAG,GAAA,CAAI,YAAY,GAAG,GAAG,CAAA;AACpE,EAAA,MAAM,UAAU,eAAA,CAAgB,QAAA,EAAU,SAAS,MAAA,CAAO,IAAA,CAAK,YAAY,CAAC,CAAA;AAC5E,EAAA,MAAM,OAAO,kBAAA,CAAmB,OAAA,EAAS,OAAO,MAAA,CAAO,eAAe,GAAG,OAAO,CAAA;AAChF,EAAA,OAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAQ;AACjC;AAMA,SAAwB,eAAA,CAAgB,QAAkB,GAAA,EAAqC;AAC7F,EAAA,OAAO,oBAAA,CAAqB,iBAAA,CAAkB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAC5D;;"}
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const assertNever = require('../../domain/assert-never.cjs');
4
+ const constructors = require('../../domain/ir/constructors.cjs');
4
5
  const commentWriter = require('./comment-writer.cjs');
5
6
  const literalText = require('./literal-text.cjs');
6
7
 
@@ -139,7 +140,7 @@ function printLeafType(type) {
139
140
  case "keyword":
140
141
  return type.keyword;
141
142
  case "stringLiteral":
142
- return literalText.printStringLiteral(type.value, type.encoding);
143
+ return literalText.printStringLiteral(type.value, type.encoding ?? constructors.DEFAULT_STRING_ENCODING);
143
144
  case "numberLiteral":
144
145
  return literalText.printNumberLiteral(type.value);
145
146
  case "booleanLiteral":
@@ -1 +1 @@
1
- {"version":3,"file":"type-printer.cjs","sources":["../../../src/application/print/type-printer.ts"],"sourcesContent":["import { assertNever } from \"../../domain/assert-never.js\";\nimport type {\n IrIndexedAccessType,\n IrMember,\n IrPropertyName,\n IrRawType,\n IrTupleElement,\n IrType,\n} from \"../../domain/ir/nodes.js\";\nimport { writeLeadingComment } from \"./comment-writer.js\";\nimport { printEscapedString, printNumberLiteral, printStringLiteral } from \"./literal-text.js\";\nimport type { TextWriter } from \"./text-writer.js\";\n\n/**\n * Parenthesization contexts. Each predicate says when a child type needs parentheses; together they\n * reproduce the TypeScript factory's parenthesizer rules for the node kinds of the IR, so output\n * matches the original even when unions are nested (`A | (B | C)`).\n */\nconst isUnionOrIntersection = (type: IrType): boolean =>\n type.kind === \"union\" || type.kind === \"intersection\";\n/** Union and intersection members (`parenthesizeConstituentTypeOf{Union,Intersection}Type`). */\nconst needsParensAsConstituent = isUnionOrIntersection;\n/** Array element and indexed-access object (`parenthesizeNonArrayTypeOfPostfixType`). */\nconst needsParensAsPostfixOperand = (type: IrType): boolean =>\n type.kind === \"readonly\" || isUnionOrIntersection(type);\n/** Operand of `readonly` (`parenthesizeOperandOfReadonlyTypeOperator`). */\nconst needsParensAsReadonlyOperand = needsParensAsPostfixOperand;\n\nfunction writeTypeIn(\n writer: TextWriter,\n type: IrType,\n needsParens: (type: IrType) => boolean,\n): void {\n if (!needsParens(type)) {\n writeType(writer, type);\n return;\n }\n writer.write(\"(\");\n writeType(writer, type);\n writer.write(\")\");\n}\n\n/** Write a single-line list: `separator` between items, nothing for an empty list. */\nfunction writeInlineList<T>(\n writer: TextWriter,\n items: readonly T[],\n separator: string,\n writeItem: (item: T) => void,\n) {\n items.forEach((item, index) => {\n if (index > 0) {\n writer.write(separator);\n }\n writeItem(item);\n });\n}\n\n/**\n * Write a multi-line list the way the TypeScript printer does: a line break after the opening\n * token, one item per indented line, `delimiter` after every item but the last, and a line break\n * before the closing token. An empty list prints the line break only when `isLineBreakWhenEmpty`\n * (interfaces, enums and tuples do; object type literals print `{}`).\n */\nexport function writeMultiLineList<T>(\n writer: TextWriter,\n items: readonly T[],\n format: { readonly delimiter: string; readonly isLineBreakWhenEmpty: boolean },\n writeItem: (item: T) => void,\n): void {\n if (items.length === 0) {\n if (format.isLineBreakWhenEmpty) {\n writer.writeLine();\n }\n return;\n }\n writer.writeLine();\n writer.increaseIndent();\n items.forEach((item, index) => {\n if (index > 0) {\n writer.write(format.delimiter);\n writer.writeLine();\n }\n writeItem(item);\n });\n writer.decreaseIndent();\n writer.writeLine();\n}\n\nfunction writePropertyName(writer: TextWriter, name: IrPropertyName): void {\n switch (name.kind) {\n case \"identifier\":\n case \"number\":\n writer.write(name.text);\n break;\n case \"string\":\n writer.write(printEscapedString(name.value));\n break;\n default:\n assertNever(name);\n }\n}\n\n/**\n * `[name: type]`. TypeScript prints index signature parameters as an indented list, so a multi-line\n * parameter type (an object or tuple) is indented one level deeper than the member.\n */\nfunction writeIndexSignatureParameter(writer: TextWriter, name: string, type: IrType): void {\n writer.write(`[${name}: `);\n writer.increaseIndent();\n writeType(writer, type);\n writer.decreaseIndent();\n writer.write(\"]\");\n}\n\n/** Write one member of an interface or object type, with its comment and trailing semicolon. */\nexport function writeMember(writer: TextWriter, member: IrMember): void {\n for (const comment of member.comments) {\n writeLeadingComment(writer, comment);\n }\n if (member.isReadonly) {\n writer.write(\"readonly \");\n }\n if (member.kind === \"property\") {\n writePropertyName(writer, member.name);\n writer.write(member.isOptional ? \"?: \" : \": \");\n } else {\n writeIndexSignatureParameter(writer, member.parameterName, member.parameterType);\n writer.write(\": \");\n }\n writeType(writer, member.type);\n writer.write(\";\");\n}\n\nfunction writeTupleElement(writer: TextWriter, element: IrTupleElement): void {\n if (element.isRest) {\n writer.write(\"...\");\n }\n if (element.isOptional) {\n // TypeScript parenthesizes an optional element as a postfix operand (`(A | B)?`).\n writeTypeIn(writer, element.type, needsParensAsPostfixOperand);\n writer.write(\"?\");\n return;\n }\n writeType(writer, element.type);\n}\n\nfunction writeObjectType(writer: TextWriter, members: readonly IrMember[]): void {\n writer.write(\"{\");\n writeMultiLineList(writer, members, { delimiter: \"\", isLineBreakWhenEmpty: false }, (member) =>\n writeMember(writer, member),\n );\n writer.write(\"}\");\n}\n\nfunction writeTupleType(writer: TextWriter, elements: readonly IrTupleElement[]): void {\n writer.write(\"[\");\n writeMultiLineList(writer, elements, { delimiter: \",\", isLineBreakWhenEmpty: true }, (element) =>\n writeTupleElement(writer, element),\n );\n writer.write(\"]\");\n}\n\nfunction writeReferenceType(\n writer: TextWriter,\n name: string,\n typeArguments: readonly IrType[],\n): void {\n writer.write(name);\n if (typeArguments.length > 0) {\n writer.write(\"<\");\n writeInlineList(writer, typeArguments, \", \", (argument) => writeType(writer, argument));\n writer.write(\">\");\n }\n}\n\nfunction writeIndexedAccessType(writer: TextWriter, type: IrIndexedAccessType): void {\n writeTypeIn(writer, type.object, needsParensAsPostfixOperand);\n writer.write(\"[\");\n writeType(writer, type.index);\n writer.write(\"]\");\n}\n\nfunction writeConstituents(writer: TextWriter, types: readonly IrType[], separator: string): void {\n writeInlineList(writer, types, separator, (member) =>\n writeTypeIn(writer, member, needsParensAsConstituent),\n );\n}\n\ntype IrLeafType = Extract<\n IrType,\n { kind: \"keyword\" | \"stringLiteral\" | \"numberLiteral\" | \"booleanLiteral\" }\n>;\n\nfunction printLeafType(type: IrLeafType): string {\n switch (type.kind) {\n case \"keyword\":\n return type.keyword;\n case \"stringLiteral\":\n return printStringLiteral(type.value, type.encoding);\n case \"numberLiteral\":\n return printNumberLiteral(type.value);\n case \"booleanLiteral\":\n return String(type.value);\n default:\n return assertNever(type);\n }\n}\n\n/**\n * Raw text is printed as if it started at column 0, so its continuation lines get the current\n * indentation, as the TypeScript printer indents a nested node.\n */\nfunction writeRawType(writer: TextWriter, text: string): void {\n text.split(\"\\n\").forEach((line, index) => {\n if (index > 0) {\n writer.rawWrite(writer.options.newLine);\n }\n writer.write(line);\n });\n}\n\nfunction writeArrayType(writer: TextWriter, element: IrType): void {\n writeTypeIn(writer, element, needsParensAsPostfixOperand);\n writer.write(\"[]\");\n}\n\nfunction writeReadonlyType(writer: TextWriter, operand: IrType): void {\n writer.write(\"readonly \");\n writeTypeIn(writer, operand, needsParensAsReadonlyOperand);\n}\n\ntype IrOperatorType = Extract<IrType, { kind: \"array\" | \"indexedAccess\" | \"readonly\" }>;\n\n/** Types built with a type operator: `T[]`, `T[K]` and `readonly T`. */\nfunction writeOperatorType(writer: TextWriter, type: IrOperatorType): void {\n if (type.kind === \"array\") {\n writeArrayType(writer, type.element);\n } else if (type.kind === \"indexedAccess\") {\n writeIndexedAccessType(writer, type);\n } else {\n writeReadonlyType(writer, type.type);\n }\n}\n\nconst CONSTITUENT_SEPARATORS = { union: \" | \", intersection: \" & \" } as const;\n\n/** A raw type may span lines and is re-indented; any other leaf prints on one line. */\nfunction writeLeafType(writer: TextWriter, type: IrLeafType | IrRawType): void {\n if (type.kind === \"raw\") {\n writeRawType(writer, type.text);\n } else {\n writer.write(printLeafType(type));\n }\n}\n\n/** Write a type at the writer's current position. */\nexport function writeType(writer: TextWriter, type: IrType): void {\n switch (type.kind) {\n case \"keyword\":\n case \"stringLiteral\":\n case \"numberLiteral\":\n case \"booleanLiteral\":\n case \"raw\":\n writeLeafType(writer, type);\n break;\n case \"reference\":\n writeReferenceType(writer, type.name, type.typeArguments);\n break;\n case \"array\":\n case \"indexedAccess\":\n case \"readonly\":\n writeOperatorType(writer, type);\n break;\n case \"union\":\n case \"intersection\":\n writeConstituents(writer, type.types, CONSTITUENT_SEPARATORS[type.kind]);\n break;\n case \"object\":\n writeObjectType(writer, type.members);\n break;\n case \"tuple\":\n writeTupleType(writer, type.elements);\n break;\n default:\n assertNever(type);\n }\n}\n"],"names":["printEscapedString","assertNever","writeLeadingComment","printStringLiteral","printNumberLiteral"],"mappings":";;;;;;AAkBA,MAAM,wBAAwB,CAAC,IAAA,KAC7B,KAAK,IAAA,KAAS,OAAA,IAAW,KAAK,IAAA,KAAS,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s","sources":["../../../src/application/print/type-printer.ts"],"sourcesContent":["import { assertNever } from \"../../domain/assert-never.js\";\nimport { DEFAULT_STRING_ENCODING } from \"../../domain/ir/constructors.js\";\nimport type {\n IrIndexedAccessType,\n IrMember,\n IrPropertyName,\n IrRawType,\n IrTupleElement,\n IrType,\n} from \"../../domain/ir/nodes.js\";\nimport { writeLeadingComment } from \"./comment-writer.js\";\nimport { printEscapedString, printNumberLiteral, printStringLiteral } from \"./literal-text.js\";\nimport type { TextWriter } from \"./text-writer.js\";\n\n/**\n * Parenthesization contexts. Each predicate says when a child type needs parentheses; together they\n * reproduce the TypeScript factory's parenthesizer rules for the node kinds of the IR, so output\n * matches the original even when unions are nested (`A | (B | C)`).\n */\nconst isUnionOrIntersection = (type: IrType): boolean =>\n type.kind === \"union\" || type.kind === \"intersection\";\n/** Union and intersection members (`parenthesizeConstituentTypeOf{Union,Intersection}Type`). */\nconst needsParensAsConstituent = isUnionOrIntersection;\n/** Array element and indexed-access object (`parenthesizeNonArrayTypeOfPostfixType`). */\nconst needsParensAsPostfixOperand = (type: IrType): boolean =>\n type.kind === \"readonly\" || isUnionOrIntersection(type);\n/** Operand of `readonly` (`parenthesizeOperandOfReadonlyTypeOperator`). */\nconst needsParensAsReadonlyOperand = needsParensAsPostfixOperand;\n\nfunction writeTypeIn(\n writer: TextWriter,\n type: IrType,\n needsParens: (type: IrType) => boolean,\n): void {\n if (!needsParens(type)) {\n writeType(writer, type);\n return;\n }\n writer.write(\"(\");\n writeType(writer, type);\n writer.write(\")\");\n}\n\n/** Write a single-line list: `separator` between items, nothing for an empty list. */\nfunction writeInlineList<T>(\n writer: TextWriter,\n items: readonly T[],\n separator: string,\n writeItem: (item: T) => void,\n) {\n items.forEach((item, index) => {\n if (index > 0) {\n writer.write(separator);\n }\n writeItem(item);\n });\n}\n\n/**\n * Write a multi-line list the way the TypeScript printer does: a line break after the opening\n * token, one item per indented line, `delimiter` after every item but the last, and a line break\n * before the closing token. An empty list prints the line break only when `isLineBreakWhenEmpty`\n * (interfaces, enums and tuples do; object type literals print `{}`).\n */\nexport function writeMultiLineList<T>(\n writer: TextWriter,\n items: readonly T[],\n format: { readonly delimiter: string; readonly isLineBreakWhenEmpty: boolean },\n writeItem: (item: T) => void,\n): void {\n if (items.length === 0) {\n if (format.isLineBreakWhenEmpty) {\n writer.writeLine();\n }\n return;\n }\n writer.writeLine();\n writer.increaseIndent();\n items.forEach((item, index) => {\n if (index > 0) {\n writer.write(format.delimiter);\n writer.writeLine();\n }\n writeItem(item);\n });\n writer.decreaseIndent();\n writer.writeLine();\n}\n\nfunction writePropertyName(writer: TextWriter, name: IrPropertyName): void {\n switch (name.kind) {\n case \"identifier\":\n case \"number\":\n writer.write(name.text);\n break;\n case \"string\":\n writer.write(printEscapedString(name.value));\n break;\n default:\n assertNever(name);\n }\n}\n\n/**\n * `[name: type]`. TypeScript prints index signature parameters as an indented list, so a multi-line\n * parameter type (an object or tuple) is indented one level deeper than the member.\n */\nfunction writeIndexSignatureParameter(writer: TextWriter, name: string, type: IrType): void {\n writer.write(`[${name}: `);\n writer.increaseIndent();\n writeType(writer, type);\n writer.decreaseIndent();\n writer.write(\"]\");\n}\n\n/** Write one member of an interface or object type, with its comment and trailing semicolon. */\nexport function writeMember(writer: TextWriter, member: IrMember): void {\n for (const comment of member.comments) {\n writeLeadingComment(writer, comment);\n }\n if (member.isReadonly) {\n writer.write(\"readonly \");\n }\n if (member.kind === \"property\") {\n writePropertyName(writer, member.name);\n writer.write(member.isOptional ? \"?: \" : \": \");\n } else {\n writeIndexSignatureParameter(writer, member.parameterName, member.parameterType);\n writer.write(\": \");\n }\n writeType(writer, member.type);\n writer.write(\";\");\n}\n\nfunction writeTupleElement(writer: TextWriter, element: IrTupleElement): void {\n if (element.isRest) {\n writer.write(\"...\");\n }\n if (element.isOptional) {\n // TypeScript parenthesizes an optional element as a postfix operand (`(A | B)?`).\n writeTypeIn(writer, element.type, needsParensAsPostfixOperand);\n writer.write(\"?\");\n return;\n }\n writeType(writer, element.type);\n}\n\nfunction writeObjectType(writer: TextWriter, members: readonly IrMember[]): void {\n writer.write(\"{\");\n writeMultiLineList(writer, members, { delimiter: \"\", isLineBreakWhenEmpty: false }, (member) =>\n writeMember(writer, member),\n );\n writer.write(\"}\");\n}\n\nfunction writeTupleType(writer: TextWriter, elements: readonly IrTupleElement[]): void {\n writer.write(\"[\");\n writeMultiLineList(writer, elements, { delimiter: \",\", isLineBreakWhenEmpty: true }, (element) =>\n writeTupleElement(writer, element),\n );\n writer.write(\"]\");\n}\n\nfunction writeReferenceType(\n writer: TextWriter,\n name: string,\n typeArguments: readonly IrType[],\n): void {\n writer.write(name);\n if (typeArguments.length > 0) {\n writer.write(\"<\");\n writeInlineList(writer, typeArguments, \", \", (argument) => writeType(writer, argument));\n writer.write(\">\");\n }\n}\n\nfunction writeIndexedAccessType(writer: TextWriter, type: IrIndexedAccessType): void {\n writeTypeIn(writer, type.object, needsParensAsPostfixOperand);\n writer.write(\"[\");\n writeType(writer, type.index);\n writer.write(\"]\");\n}\n\nfunction writeConstituents(writer: TextWriter, types: readonly IrType[], separator: string): void {\n writeInlineList(writer, types, separator, (member) =>\n writeTypeIn(writer, member, needsParensAsConstituent),\n );\n}\n\ntype IrLeafType = Extract<\n IrType,\n { kind: \"keyword\" | \"stringLiteral\" | \"numberLiteral\" | \"booleanLiteral\" }\n>;\n\nfunction printLeafType(type: IrLeafType): string {\n switch (type.kind) {\n case \"keyword\":\n return type.keyword;\n case \"stringLiteral\":\n return printStringLiteral(type.value, type.encoding ?? DEFAULT_STRING_ENCODING);\n case \"numberLiteral\":\n return printNumberLiteral(type.value);\n case \"booleanLiteral\":\n return String(type.value);\n default:\n return assertNever(type);\n }\n}\n\n/**\n * Raw text is printed as if it started at column 0, so its continuation lines get the current\n * indentation, as the TypeScript printer indents a nested node.\n */\nfunction writeRawType(writer: TextWriter, text: string): void {\n text.split(\"\\n\").forEach((line, index) => {\n if (index > 0) {\n writer.rawWrite(writer.options.newLine);\n }\n writer.write(line);\n });\n}\n\nfunction writeArrayType(writer: TextWriter, element: IrType): void {\n writeTypeIn(writer, element, needsParensAsPostfixOperand);\n writer.write(\"[]\");\n}\n\nfunction writeReadonlyType(writer: TextWriter, operand: IrType): void {\n writer.write(\"readonly \");\n writeTypeIn(writer, operand, needsParensAsReadonlyOperand);\n}\n\ntype IrOperatorType = Extract<IrType, { kind: \"array\" | \"indexedAccess\" | \"readonly\" }>;\n\n/** Types built with a type operator: `T[]`, `T[K]` and `readonly T`. */\nfunction writeOperatorType(writer: TextWriter, type: IrOperatorType): void {\n if (type.kind === \"array\") {\n writeArrayType(writer, type.element);\n } else if (type.kind === \"indexedAccess\") {\n writeIndexedAccessType(writer, type);\n } else {\n writeReadonlyType(writer, type.type);\n }\n}\n\nconst CONSTITUENT_SEPARATORS = { union: \" | \", intersection: \" & \" } as const;\n\n/** A raw type may span lines and is re-indented; any other leaf prints on one line. */\nfunction writeLeafType(writer: TextWriter, type: IrLeafType | IrRawType): void {\n if (type.kind === \"raw\") {\n writeRawType(writer, type.text);\n } else {\n writer.write(printLeafType(type));\n }\n}\n\n/** Write a type at the writer's current position. */\nexport function writeType(writer: TextWriter, type: IrType): void {\n switch (type.kind) {\n case \"keyword\":\n case \"stringLiteral\":\n case \"numberLiteral\":\n case \"booleanLiteral\":\n case \"raw\":\n writeLeafType(writer, type);\n break;\n case \"reference\":\n writeReferenceType(writer, type.name, type.typeArguments);\n break;\n case \"array\":\n case \"indexedAccess\":\n case \"readonly\":\n writeOperatorType(writer, type);\n break;\n case \"union\":\n case \"intersection\":\n writeConstituents(writer, type.types, CONSTITUENT_SEPARATORS[type.kind]);\n break;\n case \"object\":\n writeObjectType(writer, type.members);\n break;\n case \"tuple\":\n writeTupleType(writer, type.elements);\n break;\n default:\n assertNever(type);\n }\n}\n"],"names":["printEscapedString","assertNever","writeLeadingComment","printStringLiteral","DEFAULT_STRING_ENCODING","printNumberLiteral"],"mappings":";;;;;;;AAmBA,MAAM,wBAAwB,CA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AA,uBAAA,CAAY,IAAI,CAAA;AAAA;AAEtB;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { assertNever } from '../../domain/assert-never.mjs';
2
+ import { DEFAULT_STRING_ENCODING } from '../../domain/ir/constructors.mjs';
2
3
  import { writeLeadingComment } from './comment-writer.mjs';
3
4
  import { printEscapedString, printNumberLiteral, printStringLiteral } from './literal-text.mjs';
4
5
 
@@ -137,7 +138,7 @@ function printLeafType(type) {
137
138
  case "keyword":
138
139
  return type.keyword;
139
140
  case "stringLiteral":
140
- return printStringLiteral(type.value, type.encoding);
141
+ return printStringLiteral(type.value, type.encoding ?? DEFAULT_STRING_ENCODING);
141
142
  case "numberLiteral":
142
143
  return printNumberLiteral(type.value);
143
144
  case "booleanLiteral":