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

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 (203) hide show
  1. package/README.md +12 -5
  2. package/dist/adapters/redocly-loader/configured-headers.cjs +32 -0
  3. package/dist/adapters/redocly-loader/configured-headers.cjs.map +1 -0
  4. package/dist/adapters/redocly-loader/configured-headers.mjs +30 -0
  5. package/dist/adapters/redocly-loader/configured-headers.mjs.map +1 -0
  6. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +19 -6
  7. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  8. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +18 -5
  9. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  10. package/dist/adapters/redocly-loader/ref-access.cjs +37 -4
  11. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  12. package/dist/adapters/redocly-loader/ref-access.mjs +37 -4
  13. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  14. package/dist/adapters/redocly-loader/ref-resolution-check.cjs +191 -0
  15. package/dist/adapters/redocly-loader/ref-resolution-check.cjs.map +1 -0
  16. package/dist/adapters/redocly-loader/ref-resolution-check.mjs +189 -0
  17. package/dist/adapters/redocly-loader/ref-resolution-check.mjs.map +1 -0
  18. package/dist/adapters/redocly-loader/ref-resolution-steps.cjs +73 -0
  19. package/dist/adapters/redocly-loader/ref-resolution-steps.cjs.map +1 -0
  20. package/dist/adapters/redocly-loader/ref-resolution-steps.mjs +60 -0
  21. package/dist/adapters/redocly-loader/ref-resolution-steps.mjs.map +1 -0
  22. package/dist/adapters/redocly-loader/remote-fetch.cjs +41 -14
  23. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  24. package/dist/adapters/redocly-loader/remote-fetch.mjs +40 -14
  25. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  26. package/dist/adapters/redocly-loader/schema-load-errors.cjs +23 -5
  27. package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
  28. package/dist/adapters/redocly-loader/schema-load-errors.mjs +23 -5
  29. package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
  30. package/dist/adapters/redocly-loader/unsupported-keys.cjs +9 -1
  31. package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/unsupported-keys.mjs +9 -1
  33. package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
  34. package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
  35. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  36. package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
  37. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  38. package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs +2 -1
  39. package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs.map +1 -1
  40. package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs +2 -1
  41. package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs.map +1 -1
  42. package/dist/adapters/type-ast-bridge/print-typescript.cjs.map +1 -1
  43. package/dist/adapters/type-ast-bridge/print-typescript.mjs.map +1 -1
  44. package/dist/api/default-ports.cjs +9 -0
  45. package/dist/api/default-ports.cjs.map +1 -1
  46. package/dist/api/default-ports.mjs +8 -1
  47. package/dist/api/default-ports.mjs.map +1 -1
  48. package/dist/api/discriminator-patch.cjs +5 -1
  49. package/dist/api/discriminator-patch.cjs.map +1 -1
  50. package/dist/api/discriminator-patch.mjs +5 -1
  51. package/dist/api/discriminator-patch.mjs.map +1 -1
  52. package/dist/api/document-refs.cjs +15 -12
  53. package/dist/api/document-refs.cjs.map +1 -1
  54. package/dist/api/document-refs.mjs +15 -12
  55. package/dist/api/document-refs.mjs.map +1 -1
  56. package/dist/api/document-run.cjs +4 -2
  57. package/dist/api/document-run.cjs.map +1 -1
  58. package/dist/api/document-run.mjs +4 -2
  59. package/dist/api/document-run.mjs.map +1 -1
  60. package/dist/api/footer-sink.cjs +25 -2
  61. package/dist/api/footer-sink.cjs.map +1 -1
  62. package/dist/api/footer-sink.mjs +25 -2
  63. package/dist/api/footer-sink.mjs.map +1 -1
  64. package/dist/api/legacy-callback-warning.cjs +4 -1
  65. package/dist/api/legacy-callback-warning.cjs.map +1 -1
  66. package/dist/api/legacy-callback-warning.mjs +4 -1
  67. package/dist/api/legacy-callback-warning.mjs.map +1 -1
  68. package/dist/api/legacy-ts-helpers.cjs.map +1 -1
  69. package/dist/api/legacy-ts-helpers.mjs.map +1 -1
  70. package/dist/api/legacy-utils.cjs.map +1 -1
  71. package/dist/api/legacy-utils.mjs.map +1 -1
  72. package/dist/api/openapi-ts.cjs +2 -1
  73. package/dist/api/openapi-ts.cjs.map +1 -1
  74. package/dist/api/openapi-ts.mjs +3 -2
  75. package/dist/api/openapi-ts.mjs.map +1 -1
  76. package/dist/api/transform-context.cjs +1 -1
  77. package/dist/api/transform-context.cjs.map +1 -1
  78. package/dist/api/transform-context.mjs +1 -1
  79. package/dist/api/transform-context.mjs.map +1 -1
  80. package/dist/api/transform-schema.cjs.map +1 -1
  81. package/dist/api/transform-schema.mjs.map +1 -1
  82. package/dist/application/print/type-printer.cjs +2 -1
  83. package/dist/application/print/type-printer.cjs.map +1 -1
  84. package/dist/application/print/type-printer.mjs +2 -1
  85. package/dist/application/print/type-printer.mjs.map +1 -1
  86. package/dist/application/transform/document/parameters.cjs +1 -1
  87. package/dist/application/transform/document/parameters.cjs.map +1 -1
  88. package/dist/application/transform/document/parameters.mjs +1 -1
  89. package/dist/application/transform/document/parameters.mjs.map +1 -1
  90. package/dist/application/transform/document/paths.cjs +1 -1
  91. package/dist/application/transform/document/paths.cjs.map +1 -1
  92. package/dist/application/transform/document/paths.mjs +1 -1
  93. package/dist/application/transform/document/paths.mjs.map +1 -1
  94. package/dist/application/transform/footer/evaluation.cjs +9 -0
  95. package/dist/application/transform/footer/evaluation.cjs.map +1 -1
  96. package/dist/application/transform/footer/evaluation.mjs +8 -1
  97. package/dist/application/transform/footer/evaluation.mjs.map +1 -1
  98. package/dist/application/transform/footer/type-evaluation.cjs +4 -112
  99. package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
  100. package/dist/application/transform/footer/type-evaluation.mjs +4 -112
  101. package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
  102. package/dist/application/transform/footer/type-indexing.cjs +107 -0
  103. package/dist/application/transform/footer/type-indexing.cjs.map +1 -0
  104. package/dist/application/transform/footer/type-indexing.mjs +105 -0
  105. package/dist/application/transform/footer/type-indexing.mjs.map +1 -0
  106. package/dist/cli/api-settings.cjs +78 -0
  107. package/dist/cli/api-settings.cjs.map +1 -0
  108. package/dist/cli/api-settings.mjs +73 -0
  109. package/dist/cli/api-settings.mjs.map +1 -0
  110. package/dist/cli/cli-arguments.cjs +1 -0
  111. package/dist/cli/cli-arguments.cjs.map +1 -1
  112. package/dist/cli/cli-arguments.mjs +1 -1
  113. package/dist/cli/cli-arguments.mjs.map +1 -1
  114. package/dist/cli/help-text.cjs +3 -3
  115. package/dist/cli/help-text.cjs.map +1 -1
  116. package/dist/cli/help-text.mjs +3 -3
  117. package/dist/cli/help-text.mjs.map +1 -1
  118. package/dist/cli/redocly-apis.cjs +8 -4
  119. package/dist/cli/redocly-apis.cjs.map +1 -1
  120. package/dist/cli/redocly-apis.mjs +7 -3
  121. package/dist/cli/redocly-apis.mjs.map +1 -1
  122. package/dist/cli/run-cli.cjs +5 -1
  123. package/dist/cli/run-cli.cjs.map +1 -1
  124. package/dist/cli/run-cli.mjs +5 -1
  125. package/dist/cli/run-cli.mjs.map +1 -1
  126. package/dist/domain/errors.cjs +4 -1
  127. package/dist/domain/errors.cjs.map +1 -1
  128. package/dist/domain/errors.mjs +4 -1
  129. package/dist/domain/errors.mjs.map +1 -1
  130. package/dist/domain/ir/constructors.cjs +2 -0
  131. package/dist/domain/ir/constructors.cjs.map +1 -1
  132. package/dist/domain/ir/constructors.mjs +2 -1
  133. package/dist/domain/ir/constructors.mjs.map +1 -1
  134. package/dist/domain/openapi/path-templates.cjs +1 -1
  135. package/dist/domain/openapi/path-templates.cjs.map +1 -1
  136. package/dist/domain/openapi/path-templates.mjs +1 -1
  137. package/dist/domain/openapi/path-templates.mjs.map +1 -1
  138. package/dist/domain/url-credentials.cjs +10 -0
  139. package/dist/domain/url-credentials.cjs.map +1 -0
  140. package/dist/domain/url-credentials.mjs +8 -0
  141. package/dist/domain/url-credentials.mjs.map +1 -0
  142. package/dist/domain/warnings.cjs +9 -1
  143. package/dist/domain/warnings.cjs.map +1 -1
  144. package/dist/domain/warnings.mjs +9 -1
  145. package/dist/domain/warnings.mjs.map +1 -1
  146. package/dist/index.cjs +2 -0
  147. package/dist/index.cjs.map +1 -1
  148. package/dist/index.d.cts +1160 -53
  149. package/dist/index.d.mts +1160 -53
  150. package/dist/index.d.ts +1160 -53
  151. package/dist/index.mjs +1 -0
  152. package/dist/index.mjs.map +1 -1
  153. package/dist/transform/path-item-object.cjs.map +1 -1
  154. package/dist/transform/path-item-object.mjs.map +1 -1
  155. package/package.json +6 -5
  156. package/src/adapters/redocly-loader/configured-headers.ts +65 -0
  157. package/src/adapters/redocly-loader/redocly-schema-loader.ts +22 -7
  158. package/src/adapters/redocly-loader/ref-access.ts +60 -5
  159. package/src/adapters/redocly-loader/ref-resolution-check.ts +257 -0
  160. package/src/adapters/redocly-loader/ref-resolution-steps.ts +113 -0
  161. package/src/adapters/redocly-loader/remote-fetch.ts +77 -21
  162. package/src/adapters/redocly-loader/schema-load-errors.ts +33 -11
  163. package/src/adapters/redocly-loader/unsupported-keys.ts +17 -2
  164. package/src/adapters/terminal-logger/terminal-logger.ts +9 -5
  165. package/src/adapters/type-ast-bridge/ir-to-typescript.ts +2 -1
  166. package/src/adapters/type-ast-bridge/print-typescript.ts +3 -1
  167. package/src/adapters/type-ast-bridge/typescript-types.ts +57 -5
  168. package/src/api/default-ports.ts +16 -0
  169. package/src/api/discriminator-patch.ts +7 -2
  170. package/src/api/document-refs.ts +19 -15
  171. package/src/api/document-run.ts +9 -6
  172. package/src/api/footer-sink.ts +34 -2
  173. package/src/api/legacy-callback-warning.ts +7 -3
  174. package/src/api/legacy-ts-helpers.ts +7 -5
  175. package/src/api/legacy-utils.ts +1 -1
  176. package/src/api/openapi-ts.ts +2 -0
  177. package/src/api/run-context.ts +34 -0
  178. package/src/api/transform-context.ts +10 -8
  179. package/src/api/transform-schema.ts +6 -5
  180. package/src/application/print/type-printer.ts +2 -1
  181. package/src/application/transform/document/parameters.ts +2 -1
  182. package/src/application/transform/document/paths.ts +2 -1
  183. package/src/application/transform/footer/evaluation.ts +10 -0
  184. package/src/application/transform/footer/type-evaluation.ts +6 -133
  185. package/src/application/transform/footer/type-indexing.ts +152 -0
  186. package/src/cli/api-settings.ts +109 -0
  187. package/src/cli/cli-arguments.ts +5 -2
  188. package/src/cli/help-text.ts +4 -4
  189. package/src/cli/redocly-apis.ts +13 -7
  190. package/src/cli/run-cli.ts +5 -1
  191. package/src/domain/errors.ts +8 -2
  192. package/src/domain/ir/constructors.ts +3 -0
  193. package/src/domain/ir/nodes.ts +9 -6
  194. package/src/domain/openapi/path-templates.ts +2 -1
  195. package/src/domain/url-credentials.ts +18 -0
  196. package/src/domain/warnings.ts +8 -0
  197. package/src/index.ts +1 -0
  198. package/src/transform/path-item-object.ts +6 -2
  199. package/src/types/generator-options.ts +12 -32
  200. package/src/types/openapi-common.ts +1 -0
  201. package/src/types/openapi-request.ts +3 -0
  202. package/src/types/openapi-schema.ts +2 -0
  203. package/src/types/openapi-security.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-ts-helpers.cjs","sources":["../../src/api/legacy-ts-helpers.ts"],"sourcesContent":["import { toTypeNode, toValueExpression } from \"../adapters/type-ast-bridge/ir-to-typescript.js\";\nimport { lazyNode } from \"../adapters/type-ast-bridge/lazy-node.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport {\n enumMemberDescription,\n quotedMemberName,\n} from \"../application/transform/footer/enum-naming.js\";\nimport { HELPER_TYPES } from \"../application/transform/helper-types.js\";\nimport { schemaComment } from \"../application/transform/schema-comment.js\";\nimport type { IrType } from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry } from \"./footer-entry.js\";\nimport type { TypeInput } from \"./type-helpers.js\";\n\n/**\n * The original's helpers that build TypeScript compiler nodes, kept for 1.x and deprecated\n * (ADR-004, decision 9). They load TypeScript on first use through the bridge; the generator\n * itself does not use them.\n */\n\nexport const JS_PROPERTY_INDEX_RE = /^[A-Za-z_$][A-Za-z_$0-9]*$/;\nexport const JS_ENUM_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+(.)?/g;\nexport const JS_PROPERTY_INDEX_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+/g;\nexport const SPECIAL_CHARACTER_MAP: Record<string, string> = {\n \"+\": \"Plus\",\n // Add more mappings as needed\n};\n\n/**\n * The `?` token. Created on first use, so importing the package needs no TypeScript.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport const QUESTION_TOKEN: ts.QuestionToken = lazyNode(() => {\n const ts = loadTypeScript();\n return ts.factory.createToken(ts.SyntaxKind.QuestionToken);\n});\n\nexport interface AnnotatedSchemaObject {\n const?: unknown; // jsdoc without value\n default?: unknown; // jsdoc with value\n deprecated?: boolean; // jsdoc without value\n description?: string; // jsdoc with value\n enum?: unknown[]; // jsdoc without value\n example?: string; // jsdoc with value\n examples?: unknown;\n format?: string; // not jsdoc\n nullable?: boolean; // Node information\n summary?: string; // not jsdoc\n title?: string; // not jsdoc\n type?: string | string[]; // Type of node\n}\n\n/**\n * Add the schema's JSDoc comment to a TypeScript property signature.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function addJSDocComment(\n schemaObject: AnnotatedSchemaObject,\n node: ts.PropertySignature,\n): void {\n const ts = loadTypeScript();\n const comment = schemaComment(schemaObject);\n if (comment) {\n ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment.text, true);\n }\n}\n\n/** A type argument of the deprecated helpers as TypeScript; IR from type helpers is converted. */\nfunction legacyTypeNode(type: TypeInput): ts.TypeNode {\n const ts = loadTypeScript();\n return typeof type.kind === \"string\" ? toTypeNode(ts, type as IrType) : (type as ts.TypeNode);\n}\n\n/** Add a helper type alias to the footer once, as a named raw declaration (like the generator). */\nfunction requireHelper(injectFooter: FooterEntry[], helper: { name: string; text: string }): void {\n if (!injectFooter.some((entry) => declaresTypeAlias(entry, helper.name))) {\n injectFooter.push({ kind: \"rawDeclaration\", name: helper.name, text: helper.text });\n }\n}\n\n/**\n * Deduplicate simple primitive types from an array of nodes\n * Note: won’t deduplicate complex types like objects\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsDedupe(types: TypeInput[]): ts.TypeNode[] {\n const encounteredTypes = new Set<number>();\n const filteredTypes: ts.TypeNode[] = [];\n for (const t of types.map(legacyTypeNode)) {\n // only mark for deduplication if this is not a const (\"text\" means it is a const)\n if (!(\"text\" in ((t as ts.LiteralTypeNode).literal ?? t))) {\n const { kind } = (t as ts.LiteralTypeNode).literal ?? t;\n if (encounteredTypes.has(kind)) {\n continue;\n }\n if (tsIsPrimitive(t)) {\n encounteredTypes.add(kind);\n }\n }\n filteredTypes.push(t);\n }\n return filteredTypes;\n}\n\n/** @deprecated The generator keeps its own enum registry per run; kept for 1.x (ADR-004). */\nexport const enumCache = new Map<string, ts.EnumDeclaration>();\n\n/**\n * Create a TS enum (with sanitized name and members)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnum(\n name: string,\n members: (string | number)[],\n metadata?: { name?: string; description?: string | null }[],\n options?: { export?: boolean; shouldCache?: boolean },\n) {\n const ts = loadTypeScript();\n let enumName = sanitizeMemberName(name);\n enumName = `${enumName.charAt(0).toUpperCase()}${enumName.substring(1)}`;\n let key = \"\";\n if (options?.shouldCache) {\n key = `${members\n .slice(0)\n .sort()\n .map((v, i) => {\n return `${metadata?.[i]?.name ?? String(v)}:${metadata?.[i]?.description || \"\"}`;\n })\n .join(\",\")}`;\n if (enumCache.has(key)) {\n return enumCache.get(key) as ts.EnumDeclaration;\n }\n }\n const enumDeclaration = ts.factory.createEnumDeclaration(\n /* modifiers */ options ? tsModifiers({ export: options.export ?? false }) : undefined,\n /* name */ enumName,\n /* members */ members.map((value, i) => tsEnumMember(value, metadata?.[i])),\n );\n options?.shouldCache && enumCache.set(key, enumDeclaration);\n return enumDeclaration;\n}\n\n/**\n * Create an exported TS array literal expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsArrayLiteralExpression(\n name: string,\n elementType: TypeInput,\n values: (string | number)[],\n options?: { export?: boolean; readonly?: boolean; injectFooter?: FooterEntry[] },\n) {\n const ts = loadTypeScript();\n let variableName = sanitizeMemberName(name);\n variableName = `${variableName.charAt(0).toLowerCase()}${variableName.substring(1)}`;\n\n if (options?.injectFooter) {\n requireHelper(options.injectFooter, HELPER_TYPES.flattenedDeepRequired);\n }\n\n const arrayType = options?.readonly\n ? tsReadonlyArray(elementType, options.injectFooter)\n : ts.factory.createArrayTypeNode(legacyTypeNode(elementType));\n\n return ts.factory.createVariableStatement(\n options ? tsModifiers({ export: options.export ?? false }) : undefined,\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n variableName,\n undefined,\n arrayType,\n ts.factory.createArrayLiteralExpression(\n values.map((value) => toValueExpression(ts, value)),\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n );\n}\n\nfunction sanitizeMemberName(name: string) {\n let sanitizedName = name.replace(JS_ENUM_INVALID_CHARS_RE, (c) => {\n // The pattern matches at least one character, so `last` is always a character.\n const last = c.at(-1) ?? \"\";\n return JS_PROPERTY_INDEX_INVALID_CHARS_RE.test(last) ? \"\" : last.toUpperCase();\n });\n if (Number(name[0]) >= 0) {\n sanitizedName = `Value${name}`;\n }\n return sanitizedName;\n}\n\n/** An enum member name: a valid identifier as is; anything else prefixed, replaced or quoted. */\nfunction enumMemberName(value: string | number, explicitName: string | undefined): string {\n let name = explicitName ?? String(value);\n if (JS_PROPERTY_INDEX_RE.test(name)) {\n return name;\n }\n if (Number(name[0]) >= 0) {\n // A decimal point is not valid in a name; keep the digits readable.\n name = `Value${name}`.replace(\".\", \"_\");\n } else if (name[0] === \"-\") {\n name = `ValueMinus${name.slice(1)}`;\n }\n const invalidCharMatch = name.match(JS_PROPERTY_INDEX_INVALID_CHARS_RE);\n if (!invalidCharMatch) {\n return name === \"\" ? quotedMemberName(name) : name;\n }\n if (invalidCharMatch[0] === name) {\n return quotedMemberName(name);\n }\n return name.replace(JS_PROPERTY_INDEX_INVALID_CHARS_RE, (s) =>\n s in SPECIAL_CHARACTER_MAP ? (SPECIAL_CHARACTER_MAP[s] as string) : \"_\",\n );\n}\n\n/**\n * Sanitize TS enum member expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnumMember(\n value: string | number,\n metadata: { name?: string; description?: string | null } = {},\n) {\n const ts = loadTypeScript();\n const name = enumMemberName(value, metadata.name);\n const member = ts.factory.createEnumMember(name, toValueExpression(ts, value));\n const trimmedDescription = enumMemberDescription(metadata.description);\n if (trimmedDescription === \"\") {\n return member;\n }\n\n return ts.addSyntheticLeadingComment(\n member,\n ts.SyntaxKind.SingleLineCommentTrivia,\n ` ${trimmedDescription}`,\n true,\n );\n}\n\n/**\n * Is this a primitive type (string, number, boolean, null, undefined)?\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsIsPrimitive(input: TypeInput): boolean {\n const ts = loadTypeScript();\n if (!input) {\n return true;\n }\n const type = legacyTypeNode(input);\n return (\n ts.SyntaxKind[type.kind] === \"BooleanKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NeverKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NullKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NumberKeyword\" ||\n ts.SyntaxKind[type.kind] === \"StringKeyword\" ||\n ts.SyntaxKind[type.kind] === \"UndefinedKeyword\" ||\n (\"literal\" in type && tsIsPrimitive(type.literal as ts.TypeLiteralNode))\n );\n}\n\n/**\n * Modifiers (readonly)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsModifiers(modifiers: { readonly?: boolean; export?: boolean }): ts.Modifier[] {\n const ts = loadTypeScript();\n const typeMods: ts.Modifier[] = [];\n if (modifiers.export) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ExportKeyword));\n }\n if (modifiers.readonly) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword));\n }\n return typeMods;\n}\n\n/**\n * Create a valid property index\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsPropertyIndex(index: string | number) {\n const ts = loadTypeScript();\n if (\n (typeof index === \"number\" && !(index < 0)) ||\n (typeof index === \"string\" && String(Number(index)) === index && index[0] !== \"-\")\n ) {\n return ts.factory.createNumericLiteral(index);\n }\n return typeof index === \"string\" && JS_PROPERTY_INDEX_RE.test(index)\n ? ts.factory.createIdentifier(index)\n : ts.factory.createStringLiteral(String(index));\n}\n\n/**\n * Enhanced ReadonlyArray.\n * eg: type Foo = ReadonlyArray<T>; type Bar = ReadonlyArray<T[]>\n * Foo and Bar are both of type `readonly T[]`\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsReadonlyArray(type: TypeInput, injectFooter?: FooterEntry[]): ts.TypeNode {\n const ts = loadTypeScript();\n if (injectFooter) {\n requireHelper(injectFooter, HELPER_TYPES.readonlyArray);\n }\n return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(\"ReadonlyArray\"), [\n legacyTypeNode(type),\n ]);\n}\n"],"names":["lazyNode","loadTypeScript","schemaComment","toTypeNode","declaresTypeAlias","HELPER_TYPES","toValueExpression","quotedMemberName","enumMemberDescription"],"mappings":";;;;;;;;;;AAoBO,MAAM,oBAAA,GAAuB;AAC7B,MAAM,wBAAA,GAA2B;AACjC,MAAM,kCAAA,GAAqC;AAC3C,MAAM,qBAAA,GAAgD;AAAA,EAC3D,GAAA,EAAK;AAAA;AAEP;AAMO,MAAM,cAAA,GAAmCA,kBAAS,MAAM;AAC7D,EAAA,MAAM,KAAKC,6BAAA,EAAe;AAC1B,EAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,WAAA,CAAY,EAAA,CAAG,WAAW,aAAa,CAAA;AAC3D,CAAC;AAqBM,SAAS,eAAA,CACd,cACA,IAAA,EACM;AACN,EAAA,MAAM,KAAKA,6BAAA,EAAe;AAC1B,EAAA,MAAM,OAAA,GAAUC,4BAAc,YAAY,CAAA;AAC1C,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,EAAA,CAAG,2BAA2B,IAAA,EAAM,EAAA,CAAG,WAAW,sBAAA,EAAwB,OAAA,CAAQ,MAAM,IAAI,CAAA;AAAA,EAC9F;AACF;AAGA,SAAS,eAAe,IAAA,EAA8B;AACpD,EAAA,MAAM,KAAKD,6BAAA,EAAe;AAC1B,EAAA,OAAO,OAAO,IAAA,CAAK,IAAA,KAAS,WAAWE,yBAAA,CAAW,EAAA,EAAI,IAAc,CAAA,GAAK,IAAA;AAC3E;AAGA,SAAS,aAAA,CAAc,cAA6B,MAAA,EAA8C;AAChG,EAAA,IAAI,CAAC,YAAA,CAAa,IAAA,CAAK,CAAC,KAAA,KAAUC,8BAAkB,KAAA,EAAO,MAAA,CAAO,IAAI,CAAC,CAAA,EAAG;AACxE,IAAA,YAAA,CAAa,IAAA,CAAK,EAAE,IAAA,EAAM,gBAAA,EAAkB,IAAA,EAAM,OAAO,IAAA,EAAM,IAAA,EAAM,MAAA,CAAO,IAAA,EAA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,EAAA,CAAG,UAAA,CAAW,eAAe,CAAC,CAAA;AAAA,EACxE;AACA,EAAA,OAAO,QAAA;AACT;AAMO,SAAS,gBAAgB,KAAA,EAAwB;AACtD,EAAA,MAAM,KAAKA,6BAAA,EAAe;AAC1B,EAAA,IACG,OAAO,KAAA,KAAU,QAAA,IAAY,EAAE,KAAA,GAAQ,CAAA,CAAA,IACvC,OAAO,KAAA,KAAU,QAAA,IAAY,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA,KAAM,SAAS,KAAA,CAAM,CAAC,MAAM,GAAA,EAC9E;AACA,IAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,oBAAA,CAAqB,KAAK,CAAA;AAAA,EAC9C;AACA,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,oBAAA,CAAqB,IAAA,CAAK,KAAK,CAAA,GAC/D,EAAA,CAAG,OAAA,CAAQ,gBAAA,CAAiB,KAAK,CAAA,GACjC,EAAA,CAAG,QAAQ,mBAAA,CAAoB,MAAA,CAAO,KAAK,CAAC,CAAA;AAClD;AAQO,SAAS,eAAA,CAAgB,MAAiB,YAAA,EAA2C;AAC1F,EAAA,MAAM,KAAKA,6BAAA,EAAe;AAC1B,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,aAAA,CAAc,YAAA,EAAcI,yBAAa,aAAa,CAAA;AAAA,EACxD;AACA,EAAA,OAAO,GAAG,OAAA,CAAQ,uBAAA,CAAwB,GAAG,OAAA,CAAQ,gBAAA,CAAiB,eAAe,CAAA,EAAG;AAAA,IACtF,eAAe,IAAI;AAAA,GACpB,CAAA;AACH;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"legacy-ts-helpers.cjs","sources":["../../src/api/legacy-ts-helpers.ts"],"sourcesContent":["import { toTypeNode, toValueExpression } from \"../adapters/type-ast-bridge/ir-to-typescript.js\";\nimport { lazyNode } from \"../adapters/type-ast-bridge/lazy-node.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport {\n enumMemberDescription,\n quotedMemberName,\n} from \"../application/transform/footer/enum-naming.js\";\nimport { HELPER_TYPES } from \"../application/transform/helper-types.js\";\nimport { schemaComment } from \"../application/transform/schema-comment.js\";\nimport type { IrType } from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry } from \"./footer-entry.js\";\nimport type { TypeInput } from \"./type-helpers.js\";\n\n/**\n * The original's helpers that build TypeScript compiler nodes, kept for 1.x and deprecated\n * (ADR-004, decision 9). They load TypeScript on first use through the bridge; the generator\n * itself does not use them.\n */\n\nexport const JS_PROPERTY_INDEX_RE = /^[A-Za-z_$][A-Za-z_$0-9]*$/;\nexport const JS_ENUM_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+(.)?/g;\nexport const JS_PROPERTY_INDEX_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+/g;\nexport const SPECIAL_CHARACTER_MAP: Record<string, string> = {\n \"+\": \"Plus\",\n // Add more mappings as needed\n};\n\n/**\n * The `?` token. Created on first use, so importing the package needs no TypeScript.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport const QUESTION_TOKEN: ts.QuestionToken = lazyNode(() => {\n const ts = loadTypeScript();\n return ts.factory.createToken(ts.SyntaxKind.QuestionToken);\n});\n\nexport interface AnnotatedSchemaObject {\n const?: unknown; // jsdoc without value\n default?: unknown; // jsdoc with value\n deprecated?: boolean; // jsdoc without value\n description?: string; // jsdoc with value\n enum?: unknown[]; // jsdoc without value\n example?: string; // jsdoc with value\n examples?: unknown;\n format?: string; // not jsdoc\n nullable?: boolean; // Node information\n summary?: string; // not jsdoc\n title?: string; // not jsdoc\n type?: string | string[]; // Type of node\n}\n\n/**\n * Add the schema's JSDoc comment to a TypeScript property signature.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function addJSDocComment(\n schemaObject: AnnotatedSchemaObject,\n node: ts.PropertySignature,\n): void {\n const ts = loadTypeScript();\n const comment = schemaComment(schemaObject);\n if (comment) {\n ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment.text, true);\n }\n}\n\n/** A type argument of the deprecated helpers as TypeScript; IR from type helpers is converted. */\nfunction legacyTypeNode(type: TypeInput): ts.TypeNode {\n const ts = loadTypeScript();\n return typeof type.kind === \"string\" ? toTypeNode(ts, type as IrType) : (type as ts.TypeNode);\n}\n\n/** Add a helper type alias to the footer once, as a named raw declaration (like the generator). */\nfunction requireHelper(injectFooter: FooterEntry[], helper: { name: string; text: string }): void {\n if (!injectFooter.some((entry) => declaresTypeAlias(entry, helper.name))) {\n injectFooter.push({ kind: \"rawDeclaration\", name: helper.name, text: helper.text });\n }\n}\n\n/**\n * Deduplicate simple primitive types from an array of nodes\n * Note: won’t deduplicate complex types like objects\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsDedupe(types: TypeInput[]): ts.TypeNode[] {\n const encounteredTypes = new Set<number>();\n const filteredTypes: ts.TypeNode[] = [];\n for (const t of types.map(legacyTypeNode)) {\n // only mark for deduplication if this is not a const (\"text\" means it is a const)\n if (!(\"text\" in ((t as ts.LiteralTypeNode).literal ?? t))) {\n const { kind } = (t as ts.LiteralTypeNode).literal ?? t;\n if (encounteredTypes.has(kind)) {\n continue;\n }\n if (tsIsPrimitive(t)) {\n encounteredTypes.add(kind);\n }\n }\n filteredTypes.push(t);\n }\n return filteredTypes;\n}\n\n/** @deprecated The generator keeps its own enum registry per run; kept for 1.x (ADR-004). */\nexport const enumCache: Map<string, ts.EnumDeclaration> = new Map();\n\n/**\n * Create a TS enum (with sanitized name and members)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnum(\n name: string,\n members: (string | number)[],\n metadata?: { name?: string; description?: string | null }[],\n options?: { export?: boolean; shouldCache?: boolean },\n): ts.EnumDeclaration {\n const ts = loadTypeScript();\n let enumName = sanitizeMemberName(name);\n enumName = `${enumName.charAt(0).toUpperCase()}${enumName.substring(1)}`;\n let key = \"\";\n if (options?.shouldCache) {\n key = `${members\n .slice(0)\n .sort()\n .map((v, i) => {\n return `${metadata?.[i]?.name ?? String(v)}:${metadata?.[i]?.description || \"\"}`;\n })\n .join(\",\")}`;\n if (enumCache.has(key)) {\n return enumCache.get(key) as ts.EnumDeclaration;\n }\n }\n const enumDeclaration = ts.factory.createEnumDeclaration(\n /* modifiers */ options ? tsModifiers({ export: options.export ?? false }) : undefined,\n /* name */ enumName,\n /* members */ members.map((value, i) => tsEnumMember(value, metadata?.[i])),\n );\n options?.shouldCache && enumCache.set(key, enumDeclaration);\n return enumDeclaration;\n}\n\n/**\n * Create an exported TS array literal expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsArrayLiteralExpression(\n name: string,\n elementType: TypeInput,\n values: (string | number)[],\n options?: { export?: boolean; readonly?: boolean; injectFooter?: FooterEntry[] },\n): ts.VariableStatement {\n const ts = loadTypeScript();\n let variableName = sanitizeMemberName(name);\n variableName = `${variableName.charAt(0).toLowerCase()}${variableName.substring(1)}`;\n\n if (options?.injectFooter) {\n requireHelper(options.injectFooter, HELPER_TYPES.flattenedDeepRequired);\n }\n\n const arrayType = options?.readonly\n ? tsReadonlyArray(elementType, options.injectFooter)\n : ts.factory.createArrayTypeNode(legacyTypeNode(elementType));\n\n return ts.factory.createVariableStatement(\n options ? tsModifiers({ export: options.export ?? false }) : undefined,\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n variableName,\n undefined,\n arrayType,\n ts.factory.createArrayLiteralExpression(\n values.map((value) => toValueExpression(ts, value)),\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n );\n}\n\nfunction sanitizeMemberName(name: string) {\n let sanitizedName = name.replace(JS_ENUM_INVALID_CHARS_RE, (c) => {\n // The pattern matches at least one character, so `last` is always a character.\n const last = c.at(-1) ?? \"\";\n return JS_PROPERTY_INDEX_INVALID_CHARS_RE.test(last) ? \"\" : last.toUpperCase();\n });\n if (Number(name[0]) >= 0) {\n sanitizedName = `Value${name}`;\n }\n return sanitizedName;\n}\n\n/** An enum member name: a valid identifier as is; anything else prefixed, replaced or quoted. */\nfunction enumMemberName(value: string | number, explicitName: string | undefined): string {\n let name = explicitName ?? String(value);\n if (JS_PROPERTY_INDEX_RE.test(name)) {\n return name;\n }\n if (Number(name[0]) >= 0) {\n // A decimal point is not valid in a name; keep the digits readable.\n name = `Value${name}`.replace(\".\", \"_\");\n } else if (name[0] === \"-\") {\n name = `ValueMinus${name.slice(1)}`;\n }\n const invalidCharMatch = name.match(JS_PROPERTY_INDEX_INVALID_CHARS_RE);\n if (!invalidCharMatch) {\n return name === \"\" ? quotedMemberName(name) : name;\n }\n if (invalidCharMatch[0] === name) {\n return quotedMemberName(name);\n }\n return name.replace(JS_PROPERTY_INDEX_INVALID_CHARS_RE, (s) =>\n s in SPECIAL_CHARACTER_MAP ? (SPECIAL_CHARACTER_MAP[s] as string) : \"_\",\n );\n}\n\n/**\n * Sanitize TS enum member expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnumMember(\n value: string | number,\n metadata: { name?: string; description?: string | null } = {},\n): ts.EnumMember {\n const ts = loadTypeScript();\n const name = enumMemberName(value, metadata.name);\n const member = ts.factory.createEnumMember(name, toValueExpression(ts, value));\n const trimmedDescription = enumMemberDescription(metadata.description);\n if (trimmedDescription === \"\") {\n return member;\n }\n\n return ts.addSyntheticLeadingComment(\n member,\n ts.SyntaxKind.SingleLineCommentTrivia,\n ` ${trimmedDescription}`,\n true,\n );\n}\n\n/**\n * Is this a primitive type (string, number, boolean, null, undefined)?\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsIsPrimitive(input: TypeInput): boolean {\n const ts = loadTypeScript();\n if (!input) {\n return true;\n }\n const type = legacyTypeNode(input);\n return (\n ts.SyntaxKind[type.kind] === \"BooleanKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NeverKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NullKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NumberKeyword\" ||\n ts.SyntaxKind[type.kind] === \"StringKeyword\" ||\n ts.SyntaxKind[type.kind] === \"UndefinedKeyword\" ||\n (\"literal\" in type && tsIsPrimitive(type.literal as ts.TypeLiteralNode))\n );\n}\n\n/**\n * Modifiers (readonly)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsModifiers(modifiers: { readonly?: boolean; export?: boolean }): ts.Modifier[] {\n const ts = loadTypeScript();\n const typeMods: ts.Modifier[] = [];\n if (modifiers.export) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ExportKeyword));\n }\n if (modifiers.readonly) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword));\n }\n return typeMods;\n}\n\n/**\n * Create a valid property index\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsPropertyIndex(\n index: string | number,\n): ts.Identifier | ts.NumericLiteral | ts.StringLiteral {\n const ts = loadTypeScript();\n if (\n (typeof index === \"number\" && !(index < 0)) ||\n (typeof index === \"string\" && String(Number(index)) === index && index[0] !== \"-\")\n ) {\n return ts.factory.createNumericLiteral(index);\n }\n return typeof index === \"string\" && JS_PROPERTY_INDEX_RE.test(index)\n ? ts.factory.createIdentifier(index)\n : ts.factory.createStringLiteral(String(index));\n}\n\n/**\n * Enhanced ReadonlyArray.\n * eg: type Foo = ReadonlyArray<T>; type Bar = ReadonlyArray<T[]>\n * Foo and Bar are both of type `readonly T[]`\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsReadonlyArray(type: TypeInput, injectFooter?: FooterEntry[]): ts.TypeNode {\n const ts = loadTypeScript();\n if (injectFooter) {\n requireHelper(injectFooter, HELPER_TYPES.readonlyArray);\n }\n return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(\"ReadonlyArray\"), [\n legacyTypeNode(type),\n ]);\n}\n"],"names":["lazyNode","loadTypeScript","schemaComment","toTypeNode","declaresTypeAlias","HELPER_TYPES","toValueExpression","quotedMemberName","enumMemberDescription"],"mappings":";;;;;;;;;;AAoBO,MAAM,oBAAA,GAAuB;AAC7B,MAAM,wBAAA,GAA2B;AACjC,MAAM,kCAAA,GAAqC;AAC3C,MAAM,qBAAA,GAAgD;AAAA,EAC3D,GAAA,EAAK;AAAA;AAEP;AAMO,MAAM,cAAA,GAAmCA,kBAAS,MAAM;AAC7D,EAAA,MAAM,KAAKC,6BAAA,EAAe;AAC1B,EAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,WAAA,CAAY,EAAA,CAAG,WAAW,aAAa,CAAA;AAC3D,CAAC;AAqBM,SAAS,eAAA,CACd,cACA,IAAA,EACM;AACN,EAAA,MAAM,KAAKA,6BAAA,EAAe;AAC1B,EAAA,MAAM,OAAA,GAAUC,4BAAc,YAAY,CAAA;AAC1C,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,EAAA,CAAG,2BAA2B,IAAA,EAAM,EAAA,CAAG,WAAW,sBAAA,EAAwB,OAAA,CAAQ,MAAM,IAAI,CAAA;AAAA,EAC9F;AACF;AAGA,SAAS,eAAe,IAAA,EAA8B;AACpD,EAAA,MAAM,KAAKD,6BAAA,EAAe;AAC1B,EAAA,OAAO,OAAO,IAAA,CAAK,IAAA,KAAS,WAAWE,yBAAA,CAAW,EAAA,EAAI,IAAc,CAAA,GAAK,IAAA;AAC3E;AAGA,SAAS,aAAA,CAAc,cAA6B,MAAA,EAA8C;AAChG,EAAA,IAAI,CAAC,YAAA,CAAa,IAAA,CAAK,CAAC,KAAA,KAAUC,8BAAkB,KAAA,EAAO,MAAA,CAAO,IAAI,CAAC,CAAA,EAAG;AACxE,IAAA,YAAA,CAAa,IAAA,CAAK,EAAE,IAAA,EAAM,gBAAA,EAAkB,IAAA,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U;AACtB,IAAA,QAAA,CAAS,KAAK,EAAA,CAAG,OAAA,CAAQ,eAAe,EAAA,CAAG,UAAA,CAAW,eAAe,CAAC,CAAA;AAAA,EACxE;AACA,EAAA,OAAO,QAAA;AACT;AAMO,SAAS,gBACd,KAAA,EACsD;AACtD,EAAA,MAAM,KAAKA,6BAAA,EAAe;AAC1B,EAAA,IACG,OAAO,KAAA,KAAU,QAAA,IAAY,EAAE,KAAA,GAAQ,CAAA,CAAA,IACvC,OAAO,KAAA,KAAU,QAAA,IAAY,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA,KAAM,SAAS,KAAA,CAAM,CAAC,MAAM,GAAA,EAC9E;AACA,IAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,oBAAA,CAAqB,KAAK,CAAA;AAAA,EAC9C;AACA,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,oBAAA,CAAqB,IAAA,CAAK,KAAK,CAAA,GAC/D,EAAA,CAAG,OAAA,CAAQ,gBAAA,CAAiB,KAAK,CAAA,GACjC,EAAA,CAAG,QAAQ,mBAAA,CAAoB,MAAA,CAAO,KAAK,CAAC,CAAA;AAClD;AAQO,SAAS,eAAA,CAAgB,MAAiB,YAAA,EAA2C;AAC1F,EAAA,MAAM,KAAKA,6BAAA,EAAe;AAC1B,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,aAAA,CAAc,YAAA,EAAcI,yBAAa,aAAa,CAAA;AAAA,EACxD;AACA,EAAA,OAAO,GAAG,OAAA,CAAQ,uBAAA,CAAwB,GAAG,OAAA,CAAQ,gBAAA,CAAiB,eAAe,CAAA,EAAG;AAAA,IACtF,eAAe,IAAI;AAAA,GACpB,CAAA;AACH;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-ts-helpers.mjs","sources":["../../src/api/legacy-ts-helpers.ts"],"sourcesContent":["import { toTypeNode, toValueExpression } from \"../adapters/type-ast-bridge/ir-to-typescript.js\";\nimport { lazyNode } from \"../adapters/type-ast-bridge/lazy-node.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport {\n enumMemberDescription,\n quotedMemberName,\n} from \"../application/transform/footer/enum-naming.js\";\nimport { HELPER_TYPES } from \"../application/transform/helper-types.js\";\nimport { schemaComment } from \"../application/transform/schema-comment.js\";\nimport type { IrType } from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry } from \"./footer-entry.js\";\nimport type { TypeInput } from \"./type-helpers.js\";\n\n/**\n * The original's helpers that build TypeScript compiler nodes, kept for 1.x and deprecated\n * (ADR-004, decision 9). They load TypeScript on first use through the bridge; the generator\n * itself does not use them.\n */\n\nexport const JS_PROPERTY_INDEX_RE = /^[A-Za-z_$][A-Za-z_$0-9]*$/;\nexport const JS_ENUM_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+(.)?/g;\nexport const JS_PROPERTY_INDEX_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+/g;\nexport const SPECIAL_CHARACTER_MAP: Record<string, string> = {\n \"+\": \"Plus\",\n // Add more mappings as needed\n};\n\n/**\n * The `?` token. Created on first use, so importing the package needs no TypeScript.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport const QUESTION_TOKEN: ts.QuestionToken = lazyNode(() => {\n const ts = loadTypeScript();\n return ts.factory.createToken(ts.SyntaxKind.QuestionToken);\n});\n\nexport interface AnnotatedSchemaObject {\n const?: unknown; // jsdoc without value\n default?: unknown; // jsdoc with value\n deprecated?: boolean; // jsdoc without value\n description?: string; // jsdoc with value\n enum?: unknown[]; // jsdoc without value\n example?: string; // jsdoc with value\n examples?: unknown;\n format?: string; // not jsdoc\n nullable?: boolean; // Node information\n summary?: string; // not jsdoc\n title?: string; // not jsdoc\n type?: string | string[]; // Type of node\n}\n\n/**\n * Add the schema's JSDoc comment to a TypeScript property signature.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function addJSDocComment(\n schemaObject: AnnotatedSchemaObject,\n node: ts.PropertySignature,\n): void {\n const ts = loadTypeScript();\n const comment = schemaComment(schemaObject);\n if (comment) {\n ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment.text, true);\n }\n}\n\n/** A type argument of the deprecated helpers as TypeScript; IR from type helpers is converted. */\nfunction legacyTypeNode(type: TypeInput): ts.TypeNode {\n const ts = loadTypeScript();\n return typeof type.kind === \"string\" ? toTypeNode(ts, type as IrType) : (type as ts.TypeNode);\n}\n\n/** Add a helper type alias to the footer once, as a named raw declaration (like the generator). */\nfunction requireHelper(injectFooter: FooterEntry[], helper: { name: string; text: string }): void {\n if (!injectFooter.some((entry) => declaresTypeAlias(entry, helper.name))) {\n injectFooter.push({ kind: \"rawDeclaration\", name: helper.name, text: helper.text });\n }\n}\n\n/**\n * Deduplicate simple primitive types from an array of nodes\n * Note: won’t deduplicate complex types like objects\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsDedupe(types: TypeInput[]): ts.TypeNode[] {\n const encounteredTypes = new Set<number>();\n const filteredTypes: ts.TypeNode[] = [];\n for (const t of types.map(legacyTypeNode)) {\n // only mark for deduplication if this is not a const (\"text\" means it is a const)\n if (!(\"text\" in ((t as ts.LiteralTypeNode).literal ?? t))) {\n const { kind } = (t as ts.LiteralTypeNode).literal ?? t;\n if (encounteredTypes.has(kind)) {\n continue;\n }\n if (tsIsPrimitive(t)) {\n encounteredTypes.add(kind);\n }\n }\n filteredTypes.push(t);\n }\n return filteredTypes;\n}\n\n/** @deprecated The generator keeps its own enum registry per run; kept for 1.x (ADR-004). */\nexport const enumCache = new Map<string, ts.EnumDeclaration>();\n\n/**\n * Create a TS enum (with sanitized name and members)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnum(\n name: string,\n members: (string | number)[],\n metadata?: { name?: string; description?: string | null }[],\n options?: { export?: boolean; shouldCache?: boolean },\n) {\n const ts = loadTypeScript();\n let enumName = sanitizeMemberName(name);\n enumName = `${enumName.charAt(0).toUpperCase()}${enumName.substring(1)}`;\n let key = \"\";\n if (options?.shouldCache) {\n key = `${members\n .slice(0)\n .sort()\n .map((v, i) => {\n return `${metadata?.[i]?.name ?? String(v)}:${metadata?.[i]?.description || \"\"}`;\n })\n .join(\",\")}`;\n if (enumCache.has(key)) {\n return enumCache.get(key) as ts.EnumDeclaration;\n }\n }\n const enumDeclaration = ts.factory.createEnumDeclaration(\n /* modifiers */ options ? tsModifiers({ export: options.export ?? false }) : undefined,\n /* name */ enumName,\n /* members */ members.map((value, i) => tsEnumMember(value, metadata?.[i])),\n );\n options?.shouldCache && enumCache.set(key, enumDeclaration);\n return enumDeclaration;\n}\n\n/**\n * Create an exported TS array literal expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsArrayLiteralExpression(\n name: string,\n elementType: TypeInput,\n values: (string | number)[],\n options?: { export?: boolean; readonly?: boolean; injectFooter?: FooterEntry[] },\n) {\n const ts = loadTypeScript();\n let variableName = sanitizeMemberName(name);\n variableName = `${variableName.charAt(0).toLowerCase()}${variableName.substring(1)}`;\n\n if (options?.injectFooter) {\n requireHelper(options.injectFooter, HELPER_TYPES.flattenedDeepRequired);\n }\n\n const arrayType = options?.readonly\n ? tsReadonlyArray(elementType, options.injectFooter)\n : ts.factory.createArrayTypeNode(legacyTypeNode(elementType));\n\n return ts.factory.createVariableStatement(\n options ? tsModifiers({ export: options.export ?? false }) : undefined,\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n variableName,\n undefined,\n arrayType,\n ts.factory.createArrayLiteralExpression(\n values.map((value) => toValueExpression(ts, value)),\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n );\n}\n\nfunction sanitizeMemberName(name: string) {\n let sanitizedName = name.replace(JS_ENUM_INVALID_CHARS_RE, (c) => {\n // The pattern matches at least one character, so `last` is always a character.\n const last = c.at(-1) ?? \"\";\n return JS_PROPERTY_INDEX_INVALID_CHARS_RE.test(last) ? \"\" : last.toUpperCase();\n });\n if (Number(name[0]) >= 0) {\n sanitizedName = `Value${name}`;\n }\n return sanitizedName;\n}\n\n/** An enum member name: a valid identifier as is; anything else prefixed, replaced or quoted. */\nfunction enumMemberName(value: string | number, explicitName: string | undefined): string {\n let name = explicitName ?? String(value);\n if (JS_PROPERTY_INDEX_RE.test(name)) {\n return name;\n }\n if (Number(name[0]) >= 0) {\n // A decimal point is not valid in a name; keep the digits readable.\n name = `Value${name}`.replace(\".\", \"_\");\n } else if (name[0] === \"-\") {\n name = `ValueMinus${name.slice(1)}`;\n }\n const invalidCharMatch = name.match(JS_PROPERTY_INDEX_INVALID_CHARS_RE);\n if (!invalidCharMatch) {\n return name === \"\" ? quotedMemberName(name) : name;\n }\n if (invalidCharMatch[0] === name) {\n return quotedMemberName(name);\n }\n return name.replace(JS_PROPERTY_INDEX_INVALID_CHARS_RE, (s) =>\n s in SPECIAL_CHARACTER_MAP ? (SPECIAL_CHARACTER_MAP[s] as string) : \"_\",\n );\n}\n\n/**\n * Sanitize TS enum member expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnumMember(\n value: string | number,\n metadata: { name?: string; description?: string | null } = {},\n) {\n const ts = loadTypeScript();\n const name = enumMemberName(value, metadata.name);\n const member = ts.factory.createEnumMember(name, toValueExpression(ts, value));\n const trimmedDescription = enumMemberDescription(metadata.description);\n if (trimmedDescription === \"\") {\n return member;\n }\n\n return ts.addSyntheticLeadingComment(\n member,\n ts.SyntaxKind.SingleLineCommentTrivia,\n ` ${trimmedDescription}`,\n true,\n );\n}\n\n/**\n * Is this a primitive type (string, number, boolean, null, undefined)?\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsIsPrimitive(input: TypeInput): boolean {\n const ts = loadTypeScript();\n if (!input) {\n return true;\n }\n const type = legacyTypeNode(input);\n return (\n ts.SyntaxKind[type.kind] === \"BooleanKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NeverKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NullKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NumberKeyword\" ||\n ts.SyntaxKind[type.kind] === \"StringKeyword\" ||\n ts.SyntaxKind[type.kind] === \"UndefinedKeyword\" ||\n (\"literal\" in type && tsIsPrimitive(type.literal as ts.TypeLiteralNode))\n );\n}\n\n/**\n * Modifiers (readonly)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsModifiers(modifiers: { readonly?: boolean; export?: boolean }): ts.Modifier[] {\n const ts = loadTypeScript();\n const typeMods: ts.Modifier[] = [];\n if (modifiers.export) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ExportKeyword));\n }\n if (modifiers.readonly) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword));\n }\n return typeMods;\n}\n\n/**\n * Create a valid property index\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsPropertyIndex(index: string | number) {\n const ts = loadTypeScript();\n if (\n (typeof index === \"number\" && !(index < 0)) ||\n (typeof index === \"string\" && String(Number(index)) === index && index[0] !== \"-\")\n ) {\n return ts.factory.createNumericLiteral(index);\n }\n return typeof index === \"string\" && JS_PROPERTY_INDEX_RE.test(index)\n ? ts.factory.createIdentifier(index)\n : ts.factory.createStringLiteral(String(index));\n}\n\n/**\n * Enhanced ReadonlyArray.\n * eg: type Foo = ReadonlyArray<T>; type Bar = ReadonlyArray<T[]>\n * Foo and Bar are both of type `readonly T[]`\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsReadonlyArray(type: TypeInput, injectFooter?: FooterEntry[]): ts.TypeNode {\n const ts = loadTypeScript();\n if (injectFooter) {\n requireHelper(injectFooter, HELPER_TYPES.readonlyArray);\n }\n return ts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,QAAA;AACT;AAMO,SAAS,gBAAgB,KAAA,EAAwB;AACtD,EAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,EAAA,IACG,OAAO,KAAA,KAAU,QAAA,IAAY,EAAE,KAAA,GAAQ,CAAA,CAAA,IACvC,OAAO,KAAA,KAAU,QAAA,IAAY,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA,KAAM,SAAS,KAAA,CAAM,CAAC,MAAM,GAAA,EAC9E;AACA,IAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,oBAAA,CAAqB,KAAK,CAAA;AAAA,EAC9C;AACA,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,oBAAA,CAAqB,IAAA,CAAK,KAAK,CAAA,GAC/D,EAAA,CAAG,OAAA,CAAQ,gBAAA,CAAiB,KAAK,CAAA,GACjC,EAAA,CAAG,QAAQ,mBAAA,CAAoB,MAAA,CAAO,KAAK,CAAC,CAAA;AAClD;AAQO,SAAS,eAAA,CAAgB,MAAiB,YAAA,EAA2C;AAC1F,EAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,aAAA,CAAc,YAAA,EAAc,aAAa,aAAa,CAAA;AAAA,EACxD;AACA,EAAA,OAAO,GAAG,OAAA,CAAQ,uBAAA,CAAwB,GAAG,OAAA,CAAQ,gBAAA,CAAiB,eAAe,CAAA,EAAG;AAAA,IACtF,eAAe,IAAI;AAAA,GACpB,CAAA;AACH;;"}
1
+ {"version":3,"file":"legacy-ts-helpers.mjs","sources":["../../src/api/legacy-ts-helpers.ts"],"sourcesContent":["import { toTypeNode, toValueExpression } from \"../adapters/type-ast-bridge/ir-to-typescript.js\";\nimport { lazyNode } from \"../adapters/type-ast-bridge/lazy-node.js\";\nimport { loadTypeScript } from \"../adapters/type-ast-bridge/load-typescript.js\";\nimport type { ts } from \"../adapters/type-ast-bridge/typescript-types.js\";\nimport {\n enumMemberDescription,\n quotedMemberName,\n} from \"../application/transform/footer/enum-naming.js\";\nimport { HELPER_TYPES } from \"../application/transform/helper-types.js\";\nimport { schemaComment } from \"../application/transform/schema-comment.js\";\nimport type { IrType } from \"../domain/ir/nodes.js\";\nimport { declaresTypeAlias, type FooterEntry } from \"./footer-entry.js\";\nimport type { TypeInput } from \"./type-helpers.js\";\n\n/**\n * The original's helpers that build TypeScript compiler nodes, kept for 1.x and deprecated\n * (ADR-004, decision 9). They load TypeScript on first use through the bridge; the generator\n * itself does not use them.\n */\n\nexport const JS_PROPERTY_INDEX_RE = /^[A-Za-z_$][A-Za-z_$0-9]*$/;\nexport const JS_ENUM_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+(.)?/g;\nexport const JS_PROPERTY_INDEX_INVALID_CHARS_RE = /[^A-Za-z_$0-9]+/g;\nexport const SPECIAL_CHARACTER_MAP: Record<string, string> = {\n \"+\": \"Plus\",\n // Add more mappings as needed\n};\n\n/**\n * The `?` token. Created on first use, so importing the package needs no TypeScript.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport const QUESTION_TOKEN: ts.QuestionToken = lazyNode(() => {\n const ts = loadTypeScript();\n return ts.factory.createToken(ts.SyntaxKind.QuestionToken);\n});\n\nexport interface AnnotatedSchemaObject {\n const?: unknown; // jsdoc without value\n default?: unknown; // jsdoc with value\n deprecated?: boolean; // jsdoc without value\n description?: string; // jsdoc with value\n enum?: unknown[]; // jsdoc without value\n example?: string; // jsdoc with value\n examples?: unknown;\n format?: string; // not jsdoc\n nullable?: boolean; // Node information\n summary?: string; // not jsdoc\n title?: string; // not jsdoc\n type?: string | string[]; // Type of node\n}\n\n/**\n * Add the schema's JSDoc comment to a TypeScript property signature.\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function addJSDocComment(\n schemaObject: AnnotatedSchemaObject,\n node: ts.PropertySignature,\n): void {\n const ts = loadTypeScript();\n const comment = schemaComment(schemaObject);\n if (comment) {\n ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, comment.text, true);\n }\n}\n\n/** A type argument of the deprecated helpers as TypeScript; IR from type helpers is converted. */\nfunction legacyTypeNode(type: TypeInput): ts.TypeNode {\n const ts = loadTypeScript();\n return typeof type.kind === \"string\" ? toTypeNode(ts, type as IrType) : (type as ts.TypeNode);\n}\n\n/** Add a helper type alias to the footer once, as a named raw declaration (like the generator). */\nfunction requireHelper(injectFooter: FooterEntry[], helper: { name: string; text: string }): void {\n if (!injectFooter.some((entry) => declaresTypeAlias(entry, helper.name))) {\n injectFooter.push({ kind: \"rawDeclaration\", name: helper.name, text: helper.text });\n }\n}\n\n/**\n * Deduplicate simple primitive types from an array of nodes\n * Note: won’t deduplicate complex types like objects\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsDedupe(types: TypeInput[]): ts.TypeNode[] {\n const encounteredTypes = new Set<number>();\n const filteredTypes: ts.TypeNode[] = [];\n for (const t of types.map(legacyTypeNode)) {\n // only mark for deduplication if this is not a const (\"text\" means it is a const)\n if (!(\"text\" in ((t as ts.LiteralTypeNode).literal ?? t))) {\n const { kind } = (t as ts.LiteralTypeNode).literal ?? t;\n if (encounteredTypes.has(kind)) {\n continue;\n }\n if (tsIsPrimitive(t)) {\n encounteredTypes.add(kind);\n }\n }\n filteredTypes.push(t);\n }\n return filteredTypes;\n}\n\n/** @deprecated The generator keeps its own enum registry per run; kept for 1.x (ADR-004). */\nexport const enumCache: Map<string, ts.EnumDeclaration> = new Map();\n\n/**\n * Create a TS enum (with sanitized name and members)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnum(\n name: string,\n members: (string | number)[],\n metadata?: { name?: string; description?: string | null }[],\n options?: { export?: boolean; shouldCache?: boolean },\n): ts.EnumDeclaration {\n const ts = loadTypeScript();\n let enumName = sanitizeMemberName(name);\n enumName = `${enumName.charAt(0).toUpperCase()}${enumName.substring(1)}`;\n let key = \"\";\n if (options?.shouldCache) {\n key = `${members\n .slice(0)\n .sort()\n .map((v, i) => {\n return `${metadata?.[i]?.name ?? String(v)}:${metadata?.[i]?.description || \"\"}`;\n })\n .join(\",\")}`;\n if (enumCache.has(key)) {\n return enumCache.get(key) as ts.EnumDeclaration;\n }\n }\n const enumDeclaration = ts.factory.createEnumDeclaration(\n /* modifiers */ options ? tsModifiers({ export: options.export ?? false }) : undefined,\n /* name */ enumName,\n /* members */ members.map((value, i) => tsEnumMember(value, metadata?.[i])),\n );\n options?.shouldCache && enumCache.set(key, enumDeclaration);\n return enumDeclaration;\n}\n\n/**\n * Create an exported TS array literal expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsArrayLiteralExpression(\n name: string,\n elementType: TypeInput,\n values: (string | number)[],\n options?: { export?: boolean; readonly?: boolean; injectFooter?: FooterEntry[] },\n): ts.VariableStatement {\n const ts = loadTypeScript();\n let variableName = sanitizeMemberName(name);\n variableName = `${variableName.charAt(0).toLowerCase()}${variableName.substring(1)}`;\n\n if (options?.injectFooter) {\n requireHelper(options.injectFooter, HELPER_TYPES.flattenedDeepRequired);\n }\n\n const arrayType = options?.readonly\n ? tsReadonlyArray(elementType, options.injectFooter)\n : ts.factory.createArrayTypeNode(legacyTypeNode(elementType));\n\n return ts.factory.createVariableStatement(\n options ? tsModifiers({ export: options.export ?? false }) : undefined,\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n variableName,\n undefined,\n arrayType,\n ts.factory.createArrayLiteralExpression(\n values.map((value) => toValueExpression(ts, value)),\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n );\n}\n\nfunction sanitizeMemberName(name: string) {\n let sanitizedName = name.replace(JS_ENUM_INVALID_CHARS_RE, (c) => {\n // The pattern matches at least one character, so `last` is always a character.\n const last = c.at(-1) ?? \"\";\n return JS_PROPERTY_INDEX_INVALID_CHARS_RE.test(last) ? \"\" : last.toUpperCase();\n });\n if (Number(name[0]) >= 0) {\n sanitizedName = `Value${name}`;\n }\n return sanitizedName;\n}\n\n/** An enum member name: a valid identifier as is; anything else prefixed, replaced or quoted. */\nfunction enumMemberName(value: string | number, explicitName: string | undefined): string {\n let name = explicitName ?? String(value);\n if (JS_PROPERTY_INDEX_RE.test(name)) {\n return name;\n }\n if (Number(name[0]) >= 0) {\n // A decimal point is not valid in a name; keep the digits readable.\n name = `Value${name}`.replace(\".\", \"_\");\n } else if (name[0] === \"-\") {\n name = `ValueMinus${name.slice(1)}`;\n }\n const invalidCharMatch = name.match(JS_PROPERTY_INDEX_INVALID_CHARS_RE);\n if (!invalidCharMatch) {\n return name === \"\" ? quotedMemberName(name) : name;\n }\n if (invalidCharMatch[0] === name) {\n return quotedMemberName(name);\n }\n return name.replace(JS_PROPERTY_INDEX_INVALID_CHARS_RE, (s) =>\n s in SPECIAL_CHARACTER_MAP ? (SPECIAL_CHARACTER_MAP[s] as string) : \"_\",\n );\n}\n\n/**\n * Sanitize TS enum member expression\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsEnumMember(\n value: string | number,\n metadata: { name?: string; description?: string | null } = {},\n): ts.EnumMember {\n const ts = loadTypeScript();\n const name = enumMemberName(value, metadata.name);\n const member = ts.factory.createEnumMember(name, toValueExpression(ts, value));\n const trimmedDescription = enumMemberDescription(metadata.description);\n if (trimmedDescription === \"\") {\n return member;\n }\n\n return ts.addSyntheticLeadingComment(\n member,\n ts.SyntaxKind.SingleLineCommentTrivia,\n ` ${trimmedDescription}`,\n true,\n );\n}\n\n/**\n * Is this a primitive type (string, number, boolean, null, undefined)?\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsIsPrimitive(input: TypeInput): boolean {\n const ts = loadTypeScript();\n if (!input) {\n return true;\n }\n const type = legacyTypeNode(input);\n return (\n ts.SyntaxKind[type.kind] === \"BooleanKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NeverKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NullKeyword\" ||\n ts.SyntaxKind[type.kind] === \"NumberKeyword\" ||\n ts.SyntaxKind[type.kind] === \"StringKeyword\" ||\n ts.SyntaxKind[type.kind] === \"UndefinedKeyword\" ||\n (\"literal\" in type && tsIsPrimitive(type.literal as ts.TypeLiteralNode))\n );\n}\n\n/**\n * Modifiers (readonly)\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsModifiers(modifiers: { readonly?: boolean; export?: boolean }): ts.Modifier[] {\n const ts = loadTypeScript();\n const typeMods: ts.Modifier[] = [];\n if (modifiers.export) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ExportKeyword));\n }\n if (modifiers.readonly) {\n typeMods.push(ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword));\n }\n return typeMods;\n}\n\n/**\n * Create a valid property index\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsPropertyIndex(\n index: string | number,\n): ts.Identifier | ts.NumericLiteral | ts.StringLiteral {\n const ts = loadTypeScript();\n if (\n (typeof index === \"number\" && !(index < 0)) ||\n (typeof index === \"string\" && String(Number(index)) === index && index[0] !== \"-\")\n ) {\n return ts.factory.createNumericLiteral(index);\n }\n return typeof index === \"string\" && JS_PROPERTY_INDEX_RE.test(index)\n ? ts.factory.createIdentifier(index)\n : ts.factory.createStringLiteral(String(index));\n}\n\n/**\n * Enhanced ReadonlyArray.\n * eg: type Foo = ReadonlyArray<T>; type Bar = ReadonlyArray<T[]>\n * Foo and Bar are both of type `readonly T[]`\n * @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).\n */\nexport function tsReadonlyArray(type: TypeInput, injectFooter?: FooterEntry[]): ts.TypeNode {\n const ts = loadTypeScript();\n if (injectFooter) {\n requireHelper(injectFooter, HELPER_TYPES.readonlyArray);\n }\n return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(\"ReadonlyArray\"), [\n legacyTypeNode(type),\n ]);\n}\n"],"names":[],"mapp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EAAA,IACG,OAAO,KAAA,KAAU,QAAA,IAAY,EAAE,KAAA,GAAQ,CAAA,CAAA,IACvC,OAAO,KAAA,KAAU,QAAA,IAAY,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA,KAAM,SAAS,KAAA,CAAM,CAAC,MAAM,GAAA,EAC9E;AACA,IAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,oBAAA,CAAqB,KAAK,CAAA;AAAA,EAC9C;AACA,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,oBAAA,CAAqB,IAAA,CAAK,KAAK,CAAA,GAC/D,EAAA,CAAG,OAAA,CAAQ,gBAAA,CAAiB,KAAK,CAAA,GACjC,EAAA,CAAG,QAAQ,mBAAA,CAAoB,MAAA,CAAO,KAAK,CAAC,CAAA;AAClD;AAQO,SAAS,eAAA,CAAgB,MAAiB,YAAA,EAA2C;AAC1F,EAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,aAAA,CAAc,YAAA,EAAc,aAAa,aAAa,CAAA;AAAA,EACxD;AACA,EAAA,OAAO,GAAG,OAAA,CAAQ,uBAAA,CAAwB,GAAG,OAAA,CAAQ,gBAAA,CAAiB,eAAe,CAAA,EAAG;AAAA,IACtF,eAAe,IAAI;AAAA,GACpB,CAAA;AACH;;"}
@@ -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,KAA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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,S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4B,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,CAA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;AAAA,KACpE;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAQO,SAAS,UAAA,CACd,MAAA,EACA,IAAA,EACA,OAAA,EACe;AACf,EAAA,OAAO,kBAAA,CAAsB,MAAA,EAAQ,IAAA,EAAM,OAAO,CAAA;AACpD;AAMO,SAAS,IAAA,CACd,GAAA,EACA,EAAA,EACA,IAAA,GAA4B,EAAC,EACvB;AACN,EAAA,YAAA,CAAa,GAAA,EAAK,IAAI,IAAI,CAAA;AAC5B;AAMO,SAAS,IAAA,CAAK,GAAA,EAAa,MAAA,GAAS,KAAA,EAAO;AAChD,EAAA,aAAA,CAAc,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAChC;;"}
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: 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;AAC9B;AAMO,SAAS,KAAA,CAAM,GAAA,EAAa,KAAA,EAAgB,IAAA,EAAe;AAEhE,EAAA,aAAA,CAAc,KAAK,CAAA,CAAE,KAAA,CAAM,GAAA,EAAK,OAAiC,IAAI,CAAA;AACvE;AAMO,SAAS,MAAM,GAAA,EAAa;AACjC,EAAA,aAAA,CAAc,KAAK,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA;AAChC;AAGO,SAAS,WAAW,CAAA,EAAW;AACpC,EAAA,OAAO,OAAO,CAAA,KAAM,QAAA,GAAW,cAAA,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,OAAO,kBAAA,CAAsB,MAAA,EAAQ,IAAA,EAAM,OAAO,CAAA;AACpD;AAMO,SAAS,IAAA,CACd,GAAA,EACA,EAAA,EACA,IAAA,GAA4B,EAAC,EACvB;AACN,EAAA,YAAA,CAAa,GAAA,EAAK,IAAI,IAAI,CAAA;AAC5B;AAMO,SAAS,IAAA,CAAK,GAAA,EAAa,MAAA,GAAS,KAAA,EAAO;AAChD,EAAA,aAAA,CAAc,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAChC;;"}
@@ -26,7 +26,8 @@ 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
32
  return { loader, logger, redoc, now: defaultPorts.monotonicNow };
32
33
  }
@@ -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 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 remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,\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","DEFAULT_REMOTE_DOCUMENT_LIMITS"],"mappings":";;;;;;;;;;AAoBA,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,kCAAA;AAAA,IACpB,oBAAA,EAAsBC;AAAA,GACvB,CAAA;AACD,EAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,EAAQ,KAAA,EAAO,KAAKF,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,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, 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,7 +22,8 @@ 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
28
  return { loader, logger, redoc, now: monotonicNow };
28
29
  }
@@ -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 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 remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,\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":";;;;;;AAoBA,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,qBAAA;AAAA,IACpB,oBAAA,EAAsB;AAAA,GACvB,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;;"}
@@ -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,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;AAA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A,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;AAAA,IACxB,mBAAmB,GAAA,CAAI,iBAAA;AAAA,IACvB,WAAW,GAAA,CAAI,SAAA;AAAA,IACf,yBAAyB,GAAA,CAAI,uBAAA;AAAA,IAC7B,qBAAqB,GAAA,CAAI,mBAAA;AAA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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,GAAA,CAAI,mBAAA;AAAA,IACzB,YAAY,GAAA,CAAI,UAAA;AAAA,IAChB,QAAQ,GAAA,CAAI,MAAA;AAAA,IACZ,eAAe,GAAA,CAAI;AAAA,GACrB;AACF;AAGA,SAAS,UAA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A,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":";;;;;;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,W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;AACrD,EAAA,OAAO;AAAA,IACL,GAAA,EAAK,YAAA;AAAA,IACL,KAAA,EAAO,CAAC,OAAA,EAAS,UAAA,KAAe,OAAO,KAAA,CAAM,OAAA,EAAS,MAAM,UAAU;AAAA,GACxE;AACF;AAGO,SAAS,uBAAuB,GAAA,EAAmC;AACxE,EAAA,OAAO;AAAA,IACL,OAAA,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,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 +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":";;;;;;;;;;;;;;;;;AAoBA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,aAAa,KAAA,EAA6B;AACjD,EAAA,MAAM,OAAOA,2BAAA,CAAgB,KAAK,IAC7B,KAAA,CAA4B,IAAA,GAC5B,MAA2C,IAAA,EAAM,WAAA;AACtD,EAAA,OAAO,IAAA,KAAS,eAAA;AAClB;AAGA,MAAM,cAAc,MAAY,MAAA;AAChC,MAAM,mBAAmB,EAAE,KAAA,EAAO,aAAa,IAAA,EAAM,WAAA,EAAa,OAAO,WAAA,EAAY;AAcrF,SAAS,iBAAA,CACPC,UAAA,EACA,GAAA,EACA,QAAA,EACiB;AACjB,EAAA,MAAM,eAA8B,EAAC;AACrC,EAAA,MAAM,OAAA,GAAyB;AAAA,IAC7B,GAAG,GAAA;AAAA,IACH,YAAA;AAAA,IACA,SAAA,EAAW,IAAIC,wBAAA,CAAU,IAAIC,6BAAkB,YAAY,CAAA,EAAG,MAAM,QAAQ,CAAA;AAAA,IAC5E,MAAA,EAAQ,gBAAA;AAAA,IACR,sBAAA,sBAA4B,GAAA;AAAI,GAClC;AACA,EAAA,MAAM,cAAA,GAAiB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,UAAA,EAAY;AAC9B,MAAA,GAAA,CAAI,QAAQ,IAAA,CAAKU,wCAAA,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,MAAMT,UAAA,GAAW,MAAA;AACjB,EAAA,mBAAA,CAAoBA,YAAU,GAAG,CAAA;AACjC,EAAA,MAAM,OAAA,GAAUG,wCAAuB,GAAG,CAAA;AAE1C,EAAA,MAAM,OAAA,GAAUC,sBAAaJ,UAAA,EAAU,OAAA,EAAS,MAAM,GAAA,CAAI,YAAA,CAAa,MAAA,CAAOD,2BAAe,CAAC,CAAA;AAC9F,EAAA,MAAM,MAAA,GAAS,kBAAkB,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 { 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 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(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: 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","OutputFix","SharedEnumNameRecorder","FirstSchemaNameRecorder","checkedEnumValues","excludedValuesWarning","documentClosing","renameTakenAliases","documentDeclarations"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,MAAM,eAAA,GAAkB,YAAA;AAGxB,SAAS,aAAa,KAAA,EAA6B;AACjD,EAAA,MAAM,OAAOA,2BAAA,CAAgB,KAAK,IAC7B,KAAA,CAA4B,IAAA,GAC5B,MAA2C,IAAA,EAAM,WAAA;AACtD,EAAA,OAAO,IAAA,KAAS,eAAA;AAClB;AAGA,MAAM,cAAc,MAAY,MAAA;AAChC,MAAM,mBAAmB,EAAE,KAAA,EAAO,aAAa,IAAA,EAAM,WAAA,EAAa,OAAO,WAAA,EAAY;AAcrF,SAAS,iBAAA,CACPC,UAAA,EACA,GAAA,EACA,QAAA,EACiB;AACjB,EAAA,MAAM,eAA8B,EAAC;AACrC,EAAA,MAAM,OAAA,GAAsB;AAAA,IAC1B,GAAG,GAAA;AAAA,IACH,YAAA;AAAA,IACA,SAAA,EAAW,IAAIC,wBAAA,CAAU,IAAIC,6BAAkB,YAAY,CAAA,EAAG,MAAM,QAAQ,CAAA;AAAA,IAC5E,MAAA,EAAQ,gBAAA;AAAA,IACR,sBAAA,sBAA4B,GAAA;AAAI,GAClC;AACA,EAAA,MAAM,cAAA,GAAiBC,wCAAuB,OAAO,CAAA;AACrD,EAAA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AAI,QAAQ,IAAA,CAAKU,wCAAA,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,EAAsC;AACxF,EAAA,MAAMT,UAAA,GAAW,MAAA;AACjB,EAAA,mBAAA,CAAoBA,YAAU,GAAG,CAAA;AACjC,EAAA,MAAM,OAAA,GAAUG,wCAAuB,GAAG,CAAA;AAE1C,EAAA,MAAM,OAAA,GAAUC,sBAAaJ,UAAA,EAAU,OAAA,EAAS,MAAM,GAAA,CAAI,YAAA,CAAa,MAAA,CAAOD,2BAAe,CAAC,CAAA;AAC9F,EAAA,MAAM,MAAA,GAAS,kBAAkB,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 +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,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;AAGA,SAAS,mBAAmB,GAAA,EAA6C;AACvE,EAAA,IAAI,GAAA,CAA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F,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 { 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 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(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: 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: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AAO,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":