@kubb/plugin-ts 5.1.0-canary.20261023T200213 → 5.1.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["createRequire","isNonNullable","syncSchemaRef","factory.createEnumDeclaration","File","parserTs","ast","syncSchemaRef","ast","ast","File","factory","ast","factory.createTypeReferenceNode","factory.createUrlTemplateType","factory.dateOrStringNode","factory.constToTypeNode","factory.createUnionDeclaration","isStringType","factory.createIntersectionDeclaration","factory.createTypeLiteralNode","factory.buildMemberNodes","factory.createArrayDeclaration","factory.buildTupleNode","factory.buildPropertyType","syncSchemaRef","factory.createPropertySignature","factory.appendJSDocToNode","factory.buildIndexSignatures","factory.wrapNullableOptional","parserTs","factory.createOmitDeclaration","factory.isUnionTypeNode","factory.createTypeDeclaration","defineGenerator","jsxRenderer","ast","File","createResolver","defineExtension","Resolver"],"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/components/Type.tsx","../src/printers/printerTs.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":["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/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction convert(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n// Plugins resolve the same names over and over (about 47,000 calls for a 1,000 schema spec), so\n// results are kept. Clearing at the limit bounds the memory a long-running process spends on it.\nconst cache = new Map<string, string>()\nconst cacheLimit = 10_000\n\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const key = `${pascal ? 'P' : 'c'}${text}`\n const cached = cache.get(key)\n if (cached !== undefined) return cached\n\n const result = convert(text, pascal)\n if (cache.size >= cacheLimit) cache.clear()\n cache.set(key, result)\n return result\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Uppercases only the first character of `text`, leaving the rest untouched.\n * Unlike {@link 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 const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\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 '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/**\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 } = new RegExp(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 './casing.ts'\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 { createRequire } from 'node:module'\nimport { camelCase, pascalCase, screamingSnakeCase, snakeCase } from '@internals/utils'\nimport { syncSchemaRef } from 'kubb/kit'\nimport type { ast } from 'kubb/kit'\nimport type ts from '@typescript/typescript6'\n\n/**\n * Loaded with `require`, not `import`. When ESM imports a CommonJS package, Node keeps a second\n * copy of its source to detect named exports, and for TypeScript that copy is about 9 MB.\n */\nconst typescript: typeof ts = createRequire(import.meta.url)('@typescript/typescript6')\n\nconst { SyntaxKind, factory } = typescript\n\nfunction isNumber(value: unknown): value is number {\n return typeof value === 'number' && !Number.isNaN(value)\n}\n\n// https://ts-ast-viewer.com/\n\n/**\n * TypeScript AST modifiers for the `export` keyword.\n */\nexport const modifiers = {\n export: factory.createModifier(typescript.SyntaxKind.ExportKeyword),\n} as const\n\nexport const isUnionTypeNode = typescript.isUnionTypeNode\n\nexport function isNonNullable<T>(value: T | null | undefined): value is T {\n return value !== null && value !== undefined\n}\n\nfunction isValidIdentifier(str: string): boolean {\n if (!str.length || str.trim() !== str) {\n return false\n }\n\n // Mirrors `typescript.isIdentifierText`, which is not in the public type declarations.\n // Walking by code point with `isIdentifierStart`/`isIdentifierPart` rejects\n // invalid names such as private identifiers (`#FOO`), forcing `propertyName`\n // to quote them.\n let ch = str.codePointAt(0)!\n if (!typescript.isIdentifierStart(ch, typescript.ScriptTarget.Latest)) {\n return false\n }\n for (let i = ch > 0xffff ? 2 : 1; i < str.length; i += ch > 0xffff ? 2 : 1) {\n ch = str.codePointAt(i)!\n if (!typescript.isIdentifierPart(ch, typescript.ScriptTarget.Latest)) {\n return false\n }\n }\n return true\n}\n\nfunction propertyName(name: string | ts.PropertyName): ts.PropertyName {\n if (typeof name === 'string') {\n const isValid = isValidIdentifier(name)\n return isValid ? factory.createIdentifier(name) : factory.createStringLiteral(name)\n }\n return name\n}\n\nconst questionToken = factory.createToken(typescript.SyntaxKind.QuestionToken)\n\n/**\n * Creates a question token for optional type annotations.\n * Pass `true` to use the cached token, or provide a pre-created token.\n */\nfunction createQuestionToken(token?: boolean | ts.QuestionToken) {\n if (!token) {\n return undefined\n }\n if (token === true) {\n return questionToken\n }\n return token\n}\n\n/**\n * Creates a TypeScript intersection type node from multiple type nodes.\n * Returns the single node if only one is provided, or wraps in parentheses if requested.\n */\nexport function createIntersectionDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode | 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 = factory.createIntersectionTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return node\n}\n\n/**\n * Creates a TypeScript array type node.\n * Use `arrayType: 'array'` for bracket syntax (`T[]`), or `'generic'` for `Array<T>`.\n *\n * @example Array bracket syntax\n * `createArrayDeclaration({ nodes: [stringType], arrayType: 'array' }) // → string[]`\n *\n * @example Generic Array syntax\n * `createArrayDeclaration({ nodes: [stringType], arrayType: 'generic' }) // → Array<string>`\n */\nexport function createArrayDeclaration({ nodes, arrayType = 'array' }: { nodes: Array<ts.TypeNode>; arrayType?: 'array' | 'generic' }): ts.TypeNode {\n if (!nodes.length) {\n return factory.createTupleTypeNode([])\n }\n\n if (nodes.length === 1) {\n const node = nodes[0]!\n if (arrayType === 'generic') {\n return factory.createTypeReferenceNode(factory.createIdentifier('Array'), [node])\n }\n return factory.createArrayTypeNode(node)\n }\n\n // For union types (multiple nodes), respect arrayType preference\n const unionType = factory.createUnionTypeNode(nodes)\n if (arrayType === 'generic') {\n return factory.createTypeReferenceNode(factory.createIdentifier('Array'), [unionType])\n }\n // For array syntax with unions, we need parentheses: (string | number)[]\n return factory.createArrayTypeNode(factory.createParenthesizedType(unionType))\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<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode {\n if (!nodes.length) {\n return keywordTypeNodes.any\n }\n\n if (nodes.length === 1) {\n return nodes[0] as ts.TypeNode\n }\n\n const node = factory.createUnionTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return 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 modifiers = [],\n name,\n questionToken,\n type,\n}: {\n readOnly?: boolean\n modifiers?: Array<ts.Modifier>\n name: ts.PropertyName | string\n questionToken?: ts.QuestionToken | boolean\n type?: ts.TypeNode\n}) {\n return factory.createPropertySignature(\n [...modifiers, readOnly ? factory.createToken(typescript.SyntaxKind.ReadonlyKeyword) : undefined].filter(\n (modifier): modifier is ts.Modifier => modifier !== undefined,\n ),\n propertyName(name),\n createQuestionToken(questionToken),\n type,\n )\n}\n\n/**\n * Attaches JSDoc comments to an AST node as synthetic leading comments.\n * Filters out undefined comments before attaching.\n *\n * @see https://github.com/microsoft/TypeScript/issues/44151\n */\nexport function appendJSDocToNode<TNode extends ts.Node>({ node, comments }: { node: TNode; comments: Array<string | undefined> }) {\n const filteredComments = comments.filter(Boolean)\n\n if (!filteredComments.length) {\n return node\n }\n\n // A description can span lines; each one needs its own ` * ` prefix.\n const text = filteredComments\n .flatMap((comment = '') => comment.split(/\\r?\\n/))\n .reduce((acc = '', comment = '') => {\n return `${acc}\\n * ${comment.replaceAll('*/', '*\\\\/')}`\n }, '*')\n\n // Use the node directly instead of spreading to avoid creating Unknown nodes\n // TypeScript's addSyntheticLeadingComment accepts the node as-is\n return typescript.addSyntheticLeadingComment(node, typescript.SyntaxKind.MultiLineCommentTrivia, `${text || '*'}\\n`, true)\n}\n\n/**\n * Creates a TypeScript index signature for dynamic property access.\n * Defines the key type (default: `string`) and value type on an object.\n */\nfunction createIndexSignature(\n type: ts.TypeNode,\n {\n modifiers,\n indexName = 'key',\n indexType = factory.createKeywordTypeNode(typescript.SyntaxKind.StringKeyword),\n }: {\n indexName?: string\n indexType?: ts.TypeNode\n decorators?: Array<ts.Decorator>\n modifiers?: Array<ts.Modifier>\n } = {},\n) {\n return factory.createIndexSignature(modifiers, [factory.createParameterDeclaration(undefined, undefined, indexName, undefined, indexType)], type)\n}\n\n/**\n * Creates a TypeScript type declaration as either a type alias or interface.\n * Intelligently selects the syntax based on the type structure 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 | ts.Identifier\n type: ts.TypeNode\n}) {\n if (syntax === 'interface' && typescript.isTypeLiteralNode(type)) {\n const node = factory.createInterfaceDeclaration(isExportable ? [modifiers.export] : [], name, undefined, undefined, [...type.members])\n\n return appendJSDocToNode({\n node,\n comments,\n })\n }\n\n const node = factory.createTypeAliasDeclaration(isExportable ? [modifiers.export] : [], name, undefined, type)\n\n return appendJSDocToNode({\n node,\n comments,\n })\n}\n\n/**\n * Converts an enum member value to a literal expression. Numbers become numeric literals (negatives use a prefix\n * minus, as `createNumericLiteral` rejects them) unless `asNumber` is `false`, which emits the string form.\n */\nfunction valueToExpression(value: string | number | boolean, asNumber = isNumber(value)): ts.Expression {\n if (typeof value === 'boolean') {\n return value ? factory.createTrue() : factory.createFalse()\n }\n if (asNumber && isNumber(value)) {\n return value < 0\n ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value)))\n : factory.createNumericLiteral(value)\n }\n return factory.createStringLiteral(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 node, type node] - name node 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: ts.Node | undefined, type: ts.Node] {\n if (type === 'literal' || type === 'inlineLiteral') {\n return [\n undefined,\n factory.createTypeAliasDeclaration(\n [factory.createToken(typescript.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(typeName),\n undefined,\n factory.createUnionTypeNode(\n enums\n .map(([_key, value]) => {\n if (isNumber(value)) {\n if (value < 0) {\n return factory.createLiteralTypeNode(\n factory.createPrefixUnaryExpression(typescript.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value))),\n )\n }\n return factory.createLiteralTypeNode(factory.createNumericLiteral(value?.toString()))\n }\n\n if (typeof value === 'boolean') {\n return factory.createLiteralTypeNode(value ? factory.createTrue() : factory.createFalse())\n }\n if (value !== null && value !== undefined) {\n return factory.createLiteralTypeNode(factory.createStringLiteral(value.toString()))\n }\n\n return undefined\n })\n .filter((node): node is ts.LiteralTypeNode => node !== undefined),\n ),\n ),\n ]\n }\n\n if (type === 'enum' || type === 'constEnum') {\n return [\n undefined,\n factory.createEnumDeclaration(\n [\n factory.createToken(typescript.SyntaxKind.ExportKeyword),\n type === 'constEnum' ? factory.createToken(typescript.SyntaxKind.ConstKeyword) : undefined,\n ].filter(\n (modifier): modifier is ts.ModifierToken<ts.SyntaxKind.ExportKeyword> | ts.ModifierToken<ts.SyntaxKind.ConstKeyword> => modifier !== undefined,\n ),\n factory.createIdentifier(typeName),\n enums\n .map(([key, value, description]) => {\n const initializer = valueToExpression(value, Number.parseInt(value.toString(), 10) === value)\n\n if (isNumber(Number.parseInt(key.toString(), 10))) {\n const casingKey = applyEnumKeyCasing(`${typeName}_${key}`, enumKeyCasing)\n return appendJSDocToNode({ node: factory.createEnumMember(propertyName(casingKey), initializer), comments: [description] })\n }\n\n if (key !== null && key !== undefined) {\n const casingKey = applyEnumKeyCasing(key.toString(), enumKeyCasing)\n return appendJSDocToNode({ node: factory.createEnumMember(propertyName(casingKey), initializer), comments: [description] })\n }\n\n return undefined\n })\n .filter((member): member is ts.EnumMember => member !== undefined),\n ),\n ]\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 [\n undefined,\n factory.createTypeAliasDeclaration(\n [factory.createToken(typescript.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(typeName),\n undefined,\n factory.createKeywordTypeNode(typescript.SyntaxKind.NeverKeyword),\n ),\n ]\n }\n\n return [\n factory.createVariableStatement(\n [factory.createToken(typescript.SyntaxKind.ExportKeyword)],\n factory.createVariableDeclarationList(\n [\n factory.createVariableDeclaration(\n factory.createIdentifier(identifierName),\n undefined,\n undefined,\n factory.createAsExpression(\n factory.createObjectLiteralExpression(\n enums\n .map(([key, value, description]) => {\n const initializer = valueToExpression(value)\n\n if (key !== null && key !== undefined) {\n const casingKey = applyEnumKeyCasing(key.toString(), enumKeyCasing)\n return appendJSDocToNode({ node: factory.createPropertyAssignment(propertyName(casingKey), initializer), comments: [description] })\n }\n\n return undefined\n })\n .filter((property): property is ts.PropertyAssignment => property !== undefined),\n true,\n ),\n factory.createTypeReferenceNode(factory.createIdentifier('const'), undefined),\n ),\n ),\n ],\n typescript.NodeFlags.Const,\n ),\n ),\n factory.createTypeAliasDeclaration(\n [factory.createToken(typescript.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(typeName),\n undefined,\n factory.createIndexedAccessTypeNode(\n factory.createParenthesizedType(factory.createTypeQueryNode(factory.createIdentifier(identifierName), undefined)),\n factory.createTypeOperatorNode(typescript.SyntaxKind.KeyOfKeyword, factory.createTypeQueryNode(factory.createIdentifier(identifierName), undefined)),\n ),\n ),\n ]\n}\n\n/**\n * Creates a TypeScript `Omit<T, Keys>` type reference node.\n * Optionally wraps the type in `NonNullable<T>` if `nonNullable` is true.\n */\nexport function createOmitDeclaration({ keys, type, nonNullable }: { keys: Array<string> | string; type: ts.TypeNode; nonNullable?: boolean }) {\n const node = nonNullable ? factory.createTypeReferenceNode(factory.createIdentifier('NonNullable'), [type]) : type\n\n if (Array.isArray(keys)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Omit'), [\n node,\n factory.createUnionTypeNode(\n keys.map((key) => {\n return factory.createLiteralTypeNode(factory.createStringLiteral(key))\n }),\n ),\n ])\n }\n\n return factory.createTypeReferenceNode(factory.createIdentifier('Omit'), [node, factory.createLiteralTypeNode(factory.createStringLiteral(keys))])\n}\n\n/**\n * Pre-built TypeScript keyword type nodes for common primitive types.\n * Use these to avoid repeatedly creating the same type nodes.\n */\nexport const keywordTypeNodes = {\n any: factory.createKeywordTypeNode(typescript.SyntaxKind.AnyKeyword),\n unknown: factory.createKeywordTypeNode(typescript.SyntaxKind.UnknownKeyword),\n void: factory.createKeywordTypeNode(typescript.SyntaxKind.VoidKeyword),\n number: factory.createKeywordTypeNode(typescript.SyntaxKind.NumberKeyword),\n integer: factory.createKeywordTypeNode(typescript.SyntaxKind.NumberKeyword),\n bigint: factory.createKeywordTypeNode(typescript.SyntaxKind.BigIntKeyword),\n object: factory.createKeywordTypeNode(typescript.SyntaxKind.ObjectKeyword),\n string: factory.createKeywordTypeNode(typescript.SyntaxKind.StringKeyword),\n boolean: factory.createKeywordTypeNode(typescript.SyntaxKind.BooleanKeyword),\n undefined: factory.createKeywordTypeNode(typescript.SyntaxKind.UndefinedKeyword),\n null: factory.createLiteralTypeNode(factory.createToken(typescript.SyntaxKind.NullKeyword)),\n never: factory.createKeywordTypeNode(typescript.SyntaxKind.NeverKeyword),\n} as const\n\n/**\n * Converts a path like '/pet/{petId}/uploadImage' to a template literal type\n * like `/pet/${string}/uploadImage`\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): ts.TypeNode {\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 factory.createLiteralTypeNode(factory.createStringLiteral(normalized))\n }\n\n const segments = normalized.split(/(\\{[^}]+\\})/)\n const parts: Array<string> = []\n const parameterIndices: Array<number> = []\n\n segments.forEach((segment) => {\n if (segment.startsWith('{') && segment.endsWith('}')) {\n parameterIndices.push(parts.length)\n parts.push(segment)\n } else if (segment) {\n parts.push(segment)\n }\n })\n\n const head = typescript.factory.createTemplateHead(parts[0] || '')\n const templateSpans: Array<ts.TemplateLiteralTypeSpan> = []\n\n parameterIndices.forEach((paramIndex, i) => {\n const isLast = i === parameterIndices.length - 1\n const nextPart = parts[paramIndex + 1] || ''\n const literal = isLast ? typescript.factory.createTemplateTail(nextPart) : typescript.factory.createTemplateMiddle(nextPart)\n templateSpans.push(typescript.factory.createTemplateLiteralTypeSpan(keywordTypeNodes.string, literal))\n })\n\n return typescript.factory.createTemplateLiteralType(head, templateSpans)\n}\n\n/**\n * Creates a TypeScript type literal node (anonymous object type).\n */\nexport const createTypeLiteralNode = factory.createTypeLiteralNode\n\n/**\n * Creates a TypeScript type reference node (e.g., `Array<string>`, `Record<K, V>`).\n */\nexport const createTypeReferenceNode = factory.createTypeReferenceNode\n\n// ─── Printer helpers ──────────────────────────────────────────────────────────\n\n/**\n * Converts a primitive const value to a TypeScript literal type node.\n * Handles negative numbers via a prefix unary expression.\n */\nexport function constToTypeNode(value: string | number | boolean, format: 'string' | 'number' | 'boolean'): ts.TypeNode | undefined {\n if (format === 'boolean') {\n return factory.createLiteralTypeNode(value === true ? factory.createTrue() : factory.createFalse())\n }\n const literal = format === 'number' && typeof value === 'number' ? value : String(value)\n return factory.createLiteralTypeNode(valueToExpression(literal) as ts.LiteralTypeNode['literal'])\n}\n\n/**\n * Returns a `Date` reference type node when `representation` is `'date'`, otherwise falls back to `string`.\n */\nexport function dateOrStringNode(node: { representation?: string }): ts.TypeNode {\n return node.representation === 'date' ? createTypeReferenceNode(factory.createIdentifier('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(\n members: Array<ast.SchemaNode> | undefined,\n print: (node: ast.SchemaNode) => ts.TypeNode | null | undefined,\n): Array<ts.TypeNode> {\n return (members ?? []).map(print).filter(isNonNullable)\n}\n\n/**\n * Builds a TypeScript tuple type node 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) => ts.TypeNode | null | undefined): ts.TypeNode {\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 ? factory.createOptionalTypeNode(item) : item))\n }\n\n if (max === undefined && restNode) {\n items.push(factory.createRestTypeNode(factory.createArrayTypeNode(restNode)))\n }\n\n return factory.createTupleTypeNode(items)\n}\n\n/**\n * Appends `| null` and then `| undefined` to a type when requested.\n */\nexport function wrapNullableOptional(type: ts.TypeNode, nullable: boolean, addsUndefined: boolean): ts.TypeNode {\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: ts.TypeNode,\n optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined',\n optional?: boolean,\n): ts.TypeNode {\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\nconst indexSignaturePrinter = typescript.createPrinter()\nconst indexSignatureSource = typescript.createSourceFile('', '', typescript.ScriptTarget.Latest)\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 print: (node: ast.SchemaNode) => ts.TypeNode | null | undefined,\n): Array<ts.TypeElement> {\n const valueTypes: Array<ts.TypeNode> = []\n\n if (node.additionalProperties && node.additionalProperties !== true) {\n valueTypes.push(print(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 = print(schema) ?? keywordTypeNodes.unknown\n valueTypes.push(schema.nullable ? createUnionDeclaration({ nodes: [patternType, keywordTypeNodes.null] }) : patternType)\n }\n\n if (valueTypes.length === 0) return []\n\n const seen = new Set<string>()\n const distinct = valueTypes.filter((type) => {\n const key = indexSignaturePrinter.printNode(typescript.EmitHint.Unspecified, type, indexSignatureSource)\n return seen.has(key) ? false : (seen.add(key), true)\n })\n\n return [createIndexSignature(propertyCount > 0 ? keywordTypeNodes.unknown : createUnionDeclaration({ nodes: distinct }))]\n}\n","import { camelCase, trimQuotes } from '@internals/utils'\nimport type { ast } from 'kubb/kit'\nimport { parserTs } from '@kubb/parser-ts'\nimport { File } from 'kubb/jsx'\nimport type { KubbReactNode } from 'kubb/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 : 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} isExportable isIndexable isTypeOnly={false}>\n {parserTs().print(nameNode)}\n </File.Source>\n )}\n <File.Source\n name={typeName}\n isIndexable={!namesMerge}\n isExportable={!namesMerge && enumOptions.type !== 'inlineLiteral'}\n isTypeOnly={['asConst', 'literal', undefined].includes(enumOptions.type)}\n >\n {parserTs().print(typeNode)}\n </File.Source>\n </>\n )\n}\n","import { ast, type Group, type NodeCache, type Output, type Resolver, type ResolverFileParams, Url } 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 a dependency plugin's generated file for `node.operationId`, cached in `cache` (the\n * current node's `ctx.cache`) under the resolver's own plugin name. Several dependents reading the\n * same dependency for the same operation in one pass (a query plugin's several hook generators, the\n * MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.\n *\n * @example Cache `plugin-ts`'s file for the current operation\n * ```ts\n * const fileTs = resolveDependencyOperationFile({ cache: ctx.cache, node, resolver: tsResolver, root, output })\n * ```\n */\nexport function resolveDependencyOperationFile(options: {\n cache: NodeCache\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 { cache, node, resolver, root, output, group } = options\n\n return cache.ensureItem(`${resolver.pluginName}:operationFile`, () =>\n resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\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 }\n }\n\nexport type OperationCommentLink = 'pathTemplate' | 'urlPath' | false | ((node: ast.OperationNode) => string | undefined)\n\nexport type BuildOperationCommentsOptions = {\n link?: OperationCommentLink\n linkPosition?: 'beforeDeprecated' | 'afterDeprecated'\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<ast.ParameterNode['in'], 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\nfunction getOperationLink(node: ast.OperationNode, link: OperationCommentLink): string | null {\n if (!link) {\n return null\n }\n\n if (typeof link === 'function') {\n return link(node) ?? null\n }\n\n return node.path ? `{@link ${Url.toPath(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\nexport type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n\n/**\n * Reads the single base content type of an operation's primary success response, lowercased and\n * stripped of any `; charset=...` suffix. Returns `undefined` when the response declares zero or\n * more than one content type, since neither case has a single type to act on.\n */\nfunction getPrimarySuccessContentType(node: ast.OperationNode): string | undefined {\n const contentTypes = getPrimarySuccessResponse(node)?.content?.map((entry) => entry.contentType) ?? []\n if (contentTypes.length !== 1) return undefined\n return contentTypes[0]!.split(';')[0]!.trim().toLowerCase()\n}\n\n/**\n * Whether an operation streams its primary success response as Server-Sent Events\n * (`text/event-stream`). The client generator uses this to return a typed event stream instead of a\n * one-shot `RequestResult`.\n */\nexport function isEventStream(node: ast.OperationNode): boolean {\n return getPrimarySuccessContentType(node) === 'text/event-stream'\n}\n\n/**\n * Derives the default `responseType` for an operation from its primary success response.\n *\n * Returns a value only when that response declares a single non-JSON content type. `text/event-stream`\n * and other binary types (`application/octet-stream`, `application/pdf`, `image/*`, `audio/*`,\n * `video/*`) map to a stream or `'blob'`, and other `text/*` maps to `'text'`. Otherwise `undefined`,\n * leaving the runtime client's `Content-Type` auto-detection in charge.\n */\nexport function getResponseType(node: ast.OperationNode): ResponseType | undefined {\n const baseType = getPrimarySuccessContentType(node)\n if (!baseType) return undefined\n\n if (baseType === 'application/json' || baseType.endsWith('+json') || baseType === 'text/json') return undefined\n if (baseType === 'text/event-stream') return 'stream'\n if (baseType.startsWith('text/')) return 'text'\n if (baseType === 'application/octet-stream' || baseType === 'application/pdf' || /^(image|audio|video)\\//.test(baseType)) return 'blob'\n return undefined\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 * 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// The request groups come from the grouped params, so `config` drops the data-shape keys to stay\n// assignable to `Options`, which omits them from `RequestConfig`.\nconst requestConfigBaseType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\n\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n\n // Only the ambiguous side is offered: a single-type side has nothing to pick, so it stays baked in\n // the generated call.\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n return members.length ? `${requestConfigBaseType} & { contentType?: { ${members.join('; ')} } }` : requestConfigBaseType\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...). Unlike {@link buildRequestConfigType}, it never adds a\n * `contentType?:` member: query hooks wrap GET operations, which carry no request body to select a\n * content type for.\n */\nexport function buildClientOptionType(): string {\n return requestConfigBaseType\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: 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 } = 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 }\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 isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !groups.body,\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 }` 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 } {\n const { isConfigurable = true } = options\n const { groups, isOptional } = getRequestGroupOptionality(node)\n\n const names = (['path', 'query', 'body', 'headers'] as const).filter((key) => groups[key])\n\n const firstParam = names.length > 0 ? `{ ${names.join(', ')} }: ${resolver.response.options(node)}${isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { link = 'pathTemplate', linkPosition = 'afterDeprecated', splitLines = false } = options\n const linkComment = getOperationLink(node, link)\n const comments =\n linkPosition === 'beforeDeprecated'\n ? [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, linkComment, node.deprecated && '@deprecated']\n : [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, node.deprecated && '@deprecated', linkComment]\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 * 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 group = (location: ast.ParameterNode['in']) => {\n const seen = new Set<string>()\n\n return node.parameters.filter((param) => {\n if (param.in !== location || seen.has(param.name)) return false\n seen.add(param.name)\n return true\n })\n }\n\n const groups: OperationParameterGroups = { path: group('path'), query: group('query'), header: group('header'), cookie: group('cookie') }\n\n operationParameterGroupsByNode.set(node, groups)\n return groups\n}\n\n/**\n * Builds the combined `{ body, path, query, headers }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same\n * shape from the same inputs. `primitive: 'object'` is a no-op for the TS printer and tells the Zod\n * printer to emit `z.object(…)` rather than a record.\n */\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver): ast.SchemaNode {\n const { path, query, header } = 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 ] as const\n\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 return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({\n name: 'body',\n required: hasBody,\n schema: hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever(),\n }),\n ...groups.map(({ name, params, resolve }) => {\n const required = 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 ],\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 schema: ast.factory.createSchema({ type: 'enum', enumValues: [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\nconst typeNamesByResolver = new WeakMap<OperationTypeNameResolver, Map<string, string[]>>()\n\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const cacheKey = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n let byResolver = typeNamesByResolver.get(resolver)\n if (byResolver) {\n const cached = byResolver.get(cacheKey)\n if (cached) return cached\n } else {\n byResolver = new Map()\n typeNamesByResolver.set(resolver, byResolver)\n }\n\n const { path, query, header } = 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 ]\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 const result = names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n byResolver.set(cacheKey, result)\n return result\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 { toFilePath } from '@internals/utils'\nimport type { ast, Resolver, ResolverFile } from 'kubb/kit'\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` 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}\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 * Resolves a single operation parameter name with the\n * `<operationId> <in> <name>` template.\n *\n * @example\n * `operationParamName.call(resolver, node, param) // → 'DeletePetPathPetId'`\n */\nfunction operationParamName(this: Resolver, node: ast.OperationNode, param: ast.ParameterNode): string {\n return this.name(`${node.operationId} ${param.in} ${param.name}`)\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: operationParamName,\n path(node) {\n return this.name(`${node.operationId} Path`)\n },\n query(node) {\n return this.name(`${node.operationId} Query`)\n },\n headers(node) {\n return this.name(`${node.operationId} Headers`)\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 return this.name(`${node.operationId} Status ${statusCode}`)\n },\n body(node) {\n return this.name(`${node.operationId} Body`)\n },\n responses(node) {\n return this.name(`${node.operationId} Responses`)\n },\n response(node) {\n return this.name(`${node.operationId} Response`)\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 `${toFilePath(name, caseLast)}${extname}`\n },\n }\n}\n","import { camelCase } from '@internals/utils'\nimport 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 type { ResolverTs } from './types.ts'\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\nexport function buildPropertyJSDocComments(schema: ast.SchemaNode, optional?: boolean): Array<string | undefined> {\n const meta = syncSchemaRef(schema)\n\n const isArray = meta?.primitive === 'array'\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 ? `@minLength ${meta.min}` : null,\n !isArray && meta && 'max' in meta && meta.max !== undefined ? `@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 comments.length && 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 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 { ast } from 'kubb/kit'\nimport { File } from 'kubb/jsx'\nimport type { KubbReactNode } from 'kubb/jsx'\nimport 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\nexport function Type({ name, node, printer, enum: enumOptions, resolver }: Props): KubbReactNode {\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\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 <File.Source name={name} isTypeOnly isExportable isIndexable>\n {output}\n </File.Source>\n )}\n </>\n )\n}\n","import { mapSchemaItems, mapSchemaProperties } from '@internals/shared'\nimport { ast, isStringType, syncSchemaRef } from 'kubb/kit'\nimport { parserTs } from '@kubb/parser-ts'\nimport type ts from '@typescript/typescript6'\nimport * as factory from '../factory.ts'\nimport type { PluginTs, ResolverTs } from '../types.ts'\nimport { buildPropertyJSDocComments, enumTypeName, isInlineConstEnum } from '../utils.ts'\n\nconst { isNonNullable } = factory\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. Use `this.transform` to\n * 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 ts.factory.createTypeReferenceNode('Date', [])\n * },\n * },\n * },\n * })\n * ```\n */\nexport type PrinterTsNodes = ast.PrinterPartial<ts.TypeNode, PrinterTsOptions>\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?: Set<string>\n /**\n * Custom handler map for node type overrides.\n */\n nodes?: PrinterTsNodes\n}\n\n/**\n * TypeScript printer factory options: maps `SchemaNode` → `ts.TypeNode` (raw) or `ts.Node` (full declaration).\n */\nexport type PrinterTsFactory = ast.PrinterFactoryOptions<'typescript', PrinterTsOptions, ts.TypeNode, string>\n\ntype PrinterTs = PrinterTsFactory\n\n/**\n * TypeScript type printer built with `definePrinter`.\n *\n * Converts a `SchemaNode` AST node into a TypeScript AST node:\n * - **`printer.print(node)`** — when `options.typeName` is set, returns a full\n * `type Name = …` or `interface Name { … }` declaration (`ts.Node`).\n * Without `typeName`, returns the raw `ts.TypeNode` for the schema.\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 typeNode = printer.print(schemaNode) // ts.TypeNode\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) // ts.TypeAliasDeclaration | ts.InterfaceDeclaration\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, undefined)\n },\n enum(node) {\n const values = ast.getSchemaLiteralValues(node)\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({ withParentheses: true, 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, undefined)\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 withParentheses: true,\n })\n }\n\n return this.transform(m)\n })\n .filter(isNonNullable)\n\n return factory.createUnionDeclaration({ withParentheses: true, nodes: memberNodes })\n }\n\n return factory.createUnionDeclaration({ withParentheses: true, nodes: factory.buildMemberNodes(members, this.transform) })\n },\n intersection(node) {\n return factory.createIntersectionDeclaration({ withParentheses: true, 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 addsQuestionToken = options.optionalType === 'questionToken' || options.optionalType === 'questionTokenAndUndefined'\n\n const propertyNodes: Array<ts.TypeElement> = 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 return factory.appendJSDocToNode({ node: propertyNode, comments: buildPropertyJSDocComments(property.schema, optional) })\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 ...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 result = factory.wrapNullableOptional(transformed, !!meta.nullable, !!(meta.nullish || meta.optional) && addsUndefined)\n return parserTs().print(result)\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: ts.TypeNode = keysToOmit?.length\n ? factory.createOmitDeclaration({ keys: keysToOmit, type: transformed, nonNullable: true })\n : 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' || factory.isUnionTypeNode(inner) || !!keysToOmit?.length\n\n const typeNode = 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 return parserTs().print(typeNode)\n },\n }\n})\n","import { buildOptionsSchema, buildResponses, getOperationParameters, resolveContentTypeVariants } from '@internals/shared'\nimport { ast, defineGenerator } from 'kubb/kit'\nimport { File, jsxRenderer } from 'kubb/jsx'\nimport { Type } from '../components/Type.tsx'\nimport { printerTs } from '../printers/printerTs.ts'\nimport type { PluginTs } from '../types'\nimport { buildParams, buildResponseUnion, enumTypeName, isInlineConstEnum } 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 (!node.name) {\n return\n }\n // Build a set of schema names that are enums 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 = new Set<string>(ctx.meta.enumNames)\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 } = ctx.options\n const { config, resolver, root } = ctx\n\n const meta = {\n file: resolver.file({ name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path, root, output, group: group ?? undefined }),\n } as const\n\n // Build a set of schema names that are enums 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 = new Set<string>(ctx.meta.enumNames)\n const importName = (schemaName: string) => enumTypeName({ resolver, name: schemaName, enumOptions, isEnum: enumSchemaNames.has(schemaName) })\n\n function renderSchemaType({ schema, name, keysToOmit }: { schema: ast.SchemaNode | null; name: string; keysToOmit?: Array<string> | null }) {\n if (!schema) return null\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} />\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 decorate?: (schema: ast.SchemaNode) => ast.SchemaNode,\n ) {\n const variants = resolveContentTypeVariants(entries, baseName)\n const unionSchema = ast.factory.createSchema({\n type: 'union',\n members: variants.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: pathParams, query: queryParams, header: headerParams } = getOperationParameters(node)\n\n const paramGroupTypes = [\n pathParams.length > 0 && renderSchemaType({ schema: buildParams({ params: pathParams }), name: resolver.param.path(node, pathParams[0]!) }),\n queryParams.length > 0 && renderSchemaType({ schema: buildParams({ params: queryParams }), name: resolver.param.query(node, queryParams[0]!) }),\n headerParams.length > 0 && renderSchemaType({ schema: buildParams({ params: headerParams }), name: resolver.param.headers(node, headerParams[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 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), (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 variants = (res.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))\n }\n const primary = variants[0] ?? res.content?.[0]\n return renderSchemaType({\n schema: primary?.schema ?? null,\n name: resolver.response.status(node, res.statusCode),\n keysToOmit: primary?.keysToOmit,\n })\n })\n\n const optionsType = renderSchemaType({\n schema: buildOptionsSchema(node, resolver),\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 if (!node.responses.some(hasSchema)) {\n return null\n }\n\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 })!,\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 } from '@internals/shared'\nimport { ensureValidVarName, pascalCase } from '@internals/utils'\nimport { 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 every generated TypeScript type. Import this in other plugins that need\n * to reference the exact names `plugin-ts` produces without duplicating the\n * casing/file-layout rules.\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 ensureValidVarName(pascalCase(name))\n },\n file: createCasedFile(pascalCase),\n param: createOperationParamResolver(),\n response: {\n ...createOperationResponseResolver(),\n options(node) {\n return this.name(`${node.operationId} Options`)\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 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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,QAAQ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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.cjs","names":["isNonNullable","generate","syncSchemaRef","factory.createEnumDeclaration","File","ast","syncSchemaRef","ast","ast","File","factory","factory.print","factory.createRaw","parserTs","ast","factory.createTypeReferenceNode","factory.createUrlTemplateType","factory.dateOrStringNode","factory.constToTypeNode","factory.createUnionDeclaration","isStringType","factory.createIntersectionDeclaration","factory.createTypeLiteralNode","factory.buildMemberNodes","factory.createArrayDeclaration","factory.buildTupleNode","factory.buildPropertyType","syncSchemaRef","factory.createPropertySignature","factory.appendJSDocToNode","factory.buildIndexSignatures","factory.wrapNullableOptional","factory.createOmitDeclaration","factory.createTypeDeclaration","defineGenerator","jsxRenderer","ast","File","createResolver","defineExtension","Resolver"],"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/components/Type.tsx","../src/printers/printerTs.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":["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/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction convert(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n// Plugins resolve the same names over and over (about 47,000 calls for a 1,000 schema spec), so\n// results are kept. Clearing at the limit bounds the memory a long-running process spends on it.\nconst cache = new Map<string, string>()\nconst cacheLimit = 10_000\n\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const key = `${pascal ? 'P' : 'c'}${text}`\n const cached = cache.get(key)\n if (cached !== undefined) return cached\n\n const result = convert(text, pascal)\n if (cache.size >= cacheLimit) cache.clear()\n cache.set(key, result)\n return result\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Uppercases only the first character of `text`, leaving the rest untouched.\n * Unlike {@link 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 const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\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 '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/**\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 } = new RegExp(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 './casing.ts'\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 { camelCase, pascalCase, screamingSnakeCase, snakeCase } from '@internals/utils'\nimport { 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 primitive const value to a TypeScript literal type.\n */\nexport function constToTypeNode(value: string | number | boolean, format: 'string' | 'number' | 'boolean'): TsNode | undefined {\n if (format === 'boolean') {\n return createLiteralType(value === true)\n }\n return createLiteralType(format === '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 { camelCase, trimQuotes } from '@internals/utils'\nimport type { ast } from 'kubb/kit'\nimport { File } from 'kubb/jsx'\nimport type { KubbReactNode } from 'kubb/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 : 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 NodeCache, type Output, type Resolver, type ResolverFileParams, Url } 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 a dependency plugin's generated file for `node.operationId`, cached in `cache` (the\n * current node's `ctx.cache`) under the resolver's own plugin name. Several dependents reading the\n * same dependency for the same operation in one pass (a query plugin's several hook generators, the\n * MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.\n *\n * @example Cache `plugin-ts`'s file for the current operation\n * ```ts\n * const fileTs = resolveDependencyOperationFile({ cache: ctx.cache, node, resolver: tsResolver, root, output })\n * ```\n */\nexport function resolveDependencyOperationFile(options: {\n cache: NodeCache\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 { cache, node, resolver, root, output, group } = options\n\n return cache.ensureItem(`${resolver.pluginName}:operationFile`, () =>\n resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\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 }\n }\n\nexport type OperationCommentLink = 'pathTemplate' | 'urlPath' | false | ((node: ast.OperationNode) => string | undefined)\n\nexport type BuildOperationCommentsOptions = {\n link?: OperationCommentLink\n linkPosition?: 'beforeDeprecated' | 'afterDeprecated'\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<ast.ParameterNode['in'], 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\nfunction getOperationLink(node: ast.OperationNode, link: OperationCommentLink): string | null {\n if (!link) {\n return null\n }\n\n if (typeof link === 'function') {\n return link(node) ?? null\n }\n\n return node.path ? `{@link ${Url.toPath(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\nexport type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n\n/**\n * Reads the single base content type of an operation's primary success response, lowercased and\n * stripped of any `; charset=...` suffix. Returns `undefined` when the response declares zero or\n * more than one content type, since neither case has a single type to act on.\n */\nfunction getPrimarySuccessContentType(node: ast.OperationNode): string | undefined {\n const contentTypes = getPrimarySuccessResponse(node)?.content?.map((entry) => entry.contentType) ?? []\n if (contentTypes.length !== 1) return undefined\n return contentTypes[0]!.split(';')[0]!.trim().toLowerCase()\n}\n\n/**\n * Whether an operation streams its primary success response as Server-Sent Events\n * (`text/event-stream`). The client generator uses this to return a typed event stream instead of a\n * one-shot `RequestResult`.\n */\nexport function isEventStream(node: ast.OperationNode): boolean {\n return getPrimarySuccessContentType(node) === 'text/event-stream'\n}\n\n/**\n * Derives the default `responseType` for an operation from its primary success response.\n *\n * Returns a value only when that response declares a single non-JSON content type. `text/event-stream`\n * and other binary types (`application/octet-stream`, `application/pdf`, `image/*`, `audio/*`,\n * `video/*`) map to a stream or `'blob'`, and other `text/*` maps to `'text'`. Otherwise `undefined`,\n * leaving the runtime client's `Content-Type` auto-detection in charge.\n */\nexport function getResponseType(node: ast.OperationNode): ResponseType | undefined {\n const baseType = getPrimarySuccessContentType(node)\n if (!baseType) return undefined\n\n if (baseType === 'application/json' || baseType.endsWith('+json') || baseType === 'text/json') return undefined\n if (baseType === 'text/event-stream') return 'stream'\n if (baseType.startsWith('text/')) return 'text'\n if (baseType === 'application/octet-stream' || baseType === 'application/pdf' || /^(image|audio|video)\\//.test(baseType)) return 'blob'\n return undefined\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 * 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// The request groups come from the grouped params, so `config` drops the data-shape keys to stay\n// assignable to `Options`, which omits them from `RequestConfig`.\nconst requestConfigBaseType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\n\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n\n // Only the ambiguous side is offered: a single-type side has nothing to pick, so it stays baked in\n // the generated call.\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n return members.length ? `${requestConfigBaseType} & { contentType?: { ${members.join('; ')} } }` : requestConfigBaseType\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...). Unlike {@link buildRequestConfigType}, it never adds a\n * `contentType?:` member: query hooks wrap GET operations, which carry no request body to select a\n * content type for.\n */\nexport function buildClientOptionType(): string {\n return requestConfigBaseType\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: 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 } = 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 }\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 isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !groups.body,\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 }` 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 } {\n const { isConfigurable = true } = options\n const { groups, isOptional } = getRequestGroupOptionality(node)\n\n const names = (['path', 'query', 'body', 'headers'] as const).filter((key) => groups[key])\n\n const firstParam = names.length > 0 ? `{ ${names.join(', ')} }: ${resolver.response.options(node)}${isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { link = 'pathTemplate', linkPosition = 'afterDeprecated', splitLines = false } = options\n const linkComment = getOperationLink(node, link)\n const comments =\n linkPosition === 'beforeDeprecated'\n ? [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, linkComment, node.deprecated && '@deprecated']\n : [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, node.deprecated && '@deprecated', linkComment]\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 * 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 group = (location: ast.ParameterNode['in']) => {\n const seen = new Set<string>()\n\n return node.parameters.filter((param) => {\n if (param.in !== location || seen.has(param.name)) return false\n seen.add(param.name)\n return true\n })\n }\n\n const groups: OperationParameterGroups = { path: group('path'), query: group('query'), header: group('header'), cookie: group('cookie') }\n\n operationParameterGroupsByNode.set(node, groups)\n return groups\n}\n\n/**\n * Builds the combined `{ body, path, query, headers }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same\n * shape from the same inputs. `primitive: 'object'` is a no-op for the TS printer and tells the Zod\n * printer to emit `z.object(…)` rather than a record.\n */\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver): ast.SchemaNode {\n const { path, query, header } = 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 ] as const\n\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 return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({\n name: 'body',\n required: hasBody,\n schema: hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever(),\n }),\n ...groups.map(({ name, params, resolve }) => {\n const required = 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 ],\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 schema: ast.factory.createSchema({ type: 'enum', enumValues: [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\nconst typeNamesByResolver = new WeakMap<OperationTypeNameResolver, Map<string, string[]>>()\n\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const cacheKey = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n let byResolver = typeNamesByResolver.get(resolver)\n if (byResolver) {\n const cached = byResolver.get(cacheKey)\n if (cached) return cached\n } else {\n byResolver = new Map()\n typeNamesByResolver.set(resolver, byResolver)\n }\n\n const { path, query, header } = 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 ]\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 const result = names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n byResolver.set(cacheKey, result)\n return result\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 { toFilePath } from '@internals/utils'\nimport type { ast, Resolver, ResolverFile } from 'kubb/kit'\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` 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}\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 * Resolves a single operation parameter name with the\n * `<operationId> <in> <name>` template.\n *\n * @example\n * `operationParamName.call(resolver, node, param) // → 'DeletePetPathPetId'`\n */\nfunction operationParamName(this: Resolver, node: ast.OperationNode, param: ast.ParameterNode): string {\n return this.name(`${node.operationId} ${param.in} ${param.name}`)\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: operationParamName,\n path(node) {\n return this.name(`${node.operationId} Path`)\n },\n query(node) {\n return this.name(`${node.operationId} Query`)\n },\n headers(node) {\n return this.name(`${node.operationId} Headers`)\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 return this.name(`${node.operationId} Status ${statusCode}`)\n },\n body(node) {\n return this.name(`${node.operationId} Body`)\n },\n responses(node) {\n return this.name(`${node.operationId} Responses`)\n },\n response(node) {\n return this.name(`${node.operationId} Response`)\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 `${toFilePath(name, caseLast)}${extname}`\n },\n }\n}\n","import { camelCase } from '@internals/utils'\nimport 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 type { ResolverTs } from './types.ts'\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\nexport function buildPropertyJSDocComments(schema: ast.SchemaNode, optional?: boolean): Array<string | undefined> {\n const meta = syncSchemaRef(schema)\n\n const isArray = meta?.primitive === 'array'\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 ? `@minLength ${meta.min}` : null,\n !isArray && meta && 'max' in meta && meta.max !== undefined ? `@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 comments.length && 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 { ast } from 'kubb/kit'\nimport { File } from 'kubb/jsx'\nimport type { KubbReactNode } from 'kubb/jsx'\nimport 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\nexport function Type({ name, node, printer, enum: enumOptions, resolver }: Props): KubbReactNode {\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\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 <File.Source name={name} pointer={node.pointer} isTypeOnly isExportable isIndexable>\n {output}\n </File.Source>\n )}\n </>\n )\n}\n","import { mapSchemaItems, mapSchemaProperties } from '@internals/shared'\nimport { ast, isStringType, syncSchemaRef } from 'kubb/kit'\nimport { parserTs } from '@kubb/parser-ts'\nimport * as factory from '../factory.ts'\nimport type { PluginTs, ResolverTs } from '../types.ts'\nimport { buildPropertyJSDocComments, enumTypeName, isInlineConstEnum } from '../utils.ts'\n\nconst { isNonNullable } = factory\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?: Set<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 : 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 // 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 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 return factory.appendJSDocToNode({ node: propertyNode, comments: buildPropertyJSDocComments(property.schema, optional) })\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 return factory.print(factory.wrapNullableOptional(transformed, !!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 { buildOptionsSchema, buildResponses, getOperationParameters, resolveContentTypeVariants } from '@internals/shared'\nimport { ast, defineGenerator } from 'kubb/kit'\nimport { File, jsxRenderer } from 'kubb/jsx'\nimport { Type } from '../components/Type.tsx'\nimport { printerTs } from '../printers/printerTs.ts'\nimport type { PluginTs } from '../types'\nimport { buildParams, buildResponseUnion, enumTypeName, isInlineConstEnum } 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 (!node.name) {\n return\n }\n // Build a set of schema names that are enums 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 = new Set<string>(ctx.meta.enumNames)\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 } = ctx.options\n const { config, resolver, root } = ctx\n\n const meta = {\n file: resolver.file({ name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path, root, output, group: group ?? undefined }),\n } as const\n\n // Build a set of schema names that are enums 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 = new Set<string>(ctx.meta.enumNames)\n const importName = (schemaName: string) => enumTypeName({ resolver, name: schemaName, enumOptions, isEnum: enumSchemaNames.has(schemaName) })\n\n function renderSchemaType({ schema, name, keysToOmit }: { schema: ast.SchemaNode | null; name: string; keysToOmit?: Array<string> | null }) {\n if (!schema) return null\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} />\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 const unionSchema = ast.factory.createSchema({\n type: 'union',\n pointer,\n members: variants.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: pathParams, query: queryParams, header: headerParams } = getOperationParameters(node)\n\n const paramGroupTypes = [\n pathParams.length > 0 && renderSchemaType({ schema: buildParams({ params: pathParams }), name: resolver.param.path(node, pathParams[0]!) }),\n queryParams.length > 0 && renderSchemaType({ schema: buildParams({ params: queryParams }), name: resolver.param.query(node, queryParams[0]!) }),\n headerParams.length > 0 && renderSchemaType({ schema: buildParams({ params: headerParams }), name: resolver.param.headers(node, headerParams[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 variants = (res.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] ?? res.content?.[0]\n return renderSchemaType({\n schema: primary?.schema ? { ...primary.schema, pointer: res.pointer ?? primary.schema.pointer } : null,\n name: resolver.response.status(node, res.statusCode),\n keysToOmit: primary?.keysToOmit,\n })\n })\n\n const optionsType = renderSchemaType({\n schema: buildOptionsSchema(node, resolver),\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 if (!node.responses.some(hasSchema)) {\n return null\n }\n\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 })!,\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 } from '@internals/shared'\nimport { ensureValidVarName, pascalCase } from '@internals/utils'\nimport { 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 every generated TypeScript type. Import this in other plugins that need\n * to reference the exact names `plugin-ts` produces without duplicating the\n * casing/file-layout rules.\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 ensureValidVarName(pascalCase(name))\n },\n file: createCasedFile(pascalCase),\n param: createOperationParamResolver(),\n response: {\n ...createOperationResponseResolver(),\n options(node) {\n return this.name(`${node.operationId} Options`)\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 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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,QAAQ,MAAc,QAAyB;CACtD,OAAO,KACJ,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,gBAAgB,OAAO,CAAC,CAChC,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAChC;AAIA,MAAM,wBAAQ,IAAI,IAAoB;AACtC,MAAM,aAAa;AAEnB,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,MAAM,MAAM,GAAG,SAAS,MAAM,MAAM;CACpC,MAAM,SAAS,MAAM,IAAI,GAAG;CAC5B,IAAI,WAAW,KAAA,GAAW,OAAO;CAEjC,MAAM,SAAS,QAAQ,MAAM,MAAM;CACnC,IAAI,MAAM,QAAQ,YAAY,MAAM,MAAM;CAC1C,MAAM,IAAI,KAAK,MAAM;CACrB,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,UAAU,MAAc,EAAE,SAAS,IAAI,S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