@kubb/plugin-client 5.8.0-canary.20261025T201031 → 5.9.0-canary.20261025T213930

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 CHANGED
@@ -209,6 +209,16 @@ function getOperationParameters(node) {
209
209
  operationParameterGroupsByNode.set(node, groups);
210
210
  return groups;
211
211
  }
212
+ /**
213
+ * Builds the combined `{ body, path, query, headers }` options object schema for an operation,
214
+ * referencing the already-resolved body and grouped param names. Shared by `@kubb/plugin-ts`'s
215
+ * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same
216
+ * shape from the same inputs. `primitive: 'object'` is a no-op for the TS printer and tells the Zod
217
+ * printer to emit `z.object(…)` rather than a record.
218
+ */
219
+ function hasRequestContentTypeChoice(node) {
220
+ return (node.requestBody?.content ?? []).filter((entry) => entry.schema).length > 1;
221
+ }
212
222
  function getStatusCodeNumber(statusCode) {
213
223
  const code = Number(statusCode);
214
224
  return Number.isNaN(code) ? null : code;
@@ -285,6 +295,7 @@ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
285
295
  const reservedWords = /* @__PURE__ */ new Set([
286
296
  "abstract",
287
297
  "arguments",
298
+ "await",
288
299
  "boolean",
289
300
  "break",
290
301
  "byte",
@@ -416,6 +427,11 @@ function isIdentifier(name) {
416
427
  return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
417
428
  }
418
429
  //#endregion
430
+ //#region ../../internals/shared/src/resolver.ts
431
+ function resolveOperationName(name) {
432
+ return ensureValidVarName(camelCase(name));
433
+ }
434
+ //#endregion
419
435
  //#region ../../internals/shared/src/group.ts
420
436
  /**
421
437
  * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the
@@ -454,7 +470,7 @@ var compatibility = {
454
470
  };
455
471
  //#endregion
456
472
  //#region package.json
457
- var version = "5.8.0-canary.20261025T201031";
473
+ var version = "5.9.0-canary.20261025T213930";
458
474
  //#endregion
459
475
  //#region ../../internals/client/src/builders/validatorOptions.ts
460
476
  /**
@@ -692,16 +708,17 @@ function buildResultType({ node, types, returnType }) {
692
708
  * `return request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>`
693
709
  */
694
710
  function buildReturnStatement({ node, types, callConfig, returnType, throwOnErrorDefault }) {
695
- if (returnType === "data") return `return unwrapResult(request(${callConfig}), config.throwOnError ?? ${throwOnErrorDefault}) as ${buildResultType({
711
+ const request = returnType !== "plain" && hasRequestContentTypeChoice(node) ? `request<${types.response.options(node)}['body']>` : "request";
712
+ if (returnType === "data") return `return unwrapResult(${request}(${callConfig}), config.throwOnError ?? ${throwOnErrorDefault}) as ${buildResultType({
696
713
  node,
697
714
  types,
698
715
  returnType
699
716
  })}`;
700
- if (returnType === "plain") return `return request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
717
+ if (returnType === "plain") return `return ${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
701
718
  node,
702
719
  types
703
720
  })}>>`;
704
- return `return withUnwrap(request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
721
+ return `return withUnwrap(${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
705
722
  node,
706
723
  types
707
724
  })}>>)`;
@@ -1108,8 +1125,8 @@ const defaultMacros = [kubb_kit.macroSimplifyUnion];
1108
1125
  //#endregion
1109
1126
  //#region ../../internals/client/src/resolver.ts
1110
1127
  /**
1111
- * Default resolver shared by the client plugins. Functions and files inherit the built-in camelCase
1112
- * `name` and `file`; classes and tag groups use PascalCase.
1128
+ * Default resolver shared by the client plugins. Functions use safe camelCase identifiers and
1129
+ * files inherit the built-in casing; classes and tag groups use PascalCase.
1113
1130
  *
1114
1131
  * @example
1115
1132
  * ```ts
@@ -1119,6 +1136,7 @@ const defaultMacros = [kubb_kit.macroSimplifyUnion];
1119
1136
  */
1120
1137
  const resolverClient = (0, kubb_kit.createResolver)({
1121
1138
  pluginName: "plugin-contract-client",
1139
+ name: resolveOperationName,
1122
1140
  className(name) {
1123
1141
  return ensureValidVarName(pascalCase(name));
1124
1142
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["Url","functionPrinter","createFunctionParameters","createFunctionParameter","ast","ast","File","Function","pluginTsName","pluginZodName","Diagnostics","defineGenerator","jsxRenderer","ast","pluginZodName","path","File","macroSimplifyUnion","createResolver","defineExtension","pluginTsName","pluginZodName","Resolver"],"sources":["../../../internals/shared/src/operation.ts","../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/shared/src/group.ts","../kubb-extension.json","../package.json","../../../internals/client/src/builders/validatorOptions.ts","../../../internals/client/src/builders/security.ts","../../../internals/client/src/builders/validator.ts","../../../internals/client/src/builders/contentType.ts","../../../internals/client/src/builders/generics.ts","../../../internals/client/src/builders/returnStatement.ts","../../../internals/client/src/builders/signature.ts","../../../internals/client/src/builders/styles.ts","../../../internals/client/src/components/Operation.tsx","../../../internals/client/src/resolveOperationTypes.ts","../../../internals/client/src/generators/clientGenerator.tsx","../../../internals/client/src/macros.ts","../../../internals/client/src/resolver.ts","../src/generators/clientGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import { ast, type Group, type NodeCache, type Output, type Resolver, type ResolverFileParams, Url } from 'kubb/kit'\n\n/**\n * Builds the `ResolverFileParams` every operation generator passes to\n * `resolver.file`: a file named `name`, tagged by the operation's first\n * tag (or `'default'`), at the operation's path. Centralizes the entry object\n * that was repeated at dozens of call sites across the client and query plugins.\n *\n * @example\n * ```ts\n * resolver.file(operationFileEntry(node, node.operationId), { root, output, group })\n * ```\n */\nexport function operationFileEntry(node: ast.OperationNode, name: string, extname: ResolverFileParams['extname'] = '.ts'): ResolverFileParams {\n return {\n name,\n extname,\n tag: node.tags[0] ?? 'default',\n path: node.path,\n }\n}\n\n/**\n * Resolves a dependency plugin's generated file for `node.operationId`, cached in `cache` (the\n * current node's `ctx.cache`) under the resolver's own plugin name. Several dependents reading the\n * same dependency for the same operation in one pass (a query plugin's several hook generators, the\n * MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.\n *\n * @example Cache `plugin-ts`'s file for the current operation\n * ```ts\n * const fileTs = resolveDependencyOperationFile({ cache: ctx.cache, node, resolver: tsResolver, root, output })\n * ```\n */\nexport function resolveDependencyOperationFile(options: {\n cache: NodeCache\n node: ast.OperationNode\n resolver: Pick<Resolver, 'file' | 'pluginName'>\n root: string\n output: Output\n group?: Group | null\n}): ast.FileNode {\n const { cache, node, resolver, root, output, group } = options\n\n return cache.ensureItem(`${resolver.pluginName}:operationFile`, () =>\n resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\n )\n}\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type OperationCommentLink = 'pathTemplate' | 'urlPath' | false | ((node: ast.OperationNode) => string | undefined)\n\nexport type BuildOperationCommentsOptions = {\n link?: OperationCommentLink\n linkPosition?: 'beforeDeprecated' | 'afterDeprecated'\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<ast.ParameterNode['in'], Array<ast.ParameterNode>>\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\nfunction getOperationLink(node: ast.OperationNode, link: OperationCommentLink): string | null {\n if (!link) {\n return null\n }\n\n if (typeof link === 'function') {\n return link(node) ?? null\n }\n\n return node.path ? `{@link ${Url.toPath(node.path)}}` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(node.requestBody?.content?.map((e) => e.contentType) ?? [])\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(getPrimarySuccessResponse(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\nexport type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n\n/**\n * Reads the single base content type of an operation's primary success response, lowercased and\n * stripped of any `; charset=...` suffix. Returns `undefined` when the response declares zero or\n * more than one content type, since neither case has a single type to act on.\n */\nfunction getPrimarySuccessContentType(node: ast.OperationNode): string | undefined {\n const contentTypes = getPrimarySuccessResponse(node)?.content?.map((entry) => entry.contentType) ?? []\n if (contentTypes.length !== 1) return undefined\n return contentTypes[0]!.split(';')[0]!.trim().toLowerCase()\n}\n\n/**\n * Whether an operation streams its primary success response as Server-Sent Events\n * (`text/event-stream`). The client generator uses this to return a typed event stream instead of a\n * one-shot `RequestResult`.\n */\nexport function isEventStream(node: ast.OperationNode): boolean {\n return getPrimarySuccessContentType(node) === 'text/event-stream'\n}\n\n/**\n * Derives the default `responseType` for an operation from its primary success response.\n *\n * Returns a value only when that response declares a single non-JSON content type. `text/event-stream`\n * and other binary types (`application/octet-stream`, `application/pdf`, `image/*`, `audio/*`,\n * `video/*`) map to a stream or `'blob'`, and other `text/*` maps to `'text'`. Otherwise `undefined`,\n * leaving the runtime client's `Content-Type` auto-detection in charge.\n */\nexport function getResponseType(node: ast.OperationNode): ResponseType | undefined {\n const baseType = getPrimarySuccessContentType(node)\n if (!baseType) return undefined\n\n if (baseType === 'application/json' || baseType.endsWith('+json') || baseType === 'text/json') return undefined\n if (baseType === 'text/event-stream') return 'stream'\n if (baseType.startsWith('text/')) return 'text'\n if (baseType === 'application/octet-stream' || baseType === 'application/pdf' || /^(image|audio|video)\\//.test(baseType)) return 'blob'\n return undefined\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n// The request groups come from the grouped params, so `config` drops the data-shape keys to stay\n// assignable to `Options`, which omits them from `RequestConfig`.\nconst requestConfigBaseType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\n\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n\n // Only the ambiguous side is offered: a single-type side has nothing to pick, so it stays baked in\n // the generated call.\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n return members.length ? `${requestConfigBaseType} & { contentType?: { ${members.join('; ')} } }` : requestConfigBaseType\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...). Unlike {@link buildRequestConfigType}, it never adds a\n * `contentType?:` member: query hooks wrap GET operations, which carry no request body to select a\n * content type for.\n */\nexport function buildClientOptionType(): string {\n return requestConfigBaseType\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n}\n\n/**\n * Which of the grouped request options an operation carries.\n */\nexport function getRequestGroups(node: ast.OperationNode): RequestGroups {\n const { path, query, header } = getOperationParameters(node)\n return {\n path: path.length > 0,\n query: query.length > 0,\n body: Boolean(node.requestBody?.content?.[0]?.schema),\n headers: header.length > 0,\n }\n}\n\nexport type RequestGroupOptionality = {\n groups: RequestGroups\n hasRequiredPath: boolean\n hasRequiredQuery: boolean\n hasRequiredHeader: boolean\n /**\n * Whether the grouped request parameter can default to `{}`. True only when no group carries a\n * required member, so every member is safe to omit.\n */\n isOptional: boolean\n}\n\n/**\n * Resolves which grouped request options an operation carries together with whether each group\n * holds a required member. The grouped parameter stays optional only when nothing inside it is\n * required, matching the generated `RequestConfig` type.\n */\nexport function getRequestGroupOptionality(node: ast.OperationNode): RequestGroupOptionality {\n const groups = getRequestGroups(node)\n const { path, query, header } = getOperationParameters(node)\n const hasRequiredPath = path.some((param) => param.required)\n const hasRequiredQuery = query.some((param) => param.required)\n const hasRequiredHeader = header.some((param) => param.required)\n\n return {\n groups,\n hasRequiredPath,\n hasRequiredQuery,\n hasRequiredHeader,\n isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !groups.body,\n }\n}\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: RequestGroups } {\n const { isConfigurable = true } = options\n const { groups, isOptional } = getRequestGroupOptionality(node)\n\n const names = (['path', 'query', 'body', 'headers'] as const).filter((key) => groups[key])\n\n const firstParam = names.length > 0 ? `{ ${names.join(', ')} }: ${resolver.response.options(node)}${isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { link = 'pathTemplate', linkPosition = 'afterDeprecated', splitLines = false } = options\n const linkComment = getOperationLink(node, link)\n const comments =\n linkPosition === 'beforeDeprecated'\n ? [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, linkComment, node.deprecated && '@deprecated']\n : [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, node.deprecated && '@deprecated', linkComment]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\nconst operationParameterGroupsByNode = new WeakMap<ast.OperationNode, OperationParameterGroups>()\n\n/**\n * Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each\n * group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance\n * (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the\n * same parameters once per plugin.\n */\nexport function getOperationParameters(node: ast.OperationNode): OperationParameterGroups {\n const cached = operationParameterGroupsByNode.get(node)\n if (cached) return cached\n\n // A malformed spec can declare the same name twice within one location. Both would resolve to the\n // same output property, so emitting both would yield an object type with a duplicate member,\n // which TypeScript rejects. Keep the first.\n const group = (location: ast.ParameterNode['in']) => {\n const seen = new Set<string>()\n\n return node.parameters.filter((param) => {\n if (param.in !== location || seen.has(param.name)) return false\n seen.add(param.name)\n return true\n })\n }\n\n const groups: OperationParameterGroups = { path: group('path'), query: group('query'), header: group('header'), cookie: group('cookie') }\n\n operationParameterGroupsByNode.set(node, groups)\n return groups\n}\n\n/**\n * Builds the combined `{ body, path, query, headers }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same\n * shape from the same inputs. `primitive: 'object'` is a no-op for the TS printer and tells the Zod\n * printer to emit `z.object(…)` rather than a record.\n */\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver): ast.SchemaNode {\n const { path, query, header } = getOperationParameters(node)\n const hasBody = Boolean(node.requestBody?.content?.[0]?.schema)\n const createNever = () => ast.factory.createSchema({ type: 'never', primitive: undefined, optional: true })\n const groups = [\n { name: 'path', params: path, resolve: resolver.param.path },\n { name: 'query', params: query, resolve: resolver.param.query },\n { name: 'headers', params: header, resolve: resolver.param.headers },\n ] as const\n\n // NOTE(v5-stable): the fields were renamed from the legacy beta shape\n // (`data`/`pathParams`/`queryParams`/`headerParams`) to `body`/`path`/`query`/`headers` so the\n // type matches the runtime client. Drop this note once v5 leaves beta.\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({\n name: 'body',\n required: hasBody,\n schema: hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever(),\n }),\n ...groups.map(({ name, params, resolve }) => {\n const required = params.some((param) => param.required)\n\n return ast.factory.createProperty({\n name,\n required,\n schema:\n params.length > 0\n ? ast.factory.createSchema({ type: 'ref', name: resolve.call(resolver.param, node, params[0]!), optional: !required })\n : createNever(),\n })\n }),\n ],\n })\n}\n\n/**\n * The schema a status occupies in the `<Name>Responses` record. A status that documents several\n * content types becomes a `{ contentType; data }` union so the runtime can surface the negotiated type\n * on `result.parsed`, while the standalone `<Name>StatusNNN` alias stays the plain body union that the\n * query hooks and `result.data` use.\n */\nfunction buildResponseRecordEntry(node: ast.OperationNode, res: ast.ResponseNode, resolver: ResponseStatusNameResolver): ast.SchemaNode {\n const statusName = resolver.response.status(node, res.statusCode)\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length <= 1) {\n return ast.factory.createSchema({ type: 'ref', name: statusName })\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: resolveContentTypeVariants(variants, statusName).map((variant) =>\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'contentType',\n required: true,\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] }),\n }),\n ast.factory.createProperty({\n name: 'data',\n required: true,\n schema: ast.factory.createSchema({ type: 'ref', name: variant.name }),\n }),\n ],\n }),\n ),\n })\n}\n\n/**\n * Builds the per-status `<Name>Responses` record for an operation, referencing the already-resolved\n * `<Name>StatusNNN` names. Shared by `@kubb/plugin-ts`'s `Responses` type and `@kubb/plugin-zod`'s\n * inferred responses schema, so both emit the same shape from the same inputs.\n *\n * Always emits the keyed record, even when an operation declares no responses. An operation with no\n * responses renders as an empty object, which keeps every consumer's import (for example the axios\n * SDK's `RequestResult<XResponses>`) resolvable instead of pointing at a missing export.\n */\nexport function buildResponses(node: ast.OperationNode, resolver: ResponseStatusNameResolver): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: node.responses.map((res) =>\n ast.factory.createProperty({\n name: String(res.statusCode),\n required: true,\n schema: buildResponseRecordEntry(node, res, resolver),\n }),\n ),\n })\n}\n\nexport function getStatusCodeNumber(statusCode: ast.StatusCode | number | string): number | null {\n const code = Number(statusCode)\n\n return Number.isNaN(code) ? null : code\n}\n\nexport function isSuccessStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 200 && code < 300\n}\n\nexport function isErrorStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 400\n}\n\nexport function getSuccessResponses<TResponse extends ResponseLike>(responses: ReadonlyArray<TResponse>): Array<TResponse> {\n return responses.filter((response) => isSuccessStatusCode(response.statusCode))\n}\n\nexport function getOperationSuccessResponses(node: ast.OperationNode): Array<ast.ResponseNode> {\n return getSuccessResponses(node.responses)\n}\n\nexport function getPrimarySuccessResponse(node: ast.OperationNode): ast.ResponseNode | null {\n return getOperationSuccessResponses(node)[0] ?? null\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.filter((response) => isSuccessStatusCode(response.statusCode)).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.response.status(node, response.statusCode))\n}\n\nconst typeNamesByResolver = new WeakMap<OperationTypeNameResolver, Map<string, string[]>>()\n\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const cacheKey = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n let byResolver = typeNamesByResolver.get(resolver)\n if (byResolver) {\n const cached = byResolver.get(cacheKey)\n if (cached) return cached\n } else {\n byResolver = new Map()\n typeNamesByResolver.set(resolver, byResolver)\n }\n\n const { path, query, header } = getOperationParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ]\n const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n const result = names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n byResolver.set(cacheKey, result)\n return result\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = getStatusCodeNumber(response.statusCode)\n if (code === null) {\n continue\n }\n\n types.push([code, isSuccessStatusCode(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n","type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction convert(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n// Plugins resolve the same names over and over (about 47,000 calls for a 1,000 schema spec), so\n// results are kept. Clearing at the limit bounds the memory a long-running process spends on it.\nconst cache = new Map<string, string>()\nconst cacheLimit = 10_000\n\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const key = `${pascal ? 'P' : 'c'}${text}`\n const cached = cache.get(key)\n if (cached !== undefined) return cached\n\n const result = convert(text, pascal)\n if (cache.size >= cacheLimit) cache.clear()\n cache.set(key, result)\n return result\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Uppercases only the first character of `text`, leaving the rest untouched.\n * Unlike {@link pascalCase} it never re-splits word boundaries or strips characters.\n *\n * @example\n * `capitalize('getPetById') // 'GetPetById'`\n */\nexport function capitalize(text: string): string {\n return `${text.charAt(0).toUpperCase()}${text.slice(1)}`\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example From camelCase\n * `snakeCase('helloWorld') // 'hello_world'`\n *\n * @example From mixed separators\n * `snakeCase('Hello-World') // 'hello_world'`\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example From camelCase\n * `screamingSnakeCase('helloWorld') // 'HELLO_WORLD'`\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `name` when it's a syntactically valid JavaScript variable name,\n * otherwise prefixes it with `_` so the result is a valid identifier.\n *\n * Useful for sanitizing OpenAPI schema names or operation IDs that start with\n * a digit (e.g. `409`, `504AccountCancel`) before using them as exported\n * variable, type, or function names.\n *\n * @example\n * ```ts\n * ensureValidVarName('409') // '_409'\n * ensureValidVarName('504AccountCancel') // '_504AccountCancel'\n * ensureValidVarName('Pet') // 'Pet'\n * ensureValidVarName('class') // '_class'\n * ```\n */\nexport function ensureValidVarName(name: string): string {\n if (!name || isValidVarName(name)) {\n return name\n }\n return `_${name}`\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from '@internals/utils'\nimport type { Group } from 'kubb/kit'\n\n/**\n * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the\n * shared default naming so every plugin groups output consistently:\n *\n * - `path` groups use the second path segment (`/pet/findByStatus` → `pet`).\n * - other groups use the camelCased group (`pet store` → `petStore`).\n *\n * A user-provided `group.name` always wins over the default namer, so callers stay in\n * control of their output folders. Returns `null` when grouping is disabled, matching the\n * per-plugin convention.\n *\n * @param group - The user-supplied group option, or `undefined` to disable grouping.\n *\n * @example\n * ```ts\n * createGroupConfig(group) // shared across every plugin\n * ```\n */\nexport function createGroupConfig(group: Group | undefined): Group | null {\n if (!group) {\n return null\n }\n\n const defaultName = (ctx: { group: string }): string => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n\n return camelCase(ctx.group)\n }\n\n return {\n ...group,\n name: group.name ? group.name : defaultName,\n } satisfies Group\n}\n","","","import { isSuccessStatusCode } from '@internals/shared'\nimport type { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport type { ValidatorOptions } from '../types.ts'\n\n/**\n * Returns `true` when any direction of the validator uses zod (used for dependency checks).\n */\nexport function isValidatorEnabled(validator: ValidatorOptions | undefined): boolean {\n if (!validator) return false\n if (validator === 'zod') return true\n return Boolean(validator.request || validator.params || validator.response)\n}\n\n/**\n * Returns `'zod'` when request body parsing is enabled, `null` otherwise. The string shorthand\n * `'zod'` validates the response only, so it does not enable request parsing.\n */\nexport function resolveRequestValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator || validator === 'zod') return null\n return validator.request ?? null\n}\n\n/**\n * Returns `'zod'` when path, query, and header params parsing is enabled, `null` otherwise. Only the\n * object form `{ params: 'zod' }` enables it.\n */\nexport function resolveParamsValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator || validator === 'zod') return null\n return validator.params ?? null\n}\n\n/**\n * Returns `'zod'` when response parsing is enabled, `null` otherwise. The string shorthand `'zod'`\n * maps to response parsing.\n */\nexport function resolveResponseValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator) return null\n if (validator === 'zod') return 'zod'\n return validator.response ?? null\n}\n\n/**\n * Resolves the zod schema name a generated client validates an error body with on the non-throw path.\n * Uses the error-only `<operation>ErrorSchema` (the union of non-2xx statuses); returns `null` when the\n * operation documents no error responses with a schema.\n */\nexport function buildZodErrorParse(node: ast.OperationNode, zodResolver: ResolverZod): string | null {\n const hasErrorResponse = node.responses.some((res) => !isSuccessStatusCode(res.statusCode) && res.content?.some((entry) => entry.schema))\n if (!hasErrorResponse) return null\n return zodResolver.response.error?.(node) || null\n}\n","/**\n * A resolved security scheme as emitted on each generated call's `security` array. The runtime calls\n * the configured `auth` resolver with this object and places the returned token: `http` bearer/basic\n * on `Authorization`, `apiKey` under `name` in the header/query/cookie, and `oauth2`/`openIdConnect`\n * as a bearer token.\n */\nexport type Auth = {\n type: 'http' | 'apiKey' | 'oauth2' | 'openIdConnect'\n scheme?: 'bearer' | 'basic'\n name?: string\n in?: 'header' | 'query' | 'cookie'\n scopes?: Array<string>\n}\n\n/**\n * A single OpenAPI security requirement read from the spec: scheme name to the scopes it needs.\n */\ntype SecurityRequirement = Record<string, Array<string>>\n\n/**\n * The slice of an OpenAPI document the security derivation reads: the global `security`, the\n * per-operation `security` under `paths`, and the `securitySchemes` map under `components`. Typed\n * locally so this package stays independent of the OpenAPI adapter.\n */\nexport type SecurityDocument = {\n security?: Array<SecurityRequirement>\n components?: {\n securitySchemes?: Record<string, OasSecurityScheme | { $ref: string } | undefined>\n }\n paths?: Record<string, Record<string, { security?: Array<SecurityRequirement> } | undefined> | undefined>\n}\n\ntype OasSecurityScheme = { type: 'http'; scheme?: string } | { type: 'apiKey'; name?: string; in?: string } | { type: 'oauth2' } | { type: 'openIdConnect' }\n\nfunction serializeAuth(auth: Auth): string {\n const parts = [`type: '${auth.type}'`]\n if (auth.scheme) parts.push(`scheme: '${auth.scheme}'`)\n if (auth.name) parts.push(`name: '${auth.name}'`)\n if (auth.in) parts.push(`in: '${auth.in}'`)\n if (auth.scopes?.length) parts.push(`scopes: [${auth.scopes.map((scope) => `'${scope}'`).join(', ')}]`)\n return `{ ${parts.join(', ')} }`\n}\n\n/**\n * Maps an OpenAPI security scheme to the inline `Auth` object, or `null` when the runtime cannot\n * place it (an unresolved `$ref`, or an `apiKey` without a name or outside `header` / `query` /\n * `cookie`). `http` schemes other than `basic` are treated as bearer.\n */\nexport function resolveSecurityScheme(scheme: OasSecurityScheme | { $ref: string } | undefined): Auth | null {\n if (!scheme || '$ref' in scheme) return null\n if (scheme.type === 'apiKey') {\n if (!scheme.name || (scheme.in !== 'header' && scheme.in !== 'query' && scheme.in !== 'cookie')) return null\n return { type: 'apiKey', name: scheme.name, in: scheme.in }\n }\n if (scheme.type === 'http') return { type: 'http', scheme: scheme.scheme?.toLowerCase() === 'basic' ? 'basic' : 'bearer' }\n if (scheme.type === 'oauth2') return { type: 'oauth2' }\n if (scheme.type === 'openIdConnect') return { type: 'openIdConnect' }\n return null\n}\n\n/**\n * Derives the per-operation security metadata from the OpenAPI document. The operation's own\n * `security` overrides the global `security` (an explicit empty array disables auth), and every\n * referenced scheme is resolved from `components.securitySchemes` into a flat, de-duplicated list of\n * `Auth` objects the runtime walks in order.\n *\n * @example\n * `getOperationSecurity({ document, method: 'POST', path: '/pet' })`\n * `// [{ type: 'http', scheme: 'bearer' }]`\n */\nexport function getOperationSecurity({\n document,\n method,\n path,\n}: {\n document: SecurityDocument | null | undefined\n method: string\n path: string\n}): Array<Auth> | undefined {\n if (!document) return undefined\n\n const operation = document.paths?.[path]?.[method.toLowerCase()]\n const requirements = operation?.security ?? document.security\n if (!requirements?.length) return undefined\n\n const definitions = document.components?.securitySchemes ?? {}\n const security: Array<Auth> = []\n const seen = new Set<string>()\n for (const requirement of requirements) {\n for (const [schemeName, scopes] of Object.entries(requirement)) {\n if (seen.has(schemeName)) continue\n seen.add(schemeName)\n const auth = resolveSecurityScheme(definitions[schemeName])\n if (auth) security.push(scopes.length ? { ...auth, scopes } : auth)\n }\n }\n\n return security.length ? security : undefined\n}\n\n/**\n * Serializes the per-operation security into the literal emitted on each generated call's `security`\n * field. The runtime `resolveAuth` helper walks it, calling the configured `auth` resolver per entry.\n *\n * @example\n * `buildSecurityMetadata({ security: [{ type: 'http', scheme: 'bearer' }] }) // \"[{ type: 'http', scheme: 'bearer' }]\"`\n */\nexport function buildSecurityMetadata({ security }: { security?: Array<Auth> }): string | null {\n if (!security?.length) return null\n return `[${security.map(serializeAuth).join(', ')}]`\n}\n","import { getOperationParameters } from '@internals/shared'\nimport type { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport type { ValidatorOptions } from '../types.ts'\nimport { buildZodErrorParse, resolveParamsValidator, resolveRequestValidator, resolveResponseValidator } from './validatorOptions.ts'\n\n/**\n * The per-call validator references a generated function wires into its request config. Each hook is\n * the bare schema reference passed to the runtime's `validator.request` / `validator.path` /\n * `validator.query` / `validator.headers` / `validator.response` / `validator.error` slot; `client.ts`\n * runs it through `validateStandardSchema`. The response validator only ever sees success (2xx) bodies.\n */\nexport type ValidatorHooks = {\n /**\n * Schema reference for the `validator.request` hook, or `null` when request validation is off.\n */\n request: string | null\n /**\n * Schema references for the `validator.path` / `query` / `headers` hooks (`headers` wrapped in\n * `toHeadersStandardSchema`), or `null` when params validation is off or the group is empty.\n */\n path: string | null\n query: string | null\n headers: string | null\n /**\n * Schema reference for the `validator.response` hook, or `null` when response validation is off.\n */\n response: string | null\n /**\n * Schema reference for the `validator.error` hook, or `null` when error validation is off or the\n * operation documents no error responses. The runtime runs this on the error body when a non-2xx\n * call does not throw.\n */\n error: string | null\n /**\n * Zod schema names the generated file imports from the zod plugin output.\n */\n importedZodNames: Array<string>\n}\n\n/**\n * Builds the validator-hook references for one operation. Request body and params validation run before the send.\n * Response validation runs on the success body only. Returns `null` references when the matching\n * direction is disabled or the schema is absent.\n */\nexport function buildValidatorHooks({\n node,\n validator,\n zodResolver,\n}: {\n node: ast.OperationNode\n validator: ValidatorOptions | undefined\n zodResolver: ResolverZod | null | undefined\n}): ValidatorHooks {\n const hasRequestBody = Boolean(node.requestBody?.content?.[0]?.schema)\n const parsesResponse = zodResolver && resolveResponseValidator(validator) === 'zod'\n\n // Success responses validate with the success-only `<operation>ResponseSchema`; error bodies are never zod-parsed on the throw path.\n const response = parsesResponse ? zodResolver.response.response(node) || null : null\n const error = parsesResponse ? buildZodErrorParse(node, zodResolver) : null\n const request = zodResolver && resolveRequestValidator(validator) === 'zod' && hasRequestBody ? zodResolver.response.body(node) || null : null\n\n const paramGroups = getOperationParameters(node)\n const resolveParamsName = (kind: 'path' | 'query' | 'headers', params: Array<ast.ParameterNode>): string | null =>\n zodResolver && resolveParamsValidator(validator) === 'zod' && params.length > 0 ? zodResolver.param[kind](node, params[0]!) : null\n const path = resolveParamsName('path', paramGroups.path)\n const query = resolveParamsName('query', paramGroups.query)\n const headers = resolveParamsName('headers', paramGroups.header)\n\n // Order is output: the generated file imports the response schema, then the error schema, then the request body and params schemas.\n const importedZodNames = [response, error, request, path, query, headers].filter((name): name is string => Boolean(name))\n\n const headersValidator = headers ? `toHeadersStandardSchema(${headers}, ${headers}.shape)` : null\n\n return { request, path, query, headers: headersValidator, response, error, importedZodNames }\n}\n\n/**\n * Prints the `validator: { … }` entry of a call config from the hooks named in `keys`, or `null` when none is set.\n */\nexport function buildValidatorLiteral(hooks: ValidatorHooks | null, keys: ReadonlyArray<keyof Omit<ValidatorHooks, 'importedZodNames'>>): string | null {\n const entries = keys.flatMap((key) => (hooks?.[key] ? [`${key}: ${hooks[key]}`] : []))\n return entries.length ? `validator: { ${entries.join(', ')} }` : null\n}\n","import { getContentTypeInfo, getResponseContentTypeInfo } from '@internals/shared'\nimport { ast } from 'kubb/kit'\n\n/**\n * Builds the `contentType` entry baked into the call config, or `null` for the JSON default.\n *\n * `merge` is `true` when the generated function must destructure `contentType` from `options` and\n * merge it over the baked request default, because the caller can also pick a response content type.\n */\nexport function buildContentType({ node }: { node: ast.HttpOperationNode }): { literal: string | null; merge: boolean } {\n const { defaultContentType } = getContentTypeInfo(node)\n const hasRequestBody = Boolean(node.requestBody?.content?.[0]?.schema)\n // Bake the request body content type only when it is not the JSON default. The first declared type is\n // the default for an operation with several request types; the caller overrides it on `contentType`.\n const requestContentType = hasRequestBody && defaultContentType !== 'application/json' ? defaultContentType : null\n\n if (!requestContentType) return { literal: null, merge: false }\n\n // When the caller can also pick a response content type, a partial `{ response }` would replace the\n // baked request default through `...config`, so merge the caller's choice over it instead.\n const merge = getResponseContentTypeInfo(node).isMultipleContentTypes\n\n return {\n merge,\n literal: merge\n ? `contentType: { request: '${requestContentType}', ...(typeof contentType === 'string' ? { request: contentType } : contentType) }`\n : `contentType: { request: '${requestContentType}' }`,\n }\n}\n","import type { ast } from 'kubb/kit'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\n\n/**\n * Builds the `RequestResult` generic arguments for one operation: the per-status responses record\n * plus the per-call `ThrowOnError` flag. `SuccessOf` / `ErrorOf` split the record inside the\n * runtime, so this only names the record and threads `ThrowOnError`.\n *\n * @example\n * `buildRequestResultGenerics({ node, types }) // 'AddPetResponses, ThrowOnError'`\n */\nexport function buildRequestResultGenerics({ node, types }: { node: ast.OperationNode; types: OperationTypeNames }): string {\n return `${types.response.responses(node)}, ThrowOnError`\n}\n\n/**\n * Builds the full return type an operation's function signature uses: `Unwrappable<RequestResult>`\n * for the default `returnType: 'full'`, already a promise so no further wrapping is needed, a plain\n * `Promise<RequestResult>` for the internal `'plain'` shape, or a\n * `Promise` of the runtime's `UnwrappedResult` when `returnType: 'data'` narrows a resolved call\n * down to the bare success body.\n *\n * @example\n * `buildResultType({ node, types, returnType: 'data' }) // 'Promise<UnwrappedResult<AddPetResponses, ThrowOnError>>'`\n */\nexport function buildResultType({ node, types, returnType }: { node: ast.OperationNode; types: OperationTypeNames; returnType: ReturnTypeOption }): string {\n const generics = buildRequestResultGenerics({ node, types })\n if (returnType === 'data') return `Promise<UnwrappedResult<${generics}>>`\n if (returnType === 'plain') return `Promise<RequestResult<${generics}>>`\n return `Unwrappable<RequestResult<${generics}>>`\n}\n","import type { ast } from 'kubb/kit'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\nimport { buildRequestResultGenerics, buildResultType } from './generics.ts'\n\n/**\n * Builds the return statement of a generated operation function. With the default\n * `returnType: 'full'` the runtime call already resolves to `{ data, error, request, response }`.\n * The generated code casts that result to the operation's `RequestResult`, then wraps it with\n * `withUnwrap`, so the caller can `await` it directly or call `.unwrap()` for the bare success\n * body. With `returnType: 'data'` it instead routes the call through the runtime's `unwrapResult`,\n * which narrows the resolved value down to the bare success body the same way `RequestResult`\n * already does, using the plugin default when the call leaves `throwOnError` unset.\n * With `returnType: 'plain'` it returns the runtime call as is, cast to `RequestResult`, with no helper.\n *\n * Cast first, wrap second, for the `'full'` path. That order keeps `withUnwrap`'s generic inferred\n * as `RequestResult` instead of the runtime's own internal result type. Casting an `Unwrappable<A>`\n * straight to `Unwrappable<B>` does not work: the `.then` overload stays pinned to `A`, and `as`\n * rejects that two-generic swap even where `A` and `B` on their own would satisfy it.\n *\n * @example\n * `return withUnwrap(request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>)`\n * @example\n * `return unwrapResult(request({ method: 'POST', url: '/pet', ...config }), config.throwOnError ?? false) as Promise<UnwrappedResult<AddPetResponses, ThrowOnError>>`\n * @example\n * `return request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>`\n */\nexport function buildReturnStatement({\n node,\n types,\n callConfig,\n returnType,\n throwOnErrorDefault,\n}: {\n node: ast.OperationNode\n types: OperationTypeNames\n callConfig: string\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n}): string {\n if (returnType === 'data') {\n const resultType = buildResultType({ node, types, returnType })\n return `return unwrapResult(request(${callConfig}), config.throwOnError ?? ${throwOnErrorDefault}) as ${resultType}`\n }\n if (returnType === 'plain') {\n return `return request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({ node, types })}>>`\n }\n return `return withUnwrap(request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({ node, types })}>>)`\n}\n","import type { ast } from 'kubb/kit'\nimport { getRequestGroupOptionality } from '@internals/shared'\nimport { createFunctionParameter, createFunctionParameters, functionPrinter } from '@kubb/plugin-ts'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\nimport { buildResultType } from './generics.ts'\n\nconst declarationPrinter = functionPrinter({ mode: 'declaration' })\n\n/**\n * The pieces of a generated operation function's grouped-options signature.\n */\nexport type GroupedOptionsSignature = {\n /**\n * The single function parameter: `options: Options<<Name>Options, ThrowOnError>`.\n */\n paramsSignature: string\n /**\n * The function return type: `Unwrappable<RequestResult<<Name>Responses, ThrowOnError>>`.\n */\n returnType: string\n /**\n * The function generics. One per-call `ThrowOnError` flag, defaulting to the plugin setting.\n */\n generics: Array<string>\n}\n\n/**\n * Builds the grouped-options signature for one operation: a single `options` object whose `TData`\n * is the `<Name>Options` type, and a `RequestResult` return type keyed to the per-status responses\n * record. There are no positional arguments.\n *\n * The generated file imports `<Name>Options` and `<Name>Responses` and uses them directly, so no\n * per-operation input type has to be emitted. Both names come from `types`, which is `plugin-ts` or\n * `plugin-zod`'s inferred types (see `resolveOperationTypes`).\n */\nexport function buildGroupedOptionsSignature({\n node,\n types,\n returnType,\n throwOnErrorDefault,\n}: {\n node: ast.OperationNode\n types: OperationTypeNames\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n}): GroupedOptionsSignature {\n const optionsName = types.response.options(node)\n const { isOptional } = getRequestGroupOptionality(node)\n\n const paramsSignature =\n declarationPrinter.print(\n createFunctionParameters({\n params: [createFunctionParameter({ name: 'options', type: `Options<${optionsName}, ThrowOnError>`, ...(isOptional ? { default: '{}' } : {}) })],\n }),\n ) ?? ''\n\n return {\n paramsSignature,\n returnType: buildResultType({ node, types, returnType }),\n generics: [`ThrowOnError extends boolean = ${throwOnErrorDefault}`],\n }\n}\n","import { isValidVarName } from '@internals/utils'\nimport { ast } from 'kubb/kit'\n\ntype StyledLocation = 'path' | 'query' | 'header' | 'cookie'\n\n/**\n * Renders a parameter name as an object-literal key, quoted when it is not a bare identifier. Every\n * location keeps the spec name: the runtime looks path styles up by the `{name}` placeholder in the\n * URL, and the other locations by the key it serializes.\n */\nfunction toKey(name: string): string {\n return isValidVarName(name) ? name : JSON.stringify(name)\n}\n\n/**\n * Serializes one parameter's metadata into a `{ style, explode, allowReserved, contentType }`\n * literal, or `null` when the parameter carries none. Path and query carry the serialization\n * `style`; header and cookie use a fixed style (`simple` and `form`), so only `explode` is emitted\n * for them. `allowReserved` only applies to query parameters, and `contentType` to every location\n * except path.\n */\nfunction serializeParameter(parameter: ast.ParameterNode): string | null {\n const parts: Array<string> = []\n if ((parameter.in === 'path' || parameter.in === 'query') && parameter.style) parts.push(`style: '${parameter.style}'`)\n if (parameter.explode !== undefined) parts.push(`explode: ${parameter.explode}`)\n if (parameter.in === 'query' && parameter.allowReserved !== undefined) parts.push(`allowReserved: ${parameter.allowReserved}`)\n if (parameter.in !== 'path' && parameter.contentType) parts.push(`contentType: '${parameter.contentType}'`)\n return parts.length > 0 ? `{ ${parts.join(', ')} }` : null\n}\n\n/**\n * Serializes the `encoding` of the request body's default content type into a `{ property: { ... } }`\n * literal, or `null` when it carries none. Only an operation with a single request content type\n * emits it, because the runtime applies `styles.body` to whichever type the caller selects.\n */\nfunction serializeBodyEncoding(node: ast.HttpOperationNode): string | null {\n const content = node.requestBody?.content\n const entries = Object.entries(content?.length === 1 ? (content[0]?.encoding ?? {}) : {}).map(\n ([property, { contentType, style, explode, allowReserved }]) => {\n const parts = [\n style && `style: ${JSON.stringify(style)}`,\n explode !== undefined && `explode: ${explode}`,\n allowReserved !== undefined && `allowReserved: ${allowReserved}`,\n contentType && `contentType: ${JSON.stringify(contentType)}`,\n ].filter(Boolean)\n return `${isValidVarName(property) ? property : JSON.stringify(property)}: { ${parts.join(', ')} }`\n },\n )\n\n return entries.length > 0 ? `body: { ${entries.join(', ')} }` : null\n}\n\n/**\n * Builds the per-operation `styles` literal from the operation's parameters, grouped by location.\n * Entries are keyed by the spec name of the parameter.\n * Only parameters whose source defines `style`, `explode`, `allowReserved`, or `contentType` are\n * emitted, so calls without serialization metadata keep the runtime defaults and existing output\n * is unchanged. A form request body adds a `body` group keyed by property name from its `encoding`.\n * Returns `null` when nothing carries metadata.\n *\n * @example\n * ```ts\n * // a path param with { style: 'matrix', explode: true } and a query param with { explode: false }\n * buildStyles({ node }) // \"{ path: { id: { style: 'matrix', explode: true } }, query: { tags: { explode: false } } }\"\n * ```\n */\nexport function buildStyles({ node }: { node: ast.OperationNode }): string | null {\n if (!ast.isHttpOperationNode(node)) return null\n\n const groups: Record<StyledLocation, Array<string>> = { path: [], query: [], header: [], cookie: [] }\n\n for (const parameter of node.parameters) {\n const literal = serializeParameter(parameter)\n if (!literal) continue\n groups[parameter.in].push(`${toKey(parameter.name)}: ${literal}`)\n }\n\n const entries = [\n ...(Object.keys(groups) as Array<StyledLocation>)\n .filter((location) => groups[location].length > 0)\n .map((location) => `${location}: { ${groups[location].join(', ')} }`),\n serializeBodyEncoding(node),\n ].filter(Boolean)\n\n return entries.length > 0 ? `{ ${entries.join(', ')} }` : null\n}\n","import { buildOperationComments, getResponseType, isEventStream } from '@internals/shared'\nimport { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport { File, Function } from 'kubb/jsx'\nimport type { KubbReactNode } from 'kubb/jsx'\nimport { buildContentType } from '../builders/contentType.ts'\nimport { buildReturnStatement } from '../builders/returnStatement.ts'\nimport { type Auth, buildSecurityMetadata } from '../builders/security.ts'\nimport { buildGroupedOptionsSignature } from '../builders/signature.ts'\nimport { buildStyles } from '../builders/styles.ts'\nimport { buildValidatorHooks, buildValidatorLiteral } from '../builders/validator.ts'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption, ValidatorOptions } from '../types.ts'\n\ntype Props = {\n /**\n * The generated function name.\n */\n name: string\n /**\n * The operation being generated.\n */\n node: ast.OperationNode\n /**\n * The operation type names the signature references, from `plugin-ts` or `plugin-zod`'s inferred\n * types.\n */\n types: OperationTypeNames\n /**\n * Resolver for the zod schema names the validators reference, when `validator` is on.\n */\n zodResolver?: ResolverZod | null\n /**\n * The active validator option, driving the validator-hook wiring.\n */\n validator?: ValidatorOptions\n /**\n * Shape of the value the generated function resolves to.\n */\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n /**\n * Per-operation security, resolved from the spec into inline `Auth` objects and serialized onto the\n * call config's `security` field for the runtime `auth` resolver to consume.\n */\n security?: Array<Auth>\n}\n\n/**\n * Renders one client operation: the grouped `<Name>Request` type and the function that forwards a\n * single `options` object to the resolved client and returns the `Unwrappable<RequestResult>`. The\n * type, signature, and call config are built with the AST factory, and only the jsx-renderer emits\n * the source.\n */\nexport function Operation({ name, node, types, zodResolver, validator, returnType, throwOnErrorDefault, security }: Props): KubbReactNode {\n if (!ast.isHttpOperationNode(node)) return null\n\n const signature = buildGroupedOptionsSignature({ node, types, returnType, throwOnErrorDefault })\n const validators = buildValidatorHooks({ node, validator, zodResolver })\n const securityLiteral = buildSecurityMetadata({ security })\n const stylesLiteral = buildStyles({ node })\n\n const { literal: contentTypeLiteral, merge: mergeContentType } = buildContentType({ node })\n\n const eventStream = isEventStream(node)\n const responseType = getResponseType(node)\n const responseTypeLiteral = responseType ? `responseType: '${responseType}'` : null\n\n const validatorLiteral = buildValidatorLiteral(validators, ['request', 'path', 'query', 'headers', 'response', 'error'])\n\n const callConfig = `{ ${[\n `method: '${node.method.toUpperCase()}'`,\n `url: '${node.path}'`,\n securityLiteral ? `security: ${securityLiteral}` : null,\n stylesLiteral ? `styles: ${stylesLiteral}` : null,\n validatorLiteral,\n contentTypeLiteral,\n responseTypeLiteral,\n '...config',\n `throwOnError: config.throwOnError ?? ${throwOnErrorDefault}`,\n ]\n .filter(Boolean)\n .join(', ')} }`\n\n const eventType = `SuccessOf<${types.response.responses(node)}>`\n const functionReturnType = eventStream ? `Promise<EventStreamResult<${eventType}>>` : signature.returnType\n const returnStatement = eventStream\n ? `return toEventStream<${eventType}>(request(${callConfig}))`\n : buildReturnStatement({ node, types, callConfig, returnType, throwOnErrorDefault })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n generics={signature.generics}\n params={signature.paramsSignature}\n returnType={functionReturnType}\n JSDoc={{ comments: buildOperationComments(node, { link: 'urlPath', linkPosition: 'beforeDeprecated', splitLines: true }) }}\n >\n {mergeContentType ? 'const { client: request = client, contentType, ...config } = options' : 'const { client: request = client, ...config } = options'}\n <br />\n {returnStatement}\n </Function>\n </File.Source>\n )\n}\n","import { type ast, Diagnostics, type Generator, type Group, type Output } from 'kubb/kit'\nimport { pluginTsName, type ResolverTs } from '@kubb/plugin-ts'\nimport { pluginZodName, type ResolverZod } from '@kubb/plugin-zod'\nimport type { ContractClientFactory } from './types.ts'\n\ntype GeneratorDriver = Parameters<NonNullable<Generator<ContractClientFactory>['operations']>>[1]['driver']\n\n/**\n * The two per-operation type names a generated client references: the grouped input and the\n * per-status responses record its `RequestResult` is keyed on.\n */\nexport type OperationTypeNames = {\n response: {\n /**\n * Resolves the name of the operation's grouped `{ body, path, query, headers }` input type.\n */\n options(node: ast.OperationNode): string\n /**\n * Resolves the name of the operation's per-status responses record type.\n */\n responses(node: ast.OperationNode): string\n }\n}\n\n/**\n * Where a generated client sources its operation types, plus the resolver and output the file\n * declaring them is resolved with.\n */\nexport type OperationTypeSource = OperationTypeNames & {\n /**\n * `plugin-ts` shaped resolver of the plugin supplying the names, also used to resolve the file they are exported from.\n */\n resolver: ResolverTs\n /**\n * The supplying plugin's own `output`, when it configured one.\n */\n output: Output | undefined\n /**\n * The supplying plugin's own `group`, when it configured one.\n */\n group: Group | undefined\n}\n\n/**\n * A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`\n * exports next to each schema, so code written against `plugin-ts` names picks up the zod types.\n */\nfunction toZodTypeResolver(resolver: ResolverZod): ResolverTs {\n const type = (name: string) => resolver.schema.type(name)\n\n return {\n ...resolver,\n // A class method, so a spread drops it, and it reads private fields, so it must run on `resolver`.\n file: resolver.file.bind(resolver),\n param: {\n name: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.name(node, p)),\n path: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.path(node, p)),\n query: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.query(node, p)),\n headers: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.headers(node, p)),\n },\n response: {\n body: (node: ast.OperationNode) => type(resolver.response.body(node)),\n status: (node: ast.OperationNode, statusCode: ast.StatusCode) => type(resolver.response.status(node, statusCode)),\n response: (node: ast.OperationNode) => type(resolver.response.response(node)),\n responses: (node: ast.OperationNode) => type(resolver.response.responses(node)),\n options: (node: ast.OperationNode) => resolver.response.options(node),\n },\n } as unknown as ResolverTs\n}\n\n/**\n * Picks the plugin generated clients, query hooks, and MCP handlers take their operation types from.\n *\n * `pluginZod({ inferred: 'codec' })` wins, so a codec param takes its domain value. Otherwise `plugin-ts`\n * wins when it is in the pipeline, and without it any `pluginZod({ inferred })`. Throws\n * `KUBB_MISSING_DEPENDENCY` for `pluginName` when neither is available.\n *\n * @example\n * ```ts\n * const types = resolveOperationTypes(ctx.driver, ctx.plugin.name)\n * types.response.options(node) // 'GetPetByIdOptions', or 'GetPetByIdOptionsSchemaType' from zod\n * ```\n */\nexport function resolveOperationTypes(driver: GeneratorDriver, pluginName: string): OperationTypeSource {\n const pluginTs = driver.getPlugin(pluginTsName)\n const pluginZod = driver.getPlugin(pluginZodName)\n\n if (pluginTs && pluginZod?.options?.inferred !== 'codec') {\n const resolver = driver.getResolver(pluginTsName)\n return { response: resolver.response, resolver, output: pluginTs.options?.output, group: pluginTs.options?.group ?? undefined }\n }\n\n if (!pluginZod?.options?.inferred) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: `Plugin \"${pluginName}\" has no source for operation types.`,\n help: `Add \\`pluginTs()\\` before \"${pluginName}\", or add \\`pluginZod({ inferred: true })\\`.`,\n location: { kind: 'config' },\n plugin: pluginName,\n })\n }\n\n const resolver = toZodTypeResolver(driver.getResolver(pluginZodName))\n return { response: resolver.response, resolver, output: pluginZod.options.output, group: pluginZod.options.group ?? undefined }\n}\n","import path from 'node:path'\nimport { isEventStream, operationFileEntry, resolveDependencyOperationFile } from '@internals/shared'\nimport { ast, defineGenerator } from 'kubb/kit'\nimport type { Generator } from 'kubb/kit'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, jsxRenderer } from 'kubb/jsx'\nimport { isValidatorEnabled } from '../builders/validatorOptions.ts'\nimport { getOperationSecurity, type SecurityDocument } from '../builders/security.ts'\nimport { buildValidatorHooks } from '../builders/validator.ts'\nimport { Operation } from '../components/Operation.tsx'\nimport { resolveOperationTypes } from '../resolveOperationTypes.ts'\nimport type { ContractClientFactory } from '../types.ts'\n\n/**\n * Builds the built-in per-operation generator shared by the client plugins (`@kubb/plugin-fetch`,\n * `@kubb/plugin-axios`). Emits one async function per OpenAPI operation using the shared\n * `Operation` component: a grouped `<Name>Request` type and a function that forwards a single\n * `options` object to the bundled `client` and returns the `Unwrappable<RequestResult>`. Only the\n * generator `name` differs between plugins. Every other resolution, import, and rendering step is\n * identical.\n */\nexport function createClientGenerator<TFactory extends ContractClientFactory>(\n name: string,\n resolveClientPath?: (options: TFactory['resolvedOptions'], root: string) => string,\n): Generator<TFactory> {\n return defineGenerator<TFactory>({\n name,\n renderer: jsxRenderer,\n operation(node, ctx) {\n if (!ast.isHttpOperationNode(node)) return null\n\n const { config, driver, resolver, root } = ctx\n const { output, validator, returnType, throwOnErrorDefault, group } = ctx.options\n\n const types = resolveOperationTypes(driver, ctx.plugin.name)\n\n const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(pluginZodName) : null\n const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null\n\n const importedTypeNames = [types.response.options(node), types.response.responses(node)]\n\n const validatorHooks = buildValidatorHooks({ node, validator, zodResolver })\n const importedZodNames = validatorHooks.importedZodNames\n\n const meta = {\n name: resolver.name(node.operationId),\n file: resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\n fileTypes: resolveDependencyOperationFile({\n cache: ctx.cache,\n node,\n resolver: types.resolver,\n root,\n output: types.output ?? output,\n group: types.group,\n }),\n fileZod:\n zodResolver && pluginZod?.options\n ? zodResolver.file({\n ...operationFileEntry(node, node.operationId),\n root,\n output: pluginZod.options.output ?? output,\n group: pluginZod.options?.group ?? undefined,\n })\n : null,\n } as const\n\n const security = getOperationSecurity({\n document: ctx.adapter.document as SecurityDocument | null | undefined,\n method: node.method,\n path: node.path,\n })\n\n // A custom client module is emitted verbatim, so `importPath` is used exactly as configured.\n // The default `.kubb/client.ts` is a file path and is made relative to the operation file.\n const customClientPath = resolveClientPath?.(ctx.options, root)\n const clientPath = customClientPath ?? path.resolve(root, '.kubb/client.ts')\n const clientRoot = customClientPath === undefined ? meta.file.path : undefined\n // The headers validator helper ships in `.kubb/standardSchema.ts`; a custom client module exports it\n // alongside its other runtime helpers.\n const standardSchemaPath = customClientPath ?? path.resolve(root, '.kubb/standardSchema.ts')\n const eventStream = isEventStream(node)\n\n const clientValueImports = (() => {\n if (eventStream) return ['client', 'toEventStream']\n if (returnType === 'plain') return ['client']\n if (returnType === 'data') return ['client', 'unwrapResult']\n return ['client', 'withUnwrap']\n })()\n\n const clientTypeImports = (() => {\n if (eventStream) return ['Options', 'EventStreamResult', 'SuccessOf']\n if (returnType === 'plain') return ['Options', 'RequestResult']\n if (returnType === 'data') return ['Options', 'UnwrappedResult']\n return ['Options', 'Unwrappable', 'RequestResult']\n })()\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.default.banner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.default.footer(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n <File.Import name={clientValueImports} root={clientRoot} path={clientPath} />\n <File.Import name={clientTypeImports} root={clientRoot} path={clientPath} isTypeOnly />\n\n {meta.fileTypes && importedTypeNames.length > 0 && (\n <File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTypes.path} isTypeOnly />\n )}\n\n {meta.fileZod && importedZodNames.length > 0 && <File.Import name={importedZodNames} root={meta.file.path} path={meta.fileZod.path} />}\n {validatorHooks.headers && <File.Import name={['toHeadersStandardSchema']} root={clientRoot} path={standardSchemaPath} />}\n\n <Operation\n name={meta.name}\n node={node}\n types={types}\n zodResolver={zodResolver}\n validator={validator}\n returnType={returnType}\n throwOnErrorDefault={throwOnErrorDefault}\n security={security}\n />\n </File>\n )\n },\n })\n}\n","import { macroSimplifyUnion } from 'kubb/kit'\nimport type { ast } from 'kubb/kit'\n\n/**\n * Macros the client plugins apply by default, ahead of any user macros. `macroSimplifyUnion`\n * drops union members a broader scalar already covers, keeping the generated response and error\n * unions tidy. A plugin wires them with `ctx.setMacros([...defaultMacros, ...userMacros])`.\n */\nexport const defaultMacros: ReadonlyArray<ast.Macro> = [macroSimplifyUnion]\n","import { camelCase, ensureValidVarName, pascalCase } from '@internals/utils'\nimport { createResolver } from 'kubb/kit'\nimport type { PluginContractClient } from './types.ts'\n\n/**\n * Default resolver shared by the client plugins. Functions and files inherit the built-in camelCase\n * `name` and `file`; classes and tag groups use PascalCase.\n *\n * @example\n * ```ts\n * resolverClient.name('show pet by id') // 'showPetById'\n * resolverClient.groupName('pet') // 'PetClient'\n * ```\n */\nexport const resolverClient = createResolver<PluginContractClient>({\n pluginName: 'plugin-contract-client',\n className(name) {\n return ensureValidVarName(pascalCase(name))\n },\n groupName(name) {\n return ensureValidVarName(pascalCase(`${name} Client`))\n },\n propertyName(name) {\n return ensureValidVarName(camelCase(name))\n },\n})\n","import { createClientGenerator } from '@internals/client'\nimport type { PluginClient } from '../types.ts'\n\n/**\n * Built-in operation generator for `@kubb/plugin-client`. Emits one async function per OpenAPI\n * operation using the shared `Operation` component: a grouped `<Name>Request` type and a function\n * that forwards a single `options` object to the user-provided client module and returns the `RequestResult`.\n */\nexport const clientGenerator = createClientGenerator<PluginClient>('client', (options) => options.importPath)\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 { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { defaultMacros, isValidatorEnabled, resolverClient } from '@internals/client'\nimport type { PluginClient, ResolverClient } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-client`.\n */\nexport const pluginClientName = 'plugin-client' satisfies PluginClient['name']\n\n/**\n * Generates typed operations that call a client module owned by your application.\n * The module at `importPath` must export the runtime helpers and types used by generated operations.\n * Kubb does not copy or inject a transport implementation.\n *\n * @example\n * ```ts\n * pluginClient({ importPath: '../api/client' })\n * ```\n */\nexport const pluginClient = defineExtension<PluginClient>({\n kind: 'plugin',\n meta: { name: pluginClientName, version, compatibility },\n dependencies: (options) => ({ [pluginTsName]: { optional: true }, [pluginZodName]: { optional: !isValidatorEnabled(options.validator) } }),\n setup(options) {\n const {\n output = { path: 'clients', barrel: { type: 'named' } },\n exclude = [],\n include,\n override = [],\n importPath,\n throwOnErrorDefault = true,\n validator = false,\n group,\n resolver: userResolver,\n } = options\n\n const resolver = userResolver ? Resolver.merge<ResolverClient>(resolverClient, userResolver) : resolverClient\n\n setResolver(resolver)\n setMacros([...defaultMacros, ...(options.macros ?? [])])\n addGenerator(clientGenerator)\n\n return {\n output,\n exclude,\n include,\n override,\n group: createGroupConfig(group),\n importPath,\n baseURL: undefined,\n throwOnErrorDefault,\n validator,\n returnType: 'plain',\n sdk: undefined,\n resolver,\n }\n },\n})\n\nexport default pluginClient\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAAgB,mBAAmB,MAAyB,MAAc,UAAyC,OAA2B;CAC5I,OAAO;EACL;EACA;EACA,KAAK,KAAK,KAAK,MAAM;EACrB,MAAM,KAAK;CACb;AACF;;;;;;;;;;;;AAaA,SAAgB,+BAA+B,SAO9B;CACf,MAAM,EAAE,OAAO,MAAM,UAAU,MAAM,QAAQ,UAAU;CAEvD,OAAO,MAAM,WAAW,GAAG,SAAS,WAAW,uBAC7C,SAAS,KAAK;EAAE,GAAG,mBAAmB,MAAM,KAAK,WAAW;EAAG;EA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a,gBAAA,GAAeC,SAAAA,gBAAAA,CAA8B;CACxD,MAAM;CACN,MAAM;EAAE,MAAM;EAAkB;EAAS;CAAc;CACvD,eAAe,aAAa;GAAGC,gBAAAA,eAAe,EAAE,UAAU,KAAK;GAAIC,iBAAAA,gBAAgB,EAAE,UAAU,CAAC,mBAAmB,QAAQ,SAAS,EAAE;CAAE;CACxI,MAAM,SAAS;EACb,MAAM,EACJ,SAAS;GAAE,MAAM;GAAW,QAAQ,EAAE,MAAM,QAAQ;EAAE,GACtD,UAAU,CAAC,GACX,SACA,WAAW,CAAC,GACZ,YACA,sBAAsB,MACtB,YAAY,OACZ,OACA,UAAU,iBACR;EAEJ,MAAM,WAAW,eAAeC,SAAAA,SAAS,MAAsB,gBAAgB,YAAY,IAAI;EAE/F,CAAA,GAAA,SAAA,YAAA,CAAY,QAAQ;EACpB,CAAA,GAAA,SAAA,UAAA,CAAU,CAAC,GAAG,eAAe,GAAI,QAAQ,UAAU,CAAC,CAAE,CAAC;EACvD,CAAA,GAAA,SAAA,aAAA,CAAa,eAAe;EAE5B,OAAO;GACL;GACA;GACA;GACA;GACA,OAAO,kBAAkB,KAAK;GAC9B;GACA,SAAS,KAAA;GACT;GACA;GACA,YAAY;GACZ,KAAK,KAAA;GACL;EACF;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["Url","functionPrinter","createFunctionParameters","createFunctionParameter","ast","ast","File","Function","pluginTsName","pluginZodName","Diagnostics","defineGenerator","jsxRenderer","ast","pluginZodName","path","File","macroSimplifyUnion","createResolver","defineExtension","pluginTsName","pluginZodName","Resolver"],"sources":["../../../internals/shared/src/operation.ts","../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/shared/src/resolver.ts","../../../internals/shared/src/group.ts","../kubb-extension.json","../package.json","../../../internals/client/src/builders/validatorOptions.ts","../../../internals/client/src/builders/security.ts","../../../internals/client/src/builders/validator.ts","../../../internals/client/src/builders/contentType.ts","../../../internals/client/src/builders/generics.ts","../../../internals/client/src/builders/returnStatement.ts","../../../internals/client/src/builders/signature.ts","../../../internals/client/src/builders/styles.ts","../../../internals/client/src/components/Operation.tsx","../../../internals/client/src/resolveOperationTypes.ts","../../../internals/client/src/generators/clientGenerator.tsx","../../../internals/client/src/macros.ts","../../../internals/client/src/resolver.ts","../src/generators/clientGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import { ast, type Group, type NodeCache, type Output, type Resolver, type ResolverFileParams, Url } from 'kubb/kit'\n\n/**\n * Builds the `ResolverFileParams` every operation generator passes to\n * `resolver.file`: a file named `name`, tagged by the operation's first\n * tag (or `'default'`), at the operation's path. Centralizes the entry object\n * that was repeated at dozens of call sites across the client and query plugins.\n *\n * @example\n * ```ts\n * resolver.file(operationFileEntry(node, node.operationId), { root, output, group })\n * ```\n */\nexport function operationFileEntry(node: ast.OperationNode, name: string, extname: ResolverFileParams['extname'] = '.ts'): ResolverFileParams {\n return {\n name,\n extname,\n tag: node.tags[0] ?? 'default',\n path: node.path,\n }\n}\n\n/**\n * Resolves a dependency plugin's generated file for `node.operationId`, cached in `cache` (the\n * current node's `ctx.cache`) under the resolver's own plugin name. Several dependents reading the\n * same dependency for the same operation in one pass (a query plugin's several hook generators, the\n * MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.\n *\n * @example Cache `plugin-ts`'s file for the current operation\n * ```ts\n * const fileTs = resolveDependencyOperationFile({ cache: ctx.cache, node, resolver: tsResolver, root, output })\n * ```\n */\nexport function resolveDependencyOperationFile(options: {\n cache: NodeCache\n node: ast.OperationNode\n resolver: Pick<Resolver, 'file' | 'pluginName'>\n root: string\n output: Output\n group?: Group | null\n}): ast.FileNode {\n const { cache, node, resolver, root, output, group } = options\n\n return cache.ensureItem(`${resolver.pluginName}:operationFile`, () =>\n resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\n )\n}\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type OperationCommentLink = 'pathTemplate' | 'urlPath' | false | ((node: ast.OperationNode) => string | undefined)\n\nexport type BuildOperationCommentsOptions = {\n link?: OperationCommentLink\n linkPosition?: 'beforeDeprecated' | 'afterDeprecated'\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<ast.ParameterNode['in'], Array<ast.ParameterNode>>\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\nfunction getOperationLink(node: ast.OperationNode, link: OperationCommentLink): string | null {\n if (!link) {\n return null\n }\n\n if (typeof link === 'function') {\n return link(node) ?? null\n }\n\n return node.path ? `{@link ${Url.toPath(node.path)}}` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(node.requestBody?.content?.map((e) => e.contentType) ?? [])\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(getPrimarySuccessResponse(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\nexport type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n\n/**\n * Reads the single base content type of an operation's primary success response, lowercased and\n * stripped of any `; charset=...` suffix. Returns `undefined` when the response declares zero or\n * more than one content type, since neither case has a single type to act on.\n */\nfunction getPrimarySuccessContentType(node: ast.OperationNode): string | undefined {\n const contentTypes = getPrimarySuccessResponse(node)?.content?.map((entry) => entry.contentType) ?? []\n if (contentTypes.length !== 1) return undefined\n return contentTypes[0]!.split(';')[0]!.trim().toLowerCase()\n}\n\n/**\n * Whether an operation streams its primary success response as Server-Sent Events\n * (`text/event-stream`). The client generator uses this to return a typed event stream instead of a\n * one-shot `RequestResult`.\n */\nexport function isEventStream(node: ast.OperationNode): boolean {\n return getPrimarySuccessContentType(node) === 'text/event-stream'\n}\n\n/**\n * Derives the default `responseType` for an operation from its primary success response.\n *\n * Returns a value only when that response declares a single non-JSON content type. `text/event-stream`\n * and other binary types (`application/octet-stream`, `application/pdf`, `image/*`, `audio/*`,\n * `video/*`) map to a stream or `'blob'`, and other `text/*` maps to `'text'`. Otherwise `undefined`,\n * leaving the runtime client's `Content-Type` auto-detection in charge.\n */\nexport function getResponseType(node: ast.OperationNode): ResponseType | undefined {\n const baseType = getPrimarySuccessContentType(node)\n if (!baseType) return undefined\n\n if (baseType === 'application/json' || baseType.endsWith('+json') || baseType === 'text/json') return undefined\n if (baseType === 'text/event-stream') return 'stream'\n if (baseType.startsWith('text/')) return 'text'\n if (baseType === 'application/octet-stream' || baseType === 'application/pdf' || /^(image|audio|video)\\//.test(baseType)) return 'blob'\n return undefined\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n// The request groups come from the grouped params, so `config` drops the data-shape keys to stay\n// assignable to `Options`, which omits them from `RequestConfig`.\nconst requestConfigBaseType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\n\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n\n // Only the ambiguous side is offered: a single-type side has nothing to pick, so it stays baked in\n // the generated call.\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n return members.length ? `${requestConfigBaseType} & { contentType?: { ${members.join('; ')} } }` : requestConfigBaseType\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...). Unlike {@link buildRequestConfigType}, it never adds a\n * `contentType?:` member: query hooks wrap GET operations, which carry no request body to select a\n * content type for.\n */\nexport function buildClientOptionType(): string {\n return requestConfigBaseType\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n}\n\n/**\n * Which of the grouped request options an operation carries.\n */\nexport function getRequestGroups(node: ast.OperationNode): RequestGroups {\n const { path, query, header } = getOperationParameters(node)\n return {\n path: path.length > 0,\n query: query.length > 0,\n body: Boolean(node.requestBody?.content?.[0]?.schema),\n headers: header.length > 0,\n }\n}\n\nexport type RequestGroupOptionality = {\n groups: RequestGroups\n hasRequiredPath: boolean\n hasRequiredQuery: boolean\n hasRequiredHeader: boolean\n /**\n * Whether the grouped request parameter can default to `{}`. True only when no group carries a\n * required member, so every member is safe to omit.\n */\n isOptional: boolean\n}\n\n/**\n * Resolves which grouped request options an operation carries together with whether each group\n * holds a required member. The grouped parameter stays optional only when nothing inside it is\n * required, matching the generated `RequestConfig` type.\n */\nexport function getRequestGroupOptionality(node: ast.OperationNode): RequestGroupOptionality {\n const groups = getRequestGroups(node)\n const { path, query, header } = getOperationParameters(node)\n const hasRequiredPath = path.some((param) => param.required)\n const hasRequiredQuery = query.some((param) => param.required)\n const hasRequiredHeader = header.some((param) => param.required)\n\n return {\n groups,\n hasRequiredPath,\n hasRequiredQuery,\n hasRequiredHeader,\n isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !groups.body,\n }\n}\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: RequestGroups } {\n const { isConfigurable = true } = options\n const { groups, isOptional } = getRequestGroupOptionality(node)\n\n const names = (['path', 'query', 'body', 'headers'] as const).filter((key) => groups[key])\n\n // 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\nconst typeNamesByResolver = new WeakMap<OperationTypeNameResolver, Map<string, string[]>>()\n\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const cacheKey = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n let byResolver = typeNamesByResolver.get(resolver)\n if (byResolver) {\n const cached = byResolver.get(cacheKey)\n if (cached) return cached\n } else {\n byResolver = new Map()\n typeNamesByResolver.set(resolver, byResolver)\n }\n\n const { path, query, header } = getOperationParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ]\n const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n const result = names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n byResolver.set(cacheKey, result)\n return result\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = getStatusCodeNumber(response.statusCode)\n if (code === null) {\n continue\n }\n\n types.push([code, isSuccessStatusCode(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n","type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction convert(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n// Plugins resolve the same names over and over (about 47,000 calls for a 1,000 schema spec), so\n// results are kept. Clearing at the limit bounds the memory a long-running process spends on it.\nconst cache = new Map<string, string>()\nconst cacheLimit = 10_000\n\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const key = `${pascal ? 'P' : 'c'}${text}`\n const cached = cache.get(key)\n if (cached !== undefined) return cached\n\n const result = convert(text, pascal)\n if (cache.size >= cacheLimit) cache.clear()\n cache.set(key, result)\n return result\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Uppercases only the first character of `text`, leaving the rest untouched.\n * Unlike {@link pascalCase} it never re-splits word boundaries or strips characters.\n *\n * @example\n * `capitalize('getPetById') // 'GetPetById'`\n */\nexport function capitalize(text: string): string {\n return `${text.charAt(0).toUpperCase()}${text.slice(1)}`\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example From camelCase\n * `snakeCase('helloWorld') // 'hello_world'`\n *\n * @example From mixed separators\n * `snakeCase('Hello-World') // 'hello_world'`\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example From camelCase\n * `screamingSnakeCase('helloWorld') // 'HELLO_WORLD'`\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'await',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `name` when it's a syntactically valid JavaScript variable name,\n * otherwise prefixes it with `_` so the result is a valid identifier.\n *\n * Useful for sanitizing OpenAPI schema names or operation IDs that start with\n * a digit (e.g. `409`, `504AccountCancel`) before using them as exported\n * variable, type, or function names.\n *\n * @example\n * ```ts\n * ensureValidVarName('409') // '_409'\n * ensureValidVarName('504AccountCancel') // '_504AccountCancel'\n * ensureValidVarName('Pet') // 'Pet'\n * ensureValidVarName('class') // '_class'\n * ```\n */\nexport function ensureValidVarName(name: string): string {\n if (!name || isValidVarName(name)) {\n return name\n }\n return `_${name}`\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase, ensureValidVarName, toFilePath } from '@internals/utils'\nimport type { ast, Resolver, ResolverFile } from 'kubb/kit'\n\nexport function resolveOperationName(name: string): string {\n return ensureValidVarName(camelCase(name))\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 * Resolves a single operation parameter name with the\n * `<operationId> <in> <name>` template.\n *\n * @example\n * `operationParamName.call(resolver, node, param) // → 'DeletePetPathPetId'`\n */\nfunction operationParamName(this: Resolver, node: ast.OperationNode, param: ast.ParameterNode): string {\n return this.name(`${node.operationId} ${param.in} ${param.name}`)\n}\n\n/**\n * Builds the shared `param` namespace. Spread the result into `createResolver`\n * and override individual methods next to it when a plugin deviates.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ param: createOperationParamResolver(), ... })\n * ```\n */\nexport function createOperationParamResolver(): OperationParamResolver {\n return {\n name: operationParamName,\n path(node) {\n return this.name(`${node.operationId} Path`)\n },\n query(node) {\n return this.name(`${node.operationId} Query`)\n },\n headers(node) {\n return this.name(`${node.operationId} Headers`)\n },\n }\n}\n\n/**\n * Builds the shared `response` namespace. Spread the result into\n * `createResolver` and add plugin-specific methods (`options`, `error`) next\n * to it.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ response: { ...createOperationResponseResolver(), options(node) {...} }, ... })\n * ```\n */\nexport function createOperationResponseResolver(): OperationResponseResolver {\n return {\n status(node, statusCode) {\n return this.name(`${node.operationId} Status ${statusCode}`)\n },\n body(node) {\n return this.name(`${node.operationId} Body`)\n },\n responses(node) {\n return this.name(`${node.operationId} Responses`)\n },\n response(node) {\n return this.name(`${node.operationId} Response`)\n },\n }\n}\n\n/**\n * Builds a resolver `file` override whose base name runs every path segment\n * through `toFilePath`, casing the final segment with `caseLast`.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ file: createCasedFile(pascalCase), ... })\n * ```\n */\nexport function createCasedFile(caseLast: (part: string) => string): ResolverFile {\n return {\n baseName({ name, extname }) {\n return `${toFilePath(name, caseLast)}${extname}`\n },\n }\n}\n","import { camelCase } from '@internals/utils'\nimport type { Group } from 'kubb/kit'\n\n/**\n * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the\n * shared default naming so every plugin groups output consistently:\n *\n * - `path` groups use the second path segment (`/pet/findByStatus` → `pet`).\n * - other groups use the camelCased group (`pet store` → `petStore`).\n *\n * A user-provided `group.name` always wins over the default namer, so callers stay in\n * control of their output folders. Returns `null` when grouping is disabled, matching the\n * per-plugin convention.\n *\n * @param group - The user-supplied group option, or `undefined` to disable grouping.\n *\n * @example\n * ```ts\n * createGroupConfig(group) // shared across every plugin\n * ```\n */\nexport function createGroupConfig(group: Group | undefined): Group | null {\n if (!group) {\n return null\n }\n\n const defaultName = (ctx: { group: string }): string => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n\n return camelCase(ctx.group)\n }\n\n return {\n ...group,\n name: group.name ? group.name : defaultName,\n } satisfies Group\n}\n","","","import { isSuccessStatusCode } from '@internals/shared'\nimport type { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport type { ValidatorOptions } from '../types.ts'\n\n/**\n * Returns `true` when any direction of the validator uses zod (used for dependency checks).\n */\nexport function isValidatorEnabled(validator: ValidatorOptions | undefined): boolean {\n if (!validator) return false\n if (validator === 'zod') return true\n return Boolean(validator.request || validator.params || validator.response)\n}\n\n/**\n * Returns `'zod'` when request body parsing is enabled, `null` otherwise. The string shorthand\n * `'zod'` validates the response only, so it does not enable request parsing.\n */\nexport function resolveRequestValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator || validator === 'zod') return null\n return validator.request ?? null\n}\n\n/**\n * Returns `'zod'` when path, query, and header params parsing is enabled, `null` otherwise. Only the\n * object form `{ params: 'zod' }` enables it.\n */\nexport function resolveParamsValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator || validator === 'zod') return null\n return validator.params ?? null\n}\n\n/**\n * Returns `'zod'` when response parsing is enabled, `null` otherwise. The string shorthand `'zod'`\n * maps to response parsing.\n */\nexport function resolveResponseValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator) return null\n if (validator === 'zod') return 'zod'\n return validator.response ?? null\n}\n\n/**\n * Resolves the zod schema name a generated client validates an error body with on the non-throw path.\n * Uses the error-only `<operation>ErrorSchema` (the union of non-2xx statuses); returns `null` when the\n * operation documents no error responses with a schema.\n */\nexport function buildZodErrorParse(node: ast.OperationNode, zodResolver: ResolverZod): string | null {\n const hasErrorResponse = node.responses.some((res) => !isSuccessStatusCode(res.statusCode) && res.content?.some((entry) => entry.schema))\n if (!hasErrorResponse) return null\n return zodResolver.response.error?.(node) || null\n}\n","/**\n * A resolved security scheme as emitted on each generated call's `security` array. The runtime calls\n * the configured `auth` resolver with this object and places the returned token: `http` bearer/basic\n * on `Authorization`, `apiKey` under `name` in the header/query/cookie, and `oauth2`/`openIdConnect`\n * as a bearer token.\n */\nexport type Auth = {\n type: 'http' | 'apiKey' | 'oauth2' | 'openIdConnect'\n scheme?: 'bearer' | 'basic'\n name?: string\n in?: 'header' | 'query' | 'cookie'\n scopes?: Array<string>\n}\n\n/**\n * A single OpenAPI security requirement read from the spec: scheme name to the scopes it needs.\n */\ntype SecurityRequirement = Record<string, Array<string>>\n\n/**\n * The slice of an OpenAPI document the security derivation reads: the global `security`, the\n * per-operation `security` under `paths`, and the `securitySchemes` map under `components`. Typed\n * locally so this package stays independent of the OpenAPI adapter.\n */\nexport type SecurityDocument = {\n security?: Array<SecurityRequirement>\n components?: {\n securitySchemes?: Record<string, OasSecurityScheme | { $ref: string } | undefined>\n }\n paths?: Record<string, Record<string, { security?: Array<SecurityRequirement> } | undefined> | undefined>\n}\n\ntype OasSecurityScheme = { type: 'http'; scheme?: string } | { type: 'apiKey'; name?: string; in?: string } | { type: 'oauth2' } | { type: 'openIdConnect' }\n\nfunction serializeAuth(auth: Auth): string {\n const parts = [`type: '${auth.type}'`]\n if (auth.scheme) parts.push(`scheme: '${auth.scheme}'`)\n if (auth.name) parts.push(`name: '${auth.name}'`)\n if (auth.in) parts.push(`in: '${auth.in}'`)\n if (auth.scopes?.length) parts.push(`scopes: [${auth.scopes.map((scope) => `'${scope}'`).join(', ')}]`)\n return `{ ${parts.join(', ')} }`\n}\n\n/**\n * Maps an OpenAPI security scheme to the inline `Auth` object, or `null` when the runtime cannot\n * place it (an unresolved `$ref`, or an `apiKey` without a name or outside `header` / `query` /\n * `cookie`). `http` schemes other than `basic` are treated as bearer.\n */\nexport function resolveSecurityScheme(scheme: OasSecurityScheme | { $ref: string } | undefined): Auth | null {\n if (!scheme || '$ref' in scheme) return null\n if (scheme.type === 'apiKey') {\n if (!scheme.name || (scheme.in !== 'header' && scheme.in !== 'query' && scheme.in !== 'cookie')) return null\n return { type: 'apiKey', name: scheme.name, in: scheme.in }\n }\n if (scheme.type === 'http') return { type: 'http', scheme: scheme.scheme?.toLowerCase() === 'basic' ? 'basic' : 'bearer' }\n if (scheme.type === 'oauth2') return { type: 'oauth2' }\n if (scheme.type === 'openIdConnect') return { type: 'openIdConnect' }\n return null\n}\n\n/**\n * Derives the per-operation security metadata from the OpenAPI document. The operation's own\n * `security` overrides the global `security` (an explicit empty array disables auth), and every\n * referenced scheme is resolved from `components.securitySchemes` into a flat, de-duplicated list of\n * `Auth` objects the runtime walks in order.\n *\n * @example\n * `getOperationSecurity({ document, method: 'POST', path: '/pet' })`\n * `// [{ type: 'http', scheme: 'bearer' }]`\n */\nexport function getOperationSecurity({\n document,\n method,\n path,\n}: {\n document: SecurityDocument | null | undefined\n method: string\n path: string\n}): Array<Auth> | undefined {\n if (!document) return undefined\n\n const operation = document.paths?.[path]?.[method.toLowerCase()]\n const requirements = operation?.security ?? document.security\n if (!requirements?.length) return undefined\n\n const definitions = document.components?.securitySchemes ?? {}\n const security: Array<Auth> = []\n const seen = new Set<string>()\n for (const requirement of requirements) {\n for (const [schemeName, scopes] of Object.entries(requirement)) {\n if (seen.has(schemeName)) continue\n seen.add(schemeName)\n const auth = resolveSecurityScheme(definitions[schemeName])\n if (auth) security.push(scopes.length ? { ...auth, scopes } : auth)\n }\n }\n\n return security.length ? security : undefined\n}\n\n/**\n * Serializes the per-operation security into the literal emitted on each generated call's `security`\n * field. The runtime `resolveAuth` helper walks it, calling the configured `auth` resolver per entry.\n *\n * @example\n * `buildSecurityMetadata({ security: [{ type: 'http', scheme: 'bearer' }] }) // \"[{ type: 'http', scheme: 'bearer' }]\"`\n */\nexport function buildSecurityMetadata({ security }: { security?: Array<Auth> }): string | null {\n if (!security?.length) return null\n return `[${security.map(serializeAuth).join(', ')}]`\n}\n","import { getOperationParameters } from '@internals/shared'\nimport type { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport type { ValidatorOptions } from '../types.ts'\nimport { buildZodErrorParse, resolveParamsValidator, resolveRequestValidator, resolveResponseValidator } from './validatorOptions.ts'\n\n/**\n * The per-call validator references a generated function wires into its request config. Each hook is\n * the bare schema reference passed to the runtime's `validator.request` / `validator.path` /\n * `validator.query` / `validator.headers` / `validator.response` / `validator.error` slot; `client.ts`\n * runs it through `validateStandardSchema`. The response validator only ever sees success (2xx) bodies.\n */\nexport type ValidatorHooks = {\n /**\n * Schema reference for the `validator.request` hook, or `null` when request validation is off.\n */\n request: string | null\n /**\n * Schema references for the `validator.path` / `query` / `headers` hooks (`headers` wrapped in\n * `toHeadersStandardSchema`), or `null` when params validation is off or the group is empty.\n */\n path: string | null\n query: string | null\n headers: string | null\n /**\n * Schema reference for the `validator.response` hook, or `null` when response validation is off.\n */\n response: string | null\n /**\n * Schema reference for the `validator.error` hook, or `null` when error validation is off or the\n * operation documents no error responses. The runtime runs this on the error body when a non-2xx\n * call does not throw.\n */\n error: string | null\n /**\n * Zod schema names the generated file imports from the zod plugin output.\n */\n importedZodNames: Array<string>\n}\n\n/**\n * Builds the validator-hook references for one operation. Request body and params validation run before the send.\n * Response validation runs on the success body only. Returns `null` references when the matching\n * direction is disabled or the schema is absent.\n */\nexport function buildValidatorHooks({\n node,\n validator,\n zodResolver,\n}: {\n node: ast.OperationNode\n validator: ValidatorOptions | undefined\n zodResolver: ResolverZod | null | undefined\n}): ValidatorHooks {\n const hasRequestBody = Boolean(node.requestBody?.content?.[0]?.schema)\n const parsesResponse = zodResolver && resolveResponseValidator(validator) === 'zod'\n\n // Success responses validate with the success-only `<operation>ResponseSchema`; error bodies are never zod-parsed on the throw path.\n const response = parsesResponse ? zodResolver.response.response(node) || null : null\n const error = parsesResponse ? buildZodErrorParse(node, zodResolver) : null\n const request = zodResolver && resolveRequestValidator(validator) === 'zod' && hasRequestBody ? zodResolver.response.body(node) || null : null\n\n const paramGroups = getOperationParameters(node)\n const resolveParamsName = (kind: 'path' | 'query' | 'headers', params: Array<ast.ParameterNode>): string | null =>\n zodResolver && resolveParamsValidator(validator) === 'zod' && params.length > 0 ? zodResolver.param[kind](node, params[0]!) : null\n const path = resolveParamsName('path', paramGroups.path)\n const query = resolveParamsName('query', paramGroups.query)\n const headers = resolveParamsName('headers', paramGroups.header)\n\n // Order is output: the generated file imports the response schema, then the error schema, then the request body and params schemas.\n const importedZodNames = [response, error, request, path, query, headers].filter((name): name is string => Boolean(name))\n\n const headersValidator = headers ? `toHeadersStandardSchema(${headers}, ${headers}.shape)` : null\n\n return { request, path, query, headers: headersValidator, response, error, importedZodNames }\n}\n\n/**\n * Prints the `validator: { … }` entry of a call config from the hooks named in `keys`, or `null` when none is set.\n */\nexport function buildValidatorLiteral(hooks: ValidatorHooks | null, keys: ReadonlyArray<keyof Omit<ValidatorHooks, 'importedZodNames'>>): string | null {\n const entries = keys.flatMap((key) => (hooks?.[key] ? [`${key}: ${hooks[key]}`] : []))\n return entries.length ? `validator: { ${entries.join(', ')} }` : null\n}\n","import { getContentTypeInfo, getResponseContentTypeInfo } from '@internals/shared'\nimport { ast } from 'kubb/kit'\n\n/**\n * Builds the `contentType` entry baked into the call config, or `null` for the JSON default.\n *\n * `merge` is `true` when the generated function must destructure `contentType` from `options` and\n * merge it over the baked request default, because the caller can also pick a response content type.\n */\nexport function buildContentType({ node }: { node: ast.HttpOperationNode }): { literal: string | null; merge: boolean } {\n const { defaultContentType } = getContentTypeInfo(node)\n const hasRequestBody = Boolean(node.requestBody?.content?.[0]?.schema)\n // Bake the request body content type only when it is not the JSON default. The first declared type is\n // the default for an operation with several request types; the caller overrides it on `contentType`.\n const requestContentType = hasRequestBody && defaultContentType !== 'application/json' ? defaultContentType : null\n\n if (!requestContentType) return { literal: null, merge: false }\n\n // When the caller can also pick a response content type, a partial `{ response }` would replace the\n // baked request default through `...config`, so merge the caller's choice over it instead.\n const merge = getResponseContentTypeInfo(node).isMultipleContentTypes\n\n return {\n merge,\n literal: merge\n ? `contentType: { request: '${requestContentType}', ...(typeof contentType === 'string' ? { request: contentType } : contentType) }`\n : `contentType: { request: '${requestContentType}' }`,\n }\n}\n","import type { ast } from 'kubb/kit'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\n\n/**\n * Builds the `RequestResult` generic arguments for one operation: the per-status responses record\n * plus the per-call `ThrowOnError` flag. `SuccessOf` / `ErrorOf` split the record inside the\n * runtime, so this only names the record and threads `ThrowOnError`.\n *\n * @example\n * `buildRequestResultGenerics({ node, types }) // 'AddPetResponses, ThrowOnError'`\n */\nexport function buildRequestResultGenerics({ node, types }: { node: ast.OperationNode; types: OperationTypeNames }): string {\n return `${types.response.responses(node)}, ThrowOnError`\n}\n\n/**\n * Builds the full return type an operation's function signature uses: `Unwrappable<RequestResult>`\n * for the default `returnType: 'full'`, already a promise so no further wrapping is needed, a plain\n * `Promise<RequestResult>` for the internal `'plain'` shape, or a\n * `Promise` of the runtime's `UnwrappedResult` when `returnType: 'data'` narrows a resolved call\n * down to the bare success body.\n *\n * @example\n * `buildResultType({ node, types, returnType: 'data' }) // 'Promise<UnwrappedResult<AddPetResponses, ThrowOnError>>'`\n */\nexport function buildResultType({ node, types, returnType }: { node: ast.OperationNode; types: OperationTypeNames; returnType: ReturnTypeOption }): string {\n const generics = buildRequestResultGenerics({ node, types })\n if (returnType === 'data') return `Promise<UnwrappedResult<${generics}>>`\n if (returnType === 'plain') return `Promise<RequestResult<${generics}>>`\n return `Unwrappable<RequestResult<${generics}>>`\n}\n","import { hasRequestContentTypeChoice } from '@internals/shared'\nimport type { ast } from 'kubb/kit'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\nimport { buildRequestResultGenerics, buildResultType } from './generics.ts'\n\n/**\n * Builds the return statement of a generated operation function. With the default\n * `returnType: 'full'` the runtime call already resolves to `{ data, error, request, response }`.\n * The generated code casts that result to the operation's `RequestResult`, then wraps it with\n * `withUnwrap`, so the caller can `await` it directly or call `.unwrap()` for the bare success\n * body. With `returnType: 'data'` it instead routes the call through the runtime's `unwrapResult`,\n * which narrows the resolved value down to the bare success body the same way `RequestResult`\n * already does, using the plugin default when the call leaves `throwOnError` unset.\n * With `returnType: 'plain'` it returns the runtime call as is, cast to `RequestResult`, with no helper.\n *\n * Cast first, wrap second, for the `'full'` path. That order keeps `withUnwrap`'s generic inferred\n * as `RequestResult` instead of the runtime's own internal result type. Casting an `Unwrappable<A>`\n * straight to `Unwrappable<B>` does not work: the `.then` overload stays pinned to `A`, and `as`\n * rejects that two-generic swap even where `A` and `B` on their own would satisfy it.\n *\n * @example\n * `return withUnwrap(request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>)`\n * @example\n * `return unwrapResult(request({ method: 'POST', url: '/pet', ...config }), config.throwOnError ?? false) as Promise<UnwrappedResult<AddPetResponses, ThrowOnError>>`\n * @example\n * `return request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>`\n */\nexport function buildReturnStatement({\n node,\n types,\n callConfig,\n returnType,\n throwOnErrorDefault,\n}: {\n node: ast.OperationNode\n types: OperationTypeNames\n callConfig: string\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n}): string {\n // The options of a body offered in several media types are a union, so the body type cannot be inferred from `config`.\n // A `'plain'` client is the caller's own function, which takes no type argument.\n const request = returnType !== 'plain' && hasRequestContentTypeChoice(node) ? `request<${types.response.options(node)}['body']>` : 'request'\n if (returnType === 'data') {\n const resultType = buildResultType({ node, types, returnType })\n return `return unwrapResult(${request}(${callConfig}), config.throwOnError ?? ${throwOnErrorDefault}) as ${resultType}`\n }\n if (returnType === 'plain') {\n return `return ${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({ node, types })}>>`\n }\n return `return withUnwrap(${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({ node, types })}>>)`\n}\n","import type { ast } from 'kubb/kit'\nimport { getRequestGroupOptionality } from '@internals/shared'\nimport { createFunctionParameter, createFunctionParameters, functionPrinter } from '@kubb/plugin-ts'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\nimport { buildResultType } from './generics.ts'\n\nconst declarationPrinter = functionPrinter({ mode: 'declaration' })\n\n/**\n * The pieces of a generated operation function's grouped-options signature.\n */\nexport type GroupedOptionsSignature = {\n /**\n * The single function parameter: `options: Options<<Name>Options, ThrowOnError>`.\n */\n paramsSignature: string\n /**\n * The function return type: `Unwrappable<RequestResult<<Name>Responses, ThrowOnError>>`.\n */\n returnType: string\n /**\n * The function generics. One per-call `ThrowOnError` flag, defaulting to the plugin setting.\n */\n generics: Array<string>\n}\n\n/**\n * Builds the grouped-options signature for one operation: a single `options` object whose `TData`\n * is the `<Name>Options` type, and a `RequestResult` return type keyed to the per-status responses\n * record. There are no positional arguments.\n *\n * The generated file imports `<Name>Options` and `<Name>Responses` and uses them directly, so no\n * per-operation input type has to be emitted. Both names come from `types`, which is `plugin-ts` or\n * `plugin-zod`'s inferred types (see `resolveOperationTypes`).\n */\nexport function buildGroupedOptionsSignature({\n node,\n types,\n returnType,\n throwOnErrorDefault,\n}: {\n node: ast.OperationNode\n types: OperationTypeNames\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n}): GroupedOptionsSignature {\n const optionsName = types.response.options(node)\n const { isOptional } = getRequestGroupOptionality(node)\n\n const paramsSignature =\n declarationPrinter.print(\n createFunctionParameters({\n params: [createFunctionParameter({ name: 'options', type: `Options<${optionsName}, ThrowOnError>`, ...(isOptional ? { default: '{}' } : {}) })],\n }),\n ) ?? ''\n\n return {\n paramsSignature,\n returnType: buildResultType({ node, types, returnType }),\n generics: [`ThrowOnError extends boolean = ${throwOnErrorDefault}`],\n }\n}\n","import { isValidVarName } from '@internals/utils'\nimport { ast } from 'kubb/kit'\n\ntype StyledLocation = 'path' | 'query' | 'header' | 'cookie'\n\n/**\n * Renders a parameter name as an object-literal key, quoted when it is not a bare identifier. Every\n * location keeps the spec name: the runtime looks path styles up by the `{name}` placeholder in the\n * URL, and the other locations by the key it serializes.\n */\nfunction toKey(name: string): string {\n return isValidVarName(name) ? name : JSON.stringify(name)\n}\n\n/**\n * Serializes one parameter's metadata into a `{ style, explode, allowReserved, contentType }`\n * literal, or `null` when the parameter carries none. Path and query carry the serialization\n * `style`; header and cookie use a fixed style (`simple` and `form`), so only `explode` is emitted\n * for them. `allowReserved` only applies to query parameters, and `contentType` to every location\n * except path.\n */\nfunction serializeParameter(parameter: ast.ParameterNode): string | null {\n const parts: Array<string> = []\n if ((parameter.in === 'path' || parameter.in === 'query') && parameter.style) parts.push(`style: '${parameter.style}'`)\n if (parameter.explode !== undefined) parts.push(`explode: ${parameter.explode}`)\n if (parameter.in === 'query' && parameter.allowReserved !== undefined) parts.push(`allowReserved: ${parameter.allowReserved}`)\n if (parameter.in !== 'path' && parameter.contentType) parts.push(`contentType: '${parameter.contentType}'`)\n return parts.length > 0 ? `{ ${parts.join(', ')} }` : null\n}\n\n/**\n * Serializes the `encoding` of the request body's default content type into a `{ property: { ... } }`\n * literal, or `null` when it carries none. Only an operation with a single request content type\n * emits it, because the runtime applies `styles.body` to whichever type the caller selects.\n */\nfunction serializeBodyEncoding(node: ast.HttpOperationNode): string | null {\n const content = node.requestBody?.content\n const entries = Object.entries(content?.length === 1 ? (content[0]?.encoding ?? {}) : {}).map(\n ([property, { contentType, style, explode, allowReserved }]) => {\n const parts = [\n style && `style: ${JSON.stringify(style)}`,\n explode !== undefined && `explode: ${explode}`,\n allowReserved !== undefined && `allowReserved: ${allowReserved}`,\n contentType && `contentType: ${JSON.stringify(contentType)}`,\n ].filter(Boolean)\n return `${isValidVarName(property) ? property : JSON.stringify(property)}: { ${parts.join(', ')} }`\n },\n )\n\n return entries.length > 0 ? `body: { ${entries.join(', ')} }` : null\n}\n\n/**\n * Builds the per-operation `styles` literal from the operation's parameters, grouped by location.\n * Entries are keyed by the spec name of the parameter.\n * Only parameters whose source defines `style`, `explode`, `allowReserved`, or `contentType` are\n * emitted, so calls without serialization metadata keep the runtime defaults and existing output\n * is unchanged. A form request body adds a `body` group keyed by property name from its `encoding`.\n * Returns `null` when nothing carries metadata.\n *\n * @example\n * ```ts\n * // a path param with { style: 'matrix', explode: true } and a query param with { explode: false }\n * buildStyles({ node }) // \"{ path: { id: { style: 'matrix', explode: true } }, query: { tags: { explode: false } } }\"\n * ```\n */\nexport function buildStyles({ node }: { node: ast.OperationNode }): string | null {\n if (!ast.isHttpOperationNode(node)) return null\n\n const groups: Record<StyledLocation, Array<string>> = { path: [], query: [], header: [], cookie: [] }\n\n for (const parameter of node.parameters) {\n const literal = serializeParameter(parameter)\n if (!literal) continue\n groups[parameter.in].push(`${toKey(parameter.name)}: ${literal}`)\n }\n\n const entries = [\n ...(Object.keys(groups) as Array<StyledLocation>)\n .filter((location) => groups[location].length > 0)\n .map((location) => `${location}: { ${groups[location].join(', ')} }`),\n serializeBodyEncoding(node),\n ].filter(Boolean)\n\n return entries.length > 0 ? `{ ${entries.join(', ')} }` : null\n}\n","import { buildOperationComments, getResponseType, isEventStream } from '@internals/shared'\nimport { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport { File, Function } from 'kubb/jsx'\nimport type { KubbReactNode } from 'kubb/jsx'\nimport { buildContentType } from '../builders/contentType.ts'\nimport { buildReturnStatement } from '../builders/returnStatement.ts'\nimport { type Auth, buildSecurityMetadata } from '../builders/security.ts'\nimport { buildGroupedOptionsSignature } from '../builders/signature.ts'\nimport { buildStyles } from '../builders/styles.ts'\nimport { buildValidatorHooks, buildValidatorLiteral } from '../builders/validator.ts'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption, ValidatorOptions } from '../types.ts'\n\ntype Props = {\n /**\n * The generated function name.\n */\n name: string\n /**\n * The operation being generated.\n */\n node: ast.OperationNode\n /**\n * The operation type names the signature references, from `plugin-ts` or `plugin-zod`'s inferred\n * types.\n */\n types: OperationTypeNames\n /**\n * Resolver for the zod schema names the validators reference, when `validator` is on.\n */\n zodResolver?: ResolverZod | null\n /**\n * The active validator option, driving the validator-hook wiring.\n */\n validator?: ValidatorOptions\n /**\n * Shape of the value the generated function resolves to.\n */\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n /**\n * Per-operation security, resolved from the spec into inline `Auth` objects and serialized onto the\n * call config's `security` field for the runtime `auth` resolver to consume.\n */\n security?: Array<Auth>\n}\n\n/**\n * Renders one client operation: the grouped `<Name>Request` type and the function that forwards a\n * single `options` object to the resolved client and returns the `Unwrappable<RequestResult>`. The\n * type, signature, and call config are built with the AST factory, and only the jsx-renderer emits\n * the source.\n */\nexport function Operation({ name, node, types, zodResolver, validator, returnType, throwOnErrorDefault, security }: Props): KubbReactNode {\n if (!ast.isHttpOperationNode(node)) return null\n\n const signature = buildGroupedOptionsSignature({ node, types, returnType, throwOnErrorDefault })\n const validators = buildValidatorHooks({ node, validator, zodResolver })\n const securityLiteral = buildSecurityMetadata({ security })\n const stylesLiteral = buildStyles({ node })\n\n const { literal: contentTypeLiteral, merge: mergeContentType } = buildContentType({ node })\n\n const eventStream = isEventStream(node)\n const responseType = getResponseType(node)\n const responseTypeLiteral = responseType ? `responseType: '${responseType}'` : null\n\n const validatorLiteral = buildValidatorLiteral(validators, ['request', 'path', 'query', 'headers', 'response', 'error'])\n\n const callConfig = `{ ${[\n `method: '${node.method.toUpperCase()}'`,\n `url: '${node.path}'`,\n securityLiteral ? `security: ${securityLiteral}` : null,\n stylesLiteral ? `styles: ${stylesLiteral}` : null,\n validatorLiteral,\n contentTypeLiteral,\n responseTypeLiteral,\n '...config',\n `throwOnError: config.throwOnError ?? ${throwOnErrorDefault}`,\n ]\n .filter(Boolean)\n .join(', ')} }`\n\n const eventType = `SuccessOf<${types.response.responses(node)}>`\n const functionReturnType = eventStream ? `Promise<EventStreamResult<${eventType}>>` : signature.returnType\n const returnStatement = eventStream\n ? `return toEventStream<${eventType}>(request(${callConfig}))`\n : buildReturnStatement({ node, types, callConfig, returnType, throwOnErrorDefault })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n generics={signature.generics}\n params={signature.paramsSignature}\n returnType={functionReturnType}\n JSDoc={{ comments: buildOperationComments(node, { link: 'urlPath', linkPosition: 'beforeDeprecated', splitLines: true }) }}\n >\n {mergeContentType ? 'const { client: request = client, contentType, ...config } = options' : 'const { client: request = client, ...config } = options'}\n <br />\n {returnStatement}\n </Function>\n </File.Source>\n )\n}\n","import { type ast, Diagnostics, type Generator, type Group, type Output } from 'kubb/kit'\nimport { pluginTsName, type ResolverTs } from '@kubb/plugin-ts'\nimport { pluginZodName, type ResolverZod } from '@kubb/plugin-zod'\nimport type { ContractClientFactory } from './types.ts'\n\ntype GeneratorDriver = Parameters<NonNullable<Generator<ContractClientFactory>['operations']>>[1]['driver']\n\n/**\n * The two per-operation type names a generated client references: the grouped input and the\n * per-status responses record its `RequestResult` is keyed on.\n */\nexport type OperationTypeNames = {\n response: {\n /**\n * Resolves the name of the operation's grouped `{ body, path, query, headers }` input type.\n */\n options(node: ast.OperationNode): string\n /**\n * Resolves the name of the operation's per-status responses record type.\n */\n responses(node: ast.OperationNode): string\n }\n}\n\n/**\n * Where a generated client sources its operation types, plus the resolver and output the file\n * declaring them is resolved with.\n */\nexport type OperationTypeSource = OperationTypeNames & {\n /**\n * `plugin-ts` shaped resolver of the plugin supplying the names, also used to resolve the file they are exported from.\n */\n resolver: ResolverTs\n /**\n * The supplying plugin's own `output`, when it configured one.\n */\n output: Output | undefined\n /**\n * The supplying plugin's own `group`, when it configured one.\n */\n group: Group | undefined\n}\n\n/**\n * A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`\n * exports next to each schema, so code written against `plugin-ts` names picks up the zod types.\n */\nfunction toZodTypeResolver(resolver: ResolverZod): ResolverTs {\n const type = (name: string) => resolver.schema.type(name)\n\n return {\n ...resolver,\n // A class method, so a spread drops it, and it reads private fields, so it must run on `resolver`.\n file: resolver.file.bind(resolver),\n param: {\n name: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.name(node, p)),\n path: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.path(node, p)),\n query: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.query(node, p)),\n headers: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.headers(node, p)),\n },\n response: {\n body: (node: ast.OperationNode) => type(resolver.response.body(node)),\n status: (node: ast.OperationNode, statusCode: ast.StatusCode) => type(resolver.response.status(node, statusCode)),\n response: (node: ast.OperationNode) => type(resolver.response.response(node)),\n responses: (node: ast.OperationNode) => type(resolver.response.responses(node)),\n options: (node: ast.OperationNode) => resolver.response.options(node),\n },\n } as unknown as ResolverTs\n}\n\n/**\n * Picks the plugin generated clients, query hooks, and MCP handlers take their operation types from.\n *\n * `pluginZod({ inferred: 'codec' })` wins, so a codec param takes its domain value. Otherwise `plugin-ts`\n * wins when it is in the pipeline, and without it any `pluginZod({ inferred })`. Throws\n * `KUBB_MISSING_DEPENDENCY` for `pluginName` when neither is available.\n *\n * @example\n * ```ts\n * const types = resolveOperationTypes(ctx.driver, ctx.plugin.name)\n * types.response.options(node) // 'GetPetByIdOptions', or 'GetPetByIdOptionsSchemaType' from zod\n * ```\n */\nexport function resolveOperationTypes(driver: GeneratorDriver, pluginName: string): OperationTypeSource {\n const pluginTs = driver.getPlugin(pluginTsName)\n const pluginZod = driver.getPlugin(pluginZodName)\n\n if (pluginTs && pluginZod?.options?.inferred !== 'codec') {\n const resolver = driver.getResolver(pluginTsName)\n return { response: resolver.response, resolver, output: pluginTs.options?.output, group: pluginTs.options?.group ?? undefined }\n }\n\n if (!pluginZod?.options?.inferred) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: `Plugin \"${pluginName}\" has no source for operation types.`,\n help: `Add \\`pluginTs()\\` before \"${pluginName}\", or add \\`pluginZod({ inferred: true })\\`.`,\n location: { kind: 'config' },\n plugin: pluginName,\n })\n }\n\n const resolver = toZodTypeResolver(driver.getResolver(pluginZodName))\n return { response: resolver.response, resolver, output: pluginZod.options.output, group: pluginZod.options.group ?? undefined }\n}\n","import path from 'node:path'\nimport { isEventStream, operationFileEntry, resolveDependencyOperationFile } from '@internals/shared'\nimport { ast, defineGenerator } from 'kubb/kit'\nimport type { Generator } from 'kubb/kit'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, jsxRenderer } from 'kubb/jsx'\nimport { isValidatorEnabled } from '../builders/validatorOptions.ts'\nimport { getOperationSecurity, type SecurityDocument } from '../builders/security.ts'\nimport { buildValidatorHooks } from '../builders/validator.ts'\nimport { Operation } from '../components/Operation.tsx'\nimport { resolveOperationTypes } from '../resolveOperationTypes.ts'\nimport type { ContractClientFactory } from '../types.ts'\n\n/**\n * Builds the built-in per-operation generator shared by the client plugins (`@kubb/plugin-fetch`,\n * `@kubb/plugin-axios`). Emits one async function per OpenAPI operation using the shared\n * `Operation` component: a grouped `<Name>Request` type and a function that forwards a single\n * `options` object to the bundled `client` and returns the `Unwrappable<RequestResult>`. Only the\n * generator `name` differs between plugins. Every other resolution, import, and rendering step is\n * identical.\n */\nexport function createClientGenerator<TFactory extends ContractClientFactory>(\n name: string,\n resolveClientPath?: (options: TFactory['resolvedOptions'], root: string) => string,\n): Generator<TFactory> {\n return defineGenerator<TFactory>({\n name,\n renderer: jsxRenderer,\n operation(node, ctx) {\n if (!ast.isHttpOperationNode(node)) return null\n\n const { config, driver, resolver, root } = ctx\n const { output, validator, returnType, throwOnErrorDefault, group } = ctx.options\n\n const types = resolveOperationTypes(driver, ctx.plugin.name)\n\n const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(pluginZodName) : null\n const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null\n\n const importedTypeNames = [types.response.options(node), types.response.responses(node)]\n\n const validatorHooks = buildValidatorHooks({ node, validator, zodResolver })\n const importedZodNames = validatorHooks.importedZodNames\n\n const meta = {\n name: resolver.name(node.operationId),\n file: resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\n fileTypes: resolveDependencyOperationFile({\n cache: ctx.cache,\n node,\n resolver: types.resolver,\n root,\n output: types.output ?? output,\n group: types.group,\n }),\n fileZod:\n zodResolver && pluginZod?.options\n ? zodResolver.file({\n ...operationFileEntry(node, node.operationId),\n root,\n output: pluginZod.options.output ?? output,\n group: pluginZod.options?.group ?? undefined,\n })\n : null,\n } as const\n\n const security = getOperationSecurity({\n document: ctx.adapter.document as SecurityDocument | null | undefined,\n method: node.method,\n path: node.path,\n })\n\n // A custom client module is emitted verbatim, so `importPath` is used exactly as configured.\n // The default `.kubb/client.ts` is a file path and is made relative to the operation file.\n const customClientPath = resolveClientPath?.(ctx.options, root)\n const clientPath = customClientPath ?? path.resolve(root, '.kubb/client.ts')\n const clientRoot = customClientPath === undefined ? meta.file.path : undefined\n // The headers validator helper ships in `.kubb/standardSchema.ts`; a custom client module exports it\n // alongside its other runtime helpers.\n const standardSchemaPath = customClientPath ?? path.resolve(root, '.kubb/standardSchema.ts')\n const eventStream = isEventStream(node)\n\n const clientValueImports = (() => {\n if (eventStream) return ['client', 'toEventStream']\n if (returnType === 'plain') return ['client']\n if (returnType === 'data') return ['client', 'unwrapResult']\n return ['client', 'withUnwrap']\n })()\n\n const clientTypeImports = (() => {\n if (eventStream) return ['Options', 'EventStreamResult', 'SuccessOf']\n if (returnType === 'plain') return ['Options', 'RequestResult']\n if (returnType === 'data') return ['Options', 'UnwrappedResult']\n return ['Options', 'Unwrappable', 'RequestResult']\n })()\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.default.banner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.default.footer(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n <File.Import name={clientValueImports} root={clientRoot} path={clientPath} />\n <File.Import name={clientTypeImports} root={clientRoot} path={clientPath} isTypeOnly />\n\n {meta.fileTypes && importedTypeNames.length > 0 && (\n <File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTypes.path} isTypeOnly />\n )}\n\n {meta.fileZod && importedZodNames.length > 0 && <File.Import name={importedZodNames} root={meta.file.path} path={meta.fileZod.path} />}\n {validatorHooks.headers && <File.Import name={['toHeadersStandardSchema']} root={clientRoot} path={standardSchemaPath} />}\n\n <Operation\n name={meta.name}\n node={node}\n types={types}\n zodResolver={zodResolver}\n validator={validator}\n returnType={returnType}\n throwOnErrorDefault={throwOnErrorDefault}\n security={security}\n />\n </File>\n )\n },\n })\n}\n","import { macroSimplifyUnion } from 'kubb/kit'\nimport type { ast } from 'kubb/kit'\n\n/**\n * Macros the client plugins apply by default, ahead of any user macros. `macroSimplifyUnion`\n * drops union members a broader scalar already covers, keeping the generated response and error\n * unions tidy. A plugin wires them with `ctx.setMacros([...defaultMacros, ...userMacros])`.\n */\nexport const defaultMacros: ReadonlyArray<ast.Macro> = [macroSimplifyUnion]\n","import { resolveOperationName } from '@internals/shared'\nimport { camelCase, ensureValidVarName, pascalCase } from '@internals/utils'\nimport { createResolver } from 'kubb/kit'\nimport type { PluginContractClient } from './types.ts'\n\n/**\n * Default resolver shared by the client plugins. Functions use safe camelCase identifiers and\n * files inherit the built-in casing; classes and tag groups use PascalCase.\n *\n * @example\n * ```ts\n * resolverClient.name('show pet by id') // 'showPetById'\n * resolverClient.groupName('pet') // 'PetClient'\n * ```\n */\nexport const resolverClient = createResolver<PluginContractClient>({\n pluginName: 'plugin-contract-client',\n name: resolveOperationName,\n className(name) {\n return ensureValidVarName(pascalCase(name))\n },\n groupName(name) {\n return ensureValidVarName(pascalCase(`${name} Client`))\n },\n propertyName(name) {\n return ensureValidVarName(camelCase(name))\n },\n})\n","import { createClientGenerator } from '@internals/client'\nimport type { PluginClient } from '../types.ts'\n\n/**\n * Built-in operation generator for `@kubb/plugin-client`. Emits one async function per OpenAPI\n * operation using the shared `Operation` component: a grouped `<Name>Request` type and a function\n * that forwards a single `options` object to the user-provided client module and returns the `RequestResult`.\n */\nexport const clientGenerator = createClientGenerator<PluginClient>('client', (options) => options.importPath)\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 { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { defaultMacros, isValidatorEnabled, resolverClient } from '@internals/client'\nimport type { PluginClient, ResolverClient } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-client`.\n */\nexport const pluginClientName = 'plugin-client' satisfies PluginClient['name']\n\n/**\n * Generates typed operations that call a client module owned by your application.\n * The module at `importPath` must export the runtime helpers and types used by generated operations.\n * Kubb does not copy or inject a transport implementation.\n *\n * @example\n * ```ts\n * pluginClient({ importPath: '../api/client' })\n * ```\n */\nexport const pluginClient = defineExtension<PluginClient>({\n kind: 'plugin',\n meta: { name: pluginClientName, version, compatibility },\n dependencies: (options) => ({ [pluginTsName]: { optional: true }, [pluginZodName]: { optional: !isValidatorEnabled(options.validator) } }),\n setup(options) {\n const {\n output = { path: 'clients', barrel: { type: 'named' } },\n exclude = [],\n include,\n override = [],\n importPath,\n throwOnErrorDefault = true,\n validator = false,\n group,\n resolver: userResolver,\n } = options\n\n const resolver = userResolver ? Resolver.merge<ResolverClient>(resolverClient, userResolver) : resolverClient\n\n setResolver(resolver)\n setMacros([...defaultMacros, ...(options.macros ?? [])])\n addGenerator(clientGenerator)\n\n return {\n output,\n exclude,\n include,\n override,\n group: createGroupConfig(group),\n importPath,\n baseURL: undefined,\n throwOnErrorDefault,\n validator,\n returnType: 'plain',\n sdk: undefined,\n resolver,\n }\n },\n})\n\nexport default pluginClient\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAAgB,mBAAmB,MAAyB,MAAc,UAAyC,OAA2B;CAC5I,OAAO;EACL;EACA;EACA,KAAK,KAAK,KAAK,MAAM;EACrB,MAAM,KAAK;CACb;AACF;;;;;;;;;;;;AAaA,SAAgB,+BAA+B,SAO9B;CACf,MAAM,EAAE,OAAO,MAAM,UAAU,MAAM,QAAQ,UAAU;CAEvD,OAAO,MAAM,WAAW,GAAG,SAAS,WAAW,uBAC7C,SAAS,KAAK;EAAE,GAAG,mBAAmB,MAAM,KAAK,WAAW;EAAG;EAAM;EAAQ,OAAO,SAAS,KAAA;CAAU,CAAC,CAC1G;AACF;AA8DA,SAAS,iBAAiB,MAAyB,MAA2C;CAC5F,IAAI,CAAC,MACH,OAAO;CAGT,IAA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AmB,WAAW,GAAG,KAAK,QAAQ,CAAC;CACxD;CACA,aAAa,MAAM;EACjB,OAAO,mBAAmB,UAAU,IAAI,CAAC;CAC3C;AACF,CAAC;;;;;;;;ACnBD,MAAa,kBAAkB,sBAAoC,WAAW,YAAY,QAAQ,UAAU;;;;;;ACK5G,MAAa,mBAAmB;;;;;;;;;;;AAYhC,MAAa,gBAAA,GAAeC,SAAAA,gBAAAA,CAA8B;CACxD,MAAM;CACN,MAAM;EAAE,MAAM;EAAkB;EAAS;CAAc;CACvD,eAAe,aAAa;GAAGC,gBAAAA,eAAe,EAAE,UAAU,KAAK;GAAIC,iBAAAA,gBAAgB,EAAE,UAAU,CAAC,mBAAmB,QAAQ,SAAS,EAAE;CAAE;CACxI,MAAM,SAAS;EACb,MAAM,EACJ,SAAS;GAAE,MAAM;GAAW,QAAQ,EAAE,MAAM,QAAQ;EAAE,GACtD,UAAU,CAAC,GACX,SACA,WAAW,CAAC,GACZ,YACA,sBAAsB,MACtB,YAAY,OACZ,OACA,UAAU,iBACR;EAEJ,MAAM,WAAW,eAAeC,SAAAA,SAAS,MAAsB,gBAAgB,YAAY,IAAI;EAE/F,CAAA,GAAA,SAAA,YAAA,CAAY,QAAQ;EACpB,CAAA,GAAA,SAAA,UAAA,CAAU,CAAC,GAAG,eAAe,GAAI,QAAQ,UAAU,CAAC,CAAE,CAAC;EACvD,CAAA,GAAA,SAAA,aAAA,CAAa,eAAe;EAE5B,OAAO;GACL;GACA;GACA;GACA;GACA,OAAO,kBAAkB,KAAK;GAC9B;GACA,SAAS,KAAA;GACT;GACA;GACA,YAAY;GACZ,KAAK,KAAA;GACL;EACF;CACF;AACF,CAAC"}
package/dist/index.js CHANGED
@@ -183,6 +183,16 @@ function getOperationParameters(node) {
183
183
  operationParameterGroupsByNode.set(node, groups);
184
184
  return groups;
185
185
  }
186
+ /**
187
+ * Builds the combined `{ body, path, query, headers }` options object schema for an operation,
188
+ * referencing the already-resolved body and grouped param names. Shared by `@kubb/plugin-ts`'s
189
+ * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same
190
+ * shape from the same inputs. `primitive: 'object'` is a no-op for the TS printer and tells the Zod
191
+ * printer to emit `z.object(…)` rather than a record.
192
+ */
193
+ function hasRequestContentTypeChoice(node) {
194
+ return (node.requestBody?.content ?? []).filter((entry) => entry.schema).length > 1;
195
+ }
186
196
  function getStatusCodeNumber(statusCode) {
187
197
  const code = Number(statusCode);
188
198
  return Number.isNaN(code) ? null : code;
@@ -259,6 +269,7 @@ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
259
269
  const reservedWords = /* @__PURE__ */ new Set([
260
270
  "abstract",
261
271
  "arguments",
272
+ "await",
262
273
  "boolean",
263
274
  "break",
264
275
  "byte",
@@ -390,6 +401,11 @@ function isIdentifier(name) {
390
401
  return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
391
402
  }
392
403
  //#endregion
404
+ //#region ../../internals/shared/src/resolver.ts
405
+ function resolveOperationName(name) {
406
+ return ensureValidVarName(camelCase(name));
407
+ }
408
+ //#endregion
393
409
  //#region ../../internals/shared/src/group.ts
394
410
  /**
395
411
  * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the
@@ -428,7 +444,7 @@ var compatibility = {
428
444
  };
429
445
  //#endregion
430
446
  //#region package.json
431
- var version = "5.8.0-canary.20261025T201031";
447
+ var version = "5.9.0-canary.20261025T213930";
432
448
  //#endregion
433
449
  //#region ../../internals/client/src/builders/validatorOptions.ts
434
450
  /**
@@ -666,16 +682,17 @@ function buildResultType({ node, types, returnType }) {
666
682
  * `return request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>`
667
683
  */
668
684
  function buildReturnStatement({ node, types, callConfig, returnType, throwOnErrorDefault }) {
669
- if (returnType === "data") return `return unwrapResult(request(${callConfig}), config.throwOnError ?? ${throwOnErrorDefault}) as ${buildResultType({
685
+ const request = returnType !== "plain" && hasRequestContentTypeChoice(node) ? `request<${types.response.options(node)}['body']>` : "request";
686
+ if (returnType === "data") return `return unwrapResult(${request}(${callConfig}), config.throwOnError ?? ${throwOnErrorDefault}) as ${buildResultType({
670
687
  node,
671
688
  types,
672
689
  returnType
673
690
  })}`;
674
- if (returnType === "plain") return `return request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
691
+ if (returnType === "plain") return `return ${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
675
692
  node,
676
693
  types
677
694
  })}>>`;
678
- return `return withUnwrap(request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
695
+ return `return withUnwrap(${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
679
696
  node,
680
697
  types
681
698
  })}>>)`;
@@ -1082,8 +1099,8 @@ const defaultMacros = [macroSimplifyUnion];
1082
1099
  //#endregion
1083
1100
  //#region ../../internals/client/src/resolver.ts
1084
1101
  /**
1085
- * Default resolver shared by the client plugins. Functions and files inherit the built-in camelCase
1086
- * `name` and `file`; classes and tag groups use PascalCase.
1102
+ * Default resolver shared by the client plugins. Functions use safe camelCase identifiers and
1103
+ * files inherit the built-in casing; classes and tag groups use PascalCase.
1087
1104
  *
1088
1105
  * @example
1089
1106
  * ```ts
@@ -1093,6 +1110,7 @@ const defaultMacros = [macroSimplifyUnion];
1093
1110
  */
1094
1111
  const resolverClient = createResolver({
1095
1112
  pluginName: "plugin-contract-client",
1113
+ name: resolveOperationName,
1096
1114
  className(name) {
1097
1115
  return ensureValidVarName(pascalCase(name));
1098
1116
  },
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../internals/shared/src/operation.ts","../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/shared/src/group.ts","../kubb-extension.json","../package.json","../../../internals/client/src/builders/validatorOptions.ts","../../../internals/client/src/builders/security.ts","../../../internals/client/src/builders/validator.ts","../../../internals/client/src/builders/contentType.ts","../../../internals/client/src/builders/generics.ts","../../../internals/client/src/builders/returnStatement.ts","../../../internals/client/src/builders/signature.ts","../../../internals/client/src/builders/styles.ts","../../../internals/client/src/components/Operation.tsx","../../../internals/client/src/resolveOperationTypes.ts","../../../internals/client/src/generators/clientGenerator.tsx","../../../internals/client/src/macros.ts","../../../internals/client/src/resolver.ts","../src/generators/clientGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import { ast, type Group, type NodeCache, type Output, type Resolver, type ResolverFileParams, Url } from 'kubb/kit'\n\n/**\n * Builds the `ResolverFileParams` every operation generator passes to\n * `resolver.file`: a file named `name`, tagged by the operation's first\n * tag (or `'default'`), at the operation's path. Centralizes the entry object\n * that was repeated at dozens of call sites across the client and query plugins.\n *\n * @example\n * ```ts\n * resolver.file(operationFileEntry(node, node.operationId), { root, output, group })\n * ```\n */\nexport function operationFileEntry(node: ast.OperationNode, name: string, extname: ResolverFileParams['extname'] = '.ts'): ResolverFileParams {\n return {\n name,\n extname,\n tag: node.tags[0] ?? 'default',\n path: node.path,\n }\n}\n\n/**\n * Resolves a dependency plugin's generated file for `node.operationId`, cached in `cache` (the\n * current node's `ctx.cache`) under the resolver's own plugin name. Several dependents reading the\n * same dependency for the same operation in one pass (a query plugin's several hook generators, the\n * MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.\n *\n * @example Cache `plugin-ts`'s file for the current operation\n * ```ts\n * const fileTs = resolveDependencyOperationFile({ cache: ctx.cache, node, resolver: tsResolver, root, output })\n * ```\n */\nexport function resolveDependencyOperationFile(options: {\n cache: NodeCache\n node: ast.OperationNode\n resolver: Pick<Resolver, 'file' | 'pluginName'>\n root: string\n output: Output\n group?: Group | null\n}): ast.FileNode {\n const { cache, node, resolver, root, output, group } = options\n\n return cache.ensureItem(`${resolver.pluginName}:operationFile`, () =>\n resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\n )\n}\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type OperationCommentLink = 'pathTemplate' | 'urlPath' | false | ((node: ast.OperationNode) => string | undefined)\n\nexport type BuildOperationCommentsOptions = {\n link?: OperationCommentLink\n linkPosition?: 'beforeDeprecated' | 'afterDeprecated'\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<ast.ParameterNode['in'], Array<ast.ParameterNode>>\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\nfunction getOperationLink(node: ast.OperationNode, link: OperationCommentLink): string | null {\n if (!link) {\n return null\n }\n\n if (typeof link === 'function') {\n return link(node) ?? null\n }\n\n return node.path ? `{@link ${Url.toPath(node.path)}}` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(node.requestBody?.content?.map((e) => e.contentType) ?? [])\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(getPrimarySuccessResponse(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\nexport type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n\n/**\n * Reads the single base content type of an operation's primary success response, lowercased and\n * stripped of any `; charset=...` suffix. Returns `undefined` when the response declares zero or\n * more than one content type, since neither case has a single type to act on.\n */\nfunction getPrimarySuccessContentType(node: ast.OperationNode): string | undefined {\n const contentTypes = getPrimarySuccessResponse(node)?.content?.map((entry) => entry.contentType) ?? []\n if (contentTypes.length !== 1) return undefined\n return contentTypes[0]!.split(';')[0]!.trim().toLowerCase()\n}\n\n/**\n * Whether an operation streams its primary success response as Server-Sent Events\n * (`text/event-stream`). The client generator uses this to return a typed event stream instead of a\n * one-shot `RequestResult`.\n */\nexport function isEventStream(node: ast.OperationNode): boolean {\n return getPrimarySuccessContentType(node) === 'text/event-stream'\n}\n\n/**\n * Derives the default `responseType` for an operation from its primary success response.\n *\n * Returns a value only when that response declares a single non-JSON content type. `text/event-stream`\n * and other binary types (`application/octet-stream`, `application/pdf`, `image/*`, `audio/*`,\n * `video/*`) map to a stream or `'blob'`, and other `text/*` maps to `'text'`. Otherwise `undefined`,\n * leaving the runtime client's `Content-Type` auto-detection in charge.\n */\nexport function getResponseType(node: ast.OperationNode): ResponseType | undefined {\n const baseType = getPrimarySuccessContentType(node)\n if (!baseType) return undefined\n\n if (baseType === 'application/json' || baseType.endsWith('+json') || baseType === 'text/json') return undefined\n if (baseType === 'text/event-stream') return 'stream'\n if (baseType.startsWith('text/')) return 'text'\n if (baseType === 'application/octet-stream' || baseType === 'application/pdf' || /^(image|audio|video)\\//.test(baseType)) return 'blob'\n return undefined\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n// The request groups come from the grouped params, so `config` drops the data-shape keys to stay\n// assignable to `Options`, which omits them from `RequestConfig`.\nconst requestConfigBaseType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\n\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n\n // Only the ambiguous side is offered: a single-type side has nothing to pick, so it stays baked in\n // the generated call.\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n return members.length ? `${requestConfigBaseType} & { contentType?: { ${members.join('; ')} } }` : requestConfigBaseType\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...). Unlike {@link buildRequestConfigType}, it never adds a\n * `contentType?:` member: query hooks wrap GET operations, which carry no request body to select a\n * content type for.\n */\nexport function buildClientOptionType(): string {\n return requestConfigBaseType\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n}\n\n/**\n * Which of the grouped request options an operation carries.\n */\nexport function getRequestGroups(node: ast.OperationNode): RequestGroups {\n const { path, query, header } = getOperationParameters(node)\n return {\n path: path.length > 0,\n query: query.length > 0,\n body: Boolean(node.requestBody?.content?.[0]?.schema),\n headers: header.length > 0,\n }\n}\n\nexport type RequestGroupOptionality = {\n groups: RequestGroups\n hasRequiredPath: boolean\n hasRequiredQuery: boolean\n hasRequiredHeader: boolean\n /**\n * Whether the grouped request parameter can default to `{}`. True only when no group carries a\n * required member, so every member is safe to omit.\n */\n isOptional: boolean\n}\n\n/**\n * Resolves which grouped request options an operation carries together with whether each group\n * holds a required member. The grouped parameter stays optional only when nothing inside it is\n * required, matching the generated `RequestConfig` type.\n */\nexport function getRequestGroupOptionality(node: ast.OperationNode): RequestGroupOptionality {\n const groups = getRequestGroups(node)\n const { path, query, header } = getOperationParameters(node)\n const hasRequiredPath = path.some((param) => param.required)\n const hasRequiredQuery = query.some((param) => param.required)\n const hasRequiredHeader = header.some((param) => param.required)\n\n return {\n groups,\n hasRequiredPath,\n hasRequiredQuery,\n hasRequiredHeader,\n isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !groups.body,\n }\n}\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: RequestGroups } {\n const { isConfigurable = true } = options\n const { groups, isOptional } = getRequestGroupOptionality(node)\n\n const names = (['path', 'query', 'body', 'headers'] as const).filter((key) => groups[key])\n\n const firstParam = names.length > 0 ? `{ ${names.join(', ')} }: ${resolver.response.options(node)}${isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { link = 'pathTemplate', linkPosition = 'afterDeprecated', splitLines = false } = options\n const linkComment = getOperationLink(node, link)\n const comments =\n linkPosition === 'beforeDeprecated'\n ? [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, linkComment, node.deprecated && '@deprecated']\n : [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, node.deprecated && '@deprecated', linkComment]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\nconst operationParameterGroupsByNode = new WeakMap<ast.OperationNode, OperationParameterGroups>()\n\n/**\n * Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each\n * group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance\n * (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the\n * same parameters once per plugin.\n */\nexport function getOperationParameters(node: ast.OperationNode): OperationParameterGroups {\n const cached = operationParameterGroupsByNode.get(node)\n if (cached) return cached\n\n // A malformed spec can declare the same name twice within one location. Both would resolve to the\n // same output property, so emitting both would yield an object type with a duplicate member,\n // which TypeScript rejects. Keep the first.\n const group = (location: ast.ParameterNode['in']) => {\n const seen = new Set<string>()\n\n return node.parameters.filter((param) => {\n if (param.in !== location || seen.has(param.name)) return false\n seen.add(param.name)\n return true\n })\n }\n\n const groups: OperationParameterGroups = { path: group('path'), query: group('query'), header: group('header'), cookie: group('cookie') }\n\n operationParameterGroupsByNode.set(node, groups)\n return groups\n}\n\n/**\n * Builds the combined `{ body, path, query, headers }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same\n * shape from the same inputs. `primitive: 'object'` is a no-op for the TS printer and tells the Zod\n * printer to emit `z.object(…)` rather than a record.\n */\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver): ast.SchemaNode {\n const { path, query, header } = getOperationParameters(node)\n const hasBody = Boolean(node.requestBody?.content?.[0]?.schema)\n const createNever = () => ast.factory.createSchema({ type: 'never', primitive: undefined, optional: true })\n const groups = [\n { name: 'path', params: path, resolve: resolver.param.path },\n { name: 'query', params: query, resolve: resolver.param.query },\n { name: 'headers', params: header, resolve: resolver.param.headers },\n ] as const\n\n // NOTE(v5-stable): the fields were renamed from the legacy beta shape\n // (`data`/`pathParams`/`queryParams`/`headerParams`) to `body`/`path`/`query`/`headers` so the\n // type matches the runtime client. Drop this note once v5 leaves beta.\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({\n name: 'body',\n required: hasBody,\n schema: hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever(),\n }),\n ...groups.map(({ name, params, resolve }) => {\n const required = params.some((param) => param.required)\n\n return ast.factory.createProperty({\n name,\n required,\n schema:\n params.length > 0\n ? ast.factory.createSchema({ type: 'ref', name: resolve.call(resolver.param, node, params[0]!), optional: !required })\n : createNever(),\n })\n }),\n ],\n })\n}\n\n/**\n * The schema a status occupies in the `<Name>Responses` record. A status that documents several\n * content types becomes a `{ contentType; data }` union so the runtime can surface the negotiated type\n * on `result.parsed`, while the standalone `<Name>StatusNNN` alias stays the plain body union that the\n * query hooks and `result.data` use.\n */\nfunction buildResponseRecordEntry(node: ast.OperationNode, res: ast.ResponseNode, resolver: ResponseStatusNameResolver): ast.SchemaNode {\n const statusName = resolver.response.status(node, res.statusCode)\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length <= 1) {\n return ast.factory.createSchema({ type: 'ref', name: statusName })\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: resolveContentTypeVariants(variants, statusName).map((variant) =>\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'contentType',\n required: true,\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] }),\n }),\n ast.factory.createProperty({\n name: 'data',\n required: true,\n schema: ast.factory.createSchema({ type: 'ref', name: variant.name }),\n }),\n ],\n }),\n ),\n })\n}\n\n/**\n * Builds the per-status `<Name>Responses` record for an operation, referencing the already-resolved\n * `<Name>StatusNNN` names. Shared by `@kubb/plugin-ts`'s `Responses` type and `@kubb/plugin-zod`'s\n * inferred responses schema, so both emit the same shape from the same inputs.\n *\n * Always emits the keyed record, even when an operation declares no responses. An operation with no\n * responses renders as an empty object, which keeps every consumer's import (for example the axios\n * SDK's `RequestResult<XResponses>`) resolvable instead of pointing at a missing export.\n */\nexport function buildResponses(node: ast.OperationNode, resolver: ResponseStatusNameResolver): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: node.responses.map((res) =>\n ast.factory.createProperty({\n name: String(res.statusCode),\n required: true,\n schema: buildResponseRecordEntry(node, res, resolver),\n }),\n ),\n })\n}\n\nexport function getStatusCodeNumber(statusCode: ast.StatusCode | number | string): number | null {\n const code = Number(statusCode)\n\n return Number.isNaN(code) ? null : code\n}\n\nexport function isSuccessStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 200 && code < 300\n}\n\nexport function isErrorStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 400\n}\n\nexport function getSuccessResponses<TResponse extends ResponseLike>(responses: ReadonlyArray<TResponse>): Array<TResponse> {\n return responses.filter((response) => isSuccessStatusCode(response.statusCode))\n}\n\nexport function getOperationSuccessResponses(node: ast.OperationNode): Array<ast.ResponseNode> {\n return getSuccessResponses(node.responses)\n}\n\nexport function getPrimarySuccessResponse(node: ast.OperationNode): ast.ResponseNode | null {\n return getOperationSuccessResponses(node)[0] ?? null\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.filter((response) => isSuccessStatusCode(response.statusCode)).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.response.status(node, response.statusCode))\n}\n\nconst typeNamesByResolver = new WeakMap<OperationTypeNameResolver, Map<string, string[]>>()\n\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const cacheKey = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n let byResolver = typeNamesByResolver.get(resolver)\n if (byResolver) {\n const cached = byResolver.get(cacheKey)\n if (cached) return cached\n } else {\n byResolver = new Map()\n typeNamesByResolver.set(resolver, byResolver)\n }\n\n const { path, query, header } = getOperationParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ]\n const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n const result = names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n byResolver.set(cacheKey, result)\n return result\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = getStatusCodeNumber(response.statusCode)\n if (code === null) {\n continue\n }\n\n types.push([code, isSuccessStatusCode(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n","type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction convert(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n// Plugins resolve the same names over and over (about 47,000 calls for a 1,000 schema spec), so\n// results are kept. Clearing at the limit bounds the memory a long-running process spends on it.\nconst cache = new Map<string, string>()\nconst cacheLimit = 10_000\n\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const key = `${pascal ? 'P' : 'c'}${text}`\n const cached = cache.get(key)\n if (cached !== undefined) return cached\n\n const result = convert(text, pascal)\n if (cache.size >= cacheLimit) cache.clear()\n cache.set(key, result)\n return result\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Uppercases only the first character of `text`, leaving the rest untouched.\n * Unlike {@link pascalCase} it never re-splits word boundaries or strips characters.\n *\n * @example\n * `capitalize('getPetById') // 'GetPetById'`\n */\nexport function capitalize(text: string): string {\n return `${text.charAt(0).toUpperCase()}${text.slice(1)}`\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example From camelCase\n * `snakeCase('helloWorld') // 'hello_world'`\n *\n * @example From mixed separators\n * `snakeCase('Hello-World') // 'hello_world'`\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example From camelCase\n * `screamingSnakeCase('helloWorld') // 'HELLO_WORLD'`\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `name` when it's a syntactically valid JavaScript variable name,\n * otherwise prefixes it with `_` so the result is a valid identifier.\n *\n * Useful for sanitizing OpenAPI schema names or operation IDs that start with\n * a digit (e.g. `409`, `504AccountCancel`) before using them as exported\n * variable, type, or function names.\n *\n * @example\n * ```ts\n * ensureValidVarName('409') // '_409'\n * ensureValidVarName('504AccountCancel') // '_504AccountCancel'\n * ensureValidVarName('Pet') // 'Pet'\n * ensureValidVarName('class') // '_class'\n * ```\n */\nexport function ensureValidVarName(name: string): string {\n if (!name || isValidVarName(name)) {\n return name\n }\n return `_${name}`\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from '@internals/utils'\nimport type { Group } from 'kubb/kit'\n\n/**\n * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the\n * shared default naming so every plugin groups output consistently:\n *\n * - `path` groups use the second path segment (`/pet/findByStatus` → `pet`).\n * - other groups use the camelCased group (`pet store` → `petStore`).\n *\n * A user-provided `group.name` always wins over the default namer, so callers stay in\n * control of their output folders. Returns `null` when grouping is disabled, matching the\n * per-plugin convention.\n *\n * @param group - The user-supplied group option, or `undefined` to disable grouping.\n *\n * @example\n * ```ts\n * createGroupConfig(group) // shared across every plugin\n * ```\n */\nexport function createGroupConfig(group: Group | undefined): Group | null {\n if (!group) {\n return null\n }\n\n const defaultName = (ctx: { group: string }): string => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n\n return camelCase(ctx.group)\n }\n\n return {\n ...group,\n name: group.name ? group.name : defaultName,\n } satisfies Group\n}\n","","","import { isSuccessStatusCode } from '@internals/shared'\nimport type { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport type { ValidatorOptions } from '../types.ts'\n\n/**\n * Returns `true` when any direction of the validator uses zod (used for dependency checks).\n */\nexport function isValidatorEnabled(validator: ValidatorOptions | undefined): boolean {\n if (!validator) return false\n if (validator === 'zod') return true\n return Boolean(validator.request || validator.params || validator.response)\n}\n\n/**\n * Returns `'zod'` when request body parsing is enabled, `null` otherwise. The string shorthand\n * `'zod'` validates the response only, so it does not enable request parsing.\n */\nexport function resolveRequestValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator || validator === 'zod') return null\n return validator.request ?? null\n}\n\n/**\n * Returns `'zod'` when path, query, and header params parsing is enabled, `null` otherwise. Only the\n * object form `{ params: 'zod' }` enables it.\n */\nexport function resolveParamsValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator || validator === 'zod') return null\n return validator.params ?? null\n}\n\n/**\n * Returns `'zod'` when response parsing is enabled, `null` otherwise. The string shorthand `'zod'`\n * maps to response parsing.\n */\nexport function resolveResponseValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator) return null\n if (validator === 'zod') return 'zod'\n return validator.response ?? null\n}\n\n/**\n * Resolves the zod schema name a generated client validates an error body with on the non-throw path.\n * Uses the error-only `<operation>ErrorSchema` (the union of non-2xx statuses); returns `null` when the\n * operation documents no error responses with a schema.\n */\nexport function buildZodErrorParse(node: ast.OperationNode, zodResolver: ResolverZod): string | null {\n const hasErrorResponse = node.responses.some((res) => !isSuccessStatusCode(res.statusCode) && res.content?.some((entry) => entry.schema))\n if (!hasErrorResponse) return null\n return zodResolver.response.error?.(node) || null\n}\n","/**\n * A resolved security scheme as emitted on each generated call's `security` array. The runtime calls\n * the configured `auth` resolver with this object and places the returned token: `http` bearer/basic\n * on `Authorization`, `apiKey` under `name` in the header/query/cookie, and `oauth2`/`openIdConnect`\n * as a bearer token.\n */\nexport type Auth = {\n type: 'http' | 'apiKey' | 'oauth2' | 'openIdConnect'\n scheme?: 'bearer' | 'basic'\n name?: string\n in?: 'header' | 'query' | 'cookie'\n scopes?: Array<string>\n}\n\n/**\n * A single OpenAPI security requirement read from the spec: scheme name to the scopes it needs.\n */\ntype SecurityRequirement = Record<string, Array<string>>\n\n/**\n * The slice of an OpenAPI document the security derivation reads: the global `security`, the\n * per-operation `security` under `paths`, and the `securitySchemes` map under `components`. Typed\n * locally so this package stays independent of the OpenAPI adapter.\n */\nexport type SecurityDocument = {\n security?: Array<SecurityRequirement>\n components?: {\n securitySchemes?: Record<string, OasSecurityScheme | { $ref: string } | undefined>\n }\n paths?: Record<string, Record<string, { security?: Array<SecurityRequirement> } | undefined> | undefined>\n}\n\ntype OasSecurityScheme = { type: 'http'; scheme?: string } | { type: 'apiKey'; name?: string; in?: string } | { type: 'oauth2' } | { type: 'openIdConnect' }\n\nfunction serializeAuth(auth: Auth): string {\n const parts = [`type: '${auth.type}'`]\n if (auth.scheme) parts.push(`scheme: '${auth.scheme}'`)\n if (auth.name) parts.push(`name: '${auth.name}'`)\n if (auth.in) parts.push(`in: '${auth.in}'`)\n if (auth.scopes?.length) parts.push(`scopes: [${auth.scopes.map((scope) => `'${scope}'`).join(', ')}]`)\n return `{ ${parts.join(', ')} }`\n}\n\n/**\n * Maps an OpenAPI security scheme to the inline `Auth` object, or `null` when the runtime cannot\n * place it (an unresolved `$ref`, or an `apiKey` without a name or outside `header` / `query` /\n * `cookie`). `http` schemes other than `basic` are treated as bearer.\n */\nexport function resolveSecurityScheme(scheme: OasSecurityScheme | { $ref: string } | undefined): Auth | null {\n if (!scheme || '$ref' in scheme) return null\n if (scheme.type === 'apiKey') {\n if (!scheme.name || (scheme.in !== 'header' && scheme.in !== 'query' && scheme.in !== 'cookie')) return null\n return { type: 'apiKey', name: scheme.name, in: scheme.in }\n }\n if (scheme.type === 'http') return { type: 'http', scheme: scheme.scheme?.toLowerCase() === 'basic' ? 'basic' : 'bearer' }\n if (scheme.type === 'oauth2') return { type: 'oauth2' }\n if (scheme.type === 'openIdConnect') return { type: 'openIdConnect' }\n return null\n}\n\n/**\n * Derives the per-operation security metadata from the OpenAPI document. The operation's own\n * `security` overrides the global `security` (an explicit empty array disables auth), and every\n * referenced scheme is resolved from `components.securitySchemes` into a flat, de-duplicated list of\n * `Auth` objects the runtime walks in order.\n *\n * @example\n * `getOperationSecurity({ document, method: 'POST', path: '/pet' })`\n * `// [{ type: 'http', scheme: 'bearer' }]`\n */\nexport function getOperationSecurity({\n document,\n method,\n path,\n}: {\n document: SecurityDocument | null | undefined\n method: string\n path: string\n}): Array<Auth> | undefined {\n if (!document) return undefined\n\n const operation = document.paths?.[path]?.[method.toLowerCase()]\n const requirements = operation?.security ?? document.security\n if (!requirements?.length) return undefined\n\n const definitions = document.components?.securitySchemes ?? {}\n const security: Array<Auth> = []\n const seen = new Set<string>()\n for (const requirement of requirements) {\n for (const [schemeName, scopes] of Object.entries(requirement)) {\n if (seen.has(schemeName)) continue\n seen.add(schemeName)\n const auth = resolveSecurityScheme(definitions[schemeName])\n if (auth) security.push(scopes.length ? { ...auth, scopes } : auth)\n }\n }\n\n return security.length ? security : undefined\n}\n\n/**\n * Serializes the per-operation security into the literal emitted on each generated call's `security`\n * field. The runtime `resolveAuth` helper walks it, calling the configured `auth` resolver per entry.\n *\n * @example\n * `buildSecurityMetadata({ security: [{ type: 'http', scheme: 'bearer' }] }) // \"[{ type: 'http', scheme: 'bearer' }]\"`\n */\nexport function buildSecurityMetadata({ security }: { security?: Array<Auth> }): string | null {\n if (!security?.length) return null\n return `[${security.map(serializeAuth).join(', ')}]`\n}\n","import { getOperationParameters } from '@internals/shared'\nimport type { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport type { ValidatorOptions } from '../types.ts'\nimport { buildZodErrorParse, resolveParamsValidator, resolveRequestValidator, resolveResponseValidator } from './validatorOptions.ts'\n\n/**\n * The per-call validator references a generated function wires into its request config. Each hook is\n * the bare schema reference passed to the runtime's `validator.request` / `validator.path` /\n * `validator.query` / `validator.headers` / `validator.response` / `validator.error` slot; `client.ts`\n * runs it through `validateStandardSchema`. The response validator only ever sees success (2xx) bodies.\n */\nexport type ValidatorHooks = {\n /**\n * Schema reference for the `validator.request` hook, or `null` when request validation is off.\n */\n request: string | null\n /**\n * Schema references for the `validator.path` / `query` / `headers` hooks (`headers` wrapped in\n * `toHeadersStandardSchema`), or `null` when params validation is off or the group is empty.\n */\n path: string | null\n query: string | null\n headers: string | null\n /**\n * Schema reference for the `validator.response` hook, or `null` when response validation is off.\n */\n response: string | null\n /**\n * Schema reference for the `validator.error` hook, or `null` when error validation is off or the\n * operation documents no error responses. The runtime runs this on the error body when a non-2xx\n * call does not throw.\n */\n error: string | null\n /**\n * Zod schema names the generated file imports from the zod plugin output.\n */\n importedZodNames: Array<string>\n}\n\n/**\n * Builds the validator-hook references for one operation. Request body and params validation run before the send.\n * Response validation runs on the success body only. Returns `null` references when the matching\n * direction is disabled or the schema is absent.\n */\nexport function buildValidatorHooks({\n node,\n validator,\n zodResolver,\n}: {\n node: ast.OperationNode\n validator: ValidatorOptions | undefined\n zodResolver: ResolverZod | null | undefined\n}): ValidatorHooks {\n const hasRequestBody = Boolean(node.requestBody?.content?.[0]?.schema)\n const parsesResponse = zodResolver && resolveResponseValidator(validator) === 'zod'\n\n // Success responses validate with the success-only `<operation>ResponseSchema`; error bodies are never zod-parsed on the throw path.\n const response = parsesResponse ? zodResolver.response.response(node) || null : null\n const error = parsesResponse ? buildZodErrorParse(node, zodResolver) : null\n const request = zodResolver && resolveRequestValidator(validator) === 'zod' && hasRequestBody ? zodResolver.response.body(node) || null : null\n\n const paramGroups = getOperationParameters(node)\n const resolveParamsName = (kind: 'path' | 'query' | 'headers', params: Array<ast.ParameterNode>): string | null =>\n zodResolver && resolveParamsValidator(validator) === 'zod' && params.length > 0 ? zodResolver.param[kind](node, params[0]!) : null\n const path = resolveParamsName('path', paramGroups.path)\n const query = resolveParamsName('query', paramGroups.query)\n const headers = resolveParamsName('headers', paramGroups.header)\n\n // Order is output: the generated file imports the response schema, then the error schema, then the request body and params schemas.\n const importedZodNames = [response, error, request, path, query, headers].filter((name): name is string => Boolean(name))\n\n const headersValidator = headers ? `toHeadersStandardSchema(${headers}, ${headers}.shape)` : null\n\n return { request, path, query, headers: headersValidator, response, error, importedZodNames }\n}\n\n/**\n * Prints the `validator: { … }` entry of a call config from the hooks named in `keys`, or `null` when none is set.\n */\nexport function buildValidatorLiteral(hooks: ValidatorHooks | null, keys: ReadonlyArray<keyof Omit<ValidatorHooks, 'importedZodNames'>>): string | null {\n const entries = keys.flatMap((key) => (hooks?.[key] ? [`${key}: ${hooks[key]}`] : []))\n return entries.length ? `validator: { ${entries.join(', ')} }` : null\n}\n","import { getContentTypeInfo, getResponseContentTypeInfo } from '@internals/shared'\nimport { ast } from 'kubb/kit'\n\n/**\n * Builds the `contentType` entry baked into the call config, or `null` for the JSON default.\n *\n * `merge` is `true` when the generated function must destructure `contentType` from `options` and\n * merge it over the baked request default, because the caller can also pick a response content type.\n */\nexport function buildContentType({ node }: { node: ast.HttpOperationNode }): { literal: string | null; merge: boolean } {\n const { defaultContentType } = getContentTypeInfo(node)\n const hasRequestBody = Boolean(node.requestBody?.content?.[0]?.schema)\n // Bake the request body content type only when it is not the JSON default. The first declared type is\n // the default for an operation with several request types; the caller overrides it on `contentType`.\n const requestContentType = hasRequestBody && defaultContentType !== 'application/json' ? defaultContentType : null\n\n if (!requestContentType) return { literal: null, merge: false }\n\n // When the caller can also pick a response content type, a partial `{ response }` would replace the\n // baked request default through `...config`, so merge the caller's choice over it instead.\n const merge = getResponseContentTypeInfo(node).isMultipleContentTypes\n\n return {\n merge,\n literal: merge\n ? `contentType: { request: '${requestContentType}', ...(typeof contentType === 'string' ? { request: contentType } : contentType) }`\n : `contentType: { request: '${requestContentType}' }`,\n }\n}\n","import type { ast } from 'kubb/kit'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\n\n/**\n * Builds the `RequestResult` generic arguments for one operation: the per-status responses record\n * plus the per-call `ThrowOnError` flag. `SuccessOf` / `ErrorOf` split the record inside the\n * runtime, so this only names the record and threads `ThrowOnError`.\n *\n * @example\n * `buildRequestResultGenerics({ node, types }) // 'AddPetResponses, ThrowOnError'`\n */\nexport function buildRequestResultGenerics({ node, types }: { node: ast.OperationNode; types: OperationTypeNames }): string {\n return `${types.response.responses(node)}, ThrowOnError`\n}\n\n/**\n * Builds the full return type an operation's function signature uses: `Unwrappable<RequestResult>`\n * for the default `returnType: 'full'`, already a promise so no further wrapping is needed, a plain\n * `Promise<RequestResult>` for the internal `'plain'` shape, or a\n * `Promise` of the runtime's `UnwrappedResult` when `returnType: 'data'` narrows a resolved call\n * down to the bare success body.\n *\n * @example\n * `buildResultType({ node, types, returnType: 'data' }) // 'Promise<UnwrappedResult<AddPetResponses, ThrowOnError>>'`\n */\nexport function buildResultType({ node, types, returnType }: { node: ast.OperationNode; types: OperationTypeNames; returnType: ReturnTypeOption }): string {\n const generics = buildRequestResultGenerics({ node, types })\n if (returnType === 'data') return `Promise<UnwrappedResult<${generics}>>`\n if (returnType === 'plain') return `Promise<RequestResult<${generics}>>`\n return `Unwrappable<RequestResult<${generics}>>`\n}\n","import type { ast } from 'kubb/kit'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\nimport { buildRequestResultGenerics, buildResultType } from './generics.ts'\n\n/**\n * Builds the return statement of a generated operation function. With the default\n * `returnType: 'full'` the runtime call already resolves to `{ data, error, request, response }`.\n * The generated code casts that result to the operation's `RequestResult`, then wraps it with\n * `withUnwrap`, so the caller can `await` it directly or call `.unwrap()` for the bare success\n * body. With `returnType: 'data'` it instead routes the call through the runtime's `unwrapResult`,\n * which narrows the resolved value down to the bare success body the same way `RequestResult`\n * already does, using the plugin default when the call leaves `throwOnError` unset.\n * With `returnType: 'plain'` it returns the runtime call as is, cast to `RequestResult`, with no helper.\n *\n * Cast first, wrap second, for the `'full'` path. That order keeps `withUnwrap`'s generic inferred\n * as `RequestResult` instead of the runtime's own internal result type. Casting an `Unwrappable<A>`\n * straight to `Unwrappable<B>` does not work: the `.then` overload stays pinned to `A`, and `as`\n * rejects that two-generic swap even where `A` and `B` on their own would satisfy it.\n *\n * @example\n * `return withUnwrap(request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>)`\n * @example\n * `return unwrapResult(request({ method: 'POST', url: '/pet', ...config }), config.throwOnError ?? false) as Promise<UnwrappedResult<AddPetResponses, ThrowOnError>>`\n * @example\n * `return request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>`\n */\nexport function buildReturnStatement({\n node,\n types,\n callConfig,\n returnType,\n throwOnErrorDefault,\n}: {\n node: ast.OperationNode\n types: OperationTypeNames\n callConfig: string\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n}): string {\n if (returnType === 'data') {\n const resultType = buildResultType({ node, types, returnType })\n return `return unwrapResult(request(${callConfig}), config.throwOnError ?? ${throwOnErrorDefault}) as ${resultType}`\n }\n if (returnType === 'plain') {\n return `return request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({ node, types })}>>`\n }\n return `return withUnwrap(request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({ node, types })}>>)`\n}\n","import type { ast } from 'kubb/kit'\nimport { getRequestGroupOptionality } from '@internals/shared'\nimport { createFunctionParameter, createFunctionParameters, functionPrinter } from '@kubb/plugin-ts'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\nimport { buildResultType } from './generics.ts'\n\nconst declarationPrinter = functionPrinter({ mode: 'declaration' })\n\n/**\n * The pieces of a generated operation function's grouped-options signature.\n */\nexport type GroupedOptionsSignature = {\n /**\n * The single function parameter: `options: Options<<Name>Options, ThrowOnError>`.\n */\n paramsSignature: string\n /**\n * The function return type: `Unwrappable<RequestResult<<Name>Responses, ThrowOnError>>`.\n */\n returnType: string\n /**\n * The function generics. One per-call `ThrowOnError` flag, defaulting to the plugin setting.\n */\n generics: Array<string>\n}\n\n/**\n * Builds the grouped-options signature for one operation: a single `options` object whose `TData`\n * is the `<Name>Options` type, and a `RequestResult` return type keyed to the per-status responses\n * record. There are no positional arguments.\n *\n * The generated file imports `<Name>Options` and `<Name>Responses` and uses them directly, so no\n * per-operation input type has to be emitted. Both names come from `types`, which is `plugin-ts` or\n * `plugin-zod`'s inferred types (see `resolveOperationTypes`).\n */\nexport function buildGroupedOptionsSignature({\n node,\n types,\n returnType,\n throwOnErrorDefault,\n}: {\n node: ast.OperationNode\n types: OperationTypeNames\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n}): GroupedOptionsSignature {\n const optionsName = types.response.options(node)\n const { isOptional } = getRequestGroupOptionality(node)\n\n const paramsSignature =\n declarationPrinter.print(\n createFunctionParameters({\n params: [createFunctionParameter({ name: 'options', type: `Options<${optionsName}, ThrowOnError>`, ...(isOptional ? { default: '{}' } : {}) })],\n }),\n ) ?? ''\n\n return {\n paramsSignature,\n returnType: buildResultType({ node, types, returnType }),\n generics: [`ThrowOnError extends boolean = ${throwOnErrorDefault}`],\n }\n}\n","import { isValidVarName } from '@internals/utils'\nimport { ast } from 'kubb/kit'\n\ntype StyledLocation = 'path' | 'query' | 'header' | 'cookie'\n\n/**\n * Renders a parameter name as an object-literal key, quoted when it is not a bare identifier. Every\n * location keeps the spec name: the runtime looks path styles up by the `{name}` placeholder in the\n * URL, and the other locations by the key it serializes.\n */\nfunction toKey(name: string): string {\n return isValidVarName(name) ? name : JSON.stringify(name)\n}\n\n/**\n * Serializes one parameter's metadata into a `{ style, explode, allowReserved, contentType }`\n * literal, or `null` when the parameter carries none. Path and query carry the serialization\n * `style`; header and cookie use a fixed style (`simple` and `form`), so only `explode` is emitted\n * for them. `allowReserved` only applies to query parameters, and `contentType` to every location\n * except path.\n */\nfunction serializeParameter(parameter: ast.ParameterNode): string | null {\n const parts: Array<string> = []\n if ((parameter.in === 'path' || parameter.in === 'query') && parameter.style) parts.push(`style: '${parameter.style}'`)\n if (parameter.explode !== undefined) parts.push(`explode: ${parameter.explode}`)\n if (parameter.in === 'query' && parameter.allowReserved !== undefined) parts.push(`allowReserved: ${parameter.allowReserved}`)\n if (parameter.in !== 'path' && parameter.contentType) parts.push(`contentType: '${parameter.contentType}'`)\n return parts.length > 0 ? `{ ${parts.join(', ')} }` : null\n}\n\n/**\n * Serializes the `encoding` of the request body's default content type into a `{ property: { ... } }`\n * literal, or `null` when it carries none. Only an operation with a single request content type\n * emits it, because the runtime applies `styles.body` to whichever type the caller selects.\n */\nfunction serializeBodyEncoding(node: ast.HttpOperationNode): string | null {\n const content = node.requestBody?.content\n const entries = Object.entries(content?.length === 1 ? (content[0]?.encoding ?? {}) : {}).map(\n ([property, { contentType, style, explode, allowReserved }]) => {\n const parts = [\n style && `style: ${JSON.stringify(style)}`,\n explode !== undefined && `explode: ${explode}`,\n allowReserved !== undefined && `allowReserved: ${allowReserved}`,\n contentType && `contentType: ${JSON.stringify(contentType)}`,\n ].filter(Boolean)\n return `${isValidVarName(property) ? property : JSON.stringify(property)}: { ${parts.join(', ')} }`\n },\n )\n\n return entries.length > 0 ? `body: { ${entries.join(', ')} }` : null\n}\n\n/**\n * Builds the per-operation `styles` literal from the operation's parameters, grouped by location.\n * Entries are keyed by the spec name of the parameter.\n * Only parameters whose source defines `style`, `explode`, `allowReserved`, or `contentType` are\n * emitted, so calls without serialization metadata keep the runtime defaults and existing output\n * is unchanged. A form request body adds a `body` group keyed by property name from its `encoding`.\n * Returns `null` when nothing carries metadata.\n *\n * @example\n * ```ts\n * // a path param with { style: 'matrix', explode: true } and a query param with { explode: false }\n * buildStyles({ node }) // \"{ path: { id: { style: 'matrix', explode: true } }, query: { tags: { explode: false } } }\"\n * ```\n */\nexport function buildStyles({ node }: { node: ast.OperationNode }): string | null {\n if (!ast.isHttpOperationNode(node)) return null\n\n const groups: Record<StyledLocation, Array<string>> = { path: [], query: [], header: [], cookie: [] }\n\n for (const parameter of node.parameters) {\n const literal = serializeParameter(parameter)\n if (!literal) continue\n groups[parameter.in].push(`${toKey(parameter.name)}: ${literal}`)\n }\n\n const entries = [\n ...(Object.keys(groups) as Array<StyledLocation>)\n .filter((location) => groups[location].length > 0)\n .map((location) => `${location}: { ${groups[location].join(', ')} }`),\n serializeBodyEncoding(node),\n ].filter(Boolean)\n\n return entries.length > 0 ? `{ ${entries.join(', ')} }` : null\n}\n","import { buildOperationComments, getResponseType, isEventStream } from '@internals/shared'\nimport { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport { File, Function } from 'kubb/jsx'\nimport type { KubbReactNode } from 'kubb/jsx'\nimport { buildContentType } from '../builders/contentType.ts'\nimport { buildReturnStatement } from '../builders/returnStatement.ts'\nimport { type Auth, buildSecurityMetadata } from '../builders/security.ts'\nimport { buildGroupedOptionsSignature } from '../builders/signature.ts'\nimport { buildStyles } from '../builders/styles.ts'\nimport { buildValidatorHooks, buildValidatorLiteral } from '../builders/validator.ts'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption, ValidatorOptions } from '../types.ts'\n\ntype Props = {\n /**\n * The generated function name.\n */\n name: string\n /**\n * The operation being generated.\n */\n node: ast.OperationNode\n /**\n * The operation type names the signature references, from `plugin-ts` or `plugin-zod`'s inferred\n * types.\n */\n types: OperationTypeNames\n /**\n * Resolver for the zod schema names the validators reference, when `validator` is on.\n */\n zodResolver?: ResolverZod | null\n /**\n * The active validator option, driving the validator-hook wiring.\n */\n validator?: ValidatorOptions\n /**\n * Shape of the value the generated function resolves to.\n */\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n /**\n * Per-operation security, resolved from the spec into inline `Auth` objects and serialized onto the\n * call config's `security` field for the runtime `auth` resolver to consume.\n */\n security?: Array<Auth>\n}\n\n/**\n * Renders one client operation: the grouped `<Name>Request` type and the function that forwards a\n * single `options` object to the resolved client and returns the `Unwrappable<RequestResult>`. The\n * type, signature, and call config are built with the AST factory, and only the jsx-renderer emits\n * the source.\n */\nexport function Operation({ name, node, types, zodResolver, validator, returnType, throwOnErrorDefault, security }: Props): KubbReactNode {\n if (!ast.isHttpOperationNode(node)) return null\n\n const signature = buildGroupedOptionsSignature({ node, types, returnType, throwOnErrorDefault })\n const validators = buildValidatorHooks({ node, validator, zodResolver })\n const securityLiteral = buildSecurityMetadata({ security })\n const stylesLiteral = buildStyles({ node })\n\n const { literal: contentTypeLiteral, merge: mergeContentType } = buildContentType({ node })\n\n const eventStream = isEventStream(node)\n const responseType = getResponseType(node)\n const responseTypeLiteral = responseType ? `responseType: '${responseType}'` : null\n\n const validatorLiteral = buildValidatorLiteral(validators, ['request', 'path', 'query', 'headers', 'response', 'error'])\n\n const callConfig = `{ ${[\n `method: '${node.method.toUpperCase()}'`,\n `url: '${node.path}'`,\n securityLiteral ? `security: ${securityLiteral}` : null,\n stylesLiteral ? `styles: ${stylesLiteral}` : null,\n validatorLiteral,\n contentTypeLiteral,\n responseTypeLiteral,\n '...config',\n `throwOnError: config.throwOnError ?? ${throwOnErrorDefault}`,\n ]\n .filter(Boolean)\n .join(', ')} }`\n\n const eventType = `SuccessOf<${types.response.responses(node)}>`\n const functionReturnType = eventStream ? `Promise<EventStreamResult<${eventType}>>` : signature.returnType\n const returnStatement = eventStream\n ? `return toEventStream<${eventType}>(request(${callConfig}))`\n : buildReturnStatement({ node, types, callConfig, returnType, throwOnErrorDefault })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n generics={signature.generics}\n params={signature.paramsSignature}\n returnType={functionReturnType}\n JSDoc={{ comments: buildOperationComments(node, { link: 'urlPath', linkPosition: 'beforeDeprecated', splitLines: true }) }}\n >\n {mergeContentType ? 'const { client: request = client, contentType, ...config } = options' : 'const { client: request = client, ...config } = options'}\n <br />\n {returnStatement}\n </Function>\n </File.Source>\n )\n}\n","import { type ast, Diagnostics, type Generator, type Group, type Output } from 'kubb/kit'\nimport { pluginTsName, type ResolverTs } from '@kubb/plugin-ts'\nimport { pluginZodName, type ResolverZod } from '@kubb/plugin-zod'\nimport type { ContractClientFactory } from './types.ts'\n\ntype GeneratorDriver = Parameters<NonNullable<Generator<ContractClientFactory>['operations']>>[1]['driver']\n\n/**\n * The two per-operation type names a generated client references: the grouped input and the\n * per-status responses record its `RequestResult` is keyed on.\n */\nexport type OperationTypeNames = {\n response: {\n /**\n * Resolves the name of the operation's grouped `{ body, path, query, headers }` input type.\n */\n options(node: ast.OperationNode): string\n /**\n * Resolves the name of the operation's per-status responses record type.\n */\n responses(node: ast.OperationNode): string\n }\n}\n\n/**\n * Where a generated client sources its operation types, plus the resolver and output the file\n * declaring them is resolved with.\n */\nexport type OperationTypeSource = OperationTypeNames & {\n /**\n * `plugin-ts` shaped resolver of the plugin supplying the names, also used to resolve the file they are exported from.\n */\n resolver: ResolverTs\n /**\n * The supplying plugin's own `output`, when it configured one.\n */\n output: Output | undefined\n /**\n * The supplying plugin's own `group`, when it configured one.\n */\n group: Group | undefined\n}\n\n/**\n * A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`\n * exports next to each schema, so code written against `plugin-ts` names picks up the zod types.\n */\nfunction toZodTypeResolver(resolver: ResolverZod): ResolverTs {\n const type = (name: string) => resolver.schema.type(name)\n\n return {\n ...resolver,\n // A class method, so a spread drops it, and it reads private fields, so it must run on `resolver`.\n file: resolver.file.bind(resolver),\n param: {\n name: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.name(node, p)),\n path: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.path(node, p)),\n query: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.query(node, p)),\n headers: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.headers(node, p)),\n },\n response: {\n body: (node: ast.OperationNode) => type(resolver.response.body(node)),\n status: (node: ast.OperationNode, statusCode: ast.StatusCode) => type(resolver.response.status(node, statusCode)),\n response: (node: ast.OperationNode) => type(resolver.response.response(node)),\n responses: (node: ast.OperationNode) => type(resolver.response.responses(node)),\n options: (node: ast.OperationNode) => resolver.response.options(node),\n },\n } as unknown as ResolverTs\n}\n\n/**\n * Picks the plugin generated clients, query hooks, and MCP handlers take their operation types from.\n *\n * `pluginZod({ inferred: 'codec' })` wins, so a codec param takes its domain value. Otherwise `plugin-ts`\n * wins when it is in the pipeline, and without it any `pluginZod({ inferred })`. Throws\n * `KUBB_MISSING_DEPENDENCY` for `pluginName` when neither is available.\n *\n * @example\n * ```ts\n * const types = resolveOperationTypes(ctx.driver, ctx.plugin.name)\n * types.response.options(node) // 'GetPetByIdOptions', or 'GetPetByIdOptionsSchemaType' from zod\n * ```\n */\nexport function resolveOperationTypes(driver: GeneratorDriver, pluginName: string): OperationTypeSource {\n const pluginTs = driver.getPlugin(pluginTsName)\n const pluginZod = driver.getPlugin(pluginZodName)\n\n if (pluginTs && pluginZod?.options?.inferred !== 'codec') {\n const resolver = driver.getResolver(pluginTsName)\n return { response: resolver.response, resolver, output: pluginTs.options?.output, group: pluginTs.options?.group ?? undefined }\n }\n\n if (!pluginZod?.options?.inferred) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: `Plugin \"${pluginName}\" has no source for operation types.`,\n help: `Add \\`pluginTs()\\` before \"${pluginName}\", or add \\`pluginZod({ inferred: true })\\`.`,\n location: { kind: 'config' },\n plugin: pluginName,\n })\n }\n\n const resolver = toZodTypeResolver(driver.getResolver(pluginZodName))\n return { response: resolver.response, resolver, output: pluginZod.options.output, group: pluginZod.options.group ?? undefined }\n}\n","import path from 'node:path'\nimport { isEventStream, operationFileEntry, resolveDependencyOperationFile } from '@internals/shared'\nimport { ast, defineGenerator } from 'kubb/kit'\nimport type { Generator } from 'kubb/kit'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, jsxRenderer } from 'kubb/jsx'\nimport { isValidatorEnabled } from '../builders/validatorOptions.ts'\nimport { getOperationSecurity, type SecurityDocument } from '../builders/security.ts'\nimport { buildValidatorHooks } from '../builders/validator.ts'\nimport { Operation } from '../components/Operation.tsx'\nimport { resolveOperationTypes } from '../resolveOperationTypes.ts'\nimport type { ContractClientFactory } from '../types.ts'\n\n/**\n * Builds the built-in per-operation generator shared by the client plugins (`@kubb/plugin-fetch`,\n * `@kubb/plugin-axios`). Emits one async function per OpenAPI operation using the shared\n * `Operation` component: a grouped `<Name>Request` type and a function that forwards a single\n * `options` object to the bundled `client` and returns the `Unwrappable<RequestResult>`. Only the\n * generator `name` differs between plugins. Every other resolution, import, and rendering step is\n * identical.\n */\nexport function createClientGenerator<TFactory extends ContractClientFactory>(\n name: string,\n resolveClientPath?: (options: TFactory['resolvedOptions'], root: string) => string,\n): Generator<TFactory> {\n return defineGenerator<TFactory>({\n name,\n renderer: jsxRenderer,\n operation(node, ctx) {\n if (!ast.isHttpOperationNode(node)) return null\n\n const { config, driver, resolver, root } = ctx\n const { output, validator, returnType, throwOnErrorDefault, group } = ctx.options\n\n const types = resolveOperationTypes(driver, ctx.plugin.name)\n\n const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(pluginZodName) : null\n const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null\n\n const importedTypeNames = [types.response.options(node), types.response.responses(node)]\n\n const validatorHooks = buildValidatorHooks({ node, validator, zodResolver })\n const importedZodNames = validatorHooks.importedZodNames\n\n const meta = {\n name: resolver.name(node.operationId),\n file: resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\n fileTypes: resolveDependencyOperationFile({\n cache: ctx.cache,\n node,\n resolver: types.resolver,\n root,\n output: types.output ?? output,\n group: types.group,\n }),\n fileZod:\n zodResolver && pluginZod?.options\n ? zodResolver.file({\n ...operationFileEntry(node, node.operationId),\n root,\n output: pluginZod.options.output ?? output,\n group: pluginZod.options?.group ?? undefined,\n })\n : null,\n } as const\n\n const security = getOperationSecurity({\n document: ctx.adapter.document as SecurityDocument | null | undefined,\n method: node.method,\n path: node.path,\n })\n\n // A custom client module is emitted verbatim, so `importPath` is used exactly as configured.\n // The default `.kubb/client.ts` is a file path and is made relative to the operation file.\n const customClientPath = resolveClientPath?.(ctx.options, root)\n const clientPath = customClientPath ?? path.resolve(root, '.kubb/client.ts')\n const clientRoot = customClientPath === undefined ? meta.file.path : undefined\n // The headers validator helper ships in `.kubb/standardSchema.ts`; a custom client module exports it\n // alongside its other runtime helpers.\n const standardSchemaPath = customClientPath ?? path.resolve(root, '.kubb/standardSchema.ts')\n const eventStream = isEventStream(node)\n\n const clientValueImports = (() => {\n if (eventStream) return ['client', 'toEventStream']\n if (returnType === 'plain') return ['client']\n if (returnType === 'data') return ['client', 'unwrapResult']\n return ['client', 'withUnwrap']\n })()\n\n const clientTypeImports = (() => {\n if (eventStream) return ['Options', 'EventStreamResult', 'SuccessOf']\n if (returnType === 'plain') return ['Options', 'RequestResult']\n if (returnType === 'data') return ['Options', 'UnwrappedResult']\n return ['Options', 'Unwrappable', 'RequestResult']\n })()\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.default.banner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.default.footer(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n <File.Import name={clientValueImports} root={clientRoot} path={clientPath} />\n <File.Import name={clientTypeImports} root={clientRoot} path={clientPath} isTypeOnly />\n\n {meta.fileTypes && importedTypeNames.length > 0 && (\n <File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTypes.path} isTypeOnly />\n )}\n\n {meta.fileZod && importedZodNames.length > 0 && <File.Import name={importedZodNames} root={meta.file.path} path={meta.fileZod.path} />}\n {validatorHooks.headers && <File.Import name={['toHeadersStandardSchema']} root={clientRoot} path={standardSchemaPath} />}\n\n <Operation\n name={meta.name}\n node={node}\n types={types}\n zodResolver={zodResolver}\n validator={validator}\n returnType={returnType}\n throwOnErrorDefault={throwOnErrorDefault}\n security={security}\n />\n </File>\n )\n },\n })\n}\n","import { macroSimplifyUnion } from 'kubb/kit'\nimport type { ast } from 'kubb/kit'\n\n/**\n * Macros the client plugins apply by default, ahead of any user macros. `macroSimplifyUnion`\n * drops union members a broader scalar already covers, keeping the generated response and error\n * unions tidy. A plugin wires them with `ctx.setMacros([...defaultMacros, ...userMacros])`.\n */\nexport const defaultMacros: ReadonlyArray<ast.Macro> = [macroSimplifyUnion]\n","import { camelCase, ensureValidVarName, pascalCase } from '@internals/utils'\nimport { createResolver } from 'kubb/kit'\nimport type { PluginContractClient } from './types.ts'\n\n/**\n * Default resolver shared by the client plugins. Functions and files inherit the built-in camelCase\n * `name` and `file`; classes and tag groups use PascalCase.\n *\n * @example\n * ```ts\n * resolverClient.name('show pet by id') // 'showPetById'\n * resolverClient.groupName('pet') // 'PetClient'\n * ```\n */\nexport const resolverClient = createResolver<PluginContractClient>({\n pluginName: 'plugin-contract-client',\n className(name) {\n return ensureValidVarName(pascalCase(name))\n },\n groupName(name) {\n return ensureValidVarName(pascalCase(`${name} Client`))\n },\n propertyName(name) {\n return ensureValidVarName(camelCase(name))\n },\n})\n","import { createClientGenerator } from '@internals/client'\nimport type { PluginClient } from '../types.ts'\n\n/**\n * Built-in operation generator for `@kubb/plugin-client`. Emits one async function per OpenAPI\n * operation using the shared `Operation` component: a grouped `<Name>Request` type and a function\n * that forwards a single `options` object to the user-provided client module and returns the `RequestResult`.\n */\nexport const clientGenerator = createClientGenerator<PluginClient>('client', (options) => options.importPath)\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 { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { defaultMacros, isValidatorEnabled, resolverClient } from '@internals/client'\nimport type { PluginClient, ResolverClient } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-client`.\n */\nexport const pluginClientName = 'plugin-client' satisfies PluginClient['name']\n\n/**\n * Generates typed operations that call a client module owned by your application.\n * The module at `importPath` must export the runtime helpers and types used by generated operations.\n * Kubb does not copy or inject a transport implementation.\n *\n * @example\n * ```ts\n * pluginClient({ importPath: '../api/client' })\n * ```\n */\nexport const pluginClient = defineExtension<PluginClient>({\n kind: 'plugin',\n meta: { name: pluginClientName, version, compatibility },\n dependencies: (options) => ({ [pluginTsName]: { optional: true }, [pluginZodName]: { optional: !isValidatorEnabled(options.validator) } }),\n setup(options) {\n const {\n output = { path: 'clients', barrel: { type: 'named' } },\n exclude = [],\n include,\n override = [],\n importPath,\n throwOnErrorDefault = true,\n validator = false,\n group,\n resolver: userResolver,\n } = options\n\n const resolver = userResolver ? Resolver.merge<ResolverClient>(resolverClient, userResolver) : resolverClient\n\n setResolver(resolver)\n setMacros([...defaultMacros, ...(options.macros ?? [])])\n addGenerator(clientGenerator)\n\n return {\n output,\n exclude,\n include,\n override,\n group: createGroupConfig(group),\n importPath,\n baseURL: undefined,\n throwOnErrorDefault,\n validator,\n returnType: 'plain',\n sdk: undefined,\n resolver,\n }\n },\n})\n\nexport default pluginClient\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,SAAgB,mBAAmB,MAAyB,MAAc,UAAyC,OAA2B;CAC5I,OAAO;EACL;EACA;EACA,KAAK,KAAK,KAAK,MAAM;EACrB,MAAM,KAAK;CACb;AACF;;;;;;;;;;;;AAaA,SAAgB,+BAA+B,SAO9B;CACf,MAAM,EAAE,OAAO,MAAM,UAAU,MAAM,QAAQ,UAAU;CAEvD,OAAO,MAAM,WAAW,GAAG,SAAS,WAAW,uBAC7C,SAAS,KAAK;EAAE,GAAG,mBAAmB,MAAM,KAAK,WAAW;EAAG;EAAM;EAAQ,OAAO,SAAS,KAAA;CAAU,CAAC,CAC1G;AACF;AA8DA,SAAS,iBAAiB,MAAyB,MAA2C;CAC5F,IAAI,CAAC,MACH,OAAO;CAGT,IAAI,OAAO,SAAS,YAClB,OAAO,KAAK,IAAI,KAAK;CAGvB,OAAO,KAAK,OAAO,UAAU,IAAI,OAAO,KAAK,IAAI,EAAE,KAAK;AAC1D;;;;;AAMA,SAAS,qBAAqB,cAAyC;CACrE,MAAM,yBAAyB,aAAa,SAAS;CAErD,OAAO;EACL;EACA;EACA,kBAAkB,yBAAyB,aAAa,KAAK,OAAO,KAAK,UAAU,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI;EACtG,oBAAoB,aAAa,MAAM;EACvC,aAAa,aAAa,MAAM,OAAO,OAAO,qBAAqB;CACrE;AACF;AAEA,SAAgB,mBAAmB,MAA0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AAC;CAC3C;AACF,CAAC;;;;;;;;ACjBD,MAAa,kBAAkB,sBAAoC,WAAW,YAAY,QAAQ,UAAU;;;;;;ACK5G,MAAa,mBAAmB;;;;;;;;;;;AAYhC,MAAa,eAAe,gBAA8B;CACxD,MAAM;CACN,MAAM;EAAE,MAAM;EAAkB;EAAS;CAAc;CACvD,eAAe,aAAa;GAAG,eAAe,EAAE,UAAU,KAAK;GAAI,gBAAgB,EAAE,UAAU,CAAC,mBAAmB,QAAQ,SAAS,EAAE;CAAE;CACxI,MAAM,SAAS;EACb,MAAM,EACJ,SAAS;GAAE,MAAM;GAAW,QAAQ,EAAE,MAAM,QAAQ;EAAE,GACtD,UAAU,CAAC,GACX,SACA,WAAW,CAAC,GACZ,YACA,sBAAsB,MACtB,YAAY,OACZ,OACA,UAAU,iBACR;EAEJ,MAAM,WAAW,eAAe,SAAS,MAAsB,gBAAgB,YAAY,IAAI;EAE/F,YAAY,QAAQ;EACpB,UAAU,CAAC,GAAG,eAAe,GAAI,QAAQ,UAAU,CAAC,CAAE,CAAC;EACvD,aAAa,eAAe;EAE5B,OAAO;GACL;GACA;GACA;GACA;GACA,OAAO,kBAAkB,KAAK;GAC9B;GACA,SAAS,KAAA;GACT;GACA;GACA,YAAY;GACZ,KAAK,KAAA;GACL;EACF;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../internals/shared/src/operation.ts","../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/shared/src/resolver.ts","../../../internals/shared/src/group.ts","../kubb-extension.json","../package.json","../../../internals/client/src/builders/validatorOptions.ts","../../../internals/client/src/builders/security.ts","../../../internals/client/src/builders/validator.ts","../../../internals/client/src/builders/contentType.ts","../../../internals/client/src/builders/generics.ts","../../../internals/client/src/builders/returnStatement.ts","../../../internals/client/src/builders/signature.ts","../../../internals/client/src/builders/styles.ts","../../../internals/client/src/components/Operation.tsx","../../../internals/client/src/resolveOperationTypes.ts","../../../internals/client/src/generators/clientGenerator.tsx","../../../internals/client/src/macros.ts","../../../internals/client/src/resolver.ts","../src/generators/clientGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import { ast, type Group, type NodeCache, type Output, type Resolver, type ResolverFileParams, Url } from 'kubb/kit'\n\n/**\n * Builds the `ResolverFileParams` every operation generator passes to\n * `resolver.file`: a file named `name`, tagged by the operation's first\n * tag (or `'default'`), at the operation's path. Centralizes the entry object\n * that was repeated at dozens of call sites across the client and query plugins.\n *\n * @example\n * ```ts\n * resolver.file(operationFileEntry(node, node.operationId), { root, output, group })\n * ```\n */\nexport function operationFileEntry(node: ast.OperationNode, name: string, extname: ResolverFileParams['extname'] = '.ts'): ResolverFileParams {\n return {\n name,\n extname,\n tag: node.tags[0] ?? 'default',\n path: node.path,\n }\n}\n\n/**\n * Resolves a dependency plugin's generated file for `node.operationId`, cached in `cache` (the\n * current node's `ctx.cache`) under the resolver's own plugin name. Several dependents reading the\n * same dependency for the same operation in one pass (a query plugin's several hook generators, the\n * MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.\n *\n * @example Cache `plugin-ts`'s file for the current operation\n * ```ts\n * const fileTs = resolveDependencyOperationFile({ cache: ctx.cache, node, resolver: tsResolver, root, output })\n * ```\n */\nexport function resolveDependencyOperationFile(options: {\n cache: NodeCache\n node: ast.OperationNode\n resolver: Pick<Resolver, 'file' | 'pluginName'>\n root: string\n output: Output\n group?: Group | null\n}): ast.FileNode {\n const { cache, node, resolver, root, output, group } = options\n\n return cache.ensureItem(`${resolver.pluginName}:operationFile`, () =>\n resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\n )\n}\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type OperationCommentLink = 'pathTemplate' | 'urlPath' | false | ((node: ast.OperationNode) => string | undefined)\n\nexport type BuildOperationCommentsOptions = {\n link?: OperationCommentLink\n linkPosition?: 'beforeDeprecated' | 'afterDeprecated'\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<ast.ParameterNode['in'], Array<ast.ParameterNode>>\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\nfunction getOperationLink(node: ast.OperationNode, link: OperationCommentLink): string | null {\n if (!link) {\n return null\n }\n\n if (typeof link === 'function') {\n return link(node) ?? null\n }\n\n return node.path ? `{@link ${Url.toPath(node.path)}}` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(node.requestBody?.content?.map((e) => e.contentType) ?? [])\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(getPrimarySuccessResponse(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\nexport type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n\n/**\n * Reads the single base content type of an operation's primary success response, lowercased and\n * stripped of any `; charset=...` suffix. Returns `undefined` when the response declares zero or\n * more than one content type, since neither case has a single type to act on.\n */\nfunction getPrimarySuccessContentType(node: ast.OperationNode): string | undefined {\n const contentTypes = getPrimarySuccessResponse(node)?.content?.map((entry) => entry.contentType) ?? []\n if (contentTypes.length !== 1) return undefined\n return contentTypes[0]!.split(';')[0]!.trim().toLowerCase()\n}\n\n/**\n * Whether an operation streams its primary success response as Server-Sent Events\n * (`text/event-stream`). The client generator uses this to return a typed event stream instead of a\n * one-shot `RequestResult`.\n */\nexport function isEventStream(node: ast.OperationNode): boolean {\n return getPrimarySuccessContentType(node) === 'text/event-stream'\n}\n\n/**\n * Derives the default `responseType` for an operation from its primary success response.\n *\n * Returns a value only when that response declares a single non-JSON content type. `text/event-stream`\n * and other binary types (`application/octet-stream`, `application/pdf`, `image/*`, `audio/*`,\n * `video/*`) map to a stream or `'blob'`, and other `text/*` maps to `'text'`. Otherwise `undefined`,\n * leaving the runtime client's `Content-Type` auto-detection in charge.\n */\nexport function getResponseType(node: ast.OperationNode): ResponseType | undefined {\n const baseType = getPrimarySuccessContentType(node)\n if (!baseType) return undefined\n\n if (baseType === 'application/json' || baseType.endsWith('+json') || baseType === 'text/json') return undefined\n if (baseType === 'text/event-stream') return 'stream'\n if (baseType.startsWith('text/')) return 'text'\n if (baseType === 'application/octet-stream' || baseType === 'application/pdf' || /^(image|audio|video)\\//.test(baseType)) return 'blob'\n return undefined\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n// The request groups come from the grouped params, so `config` drops the data-shape keys to stay\n// assignable to `Options`, which omits them from `RequestConfig`.\nconst requestConfigBaseType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`\n\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n\n // Only the ambiguous side is offered: a single-type side has nothing to pick, so it stays baked in\n // the generated call.\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n return members.length ? `${requestConfigBaseType} & { contentType?: { ${members.join('; ')} } }` : requestConfigBaseType\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...). Unlike {@link buildRequestConfigType}, it never adds a\n * `contentType?:` member: query hooks wrap GET operations, which carry no request body to select a\n * content type for.\n */\nexport function buildClientOptionType(): string {\n return requestConfigBaseType\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n}\n\n/**\n * Which of the grouped request options an operation carries.\n */\nexport function getRequestGroups(node: ast.OperationNode): RequestGroups {\n const { path, query, header } = getOperationParameters(node)\n return {\n path: path.length > 0,\n query: query.length > 0,\n body: Boolean(node.requestBody?.content?.[0]?.schema),\n headers: header.length > 0,\n }\n}\n\nexport type RequestGroupOptionality = {\n groups: RequestGroups\n hasRequiredPath: boolean\n hasRequiredQuery: boolean\n hasRequiredHeader: boolean\n /**\n * Whether the grouped request parameter can default to `{}`. True only when no group carries a\n * required member, so every member is safe to omit.\n */\n isOptional: boolean\n}\n\n/**\n * Resolves which grouped request options an operation carries together with whether each group\n * holds a required member. The grouped parameter stays optional only when nothing inside it is\n * required, matching the generated `RequestConfig` type.\n */\nexport function getRequestGroupOptionality(node: ast.OperationNode): RequestGroupOptionality {\n const groups = getRequestGroups(node)\n const { path, query, header } = getOperationParameters(node)\n const hasRequiredPath = path.some((param) => param.required)\n const hasRequiredQuery = query.some((param) => param.required)\n const hasRequiredHeader = header.some((param) => param.required)\n\n return {\n groups,\n hasRequiredPath,\n hasRequiredQuery,\n hasRequiredHeader,\n isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !groups.body,\n }\n}\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: RequestGroups } {\n const { isConfigurable = true } = options\n const { groups, isOptional } = getRequestGroupOptionality(node)\n\n const names = (['path', 'query', 'body', 'headers'] as const).filter((key) => groups[key])\n\n // 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\nconst typeNamesByResolver = new WeakMap<OperationTypeNameResolver, Map<string, string[]>>()\n\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const cacheKey = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n let byResolver = typeNamesByResolver.get(resolver)\n if (byResolver) {\n const cached = byResolver.get(cacheKey)\n if (cached) return cached\n } else {\n byResolver = new Map()\n typeNamesByResolver.set(resolver, byResolver)\n }\n\n const { path, query, header } = getOperationParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ]\n const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n const result = names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n byResolver.set(cacheKey, result)\n return result\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = getStatusCodeNumber(response.statusCode)\n if (code === null) {\n continue\n }\n\n types.push([code, isSuccessStatusCode(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n","type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction convert(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n// Plugins resolve the same names over and over (about 47,000 calls for a 1,000 schema spec), so\n// results are kept. Clearing at the limit bounds the memory a long-running process spends on it.\nconst cache = new Map<string, string>()\nconst cacheLimit = 10_000\n\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const key = `${pascal ? 'P' : 'c'}${text}`\n const cached = cache.get(key)\n if (cached !== undefined) return cached\n\n const result = convert(text, pascal)\n if (cache.size >= cacheLimit) cache.clear()\n cache.set(key, result)\n return result\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Uppercases only the first character of `text`, leaving the rest untouched.\n * Unlike {@link pascalCase} it never re-splits word boundaries or strips characters.\n *\n * @example\n * `capitalize('getPetById') // 'GetPetById'`\n */\nexport function capitalize(text: string): string {\n return `${text.charAt(0).toUpperCase()}${text.slice(1)}`\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example From camelCase\n * `snakeCase('helloWorld') // 'hello_world'`\n *\n * @example From mixed separators\n * `snakeCase('Hello-World') // 'hello_world'`\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example From camelCase\n * `screamingSnakeCase('helloWorld') // 'HELLO_WORLD'`\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'await',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `name` when it's a syntactically valid JavaScript variable name,\n * otherwise prefixes it with `_` so the result is a valid identifier.\n *\n * Useful for sanitizing OpenAPI schema names or operation IDs that start with\n * a digit (e.g. `409`, `504AccountCancel`) before using them as exported\n * variable, type, or function names.\n *\n * @example\n * ```ts\n * ensureValidVarName('409') // '_409'\n * ensureValidVarName('504AccountCancel') // '_504AccountCancel'\n * ensureValidVarName('Pet') // 'Pet'\n * ensureValidVarName('class') // '_class'\n * ```\n */\nexport function ensureValidVarName(name: string): string {\n if (!name || isValidVarName(name)) {\n return name\n }\n return `_${name}`\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase, ensureValidVarName, toFilePath } from '@internals/utils'\nimport type { ast, Resolver, ResolverFile } from 'kubb/kit'\n\nexport function resolveOperationName(name: string): string {\n return ensureValidVarName(camelCase(name))\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 * Resolves a single operation parameter name with the\n * `<operationId> <in> <name>` template.\n *\n * @example\n * `operationParamName.call(resolver, node, param) // → 'DeletePetPathPetId'`\n */\nfunction operationParamName(this: Resolver, node: ast.OperationNode, param: ast.ParameterNode): string {\n return this.name(`${node.operationId} ${param.in} ${param.name}`)\n}\n\n/**\n * Builds the shared `param` namespace. Spread the result into `createResolver`\n * and override individual methods next to it when a plugin deviates.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ param: createOperationParamResolver(), ... })\n * ```\n */\nexport function createOperationParamResolver(): OperationParamResolver {\n return {\n name: operationParamName,\n path(node) {\n return this.name(`${node.operationId} Path`)\n },\n query(node) {\n return this.name(`${node.operationId} Query`)\n },\n headers(node) {\n return this.name(`${node.operationId} Headers`)\n },\n }\n}\n\n/**\n * Builds the shared `response` namespace. Spread the result into\n * `createResolver` and add plugin-specific methods (`options`, `error`) next\n * to it.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ response: { ...createOperationResponseResolver(), options(node) {...} }, ... })\n * ```\n */\nexport function createOperationResponseResolver(): OperationResponseResolver {\n return {\n status(node, statusCode) {\n return this.name(`${node.operationId} Status ${statusCode}`)\n },\n body(node) {\n return this.name(`${node.operationId} Body`)\n },\n responses(node) {\n return this.name(`${node.operationId} Responses`)\n },\n response(node) {\n return this.name(`${node.operationId} Response`)\n },\n }\n}\n\n/**\n * Builds a resolver `file` override whose base name runs every path segment\n * through `toFilePath`, casing the final segment with `caseLast`.\n *\n * @example\n * ```ts\n * createResolver<PluginTs>({ file: createCasedFile(pascalCase), ... })\n * ```\n */\nexport function createCasedFile(caseLast: (part: string) => string): ResolverFile {\n return {\n baseName({ name, extname }) {\n return `${toFilePath(name, caseLast)}${extname}`\n },\n }\n}\n","import { camelCase } from '@internals/utils'\nimport type { Group } from 'kubb/kit'\n\n/**\n * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the\n * shared default naming so every plugin groups output consistently:\n *\n * - `path` groups use the second path segment (`/pet/findByStatus` → `pet`).\n * - other groups use the camelCased group (`pet store` → `petStore`).\n *\n * A user-provided `group.name` always wins over the default namer, so callers stay in\n * control of their output folders. Returns `null` when grouping is disabled, matching the\n * per-plugin convention.\n *\n * @param group - The user-supplied group option, or `undefined` to disable grouping.\n *\n * @example\n * ```ts\n * createGroupConfig(group) // shared across every plugin\n * ```\n */\nexport function createGroupConfig(group: Group | undefined): Group | null {\n if (!group) {\n return null\n }\n\n const defaultName = (ctx: { group: string }): string => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n\n return camelCase(ctx.group)\n }\n\n return {\n ...group,\n name: group.name ? group.name : defaultName,\n } satisfies Group\n}\n","","","import { isSuccessStatusCode } from '@internals/shared'\nimport type { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport type { ValidatorOptions } from '../types.ts'\n\n/**\n * Returns `true` when any direction of the validator uses zod (used for dependency checks).\n */\nexport function isValidatorEnabled(validator: ValidatorOptions | undefined): boolean {\n if (!validator) return false\n if (validator === 'zod') return true\n return Boolean(validator.request || validator.params || validator.response)\n}\n\n/**\n * Returns `'zod'` when request body parsing is enabled, `null` otherwise. The string shorthand\n * `'zod'` validates the response only, so it does not enable request parsing.\n */\nexport function resolveRequestValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator || validator === 'zod') return null\n return validator.request ?? null\n}\n\n/**\n * Returns `'zod'` when path, query, and header params parsing is enabled, `null` otherwise. Only the\n * object form `{ params: 'zod' }` enables it.\n */\nexport function resolveParamsValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator || validator === 'zod') return null\n return validator.params ?? null\n}\n\n/**\n * Returns `'zod'` when response parsing is enabled, `null` otherwise. The string shorthand `'zod'`\n * maps to response parsing.\n */\nexport function resolveResponseValidator(validator: ValidatorOptions | undefined): 'zod' | null {\n if (!validator) return null\n if (validator === 'zod') return 'zod'\n return validator.response ?? null\n}\n\n/**\n * Resolves the zod schema name a generated client validates an error body with on the non-throw path.\n * Uses the error-only `<operation>ErrorSchema` (the union of non-2xx statuses); returns `null` when the\n * operation documents no error responses with a schema.\n */\nexport function buildZodErrorParse(node: ast.OperationNode, zodResolver: ResolverZod): string | null {\n const hasErrorResponse = node.responses.some((res) => !isSuccessStatusCode(res.statusCode) && res.content?.some((entry) => entry.schema))\n if (!hasErrorResponse) return null\n return zodResolver.response.error?.(node) || null\n}\n","/**\n * A resolved security scheme as emitted on each generated call's `security` array. The runtime calls\n * the configured `auth` resolver with this object and places the returned token: `http` bearer/basic\n * on `Authorization`, `apiKey` under `name` in the header/query/cookie, and `oauth2`/`openIdConnect`\n * as a bearer token.\n */\nexport type Auth = {\n type: 'http' | 'apiKey' | 'oauth2' | 'openIdConnect'\n scheme?: 'bearer' | 'basic'\n name?: string\n in?: 'header' | 'query' | 'cookie'\n scopes?: Array<string>\n}\n\n/**\n * A single OpenAPI security requirement read from the spec: scheme name to the scopes it needs.\n */\ntype SecurityRequirement = Record<string, Array<string>>\n\n/**\n * The slice of an OpenAPI document the security derivation reads: the global `security`, the\n * per-operation `security` under `paths`, and the `securitySchemes` map under `components`. Typed\n * locally so this package stays independent of the OpenAPI adapter.\n */\nexport type SecurityDocument = {\n security?: Array<SecurityRequirement>\n components?: {\n securitySchemes?: Record<string, OasSecurityScheme | { $ref: string } | undefined>\n }\n paths?: Record<string, Record<string, { security?: Array<SecurityRequirement> } | undefined> | undefined>\n}\n\ntype OasSecurityScheme = { type: 'http'; scheme?: string } | { type: 'apiKey'; name?: string; in?: string } | { type: 'oauth2' } | { type: 'openIdConnect' }\n\nfunction serializeAuth(auth: Auth): string {\n const parts = [`type: '${auth.type}'`]\n if (auth.scheme) parts.push(`scheme: '${auth.scheme}'`)\n if (auth.name) parts.push(`name: '${auth.name}'`)\n if (auth.in) parts.push(`in: '${auth.in}'`)\n if (auth.scopes?.length) parts.push(`scopes: [${auth.scopes.map((scope) => `'${scope}'`).join(', ')}]`)\n return `{ ${parts.join(', ')} }`\n}\n\n/**\n * Maps an OpenAPI security scheme to the inline `Auth` object, or `null` when the runtime cannot\n * place it (an unresolved `$ref`, or an `apiKey` without a name or outside `header` / `query` /\n * `cookie`). `http` schemes other than `basic` are treated as bearer.\n */\nexport function resolveSecurityScheme(scheme: OasSecurityScheme | { $ref: string } | undefined): Auth | null {\n if (!scheme || '$ref' in scheme) return null\n if (scheme.type === 'apiKey') {\n if (!scheme.name || (scheme.in !== 'header' && scheme.in !== 'query' && scheme.in !== 'cookie')) return null\n return { type: 'apiKey', name: scheme.name, in: scheme.in }\n }\n if (scheme.type === 'http') return { type: 'http', scheme: scheme.scheme?.toLowerCase() === 'basic' ? 'basic' : 'bearer' }\n if (scheme.type === 'oauth2') return { type: 'oauth2' }\n if (scheme.type === 'openIdConnect') return { type: 'openIdConnect' }\n return null\n}\n\n/**\n * Derives the per-operation security metadata from the OpenAPI document. The operation's own\n * `security` overrides the global `security` (an explicit empty array disables auth), and every\n * referenced scheme is resolved from `components.securitySchemes` into a flat, de-duplicated list of\n * `Auth` objects the runtime walks in order.\n *\n * @example\n * `getOperationSecurity({ document, method: 'POST', path: '/pet' })`\n * `// [{ type: 'http', scheme: 'bearer' }]`\n */\nexport function getOperationSecurity({\n document,\n method,\n path,\n}: {\n document: SecurityDocument | null | undefined\n method: string\n path: string\n}): Array<Auth> | undefined {\n if (!document) return undefined\n\n const operation = document.paths?.[path]?.[method.toLowerCase()]\n const requirements = operation?.security ?? document.security\n if (!requirements?.length) return undefined\n\n const definitions = document.components?.securitySchemes ?? {}\n const security: Array<Auth> = []\n const seen = new Set<string>()\n for (const requirement of requirements) {\n for (const [schemeName, scopes] of Object.entries(requirement)) {\n if (seen.has(schemeName)) continue\n seen.add(schemeName)\n const auth = resolveSecurityScheme(definitions[schemeName])\n if (auth) security.push(scopes.length ? { ...auth, scopes } : auth)\n }\n }\n\n return security.length ? security : undefined\n}\n\n/**\n * Serializes the per-operation security into the literal emitted on each generated call's `security`\n * field. The runtime `resolveAuth` helper walks it, calling the configured `auth` resolver per entry.\n *\n * @example\n * `buildSecurityMetadata({ security: [{ type: 'http', scheme: 'bearer' }] }) // \"[{ type: 'http', scheme: 'bearer' }]\"`\n */\nexport function buildSecurityMetadata({ security }: { security?: Array<Auth> }): string | null {\n if (!security?.length) return null\n return `[${security.map(serializeAuth).join(', ')}]`\n}\n","import { getOperationParameters } from '@internals/shared'\nimport type { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport type { ValidatorOptions } from '../types.ts'\nimport { buildZodErrorParse, resolveParamsValidator, resolveRequestValidator, resolveResponseValidator } from './validatorOptions.ts'\n\n/**\n * The per-call validator references a generated function wires into its request config. Each hook is\n * the bare schema reference passed to the runtime's `validator.request` / `validator.path` /\n * `validator.query` / `validator.headers` / `validator.response` / `validator.error` slot; `client.ts`\n * runs it through `validateStandardSchema`. The response validator only ever sees success (2xx) bodies.\n */\nexport type ValidatorHooks = {\n /**\n * Schema reference for the `validator.request` hook, or `null` when request validation is off.\n */\n request: string | null\n /**\n * Schema references for the `validator.path` / `query` / `headers` hooks (`headers` wrapped in\n * `toHeadersStandardSchema`), or `null` when params validation is off or the group is empty.\n */\n path: string | null\n query: string | null\n headers: string | null\n /**\n * Schema reference for the `validator.response` hook, or `null` when response validation is off.\n */\n response: string | null\n /**\n * Schema reference for the `validator.error` hook, or `null` when error validation is off or the\n * operation documents no error responses. The runtime runs this on the error body when a non-2xx\n * call does not throw.\n */\n error: string | null\n /**\n * Zod schema names the generated file imports from the zod plugin output.\n */\n importedZodNames: Array<string>\n}\n\n/**\n * Builds the validator-hook references for one operation. Request body and params validation run before the send.\n * Response validation runs on the success body only. Returns `null` references when the matching\n * direction is disabled or the schema is absent.\n */\nexport function buildValidatorHooks({\n node,\n validator,\n zodResolver,\n}: {\n node: ast.OperationNode\n validator: ValidatorOptions | undefined\n zodResolver: ResolverZod | null | undefined\n}): ValidatorHooks {\n const hasRequestBody = Boolean(node.requestBody?.content?.[0]?.schema)\n const parsesResponse = zodResolver && resolveResponseValidator(validator) === 'zod'\n\n // Success responses validate with the success-only `<operation>ResponseSchema`; error bodies are never zod-parsed on the throw path.\n const response = parsesResponse ? zodResolver.response.response(node) || null : null\n const error = parsesResponse ? buildZodErrorParse(node, zodResolver) : null\n const request = zodResolver && resolveRequestValidator(validator) === 'zod' && hasRequestBody ? zodResolver.response.body(node) || null : null\n\n const paramGroups = getOperationParameters(node)\n const resolveParamsName = (kind: 'path' | 'query' | 'headers', params: Array<ast.ParameterNode>): string | null =>\n zodResolver && resolveParamsValidator(validator) === 'zod' && params.length > 0 ? zodResolver.param[kind](node, params[0]!) : null\n const path = resolveParamsName('path', paramGroups.path)\n const query = resolveParamsName('query', paramGroups.query)\n const headers = resolveParamsName('headers', paramGroups.header)\n\n // Order is output: the generated file imports the response schema, then the error schema, then the request body and params schemas.\n const importedZodNames = [response, error, request, path, query, headers].filter((name): name is string => Boolean(name))\n\n const headersValidator = headers ? `toHeadersStandardSchema(${headers}, ${headers}.shape)` : null\n\n return { request, path, query, headers: headersValidator, response, error, importedZodNames }\n}\n\n/**\n * Prints the `validator: { … }` entry of a call config from the hooks named in `keys`, or `null` when none is set.\n */\nexport function buildValidatorLiteral(hooks: ValidatorHooks | null, keys: ReadonlyArray<keyof Omit<ValidatorHooks, 'importedZodNames'>>): string | null {\n const entries = keys.flatMap((key) => (hooks?.[key] ? [`${key}: ${hooks[key]}`] : []))\n return entries.length ? `validator: { ${entries.join(', ')} }` : null\n}\n","import { getContentTypeInfo, getResponseContentTypeInfo } from '@internals/shared'\nimport { ast } from 'kubb/kit'\n\n/**\n * Builds the `contentType` entry baked into the call config, or `null` for the JSON default.\n *\n * `merge` is `true` when the generated function must destructure `contentType` from `options` and\n * merge it over the baked request default, because the caller can also pick a response content type.\n */\nexport function buildContentType({ node }: { node: ast.HttpOperationNode }): { literal: string | null; merge: boolean } {\n const { defaultContentType } = getContentTypeInfo(node)\n const hasRequestBody = Boolean(node.requestBody?.content?.[0]?.schema)\n // Bake the request body content type only when it is not the JSON default. The first declared type is\n // the default for an operation with several request types; the caller overrides it on `contentType`.\n const requestContentType = hasRequestBody && defaultContentType !== 'application/json' ? defaultContentType : null\n\n if (!requestContentType) return { literal: null, merge: false }\n\n // When the caller can also pick a response content type, a partial `{ response }` would replace the\n // baked request default through `...config`, so merge the caller's choice over it instead.\n const merge = getResponseContentTypeInfo(node).isMultipleContentTypes\n\n return {\n merge,\n literal: merge\n ? `contentType: { request: '${requestContentType}', ...(typeof contentType === 'string' ? { request: contentType } : contentType) }`\n : `contentType: { request: '${requestContentType}' }`,\n }\n}\n","import type { ast } from 'kubb/kit'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\n\n/**\n * Builds the `RequestResult` generic arguments for one operation: the per-status responses record\n * plus the per-call `ThrowOnError` flag. `SuccessOf` / `ErrorOf` split the record inside the\n * runtime, so this only names the record and threads `ThrowOnError`.\n *\n * @example\n * `buildRequestResultGenerics({ node, types }) // 'AddPetResponses, ThrowOnError'`\n */\nexport function buildRequestResultGenerics({ node, types }: { node: ast.OperationNode; types: OperationTypeNames }): string {\n return `${types.response.responses(node)}, ThrowOnError`\n}\n\n/**\n * Builds the full return type an operation's function signature uses: `Unwrappable<RequestResult>`\n * for the default `returnType: 'full'`, already a promise so no further wrapping is needed, a plain\n * `Promise<RequestResult>` for the internal `'plain'` shape, or a\n * `Promise` of the runtime's `UnwrappedResult` when `returnType: 'data'` narrows a resolved call\n * down to the bare success body.\n *\n * @example\n * `buildResultType({ node, types, returnType: 'data' }) // 'Promise<UnwrappedResult<AddPetResponses, ThrowOnError>>'`\n */\nexport function buildResultType({ node, types, returnType }: { node: ast.OperationNode; types: OperationTypeNames; returnType: ReturnTypeOption }): string {\n const generics = buildRequestResultGenerics({ node, types })\n if (returnType === 'data') return `Promise<UnwrappedResult<${generics}>>`\n if (returnType === 'plain') return `Promise<RequestResult<${generics}>>`\n return `Unwrappable<RequestResult<${generics}>>`\n}\n","import { hasRequestContentTypeChoice } from '@internals/shared'\nimport type { ast } from 'kubb/kit'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\nimport { buildRequestResultGenerics, buildResultType } from './generics.ts'\n\n/**\n * Builds the return statement of a generated operation function. With the default\n * `returnType: 'full'` the runtime call already resolves to `{ data, error, request, response }`.\n * The generated code casts that result to the operation's `RequestResult`, then wraps it with\n * `withUnwrap`, so the caller can `await` it directly or call `.unwrap()` for the bare success\n * body. With `returnType: 'data'` it instead routes the call through the runtime's `unwrapResult`,\n * which narrows the resolved value down to the bare success body the same way `RequestResult`\n * already does, using the plugin default when the call leaves `throwOnError` unset.\n * With `returnType: 'plain'` it returns the runtime call as is, cast to `RequestResult`, with no helper.\n *\n * Cast first, wrap second, for the `'full'` path. That order keeps `withUnwrap`'s generic inferred\n * as `RequestResult` instead of the runtime's own internal result type. Casting an `Unwrappable<A>`\n * straight to `Unwrappable<B>` does not work: the `.then` overload stays pinned to `A`, and `as`\n * rejects that two-generic swap even where `A` and `B` on their own would satisfy it.\n *\n * @example\n * `return withUnwrap(request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>)`\n * @example\n * `return unwrapResult(request({ method: 'POST', url: '/pet', ...config }), config.throwOnError ?? false) as Promise<UnwrappedResult<AddPetResponses, ThrowOnError>>`\n * @example\n * `return request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>`\n */\nexport function buildReturnStatement({\n node,\n types,\n callConfig,\n returnType,\n throwOnErrorDefault,\n}: {\n node: ast.OperationNode\n types: OperationTypeNames\n callConfig: string\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n}): string {\n // The options of a body offered in several media types are a union, so the body type cannot be inferred from `config`.\n // A `'plain'` client is the caller's own function, which takes no type argument.\n const request = returnType !== 'plain' && hasRequestContentTypeChoice(node) ? `request<${types.response.options(node)}['body']>` : 'request'\n if (returnType === 'data') {\n const resultType = buildResultType({ node, types, returnType })\n return `return unwrapResult(${request}(${callConfig}), config.throwOnError ?? ${throwOnErrorDefault}) as ${resultType}`\n }\n if (returnType === 'plain') {\n return `return ${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({ node, types })}>>`\n }\n return `return withUnwrap(${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({ node, types })}>>)`\n}\n","import type { ast } from 'kubb/kit'\nimport { getRequestGroupOptionality } from '@internals/shared'\nimport { createFunctionParameter, createFunctionParameters, functionPrinter } from '@kubb/plugin-ts'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption } from '../types.ts'\nimport { buildResultType } from './generics.ts'\n\nconst declarationPrinter = functionPrinter({ mode: 'declaration' })\n\n/**\n * The pieces of a generated operation function's grouped-options signature.\n */\nexport type GroupedOptionsSignature = {\n /**\n * The single function parameter: `options: Options<<Name>Options, ThrowOnError>`.\n */\n paramsSignature: string\n /**\n * The function return type: `Unwrappable<RequestResult<<Name>Responses, ThrowOnError>>`.\n */\n returnType: string\n /**\n * The function generics. One per-call `ThrowOnError` flag, defaulting to the plugin setting.\n */\n generics: Array<string>\n}\n\n/**\n * Builds the grouped-options signature for one operation: a single `options` object whose `TData`\n * is the `<Name>Options` type, and a `RequestResult` return type keyed to the per-status responses\n * record. There are no positional arguments.\n *\n * The generated file imports `<Name>Options` and `<Name>Responses` and uses them directly, so no\n * per-operation input type has to be emitted. Both names come from `types`, which is `plugin-ts` or\n * `plugin-zod`'s inferred types (see `resolveOperationTypes`).\n */\nexport function buildGroupedOptionsSignature({\n node,\n types,\n returnType,\n throwOnErrorDefault,\n}: {\n node: ast.OperationNode\n types: OperationTypeNames\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n}): GroupedOptionsSignature {\n const optionsName = types.response.options(node)\n const { isOptional } = getRequestGroupOptionality(node)\n\n const paramsSignature =\n declarationPrinter.print(\n createFunctionParameters({\n params: [createFunctionParameter({ name: 'options', type: `Options<${optionsName}, ThrowOnError>`, ...(isOptional ? { default: '{}' } : {}) })],\n }),\n ) ?? ''\n\n return {\n paramsSignature,\n returnType: buildResultType({ node, types, returnType }),\n generics: [`ThrowOnError extends boolean = ${throwOnErrorDefault}`],\n }\n}\n","import { isValidVarName } from '@internals/utils'\nimport { ast } from 'kubb/kit'\n\ntype StyledLocation = 'path' | 'query' | 'header' | 'cookie'\n\n/**\n * Renders a parameter name as an object-literal key, quoted when it is not a bare identifier. Every\n * location keeps the spec name: the runtime looks path styles up by the `{name}` placeholder in the\n * URL, and the other locations by the key it serializes.\n */\nfunction toKey(name: string): string {\n return isValidVarName(name) ? name : JSON.stringify(name)\n}\n\n/**\n * Serializes one parameter's metadata into a `{ style, explode, allowReserved, contentType }`\n * literal, or `null` when the parameter carries none. Path and query carry the serialization\n * `style`; header and cookie use a fixed style (`simple` and `form`), so only `explode` is emitted\n * for them. `allowReserved` only applies to query parameters, and `contentType` to every location\n * except path.\n */\nfunction serializeParameter(parameter: ast.ParameterNode): string | null {\n const parts: Array<string> = []\n if ((parameter.in === 'path' || parameter.in === 'query') && parameter.style) parts.push(`style: '${parameter.style}'`)\n if (parameter.explode !== undefined) parts.push(`explode: ${parameter.explode}`)\n if (parameter.in === 'query' && parameter.allowReserved !== undefined) parts.push(`allowReserved: ${parameter.allowReserved}`)\n if (parameter.in !== 'path' && parameter.contentType) parts.push(`contentType: '${parameter.contentType}'`)\n return parts.length > 0 ? `{ ${parts.join(', ')} }` : null\n}\n\n/**\n * Serializes the `encoding` of the request body's default content type into a `{ property: { ... } }`\n * literal, or `null` when it carries none. Only an operation with a single request content type\n * emits it, because the runtime applies `styles.body` to whichever type the caller selects.\n */\nfunction serializeBodyEncoding(node: ast.HttpOperationNode): string | null {\n const content = node.requestBody?.content\n const entries = Object.entries(content?.length === 1 ? (content[0]?.encoding ?? {}) : {}).map(\n ([property, { contentType, style, explode, allowReserved }]) => {\n const parts = [\n style && `style: ${JSON.stringify(style)}`,\n explode !== undefined && `explode: ${explode}`,\n allowReserved !== undefined && `allowReserved: ${allowReserved}`,\n contentType && `contentType: ${JSON.stringify(contentType)}`,\n ].filter(Boolean)\n return `${isValidVarName(property) ? property : JSON.stringify(property)}: { ${parts.join(', ')} }`\n },\n )\n\n return entries.length > 0 ? `body: { ${entries.join(', ')} }` : null\n}\n\n/**\n * Builds the per-operation `styles` literal from the operation's parameters, grouped by location.\n * Entries are keyed by the spec name of the parameter.\n * Only parameters whose source defines `style`, `explode`, `allowReserved`, or `contentType` are\n * emitted, so calls without serialization metadata keep the runtime defaults and existing output\n * is unchanged. A form request body adds a `body` group keyed by property name from its `encoding`.\n * Returns `null` when nothing carries metadata.\n *\n * @example\n * ```ts\n * // a path param with { style: 'matrix', explode: true } and a query param with { explode: false }\n * buildStyles({ node }) // \"{ path: { id: { style: 'matrix', explode: true } }, query: { tags: { explode: false } } }\"\n * ```\n */\nexport function buildStyles({ node }: { node: ast.OperationNode }): string | null {\n if (!ast.isHttpOperationNode(node)) return null\n\n const groups: Record<StyledLocation, Array<string>> = { path: [], query: [], header: [], cookie: [] }\n\n for (const parameter of node.parameters) {\n const literal = serializeParameter(parameter)\n if (!literal) continue\n groups[parameter.in].push(`${toKey(parameter.name)}: ${literal}`)\n }\n\n const entries = [\n ...(Object.keys(groups) as Array<StyledLocation>)\n .filter((location) => groups[location].length > 0)\n .map((location) => `${location}: { ${groups[location].join(', ')} }`),\n serializeBodyEncoding(node),\n ].filter(Boolean)\n\n return entries.length > 0 ? `{ ${entries.join(', ')} }` : null\n}\n","import { buildOperationComments, getResponseType, isEventStream } from '@internals/shared'\nimport { ast } from 'kubb/kit'\nimport type { ResolverZod } from '@kubb/plugin-zod'\nimport { File, Function } from 'kubb/jsx'\nimport type { KubbReactNode } from 'kubb/jsx'\nimport { buildContentType } from '../builders/contentType.ts'\nimport { buildReturnStatement } from '../builders/returnStatement.ts'\nimport { type Auth, buildSecurityMetadata } from '../builders/security.ts'\nimport { buildGroupedOptionsSignature } from '../builders/signature.ts'\nimport { buildStyles } from '../builders/styles.ts'\nimport { buildValidatorHooks, buildValidatorLiteral } from '../builders/validator.ts'\nimport type { OperationTypeNames } from '../resolveOperationTypes.ts'\nimport type { ReturnTypeOption, ValidatorOptions } from '../types.ts'\n\ntype Props = {\n /**\n * The generated function name.\n */\n name: string\n /**\n * The operation being generated.\n */\n node: ast.OperationNode\n /**\n * The operation type names the signature references, from `plugin-ts` or `plugin-zod`'s inferred\n * types.\n */\n types: OperationTypeNames\n /**\n * Resolver for the zod schema names the validators reference, when `validator` is on.\n */\n zodResolver?: ResolverZod | null\n /**\n * The active validator option, driving the validator-hook wiring.\n */\n validator?: ValidatorOptions\n /**\n * Shape of the value the generated function resolves to.\n */\n returnType: ReturnTypeOption\n throwOnErrorDefault: boolean\n /**\n * Per-operation security, resolved from the spec into inline `Auth` objects and serialized onto the\n * call config's `security` field for the runtime `auth` resolver to consume.\n */\n security?: Array<Auth>\n}\n\n/**\n * Renders one client operation: the grouped `<Name>Request` type and the function that forwards a\n * single `options` object to the resolved client and returns the `Unwrappable<RequestResult>`. The\n * type, signature, and call config are built with the AST factory, and only the jsx-renderer emits\n * the source.\n */\nexport function Operation({ name, node, types, zodResolver, validator, returnType, throwOnErrorDefault, security }: Props): KubbReactNode {\n if (!ast.isHttpOperationNode(node)) return null\n\n const signature = buildGroupedOptionsSignature({ node, types, returnType, throwOnErrorDefault })\n const validators = buildValidatorHooks({ node, validator, zodResolver })\n const securityLiteral = buildSecurityMetadata({ security })\n const stylesLiteral = buildStyles({ node })\n\n const { literal: contentTypeLiteral, merge: mergeContentType } = buildContentType({ node })\n\n const eventStream = isEventStream(node)\n const responseType = getResponseType(node)\n const responseTypeLiteral = responseType ? `responseType: '${responseType}'` : null\n\n const validatorLiteral = buildValidatorLiteral(validators, ['request', 'path', 'query', 'headers', 'response', 'error'])\n\n const callConfig = `{ ${[\n `method: '${node.method.toUpperCase()}'`,\n `url: '${node.path}'`,\n securityLiteral ? `security: ${securityLiteral}` : null,\n stylesLiteral ? `styles: ${stylesLiteral}` : null,\n validatorLiteral,\n contentTypeLiteral,\n responseTypeLiteral,\n '...config',\n `throwOnError: config.throwOnError ?? ${throwOnErrorDefault}`,\n ]\n .filter(Boolean)\n .join(', ')} }`\n\n const eventType = `SuccessOf<${types.response.responses(node)}>`\n const functionReturnType = eventStream ? `Promise<EventStreamResult<${eventType}>>` : signature.returnType\n const returnStatement = eventStream\n ? `return toEventStream<${eventType}>(request(${callConfig}))`\n : buildReturnStatement({ node, types, callConfig, returnType, throwOnErrorDefault })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n generics={signature.generics}\n params={signature.paramsSignature}\n returnType={functionReturnType}\n JSDoc={{ comments: buildOperationComments(node, { link: 'urlPath', linkPosition: 'beforeDeprecated', splitLines: true }) }}\n >\n {mergeContentType ? 'const { client: request = client, contentType, ...config } = options' : 'const { client: request = client, ...config } = options'}\n <br />\n {returnStatement}\n </Function>\n </File.Source>\n )\n}\n","import { type ast, Diagnostics, type Generator, type Group, type Output } from 'kubb/kit'\nimport { pluginTsName, type ResolverTs } from '@kubb/plugin-ts'\nimport { pluginZodName, type ResolverZod } from '@kubb/plugin-zod'\nimport type { ContractClientFactory } from './types.ts'\n\ntype GeneratorDriver = Parameters<NonNullable<Generator<ContractClientFactory>['operations']>>[1]['driver']\n\n/**\n * The two per-operation type names a generated client references: the grouped input and the\n * per-status responses record its `RequestResult` is keyed on.\n */\nexport type OperationTypeNames = {\n response: {\n /**\n * Resolves the name of the operation's grouped `{ body, path, query, headers }` input type.\n */\n options(node: ast.OperationNode): string\n /**\n * Resolves the name of the operation's per-status responses record type.\n */\n responses(node: ast.OperationNode): string\n }\n}\n\n/**\n * Where a generated client sources its operation types, plus the resolver and output the file\n * declaring them is resolved with.\n */\nexport type OperationTypeSource = OperationTypeNames & {\n /**\n * `plugin-ts` shaped resolver of the plugin supplying the names, also used to resolve the file they are exported from.\n */\n resolver: ResolverTs\n /**\n * The supplying plugin's own `output`, when it configured one.\n */\n output: Output | undefined\n /**\n * The supplying plugin's own `group`, when it configured one.\n */\n group: Group | undefined\n}\n\n/**\n * A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`\n * exports next to each schema, so code written against `plugin-ts` names picks up the zod types.\n */\nfunction toZodTypeResolver(resolver: ResolverZod): ResolverTs {\n const type = (name: string) => resolver.schema.type(name)\n\n return {\n ...resolver,\n // A class method, so a spread drops it, and it reads private fields, so it must run on `resolver`.\n file: resolver.file.bind(resolver),\n param: {\n name: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.name(node, p)),\n path: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.path(node, p)),\n query: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.query(node, p)),\n headers: (node: ast.OperationNode, p: ast.ParameterNode) => type(resolver.param.headers(node, p)),\n },\n response: {\n body: (node: ast.OperationNode) => type(resolver.response.body(node)),\n status: (node: ast.OperationNode, statusCode: ast.StatusCode) => type(resolver.response.status(node, statusCode)),\n response: (node: ast.OperationNode) => type(resolver.response.response(node)),\n responses: (node: ast.OperationNode) => type(resolver.response.responses(node)),\n options: (node: ast.OperationNode) => resolver.response.options(node),\n },\n } as unknown as ResolverTs\n}\n\n/**\n * Picks the plugin generated clients, query hooks, and MCP handlers take their operation types from.\n *\n * `pluginZod({ inferred: 'codec' })` wins, so a codec param takes its domain value. Otherwise `plugin-ts`\n * wins when it is in the pipeline, and without it any `pluginZod({ inferred })`. Throws\n * `KUBB_MISSING_DEPENDENCY` for `pluginName` when neither is available.\n *\n * @example\n * ```ts\n * const types = resolveOperationTypes(ctx.driver, ctx.plugin.name)\n * types.response.options(node) // 'GetPetByIdOptions', or 'GetPetByIdOptionsSchemaType' from zod\n * ```\n */\nexport function resolveOperationTypes(driver: GeneratorDriver, pluginName: string): OperationTypeSource {\n const pluginTs = driver.getPlugin(pluginTsName)\n const pluginZod = driver.getPlugin(pluginZodName)\n\n if (pluginTs && pluginZod?.options?.inferred !== 'codec') {\n const resolver = driver.getResolver(pluginTsName)\n return { response: resolver.response, resolver, output: pluginTs.options?.output, group: pluginTs.options?.group ?? undefined }\n }\n\n if (!pluginZod?.options?.inferred) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: `Plugin \"${pluginName}\" has no source for operation types.`,\n help: `Add \\`pluginTs()\\` before \"${pluginName}\", or add \\`pluginZod({ inferred: true })\\`.`,\n location: { kind: 'config' },\n plugin: pluginName,\n })\n }\n\n const resolver = toZodTypeResolver(driver.getResolver(pluginZodName))\n return { response: resolver.response, resolver, output: pluginZod.options.output, group: pluginZod.options.group ?? undefined }\n}\n","import path from 'node:path'\nimport { isEventStream, operationFileEntry, resolveDependencyOperationFile } from '@internals/shared'\nimport { ast, defineGenerator } from 'kubb/kit'\nimport type { Generator } from 'kubb/kit'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, jsxRenderer } from 'kubb/jsx'\nimport { isValidatorEnabled } from '../builders/validatorOptions.ts'\nimport { getOperationSecurity, type SecurityDocument } from '../builders/security.ts'\nimport { buildValidatorHooks } from '../builders/validator.ts'\nimport { Operation } from '../components/Operation.tsx'\nimport { resolveOperationTypes } from '../resolveOperationTypes.ts'\nimport type { ContractClientFactory } from '../types.ts'\n\n/**\n * Builds the built-in per-operation generator shared by the client plugins (`@kubb/plugin-fetch`,\n * `@kubb/plugin-axios`). Emits one async function per OpenAPI operation using the shared\n * `Operation` component: a grouped `<Name>Request` type and a function that forwards a single\n * `options` object to the bundled `client` and returns the `Unwrappable<RequestResult>`. Only the\n * generator `name` differs between plugins. Every other resolution, import, and rendering step is\n * identical.\n */\nexport function createClientGenerator<TFactory extends ContractClientFactory>(\n name: string,\n resolveClientPath?: (options: TFactory['resolvedOptions'], root: string) => string,\n): Generator<TFactory> {\n return defineGenerator<TFactory>({\n name,\n renderer: jsxRenderer,\n operation(node, ctx) {\n if (!ast.isHttpOperationNode(node)) return null\n\n const { config, driver, resolver, root } = ctx\n const { output, validator, returnType, throwOnErrorDefault, group } = ctx.options\n\n const types = resolveOperationTypes(driver, ctx.plugin.name)\n\n const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(pluginZodName) : null\n const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null\n\n const importedTypeNames = [types.response.options(node), types.response.responses(node)]\n\n const validatorHooks = buildValidatorHooks({ node, validator, zodResolver })\n const importedZodNames = validatorHooks.importedZodNames\n\n const meta = {\n name: resolver.name(node.operationId),\n file: resolver.file({ ...operationFileEntry(node, node.operationId), root, output, group: group ?? undefined }),\n fileTypes: resolveDependencyOperationFile({\n cache: ctx.cache,\n node,\n resolver: types.resolver,\n root,\n output: types.output ?? output,\n group: types.group,\n }),\n fileZod:\n zodResolver && pluginZod?.options\n ? zodResolver.file({\n ...operationFileEntry(node, node.operationId),\n root,\n output: pluginZod.options.output ?? output,\n group: pluginZod.options?.group ?? undefined,\n })\n : null,\n } as const\n\n const security = getOperationSecurity({\n document: ctx.adapter.document as SecurityDocument | null | undefined,\n method: node.method,\n path: node.path,\n })\n\n // A custom client module is emitted verbatim, so `importPath` is used exactly as configured.\n // The default `.kubb/client.ts` is a file path and is made relative to the operation file.\n const customClientPath = resolveClientPath?.(ctx.options, root)\n const clientPath = customClientPath ?? path.resolve(root, '.kubb/client.ts')\n const clientRoot = customClientPath === undefined ? meta.file.path : undefined\n // The headers validator helper ships in `.kubb/standardSchema.ts`; a custom client module exports it\n // alongside its other runtime helpers.\n const standardSchemaPath = customClientPath ?? path.resolve(root, '.kubb/standardSchema.ts')\n const eventStream = isEventStream(node)\n\n const clientValueImports = (() => {\n if (eventStream) return ['client', 'toEventStream']\n if (returnType === 'plain') return ['client']\n if (returnType === 'data') return ['client', 'unwrapResult']\n return ['client', 'withUnwrap']\n })()\n\n const clientTypeImports = (() => {\n if (eventStream) return ['Options', 'EventStreamResult', 'SuccessOf']\n if (returnType === 'plain') return ['Options', 'RequestResult']\n if (returnType === 'data') return ['Options', 'UnwrappedResult']\n return ['Options', 'Unwrappable', 'RequestResult']\n })()\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.default.banner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.default.footer(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n <File.Import name={clientValueImports} root={clientRoot} path={clientPath} />\n <File.Import name={clientTypeImports} root={clientRoot} path={clientPath} isTypeOnly />\n\n {meta.fileTypes && importedTypeNames.length > 0 && (\n <File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTypes.path} isTypeOnly />\n )}\n\n {meta.fileZod && importedZodNames.length > 0 && <File.Import name={importedZodNames} root={meta.file.path} path={meta.fileZod.path} />}\n {validatorHooks.headers && <File.Import name={['toHeadersStandardSchema']} root={clientRoot} path={standardSchemaPath} />}\n\n <Operation\n name={meta.name}\n node={node}\n types={types}\n zodResolver={zodResolver}\n validator={validator}\n returnType={returnType}\n throwOnErrorDefault={throwOnErrorDefault}\n security={security}\n />\n </File>\n )\n },\n })\n}\n","import { macroSimplifyUnion } from 'kubb/kit'\nimport type { ast } from 'kubb/kit'\n\n/**\n * Macros the client plugins apply by default, ahead of any user macros. `macroSimplifyUnion`\n * drops union members a broader scalar already covers, keeping the generated response and error\n * unions tidy. A plugin wires them with `ctx.setMacros([...defaultMacros, ...userMacros])`.\n */\nexport const defaultMacros: ReadonlyArray<ast.Macro> = [macroSimplifyUnion]\n","import { resolveOperationName } from '@internals/shared'\nimport { camelCase, ensureValidVarName, pascalCase } from '@internals/utils'\nimport { createResolver } from 'kubb/kit'\nimport type { PluginContractClient } from './types.ts'\n\n/**\n * Default resolver shared by the client plugins. Functions use safe camelCase identifiers and\n * files inherit the built-in casing; classes and tag groups use PascalCase.\n *\n * @example\n * ```ts\n * resolverClient.name('show pet by id') // 'showPetById'\n * resolverClient.groupName('pet') // 'PetClient'\n * ```\n */\nexport const resolverClient = createResolver<PluginContractClient>({\n pluginName: 'plugin-contract-client',\n name: resolveOperationName,\n className(name) {\n return ensureValidVarName(pascalCase(name))\n },\n groupName(name) {\n return ensureValidVarName(pascalCase(`${name} Client`))\n },\n propertyName(name) {\n return ensureValidVarName(camelCase(name))\n },\n})\n","import { createClientGenerator } from '@internals/client'\nimport type { PluginClient } from '../types.ts'\n\n/**\n * Built-in operation generator for `@kubb/plugin-client`. Emits one async function per OpenAPI\n * operation using the shared `Operation` component: a grouped `<Name>Request` type and a function\n * that forwards a single `options` object to the user-provided client module and returns the `RequestResult`.\n */\nexport const clientGenerator = createClientGenerator<PluginClient>('client', (options) => options.importPath)\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 { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { defaultMacros, isValidatorEnabled, resolverClient } from '@internals/client'\nimport type { PluginClient, ResolverClient } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-client`.\n */\nexport const pluginClientName = 'plugin-client' satisfies PluginClient['name']\n\n/**\n * Generates typed operations that call a client module owned by your application.\n * The module at `importPath` must export the runtime helpers and types used by generated operations.\n * Kubb does not copy or inject a transport implementation.\n *\n * @example\n * ```ts\n * pluginClient({ importPath: '../api/client' })\n * ```\n */\nexport const pluginClient = defineExtension<PluginClient>({\n kind: 'plugin',\n meta: { name: pluginClientName, version, compatibility },\n dependencies: (options) => ({ [pluginTsName]: { optional: true }, [pluginZodName]: { optional: !isValidatorEnabled(options.validator) } }),\n setup(options) {\n const {\n output = { path: 'clients', barrel: { type: 'named' } },\n exclude = [],\n include,\n override = [],\n importPath,\n throwOnErrorDefault = true,\n validator = false,\n group,\n resolver: userResolver,\n } = options\n\n const resolver = userResolver ? Resolver.merge<ResolverClient>(resolverClient, userResolver) : resolverClient\n\n setResolver(resolver)\n setMacros([...defaultMacros, ...(options.macros ?? [])])\n addGenerator(clientGenerator)\n\n return {\n output,\n exclude,\n include,\n override,\n group: createGroupConfig(group),\n importPath,\n baseURL: undefined,\n throwOnErrorDefault,\n validator,\n returnType: 'plain',\n sdk: undefined,\n resolver,\n }\n },\n})\n\nexport default pluginClient\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,SAAgB,mBAAmB,MAAyB,MAAc,UAAyC,OAA2B;CAC5I,OAAO;EACL;EACA;EACA,KAAK,KAAK,KAAK,MAAM;EACrB,MAAM,KAAK;CACb;AACF;;;;;;;;;;;;AAaA,SAAgB,+BAA+B,SAO9B;CACf,MAAM,EAAE,OAAO,MAAM,UAAU,MAAM,QAAQ,UAAU;CAEvD,OAAO,MAAM,WAAW,GAAG,SAAS,WAAW,uBAC7C,SAAS,KAAK;EAAE,GAAG,mBAAmB,MAAM,KAAK,WAAW;EAAG;EAAM;EAAQ,OAAO,SAAS,KAAA;CAAU,CAAC,CAC1G;AACF;AA8DA,SAAS,iBAAiB,MAAyB,MAA2C;CAC5F,IAAI,CAAC,MACH,OAAO;CAGT,IAAI,OAAO,SAAS,YAClB,OAAO,KAAK,IAAI,KAAK;CAGvB,OAAO,KAAK,OAAO,UAAU,IAAI,OAAO,KAAK,IAAI,EAAE,KAAK;AAC1D;;;;;AAMA,SAAS,qBAAqB,cAAyC;CACrE,MAAM,yBAAyB,aAA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,CAAE,CAAC;EACvD,aAAa,eAAe;EAE5B,OAAO;GACL;GACA;GACA;GACA;GACA,OAAO,kBAAkB,KAAK;GAC9B;GACA,SAAS,KAAA;GACT;GACA;GACA,YAAY;GACZ,KAAK,KAAA;GACL;EACF;CACF;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "5.8.0-canary.20261025T201031",
3
+ "version": "5.9.0-canary.20261025T213930",
4
4
  "description": "Generate typed API operations against your own client module.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -52,12 +52,12 @@
52
52
  "registry": "https://registry.npmjs.org/"
53
53
  },
54
54
  "dependencies": {
55
- "@kubb/plugin-ts": "^5.3.0-canary.20261025T201031",
56
- "@kubb/plugin-zod": "^5.8.0-canary.20261025T201031"
55
+ "@kubb/plugin-ts": "^5.4.0-canary.20261025T213930",
56
+ "@kubb/plugin-zod": "^5.8.0-canary.20261025T213930"
57
57
  },
58
58
  "devDependencies": {
59
- "@internals/client": "0.1.0-canary.20261025T201031",
60
- "@internals/shared": "0.1.0-canary.20261025T201031",
59
+ "@internals/client": "0.1.0-canary.20261025T213930",
60
+ "@internals/shared": "0.1.0-canary.20261025T213930",
61
61
  "kubb": "^5.14.2",
62
62
  "typescript": "^7.0.2"
63
63
  },