@kubb/plugin-zod 5.0.0-beta.84 → 5.0.0-beta.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +306 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +118 -137
- package/dist/index.js +307 -173
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["File","Const","Type","ast","strictOneOfMember","ast","ast","jsxRenderer","File","ast"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/fs.ts","../../../internals/utils/src/reserved.ts","../../../internals/shared/src/params.ts","../../../internals/shared/src/operation.ts","../../../internals/shared/src/group.ts","../src/components/Zod.tsx","../src/constants.ts","../src/utils.ts","../src/printers/printerZod.ts","../src/printers/printerZodMini.ts","../src/generators/zodGenerator.tsx","../src/resolvers/resolverZod.ts","../src/plugin.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 toCamelOrPascal(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/**\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 * 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","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 | null, filePath?: string | null): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\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","/**\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 /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(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","import { camelCase } from '@internals/utils'\nimport type { ast } from 'kubb/kit'\n\nconst caseParamsCache = new WeakMap<Array<ast.ParameterNode>, Array<ast.ParameterNode>>()\n\n/**\n * Applies camelCase to parameter names and returns a new array without mutating the input.\n *\n * Run it before handing parameters to schema builders so output property keys get the right casing\n * while `OperationNode.parameters` stays intact for other consumers. When `casing` is unset, the\n * original array is returned unchanged. Results are cached per input array.\n */\nexport function caseParams(params: Array<ast.ParameterNode>, casing: 'camelcase' | undefined): Array<ast.ParameterNode> {\n if (!casing) return params\n\n const cached = caseParamsCache.get(params)\n if (cached) return cached\n\n const result = params.map((param) => ({ ...param, name: camelCase(param.name) }))\n caseParamsCache.set(params, result)\n return result\n}\n\n/**\n * Drops parameters that collapse to the same property identity once camelCased, keeping the first.\n *\n * Some specs declare the same parameter twice under different casings (for example AWS S3 lists both\n * `max-uploads` and `MaxUploads`). Both resolve to one output property, so emitting both would yield\n * an object type with a duplicate member, which TypeScript rejects. De-duplicate by the camelCased\n * identity so the resulting group is collision-free regardless of the names each caller carries.\n */\nexport function dedupeByCasedName(params: Array<ast.ParameterNode>): Array<ast.ParameterNode> {\n const seen = new Set<string>()\n\n return params.filter((param) => {\n const key = camelCase(param.name)\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n}\n\nexport function buildParamsMapping<TParam extends { name: string }>(\n originalParams: ReadonlyArray<TParam>,\n mappedParams: ReadonlyArray<TParam>,\n): Record<string, string> | null {\n const mapping: Record<string, string> = {}\n let hasChanged = false\n\n originalParams.forEach((param, i) => {\n const mappedName = mappedParams[i]?.name ?? param.name\n mapping[param.name] = mappedName\n\n if (param.name !== mappedName) {\n hasChanged = true\n }\n })\n\n return hasChanged ? mapping : null\n}\n\nexport function buildTransformedParamsMapping<TParam extends { name: string }>(\n params: ReadonlyArray<TParam>,\n transformName: (name: string) => string,\n): Record<string, string> | null {\n if (!params.length) {\n return null\n }\n\n return buildParamsMapping(\n params,\n params.map((param) => ({ ...param, name: transformName(param.name) })),\n )\n}\n","import { Url } from '@internals/utils'\nimport { ast, type ResolverFileParams } from 'kubb/kit'\nimport { caseParams, dedupeByCasedName } from './params.ts'\n\n/**\n * Builds the `ResolverFileParams` every operation generator passes to\n * `resolver.resolveFile`: 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.resolveFile(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\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n resolveDataName(node: ast.OperationNode): string\n}\n\nexport type ResponseStatusNameResolver = {\n resolveResponseStatusName(node: ast.OperationNode, statusCode: ast.StatusCode): string\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n resolveResponseName(node: ast.OperationNode): string\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n\n/**\n * Resolver interface for building operation parameters.\n *\n * `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.\n */\nexport type OperationParamsResolver = {\n /**\n * Resolves the type name for an individual parameter.\n *\n * @example Individual path parameter name\n * `resolver.resolveParamName(node, param) // → 'DeletePetPathPetId'`\n */\n resolveParamName(node: ast.OperationNode, param: ast.ParameterNode): string\n /**\n * Resolves the request body type name.\n *\n * @example Request body type name\n * `resolver.resolveDataName(node) // → 'CreatePetData'`\n */\n resolveDataName(node: ast.OperationNode): string\n /**\n * Resolves the grouped path parameters type name.\n * When the return value equals `resolveParamName`, no indexed access is emitted.\n *\n * @example Grouped path params type name\n * `resolver.resolvePathParamsName(node, param) // → 'DeletePetPathParams'`\n */\n resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n /**\n * Resolves the grouped query parameters type name.\n * When the return value equals `resolveParamName`, an inline struct type is emitted instead.\n *\n * @example Grouped query params type name\n * `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`\n */\n resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n /**\n * Resolves the grouped header parameters type name.\n * When the return value equals `resolveParamName`, an inline struct type is emitted instead.\n *\n * @example Grouped header params type name\n * `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`\n */\n resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\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 paramsCasing?: 'camelcase' | 'original'\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `PathParams`/`QueryParams`/`HeaderParams` type names. Set to `false`\n * for clients that reference the grouped `RequestConfig` 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 if (link === 'urlPath') {\n return node.path ? `{@link ${Url.toPath(node.path)}}` : null\n }\n\n return node.path ? `{@link ${node.path.replaceAll('{', ':').replaceAll('}', '')}}` : null\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n const contentTypes = node.requestBody?.content?.map((e) => e.contentType) ?? []\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\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 const contentTypes = getPrimarySuccessResponse(node)?.content?.map((e) => e.contentType) ?? []\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 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\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\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`.\n const configType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\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 ? `${configType} & { contentType?: { ${members.join('; ')} } }` : configType\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 `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\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 RequestConfigNameResolver = RequestConfigResolver & {\n resolveRequestConfigName(node: ast.OperationNode): string\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers }` parameter for a generated client\n * function, typed from the operation's `RequestConfig` (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: RequestConfigNameResolver,\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.resolveRequestConfigName(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\nexport function getOperationParameters(node: ast.OperationNode, options: { paramsCasing?: 'camelcase' | 'original' } = {}): OperationParameterGroups {\n const params = caseParams(node.parameters, options.paramsCasing === 'original' ? undefined : 'camelcase')\n\n return {\n path: dedupeByCasedName(params.filter((param) => param.in === 'path')),\n query: dedupeByCasedName(params.filter((param) => param.in === 'query')),\n header: dedupeByCasedName(params.filter((param) => param.in === 'header')),\n cookie: dedupeByCasedName(params.filter((param) => param.in === 'cookie')),\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\n .filter((response) => isErrorStatusCode(response.statusCode))\n .map((response) => resolver.resolveResponseStatusName(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses\n .filter((response) => isSuccessStatusCode(response.statusCode))\n .map((response) => resolver.resolveResponseStatusName(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.resolveResponseStatusName(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.paramsCasing ?? ''}\\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, { paramsCasing: options.paramsCasing })\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.resolvePathParamsName(node, param)),\n ...query.map((param) => resolver.resolveQueryParamsName(node, param)),\n ...header.map((param) => resolver.resolveHeaderParamsName(node, param)),\n ]\n const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null, resolver.resolveResponseName(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.resolveResponseName(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.resolveResponseName(node) : resolver.resolveResponseStatusName(node, response.statusCode)])\n }\n\n return types\n}\n\nexport function findSuccessStatusCode(responses: Array<{ statusCode: ast.StatusCode | number | string }>): ast.StatusCode | null {\n for (const response of responses) {\n if (isSuccessStatusCode(response.statusCode)) {\n return response.statusCode as ast.StatusCode\n }\n }\n\n return null\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'\nimport { Const, File, Type } from 'kubb/jsx'\nimport type { KubbReactNode } from 'kubb/jsx'\nimport type { PrinterZodFactory } from '../printers/printerZod.ts'\nimport type { PrinterZodMiniFactory } from '../printers/printerZodMini.ts'\n\ntype Props = {\n name: string\n node: ast.SchemaNode\n /**\n * Pre-configured printer instance created by the generator.\n * The generator selects `printerZod` or `printerZodMini` based on the `mini` option,\n * then merges in any user-supplied `printer.nodes` overrides.\n */\n printer: ast.Printer<PrinterZodFactory> | ast.Printer<PrinterZodMiniFactory>\n inferTypeName?: string | null\n /**\n * Set when the schema references itself. A self-referential initializer (e.g. a `z.lazy(() => …)`\n * back to the same const) is implicitly `any` under `strict`, so the const is annotated with an\n * explicit `z.ZodType` to break the inference cycle.\n */\n cyclic?: boolean\n}\n\nexport function Zod({ name, node, printer, inferTypeName, cyclic }: Props): KubbReactNode {\n const output = printer.print(node)\n\n if (!output) {\n return\n }\n\n // A cyclic object emits its self-references as deferred getters (`get prop() { … }`), so its\n // initializer never references itself directly and TypeScript infers it fine — annotating it would\n // only strip the `ZodObject` methods (`.omit()`, `.strict()`). Only non-object cyclic schemas (a\n // union/array with a top-level `z.lazy(() => self)`) are implicitly `any` and need the annotation.\n const needsAnnotation = cyclic && node.type !== 'object'\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} type={needsAnnotation ? 'z.ZodType' : undefined}>\n {output}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n <Type export name={inferTypeName}>\n {`z.infer<typeof ${name}>`}\n </Type>\n </File.Source>\n )}\n </>\n )\n}\n","/**\n * Import paths that use a namespace import (`import * as z from '...'`).\n * All other import paths use a named import (`import { z } from '...'`).\n */\nexport const ZOD_NAMESPACE_IMPORTS = new Set(['zod', 'zod/mini'] as const)\n","import { ast } from 'kubb/kit'\nimport type { PluginZod } from './types.ts'\n\n/**\n * Returns `true` when the given coercion option enables coercion for the specified type.\n */\nexport function shouldCoerce(coercion: PluginZod['resolvedOptions']['coercion'] | undefined, type: 'dates' | 'strings' | 'numbers'): boolean {\n if (coercion === undefined || coercion === false) return false\n if (coercion === true) return true\n\n return !!coercion[type]\n}\n\n/**\n * A codec for a schema node whose runtime type differs from its JSON wire type:\n * the output (response) schema decodes wire → runtime, and the input (request)\n * variant encodes runtime → wire.\n *\n * To support another codec type, append a `Codec` to `codecs` and route that\n * type's printer node handler through `getCodec`.\n */\nexport type Codec = {\n /**\n * Whether this node is encoded/decoded by this codec.\n */\n matches(node: ast.SchemaNode): boolean\n /**\n * Output direction (response): decode the wire value into the runtime type.\n */\n decode(node: ast.SchemaNode): string\n /**\n * Input direction (request): encode the runtime value back to the wire value.\n */\n encode(node: ast.SchemaNode): string\n}\n\n/**\n * `dateType: 'date'` fields are typed as `Date` but travel as ISO `string`s.\n * Output decodes `string → Date`; input encodes `Date → string`, preserving the\n * `date` (`YYYY-MM-DD`) vs `date-time` precision carried on `node.format`.\n */\nconst dateCodec: Codec = {\n matches(node) {\n return node.type === 'date' && node.representation === 'date'\n },\n decode(node) {\n return node.format === 'date' ? 'z.iso.date().transform((value) => new Date(value))' : 'z.iso.datetime().transform((value) => new Date(value))'\n },\n encode(node) {\n return node.format === 'date' ? 'z.date().transform((value) => value.toISOString().slice(0, 10))' : 'z.date().transform((value) => value.toISOString())'\n },\n}\n\n/**\n * Registered codecs, checked in order.\n */\nconst codecs: Array<Codec> = [dateCodec]\n\n/**\n * Returns the codec for this node, or `undefined` when the node needs no\n * encode/decode (its wire and runtime types match).\n */\nexport function getCodec(node: ast.SchemaNode | undefined): Codec | undefined {\n if (!node) return undefined\n return codecs.find((codec) => codec.matches(node))\n}\n\n/**\n * Returns `true` when the node itself is encoded/decoded by a codec.\n */\nexport function hasCodec(node: ast.SchemaNode | undefined): boolean {\n return getCodec(node) !== undefined\n}\n\n/**\n * Returns `true` when the schema transitively contains a codec node —\n * a value whose runtime type differs from its wire type (see {@link hasCodec}),\n * so it must be decoded (response) or encoded (request) at the validation boundary.\n * `$ref`s are followed via their resolved schema; a `seen` set guards cycles.\n */\nexport function containsCodec(node: ast.SchemaNode | undefined, seen: Set<string> = new Set()): boolean {\n if (!node) return false\n\n if (hasCodec(node)) return true\n\n if (node.type === 'ref') {\n if (!node.ref) return false\n const refName = ast.extractRefName(node.ref)\n if (refName) {\n if (seen.has(refName)) return false\n seen.add(refName)\n }\n const resolved = ast.syncSchemaRef(node)\n if (resolved.type === 'ref') return false\n return containsCodec(resolved, seen)\n }\n\n const children: Array<ast.SchemaNode | undefined> = []\n if ('properties' in node && node.properties) children.push(...node.properties.map((prop) => prop.schema))\n if ('items' in node && node.items) children.push(...node.items)\n if ('members' in node && node.members) children.push(...node.members)\n if ('additionalProperties' in node && node.additionalProperties && node.additionalProperties !== true) children.push(node.additionalProperties)\n\n return children.some((child) => containsCodec(child, seen))\n}\n\n/**\n * Collects the names of `$ref` schemas that transitively contain a codec, so the generator can route\n * them to their input (encode) variant.\n */\nexport function collectCodecRefNames(node: ast.SchemaNode): Array<string> {\n return ast.collect<string>(node, {\n schema: (n) => (n.type === 'ref' && n.ref && containsCodec(n) ? (ast.extractRefName(n.ref) ?? undefined) : undefined),\n })\n}\n\n/**\n * Whether the node is a plain inline object whose shape can be lifted into an `.extend({ … })`\n * argument. A catchall, `patternProperties`, or a nullable/optional wrapper cannot, so those stay\n * on `.and(…)`.\n */\nfunction isPlainInlineObject(node: ast.SchemaNode): boolean {\n return node.type === 'object' && !node.nullable && !node.optional && !node.nullish && node.additionalProperties === undefined && !node.patternProperties\n}\n\n/**\n * Whether a node renders as a bare Zod object — one that accepts `.extend(…)` and can be a\n * `z.discriminatedUnion` option. Covers object nodes, `$ref`s that resolve to (or are still\n * unresolved) objects, single-member unions of an object, and object-composable `allOf`.\n *\n * `cyclicSchemas` bounds the recursion: a ref into a cycle renders as `z.lazy(…)`, not an object.\n */\nexport function isObjectSchemaNode(node: ast.SchemaNode, cyclicSchemas?: ReadonlySet<string>): boolean {\n if (node.nullable || node.optional || node.nullish) return false\n if (node.type === 'object') return true\n\n if (node.type === 'ref') {\n const refName = (node.ref ? ast.extractRefName(node.ref) : undefined) ?? node.name\n if (refName && cyclicSchemas?.has(refName)) return false\n const resolved = ast.syncSchemaRef(node)\n // An unresolved ref keeps its `ref` type; assume it resolves to an object (matches the printer's\n // prior optimism that only a resolved intersection blocks a discriminated union).\n return resolved.type === 'ref' || isObjectSchemaNode(resolved, cyclicSchemas)\n }\n\n if (node.type === 'union') {\n const members = node.members ?? []\n return members.length === 1 && isObjectSchemaNode(members[0]!, cyclicSchemas)\n }\n\n return isObjectComposableIntersection(node, cyclicSchemas)\n}\n\n/**\n * Whether an `allOf` is a pure object composition — an object base plus inline object members whose\n * shapes merge with `.extend(…)`. These stay a Zod object instead of a `ZodIntersection`, which\n * `z.discriminatedUnion` rejects.\n */\nexport function isObjectComposableIntersection(node: ast.SchemaNode, cyclicSchemas?: ReadonlySet<string>): boolean {\n if (node.type !== 'intersection') return false\n const [first, ...rest] = node.members ?? []\n return !!first && isObjectSchemaNode(first, cyclicSchemas) && rest.every(isPlainInlineObject)\n}\n\n/**\n * Format a default value as a code-level literal.\n * Objects become `{}`, primitives become their string representation, strings are quoted.\n */\nexport function formatDefault(value: unknown): string {\n if (typeof value === 'string') return ast.stringify(value)\n if (typeof value === 'object' && value !== null) return '{}'\n\n return String(value ?? '')\n}\n\n/**\n * Format a default for `.default(...)` so the literal matches the generated schema's type.\n *\n * An OpenAPI `default` does not always agree with the schema it sits on: a `bigint` field\n * (`format: int64`) carries a `number` default, and a spec may put `default: {}` on an `array`.\n * Emitting those verbatim produces a Zod schema that does not typecheck, so coerce the bigint case\n * to a `BigInt(...)` literal and emit an array literal for arrays (dropping a non-array default).\n * Returns `null` when no `.default(...)` should be emitted. Keys off the schema node's type.\n */\nexport function defaultLiteral(node: ast.SchemaNode | undefined, value: unknown): string | null {\n // A `null` default is invalid on a non-nullable schema and redundant on a nullish one, and emitting\n // it produces a bare `.default()` (no argument). Drop it.\n if (value === null) return null\n if (node && ast.narrowSchema(node, 'bigint')) {\n if (typeof value === 'bigint') return `BigInt(${value})`\n if (typeof value === 'number' && Number.isInteger(value)) return `BigInt(${value})`\n return null\n }\n if (node && ast.narrowSchema(node, 'array')) {\n return Array.isArray(value) ? JSON.stringify(value) : null\n }\n // An enum/literal schema narrows to its members (e.g. `1 | 3`), but the spec default may not match\n // that type (`default: '1'` on a numeric enum). Emit the matching member's typed literal so the\n // default agrees with the schema, or drop a default that matches no member.\n const enumNode = node ? ast.narrowSchema(node, 'enum') : undefined\n if (enumNode) {\n const values = enumNode.namedEnumValues?.map((member) => member.value) ?? enumNode.enumValues ?? []\n if (values.length) {\n const match = values.find((member) => member === value || String(member) === String(value))\n return match != null ? formatLiteral(match) : null\n }\n }\n return formatDefault(value)\n}\n\n/**\n * Format a primitive enum/literal value.\n * Strings are quoted; numbers and booleans are emitted raw.\n */\nexport function formatLiteral(v: string | number | boolean): string {\n if (typeof v === 'string') return ast.stringify(v)\n\n return String(v)\n}\n\n/**\n * Build the Zod schema for a set of literal enum values.\n * `z.enum()` only accepts string members in Zod v4, so a numeric, boolean, or\n * mixed set is emitted as a single `z.literal(…)` or a `z.union([z.literal(…), …])`.\n * An all-string set keeps the more compact `z.enum([…])`.\n */\nexport function buildEnum(values: Array<string | number | boolean>): string {\n const allStrings = values.every((v) => typeof v === 'string')\n if (allStrings) return `z.enum([${values.map(formatLiteral).join(', ')}])`\n\n const literals = values.map((v) => `z.literal(${formatLiteral(v)})`)\n if (literals.length === 1) return literals[0]!\n\n return `z.union([${literals.join(', ')}])`\n}\n\n/**\n * Numeric constraint limits for Zod schemas (min, max, and exclusive bounds).\n */\nexport type NumericConstraints = {\n min?: number\n max?: number\n exclusiveMinimum?: number\n exclusiveMaximum?: number\n multipleOf?: number\n}\n\n/**\n * Length constraint limits for string and array schemas (min, max, and regex pattern).\n */\nexport type LengthConstraints = {\n min?: number\n max?: number\n pattern?: string\n /**\n * Output form for the `pattern` regex. `'literal'` emits a regex literal,\n * `'constructor'` emits `new RegExp(...)`.\n *\n * @default 'literal'\n */\n regexType?: PluginZod['resolvedOptions']['regexType']\n}\n\n/**\n * Map a `regexType` to the `func` argument of `toRegExpString`: `'constructor'` emits\n * `new RegExp(...)`, while `'literal'` (the default) emits a regex literal.\n */\nfunction regexFunc(regexType: PluginZod['resolvedOptions']['regexType'] | undefined): string | null {\n return regexType === 'constructor' ? 'RegExp' : null\n}\n\n/**\n * Builds a Zod record key schema that enforces the `patternProperties` regexes a plain\n * `.catchall()` would drop. Several patterns combine into one alternation (`(^a)|(^b)`).\n */\nexport function patternKeySchema({ patterns, regexType }: { patterns: Array<string>; regexType?: PluginZod['resolvedOptions']['regexType'] }): string {\n return `z.string().regex(${patternKeySource({ patterns, regexType })})`\n}\n\n/**\n * `zod/mini` variant of {@link patternKeySchema}, wrapping the regex in `.check(z.regex(...))`.\n */\nexport function patternKeySchemaMini({ patterns, regexType }: { patterns: Array<string>; regexType?: PluginZod['resolvedOptions']['regexType'] }): string {\n return `z.string().check(z.regex(${patternKeySource({ patterns, regexType })}))`\n}\n\nfunction patternKeySource({ patterns, regexType }: { patterns: Array<string>; regexType?: PluginZod['resolvedOptions']['regexType'] }): string {\n const source = patterns.length === 1 ? patterns[0]! : patterns.map((pattern) => `(${pattern})`).join('|')\n return ast.toRegExpString(source, regexFunc(regexType))\n}\n\n/**\n * Modifier options for applying chainable methods to Zod schema values.\n */\nexport type ModifierOptions = {\n value: string\n schema?: ast.SchemaNode\n nullable?: boolean\n optional?: boolean\n nullish?: boolean\n defaultValue?: unknown\n description?: string\n examples?: Array<unknown>\n}\n\n/**\n * Build `.min()` / `.max()` / `.gt()` / `.lt()` constraint chains for numbers\n * using the standard chainable Zod v4 API.\n */\nexport function numberConstraints({ min, max, exclusiveMinimum, exclusiveMaximum, multipleOf }: NumericConstraints): string {\n return [\n min !== undefined ? `.min(${min})` : '',\n max !== undefined ? `.max(${max})` : '',\n exclusiveMinimum !== undefined ? `.gt(${exclusiveMinimum})` : '',\n exclusiveMaximum !== undefined ? `.lt(${exclusiveMaximum})` : '',\n multipleOf !== undefined ? `.multipleOf(${multipleOf})` : '',\n ].join('')\n}\n\n/**\n * Build `.min()` / `.max()` / `.regex()` chains for strings/arrays\n * using the standard chainable Zod v4 API.\n */\nexport function lengthConstraints({ min, max, pattern, regexType }: LengthConstraints): string {\n return [\n min !== undefined ? `.min(${min})` : '',\n max !== undefined ? `.max(${max})` : '',\n pattern !== undefined ? `.regex(${ast.toRegExpString(pattern, regexFunc(regexType))})` : '',\n ].join('')\n}\n\n/**\n * Build `.check(z.minimum(), z.maximum())` for `zod/mini` numeric constraints.\n */\nexport function numberChecksMini({ min, max, exclusiveMinimum, exclusiveMaximum, multipleOf }: NumericConstraints): string {\n const checks: Array<string> = []\n if (min !== undefined) checks.push(`z.minimum(${min})`)\n if (max !== undefined) checks.push(`z.maximum(${max})`)\n if (exclusiveMinimum !== undefined) checks.push(`z.minimum(${exclusiveMinimum}, { exclusive: true })`)\n if (exclusiveMaximum !== undefined) checks.push(`z.maximum(${exclusiveMaximum}, { exclusive: true })`)\n if (multipleOf !== undefined) checks.push(`z.multipleOf(${multipleOf})`)\n return checks.length ? `.check(${checks.join(', ')})` : ''\n}\n\n/**\n * Build `.check(z.minLength(), z.maxLength(), z.regex())` for `zod/mini` length constraints.\n */\nexport function lengthChecksMini({ min, max, pattern, regexType }: LengthConstraints): string {\n const checks: Array<string> = []\n if (min !== undefined) checks.push(`z.minLength(${min})`)\n if (max !== undefined) checks.push(`z.maxLength(${max})`)\n if (pattern !== undefined) checks.push(`z.regex(${ast.toRegExpString(pattern, regexFunc(regexType))})`)\n return checks.length ? `.check(${checks.join(', ')})` : ''\n}\n\n/**\n * Apply nullable / optional / nullish modifiers, an optional `.describe()` call, and an\n * optional `.meta({ examples })` call to a schema value string using the chainable Zod v4 API.\n */\nexport function applyModifiers({ value, schema, nullable, optional, nullish, defaultValue, description, examples }: ModifierOptions): string {\n const withModifier = (() => {\n if (nullish || (nullable && optional)) return `${value}.nullish()`\n if (optional) return `${value}.optional()`\n if (nullable) return `${value}.nullable()`\n return value\n })()\n const literal = defaultValue !== undefined ? defaultLiteral(schema, defaultValue) : null\n const withDefault = literal !== null ? `${withModifier}.default(${literal})` : withModifier\n const withDescription = description ? `${withDefault}.describe(${ast.stringify(description)})` : withDefault\n return examples?.length ? `${withDescription}.meta({ examples: [${examples.map(formatDefault).join(', ')}] })` : withDescription\n}\n\nfunction modifierDepth(schema: ast.SchemaNode): number {\n if (schema.nullish || (schema.nullable && schema.optional)) return 2\n if (schema.nullable || schema.optional) return 1\n return 0\n}\n\n/**\n * Build the `.unwrap()` chain to insert before `.omit()` when the schema is a `$ref`.\n *\n * A `$ref` resolves to a named schema variable that already carries its own `.nullable()` /\n * `.optional()` / `.nullish()` / `.default()` wrappers. `.omit()` lives on the inner `ZodObject`,\n * not on those `ZodNullable` / `ZodOptional` / `ZodDefault` wrappers, so the omit has to unwrap\n * down to the object first. This mirrors plugin-ts emitting `Omit<NonNullable<T>, …>`. Inline\n * objects need no unwrap because the printer adds their modifiers after `.omit()`.\n */\nexport function omitUnwrapChain(node: ast.SchemaNode): string {\n const ref = ast.narrowSchema(node, 'ref')\n if (!ref) return ''\n\n const target = ref.schema ?? ref\n const depth = modifierDepth(target) + (target.default !== undefined ? 1 : 0)\n return '.unwrap()'.repeat(depth)\n}\n\n/**\n * Apply nullable / optional / nullish modifiers using the functional `zod/mini` API\n * (`z.nullable()`, `z.optional()`, `z.nullish()`).\n */\nexport function applyMiniModifiers({ value, schema, nullable, optional, nullish, defaultValue }: Omit<ModifierOptions, 'description'>): string {\n const withModifier = (() => {\n if (nullish) return `z.nullish(${value})`\n const withNullable = nullable ? `z.nullable(${value})` : value\n return optional ? `z.optional(${withNullable})` : withNullable\n })()\n const literal = defaultValue !== undefined ? defaultLiteral(schema, defaultValue) : null\n return literal !== null ? `z._default(${withModifier}, ${literal})` : withModifier\n}\n\ntype BuildGroupedParamsSchemaOptions = {\n params: Array<ast.ParameterNode>\n optional?: boolean\n}\n\n/**\n * Builds an `object` schema node grouping the given parameter nodes.\n * The `primitive: 'object'` marker ensures the Zod printer emits `z.object(…)` rather than a record.\n */\nexport function buildGroupedParamsSchema({ params, optional }: BuildGroupedParamsSchemaOptions): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n optional,\n primitive: 'object',\n properties: params.map((param) =>\n ast.factory.createProperty({\n name: param.name,\n required: param.required,\n schema: param.schema,\n }),\n ),\n })\n}\n","import { ast } from 'kubb/kit'\nimport type { PluginZod, ResolverZod } from '../types.ts'\nimport {\n applyModifiers,\n buildEnum,\n containsCodec,\n formatLiteral,\n getCodec,\n isObjectComposableIntersection,\n isObjectSchemaNode,\n lengthConstraints,\n numberConstraints,\n omitUnwrapChain,\n patternKeySchema,\n shouldCoerce,\n} from '../utils.ts'\nimport type { AdapterOas } from '@kubb/adapter-oas'\n\n/**\n * Partial map of node-type overrides for the Zod 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, `this.base` to reuse the output of the\n * handler being replaced, and `this.options` to read printer options.\n *\n * @example Override the `date` handler\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * date(node) {\n * return 'z.iso.date()'\n * },\n * },\n * },\n * })\n * ```\n *\n * @example Wrap the built-in output\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * object(node) {\n * return `${this.base(node)}.openapi(${JSON.stringify({ description: node.description })})`\n * },\n * },\n * },\n * })\n * ```\n */\nexport type PrinterZodNodes = ast.PrinterPartial<string, PrinterZodOptions>\n\nexport type PrinterZodOptions = {\n /**\n * Enable automatic type coercion for strings, numbers, and dates.\n */\n coercion?: PluginZod['resolvedOptions']['coercion']\n /**\n * Use `z.guid()` or `z.uuid()` for UUID/GUID validation.\n *\n * @default 'uuid'\n */\n guidType?: PluginZod['resolvedOptions']['guidType']\n /**\n * Output form for an OpenAPI `pattern` inside `.regex(...)`: a regex literal\n * (`'literal'`) or the `RegExp` constructor (`'constructor'`).\n *\n * @default 'literal'\n */\n regexType?: PluginZod['resolvedOptions']['regexType']\n /**\n * Date format in the OpenAPI spec (`'date'` or `'date-time'`).\n */\n dateType?: AdapterOas['resolvedOptions']['dateType']\n /**\n * Transforms raw schema names into valid JavaScript identifiers.\n */\n resolver?: ResolverZod\n /**\n * Properties to exclude using `.omit({ key: true })`.\n */\n keysToOmit?: Array<string> | null\n /**\n * Schema names that form circular dependency chains.\n * Properties referencing these emit lazy getters wrapping refs in `z.lazy(() => …)`.\n */\n cyclicSchemas?: ReadonlySet<string>\n /**\n * Print direction for `dateType: 'date'` fields (`Date` in TypeScript):\n * - `'output'` (default): decode the wire `string` into a `Date` (response bodies).\n * - `'input'`: encode a `Date` back into the wire `string` (request bodies/params).\n *\n * Diverging the directions requires the generator to emit an `${name}InputSchema`\n * variant for each date-bearing component.\n */\n direction?: 'input' | 'output'\n /**\n * Maps a component `$ref` path to its collision-resolved name. When two components collide\n * (across sections or by case), the adapter renames one of them; the `ref()` handler resolves\n * the referenced name through this map so the emitted schema reference matches the renamed component.\n */\n nameMapping?: ReadonlyMap<string, string>\n /**\n * Custom handler map for node type overrides.\n */\n nodes?: PrinterZodNodes\n}\n\n/**\n * Factory options for the Zod printer, defining input/output types and configuration.\n */\nexport type PrinterZodFactory = ast.PrinterFactoryOptions<'zod', PrinterZodOptions, string, string>\n\nfunction strictOneOfMember(member: string, node: ast.SchemaNode, cyclicSchemas?: ReadonlySet<string>): string {\n if (node.type === 'object' && node.additionalProperties === undefined) {\n return `${member}.strict()`\n }\n\n if (node.type === 'ref') {\n if (member.startsWith('z.lazy(')) {\n return member\n }\n\n // A cyclic ref is annotated `z.ZodType`, and a nullable/optional ref is wrapped in\n // ZodNullable/ZodOptional, and neither exposes `.strict()`. Only a bare `ZodObject` ref takes it.\n // A union member ref may carry only `node.name` (no `node.ref`), so fall back to it like `ref()`.\n const refName = (node.ref ? ast.extractRefName(node.ref) : undefined) ?? node.name\n if (refName && cyclicSchemas?.has(refName)) {\n return member\n }\n\n const schema = ast.syncSchemaRef(node)\n\n if (schema.nullable || schema.optional || node.nullable || node.optional) {\n return member\n }\n\n if (schema.type === 'object' && (schema.additionalProperties === undefined || schema.additionalProperties === false)) {\n return `${member}.strict()`\n }\n }\n\n return member\n}\n\nfunction getMemberConstraint({ member, regexType }: { member: ast.SchemaNode; regexType: PrinterZodOptions['regexType'] }): string | undefined {\n if (member.primitive === 'string') return lengthConstraints({ ...(ast.narrowSchema(member, 'string') ?? {}), regexType }) || undefined\n if (member.primitive === 'number' || member.primitive === 'integer')\n return numberConstraints(ast.narrowSchema(member, 'number') ?? ast.narrowSchema(member, 'integer') ?? {}) || undefined\n if (member.primitive === 'array') return lengthConstraints({ ...(ast.narrowSchema(member, 'array') ?? {}), regexType }) || undefined\n}\n\n/**\n * The printer slice `buildZodObjectShape` needs: the recursive `transform` and the resolved options.\n */\ntype ZodPrinterContext = {\n transform: (node: ast.SchemaNode) => string | null\n options: PrinterZodOptions\n}\n\n/**\n * Builds the `{ key: value, … }` shape for an object node, shared by the `z.object(...)` and\n * `.extend(...)` renderings so they stay in lockstep.\n */\nfunction buildZodObjectShape(ctx: ZodPrinterContext, node: ast.SchemaNode): string {\n const objectNode = ast.narrowSchema(node, 'object')\n if (!objectNode) return '{}'\n\n const isCyclic = (schema: ast.SchemaNode): boolean =>\n ctx.options.cyclicSchemas != null && ast.containsCircularRef(schema, { circularSchemas: ctx.options.cyclicSchemas })\n\n const entries = ast\n .mapSchemaProperties(objectNode, (schema) => {\n // Inside a getter the getter itself defers evaluation, so suppress z.lazy() wrapping on\n // nested refs by temporarily clearing cyclicSchemas.\n const hasSelfRef = isCyclic(schema)\n const savedCyclicSchemas = ctx.options.cyclicSchemas\n if (hasSelfRef) ctx.options.cyclicSchemas = undefined\n const baseOutput = ctx.transform(schema) ?? ctx.transform(ast.factory.createSchema({ type: 'unknown' }))!\n if (hasSelfRef) ctx.options.cyclicSchemas = savedCyclicSchemas\n return baseOutput\n })\n .map(({ name: propName, property, output: baseOutput }) => {\n const { schema } = property\n const meta = ast.syncSchemaRef(schema)\n\n // When a property schema is not a ref but the metadata is from a ref (e.g., discriminator\n // property override), skip applying the description from the ref target to avoid applying\n // metadata from a replaced schema.\n const descriptionToApply = schema.type !== 'ref' && meta.type === 'ref' ? undefined : meta.description\n\n const value = applyModifiers({\n value: baseOutput,\n schema,\n nullable: meta.nullable,\n optional: schema.optional || property.required === false,\n nullish: schema.nullish,\n defaultValue: meta.default,\n description: descriptionToApply,\n examples: meta.examples,\n })\n\n return isCyclic(schema) ? ast.lazyGetter({ name: propName, body: value }) : `${ast.objectKey(propName)}: ${value}`\n })\n\n return ast.buildObject(entries)\n}\n\n/**\n * Zod v4 printer built with `definePrinter`.\n *\n * Converts a `SchemaNode` AST into a Zod v4 code string using the chainable API\n * (`.optional()`, `.nullable()`, `.omit()`, etc.). For improved tree-shaking, see {@link printerZodMini}.\n *\n * @example Chainable API\n * ```ts\n * const printer = printerZod({ coercion: false })\n * const code = printer.print(stringNode) // \"z.string()\"\n * ```\n */\nexport const printerZod = ast.createPrinter<PrinterZodFactory>((options) => {\n // The object handler temporarily reassigns `options.cyclicSchemas` to `undefined` while rendering a\n // getter body (to suppress nested `z.lazy()`), so capture a stable reference for the `.strict()`\n // skip decision, which must still see cyclic members inside those getter bodies.\n const cyclicSchemaNames = options.cyclicSchemas\n return {\n name: 'zod',\n options,\n nodes: {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n never: () => 'z.never()',\n boolean: () => 'z.boolean()',\n null: () => 'z.null()',\n string(node) {\n const base = shouldCoerce(this.options.coercion, 'strings') ? 'z.coerce.string()' : 'z.string()'\n\n return `${base}${lengthConstraints({ ...node, regexType: this.options.regexType })}`\n },\n number(node) {\n const base = shouldCoerce(this.options.coercion, 'numbers') ? 'z.coerce.number()' : 'z.number()'\n\n return `${base}${numberConstraints(node)}`\n },\n integer(node) {\n const base = shouldCoerce(this.options.coercion, 'numbers') ? 'z.coerce.number().int()' : 'z.int()'\n\n return `${base}${numberConstraints(node)}`\n },\n bigint() {\n return shouldCoerce(this.options.coercion, 'numbers') ? 'z.coerce.bigint()' : 'z.bigint()'\n },\n date(node) {\n // representation: 'date' fields are typed as `Date`, so decode/encode at the boundary.\n const codec = getCodec(node)\n if (codec) {\n if (this.options.direction === 'input') return codec.encode(node)\n return shouldCoerce(this.options.coercion, 'dates') ? 'z.coerce.date()' : codec.decode(node)\n }\n\n return 'z.iso.date()'\n },\n datetime(node) {\n const offset = node.offset || this.options.dateType === 'stringOffset'\n const local = node.local || this.options.dateType === 'stringLocal'\n\n if (offset) return 'z.iso.datetime({ offset: true })'\n if (local) return 'z.iso.datetime({ local: true })'\n\n return 'z.iso.datetime()'\n },\n time(node) {\n if (node.representation === 'string') {\n return 'z.iso.time()'\n }\n\n return shouldCoerce(this.options.coercion, 'dates') ? 'z.coerce.date()' : 'z.date()'\n },\n uuid(node) {\n const base = this.options.guidType === 'guid' ? 'z.guid()' : 'z.uuid()'\n\n return `${base}${lengthConstraints({ ...node, regexType: this.options.regexType })}`\n },\n email(node) {\n return `z.email()${lengthConstraints({ ...node, regexType: this.options.regexType })}`\n },\n url(node) {\n return `z.url()${lengthConstraints({ ...node, regexType: this.options.regexType })}`\n },\n ipv4: () => 'z.ipv4()',\n ipv6: () => 'z.ipv6()',\n blob: () => 'z.instanceof(File)',\n enum(node) {\n const values = node.namedEnumValues?.map((v) => v.value) ?? node.enumValues ?? []\n const nonNullValues = values.filter((v): v is string | number | boolean => v !== null)\n\n // asConst-style enum: use z.union([z.literal(…), …])\n if (node.namedEnumValues?.length) {\n const literals = nonNullValues.map((v) => `z.literal(${formatLiteral(v)})`)\n\n if (literals.length === 1) return literals[0]!\n return `z.union([${literals.join(', ')}])`\n }\n\n // Regular enum: z.enum for all-string sets, z.literal/z.union otherwise\n return buildEnum(nonNullValues)\n },\n ref(node) {\n if (!node.name) return null\n // `nameMapping` (keyed by the full $ref) carries the collision-resolved name when the\n // referenced component was renamed; otherwise fall back to the short ref name.\n const refName = node.ref ? (this.options.nameMapping?.get(node.ref) ?? ast.extractRefName(node.ref) ?? node.name) : node.name\n\n // In the input direction, a date-bearing component resolves to its `${name}InputSchema`\n // variant so request bodies encode `Date → string` instead of decoding.\n const useInputVariant = node.ref != null && this.options.direction === 'input' && containsCodec(node)\n const resolvedName = node.ref\n ? useInputVariant\n ? (this.options.resolver?.resolveInputSchemaName(refName) ?? refName)\n : (this.options.resolver?.default(refName, 'function') ?? refName)\n : node.name\n\n if (node.ref && this.options.cyclicSchemas?.has(refName)) {\n return `z.lazy(() => ${resolvedName})`\n }\n\n return resolvedName\n },\n object(node) {\n const entries = node.properties ?? []\n const objectBase = `z.object(${buildZodObjectShape(this, node)})`\n\n const result = (() => {\n const patterns = node.patternProperties ? Object.entries(node.patternProperties) : []\n\n if (node.additionalProperties && node.additionalProperties !== true) {\n const catchallType = this.transform(node.additionalProperties)\n return catchallType ? `${objectBase}.catchall(${catchallType})` : objectBase\n }\n if (node.additionalProperties === true) return `${objectBase}.catchall(${this.transform(ast.factory.createSchema({ type: 'unknown' }))})`\n // `additionalProperties: false` still permits patternProperties keys, so skip `.strict()` when patterns exist.\n if (node.additionalProperties === false && patterns.length === 0) return `${objectBase}.strict()`\n\n // No fixed properties: z.record enforces the key pattern. With fixed properties a record would\n // reject the declared keys, so fall back to .catchall (value validated, key pattern not).\n if (patterns.length > 0) {\n const values = patterns.map(([, valueSchema]) => {\n const valueType = this.transform(valueSchema) ?? this.transform(ast.factory.createSchema({ type: 'unknown' }))!\n return valueSchema.nullable ? `${valueType}.nullable()` : valueType\n })\n const distinct = [...new Set(values)]\n const value = distinct.length === 1 ? distinct[0]! : `z.union([${distinct.join(', ')}])`\n\n if (entries.length > 0) return `${objectBase}.catchall(${value})`\n return `z.record(${patternKeySchema({ patterns: patterns.map(([pattern]) => pattern), regexType: this.options.regexType })}, ${value})`\n }\n return objectBase\n })()\n\n return result\n },\n array(node) {\n const items = ast\n .mapSchemaItems(node, (item) => this.transform(item))\n .map(({ output }) => output)\n .filter(Boolean)\n const inner = items.join(', ') || this.transform(ast.factory.createSchema({ type: 'unknown' }))!\n const base = `z.array(${inner})${lengthConstraints({ ...node, regexType: this.options.regexType })}`\n\n return node.unique ? `${base}.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : base\n },\n tuple(node) {\n const items = ast\n .mapSchemaItems(node, (item) => this.transform(item))\n .map(({ output }) => output)\n .filter(Boolean)\n\n return `z.tuple(${ast.buildList(items)})`\n },\n union(node) {\n const nodeMembers = node.members ?? []\n const members = ast\n .mapSchemaMembers(node, (memberNode) => this.transform(memberNode))\n .map(({ schema, output }) => (output && node.strategy === 'one' ? strictOneOfMember(output, schema, cyclicSchemaNames) : output))\n .filter(Boolean)\n if (members.length === 0) return ''\n if (members.length === 1) return members[0]!\n // z.discriminatedUnion needs every option to be a ZodObject. Object variants (refs or\n // `.extend(…)`-composed `allOf`) qualify; intersections, cyclic `z.lazy(…)` refs, and\n // non-objects fall back to z.union.\n const allDiscriminable = nodeMembers.every((m) => isObjectSchemaNode(m, cyclicSchemaNames))\n if (node.discriminatorPropertyName && allDiscriminable) {\n return `z.discriminatedUnion(${ast.stringify(node.discriminatorPropertyName)}, ${ast.buildList(members)})`\n }\n\n return `z.union(${ast.buildList(members)})`\n },\n intersection(node) {\n const members = node.members ?? []\n if (members.length === 0) return ''\n\n const [first, ...rest] = members\n if (!first) return ''\n\n const firstBase = this.transform(first)\n if (!firstBase) return ''\n\n // An object `allOf` is a merge, not a runtime intersection: `.extend({ … })` keeps it a\n // ZodObject (usable in z.discriminatedUnion) instead of the non-discriminable `.and(…)`.\n if (rest.length > 0 && isObjectComposableIntersection(node, cyclicSchemaNames)) {\n return rest.reduce((acc, member) => `${acc}.extend(${buildZodObjectShape(this, member)})`, firstBase)\n }\n\n return rest.reduce((acc, member) => {\n const constraint = getMemberConstraint({ member, regexType: this.options.regexType })\n if (constraint) return acc + constraint\n const transformed = this.transform(member)\n return transformed ? `${acc}.and(${transformed})` : acc\n }, firstBase)\n },\n },\n overrides: options.nodes,\n print(node) {\n const { keysToOmit } = this.options\n\n const transformed = this.transform(node)\n if (!transformed) return null\n\n const meta = ast.syncSchemaRef(node)\n\n const base = (() => {\n if (!keysToOmit?.length || meta.primitive !== 'object' || (meta.type === 'union' && meta.discriminatorPropertyName)) return transformed\n // Discriminated unions (z.discriminatedUnion) do not support .omit(), so skip them.\n\n // A nullable/optional ref resolves to a ZodNullable/ZodOptional variable; .omit() lives on\n // the inner ZodObject, so unwrap down to it first (mirrors printerTs `Omit<NonNullable<T>, …>`).\n // applyModifiers re-applies the nullable/optional wrapper after the omit.\n const unwrap = omitUnwrapChain(node)\n const omit = `.omit({ ${keysToOmit.map((k: string) => `\"${k}\": true`).join(', ')} })`\n\n // If this is a lazy reference, apply omit inside the lazy function\n const lazyMatch = transformed.match(/^z\\.lazy\\(\\(\\)\\s*=>\\s*(.+)\\)$/)\n if (lazyMatch) return `z.lazy(() => ${lazyMatch[1]}${unwrap}${omit})`\n return `${transformed}${unwrap}${omit}`\n })()\n\n return applyModifiers({\n value: base,\n schema: node,\n nullable: meta.nullable,\n optional: meta.optional,\n nullish: meta.nullish,\n defaultValue: meta.default,\n description: meta.description,\n examples: meta.examples,\n })\n },\n }\n})\n","import { ast } from 'kubb/kit'\nimport type { PluginZod, ResolverZod } from '../types.ts'\nimport {\n applyMiniModifiers,\n buildEnum,\n formatLiteral,\n isObjectComposableIntersection,\n isObjectSchemaNode,\n lengthChecksMini,\n numberChecksMini,\n omitUnwrapChain,\n patternKeySchemaMini,\n} from '../utils.ts'\n\n/**\n * Partial map of node-type overrides for the Zod Mini 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, `this.base` to reuse the output of the\n * handler being replaced, and `this.options` to read printer options.\n *\n * @example Override the `date` handler\n * ```ts\n * pluginZod({\n * mini: true,\n * printer: {\n * nodes: {\n * date(node) {\n * return 'z.iso.date()'\n * },\n * },\n * },\n * })\n * ```\n */\nexport type PrinterZodMiniNodes = ast.PrinterPartial<string, PrinterZodMiniOptions>\n\nexport type PrinterZodMiniOptions = {\n /**\n * Use `z.guid()` or `z.uuid()` for UUID/GUID validation.\n *\n * @default 'uuid'\n */\n guidType?: PluginZod['resolvedOptions']['guidType']\n /**\n * Output form for an OpenAPI `pattern` inside `z.regex(...)`: a regex literal\n * (`'literal'`) or the `RegExp` constructor (`'constructor'`).\n *\n * @default 'literal'\n */\n regexType?: PluginZod['resolvedOptions']['regexType']\n /**\n * Transforms raw schema names into valid JavaScript identifiers.\n */\n resolver?: ResolverZod\n /**\n * Properties to exclude using `.omit({ key: true })`.\n */\n keysToOmit?: Array<string> | null\n /**\n * Schema names that form circular dependency chains.\n * Properties referencing these emit lazy getters wrapping refs in `z.lazy(() => …)`.\n */\n cyclicSchemas?: ReadonlySet<string>\n /**\n * Maps a component `$ref` path to its collision-resolved name. When two components collide\n * (across sections or by case), the adapter renames one of them; the `ref()` handler resolves\n * the referenced name through this map so the emitted schema reference matches the renamed component.\n */\n nameMapping?: ReadonlyMap<string, string>\n /**\n * Custom handler map for node type overrides.\n */\n nodes?: PrinterZodMiniNodes\n}\n\n/**\n * Factory options for the Zod Mini printer, defining input/output types and configuration.\n */\nexport type PrinterZodMiniFactory = ast.PrinterFactoryOptions<'zod-mini', PrinterZodMiniOptions, string, string>\n\nfunction strictOneOfMember(member: string, node: ast.SchemaNode): string {\n if (node.type === 'object' && (node.additionalProperties === undefined || node.additionalProperties === false)) {\n return member.replace(/^z\\.object\\(/, 'z.strictObject(')\n }\n\n return member\n}\n\nfunction getMemberConstraintMini({ member, regexType }: { member: ast.SchemaNode; regexType: PrinterZodMiniOptions['regexType'] }): string | undefined {\n if (member.primitive === 'string') return lengthChecksMini({ ...(ast.narrowSchema(member, 'string') ?? {}), regexType }) || undefined\n if (member.primitive === 'number' || member.primitive === 'integer')\n return numberChecksMini(ast.narrowSchema(member, 'number') ?? ast.narrowSchema(member, 'integer') ?? {}) || undefined\n if (member.primitive === 'array') return lengthChecksMini({ ...(ast.narrowSchema(member, 'array') ?? {}), regexType }) || undefined\n}\n\n/**\n * The Mini printer slice `buildZodMiniObjectShape` needs: the recursive `transform` and the options.\n */\ntype ZodMiniPrinterContext = {\n transform: (node: ast.SchemaNode) => string | null\n options: PrinterZodMiniOptions\n}\n\n/**\n * Builds the `{ key: value, … }` shape for an object node with the functional `zod/mini` modifiers,\n * shared by the `z.object(...)` and `z.extend(...)` renderings so they stay in lockstep.\n */\nfunction buildZodMiniObjectShape(ctx: ZodMiniPrinterContext, node: ast.SchemaNode): string {\n const objectNode = ast.narrowSchema(node, 'object')\n if (!objectNode) return '{}'\n\n const isCyclic = (schema: ast.SchemaNode): boolean =>\n ctx.options.cyclicSchemas != null && ast.containsCircularRef(schema, { circularSchemas: ctx.options.cyclicSchemas })\n\n const entries = ast\n .mapSchemaProperties(objectNode, (schema) => {\n const hasSelfRef = isCyclic(schema)\n const savedCyclicSchemas = ctx.options.cyclicSchemas\n if (hasSelfRef) ctx.options.cyclicSchemas = undefined\n const baseOutput = ctx.transform(schema) ?? ctx.transform(ast.factory.createSchema({ type: 'unknown' }))!\n if (hasSelfRef) ctx.options.cyclicSchemas = savedCyclicSchemas\n return baseOutput\n })\n .map(({ name: propName, property, output: baseOutput }) => {\n const { schema } = property\n const meta = ast.syncSchemaRef(schema)\n\n const value = applyMiniModifiers({\n value: baseOutput,\n schema,\n nullable: meta.nullable,\n optional: schema.optional || property.required === false,\n nullish: schema.nullish,\n defaultValue: meta.default,\n })\n\n return isCyclic(schema) ? ast.lazyGetter({ name: propName, body: value }) : `${ast.objectKey(propName)}: ${value}`\n })\n\n return ast.buildObject(entries)\n}\n\n/**\n * Zod v4 Mini printer built with `definePrinter`.\n *\n * Converts a `SchemaNode` AST into a Zod v4 code string using the functional API\n * (`z.optional(z.string())`) for improved tree-shaking. See {@link printerZod} for the chainable API.\n *\n * @example Functional Mini API\n * ```ts\n * const printer = printerZodMini({})\n * const code = printer.print(optionalStringNode) // \"z.optional(z.string())\"\n * ```\n */\nexport const printerZodMini = ast.createPrinter<PrinterZodMiniFactory>((options) => {\n // The object handler temporarily clears `options.cyclicSchemas` while rendering a getter body, so\n // capture a stable reference for the intersection/union discriminability decisions.\n const cyclicSchemaNames = options.cyclicSchemas\n return {\n name: 'zod-mini',\n options,\n nodes: {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n never: () => 'z.never()',\n boolean: () => 'z.boolean()',\n null: () => 'z.null()',\n string(node) {\n return `z.string()${lengthChecksMini({ ...node, regexType: this.options.regexType })}`\n },\n number(node) {\n return `z.number()${numberChecksMini(node)}`\n },\n integer(node) {\n return `z.int()${numberChecksMini(node)}`\n },\n bigint(node) {\n return `z.bigint()${numberChecksMini(node)}`\n },\n date(node) {\n if (node.representation === 'string') {\n return 'z.iso.date()'\n }\n\n return 'z.date()'\n },\n datetime() {\n // Mini mode: datetime validation via z.string() (z.iso.datetime not available in mini)\n return 'z.string()'\n },\n time(node) {\n if (node.representation === 'string') {\n return 'z.iso.time()'\n }\n\n return 'z.date()'\n },\n uuid(node) {\n const base = this.options.guidType === 'guid' ? 'z.guid()' : 'z.uuid()'\n\n return `${base}${lengthChecksMini({ ...node, regexType: this.options.regexType })}`\n },\n email(node) {\n return `z.email()${lengthChecksMini({ ...node, regexType: this.options.regexType })}`\n },\n url(node) {\n return `z.url()${lengthChecksMini({ ...node, regexType: this.options.regexType })}`\n },\n ipv4: () => 'z.ipv4()',\n ipv6: () => 'z.ipv6()',\n blob: () => 'z.instanceof(File)',\n enum(node) {\n const values = node.namedEnumValues?.map((v) => v.value) ?? node.enumValues ?? []\n const nonNullValues = values.filter((v): v is string | number | boolean => v !== null)\n\n // asConst-style enum: use z.union([z.literal(…), …])\n if (node.namedEnumValues?.length) {\n const literals = nonNullValues.map((v) => `z.literal(${formatLiteral(v)})`)\n if (literals.length === 1) return literals[0]!\n return `z.union([${literals.join(', ')}])`\n }\n\n // Regular enum: z.enum for all-string sets, z.literal/z.union otherwise\n return buildEnum(nonNullValues)\n },\n\n ref(node) {\n if (!node.name) return null\n // `nameMapping` (keyed by the full $ref) carries the collision-resolved name when the\n // referenced component was renamed; otherwise fall back to the short ref name.\n const refName = node.ref ? (this.options.nameMapping?.get(node.ref) ?? ast.extractRefName(node.ref) ?? node.name) : node.name\n const resolvedName = node.ref ? (this.options.resolver?.default(refName, 'function') ?? refName) : node.name\n\n if (node.ref && this.options.cyclicSchemas?.has(refName)) {\n return `z.lazy(() => ${resolvedName})`\n }\n\n return resolvedName\n },\n object(node) {\n const entries = node.properties ?? []\n const objectBase = `z.object(${buildZodMiniObjectShape(this, node)})`\n\n // zod/mini has no chainable `.catchall()`/`.strict()`, so route through the functional forms.\n const patterns = node.patternProperties ? Object.entries(node.patternProperties) : []\n\n if (node.additionalProperties && node.additionalProperties !== true) {\n const catchallType = this.transform(node.additionalProperties)\n return catchallType ? `z.catchall(${objectBase}, ${catchallType})` : objectBase\n }\n if (node.additionalProperties === true) return `z.catchall(${objectBase}, ${this.transform(ast.factory.createSchema({ type: 'unknown' }))})`\n if (node.additionalProperties === false && patterns.length === 0) return objectBase.replace(/^z\\.object\\(/, 'z.strictObject(')\n\n if (patterns.length > 0) {\n const values = patterns.map(([, valueSchema]) => {\n const valueType = this.transform(valueSchema) ?? this.transform(ast.factory.createSchema({ type: 'unknown' }))!\n return valueSchema.nullable ? `z.nullable(${valueType})` : valueType\n })\n const distinct = [...new Set(values)]\n const value = distinct.length === 1 ? distinct[0]! : `z.union([${distinct.join(', ')}])`\n\n if (entries.length > 0) return `z.catchall(${objectBase}, ${value})`\n return `z.record(${patternKeySchemaMini({ patterns: patterns.map(([pattern]) => pattern), regexType: this.options.regexType })}, ${value})`\n }\n return objectBase\n },\n array(node) {\n const items = ast\n .mapSchemaItems(node, (item) => this.transform(item))\n .map(({ output }) => output)\n .filter(Boolean)\n const inner = items.join(', ') || this.transform(ast.factory.createSchema({ type: 'unknown' }))!\n const base = `z.array(${inner})${lengthChecksMini({ ...node, regexType: this.options.regexType })}`\n\n return node.unique ? `${base}.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : base\n },\n tuple(node) {\n const items = ast\n .mapSchemaItems(node, (item) => this.transform(item))\n .map(({ output }) => output)\n .filter(Boolean)\n\n return `z.tuple(${ast.buildList(items)})`\n },\n union(node) {\n const nodeMembers = node.members ?? []\n const members = ast\n .mapSchemaMembers(node, (memberNode) => this.transform(memberNode))\n .map(({ schema, output }) => (output && node.strategy === 'one' ? strictOneOfMember(output, schema) : output))\n .filter(Boolean)\n if (members.length === 0) return ''\n if (members.length === 1) return members[0]!\n // z.discriminatedUnion needs every option to be a Zod object. Object variants (refs or\n // `z.extend(…)`-composed `allOf`) qualify; intersections, cyclic `z.lazy(…)` refs, and\n // non-objects fall back to z.union.\n const allDiscriminable = nodeMembers.every((m) => isObjectSchemaNode(m, cyclicSchemaNames))\n if (node.discriminatorPropertyName && allDiscriminable) {\n return `z.discriminatedUnion(${ast.stringify(node.discriminatorPropertyName)}, ${ast.buildList(members)})`\n }\n\n return `z.union(${ast.buildList(members)})`\n },\n intersection(node) {\n const members = node.members ?? []\n if (members.length === 0) return ''\n\n const [first, ...rest] = members\n if (!first) return ''\n\n const firstBase = this.transform(first)\n if (!firstBase) return ''\n\n // An object `allOf` is a merge, not a runtime intersection: `z.extend(base, { … })` keeps it\n // a Zod object (usable in z.discriminatedUnion) instead of a non-discriminable `z.intersection`.\n if (rest.length > 0 && isObjectComposableIntersection(node, cyclicSchemaNames)) {\n return rest.reduce((acc, member) => `z.extend(${acc}, ${buildZodMiniObjectShape(this, member)})`, firstBase)\n }\n\n return rest.reduce((acc, member) => {\n const constraint = getMemberConstraintMini({ member, regexType: this.options.regexType })\n if (constraint) return acc + constraint\n const transformed = this.transform(member)\n return transformed ? `z.intersection(${acc}, ${transformed})` : acc\n }, firstBase)\n },\n },\n overrides: options.nodes,\n print(node) {\n const { keysToOmit } = this.options\n\n const transformed = this.transform(node)\n if (!transformed) return null\n\n const meta = ast.syncSchemaRef(node)\n\n const base = (() => {\n if (!keysToOmit?.length || meta.primitive !== 'object' || (meta.type === 'union' && meta.discriminatorPropertyName)) return transformed\n // Discriminated unions (z.discriminatedUnion) do not support .omit(), so skip them.\n\n // A nullable/optional ref resolves to a ZodMiniNullable/ZodMiniOptional variable; .omit() lives\n // on the inner object, so unwrap down to it first (mirrors printerTs `Omit<NonNullable<T>, …>`).\n // applyMiniModifiers re-applies the nullable/optional wrapper after the omit.\n const unwrap = omitUnwrapChain(node)\n const omit = `.omit({ ${keysToOmit.map((k: string) => `\"${k}\": true`).join(', ')} })`\n\n // If this is a lazy reference, apply omit inside the lazy function\n const lazyMatch = transformed.match(/^z\\.lazy\\(\\(\\)\\s*=>\\s*(.+)\\)$/)\n if (lazyMatch) return `z.lazy(() => ${lazyMatch[1]}${unwrap}${omit})`\n return `${transformed}${unwrap}${omit}`\n })()\n\n return applyMiniModifiers({\n value: base,\n schema: node,\n nullable: meta.nullable,\n optional: meta.optional,\n nullish: meta.nullish,\n defaultValue: meta.default,\n })\n },\n }\n})\n","import { caseParams, getSuccessResponses, isSuccessStatusCode, resolveContentTypeVariants } from '@internals/shared'\nimport type { Adapter } from 'kubb/kit'\nimport { ast, defineGenerator } from 'kubb/kit'\nimport type { AdapterOas } from '@kubb/adapter-oas'\nimport { File, jsxRenderer } from 'kubb/jsx'\nimport { Zod } from '../components/Zod.tsx'\nimport { ZOD_NAMESPACE_IMPORTS } from '../constants.ts'\nimport { printerZod } from '../printers/printerZod.ts'\nimport { printerZodMini } from '../printers/printerZodMini.ts'\nimport type { PluginZod, ResolverZod } from '../types'\nimport { collectCodecRefNames, containsCodec } from '../utils.ts'\n\ntype StdPrinters = { output: ReturnType<typeof printerZod>; input: ReturnType<typeof printerZod> }\ntype ZodPrinterEntry = StdPrinters & { coercion: unknown; guidType: unknown; regexType: unknown; dateType: unknown; nodes: unknown }\ntype ZodMiniPrinterEntry = { printer: ReturnType<typeof printerZodMini>; guidType: unknown; regexType: unknown; nodes: unknown }\n\n// Per-build caches: keyed on resolver (unique per plugin instance per build, GC'd when released)\nconst zodPrinterCache = new WeakMap<ResolverZod, ZodPrinterEntry>()\nconst zodMiniPrinterCache = new WeakMap<ResolverZod, ZodMiniPrinterEntry>()\n\ntype StdPrinterParams = {\n coercion: unknown\n guidType: unknown\n regexType: unknown\n dateType: unknown\n cyclicSchemas: ReadonlySet<string>\n nameMapping?: ReadonlyMap<string, string>\n nodes: unknown\n}\n\n/**\n * Returns the cached `output`/`input` direction printers for a resolver, building them on\n * first use. The `input` printer encodes `Date → string` for request bodies, and `output` decodes\n * `string → Date` for responses. Schemas without `dateType: 'date'` fields print identically.\n */\nfunction getStdPrinters(resolver: ResolverZod, params: StdPrinterParams): StdPrinters {\n const cached = zodPrinterCache.get(resolver)\n if (\n cached &&\n cached.coercion === params.coercion &&\n cached.guidType === params.guidType &&\n cached.regexType === params.regexType &&\n cached.dateType === params.dateType &&\n cached.nodes === params.nodes\n ) {\n return { output: cached.output, input: cached.input }\n }\n const base = { ...params, resolver } as Parameters<typeof printerZod>[0]\n const output = printerZod({ ...base, direction: 'output' })\n const input = printerZod({ ...base, direction: 'input' })\n zodPrinterCache.set(resolver, {\n output,\n input,\n coercion: params.coercion,\n guidType: params.guidType,\n regexType: params.regexType,\n dateType: params.dateType,\n nodes: params.nodes,\n })\n return { output, input }\n}\n\nfunction getMiniPrinter(\n resolver: ResolverZod,\n params: {\n guidType: unknown\n regexType: unknown\n cyclicSchemas: ReadonlySet<string>\n nameMapping?: ReadonlyMap<string, string>\n nodes: unknown\n },\n) {\n const cached = zodMiniPrinterCache.get(resolver)\n if (cached && cached.guidType === params.guidType && cached.regexType === params.regexType && cached.nodes === params.nodes) return cached.printer\n const p = printerZodMini({ ...params, resolver } as Parameters<typeof printerZodMini>[0])\n zodMiniPrinterCache.set(resolver, { printer: p, guidType: params.guidType, regexType: params.regexType, nodes: params.nodes })\n return p\n}\n\n/**\n * Built-in generator for `@kubb/plugin-zod`. Emits one Zod schema per\n * schema in the spec plus per-operation request/response/parameter schemas.\n * When `mini: true`, schemas use the Zod Mini functional API instead of\n * chainable methods.\n */\nexport const zodGenerator = defineGenerator<PluginZod>({\n name: 'zod',\n renderer: jsxRenderer,\n schema(node, ctx) {\n const { adapter, config, resolver, root } = ctx\n const { output, coercion, guidType, regexType, mini, inferred, importPath, group, printer } = ctx.options\n const dateType = (adapter as Adapter<AdapterOas>).options.dateType\n\n if (!node.name) {\n return\n }\n\n const isZodImport = ZOD_NAMESPACE_IMPORTS.has(importPath as 'zod' | 'zod/mini')\n const cyclicSchemas = new Set<string>(ctx.meta.circularNames)\n\n // A codec component is rendered twice: the canonical (output) schema decodes\n // `string → Date`, and an `${name}InputSchema` variant encodes `Date → string` for requests.\n const hasCodec = !mini && containsCodec(node)\n\n const codecRefNames = new Set(hasCodec ? collectCodecRefNames(node) : [])\n const importEntries = adapter.getImports(node, (schemaName) => ({\n name: resolver.resolveSchemaName(schemaName),\n path: resolver.resolveFile({ name: schemaName, extname: '.ts' }, { root, output, group: group ?? undefined }).path,\n }))\n const inputImportEntries = hasCodec\n ? [...codecRefNames].map((schemaName) => ({\n name: [resolver.resolveInputSchemaName(schemaName)],\n path: resolver.resolveFile({ name: schemaName, extname: '.ts' }, { root, output, group: group ?? undefined }).path,\n }))\n : []\n const seenImports = new Set<string>()\n const imports = [...importEntries, ...inputImportEntries].filter((imp) => {\n const key = `${Array.isArray(imp.name) ? imp.name.join(',') : imp.name}|${imp.path}`\n if (seenImports.has(key)) return false\n seenImports.add(key)\n return true\n })\n\n const meta = {\n name: resolver.resolveSchemaName(node.name),\n file: resolver.resolveFile({ name: node.name, extname: '.ts' }, { root, output, group: group ?? undefined }),\n } as const\n\n const inferTypeName = inferred ? resolver.resolveSchemaTypeName(node.name) : null\n\n const nameMapping = (adapter as Adapter<AdapterOas>).options.nameMapping\n const stdPrinters = mini ? null : getStdPrinters(resolver, { coercion, guidType, regexType, dateType, cyclicSchemas, nameMapping, nodes: printer?.nodes })\n const schemaPrinter = mini ? getMiniPrinter(resolver, { guidType, regexType, cyclicSchemas, nameMapping, nodes: printer?.nodes }) : stdPrinters!.output\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n <File.Import name={isZodImport ? 'z' : ['z']} path={importPath} isNameSpace={isZodImport} />\n {imports.map((imp) => (\n <File.Import key={[node.name, imp.path, imp.name].join('-')} root={meta.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Zod name={meta.name} node={node} printer={schemaPrinter} inferTypeName={inferTypeName} cyclic={cyclicSchemas.has(node.name)} />\n {hasCodec && stdPrinters && (\n <Zod\n name={resolver.resolveInputSchemaName(node.name)}\n node={node}\n printer={stdPrinters.input}\n inferTypeName={inferred ? resolver.resolveInputSchemaTypeName(node.name) : null}\n cyclic={cyclicSchemas.has(node.name)}\n />\n )}\n </File>\n )\n },\n operation(node, ctx) {\n if (!ast.isHttpOperationNode(node)) return null\n const { adapter, config, resolver, root } = ctx\n const { output, coercion, guidType, regexType, mini, inferred, importPath, group, printer } = ctx.options\n const dateType = (adapter as Adapter<AdapterOas>).options.dateType\n\n const isZodImport = ZOD_NAMESPACE_IMPORTS.has(importPath as 'zod' | 'zod/mini')\n\n const params = caseParams(node.parameters, 'camelcase')\n\n const meta = {\n file: resolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output, group: group ?? undefined },\n ),\n } as const\n\n const cyclicSchemas = new Set<string>(ctx.meta.circularNames)\n const nameMapping = (adapter as Adapter<AdapterOas>).options.nameMapping\n\n function renderSchemaEntry({\n schema,\n name,\n keysToOmit,\n direction = 'output',\n }: {\n schema: ast.SchemaNode | null\n name: string\n keysToOmit?: Array<string> | null\n direction?: 'input' | 'output'\n }) {\n if (!schema) return null\n\n const inferTypeName = inferred ? resolver.resolveTypeName(name) : null\n\n // In the input direction, refs to codec components resolve to their input variant.\n const codecRefNames = direction === 'input' && !mini ? new Set(collectCodecRefNames(schema)) : null\n const imports = adapter.getImports(schema, (schemaName) => ({\n name: codecRefNames?.has(schemaName) ? resolver.resolveInputSchemaName(schemaName) : resolver.resolveSchemaName(schemaName),\n path: resolver.resolveFile({ name: schemaName, extname: '.ts' }, { root, output, group: group ?? undefined }).path,\n }))\n\n const schemaPrinter = mini\n ? keysToOmit?.length\n ? printerZodMini({ guidType, regexType, resolver, keysToOmit, cyclicSchemas, nameMapping, nodes: printer?.nodes })\n : getMiniPrinter(resolver, { guidType, regexType, cyclicSchemas, nameMapping, nodes: printer?.nodes })\n : keysToOmit?.length\n ? printerZod({\n coercion,\n guidType,\n regexType,\n dateType,\n resolver,\n keysToOmit,\n cyclicSchemas,\n nameMapping,\n nodes: printer?.nodes,\n direction,\n })\n : getStdPrinters(resolver, { coercion, guidType, regexType, dateType, cyclicSchemas, nameMapping, nodes: printer?.nodes })[direction]\n\n return (\n <>\n {imports.map((imp) => (\n <File.Import key={[name, imp.path, imp.name].join('-')} root={meta.file.path} path={imp.path} name={imp.name} />\n ))}\n {/* Operation schemas reference (and import) the component schemas, which carry the\n `z.ZodType` annotation at their own definition when cyclic. Annotating the operation\n schema too would only erase its inferred type to `unknown`, breaking typed consumers\n (e.g. the MCP server's request types), so it is never marked cyclic here. */}\n <Zod name={name} node={schema} printer={schemaPrinter} inferTypeName={inferTypeName} cyclic={false} />\n </>\n )\n }\n\n // Multiple content types for a single name: emit one schema per content type plus a union alias.\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 direction?: 'input' | 'output',\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 renderSchemaEntry({\n schema: decorate ? decorate(variant.schema) : variant.schema,\n name: variant.name,\n keysToOmit: variant.keysToOmit,\n direction,\n }),\n )}\n {renderSchemaEntry({ schema: unionSchema, name: baseName, direction })}\n </>\n )\n }\n\n const paramSchemas = params.map((param) => renderSchemaEntry({ schema: param.schema, name: resolver.resolveParamName(node, param), direction: 'input' }))\n\n const responseSchemas = node.responses.map((res) => {\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length > 1) {\n return buildContentTypeVariants(res.content!, resolver.resolveResponseStatusName(node, res.statusCode))\n }\n const primary = variants[0] ?? res.content?.[0]\n return renderSchemaEntry({\n schema: primary?.schema ?? null,\n name: resolver.resolveResponseStatusName(node, res.statusCode),\n keysToOmit: primary?.keysToOmit,\n })\n })\n\n const responsesWithSchema = node.responses.filter((res) => res.content?.some((entry) => entry.schema))\n // Validate success (2xx) bodies only. Error bodies are surfaced unparsed, typed by plugin-ts (#369).\n const successResponsesWithSchema = getSuccessResponses(responsesWithSchema)\n const responseUnionSchema =\n responsesWithSchema.length > 0\n ? (() => {\n const responseUnionName = resolver.resolveResponseName(node)\n\n // Collect import names from the success response schemas to detect naming collisions.\n // When a 2xx response is a $ref to a component schema whose resolved name matches the\n // response union name, skip generation to avoid redeclaration errors.\n const importedNames = new Set(\n successResponsesWithSchema.flatMap((res) =>\n (res.content ?? []).flatMap((entry) =>\n entry.schema\n ? adapter\n .getImports(entry.schema, (schemaName) => ({\n name: resolver.resolveSchemaName(schemaName),\n path: '',\n }))\n .flatMap((imp) => (Array.isArray(imp.name) ? imp.name : [imp.name]))\n : [],\n ),\n ),\n )\n\n if (importedNames.has(responseUnionName)) {\n return null\n }\n\n const members = successResponsesWithSchema.map((res) =>\n ast.factory.createSchema({ type: 'ref', name: resolver.resolveResponseStatusName(node, res.statusCode) }),\n )\n\n // No documented 2xx schema: fall back to an unknown schema so the response name still\n // resolves for consumers that parse success bodies.\n if (members.length === 0) {\n return renderSchemaEntry({ schema: ast.factory.createSchema({ type: 'unknown' }), name: responseUnionName })\n }\n\n const unionNode = members.length === 1 ? members[0]! : ast.factory.createSchema({ type: 'union', members })\n\n return renderSchemaEntry({\n schema: unionNode,\n name: responseUnionName,\n })\n })()\n : null\n\n // Validate error bodies on the non-throw path. Mirrors the success union but selects every\n // non-2xx response (including the OpenAPI `default`) so it lines up with plugin-ts `ErrorOf` (#369).\n const errorResponsesWithSchema = responsesWithSchema.filter((res) => !isSuccessStatusCode(res.statusCode))\n const errorUnionSchema =\n errorResponsesWithSchema.length > 0\n ? (() => {\n const errorUnionName = resolver.resolveErrorName(node)\n\n const importedNames = new Set(\n errorResponsesWithSchema.flatMap((res) =>\n (res.content ?? []).flatMap((entry) =>\n entry.schema\n ? adapter\n .getImports(entry.schema, (schemaName) => ({\n name: resolver.resolveSchemaName(schemaName),\n path: '',\n }))\n .flatMap((imp) => (Array.isArray(imp.name) ? imp.name : [imp.name]))\n : [],\n ),\n ),\n )\n\n if (importedNames.has(errorUnionName)) {\n return null\n }\n\n const members = errorResponsesWithSchema.map((res) =>\n ast.factory.createSchema({ type: 'ref', name: resolver.resolveResponseStatusName(node, res.statusCode) }),\n )\n\n const unionNode = members.length === 1 ? members[0]! : ast.factory.createSchema({ type: 'union', members })\n\n return renderSchemaEntry({\n schema: unionNode,\n name: errorUnionName,\n })\n })()\n : null\n\n const requestBodyContent = node.requestBody?.content ?? []\n const requestSchema = (() => {\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 renderSchemaEntry({\n schema: { ...entry.schema, description: node.requestBody!.description ?? entry.schema.description },\n name: resolver.resolveDataName(node),\n keysToOmit: entry.keysToOmit,\n direction: 'input',\n })\n }\n return buildContentTypeVariants(\n requestBodyContent,\n resolver.resolveDataName(node),\n (schema) => ({\n ...schema,\n description: node.requestBody!.description ?? schema.description,\n }),\n 'input',\n )\n })()\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n <File.Import name={isZodImport ? 'z' : ['z']} path={importPath} isNameSpace={isZodImport} />\n {paramSchemas}\n {responseSchemas}\n {responseUnionSchema}\n {errorUnionSchema}\n {requestSchema}\n </File>\n )\n },\n})\n","import { camelCase, ensureValidVarName, pascalCase, toFilePath } from '@internals/utils'\nimport { defineResolver } from 'kubb/kit'\nimport type { PluginZod } from '../types.ts'\n\n/**\n * Default resolver used by `@kubb/plugin-zod`. Decides the names and file\n * paths for every generated Zod schema. Schemas use camelCase with a\n * `Schema` suffix (`listPetsSchema`); their inferred types use PascalCase\n * with a `SchemaType` suffix (`PetSchemaType`), so the value and the type\n * never share an identifier even when the schema name is all-uppercase.\n *\n * @example Resolve schema and type names\n * ```ts\n * import { resolverZod } from '@kubb/plugin-zod'\n *\n * resolverZod.default('list pets', 'function') // 'listPetsSchema'\n * resolverZod.resolveSchemaTypeName('pet') // 'PetSchemaType'\n * ```\n */\nexport const resolverZod = defineResolver<PluginZod>(() => {\n return {\n name: 'default',\n pluginName: 'plugin-zod',\n default(name, type) {\n if (type === 'file') return toFilePath(name, (part) => camelCase(part, { suffix: 'schema' }))\n return ensureValidVarName(camelCase(name, { suffix: type ? 'schema' : undefined }))\n },\n resolveSchemaName(name) {\n return ensureValidVarName(camelCase(name, { suffix: 'schema' }))\n },\n resolveSchemaTypeName(name) {\n return ensureValidVarName(pascalCase(name, { suffix: 'schema type' }))\n },\n resolveInputSchemaName(name) {\n return this.resolveSchemaName(`${name} input`)\n },\n resolveInputSchemaTypeName(name) {\n return this.resolveSchemaTypeName(`${name} input`)\n },\n resolveTypeName(name) {\n return ensureValidVarName(pascalCase(name, { suffix: 'type' }))\n },\n resolvePathName(name, type) {\n return this.default(name, type)\n },\n resolveParamName(node, param) {\n return this.resolveSchemaName(`${node.operationId} ${param.in} ${param.name}`)\n },\n resolveResponseStatusName(node, statusCode) {\n return this.resolveSchemaName(`${node.operationId} Status ${statusCode}`)\n },\n resolveDataName(node) {\n return this.resolveSchemaName(`${node.operationId} Data`)\n },\n resolveResponsesName(node) {\n return this.resolveSchemaName(`${node.operationId} Responses`)\n },\n resolveResponseName(node) {\n return this.resolveSchemaName(`${node.operationId} Response`)\n },\n resolveErrorName(node) {\n return this.resolveSchemaName(`${node.operationId} Error`)\n },\n resolvePathParamsName(node, param) {\n return this.resolveParamName(node, param)\n },\n resolveQueryParamsName(node, param) {\n return this.resolveParamName(node, param)\n },\n resolveHeaderParamsName(node, param) {\n return this.resolveParamName(node, param)\n },\n }\n})\n","import { createGroupConfig } from '@internals/shared'\nimport { definePlugin } from 'kubb/kit'\nimport { zodGenerator } from './generators/zodGenerator.tsx'\nimport { resolverZod } from './resolvers/resolverZod.ts'\nimport type { PluginZod } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-zod`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\n/**\n * Generates Zod v4 schemas from an OpenAPI spec. Use them to validate API\n * responses at runtime, build form schemas, or feed back into router libraries\n * that consume Zod (tRPC, Hono, Elysia). Pair with `@kubb/plugin-axios` or\n * `@kubb/plugin-fetch` and set the client's `validator: 'zod'` to validate every response\n * automatically.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginTs } from '@kubb/plugin-ts'\n * import { pluginZod } from '@kubb/plugin-zod'\n *\n * export default defineConfig({\n * input: { path: './petStore.yaml' },\n * output: { path: './src/gen' },\n * plugins: [\n * pluginTs(),\n * pluginZod({\n * output: { path: './zod' },\n * inferred: true,\n * }),\n * ],\n * })\n * ```\n */\nexport const pluginZod = definePlugin<PluginZod>((options) => {\n const {\n output = { path: 'zod', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n mini = false,\n guidType = 'uuid',\n regexType = 'literal',\n importPath = mini ? 'zod/mini' : 'zod',\n coercion = false,\n inferred = false,\n printer,\n resolver: userResolver,\n macros: userMacros,\n } = options\n\n const groupConfig = createGroupConfig(group)\n\n return {\n name: pluginZodName,\n options,\n hooks: {\n 'kubb:plugin:setup'(ctx) {\n ctx.setOptions({\n output,\n exclude,\n include,\n override,\n group: groupConfig,\n importPath,\n coercion,\n inferred,\n guidType,\n regexType,\n mini,\n printer,\n })\n ctx.setResolver(userResolver ? { ...resolverZod, ...userResolver } : resolverZod)\n if (userMacros?.length) {\n ctx.setMacros(userMacros)\n }\n ctx.addGenerator(zodGenerator)\n },\n },\n }\n})\n\nexport default pluginZod\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,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;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D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,QAAQ,EAAE,MAAM,QAAQ;CAAE,GAClD,OACA,UAAU,CAAC,GACX,SACA,WAAW,CAAC,GACZ,OAAO,OACP,WAAW,QACX,YAAY,WACZ,aAAa,OAAO,aAAa,OACjC,WAAW,OACX,WAAW,OACX,SACA,UAAU,cACV,QAAQ,eACN;CAEJ,MAAM,cAAc,kBAAkB,KAAK;CAE3C,OAAO;EACL,MAAM;EACN;EACA,OAAO,EACL,oBAAoB,KAAK;GACvB,IAAI,WAAW;IACb;IACA;IACA;IACA;IACA,OAAO;IACP;IACA;IACA;IACA;IACA;IACA;IACA;GACF,CAAC;GACD,IAAI,YAAY,eAAe;IAAE,GAAG;IAAa,GAAG;GAAa,IAAI,WAAW;GAChF,IAAI,YAAY,QACd,IAAI,UAAU,UAAU;GAE1B,IAAI,aAAa,YAAY;EAC/B,EACF;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["File","Const","Type","ast","strictOneOfMember","ast","ast","jsxRenderer","File","ast","Resolver"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/strings.ts","../../../internals/utils/src/codegen.ts","../../../internals/utils/src/fs.ts","../../../internals/shared/src/params.ts","../../../internals/shared/src/operation.ts","../../../internals/shared/src/group.ts","../src/components/Zod.tsx","../src/constants.ts","../src/utils.ts","../src/printers/printerZod.ts","../src/printers/printerZodMini.ts","../src/generators/zodGenerator.tsx","../src/resolvers/resolverZod.ts","../src/plugin.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 toCamelOrPascal(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/**\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 * 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 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 plain object as multi-line `key: value` source for embedding in generated code. Nested\n * objects recurse with fixed indentation, so the result drops straight into an object literal\n * without re-parsing.\n *\n * @example\n * ```ts\n * stringifyObject({ foo: 'bar', nested: { a: 1 } })\n * // 'foo: bar,\\nnested: {\\n a: 1\\n }'\n * ```\n */\nexport function stringifyObject(value: Record<string, unknown>): string {\n const items = Object.entries(value)\n .map(([key, val]) => {\n if (val !== null && typeof val === 'object') {\n return `${key}: {\\n ${stringifyObject(val as Record<string, unknown>)}\\n }`\n }\n return `${key}: ${val}`\n })\n .filter(Boolean)\n return items.join(',\\n')\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 { isIdentifier } from './reserved.ts'\nimport { singleQuote } from './strings.ts'\n\nconst INDENT = ' '\n\n/**\n * Builds a JSDoc comment block from an array of lines. Returns `fallback` when there are no\n * comments.\n *\n * @example\n * ```ts\n * buildJSDoc(['@type string', '@example hello'])\n * // '/**\\n * @type string\\n * @example hello\\n *\\/\\n '\n * ```\n */\nexport function buildJSDoc(\n comments: Array<string>,\n options: {\n /**\n * String used to indent each comment line.\n * @default ' * '\n */\n indent?: string\n /**\n * String appended after the closing tag.\n * @default '\\n '\n */\n suffix?: string\n /**\n * Returned as-is when `comments` is empty.\n * @default ' '\n */\n fallback?: string\n } = {},\n): string {\n const { indent = ' * ', suffix = '\\n ', fallback = ' ' } = options\n\n if (comments.length === 0) return fallback\n\n return `/**\\n${comments.map((c) => `${indent}${c}`).join('\\n')}\\n */${suffix}`\n}\n\n/**\n * Indents every non-empty line of `text` by one indent level, leaving blank lines empty.\n */\nfunction indentLines(text: string): string {\n if (!text) return ''\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${INDENT}${line}` : ''))\n .join('\\n')\n}\n\n/**\n * Renders an object key, quoting it with single quotes only when it is not a valid identifier.\n * Reserved words and globals (`name`, `class`, …) are valid bare keys and stay unquoted.\n *\n * @example\n * ```ts\n * objectKey('name') // 'name'\n * objectKey('x-total') // \"'x-total'\"\n * ```\n */\nexport function objectKey(name: string): string {\n return isIdentifier(name) ? name : singleQuote(name)\n}\n\n/**\n * Assembles a multi-line object literal from already-rendered `entries`, indenting each entry one\n * level and closing the brace at column zero. Entries that are themselves multi-line objects indent\n * cumulatively. Each entry ends with a trailing comma to match the formatter's multi-line style.\n *\n * @example\n * ```ts\n * buildObject(['id: z.number()', 'name: z.string()'])\n * // '{\\n id: z.number(),\\n name: z.string(),\\n}'\n * ```\n */\nexport function buildObject(entries: Array<string>): string {\n if (entries.length === 0) return '{}'\n const body = entries.map((entry) => `${indentLines(entry)},`).join('\\n')\n\n return `{\\n${body}\\n}`\n}\n\n/**\n * Assembles a bracketed list (array by default) from already-rendered `items`. Keeps everything on\n * one line when no item spans multiple lines, and otherwise puts each item on its own line, indented\n * one level with a trailing comma and the closing bracket at column zero. Used for member lists such\n * as `z.union([…])` and `z.array([…])`.\n *\n * @example\n * ```ts\n * buildList(['z.string()', 'z.number()'])\n * // '[z.string(), z.number()]'\n * ```\n */\nexport function buildList(items: Array<string>, brackets: [open: string, close: string] = ['[', ']']): string {\n const [open, close] = brackets\n if (items.length === 0) return `${open}${close}`\n if (!items.some((item) => item.includes('\\n'))) return `${open}${items.join(', ')}${close}`\n const body = items.map((item) => `${indentLines(item)},`).join('\\n')\n\n return `${open}\\n${body}\\n${close}`\n}\n\n/**\n * Emits a lazy getter for a circular-ref property position, `get name() { return body }`. The key\n * is quoted only when it is not a valid identifier. Used by the string printers to defer evaluation\n * of a recursive schema until first access.\n *\n * @example\n * ```ts\n * lazyGetter({ name: 'parent', body: 'z.lazy(() => Pet)' })\n * // \"get parent() { return z.lazy(() => Pet) }\"\n * ```\n */\nexport function lazyGetter({ name, body }: { name: string; body: string }): string {\n return `get ${objectKey(name)}() { return ${body} }`\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 | null, filePath?: string | null): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\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, isValidVarName } from '@internals/utils'\nimport type { ast } from 'kubb/kit'\n\nconst caseParamsCache = new WeakMap<Array<ast.ParameterNode>, Array<ast.ParameterNode>>()\n\n/**\n * Applies camelCase to parameter names and returns a new array without mutating the input.\n *\n * Run it before handing parameters to schema builders so output property keys get the right casing\n * while `OperationNode.parameters` stays intact for other consumers. When `casing` is unset, the\n * original array is returned unchanged. Results are cached per input array.\n */\nexport function caseParams(params: Array<ast.ParameterNode>, casing: 'camelcase' | undefined): Array<ast.ParameterNode> {\n if (!casing) return params\n\n const cached = caseParamsCache.get(params)\n if (cached) return cached\n\n const result = params.map((param) => ({ ...param, name: camelCase(param.name) }))\n caseParamsCache.set(params, result)\n return result\n}\n\n/**\n * Drops parameters that collapse to the same property identity once camelCased, keeping the first.\n *\n * Some specs declare the same parameter twice under different casings (for example AWS S3 lists both\n * `max-uploads` and `MaxUploads`). Both resolve to one output property, so emitting both would yield\n * an object type with a duplicate member, which TypeScript rejects. De-duplicate by the camelCased\n * identity so the resulting group is collision-free regardless of the names each caller carries.\n */\nexport function dedupeByCasedName(params: Array<ast.ParameterNode>): Array<ast.ParameterNode> {\n const seen = new Set<string>()\n\n return params.filter((param) => {\n const key = camelCase(param.name)\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n}\n\nexport function buildParamsMapping<TParam extends { name: string }>(\n originalParams: ReadonlyArray<TParam>,\n mappedParams: ReadonlyArray<TParam>,\n): Record<string, string> | null {\n const mapping: Record<string, string> = {}\n let hasChanged = false\n\n originalParams.forEach((param, i) => {\n const mappedName = mappedParams[i]?.name ?? param.name\n mapping[param.name] = mappedName\n\n if (param.name !== mappedName) {\n hasChanged = true\n }\n })\n\n return hasChanged ? mapping : null\n}\n\nexport function buildTransformedParamsMapping<TParam extends { name: string }>(\n params: ReadonlyArray<TParam>,\n transformName: (name: string) => string,\n): Record<string, string> | null {\n if (!params.length) {\n return null\n }\n\n return buildParamsMapping(\n params,\n params.map((param) => ({ ...param, name: transformName(param.name) })),\n )\n}\n\nfunction toAccess(object: string, name: string): string {\n return isValidVarName(name) ? `${object}.${name}` : `${object}[${JSON.stringify(name)}]`\n}\n\n/**\n * Renders the object-literal expression that renames the camelCased keys of a grouped request\n * option back to the names the OpenAPI document declares, guarded so an omitted optional group\n * stays omitted. Shared by the client and cypress generators, which pass a `buildParamsMapping`\n * result and the source expression to read the keys from.\n *\n * @example\n * ```ts\n * buildParamsRemapExpression({ source: 'config.query', mapping: { include_deleted: 'includeDeleted' } })\n * // 'config.query ? { \"include_deleted\": config.query.includeDeleted } : config.query'\n * ```\n */\nexport function buildParamsRemapExpression({ source, mapping }: { source: string; mapping: Record<string, string> }): string {\n const pairs = Object.entries(mapping)\n .map(([originalName, casedName]) => `${JSON.stringify(originalName)}: ${toAccess(source, casedName)}`)\n .join(', ')\n\n return `${source} ? { ${pairs} } : ${source}`\n}\n","import { Url } from '@internals/utils'\nimport { ast, type ResolverFileParams } from 'kubb/kit'\nimport { caseParams, dedupeByCasedName } from './params.ts'\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\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\n/**\n * Resolver interface for building operation parameters.\n *\n * `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.\n */\nexport type OperationParamsResolver = {\n /**\n * Naming for an operation's parameters, grouped by location.\n */\n param: {\n /**\n * Resolves the type name for an individual parameter.\n *\n * @example Individual path parameter name\n * `resolver.param.name(node, param) // → 'DeletePetPathPetId'`\n */\n name(node: ast.OperationNode, param: ast.ParameterNode): string\n /**\n * Resolves the grouped path parameters type name.\n * When the return value equals `resolver.param.name`, no indexed access is emitted.\n *\n * @example Grouped path params type name\n * `resolver.param.path(node, param) // → 'DeletePetPath'`\n */\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n /**\n * Resolves the grouped query parameters type name.\n * When the return value equals `resolver.param.name`, an inline struct type is emitted instead.\n *\n * @example Grouped query params type name\n * `resolver.param.query(node, param) // → 'FindPetsByStatusQuery'`\n */\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n /**\n * Resolves the grouped header parameters type name.\n * When the return value equals `resolver.param.name`, an inline struct type is emitted instead.\n *\n * @example Grouped header params type name\n * `resolver.param.headers(node, param) // → 'DeletePetHeaders'`\n */\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n /**\n * Naming for an operation's request and response types.\n */\n response: {\n /**\n * Resolves the request body type name.\n *\n * @example Request body type name\n * `resolver.response.body(node) // → 'CreatePetBody'`\n */\n body(node: ast.OperationNode): 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 paramsCasing?: 'camelcase' | 'original'\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 if (link === 'urlPath') {\n return node.path ? `{@link ${Url.toPath(node.path)}}` : null\n }\n\n return node.path ? `{@link ${node.path.replaceAll('{', ':').replaceAll('}', '')}}` : 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\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\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`.\n const configType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\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 ? `${configType} & { contentType?: { ${members.join('; ')} } }` : configType\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 `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\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\nexport function getOperationParameters(node: ast.OperationNode, options: { paramsCasing?: 'camelcase' | 'original' } = {}): OperationParameterGroups {\n const params = caseParams(node.parameters, options.paramsCasing === 'original' ? undefined : 'camelcase')\n\n return {\n path: dedupeByCasedName(params.filter((param) => param.in === 'path')),\n query: dedupeByCasedName(params.filter((param) => param.in === 'query')),\n header: dedupeByCasedName(params.filter((param) => param.in === 'header')),\n cookie: dedupeByCasedName(params.filter((param) => param.in === 'cookie')),\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.paramsCasing ?? ''}\\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, { paramsCasing: options.paramsCasing })\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\nexport function findSuccessStatusCode(responses: Array<{ statusCode: ast.StatusCode | number | string }>): ast.StatusCode | null {\n for (const response of responses) {\n if (isSuccessStatusCode(response.statusCode)) {\n return response.statusCode as ast.StatusCode\n }\n }\n\n return null\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'\nimport { Const, File, Type } from 'kubb/jsx'\nimport type { KubbReactNode } from 'kubb/jsx'\nimport type { PrinterZodFactory } from '../printers/printerZod.ts'\nimport type { PrinterZodMiniFactory } from '../printers/printerZodMini.ts'\n\ntype Props = {\n name: string\n node: ast.SchemaNode\n /**\n * Pre-configured printer instance created by the generator.\n * The generator selects `printerZod` or `printerZodMini` based on the `mini` option,\n * then merges in any user-supplied `printer.nodes` overrides.\n */\n printer: ast.Printer<PrinterZodFactory> | ast.Printer<PrinterZodMiniFactory>\n inferTypeName?: string | null\n /**\n * Set when the schema references itself. A self-referential initializer (e.g. a `z.lazy(() => …)`\n * back to the same const) is implicitly `any` under `strict`, so the const is annotated with an\n * explicit `z.ZodType` to break the inference cycle.\n */\n cyclic?: boolean\n}\n\nexport function Zod({ name, node, printer, inferTypeName, cyclic }: Props): KubbReactNode {\n const output = printer.print(node)\n\n if (!output) {\n return\n }\n\n // A cyclic object emits its self-references as deferred getters (`get prop() { … }`), so its\n // initializer never references itself directly and TypeScript infers it fine — annotating it would\n // only strip the `ZodObject` methods (`.omit()`, `.strict()`). Only non-object cyclic schemas (a\n // union/array with a top-level `z.lazy(() => self)`) are implicitly `any` and need the annotation.\n const needsAnnotation = cyclic && node.type !== 'object'\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} type={needsAnnotation ? 'z.ZodType' : undefined}>\n {output}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n <Type export name={inferTypeName}>\n {`z.infer<typeof ${name}>`}\n </Type>\n </File.Source>\n )}\n </>\n )\n}\n","/**\n * Import paths that use a namespace import (`import * as z from '...'`).\n * All other import paths use a named import (`import { z } from '...'`).\n */\nexport const ZOD_NAMESPACE_IMPORTS = new Set(['zod', 'zod/mini'] as const)\n","import { stringify, toRegExpString } from '@internals/utils'\nimport { ast } from 'kubb/kit'\nimport type { PluginZod } from './types.ts'\n\n/**\n * Returns `true` when the given coercion option enables coercion for the specified type.\n */\nexport function shouldCoerce(coercion: PluginZod['resolvedOptions']['coercion'] | undefined, type: 'dates' | 'strings' | 'numbers'): boolean {\n if (coercion === undefined || coercion === false) return false\n if (coercion === true) return true\n\n return !!coercion[type]\n}\n\n/**\n * A codec for a schema node whose runtime type differs from its JSON wire type:\n * the output (response) schema decodes wire → runtime, and the input (request)\n * variant encodes runtime → wire.\n *\n * To support another codec type, append a `Codec` to `codecs` and route that\n * type's printer node handler through `getCodec`.\n */\nexport type Codec = {\n /**\n * Whether this node is encoded/decoded by this codec.\n */\n matches(node: ast.SchemaNode): boolean\n /**\n * Output direction (response): decode the wire value into the runtime type.\n */\n decode(node: ast.SchemaNode): string\n /**\n * Input direction (request): encode the runtime value back to the wire value.\n */\n encode(node: ast.SchemaNode): string\n}\n\n/**\n * `dateType: 'date'` fields are typed as `Date` but travel as ISO `string`s.\n * Output decodes `string → Date`; input encodes `Date → string`, preserving the\n * `date` (`YYYY-MM-DD`) vs `date-time` precision carried on `node.format`.\n */\nconst dateCodec: Codec = {\n matches(node) {\n return node.type === 'date' && node.representation === 'date'\n },\n decode(node) {\n return node.format === 'date' ? 'z.iso.date().transform((value) => new Date(value))' : 'z.iso.datetime().transform((value) => new Date(value))'\n },\n encode(node) {\n return node.format === 'date' ? 'z.date().transform((value) => value.toISOString().slice(0, 10))' : 'z.date().transform((value) => value.toISOString())'\n },\n}\n\n/**\n * Registered codecs, checked in order.\n */\nconst codecs: Array<Codec> = [dateCodec]\n\n/**\n * Returns the codec for this node, or `undefined` when the node needs no\n * encode/decode (its wire and runtime types match).\n */\nexport function getCodec(node: ast.SchemaNode | undefined): Codec | undefined {\n if (!node) return undefined\n return codecs.find((codec) => codec.matches(node))\n}\n\n/**\n * Returns `true` when the node itself is encoded/decoded by a codec.\n */\nexport function hasCodec(node: ast.SchemaNode | undefined): boolean {\n return getCodec(node) !== undefined\n}\n\n/**\n * Returns `true` when the schema transitively contains a codec node —\n * a value whose runtime type differs from its wire type (see {@link hasCodec}),\n * so it must be decoded (response) or encoded (request) at the validation boundary.\n * `$ref`s are followed via their resolved schema; a `seen` set guards cycles.\n */\nexport function containsCodec(node: ast.SchemaNode | undefined, seen: Set<string> = new Set()): boolean {\n if (!node) return false\n\n if (hasCodec(node)) return true\n\n if (node.type === 'ref') {\n if (!node.ref) return false\n const refName = ast.extractRefName(node.ref)\n if (refName) {\n if (seen.has(refName)) return false\n seen.add(refName)\n }\n const resolved = ast.syncSchemaRef(node)\n if (resolved.type === 'ref') return false\n return containsCodec(resolved, seen)\n }\n\n const children: Array<ast.SchemaNode | undefined> = []\n if ('properties' in node && node.properties) children.push(...node.properties.map((prop) => prop.schema))\n if ('items' in node && node.items) children.push(...node.items)\n if ('members' in node && node.members) children.push(...node.members)\n if ('additionalProperties' in node && node.additionalProperties && node.additionalProperties !== true) children.push(node.additionalProperties)\n\n return children.some((child) => containsCodec(child, seen))\n}\n\n/**\n * Collects the names of `$ref` schemas that transitively contain a codec, so the generator can route\n * them to their input (encode) variant.\n */\nexport function collectCodecRefNames(node: ast.SchemaNode): Array<string> {\n return ast.collect<string>(node, {\n schema: (n) => (n.type === 'ref' && n.ref && containsCodec(n) ? (ast.extractRefName(n.ref) ?? undefined) : undefined),\n })\n}\n\n/**\n * Whether the node is a plain inline object whose shape can be lifted into an `.extend({ … })`\n * argument. A catchall, `patternProperties`, or a nullable/optional wrapper cannot, so those stay\n * on `.and(…)`.\n */\nfunction isPlainInlineObject(node: ast.SchemaNode): boolean {\n return node.type === 'object' && !node.nullable && !node.optional && !node.nullish && node.additionalProperties === undefined && !node.patternProperties\n}\n\n/**\n * Whether a node renders as a bare Zod object — one that accepts `.extend(…)` and can be a\n * `z.discriminatedUnion` option. Covers object nodes, `$ref`s that resolve to (or are still\n * unresolved) objects, single-member unions of an object, and object-composable `allOf`.\n *\n * `cyclicSchemas` bounds the recursion: a ref into a cycle renders as `z.lazy(…)`, not an object.\n */\nexport function isObjectSchemaNode(node: ast.SchemaNode, cyclicSchemas?: ReadonlySet<string>): boolean {\n if (node.nullable || node.optional || node.nullish) return false\n if (node.type === 'object') return true\n\n if (node.type === 'ref') {\n const refName = (node.ref ? ast.extractRefName(node.ref) : undefined) ?? node.name\n if (refName && cyclicSchemas?.has(refName)) return false\n const resolved = ast.syncSchemaRef(node)\n // An unresolved ref keeps its `ref` type; assume it resolves to an object (matches the printer's\n // prior optimism that only a resolved intersection blocks a discriminated union).\n return resolved.type === 'ref' || isObjectSchemaNode(resolved, cyclicSchemas)\n }\n\n if (node.type === 'union') {\n const members = node.members ?? []\n return members.length === 1 && isObjectSchemaNode(members[0]!, cyclicSchemas)\n }\n\n return isObjectComposableIntersection(node, cyclicSchemas)\n}\n\n/**\n * Whether an `allOf` is a pure object composition — an object base plus inline object members whose\n * shapes merge with `.extend(…)`. These stay a Zod object instead of a `ZodIntersection`, which\n * `z.discriminatedUnion` rejects.\n */\nexport function isObjectComposableIntersection(node: ast.SchemaNode, cyclicSchemas?: ReadonlySet<string>): boolean {\n if (node.type !== 'intersection') return false\n const [first, ...rest] = node.members ?? []\n return !!first && isObjectSchemaNode(first, cyclicSchemas) && rest.every(isPlainInlineObject)\n}\n\n/**\n * Format a default value as a code-level literal.\n * Objects become `{}`, primitives become their string representation, strings are quoted.\n */\nexport function formatDefault(value: unknown): string {\n if (typeof value === 'string') return stringify(value)\n if (typeof value === 'object' && value !== null) return '{}'\n\n return String(value ?? '')\n}\n\n/**\n * Format a default for `.default(...)` so the literal matches the generated schema's type.\n *\n * An OpenAPI `default` does not always agree with the schema it sits on: a `bigint` field\n * (`format: int64`) carries a `number` default, and a spec may put `default: {}` on an `array`.\n * Emitting those verbatim produces a Zod schema that does not typecheck, so coerce the bigint case\n * to a `BigInt(...)` literal and emit an array literal for arrays (dropping a non-array default).\n * Returns `null` when no `.default(...)` should be emitted. Keys off the schema node's type.\n */\nexport function defaultLiteral(node: ast.SchemaNode | undefined, value: unknown): string | null {\n // A `null` default is invalid on a non-nullable schema and redundant on a nullish one, and emitting\n // it produces a bare `.default()` (no argument). Drop it.\n if (value === null) return null\n if (node && ast.narrowSchema(node, 'bigint')) {\n if (typeof value === 'bigint') return `BigInt(${value})`\n if (typeof value === 'number' && Number.isInteger(value)) return `BigInt(${value})`\n return null\n }\n if (node && ast.narrowSchema(node, 'array')) {\n return Array.isArray(value) ? JSON.stringify(value) : null\n }\n // An enum/literal schema narrows to its members (e.g. `1 | 3`), but the spec default may not match\n // that type (`default: '1'` on a numeric enum). Emit the matching member's typed literal so the\n // default agrees with the schema, or drop a default that matches no member.\n const enumNode = node ? ast.narrowSchema(node, 'enum') : undefined\n if (enumNode) {\n const values = enumNode.namedEnumValues?.map((member) => member.value) ?? enumNode.enumValues ?? []\n if (values.length) {\n const match = values.find((member) => member === value || String(member) === String(value))\n return match != null ? formatLiteral(match) : null\n }\n }\n return formatDefault(value)\n}\n\n/**\n * Format a primitive enum/literal value.\n * Strings are quoted; numbers and booleans are emitted raw.\n */\nexport function formatLiteral(v: string | number | boolean): string {\n if (typeof v === 'string') return stringify(v)\n\n return String(v)\n}\n\n/**\n * Build the Zod schema for a set of literal enum values.\n * `z.enum()` only accepts string members in Zod v4, so a numeric, boolean, or\n * mixed set is emitted as a single `z.literal(…)` or a `z.union([z.literal(…), …])`.\n * An all-string set keeps the more compact `z.enum([…])`.\n */\nexport function buildEnum(values: Array<string | number | boolean>): string {\n const allStrings = values.every((v) => typeof v === 'string')\n if (allStrings) return `z.enum([${values.map(formatLiteral).join(', ')}])`\n\n const literals = values.map((v) => `z.literal(${formatLiteral(v)})`)\n if (literals.length === 1) return literals[0]!\n\n return `z.union([${literals.join(', ')}])`\n}\n\n/**\n * Numeric constraint limits for Zod schemas (min, max, and exclusive bounds).\n */\nexport type NumericConstraints = {\n min?: number\n max?: number\n exclusiveMinimum?: number\n exclusiveMaximum?: number\n multipleOf?: number\n}\n\n/**\n * Length constraint limits for string and array schemas (min, max, and regex pattern).\n */\nexport type LengthConstraints = {\n min?: number\n max?: number\n pattern?: string\n /**\n * Output form for the `pattern` regex. `'literal'` emits a regex literal,\n * `'constructor'` emits `new RegExp(...)`.\n *\n * @default 'literal'\n */\n regexType?: PluginZod['resolvedOptions']['regexType']\n}\n\n/**\n * Map a `regexType` to the `func` argument of `toRegExpString`: `'constructor'` emits\n * `new RegExp(...)`, while `'literal'` (the default) emits a regex literal.\n */\nfunction regexFunc(regexType: PluginZod['resolvedOptions']['regexType'] | undefined): string | null {\n return regexType === 'constructor' ? 'RegExp' : null\n}\n\n/**\n * Builds a Zod record key schema that enforces the `patternProperties` regexes a plain\n * `.catchall()` would drop. Several patterns combine into one alternation (`(^a)|(^b)`).\n */\nexport function patternKeySchema({ patterns, regexType }: { patterns: Array<string>; regexType?: PluginZod['resolvedOptions']['regexType'] }): string {\n return `z.string().regex(${patternKeySource({ patterns, regexType })})`\n}\n\n/**\n * `zod/mini` variant of {@link patternKeySchema}, wrapping the regex in `.check(z.regex(...))`.\n */\nexport function patternKeySchemaMini({ patterns, regexType }: { patterns: Array<string>; regexType?: PluginZod['resolvedOptions']['regexType'] }): string {\n return `z.string().check(z.regex(${patternKeySource({ patterns, regexType })}))`\n}\n\nfunction patternKeySource({ patterns, regexType }: { patterns: Array<string>; regexType?: PluginZod['resolvedOptions']['regexType'] }): string {\n const source = patterns.length === 1 ? patterns[0]! : patterns.map((pattern) => `(${pattern})`).join('|')\n return toRegExpString(source, regexFunc(regexType))\n}\n\n/**\n * Modifier options for applying chainable methods to Zod schema values.\n */\nexport type ModifierOptions = {\n value: string\n schema?: ast.SchemaNode\n nullable?: boolean\n optional?: boolean\n nullish?: boolean\n defaultValue?: unknown\n description?: string\n examples?: Array<unknown>\n}\n\n/**\n * Build `.min()` / `.max()` / `.gt()` / `.lt()` constraint chains for numbers\n * using the standard chainable Zod v4 API.\n */\nexport function numberConstraints({ min, max, exclusiveMinimum, exclusiveMaximum, multipleOf }: NumericConstraints): string {\n return [\n min !== undefined ? `.min(${min})` : '',\n max !== undefined ? `.max(${max})` : '',\n exclusiveMinimum !== undefined ? `.gt(${exclusiveMinimum})` : '',\n exclusiveMaximum !== undefined ? `.lt(${exclusiveMaximum})` : '',\n multipleOf !== undefined ? `.multipleOf(${multipleOf})` : '',\n ].join('')\n}\n\n/**\n * Build `.min()` / `.max()` / `.regex()` chains for strings/arrays\n * using the standard chainable Zod v4 API.\n */\nexport function lengthConstraints({ min, max, pattern, regexType }: LengthConstraints): string {\n return [\n min !== undefined ? `.min(${min})` : '',\n max !== undefined ? `.max(${max})` : '',\n pattern !== undefined ? `.regex(${toRegExpString(pattern, regexFunc(regexType))})` : '',\n ].join('')\n}\n\n/**\n * Build `.check(z.minimum(), z.maximum())` for `zod/mini` numeric constraints.\n */\nexport function numberChecksMini({ min, max, exclusiveMinimum, exclusiveMaximum, multipleOf }: NumericConstraints): string {\n const checks: Array<string> = []\n if (min !== undefined) checks.push(`z.minimum(${min})`)\n if (max !== undefined) checks.push(`z.maximum(${max})`)\n if (exclusiveMinimum !== undefined) checks.push(`z.minimum(${exclusiveMinimum}, { exclusive: true })`)\n if (exclusiveMaximum !== undefined) checks.push(`z.maximum(${exclusiveMaximum}, { exclusive: true })`)\n if (multipleOf !== undefined) checks.push(`z.multipleOf(${multipleOf})`)\n return checks.length ? `.check(${checks.join(', ')})` : ''\n}\n\n/**\n * Build `.check(z.minLength(), z.maxLength(), z.regex())` for `zod/mini` length constraints.\n */\nexport function lengthChecksMini({ min, max, pattern, regexType }: LengthConstraints): string {\n const checks: Array<string> = []\n if (min !== undefined) checks.push(`z.minLength(${min})`)\n if (max !== undefined) checks.push(`z.maxLength(${max})`)\n if (pattern !== undefined) checks.push(`z.regex(${toRegExpString(pattern, regexFunc(regexType))})`)\n return checks.length ? `.check(${checks.join(', ')})` : ''\n}\n\n/**\n * Apply nullable / optional / nullish modifiers, an optional `.describe()` call, and an\n * optional `.meta({ examples })` call to a schema value string using the chainable Zod v4 API.\n */\nexport function applyModifiers({ value, schema, nullable, optional, nullish, defaultValue, description, examples }: ModifierOptions): string {\n const withModifier = (() => {\n if (nullish || (nullable && optional)) return `${value}.nullish()`\n if (optional) return `${value}.optional()`\n if (nullable) return `${value}.nullable()`\n return value\n })()\n const literal = defaultValue !== undefined ? defaultLiteral(schema, defaultValue) : null\n const withDefault = literal !== null ? `${withModifier}.default(${literal})` : withModifier\n const withDescription = description ? `${withDefault}.describe(${stringify(description)})` : withDefault\n return examples?.length ? `${withDescription}.meta({ examples: [${examples.map(formatDefault).join(', ')}] })` : withDescription\n}\n\nfunction modifierDepth(schema: ast.SchemaNode): number {\n if (schema.nullish || (schema.nullable && schema.optional)) return 2\n if (schema.nullable || schema.optional) return 1\n return 0\n}\n\n/**\n * Build the `.unwrap()` chain to insert before `.omit()` when the schema is a `$ref`.\n *\n * A `$ref` resolves to a named schema variable that already carries its own `.nullable()` /\n * `.optional()` / `.nullish()` / `.default()` wrappers. `.omit()` lives on the inner `ZodObject`,\n * not on those `ZodNullable` / `ZodOptional` / `ZodDefault` wrappers, so the omit has to unwrap\n * down to the object first. This mirrors plugin-ts emitting `Omit<NonNullable<T>, …>`. Inline\n * objects need no unwrap because the printer adds their modifiers after `.omit()`.\n */\nexport function omitUnwrapChain(node: ast.SchemaNode): string {\n const ref = ast.narrowSchema(node, 'ref')\n if (!ref) return ''\n\n const target = ref.schema ?? ref\n const depth = modifierDepth(target) + (target.default !== undefined ? 1 : 0)\n return '.unwrap()'.repeat(depth)\n}\n\n/**\n * Apply nullable / optional / nullish modifiers using the functional `zod/mini` API\n * (`z.nullable()`, `z.optional()`, `z.nullish()`).\n */\nexport function applyMiniModifiers({ value, schema, nullable, optional, nullish, defaultValue }: Omit<ModifierOptions, 'description'>): string {\n const withModifier = (() => {\n if (nullish) return `z.nullish(${value})`\n const withNullable = nullable ? `z.nullable(${value})` : value\n return optional ? `z.optional(${withNullable})` : withNullable\n })()\n const literal = defaultValue !== undefined ? defaultLiteral(schema, defaultValue) : null\n return literal !== null ? `z._default(${withModifier}, ${literal})` : withModifier\n}\n\ntype BuildGroupedParamsSchemaOptions = {\n params: Array<ast.ParameterNode>\n optional?: boolean\n}\n\n/**\n * Builds an `object` schema node grouping the given parameter nodes.\n * The `primitive: 'object'` marker ensures the Zod printer emits `z.object(…)` rather than a record.\n */\nexport function buildGroupedParamsSchema({ params, optional }: BuildGroupedParamsSchemaOptions): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n optional,\n primitive: 'object',\n properties: params.map((param) =>\n ast.factory.createProperty({\n name: param.name,\n required: param.required,\n schema: param.schema,\n }),\n ),\n })\n}\n","import { buildList, buildObject, lazyGetter, objectKey, stringify } from '@internals/utils'\nimport { ast } from 'kubb/kit'\nimport type { PluginZod, ResolverZod } from '../types.ts'\nimport {\n applyModifiers,\n buildEnum,\n containsCodec,\n formatLiteral,\n getCodec,\n isObjectComposableIntersection,\n isObjectSchemaNode,\n lengthConstraints,\n numberConstraints,\n omitUnwrapChain,\n patternKeySchema,\n shouldCoerce,\n} from '../utils.ts'\nimport type { AdapterOas } from '@kubb/adapter-oas'\n\n/**\n * Partial map of node-type overrides for the Zod 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, `this.base` to reuse the output of the\n * handler being replaced, and `this.options` to read printer options.\n *\n * @example Override the `date` handler\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * date(node) {\n * return 'z.iso.date()'\n * },\n * },\n * },\n * })\n * ```\n *\n * @example Wrap the built-in output\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * object(node) {\n * return `${this.base(node)}.openapi(${JSON.stringify({ description: node.description })})`\n * },\n * },\n * },\n * })\n * ```\n */\nexport type PrinterZodNodes = ast.PrinterPartial<string, PrinterZodOptions>\n\nexport type PrinterZodOptions = {\n /**\n * Enable automatic type coercion for strings, numbers, and dates.\n */\n coercion?: PluginZod['resolvedOptions']['coercion']\n /**\n * Use `z.guid()` or `z.uuid()` for UUID/GUID validation.\n *\n * @default 'uuid'\n */\n guidType?: PluginZod['resolvedOptions']['guidType']\n /**\n * Output form for an OpenAPI `pattern` inside `.regex(...)`: a regex literal\n * (`'literal'`) or the `RegExp` constructor (`'constructor'`).\n *\n * @default 'literal'\n */\n regexType?: PluginZod['resolvedOptions']['regexType']\n /**\n * Date format in the OpenAPI spec (`'date'` or `'date-time'`).\n */\n dateType?: AdapterOas['resolvedOptions']['dateType']\n /**\n * Transforms raw schema names into valid JavaScript identifiers.\n */\n resolver?: ResolverZod\n /**\n * Properties to exclude using `.omit({ key: true })`.\n */\n keysToOmit?: Array<string> | null\n /**\n * Schema names that form circular dependency chains.\n * Properties referencing these emit lazy getters wrapping refs in `z.lazy(() => …)`.\n */\n cyclicSchemas?: ReadonlySet<string>\n /**\n * Print direction for `dateType: 'date'` fields (`Date` in TypeScript):\n * - `'output'` (default): decode the wire `string` into a `Date` (response bodies).\n * - `'input'`: encode a `Date` back into the wire `string` (request bodies/params).\n *\n * Diverging the directions requires the generator to emit an `${name}InputSchema`\n * variant for each date-bearing component.\n */\n direction?: 'input' | 'output'\n /**\n * Maps a component `$ref` path to its collision-resolved name. When two components collide\n * (across sections or by case), the adapter renames one of them; the `ref()` handler resolves\n * the referenced name through this map so the emitted schema reference matches the renamed component.\n */\n nameMapping?: ReadonlyMap<string, string>\n /**\n * Custom handler map for node type overrides.\n */\n nodes?: PrinterZodNodes\n}\n\n/**\n * Factory options for the Zod printer, defining input/output types and configuration.\n */\nexport type PrinterZodFactory = ast.PrinterFactoryOptions<'zod', PrinterZodOptions, string, string>\n\nfunction strictOneOfMember(member: string, node: ast.SchemaNode, cyclicSchemas?: ReadonlySet<string>): string {\n if (node.type === 'object' && node.additionalProperties === undefined) {\n return `${member}.strict()`\n }\n\n if (node.type === 'ref') {\n if (member.startsWith('z.lazy(')) {\n return member\n }\n\n // A cyclic ref is annotated `z.ZodType`, and a nullable/optional ref is wrapped in\n // ZodNullable/ZodOptional, and neither exposes `.strict()`. Only a bare `ZodObject` ref takes it.\n // A union member ref may carry only `node.name` (no `node.ref`), so fall back to it like `ref()`.\n const refName = (node.ref ? ast.extractRefName(node.ref) : undefined) ?? node.name\n if (refName && cyclicSchemas?.has(refName)) {\n return member\n }\n\n const schema = ast.syncSchemaRef(node)\n\n if (schema.nullable || schema.optional || node.nullable || node.optional) {\n return member\n }\n\n if (schema.type === 'object' && (schema.additionalProperties === undefined || schema.additionalProperties === false)) {\n return `${member}.strict()`\n }\n }\n\n return member\n}\n\nfunction getMemberConstraint({ member, regexType }: { member: ast.SchemaNode; regexType: PrinterZodOptions['regexType'] }): string | undefined {\n if (member.primitive === 'string') return lengthConstraints({ ...(ast.narrowSchema(member, 'string') ?? {}), regexType }) || undefined\n if (member.primitive === 'number' || member.primitive === 'integer')\n return numberConstraints(ast.narrowSchema(member, 'number') ?? ast.narrowSchema(member, 'integer') ?? {}) || undefined\n if (member.primitive === 'array') return lengthConstraints({ ...(ast.narrowSchema(member, 'array') ?? {}), regexType }) || undefined\n}\n\n/**\n * The printer slice `buildZodObjectShape` needs: the recursive `transform` and the resolved options.\n */\ntype ZodPrinterContext = {\n transform: (node: ast.SchemaNode) => string | null\n options: PrinterZodOptions\n}\n\n/**\n * Builds the `{ key: value, … }` shape for an object node, shared by the `z.object(...)` and\n * `.extend(...)` renderings so they stay in lockstep.\n */\nfunction buildZodObjectShape(ctx: ZodPrinterContext, node: ast.SchemaNode): string {\n const objectNode = ast.narrowSchema(node, 'object')\n if (!objectNode) return '{}'\n\n const isCyclic = (schema: ast.SchemaNode): boolean =>\n ctx.options.cyclicSchemas != null && ast.containsCircularRef(schema, { circularSchemas: ctx.options.cyclicSchemas })\n\n const entries = ast\n .mapSchemaProperties(objectNode, (schema) => {\n // Inside a getter the getter itself defers evaluation, so suppress z.lazy() wrapping on\n // nested refs by temporarily clearing cyclicSchemas.\n const hasSelfRef = isCyclic(schema)\n const savedCyclicSchemas = ctx.options.cyclicSchemas\n if (hasSelfRef) ctx.options.cyclicSchemas = undefined\n const baseOutput = ctx.transform(schema) ?? ctx.transform(ast.factory.createSchema({ type: 'unknown' }))!\n if (hasSelfRef) ctx.options.cyclicSchemas = savedCyclicSchemas\n return baseOutput\n })\n .map(({ name: propName, property, output: baseOutput }) => {\n const { schema } = property\n const meta = ast.syncSchemaRef(schema)\n\n // When a property schema is not a ref but the metadata is from a ref (e.g., discriminator\n // property override), skip applying the description from the ref target to avoid applying\n // metadata from a replaced schema.\n const descriptionToApply = schema.type !== 'ref' && meta.type === 'ref' ? undefined : meta.description\n\n const value = applyModifiers({\n value: baseOutput,\n schema,\n nullable: meta.nullable,\n optional: schema.optional || property.required === false,\n nullish: schema.nullish,\n defaultValue: meta.default,\n description: descriptionToApply,\n examples: meta.examples,\n })\n\n return isCyclic(schema) ? lazyGetter({ name: propName, body: value }) : `${objectKey(propName)}: ${value}`\n })\n\n return buildObject(entries)\n}\n\n/**\n * Zod v4 printer built with `definePrinter`.\n *\n * Converts a `SchemaNode` AST into a Zod v4 code string using the chainable API\n * (`.optional()`, `.nullable()`, `.omit()`, etc.). For improved tree-shaking, see {@link printerZodMini}.\n *\n * @example Chainable API\n * ```ts\n * const printer = printerZod({ coercion: false })\n * const code = printer.print(stringNode) // \"z.string()\"\n * ```\n */\nexport const printerZod = ast.createPrinter<PrinterZodFactory>((options) => {\n // The object handler temporarily reassigns `options.cyclicSchemas` to `undefined` while rendering a\n // getter body (to suppress nested `z.lazy()`), so capture a stable reference for the `.strict()`\n // skip decision, which must still see cyclic members inside those getter bodies.\n const cyclicSchemaNames = options.cyclicSchemas\n return {\n name: 'zod',\n options,\n nodes: {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n never: () => 'z.never()',\n boolean: () => 'z.boolean()',\n null: () => 'z.null()',\n string(node) {\n const base = shouldCoerce(this.options.coercion, 'strings') ? 'z.coerce.string()' : 'z.string()'\n\n return `${base}${lengthConstraints({ ...node, regexType: this.options.regexType })}`\n },\n number(node) {\n const base = shouldCoerce(this.options.coercion, 'numbers') ? 'z.coerce.number()' : 'z.number()'\n\n return `${base}${numberConstraints(node)}`\n },\n integer(node) {\n const base = shouldCoerce(this.options.coercion, 'numbers') ? 'z.coerce.number().int()' : 'z.int()'\n\n return `${base}${numberConstraints(node)}`\n },\n bigint() {\n return shouldCoerce(this.options.coercion, 'numbers') ? 'z.coerce.bigint()' : 'z.bigint()'\n },\n date(node) {\n // representation: 'date' fields are typed as `Date`, so decode/encode at the boundary.\n const codec = getCodec(node)\n if (codec) {\n if (this.options.direction === 'input') return codec.encode(node)\n return shouldCoerce(this.options.coercion, 'dates') ? 'z.coerce.date()' : codec.decode(node)\n }\n\n return 'z.iso.date()'\n },\n datetime(node) {\n const offset = node.offset || this.options.dateType === 'stringOffset'\n const local = node.local || this.options.dateType === 'stringLocal'\n\n if (offset) return 'z.iso.datetime({ offset: true })'\n if (local) return 'z.iso.datetime({ local: true })'\n\n return 'z.iso.datetime()'\n },\n time(node) {\n if (node.representation === 'string') {\n return 'z.iso.time()'\n }\n\n return shouldCoerce(this.options.coercion, 'dates') ? 'z.coerce.date()' : 'z.date()'\n },\n uuid(node) {\n const base = this.options.guidType === 'guid' ? 'z.guid()' : 'z.uuid()'\n\n return `${base}${lengthConstraints({ ...node, regexType: this.options.regexType })}`\n },\n email(node) {\n return `z.email()${lengthConstraints({ ...node, regexType: this.options.regexType })}`\n },\n url(node) {\n return `z.url()${lengthConstraints({ ...node, regexType: this.options.regexType })}`\n },\n ipv4: () => 'z.ipv4()',\n ipv6: () => 'z.ipv6()',\n blob: () => 'z.instanceof(File)',\n enum(node) {\n const values = node.namedEnumValues?.map((v) => v.value) ?? node.enumValues ?? []\n const nonNullValues = values.filter((v): v is string | number | boolean => v !== null)\n\n // asConst-style enum: use z.union([z.literal(…), …])\n if (node.namedEnumValues?.length) {\n const literals = nonNullValues.map((v) => `z.literal(${formatLiteral(v)})`)\n\n if (literals.length === 1) return literals[0]!\n return `z.union([${literals.join(', ')}])`\n }\n\n // Regular enum: z.enum for all-string sets, z.literal/z.union otherwise\n return buildEnum(nonNullValues)\n },\n ref(node) {\n if (!node.name) return null\n // `nameMapping` (keyed by the full $ref) carries the collision-resolved name when the\n // referenced component was renamed; otherwise fall back to the short ref name.\n const refName = node.ref ? (this.options.nameMapping?.get(node.ref) ?? ast.extractRefName(node.ref) ?? node.name) : node.name\n\n // In the input direction, a date-bearing component resolves to its `${name}InputSchema`\n // variant so request bodies encode `Date → string` instead of decoding.\n const useInputVariant = node.ref != null && this.options.direction === 'input' && containsCodec(node)\n const resolvedName = node.ref\n ? useInputVariant\n ? (this.options.resolver?.schema.inputName(refName) ?? refName)\n : (this.options.resolver?.name(refName) ?? refName)\n : node.name\n\n if (node.ref && this.options.cyclicSchemas?.has(refName)) {\n return `z.lazy(() => ${resolvedName})`\n }\n\n return resolvedName\n },\n object(node) {\n const entries = node.properties ?? []\n const objectBase = `z.object(${buildZodObjectShape(this, node)})`\n\n const result = (() => {\n const patterns = node.patternProperties ? Object.entries(node.patternProperties) : []\n\n if (node.additionalProperties && node.additionalProperties !== true) {\n const catchallType = this.transform(node.additionalProperties)\n return catchallType ? `${objectBase}.catchall(${catchallType})` : objectBase\n }\n if (node.additionalProperties === true) return `${objectBase}.catchall(${this.transform(ast.factory.createSchema({ type: 'unknown' }))})`\n // `additionalProperties: false` still permits patternProperties keys, so skip `.strict()` when patterns exist.\n if (node.additionalProperties === false && patterns.length === 0) return `${objectBase}.strict()`\n\n // No fixed properties: z.record enforces the key pattern. With fixed properties a record would\n // reject the declared keys, so fall back to .catchall (value validated, key pattern not).\n if (patterns.length > 0) {\n const values = patterns.map(([, valueSchema]) => {\n const valueType = this.transform(valueSchema) ?? this.transform(ast.factory.createSchema({ type: 'unknown' }))!\n return valueSchema.nullable ? `${valueType}.nullable()` : valueType\n })\n const distinct = [...new Set(values)]\n const value = distinct.length === 1 ? distinct[0]! : `z.union([${distinct.join(', ')}])`\n\n if (entries.length > 0) return `${objectBase}.catchall(${value})`\n return `z.record(${patternKeySchema({ patterns: patterns.map(([pattern]) => pattern), regexType: this.options.regexType })}, ${value})`\n }\n return objectBase\n })()\n\n return result\n },\n array(node) {\n const items = ast\n .mapSchemaItems(node, (item) => this.transform(item))\n .map(({ output }) => output)\n .filter(Boolean)\n const inner = items.join(', ') || this.transform(ast.factory.createSchema({ type: 'unknown' }))!\n const base = `z.array(${inner})${lengthConstraints({ ...node, regexType: this.options.regexType })}`\n\n return node.unique ? `${base}.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : base\n },\n tuple(node) {\n const items = ast\n .mapSchemaItems(node, (item) => this.transform(item))\n .map(({ output }) => output)\n .filter(Boolean)\n\n return `z.tuple(${buildList(items)})`\n },\n union(node) {\n const nodeMembers = node.members ?? []\n const members = ast\n .mapSchemaMembers(node, (memberNode) => this.transform(memberNode))\n .map(({ schema, output }) => (output && node.strategy === 'one' ? strictOneOfMember(output, schema, cyclicSchemaNames) : output))\n .filter(Boolean)\n if (members.length === 0) return ''\n if (members.length === 1) return members[0]!\n // z.discriminatedUnion needs every option to be a ZodObject. Object variants (refs or\n // `.extend(…)`-composed `allOf`) qualify; intersections, cyclic `z.lazy(…)` refs, and\n // non-objects fall back to z.union.\n const allDiscriminable = nodeMembers.every((m) => isObjectSchemaNode(m, cyclicSchemaNames))\n if (node.discriminatorPropertyName && allDiscriminable) {\n return `z.discriminatedUnion(${stringify(node.discriminatorPropertyName)}, ${buildList(members)})`\n }\n\n return `z.union(${buildList(members)})`\n },\n intersection(node) {\n const members = node.members ?? []\n if (members.length === 0) return ''\n\n const [first, ...rest] = members\n if (!first) return ''\n\n const firstBase = this.transform(first)\n if (!firstBase) return ''\n\n // An object `allOf` is a merge, not a runtime intersection: `.extend({ … })` keeps it a\n // ZodObject (usable in z.discriminatedUnion) instead of the non-discriminable `.and(…)`.\n if (rest.length > 0 && isObjectComposableIntersection(node, cyclicSchemaNames)) {\n return rest.reduce((acc, member) => `${acc}.extend(${buildZodObjectShape(this, member)})`, firstBase)\n }\n\n return rest.reduce((acc, member) => {\n const constraint = getMemberConstraint({ member, regexType: this.options.regexType })\n if (constraint) return acc + constraint\n const transformed = this.transform(member)\n return transformed ? `${acc}.and(${transformed})` : acc\n }, firstBase)\n },\n },\n overrides: options.nodes,\n print(node) {\n const { keysToOmit } = this.options\n\n const transformed = this.transform(node)\n if (!transformed) return null\n\n const meta = ast.syncSchemaRef(node)\n\n const base = (() => {\n if (!keysToOmit?.length || meta.primitive !== 'object' || (meta.type === 'union' && meta.discriminatorPropertyName)) return transformed\n // Discriminated unions (z.discriminatedUnion) do not support .omit(), so skip them.\n\n // A nullable/optional ref resolves to a ZodNullable/ZodOptional variable; .omit() lives on\n // the inner ZodObject, so unwrap down to it first (mirrors printerTs `Omit<NonNullable<T>, …>`).\n // applyModifiers re-applies the nullable/optional wrapper after the omit.\n const unwrap = omitUnwrapChain(node)\n const omit = `.omit({ ${keysToOmit.map((k: string) => `\"${k}\": true`).join(', ')} })`\n\n // If this is a lazy reference, apply omit inside the lazy function\n const lazyMatch = transformed.match(/^z\\.lazy\\(\\(\\)\\s*=>\\s*(.+)\\)$/)\n if (lazyMatch) return `z.lazy(() => ${lazyMatch[1]}${unwrap}${omit})`\n return `${transformed}${unwrap}${omit}`\n })()\n\n return applyModifiers({\n value: base,\n schema: node,\n nullable: meta.nullable,\n optional: meta.optional,\n nullish: meta.nullish,\n defaultValue: meta.default,\n description: meta.description,\n examples: meta.examples,\n })\n },\n }\n})\n","import { buildList, buildObject, lazyGetter, objectKey, stringify } from '@internals/utils'\nimport { ast } from 'kubb/kit'\nimport type { PluginZod, ResolverZod } from '../types.ts'\nimport {\n applyMiniModifiers,\n buildEnum,\n formatLiteral,\n isObjectComposableIntersection,\n isObjectSchemaNode,\n lengthChecksMini,\n numberChecksMini,\n omitUnwrapChain,\n patternKeySchemaMini,\n} from '../utils.ts'\n\n/**\n * Partial map of node-type overrides for the Zod Mini 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, `this.base` to reuse the output of the\n * handler being replaced, and `this.options` to read printer options.\n *\n * @example Override the `date` handler\n * ```ts\n * pluginZod({\n * mini: true,\n * printer: {\n * nodes: {\n * date(node) {\n * return 'z.iso.date()'\n * },\n * },\n * },\n * })\n * ```\n */\nexport type PrinterZodMiniNodes = ast.PrinterPartial<string, PrinterZodMiniOptions>\n\nexport type PrinterZodMiniOptions = {\n /**\n * Use `z.guid()` or `z.uuid()` for UUID/GUID validation.\n *\n * @default 'uuid'\n */\n guidType?: PluginZod['resolvedOptions']['guidType']\n /**\n * Output form for an OpenAPI `pattern` inside `z.regex(...)`: a regex literal\n * (`'literal'`) or the `RegExp` constructor (`'constructor'`).\n *\n * @default 'literal'\n */\n regexType?: PluginZod['resolvedOptions']['regexType']\n /**\n * Transforms raw schema names into valid JavaScript identifiers.\n */\n resolver?: ResolverZod\n /**\n * Properties to exclude using `.omit({ key: true })`.\n */\n keysToOmit?: Array<string> | null\n /**\n * Schema names that form circular dependency chains.\n * Properties referencing these emit lazy getters wrapping refs in `z.lazy(() => …)`.\n */\n cyclicSchemas?: ReadonlySet<string>\n /**\n * Maps a component `$ref` path to its collision-resolved name. When two components collide\n * (across sections or by case), the adapter renames one of them; the `ref()` handler resolves\n * the referenced name through this map so the emitted schema reference matches the renamed component.\n */\n nameMapping?: ReadonlyMap<string, string>\n /**\n * Custom handler map for node type overrides.\n */\n nodes?: PrinterZodMiniNodes\n}\n\n/**\n * Factory options for the Zod Mini printer, defining input/output types and configuration.\n */\nexport type PrinterZodMiniFactory = ast.PrinterFactoryOptions<'zod-mini', PrinterZodMiniOptions, string, string>\n\nfunction strictOneOfMember(member: string, node: ast.SchemaNode): string {\n if (node.type === 'object' && (node.additionalProperties === undefined || node.additionalProperties === false)) {\n return member.replace(/^z\\.object\\(/, 'z.strictObject(')\n }\n\n return member\n}\n\nfunction getMemberConstraintMini({ member, regexType }: { member: ast.SchemaNode; regexType: PrinterZodMiniOptions['regexType'] }): string | undefined {\n if (member.primitive === 'string') return lengthChecksMini({ ...(ast.narrowSchema(member, 'string') ?? {}), regexType }) || undefined\n if (member.primitive === 'number' || member.primitive === 'integer')\n return numberChecksMini(ast.narrowSchema(member, 'number') ?? ast.narrowSchema(member, 'integer') ?? {}) || undefined\n if (member.primitive === 'array') return lengthChecksMini({ ...(ast.narrowSchema(member, 'array') ?? {}), regexType }) || undefined\n}\n\n/**\n * The Mini printer slice `buildZodMiniObjectShape` needs: the recursive `transform` and the options.\n */\ntype ZodMiniPrinterContext = {\n transform: (node: ast.SchemaNode) => string | null\n options: PrinterZodMiniOptions\n}\n\n/**\n * Builds the `{ key: value, … }` shape for an object node with the functional `zod/mini` modifiers,\n * shared by the `z.object(...)` and `z.extend(...)` renderings so they stay in lockstep.\n */\nfunction buildZodMiniObjectShape(ctx: ZodMiniPrinterContext, node: ast.SchemaNode): string {\n const objectNode = ast.narrowSchema(node, 'object')\n if (!objectNode) return '{}'\n\n const isCyclic = (schema: ast.SchemaNode): boolean =>\n ctx.options.cyclicSchemas != null && ast.containsCircularRef(schema, { circularSchemas: ctx.options.cyclicSchemas })\n\n const entries = ast\n .mapSchemaProperties(objectNode, (schema) => {\n const hasSelfRef = isCyclic(schema)\n const savedCyclicSchemas = ctx.options.cyclicSchemas\n if (hasSelfRef) ctx.options.cyclicSchemas = undefined\n const baseOutput = ctx.transform(schema) ?? ctx.transform(ast.factory.createSchema({ type: 'unknown' }))!\n if (hasSelfRef) ctx.options.cyclicSchemas = savedCyclicSchemas\n return baseOutput\n })\n .map(({ name: propName, property, output: baseOutput }) => {\n const { schema } = property\n const meta = ast.syncSchemaRef(schema)\n\n const value = applyMiniModifiers({\n value: baseOutput,\n schema,\n nullable: meta.nullable,\n optional: schema.optional || property.required === false,\n nullish: schema.nullish,\n defaultValue: meta.default,\n })\n\n return isCyclic(schema) ? lazyGetter({ name: propName, body: value }) : `${objectKey(propName)}: ${value}`\n })\n\n return buildObject(entries)\n}\n\n/**\n * Zod v4 Mini printer built with `definePrinter`.\n *\n * Converts a `SchemaNode` AST into a Zod v4 code string using the functional API\n * (`z.optional(z.string())`) for improved tree-shaking. See {@link printerZod} for the chainable API.\n *\n * @example Functional Mini API\n * ```ts\n * const printer = printerZodMini({})\n * const code = printer.print(optionalStringNode) // \"z.optional(z.string())\"\n * ```\n */\nexport const printerZodMini = ast.createPrinter<PrinterZodMiniFactory>((options) => {\n // The object handler temporarily clears `options.cyclicSchemas` while rendering a getter body, so\n // capture a stable reference for the intersection/union discriminability decisions.\n const cyclicSchemaNames = options.cyclicSchemas\n return {\n name: 'zod-mini',\n options,\n nodes: {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n never: () => 'z.never()',\n boolean: () => 'z.boolean()',\n null: () => 'z.null()',\n string(node) {\n return `z.string()${lengthChecksMini({ ...node, regexType: this.options.regexType })}`\n },\n number(node) {\n return `z.number()${numberChecksMini(node)}`\n },\n integer(node) {\n return `z.int()${numberChecksMini(node)}`\n },\n bigint(node) {\n return `z.bigint()${numberChecksMini(node)}`\n },\n date(node) {\n if (node.representation === 'string') {\n return 'z.iso.date()'\n }\n\n return 'z.date()'\n },\n datetime() {\n // Mini mode: datetime validation via z.string() (z.iso.datetime not available in mini)\n return 'z.string()'\n },\n time(node) {\n if (node.representation === 'string') {\n return 'z.iso.time()'\n }\n\n return 'z.date()'\n },\n uuid(node) {\n const base = this.options.guidType === 'guid' ? 'z.guid()' : 'z.uuid()'\n\n return `${base}${lengthChecksMini({ ...node, regexType: this.options.regexType })}`\n },\n email(node) {\n return `z.email()${lengthChecksMini({ ...node, regexType: this.options.regexType })}`\n },\n url(node) {\n return `z.url()${lengthChecksMini({ ...node, regexType: this.options.regexType })}`\n },\n ipv4: () => 'z.ipv4()',\n ipv6: () => 'z.ipv6()',\n blob: () => 'z.instanceof(File)',\n enum(node) {\n const values = node.namedEnumValues?.map((v) => v.value) ?? node.enumValues ?? []\n const nonNullValues = values.filter((v): v is string | number | boolean => v !== null)\n\n // asConst-style enum: use z.union([z.literal(…), …])\n if (node.namedEnumValues?.length) {\n const literals = nonNullValues.map((v) => `z.literal(${formatLiteral(v)})`)\n if (literals.length === 1) return literals[0]!\n return `z.union([${literals.join(', ')}])`\n }\n\n // Regular enum: z.enum for all-string sets, z.literal/z.union otherwise\n return buildEnum(nonNullValues)\n },\n\n ref(node) {\n if (!node.name) return null\n // `nameMapping` (keyed by the full $ref) carries the collision-resolved name when the\n // referenced component was renamed; otherwise fall back to the short ref name.\n const refName = node.ref ? (this.options.nameMapping?.get(node.ref) ?? ast.extractRefName(node.ref) ?? node.name) : node.name\n const resolvedName = node.ref ? (this.options.resolver?.name(refName) ?? refName) : node.name\n\n if (node.ref && this.options.cyclicSchemas?.has(refName)) {\n return `z.lazy(() => ${resolvedName})`\n }\n\n return resolvedName\n },\n object(node) {\n const entries = node.properties ?? []\n const objectBase = `z.object(${buildZodMiniObjectShape(this, node)})`\n\n // zod/mini has no chainable `.catchall()`/`.strict()`, so route through the functional forms.\n const patterns = node.patternProperties ? Object.entries(node.patternProperties) : []\n\n if (node.additionalProperties && node.additionalProperties !== true) {\n const catchallType = this.transform(node.additionalProperties)\n return catchallType ? `z.catchall(${objectBase}, ${catchallType})` : objectBase\n }\n if (node.additionalProperties === true) return `z.catchall(${objectBase}, ${this.transform(ast.factory.createSchema({ type: 'unknown' }))})`\n if (node.additionalProperties === false && patterns.length === 0) return objectBase.replace(/^z\\.object\\(/, 'z.strictObject(')\n\n if (patterns.length > 0) {\n const values = patterns.map(([, valueSchema]) => {\n const valueType = this.transform(valueSchema) ?? this.transform(ast.factory.createSchema({ type: 'unknown' }))!\n return valueSchema.nullable ? `z.nullable(${valueType})` : valueType\n })\n const distinct = [...new Set(values)]\n const value = distinct.length === 1 ? distinct[0]! : `z.union([${distinct.join(', ')}])`\n\n if (entries.length > 0) return `z.catchall(${objectBase}, ${value})`\n return `z.record(${patternKeySchemaMini({ patterns: patterns.map(([pattern]) => pattern), regexType: this.options.regexType })}, ${value})`\n }\n return objectBase\n },\n array(node) {\n const items = ast\n .mapSchemaItems(node, (item) => this.transform(item))\n .map(({ output }) => output)\n .filter(Boolean)\n const inner = items.join(', ') || this.transform(ast.factory.createSchema({ type: 'unknown' }))!\n const base = `z.array(${inner})${lengthChecksMini({ ...node, regexType: this.options.regexType })}`\n\n return node.unique ? `${base}.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : base\n },\n tuple(node) {\n const items = ast\n .mapSchemaItems(node, (item) => this.transform(item))\n .map(({ output }) => output)\n .filter(Boolean)\n\n return `z.tuple(${buildList(items)})`\n },\n union(node) {\n const nodeMembers = node.members ?? []\n const members = ast\n .mapSchemaMembers(node, (memberNode) => this.transform(memberNode))\n .map(({ schema, output }) => (output && node.strategy === 'one' ? strictOneOfMember(output, schema) : output))\n .filter(Boolean)\n if (members.length === 0) return ''\n if (members.length === 1) return members[0]!\n // z.discriminatedUnion needs every option to be a Zod object. Object variants (refs or\n // `z.extend(…)`-composed `allOf`) qualify; intersections, cyclic `z.lazy(…)` refs, and\n // non-objects fall back to z.union.\n const allDiscriminable = nodeMembers.every((m) => isObjectSchemaNode(m, cyclicSchemaNames))\n if (node.discriminatorPropertyName && allDiscriminable) {\n return `z.discriminatedUnion(${stringify(node.discriminatorPropertyName)}, ${buildList(members)})`\n }\n\n return `z.union(${buildList(members)})`\n },\n intersection(node) {\n const members = node.members ?? []\n if (members.length === 0) return ''\n\n const [first, ...rest] = members\n if (!first) return ''\n\n const firstBase = this.transform(first)\n if (!firstBase) return ''\n\n // An object `allOf` is a merge, not a runtime intersection: `z.extend(base, { … })` keeps it\n // a Zod object (usable in z.discriminatedUnion) instead of a non-discriminable `z.intersection`.\n if (rest.length > 0 && isObjectComposableIntersection(node, cyclicSchemaNames)) {\n return rest.reduce((acc, member) => `z.extend(${acc}, ${buildZodMiniObjectShape(this, member)})`, firstBase)\n }\n\n return rest.reduce((acc, member) => {\n const constraint = getMemberConstraintMini({ member, regexType: this.options.regexType })\n if (constraint) return acc + constraint\n const transformed = this.transform(member)\n return transformed ? `z.intersection(${acc}, ${transformed})` : acc\n }, firstBase)\n },\n },\n overrides: options.nodes,\n print(node) {\n const { keysToOmit } = this.options\n\n const transformed = this.transform(node)\n if (!transformed) return null\n\n const meta = ast.syncSchemaRef(node)\n\n const base = (() => {\n if (!keysToOmit?.length || meta.primitive !== 'object' || (meta.type === 'union' && meta.discriminatorPropertyName)) return transformed\n // Discriminated unions (z.discriminatedUnion) do not support .omit(), so skip them.\n\n // A nullable/optional ref resolves to a ZodMiniNullable/ZodMiniOptional variable; .omit() lives\n // on the inner object, so unwrap down to it first (mirrors printerTs `Omit<NonNullable<T>, …>`).\n // applyMiniModifiers re-applies the nullable/optional wrapper after the omit.\n const unwrap = omitUnwrapChain(node)\n const omit = `.omit({ ${keysToOmit.map((k: string) => `\"${k}\": true`).join(', ')} })`\n\n // If this is a lazy reference, apply omit inside the lazy function\n const lazyMatch = transformed.match(/^z\\.lazy\\(\\(\\)\\s*=>\\s*(.+)\\)$/)\n if (lazyMatch) return `z.lazy(() => ${lazyMatch[1]}${unwrap}${omit})`\n return `${transformed}${unwrap}${omit}`\n })()\n\n return applyMiniModifiers({\n value: base,\n schema: node,\n nullable: meta.nullable,\n optional: meta.optional,\n nullish: meta.nullish,\n defaultValue: meta.default,\n })\n },\n }\n})\n","import { caseParams, getSuccessResponses, isSuccessStatusCode, resolveContentTypeVariants } from '@internals/shared'\nimport type { Adapter } from 'kubb/kit'\nimport { ast, defineGenerator } from 'kubb/kit'\nimport type { AdapterOas } from '@kubb/adapter-oas'\nimport { File, jsxRenderer } from 'kubb/jsx'\nimport { Zod } from '../components/Zod.tsx'\nimport { ZOD_NAMESPACE_IMPORTS } from '../constants.ts'\nimport { printerZod } from '../printers/printerZod.ts'\nimport { printerZodMini } from '../printers/printerZodMini.ts'\nimport type { PluginZod, ResolverZod } from '../types'\nimport { collectCodecRefNames, containsCodec } from '../utils.ts'\n\ntype StdPrinters = { output: ReturnType<typeof printerZod>; input: ReturnType<typeof printerZod> }\ntype ZodPrinterEntry = StdPrinters & { coercion: unknown; guidType: unknown; regexType: unknown; dateType: unknown; nodes: unknown }\ntype ZodMiniPrinterEntry = { printer: ReturnType<typeof printerZodMini>; guidType: unknown; regexType: unknown; nodes: unknown }\n\n// Per-build caches: keyed on resolver (unique per plugin instance per build, GC'd when released)\nconst zodPrinterCache = new WeakMap<ResolverZod, ZodPrinterEntry>()\nconst zodMiniPrinterCache = new WeakMap<ResolverZod, ZodMiniPrinterEntry>()\n\ntype StdPrinterParams = {\n coercion: unknown\n guidType: unknown\n regexType: unknown\n dateType: unknown\n cyclicSchemas: ReadonlySet<string>\n nameMapping?: ReadonlyMap<string, string>\n nodes: unknown\n}\n\ntype BuildResponseUnionParams = {\n responses: Array<ast.ResponseNode>\n name: string\n fallbackUnknown: boolean\n}\n\n/**\n * Returns the cached `output`/`input` direction printers for a resolver, building them on\n * first use. The `input` printer encodes `Date → string` for request bodies, and `output` decodes\n * `string → Date` for responses. Schemas without `dateType: 'date'` fields print identically.\n */\nfunction getStdPrinters(resolver: ResolverZod, params: StdPrinterParams): StdPrinters {\n const cached = zodPrinterCache.get(resolver)\n if (\n cached &&\n cached.coercion === params.coercion &&\n cached.guidType === params.guidType &&\n cached.regexType === params.regexType &&\n cached.dateType === params.dateType &&\n cached.nodes === params.nodes\n ) {\n return { output: cached.output, input: cached.input }\n }\n const base = { ...params, resolver } as Parameters<typeof printerZod>[0]\n const output = printerZod({ ...base, direction: 'output' })\n const input = printerZod({ ...base, direction: 'input' })\n zodPrinterCache.set(resolver, {\n output,\n input,\n coercion: params.coercion,\n guidType: params.guidType,\n regexType: params.regexType,\n dateType: params.dateType,\n nodes: params.nodes,\n })\n return { output, input }\n}\n\nfunction getMiniPrinter(\n resolver: ResolverZod,\n params: {\n guidType: unknown\n regexType: unknown\n cyclicSchemas: ReadonlySet<string>\n nameMapping?: ReadonlyMap<string, string>\n nodes: unknown\n },\n) {\n const cached = zodMiniPrinterCache.get(resolver)\n if (cached && cached.guidType === params.guidType && cached.regexType === params.regexType && cached.nodes === params.nodes) return cached.printer\n const p = printerZodMini({ ...params, resolver } as Parameters<typeof printerZodMini>[0])\n zodMiniPrinterCache.set(resolver, { printer: p, guidType: params.guidType, regexType: params.regexType, nodes: params.nodes })\n return p\n}\n\n/**\n * Built-in generator for `@kubb/plugin-zod`. Emits one Zod schema per\n * schema in the spec plus per-operation request/response/parameter schemas.\n * When `mini: true`, schemas use the Zod Mini functional API instead of\n * chainable methods.\n */\nexport const zodGenerator = defineGenerator<PluginZod>({\n name: 'zod',\n renderer: jsxRenderer,\n schema(node, ctx) {\n const { adapter, config, resolver, root } = ctx\n const { output, coercion, guidType, regexType, mini, inferred, importPath, group, printer } = ctx.options\n const dateType = (adapter as Adapter<AdapterOas>).options.dateType\n\n if (!node.name) {\n return\n }\n\n const isZodImport = ZOD_NAMESPACE_IMPORTS.has(importPath as 'zod' | 'zod/mini')\n const cyclicSchemas = new Set<string>(ctx.meta.circularNames)\n\n // A codec component is rendered twice: the canonical (output) schema decodes\n // `string → Date`, and an `${name}InputSchema` variant encodes `Date → string` for requests.\n const hasCodec = !mini && containsCodec(node)\n\n const codecRefNames = new Set(hasCodec ? collectCodecRefNames(node) : [])\n const importEntries = adapter.getImports(node, (schemaName) => ({\n name: resolver.name(schemaName),\n path: resolver.file({ name: schemaName, extname: '.ts', root, output, group: group ?? undefined }).path,\n }))\n const inputImportEntries = hasCodec\n ? [...codecRefNames].map((schemaName) => ({\n name: [resolver.schema.inputName(schemaName)],\n path: resolver.file({ name: schemaName, extname: '.ts', root, output, group: group ?? undefined }).path,\n }))\n : []\n const seenImports = new Set<string>()\n const imports = [...importEntries, ...inputImportEntries].filter((imp) => {\n const key = `${Array.isArray(imp.name) ? imp.name.join(',') : imp.name}|${imp.path}`\n if (seenImports.has(key)) return false\n seenImports.add(key)\n return true\n })\n\n const meta = {\n name: resolver.name(node.name),\n file: resolver.file({ name: node.name, extname: '.ts', root, output, group: group ?? undefined }),\n } as const\n\n const inferTypeName = inferred ? resolver.schema.typeName(node.name) : null\n\n const nameMapping = (adapter as Adapter<AdapterOas>).options.nameMapping\n const stdPrinters = mini ? null : getStdPrinters(resolver, { coercion, guidType, regexType, dateType, cyclicSchemas, nameMapping, nodes: printer?.nodes })\n const schemaPrinter = mini ? getMiniPrinter(resolver, { guidType, regexType, cyclicSchemas, nameMapping, nodes: printer?.nodes }) : stdPrinters!.output\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 <File.Import name={isZodImport ? 'z' : ['z']} path={importPath} isNameSpace={isZodImport} />\n {imports.map((imp) => (\n <File.Import key={[node.name, imp.path, imp.name].join('-')} root={meta.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Zod name={meta.name} node={node} printer={schemaPrinter} inferTypeName={inferTypeName} cyclic={cyclicSchemas.has(node.name)} />\n {hasCodec && stdPrinters && (\n <Zod\n name={resolver.schema.inputName(node.name)}\n node={node}\n printer={stdPrinters.input}\n inferTypeName={inferred ? resolver.schema.inputTypeName(node.name) : null}\n cyclic={cyclicSchemas.has(node.name)}\n />\n )}\n </File>\n )\n },\n operation(node, ctx) {\n if (!ast.isHttpOperationNode(node)) return null\n const { adapter, config, resolver, root } = ctx\n const { output, coercion, guidType, regexType, mini, inferred, importPath, group, printer } = ctx.options\n const dateType = (adapter as Adapter<AdapterOas>).options.dateType\n\n const isZodImport = ZOD_NAMESPACE_IMPORTS.has(importPath as 'zod' | 'zod/mini')\n\n const params = caseParams(node.parameters, 'camelcase')\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 const cyclicSchemas = new Set<string>(ctx.meta.circularNames)\n const nameMapping = (adapter as Adapter<AdapterOas>).options.nameMapping\n\n function renderSchemaEntry({\n schema,\n name,\n keysToOmit,\n direction = 'output',\n }: {\n schema: ast.SchemaNode | null\n name: string\n keysToOmit?: Array<string> | null\n direction?: 'input' | 'output'\n }) {\n if (!schema) return null\n\n const inferTypeName = inferred ? resolver.schema.type(name) : null\n\n // In the input direction, refs to codec components resolve to their input variant.\n const codecRefNames = direction === 'input' && !mini ? new Set(collectCodecRefNames(schema)) : null\n const imports = adapter.getImports(schema, (schemaName) => ({\n name: codecRefNames?.has(schemaName) ? resolver.schema.inputName(schemaName) : resolver.name(schemaName),\n path: resolver.file({ name: schemaName, extname: '.ts', root, output, group: group ?? undefined }).path,\n }))\n\n const schemaPrinter = mini\n ? keysToOmit?.length\n ? printerZodMini({ guidType, regexType, resolver, keysToOmit, cyclicSchemas, nameMapping, nodes: printer?.nodes })\n : getMiniPrinter(resolver, { guidType, regexType, cyclicSchemas, nameMapping, nodes: printer?.nodes })\n : keysToOmit?.length\n ? printerZod({\n coercion,\n guidType,\n regexType,\n dateType,\n resolver,\n keysToOmit,\n cyclicSchemas,\n nameMapping,\n nodes: printer?.nodes,\n direction,\n })\n : getStdPrinters(resolver, { coercion, guidType, regexType, dateType, cyclicSchemas, nameMapping, nodes: printer?.nodes })[direction]\n\n return (\n <>\n {imports.map((imp) => (\n <File.Import key={[name, imp.path, imp.name].join('-')} root={meta.file.path} path={imp.path} name={imp.name} />\n ))}\n {/* Operation schemas reference (and import) the component schemas, which carry the\n `z.ZodType` annotation at their own definition when cyclic. Annotating the operation\n schema too would only erase its inferred type to `unknown`, breaking typed consumers\n (e.g. the MCP server's request types), so it is never marked cyclic here. */}\n <Zod name={name} node={schema} printer={schemaPrinter} inferTypeName={inferTypeName} cyclic={false} />\n </>\n )\n }\n\n // Multiple content types for a single name: emit one schema per content type plus a union alias.\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 direction?: 'input' | 'output',\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 renderSchemaEntry({\n schema: decorate ? decorate(variant.schema) : variant.schema,\n name: variant.name,\n keysToOmit: variant.keysToOmit,\n direction,\n }),\n )}\n {renderSchemaEntry({ schema: unionSchema, name: baseName, direction })}\n </>\n )\n }\n\n // Builds a response/error union schema: one schema per member response, aliased under `name`.\n function buildResponseUnion({ responses, name, fallbackUnknown }: BuildResponseUnionParams) {\n // Collect import names from the response schemas to detect naming collisions. When a response\n // is a $ref to a component schema whose resolved name matches `name`, skip generation to avoid\n // redeclaration errors.\n const importedNames = new Set(\n responses.flatMap((res) =>\n (res.content ?? []).flatMap((entry) =>\n entry.schema\n ? adapter\n .getImports(entry.schema, (schemaName) => ({\n name: resolver.name(schemaName),\n path: '',\n }))\n .flatMap((imp) => (Array.isArray(imp.name) ? imp.name : [imp.name]))\n : [],\n ),\n ),\n )\n\n if (importedNames.has(name)) {\n return null\n }\n\n const members = responses.map((res) => ast.factory.createSchema({ type: 'ref', name: resolver.response.status(node, res.statusCode) }))\n\n // No documented schema: fall back to an unknown schema so the name still resolves for\n // consumers that parse those bodies.\n if (fallbackUnknown && members.length === 0) {\n return renderSchemaEntry({ schema: ast.factory.createSchema({ type: 'unknown' }), name })\n }\n\n const unionNode = members.length === 1 ? members[0]! : ast.factory.createSchema({ type: 'union', members })\n\n return renderSchemaEntry({\n schema: unionNode,\n name,\n })\n }\n\n const paramSchemas = params.map((param) => renderSchemaEntry({ schema: param.schema, name: resolver.param.name(node, param), direction: 'input' }))\n\n const responseSchemas = node.responses.map((res) => {\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length > 1) {\n return buildContentTypeVariants(res.content!, resolver.response.status(node, res.statusCode))\n }\n const primary = variants[0] ?? res.content?.[0]\n return renderSchemaEntry({\n schema: primary?.schema ?? null,\n name: resolver.response.status(node, res.statusCode),\n keysToOmit: primary?.keysToOmit,\n })\n })\n\n const responsesWithSchema = node.responses.filter((res) => res.content?.some((entry) => entry.schema))\n // Validate success (2xx) bodies only. Error bodies are surfaced unparsed, typed by plugin-ts (#369).\n const successResponsesWithSchema = getSuccessResponses(responsesWithSchema)\n const responseUnionSchema =\n responsesWithSchema.length > 0\n ? buildResponseUnion({ responses: successResponsesWithSchema, name: resolver.response.response(node), fallbackUnknown: true })\n : null\n\n // Validate error bodies on the non-throw path. Mirrors the success union but selects every\n // non-2xx response (including the OpenAPI `default`) so it lines up with plugin-ts `ErrorOf` (#369).\n const errorResponsesWithSchema = responsesWithSchema.filter((res) => !isSuccessStatusCode(res.statusCode))\n const errorUnionSchema =\n errorResponsesWithSchema.length > 0\n ? buildResponseUnion({ responses: errorResponsesWithSchema, name: resolver.response.error(node), fallbackUnknown: false })\n : null\n\n const requestBodyContent = node.requestBody?.content ?? []\n const requestSchema = (() => {\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 renderSchemaEntry({\n schema: { ...entry.schema, description: node.requestBody!.description ?? entry.schema.description },\n name: resolver.response.body(node),\n keysToOmit: entry.keysToOmit,\n direction: 'input',\n })\n }\n return buildContentTypeVariants(\n requestBodyContent,\n resolver.response.body(node),\n (schema) => ({\n ...schema,\n description: node.requestBody!.description ?? schema.description,\n }),\n 'input',\n )\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 <File.Import name={isZodImport ? 'z' : ['z']} path={importPath} isNameSpace={isZodImport} />\n {paramSchemas}\n {responseSchemas}\n {responseUnionSchema}\n {errorUnionSchema}\n {requestSchema}\n </File>\n )\n },\n})\n","import { camelCase, ensureValidVarName, pascalCase, toFilePath } from '@internals/utils'\nimport { createResolver } from 'kubb/kit'\nimport type { PluginZod } from '../types.ts'\n\n/**\n * Default resolver used by `@kubb/plugin-zod`. Decides the names and file\n * paths for every generated Zod schema. Schemas use camelCase with a\n * `Schema` suffix (`listPetsSchema`); their inferred types use PascalCase\n * with a `SchemaType` suffix (`PetSchemaType`), so the value and the type\n * never share an identifier even when the schema name is all-uppercase.\n *\n * @example Resolve schema and type names\n * ```ts\n * import { resolverZod } from '@kubb/plugin-zod'\n *\n * resolverZod.name('list pets') // 'listPetsSchema'\n * resolverZod.schema.typeName('pet') // 'PetSchemaType'\n * ```\n */\nexport const resolverZod = createResolver<PluginZod>({\n pluginName: 'plugin-zod',\n name(name) {\n return ensureValidVarName(camelCase(name, { suffix: 'schema' }))\n },\n file: {\n baseName({ name, extname }) {\n return `${toFilePath(name, (part) => camelCase(part, { suffix: 'schema' }))}${extname}`\n },\n },\n schema: {\n typeName(name) {\n return ensureValidVarName(pascalCase(name, { suffix: 'schema type' }))\n },\n type(name) {\n return ensureValidVarName(pascalCase(name, { suffix: 'type' }))\n },\n inputName(name) {\n return this.name(`${name} input`)\n },\n inputTypeName(name) {\n return this.schema.typeName(`${name} input`)\n },\n },\n param: {\n name(node, param) {\n return this.name(`${node.operationId} ${param.in} ${param.name}`)\n },\n path(node, param) {\n return this.param.name(node, param)\n },\n query(node, param) {\n return this.param.name(node, param)\n },\n headers(node, param) {\n return this.param.name(node, param)\n },\n },\n response: {\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 error(node) {\n return this.name(`${node.operationId} Error`)\n },\n },\n})\n","import { createGroupConfig } from '@internals/shared'\nimport { definePlugin, Resolver } from 'kubb/kit'\nimport { zodGenerator } from './generators/zodGenerator.tsx'\nimport { resolverZod } from './resolvers/resolverZod.ts'\nimport type { PluginZod } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-zod`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\n/**\n * Generates Zod v4 schemas from an OpenAPI spec. Use them to validate API\n * responses at runtime, build form schemas, or feed back into router libraries\n * that consume Zod (tRPC, Hono, Elysia). Pair with `@kubb/plugin-axios` or\n * `@kubb/plugin-fetch` and set the client's `validator: 'zod'` to validate every response\n * automatically.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginTs } from '@kubb/plugin-ts'\n * import { pluginZod } from '@kubb/plugin-zod'\n *\n * export default defineConfig({\n * input: { path: './petStore.yaml' },\n * output: { path: './src/gen' },\n * plugins: [\n * pluginTs(),\n * pluginZod({\n * output: { path: './zod' },\n * inferred: true,\n * }),\n * ],\n * })\n * ```\n */\nexport const pluginZod = definePlugin<PluginZod>((options) => {\n const {\n output = { path: 'zod', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n mini = false,\n guidType = 'uuid',\n regexType = 'literal',\n importPath = mini ? 'zod/mini' : 'zod',\n coercion = false,\n inferred = false,\n printer,\n resolver: userResolver,\n macros: userMacros,\n } = options\n\n const groupConfig = createGroupConfig(group)\n\n return {\n name: pluginZodName,\n options,\n hooks: {\n 'kubb:plugin:setup'(ctx) {\n ctx.setOptions({\n output,\n exclude,\n include,\n override,\n group: groupConfig,\n importPath,\n coercion,\n inferred,\n guidType,\n regexType,\n mini,\n printer,\n })\n ctx.setResolver(userResolver ? Resolver.merge(resolverZod, userResolver) : resolverZod)\n if (userMacros?.length) {\n ctx.setMacros(userMacros)\n }\n ctx.addGenerator(zodGenerator)\n },\n },\n }\n})\n\nexport default pluginZod\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,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;;;;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