@kubb/plugin-zod 5.8.1 → 5.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +23 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/kubb-extension.json +1 -1
- package/package.json +3 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../internals/shared/src/operation.ts","../../../internals/shared/src/adapter.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/strings.ts","../../../internals/utils/src/codegen.ts","../../../internals/utils/src/fs.ts","../../../internals/shared/src/resolver.ts","../../../internals/shared/src/group.ts","../../../internals/shared/src/schemaTraversal.ts","../src/components/Zod.tsx","../src/utils.ts","../src/printers/zodNodes.ts","../src/printers/printerZod.ts","../src/printers/printerZodMini.ts","../src/generators/zodGenerator.tsx","../kubb-extension.json","../package.json","../src/resolvers/resolverZod.ts","../src/plugin.ts"],"sourcesContent":["import { ast, type Group, type Memo, type Output, type Resolver, type ResolverFileParams, Url } from '@kubb/kit'\n\n/**\n * Builds the `ResolverFileParams` every operation generator passes to\n * `resolver.file`: a file named `name`, tagged by the operation's first\n * tag (or `'default'`), at the operation's path. Centralizes the entry object\n * that was repeated at dozens of call sites across the client and query plugins.\n *\n * @example\n * ```ts\n * resolver.file(operationFileEntry(node, node.operationId), { root, output, group })\n * ```\n */\nexport function operationFileEntry(node: ast.OperationNode, name: string, extname: ResolverFileParams['extname'] = '.ts'): ResolverFileParams {\n return {\n name,\n extname,\n tag: node.tags[0] ?? 'default',\n path: node.path,\n }\n}\n\n/**\n * Resolves a dependency plugin's generated file for `node.operationId`, cached in `memo` (the\n * build's `ctx.memo`) under the resolver's own plugin name and the operation. Several dependents reading the\n * same dependency for the same operation in one pass (a query plugin's several hook generators, the\n * MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.\n *\n * @example Cache `plugin-ts`'s file for the current operation\n * ```ts\n * const fileTs = resolveDependencyOperationFile({ memo: ctx.memo, node, resolver: tsResolver, root, output })\n * ```\n */\nexport function resolveDependencyOperationFile(options: {\n memo: Memo\n node: ast.OperationNode\n resolver: Pick<Resolver, 'file' | 'pluginName'>\n root: string\n output: Output\n group?: Group | null\n}): ast.FileNode {\n const { memo, node, resolver, root, output, group } = options\n\n return memo(`${resolver.pluginName}:operationFile:${node.operationId}`, () =>\n resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\n )\n}\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type OperationCommentLink = 'pathTemplate' | 'urlPath' | false | ((node: ast.OperationNode) => string | undefined)\n\nexport type BuildOperationCommentsOptions = {\n link?: OperationCommentLink\n linkPosition?: 'beforeDeprecated' | 'afterDeprecated'\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<ast.ParameterNode['in'], Array<ast.ParameterNode>>\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\nfunction getOperationLink(node: ast.OperationNode, link: OperationCommentLink): string | null {\n if (!link) {\n return null\n }\n\n if (typeof link === 'function') {\n return link(node) ?? null\n }\n\n return node.path ? `{@link ${Url.toPath(node.path)}}` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(node.requestBody?.content?.map((e) => e.contentType) ?? [])\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(getPrimarySuccessResponse(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\nexport type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n\n/**\n * Reads the single base content type of an operation's primary success response, lowercased and\n * stripped of any `; charset=...` suffix. Returns `undefined` when the response declares zero or\n * more than one content type, since neither case has a single type to act on.\n */\nfunction getPrimarySuccessContentType(node: ast.OperationNode): string | undefined {\n const contentTypes = getPrimarySuccessResponse(node)?.content?.map((entry) => entry.contentType) ?? []\n if (contentTypes.length !== 1) return undefined\n return contentTypes[0]!.split(';')[0]!.trim().toLowerCase()\n}\n\n/**\n * Whether an operation streams its primary success response as Server-Sent Events\n * (`text/event-stream`). The client generator uses this to return a typed event stream instead of a\n * one-shot `RequestResult`.\n */\nexport function isEventStream(node: ast.OperationNode): boolean {\n return getPrimarySuccessContentType(node) === 'text/event-stream'\n}\n\n/**\n * Derives the default `responseType` for an operation from its primary success response.\n *\n * Returns a value only when that response declares a single non-JSON content type. `text/event-stream`\n * and other binary types (`application/octet-stream`, `application/pdf`, `image/*`, `audio/*`,\n * `video/*`) map to a stream or `'blob'`, and other `text/*` maps to `'text'`. Otherwise `undefined`,\n * leaving the runtime client's `Content-Type` auto-detection in charge.\n */\nexport function getResponseType(node: ast.OperationNode): ResponseType | undefined {\n const baseType = getPrimarySuccessContentType(node)\n if (!baseType) return undefined\n\n if (baseType === 'application/json' || baseType.endsWith('+json') || baseType === 'text/json') return undefined\n if (baseType === 'text/event-stream') return 'stream'\n if (baseType.startsWith('text/')) return 'text'\n if (baseType === 'application/octet-stream' || baseType === 'application/pdf' || /^(image|audio|video)\\//.test(baseType)) return 'blob'\n return undefined\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n// The request groups come from the grouped params, so `config` drops the data-shape keys to stay\n// assignable to `Options`, which omits them from `RequestConfig`.\nconst requestConfigBaseType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\n\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n\n // Only the ambiguous side is offered: a single-type side has nothing to pick, so it stays baked in\n // the generated call.\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n return members.length ? `${requestConfigBaseType} & { contentType?: { ${members.join('; ')} } }` : requestConfigBaseType\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...). Unlike {@link buildRequestConfigType}, it never adds a\n * `contentType?:` member: query hooks wrap GET operations, which carry no request body to select a\n * content type for.\n */\nexport function buildClientOptionType(): string {\n return requestConfigBaseType\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n}\n\n/**\n * Which of the grouped request options an operation carries.\n */\nexport function getRequestGroups(node: ast.OperationNode): RequestGroups {\n const { path, query, header } = getOperationParameters(node)\n return {\n path: path.length > 0,\n query: query.length > 0,\n body: Boolean(node.requestBody?.content?.[0]?.schema),\n headers: header.length > 0,\n }\n}\n\nexport type RequestGroupOptionality = {\n groups: RequestGroups\n hasRequiredPath: boolean\n hasRequiredQuery: boolean\n hasRequiredHeader: boolean\n /**\n * Whether the grouped request parameter can default to `{}`. True only when no group carries a\n * required member, so every member is safe to omit.\n */\n isOptional: boolean\n}\n\n/**\n * Resolves which grouped request options an operation carries together with whether each group\n * holds a required member. The grouped parameter stays optional only when nothing inside it is\n * required, matching the generated `RequestConfig` type.\n */\nexport function getRequestGroupOptionality(node: ast.OperationNode): RequestGroupOptionality {\n const groups = getRequestGroups(node)\n const { path, query, header } = getOperationParameters(node)\n const hasRequiredPath = path.some((param) => param.required)\n const hasRequiredQuery = query.some((param) => param.required)\n const hasRequiredHeader = header.some((param) => param.required)\n\n return {\n groups,\n hasRequiredPath,\n hasRequiredQuery,\n hasRequiredHeader,\n isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !groups.body,\n }\n}\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: RequestGroups } {\n const { isConfigurable = true } = options\n const { groups, isOptional } = getRequestGroupOptionality(node)\n\n const names = (['path', 'query', 'body', 'headers'] as const).filter((key) => groups[key])\n\n // These callers never carry the `contentType` that several media types require.\n const optionsType = hasRequestContentTypeChoice(node)\n ? `Pick<${resolver.response.options(node)}, ${names.map((name) => `'${name}'`).join(' | ')}>`\n : resolver.response.options(node)\n const firstParam = names.length > 0 ? `{ ${names.join(', ')} }: ${optionsType}${isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { link = 'pathTemplate', linkPosition = 'afterDeprecated', splitLines = false } = options\n const linkComment = getOperationLink(node, link)\n const comments =\n linkPosition === 'beforeDeprecated'\n ? [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, linkComment, node.deprecated && '@deprecated']\n : [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, node.deprecated && '@deprecated', linkComment]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\nconst operationParameterGroupsByNode = new WeakMap<ast.OperationNode, OperationParameterGroups>()\n\n/**\n * Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each\n * group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance\n * (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the\n * same parameters once per plugin.\n */\nexport function getOperationParameters(node: ast.OperationNode): OperationParameterGroups {\n const cached = operationParameterGroupsByNode.get(node)\n if (cached) return cached\n\n // A malformed spec can declare the same name twice within one location. Both would resolve to the\n // same output property, so emitting both would yield an object type with a duplicate member,\n // which TypeScript rejects. Keep the first.\n const group = (location: ast.ParameterNode['in']) => {\n const seen = new Set<string>()\n\n return node.parameters.filter((param) => {\n if (param.in !== location || seen.has(param.name)) return false\n seen.add(param.name)\n return true\n })\n }\n\n const groups: OperationParameterGroups = { path: group('path'), query: group('query'), header: group('header'), cookie: group('cookie') }\n\n operationParameterGroupsByNode.set(node, groups)\n return groups\n}\n\n/**\n * Builds the combined `{ body, path, query, headers }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same\n * shape from the same inputs. `primitive: 'object'` is a no-op for the TS printer and tells the Zod\n * printer to emit `z.object(…)` rather than a record.\n */\nexport function hasRequestContentTypeChoice(node: ast.OperationNode): boolean {\n return (node.requestBody?.content ?? []).filter((entry) => entry.schema).length > 1\n}\n\n/**\n * Casts a call argument to the client's parameter type; a `'plain'` client is non-generic.\n */\nexport function castToClientOptions(callArg: string, clientName: string, returnType: 'full' | 'data' | 'plain' = 'full'): string {\n return `${callArg} as Parameters<typeof ${clientName}${returnType === 'plain' ? '' : '<true>'}>[0]`\n}\n\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver, { pairContentTypes = false } = {}): ast.SchemaNode {\n const { path, query, header } = getOperationParameters(node)\n const hasBody = Boolean(node.requestBody?.content?.[0]?.schema)\n const createNever = () => ast.factory.createSchema({ type: 'never', primitive: undefined, optional: true })\n const groups = [\n { name: 'path', params: path, resolve: resolver.param.path },\n { name: 'query', params: query, resolve: resolver.param.query },\n { name: 'headers', params: header, resolve: resolver.param.headers },\n ] as const\n\n const createOptions = (body: ast.SchemaNode, extra: Array<ast.PropertyNode> = []) =>\n // NOTE(v5-stable): the fields were renamed from the legacy beta shape\n // (`data`/`pathParams`/`queryParams`/`headerParams`) to `body`/`path`/`query`/`headers` so the\n // type matches the runtime client. Drop this note once v5 leaves beta.\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({ name: 'body', required: hasBody, schema: body }),\n ...groups.map(({ name, params, resolve }) => {\n const required = params.some((param) => param.required)\n\n return ast.factory.createProperty({\n name,\n required,\n schema:\n params.length > 0\n ? ast.factory.createSchema({ type: 'ref', name: resolve.call(resolver.param, node, params[0]!), optional: !required })\n : createNever(),\n })\n }),\n ...extra,\n ],\n })\n\n const variants =\n pairContentTypes && hasRequestContentTypeChoice(node) ? resolveContentTypeVariants(node.requestBody?.content ?? [], resolver.response.body(node)) : []\n if (variants.length < 2) {\n return createOptions(hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever())\n }\n\n // The first media type is the runtime default, so only the others must pass `contentType`.\n return ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant, index) =>\n createOptions(ast.factory.createSchema({ type: 'ref', name: variant.name }), [\n ast.factory.createProperty({\n name: 'contentType',\n required: index > 0,\n schema: ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'request',\n required: true,\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] }),\n }),\n ],\n }),\n }),\n ]),\n ),\n })\n}\n\n/**\n * The schema a status occupies in the `<Name>Responses` record. A status that documents several\n * content types becomes a `{ contentType; data }` union so the runtime can surface the negotiated type\n * on `result.parsed`, while the standalone `<Name>StatusNNN` alias stays the plain body union that the\n * query hooks and `result.data` use.\n */\nfunction buildResponseRecordEntry(node: ast.OperationNode, res: ast.ResponseNode, resolver: ResponseStatusNameResolver): ast.SchemaNode {\n const statusName = resolver.response.status(node, res.statusCode)\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length <= 1) {\n return ast.factory.createSchema({ type: 'ref', name: statusName })\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: resolveContentTypeVariants(variants, statusName).map((variant) =>\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'contentType',\n required: true,\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] }),\n }),\n ast.factory.createProperty({\n name: 'data',\n required: true,\n schema: ast.factory.createSchema({ type: 'ref', name: variant.name }),\n }),\n ],\n }),\n ),\n })\n}\n\n/**\n * Builds the per-status `<Name>Responses` record for an operation, referencing the already-resolved\n * `<Name>StatusNNN` names. Shared by `@kubb/plugin-ts`'s `Responses` type and `@kubb/plugin-zod`'s\n * inferred responses schema, so both emit the same shape from the same inputs.\n *\n * Always emits the keyed record, even when an operation declares no responses. An operation with no\n * responses renders as an empty object, which keeps every consumer's import (for example the axios\n * SDK's `RequestResult<XResponses>`) resolvable instead of pointing at a missing export.\n */\nexport function buildResponses(node: ast.OperationNode, resolver: ResponseStatusNameResolver): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: node.responses.map((res) =>\n ast.factory.createProperty({\n name: String(res.statusCode),\n required: true,\n schema: buildResponseRecordEntry(node, res, resolver),\n }),\n ),\n })\n}\n\nexport function getStatusCodeNumber(statusCode: ast.StatusCode | number | string): number | null {\n const code = Number(statusCode)\n\n return Number.isNaN(code) ? null : code\n}\n\nexport function isSuccessStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 200 && code < 300\n}\n\nexport function isErrorStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 400\n}\n\nexport function getSuccessResponses<TResponse extends ResponseLike>(responses: ReadonlyArray<TResponse>): Array<TResponse> {\n return responses.filter((response) => isSuccessStatusCode(response.statusCode))\n}\n\nexport function getOperationSuccessResponses(node: ast.OperationNode): Array<ast.ResponseNode> {\n return getSuccessResponses(node.responses)\n}\n\nexport function getPrimarySuccessResponse(node: ast.OperationNode): ast.ResponseNode | null {\n return getOperationSuccessResponses(node)[0] ?? null\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.filter((response) => isSuccessStatusCode(response.statusCode)).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.response.status(node, response.statusCode))\n}\n\n/**\n * Lists the type names an operation's types file declares, computed once per resolver and `options` so every\n * dependent reads the same list.\n */\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver & Pick<Resolver, 'memo'>,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const key = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n return resolver.memo(`operationTypeNames:${key}`, () => {\n const { path, query, header } = getOperationParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ]\n const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n return names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n })\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = getStatusCodeNumber(response.statusCode)\n if (code === null) {\n continue\n }\n\n types.push([code, isSuccessStatusCode(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n","import { type Adapter, Diagnostics } from '@kubb/kit'\nimport type { AdapterOas } from '@kubb/adapter-oas'\n\n/**\n * Narrows the generic `Adapter` from a generator context to the OpenAPI adapter,\n * so OAS-only options (`dateType`, `enums`) and the parsed `document` are typed.\n *\n * Throws when a non-OAS adapter is configured, turning a silently wrong cast into a\n * clear, actionable error at the point of use.\n *\n * @example\n * ```ts\n * const { dateType } = getOasAdapter(ctx.adapter).options\n * ```\n */\nexport function getOasAdapter(adapter: Adapter): Adapter<AdapterOas> {\n if (adapter.name !== 'oas') {\n throw new Diagnostics.Error({\n code: Diagnostics.code.adapterRequired,\n severity: 'error',\n message: `Expected the OpenAPI adapter (adapterOas), but received \"${adapter.name}\".`,\n help: 'Set `adapter: adapterOas()` in kubb.config.ts.',\n location: { kind: 'config' },\n })\n }\n\n return adapter as Adapter<AdapterOas>\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'await',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `name` when it's a syntactically valid JavaScript variable name,\n * otherwise prefixes it with `_` so the result is a valid identifier.\n *\n * Useful for sanitizing OpenAPI schema names or operation IDs that start with\n * a digit (e.g. `409`, `504AccountCancel`) before using them as exported\n * variable, type, or function names.\n *\n * @example\n * ```ts\n * ensureValidVarName('409') // '_409'\n * ensureValidVarName('504AccountCancel') // '_504AccountCancel'\n * ensureValidVarName('Pet') // 'Pet'\n * ensureValidVarName('class') // '_class'\n * ```\n */\nexport function ensureValidVarName(name: string): string {\n if (!name || isValidVarName(name)) {\n return name\n }\n return `_${name}`\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","/**\n * Wraps a value in single quotes for emitting a single-quoted JavaScript string literal, escaping\n * any backslash or single quote in the content.\n *\n * @example\n * ```ts\n * singleQuote('foo') // \"'foo'\"\n * singleQuote(\"o'clock\") // \"'o\\\\'clock'\"\n * ```\n */\nexport function singleQuote(value: string | number | boolean | undefined | null): string {\n if (value === undefined || value === null) return \"''\"\n const escaped = String(value).replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")\n\n return `'${escaped}'`\n}\n\n/**\n * Strips a single matching pair of `\"...\"`, `'...'`, or `` `...` `` from both ends of `text`.\n * Returns the string unchanged when no balanced quote pair is found.\n *\n * @example\n * ```ts\n * trimQuotes('\"hello\"') // 'hello'\n * trimQuotes('hello') // 'hello'\n * ```\n */\nexport function trimQuotes(text: string): string {\n if (text.length >= 2) {\n const first = text[0]\n const last = text[text.length - 1]\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\") || (first === '`' && last === '`')) {\n return text.slice(1, -1)\n }\n }\n return text\n}\n\n/**\n * Serializes a primitive to a single-quoted string literal, stripping any surrounding quotes first.\n *\n * Escaping runs through `JSON.stringify`, then the result switches to single quotes so the generated\n * code matches the repo style without a formatter.\n *\n * @example\n * ```ts\n * stringify('hello') // \"'hello'\"\n * stringify('\"hello\"') // \"'hello'\"\n * ```\n */\nexport function stringify(value: string | number | boolean | undefined): string {\n if (value === undefined || value === null) return \"''\"\n const json = JSON.stringify(trimQuotes(value.toString()))\n const inner = json.slice(1, -1).replace(/\\\\\"/g, '\"').replace(/'/g, \"\\\\'\")\n return `'${inner}'`\n}\n\n/**\n * Escapes an `@` at the start of a line, so a multi-line description can't start a new JSDoc tag.\n * Editors render `\\@` as `@` in hovers.\n *\n * @example\n * ```ts\n * jsDocEscape('intro\\n@example value') // 'intro\\n\\\\@example value'\n * ```\n */\nexport function jsDocEscape(input: unknown): string {\n return `${input}`.replace(/^(\\s*)@/gm, '$1\\\\@')\n}\n\n/**\n * Escapes characters that are not allowed inside JS string literals, covering quotes, backslashes,\n * and the Unicode line terminators U+2028 and U+2029.\n *\n * @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4\n *\n * @example\n * ```ts\n * jsStringEscape('say \"hi\"\\nbye') // 'say \\\\\"hi\\\\\"\\\\nbye'\n * ```\n */\nexport function jsStringEscape(input: unknown): string {\n return `${input}`.replace(/[\"'\\\\\\n\\r\\u2028\\u2029]/g, (character) => {\n switch (character) {\n case '\"':\n case \"'\":\n case '\\\\':\n return `\\\\${character}`\n case '\\n':\n return '\\\\n'\n case '\\r':\n return '\\\\r'\n case '\\u2028':\n return '\\\\u2028'\n case '\\u2029':\n return '\\\\u2029'\n default:\n return ''\n }\n })\n}\n\n// `\\p{`, `\\P{` or `\\u{` behind an odd number of backslashes, or a character outside the BMP: both need the `u` flag.\nconst NEEDS_UNICODE = /(?<!\\\\)(?:\\\\\\\\)*\\\\[pPu]\\{|[\\u{10000}-\\u{10FFFF}]/u\n// Escapes the `u` flag accepts. `\\-` only counts inside a class.\nconst KEPT_ESCAPE = /[A-Za-z0-9^$\\\\.*+?()[\\]{}|/]/\n\n/**\n * Drops the backslash from escapes that the `u` flag rejects: an escaped punctuation character that is\n * not a syntax character, and `\\-` outside a class. Both match the same character without the backslash.\n */\nfunction dropIdentityEscapes(pattern: string): string {\n let inClass = false\n\n return pattern.replace(/\\\\(.)|[[\\]]/gs, (match, escaped?: string) => {\n if (escaped === undefined) {\n inClass = match === '['\n return match\n }\n\n return KEPT_ESCAPE.test(escaped) || (escaped === '-' && inClass) ? match : escaped\n })\n}\n\n/**\n * Builds the `RegExp` for a pattern, adding the `u` flag when it uses `\\p{...}`, `\\P{...}` or `\\u{...}`, or\n * holds a character outside the BMP. A pattern that is not valid under `u` keeps the flags it came with.\n */\nfunction toRegExp(pattern: string, flags: string | undefined): RegExp {\n if (flags?.includes('u') || !NEEDS_UNICODE.test(pattern)) return new RegExp(pattern, flags)\n\n try {\n return new RegExp(dropIdentityEscapes(pattern), `${flags ?? ''}u`)\n } catch {\n return new RegExp(pattern, flags)\n }\n}\n\n/**\n * Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.\n * Inline flags expressed as a `^(?im)` prefix are extracted and applied to the resulting expression.\n * Pass `null` as the second argument to emit a `/pattern/flags` literal instead.\n *\n * @example\n * ```ts\n * toRegExpString('^(?im)foo') // 'new RegExp(\"^foo\", \"im\")'\n * toRegExpString('^(?im)foo', null) // '/^foo/im'\n * ```\n */\nexport function toRegExpString(text: string, func: string | null = 'RegExp'): string {\n const raw = trimQuotes(text)\n\n const match = raw.match(/^\\^(\\(\\?([igmsuy]+)\\))/i)\n const replacementTarget = match?.[1] ?? ''\n const matchedFlags = match?.[2]\n const cleaned = raw\n .replace(/^\\\\?\\//, '')\n .replace(/\\\\?\\/$/, '')\n .replace(replacementTarget, '')\n\n const { source, flags } = toRegExp(cleaned, matchedFlags)\n\n if (func === null) return `/${source}/${flags}`\n\n return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ''})`\n}\n\n/**\n * Renders a dotted path or string array as an optional-chaining accessor expression rooted at\n * `accessor`. Returns `null` for an empty path.\n *\n * @example\n * ```ts\n * getNestedAccessor('pagination.next.id', 'lastPage')\n * // \"lastPage?.['pagination']?.['next']?.['id']\"\n * ```\n */\nexport function getNestedAccessor(param: string | Array<string>, accessor: string): string | null {\n const parts = Array.isArray(param) ? param : param.split('.')\n if (parts.length === 0 || (parts.length === 1 && parts[0] === '')) return null\n return `${accessor}?.['${`${parts.join(\"']?.['\")}']`}`\n}\n","import { 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 '@kubb/kit'\n\nfunction toSlash(p: string): string {\n if (p.startsWith('\\\\\\\\?\\\\')) return p\n return p.replaceAll('\\\\', '/')\n}\n\n/**\n * Returns the relative path from `rootDir` to `filePath`, always using forward slashes\n * and prefixed with `./` when not already traversing upward.\n *\n * @example\n * ```ts\n * getRelativePath('/src/components', '/src/components/Button.tsx') // './Button.tsx'\n * getRelativePath('/src/components', '/src/utils/helpers.ts') // '../utils/helpers.ts'\n * ```\n */\nexport function getRelativePath(rootDir: string, filePath: string): string {\n const relativePath = posix.relative(toSlash(rootDir), toSlash(filePath))\n\n return relativePath.startsWith('../') ? relativePath : `./${relativePath}`\n}\n\n/**\n * Builds a nested file path from a dotted name. Splits on dots that precede a letter\n * (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases\n * every earlier segment, applies `caseLast` to the final segment, and joins with `/`.\n *\n * Empty segments are dropped before joining. They arise when the name starts with a dot\n * followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to\n * an empty string). Without this a leading `/` would form, which `path.resolve` reads as an\n * absolute path, letting generated files escape the configured output directory.\n *\n * @example Nested path from a dotted name\n * `toFilePath('pet.petId') // 'pet/petId'`\n *\n * @example PascalCase the final segment\n * `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`\n *\n * @example Suffix applied to the final segment only\n * `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`\n */\nexport function toFilePath(name: string, caseLast: (part: string) => string = camelCase): string {\n const parts = name.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => (i === parts.length - 1 ? caseLast(part) : camelCase(part)))\n .filter(Boolean)\n .join('/')\n}\n","import { ensureValidVarName, toFilePath } from '@internals/utils'\nimport { ast, camelCase } from '@kubb/kit'\nimport type { GeneratorContext, Resolver, ResolverFile } from '@kubb/kit'\n\n/**\n * The shared top-level `name` of the operation plugins, computed once per operation name and build.\n */\nexport function resolveOperationName(this: Resolver, name: string): string {\n return this.memo(`operation:${name}`, () => ensureValidVarName(camelCase(name)))\n}\n\n/**\n * Builds the allocation key for a declaration an operation owns. `scope` names which declaration\n * it is, so two of them never share an allocation even when a custom resolver gives both the same\n * name. Leave `scope` empty for the operation's own declaration.\n *\n * @example\n * ```ts\n * resolver.resolveName({ key: operationKey(node, 'response', 'status', 404), name })\n * ```\n */\nexport function operationKey(node: ast.OperationNode, ...scope: Array<string | number>): Array<string | undefined> {\n return ['operation', node.method, node.path, ...scope.map(String)]\n}\n\n/**\n * The `param` namespace shared by the schema-producing plugins (ts, zod, faker):\n * per-parameter names plus the grouped `Path`/`Query`/`Headers` names, all routed\n * through the plugin's top-level `name` casing.\n */\nexport type OperationParamResolver = {\n name(this: Resolver, node: ast.OperationNode, param: ast.ParameterNode): string\n path(this: Resolver, node: ast.OperationNode): string\n query(this: Resolver, node: ast.OperationNode): string\n headers(this: Resolver, node: ast.OperationNode): string\n}\n\n/**\n * The `response` namespace shared by the schema-producing plugins: per-status,\n * body, and combined response names, all routed through the plugin's top-level\n * `name` casing.\n */\nexport type OperationResponseResolver = {\n status(this: Resolver, node: ast.OperationNode, statusCode: ast.StatusCode): string\n body(this: Resolver, node: ast.OperationNode): string\n responses(this: Resolver, node: ast.OperationNode): string\n response(this: Resolver, node: ast.OperationNode): string\n}\n\n/**\n * Builds the shared `param` namespace. Spread the result into `createResolver`\n * and override individual methods next to it when a plugin deviates.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ param: createOperationParamResolver(), ... })\n * ```\n */\nexport function createOperationParamResolver(): OperationParamResolver {\n return {\n name(node, param) {\n const name = this.name(`${node.operationId} ${param.in} ${param.name}`)\n return this.resolveName({ key: operationKey(node, 'param', 'name', param.in, param.name), name })\n },\n path(node) {\n const name = this.name(`${node.operationId} Path`)\n return this.resolveName({ key: operationKey(node, 'param', 'path'), name })\n },\n query(node) {\n const name = this.name(`${node.operationId} Query`)\n return this.resolveName({ key: operationKey(node, 'param', 'query'), name })\n },\n headers(node) {\n const name = this.name(`${node.operationId} Headers`)\n return this.resolveName({ key: operationKey(node, 'param', 'headers'), name })\n },\n }\n}\n\n/**\n * Builds the shared `response` namespace. Spread the result into\n * `createResolver` and add plugin-specific methods (`options`, `error`) next\n * to it.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ response: { ...createOperationResponseResolver(), options(node) {...} }, ... })\n * ```\n */\nexport function createOperationResponseResolver(): OperationResponseResolver {\n return {\n status(node, statusCode) {\n const name = this.name(`${node.operationId} Status ${statusCode}`)\n return this.resolveName({ key: operationKey(node, 'response', 'status', statusCode), name })\n },\n body(node) {\n const name = this.name(`${node.operationId} Body`)\n return this.resolveName({ key: operationKey(node, 'response', 'body'), name })\n },\n responses(node) {\n const name = this.name(`${node.operationId} Responses`)\n return this.resolveName({ key: operationKey(node, 'response', 'responses'), name })\n },\n response(node) {\n const name = this.name(`${node.operationId} Response`)\n return this.resolveName({ key: operationKey(node, 'response', 'response'), name })\n },\n }\n}\n\n/**\n * Builds a resolver `file` override whose base name runs every path segment\n * through `toFilePath`, casing the final segment with `caseLast`.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ file: createCasedFile(pascalCase), ... })\n * ```\n */\nexport function createCasedFile(caseLast: (part: string) => string): ResolverFile {\n return {\n baseName({ name, extname }) {\n return this.memo(`file:${name}\\0${extname}`, (): ast.FileNode['baseName'] => `${toFilePath(name, caseLast)}${extname}`)\n },\n }\n}\n\ntype SchemaIndexContext = Pick<GeneratorContext, 'memo' | 'driver'>\n\n/**\n * Names of the schemas in a circular reference chain, computed once per build.\n */\nexport function getCircularNames(ctx: SchemaIndexContext): ReadonlySet<string> {\n return ctx.memo('circularNames:set', () => ast.findCircularSchemas(ctx.driver.inputNode?.schemas ?? []))\n}\n\n/**\n * Names of the schemas whose type is `enum`, computed once per build.\n */\nexport function getEnumNames(ctx: SchemaIndexContext): ReadonlySet<string> {\n return ctx.memo(\n 'enumNames:set',\n () => new Set((ctx.driver.inputNode?.schemas ?? []).flatMap((schema) => (schema.type === 'enum' && schema.name ? [schema.name] : []))),\n )\n}\n\ndeclare global {\n namespace Kubb {\n interface MemoRegistry {\n operation: string\n file: ast.FileNode['baseName']\n operationTypeNames: Array<string>\n }\n }\n}\n","import { camelCase, type Group } from '@kubb/kit'\n\n/**\n * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the\n * shared default naming so every plugin groups output consistently:\n *\n * - `path` groups use the second path segment (`/pet/findByStatus` → `pet`).\n * - other groups use the camelCased group (`pet store` → `petStore`).\n *\n * A user-provided `group.name` always wins over the default namer, so callers stay in\n * control of their output folders. Returns `null` when grouping is disabled, matching the\n * per-plugin convention.\n *\n * @param group - The user-supplied group option, or `undefined` to disable grouping.\n *\n * @example\n * ```ts\n * createGroupConfig(group) // shared across every plugin\n * ```\n */\nexport function createGroupConfig(group: Group | undefined): Group | null {\n if (!group) {\n return null\n }\n\n const defaultName = (ctx: { group: string }): string => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n\n return camelCase(ctx.group)\n }\n\n return {\n ...group,\n name: group.name ? group.name : defaultName,\n } satisfies Group\n}\n","import type { ast } from '@kubb/kit'\n\n/**\n * Converts a child schema to printer output. Plugins instantiate it with their own output type:\n * `string` for the zod and faker printers, `ts.TypeNode` for the TypeScript printer. A printer's\n * `this.transform` fits directly, so its `null` for an empty result carries through to `output`.\n */\nexport type SchemaTransform<TOutput> = (schema: ast.SchemaNode) => TOutput\n\n/**\n * A union or intersection member, or an array or tuple item, paired with its transformed output.\n */\nexport type MappedSchema<TOutput> = {\n /**\n * The original child schema, kept so the printer can read its metadata for leaf formatting.\n */\n schema: ast.SchemaNode\n /**\n * The child schema after being run through the transform.\n */\n output: TOutput\n}\n\n/**\n * An object property paired with its transformed output.\n */\nexport type MappedProperty<TOutput> = {\n /**\n * The property name as written on the schema, before any identifier quoting.\n */\n name: string\n /**\n * The original property node, kept so the printer can read `required`, `schema`, and metadata.\n */\n property: ast.PropertyNode\n /**\n * The property schema after being run through the transform.\n */\n output: TOutput\n}\n\n/**\n * Maps each property of an object schema to its transformed output. Pairs every result with the\n * original property so the printer keeps full control over modifiers, getters, and key syntax.\n *\n * @example\n * ```ts\n * const entries = mapSchemaProperties(node, (schema) => this.transform(schema))\n * // entries: [{ name: 'id', property, output: 'z.number()' }, ...]\n * ```\n */\nexport function mapSchemaProperties<TOutput>(node: ast.ObjectSchemaNode, transform: SchemaTransform<TOutput>): Array<MappedProperty<TOutput>> {\n return node.properties.map((property) => ({ name: property.name, property, output: transform(property.schema) }))\n}\n\n/**\n * Maps each member of a union or intersection schema to its transformed output, pairing every\n * result with the original member.\n */\nexport function mapSchemaMembers<TOutput>(\n node: ast.UnionSchemaNode | ast.IntersectionSchemaNode,\n transform: SchemaTransform<TOutput>,\n): Array<MappedSchema<TOutput>> {\n return (node.members ?? []).map((schema) => ({ schema, output: transform(schema) }))\n}\n\n/**\n * Maps each item of an array or tuple schema to its transformed output, pairing every result with\n * the original item.\n */\nexport function mapSchemaItems<TOutput>(node: ast.ArraySchemaNode, transform: SchemaTransform<TOutput>): Array<MappedSchema<TOutput>> {\n return (node.items ?? []).map((schema) => ({ schema, output: transform(schema) }))\n}\n","import { ast, containsCircularRef } from '@kubb/kit'\nimport { Const, File, Function, Type } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx'\nimport type { PrinterZodFactory } from '../printers/printerZod.ts'\nimport type { PrinterZodMiniFactory } from '../printers/printerZodMini.ts'\n\nimport type { CompileOptions } from '../types.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 * The helper the `inferTypeName` alias is printed with. `infer` and `output` name the parsed value,\n * `input` the value the schema accepts; they differ only for a codec.\n *\n * @default 'infer'\n */\n inferKind?: 'infer' | 'input' | 'output'\n typeGuards?: boolean | { is?: boolean; assert?: boolean }\n isName?: string | null\n assertName?: string | null\n mini?: boolean\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 * Wrap the schema initializer in `z.compile(...)` for fast-path validation.\n * Pass `{ strict: true }` to enforce strict compilation without silent fallback.\n *\n * @note Only compatible with Zod v4.5.0 or above.\n */\n compile?: boolean | CompileOptions\n}\n\nexport function Zod({ name, node, printer, inferTypeName, inferKind = 'infer', typeGuards, isName, assertName, mini, cyclic, compile }: Props): KubbReactNode {\n const output = printer.print(node)\n const printerImports = printer.drainImports()\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 const isBare = ast.isBareRef(node, printer.options.keysToOmit)\n const isCyclic = Boolean(cyclic || (printer.options.cyclicSchemas && containsCircularRef(node, { circularSchemas: printer.options.cyclicSchemas })))\n const shouldCompile = Boolean(compile) && !isBare && !isCyclic\n const value = shouldCompile ? (typeof compile === 'object' && compile.strict ? `z.compile(${output}, { strict: true })` : `z.compile(${output})`) : output\n\n const targetType = inferTypeName ?? `z.infer<typeof ${name}>`\n const shouldGenerateIs = isName && (typeof typeGuards === 'object' ? (typeGuards.is ?? true) : Boolean(typeGuards))\n const shouldGenerateAssert = assertName && (typeof typeGuards === 'object' ? (typeGuards.assert ?? true) : Boolean(typeGuards))\n\n return (\n <>\n {printerImports.map((imp) => (\n <File.Import\n key={[name, imp.path, imp.name].join('-')}\n name={imp.name}\n path={imp.path}\n root={imp.root}\n isTypeOnly={imp.isTypeOnly}\n isNameSpace={imp.isNameSpace}\n />\n ))}\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} type={needsAnnotation ? 'z.ZodType' : undefined}>\n {value}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n <Type export name={inferTypeName}>\n {`z.${inferKind}<typeof ${name}>`}\n </Type>\n </File.Source>\n )}\n {shouldGenerateIs && (\n <File.Source name={isName} isExportable isIndexable>\n <Const export name={isName} JSDoc={{ comments: [`Type guard for {@link ${name}}`] }}>\n {mini ? `(data: unknown): data is ${targetType} => z.validate(${name}, data)` : `(data: unknown): data is ${targetType} => ${name}.validate(data)`}\n </Const>\n </File.Source>\n )}\n {shouldGenerateAssert && (\n <File.Source name={assertName} isExportable isIndexable>\n <Function\n export\n name={assertName}\n params=\"data: unknown\"\n returnType={`asserts data is ${targetType}`}\n JSDoc={{ comments: [`Asserter for {@link ${name}}`, '@throws {z.ZodError} If data is invalid'] }}\n >\n {mini ? `if (!z.validate(${name}, data)) {\\n z.parse(${name}, data)\\n}` : `if (!${name}.validate(data)) {\\n ${name}.parse(data)\\n}`}\n </Function>\n </File.Source>\n )}\n </>\n )\n}\n","import { buildObject, stringify, toRegExpString } from '@internals/utils'\nimport { mapSchemaProperties } from '@internals/shared'\nimport { ast, containsCircularRef, syncSchemaRef } 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 * Whether the schema node represents a closed or finite set of keys (e.g. enum, literal,\n * or union of enums/literals).\n *\n * In Zod v4, passing a closed key schema to `z.record()` enforces exhaustiveness (all keys\n * must exist in the input). OpenAPI 3.1 `propertyNames` only validates present keys without\n * requiring all keys to exist, so closed key schemas use `z.partialRecord()` instead.\n */\nexport function isClosedKeySchema(node: ast.SchemaNode | undefined): boolean {\n if (!node) return false\n const resolved = syncSchemaRef(node)\n if (resolved.type === 'enum') return true\n if (resolved.type === 'union') {\n const members = resolved.members ?? []\n return members.length > 0 && members.every(isClosedKeySchema)\n }\n return false\n}\n\n/**\n * Whether the node is a plain inline object whose shape can be lifted into an `.extend({ … })`\n * argument. Property counts, a catchall, `patternProperties`, or a nullable/optional wrapper cannot, so those stay\n * on `.and(…)`.\n */\nexport function isPlainInlineObject(node: ast.SchemaNode): boolean {\n if (node.type !== 'object') return false\n if (node.minProperties !== undefined || node.maxProperties !== undefined) return false\n if (node.nullable || node.optional || node.nullish) return false\n\n const hasAdditionalProperties = node.additionalProperties !== undefined\n const hasPatternProperties = Boolean(node.patternProperties)\n\n return !hasAdditionalProperties && !hasPatternProperties && !node.propertyNames\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 * Property counts render as a pipe. A ref into `cyclicSchemas` renders as `z.lazy(…)`.\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') {\n if (node.minProperties !== undefined || node.maxProperties !== undefined) return false\n const hasProperties = Boolean(node.properties?.length)\n const hasTypedAdditionalProperties = Boolean(node.additionalProperties && node.additionalProperties !== true)\n const hasPatternProperties = Boolean(node.patternProperties)\n\n const isRecord = !hasProperties && (hasTypedAdditionalProperties || hasPatternProperties || node.propertyNames)\n\n return !isRecord\n }\n\n if (node.type === 'ref') {\n const refName = ast.resolveRefName(node)\n if (refName && cyclicSchemas?.has(refName)) return false\n const resolved = 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\nexport function preserveRequiredProperties(members: Array<ast.SchemaNode>): Array<ast.SchemaNode> {\n const hasRequiredProperty = ({\n node,\n propertyName,\n seen = new Set<ast.SchemaNode>(),\n }: {\n node: ast.SchemaNode\n propertyName: string\n seen?: Set<ast.SchemaNode>\n }): boolean => {\n if (seen.has(node)) return false\n seen.add(node)\n const resolved = syncSchemaRef(node)\n const composition = ast.narrowSchema(resolved, ast.schemaTypes.intersection) ?? ast.narrowSchema(resolved, ast.schemaTypes.union)\n // Property lookup skips unions, but a single-member union prints as its member.\n if (composition) {\n if (composition.type === ast.schemaTypes.union && composition.members?.length !== 1) return false\n return composition.members?.some((child) => hasRequiredProperty({ node: child, propertyName, seen })) ?? false\n }\n return ast\n .resolveSchemaProperties({ node: resolved, propertyName })\n .some((property) => property.required !== false && !property.schema.optional && !property.schema.nullish)\n }\n\n return members.map((member, index) => {\n const object = ast.narrowSchema(member, ast.schemaTypes.object)\n if (!object || index === 0) return member\n\n return {\n ...object,\n properties: object.properties.map((property) => {\n const required = members.slice(0, index).some((base) => hasRequiredProperty({ node: base, propertyName: property.name }))\n if (!required) return property\n\n return {\n ...property,\n required: true,\n schema: { ...property.schema, optional: false, nullish: false, nullable: property.schema.nullable || property.schema.nullish },\n }\n }),\n }\n })\n}\n\n/**\n * Format a default value as a code-level literal.\n * Arrays and objects keep their contents as a JSON literal, primitives become their string\n * 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 JSON.stringify(value)\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 const resolved = node ? syncSchemaRef(node) : undefined\n if (resolved && ast.narrowSchema(resolved, '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 (resolved && ast.narrowSchema(resolved, '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 = resolved ? ast.narrowSchema(resolved, '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 ? formatDefault(match) : null\n }\n }\n return formatDefault(value)\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<unknown>): string {\n const allStrings = values.every((v) => typeof v === 'string')\n if (allStrings) return `z.enum([${values.map((v) => formatDefault(v)).join(', ')}])`\n\n const literals = values.map((value) => buildLiteral(value))\n if (literals.length === 1) return literals[0]!\n\n return `z.union([${literals.join(', ')}])`\n}\n\n/**\n * Preserves the structure of JSON const values in both Zod APIs.\n */\nexport function buildLiteral(value: unknown): string {\n if (value === null) return 'z.null()'\n if (Array.isArray(value)) return `z.tuple([${value.map((item) => buildLiteral(item)).join(', ')}])`\n if (typeof value === 'object') {\n const properties = Object.entries(value).map(([name, item]) => `${JSON.stringify(name)}: ${buildLiteral(item)}`)\n return `z.strictObject({${properties.join(', ')}})`\n }\n return `z.literal(${formatDefault(value)})`\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 * Digit pattern for a `type: 'string'` schema that carries an integer `format`, the way ProtoJSON\n * encodes 64-bit integers. Returns `undefined` for every other format, and a `pattern` from the\n * spec takes precedence over this fallback.\n *\n * @example\n * ```ts\n * integerFormatPattern('uint64') // '^\\\\d+$'\n * ```\n */\nexport function integerFormatPattern(format: string | undefined): string | undefined {\n if (format === 'int32' || format === 'int64') return '^-?\\\\d+$'\n if (format === 'uint64') return '^\\\\d+$'\n\n return undefined\n}\n\n/**\n * Renders a `pattern` as a regex literal, or as `new RegExp(...)` when `regexType` is `'constructor'`.\n */\nfunction regexSource(pattern: string, regexType: PluginZod['resolvedOptions']['regexType'] | undefined): string {\n return toRegExpString(pattern, regexType === 'constructor' ? 'RegExp' : null)\n}\n\nfunction joinPatterns(patterns: Array<string>): string {\n return patterns.length === 1 ? patterns[0]! : patterns.map((pattern) => `(${pattern})`).join('|')\n}\n\n/**\n * Builds a Zod record key schema that enforces the `patternProperties` regexes a plain\n * `.catchall()` would drop.\n */\nexport function patternKeySchema({ patterns, regexType }: { patterns: Array<string>; regexType?: PluginZod['resolvedOptions']['regexType'] }): string {\n return `z.string().regex(${regexSource(joinPatterns(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(${regexSource(joinPatterns(patterns), 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(${regexSource(pattern, 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(${regexSource(pattern, regexType)})`)\n return checks.length ? `.check(${checks.join(', ')})` : ''\n}\n\n/**\n * Checks property counts before object parsing strips unknown keys or inserts defaults.\n */\nexport function objectConstraints({ value, node }: { value: string; node: ast.SchemaNode }): string {\n if (node.type !== 'object') return value\n const checks: Array<string> = []\n const skip = 'typeof value !== \"object\" || value === null || Array.isArray(value)'\n if (node.minProperties !== undefined) {\n checks.push(\n `z.refine(value => ${skip} || Object.keys(value).length >= ${node.minProperties}, { message: \"Object must have at least ${node.minProperties} properties\" })`,\n )\n }\n if (node.maxProperties !== undefined) {\n checks.push(\n `z.refine(value => ${skip} || Object.keys(value).length <= ${node.maxProperties}, { message: \"Object must have at most ${node.maxProperties} properties\" })`,\n )\n }\n return checks.length ? `z.pipe(z.unknown().check(${checks.join(', ')}), ${value})` : value\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()`. Zod Mini has no\n * `.unwrap()`, so its printer passes `._zod.def.innerType` as the `step`.\n */\nexport function omitUnwrapChain(node: ast.SchemaNode, step = '.unwrap()'): 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 step.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\n/**\n * Calls for string `format`s with a dedicated Zod constructor; a `Map` so `constructor` cannot hit `Object.prototype`.\n */\nexport const STRING_FORMAT_CALLS = new Map<string | undefined, string>([\n ['byte', 'z.base64()'],\n ['base64', 'z.base64()'],\n ['base64url', 'z.base64url()'],\n ['jwt', 'z.jwt()'],\n ['ulid', 'z.ulid()'],\n ['iban', 'z.iban()'],\n ['duration', 'z.iso.duration()'],\n ['hostname', 'z.hostname()'],\n])\n\n/**\n * Marks an inline `oneOf` object strict, so `object()` builds `z.strictObject(...)` and no eager `.shape` read hits a deferred getter.\n */\nexport function strictOneOfNode(node: ast.SchemaNode): ast.SchemaNode {\n return node.type === 'object' && node.additionalProperties === undefined ? { ...node, additionalProperties: false } : node\n}\n\n/**\n * The constraint chain an `allOf` member adds to a bare string, number or array; each printer passes its own renderers.\n */\nexport function getMemberConstraint({\n member,\n regexType,\n lengths,\n numbers,\n}: {\n member: ast.SchemaNode\n regexType?: LengthConstraints['regexType']\n lengths: (constraints: LengthConstraints) => string\n numbers: (constraints: NumericConstraints) => string\n}): string | undefined {\n if (member.primitive === 'string') return lengths({ ...(ast.narrowSchema(member, 'string') ?? {}), regexType }) || undefined\n if (member.primitive === 'number' || member.primitive === 'integer')\n return numbers(ast.narrowSchema(member, 'number') ?? ast.narrowSchema(member, 'integer') ?? {}) || undefined\n if (member.primitive === 'array') return lengths({ ...(ast.narrowSchema(member, 'array') ?? {}), regexType }) || undefined\n}\n\ntype PrinterContext = {\n transform: (node: ast.SchemaNode) => string | null\n options: { cyclicSchemas?: ReadonlySet<string>; nodes?: Partial<Record<ast.SchemaType, unknown>> }\n}\n\n/**\n * Builds the `{ key: value, … }` shape shared by the `z.object(...)` and `.extend(...)` renderings.\n */\nexport function buildObjectShape(\n ctx: PrinterContext,\n node: ast.SchemaNode,\n renderProperty: (args: {\n name: string\n value: string\n schema: ast.SchemaNode\n required?: boolean\n meta: ReturnType<typeof syncSchemaRef>\n cyclic: boolean\n }) => string,\n): 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 && containsCircularRef(schema, { circularSchemas: ctx.options.cyclicSchemas })\n\n const entries = mapSchemaProperties(objectNode, (schema) => {\n // A getter defers evaluation, so clear cyclicSchemas to skip z.lazy() on nested refs.\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 }).map(({ name, property, output: value }) => {\n const { schema } = property\n return renderProperty({ name, value, schema, required: property.required, meta: syncSchemaRef(schema), cyclic: isCyclic(schema) })\n })\n\n return buildObject(entries)\n}\n\n/**\n * Shared `print` body: transforms the node, applies `keysToOmit` as `.omit(...)` (or `z.omit(...)` when `mini`), then `modify` adds the modifiers.\n */\nexport function printWithOmit(\n ctx: { transform: (node: ast.SchemaNode) => string | null; options: { keysToOmit?: Array<string> | null } },\n node: ast.SchemaNode,\n modify: (value: string, meta: ReturnType<typeof syncSchemaRef>) => string,\n mini = false,\n): string | null {\n const { keysToOmit } = ctx.options\n\n const transformed = ctx.transform(node)\n if (!transformed) return null\n\n const meta = syncSchemaRef(node)\n\n const base = (() => {\n if (!keysToOmit?.length || meta.primitive !== 'object' || (meta.type === 'union' && meta.discriminatorPropertyName)) return transformed\n\n // A ref resolves to a wrapper variable; unwrap to the inner object before omitting.\n // Zod Mini schemas have no `.unwrap()` / `.omit()`, so walk `_zod.def.innerType` and call `z.omit()`.\n const unwrap = omitUnwrapChain(node, mini ? '._zod.def.innerType' : '.unwrap()')\n const mask = `{ ${keysToOmit.map((k: string) => `\"${k}\": true`).join(', ')} }`\n const omit = (target: string) => {\n const inner = `${target}${unwrap}`\n const hasObjectConstraints = meta.type === 'object' && (meta.minProperties !== undefined || meta.maxProperties !== undefined)\n const pipe = mini ? `${inner}._zod.def` : inner\n const object = hasObjectConstraints ? `${pipe}.out` : inner\n const omitted = mini ? `z.omit(${object}, ${mask})` : `${object}.omit(${mask})`\n return hasObjectConstraints ? `z.pipe(${pipe}.in, ${omitted})` : omitted\n }\n\n const lazyMatch = transformed.match(/^z\\.lazy\\(\\(\\)\\s*=>\\s*(.+)\\)$/)\n if (lazyMatch) return `z.lazy(() => ${omit(lazyMatch[1]!)})`\n return omit(transformed)\n })()\n\n return modify(base, meta)\n}\n","import { mapSchemaItems, mapSchemaMembers } from '@internals/shared'\nimport { buildList, stringify } from '@internals/utils'\nimport { ast, syncSchemaRef } from '@kubb/kit'\nimport type { PluginZod, ResolverZod } from '../types.ts'\nimport {\n buildEnum,\n buildLiteral,\n type buildObjectShape,\n getMemberConstraint,\n integerFormatPattern,\n isClosedKeySchema,\n isObjectComposableIntersection,\n isObjectSchemaNode,\n type lengthConstraints,\n type numberConstraints,\n objectConstraints,\n type patternKeySchema,\n preserveRequiredProperties,\n shouldCoerce,\n strictOneOfNode,\n STRING_FORMAT_CALLS,\n} from '../utils.ts'\n\n/**\n * The options both Zod printers read in the shared handlers.\n */\nexport type ZodNodeOptions = {\n coercion?: PluginZod['resolvedOptions']['coercion']\n guidType?: PluginZod['resolvedOptions']['guidType']\n regexType?: PluginZod['resolvedOptions']['regexType']\n oneOfType?: PluginZod['resolvedOptions']['oneOfType']\n resolver?: ResolverZod\n cyclicSchemas?: ReadonlySet<string>\n direction?: 'encode' | 'decode'\n nodes?: Partial<Record<ast.SchemaType, unknown>>\n}\n\n/**\n * The strings that differ between the chainable `zod` API and the functional `zod/mini` API.\n */\nexport type ZodDialect<TOptions extends ZodNodeOptions = ZodNodeOptions> = {\n lengths: typeof lengthConstraints\n numbers: typeof numberConstraints\n patternKey: typeof patternKeySchema\n objectShape: (ctx: Parameters<typeof buildObjectShape>[0], node: ast.SchemaNode) => string\n /**\n * The coerced integer base, without its numeric checks.\n */\n coercedInt: string\n /**\n * Wraps a schema so its input is coerced to a number before the schema checks it.\n */\n coercedNumber: (schema: string) => string\n catchall: (object: string, value: string) => string\n nullable: (value: string) => string\n unique: (array: string) => string\n extend: (base: string, shape: string) => string\n intersection: (left: string, right: string) => string\n /**\n * Post-processes a member of a strict `oneOf`. `zod/mini` has no chainable `.strict()`, so it leaves this unset.\n */\n strictMember?: (member: string, schema: ast.SchemaNode, cyclicSchemas?: ReadonlySet<string>) => string\n /**\n * Whether a `$ref` resolves to its `${name}InputSchema` variant. `zod/mini` is direction-free, so it leaves this unset.\n */\n useInputVariant?: (node: ast.SchemaNode, options: TOptions) => boolean\n}\n\n/**\n * Reads a union of bare single-value enums as one enum, except under `xor` or an enum override, which need each member.\n * Only a numeric union with a `format` coerces, because it printed as `z.coerce.number()` before the adapter kept its values.\n */\nfunction getLiteralUnion({\n node,\n options,\n}: {\n node: ast.UnionSchemaNode\n options: ZodNodeOptions\n}): { values: Array<string | number | boolean>; coerce: boolean } | undefined {\n if ((node.strategy === 'one' && options.oneOfType === 'xor') || options.nodes?.enum) return undefined\n const values = (node.members ?? []).map((member) => {\n const enumNode = ast.narrowSchema(member, ast.schemaTypes.enum)\n return enumNode && !enumNode.name && !enumNode.nullable && !enumNode.namedEnumValues && enumNode.enumValues?.length === 1\n ? enumNode.enumValues[0]\n : undefined\n })\n if (!values.length || !values.every((value): value is string | number | boolean => value !== undefined && value !== null)) return undefined\n\n return { values, coerce: !!node.format && values.every((value) => typeof value === 'number') && shouldCoerce(options.coercion, 'numbers') }\n}\n\n/**\n * Whether a discriminated union member's discriminator property prints as a coerced literal union.\n */\nfunction hasCoercedDiscriminator({ member, propertyName, options }: { member: ast.SchemaNode; propertyName: string; options: ZodNodeOptions }): boolean {\n return ast.resolveSchemaProperties({ node: member, propertyName }).some(({ schema }) => {\n const resolved = syncSchemaRef(schema)\n return resolved.type === 'union' && !!getLiteralUnion({ node: resolved, options })?.coerce\n })\n}\n\n/**\n * Builds the scalar handlers both dialects share. They never recurse into children. The temporal\n * scalars and `bigint` differ per dialect, so each printer adds its own.\n */\nexport function buildScalarNodes<TOptions extends ZodNodeOptions>(dialect: ZodDialect<TOptions>): ast.PrinterPartial<string, TOptions> {\n return {\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 coerce = shouldCoerce(this.options.coercion, 'strings')\n const call = coerce ? undefined : STRING_FORMAT_CALLS.get(node.format)\n if (call) return `${call}${dialect.lengths({ ...node, regexType: this.options.regexType })}`\n\n const base = coerce ? 'z.coerce.string()' : 'z.string()'\n const pattern = node.pattern ?? integerFormatPattern(node.format)\n\n return `${base}${dialect.lengths({ ...node, pattern, 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}${dialect.numbers(node)}`\n },\n integer(node) {\n if (shouldCoerce(this.options.coercion, 'numbers')) return `${dialect.coercedInt}${dialect.numbers(node)}`\n if (node.format === 'int32') return `z.int32()${dialect.numbers(node)}`\n if (node.format === 'uint32') return `z.uint32()${dialect.numbers(node)}`\n\n return `z.int()${dialect.numbers(node)}`\n },\n uuid(node) {\n const base = this.options.guidType === 'guid' ? 'z.guid()' : 'z.uuid()'\n\n return `${base}${dialect.lengths({ ...node, regexType: this.options.regexType })}`\n },\n email(node) {\n return `z.email()${dialect.lengths({ ...node, regexType: this.options.regexType })}`\n },\n url(node) {\n return `z.url()${dialect.lengths({ ...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) => buildLiteral(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 }\n}\n\n/**\n * Builds the node handlers of one Zod printer instance from its dialect: the shared scalars plus\n * the `ref` and container handlers.\n *\n * `cyclicSchemas` is captured once because the object handler clears `options.cyclicSchemas` while\n * it renders a getter body, and the `.strict()` and discriminability decisions must still see it.\n */\nexport function buildZodNodes<TOptions extends ZodNodeOptions>(\n dialect: ZodDialect<TOptions>,\n cyclicSchemas: ReadonlySet<string> | undefined,\n): ast.PrinterPartial<string, TOptions> {\n const unionsWithSiblings = new WeakSet<ast.SchemaNode>()\n\n return {\n ...buildScalarNodes(dialect),\n ref(node) {\n if (!node.name) return null\n const refName = ast.resolveRefName(node)\n if (!refName) return null\n\n // In the input direction, a component whose fields print differently by direction resolves\n // to its `${name}InputSchema` variant so request bodies encode instead of decoding.\n const useInputVariant = node.ref != null && (dialect.useInputVariant?.(node, this.options) ?? false)\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 patterns = node.patternProperties ? Object.entries(node.patternProperties) : []\n const propertyNamesNode = node.propertyNames\n const propertyNamesKeySchema = propertyNamesNode ? this.transform(propertyNamesNode) : null\n\n // `additionalProperties: false` still permits patternProperties keys, so only a pattern-free object is strict.\n // `z.strictObject(...)` rather than `z.object(...).strict()`: `.strict()` reads `.shape` eagerly, which runs a\n // self-reference's deferred getter while its own `const` is still in the temporal dead zone.\n const isStrict = node.additionalProperties === false && patterns.length === 0\n const isLoose = node.additionalProperties === true\n const ctor = isStrict ? 'z.strictObject' : isLoose ? 'z.looseObject' : 'z.object'\n const shape = dialect.objectShape(this, node)\n const objectBase = `${ctor}(${shape})`\n\n const result = (() => {\n // Closed key schemas (enums, literals) use z.partialRecord() so missing keys do not fail exhaustiveness.\n const recordFn = isClosedKeySchema(propertyNamesNode) ? 'z.partialRecord' : 'z.record'\n\n if (node.additionalProperties && node.additionalProperties !== true) {\n const catchallType = this.transform(node.additionalProperties)\n if (entries.length === 0) {\n return catchallType ? `${recordFn}(${propertyNamesKeySchema || 'z.string()'}, ${catchallType})` : objectBase\n }\n return catchallType ? dialect.catchall(objectBase, catchallType) : objectBase\n }\n if (entries.length === 0 && patterns.length === 0 && propertyNamesKeySchema && !isStrict) {\n const unknownType = this.transform(ast.factory.createSchema({ type: ast.schemaTypes.unknown }))!\n return `${recordFn}(${propertyNamesKeySchema}, ${unknownType})`\n }\n if (node.additionalProperties === true) return objectBase\n if (isStrict) return objectBase\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 a 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: ast.schemaTypes.unknown }))!\n return valueSchema.nullable ? dialect.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 dialect.catchall(objectBase, value)\n return `z.record(${dialect.patternKey({ patterns: patterns.map(([pattern]) => pattern), regexType: this.options.regexType })}, ${value})`\n }\n\n return objectBase\n })()\n\n return objectConstraints({ value: result, node })\n },\n array(node) {\n const items = mapSchemaItems(node, (item) => this.transform(item))\n .map(({ output }) => output)\n .filter(Boolean)\n const inner = items.join(', ') || this.transform(ast.factory.createSchema({ type: ast.schemaTypes.unknown }))!\n const base = `z.array(${inner})${dialect.lengths({ ...node, regexType: this.options.regexType })}`\n\n return node.unique ? dialect.unique(base) : base\n },\n tuple(node) {\n const items = 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 literalUnion = getLiteralUnion({ node, options: this.options })\n if (literalUnion) {\n const schema = buildEnum(literalUnion.values)\n return literalUnion.coerce ? dialect.coercedNumber(schema) : schema\n }\n\n const nodeMembers = node.members ?? []\n const { discriminatorPropertyName } = node\n // z.discriminatedUnion needs every option to be a Zod object. Object variants (refs or\n // extend-composed `allOf`) qualify; intersections, cyclic `z.lazy(…)` refs, and\n // non-objects fall back to z.union. A coerced discriminator hides its values behind\n // `z.coerce.number()`, which z.discriminatedUnion cannot read, so it falls back too.\n const isDiscriminated =\n !!discriminatorPropertyName &&\n nodeMembers.every((m) => isObjectSchemaNode(m, cyclicSchemas)) &&\n !nodeMembers.some((m) => hasCoercedDiscriminator({ member: m, propertyName: discriminatorPropertyName, options: this.options }))\n const isXor = node.strategy === 'one' && !isDiscriminated && this.options.oneOfType === 'xor'\n // `z.xor` already rejects a value matching several members, so its members stay as declared.\n const isStrict = node.strategy === 'one' && !isXor && !unionsWithSiblings.has(node)\n const members = mapSchemaMembers(node, (memberNode) => this.transform(isStrict ? strictOneOfNode(memberNode) : memberNode))\n .map(({ schema, output }) => (output && isStrict && dialect.strictMember ? dialect.strictMember(output, schema, cyclicSchemas) : output))\n .filter(Boolean)\n if (members.length === 0) return ''\n if (members.length === 1) return members[0]!\n if (isDiscriminated) {\n return `z.discriminatedUnion(${stringify(node.discriminatorPropertyName)}, ${buildList(members)})`\n }\n if (isXor) return `z.xor(${buildList(members)})`\n\n return `z.union(${buildList(members)})`\n },\n intersection(node) {\n const members = node.members ?? []\n if (members.length === 0) return ''\n const hasSiblingProperties = members.some((member) => member.type === ast.schemaTypes.object && member.properties.length > 0)\n const transform = (member: ast.SchemaNode) => {\n if (!hasSiblingProperties) return this.transform(member)\n unionsWithSiblings.add(member)\n try {\n return this.transform(member)\n } finally {\n unionsWithSiblings.delete(member)\n }\n }\n\n const [first, ...rest] = members\n if (!first) return ''\n\n const firstBase = transform(first)\n if (!firstBase) return ''\n\n // An object `allOf` is a merge, not a runtime intersection: extending keeps it a Zod object\n // (usable in z.discriminatedUnion) instead of a non-discriminable intersection.\n if (rest.length > 0 && isObjectComposableIntersection(node, cyclicSchemas)) {\n return preserveRequiredProperties(members)\n .slice(1)\n .reduce((acc, member) => dialect.extend(acc, dialect.objectShape(this, member)), firstBase)\n }\n\n return rest.reduce((acc, member) => {\n const constraint = getMemberConstraint({ member, regexType: this.options.regexType, lengths: dialect.lengths, numbers: dialect.numbers })\n if (constraint) return acc + constraint\n const transformed = transform(member)\n return transformed ? dialect.intersection(acc, transformed) : acc\n }, firstBase)\n },\n }\n}\n","import { lazyGetter, objectKey } from '@internals/utils'\nimport { ast, syncSchemaRef } from '@kubb/kit'\nimport type { PluginZod, ResolverZod } from '../types.ts'\nimport {\n applyModifiers,\n buildObjectShape,\n defaultLiteral,\n lengthConstraints,\n numberConstraints,\n patternKeySchema,\n printWithOmit,\n shouldCoerce,\n} from '../utils.ts'\nimport { buildScalarNodes, buildZodNodes, type ZodDialect } from './zodNodes.ts'\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 * How a non-discriminated `oneOf` is printed: `z.union` with strict members or `z.xor`.\n *\n * @default 'union'\n */\n oneOfType?: PluginZod['resolvedOptions']['oneOfType']\n /**\n * Date format in the OpenAPI spec (`'date'` or `'date-time'`).\n */\n dateType?: ast.ParserOptions['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 * Which way a node converts between its wire type and its runtime type:\n * - `'decode'` (default): wire into runtime, used by response schemas.\n * - `'encode'`: runtime back to wire, used by request bodies and parameters.\n *\n * Named for the conversion rather than the slot, since Zod's own `z.input` and `z.output`\n * describe a different axis and read inverted here: the `'decode'` schema is the one whose\n * `z.input` is the wire type.\n *\n * A handler returning different output per direction makes the generator emit an\n * `${name}InputSchema` variant for that component.\n */\n direction?: 'encode' | 'decode'\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 // Inline objects are already strict through their node; only a ref needs the runtime call.\n\n if (node.type === ast.schemaTypes.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 const refName = ast.resolveRefName(node)\n if (refName && cyclicSchemas?.has(refName)) {\n return member\n }\n\n const schema = syncSchemaRef(node)\n\n if (schema.nullable || schema.optional || node.nullable || node.optional) {\n return member\n }\n\n if (schema.type === ast.schemaTypes.object && (schema.additionalProperties === undefined || schema.additionalProperties === false)) {\n return `${member}.strict()`\n }\n }\n\n return member\n}\n\n/**\n * Builds the `{ key: value, … }` shape for an object node with the chainable modifiers.\n */\nfunction buildZodObjectShape(ctx: Parameters<typeof buildObjectShape>[0], node: ast.SchemaNode): string {\n return buildObjectShape(ctx, node, ({ name, value, schema, required, meta, cyclic }) => {\n const body = applyModifiers({\n value,\n schema,\n nullable: meta.nullable,\n optional: schema.optional || required === false,\n nullish: schema.nullish,\n defaultValue: meta.default,\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 description: schema.type !== ast.schemaTypes.ref && meta.type === ast.schemaTypes.ref ? undefined : meta.description,\n examples: meta.examples,\n })\n if (!cyclic) return `${objectKey(name)}: ${body}`\n const returnType = recursiveGetterType({ ctx, schema, required })\n return returnType ? `get ${objectKey(name)}(): ${returnType} { return ${body} }` : lazyGetter({ name, body })\n })\n}\n\n/**\n * Breaks getter inference cycles without widening recursive refs and arrays to `z.ZodType`.\n */\nfunction recursiveGetterType({\n ctx,\n schema,\n required,\n}: {\n ctx: Parameters<typeof buildObjectShape>[0]\n schema: ast.SchemaNode\n required?: boolean\n}): string | undefined {\n function baseType(schema: ast.SchemaNode): string | undefined {\n if (ctx.options.nodes?.[schema.type]) return undefined\n if (schema.type === ast.schemaTypes.ref) {\n const saved = ctx.options.cyclicSchemas\n ctx.options.cyclicSchemas = undefined\n const name = ctx.transform(schema)\n ctx.options.cyclicSchemas = saved\n return name ? `typeof ${name}` : undefined\n }\n if (schema.type === ast.schemaTypes.array && schema.items?.length === 1) {\n const item = baseType(schema.items[0]!)\n return item ? `z.ZodArray<${item}>` : undefined\n }\n return undefined\n }\n const base = baseType(schema)\n if (!base) return undefined\n\n const meta = syncSchemaRef(schema)\n const optional = schema.optional || required === false\n const wrapped = (() => {\n if (schema.nullish || (meta.nullable && optional)) return `z.ZodOptional<z.ZodNullable<${base}>>`\n if (optional) return `z.ZodOptional<${base}>`\n if (meta.nullable) return `z.ZodNullable<${base}>`\n return base\n })()\n return meta.default !== undefined && defaultLiteral(schema, meta.default) !== null ? `z.ZodDefault<${wrapped}>` : wrapped\n}\n\n/**\n * Types the direction probe skips. They delegate to their children rather than reading\n * `direction` themselves, so {@link containsDirectionalNode} probes their children instead.\n */\nconst CONTAINER_TYPES = new Set<ast.SchemaType>([\n ast.schemaTypes.object,\n ast.schemaTypes.array,\n ast.schemaTypes.tuple,\n ast.schemaTypes.union,\n ast.schemaTypes.intersection,\n ast.schemaTypes.ref,\n])\n\ntype DirectionProbeContext = { options: PrinterZodOptions; transform: () => null; base: () => null; import: () => void }\n\n/**\n * Runs the node's effective handler (a `printer.nodes` override, else the built-in) once per\n * direction and reports whether the two disagree. That difference is what makes a component\n * need an `${name}InputSchema` variant.\n */\nfunction variesByDirection({ node, printerOptions }: { node: ast.SchemaNode; printerOptions: PrinterZodOptions }): boolean {\n if (CONTAINER_TYPES.has(node.type)) return false\n\n const handler = printerOptions.nodes?.[node.type] ?? scalarNodes[node.type]\n if (!handler) return false\n\n const call = (direction: 'encode' | 'decode') => {\n const context: DirectionProbeContext = { options: { ...printerOptions, direction }, transform: () => null, base: () => null, import: () => {} }\n return (handler as (this: DirectionProbeContext, node: ast.SchemaNode) => string | null).call(context, node)\n }\n\n return call('decode') !== call('encode')\n}\n\n/**\n * Whether the schema transitively contains a node that prints differently per direction, so it\n * must decode on responses and encode on requests. Follows `$ref`s through their resolved schema.\n */\nexport function containsDirectionalNode({ node, printerOptions }: { node: ast.SchemaNode | undefined; printerOptions: PrinterZodOptions }): boolean {\n if (!node) return false\n\n return ast.findSchema(node, { predicate: (schema) => variesByDirection({ node: schema, printerOptions }), followRefs: true }) !== undefined\n}\n\n/**\n * Names of the `$ref` schemas the generator should route to their input (encode) variant.\n */\nexport function collectDirectionalRefNames({ node, printerOptions }: { node: ast.SchemaNode; printerOptions: PrinterZodOptions }): Array<string> {\n return ast.collectSync<string>(node, {\n schema: (n) =>\n n.type === ast.schemaTypes.ref && n.ref && containsDirectionalNode({ node: n, printerOptions }) ? (ast.resolveRefName(n) ?? undefined) : undefined,\n })\n}\n\n/**\n * Handlers that never recurse into children, so {@link variesByDirection} can call one directly\n * to probe both directions without building a printer.\n *\n * `date` and `time` are the built-in two-way conversions, decoding `string → Date` on responses\n * and encoding back on requests. `date` keeps `date` and `date-time` precision apart. `time` has\n * no date component, so it decodes onto `1970-01-01` UTC and encodes back to `HH:mm:ss`, dropping\n * fractional seconds. Only `representation: 'date'` fields convert; ISO-string fields print the\n * matching `z.iso.*()` either way. A `printer.nodes.date` or `printer.nodes.time` override\n * replaces the whole handler, direction branch included.\n */\nconst standardDialect: ZodDialect<PrinterZodOptions> = {\n lengths: lengthConstraints,\n numbers: numberConstraints,\n patternKey: patternKeySchema,\n objectShape: buildZodObjectShape,\n coercedInt: 'z.coerce.number().int()',\n coercedNumber: (schema) => `z.coerce.number().pipe(${schema})`,\n catchall: (object, value) => `${object}.catchall(${value})`,\n nullable: (value) => `${value}.nullable()`,\n unique: (array) => `${array}.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })`,\n extend: (base, shape) => `${base}.extend(${shape})`,\n intersection: (left, right) => `${left}.and(${right})`,\n strictMember: strictOneOfMember,\n useInputVariant: (node, options) => options.direction === 'encode' && containsDirectionalNode({ node, printerOptions: options }),\n}\n\nconst scalarNodes: PrinterZodNodes = {\n ...buildScalarNodes(standardDialect),\n bigint() {\n return 'z.coerce.bigint()'\n },\n date(node) {\n if (node.representation !== 'date') return 'z.iso.date()'\n\n if (this.options.direction === 'encode') {\n return node.format === 'date' ? 'z.date().transform((value) => value.toISOString().slice(0, 10))' : 'z.date().transform((value) => value.toISOString())'\n }\n\n const decoded = node.format === 'date' ? 'z.iso.date().transform((value) => new Date(value))' : 'z.iso.datetime().transform((value) => new Date(value))'\n return shouldCoerce(this.options.coercion, 'dates') ? 'z.coerce.date()' : decoded\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 if (this.options.direction === 'encode') {\n return 'z.date().transform((value) => value.toISOString().slice(11, 19))'\n }\n\n // No `z.coerce.date()` branch: `new Date('13:45:00')` is an Invalid Date, so coercion cannot parse a wire time.\n return 'z.iso.time().transform((value) => new Date(`1970-01-01T${value}Z`))'\n },\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 const nodes: PrinterZodNodes = { ...buildZodNodes(standardDialect, options.cyclicSchemas), ...scalarNodes }\n\n return {\n name: 'zod',\n options,\n nodes,\n overrides: options.nodes,\n print(node) {\n return printWithOmit(this, node, (value, meta) =>\n applyModifiers({\n value,\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})\n","import { lazyGetter, objectKey } from '@internals/utils'\nimport { ast } from '@kubb/kit'\nimport type { PluginZod, ResolverZod } from '../types.ts'\nimport { applyMiniModifiers, buildObjectShape, lengthChecksMini, numberChecksMini, patternKeySchemaMini, printWithOmit, shouldCoerce } from '../utils.ts'\nimport { buildZodNodes, type ZodDialect } from './zodNodes.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 * Enable automatic type coercion for strings, numbers, and dates through `z.coerce.*()`.\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 `z.regex(...)`: a regex literal\n * (`'literal'`) or the `RegExp` constructor (`'constructor'`).\n *\n * @default 'literal'\n */\n regexType?: PluginZod['resolvedOptions']['regexType']\n /**\n * How a non-discriminated `oneOf` is printed: `z.union` with strict members or `z.xor`.\n *\n * @default 'union'\n */\n oneOfType?: PluginZod['resolvedOptions']['oneOfType']\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 * 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\n/**\n * Builds the `{ key: value, … }` shape for an object node with the functional `zod/mini` modifiers.\n */\nfunction buildZodMiniObjectShape(ctx: Parameters<typeof buildObjectShape>[0], node: ast.SchemaNode): string {\n return buildObjectShape(ctx, node, ({ name, value, schema, required, meta, cyclic }) => {\n const body = applyMiniModifiers({\n value,\n schema,\n nullable: meta.nullable,\n optional: schema.optional || required === false,\n nullish: schema.nullish,\n defaultValue: meta.default,\n })\n return cyclic ? lazyGetter({ name, body }) : `${objectKey(name)}: ${body}`\n })\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 */\nconst miniDialect: ZodDialect<PrinterZodMiniOptions> = {\n lengths: lengthChecksMini,\n numbers: numberChecksMini,\n patternKey: patternKeySchemaMini,\n objectShape: buildZodMiniObjectShape,\n coercedInt: 'z.coerce.number().check(z.int())',\n coercedNumber: (schema) => `z.pipe(z.coerce.number(), ${schema})`,\n catchall: (object, value) => `z.catchall(${object}, ${value})`,\n nullable: (value) => `z.nullable(${value})`,\n unique: (array) => `${array}.check(z.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" }))`,\n extend: (base, shape) => `z.extend(${base}, ${shape})`,\n intersection: (left, right) => `z.intersection(${left}, ${right})`,\n}\n\nexport const printerZodMini = ast.createPrinter<PrinterZodMiniFactory>((options) => {\n return {\n name: 'zod-mini',\n options,\n nodes: {\n ...buildZodNodes(miniDialect, options.cyclicSchemas),\n bigint(node) {\n return `z.coerce.bigint()${numberChecksMini(node)}`\n },\n date(node) {\n if (node.representation === 'string') {\n return 'z.iso.date()'\n }\n\n return shouldCoerce(this.options.coercion, 'dates') ? 'z.coerce.date()' : '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 },\n overrides: options.nodes,\n print(node) {\n return printWithOmit(\n this,\n node,\n (value, meta) =>\n applyMiniModifiers({ value, schema: node, nullable: meta.nullable, optional: meta.optional, nullish: meta.nullish, defaultValue: meta.default }),\n true,\n )\n },\n }\n})\n","import {\n buildOptionsSchema,\n buildResponses,\n getCircularNames,\n getOasAdapter,\n getOperationParameters,\n getSuccessResponses,\n isSuccessStatusCode,\n resolveContentTypeVariants,\n} from '@internals/shared'\nimport { ast, defineGenerator } from '@kubb/kit'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Zod } from '../components/Zod.tsx'\nimport { collectDirectionalRefNames, containsDirectionalNode, printerZod } from '../printers/printerZod.ts'\nimport type { PrinterZodOptions } from '../printers/printerZod.ts'\nimport { printerZodMini } from '../printers/printerZodMini.ts'\nimport type { PrinterZodMiniOptions } from '../printers/printerZodMini.ts'\nimport type { PluginZod, ResolverZod } from '../types'\nimport { shouldCoerce } from '../utils.ts'\n\n/**\n * The helper an inferred alias is printed with. `'codec'` reads a request (encode) schema from its\n * input and a response (decode) schema from its output; `true` keeps `z.infer` for both.\n */\nfunction aliasKind(inferred: PluginZod['resolvedOptions']['inferred'], direction: 'encode' | 'decode'): 'infer' | 'input' | 'output' {\n if (inferred !== 'codec') return 'infer'\n return direction === 'encode' ? 'input' : 'output'\n}\n\ntype BuildResponseUnionParams = {\n responses: Array<ast.ResponseNode>\n name: string\n fallbackUnknown: boolean\n}\n\n/**\n * The printer for one direction, built once per plugin per build. A `keysToOmit` list and a\n * `printer.nodes` override differ per node and have no string key, so they get a fresh printer.\n */\nfunction getPrinter(resolver: ResolverZod, options: PrinterZodOptions, mini: boolean, direction: 'encode' | 'decode') {\n const build = () => (mini ? printerZodMini(options as PrinterZodMiniOptions) : printerZod({ ...options, direction }))\n if (options.nodes || options.keysToOmit?.length) return build()\n const { coercion, guidType, regexType, oneOfType, dateType } = options\n const coerce = (['dates', 'strings', 'numbers'] as const).map((type) => shouldCoerce(coercion, type))\n return resolver.memo(`zodPrinter:${[mini, direction, ...coerce, guidType, regexType, oneOfType, dateType].join(':')}`, build)\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, oneOfType, compile, mini, inferred, typeGuards, importPath, group, printer } = ctx.options\n const dateType = getOasAdapter(adapter).options.dateType\n\n if (!node.name) {\n return\n }\n\n const isZodImport = importPath === 'zod' || importPath === 'zod/mini'\n const cyclicSchemas = getCircularNames(ctx)\n const printerOptions: PrinterZodOptions = { coercion, guidType, regexType, oneOfType, dateType, resolver, cyclicSchemas, nodes: printer?.nodes }\n\n // Rendered twice: the canonical schema decodes, the `${name}InputSchema` variant encodes.\n const hasDirectionalNode = !mini && containsDirectionalNode({ node, printerOptions })\n\n const directionalRefNames = new Set(hasDirectionalNode ? collectDirectionalRefNames({ node, printerOptions }) : [])\n const importEntries = resolver.imports({ node, root, output, group: group ?? undefined })\n const inputImportEntries = hasDirectionalNode\n ? [...directionalRefNames].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 imports = [\n ...new Map(\n [...importEntries, ...inputImportEntries].map((imp) => [`${Array.isArray(imp.name) ? imp.name.join(',') : imp.name}|${imp.path}`, imp] as const),\n ).values(),\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 isName = typeGuards ? resolver.schema.isName(node.name) : null\n const assertName = typeGuards ? resolver.schema.assertName(node.name) : null\n\n const schemaPrinter = getPrinter(resolver, printerOptions, mini, 'decode')\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\n name={meta.name}\n node={node}\n printer={schemaPrinter}\n inferTypeName={inferred ? resolver.schema.typeName(node.name) : null}\n inferKind={aliasKind(inferred, 'decode')}\n typeGuards={typeGuards}\n isName={isName}\n assertName={assertName}\n mini={mini}\n cyclic={cyclicSchemas.has(node.name)}\n compile={compile}\n />\n {hasDirectionalNode && (\n <Zod\n name={resolver.schema.inputName(node.name)}\n node={node}\n printer={getPrinter(resolver, printerOptions, mini, 'encode')}\n inferTypeName={inferred ? resolver.schema.inputTypeName(node.name) : null}\n inferKind={aliasKind(inferred, 'encode')}\n typeGuards={typeGuards}\n isName={typeGuards ? resolver.schema.isName(resolver.schema.inputName(node.name)) : null}\n assertName={typeGuards ? resolver.schema.assertName(resolver.schema.inputName(node.name)) : null}\n mini={mini}\n cyclic={cyclicSchemas.has(node.name)}\n compile={compile}\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, oneOfType, compile, mini, inferred, importPath, group, printer } = ctx.options\n const dateType = getOasAdapter(adapter).options.dateType\n\n const isZodImport = importPath === 'zod' || importPath === 'zod/mini'\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 = getCircularNames(ctx)\n const printerOptions: PrinterZodOptions = { coercion, guidType, regexType, oneOfType, dateType, resolver, cyclicSchemas, nodes: printer?.nodes }\n\n function renderSchemaEntry({\n schema,\n name,\n keysToOmit,\n direction = 'decode',\n }: {\n schema: ast.SchemaNode | null\n name: string\n keysToOmit?: Array<string> | null\n direction?: 'encode' | 'decode'\n }) {\n if (!schema) return null\n\n const directionalRefNames = direction === 'encode' && !mini ? new Set(collectDirectionalRefNames({ node: schema, printerOptions })) : null\n const imports = resolver.imports({\n node: schema,\n root,\n output,\n group: group ?? undefined,\n name: (schemaName) => (directionalRefNames?.has(schemaName) ? resolver.schema.inputName(schemaName) : resolver.name(schemaName)),\n })\n\n const schemaPrinter = getPrinter(resolver, { ...printerOptions, keysToOmit }, mini, 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\n name={name}\n node={schema}\n printer={schemaPrinter}\n inferTypeName={inferred ? resolver.schema.type(name) : null}\n inferKind={aliasKind(inferred, direction)}\n cyclic={false}\n compile={compile}\n />\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?: 'encode' | 'decode',\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) => (entry.schema ? ast.collectImportedRefNames(entry.schema).map((refName) => resolver.name(refName)) : [])),\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 = node.parameters.map((param) =>\n renderSchemaEntry({ schema: param.schema, name: resolver.param.name(node, param), direction: 'encode' }),\n )\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: 'encode',\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 'encode',\n )\n })()\n\n // Grouped path/query/headers schemas, one object per group: what a client's `validator.path` /\n // `query` / `headers` runs at request time, and what the options schema below references.\n const { path, query, header } = getOperationParameters(node)\n\n const paramGroupSchemas = (\n [\n { kind: 'path', params: path },\n { kind: 'query', params: query },\n { kind: 'headers', params: header },\n ] as const\n )\n .filter(({ params }) => params.length > 0)\n .map(({ kind, params }) =>\n renderSchemaEntry({\n schema: ast.factory.createSchema({\n type: 'object',\n // `primitive: 'object'` makes the printer emit `z.object(…)` rather than a record.\n primitive: 'object',\n properties: params.map((param) => ast.factory.createProperty({ name: param.name, required: param.required, schema: param.schema })),\n }),\n name: resolver.param[kind](node, params[0]!),\n direction: 'encode',\n }),\n )\n\n // The combined `{ body, path, query, headers }` options and per-status `responses` schemas exist\n // only to back `resolver.response.options(node)` and `resolver.response.responses(node)` for\n // consumers sourcing types from this plugin instead of `plugin-ts`. Not worth generating when\n // nothing will import them.\n const optionsSchema = inferred\n ? renderSchemaEntry({ schema: buildOptionsSchema(node, resolver), name: resolver.name(`${node.operationId} Options`), direction: 'encode' })\n : null\n\n // The per-status record a client's `RequestResult` is keyed on. Response bodies, so `output`.\n const responsesSchema = inferred ? renderSchemaEntry({ schema: buildResponses(node, resolver), name: resolver.response.responses(node) }) : null\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 {paramGroupSchemas}\n {optionsSchema}\n {responsesSchema}\n </File>\n )\n },\n})\n","","","import { createCasedFile, createOperationParamResolver, createOperationResponseResolver, operationKey } from '@internals/shared'\nimport { ensureValidVarName } from '@internals/utils'\nimport { camelCase, createResolver, pascalCase } 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 this.memo(`name:${name}`, () => ensureValidVarName(camelCase(name, { suffix: 'schema' })))\n },\n file: createCasedFile((part) => camelCase(part, { suffix: 'schema' })),\n schema: {\n typeName(name) {\n return this.memo(`typeName:${name}`, () => ensureValidVarName(pascalCase(name, { suffix: 'schema type' })))\n },\n type(name) {\n return this.memo(`type:${name}`, () => 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 isName(name) {\n return ensureValidVarName(camelCase(name, { prefix: 'is' }))\n },\n assertName(name) {\n return ensureValidVarName(camelCase(name, { prefix: 'assert' }))\n },\n },\n param: createOperationParamResolver(),\n response: {\n ...createOperationResponseResolver(),\n error(node) {\n const name = this.name(`${node.operationId} Error`)\n return this.resolveName({ key: operationKey(node, 'response', 'error'), name })\n },\n options(node) {\n const name = this.schema.type(this.name(`${node.operationId} Options`))\n return this.resolveName({ key: operationKey(node, 'response', 'options'), name })\n },\n },\n})\n","import { createGroupConfig } from '@internals/shared'\nimport { addGenerator, defineExtension, Resolver, setMacros, setResolver } from '@kubb/kit'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { 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: './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 = defineExtension<PluginZod>({\n kind: 'plugin',\n meta: { name: pluginZodName, version, compatibility },\n setup(options) {\n const {\n output = { path: 'zod', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n compile = false,\n mini = false,\n guidType = 'uuid',\n regexType = 'literal',\n oneOfType = 'union',\n importPath = mini ? 'zod/mini' : 'zod',\n coercion = false,\n inferred = false,\n typeGuards = false,\n printer,\n resolver: userResolver,\n macros: userMacros,\n } = options\n\n setResolver(userResolver ? Resolver.merge(resolverZod, userResolver) : resolverZod)\n if (userMacros?.length) {\n setMacros(userMacros)\n }\n addGenerator(zodGenerator)\n\n return {\n output,\n exclude,\n include,\n override,\n group: createGroupConfig(group),\n importPath,\n coercion,\n // `'direction'` is the deprecated name of `'codec'`.\n inferred: inferred === 'direction' ? 'codec' : inferred,\n guidType,\n regexType,\n oneOfType,\n compile,\n mini,\n typeGuards,\n printer,\n }\n },\n})\n\nexport default pluginZod\n"],"mappings":";;;;;;;;AAiMA,SAAS,qBAAqB,aAA6B;CACzD,MAAM,WAAW,YAAY,MAAM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WACZ,YAAY,SACZ,aAAa,OAAO,aAAa,OACjC,WAAW,OACX,WAAW,OACX,aAAa,OACb,SACA,UAAU,cACV,QAAQ,eACN;EAEJ,YAAY,eAAe,SAAS,MAAM,aAAa,YAAY,IAAI,WAAW;EAClF,IAAI,YAAY,QACd,UAAU,UAAU;EAEtB,aAAa,YAAY;EAEzB,OAAO;GACL;GACA;GACA;GACA;GACA,OAAO,kBAAkB,KAAK;GAC9B;GACA;GAEA,UAAU,aAAa,cAAc,UAAU;GAC/C;GACA;GACA;GACA;GACA;GACA;GACA;EACF;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../internals/shared/src/operation.ts","../../../internals/shared/src/adapter.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/strings.ts","../../../internals/utils/src/codegen.ts","../../../internals/utils/src/fs.ts","../../../internals/shared/src/resolver.ts","../../../internals/shared/src/group.ts","../../../internals/shared/src/schemaTraversal.ts","../src/components/Zod.tsx","../src/utils.ts","../src/printers/zodNodes.ts","../src/printers/printerZod.ts","../src/printers/printerZodMini.ts","../src/generators/zodGenerator.tsx","../kubb-extension.json","../package.json","../src/resolvers/resolverZod.ts","../src/plugin.ts"],"sourcesContent":["import { ast, type Group, type Memo, type Output, type Resolver, type ResolverFileParams, Url } from '@kubb/kit'\n\n/**\n * Builds the `ResolverFileParams` every operation generator passes to\n * `resolver.file`: a file named `name`, tagged by the operation's first\n * tag (or `'default'`), at the operation's path. Centralizes the entry object\n * that was repeated at dozens of call sites across the client and query plugins.\n *\n * @example\n * ```ts\n * resolver.file(operationFileEntry(node, node.operationId), { root, output, group })\n * ```\n */\nexport function operationFileEntry(node: ast.OperationNode, name: string, extname: ResolverFileParams['extname'] = '.ts'): ResolverFileParams {\n return {\n name,\n extname,\n tag: node.tags[0] ?? 'default',\n path: node.path,\n }\n}\n\n/**\n * Resolves a dependency plugin's generated file for `node.operationId`, cached in `memo` (the\n * build's `ctx.memo`) under the resolver's own plugin name and the operation. Several dependents reading the\n * same dependency for the same operation in one pass (a query plugin's several hook generators, the\n * MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.\n *\n * @example Cache `plugin-ts`'s file for the current operation\n * ```ts\n * const fileTs = resolveDependencyOperationFile({ memo: ctx.memo, node, resolver: tsResolver, root, output })\n * ```\n */\nexport function resolveDependencyOperationFile(options: {\n memo: Memo\n node: ast.OperationNode\n resolver: Pick<Resolver, 'file' | 'pluginName'>\n root: string\n output: Output\n group?: Group | null\n}): ast.FileNode {\n const { memo, node, resolver, root, output, group } = options\n\n return memo(`${resolver.pluginName}:operationFile:${node.operationId}`, () =>\n resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\n )\n}\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type OperationCommentLink = 'pathTemplate' | 'urlPath' | false | ((node: ast.OperationNode) => string | undefined)\n\nexport type BuildOperationCommentsOptions = {\n link?: OperationCommentLink\n linkPosition?: 'beforeDeprecated' | 'afterDeprecated'\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<Exclude<ast.ParameterNode['in'], 'querystring'>, Array<ast.ParameterNode>>\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\nfunction getOperationLink(node: ast.OperationNode, link: OperationCommentLink): string | null {\n if (!link) {\n return null\n }\n\n if (typeof link === 'function') {\n return link(node) ?? null\n }\n\n return node.path ? `{@link ${Url.toPath(node.path)}}` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(node.requestBody?.content?.map((e) => e.contentType) ?? [])\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(getPrimarySuccessResponse(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\nexport type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n\n/**\n * Reads the single base content type of an operation's primary success response, lowercased and\n * stripped of any `; charset=...` suffix. Returns `undefined` when the response declares zero or\n * more than one content type, since neither case has a single type to act on.\n */\nfunction getPrimarySuccessContentType(node: ast.OperationNode): string | undefined {\n const contentTypes = getPrimarySuccessResponse(node)?.content?.map((entry) => entry.contentType) ?? []\n if (contentTypes.length !== 1) return undefined\n return contentTypes[0]!.split(';')[0]!.trim().toLowerCase()\n}\n\n/**\n * The `text/event-stream` content of the primary success response, when it is the only content type. A response that also\n * declares another type stays a normal call with its query hooks.\n */\nfunction getEventStreamContent(node: ast.OperationNode): ast.ContentNode | undefined {\n return getPrimarySuccessContentType(node) === 'text/event-stream' ? getPrimarySuccessResponse(node)?.content?.[0] : undefined\n}\n\n/**\n * Whether an operation streams its primary success response as Server-Sent Events (`text/event-stream`). The client\n * generator uses this to return a typed event stream instead of a one-shot `RequestResult`.\n */\nexport function isEventStream(node: ast.OperationNode): boolean {\n return getEventStreamContent(node) !== undefined\n}\n\n/**\n * How the document types a `text/event-stream` response, as the adapter read it from `itemSchema`: `event` when each item is\n * the parsed event with its own `event` and `data`, `data` when it is only the payload. Returns `null` without an event stream.\n */\nexport function getEventStream(node: ast.OperationNode): 'event' | 'data' | null {\n const content = getEventStreamContent(node)\n return content ? (content.stream?.shape ?? 'data') : null\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` maps to\n * `'stream'`, `application/octet-stream`, `application/pdf`, `image/*`, `audio/*` and `video/*` map to `'blob'`, and\n * other `text/*` to `'text'`. Otherwise `undefined`, leaving the runtime client's `Content-Type` auto-detection in charge.\n */\nexport function getResponseType(node: ast.OperationNode): ResponseType | undefined {\n const baseType = getPrimarySuccessContentType(node)\n if (!baseType) return undefined\n\n if (baseType === 'application/json' || baseType.endsWith('+json') || baseType === 'text/json') return undefined\n if (baseType === 'text/event-stream') return 'stream'\n if (baseType.startsWith('text/')) return 'text'\n if (baseType === 'application/octet-stream' || baseType === 'application/pdf' || /^(image|audio|video)\\//.test(baseType)) return 'blob'\n return undefined\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n// The request groups come from the grouped params, so `config` drops the data-shape keys to stay\n// assignable to `Options`, which omits them from `RequestConfig`.\nconst requestConfigBaseType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\n\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n\n // Only the ambiguous side is offered: a single-type side has nothing to pick, so it stays baked in\n // the generated call.\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n return members.length ? `${requestConfigBaseType} & { contentType?: { ${members.join('; ')} } }` : requestConfigBaseType\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...). Unlike {@link buildRequestConfigType}, it never adds a\n * `contentType?:` member: query hooks wrap GET operations, which carry no request body to select a\n * content type for.\n */\nexport function buildClientOptionType(): string {\n return requestConfigBaseType\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n}\n\n/**\n * Which of the grouped request options an operation carries.\n */\nexport function getRequestGroups(node: ast.OperationNode): RequestGroups {\n const { path, query, header } = getOperationParameters(node)\n return {\n path: path.length > 0,\n query: query.length > 0,\n body: Boolean(node.requestBody?.content?.[0]?.schema),\n headers: header.length > 0,\n }\n}\n\nexport type RequestGroupOptionality = {\n groups: RequestGroups\n hasRequiredPath: boolean\n hasRequiredQuery: boolean\n hasRequiredHeader: boolean\n /**\n * Whether the grouped request parameter can default to `{}`. True only when no group carries a\n * required member, so every member is safe to omit.\n */\n isOptional: boolean\n}\n\n/**\n * Resolves which grouped request options an operation carries together with whether each group\n * holds a required member. The grouped parameter stays optional only when nothing inside it is\n * required, matching the generated `RequestConfig` type.\n */\nexport function getRequestGroupOptionality(node: ast.OperationNode): RequestGroupOptionality {\n const groups = getRequestGroups(node)\n const { path, query, header } = getOperationParameters(node)\n const hasRequiredPath = path.some((param) => param.required)\n const hasRequiredQuery = query.some((param) => param.required)\n const hasRequiredHeader = header.some((param) => param.required)\n\n return {\n groups,\n hasRequiredPath,\n hasRequiredQuery,\n hasRequiredHeader,\n isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !groups.body,\n }\n}\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: RequestGroups } {\n const { isConfigurable = true } = options\n const { groups, isOptional } = getRequestGroupOptionality(node)\n\n const names = (['path', 'query', 'body', 'headers'] as const).filter((key) => groups[key])\n\n // These callers never carry the `contentType` that several media types require.\n const optionsType = hasRequestContentTypeChoice(node)\n ? `Pick<${resolver.response.options(node)}, ${names.map((name) => `'${name}'`).join(' | ')}>`\n : resolver.response.options(node)\n const firstParam = names.length > 0 ? `{ ${names.join(', ')} }: ${optionsType}${isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { link = 'pathTemplate', linkPosition = 'afterDeprecated', splitLines = false } = options\n const linkComment = getOperationLink(node, link)\n const comments =\n linkPosition === 'beforeDeprecated'\n ? [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, linkComment, node.deprecated && '@deprecated']\n : [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, node.deprecated && '@deprecated', linkComment]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\nconst operationParameterGroupsByNode = new WeakMap<ast.OperationNode, OperationParameterGroups>()\n\n/**\n * An OpenAPI 3.2 `querystring` parameter is the whole query string, so a form-encoded object becomes one query parameter\n * per property, typed and serialized like any other.\n * Another content type, such as JSON, stays one parameter named after it, and the runtime sends its value as the whole query string.\n */\nfunction spreadQuerystring(param: ast.ParameterNode): Array<ast.ParameterNode> {\n const schema = param.schema.type === 'ref' ? param.schema.schema : param.schema\n const formEncoded = !param.contentType || param.contentType.split(';')[0]!.trim().toLowerCase() === 'application/x-www-form-urlencoded'\n if (schema?.type !== 'object' || !formEncoded) return [param]\n return schema.properties.map((property) =>\n ast.factory.createParameter({ name: property.name, in: 'query', schema: property.schema, required: param.required && property.required }),\n )\n}\n\n/**\n * Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each\n * group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance\n * (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the\n * same parameters once per plugin.\n */\nexport function getOperationParameters(node: ast.OperationNode): OperationParameterGroups {\n const cached = operationParameterGroupsByNode.get(node)\n if (cached) return cached\n\n // A malformed spec can declare the same name twice within one location. Both would resolve to the\n // same output property, so emitting both would yield an object type with a duplicate member,\n // which TypeScript rejects. Keep the first.\n const dedupe = (params: Array<ast.ParameterNode>) => {\n const seen = new Set<string>()\n return params.filter((param) => {\n if (seen.has(param.name)) return false\n seen.add(param.name)\n return true\n })\n }\n const group = (location: ast.ParameterNode['in']) => dedupe(node.parameters.filter((param) => param.in === location))\n\n const groups: OperationParameterGroups = {\n path: group('path'),\n query: dedupe([...group('query'), ...group('querystring').flatMap(spreadQuerystring)]),\n header: group('header'),\n cookie: group('cookie'),\n }\n\n operationParameterGroupsByNode.set(node, groups)\n return groups\n}\n\n/**\n * Builds the combined `{ body, path, query, headers }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same\n * shape from the same inputs. `primitive: 'object'` is a no-op for the TS printer and tells the Zod\n * printer to emit `z.object(…)` rather than a record.\n */\nexport function hasRequestContentTypeChoice(node: ast.OperationNode): boolean {\n return (node.requestBody?.content ?? []).filter((entry) => entry.schema).length > 1\n}\n\n/**\n * Casts a call argument to the client's parameter type; a `'plain'` client is non-generic.\n */\nexport function castToClientOptions(callArg: string, clientName: string, returnType: 'full' | 'data' | 'plain' = 'full'): string {\n return `${callArg} as Parameters<typeof ${clientName}${returnType === 'plain' ? '' : '<true>'}>[0]`\n}\n\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver, { pairContentTypes = false } = {}): ast.SchemaNode {\n const { path, query, header } = getOperationParameters(node)\n const hasBody = Boolean(node.requestBody?.content?.[0]?.schema)\n const createNever = () => ast.factory.createSchema({ type: 'never', primitive: undefined, optional: true })\n const groups = [\n { name: 'path', params: path, resolve: resolver.param.path },\n { name: 'query', params: query, resolve: resolver.param.query },\n { name: 'headers', params: header, resolve: resolver.param.headers },\n ] as const\n\n const createOptions = (body: ast.SchemaNode, extra: Array<ast.PropertyNode> = []) =>\n // NOTE(v5-stable): the fields were renamed from the legacy beta shape\n // (`data`/`pathParams`/`queryParams`/`headerParams`) to `body`/`path`/`query`/`headers` so the\n // type matches the runtime client. Drop this note once v5 leaves beta.\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({ name: 'body', required: hasBody, schema: body }),\n ...groups.map(({ name, params, resolve }) => {\n const required = params.some((param) => param.required)\n\n return ast.factory.createProperty({\n name,\n required,\n schema:\n params.length > 0\n ? ast.factory.createSchema({ type: 'ref', name: resolve.call(resolver.param, node, params[0]!), optional: !required })\n : createNever(),\n })\n }),\n ...extra,\n ],\n })\n\n const variants =\n pairContentTypes && hasRequestContentTypeChoice(node) ? resolveContentTypeVariants(node.requestBody?.content ?? [], resolver.response.body(node)) : []\n if (variants.length < 2) {\n return createOptions(hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever())\n }\n\n // The first media type is the runtime default, so only the others must pass `contentType`.\n return ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant, index) =>\n createOptions(ast.factory.createSchema({ type: 'ref', name: variant.name }), [\n ast.factory.createProperty({\n name: 'contentType',\n required: index > 0,\n schema: ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'request',\n required: true,\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] }),\n }),\n ],\n }),\n }),\n ]),\n ),\n })\n}\n\n/**\n * The schema a status occupies in the `<Name>Responses` record. A status that documents several\n * content types becomes a `{ contentType; data }` union so the runtime can surface the negotiated type\n * on `result.parsed`, while the standalone `<Name>StatusNNN` alias stays the plain body union that the\n * query hooks and `result.data` use.\n */\nfunction buildResponseRecordEntry(node: ast.OperationNode, res: ast.ResponseNode, resolver: ResponseStatusNameResolver): ast.SchemaNode {\n const statusName = resolver.response.status(node, res.statusCode)\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length <= 1) {\n return ast.factory.createSchema({ type: 'ref', name: statusName })\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: resolveContentTypeVariants(variants, statusName).map((variant) =>\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'contentType',\n required: true,\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] }),\n }),\n ast.factory.createProperty({\n name: 'data',\n required: true,\n schema: ast.factory.createSchema({ type: 'ref', name: variant.name }),\n }),\n ],\n }),\n ),\n })\n}\n\n/**\n * Builds the per-status `<Name>Responses` record for an operation, referencing the already-resolved\n * `<Name>StatusNNN` names. Shared by `@kubb/plugin-ts`'s `Responses` type and `@kubb/plugin-zod`'s\n * inferred responses schema, so both emit the same shape from the same inputs.\n *\n * Always emits the keyed record, even when an operation declares no responses. An operation with no\n * responses renders as an empty object, which keeps every consumer's import (for example the axios\n * SDK's `RequestResult<XResponses>`) resolvable instead of pointing at a missing export.\n */\nexport function buildResponses(node: ast.OperationNode, resolver: ResponseStatusNameResolver): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: node.responses.map((res) =>\n ast.factory.createProperty({\n name: String(res.statusCode),\n required: true,\n schema: buildResponseRecordEntry(node, res, resolver),\n }),\n ),\n })\n}\n\nexport function getStatusCodeNumber(statusCode: ast.StatusCode | number | string): number | null {\n const code = Number(statusCode)\n\n return Number.isNaN(code) ? null : code\n}\n\nexport function isSuccessStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 200 && code < 300\n}\n\nexport function isErrorStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 400\n}\n\nexport function getSuccessResponses<TResponse extends ResponseLike>(responses: ReadonlyArray<TResponse>): Array<TResponse> {\n return responses.filter((response) => isSuccessStatusCode(response.statusCode))\n}\n\nexport function getOperationSuccessResponses(node: ast.OperationNode): Array<ast.ResponseNode> {\n return getSuccessResponses(node.responses)\n}\n\nexport function getPrimarySuccessResponse(node: ast.OperationNode): ast.ResponseNode | null {\n return getOperationSuccessResponses(node)[0] ?? null\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.filter((response) => isSuccessStatusCode(response.statusCode)).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.response.status(node, response.statusCode))\n}\n\n/**\n * Lists the type names an operation's types file declares, computed once per resolver and `options` so every\n * dependent reads the same list.\n */\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver & Pick<Resolver, 'memo'>,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const key = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n return resolver.memo(`operationTypeNames:${key}`, () => {\n const { path, query, header } = getOperationParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ]\n const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n return names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n })\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = getStatusCodeNumber(response.statusCode)\n if (code === null) {\n continue\n }\n\n types.push([code, isSuccessStatusCode(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n","import { type Adapter, Diagnostics } from '@kubb/kit'\nimport type { AdapterOas } from '@kubb/adapter-oas'\n\n/**\n * Narrows the generic `Adapter` from a generator context to the OpenAPI adapter,\n * so OAS-only options (`dateType`, `enums`) and the parsed `document` are typed.\n *\n * Throws when a non-OAS adapter is configured, turning a silently wrong cast into a\n * clear, actionable error at the point of use.\n *\n * @example\n * ```ts\n * const { dateType } = getOasAdapter(ctx.adapter).options\n * ```\n */\nexport function getOasAdapter(adapter: Adapter): Adapter<AdapterOas> {\n if (adapter.name !== 'oas') {\n throw new Diagnostics.Error({\n code: Diagnostics.code.adapterRequired,\n severity: 'error',\n message: `Expected the OpenAPI adapter (adapterOas), but received \"${adapter.name}\".`,\n help: 'Set `adapter: adapterOas()` in kubb.config.ts.',\n location: { kind: 'config' },\n })\n }\n\n return adapter as Adapter<AdapterOas>\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'await',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `name` when it's a syntactically valid JavaScript variable name,\n * otherwise prefixes it with `_` so the result is a valid identifier.\n *\n * Useful for sanitizing OpenAPI schema names or operation IDs that start with\n * a digit (e.g. `409`, `504AccountCancel`) before using them as exported\n * variable, type, or function names.\n *\n * @example\n * ```ts\n * ensureValidVarName('409') // '_409'\n * ensureValidVarName('504AccountCancel') // '_504AccountCancel'\n * ensureValidVarName('Pet') // 'Pet'\n * ensureValidVarName('class') // '_class'\n * ```\n */\nexport function ensureValidVarName(name: string): string {\n if (!name || isValidVarName(name)) {\n return name\n }\n return `_${name}`\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","/**\n * Wraps a value in single quotes for emitting a single-quoted JavaScript string literal, escaping\n * any backslash or single quote in the content.\n *\n * @example\n * ```ts\n * singleQuote('foo') // \"'foo'\"\n * singleQuote(\"o'clock\") // \"'o\\\\'clock'\"\n * ```\n */\nexport function singleQuote(value: string | number | boolean | undefined | null): string {\n if (value === undefined || value === null) return \"''\"\n const escaped = String(value).replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")\n\n return `'${escaped}'`\n}\n\n/**\n * Strips a single matching pair of `\"...\"`, `'...'`, or `` `...` `` from both ends of `text`.\n * Returns the string unchanged when no balanced quote pair is found.\n *\n * @example\n * ```ts\n * trimQuotes('\"hello\"') // 'hello'\n * trimQuotes('hello') // 'hello'\n * ```\n */\nexport function trimQuotes(text: string): string {\n if (text.length >= 2) {\n const first = text[0]\n const last = text[text.length - 1]\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\") || (first === '`' && last === '`')) {\n return text.slice(1, -1)\n }\n }\n return text\n}\n\n/**\n * Serializes a primitive to a single-quoted string literal, stripping any surrounding quotes first.\n *\n * Escaping runs through `JSON.stringify`, then the result switches to single quotes so the generated\n * code matches the repo style without a formatter.\n *\n * @example\n * ```ts\n * stringify('hello') // \"'hello'\"\n * stringify('\"hello\"') // \"'hello'\"\n * ```\n */\nexport function stringify(value: string | number | boolean | undefined): string {\n if (value === undefined || value === null) return \"''\"\n const json = JSON.stringify(trimQuotes(value.toString()))\n const inner = json.slice(1, -1).replace(/\\\\\"/g, '\"').replace(/'/g, \"\\\\'\")\n return `'${inner}'`\n}\n\n/**\n * Escapes an `@` at the start of a line, so a multi-line description can't start a new JSDoc tag.\n * Editors render `\\@` as `@` in hovers.\n *\n * @example\n * ```ts\n * jsDocEscape('intro\\n@example value') // 'intro\\n\\\\@example value'\n * ```\n */\nexport function jsDocEscape(input: unknown): string {\n return `${input}`.replace(/^(\\s*)@/gm, '$1\\\\@')\n}\n\n/**\n * Escapes characters that are not allowed inside JS string literals, covering quotes, backslashes,\n * and the Unicode line terminators U+2028 and U+2029.\n *\n * @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4\n *\n * @example\n * ```ts\n * jsStringEscape('say \"hi\"\\nbye') // 'say \\\\\"hi\\\\\"\\\\nbye'\n * ```\n */\nexport function jsStringEscape(input: unknown): string {\n return `${input}`.replace(/[\"'\\\\\\n\\r\\u2028\\u2029]/g, (character) => {\n switch (character) {\n case '\"':\n case \"'\":\n case '\\\\':\n return `\\\\${character}`\n case '\\n':\n return '\\\\n'\n case '\\r':\n return '\\\\r'\n case '\\u2028':\n return '\\\\u2028'\n case '\\u2029':\n return '\\\\u2029'\n default:\n return ''\n }\n })\n}\n\n// `\\p{`, `\\P{` or `\\u{` behind an odd number of backslashes, or a character outside the BMP: both need the `u` flag.\nconst NEEDS_UNICODE = /(?<!\\\\)(?:\\\\\\\\)*\\\\[pPu]\\{|[\\u{10000}-\\u{10FFFF}]/u\n// Escapes the `u` flag accepts. `\\-` only counts inside a class.\nconst KEPT_ESCAPE = /[A-Za-z0-9^$\\\\.*+?()[\\]{}|/]/\n\n/**\n * Drops the backslash from escapes that the `u` flag rejects: an escaped punctuation character that is\n * not a syntax character, and `\\-` outside a class. Both match the same character without the backslash.\n */\nfunction dropIdentityEscapes(pattern: string): string {\n let inClass = false\n\n return pattern.replace(/\\\\(.)|[[\\]]/gs, (match, escaped?: string) => {\n if (escaped === undefined) {\n inClass = match === '['\n return match\n }\n\n return KEPT_ESCAPE.test(escaped) || (escaped === '-' && inClass) ? match : escaped\n })\n}\n\n/**\n * Builds the `RegExp` for a pattern, adding the `u` flag when it uses `\\p{...}`, `\\P{...}` or `\\u{...}`, or\n * holds a character outside the BMP. A pattern that is not valid under `u` keeps the flags it came with.\n */\nfunction toRegExp(pattern: string, flags: string | undefined): RegExp {\n if (flags?.includes('u') || !NEEDS_UNICODE.test(pattern)) return new RegExp(pattern, flags)\n\n try {\n return new RegExp(dropIdentityEscapes(pattern), `${flags ?? ''}u`)\n } catch {\n return new RegExp(pattern, flags)\n }\n}\n\n/**\n * Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.\n * Inline flags expressed as a `^(?im)` prefix are extracted and applied to the resulting expression.\n * Pass `null` as the second argument to emit a `/pattern/flags` literal instead.\n *\n * @example\n * ```ts\n * toRegExpString('^(?im)foo') // 'new RegExp(\"^foo\", \"im\")'\n * toRegExpString('^(?im)foo', null) // '/^foo/im'\n * ```\n */\nexport function toRegExpString(text: string, func: string | null = 'RegExp'): string {\n const raw = trimQuotes(text)\n\n const match = raw.match(/^\\^(\\(\\?([igmsuy]+)\\))/i)\n const replacementTarget = match?.[1] ?? ''\n const matchedFlags = match?.[2]\n const cleaned = raw\n .replace(/^\\\\?\\//, '')\n .replace(/\\\\?\\/$/, '')\n .replace(replacementTarget, '')\n\n const { source, flags } = toRegExp(cleaned, matchedFlags)\n\n if (func === null) return `/${source}/${flags}`\n\n return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ''})`\n}\n\n/**\n * Renders a dotted path or string array as an optional-chaining accessor expression rooted at\n * `accessor`. Returns `null` for an empty path.\n *\n * @example\n * ```ts\n * getNestedAccessor('pagination.next.id', 'lastPage')\n * // \"lastPage?.['pagination']?.['next']?.['id']\"\n * ```\n */\nexport function getNestedAccessor(param: string | Array<string>, accessor: string): string | null {\n const parts = Array.isArray(param) ? param : param.split('.')\n if (parts.length === 0 || (parts.length === 1 && parts[0] === '')) return null\n return `${accessor}?.['${`${parts.join(\"']?.['\")}']`}`\n}\n","import { 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 '@kubb/kit'\n\nfunction toSlash(p: string): string {\n if (p.startsWith('\\\\\\\\?\\\\')) return p\n return p.replaceAll('\\\\', '/')\n}\n\n/**\n * Returns the relative path from `rootDir` to `filePath`, always using forward slashes\n * and prefixed with `./` when not already traversing upward.\n *\n * @example\n * ```ts\n * getRelativePath('/src/components', '/src/components/Button.tsx') // './Button.tsx'\n * getRelativePath('/src/components', '/src/utils/helpers.ts') // '../utils/helpers.ts'\n * ```\n */\nexport function getRelativePath(rootDir: string, filePath: string): string {\n const relativePath = posix.relative(toSlash(rootDir), toSlash(filePath))\n\n return relativePath.startsWith('../') ? relativePath : `./${relativePath}`\n}\n\n/**\n * Builds a nested file path from a dotted name. Splits on dots that precede a letter\n * (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases\n * every earlier segment, applies `caseLast` to the final segment, and joins with `/`.\n *\n * Empty segments are dropped before joining. They arise when the name starts with a dot\n * followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to\n * an empty string). Without this a leading `/` would form, which `path.resolve` reads as an\n * absolute path, letting generated files escape the configured output directory.\n *\n * @example Nested path from a dotted name\n * `toFilePath('pet.petId') // 'pet/petId'`\n *\n * @example PascalCase the final segment\n * `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`\n *\n * @example Suffix applied to the final segment only\n * `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`\n */\nexport function toFilePath(name: string, caseLast: (part: string) => string = camelCase): string {\n const parts = name.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => (i === parts.length - 1 ? caseLast(part) : camelCase(part)))\n .filter(Boolean)\n .join('/')\n}\n","import { ensureValidVarName, toFilePath } from '@internals/utils'\nimport { ast, camelCase } from '@kubb/kit'\nimport type { GeneratorContext, Resolver, ResolverFile } from '@kubb/kit'\n\n/**\n * The shared top-level `name` of the operation plugins, computed once per operation name and build.\n */\nexport function resolveOperationName(this: Resolver, name: string): string {\n return this.memo(`operation:${name}`, () => ensureValidVarName(camelCase(name)))\n}\n\n/**\n * Builds the allocation key for a declaration an operation owns. `scope` names which declaration\n * it is, so two of them never share an allocation even when a custom resolver gives both the same\n * name. Leave `scope` empty for the operation's own declaration.\n *\n * @example\n * ```ts\n * resolver.resolveName({ key: operationKey(node, 'response', 'status', 404), name })\n * ```\n */\nexport function operationKey(node: ast.OperationNode, ...scope: Array<string | number>): Array<string | undefined> {\n return ['operation', node.method, node.path, ...scope.map(String)]\n}\n\n/**\n * The `param` namespace shared by the schema-producing plugins (ts, zod, faker):\n * per-parameter names plus the grouped `Path`/`Query`/`Headers` names, all routed\n * through the plugin's top-level `name` casing.\n */\nexport type OperationParamResolver = {\n name(this: Resolver, node: ast.OperationNode, param: ast.ParameterNode): string\n path(this: Resolver, node: ast.OperationNode): string\n query(this: Resolver, node: ast.OperationNode): string\n headers(this: Resolver, node: ast.OperationNode): string\n}\n\n/**\n * The `response` namespace shared by the schema-producing plugins: per-status,\n * body, and combined response names, all routed through the plugin's top-level\n * `name` casing.\n */\nexport type OperationResponseResolver = {\n status(this: Resolver, node: ast.OperationNode, statusCode: ast.StatusCode): string\n body(this: Resolver, node: ast.OperationNode): string\n responses(this: Resolver, node: ast.OperationNode): string\n response(this: Resolver, node: ast.OperationNode): string\n}\n\n/**\n * Builds the shared `param` namespace. Spread the result into `createResolver`\n * and override individual methods next to it when a plugin deviates.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ param: createOperationParamResolver(), ... })\n * ```\n */\nexport function createOperationParamResolver(): OperationParamResolver {\n return {\n name(node, param) {\n const name = this.name(`${node.operationId} ${param.in} ${param.name}`)\n return this.resolveName({ key: operationKey(node, 'param', 'name', param.in, param.name), name })\n },\n path(node) {\n const name = this.name(`${node.operationId} Path`)\n return this.resolveName({ key: operationKey(node, 'param', 'path'), name })\n },\n query(node) {\n const name = this.name(`${node.operationId} Query`)\n return this.resolveName({ key: operationKey(node, 'param', 'query'), name })\n },\n headers(node) {\n const name = this.name(`${node.operationId} Headers`)\n return this.resolveName({ key: operationKey(node, 'param', 'headers'), name })\n },\n }\n}\n\n/**\n * Builds the shared `response` namespace. Spread the result into\n * `createResolver` and add plugin-specific methods (`options`, `error`) next\n * to it.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ response: { ...createOperationResponseResolver(), options(node) {...} }, ... })\n * ```\n */\nexport function createOperationResponseResolver(): OperationResponseResolver {\n return {\n status(node, statusCode) {\n const name = this.name(`${node.operationId} Status ${statusCode}`)\n return this.resolveName({ key: operationKey(node, 'response', 'status', statusCode), name })\n },\n body(node) {\n const name = this.name(`${node.operationId} Body`)\n return this.resolveName({ key: operationKey(node, 'response', 'body'), name })\n },\n responses(node) {\n const name = this.name(`${node.operationId} Responses`)\n return this.resolveName({ key: operationKey(node, 'response', 'responses'), name })\n },\n response(node) {\n const name = this.name(`${node.operationId} Response`)\n return this.resolveName({ key: operationKey(node, 'response', 'response'), name })\n },\n }\n}\n\n/**\n * Builds a resolver `file` override whose base name runs every path segment\n * through `toFilePath`, casing the final segment with `caseLast`.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ file: createCasedFile(pascalCase), ... })\n * ```\n */\nexport function createCasedFile(caseLast: (part: string) => string): ResolverFile {\n return {\n baseName({ name, extname }) {\n return this.memo(`file:${name}\\0${extname}`, (): ast.FileNode['baseName'] => `${toFilePath(name, caseLast)}${extname}`)\n },\n }\n}\n\ntype SchemaIndexContext = Pick<GeneratorContext, 'memo' | 'driver'>\n\n/**\n * Names of the schemas in a circular reference chain, computed once per build.\n */\nexport function getCircularNames(ctx: SchemaIndexContext): ReadonlySet<string> {\n return ctx.memo('circularNames:set', () => ast.findCircularSchemas(ctx.driver.inputNode?.schemas ?? []))\n}\n\n/**\n * Names of the schemas whose type is `enum`, computed once per build.\n */\nexport function getEnumNames(ctx: SchemaIndexContext): ReadonlySet<string> {\n return ctx.memo(\n 'enumNames:set',\n () => new Set((ctx.driver.inputNode?.schemas ?? []).flatMap((schema) => (schema.type === 'enum' && schema.name ? [schema.name] : []))),\n )\n}\n\ndeclare global {\n namespace Kubb {\n interface MemoRegistry {\n operation: string\n file: ast.FileNode['baseName']\n operationTypeNames: Array<string>\n }\n }\n}\n","import { camelCase, type Group } from '@kubb/kit'\n\n/**\n * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the\n * shared default naming so every plugin groups output consistently:\n *\n * - `path` groups use the second path segment (`/pet/findByStatus` → `pet`).\n * - other groups use the camelCased group (`pet store` → `petStore`).\n *\n * A user-provided `group.name` always wins over the default namer, so callers stay in\n * control of their output folders. Returns `null` when grouping is disabled, matching the\n * per-plugin convention.\n *\n * @param group - The user-supplied group option, or `undefined` to disable grouping.\n *\n * @example\n * ```ts\n * createGroupConfig(group) // shared across every plugin\n * ```\n */\nexport function createGroupConfig(group: Group | undefined): Group | null {\n if (!group) {\n return null\n }\n\n const defaultName = (ctx: { group: string }): string => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n\n return camelCase(ctx.group)\n }\n\n return {\n ...group,\n name: group.name ? group.name : defaultName,\n } satisfies Group\n}\n","import type { ast } from '@kubb/kit'\n\n/**\n * Converts a child schema to printer output. Plugins instantiate it with their own output type:\n * `string` for the zod and faker printers, `ts.TypeNode` for the TypeScript printer. A printer's\n * `this.transform` fits directly, so its `null` for an empty result carries through to `output`.\n */\nexport type SchemaTransform<TOutput> = (schema: ast.SchemaNode) => TOutput\n\n/**\n * A union or intersection member, or an array or tuple item, paired with its transformed output.\n */\nexport type MappedSchema<TOutput> = {\n /**\n * The original child schema, kept so the printer can read its metadata for leaf formatting.\n */\n schema: ast.SchemaNode\n /**\n * The child schema after being run through the transform.\n */\n output: TOutput\n}\n\n/**\n * An object property paired with its transformed output.\n */\nexport type MappedProperty<TOutput> = {\n /**\n * The property name as written on the schema, before any identifier quoting.\n */\n name: string\n /**\n * The original property node, kept so the printer can read `required`, `schema`, and metadata.\n */\n property: ast.PropertyNode\n /**\n * The property schema after being run through the transform.\n */\n output: TOutput\n}\n\n/**\n * Maps each property of an object schema to its transformed output. Pairs every result with the\n * original property so the printer keeps full control over modifiers, getters, and key syntax.\n *\n * @example\n * ```ts\n * const entries = mapSchemaProperties(node, (schema) => this.transform(schema))\n * // entries: [{ name: 'id', property, output: 'z.number()' }, ...]\n * ```\n */\nexport function mapSchemaProperties<TOutput>(node: ast.ObjectSchemaNode, transform: SchemaTransform<TOutput>): Array<MappedProperty<TOutput>> {\n return node.properties.map((property) => ({ name: property.name, property, output: transform(property.schema) }))\n}\n\n/**\n * Maps each member of a union or intersection schema to its transformed output, pairing every\n * result with the original member.\n */\nexport function mapSchemaMembers<TOutput>(\n node: ast.UnionSchemaNode | ast.IntersectionSchemaNode,\n transform: SchemaTransform<TOutput>,\n): Array<MappedSchema<TOutput>> {\n return (node.members ?? []).map((schema) => ({ schema, output: transform(schema) }))\n}\n\n/**\n * Maps each item of an array or tuple schema to its transformed output, pairing every result with\n * the original item.\n */\nexport function mapSchemaItems<TOutput>(node: ast.ArraySchemaNode, transform: SchemaTransform<TOutput>): Array<MappedSchema<TOutput>> {\n return (node.items ?? []).map((schema) => ({ schema, output: transform(schema) }))\n}\n","import { ast, containsCircularRef } from '@kubb/kit'\nimport { Const, File, Function, Type } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx'\nimport type { PrinterZodFactory } from '../printers/printerZod.ts'\nimport type { PrinterZodMiniFactory } from '../printers/printerZodMini.ts'\n\nimport type { CompileOptions } from '../types.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 * The helper the `inferTypeName` alias is printed with. `infer` and `output` name the parsed value,\n * `input` the value the schema accepts; they differ only for a codec.\n *\n * @default 'infer'\n */\n inferKind?: 'infer' | 'input' | 'output'\n typeGuards?: boolean | { is?: boolean; assert?: boolean }\n isName?: string | null\n assertName?: string | null\n mini?: boolean\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 * Wrap the schema initializer in `z.compile(...)` for fast-path validation.\n * Pass `{ strict: true }` to enforce strict compilation without silent fallback.\n *\n * @note Only compatible with Zod v4.5.0 or above.\n */\n compile?: boolean | CompileOptions\n}\n\nexport function Zod({ name, node, printer, inferTypeName, inferKind = 'infer', typeGuards, isName, assertName, mini, cyclic, compile }: Props): KubbReactNode {\n const output = printer.print(node)\n const printerImports = printer.drainImports()\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 const isBare = ast.isBareRef(node, printer.options.keysToOmit)\n const isCyclic = Boolean(cyclic || (printer.options.cyclicSchemas && containsCircularRef(node, { circularSchemas: printer.options.cyclicSchemas })))\n const shouldCompile = Boolean(compile) && !isBare && !isCyclic\n const value = shouldCompile ? (typeof compile === 'object' && compile.strict ? `z.compile(${output}, { strict: true })` : `z.compile(${output})`) : output\n\n const targetType = inferTypeName ?? `z.infer<typeof ${name}>`\n const shouldGenerateIs = isName && (typeof typeGuards === 'object' ? (typeGuards.is ?? true) : Boolean(typeGuards))\n const shouldGenerateAssert = assertName && (typeof typeGuards === 'object' ? (typeGuards.assert ?? true) : Boolean(typeGuards))\n\n return (\n <>\n {printerImports.map((imp) => (\n <File.Import\n key={[name, imp.path, imp.name].join('-')}\n name={imp.name}\n path={imp.path}\n root={imp.root}\n isTypeOnly={imp.isTypeOnly}\n isNameSpace={imp.isNameSpace}\n />\n ))}\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} type={needsAnnotation ? 'z.ZodType' : undefined}>\n {value}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n <Type export name={inferTypeName}>\n {`z.${inferKind}<typeof ${name}>`}\n </Type>\n </File.Source>\n )}\n {shouldGenerateIs && (\n <File.Source name={isName} isExportable isIndexable>\n <Const export name={isName} JSDoc={{ comments: [`Type guard for {@link ${name}}`] }}>\n {mini ? `(data: unknown): data is ${targetType} => z.validate(${name}, data)` : `(data: unknown): data is ${targetType} => ${name}.validate(data)`}\n </Const>\n </File.Source>\n )}\n {shouldGenerateAssert && (\n <File.Source name={assertName} isExportable isIndexable>\n <Function\n export\n name={assertName}\n params=\"data: unknown\"\n returnType={`asserts data is ${targetType}`}\n JSDoc={{ comments: [`Asserter for {@link ${name}}`, '@throws {z.ZodError} If data is invalid'] }}\n >\n {mini ? `if (!z.validate(${name}, data)) {\\n z.parse(${name}, data)\\n}` : `if (!${name}.validate(data)) {\\n ${name}.parse(data)\\n}`}\n </Function>\n </File.Source>\n )}\n </>\n )\n}\n","import { buildObject, stringify, toRegExpString } from '@internals/utils'\nimport { mapSchemaProperties } from '@internals/shared'\nimport { ast, containsCircularRef, syncSchemaRef } 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 * Whether the schema node represents a closed or finite set of keys (e.g. enum, literal,\n * or union of enums/literals).\n *\n * In Zod v4, passing a closed key schema to `z.record()` enforces exhaustiveness (all keys\n * must exist in the input). OpenAPI 3.1 `propertyNames` only validates present keys without\n * requiring all keys to exist, so closed key schemas use `z.partialRecord()` instead.\n */\nexport function isClosedKeySchema(node: ast.SchemaNode | undefined): boolean {\n if (!node) return false\n const resolved = syncSchemaRef(node)\n if (resolved.type === 'enum') return true\n if (resolved.type === 'union') {\n const members = resolved.members ?? []\n return members.length > 0 && members.every(isClosedKeySchema)\n }\n return false\n}\n\n/**\n * Whether the node is a plain inline object whose shape can be lifted into an `.extend({ … })`\n * argument. Property counts, a catchall, `patternProperties`, or a nullable/optional wrapper cannot, so those stay\n * on `.and(…)`.\n */\nexport function isPlainInlineObject(node: ast.SchemaNode): boolean {\n if (node.type !== 'object') return false\n if (node.minProperties !== undefined || node.maxProperties !== undefined) return false\n if (node.nullable || node.optional || node.nullish) return false\n\n const hasAdditionalProperties = node.additionalProperties !== undefined\n const hasPatternProperties = Boolean(node.patternProperties)\n\n return !hasAdditionalProperties && !hasPatternProperties && !node.propertyNames\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 * Property counts render as a pipe. A ref into `cyclicSchemas` renders as `z.lazy(…)`.\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') {\n if (node.minProperties !== undefined || node.maxProperties !== undefined) return false\n const hasProperties = Boolean(node.properties?.length)\n const hasTypedAdditionalProperties = Boolean(node.additionalProperties && node.additionalProperties !== true)\n const hasPatternProperties = Boolean(node.patternProperties)\n\n const isRecord = !hasProperties && (hasTypedAdditionalProperties || hasPatternProperties || node.propertyNames)\n\n return !isRecord\n }\n\n if (node.type === 'ref') {\n const refName = ast.resolveRefName(node)\n if (refName && cyclicSchemas?.has(refName)) return false\n const resolved = 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\nexport function preserveRequiredProperties(members: Array<ast.SchemaNode>): Array<ast.SchemaNode> {\n const hasRequiredProperty = ({\n node,\n propertyName,\n seen = new Set<ast.SchemaNode>(),\n }: {\n node: ast.SchemaNode\n propertyName: string\n seen?: Set<ast.SchemaNode>\n }): boolean => {\n if (seen.has(node)) return false\n seen.add(node)\n const resolved = syncSchemaRef(node)\n const composition = ast.narrowSchema(resolved, ast.schemaTypes.intersection) ?? ast.narrowSchema(resolved, ast.schemaTypes.union)\n // Property lookup skips unions, but a single-member union prints as its member.\n if (composition) {\n if (composition.type === ast.schemaTypes.union && composition.members?.length !== 1) return false\n return composition.members?.some((child) => hasRequiredProperty({ node: child, propertyName, seen })) ?? false\n }\n return ast\n .resolveSchemaProperties({ node: resolved, propertyName })\n .some((property) => property.required !== false && !property.schema.optional && !property.schema.nullish)\n }\n\n return members.map((member, index) => {\n const object = ast.narrowSchema(member, ast.schemaTypes.object)\n if (!object || index === 0) return member\n\n return {\n ...object,\n properties: object.properties.map((property) => {\n const required = members.slice(0, index).some((base) => hasRequiredProperty({ node: base, propertyName: property.name }))\n if (!required) return property\n\n return {\n ...property,\n required: true,\n schema: { ...property.schema, optional: false, nullish: false, nullable: property.schema.nullable || property.schema.nullish },\n }\n }),\n }\n })\n}\n\n/**\n * Format a default value as a code-level literal.\n * Arrays and objects keep their contents as a JSON literal, primitives become their string\n * 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 JSON.stringify(value)\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 const resolved = node ? syncSchemaRef(node) : undefined\n if (resolved && ast.narrowSchema(resolved, '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 (resolved && ast.narrowSchema(resolved, '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 = resolved ? ast.narrowSchema(resolved, '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 ? formatDefault(match) : null\n }\n }\n return formatDefault(value)\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<unknown>): string {\n const allStrings = values.every((v) => typeof v === 'string')\n if (allStrings) return `z.enum([${values.map((v) => formatDefault(v)).join(', ')}])`\n\n const literals = values.map((value) => buildLiteral(value))\n if (literals.length === 1) return literals[0]!\n\n return `z.union([${literals.join(', ')}])`\n}\n\n/**\n * Preserves the structure of JSON const values in both Zod APIs.\n */\nexport function buildLiteral(value: unknown): string {\n if (value === null) return 'z.null()'\n if (Array.isArray(value)) return `z.tuple([${value.map((item) => buildLiteral(item)).join(', ')}])`\n if (typeof value === 'object') {\n const properties = Object.entries(value).map(([name, item]) => `${JSON.stringify(name)}: ${buildLiteral(item)}`)\n return `z.strictObject({${properties.join(', ')}})`\n }\n return `z.literal(${formatDefault(value)})`\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 * Digit pattern for a `type: 'string'` schema that carries an integer `format`, the way ProtoJSON\n * encodes 64-bit integers. Returns `undefined` for every other format, and a `pattern` from the\n * spec takes precedence over this fallback.\n *\n * @example\n * ```ts\n * integerFormatPattern('uint64') // '^\\\\d+$'\n * ```\n */\nexport function integerFormatPattern(format: string | undefined): string | undefined {\n if (format === 'int32' || format === 'int64') return '^-?\\\\d+$'\n if (format === 'uint64') return '^\\\\d+$'\n\n return undefined\n}\n\n/**\n * Renders a `pattern` as a regex literal, or as `new RegExp(...)` when `regexType` is `'constructor'`.\n */\nfunction regexSource(pattern: string, regexType: PluginZod['resolvedOptions']['regexType'] | undefined): string {\n return toRegExpString(pattern, regexType === 'constructor' ? 'RegExp' : null)\n}\n\nfunction joinPatterns(patterns: Array<string>): string {\n return patterns.length === 1 ? patterns[0]! : patterns.map((pattern) => `(${pattern})`).join('|')\n}\n\n/**\n * Builds a Zod record key schema that enforces the `patternProperties` regexes a plain\n * `.catchall()` would drop.\n */\nexport function patternKeySchema({ patterns, regexType }: { patterns: Array<string>; regexType?: PluginZod['resolvedOptions']['regexType'] }): string {\n return `z.string().regex(${regexSource(joinPatterns(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(${regexSource(joinPatterns(patterns), 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(${regexSource(pattern, 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(${regexSource(pattern, regexType)})`)\n return checks.length ? `.check(${checks.join(', ')})` : ''\n}\n\n/**\n * Checks property counts before object parsing strips unknown keys or inserts defaults.\n */\nexport function objectConstraints({ value, node }: { value: string; node: ast.SchemaNode }): string {\n if (node.type !== 'object') return value\n const checks: Array<string> = []\n const skip = 'typeof value !== \"object\" || value === null || Array.isArray(value)'\n if (node.minProperties !== undefined) {\n checks.push(\n `z.refine(value => ${skip} || Object.keys(value).length >= ${node.minProperties}, { message: \"Object must have at least ${node.minProperties} properties\" })`,\n )\n }\n if (node.maxProperties !== undefined) {\n checks.push(\n `z.refine(value => ${skip} || Object.keys(value).length <= ${node.maxProperties}, { message: \"Object must have at most ${node.maxProperties} properties\" })`,\n )\n }\n return checks.length ? `z.pipe(z.unknown().check(${checks.join(', ')}), ${value})` : value\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()`. Zod Mini has no\n * `.unwrap()`, so its printer passes `._zod.def.innerType` as the `step`.\n */\nexport function omitUnwrapChain(node: ast.SchemaNode, step = '.unwrap()'): 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 step.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\n/**\n * Calls for string `format`s with a dedicated Zod constructor; a `Map` so `constructor` cannot hit `Object.prototype`.\n */\nexport const STRING_FORMAT_CALLS = new Map<string | undefined, string>([\n ['byte', 'z.base64()'],\n ['base64', 'z.base64()'],\n ['base64url', 'z.base64url()'],\n ['jwt', 'z.jwt()'],\n ['ulid', 'z.ulid()'],\n ['iban', 'z.iban()'],\n ['duration', 'z.iso.duration()'],\n ['hostname', 'z.hostname()'],\n])\n\n/**\n * Marks an inline `oneOf` object strict, so `object()` builds `z.strictObject(...)` and no eager `.shape` read hits a deferred getter.\n */\nexport function strictOneOfNode(node: ast.SchemaNode): ast.SchemaNode {\n return node.type === 'object' && node.additionalProperties === undefined ? { ...node, additionalProperties: false } : node\n}\n\n/**\n * The constraint chain an `allOf` member adds to a bare string, number or array; each printer passes its own renderers.\n */\nexport function getMemberConstraint({\n member,\n regexType,\n lengths,\n numbers,\n}: {\n member: ast.SchemaNode\n regexType?: LengthConstraints['regexType']\n lengths: (constraints: LengthConstraints) => string\n numbers: (constraints: NumericConstraints) => string\n}): string | undefined {\n if (member.primitive === 'string') return lengths({ ...(ast.narrowSchema(member, 'string') ?? {}), regexType }) || undefined\n if (member.primitive === 'number' || member.primitive === 'integer')\n return numbers(ast.narrowSchema(member, 'number') ?? ast.narrowSchema(member, 'integer') ?? {}) || undefined\n if (member.primitive === 'array') return lengths({ ...(ast.narrowSchema(member, 'array') ?? {}), regexType }) || undefined\n}\n\ntype PrinterContext = {\n transform: (node: ast.SchemaNode) => string | null\n options: { cyclicSchemas?: ReadonlySet<string>; nodes?: Partial<Record<ast.SchemaType, unknown>> }\n}\n\n/**\n * Builds the `{ key: value, … }` shape shared by the `z.object(...)` and `.extend(...)` renderings.\n */\nexport function buildObjectShape(\n ctx: PrinterContext,\n node: ast.SchemaNode,\n renderProperty: (args: {\n name: string\n value: string\n schema: ast.SchemaNode\n required?: boolean\n meta: ReturnType<typeof syncSchemaRef>\n cyclic: boolean\n }) => string,\n): 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 && containsCircularRef(schema, { circularSchemas: ctx.options.cyclicSchemas })\n\n const entries = mapSchemaProperties(objectNode, (schema) => {\n // A getter defers evaluation, so clear cyclicSchemas to skip z.lazy() on nested refs.\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 }).map(({ name, property, output: value }) => {\n const { schema } = property\n return renderProperty({ name, value, schema, required: property.required, meta: syncSchemaRef(schema), cyclic: isCyclic(schema) })\n })\n\n return buildObject(entries)\n}\n\n/**\n * Shared `print` body: transforms the node, applies `keysToOmit` as `.omit(...)` (or `z.omit(...)` when `mini`), then `modify` adds the modifiers.\n */\nexport function printWithOmit(\n ctx: { transform: (node: ast.SchemaNode) => string | null; options: { keysToOmit?: Array<string> | null } },\n node: ast.SchemaNode,\n modify: (value: string, meta: ReturnType<typeof syncSchemaRef>) => string,\n mini = false,\n): string | null {\n const { keysToOmit } = ctx.options\n\n const transformed = ctx.transform(node)\n if (!transformed) return null\n\n const meta = syncSchemaRef(node)\n\n const base = (() => {\n if (!keysToOmit?.length || meta.primitive !== 'object' || (meta.type === 'union' && meta.discriminatorPropertyName)) return transformed\n\n // A ref resolves to a wrapper variable; unwrap to the inner object before omitting.\n // Zod Mini schemas have no `.unwrap()` / `.omit()`, so walk `_zod.def.innerType` and call `z.omit()`.\n const unwrap = omitUnwrapChain(node, mini ? '._zod.def.innerType' : '.unwrap()')\n const mask = `{ ${keysToOmit.map((k: string) => `\"${k}\": true`).join(', ')} }`\n const omit = (target: string) => {\n const inner = `${target}${unwrap}`\n const hasObjectConstraints = meta.type === 'object' && (meta.minProperties !== undefined || meta.maxProperties !== undefined)\n const pipe = mini ? `${inner}._zod.def` : inner\n const object = hasObjectConstraints ? `${pipe}.out` : inner\n const omitted = mini ? `z.omit(${object}, ${mask})` : `${object}.omit(${mask})`\n return hasObjectConstraints ? `z.pipe(${pipe}.in, ${omitted})` : omitted\n }\n\n const lazyMatch = transformed.match(/^z\\.lazy\\(\\(\\)\\s*=>\\s*(.+)\\)$/)\n if (lazyMatch) return `z.lazy(() => ${omit(lazyMatch[1]!)})`\n return omit(transformed)\n })()\n\n return modify(base, meta)\n}\n","import { mapSchemaItems, mapSchemaMembers } from '@internals/shared'\nimport { buildList, stringify } from '@internals/utils'\nimport { ast, syncSchemaRef } from '@kubb/kit'\nimport type { PluginZod, ResolverZod } from '../types.ts'\nimport {\n buildEnum,\n buildLiteral,\n type buildObjectShape,\n getMemberConstraint,\n integerFormatPattern,\n isClosedKeySchema,\n isObjectComposableIntersection,\n isObjectSchemaNode,\n type lengthConstraints,\n type numberConstraints,\n objectConstraints,\n type patternKeySchema,\n preserveRequiredProperties,\n shouldCoerce,\n strictOneOfNode,\n STRING_FORMAT_CALLS,\n} from '../utils.ts'\n\n/**\n * The options both Zod printers read in the shared handlers.\n */\nexport type ZodNodeOptions = {\n coercion?: PluginZod['resolvedOptions']['coercion']\n guidType?: PluginZod['resolvedOptions']['guidType']\n regexType?: PluginZod['resolvedOptions']['regexType']\n oneOfType?: PluginZod['resolvedOptions']['oneOfType']\n resolver?: ResolverZod\n cyclicSchemas?: ReadonlySet<string>\n direction?: 'encode' | 'decode'\n nodes?: Partial<Record<ast.SchemaType, unknown>>\n}\n\n/**\n * The strings that differ between the chainable `zod` API and the functional `zod/mini` API.\n */\nexport type ZodDialect<TOptions extends ZodNodeOptions = ZodNodeOptions> = {\n lengths: typeof lengthConstraints\n numbers: typeof numberConstraints\n patternKey: typeof patternKeySchema\n objectShape: (ctx: Parameters<typeof buildObjectShape>[0], node: ast.SchemaNode) => string\n /**\n * The coerced integer base, without its numeric checks.\n */\n coercedInt: string\n /**\n * Wraps a schema so its input is coerced to a number before the schema checks it.\n */\n coercedNumber: (schema: string) => string\n catchall: (object: string, value: string) => string\n nullable: (value: string) => string\n unique: (array: string) => string\n extend: (base: string, shape: string) => string\n intersection: (left: string, right: string) => string\n /**\n * Post-processes a member of a strict `oneOf`. `zod/mini` has no chainable `.strict()`, so it leaves this unset.\n */\n strictMember?: (member: string, schema: ast.SchemaNode, cyclicSchemas?: ReadonlySet<string>) => string\n /**\n * Whether a `$ref` resolves to its `${name}InputSchema` variant. `zod/mini` is direction-free, so it leaves this unset.\n */\n useInputVariant?: (node: ast.SchemaNode, options: TOptions) => boolean\n}\n\n/**\n * Reads a union of bare single-value enums as one enum, except under `xor` or an enum override, which need each member.\n * Only a numeric union with a `format` coerces, because it printed as `z.coerce.number()` before the adapter kept its values.\n */\nfunction getLiteralUnion({\n node,\n options,\n}: {\n node: ast.UnionSchemaNode\n options: ZodNodeOptions\n}): { values: Array<string | number | boolean>; coerce: boolean } | undefined {\n if ((node.strategy === 'one' && options.oneOfType === 'xor') || options.nodes?.enum) return undefined\n const values = (node.members ?? []).map((member) => {\n const enumNode = ast.narrowSchema(member, ast.schemaTypes.enum)\n return enumNode && !enumNode.name && !enumNode.nullable && !enumNode.namedEnumValues && enumNode.enumValues?.length === 1\n ? enumNode.enumValues[0]\n : undefined\n })\n if (!values.length || !values.every((value): value is string | number | boolean => value !== undefined && value !== null)) return undefined\n\n return { values, coerce: !!node.format && values.every((value) => typeof value === 'number') && shouldCoerce(options.coercion, 'numbers') }\n}\n\n/**\n * Whether a discriminated union member's discriminator property prints as a coerced literal union.\n */\nfunction hasCoercedDiscriminator({ member, propertyName, options }: { member: ast.SchemaNode; propertyName: string; options: ZodNodeOptions }): boolean {\n return ast.resolveSchemaProperties({ node: member, propertyName }).some(({ schema }) => {\n const resolved = syncSchemaRef(schema)\n return resolved.type === 'union' && !!getLiteralUnion({ node: resolved, options })?.coerce\n })\n}\n\n/**\n * Builds the scalar handlers both dialects share. They never recurse into children. The temporal\n * scalars and `bigint` differ per dialect, so each printer adds its own.\n */\nexport function buildScalarNodes<TOptions extends ZodNodeOptions>(dialect: ZodDialect<TOptions>): ast.PrinterPartial<string, TOptions> {\n return {\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 coerce = shouldCoerce(this.options.coercion, 'strings')\n const call = coerce ? undefined : STRING_FORMAT_CALLS.get(node.format)\n if (call) return `${call}${dialect.lengths({ ...node, regexType: this.options.regexType })}`\n\n const base = coerce ? 'z.coerce.string()' : 'z.string()'\n const pattern = node.pattern ?? integerFormatPattern(node.format)\n\n return `${base}${dialect.lengths({ ...node, pattern, 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}${dialect.numbers(node)}`\n },\n integer(node) {\n if (shouldCoerce(this.options.coercion, 'numbers')) return `${dialect.coercedInt}${dialect.numbers(node)}`\n if (node.format === 'int32') return `z.int32()${dialect.numbers(node)}`\n if (node.format === 'uint32') return `z.uint32()${dialect.numbers(node)}`\n\n return `z.int()${dialect.numbers(node)}`\n },\n uuid(node) {\n const base = this.options.guidType === 'guid' ? 'z.guid()' : 'z.uuid()'\n\n return `${base}${dialect.lengths({ ...node, regexType: this.options.regexType })}`\n },\n email(node) {\n return `z.email()${dialect.lengths({ ...node, regexType: this.options.regexType })}`\n },\n url(node) {\n return `z.url()${dialect.lengths({ ...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) => buildLiteral(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 }\n}\n\n/**\n * Builds the node handlers of one Zod printer instance from its dialect: the shared scalars plus\n * the `ref` and container handlers.\n *\n * `cyclicSchemas` is captured once because the object handler clears `options.cyclicSchemas` while\n * it renders a getter body, and the `.strict()` and discriminability decisions must still see it.\n */\nexport function buildZodNodes<TOptions extends ZodNodeOptions>(\n dialect: ZodDialect<TOptions>,\n cyclicSchemas: ReadonlySet<string> | undefined,\n): ast.PrinterPartial<string, TOptions> {\n const unionsWithSiblings = new WeakSet<ast.SchemaNode>()\n\n return {\n ...buildScalarNodes(dialect),\n ref(node) {\n if (!node.name) return null\n const refName = ast.resolveRefName(node)\n if (!refName) return null\n\n // In the input direction, a component whose fields print differently by direction resolves\n // to its `${name}InputSchema` variant so request bodies encode instead of decoding.\n const useInputVariant = node.ref != null && (dialect.useInputVariant?.(node, this.options) ?? false)\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 patterns = node.patternProperties ? Object.entries(node.patternProperties) : []\n const propertyNamesNode = node.propertyNames\n const propertyNamesKeySchema = propertyNamesNode ? this.transform(propertyNamesNode) : null\n\n // `additionalProperties: false` still permits patternProperties keys, so only a pattern-free object is strict.\n // `z.strictObject(...)` rather than `z.object(...).strict()`: `.strict()` reads `.shape` eagerly, which runs a\n // self-reference's deferred getter while its own `const` is still in the temporal dead zone.\n const isStrict = node.additionalProperties === false && patterns.length === 0\n const isLoose = node.additionalProperties === true\n const ctor = isStrict ? 'z.strictObject' : isLoose ? 'z.looseObject' : 'z.object'\n const shape = dialect.objectShape(this, node)\n const objectBase = `${ctor}(${shape})`\n\n const result = (() => {\n // Closed key schemas (enums, literals) use z.partialRecord() so missing keys do not fail exhaustiveness.\n const recordFn = isClosedKeySchema(propertyNamesNode) ? 'z.partialRecord' : 'z.record'\n\n if (node.additionalProperties && node.additionalProperties !== true) {\n const catchallType = this.transform(node.additionalProperties)\n if (entries.length === 0) {\n return catchallType ? `${recordFn}(${propertyNamesKeySchema || 'z.string()'}, ${catchallType})` : objectBase\n }\n return catchallType ? dialect.catchall(objectBase, catchallType) : objectBase\n }\n if (entries.length === 0 && patterns.length === 0 && propertyNamesKeySchema && !isStrict) {\n const unknownType = this.transform(ast.factory.createSchema({ type: ast.schemaTypes.unknown }))!\n return `${recordFn}(${propertyNamesKeySchema}, ${unknownType})`\n }\n if (node.additionalProperties === true) return objectBase\n if (isStrict) return objectBase\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 a 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: ast.schemaTypes.unknown }))!\n return valueSchema.nullable ? dialect.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 dialect.catchall(objectBase, value)\n return `z.record(${dialect.patternKey({ patterns: patterns.map(([pattern]) => pattern), regexType: this.options.regexType })}, ${value})`\n }\n\n return objectBase\n })()\n\n return objectConstraints({ value: result, node })\n },\n array(node) {\n const items = mapSchemaItems(node, (item) => this.transform(item))\n .map(({ output }) => output)\n .filter(Boolean)\n const inner = items.join(', ') || this.transform(ast.factory.createSchema({ type: ast.schemaTypes.unknown }))!\n const base = `z.array(${inner})${dialect.lengths({ ...node, regexType: this.options.regexType })}`\n\n return node.unique ? dialect.unique(base) : base\n },\n tuple(node) {\n const items = 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 literalUnion = getLiteralUnion({ node, options: this.options })\n if (literalUnion) {\n const schema = buildEnum(literalUnion.values)\n return literalUnion.coerce ? dialect.coercedNumber(schema) : schema\n }\n\n const nodeMembers = node.members ?? []\n const { discriminatorPropertyName } = node\n // z.discriminatedUnion needs every option to be a Zod object. Object variants (refs or\n // extend-composed `allOf`) qualify; intersections, cyclic `z.lazy(…)` refs, and\n // non-objects fall back to z.union. A coerced discriminator hides its values behind\n // `z.coerce.number()`, which z.discriminatedUnion cannot read, so it falls back too.\n const isDiscriminated =\n !!discriminatorPropertyName &&\n nodeMembers.every((m) => isObjectSchemaNode(m, cyclicSchemas)) &&\n !nodeMembers.some((m) => hasCoercedDiscriminator({ member: m, propertyName: discriminatorPropertyName, options: this.options }))\n const isXor = node.strategy === 'one' && !isDiscriminated && this.options.oneOfType === 'xor'\n // `z.xor` already rejects a value matching several members, so its members stay as declared.\n const isStrict = node.strategy === 'one' && !isXor && !unionsWithSiblings.has(node)\n const members = mapSchemaMembers(node, (memberNode) => this.transform(isStrict ? strictOneOfNode(memberNode) : memberNode))\n .map(({ schema, output }) => (output && isStrict && dialect.strictMember ? dialect.strictMember(output, schema, cyclicSchemas) : output))\n .filter(Boolean)\n if (members.length === 0) return ''\n if (members.length === 1) return members[0]!\n if (isDiscriminated) {\n return `z.discriminatedUnion(${stringify(node.discriminatorPropertyName)}, ${buildList(members)})`\n }\n if (isXor) return `z.xor(${buildList(members)})`\n\n return `z.union(${buildList(members)})`\n },\n intersection(node) {\n const members = node.members ?? []\n if (members.length === 0) return ''\n const hasSiblingProperties = members.some((member) => member.type === ast.schemaTypes.object && member.properties.length > 0)\n const transform = (member: ast.SchemaNode) => {\n if (!hasSiblingProperties) return this.transform(member)\n unionsWithSiblings.add(member)\n try {\n return this.transform(member)\n } finally {\n unionsWithSiblings.delete(member)\n }\n }\n\n const [first, ...rest] = members\n if (!first) return ''\n\n const firstBase = transform(first)\n if (!firstBase) return ''\n\n // An object `allOf` is a merge, not a runtime intersection: extending keeps it a Zod object\n // (usable in z.discriminatedUnion) instead of a non-discriminable intersection.\n if (rest.length > 0 && isObjectComposableIntersection(node, cyclicSchemas)) {\n return preserveRequiredProperties(members)\n .slice(1)\n .reduce((acc, member) => dialect.extend(acc, dialect.objectShape(this, member)), firstBase)\n }\n\n return rest.reduce((acc, member) => {\n const constraint = getMemberConstraint({ member, regexType: this.options.regexType, lengths: dialect.lengths, numbers: dialect.numbers })\n if (constraint) return acc + constraint\n const transformed = transform(member)\n return transformed ? dialect.intersection(acc, transformed) : acc\n }, firstBase)\n },\n }\n}\n","import { lazyGetter, objectKey } from '@internals/utils'\nimport { ast, syncSchemaRef } from '@kubb/kit'\nimport type { PluginZod, ResolverZod } from '../types.ts'\nimport {\n applyModifiers,\n buildObjectShape,\n defaultLiteral,\n lengthConstraints,\n numberConstraints,\n patternKeySchema,\n printWithOmit,\n shouldCoerce,\n} from '../utils.ts'\nimport { buildScalarNodes, buildZodNodes, type ZodDialect } from './zodNodes.ts'\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 * How a non-discriminated `oneOf` is printed: `z.union` with strict members or `z.xor`.\n *\n * @default 'union'\n */\n oneOfType?: PluginZod['resolvedOptions']['oneOfType']\n /**\n * Date format in the OpenAPI spec (`'date'` or `'date-time'`).\n */\n dateType?: ast.ParserOptions['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 * Which way a node converts between its wire type and its runtime type:\n * - `'decode'` (default): wire into runtime, used by response schemas.\n * - `'encode'`: runtime back to wire, used by request bodies and parameters.\n *\n * Named for the conversion rather than the slot, since Zod's own `z.input` and `z.output`\n * describe a different axis and read inverted here: the `'decode'` schema is the one whose\n * `z.input` is the wire type.\n *\n * A handler returning different output per direction makes the generator emit an\n * `${name}InputSchema` variant for that component.\n */\n direction?: 'encode' | 'decode'\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 // Inline objects are already strict through their node; only a ref needs the runtime call.\n\n if (node.type === ast.schemaTypes.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 const refName = ast.resolveRefName(node)\n if (refName && cyclicSchemas?.has(refName)) {\n return member\n }\n\n const schema = syncSchemaRef(node)\n\n if (schema.nullable || schema.optional || node.nullable || node.optional) {\n return member\n }\n\n if (schema.type === ast.schemaTypes.object && (schema.additionalProperties === undefined || schema.additionalProperties === false)) {\n return `${member}.strict()`\n }\n }\n\n return member\n}\n\n/**\n * Builds the `{ key: value, … }` shape for an object node with the chainable modifiers.\n */\nfunction buildZodObjectShape(ctx: Parameters<typeof buildObjectShape>[0], node: ast.SchemaNode): string {\n return buildObjectShape(ctx, node, ({ name, value, schema, required, meta, cyclic }) => {\n const body = applyModifiers({\n value,\n schema,\n nullable: meta.nullable,\n optional: schema.optional || required === false,\n nullish: schema.nullish,\n defaultValue: meta.default,\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 description: schema.type !== ast.schemaTypes.ref && meta.type === ast.schemaTypes.ref ? undefined : meta.description,\n examples: meta.examples,\n })\n if (!cyclic) return `${objectKey(name)}: ${body}`\n const returnType = recursiveGetterType({ ctx, schema, required })\n return returnType ? `get ${objectKey(name)}(): ${returnType} { return ${body} }` : lazyGetter({ name, body })\n })\n}\n\n/**\n * Breaks getter inference cycles without widening recursive refs and arrays to `z.ZodType`.\n */\nfunction recursiveGetterType({\n ctx,\n schema,\n required,\n}: {\n ctx: Parameters<typeof buildObjectShape>[0]\n schema: ast.SchemaNode\n required?: boolean\n}): string | undefined {\n function baseType(schema: ast.SchemaNode): string | undefined {\n if (ctx.options.nodes?.[schema.type]) return undefined\n if (schema.type === ast.schemaTypes.ref) {\n const saved = ctx.options.cyclicSchemas\n ctx.options.cyclicSchemas = undefined\n const name = ctx.transform(schema)\n ctx.options.cyclicSchemas = saved\n return name ? `typeof ${name}` : undefined\n }\n if (schema.type === ast.schemaTypes.array && schema.items?.length === 1) {\n const item = baseType(schema.items[0]!)\n return item ? `z.ZodArray<${item}>` : undefined\n }\n return undefined\n }\n const base = baseType(schema)\n if (!base) return undefined\n\n const meta = syncSchemaRef(schema)\n const optional = schema.optional || required === false\n const wrapped = (() => {\n if (schema.nullish || (meta.nullable && optional)) return `z.ZodOptional<z.ZodNullable<${base}>>`\n if (optional) return `z.ZodOptional<${base}>`\n if (meta.nullable) return `z.ZodNullable<${base}>`\n return base\n })()\n return meta.default !== undefined && defaultLiteral(schema, meta.default) !== null ? `z.ZodDefault<${wrapped}>` : wrapped\n}\n\n/**\n * Types the direction probe skips. They delegate to their children rather than reading\n * `direction` themselves, so {@link containsDirectionalNode} probes their children instead.\n */\nconst CONTAINER_TYPES = new Set<ast.SchemaType>([\n ast.schemaTypes.object,\n ast.schemaTypes.array,\n ast.schemaTypes.tuple,\n ast.schemaTypes.union,\n ast.schemaTypes.intersection,\n ast.schemaTypes.ref,\n])\n\ntype DirectionProbeContext = { options: PrinterZodOptions; transform: () => null; base: () => null; import: () => void }\n\n/**\n * Runs the node's effective handler (a `printer.nodes` override, else the built-in) once per\n * direction and reports whether the two disagree. That difference is what makes a component\n * need an `${name}InputSchema` variant.\n */\nfunction variesByDirection({ node, printerOptions }: { node: ast.SchemaNode; printerOptions: PrinterZodOptions }): boolean {\n if (CONTAINER_TYPES.has(node.type)) return false\n\n const handler = printerOptions.nodes?.[node.type] ?? scalarNodes[node.type]\n if (!handler) return false\n\n const call = (direction: 'encode' | 'decode') => {\n const context: DirectionProbeContext = { options: { ...printerOptions, direction }, transform: () => null, base: () => null, import: () => {} }\n return (handler as (this: DirectionProbeContext, node: ast.SchemaNode) => string | null).call(context, node)\n }\n\n return call('decode') !== call('encode')\n}\n\n/**\n * Whether the schema transitively contains a node that prints differently per direction, so it\n * must decode on responses and encode on requests. Follows `$ref`s through their resolved schema.\n */\nexport function containsDirectionalNode({ node, printerOptions }: { node: ast.SchemaNode | undefined; printerOptions: PrinterZodOptions }): boolean {\n if (!node) return false\n\n return ast.findSchema(node, { predicate: (schema) => variesByDirection({ node: schema, printerOptions }), followRefs: true }) !== undefined\n}\n\n/**\n * Names of the `$ref` schemas the generator should route to their input (encode) variant.\n */\nexport function collectDirectionalRefNames({ node, printerOptions }: { node: ast.SchemaNode; printerOptions: PrinterZodOptions }): Array<string> {\n return ast.collectSync<string>(node, {\n schema: (n) =>\n n.type === ast.schemaTypes.ref && n.ref && containsDirectionalNode({ node: n, printerOptions }) ? (ast.resolveRefName(n) ?? undefined) : undefined,\n })\n}\n\n/**\n * Handlers that never recurse into children, so {@link variesByDirection} can call one directly\n * to probe both directions without building a printer.\n *\n * `date` and `time` are the built-in two-way conversions, decoding `string → Date` on responses\n * and encoding back on requests. `date` keeps `date` and `date-time` precision apart. `time` has\n * no date component, so it decodes onto `1970-01-01` UTC and encodes back to `HH:mm:ss`, dropping\n * fractional seconds. Only `representation: 'date'` fields convert; ISO-string fields print the\n * matching `z.iso.*()` either way. A `printer.nodes.date` or `printer.nodes.time` override\n * replaces the whole handler, direction branch included.\n */\nconst standardDialect: ZodDialect<PrinterZodOptions> = {\n lengths: lengthConstraints,\n numbers: numberConstraints,\n patternKey: patternKeySchema,\n objectShape: buildZodObjectShape,\n coercedInt: 'z.coerce.number().int()',\n coercedNumber: (schema) => `z.coerce.number().pipe(${schema})`,\n catchall: (object, value) => `${object}.catchall(${value})`,\n nullable: (value) => `${value}.nullable()`,\n unique: (array) => `${array}.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })`,\n extend: (base, shape) => `${base}.extend(${shape})`,\n intersection: (left, right) => `${left}.and(${right})`,\n strictMember: strictOneOfMember,\n useInputVariant: (node, options) => options.direction === 'encode' && containsDirectionalNode({ node, printerOptions: options }),\n}\n\nconst scalarNodes: PrinterZodNodes = {\n ...buildScalarNodes(standardDialect),\n bigint() {\n return 'z.coerce.bigint()'\n },\n date(node) {\n if (node.representation !== 'date') return 'z.iso.date()'\n\n if (this.options.direction === 'encode') {\n return node.format === 'date' ? 'z.date().transform((value) => value.toISOString().slice(0, 10))' : 'z.date().transform((value) => value.toISOString())'\n }\n\n const decoded = node.format === 'date' ? 'z.iso.date().transform((value) => new Date(value))' : 'z.iso.datetime().transform((value) => new Date(value))'\n return shouldCoerce(this.options.coercion, 'dates') ? 'z.coerce.date()' : decoded\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 if (this.options.direction === 'encode') {\n return 'z.date().transform((value) => value.toISOString().slice(11, 19))'\n }\n\n // No `z.coerce.date()` branch: `new Date('13:45:00')` is an Invalid Date, so coercion cannot parse a wire time.\n return 'z.iso.time().transform((value) => new Date(`1970-01-01T${value}Z`))'\n },\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 const nodes: PrinterZodNodes = { ...buildZodNodes(standardDialect, options.cyclicSchemas), ...scalarNodes }\n\n return {\n name: 'zod',\n options,\n nodes,\n overrides: options.nodes,\n print(node) {\n return printWithOmit(this, node, (value, meta) =>\n applyModifiers({\n value,\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})\n","import { lazyGetter, objectKey } from '@internals/utils'\nimport { ast } from '@kubb/kit'\nimport type { PluginZod, ResolverZod } from '../types.ts'\nimport { applyMiniModifiers, buildObjectShape, lengthChecksMini, numberChecksMini, patternKeySchemaMini, printWithOmit, shouldCoerce } from '../utils.ts'\nimport { buildZodNodes, type ZodDialect } from './zodNodes.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 * Enable automatic type coercion for strings, numbers, and dates through `z.coerce.*()`.\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 `z.regex(...)`: a regex literal\n * (`'literal'`) or the `RegExp` constructor (`'constructor'`).\n *\n * @default 'literal'\n */\n regexType?: PluginZod['resolvedOptions']['regexType']\n /**\n * How a non-discriminated `oneOf` is printed: `z.union` with strict members or `z.xor`.\n *\n * @default 'union'\n */\n oneOfType?: PluginZod['resolvedOptions']['oneOfType']\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 * 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\n/**\n * Builds the `{ key: value, … }` shape for an object node with the functional `zod/mini` modifiers.\n */\nfunction buildZodMiniObjectShape(ctx: Parameters<typeof buildObjectShape>[0], node: ast.SchemaNode): string {\n return buildObjectShape(ctx, node, ({ name, value, schema, required, meta, cyclic }) => {\n const body = applyMiniModifiers({\n value,\n schema,\n nullable: meta.nullable,\n optional: schema.optional || required === false,\n nullish: schema.nullish,\n defaultValue: meta.default,\n })\n return cyclic ? lazyGetter({ name, body }) : `${objectKey(name)}: ${body}`\n })\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 */\nconst miniDialect: ZodDialect<PrinterZodMiniOptions> = {\n lengths: lengthChecksMini,\n numbers: numberChecksMini,\n patternKey: patternKeySchemaMini,\n objectShape: buildZodMiniObjectShape,\n coercedInt: 'z.coerce.number().check(z.int())',\n coercedNumber: (schema) => `z.pipe(z.coerce.number(), ${schema})`,\n catchall: (object, value) => `z.catchall(${object}, ${value})`,\n nullable: (value) => `z.nullable(${value})`,\n unique: (array) => `${array}.check(z.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" }))`,\n extend: (base, shape) => `z.extend(${base}, ${shape})`,\n intersection: (left, right) => `z.intersection(${left}, ${right})`,\n}\n\nexport const printerZodMini = ast.createPrinter<PrinterZodMiniFactory>((options) => {\n return {\n name: 'zod-mini',\n options,\n nodes: {\n ...buildZodNodes(miniDialect, options.cyclicSchemas),\n bigint(node) {\n return `z.coerce.bigint()${numberChecksMini(node)}`\n },\n date(node) {\n if (node.representation === 'string') {\n return 'z.iso.date()'\n }\n\n return shouldCoerce(this.options.coercion, 'dates') ? 'z.coerce.date()' : '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 },\n overrides: options.nodes,\n print(node) {\n return printWithOmit(\n this,\n node,\n (value, meta) =>\n applyMiniModifiers({ value, schema: node, nullable: meta.nullable, optional: meta.optional, nullish: meta.nullish, defaultValue: meta.default }),\n true,\n )\n },\n }\n})\n","import {\n buildOptionsSchema,\n buildResponses,\n getCircularNames,\n getOasAdapter,\n getOperationParameters,\n getSuccessResponses,\n isSuccessStatusCode,\n resolveContentTypeVariants,\n} from '@internals/shared'\nimport { ast, defineGenerator } from '@kubb/kit'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Zod } from '../components/Zod.tsx'\nimport { collectDirectionalRefNames, containsDirectionalNode, printerZod } from '../printers/printerZod.ts'\nimport type { PrinterZodOptions } from '../printers/printerZod.ts'\nimport { printerZodMini } from '../printers/printerZodMini.ts'\nimport type { PrinterZodMiniOptions } from '../printers/printerZodMini.ts'\nimport type { PluginZod, ResolverZod } from '../types'\nimport { shouldCoerce } from '../utils.ts'\n\n/**\n * The helper an inferred alias is printed with. `'codec'` reads a request (encode) schema from its\n * input and a response (decode) schema from its output; `true` keeps `z.infer` for both.\n */\nfunction aliasKind(inferred: PluginZod['resolvedOptions']['inferred'], direction: 'encode' | 'decode'): 'infer' | 'input' | 'output' {\n if (inferred !== 'codec') return 'infer'\n return direction === 'encode' ? 'input' : 'output'\n}\n\ntype BuildResponseUnionParams = {\n responses: Array<ast.ResponseNode>\n name: string\n fallbackUnknown: boolean\n}\n\n/**\n * The printer for one direction, built once per plugin per build. A `keysToOmit` list and a\n * `printer.nodes` override differ per node and have no string key, so they get a fresh printer.\n */\nfunction getPrinter(resolver: ResolverZod, options: PrinterZodOptions, mini: boolean, direction: 'encode' | 'decode') {\n const build = () => (mini ? printerZodMini(options as PrinterZodMiniOptions) : printerZod({ ...options, direction }))\n if (options.nodes || options.keysToOmit?.length) return build()\n const { coercion, guidType, regexType, oneOfType, dateType } = options\n const coerce = (['dates', 'strings', 'numbers'] as const).map((type) => shouldCoerce(coercion, type))\n return resolver.memo(`zodPrinter:${[mini, direction, ...coerce, guidType, regexType, oneOfType, dateType].join(':')}`, build)\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, oneOfType, compile, mini, inferred, typeGuards, importPath, group, printer } = ctx.options\n const dateType = getOasAdapter(adapter).options.dateType\n\n if (!node.name) {\n return\n }\n\n const isZodImport = importPath === 'zod' || importPath === 'zod/mini'\n const cyclicSchemas = getCircularNames(ctx)\n const printerOptions: PrinterZodOptions = { coercion, guidType, regexType, oneOfType, dateType, resolver, cyclicSchemas, nodes: printer?.nodes }\n\n // Rendered twice: the canonical schema decodes, the `${name}InputSchema` variant encodes.\n const hasDirectionalNode = !mini && containsDirectionalNode({ node, printerOptions })\n\n const directionalRefNames = new Set(hasDirectionalNode ? collectDirectionalRefNames({ node, printerOptions }) : [])\n const importEntries = resolver.imports({ node, root, output, group: group ?? undefined })\n const inputImportEntries = hasDirectionalNode\n ? [...directionalRefNames].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 imports = [\n ...new Map(\n [...importEntries, ...inputImportEntries].map((imp) => [`${Array.isArray(imp.name) ? imp.name.join(',') : imp.name}|${imp.path}`, imp] as const),\n ).values(),\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 isName = typeGuards ? resolver.schema.isName(node.name) : null\n const assertName = typeGuards ? resolver.schema.assertName(node.name) : null\n\n const schemaPrinter = getPrinter(resolver, printerOptions, mini, 'decode')\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\n name={meta.name}\n node={node}\n printer={schemaPrinter}\n inferTypeName={inferred ? resolver.schema.typeName(node.name) : null}\n inferKind={aliasKind(inferred, 'decode')}\n typeGuards={typeGuards}\n isName={isName}\n assertName={assertName}\n mini={mini}\n cyclic={cyclicSchemas.has(node.name)}\n compile={compile}\n />\n {hasDirectionalNode && (\n <Zod\n name={resolver.schema.inputName(node.name)}\n node={node}\n printer={getPrinter(resolver, printerOptions, mini, 'encode')}\n inferTypeName={inferred ? resolver.schema.inputTypeName(node.name) : null}\n inferKind={aliasKind(inferred, 'encode')}\n typeGuards={typeGuards}\n isName={typeGuards ? resolver.schema.isName(resolver.schema.inputName(node.name)) : null}\n assertName={typeGuards ? resolver.schema.assertName(resolver.schema.inputName(node.name)) : null}\n mini={mini}\n cyclic={cyclicSchemas.has(node.name)}\n compile={compile}\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, oneOfType, compile, mini, inferred, importPath, group, printer } = ctx.options\n const dateType = getOasAdapter(adapter).options.dateType\n\n const isZodImport = importPath === 'zod' || importPath === 'zod/mini'\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 = getCircularNames(ctx)\n const printerOptions: PrinterZodOptions = { coercion, guidType, regexType, oneOfType, dateType, resolver, cyclicSchemas, nodes: printer?.nodes }\n\n function renderSchemaEntry({\n schema,\n name,\n keysToOmit,\n direction = 'decode',\n }: {\n schema: ast.SchemaNode | null\n name: string\n keysToOmit?: Array<string> | null\n direction?: 'encode' | 'decode'\n }) {\n if (!schema) return null\n\n const directionalRefNames = direction === 'encode' && !mini ? new Set(collectDirectionalRefNames({ node: schema, printerOptions })) : null\n const imports = resolver.imports({\n node: schema,\n root,\n output,\n group: group ?? undefined,\n name: (schemaName) => (directionalRefNames?.has(schemaName) ? resolver.schema.inputName(schemaName) : resolver.name(schemaName)),\n })\n\n const schemaPrinter = getPrinter(resolver, { ...printerOptions, keysToOmit }, mini, 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\n name={name}\n node={schema}\n printer={schemaPrinter}\n inferTypeName={inferred ? resolver.schema.type(name) : null}\n inferKind={aliasKind(inferred, direction)}\n cyclic={false}\n compile={compile}\n />\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?: 'encode' | 'decode',\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) => (entry.schema ? ast.collectImportedRefNames(entry.schema).map((refName) => resolver.name(refName)) : [])),\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 = node.parameters.map((param) =>\n renderSchemaEntry({ schema: param.schema, name: resolver.param.name(node, param), direction: 'encode' }),\n )\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: 'encode',\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 'encode',\n )\n })()\n\n // Grouped path/query/headers schemas, one object per group: what a client's `validator.path` /\n // `query` / `headers` runs at request time, and what the options schema below references.\n const { path, query, header } = getOperationParameters(node)\n\n const paramGroupSchemas = (\n [\n { kind: 'path', params: path },\n { kind: 'query', params: query },\n { kind: 'headers', params: header },\n ] as const\n )\n .filter(({ params }) => params.length > 0)\n .map(({ kind, params }) =>\n renderSchemaEntry({\n schema: ast.factory.createSchema({\n type: 'object',\n // `primitive: 'object'` makes the printer emit `z.object(…)` rather than a record.\n primitive: 'object',\n properties: params.map((param) => ast.factory.createProperty({ name: param.name, required: param.required, schema: param.schema })),\n }),\n name: resolver.param[kind](node, params[0]!),\n direction: 'encode',\n }),\n )\n\n // The combined `{ body, path, query, headers }` options and per-status `responses` schemas exist\n // only to back `resolver.response.options(node)` and `resolver.response.responses(node)` for\n // consumers sourcing types from this plugin instead of `plugin-ts`. Not worth generating when\n // nothing will import them.\n const optionsSchema = inferred\n ? renderSchemaEntry({ schema: buildOptionsSchema(node, resolver), name: resolver.name(`${node.operationId} Options`), direction: 'encode' })\n : null\n\n // The per-status record a client's `RequestResult` is keyed on. Response bodies, so `output`.\n const responsesSchema = inferred ? renderSchemaEntry({ schema: buildResponses(node, resolver), name: resolver.response.responses(node) }) : null\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 {paramGroupSchemas}\n {optionsSchema}\n {responsesSchema}\n </File>\n )\n },\n})\n","","","import { createCasedFile, createOperationParamResolver, createOperationResponseResolver, operationKey } from '@internals/shared'\nimport { ensureValidVarName } from '@internals/utils'\nimport { camelCase, createResolver, pascalCase } 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 this.memo(`name:${name}`, () => ensureValidVarName(camelCase(name, { suffix: 'schema' })))\n },\n file: createCasedFile((part) => camelCase(part, { suffix: 'schema' })),\n schema: {\n typeName(name) {\n return this.memo(`typeName:${name}`, () => ensureValidVarName(pascalCase(name, { suffix: 'schema type' })))\n },\n type(name) {\n return this.memo(`type:${name}`, () => 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 isName(name) {\n return ensureValidVarName(camelCase(name, { prefix: 'is' }))\n },\n assertName(name) {\n return ensureValidVarName(camelCase(name, { prefix: 'assert' }))\n },\n },\n param: createOperationParamResolver(),\n response: {\n ...createOperationResponseResolver(),\n error(node) {\n const name = this.name(`${node.operationId} Error`)\n return this.resolveName({ key: operationKey(node, 'response', 'error'), name })\n },\n options(node) {\n const name = this.schema.type(this.name(`${node.operationId} Options`))\n return this.resolveName({ key: operationKey(node, 'response', 'options'), name })\n },\n },\n})\n","import { createGroupConfig } from '@internals/shared'\nimport { addGenerator, defineExtension, Resolver, setMacros, setResolver } from '@kubb/kit'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { 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: './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 = defineExtension<PluginZod>({\n kind: 'plugin',\n meta: { name: pluginZodName, version, compatibility },\n setup(options) {\n const {\n output = { path: 'zod', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n compile = false,\n mini = false,\n guidType = 'uuid',\n regexType = 'literal',\n oneOfType = 'union',\n importPath = mini ? 'zod/mini' : 'zod',\n coercion = false,\n inferred = false,\n typeGuards = false,\n printer,\n resolver: userResolver,\n macros: userMacros,\n } = options\n\n setResolver(userResolver ? Resolver.merge(resolverZod, userResolver) : resolverZod)\n if (userMacros?.length) {\n setMacros(userMacros)\n }\n addGenerator(zodGenerator)\n\n return {\n output,\n exclude,\n include,\n override,\n group: createGroupConfig(group),\n importPath,\n coercion,\n // `'direction'` is the deprecated name of `'codec'`.\n inferred: inferred === 'direction' ? 'codec' : inferred,\n guidType,\n regexType,\n oneOfType,\n compile,\n mini,\n typeGuards,\n printer,\n }\n },\n})\n\nexport default pluginZod\n"],"mappings":";;;;;;;;AAgNA,SAAS,qBAAqB,aAA6B;CACzD,MAAM,WAAW,YAAY,MAAM,GAAG,CAAC,CAAC,EAAE,CAAE,KAAK;CACjD,IAAI,aAAa,oBAAoB,OAAO;CAC5C,IAAI,aAAa,uBAAuB,OAAO;CAC/C,IAAI,aAAa,qCAAqC,OAAO;CAE7D,MAAM,SADU,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,SAAA,CACvB,MAAM,eAAe,CAAC,CAAC,OAAO,OAAO;CAC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