@kubb/plugin-ts 5.5.0-canary.20261111T122006 → 5.5.1
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.
- package/dist/index.cjs +691 -821
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -7
- package/dist/index.d.ts +25 -7
- package/dist/index.js +692 -822
- package/dist/index.js.map +1 -1
- package/docs/guides/customization.md +5 -5
- package/docs/options.md +7 -5
- package/kubb-extension.json +1 -1
- package/package.json +7 -7
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isNonNullable","getEnumNames","factory.createEnumDeclaration","getEnumNames","factory","factory.print","factory.createRaw","factory.createTypeReferenceNode","factory.createUrlTemplateType","factory.dateOrStringNode","factory.createUnionDeclaration","factory.constToTypeNode","factory.createIntersectionDeclaration","factory.createTypeLiteralNode","factory.buildMemberNodes","factory.createArrayDeclaration","factory.buildTupleNode","factory.buildPropertyType","factory.createPropertySignature","factory.appendJSDocToNode","factory.buildIndexSignatures","factory.createOmitDeclaration","factory.wrapNullableOptional","factory.createTypeDeclaration","getEnumNames"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/strings.ts","../../../internals/utils/src/fs.ts","../src/factory.ts","../src/components/Enum.tsx","../../../internals/shared/src/operation.ts","../../../internals/shared/src/resolver.ts","../../../internals/shared/src/group.ts","../../../internals/shared/src/schemaTraversal.ts","../src/utils.ts","../src/printers/printerTs.ts","../src/components/Type.tsx","../src/generators/typeGenerator.tsx","../kubb-extension.json","../package.json","../src/resolvers/resolverTs.ts","../src/plugin.ts","../src/printers/functionParams.ts","../src/printers/functionPrinter.ts"],"sourcesContent":["type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n// A word starts at `petType`, `sensor2Reading`, and `HTTPResponse`, while `IDs` and `OAuth` stay whole\nconst wordStart = /(?<=[a-z\\d])(?=[A-Z])|(?<=[A-Z]{2})(?=[A-Z][a-z]{2})/\n\n/**\n * Splits `text` into words on separators (whitespace, hyphens, underscores, dots, slashes, colons)\n * and on {@link wordStart}. A segment without lowercase letters, such as `COOL` or `2D`, is one word,\n * so snake case leaves a name that is already in it unchanged.\n */\nfunction words(text: string): Array<string> {\n return text\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .flatMap((segment) => (segment === segment.toUpperCase() ? segment : segment.split(wordStart)))\n}\n\n/**\n * Uppercases only the first character of `text`, leaving the rest untouched.\n * Unlike `pascalCase` it never re-splits word boundaries or strips characters.\n *\n * @example\n * `capitalize('getPetById') // 'GetPetById'`\n */\nexport function capitalize(text: string): string {\n return `${text.charAt(0).toUpperCase()}${text.slice(1)}`\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example From camelCase\n * `snakeCase('helloWorld') // 'hello_world'`\n *\n * @example From mixed separators\n * `snakeCase('Hello-World') // 'hello_world'`\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return words(`${prefix} ${text} ${suffix}`)\n .map((word) => word.replace(/[^a-zA-Z0-9]/g, '').toLowerCase())\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example From camelCase\n * `screamingSnakeCase('helloWorld') // 'HELLO_WORLD'`\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'await',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `name` when it's a syntactically valid JavaScript variable name,\n * otherwise prefixes it with `_` so the result is a valid identifier.\n *\n * Useful for sanitizing OpenAPI schema names or operation IDs that start with\n * a digit (e.g. `409`, `504AccountCancel`) before using them as exported\n * variable, type, or function names.\n *\n * @example\n * ```ts\n * ensureValidVarName('409') // '_409'\n * ensureValidVarName('504AccountCancel') // '_504AccountCancel'\n * ensureValidVarName('Pet') // 'Pet'\n * ensureValidVarName('class') // '_class'\n * ```\n */\nexport function ensureValidVarName(name: string): string {\n if (!name || isValidVarName(name)) {\n return name\n }\n return `_${name}`\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","/**\n * Wraps a value in single quotes for emitting a single-quoted JavaScript string literal, escaping\n * any backslash or single quote in the content.\n *\n * @example\n * ```ts\n * singleQuote('foo') // \"'foo'\"\n * singleQuote(\"o'clock\") // \"'o\\\\'clock'\"\n * ```\n */\nexport function singleQuote(value: string | number | boolean | undefined | null): string {\n if (value === undefined || value === null) return \"''\"\n const escaped = String(value).replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")\n\n return `'${escaped}'`\n}\n\n/**\n * Strips a single matching pair of `\"...\"`, `'...'`, or `` `...` `` from both ends of `text`.\n * Returns the string unchanged when no balanced quote pair is found.\n *\n * @example\n * ```ts\n * trimQuotes('\"hello\"') // 'hello'\n * trimQuotes('hello') // 'hello'\n * ```\n */\nexport function trimQuotes(text: string): string {\n if (text.length >= 2) {\n const first = text[0]\n const last = text[text.length - 1]\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\") || (first === '`' && last === '`')) {\n return text.slice(1, -1)\n }\n }\n return text\n}\n\n/**\n * Serializes a primitive to a single-quoted string literal, stripping any surrounding quotes first.\n *\n * Escaping runs through `JSON.stringify`, then the result switches to single quotes so the generated\n * code matches the repo style without a formatter.\n *\n * @example\n * ```ts\n * stringify('hello') // \"'hello'\"\n * stringify('\"hello\"') // \"'hello'\"\n * ```\n */\nexport function stringify(value: string | number | boolean | undefined): string {\n if (value === undefined || value === null) return \"''\"\n const json = JSON.stringify(trimQuotes(value.toString()))\n const inner = json.slice(1, -1).replace(/\\\\\"/g, '\"').replace(/'/g, \"\\\\'\")\n return `'${inner}'`\n}\n\n/**\n * Escapes an `@` at the start of a line, so a multi-line description can't start a new JSDoc tag.\n * Editors render `\\@` as `@` in hovers.\n *\n * @example\n * ```ts\n * jsDocEscape('intro\\n@example value') // 'intro\\n\\\\@example value'\n * ```\n */\nexport function jsDocEscape(input: unknown): string {\n return `${input}`.replace(/^(\\s*)@/gm, '$1\\\\@')\n}\n\n/**\n * Escapes characters that are not allowed inside JS string literals, covering quotes, backslashes,\n * and the Unicode line terminators U+2028 and U+2029.\n *\n * @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4\n *\n * @example\n * ```ts\n * jsStringEscape('say \"hi\"\\nbye') // 'say \\\\\"hi\\\\\"\\\\nbye'\n * ```\n */\nexport function jsStringEscape(input: unknown): string {\n return `${input}`.replace(/[\"'\\\\\\n\\r\\u2028\\u2029]/g, (character) => {\n switch (character) {\n case '\"':\n case \"'\":\n case '\\\\':\n return `\\\\${character}`\n case '\\n':\n return '\\\\n'\n case '\\r':\n return '\\\\r'\n case '\\u2028':\n return '\\\\u2028'\n case '\\u2029':\n return '\\\\u2029'\n default:\n return ''\n }\n })\n}\n\n// `\\p{`, `\\P{` or `\\u{` behind an odd number of backslashes, or a character outside the BMP: both need the `u` flag.\nconst NEEDS_UNICODE = /(?<!\\\\)(?:\\\\\\\\)*\\\\[pPu]\\{|[\\u{10000}-\\u{10FFFF}]/u\n// Escapes the `u` flag accepts. `\\-` only counts inside a class.\nconst KEPT_ESCAPE = /[A-Za-z0-9^$\\\\.*+?()[\\]{}|/]/\n\n/**\n * Drops the backslash from escapes that the `u` flag rejects: an escaped punctuation character that is\n * not a syntax character, and `\\-` outside a class. Both match the same character without the backslash.\n */\nfunction dropIdentityEscapes(pattern: string): string {\n let inClass = false\n\n return pattern.replace(/\\\\(.)|[[\\]]/gs, (match, escaped?: string) => {\n if (escaped === undefined) {\n inClass = match === '['\n return match\n }\n\n return KEPT_ESCAPE.test(escaped) || (escaped === '-' && inClass) ? match : escaped\n })\n}\n\n/**\n * Builds the `RegExp` for a pattern, adding the `u` flag when it uses `\\p{...}`, `\\P{...}` or `\\u{...}`, or\n * holds a character outside the BMP. A pattern that is not valid under `u` keeps the flags it came with.\n */\nfunction toRegExp(pattern: string, flags: string | undefined): RegExp {\n if (flags?.includes('u') || !NEEDS_UNICODE.test(pattern)) return new RegExp(pattern, flags)\n\n try {\n return new RegExp(dropIdentityEscapes(pattern), `${flags ?? ''}u`)\n } catch {\n return new RegExp(pattern, flags)\n }\n}\n\n/**\n * Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.\n * Inline flags expressed as a `^(?im)` prefix are extracted and applied to the resulting expression.\n * Pass `null` as the second argument to emit a `/pattern/flags` literal instead.\n *\n * @example\n * ```ts\n * toRegExpString('^(?im)foo') // 'new RegExp(\"^foo\", \"im\")'\n * toRegExpString('^(?im)foo', null) // '/^foo/im'\n * ```\n */\nexport function toRegExpString(text: string, func: string | null = 'RegExp'): string {\n const raw = trimQuotes(text)\n\n const match = raw.match(/^\\^(\\(\\?([igmsuy]+)\\))/i)\n const replacementTarget = match?.[1] ?? ''\n const matchedFlags = match?.[2]\n const cleaned = raw\n .replace(/^\\\\?\\//, '')\n .replace(/\\\\?\\/$/, '')\n .replace(replacementTarget, '')\n\n const { source, flags } = toRegExp(cleaned, matchedFlags)\n\n if (func === null) return `/${source}/${flags}`\n\n return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ''})`\n}\n\n/**\n * Renders a dotted path or string array as an optional-chaining accessor expression rooted at\n * `accessor`. Returns `null` for an empty path.\n *\n * @example\n * ```ts\n * getNestedAccessor('pagination.next.id', 'lastPage')\n * // \"lastPage?.['pagination']?.['next']?.['id']\"\n * ```\n */\nexport function getNestedAccessor(param: string | Array<string>, accessor: string): string | null {\n const parts = Array.isArray(param) ? param : param.split('.')\n if (parts.length === 0 || (parts.length === 1 && parts[0] === '')) return null\n return `${accessor}?.['${`${parts.join(\"']?.['\")}']`}`\n}\n","import { posix } from 'node:path'\nimport { camelCase } from '@kubb/kit'\n\nfunction toSlash(p: string): string {\n if (p.startsWith('\\\\\\\\?\\\\')) return p\n return p.replaceAll('\\\\', '/')\n}\n\n/**\n * Returns the relative path from `rootDir` to `filePath`, always using forward slashes\n * and prefixed with `./` when not already traversing upward.\n *\n * @example\n * ```ts\n * getRelativePath('/src/components', '/src/components/Button.tsx') // './Button.tsx'\n * getRelativePath('/src/components', '/src/utils/helpers.ts') // '../utils/helpers.ts'\n * ```\n */\nexport function getRelativePath(rootDir: string, filePath: string): string {\n const relativePath = posix.relative(toSlash(rootDir), toSlash(filePath))\n\n return relativePath.startsWith('../') ? relativePath : `./${relativePath}`\n}\n\n/**\n * Builds a nested file path from a dotted name. Splits on dots that precede a letter\n * (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases\n * every earlier segment, applies `caseLast` to the final segment, and joins with `/`.\n *\n * Empty segments are dropped before joining. They arise when the name starts with a dot\n * followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to\n * an empty string). Without this a leading `/` would form, which `path.resolve` reads as an\n * absolute path, letting generated files escape the configured output directory.\n *\n * @example Nested path from a dotted name\n * `toFilePath('pet.petId') // 'pet/petId'`\n *\n * @example PascalCase the final segment\n * `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`\n *\n * @example Suffix applied to the final segment only\n * `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`\n */\nexport function toFilePath(name: string, caseLast: (part: string) => string = camelCase): string {\n const parts = name.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => (i === parts.length - 1 ? caseLast(part) : camelCase(part)))\n .filter(Boolean)\n .join('/')\n}\n","import { screamingSnakeCase, snakeCase } from '@internals/utils'\nimport { camelCase, pascalCase, syncSchemaRef } from '@kubb/kit'\nimport type { ast } from '@kubb/kit'\nimport { generate } from 'yuku-codegen'\n\n/**\n * A TS-ESTree node, the AST shape `yuku-codegen` prints. Nodes built here carry no source positions.\n */\nexport type TsNode = { type: string; [key: string]: unknown }\n\nfunction isNumber(value: unknown): value is number {\n return typeof value === 'number' && !Number.isNaN(value)\n}\n\nexport function isNonNullable<T>(value: T | null | undefined): value is T {\n return value !== null && value !== undefined\n}\n\n/**\n * Prints `node` as TypeScript source with single quotes and two-space indentation.\n */\nexport function print(node: TsNode): string {\n return generate(node as unknown as Parameters<typeof generate>[0], { quotes: 'single' }).code\n}\n\n/**\n * Wraps already printed TypeScript, such as a user override result, so it can sit inside a node tree.\n * Parentheses keep a union or function type intact when it lands inside an array or intersection.\n */\nexport function createRaw(text: string): TsNode {\n const name = { type: 'TSTypeReference', typeName: identifier(text), typeArguments: null }\n return /[|&?]|=>/.test(text) ? { type: 'TSParenthesizedType', typeAnnotation: name } : name\n}\n\nfunction identifier(name: string): TsNode {\n return { type: 'Identifier', name }\n}\n\nfunction literal(value: string | number | boolean): TsNode {\n return { type: 'Literal', value }\n}\n\nfunction createLiteralType(value: string | number | boolean): TsNode {\n return { type: 'TSLiteralType', literal: literal(value) }\n}\n\n/**\n * Whether `name` can be written as a bare property name instead of a quoted string.\n */\nfunction isValidIdentifier(name: string): boolean {\n return /^[\\p{ID_Start}$_][\\p{ID_Continue}$]*$/u.test(name)\n}\n\n/**\n * A property or enum member name, quoted when it is not a valid identifier.\n */\nfunction propertyName(name: string): TsNode {\n return isValidIdentifier(name) ? identifier(name) : literal(name)\n}\n\n/**\n * Indents every non-empty line of `text` by two spaces.\n */\nfunction indent(text: string): string {\n return text\n .split('\\n')\n .map((line) => (line ? ` ${line}` : line))\n .join('\\n')\n}\n\n/**\n * Creates a TypeScript intersection type.\n * Returns the single type if only one is provided. `yuku-codegen` adds the parentheses a union member needs.\n */\nexport function createIntersectionDeclaration({ nodes, withParentheses }: { nodes: Array<TsNode>; withParentheses?: boolean }): TsNode | null {\n if (!nodes.length) {\n return null\n }\n\n if (nodes.length === 1) {\n return nodes[0] || null\n }\n\n const node = { type: 'TSIntersectionType', types: nodes }\n\n return withParentheses ? { type: 'TSParenthesizedType', typeAnnotation: node } : node\n}\n\n/**\n * Creates a TypeScript array type.\n * Use `arrayType: 'array'` for bracket syntax (`T[]`), or `'generic'` for `Array<T>`.\n *\n * @example Array bracket syntax\n * `createArrayDeclaration({ nodes: [string], arrayType: 'array' }) // → string[]`\n *\n * @example Generic Array syntax\n * `createArrayDeclaration({ nodes: [string], arrayType: 'generic' }) // → Array<string>`\n */\nexport function createArrayDeclaration({ nodes, arrayType = 'array' }: { nodes: Array<TsNode>; arrayType?: 'array' | 'generic' }): TsNode {\n if (!nodes.length) {\n return { type: 'TSTupleType', elementTypes: [] }\n }\n\n const node = nodes.length === 1 ? nodes[0]! : { type: 'TSUnionType', types: nodes }\n\n return arrayType === 'generic' ? createTypeReferenceNode('Array', [node]) : { type: 'TSArrayType', elementType: node }\n}\n\n/**\n * Minimum nodes length of 2\n * @example Union type example\n * `string | number`\n */\nexport function createUnionDeclaration({ nodes, withParentheses }: { nodes: Array<TsNode>; withParentheses?: boolean }): TsNode {\n if (!nodes.length) {\n return keywordTypeNodes.any\n }\n\n if (nodes.length === 1) {\n return nodes[0]!\n }\n\n const node = { type: 'TSUnionType', types: nodes }\n\n return withParentheses ? { type: 'TSParenthesizedType', typeAnnotation: node } : node\n}\n\n/**\n * Creates a TypeScript property signature for object/interface members.\n * Supports optional markers, readonly modifiers, and type annotations.\n */\nexport function createPropertySignature({\n readOnly,\n name,\n questionToken,\n type,\n}: {\n readOnly?: boolean\n name: string\n questionToken?: boolean\n type?: TsNode\n}): TsNode {\n return {\n type: 'TSPropertySignature',\n key: propertyName(name),\n computed: false,\n optional: !!questionToken,\n readonly: !!readOnly,\n static: false,\n typeAnnotation: type ? { type: 'TSTypeAnnotation', typeAnnotation: type } : null,\n }\n}\n\n/**\n * Attaches a JSDoc block built from `comments` to `node`, dropping empty comments.\n */\nexport function appendJSDocToNode<TNode extends TsNode>({ node, comments }: { node: TNode; comments: Array<string | undefined> }): TNode {\n const lines = comments.filter(Boolean).flatMap((comment = '') => comment.split(/\\r?\\n/))\n\n if (!lines.length) {\n return node\n }\n\n // `yuku-codegen` prints the comment text as is, so a `*/` inside it would end the block early\n const value = `*\\n${lines.map((line) => ` * ${line.replaceAll('*/', '*\\\\/')}`.trimEnd()).join('\\n')}\\n `\n\n return { ...node, comments: [{ type: 'Block', value, position: 'before', sameLine: false }] }\n}\n\n/**\n * Creates a TypeScript type literal (anonymous object type) with one member per line.\n */\nexport function createTypeLiteralNode(members: Array<TsNode>): TsNode {\n return { type: 'TSTypeLiteral', members }\n}\n\n/**\n * Creates a TypeScript type reference (e.g., `Array<string>`, `Record<K, V>`).\n */\nexport function createTypeReferenceNode(name: string, typeArguments?: Array<TsNode>): TsNode {\n return {\n type: 'TSTypeReference',\n typeName: identifier(name),\n typeArguments: typeArguments?.length ? { type: 'TSTypeParameterInstantiation', params: typeArguments } : null,\n }\n}\n\nfunction exportNamed(declaration: TsNode, exportKind: 'type' | 'value'): TsNode {\n return { type: 'ExportNamedDeclaration', declaration, specifiers: [], source: null, attributes: [], exportKind }\n}\n\n/**\n * Prints a TypeScript type declaration as either a type alias or interface.\n * Uses interface syntax only when requested and the type is an object literal, and attaches JSDoc comments.\n */\nexport function createTypeDeclaration({\n syntax,\n isExportable,\n comments,\n name,\n type,\n}: {\n syntax: 'type' | 'interface'\n comments: Array<string | undefined>\n isExportable?: boolean\n name: string\n type: TsNode\n}): string {\n const declaration =\n syntax === 'interface' && type.type === 'TSTypeLiteral'\n ? {\n type: 'TSInterfaceDeclaration',\n declare: false,\n id: identifier(name),\n typeParameters: null,\n extends: [],\n body: { type: 'TSInterfaceBody', body: type.members },\n }\n : { type: 'TSTypeAliasDeclaration', declare: false, id: identifier(name), typeParameters: null, typeAnnotation: type }\n\n return print(appendJSDocToNode({ node: isExportable ? exportNamed(declaration, 'type') : declaration, comments }))\n}\n\n/**\n * Converts an enum member value to a literal. Numbers become numeric literals unless `asNumber` is `false`,\n * which emits the string form.\n */\nfunction valueToExpression(value: string | number | boolean, asNumber = isNumber(value)): TsNode {\n return literal(typeof value === 'boolean' || (asNumber && isNumber(value)) ? value : value.toString())\n}\n\n/**\n * Apply casing transformation to enum keys\n */\nfunction applyEnumKeyCasing(key: string, casing: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none' = 'none'): string {\n if (casing === 'none') {\n return key\n }\n if (casing === 'screamingSnakeCase') {\n return screamingSnakeCase(key)\n }\n if (casing === 'snakeCase') {\n return snakeCase(key)\n }\n if (casing === 'pascalCase') {\n return pascalCase(key)\n }\n if (casing === 'camelCase') {\n return camelCase(key)\n }\n return key\n}\n\n/**\n * Creates a TypeScript enum declaration or equivalent construct in various formats.\n * Returns a tuple of [name declaration, type declaration] - the name declaration may be undefined for certain types.\n *\n * @example\n * ```ts\n * const [name, type] = createEnumDeclaration({\n * type: 'enum',\n * name: 'petType',\n * typeName: 'PetType',\n * enums: [['cat', 'cat', 'A cat'], ['dog', 'dog']],\n * })\n * ```\n */\nexport function createEnumDeclaration({\n type = 'enum',\n name,\n typeName,\n enums,\n enumKeyCasing = 'none',\n}: {\n /**\n * Choose to use `enum`, `asConst`, `constEnum`, or `literal` for enums.\n * - `enum`: TypeScript enum\n * - `asConst`: const object asserted with `as const` (the caller decides the const name casing)\n * - `constEnum`: const enum\n * - `literal`: literal union type\n * @default `'enum'`\n */\n type?: 'enum' | 'asConst' | 'constEnum' | 'literal' | 'inlineLiteral'\n /**\n * Enum name in camelCase.\n */\n name: string\n /**\n * Enum name in PascalCase.\n */\n typeName: string\n enums: Array<[key: string | number, value: string | number | boolean, description?: string]>\n /**\n * Choose the casing for enum key names.\n * @default 'none'\n */\n enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none'\n}): [name: string | undefined, type: string] {\n const typeAlias = (annotation: TsNode) => createTypeDeclaration({ syntax: 'type', isExportable: true, name: typeName, comments: [], type: annotation })\n\n if (type === 'literal' || type === 'inlineLiteral') {\n const members = enums\n .map(([_key, value]) => (isNonNullable(value) ? { type: 'TSLiteralType', literal: valueToExpression(value) } : undefined))\n .filter(isNonNullable)\n\n return [undefined, typeAlias(members.length ? createUnionDeclaration({ nodes: members }) : keywordTypeNodes.never)]\n }\n\n if (type === 'enum' || type === 'constEnum') {\n const members = enums\n .map(([key, value, description]) => {\n const initializer = valueToExpression(value, Number.parseInt(value.toString(), 10) === value)\n const memberName = isNumber(Number.parseInt(key.toString(), 10)) ? `${typeName}_${key}` : key?.toString()\n if (memberName === undefined) return undefined\n\n const id = propertyName(applyEnumKeyCasing(memberName, enumKeyCasing))\n return appendJSDocToNode({ node: { type: 'TSEnumMember', id, initializer }, comments: [description] })\n })\n .filter(isNonNullable)\n\n const declaration = {\n type: 'TSEnumDeclaration',\n declare: false,\n const: type === 'constEnum',\n id: identifier(typeName),\n body: { type: 'TSEnumBody', members },\n }\n\n return [undefined, print(exportNamed(declaration, 'value'))]\n }\n\n // used when using `as const` instead of an TypeScript enum.\n // name is already cased by the caller (camelCase or pascalCase, driven by enum.constCasing).\n // typeName carries the typeSuffix for the type alias, so we use name for the const identifier.\n const identifierName = name\n\n // When there are no enum items (empty or all-null enum), don't generate a runtime const.\n // Return undefined for nameNode so the barrel won't try to export a non-existent symbol.\n // Use `never` as the type alias to keep references valid without creating a broken const.\n if (enums.length === 0) {\n return [undefined, typeAlias(keywordTypeNodes.never)]\n }\n\n // `yuku-codegen` prints object literals on one line, so each property prints on its own and the lines join here\n const properties = enums\n .map(([key, value, description]) => {\n if (key === null || key === undefined) return undefined\n\n const property = {\n type: 'Property',\n kind: 'init',\n key: propertyName(applyEnumKeyCasing(key.toString(), enumKeyCasing)),\n value: valueToExpression(value),\n computed: false,\n method: false,\n shorthand: false,\n }\n return print(appendJSDocToNode({ node: property, comments: [description] }))\n })\n .filter(isNonNullable)\n\n const query = { type: 'TSTypeQuery', exprName: identifier(identifierName), typeArguments: null }\n\n return [\n `export const ${identifierName} = {\\n${properties.map(indent).join(',\\n')},\\n} as const;`,\n typeAlias({\n type: 'TSIndexedAccessType',\n objectType: { type: 'TSParenthesizedType', typeAnnotation: query },\n indexType: { type: 'TSTypeOperator', operator: 'keyof', typeAnnotation: query },\n }),\n ]\n}\n\n/**\n * Creates a TypeScript `Omit<T, Keys>` type reference.\n * Optionally wraps the type in `NonNullable<T>` if `nonNullable` is true.\n */\nexport function createOmitDeclaration({ keys, type, nonNullable }: { keys: Array<string> | string; type: TsNode; nonNullable?: boolean }): TsNode {\n const node = nonNullable ? createTypeReferenceNode('NonNullable', [type]) : type\n\n return createTypeReferenceNode('Omit', [node, createUnionDeclaration({ nodes: [keys].flat().map(createLiteralType) })])\n}\n\n/**\n * TypeScript keyword types for common primitive types.\n */\nexport const keywordTypeNodes = {\n any: { type: 'TSAnyKeyword' },\n unknown: { type: 'TSUnknownKeyword' },\n void: { type: 'TSVoidKeyword' },\n number: { type: 'TSNumberKeyword' },\n integer: { type: 'TSNumberKeyword' },\n bigint: { type: 'TSBigIntKeyword' },\n object: { type: 'TSObjectKeyword' },\n string: { type: 'TSStringKeyword' },\n boolean: { type: 'TSBooleanKeyword' },\n undefined: { type: 'TSUndefinedKeyword' },\n null: { type: 'TSNullKeyword' },\n never: { type: 'TSNeverKeyword' },\n} as const satisfies Record<string, TsNode>\n\n/**\n * Converts an OAS-style path (e.g. `/pets/{petId}`) or an Express-style path\n * (e.g. `/pets/:petId`) to a TypeScript template literal type\n * like `` `/pets/${string}` ``.\n */\nexport function createUrlTemplateType(path: string): TsNode {\n // normalized Express `:param` → OAS `{param}` so a single regex handles both.\n const normalized = path.replace(/:([^/]+)/g, '{$1}')\n\n if (!normalized.includes('{')) {\n return createLiteralType(normalized)\n }\n\n const segments = normalized.split(/\\{[^}]+\\}/)\n // `yuku-codegen` escapes the cooked text itself when no raw text is given\n const quasis = segments.map((cooked, i) => ({ type: 'TemplateElement', value: { cooked }, tail: i === segments.length - 1 }))\n\n return { type: 'TSTemplateLiteralType', quasis, types: segments.slice(1).map(() => keywordTypeNodes.string) }\n}\n\n// ─── Printer helpers ──────────────────────────────────────────────────────────\n\n/**\n * Converts a const value to a literal type, preserving nested arrays and objects.\n */\nexport function constToTypeNode(value: unknown, format?: 'string' | 'number' | 'boolean'): TsNode {\n if (value === null) return keywordTypeNodes.null\n if (Array.isArray(value)) {\n return { type: 'TSTupleType', elementTypes: value.map((item) => constToTypeNode(item)) }\n }\n if (typeof value === 'object') {\n return createTypeLiteralNode(Object.entries(value).map(([name, item]) => createPropertySignature({ name, type: constToTypeNode(item) })))\n }\n if ((format ?? typeof value) === 'boolean') {\n return createLiteralType(value === true)\n }\n return createLiteralType((format ?? typeof value) === 'number' && typeof value === 'number' ? value : String(value))\n}\n\n/**\n * Returns a `Date` reference type when `representation` is `'date'`, otherwise falls back to `string`.\n */\nexport function dateOrStringNode(node: { representation?: string }): TsNode {\n return node.representation === 'date' ? createTypeReferenceNode('Date') : keywordTypeNodes.string\n}\n\n/**\n * Maps an array of `SchemaNode`s through the printer, filtering out `null` and `undefined` results.\n */\nexport function buildMemberNodes(members: Array<ast.SchemaNode> | undefined, print: (node: ast.SchemaNode) => TsNode | null | undefined): Array<TsNode> {\n return (members ?? []).map(print).filter(isNonNullable)\n}\n\n/**\n * Builds a TypeScript tuple type from an array schema's `items`,\n * applying min/max slice and optional/rest element rules.\n */\nexport function buildTupleNode(node: ast.ArraySchemaNode, print: (node: ast.SchemaNode) => TsNode | null | undefined): TsNode {\n let items = (node.items ?? []).map(print).filter(isNonNullable)\n\n const restNode = node.rest ? (print(node.rest) ?? undefined) : undefined\n const { min, max } = node\n\n if (max !== undefined) {\n items = items.slice(0, max)\n if (items.length < max && restNode) {\n items = [...items, ...Array(max - items.length).fill(restNode)]\n }\n }\n\n if (min !== undefined) {\n items = items.map((item, i) => (i >= min ? { type: 'TSOptionalType', typeAnnotation: item } : item))\n }\n\n if (max === undefined && restNode) {\n items.push({ type: 'TSRestType', typeAnnotation: { type: 'TSArrayType', elementType: restNode } })\n }\n\n return { type: 'TSTupleType', elementTypes: items }\n}\n\n/**\n * Appends `| null` and then `| undefined` to a type when requested.\n */\nexport function wrapNullableOptional(type: TsNode, nullable: boolean, addsUndefined: boolean): TsNode {\n const withNullable = nullable ? createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] }) : type\n return addsUndefined ? createUnionDeclaration({ nodes: [withNullable, keywordTypeNodes.undefined] }) : withNullable\n}\n\n/**\n * Applies `nullable` and optional/nullish `| undefined` union modifiers to a property's resolved base type.\n */\nexport function buildPropertyType(\n schema: ast.SchemaNode,\n baseType: TsNode,\n optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined',\n optional?: boolean,\n): TsNode {\n const addsUndefined = optionalType === 'undefined' || optionalType === 'questionTokenAndUndefined'\n const meta = syncSchemaRef(schema)\n\n return wrapNullableOptional(baseType, !!meta.nullable, addsUndefined && !!(optional || meta.nullish || meta.optional))\n}\n\n/**\n * Creates a TypeScript index signature for `additionalProperties` and `patternProperties` on an\n * object schema node. TypeScript allows only one string index signature and its value must be\n * assignable from every named property, so both keywords collapse into a single signature: the\n * union of all value types (deduplicated), or `unknown` when the object also has fixed properties.\n * The key regex of `patternProperties` cannot be expressed by an index signature and is dropped.\n */\nexport function buildIndexSignatures(\n node: { additionalProperties?: ast.SchemaNode | boolean; patternProperties?: Record<string, ast.SchemaNode> },\n propertyCount: number,\n printNode: (node: ast.SchemaNode) => TsNode | null | undefined,\n): Array<TsNode> {\n const valueTypes: Array<TsNode> = []\n\n if (node.additionalProperties && node.additionalProperties !== true) {\n valueTypes.push(printNode(node.additionalProperties) ?? keywordTypeNodes.unknown)\n } else if (node.additionalProperties === true) {\n valueTypes.push(keywordTypeNodes.unknown)\n }\n\n for (const schema of Object.values(node.patternProperties ?? {})) {\n const patternType = printNode(schema) ?? keywordTypeNodes.unknown\n valueTypes.push(schema.nullable ? createUnionDeclaration({ nodes: [patternType, keywordTypeNodes.null] }) : patternType)\n }\n\n if (valueTypes.length === 0) return []\n\n // Deduplicate by printed text, since equal types are separate node objects\n const distinct = [...new Map(valueTypes.map((type) => [print(type), type])).values()]\n const valueType = propertyCount > 0 ? keywordTypeNodes.unknown : createUnionDeclaration({ nodes: distinct })\n\n return [\n {\n type: 'TSIndexSignature',\n parameters: [{ type: 'Identifier', name: 'key', typeAnnotation: { type: 'TSTypeAnnotation', typeAnnotation: keywordTypeNodes.string } }],\n typeAnnotation: { type: 'TSTypeAnnotation', typeAnnotation: valueType },\n readonly: false,\n static: false,\n accessibility: null,\n },\n ]\n}\n","import { ensureValidVarName, trimQuotes } from '@internals/utils'\nimport { camelCase } from '@kubb/kit'\nimport type { ast } from '@kubb/kit'\nimport { File } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx'\nimport * as factory from '../factory.ts'\nimport type { PluginTs, ResolverTs } from '../types.ts'\n\ntype EnumOptions = PluginTs['resolvedOptions']['enum']\n\ntype Props = {\n node: ast.EnumSchemaNode\n enum: EnumOptions\n resolver: ResolverTs\n key?: string | number | null\n}\n\n/**\n * Resolves the runtime identifier name and the TypeScript type name for an enum schema node.\n *\n * The raw `node.name` may be a YAML key such as `\"enumNames.Type\"` which is not a\n * valid TypeScript identifier. The resolver normalizes it. For inline enum properties the adapter\n * already emits a PascalCase+suffix name, so resolution is typically a no-op.\n *\n * When `constCasing` is `'pascalCase'` and `typeSuffix` is empty, the const and the type\n * resolve to the same name, which TypeScript merges into a single value+type declaration.\n */\nexport function getEnumNames({ node, enum: enumOptions, resolver }: { node: ast.EnumSchemaNode; enum: EnumOptions; resolver: ResolverTs }): {\n enumName: string\n typeName: string\n} {\n const resolved = resolver.name(node.name!)\n const enumName = enumOptions.constCasing === 'pascalCase' ? resolved : ensureValidVarName(camelCase(node.name!))\n const typeName = enumOptions.type === 'asConst' ? resolver.enum.keyName(node, enumOptions.typeSuffix) : resolved\n\n return { enumName, typeName }\n}\n\n/**\n * Renders the enum declaration(s) for a single named `EnumSchemaNode`.\n *\n * Depending on `enum.type` this may emit:\n * - A runtime object (`asConst`) plus a `typeof` type alias\n * - A `const enum` or plain `enum` declaration (`constEnum` / `enum`)\n * - A union literal type alias (`literal`)\n *\n * The emitted `File.Source` nodes carry the resolved names so that the barrel\n * index picks up the correct export identifiers.\n */\nexport function Enum({ node, enum: enumOptions, resolver }: Props): KubbReactNode {\n const { enumName, typeName } = getEnumNames({ node, enum: enumOptions, resolver })\n\n const [nameNode, typeNode] = factory.createEnumDeclaration({\n name: enumName,\n typeName,\n enums: (node.namedEnumValues?.map((v) => [trimQuotes(v.name.toString()), v.value, v.description]) ??\n node.enumValues?.filter((v): v is NonNullable<typeof v> => v !== null && v !== undefined).map((v) => [trimQuotes(v.toString()), v]) ??\n []) as Array<[string | number, string | number | boolean, string?]>,\n type: enumOptions.type,\n enumKeyCasing: enumOptions.keyCasing,\n })\n\n // When the const and the type share a name (pascalCase const + empty typeSuffix) they merge into\n // one declaration. The const carries the barrel export, so keep the type alias in the file but out\n // of the barrel to avoid re-exporting the name a second time as `export type { … }`.\n const namesMerge = !!nameNode && enumName === typeName\n\n return (\n <>\n {nameNode && (\n <File.Source name={enumName} pointer={node.pointer} isExportable isIndexable isTypeOnly={false}>\n {nameNode}\n </File.Source>\n )}\n <File.Source\n name={typeName}\n pointer={node.pointer}\n isIndexable={!namesMerge}\n isExportable={!namesMerge && enumOptions.type !== 'inlineLiteral'}\n isTypeOnly={['asConst', 'literal', undefined].includes(enumOptions.type)}\n >\n {typeNode}\n </File.Source>\n </>\n )\n}\n","import { ast, type Group, type Memo, type Output, type Resolver, type ResolverFileParams } from '@kubb/kit'\n\n/**\n * Builds the `ResolverFileParams` every operation generator passes to\n * `resolver.file`: a file named `name`, tagged by the operation's first\n * tag (or `'default'`), at the operation's path. Centralizes the entry object\n * that was repeated at dozens of call sites across the client and query plugins.\n *\n * @example\n * ```ts\n * resolver.file(operationFileEntry(node, node.operationId), { root, output, group })\n * ```\n */\nexport function operationFileEntry(node: ast.OperationNode, name: string, extname: ResolverFileParams['extname'] = '.ts'): ResolverFileParams {\n return {\n name,\n extname,\n tag: node.tags[0] ?? 'default',\n path: node.path,\n }\n}\n\n/**\n * Resolves the file a schema-emitting plugin (`plugin-ts`, `plugin-zod`, `plugin-faker`) writes\n * `node` to, cached in `ctx.memo` under the resolver's plugin name and the\n * operation. The plugin itself and every plugin that imports from it call this, so they all get\n * the same path.\n *\n * When that path matches the file of a component schema in `ctx.driver.inputNode`, ignoring case, the file name\n * gets an `Operation` suffix: operation `point` goes to `PointOperation.ts` next to schema `Point.ts`.\n * Otherwise the two merge into one file, or overwrite each other on a case-insensitive file system.\n * Only the file name changes. The declarations keep their names.\n *\n * @example Resolve `plugin-ts`'s file for the current operation\n * ```ts\n * const fileTs = resolveOperationFile({ ctx, node, resolver: tsResolver, root, output })\n * ```\n */\nexport function resolveOperationFile(options: {\n ctx: { memo: Memo; driver: { inputNode?: { schemas: ReadonlyArray<ast.SchemaNode> } | null } }\n node: ast.OperationNode\n resolver: Pick<Resolver, 'file' | 'pluginName'>\n root: string\n output: Output\n group?: Group | null\n}): ast.FileNode {\n const { ctx, node, resolver, root, output } = options\n const { memo } = ctx\n const location = { root, output, group: options.group ?? undefined }\n\n return memo(`${resolver.pluginName}:operationFile:${node.operationId}`, () => {\n const schemaPaths = memo(\n `${resolver.pluginName}:schemaFilePaths`,\n () =>\n new Set(\n (ctx.driver.inputNode?.schemas ?? []).flatMap((schema) =>\n schema.name ? [resolver.file({ name: schema.name, extname: '.ts', ...location }).path.toLowerCase()] : [],\n ),\n ),\n )\n let file = resolver.file({ ...operationFileEntry(node, node.operationId), ...location })\n\n for (let name = `${node.operationId}Operation`; schemaPaths.has(file.path.toLowerCase()); name += 'Operation') {\n const next = resolver.file({ ...operationFileEntry(node, name), ...location })\n // A single-file output holds every declaration on purpose, so a new name changes nothing.\n if (next.path === file.path) break\n file = next\n }\n\n return file\n })\n}\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n cookies(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type BuildOperationCommentsOptions = {\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<Exclude<ast.ParameterNode['in'], 'querystring'>, Array<ast.ParameterNode>>\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\n/**\n * The operation's method and path as plain text, such as `` `GET /pet/{petId}` ``. A path is not a valid `{@link}` target.\n */\nfunction getOperationRequestLine(node: ast.OperationNode): string | null {\n return ast.isHttpOperationNode(node) && node.path ? `\\`${node.method.toUpperCase()} ${node.path}\\`` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(node.requestBody?.content?.map((e) => e.contentType) ?? [])\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(getPrimarySuccessResponse(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\ntype ResponseType = 'blob' | 'text' | 'stream'\n\nfunction baseContentType(contentType: string): string {\n return contentType.split(';')[0]!.trim().toLowerCase()\n}\n\ntype ResponseContentEntry = { contentType: string; schema?: ast.SchemaNode | null; stream?: ast.ContentNode['stream'] }\n\n/**\n * Whether a content entry is a sequence of JSON values the adapter marks as a stream, such as `application/jsonl`,\n * `application/x-ndjson`, `application/json-seq`, or any media type with an OpenAPI 3.2 `itemSchema`.\n */\nfunction isJsonLines(entry: ResponseContentEntry): boolean {\n const baseType = baseContentType(entry.contentType)\n // `multipart/mixed` is a stream of parts, not of JSON values.\n return Boolean(entry.stream) && baseType !== 'text/event-stream' && !baseType.startsWith('multipart/')\n}\n\n/**\n * How an operation streams its primary success response item by item, when that response declares one content type:\n * - `'event'` for `text/event-stream` whose `itemSchema` types the whole event with its own `event` and `data`\n * - `'data'` for `text/event-stream` typed by its payload only\n * - `'line'` for JSON Lines, one parsed JSON value per line\n *\n * Returns `null` for any other response, and for a response that also declares another content type, which stays a normal\n * call with its query hooks.\n */\nexport function getEventStream(node: ast.OperationNode): 'event' | 'data' | 'line' | null {\n const content = getPrimarySuccessResponse(node)?.content ?? []\n if (content.length !== 1) return null\n const entry = content[0]!\n if (baseContentType(entry.contentType) === 'text/event-stream') return entry.stream?.shape ?? 'data'\n return isJsonLines(entry) ? 'line' : null\n}\n\n/**\n * Whether an operation streams its primary success response, as Server-Sent Events or JSON Lines. The client generator uses\n * this to return a typed stream of items instead of a one-shot `RequestResult`.\n */\nexport function isEventStream(node: ast.OperationNode): boolean {\n return getEventStream(node) !== null\n}\n\n/**\n * Whether the primary success response offers `text/event-stream`, alone or next to other content types. The client asks\n * for the stream by default and ships the `sse.ts` runtime, so a mixed response can be read as events too.\n */\nexport function hasEventStreamContent(node: ast.OperationNode): boolean {\n const entries = getPrimarySuccessResponse(node)?.content ?? []\n // Next to another type, a stream without a schema gets no typed variant, so it keeps the plain call.\n return entries.some((entry) => baseContentType(entry.contentType) === 'text/event-stream' && (entries.length === 1 || Boolean(entry.schema)))\n}\n\nconst formContentTypes = new Set(['multipart/form-data', 'application/x-www-form-urlencoded'])\n\n/**\n * Whether the request body offers `multipart/form-data` or `application/x-www-form-urlencoded`, so the client registers the\n * form media types.\n */\nexport function hasFormBody(node: ast.OperationNode): boolean {\n return (node.requestBody?.content ?? []).some((entry) => formContentTypes.has(baseContentType(entry.contentType)))\n}\n\nfunction isJsonContentType(baseType: string): boolean {\n return baseType === 'application/json' || baseType.endsWith('+json') || baseType === 'text/json'\n}\n\n/**\n * Parser for one response content entry.\n *\n * JSON stays unset so the runtime detects it. `text/event-stream` and JSON Lines are streams. A binary schema\n * (`format: binary` / `contentMediaType`) is a blob even when the media type is not a well-known\n * binary type. Other `text/*` is text, and `application/octet-stream`, `application/pdf`,\n * `image/*`, `audio/*`, and `video/*` are blobs.\n */\nfunction responseTypeForContent(entry: ResponseContentEntry): ResponseType | undefined {\n const baseType = baseContentType(entry.contentType)\n if (!baseType) return undefined\n if (baseType === 'text/event-stream' || isJsonLines(entry)) return 'stream'\n if (isJsonContentType(baseType)) return undefined\n if (entry.schema?.type === 'blob') return 'blob'\n if (baseType.startsWith('text/')) return 'text'\n if (isBinaryContentType(baseType)) return 'blob'\n return undefined\n}\n\nfunction isBinaryContentType(baseType: string): boolean {\n return baseType === 'application/octet-stream' || baseType === 'application/pdf' || /^(image|audio|video)\\//.test(baseType)\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Returns the entry with the schema of the value the client returns: `string` for a body read as text, such as `Pet` on\n * `application/xml`, and `blob` for `image/*`, `audio/*`, `video/*`, PDF, and octet-stream. A binary schema elsewhere is a `Blob`\n * only through `parseAs: 'blob'`, which needs every entry in `entries` binary. JSON, vendor (`application/vnd.*`), stream,\n * schemaless, and wildcard entries keep their schema. `entries` is the response's full list of content types.\n */\nexport function toResponseContent<T extends ContentVariantInput & ResponseContentEntry>(entry: T, entries: ReadonlyArray<ResponseContentEntry> = [entry]): T {\n const { contentType, schema } = entry\n if (!schema || entry.stream) return entry\n\n const baseType = baseContentType(contentType)\n const resolved = ast.resolveRef(schema)\n if (isBinaryContentType(baseType)) {\n return resolved.type === 'blob' ? entry : { ...entry, schema: ast.factory.createSchema({ type: 'blob' }), keysToOmit: null }\n }\n const isPlainMediaType = Boolean(baseType) && !isJsonContentType(baseType) && !baseType.includes('*')\n if (resolved.type === 'blob') {\n // shortcut: an error response never gets `parseAs`, so a lone binary schema there reads as text too but stays `Blob`.\n const readsAsText = isPlainMediaType && !entries.every((item) => item.schema?.type === 'blob')\n return readsAsText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n }\n if (resolved.primitive === 'string') return entry\n\n const responseType = responseTypeForContent(entry)\n // A response without a body, such as a 405, has no schema to read. Only `text/*` is always text.\n if (responseType !== 'text' && (resolved.type === 'unknown' || resolved.type === 'any' || resolved.type === 'void')) return entry\n const isVendorJson = /^[^/]+\\/vnd\\./.test(baseType) && !/(xml|yaml|yml|csv)$/.test(baseType)\n const isText = responseType === 'text' || (!responseType && isPlainMediaType && !isVendorJson)\n\n return isText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n}\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...): `RequestConfig` minus what the\n * hook fills in, which is every request group and `throwOnError`. Unlike {@link buildRequestConfigType},\n * it never narrows `contentType`: query hooks wrap GET operations, which carry no request body to select\n * a content type for.\n */\nexport function buildClientOptionType(options: { omit?: Array<string> } = {}): string {\n const keys = [...requestGroupOrder, 'url', ...(options.omit ?? []), 'throwOnError']\n return `Partial<Omit<RequestConfig, ${keys.map((key) => `'${key}'`).join(' | ')}>>`\n}\n\n/**\n * The `client?:` option type of a mutation hook. When the operation has a request content type choice,\n * the mutation variables carry `contentType`, so the config leaves it out. Otherwise the ambiguous side is\n * narrowed to the operation's media types; a single-type side has nothing to pick, so it stays baked in the\n * generated call.\n */\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n if (hasRequestContentTypeChoice(node)) {\n return buildClientOptionType({ omit: ['contentType'] })\n }\n\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n const base = buildClientOptionType()\n return members.length ? `${base} & { contentType?: { ${members.join('; ')} } }` : base\n}\n\n/** The grouped request options, in the order generated signatures and calls list them. */\nexport const requestGroupOrder = ['path', 'query', 'body', 'headers', 'cookies'] as const\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n cookies: boolean\n}\n\n/**\n * Which of the grouped request options an operation carries.\n */\nexport function getRequestGroups(node: ast.OperationNode): RequestGroups {\n const { path, query, header, cookie } = getOperationParameters(node)\n return {\n path: path.length > 0,\n query: query.length > 0,\n body: Boolean(node.requestBody?.content?.[0]?.schema),\n headers: header.length > 0,\n cookies: cookie.length > 0,\n }\n}\n\nexport type RequestGroupOptionality = {\n groups: RequestGroups\n hasRequiredPath: boolean\n hasRequiredQuery: boolean\n hasRequiredHeader: boolean\n /**\n * Whether the grouped request parameter can default to `{}`. True only when no group carries a\n * required member, so every member is safe to omit.\n */\n isOptional: boolean\n}\n\n/**\n * Resolves which grouped request options an operation carries together with whether each group\n * holds a required member. The grouped parameter stays optional only when nothing inside it is\n * required, matching the generated `RequestConfig` type.\n */\nexport function getRequestGroupOptionality(node: ast.OperationNode): RequestGroupOptionality {\n const groups = getRequestGroups(node)\n const { path, query, header } = getOperationParameters(node)\n const hasRequiredPath = path.some((param) => param.required)\n const hasRequiredQuery = query.some((param) => param.required)\n const hasRequiredHeader = header.some((param) => param.required)\n\n return {\n groups,\n hasRequiredPath,\n hasRequiredQuery,\n hasRequiredHeader,\n // `cookies` never makes the parameter required: a browser sends its cookies itself and cannot set a `Cookie` header.\n isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !(groups.body && node.requestBody?.required === true),\n }\n}\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers, cookies }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: RequestGroups; names: Array<keyof RequestGroups> } {\n const { isConfigurable = true } = options\n const { groups, isOptional } = getRequestGroupOptionality(node)\n\n const names = requestGroupOrder.filter((key) => groups[key])\n\n // These callers never carry the `contentType` that several media types require.\n const optionsType = hasRequestContentTypeChoice(node)\n ? `Pick<${resolver.response.options(node)}, ${names.map((name) => `'${name}'`).join(' | ')}>`\n : resolver.response.options(node)\n const firstParam = names.length > 0 ? `{ ${names.join(', ')} }: ${optionsType}${isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n names,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { splitLines = false } = options\n // The request line leads: free text after a block tag would belong to that tag.\n const comments = [\n getOperationRequestLine(node),\n node.description && `@description ${node.description}`,\n node.summary && `@summary ${node.summary}`,\n node.deprecated && '@deprecated',\n ]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\nconst operationParameterGroupsByNode = new WeakMap<ast.OperationNode, OperationParameterGroups>()\n\n/**\n * An OpenAPI 3.2 `querystring` parameter is the whole query string, so a form-encoded object becomes one query parameter\n * per property, typed and serialized like any other.\n * Another content type, such as JSON, stays one parameter named after it, and the runtime sends its value as the whole query string.\n */\nfunction spreadQuerystring(param: ast.ParameterNode): Array<ast.ParameterNode> {\n const schema = param.schema.type === 'ref' ? param.schema.schema : param.schema\n const formEncoded = !param.contentType || param.contentType.split(';')[0]!.trim().toLowerCase() === 'application/x-www-form-urlencoded'\n if (schema?.type !== 'object' || !formEncoded) return [param]\n return schema.properties.map((property) =>\n ast.factory.createParameter({ name: property.name, in: 'query', schema: property.schema, required: param.required && property.required }),\n )\n}\n\n/**\n * Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each\n * group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance\n * (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the\n * same parameters once per plugin.\n */\nexport function getOperationParameters(node: ast.OperationNode): OperationParameterGroups {\n const cached = operationParameterGroupsByNode.get(node)\n if (cached) return cached\n\n // A malformed spec can declare the same name twice within one location. Both would resolve to the\n // same output property, so emitting both would yield an object type with a duplicate member,\n // which TypeScript rejects. Keep the first.\n const dedupe = (params: Array<ast.ParameterNode>) => {\n const seen = new Set<string>()\n return params.filter((param) => {\n if (seen.has(param.name)) return false\n seen.add(param.name)\n return true\n })\n }\n const group = (location: ast.ParameterNode['in']) => dedupe(node.parameters.filter((param) => param.in === location))\n\n const groups: OperationParameterGroups = {\n path: group('path'),\n query: dedupe([...group('query'), ...group('querystring').flatMap(spreadQuerystring)]),\n header: group('header'),\n cookie: group('cookie'),\n }\n\n operationParameterGroupsByNode.set(node, groups)\n return groups\n}\n\n/**\n * Whether the operation declares more than one request media type with a schema, so a caller must pick one on `contentType`.\n */\nexport function hasRequestContentTypeChoice(node: ast.OperationNode): boolean {\n return (node.requestBody?.content ?? []).filter((entry) => entry.schema).length > 1\n}\n\n/**\n * Casts a call argument to the client's parameter type; a `'plain'` client is non-generic.\n */\nexport function castToClientOptions(callArg: string, clientName: string, returnType: 'full' | 'data' | 'plain' = 'full'): string {\n return `${callArg} as Parameters<typeof ${clientName}${returnType === 'plain' ? '' : '<true>'}>[0]`\n}\n\n/**\n * Builds the combined `{ body, path, query, headers, cookies }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. `cookies` appears only on an operation\n * with a cookie parameter, and stays optional because a browser sends its cookies itself. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same shape from the same inputs.\n * `primitive: 'object'` is a no-op for the TS printer and tells the Zod printer to emit `z.object(…)` rather\n * than a record.\n */\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver, { pairContentTypes = false } = {}): ast.SchemaNode {\n const { path, query, header, cookie } = getOperationParameters(node)\n const hasBody = Boolean(node.requestBody?.content?.[0]?.schema)\n const createNever = () => ast.factory.createSchema({ type: 'never', primitive: undefined, optional: true })\n const groups = [\n { name: 'path', params: path, resolve: resolver.param.path },\n { name: 'query', params: query, resolve: resolver.param.query },\n { name: 'headers', params: header, resolve: resolver.param.headers },\n { name: 'cookies', params: cookie, resolve: resolver.param.cookies },\n ] as const\n\n const createOptions = (body: ast.SchemaNode, extra: Array<ast.PropertyNode> = []) =>\n // NOTE(v5-stable): the fields were renamed from the legacy beta shape\n // (`data`/`pathParams`/`queryParams`/`headerParams`) to `body`/`path`/`query`/`headers` so the\n // type matches the runtime client. Drop this note once v5 leaves beta.\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({ name: 'body', required: hasBody && node.requestBody?.required === true, schema: body }),\n ...groups\n .filter(({ name, params }) => name !== 'cookies' || params.length > 0)\n .map(({ name, params, resolve }) => {\n const required = name !== 'cookies' && params.some((param) => param.required)\n\n return ast.factory.createProperty({\n name,\n required,\n schema:\n params.length > 0\n ? ast.factory.createSchema({ type: 'ref', name: resolve.call(resolver.param, node, params[0]!), optional: !required })\n : createNever(),\n })\n }),\n ...extra,\n ],\n })\n\n const variants =\n pairContentTypes && hasRequestContentTypeChoice(node) ? resolveContentTypeVariants(node.requestBody?.content ?? [], resolver.response.body(node)) : []\n if (variants.length < 2) {\n return createOptions(hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever())\n }\n\n // The first media type is the runtime default, so only the others must pass `contentType`. A bare string sets the\n // request content type at runtime, so it is accepted next to the `{ request }` form.\n return ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant, index) => {\n const contentType = ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] })\n\n return createOptions(ast.factory.createSchema({ type: 'ref', name: variant.name }), [\n ast.factory.createProperty({\n name: 'contentType',\n required: index > 0,\n schema: ast.factory.createSchema({\n type: 'union',\n members: [\n contentType,\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [ast.factory.createProperty({ name: 'request', required: true, schema: contentType })],\n }),\n ],\n }),\n }),\n ])\n }),\n })\n}\n\n/**\n * The schema a status occupies in the `<Name>Responses` record. A status that documents several\n * content types becomes a `{ contentType; data }` union so the runtime can surface the negotiated type\n * on `result.parsed`, while the standalone `<Name>StatusNNN` alias stays the plain body union that the\n * query hooks and `result.data` use.\n */\nfunction buildResponseRecordEntry(node: ast.OperationNode, res: ast.ResponseNode, resolver: ResponseStatusNameResolver): ast.SchemaNode {\n const statusName = resolver.response.status(node, res.statusCode)\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length <= 1) {\n return ast.factory.createSchema({ type: 'ref', name: statusName })\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: resolveContentTypeVariants(variants, statusName).map((variant) =>\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'contentType',\n required: true,\n // The runtime reports the bare media type, without parameters such as `charset` or `profile`.\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [baseContentType(variant.contentType)] }),\n }),\n ast.factory.createProperty({\n name: 'data',\n required: true,\n schema: ast.factory.createSchema({ type: 'ref', name: variant.name }),\n }),\n ],\n }),\n ),\n })\n}\n\n/**\n * Builds the per-status `<Name>Responses` record for an operation, referencing the already-resolved\n * `<Name>StatusNNN` names. Shared by `@kubb/plugin-ts`'s `Responses` type and `@kubb/plugin-zod`'s\n * inferred responses schema, so both emit the same shape from the same inputs.\n *\n * Always emits the keyed record, even when an operation declares no responses. An operation with no\n * responses renders as an empty object, which keeps every consumer's import (for example the axios\n * SDK's `RequestResult<XResponses>`) resolvable instead of pointing at a missing export.\n */\nexport function buildResponses(node: ast.OperationNode, resolver: ResponseStatusNameResolver): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: node.responses.map((res) =>\n ast.factory.createProperty({\n name: String(res.statusCode),\n required: true,\n schema: buildResponseRecordEntry(node, res, resolver),\n }),\n ),\n })\n}\n\nexport function getStatusCodeNumber(statusCode: ast.StatusCode | number | string): number | null {\n const code = Number(statusCode)\n\n return Number.isNaN(code) ? null : code\n}\n\nexport function isSuccessStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 200 && code < 300\n}\n\nexport function isErrorStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 400\n}\n\nexport function getSuccessResponses<TResponse extends ResponseLike>(responses: ReadonlyArray<TResponse>): Array<TResponse> {\n return responses.filter((response) => isSuccessStatusCode(response.statusCode))\n}\n\nexport function getOperationSuccessResponses(node: ast.OperationNode): Array<ast.ResponseNode> {\n return getSuccessResponses(node.responses)\n}\n\nexport function getPrimarySuccessResponse(node: ast.OperationNode): ast.ResponseNode | null {\n return getOperationSuccessResponses(node)[0] ?? null\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.filter((response) => isSuccessStatusCode(response.statusCode)).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.response.status(node, response.statusCode))\n}\n\n/**\n * Lists the type names an operation's types file declares, computed once per resolver and `options` so every\n * dependent reads the same list.\n */\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver & Pick<Resolver, 'memo'>,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const key = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n return resolver.memo(`operationTypeNames:${key}`, () => {\n const { path, query, header, cookie } = getOperationParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ...cookie.map((param) => resolver.param.cookies(node, param)),\n ]\n const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n return names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n })\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = getStatusCodeNumber(response.statusCode)\n if (code === null) {\n continue\n }\n\n types.push([code, isSuccessStatusCode(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n","import { ensureValidVarName, toFilePath } from '@internals/utils'\nimport { ast, camelCase } from '@kubb/kit'\nimport type { GeneratorContext, Resolver, ResolverFile } from '@kubb/kit'\n\n/**\n * The shared top-level `name` of the operation plugins, computed once per operation name and build.\n */\nexport function resolveOperationName(this: Resolver, name: string): string {\n return this.memo(`operation:${name}`, () => ensureValidVarName(camelCase(name)))\n}\n\n/**\n * Builds the allocation key for a declaration an operation owns. `scope` names which declaration\n * it is, so two of them never share an allocation even when a custom resolver gives both the same\n * name. Leave `scope` empty for the operation's own declaration.\n *\n * The key starts from the operation's input `pointer`, which macros keep, so a plugin whose macro\n * rewrites the method or path still resolves another plugin's names for the same operation.\n *\n * @example\n * ```ts\n * resolver.resolveName({ key: operationKey(node, 'response', 'status', 404), name })\n * ```\n */\nexport function operationKey(node: ast.OperationNode, ...scope: Array<string | number>): Array<string | undefined> {\n const source = node.pointer ? [node.pointer] : [node.method, node.path]\n return ['operation', ...source, ...scope.map(String)]\n}\n\n/**\n * The `param` namespace shared by the schema-producing plugins (ts, zod, faker):\n * per-parameter names plus the grouped `Path`/`Query`/`Headers`/`Cookies` names, all routed\n * through the plugin's top-level `name` casing.\n */\nexport type OperationParamResolver = {\n name(this: Resolver, node: ast.OperationNode, param: ast.ParameterNode): string\n path(this: Resolver, node: ast.OperationNode): string\n query(this: Resolver, node: ast.OperationNode): string\n headers(this: Resolver, node: ast.OperationNode): string\n cookies(this: Resolver, node: ast.OperationNode): string\n}\n\n/**\n * The `response` namespace shared by the schema-producing plugins: per-status,\n * body, and combined response names, all routed through the plugin's top-level\n * `name` casing.\n */\nexport type OperationResponseResolver = {\n status(this: Resolver, node: ast.OperationNode, statusCode: ast.StatusCode): string\n body(this: Resolver, node: ast.OperationNode): string\n responses(this: Resolver, node: ast.OperationNode): string\n response(this: Resolver, node: ast.OperationNode): string\n}\n\n/**\n * Builds the shared `param` namespace. Spread the result into `createResolver`\n * and override individual methods next to it when a plugin deviates.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ param: createOperationParamResolver(), ... })\n * ```\n */\nexport function createOperationParamResolver(): OperationParamResolver {\n return {\n name(node, param) {\n const name = this.name(`${node.operationId} ${param.in} ${param.name}`)\n return this.resolveName({ key: operationKey(node, 'param', 'name', param.in, param.name), name })\n },\n path(node) {\n const name = this.name(`${node.operationId} Path`)\n return this.resolveName({ key: operationKey(node, 'param', 'path'), name })\n },\n query(node) {\n const name = this.name(`${node.operationId} Query`)\n return this.resolveName({ key: operationKey(node, 'param', 'query'), name })\n },\n headers(node) {\n const name = this.name(`${node.operationId} Headers`)\n return this.resolveName({ key: operationKey(node, 'param', 'headers'), name })\n },\n cookies(node) {\n const name = this.name(`${node.operationId} Cookies`)\n return this.resolveName({ key: operationKey(node, 'param', 'cookies'), name })\n },\n }\n}\n\n/**\n * Builds the shared `response` namespace. Spread the result into\n * `createResolver` and add plugin-specific methods (`options`, `error`) next\n * to it.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ response: { ...createOperationResponseResolver(), options(node) {...} }, ... })\n * ```\n */\nexport function createOperationResponseResolver(): OperationResponseResolver {\n return {\n status(node, statusCode) {\n const name = this.name(`${node.operationId} Status ${statusCode}`)\n return this.resolveName({ key: operationKey(node, 'response', 'status', statusCode), name })\n },\n body(node) {\n const name = this.name(`${node.operationId} Body`)\n return this.resolveName({ key: operationKey(node, 'response', 'body'), name })\n },\n responses(node) {\n const name = this.name(`${node.operationId} Responses`)\n return this.resolveName({ key: operationKey(node, 'response', 'responses'), name })\n },\n response(node) {\n const name = this.name(`${node.operationId} Response`)\n return this.resolveName({ key: operationKey(node, 'response', 'response'), name })\n },\n }\n}\n\n/**\n * Builds a resolver `file` override whose base name runs every path segment\n * through `toFilePath`, casing the final segment with `caseLast`.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ file: createCasedFile(pascalCase), ... })\n * ```\n */\nexport function createCasedFile(caseLast: (part: string) => string): ResolverFile {\n return {\n baseName({ name, extname }) {\n return this.memo(`file:${name}\\0${extname}`, (): ast.FileNode['baseName'] => `${toFilePath(name, caseLast)}${extname}`)\n },\n }\n}\n\ntype SchemaIndexContext = Pick<GeneratorContext, 'memo' | 'driver'>\n\n/**\n * Names of the schemas in a circular reference chain, computed once per build.\n */\nexport function getCircularNames(ctx: SchemaIndexContext): ReadonlySet<string> {\n return ctx.memo('circularNames:set', () => ast.findCircularSchemas(ctx.driver.inputNode?.schemas ?? []))\n}\n\n/**\n * Names of the schemas whose type is `enum`, computed once per build.\n */\nexport function getEnumNames(ctx: SchemaIndexContext): ReadonlySet<string> {\n return ctx.memo(\n 'enumNames:set',\n () => new Set((ctx.driver.inputNode?.schemas ?? []).flatMap((schema) => (schema.type === 'enum' && schema.name ? [schema.name] : []))),\n )\n}\n\ndeclare global {\n namespace Kubb {\n interface MemoRegistry {\n operation: string\n file: ast.FileNode['baseName']\n operationTypeNames: Array<string>\n }\n }\n}\n","import { camelCase, type Group } from '@kubb/kit'\n\n/**\n * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the\n * shared default naming so every plugin groups output consistently:\n *\n * - `path` groups use the second path segment (`/pet/findByStatus` → `pet`).\n * - other groups use the camelCased group (`pet store` → `petStore`).\n *\n * A user-provided `group.name` always wins over the default namer, so callers stay in\n * control of their output folders. Returns `null` when grouping is disabled, matching the\n * per-plugin convention.\n *\n * @param group - The user-supplied group option, or `undefined` to disable grouping.\n *\n * @example\n * ```ts\n * createGroupConfig(group) // shared across every plugin\n * ```\n */\nexport function createGroupConfig(group: Group | undefined): Group | null {\n if (!group) {\n return null\n }\n\n const defaultName = (ctx: { group: string }): string => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n\n return camelCase(ctx.group)\n }\n\n return {\n ...group,\n name: group.name ? group.name : defaultName,\n } satisfies Group\n}\n","import type { ast } from '@kubb/kit'\n\n/**\n * Converts a child schema to printer output. Plugins instantiate it with their own output type:\n * `string` for the zod and faker printers, `ts.TypeNode` for the TypeScript printer. A printer's\n * `this.transform` fits directly, so its `null` for an empty result carries through to `output`.\n */\nexport type SchemaTransform<TOutput> = (schema: ast.SchemaNode) => TOutput\n\n/**\n * A union or intersection member, or an array or tuple item, paired with its transformed output.\n */\nexport type MappedSchema<TOutput> = {\n /**\n * The original child schema, kept so the printer can read its metadata for leaf formatting.\n */\n schema: ast.SchemaNode\n /**\n * The child schema after being run through the transform.\n */\n output: TOutput\n}\n\n/**\n * An object property paired with its transformed output.\n */\nexport type MappedProperty<TOutput> = {\n /**\n * The property name as written on the schema, before any identifier quoting.\n */\n name: string\n /**\n * The original property node, kept so the printer can read `required`, `schema`, and metadata.\n */\n property: ast.PropertyNode\n /**\n * The property schema after being run through the transform.\n */\n output: TOutput\n}\n\n/**\n * Maps each property of an object schema to its transformed output. Pairs every result with the\n * original property so the printer keeps full control over modifiers, getters, and key syntax.\n *\n * @example\n * ```ts\n * const entries = mapSchemaProperties(node, (schema) => this.transform(schema))\n * // entries: [{ name: 'id', property, output: 'z.number()' }, ...]\n * ```\n */\nexport function mapSchemaProperties<TOutput>(node: ast.ObjectSchemaNode, transform: SchemaTransform<TOutput>): Array<MappedProperty<TOutput>> {\n return node.properties.map((property) => ({ name: property.name, property, output: transform(property.schema) }))\n}\n\n/**\n * Maps each member of a union or intersection schema to its transformed output, pairing every\n * result with the original member.\n */\nexport function mapSchemaMembers<TOutput>(\n node: ast.UnionSchemaNode | ast.IntersectionSchemaNode,\n transform: SchemaTransform<TOutput>,\n): Array<MappedSchema<TOutput>> {\n return (node.members ?? []).map((schema) => ({ schema, output: transform(schema) }))\n}\n\n/**\n * Maps each item of an array or tuple schema to its transformed output, pairing every result with\n * the original item.\n */\nexport function mapSchemaItems<TOutput>(node: ast.ArraySchemaNode, transform: SchemaTransform<TOutput>): Array<MappedSchema<TOutput>> {\n return (node.items ?? []).map((schema) => ({ schema, output: transform(schema) }))\n}\n","import { isSuccessStatusCode } from '@internals/shared'\nimport { jsDocEscape, stringify } from '@internals/utils'\nimport { ast, syncSchemaRef } from '@kubb/kit'\nimport { getEnumNames } from './components/Enum.tsx'\nimport type { PluginTs, ResolverTs } from './types.ts'\n\n/**\n * Renames inline enum declarations and their uses together.\n */\nexport function resolveInlineEnumNames({\n node,\n owner,\n resolver,\n enumOptions,\n}: {\n node: ast.SchemaNode\n owner: string\n resolver: ResolverTs\n enumOptions: PluginTs['resolvedOptions']['enum']\n}): ast.SchemaNode {\n return ast.transform(node, {\n schema(child) {\n if (child === node || child.type !== 'enum' || !child.name) return\n const name = resolver.resolveName({\n key: ['enum', owner, child.pointer ?? child.name],\n name: child.name,\n normalize: (value) => {\n // An `asConst` enum emits a value and a type alias, and the name has to be free as both.\n const { enumName, typeName } = getEnumNames({ node: { ...child, name: value }, enum: enumOptions, resolver })\n return enumOptions.type === 'literal' ? [typeName] : [enumName, typeName]\n },\n })\n return name === child.name ? undefined : { ...child, name }\n },\n })\n}\n\n/**\n * Resolves the type name an enum schema is referenced by. An enum emitted as a `const` object\n * with a `typeSuffix` uses its suffixed key alias (e.g. `StatusKey`); every other schema uses its\n * plain resolved name.\n */\ntype EnumTypeNameProps = {\n resolver: ResolverTs\n name: string\n enumOptions: { type?: string; typeSuffix?: string } | undefined\n isEnum: boolean\n}\n\nexport function enumTypeName({ resolver, name, enumOptions, isEnum }: EnumTypeNameProps): string {\n return isEnum && enumOptions?.type === 'asConst' && enumOptions.typeSuffix ? resolver.enum.keyName({ name }, enumOptions.typeSuffix) : resolver.name(name)\n}\n\n/**\n * Tells whether a `const` (single-value enum) should render as a bare literal type (`'active'`)\n * rather than a named enum reference or a runtime enum declaration.\n *\n * The parser folds `const` into a single-value enum node. The adapter decides which schemas are\n * named enums and lists them in `enumSchemaNames`, and references to those names get suffixed (for\n * example `StatusKey`). A const renders as a literal only when the adapter has not registered it as\n * a named enum, which keeps the declaration and its references in sync across adapter versions.\n */\nexport function isInlineConstEnum(node: ast.EnumSchemaNode, enumSchemaNames?: ReadonlySet<string>): boolean {\n const isConst = (node.namedEnumValues ?? node.enumValues ?? []).length === 1\n return isConst && !(node.name && enumSchemaNames?.has(node.name))\n}\n\n/**\n * Collects JSDoc annotation strings for a schema node.\n *\n * Only uses official JSDoc tags from https://jsdoc.app/: `@description`, `@deprecated`, `@default`, `@example`, `@type`.\n * Constraint metadata (min/max length, pattern, multipleOf, min/maxProperties) is emitted as plain-text lines.\n\n */\nfunction isSchemaOptional(schema: ast.SchemaNode): boolean {\n return Boolean(('optional' in schema && schema.optional) || ('nullish' in schema && schema.nullish))\n}\n\nfunction formatExample(value: unknown): string {\n if (value === null || typeof value !== 'object') {\n return String(value)\n }\n\n const rendered = JSON.stringify(value) ?? String(value)\n return rendered.replaceAll('*/', '*\\\\/')\n}\n\n/**\n * Whether a schema is binary, or an array of binary items, so its TypeScript type is `Blob` or `Blob[]`.\n */\nexport function isBinarySchema(schema: ast.SchemaNode): boolean {\n const meta = syncSchemaRef(schema)\n const isBlob = (node: ast.SchemaNode) => syncSchemaRef(node)?.type === 'blob'\n return !!meta && (isBlob(meta) || (meta.type === 'array' && 'items' in meta && (meta.items ?? []).some(isBlob)))\n}\n\nexport function buildPropertyJSDocComments(schema: ast.SchemaNode, optional?: boolean): Array<string | undefined> {\n const meta = syncSchemaRef(schema)\n\n const isArray = meta?.primitive === 'array'\n const isNumeric = meta?.primitive === 'number' || meta?.primitive === 'integer' || meta?.primitive === 'bigint'\n\n const hasDescription = meta && 'description' in meta && meta.description\n\n const formatComment =\n meta && 'format' in meta && meta.format\n ? hasDescription\n ? // Empty line between description and format\n [' ', `Format: \\`${meta.format}\\``]\n : ['@description', `Format: \\`${meta.format}\\``]\n : []\n\n // OAS 3.1 carries schema examples as an `examples` array, one `@example` line each.\n const exampleValues = meta?.examples ?? []\n\n const comments = [\n hasDescription ? `@description ${jsDocEscape(meta.description)}` : null,\n ...formatComment,\n meta && 'deprecated' in meta && meta.deprecated ? '@deprecated' : null,\n // minItems/maxItems on arrays should not be emitted as @minLength/@maxLength\n !isArray && meta && 'min' in meta && meta.min !== undefined ? `@${isNumeric ? 'minimum' : 'minLength'} ${meta.min}` : null,\n !isArray && meta && 'max' in meta && meta.max !== undefined ? `@${isNumeric ? 'maximum' : 'maxLength'} ${meta.max}` : null,\n meta && 'pattern' in meta && meta.pattern ? `@pattern ${meta.pattern}` : null,\n meta && 'default' in meta && meta.default !== undefined\n ? `@default ${'primitive' in meta && meta.primitive === 'string' && typeof meta.default === 'string' ? stringify(meta.default) : formatExample(meta.default)}`\n : null,\n ...exampleValues.map((example) => `@example ${formatExample(example)}`),\n ].filter(Boolean)\n\n // `@type` merely repeats the TypeScript type already sitting next to the property, so it only\n // earns its place inside a comment block that exists for another reason. Bare, it would just\n // add bytes with no information a reader can't already see in the signature.\n const typeTag =\n // A binary schema's primitive is `string`, which would contradict its `Blob` type.\n comments.length && !isBinarySchema(schema) && meta && 'primitive' in meta && meta.primitive\n ? [`@type ${meta.primitive}`, (optional ?? isSchemaOptional(schema)) ? ' | undefined' : null].filter(Boolean).join('')\n : null\n\n return [...comments, typeTag].filter(Boolean)\n}\n\ntype BuildParamsSchemaOptions = {\n params: Array<ast.ParameterNode>\n}\n\ntype BuildOperationSchemaOptions = {\n resolver: ResolverTs\n}\n\n/**\n * Builds the object schema for a group of parameters sharing one `in` location (path, query, or\n * header), embedding each param's own schema (and JSDoc) directly rather than referencing a\n * separate per-param type — the group itself is the only type these params get exported as.\n */\nexport function buildParams({ params }: BuildParamsSchemaOptions): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n // The group points at the `parameters` list that declares its first parameter.\n pointer: params[0]?.pointer?.replace(/\\/\\d+$/, ''),\n properties: params.map((param) =>\n ast.factory.createProperty({\n name: param.name,\n required: param.required,\n schema: ast.factory.createSchema({ ...param.schema, optional: !param.required }),\n }),\n ),\n })\n}\n\nexport function buildResponseUnion(node: ast.OperationNode, { resolver }: BuildOperationSchemaOptions): ast.SchemaNode | null {\n const allWithSchema = node.responses.filter((res) => res.content?.some((entry) => entry.schema))\n // Only 2xx responses, so an `unknown` error body cannot erase the success typing. Falls back to all responses when no 2xx has a schema.\n const successWithSchema = allWithSchema.filter((res) => isSuccessStatusCode(res.statusCode))\n const responsesWithSchema = successWithSchema.length > 0 ? successWithSchema : allWithSchema\n\n if (responsesWithSchema.length === 0) {\n return null\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: responsesWithSchema.map((res) => ast.factory.createSchema({ type: 'ref', name: resolver.response.status(node, res.statusCode) })),\n })\n}\n","import { createRequire } from 'node:module'\nimport { mapSchemaItems, mapSchemaProperties } from '@internals/shared'\nimport { ast, Diagnostics, isStringType, syncSchemaRef } from '@kubb/kit'\nimport * as factory from '../factory.ts'\nimport type { PluginTs, ResolverTs } from '../types.ts'\nimport { buildPropertyJSDocComments, enumTypeName, isBinarySchema, isInlineConstEnum } from '../utils.ts'\n\nconst { isNonNullable } = factory\n\nconst requireModule = createRequire(import.meta.url)\n\n/**\n * Loads `@kubb/parser-ts` on first use. It is an optional peer dependency: only a deprecated `printer.nodes`\n * handler that returns a TypeScript compiler node needs it. Loads synchronously because node handlers are synchronous.\n */\nexport function loadParserTs(load = () => requireModule('@kubb/parser-ts') as typeof import('@kubb/parser-ts')): typeof import('@kubb/parser-ts') {\n try {\n return load()\n } catch (error) {\n // Node says \"Cannot find module '@kubb/parser-ts'\" and Yarn PnP \"... tried to access @kubb/parser-ts ...\"; later lines hold the require stack\n if ((error as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND' || !(error as Error).message.split('\\n')[0]!.includes('@kubb/parser-ts')) throw error\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: 'Missing dependency: @kubb/parser-ts. A `printer.nodes` handler returned a TypeScript compiler node, and printing it needs @kubb/parser-ts.',\n help: 'Run `npm i -D @kubb/parser-ts` in the project, or return a string from the handler.',\n plugin: 'plugin-ts',\n })\n }\n}\n\n/**\n * Partial map of node-type overrides for the TypeScript printer.\n *\n * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`). The function\n * replaces the built-in handler for that node type and returns the TypeScript type as a string.\n * Use `this.transform` to recurse into nested schema nodes, and `this.options` to read printer options.\n *\n * @example Override the `date` handler\n * ```ts\n * pluginTs({\n * printer: {\n * nodes: {\n * date(node) {\n * return 'Date'\n * },\n * },\n * },\n * })\n * ```\n */\nexport type PrinterTsNodes = ast.PrinterPartial<string | DeprecatedTsNode, PrinterTsOptions>\n\n/** @deprecated A TypeScript compiler node returned by an override. Return a string; removed in the next major. */\ntype DeprecatedTsNode = { readonly kind: number }\n\nexport type PrinterTsOptions = {\n /**\n * Mark parameters as optional with `?` or `| undefined`.\n * - `'questionToken'` adds `?` to properties\n * - `'undefined'` adds `| undefined` to types\n *\n * @default `'questionToken'`\n */\n optionalType: PluginTs['resolvedOptions']['optionalType']\n /**\n * Array representation style.\n * - `'array'` uses bracket notation (`T[]`)\n * - `'generic'` uses generic syntax (`Array<T>`)\n *\n * @default `'array'`\n */\n arrayType: PluginTs['resolvedOptions']['arrayType']\n /**\n * Grouped enum settings. The printer emits references to enums, not the enum declarations, so only\n * `type` (the output format) and `typeSuffix` (the enum key reference suffix) matter here.\n * `constCasing` and `keyCasing` are ignored.\n */\n enum: PluginTs['resolvedOptions']['enum']\n /**\n * Syntax for generated declarations.\n * - `'type'` generates type aliases\n * - `'interface'` generates interface declarations\n *\n * @default `'type'`\n */\n syntaxType?: PluginTs['resolvedOptions']['syntaxType']\n /**\n * Exported name for the type declaration.\n * When omitted, returns only the raw type node.\n */\n name?: string\n\n /**\n * JSDoc comment to attach to the generated type.\n */\n description?: string\n /**\n * Properties to exclude using `Omit<Type, Keys>`.\n * Forces type alias syntax regardless of `syntaxType` setting.\n */\n keysToOmit?: Array<string> | null\n /**\n * Transforms raw schema names into valid TypeScript identifiers.\n */\n resolver: ResolverTs\n /**\n * Schema names that represent enums for suffixed key references.\n */\n enumSchemaNames?: ReadonlySet<string>\n /**\n * Custom handler map for node type overrides.\n */\n nodes?: PrinterTsNodes\n}\n\n/**\n * TypeScript printer factory options: maps `SchemaNode` → a TS-ESTree node, printed to a type string or a full declaration string.\n */\nexport type PrinterTsFactory = ast.PrinterFactoryOptions<'typescript', PrinterTsOptions, factory.TsNode, string>\n\ntype PrinterTs = PrinterTsFactory\n\ntype HandlerContext = { transform: (node: ast.SchemaNode) => factory.TsNode | null }\n\n/**\n * Adapts user overrides, which work in strings, to the node-based printer: `this.transform` hands them printed\n * strings and their result is wrapped back into a node. A deprecated compiler node prints through `@kubb/parser-ts`.\n */\nfunction toNodeHandlers(nodes: PrinterTsNodes | undefined): ast.PrinterPartial<factory.TsNode, PrinterTsOptions> {\n return Object.fromEntries(\n Object.entries(nodes ?? {}).map(([type, handler]) => [\n type,\n function (this: HandlerContext, node: ast.SchemaNode) {\n const transform = (child: ast.SchemaNode) => {\n const output = this.transform(child)\n return output ? factory.print(output) : null\n }\n const result = (handler as (this: unknown, node: ast.SchemaNode) => string | DeprecatedTsNode | null | undefined).call({ ...this, transform }, node)\n if (result === null || result === undefined) return result\n return factory.createRaw(\n typeof result === 'string'\n ? result\n : loadParserTs()\n .parserTs()\n .print(result as never)\n .trimEnd(),\n )\n },\n ]),\n )\n}\n\n/**\n * TypeScript type printer built with `definePrinter`.\n *\n * Converts a `SchemaNode` AST node into TypeScript source:\n * - **`printer.print(node)`** — when `options.name` is set, returns a full\n * `type Name = …` or `interface Name { … }` declaration.\n * Without `name`, returns the type for the schema, such as `string | null`.\n *\n * Dispatches on `node.type` to the appropriate handler in `nodes`. Options are closed\n * over per printer instance, so each call to `printerTs(options)` produces an independent printer.\n *\n * @example Raw type node (no `typeName`)\n * ```ts\n * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enum: { type: 'inlineLiteral' } })\n * const type = printer.print(schemaNode) // 'string | null'\n * ```\n *\n * @example Full declaration (with `typeName`)\n * ```ts\n * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enum: { type: 'inlineLiteral' }, typeName: 'MyType' })\n * const declaration = printer.print(schemaNode) // 'export type MyType = …'\n * ```\n */\nexport const printerTs = ast.createPrinter<PrinterTs>((options) => {\n const addsUndefined = options.optionalType === 'undefined' || options.optionalType === 'questionTokenAndUndefined'\n\n return {\n name: 'typescript',\n options,\n nodes: {\n any: () => factory.keywordTypeNodes.any,\n unknown: () => factory.keywordTypeNodes.unknown,\n void: () => factory.keywordTypeNodes.void,\n never: () => factory.keywordTypeNodes.never,\n boolean: () => factory.keywordTypeNodes.boolean,\n null: () => factory.keywordTypeNodes.null,\n blob: () => factory.createTypeReferenceNode('Blob'),\n string: () => factory.keywordTypeNodes.string,\n uuid: () => factory.keywordTypeNodes.string,\n email: () => factory.keywordTypeNodes.string,\n url: (node) => {\n if (node.path) {\n return factory.createUrlTemplateType(node.path)\n }\n return factory.keywordTypeNodes.string\n },\n ipv4: () => factory.keywordTypeNodes.string,\n ipv6: () => factory.keywordTypeNodes.string,\n datetime: () => factory.keywordTypeNodes.string,\n number: () => factory.keywordTypeNodes.number,\n integer: () => factory.keywordTypeNodes.number,\n bigint: () => factory.keywordTypeNodes.bigint,\n date: factory.dateOrStringNode,\n time: factory.dateOrStringNode,\n ref(node) {\n if (!node.name) {\n return null\n }\n // `node.name` may have been overridden (e.g. by the single-member allOf flatten using the\n // property-derived child name), so resolve the target through `resolveRefName` instead.\n const refName = ast.resolveRefName(node)\n if (!refName) {\n return null\n }\n\n // When a Key suffix is configured, enum refs must use the suffixed name (e.g. `StatusKey`)\n // so the reference matches what the enum file actually exports.\n const name = node.ref\n ? enumTypeName({\n resolver: this.options.resolver,\n name: refName,\n enumOptions: this.options.enum,\n isEnum: !!this.options.enumSchemaNames?.has(refName),\n })\n : refName\n\n return factory.createTypeReferenceNode(name)\n },\n enum(node) {\n const values = ast.getSchemaLiteralValues(node)\n\n if (values.some((value) => value !== null && typeof value === 'object')) {\n return factory.createUnionDeclaration({ nodes: values.map((value) => factory.constToTypeNode(value)) })\n }\n\n // A `const` (single-value enum) the adapter did not register as a named enum emits the bare\n // literal regardless of `enum.type`, matching how its references resolve.\n if (this.options.enum.type === 'inlineLiteral' || !node.name || isInlineConstEnum(node, this.options.enumSchemaNames)) {\n const literalNodes = values\n .filter((v): v is string | number | boolean => v !== null && v !== undefined)\n .map((value) => factory.constToTypeNode(value, typeof value as 'string' | 'number' | 'boolean'))\n .filter(isNonNullable)\n\n return factory.createUnionDeclaration({ nodes: literalNodes })\n }\n\n const resolvedName = enumTypeName({ resolver: this.options.resolver, name: node.name, enumOptions: this.options.enum, isEnum: true })\n\n return factory.createTypeReferenceNode(resolvedName)\n },\n union(node) {\n const members = node.members ?? []\n\n const hasStringLiteral = members.some((m) => {\n const enumNode = ast.narrowSchema(m, ast.schemaTypes.enum)\n return enumNode?.primitive === 'string'\n })\n const hasPlainString = members.some((m) => isStringType(m))\n\n if (hasStringLiteral && hasPlainString) {\n const memberNodes = members\n .map((m) => {\n if (isStringType(m)) {\n return factory.createIntersectionDeclaration({\n nodes: [factory.keywordTypeNodes.string, factory.createTypeLiteralNode([])],\n })\n }\n\n return this.transform(m)\n })\n .filter(isNonNullable)\n\n return factory.createUnionDeclaration({ nodes: memberNodes })\n }\n\n return factory.createUnionDeclaration({ nodes: factory.buildMemberNodes(members, this.transform) })\n },\n intersection(node) {\n return factory.createIntersectionDeclaration({ nodes: factory.buildMemberNodes(node.members, this.transform) })\n },\n array(node) {\n const itemNodes = mapSchemaItems(node, (item) => this.transform(item))\n .map(({ output }) => output)\n .filter(isNonNullable)\n\n return factory.createArrayDeclaration({ nodes: itemNodes, arrayType: this.options.arrayType })\n },\n tuple(node) {\n return factory.buildTupleNode(node, this.transform)\n },\n object(node) {\n const { transform, options } = this\n\n const keySchema = node.propertyNames && syncSchemaRef(node.propertyNames)\n if (\n !node.properties.length &&\n !Object.keys(node.patternProperties ?? {}).length &&\n node.propertyNames &&\n keySchema?.type === 'enum' &&\n node.additionalProperties !== false\n ) {\n const keyType = transform(node.propertyNames) ?? factory.keywordTypeNodes.string\n const valueSchema = typeof node.additionalProperties === 'object' ? node.additionalProperties : ast.factory.createSchema({ type: 'unknown' })\n const valueType = factory.buildPropertyType(valueSchema, transform(valueSchema) ?? factory.keywordTypeNodes.unknown, options.optionalType, false)\n\n return factory.createTypeReferenceNode('Partial', [factory.createTypeReferenceNode('Record', [keyType, valueType])])\n }\n\n const addsQuestionToken = options.optionalType === 'questionToken' || options.optionalType === 'questionTokenAndUndefined'\n\n const propertyNodes: Array<factory.TsNode> = mapSchemaProperties(node, (schema) => transform(schema)).map(({ name, property, output }) => {\n const baseType = output ?? factory.keywordTypeNodes.unknown\n const optional = !property.required || !!property.schema.optional || !!property.schema.nullish\n const type = factory.buildPropertyType(property.schema, baseType, options.optionalType, optional)\n const propMeta = syncSchemaRef(property.schema)\n\n const propertyNode = factory.createPropertySignature({\n questionToken: optional ? addsQuestionToken : false,\n name,\n type,\n readOnly: propMeta?.readOnly,\n })\n\n // A binary property is a file part of a form upload, where only a `File` carries a filename.\n const binaryRemark = isBinarySchema(property.schema)\n ? '@remarks Pass a `File` to send its filename. A plain `Blob` is sent with the filename `blob`.'\n : undefined\n const comments = [...buildPropertyJSDocComments(property.schema, optional), binaryRemark]\n\n return factory.appendJSDocToNode({ node: propertyNode, comments })\n })\n\n const allElements = [...propertyNodes, ...factory.buildIndexSignatures(node, propertyNodes.length, transform)]\n\n if (!allElements.length) {\n return factory.keywordTypeNodes.object\n }\n\n return factory.createTypeLiteralNode(allElements)\n },\n ...toNodeHandlers(options.nodes),\n },\n print(node) {\n const { name, syntaxType = 'type', description, keysToOmit } = this.options\n\n const transformed = this.transform(node)\n if (!transformed) return null\n\n // For ref nodes, structural metadata lives on node.schema rather than the ref node itself.\n const meta = syncSchemaRef(node)\n\n // Without name, apply modifiers inline and return.\n if (!name) {\n const omitted = keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type: transformed, nonNullable: true }) : transformed\n return factory.print(factory.wrapNullableOptional(omitted, !!meta.nullable, !!(meta.nullish || meta.optional) && addsUndefined))\n }\n\n // When keysToOmit is present, wrap with Omit first, then apply nullable/optional\n // modifiers so they are not swallowed by NonNullable inside createOmitDeclaration.\n const inner = (() => {\n const omitted = keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type: transformed, nonNullable: true }) : transformed\n // For named type declarations (type aliases), optional/nullish always produces | undefined\n // regardless of optionalType — the questionToken ? modifier only applies to object properties.\n return factory.wrapNullableOptional(omitted, !!meta.nullable, !!(meta.nullish || meta.optional))\n })()\n\n const useTypeGeneration = syntaxType === 'type' || !!keysToOmit?.length\n\n return factory.createTypeDeclaration({\n name,\n isExportable: true,\n type: inner,\n syntax: useTypeGeneration ? 'type' : 'interface',\n comments: buildPropertyJSDocComments({\n ...meta,\n description,\n }),\n })\n },\n }\n})\n","import { ast } from '@kubb/kit'\nimport { File } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx'\nimport { printerTs, type PrinterTsFactory } from '../printers/printerTs.ts'\nimport type { PluginTs, ResolverTs } from '../types.ts'\nimport { isInlineConstEnum } from '../utils.ts'\nimport { Enum, getEnumNames } from './Enum.tsx'\n\ntype Props = {\n name: string\n node: ast.SchemaNode\n /**\n * Pre-configured printer instance created by the generator.\n * Created with `printerTs({ ..., nodes: options.printer?.nodes })`.\n */\n printer: ast.Printer<PrinterTsFactory>\n enum: PluginTs['resolvedOptions']['enum']\n resolver: ResolverTs\n /**\n * Marks the source inline, so importing files absorb the type. Set by `pluginTs({ operations: 'inline' })`.\n */\n inline?: boolean\n}\n\nexport function Type({ name, node, printer, enum: enumOptions, resolver, inline }: Props): KubbReactNode {\n if (inline) {\n // An inline type has no file to declare its enums in, so they print as literal unions.\n const withoutEnums = ast.transform(node, { schema: (n) => (n.type === ast.schemaTypes.enum && n.name ? { ...n, name: undefined } : undefined) })\n // Property JSDoc would repeat in every file that absorbs the type; the schema files keep theirs.\n const expression = printerTs({ ...printer.options, name: undefined })\n .print(withoutEnums)\n ?.replace(/\\/\\*\\*[\\s\\S]*?\\*\\/\\s*/g, '')\n if (!expression) return\n\n // The file is never written; the expression as its text keeps the imports it needs in use.\n return (\n <File.Source name={name} isTypeOnly isExportable isIndexable inline={{ expression }}>\n {expression}\n </File.Source>\n )\n }\n\n const enumSchemaNodes = ast.collectSync<ast.EnumSchemaNode>(node, {\n schema(n): ast.EnumSchemaNode | undefined {\n const enumNode = ast.narrowSchema(n, ast.schemaTypes.enum)\n // Skip an inline `const` (single-value enum the adapter did not register): it renders as a\n // literal, so it gets no runtime enum declaration.\n if (enumNode?.name && !isInlineConstEnum(enumNode, printer.options.enumSchemaNames)) return enumNode\n },\n })\n\n const output = printer.print(node)\n const printerImports = printer.drainImports()\n\n if (!output) {\n return\n }\n\n const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((node) => {\n return {\n node,\n ...getEnumNames({ node, enum: enumOptions, resolver }),\n }\n })\n\n // Skip enum exports when using inlineLiteral\n const shouldExportEnums = enumOptions.type !== 'inlineLiteral'\n const shouldExportType = enumOptions.type === 'inlineLiteral' || enums.every((item) => item.typeName !== name)\n\n return (\n <>\n {shouldExportEnums && enums.map(({ node }) => <Enum key={node.name} node={node} enum={enumOptions} resolver={resolver} />)}\n {shouldExportType && (\n <>\n {printerImports.map((imp) => (\n <File.Import key={[name, imp.path, imp.name].join('-')} {...imp} />\n ))}\n <File.Source name={name} pointer={node.pointer} isTypeOnly isExportable isIndexable>\n {output}\n </File.Source>\n </>\n )}\n </>\n )\n}\n","import {\n buildOptionsSchema,\n buildResponses,\n getEnumNames,\n getOperationParameters,\n resolveContentTypeVariants,\n resolveOperationFile,\n toResponseContent,\n} from '@internals/shared'\nimport { ast, defineGenerator } from '@kubb/kit'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Type } from '../components/Type.tsx'\nimport { printerTs } from '../printers/printerTs.ts'\nimport type { PluginTs } from '../types'\nimport { buildParams, buildResponseUnion, enumTypeName, isInlineConstEnum, resolveInlineEnumNames } from '../utils.ts'\n\n/**\n * Built-in generator for `@kubb/plugin-ts`. Emits one TypeScript file per\n * schema in the spec plus per-operation request, response, and parameter\n * types. Drop-replace with a custom `Generator<PluginTs>` to change how\n * TypeScript output is produced.\n */\nexport const typeGenerator = defineGenerator<PluginTs>({\n name: 'typescript',\n renderer: jsxRenderer,\n schema(node, ctx) {\n const { enum: enumOptions, syntaxType, optionalType, arrayType, output, group, printer } = ctx.options\n const { config, resolver, root } = ctx\n\n if (enumOptions.type !== 'inlineLiteral') node = resolveInlineEnumNames({ node, owner: node.name ?? '', resolver, enumOptions })\n if (!node.name) {\n return\n }\n // Enum schema names, so the ref handler and the imports\n // name callback can use the suffixed type name (e.g. `StatusKey`) for those refs.\n const enumSchemaNames = getEnumNames(ctx)\n const importName = (schemaName: string) => enumTypeName({ resolver, name: schemaName, enumOptions, isEnum: enumSchemaNames.has(schemaName) })\n\n const imports = resolver.imports({ node, root, output, group: group ?? undefined, name: importName })\n\n const enumNode = ast.narrowSchema(node, ast.schemaTypes.enum)\n // An inline `const` (single-value enum the adapter did not register) renders as a literal type,\n // so it keeps its plain name instead of the suffixed enum-key name.\n const isEnumSchema = !!enumNode && !isInlineConstEnum(enumNode, enumSchemaNames)\n\n const meta = {\n name: enumOptions.type === 'asConst' && isEnumSchema ? resolver.enum.keyName(node, enumOptions.typeSuffix) : resolver.name(node.name),\n file: resolver.file({ name: node.name, extname: '.ts', root, output, group: group ?? undefined }),\n } as const\n\n const schemaPrinter = printerTs({\n optionalType,\n arrayType,\n enum: enumOptions,\n name: meta.name,\n syntaxType,\n description: node.description,\n resolver,\n enumSchemaNames,\n nodes: printer?.nodes,\n })\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.default.banner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.default.footer(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n {imports.map((imp) => (\n <File.Import key={[node.name, imp.path, imp.isTypeOnly].join('-')} root={meta.file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type name={meta.name} node={node} enum={enumOptions} resolver={resolver} printer={schemaPrinter} />\n </File>\n )\n },\n operation(node, ctx) {\n const { enum: enumOptions, optionalType, arrayType, syntaxType, group, output, printer, operations } = ctx.options\n const { config, resolver, root } = ctx\n const inline = operations === 'inline'\n\n const meta = {\n file: resolveOperationFile({ ctx, node, resolver, root, output, group }),\n } as const\n\n // Enum schema names, so the ref handler and the imports\n // name callback can use the suffixed type name (e.g. `StatusKey`) for those refs.\n const enumSchemaNames = getEnumNames(ctx)\n const importName = (schemaName: string) => enumTypeName({ resolver, name: schemaName, enumOptions, isEnum: enumSchemaNames.has(schemaName) })\n const inlinePrinter = inline\n ? printerTs({ optionalType, arrayType, enum: enumOptions, syntaxType, resolver, enumSchemaNames, nodes: printer?.nodes })\n : null\n\n function renderSchemaType({ schema, name, keysToOmit }: { schema: ast.SchemaNode | null; name: string; keysToOmit?: Array<string> | null }) {\n if (!schema) return null\n if (!inline && enumOptions.type !== 'inlineLiteral') schema = resolveInlineEnumNames({ node: schema, owner: node.operationId, resolver, enumOptions })\n\n const imports = resolver.imports({ node: schema, root, output, group: group ?? undefined, name: importName })\n\n const schemaPrinter = printerTs({\n optionalType,\n arrayType,\n enum: enumOptions,\n name,\n syntaxType,\n description: schema.description,\n keysToOmit,\n resolver,\n enumSchemaNames,\n nodes: printer?.nodes,\n })\n\n return (\n <>\n {imports.map((imp) => (\n <File.Import key={[name, imp.path, imp.isTypeOnly].join('-')} root={meta.file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type name={name} node={schema} enum={enumOptions} resolver={resolver} printer={schemaPrinter} inline={inline} />\n </>\n )\n }\n\n /**\n * Emits an individual type per content type plus a plain union alias under `baseName`. Shared by\n * the request body and multi-content-type responses. The response record discriminates these\n * variants by content type in {@link buildResponses}; the standalone alias stays a plain union so\n * query hooks and `result.data` keep the bare body.\n */\n function buildContentTypeVariants(\n entries: Array<{ contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }>,\n baseName: string,\n pointer: string | undefined,\n decorate?: (schema: ast.SchemaNode) => ast.SchemaNode,\n ) {\n const variants = resolveContentTypeVariants(entries, baseName)\n // Inline, content types that print the same type would repeat it in the union (`Order | Order`).\n const keys = variants.map((variant) => (inlinePrinter ? `${inlinePrinter.print(variant.schema)}:${variant.keysToOmit ?? ''}` : variant.name))\n const members = variants.filter((_, index) => keys.indexOf(keys[index]!) === index)\n const unionSchema = ast.factory.createSchema({\n type: 'union',\n pointer,\n members: members.map((variant) => ast.factory.createSchema({ type: 'ref', name: variant.name })),\n })\n return (\n <>\n {variants.map((variant) =>\n renderSchemaType({\n schema: decorate ? decorate(variant.schema) : variant.schema,\n name: variant.name,\n keysToOmit: variant.keysToOmit,\n }),\n )}\n {renderSchemaType({ schema: unionSchema, name: baseName })}\n </>\n )\n }\n\n const { path, query, header, cookie } = getOperationParameters(node)\n\n const paramGroupTypes = (\n [\n [path, resolver.param.path],\n [query, resolver.param.query],\n [header, resolver.param.headers],\n [cookie, resolver.param.cookies],\n ] as const\n ).map(\n ([params, resolveName]) =>\n params.length > 0 && renderSchemaType({ schema: buildParams({ params }), name: resolveName.call(resolver.param, node, params[0]!) }),\n )\n\n const requestBodyContent = node.requestBody?.content ?? []\n\n function buildRequestType() {\n if (requestBodyContent.length === 0) return null\n if (requestBodyContent.length === 1) {\n const entry = requestBodyContent[0]!\n if (!entry.schema) return null\n return renderSchemaType({\n schema: {\n ...entry.schema,\n pointer: node.requestBody!.pointer ?? entry.schema.pointer,\n description: node.requestBody!.description ?? entry.schema.description,\n },\n name: resolver.response.body(node),\n keysToOmit: entry.keysToOmit,\n })\n }\n // Multiple content types — generate individual types + union alias\n return buildContentTypeVariants(requestBodyContent, resolver.response.body(node), node.requestBody!.pointer, (schema) => ({\n ...schema,\n description: node.requestBody!.description ?? schema.description,\n }))\n }\n\n const requestType = buildRequestType()\n\n const responseTypes = node.responses.map((res) => {\n const content = (res.content ?? []).map((entry, _, content) => toResponseContent(entry, content))\n const variants = content.filter((entry) => entry.schema)\n // Multiple content types for a single status code — generate per-variant types + a plain union.\n // The `<Name>Responses` record discriminates them by content type (see buildResponses).\n if (variants.length > 1) {\n return buildContentTypeVariants(variants, resolver.response.status(node, res.statusCode), res.pointer)\n }\n const primary = variants[0] ?? content[0]\n return renderSchemaType({\n schema: primary?.schema ? { ...primary.schema, pointer: res.pointer ?? primary.schema.pointer } : ast.factory.createSchema({ type: 'unknown' }),\n name: resolver.response.status(node, res.statusCode),\n keysToOmit: primary?.keysToOmit,\n })\n })\n\n const optionsType = renderSchemaType({\n schema: buildOptionsSchema(node, resolver, { pairContentTypes: true }),\n name: resolver.response.options(node),\n })\n\n const responsesType = renderSchemaType({\n schema: buildResponses(node, resolver),\n name: resolver.response.responses(node),\n })\n\n function buildResponseType() {\n const hasSchema = (res: ast.ResponseNode) => (res.content ?? []).some((entry) => entry.schema)\n const responseName = resolver.response.response(node)\n\n const responsesWithSchema = node.responses.filter(hasSchema)\n const importedNames = new Set(\n responsesWithSchema.flatMap((res) =>\n (res.content ?? []).flatMap((entry) => (entry.schema ? ast.collectImportedRefNames(entry.schema).map(importName) : [])),\n ),\n )\n\n if (importedNames.has(responseName)) {\n return null\n }\n\n return renderSchemaType({\n schema: {\n ...(buildResponseUnion(node, { resolver }) ?? ast.factory.createSchema({ type: 'unknown' })),\n description: 'Union of all possible responses',\n },\n name: responseName,\n })\n }\n\n const responseType = buildResponseType()\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.default.banner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.default.footer(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n {paramGroupTypes}\n {responseTypes}\n {requestType}\n {optionsType}\n {responsesType}\n {responseType}\n </File>\n )\n },\n})\n","","","import { createCasedFile, createOperationParamResolver, createOperationResponseResolver, operationKey } from '@internals/shared'\nimport { ensureValidVarName } from '@internals/utils'\nimport { createResolver, pascalCase } from '@kubb/kit'\nimport type { PluginTs } from '../types.ts'\n\n/**\n * Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths\n * for generated TypeScript types. Other plugins should read the build's resolver\n * through `driver.getResolver(pluginTsName)` to share its name allocations.\n *\n * The `default` helpers are supplied by `createResolver`. This plugin overrides the top-level `name`\n * to use PascalCase for value and type names and `file` to write PascalCase file paths (dotted names\n * become `/`-joined), and groups the operation-specific naming under the `param`, `response`, and\n * `enum` namespaces.\n *\n * @example Resolve a type and file name\n * ```ts\n * import { resolverTs } from '@kubb/plugin-ts'\n *\n * resolverTs.name('list pets') // 'ListPets'\n * resolverTs.response.status(node, 200) // 'ListPetsStatus200'\n * ```\n */\nexport const resolverTs = createResolver<PluginTs>({\n pluginName: 'plugin-ts',\n name(name) {\n return this.memo(`name:${name}`, () => ensureValidVarName(pascalCase(name)))\n },\n file: createCasedFile(pascalCase),\n param: createOperationParamResolver(),\n response: {\n ...createOperationResponseResolver(),\n options(node) {\n const name = this.name(`${node.operationId} Options`)\n return this.resolveName({ key: operationKey(node, 'response', 'options'), name })\n },\n },\n enum: {\n keyName(node, enumTypeSuffix = 'key') {\n return `${this.name(node.name ?? '')}${enumTypeSuffix}`\n },\n },\n})\n","import { createGroupConfig } from '@internals/shared'\nimport { addGenerator, defineExtension, Resolver, setMacros, setResolver } from '@kubb/kit'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { typeGenerator } from './generators/typeGenerator.tsx'\nimport { resolverTs } from './resolvers/resolverTs.ts'\nimport type { PluginTs } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-ts`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginTsName = 'plugin-ts' satisfies PluginTs['name']\n\n/**\n * Generates TypeScript `type` aliases and `interface` declarations from an\n * OpenAPI spec. The foundation that every other Kubb plugin builds on:\n * clients, query hooks, mocks, and validators all reference the names this\n * plugin produces.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginTs } from '@kubb/plugin-ts'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [\n * pluginTs({\n * output: { path: './types' },\n * enum: { type: 'asConst' },\n * optionalType: 'questionTokenAndUndefined',\n * }),\n * ],\n * })\n * ```\n */\nexport const pluginTs = defineExtension<PluginTs>({\n kind: 'plugin',\n meta: { name: pluginTsName, version, compatibility },\n setup(options) {\n const {\n output = { path: 'types', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n enum: enumOptions = {},\n optionalType = 'questionToken',\n arrayType = 'array',\n syntaxType = 'type',\n operations = 'export',\n printer,\n resolver: userResolver,\n macros: userMacros,\n } = options\n\n const resolvedEnum = {\n type: enumOptions.type ?? 'asConst',\n constCasing: enumOptions.constCasing ?? 'camelCase',\n typeSuffix: enumOptions.typeSuffix ?? 'Key',\n keyCasing: enumOptions.keyCasing ?? 'none',\n }\n\n setResolver(userResolver ? Resolver.merge(resolverTs, userResolver) : resolverTs)\n if (userMacros?.length) {\n setMacros(userMacros)\n }\n addGenerator(typeGenerator)\n\n return {\n output,\n exclude,\n include,\n override,\n optionalType,\n group: createGroupConfig(group),\n arrayType,\n enum: resolvedEnum,\n syntaxType,\n operations,\n printer,\n }\n },\n})\n\nexport default pluginTs\n","/**\n * A type expression used as a function parameter type annotation.\n *\n * - a plain `string` is a type reference rendered as-is, e.g. `'string'`, `'QueryParams'`, `'Partial<Config>'`\n * - a {@link TypeLiteralNode} is an inline anonymous type, e.g. `{ petId: string; name?: string }`\n * - an {@link IndexedAccessTypeNode} is a single field accessed from a named type, e.g. `PathParams['petId']`\n */\nexport type TypeExpression = string | TypeLiteralNode | IndexedAccessTypeNode\n\n/**\n * An inline anonymous object type grouping named fields.\n * Renders as `{ key: Type; other?: OtherType }`.\n */\nexport type TypeLiteralNode = {\n kind: 'TypeLiteral'\n /**\n * Members of the object type, rendered in order.\n */\n members: Array<{\n /**\n * Member key.\n */\n name: string\n /**\n * Member type expression.\n */\n type: TypeExpression\n /**\n * Whether the member is optional, rendered with `?`.\n */\n optional?: boolean\n }>\n}\n\n/**\n * A single field accessed from a named group type. Renders as `target['key']`.\n */\nexport type IndexedAccessTypeNode = {\n kind: 'IndexedAccessType'\n /**\n * Name of the type being indexed, e.g. `'GetPetPathParams'`.\n */\n target: string\n /**\n * Field key to access, e.g. `'petId'`.\n */\n key: string\n}\n\n/**\n * An object destructuring binding, used as the name of a grouped function parameter.\n * Renders as `{ id, name }` or `{ id: renamed }` when `propertyName` differs.\n */\nexport type ObjectBindingPatternNode = {\n kind: 'ObjectBindingPattern'\n /**\n * Bound elements, rendered in order.\n */\n elements: Array<{\n /**\n * Local binding name.\n */\n name: string\n /**\n * Source key when it differs from the binding name, rendered as `propertyName: name`.\n */\n propertyName?: string\n }>\n}\n\n/**\n * One function parameter.\n *\n * A simple parameter has a `string` name. A destructured group has an\n * {@link ObjectBindingPatternNode} name paired with a {@link TypeLiteralNode} type.\n *\n * @example Required parameter\n * `name: Type`\n *\n * @example Optional parameter\n * `name?: Type`\n *\n * @example Parameter with default value\n * `name: Type = defaultValue`\n *\n * @example Rest parameter\n * `...name: Type[]`\n *\n * @example Destructured group\n * `{ id, name? }: { id: string; name?: string } = {}`\n */\nexport type FunctionParameterNode = {\n kind: 'FunctionParameter'\n /**\n * Parameter name, or an {@link ObjectBindingPatternNode} for a destructured group.\n */\n name: string | ObjectBindingPatternNode\n /**\n * Type annotation as a {@link TypeExpression}. Omit for untyped output.\n */\n type?: TypeExpression\n /**\n * Whether the parameter is optional, rendered with `?`.\n */\n optional?: boolean\n /**\n * Default value, written verbatim after `=`. Commonly `'{}'` for a destructured group.\n */\n default?: string\n /**\n * When `true` the parameter is emitted as a rest parameter, e.g. `...name: Type[]`.\n */\n rest?: boolean\n}\n\n/**\n * A complete function parameter list.\n *\n * Printers are responsible for sorting (`required` → `optional` → `defaulted`).\n */\nexport type FunctionParametersNode = {\n kind: 'FunctionParameters'\n /**\n * Ordered parameter nodes.\n */\n params: ReadonlyArray<FunctionParameterNode>\n}\n\n/**\n * Narrows a {@link TypeExpression} to a {@link TypeLiteralNode}.\n */\nexport function isTypeLiteral(type: TypeExpression): type is TypeLiteralNode {\n return typeof type !== 'string' && type.kind === 'TypeLiteral'\n}\n\n/**\n * Narrows a {@link TypeExpression} to an {@link IndexedAccessTypeNode}.\n */\nexport function isIndexedAccessType(type: TypeExpression): type is IndexedAccessTypeNode {\n return typeof type !== 'string' && type.kind === 'IndexedAccessType'\n}\n\n/**\n * Creates a {@link TypeLiteralNode} representing an inline anonymous object type.\n *\n * @example\n * ```ts\n * createTypeLiteral({ members: [{ name: 'petId', type: 'string', optional: false }] })\n * // { petId: string }\n * ```\n */\nexport function createTypeLiteral(props: Omit<TypeLiteralNode, 'kind'>): TypeLiteralNode {\n return { kind: 'TypeLiteral', ...props }\n}\n\n/**\n * Creates an {@link IndexedAccessTypeNode} representing a single field accessed from a named type.\n *\n * @example\n * ```ts\n * createIndexedAccessType({ target: 'DeletePetPathParams', key: 'petId' })\n * // DeletePetPathParams['petId']\n * ```\n */\nexport function createIndexedAccessType(props: Omit<IndexedAccessTypeNode, 'kind'>): IndexedAccessTypeNode {\n return { kind: 'IndexedAccessType', ...props }\n}\n\n/**\n * Creates an {@link ObjectBindingPatternNode} for a destructured parameter binding.\n *\n * @example\n * ```ts\n * createObjectBindingPattern({ elements: [{ name: 'id' }, { name: 'name' }] })\n * // { id, name }\n * ```\n */\nexport function createObjectBindingPattern(props: Omit<ObjectBindingPatternNode, 'kind'>): ObjectBindingPatternNode {\n return { kind: 'ObjectBindingPattern', ...props }\n}\n\n/**\n * Plain property descriptor for a destructured group built by {@link createFunctionParameter}.\n */\ntype FunctionParameterProperty = {\n name: string\n type: TypeExpression\n optional?: boolean\n}\n\ntype FunctionParameterInput =\n | { name: string | ObjectBindingPatternNode; type?: TypeExpression; optional?: boolean; default?: string; rest?: boolean }\n | { properties: Array<FunctionParameterProperty>; optional?: boolean; default?: string }\n\n/**\n * Creates a {@link FunctionParameterNode}. `optional` defaults to `false`.\n * Passing `properties` builds a destructured group: an {@link ObjectBindingPatternNode} name\n * paired with a {@link TypeLiteralNode} type.\n *\n * @example Optional param\n * ```ts\n * createFunctionParameter({ name: 'params', type: 'QueryParams', optional: true })\n * // → params?: QueryParams\n * ```\n *\n * @example Destructured group\n * ```ts\n * createFunctionParameter({ properties: [{ name: 'id', type: 'string' }, { name: 'name', type: 'string', optional: true }], default: '{}' })\n * // → { id, name }: { id: string; name?: string } = {}\n * ```\n */\nexport function createFunctionParameter(input: FunctionParameterInput): FunctionParameterNode {\n if ('properties' in input) {\n return {\n kind: 'FunctionParameter',\n name: createObjectBindingPattern({ elements: input.properties.map((p) => ({ name: p.name })) }),\n type: createTypeLiteral({ members: input.properties.map((p) => ({ name: p.name, type: p.type, optional: p.optional ?? false })) }),\n optional: input.optional ?? false,\n ...(input.default !== undefined ? { default: input.default } : {}),\n }\n }\n return { kind: 'FunctionParameter', optional: false, ...input }\n}\n\n/**\n * Creates a {@link FunctionParametersNode} from an ordered list of parameters.\n *\n * @example\n * ```ts\n * const empty = createFunctionParameters()\n * // { params: [] }\n * ```\n */\nexport function createFunctionParameters(props: Partial<Omit<FunctionParametersNode, 'kind'>> = {}): FunctionParametersNode {\n return { kind: 'FunctionParameters', params: [], ...props }\n}\n","/**\n * Ordering priority for function parameters: lower = sorted earlier.\n */\nconst PARAM_RANK = { required: 0, optional: 1, withDefault: 2, rest: 3 } as const\n\nimport { isIndexedAccessType, isTypeLiteral } from './functionParams.ts'\nimport type { FunctionParameterNode, FunctionParametersNode, ObjectBindingPatternNode, TypeExpression } from './functionParams.ts'\n\n/**\n * Renders a {@link TypeExpression} to its TypeScript source.\n *\n * - a `string` is a type reference, returned as-is\n * - an `IndexedAccessType` becomes `objectType['indexType']`\n * - a `TypeLiteral` becomes `{ key: Type; key?: Type }`\n *\n * `transformType` is applied once to the fully rendered type, matching how the\n * printer wrapped reference types before the `ts.factory` model.\n */\nexport function renderType(type: TypeExpression, transformType?: (type: string) => string): string {\n const rendered = renderTypeExpression(type)\n return transformType ? transformType(rendered) : rendered\n}\n\n/**\n * Renders an object-type key, quoting it as a string literal when it is not a valid\n * identifier so `{ 'content-type': string }` stays valid TypeScript.\n */\nfunction renderKey(name: string): string {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name) ? name : JSON.stringify(name)\n}\n\nfunction renderMembers(members: Array<{ key: string; type: string; optional?: boolean }>): string {\n return `{ ${members.map((member) => `${renderKey(member.key)}${member.optional ? '?' : ''}: ${member.type}`).join('; ')} }`\n}\n\nfunction renderTypeExpression(type: TypeExpression): string {\n if (typeof type === 'string') return type\n if (isIndexedAccessType(type)) return `${type.target}['${type.key}']`\n\n return renderMembers(type.members.map((member) => ({ key: member.name, type: renderTypeExpression(member.type), optional: member.optional })))\n}\n\nexport type FunctionPrinterOptions = {\n /**\n * Rendering modes supported by `functionPrinter`.\n *\n * | Mode | Output example | Use case |\n * |---------------|-----------------------------------|--------------------------------|\n * | `declaration` | `id: string, config: Config = {}` | Function parameter declaration |\n * | `call` | `id, { method, url }` | Function call arguments |\n */\n mode: 'declaration' | 'call'\n /**\n * Optional transformation applied to every parameter name before printing.\n */\n transformName?: (name: string) => string\n /**\n * Optional transformation applied to every type string before printing.\n */\n transformType?: (type: string) => string\n}\n\nfunction groupMembers(param: FunctionParameterNode): ReadonlyArray<{ name: string; optional?: boolean }> | null {\n if (typeof param.name === 'string') return null\n return param.type && isTypeLiteral(param.type) ? param.type.members : []\n}\n\nfunction rank(param: FunctionParameterNode): number {\n if (param.rest) return PARAM_RANK.rest\n if (param.default) return PARAM_RANK.withDefault\n const members = groupMembers(param)\n if (members) return members.every((m) => m.optional) ? PARAM_RANK.optional : PARAM_RANK.required\n return param.optional ? PARAM_RANK.optional : PARAM_RANK.required\n}\n\n/**\n * Orders a destructured group's binding elements and type members together,\n * required fields first, matching how grouped children were sorted before.\n */\ntype GroupMember = { name: string; propertyName?: string; type?: TypeExpression; optional?: boolean }\n\nfunction sortedGroupMembers(name: ObjectBindingPatternNode, type: TypeExpression | undefined): Array<GroupMember> {\n const members = type && isTypeLiteral(type) ? type.members : []\n const memberRank = (optional?: boolean) => (optional ? PARAM_RANK.optional : PARAM_RANK.required)\n return name.elements\n .map((element, index) => ({\n name: element.name,\n propertyName: element.propertyName,\n type: members[index]?.type,\n optional: members[index]?.optional,\n }))\n .toSorted((a, b) => memberRank(a.optional) - memberRank(b.optional))\n}\n\n/**\n * Renders one binding element: the local name, prefixed with its source key when the\n * binding renames the property, as in `{ petId: id }`.\n */\nfunction renderBindingMember(member: GroupMember, transformName?: (name: string) => string): string {\n const local = transformName ? transformName(member.name) : member.name\n return member.propertyName ? `${member.propertyName}: ${local}` : local\n}\n\n/**\n * Renders the type annotation of a destructured group. An inline object type is\n * rendered from the already-sorted members so its key order matches the binding;\n * a reference type is rendered as-is.\n */\nfunction renderGroupType(type: TypeExpression | undefined, sorted: Array<GroupMember>, transformType?: (type: string) => string): string | undefined {\n if (!type) return undefined\n if (!isTypeLiteral(type)) return renderType(type)\n\n const typed = sorted.filter((member) => member.type !== undefined)\n if (!typed.length) return undefined\n return renderMembers(\n typed.map((member) => ({ key: member.propertyName ?? member.name, type: renderType(member.type!, transformType), optional: member.optional })),\n )\n}\n\nfunction printParameter(node: FunctionParameterNode, options: FunctionPrinterOptions): string {\n const { mode, transformName, transformType } = options\n const bindingName = node.name\n\n if (mode === 'call') {\n if (typeof bindingName !== 'string') {\n const keys = sortedGroupMembers(bindingName, node.type)\n .map((member) => renderBindingMember(member))\n .join(', ')\n return `{ ${keys} }`\n }\n const name = transformName ? transformName(bindingName) : bindingName\n return node.rest ? `...${name}` : name\n }\n\n if (typeof bindingName !== 'string') {\n const sorted = sortedGroupMembers(bindingName, node.type)\n const binding = `{ ${sorted.map((member) => renderBindingMember(member, transformName)).join(', ')} }`\n const allOptional = sorted.every((member) => member.optional)\n const type = renderGroupType(node.type, sorted, transformType)\n if (type) {\n if (allOptional) return `${binding}: ${type} = ${node.default ?? '{}'}`\n return node.default ? `${binding}: ${type} = ${node.default}` : `${binding}: ${type}`\n }\n return node.default ? `${binding} = ${node.default}` : binding\n }\n\n const name = transformName ? transformName(bindingName) : bindingName\n const type = node.type ? renderType(node.type, transformType) : undefined\n\n if (node.rest) {\n return type ? `...${name}: ${type}` : `...${name}`\n }\n if (type) {\n if (node.optional) return `${name}?: ${type}`\n return node.default ? `${name}: ${type} = ${node.default}` : `${name}: ${type}`\n }\n return node.default ? `${name} = ${node.default}` : name\n}\n\n/**\n * Default function-signature printer. Renders a parameter list in one of two modes:\n * `declaration` for the function signature and `call` for the call arguments.\n *\n * @example\n * ```ts\n * const printer = functionPrinter({ mode: 'declaration' })\n *\n * const sig = createFunctionParameters({\n * params: [\n * createFunctionParameter({ name: 'petId', type: 'string', optional: false }),\n * createFunctionParameter({ name: 'config', type: 'Config', optional: false, default: '{}' }),\n * ],\n * })\n *\n * printer.print(sig) // → \"petId: string, config: Config = {}\"\n * ```\n */\nexport function functionPrinter(options: FunctionPrinterOptions) {\n return {\n name: 'functionParameters' as const,\n options,\n print(node: FunctionParametersNode): string {\n // `toSorted` is a stable sort, so equal-rank params keep their declared order.\n return node.params\n .toSorted((a, b) => rank(a) - rank(b))\n .map((p) => printParameter(p, options))\n .filter(Boolean)\n .join(', ')\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,YAAY;;;;;;AAOlB,SAAS,MAAM,MAA6B;CAC1C,OAAO,KACJ,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,SAAS,YAAa,YAAY,QAAQ,YAAY,IAAI,UAAU,QAAQ,MAAM,SAAS,CAAE;AAClG;;;;;;;;;;AAsBA,SAAgB,UAAU,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CAC1F,OAAO,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC,CACxC,KAAK,SAAS,KAAK,QAAQ,iBAAiB,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAC9D,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;AACb;;;;;;;AAQA,SAAgB,mBAAmB,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CACnG,OAAO,UAAU,MAAM;EAAE;EAAQ;CAAO,CAAC,CAAC,CAAC,YAAY;AACzD;;;;;;ACzDA,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAU;;;;;;;;;;;AAYV,SAAgB,eAAe,MAAuB;CACpD,IAAI,CAAC,QAAQ,cAAc,IAAI,IAAiB,GAC9C,OAAO;CAET,OAAO,aAAa,IAAI;A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AAa,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;EACnG,MAAM,cAAc,OAAO,OAAO,WAAW,OAAO,QAAQ;EAC5D,MAAM,OAAO,gBAAgB,KAAK,MAAM,QAAQ,aAAa;EAC7D,IAAI,MAAM;GACR,IAAI,aAAa,OAAO,GAAG,QAAQ,IAAI,KAAK,KAAK,KAAK,WAAW;GACjE,OAAO,KAAK,UAAU,GAAG,QAAQ,IAAI,KAAK,KAAK,KAAK,YAAY,GAAG,QAAQ,IAAI;EACjF;EACA,OAAO,KAAK,UAAU,GAAG,QAAQ,KAAK,KAAK,YAAY;CACzD;CAEA,MAAM,OAAO,gBAAgB,cAAc,WAAW,IAAI;CAC1D,MAAM,OAAO,KAAK,OAAO,WAAW,KAAK,MAAM,aAAa,IAAI,KAAA;CAEhE,IAAI,KAAK,MACP,OAAO,OAAO,MAAM,KAAK,IAAI,SAAS,MAAM;CAE9C,IAAI,MAAM;EACR,IAAI,KAAK,UAAU,OAAO,GAAG,KAAK,KAAK;EACvC,OAAO,KAAK,UAAU,GAAG,KAAK,IAAI,KAAK,KAAK,KAAK,YAAY,GAAG,KAAK,IAAI;CAC3E;CACA,OAAO,KAAK,UAAU,GAAG,KAAK,KAAK,KAAK,YAAY;AACtD;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,gBAAgB,SAAiC;CAC/D,OAAO;EACL,MAAM;EACN;EACA,MAAM,MAAsC;GAE1C,OAAO,KAAK,OACT,UAAU,GAAG,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CACrC,KAAK,MAAM,eAAe,GAAG,OAAO,CAAC,CAAC,CACtC,OAAO,OAAO,CAAC,CACf,KAAK,IAAI;EACd;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["isNonNullable","getEnumNames","factory.createEnumDeclaration","getEnumNames","factory","factory.createUnionDeclaration","factory.print","factory.createRaw","factory.createTypeReferenceNode","factory.createUrlTemplateType","factory.dateOrStringNode","factory.constToTypeNode","factory.createIntersectionDeclaration","factory.createTypeLiteralNode","factory.buildMemberNodes","factory.createArrayDeclaration","factory.buildTupleNode","factory.buildPropertyType","factory.createPropertySignature","factory.appendJSDocToNode","factory.buildIndexSignatures","factory.createOmitDeclaration","factory.wrapNullableOptional","factory.createTypeDeclaration","getEnumNames"],"sources":["../../../internals/utils/src/reserved.ts","../../../internals/utils/src/fs.ts","../../../internals/utils/src/strings.ts","../src/factory.ts","../src/components/Enum.tsx","../src/utils.ts","../src/printers/printerTs.ts","../src/components/Type.tsx","../../../internals/shared/src/operation.ts","../../../internals/shared/src/resolver.ts","../src/generators/typeGenerator.tsx","../kubb-extension.json","../package.json","../src/resolvers/resolverTs.ts","../src/plugin.ts","../src/printers/functionParams.ts","../src/printers/functionPrinter.ts"],"sourcesContent":["/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'await',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `name` when it's a syntactically valid JavaScript variable name,\n * otherwise prefixes it with `_` so the result is a valid identifier.\n *\n * Useful for sanitizing OpenAPI schema names or operation IDs that start with\n * a digit (e.g. `409`, `504AccountCancel`) before using them as exported\n * variable, type, or function names.\n *\n * @example\n * ```ts\n * ensureValidVarName('409') // '_409'\n * ensureValidVarName('504AccountCancel') // '_504AccountCancel'\n * ensureValidVarName('Pet') // 'Pet'\n * ensureValidVarName('class') // '_class'\n * ```\n */\nexport function ensureValidVarName(name: string): string {\n if (!name || isValidVarName(name)) {\n return name\n }\n return `_${name}`\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { posix } from 'node:path'\nimport { casing } from '@kubb/kit'\nfunction toSlash(p: string): string {\n if (p.startsWith('\\\\\\\\?\\\\')) return p\n return p.replaceAll('\\\\', '/')\n}\n\n/**\n * Returns the relative path from `rootDir` to `filePath`, always using forward slashes\n * and prefixed with `./` when not already traversing upward.\n *\n * @example\n * ```ts\n * getRelativePath('/src/components', '/src/components/Button.tsx') // './Button.tsx'\n * getRelativePath('/src/components', '/src/utils/helpers.ts') // '../utils/helpers.ts'\n * ```\n */\nexport function getRelativePath(rootDir: string, filePath: string): string {\n const relativePath = posix.relative(toSlash(rootDir), toSlash(filePath))\n\n return relativePath.startsWith('../') ? relativePath : `./${relativePath}`\n}\n\n/**\n * Builds a nested file path from a dotted name. Splits on dots that precede a letter\n * (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases\n * every earlier segment, applies `caseLast` to the final segment, and joins with `/`.\n *\n * Empty segments are dropped before joining. They arise when the name starts with a dot\n * followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to\n * an empty string). Without this a leading `/` would form, which `path.resolve` reads as an\n * absolute path, letting generated files escape the configured output directory.\n *\n * @example Nested path from a dotted name\n * `toFilePath('pet.petId') // 'pet/petId'`\n *\n * @example PascalCase the final segment\n * `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`\n *\n * @example Suffix applied to the final segment only\n * `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`\n */\nexport function toFilePath(name: string, caseLast: (part: string) => string = casing.camel): string {\n const parts = name.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => (i === parts.length - 1 ? caseLast(part) : casing.camel(part)))\n .filter(Boolean)\n .join('/')\n}\n","import { text } from '@kubb/kit'\n\n// `\\p{`, `\\P{` or `\\u{` behind an odd number of backslashes, or a character outside the BMP: both need the `u` flag.\nconst NEEDS_UNICODE = /(?<!\\\\)(?:\\\\\\\\)*\\\\[pPu]\\{|[\\u{10000}-\\u{10FFFF}]/u\n// Escapes the `u` flag accepts. `\\-` only counts inside a class.\nconst KEPT_ESCAPE = /[A-Za-z0-9^$\\\\.*+?()[\\]{}|/]/\n\n/**\n * Drops the backslash from escapes that the `u` flag rejects: an escaped punctuation character that is\n * not a syntax character, and `\\-` outside a class. Both match the same character without the backslash.\n */\nfunction dropIdentityEscapes(pattern: string): string {\n let inClass = false\n\n return pattern.replace(/\\\\(.)|[[\\]]/gs, (match, escaped?: string) => {\n if (escaped === undefined) {\n inClass = match === '['\n return match\n }\n\n return KEPT_ESCAPE.test(escaped) || (escaped === '-' && inClass) ? match : escaped\n })\n}\n\n/**\n * Builds the `RegExp` for a pattern, adding the `u` flag when it uses `\\p{...}`, `\\P{...}` or `\\u{...}`, or\n * holds a character outside the BMP. A pattern that is not valid under `u` keeps the flags it came with.\n */\nfunction toRegExp(pattern: string, flags: string | undefined): RegExp {\n if (flags?.includes('u') || !NEEDS_UNICODE.test(pattern)) return new RegExp(pattern, flags)\n\n try {\n return new RegExp(dropIdentityEscapes(pattern), `${flags ?? ''}u`)\n } catch {\n return new RegExp(pattern, flags)\n }\n}\n\n/**\n * Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.\n * Inline flags expressed as a `^(?im)` prefix are extracted and applied to the resulting expression.\n * Pass `null` as the second argument to emit a `/pattern/flags` literal instead.\n *\n * @example\n * ```ts\n * toRegExpString('^(?im)foo') // 'new RegExp(\"^foo\", \"im\")'\n * toRegExpString('^(?im)foo', null) // '/^foo/im'\n * ```\n */\nexport function toRegExpString(pattern: string, func: string | null = 'RegExp'): string {\n const raw = text.unquote(pattern)\n\n const match = raw.match(/^\\^(\\(\\?([igmsuy]+)\\))/i)\n const replacementTarget = match?.[1] ?? ''\n const matchedFlags = match?.[2]\n const cleaned = raw\n .replace(/^\\\\?\\//, '')\n .replace(/\\\\?\\/$/, '')\n .replace(replacementTarget, '')\n\n const { source, flags } = toRegExp(cleaned, matchedFlags)\n\n if (func === null) return `/${source}/${flags}`\n\n return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ''})`\n}\n\n/**\n * Renders a dotted path or string array as an optional-chaining accessor expression rooted at\n * `accessor`. Returns `null` for an empty path.\n *\n * @example\n * ```ts\n * getNestedAccessor('pagination.next.id', 'lastPage')\n * // \"lastPage?.['pagination']?.['next']?.['id']\"\n * ```\n */\nexport function getNestedAccessor(param: string | Array<string>, accessor: string): string | null {\n const parts = Array.isArray(param) ? param : param.split('.')\n if (parts.length === 0 || (parts.length === 1 && parts[0] === '')) return null\n return `${accessor}?.['${`${parts.join(\"']?.['\")}']`}`\n}\n\n/**\n * Escapes an `@` at the start of a line, so a multi-line description can't start a new JSDoc tag.\n * Editors render `\\@` as `@` in hovers.\n *\n * @example\n * ```ts\n * jsDocEscape('intro\\n@example value') // 'intro\\n\\\\@example value'\n * ```\n */\nexport function jsDocEscape(input: unknown): string {\n return `${input}`.replace(/^(\\s*)@/gm, '$1\\\\@')\n}\n","import { ast, casing, text } from '@kubb/kit'\nimport { generate } from 'yuku-codegen'\n\n/**\n * A TS-ESTree node, the AST shape `yuku-codegen` prints. Nodes built here carry no source positions.\n */\nexport type TsNode = { type: string; [key: string]: unknown }\n\nfunction isNumber(value: unknown): value is number {\n return typeof value === 'number' && !Number.isNaN(value)\n}\n\nexport function isNonNullable<T>(value: T | null | undefined): value is T {\n return value !== null && value !== undefined\n}\n\n/**\n * Prints `node` as TypeScript source with single quotes and two-space indentation.\n */\nexport function print(node: TsNode): string {\n return generate(node as unknown as Parameters<typeof generate>[0], { quotes: 'single' }).code\n}\n\n/**\n * Wraps already printed TypeScript, such as a user override result, so it can sit inside a node tree.\n * Parentheses keep a union or function type intact when it lands inside an array or intersection.\n */\nexport function createRaw(text: string): TsNode {\n const name = { type: 'TSTypeReference', typeName: identifier(text), typeArguments: null }\n return /[|&?]|=>/.test(text) ? { type: 'TSParenthesizedType', typeAnnotation: name } : name\n}\n\nfunction identifier(name: string): TsNode {\n return { type: 'Identifier', name }\n}\n\nfunction literal(value: string | number | boolean): TsNode {\n return { type: 'Literal', value }\n}\n\nfunction createLiteralType(value: string | number | boolean): TsNode {\n return { type: 'TSLiteralType', literal: literal(value) }\n}\n\n/**\n * Whether `name` can be written as a bare property name instead of a quoted string.\n */\nfunction isValidIdentifier(name: string): boolean {\n return /^[\\p{ID_Start}$_][\\p{ID_Continue}$]*$/u.test(name)\n}\n\n/**\n * A property or enum member name, quoted when it is not a valid identifier.\n */\nfunction propertyName(name: string): TsNode {\n return isValidIdentifier(name) ? identifier(name) : literal(name)\n}\n\n/**\n * Creates a TypeScript intersection type.\n * Returns the single type if only one is provided. `yuku-codegen` adds the parentheses a union member needs.\n */\nexport function createIntersectionDeclaration({ nodes, withParentheses }: { nodes: Array<TsNode>; withParentheses?: boolean }): TsNode | null {\n if (!nodes.length) {\n return null\n }\n\n if (nodes.length === 1) {\n return nodes[0] || null\n }\n\n const node = { type: 'TSIntersectionType', types: nodes }\n\n return withParentheses ? { type: 'TSParenthesizedType', typeAnnotation: node } : node\n}\n\n/**\n * Creates a TypeScript array type.\n * Use `arrayType: 'array'` for bracket syntax (`T[]`), or `'generic'` for `Array<T>`.\n *\n * @example Array bracket syntax\n * `createArrayDeclaration({ nodes: [string], arrayType: 'array' }) // → string[]`\n *\n * @example Generic Array syntax\n * `createArrayDeclaration({ nodes: [string], arrayType: 'generic' }) // → Array<string>`\n */\nexport function createArrayDeclaration({ nodes, arrayType = 'array' }: { nodes: Array<TsNode>; arrayType?: 'array' | 'generic' }): TsNode {\n if (!nodes.length) {\n return { type: 'TSTupleType', elementTypes: [] }\n }\n\n const node = nodes.length === 1 ? nodes[0]! : { type: 'TSUnionType', types: nodes }\n\n return arrayType === 'generic' ? createTypeReferenceNode('Array', [node]) : { type: 'TSArrayType', elementType: node }\n}\n\n/**\n * Minimum nodes length of 2\n * @example Union type example\n * `string | number`\n */\nexport function createUnionDeclaration({ nodes, withParentheses }: { nodes: Array<TsNode>; withParentheses?: boolean }): TsNode {\n if (!nodes.length) {\n return keywordTypeNodes.any\n }\n\n if (nodes.length === 1) {\n return nodes[0]!\n }\n\n const node = { type: 'TSUnionType', types: nodes }\n\n return withParentheses ? { type: 'TSParenthesizedType', typeAnnotation: node } : node\n}\n\n/**\n * Creates a TypeScript property signature for object/interface members.\n * Supports optional markers, readonly modifiers, and type annotations.\n */\nexport function createPropertySignature({\n readOnly,\n name,\n questionToken,\n type,\n}: {\n readOnly?: boolean\n name: string\n questionToken?: boolean\n type?: TsNode\n}): TsNode {\n return {\n type: 'TSPropertySignature',\n key: propertyName(name),\n computed: false,\n optional: !!questionToken,\n readonly: !!readOnly,\n static: false,\n typeAnnotation: type ? { type: 'TSTypeAnnotation', typeAnnotation: type } : null,\n }\n}\n\n/**\n * Attaches a JSDoc block built from `comments` to `node`, dropping empty comments.\n */\nexport function appendJSDocToNode<TNode extends TsNode>({ node, comments }: { node: TNode; comments: Array<string | undefined> }): TNode {\n const lines = comments.filter(Boolean).flatMap((comment = '') => comment.split(/\\r?\\n/))\n\n if (!lines.length) {\n return node\n }\n\n // `yuku-codegen` prints the comment text as is, so a `*/` inside it would end the block early\n const value = `*\\n${lines.map((line) => ` * ${line.replaceAll('*/', '*\\\\/')}`.trimEnd()).join('\\n')}\\n `\n\n return { ...node, comments: [{ type: 'Block', value, position: 'before', sameLine: false }] }\n}\n\n/**\n * Creates a TypeScript type literal (anonymous object type) with one member per line.\n */\nexport function createTypeLiteralNode(members: Array<TsNode>): TsNode {\n return { type: 'TSTypeLiteral', members }\n}\n\n/**\n * Creates a TypeScript type reference (e.g., `Array<string>`, `Record<K, V>`).\n */\nexport function createTypeReferenceNode(name: string, typeArguments?: Array<TsNode>): TsNode {\n return {\n type: 'TSTypeReference',\n typeName: identifier(name),\n typeArguments: typeArguments?.length ? { type: 'TSTypeParameterInstantiation', params: typeArguments } : null,\n }\n}\n\nfunction exportNamed(declaration: TsNode, exportKind: 'type' | 'value'): TsNode {\n return { type: 'ExportNamedDeclaration', declaration, specifiers: [], source: null, attributes: [], exportKind }\n}\n\n/**\n * Prints a TypeScript type declaration as either a type alias or interface.\n * Uses interface syntax only when requested and the type is an object literal, and attaches JSDoc comments.\n */\nexport function createTypeDeclaration({\n syntax,\n isExportable,\n comments,\n name,\n type,\n}: {\n syntax: 'type' | 'interface'\n comments: Array<string | undefined>\n isExportable?: boolean\n name: string\n type: TsNode\n}): string {\n const declaration =\n syntax === 'interface' && type.type === 'TSTypeLiteral'\n ? {\n type: 'TSInterfaceDeclaration',\n declare: false,\n id: identifier(name),\n typeParameters: null,\n extends: [],\n body: { type: 'TSInterfaceBody', body: type.members },\n }\n : { type: 'TSTypeAliasDeclaration', declare: false, id: identifier(name), typeParameters: null, typeAnnotation: type }\n\n return print(appendJSDocToNode({ node: isExportable ? exportNamed(declaration, 'type') : declaration, comments }))\n}\n\n/**\n * Converts an enum member value to a literal. Numbers become numeric literals unless `asNumber` is `false`,\n * which emits the string form.\n */\nfunction valueToExpression(value: string | number | boolean, asNumber = isNumber(value)): TsNode {\n return literal(typeof value === 'boolean' || (asNumber && isNumber(value)) ? value : value.toString())\n}\n\n/**\n * Apply casing transformation to enum keys\n */\nfunction applyEnumKeyCasing(key: string, keyCasing: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none' = 'none'): string {\n if (keyCasing === 'none') {\n return key\n }\n if (keyCasing === 'screamingSnakeCase') {\n return casing.screamingSnake(key)\n }\n if (keyCasing === 'snakeCase') {\n return casing.snake(key)\n }\n if (keyCasing === 'pascalCase') {\n return casing.pascal(key)\n }\n if (keyCasing === 'camelCase') {\n return casing.camel(key)\n }\n return key\n}\n\n/**\n * Creates a TypeScript enum declaration or equivalent construct in various formats.\n * Returns a tuple of [name declaration, type declaration] - the name declaration may be undefined for certain types.\n *\n * @example\n * ```ts\n * const [name, type] = createEnumDeclaration({\n * type: 'enum',\n * name: 'petType',\n * typeName: 'PetType',\n * enums: [['cat', 'cat', 'A cat'], ['dog', 'dog']],\n * })\n * ```\n */\nexport function createEnumDeclaration({\n type = 'enum',\n name,\n typeName,\n enums,\n enumKeyCasing = 'none',\n}: {\n /**\n * Choose to use `enum`, `asConst`, `constEnum`, or `literal` for enums.\n * - `enum`: TypeScript enum\n * - `asConst`: const object asserted with `as const` (the caller decides the const name casing)\n * - `constEnum`: const enum\n * - `literal`: literal union type\n * @default `'enum'`\n */\n type?: 'enum' | 'asConst' | 'constEnum' | 'literal' | 'inlineLiteral'\n /**\n * Enum name in camelCase.\n */\n name: string\n /**\n * Enum name in PascalCase.\n */\n typeName: string\n enums: Array<[key: string | number, value: string | number | boolean, description?: string]>\n /**\n * Choose the casing for enum key names.\n * @default 'none'\n */\n enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none'\n}): [name: string | undefined, type: string] {\n const typeAlias = (annotation: TsNode) => createTypeDeclaration({ syntax: 'type', isExportable: true, name: typeName, comments: [], type: annotation })\n\n if (type === 'literal' || type === 'inlineLiteral') {\n const members = enums\n .map(([_key, value]) => (isNonNullable(value) ? { type: 'TSLiteralType', literal: valueToExpression(value) } : undefined))\n .filter(isNonNullable)\n\n return [undefined, typeAlias(members.length ? createUnionDeclaration({ nodes: members }) : keywordTypeNodes.never)]\n }\n\n if (type === 'enum' || type === 'constEnum') {\n const members = enums\n .map(([key, value, description]) => {\n const initializer = valueToExpression(value, Number.parseInt(value.toString(), 10) === value)\n const memberName = isNumber(Number.parseInt(key.toString(), 10)) ? `${typeName}_${key}` : key?.toString()\n if (memberName === undefined) return undefined\n\n const id = propertyName(applyEnumKeyCasing(memberName, enumKeyCasing))\n return appendJSDocToNode({ node: { type: 'TSEnumMember', id, initializer }, comments: [description] })\n })\n .filter(isNonNullable)\n\n const declaration = {\n type: 'TSEnumDeclaration',\n declare: false,\n const: type === 'constEnum',\n id: identifier(typeName),\n body: { type: 'TSEnumBody', members },\n }\n\n return [undefined, print(exportNamed(declaration, 'value'))]\n }\n\n // used when using `as const` instead of an TypeScript enum.\n // name is already cased by the caller (camelCase or pascalCase, driven by enum.constCasing).\n // typeName carries the typeSuffix for the type alias, so we use name for the const identifier.\n const identifierName = name\n\n // When there are no enum items (empty or all-null enum), don't generate a runtime const.\n // Return undefined for nameNode so the barrel won't try to export a non-existent symbol.\n // Use `never` as the type alias to keep references valid without creating a broken const.\n if (enums.length === 0) {\n return [undefined, typeAlias(keywordTypeNodes.never)]\n }\n\n // `yuku-codegen` prints object literals on one line, so each property prints on its own and the lines join here\n const properties = enums\n .map(([key, value, description]) => {\n if (key === null || key === undefined) return undefined\n\n const property = {\n type: 'Property',\n kind: 'init',\n key: propertyName(applyEnumKeyCasing(key.toString(), enumKeyCasing)),\n value: valueToExpression(value),\n computed: false,\n method: false,\n shorthand: false,\n }\n return print(appendJSDocToNode({ node: property, comments: [description] }))\n })\n .filter(isNonNullable)\n\n const query = { type: 'TSTypeQuery', exprName: identifier(identifierName), typeArguments: null }\n\n return [\n `export const ${identifierName} = {\\n${properties.map((property) => text.indent({ text: property })).join(',\\n')},\\n} as const;`,\n typeAlias({\n type: 'TSIndexedAccessType',\n objectType: { type: 'TSParenthesizedType', typeAnnotation: query },\n indexType: { type: 'TSTypeOperator', operator: 'keyof', typeAnnotation: query },\n }),\n ]\n}\n\n/**\n * Creates a TypeScript `Omit<T, Keys>` type reference.\n * Optionally wraps the type in `NonNullable<T>` if `nonNullable` is true.\n */\nexport function createOmitDeclaration({ keys, type, nonNullable }: { keys: Array<string> | string; type: TsNode; nonNullable?: boolean }): TsNode {\n const node = nonNullable ? createTypeReferenceNode('NonNullable', [type]) : type\n\n return createTypeReferenceNode('Omit', [node, createUnionDeclaration({ nodes: [keys].flat().map(createLiteralType) })])\n}\n\n/**\n * TypeScript keyword types for common primitive types.\n */\nexport const keywordTypeNodes = {\n any: { type: 'TSAnyKeyword' },\n unknown: { type: 'TSUnknownKeyword' },\n void: { type: 'TSVoidKeyword' },\n number: { type: 'TSNumberKeyword' },\n integer: { type: 'TSNumberKeyword' },\n bigint: { type: 'TSBigIntKeyword' },\n object: { type: 'TSObjectKeyword' },\n string: { type: 'TSStringKeyword' },\n boolean: { type: 'TSBooleanKeyword' },\n undefined: { type: 'TSUndefinedKeyword' },\n null: { type: 'TSNullKeyword' },\n never: { type: 'TSNeverKeyword' },\n} as const satisfies Record<string, TsNode>\n\n/**\n * Converts an OAS-style path (e.g. `/pets/{petId}`) or an Express-style path\n * (e.g. `/pets/:petId`) to a TypeScript template literal type\n * like `` `/pets/${string}` ``.\n */\nexport function createUrlTemplateType(path: string): TsNode {\n // normalized Express `:param` → OAS `{param}` so a single regex handles both.\n const normalized = path.replace(/:([^/]+)/g, '{$1}')\n\n if (!normalized.includes('{')) {\n return createLiteralType(normalized)\n }\n\n const segments = normalized.split(/\\{[^}]+\\}/)\n // `yuku-codegen` escapes the cooked text itself when no raw text is given\n const quasis = segments.map((cooked, i) => ({ type: 'TemplateElement', value: { cooked }, tail: i === segments.length - 1 }))\n\n return { type: 'TSTemplateLiteralType', quasis, types: segments.slice(1).map(() => keywordTypeNodes.string) }\n}\n\n// ─── Printer helpers ──────────────────────────────────────────────────────────\n\n/**\n * Converts a const value to a literal type, preserving nested arrays and objects.\n */\nexport function constToTypeNode(value: unknown, format?: 'string' | 'number' | 'boolean'): TsNode {\n if (value === null) return keywordTypeNodes.null\n if (Array.isArray(value)) {\n return { type: 'TSTupleType', elementTypes: value.map((item) => constToTypeNode(item)) }\n }\n if (typeof value === 'object') {\n return createTypeLiteralNode(Object.entries(value).map(([name, item]) => createPropertySignature({ name, type: constToTypeNode(item) })))\n }\n if ((format ?? typeof value) === 'boolean') {\n return createLiteralType(value === true)\n }\n return createLiteralType((format ?? typeof value) === 'number' && typeof value === 'number' ? value : String(value))\n}\n\n/**\n * Returns a `Date` reference type when `representation` is `'date'`, otherwise falls back to `string`.\n */\nexport function dateOrStringNode(node: { representation?: string }): TsNode {\n return node.representation === 'date' ? createTypeReferenceNode('Date') : keywordTypeNodes.string\n}\n\n/**\n * Maps an array of `SchemaNode`s through the printer, filtering out `null` and `undefined` results.\n */\nexport function buildMemberNodes(members: Array<ast.SchemaNode> | undefined, print: (node: ast.SchemaNode) => TsNode | null | undefined): Array<TsNode> {\n return (members ?? []).map(print).filter(isNonNullable)\n}\n\n/**\n * Builds a TypeScript tuple type from an array schema's `items`,\n * applying min/max slice and optional/rest element rules.\n */\nexport function buildTupleNode(node: ast.ArraySchemaNode, print: (node: ast.SchemaNode) => TsNode | null | undefined): TsNode {\n let items = (node.items ?? []).map(print).filter(isNonNullable)\n\n const restNode = node.rest ? (print(node.rest) ?? undefined) : undefined\n const { min, max } = node\n\n if (max !== undefined) {\n items = items.slice(0, max)\n if (items.length < max && restNode) {\n items = [...items, ...Array(max - items.length).fill(restNode)]\n }\n }\n\n if (min !== undefined) {\n items = items.map((item, i) => (i >= min ? { type: 'TSOptionalType', typeAnnotation: item } : item))\n }\n\n if (max === undefined && restNode) {\n items.push({ type: 'TSRestType', typeAnnotation: { type: 'TSArrayType', elementType: restNode } })\n }\n\n return { type: 'TSTupleType', elementTypes: items }\n}\n\n/**\n * Appends `| null` and then `| undefined` to a type when requested.\n */\nexport function wrapNullableOptional(type: TsNode, nullable: boolean, addsUndefined: boolean): TsNode {\n const withNullable = nullable ? createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] }) : type\n return addsUndefined ? createUnionDeclaration({ nodes: [withNullable, keywordTypeNodes.undefined] }) : withNullable\n}\n\n/**\n * Applies `nullable` and optional/nullish `| undefined` union modifiers to a property's resolved base type.\n */\nexport function buildPropertyType(\n schema: ast.SchemaNode,\n baseType: TsNode,\n optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined',\n optional?: boolean,\n): TsNode {\n const addsUndefined = optionalType === 'undefined' || optionalType === 'questionTokenAndUndefined'\n const meta = ast.ref.mergeSchema(schema)\n\n return wrapNullableOptional(baseType, !!meta.nullable, addsUndefined && !!(optional || meta.nullish || meta.optional))\n}\n\n/**\n * Creates a TypeScript index signature for `additionalProperties` and `patternProperties` on an\n * object schema node. TypeScript allows only one string index signature and its value must be\n * assignable from every named property, so both keywords collapse into a single signature: the\n * union of all value types (deduplicated), or `unknown` when the object also has fixed properties.\n * The key regex of `patternProperties` cannot be expressed by an index signature and is dropped.\n */\nexport function buildIndexSignatures(\n node: { additionalProperties?: ast.SchemaNode | boolean; patternProperties?: Record<string, ast.SchemaNode> },\n propertyCount: number,\n printNode: (node: ast.SchemaNode) => TsNode | null | undefined,\n): Array<TsNode> {\n const valueTypes: Array<TsNode> = []\n\n if (node.additionalProperties && node.additionalProperties !== true) {\n valueTypes.push(printNode(node.additionalProperties) ?? keywordTypeNodes.unknown)\n } else if (node.additionalProperties === true) {\n valueTypes.push(keywordTypeNodes.unknown)\n }\n\n for (const schema of Object.values(node.patternProperties ?? {})) {\n const patternType = printNode(schema) ?? keywordTypeNodes.unknown\n valueTypes.push(schema.nullable ? createUnionDeclaration({ nodes: [patternType, keywordTypeNodes.null] }) : patternType)\n }\n\n if (valueTypes.length === 0) return []\n\n // Deduplicate by printed text, since equal types are separate node objects\n const distinct = [...new Map(valueTypes.map((type) => [print(type), type])).values()]\n const valueType = propertyCount > 0 ? keywordTypeNodes.unknown : createUnionDeclaration({ nodes: distinct })\n\n return [\n {\n type: 'TSIndexSignature',\n parameters: [{ type: 'Identifier', name: 'key', typeAnnotation: { type: 'TSTypeAnnotation', typeAnnotation: keywordTypeNodes.string } }],\n typeAnnotation: { type: 'TSTypeAnnotation', typeAnnotation: valueType },\n readonly: false,\n static: false,\n accessibility: null,\n },\n ]\n}\n","import { ensureValidVarName } from '@internals/utils'\nimport { casing, text } from '@kubb/kit'\nimport type { ast } from '@kubb/kit'\nimport { File } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx'\nimport * as factory from '../factory.ts'\nimport type { PluginTs, ResolverTs } from '../types.ts'\n\ntype EnumOptions = PluginTs['resolvedOptions']['enum']\n\ntype Props = {\n node: ast.EnumSchemaNode\n enum: EnumOptions\n resolver: ResolverTs\n key?: string | number | null\n}\n\n/**\n * Resolves the runtime identifier name and the TypeScript type name for an enum schema node.\n *\n * The raw `node.name` may be a YAML key such as `\"enumNames.Type\"` which is not a\n * valid TypeScript identifier. The resolver normalizes it. For inline enum properties the adapter\n * already emits a PascalCase+suffix name, so resolution is typically a no-op.\n *\n * When `constCasing` is `'pascalCase'` and `typeSuffix` is empty, the const and the type\n * resolve to the same name, which TypeScript merges into a single value+type declaration.\n */\nexport function getEnumNames({ node, enum: enumOptions, resolver }: { node: ast.EnumSchemaNode; enum: EnumOptions; resolver: ResolverTs }): {\n enumName: string\n typeName: string\n} {\n const resolved = resolver.name(node.name!)\n const enumName = enumOptions.constCasing === 'pascalCase' ? resolved : ensureValidVarName(casing.camel(node.name!))\n const typeName = enumOptions.type === 'asConst' ? resolver.enum.keyName(node, enumOptions.typeSuffix) : resolved\n\n return { enumName, typeName }\n}\n\n/**\n * Renders the enum declaration(s) for a single named `EnumSchemaNode`.\n *\n * Depending on `enum.type` this may emit:\n * - A runtime object (`asConst`) plus a `typeof` type alias\n * - A `const enum` or plain `enum` declaration (`constEnum` / `enum`)\n * - A union literal type alias (`literal`)\n *\n * The emitted `File.Source` nodes carry the resolved names so that the barrel\n * index picks up the correct export identifiers.\n */\nexport function Enum({ node, enum: enumOptions, resolver }: Props): KubbReactNode {\n const { enumName, typeName } = getEnumNames({ node, enum: enumOptions, resolver })\n\n const [nameNode, typeNode] = factory.createEnumDeclaration({\n name: enumName,\n typeName,\n enums: (node.namedEnumValues?.map((v) => [text.unquote(v.name.toString()), v.value, v.description]) ??\n node.enumValues?.filter((v): v is NonNullable<typeof v> => v !== null && v !== undefined).map((v) => [text.unquote(v.toString()), v]) ??\n []) as Array<[string | number, string | number | boolean, string?]>,\n type: enumOptions.type,\n enumKeyCasing: enumOptions.keyCasing,\n })\n\n // When the const and the type share a name (pascalCase const + empty typeSuffix) they merge into\n // one declaration. The const carries the barrel export, so keep the type alias in the file but out\n // of the barrel to avoid re-exporting the name a second time as `export type { … }`.\n const namesMerge = !!nameNode && enumName === typeName\n\n return (\n <>\n {nameNode && (\n <File.Source name={enumName} pointer={node.pointer} isExportable isIndexable isTypeOnly={false}>\n {nameNode}\n </File.Source>\n )}\n <File.Source\n name={typeName}\n pointer={node.pointer}\n isIndexable={!namesMerge}\n isExportable={!namesMerge && enumOptions.type !== 'inlineLiteral'}\n isTypeOnly={['asConst', 'literal', undefined].includes(enumOptions.type)}\n >\n {typeNode}\n </File.Source>\n </>\n )\n}\n","import { jsDocEscape } from '@internals/utils'\nimport { ast, text } from '@kubb/kit'\nimport { getEnumNames } from './components/Enum.tsx'\nimport type { PluginTs, ResolverTs } from './types.ts'\n\n/**\n * Renames inline enum declarations and their uses together.\n */\nexport function resolveInlineEnumNames({\n node,\n owner,\n resolver,\n enumOptions,\n}: {\n node: ast.SchemaNode\n owner: string\n resolver: ResolverTs\n enumOptions: PluginTs['resolvedOptions']['enum']\n}): ast.SchemaNode {\n return ast.node.transform(node, {\n schema(child) {\n if (child === node || child.type !== 'enum' || !child.name) return\n const name = resolver.resolveName({\n key: ['enum', owner, child.pointer ?? child.name],\n name: child.name,\n normalize: (value) => {\n // An `asConst` enum emits a value and a type alias, and the name has to be free as both.\n const { enumName, typeName } = getEnumNames({ node: { ...child, name: value }, enum: enumOptions, resolver })\n return enumOptions.type === 'literal' ? [typeName] : [enumName, typeName]\n },\n })\n return name === child.name ? undefined : { ...child, name }\n },\n })\n}\n\n/**\n * Resolves the type name an enum schema is referenced by. An enum emitted as a `const` object\n * with a `typeSuffix` uses its suffixed key alias (e.g. `StatusKey`); every other schema uses its\n * plain resolved name.\n */\ntype EnumTypeNameProps = {\n resolver: ResolverTs\n name: string\n enumOptions: { type?: string; typeSuffix?: string } | undefined\n isEnum: boolean\n}\n\nexport function enumTypeName({ resolver, name, enumOptions, isEnum }: EnumTypeNameProps): string {\n return isEnum && enumOptions?.type === 'asConst' && enumOptions.typeSuffix ? resolver.enum.keyName({ name }, enumOptions.typeSuffix) : resolver.name(name)\n}\n\n/**\n * Tells whether a `const` (single-value enum) should render as a bare literal type (`'active'`)\n * rather than a named enum reference or a runtime enum declaration.\n *\n * The parser folds `const` into a single-value enum node. The adapter decides which schemas are\n * named enums and lists them in `enumSchemaNames`, and references to those names get suffixed (for\n * example `StatusKey`). A const renders as a literal only when the adapter has not registered it as\n * a named enum, which keeps the declaration and its references in sync across adapter versions.\n */\nexport function isInlineConstEnum(node: ast.EnumSchemaNode, enumSchemaNames?: ReadonlySet<string>): boolean {\n const isConst = (node.namedEnumValues ?? node.enumValues ?? []).length === 1\n return isConst && !(node.name && enumSchemaNames?.has(node.name))\n}\n\nfunction isSchemaOptional(schema: ast.SchemaNode): boolean {\n return Boolean(('optional' in schema && schema.optional) || ('nullish' in schema && schema.nullish))\n}\n\nfunction formatExample(value: unknown): string {\n if (value === null || typeof value !== 'object') {\n return String(value)\n }\n\n const rendered = JSON.stringify(value) ?? String(value)\n return rendered.replaceAll('*/', '*\\\\/')\n}\n\n/**\n * Whether a schema is binary, or an array of binary items, so its TypeScript type is `Blob` or `Blob[]`.\n */\nexport function isBinarySchema(schema: ast.SchemaNode): boolean {\n const meta = ast.ref.mergeSchema(schema)\n const isBlob = (node: ast.SchemaNode) => ast.ref.mergeSchema(node)?.type === 'blob'\n return !!meta && (isBlob(meta) || (meta.type === 'array' && 'items' in meta && (meta.items ?? []).some(isBlob)))\n}\n\n/**\n * Collects JSDoc annotation strings for a schema node.\n *\n * Only uses official JSDoc tags from https://jsdoc.app/: `@description`, `@deprecated`, `@minimum`, `@maximum`, `@minLength`,\n * `@maxLength`, `@pattern`, `@default`, `@example`, `@see` and `@type`.\n */\nexport function buildPropertyJSDocComments(schema: ast.SchemaNode, optional?: boolean): Array<string | undefined> {\n const meta = ast.ref.mergeSchema(schema)\n\n const isArray = meta?.primitive === 'array'\n // An object's `min`/`max` count properties, which no JSDoc tag describes.\n const isObject = meta?.type === 'object'\n const isNumeric = meta?.primitive === 'number' || meta?.primitive === 'integer' || meta?.primitive === 'bigint'\n\n const hasDescription = meta && 'description' in meta && meta.description\n\n const formatComment =\n meta && 'format' in meta && meta.format\n ? hasDescription\n ? // Empty line between description and format\n [' ', `Format: \\`${meta.format}\\``]\n : ['@description', `Format: \\`${meta.format}\\``]\n : []\n\n // OAS 3.1 carries schema examples as an `examples` array, one `@example` line each.\n const exampleValues = meta?.examples ?? []\n\n const comments = [\n hasDescription ? `@description ${jsDocEscape(meta.description)}` : null,\n ...formatComment,\n meta && 'deprecated' in meta && meta.deprecated ? '@deprecated' : null,\n // minItems/maxItems on arrays should not be emitted as @minLength/@maxLength\n !isArray && !isObject && meta && 'min' in meta && meta.min !== undefined ? `@${isNumeric ? 'minimum' : 'minLength'} ${meta.min}` : null,\n !isArray && !isObject && meta && 'max' in meta && meta.max !== undefined ? `@${isNumeric ? 'maximum' : 'maxLength'} ${meta.max}` : null,\n meta && 'pattern' in meta && meta.pattern ? `@pattern ${meta.pattern}` : null,\n meta && 'default' in meta && meta.default !== undefined\n ? `@default ${'primitive' in meta && meta.primitive === 'string' && typeof meta.default === 'string' ? text.quote(meta.default) : formatExample(meta.default)}`\n : null,\n ...exampleValues.map((example) => `@example ${formatExample(example)}`),\n meta?.externalDocs ? `@see ${jsDocEscape([meta.externalDocs.url, meta.externalDocs.description].filter(Boolean).join(' '))}` : null,\n ].filter(Boolean)\n\n // `@type` merely repeats the TypeScript type already sitting next to the property, so it only\n // earns its place inside a comment block that exists for another reason. Bare, it would just\n // add bytes with no information a reader can't already see in the signature.\n const typeTag =\n // A binary schema's primitive is `string`, which would contradict its `Blob` type.\n comments.length && !isBinarySchema(schema) && meta && 'primitive' in meta && meta.primitive\n ? [`@type ${meta.primitive}`, (optional ?? isSchemaOptional(schema)) ? ' | undefined' : null].filter(Boolean).join('')\n : null\n\n return [...comments, typeTag].filter(Boolean)\n}\n\n/**\n * The example values. With `serialized`, each `serializedValue` is added as a `<caption>Serialized</caption>` example.\n */\nexport function getExampleValues(examples: Array<ast.ExampleNode> | undefined, serialized = false): Array<unknown> | undefined {\n const values = (examples ?? []).flatMap((example) => [\n ...(example.value !== undefined ? [example.value] : []),\n ...(serialized && example.serializedValue !== undefined ? [`<caption>Serialized</caption> ${jsDocEscape(example.serializedValue)}`] : []),\n ])\n return values.length > 0 ? values : undefined\n}\n\n/**\n * The JSDoc lines of a response type: `@summary`, and one `@see` per link, such as `@see getPet: getPet({ petId: $response.body#/id })`.\n */\nexport function buildResponseComments(response: ast.ResponseNode): Array<string> {\n const links = Object.entries(response.links ?? {}).map(([name, link]) => {\n const values = { ...link.parameters, ...(link.requestBody !== undefined ? { body: link.requestBody } : {}) }\n const args = Object.entries(values).map(([key, value]) => `${key}: ${formatExample(value)}`)\n return `@see ${jsDocEscape(`${name}: ${link.operationId ?? link.operationRef ?? ''}(${args.length ? `{ ${args.join(', ')} }` : ''})`)}`\n })\n return [...(response.summary ? [`@summary ${jsDocEscape(response.summary)}`] : []), ...links]\n}\n\ntype BuildParamsSchemaOptions = {\n params: Array<ast.ParameterNode>\n /**\n * Adds each serialized example to `examples` as a `<caption>Serialized</caption>` JSDoc line.\n * Leave it off when `examples` must hold values, such as for mocks.\n */\n serializedExamples?: boolean\n}\n\ntype BuildOperationSchemaOptions = {\n resolver: ResolverTs\n}\n\n/**\n * Builds the object schema for one parameter group or a response's headers. Each entry embeds its own schema and JSDoc,\n * so the group is the only type these entries are exported as.\n */\nexport function buildParams({ params, serializedExamples }: BuildParamsSchemaOptions): ast.SchemaNode {\n const pointer = params[0]?.pointer\n return ast.factory.createSchema({\n type: 'object',\n // The group points at the `parameters` list or `headers` map that declares its first parameter.\n pointer: pointer?.slice(0, pointer.lastIndexOf('/')),\n properties: params.map((param) =>\n ast.factory.createProperty({\n name: param.name,\n required: param.required,\n schema: ast.factory.createSchema({\n ...param.schema,\n optional: !param.required,\n deprecated: param.deprecated || param.schema.deprecated,\n examples: getExampleValues(param.examples, serializedExamples) ?? param.schema.examples,\n }),\n }),\n ),\n })\n}\n\nexport function buildResponseUnion(node: ast.OperationNode, { resolver }: BuildOperationSchemaOptions): ast.SchemaNode | null {\n const allWithSchema = node.responses.filter((res) => res.content?.some((entry) => entry.schema))\n // Only 2xx responses, so an `unknown` error body cannot erase the success typing. Falls back to all responses when no 2xx has a schema.\n const successWithSchema = allWithSchema.filter((res) => ast.http.status.isSuccess(res))\n const responsesWithSchema = successWithSchema.length > 0 ? successWithSchema : allWithSchema\n\n if (responsesWithSchema.length === 0) {\n return null\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: responsesWithSchema.map((res) => ast.factory.createSchema({ type: 'ref', name: resolver.response.status(node, res.statusCode) })),\n })\n}\n","import { createRequire } from 'node:module'\nimport { ast, createPrinter, Diagnostics } from '@kubb/kit'\nimport * as factory from '../factory.ts'\nimport type { PluginTs, ResolverTs } from '../types.ts'\nimport { buildPropertyJSDocComments, enumTypeName, isBinarySchema, isInlineConstEnum } from '../utils.ts'\n\nconst { isNonNullable } = factory\n\nconst requireModule = createRequire(import.meta.url)\n\n/**\n * Loads `@kubb/parser-ts` on first use. It is an optional peer dependency: only a deprecated `printer.nodes`\n * handler that returns a TypeScript compiler node needs it. Loads synchronously because node handlers are synchronous.\n */\nexport function loadParserTs(load = () => requireModule('@kubb/parser-ts') as typeof import('@kubb/parser-ts')): typeof import('@kubb/parser-ts') {\n try {\n return load()\n } catch (error) {\n // Node says \"Cannot find module '@kubb/parser-ts'\" and Yarn PnP \"... tried to access @kubb/parser-ts ...\"; later lines hold the require stack\n if ((error as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND' || !(error as Error).message.split('\\n')[0]!.includes('@kubb/parser-ts')) throw error\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: 'Missing dependency: @kubb/parser-ts. A `printer.nodes` handler returned a TypeScript compiler node, and printing it needs @kubb/parser-ts.',\n help: 'Run `npm i -D @kubb/parser-ts` in the project, or return a string from the handler.',\n plugin: 'plugin-ts',\n })\n }\n}\n\n/**\n * Partial map of node-type overrides for the TypeScript printer.\n *\n * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`). The function\n * replaces the built-in handler for that node type and returns the TypeScript type as a string.\n * Use `this.transform` to recurse into nested schema nodes, and `this.options` to read printer options.\n *\n * @example Override the `date` handler\n * ```ts\n * pluginTs({\n * printer: {\n * nodes: {\n * date(node) {\n * return 'Date'\n * },\n * },\n * },\n * })\n * ```\n */\nexport type PrinterTsNodes = ast.PrinterPartial<string | DeprecatedTsNode, PrinterTsOptions>\n\n/** @deprecated A TypeScript compiler node returned by an override. Return a string; removed in the next major. */\ntype DeprecatedTsNode = { readonly kind: number }\n\nexport type PrinterTsOptions = {\n /**\n * Mark parameters as optional with `?` or `| undefined`.\n * - `'questionToken'` adds `?` to properties\n * - `'undefined'` adds `| undefined` to types\n *\n * @default `'questionToken'`\n */\n optionalType: PluginTs['resolvedOptions']['optionalType']\n /**\n * Array representation style.\n * - `'array'` uses bracket notation (`T[]`)\n * - `'generic'` uses generic syntax (`Array<T>`)\n *\n * @default `'array'`\n */\n arrayType: PluginTs['resolvedOptions']['arrayType']\n /**\n * Grouped enum settings. The printer emits references to enums, not the enum declarations, so only\n * `type` (the output format) and `typeSuffix` (the enum key reference suffix) matter here.\n * `constCasing` and `keyCasing` are ignored.\n */\n enum: PluginTs['resolvedOptions']['enum']\n /**\n * Syntax for generated declarations.\n * - `'type'` generates type aliases\n * - `'interface'` generates interface declarations\n *\n * @default `'type'`\n */\n syntaxType?: PluginTs['resolvedOptions']['syntaxType']\n /**\n * Exported name for the type declaration.\n * When omitted, returns only the raw type node.\n */\n name?: string\n\n /**\n * JSDoc comment to attach to the generated type.\n */\n description?: string\n /**\n * `@example` values for the generated type, such as a media type's `examples`. Replaces the schema's own.\n */\n examples?: Array<unknown>\n /**\n * JSDoc lines put before the schema's own, such as a response's `@summary`.\n */\n comments?: Array<string>\n /**\n * Properties to exclude using `Omit<Type, Keys>`.\n * Forces type alias syntax regardless of `syntaxType` setting.\n */\n keysToOmit?: Array<string> | null\n /**\n * Transforms raw schema names into valid TypeScript identifiers.\n */\n resolver: ResolverTs\n /**\n * Schema names that represent enums for suffixed key references.\n */\n enumSchemaNames?: ReadonlySet<string>\n /**\n * Custom handler map for node type overrides.\n */\n nodes?: PrinterTsNodes\n}\n\n/**\n * TypeScript printer factory options: maps `SchemaNode` → a TS-ESTree node, printed to a type string or a full declaration string.\n */\nexport type PrinterTsFactory = ast.PrinterFactoryOptions<'typescript', PrinterTsOptions, factory.TsNode, string>\n\ntype PrinterTs = PrinterTsFactory\n\ntype HandlerContext = { transform: (node: ast.SchemaNode) => factory.TsNode | null }\n\n// Adds the `| null` of an OpenAPI 3.0 `nullable: true` set on an array item or union member itself.\nfunction printNullable(node: ast.SchemaNode, print: (node: ast.SchemaNode) => factory.TsNode | null | undefined): factory.TsNode | null | undefined {\n const type = print(node)\n return type && node.nullable ? factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] }) : type\n}\n\n/**\n * Adapts user overrides, which work in strings, to the node-based printer: `this.transform` hands them printed\n * strings and their result is wrapped back into a node. A deprecated compiler node prints through `@kubb/parser-ts`.\n */\nfunction toNodeHandlers(nodes: PrinterTsNodes | undefined): ast.PrinterPartial<factory.TsNode, PrinterTsOptions> {\n return Object.fromEntries(\n Object.entries(nodes ?? {}).map(([type, handler]) => [\n type,\n function (this: HandlerContext, node: ast.SchemaNode) {\n const transform = (child: ast.SchemaNode) => {\n const output = this.transform(child)\n return output ? factory.print(output) : null\n }\n const result = (handler as (this: unknown, node: ast.SchemaNode) => string | DeprecatedTsNode | null | undefined).call({ ...this, transform }, node)\n if (result === null || result === undefined) return result\n return factory.createRaw(\n typeof result === 'string'\n ? result\n : loadParserTs()\n .parserTs()\n .print(result as never)\n .trimEnd(),\n )\n },\n ]),\n )\n}\n\n/**\n * TypeScript type printer built with `definePrinter`.\n *\n * Converts a `SchemaNode` AST node into TypeScript source:\n * - **`printer.print(node)`** — when `options.name` is set, returns a full\n * `type Name = …` or `interface Name { … }` declaration.\n * Without `name`, returns the type for the schema, such as `string | null`.\n *\n * Dispatches on `node.type` to the appropriate handler in `nodes`. Options are closed\n * over per printer instance, so each call to `printerTs(options)` produces an independent printer.\n *\n * @example Raw type node (no `typeName`)\n * ```ts\n * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enum: { type: 'inlineLiteral' } })\n * const type = printer.print(schemaNode) // 'string | null'\n * ```\n *\n * @example Full declaration (with `typeName`)\n * ```ts\n * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enum: { type: 'inlineLiteral' }, typeName: 'MyType' })\n * const declaration = printer.print(schemaNode) // 'export type MyType = …'\n * ```\n */\nexport const printerTs = createPrinter<PrinterTs>((options) => {\n const addsUndefined = options.optionalType === 'undefined' || options.optionalType === 'questionTokenAndUndefined'\n\n return {\n name: 'typescript',\n options,\n nodes: {\n any: () => factory.keywordTypeNodes.any,\n unknown: () => factory.keywordTypeNodes.unknown,\n void: () => factory.keywordTypeNodes.void,\n never: () => factory.keywordTypeNodes.never,\n boolean: () => factory.keywordTypeNodes.boolean,\n null: () => factory.keywordTypeNodes.null,\n blob: () => factory.createTypeReferenceNode('Blob'),\n string: () => factory.keywordTypeNodes.string,\n uuid: () => factory.keywordTypeNodes.string,\n email: () => factory.keywordTypeNodes.string,\n url: (node) => {\n if (node.path) {\n return factory.createUrlTemplateType(node.path)\n }\n return factory.keywordTypeNodes.string\n },\n ipv4: () => factory.keywordTypeNodes.string,\n ipv6: () => factory.keywordTypeNodes.string,\n datetime: () => factory.keywordTypeNodes.string,\n number: () => factory.keywordTypeNodes.number,\n integer: () => factory.keywordTypeNodes.number,\n bigint: () => factory.keywordTypeNodes.bigint,\n date: factory.dateOrStringNode,\n time: factory.dateOrStringNode,\n ref(node) {\n if (!node.name) {\n return null\n }\n // `node.name` may have been overridden (e.g. by the single-member allOf flatten using the\n // property-derived child name), so resolve the target through `ast.ref.getName` instead.\n const refName = ast.ref.getName(node)\n if (!refName) {\n return null\n }\n\n // When a Key suffix is configured, enum refs must use the suffixed name (e.g. `StatusKey`)\n // so the reference matches what the enum file actually exports.\n const name = node.ref\n ? enumTypeName({\n resolver: this.options.resolver,\n name: refName,\n enumOptions: this.options.enum,\n isEnum: !!this.options.enumSchemaNames?.has(refName),\n })\n : refName\n\n return factory.createTypeReferenceNode(name)\n },\n enum(node) {\n const values = ast.schema.getLiterals(node)\n\n if (values.some((value) => value !== null && typeof value === 'object')) {\n return factory.createUnionDeclaration({ nodes: values.map((value) => factory.constToTypeNode(value)) })\n }\n\n // A `const` (single-value enum) the adapter did not register as a named enum emits the bare\n // literal regardless of `enum.type`, matching how its references resolve.\n if (this.options.enum.type === 'inlineLiteral' || !node.name || isInlineConstEnum(node, this.options.enumSchemaNames)) {\n const literalNodes = values\n .filter((v): v is string | number | boolean => v !== null && v !== undefined)\n .map((value) => factory.constToTypeNode(value, typeof value as 'string' | 'number' | 'boolean'))\n .filter(isNonNullable)\n\n return factory.createUnionDeclaration({ nodes: literalNodes })\n }\n\n const resolvedName = enumTypeName({ resolver: this.options.resolver, name: node.name, enumOptions: this.options.enum, isEnum: true })\n\n return factory.createTypeReferenceNode(resolvedName)\n },\n union(node) {\n const members = node.members ?? []\n\n const hasStringLiteral = members.some((m) => {\n const enumNode = ast.schema.narrow(m, ast.schema.types.enum)\n return enumNode?.primitive === 'string'\n })\n const hasPlainString = members.some((m) => ast.schema.isString(m))\n\n if (hasStringLiteral && hasPlainString) {\n const memberNodes = members\n .map((m) => {\n const print = (node: ast.SchemaNode) =>\n ast.schema.isString(node)\n ? factory.createIntersectionDeclaration({ nodes: [factory.keywordTypeNodes.string, factory.createTypeLiteralNode([])] })\n : this.transform(node)\n\n return printNullable(m, print)\n })\n .filter(isNonNullable)\n\n return factory.createUnionDeclaration({ nodes: memberNodes })\n }\n\n return factory.createUnionDeclaration({ nodes: factory.buildMemberNodes(members, (member) => printNullable(member, this.transform)) })\n },\n intersection(node) {\n return factory.createIntersectionDeclaration({ nodes: factory.buildMemberNodes(node.members, this.transform) })\n },\n array(node) {\n const itemNodes = (node.items ?? []).map((item) => printNullable(item, this.transform)).filter(isNonNullable)\n\n return factory.createArrayDeclaration({ nodes: itemNodes, arrayType: this.options.arrayType })\n },\n tuple(node) {\n return factory.buildTupleNode(node, (item) => printNullable(item, this.transform))\n },\n object(node) {\n const { transform, options } = this\n\n const keySchema = node.propertyNames && ast.ref.mergeSchema(node.propertyNames)\n if (\n !node.properties.length &&\n !Object.keys(node.patternProperties ?? {}).length &&\n node.propertyNames &&\n keySchema?.type === 'enum' &&\n node.additionalProperties !== false\n ) {\n const keyType = transform(node.propertyNames) ?? factory.keywordTypeNodes.string\n const valueSchema = typeof node.additionalProperties === 'object' ? node.additionalProperties : ast.factory.createSchema({ type: 'unknown' })\n const valueType = factory.buildPropertyType(valueSchema, transform(valueSchema) ?? factory.keywordTypeNodes.unknown, options.optionalType, false)\n\n return factory.createTypeReferenceNode('Partial', [factory.createTypeReferenceNode('Record', [keyType, valueType])])\n }\n\n const addsQuestionToken = options.optionalType === 'questionToken' || options.optionalType === 'questionTokenAndUndefined'\n\n const propertyNodes: Array<factory.TsNode> = node.properties.map((property) => {\n const { name } = property\n const output = transform(property.schema)\n const baseType = output ?? factory.keywordTypeNodes.unknown\n const optional = !property.required || !!property.schema.optional || !!property.schema.nullish\n const type = factory.buildPropertyType(property.schema, baseType, options.optionalType, optional)\n const propMeta = ast.ref.mergeSchema(property.schema)\n\n const propertyNode = factory.createPropertySignature({\n questionToken: optional ? addsQuestionToken : false,\n name,\n type,\n readOnly: propMeta?.readOnly,\n })\n\n // A binary property is a file part of a form upload, where only a `File` carries a filename.\n const binaryRemark = isBinarySchema(property.schema)\n ? '@remarks Pass a `File` to send its filename. A plain `Blob` is sent with the filename `blob`.'\n : undefined\n const comments = [...buildPropertyJSDocComments(property.schema, optional), binaryRemark]\n\n return factory.appendJSDocToNode({ node: propertyNode, comments })\n })\n\n const allElements = [...propertyNodes, ...factory.buildIndexSignatures(node, propertyNodes.length, transform)]\n\n if (!allElements.length) {\n return factory.keywordTypeNodes.object\n }\n\n return factory.createTypeLiteralNode(allElements)\n },\n ...toNodeHandlers(options.nodes),\n },\n print(node) {\n const { name, syntaxType = 'type', description, examples, comments = [], keysToOmit } = this.options\n\n const transformed = this.transform(node)\n if (!transformed) return null\n\n // For ref nodes, structural metadata lives on node.schema rather than the ref node itself.\n const meta = ast.ref.mergeSchema(node)\n\n // Without name, apply modifiers inline and return.\n if (!name) {\n const omitted = keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type: transformed, nonNullable: true }) : transformed\n return factory.print(factory.wrapNullableOptional(omitted, !!meta.nullable, !!(meta.nullish || meta.optional) && addsUndefined))\n }\n\n // When keysToOmit is present, wrap with Omit first, then apply nullable/optional\n // modifiers so they are not swallowed by NonNullable inside createOmitDeclaration.\n const inner = (() => {\n const omitted = keysToOmit?.length ? factory.createOmitDeclaration({ keys: keysToOmit, type: transformed, nonNullable: true }) : transformed\n // For named type declarations (type aliases), optional/nullish always produces | undefined\n // regardless of optionalType — the questionToken ? modifier only applies to object properties.\n return factory.wrapNullableOptional(omitted, !!meta.nullable, !!(meta.nullish || meta.optional))\n })()\n\n const useTypeGeneration = syntaxType === 'type' || !!keysToOmit?.length\n\n return factory.createTypeDeclaration({\n name,\n isExportable: true,\n type: inner,\n syntax: useTypeGeneration ? 'type' : 'interface',\n comments: [\n ...comments,\n ...buildPropertyJSDocComments({\n ...meta,\n description,\n examples: examples?.length ? examples : meta.examples,\n }),\n ],\n })\n },\n }\n})\n","import { ast } from '@kubb/kit'\nimport { File } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx'\nimport { printerTs, type PrinterTsFactory } from '../printers/printerTs.ts'\nimport type { PluginTs, ResolverTs } from '../types.ts'\nimport { isInlineConstEnum } from '../utils.ts'\nimport { Enum, getEnumNames } from './Enum.tsx'\n\ntype Props = {\n name: string\n node: ast.SchemaNode\n /**\n * Pre-configured printer instance created by the generator.\n * Created with `printerTs({ ..., nodes: options.printer?.nodes })`.\n */\n printer: ast.Printer<PrinterTsFactory>\n enum: PluginTs['resolvedOptions']['enum']\n resolver: ResolverTs\n /**\n * Marks the source inline, so importing files absorb the type. Set by `pluginTs({ operations: 'inline' })`.\n */\n inline?: boolean\n}\n\nexport function Type({ name, node, printer, enum: enumOptions, resolver, inline }: Props): KubbReactNode {\n if (inline) {\n // An inline type has no file to declare its enums in, so they print as literal unions.\n const withoutEnums = ast.node.transform(node, { schema: (n) => (n.type === ast.schema.types.enum && n.name ? { ...n, name: undefined } : undefined) })\n // Property JSDoc would repeat in every file that absorbs the type; the schema files keep theirs.\n const expression = printerTs({ ...printer.options, name: undefined })\n .print(withoutEnums)\n ?.replace(/\\/\\*\\*[\\s\\S]*?\\*\\/\\s*/g, '')\n if (!expression) return\n\n // The file is never written; the expression as its text keeps the imports it needs in use.\n return (\n <File.Source name={name} isTypeOnly isExportable isIndexable inline={{ expression }}>\n {expression}\n </File.Source>\n )\n }\n\n const enumSchemaNodes = ast.node.collect<ast.EnumSchemaNode>(node, {\n schema(n): ast.EnumSchemaNode | undefined {\n const enumNode = ast.schema.narrow(n, ast.schema.types.enum)\n // Skip an inline `const` (single-value enum the adapter did not register): it renders as a\n // literal, so it gets no runtime enum declaration.\n if (enumNode?.name && !isInlineConstEnum(enumNode, printer.options.enumSchemaNames)) return enumNode\n },\n })\n\n const output = printer.print(node)\n const printerImports = printer.drainImports()\n\n if (!output) {\n return\n }\n\n const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((node) => {\n return {\n node,\n ...getEnumNames({ node, enum: enumOptions, resolver }),\n }\n })\n\n // Skip enum exports when using inlineLiteral\n const shouldExportEnums = enumOptions.type !== 'inlineLiteral'\n const shouldExportType = enumOptions.type === 'inlineLiteral' || enums.every((item) => item.typeName !== name)\n\n return (\n <>\n {shouldExportEnums && enums.map(({ node }) => <Enum key={node.name} node={node} enum={enumOptions} resolver={resolver} />)}\n {shouldExportType && (\n <>\n {printerImports.map((imp) => (\n <File.Import key={[name, imp.path, imp.name].join('-')} {...imp} />\n ))}\n <File.Source name={name} pointer={node.pointer} isTypeOnly isExportable isIndexable>\n {output}\n </File.Source>\n </>\n )}\n </>\n )\n}\n","import { jsDocEscape } from '@internals/utils'\nimport { ast, type Group, type Memo, type Output, type Resolver, type ResolverFileParams } from '@kubb/kit'\n\n/**\n * Builds the `ResolverFileParams` every operation generator passes to\n * `resolver.file`: a file named `name`, tagged by the operation's first\n * tag (or `'default'`), at the operation's path. Centralizes the entry object\n * that was repeated at dozens of call sites across the client and query plugins.\n *\n * @example\n * ```ts\n * resolver.file(operationFileEntry(node, node.operationId), { root, output, group })\n * ```\n */\nexport function operationFileEntry(node: ast.OperationNode, name: string, extname: ResolverFileParams['extname'] = '.ts'): ResolverFileParams {\n return {\n name,\n extname,\n tag: node.tags[0] ?? 'default',\n path: node.path,\n }\n}\n\n/**\n * Resolves the file a schema-emitting plugin (`plugin-ts`, `plugin-zod`, `plugin-faker`) writes\n * `node` to, cached in `ctx.memo` under the resolver's plugin name and the\n * operation. The plugin itself and every plugin that imports from it call this, so they all get\n * the same path.\n *\n * When that path matches the file of a component schema in `ctx.driver.inputNode`, ignoring case, the file name\n * gets an `Operation` suffix: operation `point` goes to `PointOperation.ts` next to schema `Point.ts`.\n * Otherwise the two merge into one file, or overwrite each other on a case-insensitive file system.\n * Only the file name changes. The declarations keep their names.\n *\n * @example Resolve `plugin-ts`'s file for the current operation\n * ```ts\n * const fileTs = resolveOperationFile({ ctx, node, resolver: tsResolver, root, output })\n * ```\n */\nexport function resolveOperationFile(options: {\n ctx: { memo: Memo; driver: { inputNode?: { schemas: ReadonlyArray<ast.SchemaNode> } | null } }\n node: ast.OperationNode\n resolver: Pick<Resolver, 'file' | 'pluginName'>\n root: string\n output: Output\n group?: Group | null\n}): ast.FileNode {\n const { ctx, node, resolver, root, output } = options\n const { memo } = ctx\n const location = { root, output, group: options.group ?? undefined }\n\n return memo(`${resolver.pluginName}:operationFile:${node.operationId}`, () => {\n const schemaPaths = memo(\n `${resolver.pluginName}:schemaFilePaths`,\n () =>\n new Set(\n (ctx.driver.inputNode?.schemas ?? []).flatMap((schema) =>\n schema.name ? [resolver.file({ name: schema.name, extname: '.ts', ...location }).path.toLowerCase()] : [],\n ),\n ),\n )\n let file = resolver.file({ ...operationFileEntry(node, node.operationId), ...location })\n\n for (let name = `${node.operationId}Operation`; schemaPaths.has(file.path.toLowerCase()); name += 'Operation') {\n const next = resolver.file({ ...operationFileEntry(node, name), ...location })\n // A single-file output holds every declaration on purpose, so a new name changes nothing.\n if (next.path === file.path) break\n file = next\n }\n\n return file\n })\n}\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n cookies(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type BuildOperationCommentsOptions = {\n splitLines?: boolean\n}\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\n/**\n * The operation's method and path as plain text, such as `` `GET /pet/{petId}` ``. A path is not a valid `{@link}` target.\n */\nfunction getOperationRequestLine(node: ast.OperationNode): string | null {\n return ast.http.isOperation(node) && node.path ? `\\`${node.method.toUpperCase()} ${node.path}\\`` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(node.requestBody?.content?.map((e) => e.contentType) ?? [])\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(ast.http.responses.findPrimary(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\ntype ResponseType = 'blob' | 'text' | 'stream'\n\ntype ResponseContentEntry = { contentType: string; schema?: ast.SchemaNode | null; stream?: ast.ContentNode['stream'] }\n\n/**\n * How an operation streams its primary success response item by item, when that response declares one content type:\n * - `'event'` for `text/event-stream` whose `itemSchema` types the whole event with its own `event` and `data`\n * - `'data'` for `text/event-stream` typed by its payload only\n * - `'line'` for JSON Lines, one parsed JSON value per line\n *\n * Returns `null` for any other response, and for a response that also declares another content type, which stays a normal\n * call with its query hooks.\n */\nexport function getEventStream(node: ast.OperationNode): 'event' | 'data' | 'line' | null {\n const content = ast.http.responses.findPrimary(node)?.content ?? []\n if (content.length !== 1) return null\n const entry = content[0]!\n const framing = getStreamFraming(entry)\n if (framing === 'events') return entry.stream?.shape ?? 'data'\n return framing === 'lines' ? 'line' : null\n}\n\n/**\n * How a content entry is framed as a stream: `'events'` for Server-Sent Events, `'lines'` for JSON Lines.\n */\nexport function getStreamFraming(entry: Pick<ast.ContentNode, 'contentType' | 'stream'>): 'events' | 'lines' | undefined {\n if (ast.mediaType.getBase(entry) === 'text/event-stream') return 'events'\n // `multipart/mixed` with an `itemSchema` also has `stream`, but it is a stream of parts, not of JSON values.\n return entry.stream && ast.mediaType.isStream(entry) ? 'lines' : undefined\n}\n\n/**\n * Whether an operation streams its primary success response, as Server-Sent Events or JSON Lines. The client generator uses\n * this to return a typed stream of items instead of a one-shot `RequestResult`.\n */\nexport function isEventStream(node: ast.OperationNode): boolean {\n return getEventStream(node) !== null\n}\n\n// A stream without a schema is a `blob` with a string primitive, so it keeps the JSON-parse default.\nfunction isTextSchema(schema: ast.SchemaNode | null | undefined): boolean {\n if (!schema) return false\n const resolved = ast.ref.getSchema(schema)\n return resolved.type !== 'blob' && resolved.primitive === 'string'\n}\n\n/**\n * Whether an operation streams Server-Sent Events whose `data` the document types as a string, so the client keeps each\n * `data` as text instead of JSON-parsing it. With an event-shaped `itemSchema` where only some events type `data` as a\n * string, it returns the names of those events, or `false` when one of them has no fixed name.\n */\nexport function hasTextEventData(node: ast.OperationNode): boolean | Array<string> {\n const shape = getEventStream(node)\n const entry = ast.http.responses.findPrimary(node)?.content?.[0]\n if (!entry || (shape !== 'data' && shape !== 'event')) return false\n if (shape === 'data') return isTextSchema(entry.stream?.schema ?? entry.schema)\n\n const item = entry.stream?.schema ? ast.ref.getSchema(entry.stream.schema) : undefined\n if (!item) return false\n const events = item.type === 'union' ? (ast.schema.narrow(item, 'union')?.members ?? []) : [item]\n // A discriminator makes each event an intersection of its `$ref` and the pinned `event`, so every part is read.\n const propertySchemas = (event: ast.SchemaNode, propertyName: string) => ast.schema.findProperties({ node: event, propertyName }).map(({ schema }) => schema)\n const textEvents = events.filter((event) => {\n const dataSchemas = propertySchemas(event, 'data')\n return dataSchemas.length > 0 && dataSchemas.every(isTextSchema)\n })\n if (textEvents.length === events.length) return events.length > 0\n\n const eventNames = textEvents.map((event) => propertySchemas(event, 'event').flatMap((schema) => ast.schema.getLiterals(ast.ref.getSchema(schema))))\n return eventNames.length > 0 && eventNames.every((values) => values.length > 0) && [...new Set(eventNames.flat().map(String))]\n}\n\n/**\n * Whether the primary success response offers `text/event-stream`, alone or next to other content types. The client asks\n * for the stream by default and ships the `sse.ts` runtime, so a mixed response can be read as events too.\n */\nexport function hasEventStreamContent(node: ast.OperationNode): boolean {\n const entries = ast.http.responses.findPrimary(node)?.content ?? []\n // Next to another type, a stream without a schema gets no typed variant, so it keeps the plain call.\n return entries.some((entry) => getStreamFraming(entry) === 'events' && (entries.length === 1 || Boolean(entry.schema)))\n}\n\n/**\n * Whether a success response offers a stream media type next to other content types. The client returns that variant's\n * body as a `ReadableStream`, so the stream runtime is registered and a hook's data type includes the stream.\n */\nexport function hasStreamVariant(node: ast.OperationNode): boolean {\n return ast.http.responses.filterSuccess(node).some((response) => {\n const variants = (response.content ?? []).filter((entry) => entry.schema)\n return variants.length > 1 && variants.some((entry) => ast.mediaType.isStream(entry))\n })\n}\n\nconst formContentTypes = ['multipart/form-data', 'application/x-www-form-urlencoded'] as const\n\n/**\n * The form media types the operation's request body offers, `multipart/form-data` and `application/x-www-form-urlencoded`,\n * which the client needs a handler for.\n */\nexport function getFormContentTypes(node: ast.OperationNode): Array<(typeof formContentTypes)[number]> {\n const request = new Set((node.requestBody?.content ?? []).map((entry) => ast.mediaType.getBase(entry)))\n return formContentTypes.filter((contentType) => request.has(contentType))\n}\n\n/**\n * Parser for one response content entry.\n *\n * JSON stays unset so the runtime detects it. `text/event-stream` and JSON Lines are streams. A binary schema\n * (`format: binary` / `contentMediaType`) is a blob even when the media type is not a well-known\n * binary type. Other `text/*` is text, and `application/octet-stream`, `application/pdf`,\n * `image/*`, `audio/*`, and `video/*` are blobs.\n */\nfunction responseTypeForContent(entry: ResponseContentEntry): ResponseType | undefined {\n const baseType = ast.mediaType.getBase(entry)\n if (!baseType) return undefined\n if (getStreamFraming(entry)) return 'stream'\n if (ast.mediaType.isJson(baseType)) return undefined\n if (entry.schema?.type === 'blob') return 'blob'\n if (baseType.startsWith('text/')) return 'text'\n if (isBinaryContentType(baseType)) return 'blob'\n return undefined\n}\n\nfunction isBinaryContentType(baseType: string): boolean {\n return baseType === 'application/octet-stream' || baseType === 'application/pdf' || /^(image|audio|video)\\//.test(baseType)\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n // Keeps the original case, unlike ast.mediaType.getBase, so generated names stay stable.\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Returns the entry with the schema of the value the client returns: `string` for a body read as text, such as `Pet` on\n * `application/xml`, and `blob` for `image/*`, `audio/*`, `video/*`, PDF, and octet-stream. A binary schema elsewhere is a `Blob`\n * only through `parseAs: 'blob'`, which needs every entry in `entries` binary. JSON, vendor (`application/vnd.*`), stream,\n * schemaless, and wildcard entries keep their schema. `entries` is the response's full list of content types.\n */\nexport function toResponseContent<T extends ContentVariantInput & ResponseContentEntry>(entry: T, entries: ReadonlyArray<ResponseContentEntry> = [entry]): T {\n const { contentType, schema } = entry\n if (!schema || entry.stream) return entry\n\n const baseType = ast.mediaType.getBase(contentType)\n const resolved = ast.ref.getSchema(schema)\n if (isBinaryContentType(baseType)) {\n return resolved.type === 'blob' ? entry : { ...entry, schema: ast.factory.createSchema({ type: 'blob' }), keysToOmit: null }\n }\n const isPlainMediaType = Boolean(baseType) && !ast.mediaType.isJson(baseType) && !baseType.includes('*')\n if (resolved.type === 'blob') {\n // shortcut: an error response never gets `parseAs`, so a lone binary schema there reads as text too but stays `Blob`.\n const readsAsText = isPlainMediaType && !entries.every((item) => item.schema?.type === 'blob')\n return readsAsText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n }\n if (resolved.primitive === 'string') return entry\n\n const responseType = responseTypeForContent(entry)\n // A response without a body, such as a 405, has no schema to read. Only `text/*` is always text.\n if (responseType !== 'text' && (resolved.type === 'unknown' || resolved.type === 'any' || resolved.type === 'void')) return entry\n const isVendorJson = /^[^/]+\\/vnd\\./.test(baseType) && !/(xml|yaml|yml|csv)$/.test(baseType)\n const isText = responseType === 'text' || (!responseType && isPlainMediaType && !isVendorJson)\n\n return isText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n}\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...): `RequestConfig` minus what the\n * hook fills in, which is every request group and `throwOnError`. Unlike {@link buildRequestConfigType},\n * it never narrows `contentType`: query hooks wrap GET operations, which carry no request body to select\n * a content type for.\n */\nexport function buildClientOptionType(options: { omit?: Array<string> } = {}): string {\n const keys = [...requestGroupOrder, 'url', ...(options.omit ?? []), 'throwOnError']\n return `Partial<Omit<RequestConfig, ${keys.map((key) => `'${key}'`).join(' | ')}>>`\n}\n\n/**\n * The `client?:` option type of a mutation hook. When the operation has a request content type choice,\n * the mutation variables carry `contentType`, so the config leaves it out. Otherwise the ambiguous side is\n * narrowed to the operation's media types; a single-type side has nothing to pick, so it stays baked in the\n * generated call.\n */\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n if (hasRequestContentTypeChoice(node)) {\n return buildClientOptionType({ omit: ['contentType'] })\n }\n\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n const base = buildClientOptionType()\n return members.length ? `${base} & { contentType?: { ${members.join('; ')} } }` : base\n}\n\n/** The grouped request options, in the order generated signatures and calls list them. */\nexport const requestGroupOrder = ['path', 'query', 'body', 'headers', 'cookies'] as const\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n cookies: boolean\n}\n\n/**\n * Which of the grouped request options an operation carries.\n */\nexport function getRequestGroups(node: ast.OperationNode): RequestGroups {\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n return {\n path: path.length > 0,\n query: query.length > 0,\n body: Boolean(ast.http.requestBody.getSchema(node)),\n headers: header.length > 0,\n cookies: cookie.length > 0,\n }\n}\n\nexport type RequestGroupOptionality = {\n groups: RequestGroups\n hasRequiredPath: boolean\n hasRequiredQuery: boolean\n hasRequiredHeader: boolean\n /**\n * Whether the grouped request parameter can default to `{}`. True only when no group carries a\n * required member, so every member is safe to omit.\n */\n isOptional: boolean\n}\n\n/**\n * Resolves which grouped request options an operation carries together with whether each group\n * holds a required member. The grouped parameter stays optional only when nothing inside it is\n * required, matching the generated `RequestConfig` type.\n */\nexport function getRequestGroupOptionality(node: ast.OperationNode): RequestGroupOptionality {\n const groups = getRequestGroups(node)\n const { path, query, header } = ast.http.groupParameters(node)\n const hasRequiredPath = path.some((param) => param.required)\n const hasRequiredQuery = query.some((param) => param.required)\n const hasRequiredHeader = header.some((param) => param.required)\n\n return {\n groups,\n hasRequiredPath,\n hasRequiredQuery,\n hasRequiredHeader,\n // `cookies` never makes the parameter required: a browser sends its cookies itself and cannot set a `Cookie` header.\n isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !(groups.body && node.requestBody?.required === true),\n }\n}\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers, cookies }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: RequestGroups; names: Array<keyof RequestGroups> } {\n const { isConfigurable = true } = options\n const { groups, isOptional } = getRequestGroupOptionality(node)\n\n const names = requestGroupOrder.filter((key) => groups[key])\n\n // These callers never carry the `contentType` that several media types require.\n const optionsType = hasRequestContentTypeChoice(node)\n ? `Pick<${resolver.response.options(node)}, ${names.map((name) => `'${name}'`).join(' | ')}>`\n : resolver.response.options(node)\n const firstParam = names.length > 0 ? `{ ${names.join(', ')} }: ${optionsType}${isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n names,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { splitLines = false } = options\n // The request line leads: free text after a block tag would belong to that tag.\n const comments = [\n getOperationRequestLine(node),\n node.description && `@description ${node.description}`,\n node.summary && `@summary ${node.summary}`,\n node.deprecated && '@deprecated',\n node.externalDocs && `@see ${jsDocEscape([node.externalDocs.url, node.externalDocs.description].filter(Boolean).join(' '))}`,\n ]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\n/**\n * Whether the operation declares more than one request media type with a schema, so a caller must pick one on `contentType`.\n */\nexport function hasRequestContentTypeChoice(node: ast.OperationNode): boolean {\n return (node.requestBody?.content ?? []).filter((entry) => entry.schema).length > 1\n}\n\n/**\n * Casts a call argument to the client's parameter type; a `'plain'` client is non-generic.\n */\nexport function castToClientOptions(callArg: string, clientName: string, returnType: 'full' | 'data' | 'plain' = 'full'): string {\n return `${callArg} as Parameters<typeof ${clientName}${returnType === 'plain' ? '' : '<true>'}>[0]`\n}\n\n/**\n * Builds the combined `{ body, path, query, headers, cookies }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. `cookies` appears only on an operation\n * with a cookie parameter, and stays optional because a browser sends its cookies itself. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same shape from the same inputs.\n * `primitive: 'object'` is a no-op for the TS printer and tells the Zod printer to emit `z.object(…)` rather\n * than a record.\n */\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver, { pairContentTypes = false } = {}): ast.SchemaNode {\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n const hasBody = Boolean(ast.http.requestBody.getSchema(node))\n const createNever = () => ast.factory.createSchema({ type: 'never', primitive: undefined, optional: true })\n const groups = [\n { name: 'path', params: path, resolve: resolver.param.path },\n { name: 'query', params: query, resolve: resolver.param.query },\n { name: 'headers', params: header, resolve: resolver.param.headers },\n { name: 'cookies', params: cookie, resolve: resolver.param.cookies },\n ] as const\n\n const createOptions = (body: ast.SchemaNode, extra: Array<ast.PropertyNode> = []) =>\n // NOTE(v5-stable): the fields were renamed from the legacy beta shape\n // (`data`/`pathParams`/`queryParams`/`headerParams`) to `body`/`path`/`query`/`headers` so the\n // type matches the runtime client. Drop this note once v5 leaves beta.\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({ name: 'body', required: hasBody && node.requestBody?.required === true, schema: body }),\n ...groups\n .filter(({ name, params }) => name !== 'cookies' || params.length > 0)\n .map(({ name, params, resolve }) => {\n const required = name !== 'cookies' && params.some((param) => param.required)\n\n return ast.factory.createProperty({\n name,\n required,\n schema:\n params.length > 0\n ? ast.factory.createSchema({ type: 'ref', name: resolve.call(resolver.param, node, params[0]!), optional: !required })\n : createNever(),\n })\n }),\n ...extra,\n ],\n })\n\n const variants =\n pairContentTypes && hasRequestContentTypeChoice(node) ? resolveContentTypeVariants(node.requestBody?.content ?? [], resolver.response.body(node)) : []\n if (variants.length < 2) {\n return createOptions(hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever())\n }\n\n // The first media type is the runtime default, so only the others must pass `contentType`. A bare string sets the\n // request content type at runtime, so it is accepted next to the `{ request }` form.\n return ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant, index) => {\n const contentType = ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] })\n\n return createOptions(ast.factory.createSchema({ type: 'ref', name: variant.name }), [\n ast.factory.createProperty({\n name: 'contentType',\n required: index > 0,\n schema: ast.factory.createSchema({\n type: 'union',\n members: [\n contentType,\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [ast.factory.createProperty({ name: 'request', required: true, schema: contentType })],\n }),\n ],\n }),\n }),\n ])\n }),\n })\n}\n\n/**\n * The schema a status occupies in the `<Name>Responses` record. A status that documents several\n * content types becomes a `{ contentType; data }` union so the runtime can surface the negotiated type\n * on `result.parsed`, while the standalone `<Name>StatusNNN` alias stays the plain body union that the\n * query hooks and `result.data` use. With `streamData`, the stream variant of a 2xx status holds that schema, since the\n * client returns its body unread.\n */\nfunction buildResponseRecordEntry(\n node: ast.OperationNode,\n res: ast.ResponseNode,\n resolver: ResponseStatusNameResolver,\n streamData: ast.SchemaNode | undefined,\n): ast.SchemaNode {\n const statusName = resolver.response.status(node, res.statusCode)\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length <= 1) {\n return ast.factory.createSchema({ type: 'ref', name: statusName })\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: resolveContentTypeVariants(variants, statusName).map((variant) =>\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'contentType',\n required: true,\n // The runtime reports the bare media type, without parameters such as `charset` or `profile`.\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [ast.mediaType.getBase(variant)] }),\n }),\n ast.factory.createProperty({\n name: 'data',\n required: true,\n schema:\n streamData && ast.http.status.isSuccess(res) && ast.mediaType.isStream(variant)\n ? streamData\n : ast.factory.createSchema({ type: 'ref', name: variant.name }),\n }),\n ],\n }),\n ),\n })\n}\n\n/**\n * Builds the per-status `<Name>Responses` record for an operation, referencing the already-resolved\n * `<Name>StatusNNN` names. Shared by `@kubb/plugin-ts`'s `Responses` type and `@kubb/plugin-zod`'s\n * inferred responses schema, so both emit the same shape from the same inputs.\n *\n * Always emits the keyed record, even when an operation declares no responses. An operation with no\n * responses renders as an empty object, which keeps every consumer's import (for example the axios\n * SDK's `RequestResult<XResponses>`) resolvable instead of pointing at a missing export.\n *\n * `streamData` is the type of a stream variant's `data`, such as a `ReadableStream<Uint8Array>` reference.\n */\nexport function buildResponses(\n node: ast.OperationNode,\n resolver: ResponseStatusNameResolver,\n { streamData }: { streamData?: ast.SchemaNode } = {},\n): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: node.responses.map((res) =>\n ast.factory.createProperty({\n name: String(res.statusCode),\n required: true,\n schema: buildResponseRecordEntry(node, res, resolver, streamData),\n }),\n ),\n })\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return ast.http.responses.filterError(node).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return ast.http.responses.filterSuccess(node).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.response.status(node, response.statusCode))\n}\n\n/**\n * Lists the type names an operation's types file declares, computed once per resolver and `options` so every\n * dependent reads the same list.\n */\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver & Pick<Resolver, 'memo'>,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const key = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n return resolver.memo(`operationTypeNames:${key}`, () => {\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ...cookie.map((param) => resolver.param.cookies(node, param)),\n ]\n const bodyAndResponseNames = [ast.http.requestBody.getSchema(node) ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n return names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n })\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = Number(response.statusCode)\n if (Number.isNaN(code)) {\n continue\n }\n\n types.push([code, ast.http.status.isSuccess(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n","import { ensureValidVarName, toFilePath } from '@internals/utils'\nimport { ast, casing } from '@kubb/kit'\nimport type { GeneratorContext, Resolver, ResolverFile } from '@kubb/kit'\n\n/**\n * The shared top-level `name` of the operation plugins, computed once per operation name and build.\n */\nexport function resolveOperationName(this: Resolver, name: string): string {\n return this.memo(`operation:${name}`, () => ensureValidVarName(casing.camel(name)))\n}\n\n/**\n * Builds the allocation key for a declaration an operation owns. `scope` names which declaration\n * it is, so two of them never share an allocation even when a custom resolver gives both the same\n * name. Leave `scope` empty for the operation's own declaration.\n *\n * The key starts from the operation's input `pointer`, which macros keep, so a plugin whose macro\n * rewrites the method or path still resolves another plugin's names for the same operation.\n *\n * @example\n * ```ts\n * resolver.resolveName({ key: operationKey(node, 'response', 'status', 404), name })\n * ```\n */\nexport function operationKey(node: ast.OperationNode, ...scope: Array<string | number>): Array<string | undefined> {\n const source = node.pointer ? [node.pointer] : [node.method, node.path]\n return ['operation', ...source, ...scope.map(String)]\n}\n\n/**\n * The `param` namespace shared by the schema-producing plugins (ts, zod, faker):\n * per-parameter names plus the grouped `Path`/`Query`/`Headers`/`Cookies` names, all routed\n * through the plugin's top-level `name` casing.\n */\nexport type OperationParamResolver = {\n name(this: Resolver, node: ast.OperationNode, param: ast.ParameterNode): string\n path(this: Resolver, node: ast.OperationNode): string\n query(this: Resolver, node: ast.OperationNode): string\n headers(this: Resolver, node: ast.OperationNode): string\n cookies(this: Resolver, node: ast.OperationNode): string\n}\n\n/**\n * The `response` namespace shared by the schema-producing plugins: per-status,\n * body, and combined response names, all routed through the plugin's top-level\n * `name` casing.\n */\nexport type OperationResponseResolver = {\n status(this: Resolver, node: ast.OperationNode, statusCode: ast.StatusCode): string\n /**\n * Name of the headers a response declares, such as `ListPetsStatus200Headers`.\n */\n headers(this: Resolver, node: ast.OperationNode, statusCode: ast.StatusCode): string\n body(this: Resolver, node: ast.OperationNode): string\n responses(this: Resolver, node: ast.OperationNode): string\n response(this: Resolver, node: ast.OperationNode): string\n}\n\n/**\n * Builds the shared `param` namespace. Spread the result into `createResolver`\n * and override individual methods next to it when a plugin deviates.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ param: createOperationParamResolver(), ... })\n * ```\n */\nexport function createOperationParamResolver(): OperationParamResolver {\n return {\n name(node, param) {\n const name = this.name(`${node.operationId} ${param.in} ${param.name}`)\n return this.resolveName({ key: operationKey(node, 'param', 'name', param.in, param.name), name })\n },\n path(node) {\n const name = this.name(`${node.operationId} Path`)\n return this.resolveName({ key: operationKey(node, 'param', 'path'), name })\n },\n query(node) {\n const name = this.name(`${node.operationId} Query`)\n return this.resolveName({ key: operationKey(node, 'param', 'query'), name })\n },\n headers(node) {\n const name = this.name(`${node.operationId} Headers`)\n return this.resolveName({ key: operationKey(node, 'param', 'headers'), name })\n },\n cookies(node) {\n const name = this.name(`${node.operationId} Cookies`)\n return this.resolveName({ key: operationKey(node, 'param', 'cookies'), name })\n },\n }\n}\n\n/**\n * Builds the shared `response` namespace. Spread the result into\n * `createResolver` and add plugin-specific methods (`options`, `error`) next\n * to it.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ response: { ...createOperationResponseResolver(), options(node) {...} }, ... })\n * ```\n */\nexport function createOperationResponseResolver(): OperationResponseResolver {\n return {\n status(node, statusCode) {\n const name = this.name(`${node.operationId} Status ${statusCode}`)\n return this.resolveName({ key: operationKey(node, 'response', 'status', statusCode), name })\n },\n headers(node, statusCode) {\n const name = this.name(`${node.operationId} Status ${statusCode} Headers`)\n return this.resolveName({ key: operationKey(node, 'response', 'headers', statusCode), name })\n },\n body(node) {\n const name = this.name(`${node.operationId} Body`)\n return this.resolveName({ key: operationKey(node, 'response', 'body'), name })\n },\n responses(node) {\n const name = this.name(`${node.operationId} Responses`)\n return this.resolveName({ key: operationKey(node, 'response', 'responses'), name })\n },\n response(node) {\n const name = this.name(`${node.operationId} Response`)\n return this.resolveName({ key: operationKey(node, 'response', 'response'), name })\n },\n }\n}\n\n/**\n * Builds a resolver `file` override whose base name runs every path segment\n * through `toFilePath`, casing the final segment with `caseLast`.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ file: createCasedFile(pascalCase), ... })\n * ```\n */\nexport function createCasedFile(caseLast: (part: string) => string): ResolverFile {\n return {\n baseName({ name, extname }) {\n return this.memo(`file:${name}\\0${extname}`, (): ast.FileNode['baseName'] => `${toFilePath(name, caseLast)}${extname}`)\n },\n }\n}\n\ntype SchemaIndexContext = Pick<GeneratorContext, 'memo' | 'driver'>\n\n/**\n * Names of the schemas in a circular reference chain, computed once per build.\n */\nexport function getCircularNames(ctx: SchemaIndexContext): ReadonlySet<string> {\n return ctx.memo('circularNames:set', () => ast.graph.getCircularNames(ctx.driver.inputNode?.schemas ?? []))\n}\n\n/**\n * Names of the schemas whose type is `enum`, computed once per build.\n */\nexport function getEnumNames(ctx: SchemaIndexContext): ReadonlySet<string> {\n return ctx.memo(\n 'enumNames:set',\n () => new Set((ctx.driver.inputNode?.schemas ?? []).flatMap((schema) => (schema.type === 'enum' && schema.name ? [schema.name] : []))),\n )\n}\n\ndeclare global {\n namespace Kubb {\n interface MemoRegistry {\n operation: string\n file: ast.FileNode['baseName']\n operationTypeNames: Array<string>\n }\n }\n}\n","import { buildOptionsSchema, buildResponses, getEnumNames, resolveContentTypeVariants, resolveOperationFile, toResponseContent } from '@internals/shared'\nimport { ast, defineGenerator } from '@kubb/kit'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Type } from '../components/Type.tsx'\nimport { printerTs } from '../printers/printerTs.ts'\nimport type { PluginTs } from '../types'\nimport { buildParams, buildResponseComments, buildResponseUnion, enumTypeName, getExampleValues, isInlineConstEnum, resolveInlineEnumNames } from '../utils.ts'\n\n/**\n * Built-in generator for `@kubb/plugin-ts`. Emits one TypeScript file per\n * schema in the spec plus per-operation request, response, and parameter\n * types. Drop-replace with a custom `Generator<PluginTs>` to change how\n * TypeScript output is produced.\n */\nexport const typeGenerator = defineGenerator<PluginTs>({\n name: 'typescript',\n renderer: jsxRenderer,\n schema(node, ctx) {\n const { enum: enumOptions, syntaxType, optionalType, arrayType, output, group, printer } = ctx.options\n const { config, resolver, root } = ctx\n\n if (enumOptions.type !== 'inlineLiteral') node = resolveInlineEnumNames({ node, owner: node.name ?? '', resolver, enumOptions })\n if (!node.name) {\n return\n }\n // Enum schema names, so the ref handler and the imports\n // name callback can use the suffixed type name (e.g. `StatusKey`) for those refs.\n const enumSchemaNames = getEnumNames(ctx)\n const importName = (schemaName: string) => enumTypeName({ resolver, name: schemaName, enumOptions, isEnum: enumSchemaNames.has(schemaName) })\n\n const imports = resolver.imports({ node, root, output, group: group ?? undefined, name: importName })\n\n const enumNode = ast.schema.narrow(node, ast.schema.types.enum)\n // An inline `const` (single-value enum the adapter did not register) renders as a literal type,\n // so it keeps its plain name instead of the suffixed enum-key name.\n const isEnumSchema = !!enumNode && !isInlineConstEnum(enumNode, enumSchemaNames)\n\n const meta = {\n name: enumOptions.type === 'asConst' && isEnumSchema ? resolver.enum.keyName(node, enumOptions.typeSuffix) : resolver.name(node.name),\n file: resolver.file({ name: node.name, extname: '.ts', root, output, group: group ?? undefined }),\n } as const\n\n const schemaPrinter = printerTs({\n optionalType,\n arrayType,\n enum: enumOptions,\n name: meta.name,\n syntaxType,\n description: node.description,\n resolver,\n enumSchemaNames,\n nodes: printer?.nodes,\n })\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.default.banner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.default.footer(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n {imports.map((imp) => (\n <File.Import key={[node.name, imp.path, imp.isTypeOnly].join('-')} root={meta.file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type name={meta.name} node={node} enum={enumOptions} resolver={resolver} printer={schemaPrinter} />\n </File>\n )\n },\n operation(node, ctx) {\n const { enum: enumOptions, optionalType, arrayType, syntaxType, group, output, printer, operations } = ctx.options\n const { config, resolver, root } = ctx\n const inline = operations === 'inline'\n\n const meta = {\n file: resolveOperationFile({ ctx, node, resolver, root, output, group }),\n } as const\n\n // Enum schema names, so the ref handler and the imports\n // name callback can use the suffixed type name (e.g. `StatusKey`) for those refs.\n const enumSchemaNames = getEnumNames(ctx)\n const importName = (schemaName: string) => enumTypeName({ resolver, name: schemaName, enumOptions, isEnum: enumSchemaNames.has(schemaName) })\n const inlinePrinter = inline\n ? printerTs({ optionalType, arrayType, enum: enumOptions, syntaxType, resolver, enumSchemaNames, nodes: printer?.nodes })\n : null\n\n function renderSchemaType({\n schema,\n name,\n keysToOmit,\n examples,\n comments,\n }: {\n schema: ast.SchemaNode | null\n name: string\n keysToOmit?: Array<string> | null\n examples?: Array<ast.ExampleNode>\n comments?: Array<string>\n }) {\n if (!schema) return null\n if (!inline && enumOptions.type !== 'inlineLiteral') schema = resolveInlineEnumNames({ node: schema, owner: node.operationId, resolver, enumOptions })\n\n const imports = resolver.imports({ node: schema, root, output, group: group ?? undefined, name: importName })\n\n const schemaPrinter = printerTs({\n optionalType,\n arrayType,\n enum: enumOptions,\n name,\n syntaxType,\n description: schema.description,\n examples: getExampleValues(examples, true),\n comments,\n keysToOmit,\n resolver,\n enumSchemaNames,\n nodes: printer?.nodes,\n })\n\n return (\n <>\n {imports.map((imp) => (\n <File.Import key={[name, imp.path, imp.isTypeOnly].join('-')} root={meta.file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type name={name} node={schema} enum={enumOptions} resolver={resolver} printer={schemaPrinter} inline={inline} />\n </>\n )\n }\n\n /**\n * Emits an individual type per content type plus a plain union alias under `baseName`. Shared by\n * the request body and multi-content-type responses. The response record discriminates these\n * variants by content type in {@link buildResponses}; the standalone alias stays a plain union so\n * query hooks and `result.data` keep the bare body.\n */\n function buildContentTypeVariants(\n entries: Array<{ contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null; examples?: Array<ast.ExampleNode> }>,\n baseName: string,\n pointer: string | undefined,\n { decorate, comments }: { decorate?: (schema: ast.SchemaNode) => ast.SchemaNode; comments?: Array<string> },\n ) {\n const variants = resolveContentTypeVariants(entries, baseName)\n // Inline, content types that print the same type would repeat it in the union (`Order | Order`).\n const keys = variants.map((variant) => (inlinePrinter ? `${inlinePrinter.print(variant.schema)}:${variant.keysToOmit ?? ''}` : variant.name))\n const members = variants.filter((_, index) => keys.indexOf(keys[index]!) === index)\n const unionSchema = ast.factory.createSchema({\n type: 'union',\n pointer,\n members: members.map((variant) => ast.factory.createSchema({ type: 'ref', name: variant.name })),\n })\n return (\n <>\n {variants.map((variant) =>\n renderSchemaType({\n schema: decorate ? decorate(variant.schema) : variant.schema,\n name: variant.name,\n keysToOmit: variant.keysToOmit,\n examples: entries.find((entry) => entry.contentType === variant.contentType)?.examples,\n }),\n )}\n {renderSchemaType({ schema: unionSchema, name: baseName, comments })}\n </>\n )\n }\n\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n\n const paramGroupTypes = (\n [\n [path, resolver.param.path],\n [query, resolver.param.query],\n [header, resolver.param.headers],\n [cookie, resolver.param.cookies],\n ] as const\n ).map(\n ([params, resolveName]) =>\n params.length > 0 &&\n renderSchemaType({ schema: buildParams({ params, serializedExamples: true }), name: resolveName.call(resolver.param, node, params[0]!) }),\n )\n\n const requestBodyContent = node.requestBody?.content ?? []\n\n function buildRequestType() {\n if (requestBodyContent.length === 0) return null\n if (requestBodyContent.length === 1) {\n const entry = requestBodyContent[0]!\n if (!entry.schema) return null\n return renderSchemaType({\n schema: {\n ...entry.schema,\n pointer: node.requestBody!.pointer ?? entry.schema.pointer,\n description: node.requestBody!.description ?? entry.schema.description,\n },\n name: resolver.response.body(node),\n keysToOmit: entry.keysToOmit,\n examples: entry.examples,\n })\n }\n // Multiple content types — generate individual types + union alias\n return buildContentTypeVariants(requestBodyContent, resolver.response.body(node), node.requestBody!.pointer, {\n decorate: (schema) => ({ ...schema, description: node.requestBody!.description ?? schema.description }),\n })\n }\n\n const requestType = buildRequestType()\n\n const responseTypes = node.responses.map((res) => {\n const content = (res.content ?? []).map((entry, _, content) => toResponseContent(entry, content))\n const variants = content.filter((entry) => entry.schema)\n // Multiple content types for a single status code — generate per-variant types + a plain union.\n // The `<Name>Responses` record discriminates them by content type (see buildResponses).\n if (variants.length > 1) {\n return buildContentTypeVariants(variants, resolver.response.status(node, res.statusCode), res.pointer, { comments: buildResponseComments(res) })\n }\n const primary = variants[0] ?? content[0]\n return renderSchemaType({\n schema: primary?.schema ? { ...primary.schema, pointer: res.pointer ?? primary.schema.pointer } : ast.factory.createSchema({ type: 'unknown' }),\n name: resolver.response.status(node, res.statusCode),\n keysToOmit: primary?.keysToOmit,\n examples: primary?.examples,\n comments: buildResponseComments(res),\n })\n })\n\n const responseHeaderTypes = node.responses.map((res) =>\n res.headers?.length\n ? renderSchemaType({ schema: buildParams({ params: res.headers, serializedExamples: true }), name: resolver.response.headers(node, res.statusCode) })\n : null,\n )\n\n const optionsType = renderSchemaType({\n schema: buildOptionsSchema(node, resolver, { pairContentTypes: true }),\n name: resolver.response.options(node),\n })\n\n const responsesType = renderSchemaType({\n // A stream variant next to another content type comes back as the unread body, as the client's `SuccessVariant` types it.\n schema: buildResponses(node, resolver, { streamData: ast.factory.createSchema({ type: 'ref', name: 'ReadableStream<Uint8Array>' }) }),\n name: resolver.response.responses(node),\n })\n\n function buildResponseType() {\n const hasSchema = (res: ast.ResponseNode) => (res.content ?? []).some((entry) => entry.schema)\n const responseName = resolver.response.response(node)\n\n const responsesWithSchema = node.responses.filter(hasSchema)\n const importedNames = new Set(ast.http.responses.getImportedNames(responsesWithSchema).map(importName))\n\n if (importedNames.has(responseName)) {\n return null\n }\n\n return renderSchemaType({\n schema: {\n ...(buildResponseUnion(node, { resolver }) ?? ast.factory.createSchema({ type: 'unknown' })),\n description: 'Union of all possible responses',\n },\n name: responseName,\n })\n }\n\n const responseType = buildResponseType()\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.default.banner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.default.footer(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n {paramGroupTypes}\n {responseTypes}\n {responseHeaderTypes}\n {requestType}\n {optionsType}\n {responsesType}\n {responseType}\n </File>\n )\n },\n})\n","","","import { createCasedFile, createOperationParamResolver, createOperationResponseResolver, operationKey } from '@internals/shared'\nimport { ensureValidVarName } from '@internals/utils'\nimport { casing, createResolver } from '@kubb/kit'\nimport type { PluginTs } from '../types.ts'\n\n/**\n * Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths\n * for generated TypeScript types. Other plugins should read the build's resolver\n * through `driver.getResolver(pluginTsName)` to share its name allocations.\n *\n * The `default` helpers are supplied by `createResolver`. This plugin overrides the top-level `name`\n * to use PascalCase for value and type names and `file` to write PascalCase file paths (dotted names\n * become `/`-joined), and groups the operation-specific naming under the `param`, `response`, and\n * `enum` namespaces.\n *\n * @example Resolve a type and file name\n * ```ts\n * import { resolverTs } from '@kubb/plugin-ts'\n *\n * resolverTs.name('list pets') // 'ListPets'\n * resolverTs.response.status(node, 200) // 'ListPetsStatus200'\n * ```\n */\nexport const resolverTs = createResolver<PluginTs>({\n pluginName: 'plugin-ts',\n name(name) {\n return this.memo(`name:${name}`, () => ensureValidVarName(casing.pascal(name)))\n },\n file: createCasedFile(casing.pascal),\n param: createOperationParamResolver(),\n response: {\n ...createOperationResponseResolver(),\n options(node) {\n const name = this.name(`${node.operationId} Options`)\n return this.resolveName({ key: operationKey(node, 'response', 'options'), name })\n },\n },\n enum: {\n keyName(node, enumTypeSuffix = 'key') {\n return `${this.name(node.name ?? '')}${enumTypeSuffix}`\n },\n },\n})\n","import { addGenerator, defineExtension, Resolver, setMacros, setResolver } from '@kubb/kit'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { typeGenerator } from './generators/typeGenerator.tsx'\nimport { resolverTs } from './resolvers/resolverTs.ts'\nimport type { PluginTs } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-ts`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginTsName = 'plugin-ts' satisfies PluginTs['name']\n\n/**\n * Generates TypeScript `type` aliases and `interface` declarations from an\n * OpenAPI spec. The foundation that every other Kubb plugin builds on:\n * clients, query hooks, mocks, and validators all reference the names this\n * plugin produces.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginTs } from '@kubb/plugin-ts'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [\n * pluginTs({\n * output: { path: './types' },\n * enum: { type: 'asConst' },\n * optionalType: 'questionTokenAndUndefined',\n * }),\n * ],\n * })\n * ```\n */\nexport const pluginTs = defineExtension<PluginTs>({\n kind: 'plugin',\n meta: { name: pluginTsName, version, compatibility },\n setup(options) {\n const {\n output = { path: 'types', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n enum: enumOptions = {},\n optionalType = 'questionToken',\n arrayType = 'array',\n syntaxType = 'type',\n operations = 'export',\n printer,\n resolver: userResolver,\n macros: userMacros,\n } = options\n\n const resolvedEnum = {\n type: enumOptions.type ?? 'asConst',\n constCasing: enumOptions.constCasing ?? 'camelCase',\n typeSuffix: enumOptions.typeSuffix ?? 'Key',\n keyCasing: enumOptions.keyCasing ?? 'none',\n }\n\n setResolver(userResolver ? Resolver.merge(resolverTs, userResolver) : resolverTs)\n if (userMacros?.length) {\n setMacros(userMacros)\n }\n addGenerator(typeGenerator)\n\n return {\n output,\n exclude,\n include,\n override,\n optionalType,\n group: group ?? null,\n arrayType,\n enum: resolvedEnum,\n syntaxType,\n operations,\n printer,\n }\n },\n})\n\nexport default pluginTs\n","/**\n * A type expression used as a function parameter type annotation.\n *\n * - a plain `string` is a type reference rendered as-is, e.g. `'string'`, `'QueryParams'`, `'Partial<Config>'`\n * - a {@link TypeLiteralNode} is an inline anonymous type, e.g. `{ petId: string; name?: string }`\n * - an {@link IndexedAccessTypeNode} is a single field accessed from a named type, e.g. `PathParams['petId']`\n */\nexport type TypeExpression = string | TypeLiteralNode | IndexedAccessTypeNode\n\n/**\n * An inline anonymous object type grouping named fields.\n * Renders as `{ key: Type; other?: OtherType }`.\n */\nexport type TypeLiteralNode = {\n kind: 'TypeLiteral'\n /**\n * Members of the object type, rendered in order.\n */\n members: Array<{\n /**\n * Member key.\n */\n name: string\n /**\n * Member type expression.\n */\n type: TypeExpression\n /**\n * Whether the member is optional, rendered with `?`.\n */\n optional?: boolean\n }>\n}\n\n/**\n * A single field accessed from a named group type. Renders as `target['key']`.\n */\nexport type IndexedAccessTypeNode = {\n kind: 'IndexedAccessType'\n /**\n * Name of the type being indexed, e.g. `'GetPetPathParams'`.\n */\n target: string\n /**\n * Field key to access, e.g. `'petId'`.\n */\n key: string\n}\n\n/**\n * An object destructuring binding, used as the name of a grouped function parameter.\n * Renders as `{ id, name }` or `{ id: renamed }` when `propertyName` differs.\n */\nexport type ObjectBindingPatternNode = {\n kind: 'ObjectBindingPattern'\n /**\n * Bound elements, rendered in order.\n */\n elements: Array<{\n /**\n * Local binding name.\n */\n name: string\n /**\n * Source key when it differs from the binding name, rendered as `propertyName: name`.\n */\n propertyName?: string\n }>\n}\n\n/**\n * One function parameter.\n *\n * A simple parameter has a `string` name. A destructured group has an\n * {@link ObjectBindingPatternNode} name paired with a {@link TypeLiteralNode} type.\n *\n * @example Required parameter\n * `name: Type`\n *\n * @example Optional parameter\n * `name?: Type`\n *\n * @example Parameter with default value\n * `name: Type = defaultValue`\n *\n * @example Rest parameter\n * `...name: Type[]`\n *\n * @example Destructured group\n * `{ id, name? }: { id: string; name?: string } = {}`\n */\nexport type FunctionParameterNode = {\n kind: 'FunctionParameter'\n /**\n * Parameter name, or an {@link ObjectBindingPatternNode} for a destructured group.\n */\n name: string | ObjectBindingPatternNode\n /**\n * Type annotation as a {@link TypeExpression}. Omit for untyped output.\n */\n type?: TypeExpression\n /**\n * Whether the parameter is optional, rendered with `?`.\n */\n optional?: boolean\n /**\n * Default value, written verbatim after `=`. Commonly `'{}'` for a destructured group.\n */\n default?: string\n /**\n * When `true` the parameter is emitted as a rest parameter, e.g. `...name: Type[]`.\n */\n rest?: boolean\n}\n\n/**\n * A complete function parameter list.\n *\n * Printers are responsible for sorting (`required` → `optional` → `defaulted`).\n */\nexport type FunctionParametersNode = {\n kind: 'FunctionParameters'\n /**\n * Ordered parameter nodes.\n */\n params: ReadonlyArray<FunctionParameterNode>\n}\n\n/**\n * Narrows a {@link TypeExpression} to a {@link TypeLiteralNode}.\n */\nexport function isTypeLiteral(type: TypeExpression): type is TypeLiteralNode {\n return typeof type !== 'string' && type.kind === 'TypeLiteral'\n}\n\n/**\n * Narrows a {@link TypeExpression} to an {@link IndexedAccessTypeNode}.\n */\nexport function isIndexedAccessType(type: TypeExpression): type is IndexedAccessTypeNode {\n return typeof type !== 'string' && type.kind === 'IndexedAccessType'\n}\n\n/**\n * Creates a {@link TypeLiteralNode} representing an inline anonymous object type.\n *\n * @example\n * ```ts\n * createTypeLiteral({ members: [{ name: 'petId', type: 'string', optional: false }] })\n * // { petId: string }\n * ```\n */\nexport function createTypeLiteral(props: Omit<TypeLiteralNode, 'kind'>): TypeLiteralNode {\n return { kind: 'TypeLiteral', ...props }\n}\n\n/**\n * Creates an {@link IndexedAccessTypeNode} representing a single field accessed from a named type.\n *\n * @example\n * ```ts\n * createIndexedAccessType({ target: 'DeletePetPathParams', key: 'petId' })\n * // DeletePetPathParams['petId']\n * ```\n */\nexport function createIndexedAccessType(props: Omit<IndexedAccessTypeNode, 'kind'>): IndexedAccessTypeNode {\n return { kind: 'IndexedAccessType', ...props }\n}\n\n/**\n * Creates an {@link ObjectBindingPatternNode} for a destructured parameter binding.\n *\n * @example\n * ```ts\n * createObjectBindingPattern({ elements: [{ name: 'id' }, { name: 'name' }] })\n * // { id, name }\n * ```\n */\nexport function createObjectBindingPattern(props: Omit<ObjectBindingPatternNode, 'kind'>): ObjectBindingPatternNode {\n return { kind: 'ObjectBindingPattern', ...props }\n}\n\n/**\n * Plain property descriptor for a destructured group built by {@link createFunctionParameter}.\n */\ntype FunctionParameterProperty = {\n name: string\n type: TypeExpression\n optional?: boolean\n}\n\ntype FunctionParameterInput =\n | { name: string | ObjectBindingPatternNode; type?: TypeExpression; optional?: boolean; default?: string; rest?: boolean }\n | { properties: Array<FunctionParameterProperty>; optional?: boolean; default?: string }\n\n/**\n * Creates a {@link FunctionParameterNode}. `optional` defaults to `false`.\n * Passing `properties` builds a destructured group: an {@link ObjectBindingPatternNode} name\n * paired with a {@link TypeLiteralNode} type.\n *\n * @example Optional param\n * ```ts\n * createFunctionParameter({ name: 'params', type: 'QueryParams', optional: true })\n * // → params?: QueryParams\n * ```\n *\n * @example Destructured group\n * ```ts\n * createFunctionParameter({ properties: [{ name: 'id', type: 'string' }, { name: 'name', type: 'string', optional: true }], default: '{}' })\n * // → { id, name }: { id: string; name?: string } = {}\n * ```\n */\nexport function createFunctionParameter(input: FunctionParameterInput): FunctionParameterNode {\n if ('properties' in input) {\n return {\n kind: 'FunctionParameter',\n name: createObjectBindingPattern({ elements: input.properties.map((p) => ({ name: p.name })) }),\n type: createTypeLiteral({ members: input.properties.map((p) => ({ name: p.name, type: p.type, optional: p.optional ?? false })) }),\n optional: input.optional ?? false,\n ...(input.default !== undefined ? { default: input.default } : {}),\n }\n }\n return { kind: 'FunctionParameter', optional: false, ...input }\n}\n\n/**\n * Creates a {@link FunctionParametersNode} from an ordered list of parameters.\n *\n * @example\n * ```ts\n * const empty = createFunctionParameters()\n * // { params: [] }\n * ```\n */\nexport function createFunctionParameters(props: Partial<Omit<FunctionParametersNode, 'kind'>> = {}): FunctionParametersNode {\n return { kind: 'FunctionParameters', params: [], ...props }\n}\n","/**\n * Ordering priority for function parameters: lower = sorted earlier.\n */\nconst PARAM_RANK = { required: 0, optional: 1, withDefault: 2, rest: 3 } as const\n\nimport { isIndexedAccessType, isTypeLiteral } from './functionParams.ts'\nimport type { FunctionParameterNode, FunctionParametersNode, ObjectBindingPatternNode, TypeExpression } from './functionParams.ts'\n\n/**\n * Renders a {@link TypeExpression} to its TypeScript source.\n *\n * - a `string` is a type reference, returned as-is\n * - an `IndexedAccessType` becomes `objectType['indexType']`\n * - a `TypeLiteral` becomes `{ key: Type; key?: Type }`\n *\n * `transformType` is applied once to the fully rendered type, matching how the\n * printer wrapped reference types before the `ts.factory` model.\n */\nexport function renderType(type: TypeExpression, transformType?: (type: string) => string): string {\n const rendered = renderTypeExpression(type)\n return transformType ? transformType(rendered) : rendered\n}\n\n/**\n * Renders an object-type key, quoting it as a string literal when it is not a valid\n * identifier so `{ 'content-type': string }` stays valid TypeScript.\n */\nfunction renderKey(name: string): string {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name) ? name : JSON.stringify(name)\n}\n\nfunction renderMembers(members: Array<{ key: string; type: string; optional?: boolean }>): string {\n return `{ ${members.map((member) => `${renderKey(member.key)}${member.optional ? '?' : ''}: ${member.type}`).join('; ')} }`\n}\n\nfunction renderTypeExpression(type: TypeExpression): string {\n if (typeof type === 'string') return type\n if (isIndexedAccessType(type)) return `${type.target}['${type.key}']`\n\n return renderMembers(type.members.map((member) => ({ key: member.name, type: renderTypeExpression(member.type), optional: member.optional })))\n}\n\nexport type FunctionPrinterOptions = {\n /**\n * Rendering modes supported by `functionPrinter`.\n *\n * | Mode | Output example | Use case |\n * |---------------|-----------------------------------|--------------------------------|\n * | `declaration` | `id: string, config: Config = {}` | Function parameter declaration |\n * | `call` | `id, { method, url }` | Function call arguments |\n */\n mode: 'declaration' | 'call'\n /**\n * Optional transformation applied to every parameter name before printing.\n */\n transformName?: (name: string) => string\n /**\n * Optional transformation applied to every type string before printing.\n */\n transformType?: (type: string) => string\n}\n\nfunction groupMembers(param: FunctionParameterNode): ReadonlyArray<{ name: string; optional?: boolean }> | null {\n if (typeof param.name === 'string') return null\n return param.type && isTypeLiteral(param.type) ? param.type.members : []\n}\n\nfunction rank(param: FunctionParameterNode): number {\n if (param.rest) return PARAM_RANK.rest\n if (param.default) return PARAM_RANK.withDefault\n const members = groupMembers(param)\n if (members) return members.every((m) => m.optional) ? PARAM_RANK.optional : PARAM_RANK.required\n return param.optional ? PARAM_RANK.optional : PARAM_RANK.required\n}\n\n/**\n * Orders a destructured group's binding elements and type members together,\n * required fields first, matching how grouped children were sorted before.\n */\ntype GroupMember = { name: string; propertyName?: string; type?: TypeExpression; optional?: boolean }\n\nfunction sortedGroupMembers(name: ObjectBindingPatternNode, type: TypeExpression | undefined): Array<GroupMember> {\n const members = type && isTypeLiteral(type) ? type.members : []\n const memberRank = (optional?: boolean) => (optional ? PARAM_RANK.optional : PARAM_RANK.required)\n return name.elements\n .map((element, index) => ({\n name: element.name,\n propertyName: element.propertyName,\n type: members[index]?.type,\n optional: members[index]?.optional,\n }))\n .toSorted((a, b) => memberRank(a.optional) - memberRank(b.optional))\n}\n\n/**\n * Renders one binding element: the local name, prefixed with its source key when the\n * binding renames the property, as in `{ petId: id }`.\n */\nfunction renderBindingMember(member: GroupMember, transformName?: (name: string) => string): string {\n const local = transformName ? transformName(member.name) : member.name\n return member.propertyName ? `${member.propertyName}: ${local}` : local\n}\n\n/**\n * Renders the type annotation of a destructured group. An inline object type is\n * rendered from the already-sorted members so its key order matches the binding;\n * a reference type is rendered as-is.\n */\nfunction renderGroupType(type: TypeExpression | undefined, sorted: Array<GroupMember>, transformType?: (type: string) => string): string | undefined {\n if (!type) return undefined\n if (!isTypeLiteral(type)) return renderType(type)\n\n const typed = sorted.filter((member) => member.type !== undefined)\n if (!typed.length) return undefined\n return renderMembers(\n typed.map((member) => ({ key: member.propertyName ?? member.name, type: renderType(member.type!, transformType), optional: member.optional })),\n )\n}\n\nfunction printParameter(node: FunctionParameterNode, options: FunctionPrinterOptions): string {\n const { mode, transformName, transformType } = options\n const bindingName = node.name\n\n if (mode === 'call') {\n if (typeof bindingName !== 'string') {\n const keys = sortedGroupMembers(bindingName, node.type)\n .map((member) => renderBindingMember(member))\n .join(', ')\n return `{ ${keys} }`\n }\n const name = transformName ? transformName(bindingName) : bindingName\n return node.rest ? `...${name}` : name\n }\n\n if (typeof bindingName !== 'string') {\n const sorted = sortedGroupMembers(bindingName, node.type)\n const binding = `{ ${sorted.map((member) => renderBindingMember(member, transformName)).join(', ')} }`\n const allOptional = sorted.every((member) => member.optional)\n const type = renderGroupType(node.type, sorted, transformType)\n if (type) {\n if (allOptional) return `${binding}: ${type} = ${node.default ?? '{}'}`\n return node.default ? `${binding}: ${type} = ${node.default}` : `${binding}: ${type}`\n }\n return node.default ? `${binding} = ${node.default}` : binding\n }\n\n const name = transformName ? transformName(bindingName) : bindingName\n const type = node.type ? renderType(node.type, transformType) : undefined\n\n if (node.rest) {\n return type ? `...${name}: ${type}` : `...${name}`\n }\n if (type) {\n if (node.optional) return `${name}?: ${type}`\n return node.default ? `${name}: ${type} = ${node.default}` : `${name}: ${type}`\n }\n return node.default ? `${name} = ${node.default}` : name\n}\n\n/**\n * Default function-signature printer. Renders a parameter list in one of two modes:\n * `declaration` for the function signature and `call` for the call arguments.\n *\n * @example\n * ```ts\n * const printer = functionPrinter({ mode: 'declaration' })\n *\n * const sig = createFunctionParameters({\n * params: [\n * createFunctionParameter({ name: 'petId', type: 'string', optional: false }),\n * createFunctionParameter({ name: 'config', type: 'Config', optional: false, default: '{}' }),\n * ],\n * })\n *\n * printer.print(sig) // → \"petId: string, config: Config = {}\"\n * ```\n */\nexport function functionPrinter(options: FunctionPrinterOptions) {\n return {\n name: 'functionParameters' as const,\n options,\n print(node: FunctionParametersNode): string {\n // `toSorted` is a stable sort, so equal-rank params keep their declared order.\n return node.params\n .toSorted((a, b) => rank(a) - rank(b))\n .map((p) => printParameter(p, options))\n .filter(Boolean)\n .join(', ')\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAU;;;;;;;;;;;AAYV,SAAgB,eAAe,MAAuB;CACpD,IAAI,CAAC,QAAQ,cAAc,IAAI,IAAiB,GAC9C,OAAO;CAET,OAAO,aAAa,IAAI;AAC1B;;;;;;;;;;;;;;;;;AAkBA,SAAgB,mBAAmB,MAAsB;CACvD,IAAI,CAAC,QAAQ,eAAe,IAAI,GAC9B,OAAO;CAET,OAAO,IAAI;AACb;;;;;;;;;;;;;;AAeA,SAAgB,aAAa,MAAuB;CAClD,OAAO,6BAA6B,KAAK,IAAI;AAC/C;;;;;;;;;;;;;;;;;;;;;ACtGA,SAAgB,WAAW,MAAc,WAAqC,OAAO,OAAe;CAClG,MAAM,QAAQ,KAAK,MAAM,gBAAgB;CACzC,OAAO,MACJ,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