@kubb/plugin-cypress 5.5.0-canary.20261123T120417 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -436,16 +436,15 @@ ${compositeLines} const text = value instanceof Date ? value.toISOString() : St
436
436
  children: requestCall
437
437
  });
438
438
  }
439
- // src/generators/cypressGenerator.tsx
439
+ // src/templates/cypress.tsx
440
440
  /**
441
- * Built-in generator for `@kubb/plugin-cypress`. Emits one typed
441
+ * Built-in template for `@kubb/plugin-cypress`. Emits one typed
442
442
  * `cy.request()` wrapper per OpenAPI operation, ready to call inside Cypress
443
443
  * test specs and custom commands.
444
444
  */
445
- const cypressGenerator = (0, _kubb_kit.defineGenerator)({
446
- name: "cypress",
447
- renderer: _kubb_renderer_jsx.jsxRenderer,
448
- operation(node, ctx) {
445
+ const cypressOperation = (0, _kubb_kit.defineTemplate)({
446
+ kind: _kubb_ast.node.kinds.operation,
447
+ render(node, ctx) {
449
448
  if (!isOperation(node)) return null;
450
449
  const { baseURL } = ctx.options;
451
450
  const types = ctx.from(_kubb_plugin_ts.pluginTsName);
@@ -480,7 +479,7 @@ var compatibility = {
480
479
  "node": ">=22.22"
481
480
  };
482
481
  // package.json
483
- var version = "5.5.0-canary.20261123T120417";
482
+ var version = "5.5.0";
484
483
  // src/resolvers/resolverCypress.ts
485
484
  /**
486
485
  * Default resolver used by `@kubb/plugin-cypress`. Decides the names and file
@@ -542,8 +541,8 @@ const pluginCypress = (0, _kubb_kit.defineExtension)({
542
541
  }, group, exclude = [], include, override = [], baseURL, resolver: userResolver, macros: userMacros } = options;
543
542
  const resolver = userResolver ? _kubb_kit.Resolver.merge(resolverCypress, ...[userResolver].flat()) : resolverCypress;
544
543
  (0, _kubb_kit.setResolver)(resolver);
545
- if (userMacros?.length) (0, _kubb_kit.setMacros)(userMacros);
546
- (0, _kubb_kit.addGenerator)(cypressGenerator);
544
+ (0, _kubb_kit.addMacro)(...userMacros ?? []);
545
+ (0, _kubb_kit.addTemplate)(cypressOperation);
547
546
  return {
548
547
  output,
549
548
  exclude,
@@ -555,7 +554,7 @@ const pluginCypress = (0, _kubb_kit.defineExtension)({
555
554
  }
556
555
  });
557
556
  exports.Request = Request;
558
- exports.cypressGenerator = cypressGenerator;
557
+ exports.cypressOperation = cypressOperation;
559
558
  exports.default = pluginCypress;
560
559
  exports.pluginCypress = pluginCypress;
561
560
  exports.pluginCypressName = pluginCypressName;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["ast","file","ast.http.getRequestGroups","ast.http.responses.findPrimary","ast.http.responses.filterError","ast.http.groupParameters","ast.http.requestBody.getSchema","casing","Url","text","ast.http.requestBody.getSchema","Function","defineGenerator","jsxRenderer","ast.http.isOperation","pluginTsName","code","operationKey","File","ast.imports.asType","createResolver","defineExtension","pluginTsName","Resolver"],"sources":["../../../internals/ast/src/http/requestBody.ts","../../../internals/ast/src/http/status.ts","../../../internals/ast/src/http/responses.ts","../../../internals/ast/src/http/index.ts","../../../internals/ast/src/imports.ts","../../../internals/utils/src/reserved.ts","../../../internals/shared/src/operation.ts","../../../internals/shared/src/resolver.ts","../src/components/Request.tsx","../src/generators/cypressGenerator.tsx","../kubb-extension.json","../package.json","../src/resolvers/resolverCypress.ts","../src/plugin.ts"],"sourcesContent":["import type { OperationNode, SchemaNode } from '@kubb/ast'\n\n/** The schema of the first request body entry, else `undefined` when the operation takes no body. */\nexport function getSchema(node: Pick<OperationNode, 'requestBody'>): SchemaNode | undefined {\n return node.requestBody?.content?.[0]?.schema\n}\n","import type { ResponseNode, StatusCode } from '@kubb/ast'\n\ntype StatusInput = StatusCode | number | (string & {}) | Pick<ResponseNode, 'statusCode'>\n\nconst classByRange = new Map([\n ['1xx', 1],\n ['2xx', 2],\n ['3xx', 3],\n ['4xx', 4],\n ['5xx', 5],\n])\n\n/** The class digit of a status code or range: `2` for `201` and `2xx`, `null` for `default`. */\nfunction statusClass(input: StatusInput): number | null {\n const statusCode = typeof input === 'object' ? input.statusCode : input\n const rangeClass = classByRange.get(String(statusCode))\n if (rangeClass) return rangeClass\n const code = Number(statusCode)\n return Number.isNaN(code) ? null : Math.floor(code / 100)\n}\n\nexport { statusClass as getClass }\n\nexport function isSuccess(statusCode: StatusInput): boolean {\n return statusClass(statusCode) === 2\n}\n\nexport function isError(statusCode: StatusInput): boolean {\n const code = statusClass(statusCode)\n return code !== null && code >= 4\n}\n\n/** One concrete code for a status or range: `200` for `2xx` and `default`, the code itself otherwise. */\nexport function toCode(input: StatusInput): number {\n const statusCode = typeof input === 'object' ? input.statusCode : input\n const code = Number(statusCode)\n return Number.isNaN(code) ? (statusClass(statusCode) ?? 2) * 100 : code\n}\n","import { ast, type HttpOperationNode, type OperationNode, type ResponseNode, type SchemaNode } from '@kubb/ast'\nimport { isError, isSuccess } from './status.ts'\n\n/** The `4xx` and `5xx` responses, ranges included. */\nexport function filterError(node: Pick<HttpOperationNode, 'responses'>): Array<ResponseNode> {\n return node.responses.filter((response) => isError(response.statusCode))\n}\n\n/** The ref names the response bodies import, in order, with repeats. */\nexport function getImportedNames(responses: ReadonlyArray<ResponseNode>): Array<string> {\n return responses.flatMap((response) => (response.content ?? []).flatMap((entry) => (entry.schema ? ast.graph.getImportedNames(entry.schema) : [])))\n}\n\nexport function filterSuccess(node: Pick<HttpOperationNode, 'responses'>): Array<ResponseNode> {\n return node.responses.filter((response) => isSuccess(response.statusCode))\n}\n\n/** The success response a client returns: one with a body first, then an exact code over a `2xx` range. */\nexport function findPrimary(node: Pick<HttpOperationNode, 'responses'>): ResponseNode | null {\n const responses = filterSuccess(node)\n const withBody = responses.filter((response) => response.content?.some((entry) => entry.contentType))\n const candidates = withBody.length ? withBody : responses\n return candidates.find((response) => !Number.isNaN(Number(response.statusCode))) ?? candidates[0] ?? null\n}\n\n/** A union of refs to the success responses with a body, else every response with a body, else `null`. */\nexport function getUnion<TNode extends Pick<OperationNode, 'responses'>>(\n node: TNode,\n resolver: { response: { status(node: TNode, statusCode: ResponseNode['statusCode']): string } },\n): SchemaNode | null {\n const withSchema = node.responses.filter((response) => response.content?.some((entry) => entry.schema))\n const success = withSchema.filter((response) => isSuccess(response.statusCode))\n const responses = success.length > 0 ? success : withSchema\n if (responses.length === 0) return null\n\n return ast.factory.createSchema({\n type: 'union',\n members: responses.map((response) => ast.factory.createSchema({ type: 'ref', name: resolver.response.status(node, response.statusCode) })),\n })\n}\n","import { ast, type HttpOperationNode, type InputServer, type ParameterNode } from '@kubb/ast'\n\nexport const isOperation = ast.http.isOperation\nexport * as requestBody from './requestBody.ts'\nexport * as responses from './responses.ts'\nexport * as status from './status.ts'\n\n/** The server's URL when it is absolute and has no template variables, else `undefined`. */\nexport function getBaseURL(server: InputServer | undefined): string | undefined {\n if (!server || server.variables || server.url.includes('{') || !server.url.includes('://')) return undefined\n return URL.canParse(server.url) ? server.url : undefined\n}\n\n/** Computes once per key; generators visit the same node many times. */\nfunction cached<TKey extends object, TValue>(store: WeakMap<TKey, TValue>, key: TKey, compute: () => TValue): TValue {\n if (!store.has(key)) store.set(key, compute())\n return store.get(key)!\n}\n\ntype ParameterGroups = Record<'path' | 'query' | 'header' | 'cookie', Array<ParameterNode>>\n\n// Every plugin's generator visits the same node, so the groups are built once per node.\nconst parametersByNode = new WeakMap<Pick<HttpOperationNode, 'parameters'>, ParameterGroups>()\n\n/** The operation's parameters by location, with a `querystring` parameter in `query`. A repeated name keeps its first parameter. */\nexport function groupParameters(node: Pick<HttpOperationNode, 'parameters'>): ParameterGroups {\n return cached(parametersByNode, node, () => {\n const group = (...locations: Array<ParameterNode['in']>) => {\n const seen = new Set<string>()\n return locations.flatMap((location) =>\n 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 // A `querystring` parameter left whole, such as a JSON one, is sent as the query string, so it joins the query group.\n return { path: group('path'), query: group('query', 'querystring'), header: group('header'), cookie: group('cookie') }\n })\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n cookies: boolean\n /** `cookies` is never required: a browser sends its cookies itself. */\n required: { path: boolean; query: boolean; headers: boolean; body: boolean }\n /** No group holds a required member. */\n isOptional: boolean\n contentTypes: Array<string>\n /** More than one body media type has a schema, so a caller must pick one. */\n hasContentTypeChoice: boolean\n}\n\nconst requestGroupsByNode = new WeakMap<Pick<HttpOperationNode, 'parameters' | 'requestBody'>, RequestGroups>()\n\n/** Which request groups are present, which hold a required member, and the body's media types. Built once per operation. */\nexport function getRequestGroups(node: Pick<HttpOperationNode, 'parameters' | 'requestBody'>): RequestGroups {\n return cached(requestGroupsByNode, node, () => {\n const { path, query, header, cookie } = groupParameters(node)\n const content = node.requestBody?.content ?? []\n const body = Boolean(content[0]?.schema)\n const required = {\n path: path.some((param) => param.required),\n query: query.some((param) => param.required),\n headers: header.some((param) => param.required),\n body: body && node.requestBody?.required === true,\n }\n\n return {\n path: path.length > 0,\n query: query.length > 0,\n body,\n headers: header.length > 0,\n cookies: cookie.length > 0,\n required,\n isOptional: !required.path && !required.query && !required.headers && !required.body,\n contentTypes: content.map((entry) => entry.contentType),\n hasContentTypeChoice: content.filter((entry) => entry.schema).length > 1,\n }\n })\n}\n","import { file } from '@kubb/ast'\nimport type { ImportNode, ModuleName } from '@kubb/ast'\n\n/**\n * Returns the names of `imp`, each marked as a type, for an import that only types use.\n *\n * @example\n * ```tsx\n * <File.Import names={ast.imports.asType(imp)} path={imp.path} root={file.path} />\n * ```\n */\nexport function asType(imp: ImportNode): Array<ModuleName> {\n return file.getNames(imp).map((item) => ({ ...item, space: 'type' }))\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 { ast } from '@internals/ast'\nimport { jsDocEscape } from '@internals/utils'\nimport type { Resolver } from '@kubb/kit'\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n cookies(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type BuildOperationCommentsOptions = {\n splitLines?: boolean\n}\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\n/**\n * The operation's method and path as plain text, such as `` `GET /pet/{petId}` ``. A path is not a valid `{@link}` target.\n */\nfunction getOperationRequestLine(node: ast.OperationNode): string | null {\n return ast.http.isOperation(node) && node.path ? `\\`${node.method.toUpperCase()} ${node.path}\\`` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(ast.http.getRequestGroups(node).contentTypes)\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(ast.http.responses.findPrimary(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\n/** How an operation streams its success responses, as {@link getStream} returns it. */\nexport type ResponseStream = {\n /** `event` for a whole typed event, `data` for a typed payload, `line` for a JSON Lines value. */\n shape: 'event' | 'data' | 'line' | null\n /** Whether events keep `data` as text: all of them, the named ones, or none. */\n textEvents: boolean | Array<string>\n /** Whether the primary success response offers `text/event-stream`. */\n hasEventStream: boolean\n /** Whether a success response offers a stream next to other content types. */\n hasVariant: boolean\n}\n\nconst isText = (schema: ast.SchemaNode | null | undefined) => !!schema && ast.schema.is(schema, 'text', { follow: ['ref'] })\n\nfunction getTextEvents(entry: ast.ContentNode, shape: ResponseStream['shape']): ResponseStream['textEvents'] {\n if (shape === 'data') return isText(entry.stream?.schema ?? entry.schema)\n if (shape !== 'event' || !entry.stream?.schema) return false\n\n const item = ast.ref.getSchema(entry.stream.schema)\n const events = ast.schema.narrow(item, 'union')?.members ?? [item]\n // A discriminator makes each event an intersection of its `$ref` and the pinned `event`, so every part is read.\n const propertySchemas = (event: ast.SchemaNode, propertyName: string) => ast.schema.findProperties({ node: event, propertyName }).map(({ schema }) => schema)\n const textEvents = events.filter((event) => {\n const dataSchemas = propertySchemas(event, 'data')\n return dataSchemas.length > 0 && dataSchemas.every(isText)\n })\n if (textEvents.length === events.length) return events.length > 0\n\n const eventNames = textEvents.map((event) => propertySchemas(event, 'event').flatMap((schema) => ast.schema.getLiterals(ast.ref.getSchema(schema))))\n // An event without a fixed name cannot be told apart from the others.\n if (!eventNames.length || eventNames.some((values) => !values.length)) return false\n return [...new Set(eventNames.flat().map(String))]\n}\n\n/** How an operation streams its success responses, or `null` when none offers a stream. */\nexport function getStream(node: Pick<ast.HttpOperationNode, 'responses'>): ResponseStream | null {\n const entries = ast.http.responses.findPrimary(node)?.content ?? []\n const entry = entries.length === 1 ? entries[0] : undefined\n const kind = entry ? ast.mediaType.getKind(entry) : null\n const shape = kind === 'eventStream' ? (entry?.stream?.shape ?? 'data') : kind === 'lineStream' ? 'line' : null\n // Next to another type, a stream without a schema gets no typed variant, so it keeps the plain call.\n const hasEventStream = entries.some((item) => ast.mediaType.getKind(item) === 'eventStream' && (entries.length === 1 || !!item.schema))\n const hasVariant = ast.http.responses.filterSuccess(node).some((response) => {\n const variants = (response.content ?? []).filter((item) => item.schema)\n return variants.length > 1 && variants.some(ast.mediaType.isStream)\n })\n if (!shape && !hasEventStream && !hasVariant) return null\n\n return { shape, textEvents: entry ? getTextEvents(entry, shape) : false, hasEventStream, hasVariant }\n}\n\ntype ResponseType = 'blob' | 'text' | 'stream'\n\ntype ResponseContentEntry = { contentType: string; schema?: ast.SchemaNode | null; stream?: ast.ContentNode['stream'] }\n\nconst responseTypes: Partial<Record<NonNullable<ReturnType<typeof ast.mediaType.getKind>>, ResponseType>> = {\n eventStream: 'stream',\n lineStream: 'stream',\n binary: 'blob',\n text: 'text',\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n // Keeps the original case, unlike ast.mediaType.getBase, so generated names stay stable.\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Returns the entry with the schema of the value the client returns: `string` for a body read as text, such as `Pet` on\n * `application/xml`, and `blob` for `image/*`, `audio/*`, `video/*`, PDF, and octet-stream. A binary schema elsewhere is a `Blob`\n * only through `parseAs: 'blob'`, which needs every entry in `entries` binary. JSON, vendor (`application/vnd.*`), stream,\n * schemaless, and wildcard entries keep their schema. `entries` is the response's full list of content types.\n */\nexport function toResponseContent<T extends ContentVariantInput & ResponseContentEntry>(entry: T, entries: ReadonlyArray<ResponseContentEntry> = [entry]): T {\n const { contentType, schema } = entry\n if (!schema || entry.stream) return entry\n\n const baseType = ast.mediaType.getBase(contentType)\n const resolved = ast.ref.getSchema(schema)\n if (ast.mediaType.getKind(baseType) === 'binary') {\n return resolved.type === 'blob' ? entry : { ...entry, schema: ast.factory.createSchema({ type: 'blob' }), keysToOmit: null }\n }\n const isPlainMediaType = Boolean(baseType) && !ast.mediaType.isJson(baseType) && !baseType.includes('*')\n if (resolved.type === 'blob') {\n // shortcut: an error response never gets `parseAs`, so a lone binary schema there reads as text too but stays `Blob`.\n const readsAsText = isPlainMediaType && !entries.every((item) => item.schema?.type === 'blob')\n return readsAsText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n }\n if (resolved.primitive === 'string') return entry\n\n const kind = ast.mediaType.getKind(entry)\n const responseType = kind ? responseTypes[kind] : undefined\n // A response without a body, such as a 405, has no schema to read. Only `text/*` is always text.\n if (responseType !== 'text' && (resolved.type === 'unknown' || resolved.type === 'any' || resolved.type === 'void')) return entry\n const isVendorJson = /^[^/]+\\/vnd\\./.test(baseType) && !/(xml|yaml|yml|csv)$/.test(baseType)\n const isText = responseType === 'text' || (!responseType && isPlainMediaType && !isVendorJson)\n\n return isText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n}\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...): `RequestConfig` minus what the\n * hook fills in, which is every request group and `throwOnError`. Unlike {@link buildRequestConfigType},\n * it never narrows `contentType`: query hooks wrap GET operations, which carry no request body to select\n * a content type for.\n */\nexport function buildClientOptionType(options: { omit?: Array<string> } = {}): string {\n const keys = [...requestGroupOrder, 'url', ...(options.omit ?? []), 'throwOnError']\n return `Partial<Omit<RequestConfig, ${keys.map((key) => `'${key}'`).join(' | ')}>>`\n}\n\n/**\n * The `client?:` option type of a mutation hook. When the operation has a request content type choice,\n * the mutation variables carry `contentType`, so the config leaves it out. Otherwise the ambiguous side is\n * narrowed to the operation's media types; a single-type side has nothing to pick, so it stays baked in the\n * generated call.\n */\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n if (ast.http.getRequestGroups(node).hasContentTypeChoice) {\n return buildClientOptionType({ omit: ['contentType'] })\n }\n\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n const base = buildClientOptionType()\n return members.length ? `${base} & { contentType?: { ${members.join('; ')} } }` : base\n}\n\n/** The grouped request options, in the order generated signatures and calls list them. */\nexport const requestGroupOrder = ['path', 'query', 'body', 'headers', 'cookies'] as const\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers, cookies }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: ast.http.RequestGroups; names: Array<(typeof requestGroupOrder)[number]> } {\n const { isConfigurable = true } = options\n const groups = ast.http.getRequestGroups(node)\n\n const names = requestGroupOrder.filter((key) => groups[key])\n\n // These callers never carry the `contentType` that several media types require.\n const optionsType = groups.hasContentTypeChoice\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}${groups.isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n names,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { splitLines = false } = options\n // The request line leads: free text after a block tag would belong to that tag.\n const comments = [\n getOperationRequestLine(node),\n node.description && `@description ${node.description}`,\n node.summary && `@summary ${node.summary}`,\n node.deprecated && '@deprecated',\n node.externalDocs && `@see ${jsDocEscape([node.externalDocs.url, node.externalDocs.description].filter(Boolean).join(' '))}`,\n ]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\n/**\n * Casts a call argument to the client's parameter type; a `'plain'` client is non-generic.\n */\nexport function castToClientOptions(callArg: string, clientName: string, returnType: 'full' | 'data' | 'plain' = 'full'): string {\n return `${callArg} as Parameters<typeof ${clientName}${returnType === 'plain' ? '' : '<true>'}>[0]`\n}\n\n/**\n * Builds the combined `{ body, path, query, headers, cookies }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. `cookies` appears only on an operation\n * with a cookie parameter, and stays optional because a browser sends its cookies itself. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same shape from the same inputs.\n * `primitive: 'object'` is a no-op for the TS printer and tells the Zod printer to emit `z.object(…)` rather\n * than a record.\n */\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver, { pairContentTypes = false } = {}): ast.SchemaNode {\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n const hasBody = Boolean(ast.http.requestBody.getSchema(node))\n const createNever = () => ast.factory.createSchema({ type: 'never', primitive: undefined, optional: true })\n const groups = [\n { name: 'path', params: path, resolve: resolver.param.path },\n { name: 'query', params: query, resolve: resolver.param.query },\n { name: 'headers', params: header, resolve: resolver.param.headers },\n { name: 'cookies', params: cookie, resolve: resolver.param.cookies },\n ] as const\n\n const createOptions = (body: ast.SchemaNode, extra: Array<ast.PropertyNode> = []) =>\n // NOTE(v5-stable): the fields were renamed from the legacy beta shape\n // (`data`/`pathParams`/`queryParams`/`headerParams`) to `body`/`path`/`query`/`headers` so the\n // type matches the runtime client. Drop this note once v5 leaves beta.\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({ name: 'body', required: hasBody && node.requestBody?.required === true, schema: body }),\n ...groups\n .filter(({ name, params }) => name !== 'cookies' || params.length > 0)\n .map(({ name, params, resolve }) => {\n const required = name !== 'cookies' && params.some((param) => param.required)\n\n return ast.factory.createProperty({\n name,\n required,\n schema:\n params.length > 0\n ? ast.factory.createSchema({ type: 'ref', name: resolve.call(resolver.param, node, params[0]!), optional: !required })\n : createNever(),\n })\n }),\n ...extra,\n ],\n })\n\n const variants =\n pairContentTypes && ast.http.getRequestGroups(node).hasContentTypeChoice\n ? resolveContentTypeVariants(node.requestBody?.content ?? [], resolver.response.body(node))\n : []\n if (variants.length < 2) {\n return createOptions(hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever())\n }\n\n // The first media type is the runtime default, so only the others must pass `contentType`. A bare string sets the\n // request content type at runtime, so it is accepted next to the `{ request }` form.\n return ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant, index) => {\n const contentType = ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] })\n\n return createOptions(ast.factory.createSchema({ type: 'ref', name: variant.name }), [\n ast.factory.createProperty({\n name: 'contentType',\n required: index > 0,\n schema: ast.factory.createSchema({\n type: 'union',\n members: [\n contentType,\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [ast.factory.createProperty({ name: 'request', required: true, schema: contentType })],\n }),\n ],\n }),\n }),\n ])\n }),\n })\n}\n\n/**\n * The schema a status occupies in the `<Name>Responses` record. A status that documents several\n * content types becomes a `{ contentType; data }` union so the runtime can surface the negotiated type\n * on `result.parsed`, while the standalone `<Name>StatusNNN` alias stays the plain body union that the\n * query hooks and `result.data` use. With `streamData`, the stream variant of a 2xx status holds that schema, since the\n * client returns its body unread.\n */\nfunction buildResponseRecordEntry(\n node: ast.OperationNode,\n res: ast.ResponseNode,\n resolver: ResponseStatusNameResolver,\n streamData: ast.SchemaNode | undefined,\n): ast.SchemaNode {\n const statusName = resolver.response.status(node, res.statusCode)\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length <= 1) {\n return ast.factory.createSchema({ type: 'ref', name: statusName })\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: resolveContentTypeVariants(variants, statusName).map((variant) =>\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'contentType',\n required: true,\n // The runtime reports the bare media type, without parameters such as `charset` or `profile`.\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [ast.mediaType.getBase(variant)] }),\n }),\n ast.factory.createProperty({\n name: 'data',\n required: true,\n schema:\n streamData && ast.http.status.isSuccess(res) && ast.mediaType.isStream(variant)\n ? streamData\n : ast.factory.createSchema({ type: 'ref', name: variant.name }),\n }),\n ],\n }),\n ),\n })\n}\n\n/**\n * Builds the per-status `<Name>Responses` record for an operation, referencing the already-resolved\n * `<Name>StatusNNN` names. Shared by `@kubb/plugin-ts`'s `Responses` type and `@kubb/plugin-zod`'s\n * inferred responses schema, so both emit the same shape from the same inputs.\n *\n * Always emits the keyed record, even when an operation declares no responses. An operation with no\n * responses renders as an empty object, which keeps every consumer's import (for example the axios\n * SDK's `RequestResult<XResponses>`) resolvable instead of pointing at a missing export.\n *\n * `streamData` is the type of a stream variant's `data`, such as a `ReadableStream<Uint8Array>` reference.\n */\nexport function buildResponses(\n node: ast.OperationNode,\n resolver: ResponseStatusNameResolver,\n { streamData }: { streamData?: ast.SchemaNode } = {},\n): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: node.responses.map((res) =>\n ast.factory.createProperty({\n name: String(res.statusCode),\n required: true,\n schema: buildResponseRecordEntry(node, res, resolver, streamData),\n }),\n ),\n })\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return ast.http.responses.filterError(node).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return ast.http.responses.filterSuccess(node).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.response.status(node, response.statusCode))\n}\n\n/**\n * Lists the type names an operation's types file declares, computed once per resolver and `options` so every\n * dependent reads the same list.\n */\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver & Pick<Resolver, 'memo'>,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const key = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n return resolver.memo(`operationTypeNames:${key}`, () => {\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ...cookie.map((param) => resolver.param.cookies(node, param)),\n ]\n const bodyAndResponseNames = [ast.http.requestBody.getSchema(node) ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n return names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n })\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = Number(response.statusCode)\n if (Number.isNaN(code)) {\n continue\n }\n\n types.push([code, ast.http.status.isSuccess(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n\n/**\n * One object schema for a list of parameters or response headers, with each schema inline.\n */\nexport function buildParamsSchema(params: Array<ast.ParameterNode>): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n // `primitive: 'object'` makes a printer emit an object schema and not a record.\n primitive: 'object',\n properties: params.map((param) => ast.factory.createProperty({ name: param.name, required: param.required, schema: param.schema })),\n })\n}\n\n/**\n * One object schema for the parameters of an operation, where each key points at the const of\n * that parameter. The const already has its optional wrapper, so every key is required here.\n */\nexport function buildParamRefsSchema({\n node,\n params,\n resolver,\n}: {\n node: ast.OperationNode\n params: Array<ast.ParameterNode>\n resolver: { param: { name(node: ast.OperationNode, param: ast.ParameterNode): string } }\n}): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: params.map((param) =>\n ast.factory.createProperty({\n name: param.name,\n required: true,\n schema: ast.factory.createSchema({ type: 'ref', name: resolver.param.name(node, param) }),\n }),\n ),\n })\n}\n\ntype SchemaEntry = { schema: ast.SchemaNode; name: string; keysToOmit?: Array<string> | null }\n\n/**\n * The schemas a name with several content types needs: one per content type, then the union of\n * them under `baseName`.\n */\nexport function buildContentTypeEntries(\n entries: Array<ContentVariantInput>,\n baseName: string,\n decorate: (schema: ast.SchemaNode) => ast.SchemaNode = (schema) => schema,\n): Array<SchemaEntry> {\n const variants = resolveContentTypeVariants(entries, baseName)\n const union = ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant) => ast.factory.createSchema({ type: 'ref', name: variant.name })),\n })\n\n return [\n ...variants.map((variant) => ({ schema: decorate(variant.schema), name: variant.name, keysToOmit: variant.keysToOmit })),\n { schema: union, name: baseName },\n ]\n}\n\n/**\n * The schema behind a response or error name: a union of the per-status schemas. Returns `null`\n * when a response is a `$ref` to a component whose name is already `name`, which would declare it twice.\n */\nexport function buildResponseUnionSchema({\n node,\n responses,\n name,\n resolver,\n fallbackUnknown,\n}: {\n node: ast.OperationNode\n responses: Array<ast.ResponseNode>\n name: string\n resolver: { name(name: string): string; response: { status(node: ast.OperationNode, statusCode: ast.StatusCode): string } }\n /**\n * Print an unknown schema when no response has one, so the name still resolves.\n */\n fallbackUnknown: boolean\n}): ast.SchemaNode | null {\n const importedNames = new Set(ast.http.responses.getImportedNames(responses).map((refName) => resolver.name(refName)))\n if (importedNames.has(name)) return null\n\n const members = responses.map((res) => ast.factory.createSchema({ type: 'ref', name: resolver.response.status(node, res.statusCode) }))\n if (members.length === 0) return fallbackUnknown ? ast.factory.createSchema({ type: 'unknown' }) : null\n\n return members.length === 1 ? members[0]! : ast.factory.createSchema({ type: 'union', members })\n}\n","import { ast } from '@internals/ast'\nimport { ensureValidVarName } from '@internals/utils'\nimport { casing, memo, useKubb } from '@kubb/kit'\nimport type { FileTarget, GeneratorContext, Group, Output, PrinterContext, Resolver, ResolverFileParams } from '@kubb/kit'\n\n/**\n * The shared top-level `name` of the operation plugins, computed once per operation name and build.\n */\nexport function resolveOperationName(this: Resolver, name: string): string {\n return this.memo(`operation:${name}`, () => ensureValidVarName(casing.camel(name)))\n}\n\n/** `ctx.file(node)` for a file that no single node owns, such as `handlers.ts`: path, banner and footer from the current plugin. */\nexport function namedFile(entry: Pick<ResolverFileParams, 'name' | 'tag'> & { extname?: ResolverFileParams['extname'] }): FileTarget {\n const ctx = useKubb<GeneratorContext>()\n const { output, group } = ctx.options as { output: Output; group?: Group | null }\n const file = ctx.resolver.file({ extname: '.ts', ...entry, root: ctx.root, output, group: group ?? undefined })\n const fileContext = { output, config: ctx.config, file: { path: file.path, baseName: file.baseName } }\n\n return {\n baseName: file.baseName,\n path: file.path,\n meta: file.meta,\n banner: ctx.resolver.default.banner(ctx.meta, fileContext),\n footer: ctx.resolver.default.footer(ctx.meta, fileContext),\n }\n}\n\n/**\n * Names of the schemas in a circular reference chain, computed once per build. Reads the current context, so call it\n * in a generator or a printer factory.\n */\nexport function getCircularNames(): ReadonlySet<string> {\n return memo('circularNames:set', () => ast.graph.getCircularNames(useKubb<PrinterContext>().schemas))\n}\n\n/**\n * Names of the schemas whose type is `enum`, computed once per build. Reads the current context, so call it\n * in a generator or a printer factory.\n */\nexport function getEnumNames(): ReadonlySet<string> {\n return memo(\n 'enumNames:set',\n () => new Set(useKubb<PrinterContext>().schemas.flatMap((schema) => (schema.type === 'enum' && schema.name ? [schema.name] : []))),\n )\n}\n\ndeclare global {\n namespace Kubb {\n interface MemoRegistry {\n operation: string\n file: ast.FileNode['baseName']\n operationTypeNames: Array<string>\n }\n }\n}\n","import { ast } from '@internals/ast'\nimport { buildRequestParamsSignature } from '@internals/shared'\n\nimport { text, Url } from '@kubb/kit'\nimport type { ResolverTs } from '@kubb/plugin-ts'\nimport { Function } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n /**\n * AST operation node\n */\n node: ast.HttpOperationNode\n /**\n * TypeScript resolver for resolving param/data/response type names\n */\n resolver: ResolverTs\n baseURL: string | null | undefined\n}\n\nexport function Request({ baseURL = '', name, resolver, node }: Props): KubbReactNode {\n const { signature, groups } = buildRequestParamsSignature(node, resolver, { isConfigurable: false })\n const paramsSignature = [signature, 'options: Partial<Cypress.RequestOptions> = {}'].filter(Boolean).join(', ')\n\n const responseType = resolver.response.response(node)\n const returnType = `Cypress.Chainable<${responseType}>`\n\n // Bracket-access the path object with the raw OpenAPI param names, matching the generated `path` type's keys.\n const urlTemplate = Url.toGroupedTemplateString(node.path, { prefix: baseURL })\n\n // `cy.request` has no cookie option, so the cookie group goes out as a `Cookie` header. An array joins with commas, a Date\n // is ISO 8601, and an object is JSON.\n const cookieText =\n \"value instanceof Date ? value.toISOString() : Array.isArray(value) ? value.join(',') : typeof value === 'object' ? JSON.stringify(value) : String(value)\"\n // The OpenAPI 3.2 `cookie` style sends a value as it is, and throws on one it cannot send, like the generated clients do.\n // With `explode` (its default) an array sends one cookie per item and an object one cookie per key, otherwise both join with commas.\n const rawParameters = node.parameters.filter((parameter) => parameter.in === 'cookie' && parameter.style === 'cookie')\n // Only an array or object needs the join and explode code. A value with one primitive type goes out as one cookie.\n const isComposite = (parameter: ast.ParameterNode) =>\n !['string', 'number', 'integer', 'bigint', 'boolean'].includes(ast.ref.getSchema(parameter.schema).primitive ?? '')\n const isExploded = (parameter: ast.ParameterNode) => parameter.explode !== false && isComposite(parameter)\n const explodedCookies = rawParameters.filter(isExploded).map((parameter) => text.quote(parameter.name))\n const joinedCookies = rawParameters.filter((parameter) => !isExploded(parameter)).map((parameter) => text.quote(parameter.name))\n // A `form` cookie explodes only when the spec sets `explode: true`, like the generated clients, and its items stay percent-encoded.\n const explodedFormCookies = node.parameters\n .filter((parameter) => parameter.in === 'cookie' && parameter.style !== 'cookie' && parameter.explode === true && isComposite(parameter))\n .map((parameter) => text.quote(parameter.name))\n const compositeLines = rawParameters.some(isComposite)\n ? ` if (Array.isArray(value)) return value.filter((item) => item != null).map(rawCookie).join(',')\n if (typeof value === 'object' && value !== null && !(value instanceof Date)) return Object.entries(value).filter(([, item]) => item != null).flat().map(rawCookie).join(',')\\n`\n : ''\n const explodeCookieLine =\n explodedCookies.length || explodedFormCookies.length\n ? `const explodeCookie = (name: string, value: unknown, encode: (item: unknown) => string): Array<string> => {\n if (Array.isArray(value)) return value.filter((item) => item != null).map((item) => \\`\\${name}=\\${encode(item)}\\`)\n if (typeof value === 'object' && value !== null && !(value instanceof Date)) return Object.entries(value).filter(([, item]) => item != null).map(([key, item]) => \\`\\${encode(key)}=\\${encode(item)}\\`)\n return [\\`\\${name}=\\${encode(value)}\\`]\n}\\n`\n : ''\n const formCookieLine = explodedFormCookies.length\n ? 'const formCookie = (item: unknown): string => encodeURIComponent(item instanceof Date ? item.toISOString() : String(item))\\n'\n : ''\n // Keep the cookie-octet pattern in step with `rawCookieValue` in plugin-client's `templates/serializers.ts`.\n const rawCookieLine = rawParameters.length\n ? `const rawCookie = (value: unknown): string => {\n${compositeLines} const text = value instanceof Date ? value.toISOString() : String(value)\n if (!/^[\\\\x21\\\\x23-\\\\x2B\\\\x2D-\\\\x3A\\\\x3C-\\\\x5B\\\\x5D-\\\\x7E]*$/.test(text)) throw new TypeError('A cookie has characters the cookie style cannot send, escape it first.')\n return text\n}\\n`\n : ''\n const encodeCookie = joinedCookies.length\n ? `([${joinedCookies.join(', ')}].includes(name) ? rawCookie(value) : encodeURIComponent(${cookieText}))`\n : `encodeURIComponent(${cookieText})`\n const explodeRaw = explodedCookies.length ? `[${explodedCookies.join(', ')}].includes(name) ? explodeCookie(name, value, rawCookie) : ` : ''\n const explodeForm = explodedFormCookies.length ? `[${explodedFormCookies.join(', ')}].includes(name) ? explodeCookie(name, value, formCookie) : ` : ''\n const toCookies =\n explodeRaw || explodeForm\n ? `.flatMap(([name, value]) => (${explodeRaw}${explodeForm}[\\`\\${name}=\\${${encodeCookie}}\\`]))`\n : `.map(([name, value]) => \\`\\${name}=\\${${encodeCookie}}\\`)`\n // Built first and sent only when non-empty, so a call without cookies keeps the cookies Cypress attaches itself.\n const cookieLine = `${rawCookieLine}${explodeCookieLine}${formCookieLine}const cookie = (Object.entries(cookies ?? {}) as Array<[string, unknown]>).filter(([, value]) => value != null)${toCookies}.join('; ')\\n`\n\n // Cypress types a body as a string or an object, so a body that is one number or has no schema type is cast.\n const requestSchema = ast.http.requestBody.getSchema(node)\n const bodySchema = requestSchema && ast.ref.getSchema(requestSchema)\n const castBody = bodySchema && (['number', 'integer'].includes(bodySchema.primitive ?? '') || ['unknown', 'any'].includes(bodySchema.type))\n\n const requestOptions = [\n `method: ${text.quote(node.method)}`,\n `url: ${urlTemplate}`,\n groups.query && 'qs: query',\n groups.cookies ? `headers: { ${groups.headers ? '...headers, ' : ''}...(cookie ? { Cookie: cookie } : {}) }` : groups.headers && 'headers',\n groups.body && (castBody ? 'body: body as unknown as Cypress.RequestBody' : 'body'),\n '...options',\n ].filter(Boolean)\n\n // Cypress's catch-all `then` overload types a union body as `Chainable<Response | Pet> | Chainable<Response | string>`, so cast to the declared return type.\n const requestCall = `${groups.cookies ? cookieLine : ''}return cy.request<${responseType}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body) as ${returnType}`\n\n return (\n <Function name={name} export params={paramsSignature} returnType={returnType}>\n {requestCall}\n </Function>\n )\n}\n","import { ast } from '@internals/ast'\nimport { resolveOperationTypeNames } from '@internals/shared'\nimport { code, defineGenerator, operationKey } from '@kubb/kit'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Request } from '../components/Request.tsx'\nimport type { PluginCypress } from '../types.ts'\n\n/**\n * Built-in generator for `@kubb/plugin-cypress`. Emits one typed\n * `cy.request()` wrapper per OpenAPI operation, ready to call inside Cypress\n * test specs and custom commands.\n */\nexport const cypressGenerator = defineGenerator<PluginCypress>({\n name: 'cypress',\n renderer: jsxRenderer,\n operation(node, ctx) {\n if (!ast.http.isOperation(node)) return null\n const { baseURL } = ctx.options\n\n const types = ctx.from(pluginTsName)\n const tsResolver = ctx.getResolver(pluginTsName)\n const { imports } = code.join([\n types.resolver.response.options(node),\n ...resolveOperationTypeNames(node, tsResolver, { includeParams: false }).map((typeName) => types.ref(node, typeName)),\n ])\n const name = ctx.resolver.name(node.operationId)\n\n const meta = {\n name: ctx.resolver.resolveName({ key: operationKey(node), name }),\n file: ctx.file(node),\n } as const\n\n return (\n <File {...meta.file}>\n {imports.map((imp) => (\n <File.Import key={imp.path} names={ast.imports.asType(imp)} root={meta.file.path} path={imp.path} />\n ))}\n <Request name={meta.name} node={node} resolver={tsResolver} baseURL={baseURL} />\n </File>\n )\n },\n})\n","","","import { resolveOperationName } from '@internals/shared'\nimport { createResolver } from '@kubb/kit'\nimport type { PluginCypress } from '../types.ts'\n\n/**\n * Default resolver used by `@kubb/plugin-cypress`. Decides the names and file\n * paths for every generated `cy.request()` wrapper. Functions and files use\n * camelCase, matching the convention from `@kubb/plugin-axios` and `@kubb/plugin-fetch`.\n *\n * @example Resolve a helper name\n * ```ts\n * import { resolverCypress } from '@kubb/plugin-cypress'\n *\n * resolverCypress.name('list pets') // 'listPets'\n * ```\n */\nexport const resolverCypress = createResolver<PluginCypress>({\n pluginName: 'plugin-cypress',\n name: resolveOperationName,\n})\n","import { 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 { cypressGenerator } from './generators/cypressGenerator.tsx'\nimport { resolverCypress } from './resolvers/resolverCypress.ts'\nimport type { PluginCypress, ResolverCypress } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-cypress`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\n/**\n * Generates one typed `cy.request()` wrapper per OpenAPI operation. Each helper\n * has typed path params, body, query, and a typed response, so failing API\n * calls in Cypress show up at compile time instead of inside the test runner.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginTs } from '@kubb/plugin-ts'\n * import { pluginCypress } from '@kubb/plugin-cypress'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [\n * pluginTs(),\n * pluginCypress({\n * output: { path: './cypress' },\n * }),\n * ],\n * })\n * ```\n */\nexport const pluginCypress = defineExtension<PluginCypress>({\n kind: 'plugin',\n meta: { name: pluginCypressName, version, compatibility },\n dependencies: { [pluginTsName]: {} },\n setup(options) {\n const {\n output = { path: 'cypress', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n baseURL,\n resolver: userResolver,\n macros: userMacros,\n } = options\n\n const resolver = userResolver ? Resolver.merge<ResolverCypress>(resolverCypress, ...[userResolver].flat()) : resolverCypress\n\n setResolver(resolver)\n if (userMacros?.length) {\n setMacros(userMacros)\n }\n addGenerator(cypressGenerator)\n\n return {\n output,\n exclude,\n include,\n override,\n group: group ?? null,\n baseURL,\n }\n },\n})\n\nexport default pluginCypress\n"],"mappings":";;;;;;;;;;;AAGA,SAAgB,UAAU,MAAkE;CAC1F,OAAO,KAAK,aAAa,UAAU,EAAE,EAAE;AACzC;;ACDA,MAAM,+BAAe,IAAI,IAAI;CAC3B,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;AACX,CAAC;;AAGD,SAAS,YAAY,OAAmC;CACtD,MAAM,aAAa,OAAO,UAAU,WAAW,MAAM,aAAa;CAClE,MAAM,aAAa,aAAa,IAAI,OAAO,UAAU,CAAC;CACtD,IAAI,YAAY,OAAO;CACvB,MAAM,OAAO,OAAO,UAAU;CAC9B,OAAO,OAAO,MAAM,IAAI,IAAI,OAAO,KAAK,MAAM,OAAO,GAAG;AAC1D;AAIA,SAAgB,UAAU,YAAkC;CAC1D,OAAO,YAAY,UAAU,MAAM;AACrC;AAEA,SAAgB,QAAQ,YAAkC;CACxD,MAAM,OAAO,YAAY,UAAU;CACnC,OAAO,SAAS,QAAQ,QAA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CAA+B;CAC1D,MAAM;CACN,MAAM;EAAE,MAAM;EAAmB;EAAS;CAAc;CACxD,cAAc,GAAGC,gBAAAA,eAAe,CAAC,EAAE;CACnC,MAAM,SAAS;EACb,MAAM,EACJ,SAAS;GAAE,MAAM;GAAW,QAAQ,EAAE,MAAM,QAAQ;EAAE,GACtD,OACA,UAAU,CAAC,GACX,SACA,WAAW,CAAC,GACZ,SACA,UAAU,cACV,QAAQ,eACN;EAEJ,MAAM,WAAW,eAAeC,UAAAA,SAAS,MAAuB,iBAAiB,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,IAAI;EAE7G,CAAA,GAAA,UAAA,YAAA,CAAY,QAAQ;EACpB,IAAI,YAAY,QACd,CAAA,GAAA,UAAA,UAAA,CAAU,UAAU;EAEtB,CAAA,GAAA,UAAA,aAAA,CAAa,gBAAgB;EAE7B,OAAO;GACL;GACA;GACA;GACA;GACA,OAAO,SAAS;GAChB;EACF;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["ast","file","ast.http.getRequestGroups","ast.http.responses.findPrimary","ast.http.responses.filterError","ast.http.groupParameters","ast.http.requestBody.getSchema","casing","Url","text","ast.http.requestBody.getSchema","Function","defineTemplate","ast.http.isOperation","pluginTsName","code","operationKey","File","ast.imports.asType","createResolver","defineExtension","pluginTsName","Resolver"],"sources":["../../../internals/ast/src/http/requestBody.ts","../../../internals/ast/src/http/status.ts","../../../internals/ast/src/http/responses.ts","../../../internals/ast/src/http/index.ts","../../../internals/ast/src/imports.ts","../../../internals/utils/src/reserved.ts","../../../internals/shared/src/operation.ts","../../../internals/shared/src/resolver.ts","../src/components/Request.tsx","../src/templates/cypress.tsx","../kubb-extension.json","../package.json","../src/resolvers/resolverCypress.ts","../src/plugin.ts"],"sourcesContent":["import type { OperationNode, SchemaNode } from '@kubb/ast'\n\n/** The schema of the first request body entry, else `undefined` when the operation takes no body. */\nexport function getSchema(node: Pick<OperationNode, 'requestBody'>): SchemaNode | undefined {\n return node.requestBody?.content?.[0]?.schema\n}\n","import type { ResponseNode, StatusCode } from '@kubb/ast'\n\ntype StatusInput = StatusCode | number | (string & {}) | Pick<ResponseNode, 'statusCode'>\n\nconst classByRange = new Map([\n ['1xx', 1],\n ['2xx', 2],\n ['3xx', 3],\n ['4xx', 4],\n ['5xx', 5],\n])\n\n/** The class digit of a status code or range: `2` for `201` and `2xx`, `null` for `default`. */\nfunction statusClass(input: StatusInput): number | null {\n const statusCode = typeof input === 'object' ? input.statusCode : input\n const rangeClass = classByRange.get(String(statusCode))\n if (rangeClass) return rangeClass\n const code = Number(statusCode)\n return Number.isNaN(code) ? null : Math.floor(code / 100)\n}\n\nexport { statusClass as getClass }\n\nexport function isSuccess(statusCode: StatusInput): boolean {\n return statusClass(statusCode) === 2\n}\n\nexport function isError(statusCode: StatusInput): boolean {\n const code = statusClass(statusCode)\n return code !== null && code >= 4\n}\n\n/** One concrete code for a status or range: `200` for `2xx` and `default`, the code itself otherwise. */\nexport function toCode(input: StatusInput): number {\n const statusCode = typeof input === 'object' ? input.statusCode : input\n const code = Number(statusCode)\n return Number.isNaN(code) ? (statusClass(statusCode) ?? 2) * 100 : code\n}\n","import { ast, type HttpOperationNode, type OperationNode, type ResponseNode, type SchemaNode } from '@kubb/ast'\nimport { isError, isSuccess } from './status.ts'\n\n/** The `4xx` and `5xx` responses, ranges included. */\nexport function filterError(node: Pick<HttpOperationNode, 'responses'>): Array<ResponseNode> {\n return node.responses.filter((response) => isError(response.statusCode))\n}\n\n/** The ref names the response bodies import, in order, with repeats. */\nexport function getImportedNames(responses: ReadonlyArray<ResponseNode>): Array<string> {\n return responses.flatMap((response) => (response.content ?? []).flatMap((entry) => (entry.schema ? ast.graph.getImportedNames(entry.schema) : [])))\n}\n\nexport function filterSuccess(node: Pick<HttpOperationNode, 'responses'>): Array<ResponseNode> {\n return node.responses.filter((response) => isSuccess(response.statusCode))\n}\n\n/** The success response a client returns: one with a body first, then an exact code over a `2xx` range. */\nexport function findPrimary(node: Pick<HttpOperationNode, 'responses'>): ResponseNode | null {\n const responses = filterSuccess(node)\n const withBody = responses.filter((response) => response.content?.some((entry) => entry.contentType))\n const candidates = withBody.length ? withBody : responses\n return candidates.find((response) => !Number.isNaN(Number(response.statusCode))) ?? candidates[0] ?? null\n}\n\n/** A union of refs to the success responses with a body, else every response with a body, else `null`. */\nexport function getUnion<TNode extends Pick<OperationNode, 'responses'>>(\n node: TNode,\n resolver: { response: { status(node: TNode, statusCode: ResponseNode['statusCode']): string } },\n): SchemaNode | null {\n const withSchema = node.responses.filter((response) => response.content?.some((entry) => entry.schema))\n const success = withSchema.filter((response) => isSuccess(response.statusCode))\n const responses = success.length > 0 ? success : withSchema\n if (responses.length === 0) return null\n\n return ast.factory.createSchema({\n type: 'union',\n members: responses.map((response) => ast.factory.createSchema({ type: 'ref', name: resolver.response.status(node, response.statusCode) })),\n })\n}\n","import { ast, type HttpOperationNode, type InputServer, type ParameterNode } from '@kubb/ast'\n\nexport const isOperation = ast.http.isOperation\nexport * as requestBody from './requestBody.ts'\nexport * as responses from './responses.ts'\nexport * as status from './status.ts'\n\n/** The server's URL when it is absolute and has no template variables, else `undefined`. */\nexport function getBaseURL(server: InputServer | undefined): string | undefined {\n if (!server || server.variables || server.url.includes('{') || !server.url.includes('://')) return undefined\n return URL.canParse(server.url) ? server.url : undefined\n}\n\n/** Computes once per key; generators visit the same node many times. */\nfunction cached<TKey extends object, TValue>(store: WeakMap<TKey, TValue>, key: TKey, compute: () => TValue): TValue {\n if (!store.has(key)) store.set(key, compute())\n return store.get(key)!\n}\n\ntype ParameterGroups = Record<'path' | 'query' | 'header' | 'cookie', Array<ParameterNode>>\n\n// Every plugin's generator visits the same node, so the groups are built once per node.\nconst parametersByNode = new WeakMap<Pick<HttpOperationNode, 'parameters'>, ParameterGroups>()\n\n/** The operation's parameters by location, with a `querystring` parameter in `query`. A repeated name keeps its first parameter. */\nexport function groupParameters(node: Pick<HttpOperationNode, 'parameters'>): ParameterGroups {\n return cached(parametersByNode, node, () => {\n const group = (...locations: Array<ParameterNode['in']>) => {\n const seen = new Set<string>()\n return locations.flatMap((location) =>\n 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 // A `querystring` parameter left whole, such as a JSON one, is sent as the query string, so it joins the query group.\n return { path: group('path'), query: group('query', 'querystring'), header: group('header'), cookie: group('cookie') }\n })\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n cookies: boolean\n /** `cookies` is never required: a browser sends its cookies itself. */\n required: { path: boolean; query: boolean; headers: boolean; body: boolean }\n /** No group holds a required member. */\n isOptional: boolean\n contentTypes: Array<string>\n /** More than one body media type has a schema, so a caller must pick one. */\n hasContentTypeChoice: boolean\n}\n\nconst requestGroupsByNode = new WeakMap<Pick<HttpOperationNode, 'parameters' | 'requestBody'>, RequestGroups>()\n\n/** Which request groups are present, which hold a required member, and the body's media types. Built once per operation. */\nexport function getRequestGroups(node: Pick<HttpOperationNode, 'parameters' | 'requestBody'>): RequestGroups {\n return cached(requestGroupsByNode, node, () => {\n const { path, query, header, cookie } = groupParameters(node)\n const content = node.requestBody?.content ?? []\n const body = Boolean(content[0]?.schema)\n const required = {\n path: path.some((param) => param.required),\n query: query.some((param) => param.required),\n headers: header.some((param) => param.required),\n body: body && node.requestBody?.required === true,\n }\n\n return {\n path: path.length > 0,\n query: query.length > 0,\n body,\n headers: header.length > 0,\n cookies: cookie.length > 0,\n required,\n isOptional: !required.path && !required.query && !required.headers && !required.body,\n contentTypes: content.map((entry) => entry.contentType),\n hasContentTypeChoice: content.filter((entry) => entry.schema).length > 1,\n }\n })\n}\n","import { file } from '@kubb/ast'\nimport type { ImportNode, ModuleName } from '@kubb/ast'\n\n/**\n * Returns the names of `imp`, each marked as a type, for an import that only types use.\n *\n * @example\n * ```tsx\n * <File.Import names={ast.imports.asType(imp)} path={imp.path} root={file.path} />\n * ```\n */\nexport function asType(imp: ImportNode): Array<ModuleName> {\n return file.getNames(imp).map((item) => ({ ...item, space: 'type' }))\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 { ast } from '@internals/ast'\nimport { jsDocEscape } from '@internals/utils'\nimport type { Resolver } from '@kubb/kit'\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n cookies(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type BuildOperationCommentsOptions = {\n splitLines?: boolean\n}\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\n/**\n * The operation's method and path as plain text, such as `` `GET /pet/{petId}` ``. A path is not a valid `{@link}` target.\n */\nfunction getOperationRequestLine(node: ast.OperationNode): string | null {\n return ast.http.isOperation(node) && node.path ? `\\`${node.method.toUpperCase()} ${node.path}\\`` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(ast.http.getRequestGroups(node).contentTypes)\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(ast.http.responses.findPrimary(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\n/** How an operation streams its success responses, as {@link getStream} returns it. */\nexport type ResponseStream = {\n /** `event` for a whole typed event, `data` for a typed payload, `line` for a JSON Lines value. */\n shape: 'event' | 'data' | 'line' | null\n /** Whether events keep `data` as text: all of them, the named ones, or none. */\n textEvents: boolean | Array<string>\n /** Whether the primary success response offers `text/event-stream`. */\n hasEventStream: boolean\n /** Whether a success response offers a stream next to other content types. */\n hasVariant: boolean\n}\n\nconst isText = (schema: ast.SchemaNode | null | undefined) => !!schema && ast.schema.is(schema, 'text', { follow: ['ref'] })\n\nfunction getTextEvents(entry: ast.ContentNode, shape: ResponseStream['shape']): ResponseStream['textEvents'] {\n if (shape === 'data') return isText(entry.stream?.schema ?? entry.schema)\n if (shape !== 'event' || !entry.stream?.schema) return false\n\n const item = ast.ref.getSchema(entry.stream.schema)\n const events = ast.schema.narrow(item, 'union')?.members ?? [item]\n // A discriminator makes each event an intersection of its `$ref` and the pinned `event`, so every part is read.\n const propertySchemas = (event: ast.SchemaNode, propertyName: string) => ast.schema.findProperties({ node: event, propertyName }).map(({ schema }) => schema)\n const textEvents = events.filter((event) => {\n const dataSchemas = propertySchemas(event, 'data')\n return dataSchemas.length > 0 && dataSchemas.every(isText)\n })\n if (textEvents.length === events.length) return events.length > 0\n\n const eventNames = textEvents.map((event) => propertySchemas(event, 'event').flatMap((schema) => ast.schema.getLiterals(ast.ref.getSchema(schema))))\n // An event without a fixed name cannot be told apart from the others.\n if (!eventNames.length || eventNames.some((values) => !values.length)) return false\n return [...new Set(eventNames.flat().map(String))]\n}\n\n/** How an operation streams its success responses, or `null` when none offers a stream. */\nexport function getStream(node: Pick<ast.HttpOperationNode, 'responses'>): ResponseStream | null {\n const entries = ast.http.responses.findPrimary(node)?.content ?? []\n const entry = entries.length === 1 ? entries[0] : undefined\n const kind = entry ? ast.mediaType.getKind(entry) : null\n const shape = kind === 'eventStream' ? (entry?.stream?.shape ?? 'data') : kind === 'lineStream' ? 'line' : null\n // Next to another type, a stream without a schema gets no typed variant, so it keeps the plain call.\n const hasEventStream = entries.some((item) => ast.mediaType.getKind(item) === 'eventStream' && (entries.length === 1 || !!item.schema))\n const hasVariant = ast.http.responses.filterSuccess(node).some((response) => {\n const variants = (response.content ?? []).filter((item) => item.schema)\n return variants.length > 1 && variants.some(ast.mediaType.isStream)\n })\n if (!shape && !hasEventStream && !hasVariant) return null\n\n return { shape, textEvents: entry ? getTextEvents(entry, shape) : false, hasEventStream, hasVariant }\n}\n\ntype ResponseType = 'blob' | 'text' | 'stream'\n\ntype ResponseContentEntry = { contentType: string; schema?: ast.SchemaNode | null; stream?: ast.ContentNode['stream'] }\n\nconst responseTypes: Partial<Record<NonNullable<ReturnType<typeof ast.mediaType.getKind>>, ResponseType>> = {\n eventStream: 'stream',\n lineStream: 'stream',\n binary: 'blob',\n text: 'text',\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n // Keeps the original case, unlike ast.mediaType.getBase, so generated names stay stable.\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Returns the entry with the schema of the value the client returns: `string` for a body read as text, such as `Pet` on\n * `application/xml`, and `blob` for `image/*`, `audio/*`, `video/*`, PDF, and octet-stream. A binary schema elsewhere is a `Blob`\n * only through `parseAs: 'blob'`, which needs every entry in `entries` binary. JSON, vendor (`application/vnd.*`), stream,\n * schemaless, and wildcard entries keep their schema. `entries` is the response's full list of content types.\n */\nexport function toResponseContent<T extends ContentVariantInput & ResponseContentEntry>(entry: T, entries: ReadonlyArray<ResponseContentEntry> = [entry]): T {\n const { contentType, schema } = entry\n if (!schema || entry.stream) return entry\n\n const baseType = ast.mediaType.getBase(contentType)\n const resolved = ast.ref.getSchema(schema)\n if (ast.mediaType.getKind(baseType) === 'binary') {\n return resolved.type === 'blob' ? entry : { ...entry, schema: ast.factory.createSchema({ type: 'blob' }), keysToOmit: null }\n }\n const isPlainMediaType = Boolean(baseType) && !ast.mediaType.isJson(baseType) && !baseType.includes('*')\n if (resolved.type === 'blob') {\n // shortcut: an error response never gets `parseAs`, so a lone binary schema there reads as text too but stays `Blob`.\n const readsAsText = isPlainMediaType && !entries.every((item) => item.schema?.type === 'blob')\n return readsAsText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n }\n if (resolved.primitive === 'string') return entry\n\n const kind = ast.mediaType.getKind(entry)\n const responseType = kind ? responseTypes[kind] : undefined\n // A response without a body, such as a 405, has no schema to read. Only `text/*` is always text.\n if (responseType !== 'text' && (resolved.type === 'unknown' || resolved.type === 'any' || resolved.type === 'void')) return entry\n const isVendorJson = /^[^/]+\\/vnd\\./.test(baseType) && !/(xml|yaml|yml|csv)$/.test(baseType)\n const isText = responseType === 'text' || (!responseType && isPlainMediaType && !isVendorJson)\n\n return isText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n}\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...): `RequestConfig` minus what the\n * hook fills in, which is every request group and `throwOnError`. Unlike {@link buildRequestConfigType},\n * it never narrows `contentType`: query hooks wrap GET operations, which carry no request body to select\n * a content type for.\n */\nexport function buildClientOptionType(options: { omit?: Array<string> } = {}): string {\n const keys = [...requestGroupOrder, 'url', ...(options.omit ?? []), 'throwOnError']\n return `Partial<Omit<RequestConfig, ${keys.map((key) => `'${key}'`).join(' | ')}>>`\n}\n\n/**\n * The `client?:` option type of a mutation hook. When the operation has a request content type choice,\n * the mutation variables carry `contentType`, so the config leaves it out. Otherwise the ambiguous side is\n * narrowed to the operation's media types; a single-type side has nothing to pick, so it stays baked in the\n * generated call.\n */\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n if (ast.http.getRequestGroups(node).hasContentTypeChoice) {\n return buildClientOptionType({ omit: ['contentType'] })\n }\n\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n const base = buildClientOptionType()\n return members.length ? `${base} & { contentType?: { ${members.join('; ')} } }` : base\n}\n\n/** The grouped request options, in the order generated signatures and calls list them. */\nexport const requestGroupOrder = ['path', 'query', 'body', 'headers', 'cookies'] as const\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers, cookies }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: ast.http.RequestGroups; names: Array<(typeof requestGroupOrder)[number]> } {\n const { isConfigurable = true } = options\n const groups = ast.http.getRequestGroups(node)\n\n const names = requestGroupOrder.filter((key) => groups[key])\n\n // These callers never carry the `contentType` that several media types require.\n const optionsType = groups.hasContentTypeChoice\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}${groups.isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n names,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { splitLines = false } = options\n // The request line leads: free text after a block tag would belong to that tag.\n const comments = [\n getOperationRequestLine(node),\n node.description && `@description ${node.description}`,\n node.summary && `@summary ${node.summary}`,\n node.deprecated && '@deprecated',\n node.externalDocs && `@see ${jsDocEscape([node.externalDocs.url, node.externalDocs.description].filter(Boolean).join(' '))}`,\n ]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\n/**\n * Casts a call argument to the client's parameter type; a `'plain'` client is non-generic.\n */\nexport function castToClientOptions(callArg: string, clientName: string, returnType: 'full' | 'data' | 'plain' = 'full'): string {\n return `${callArg} as Parameters<typeof ${clientName}${returnType === 'plain' ? '' : '<true>'}>[0]`\n}\n\n/**\n * Builds the combined `{ body, path, query, headers, cookies }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. `cookies` appears only on an operation\n * with a cookie parameter, and stays optional because a browser sends its cookies itself. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same shape from the same inputs.\n * `primitive: 'object'` is a no-op for the TS printer and tells the Zod printer to emit `z.object(…)` rather\n * than a record.\n */\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver, { pairContentTypes = false } = {}): ast.SchemaNode {\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n const hasBody = Boolean(ast.http.requestBody.getSchema(node))\n const createNever = () => ast.factory.createSchema({ type: 'never', primitive: undefined, optional: true })\n const groups = [\n { name: 'path', params: path, resolve: resolver.param.path },\n { name: 'query', params: query, resolve: resolver.param.query },\n { name: 'headers', params: header, resolve: resolver.param.headers },\n { name: 'cookies', params: cookie, resolve: resolver.param.cookies },\n ] as const\n\n const createOptions = (body: ast.SchemaNode, extra: Array<ast.PropertyNode> = []) =>\n // NOTE(v5-stable): the fields were renamed from the legacy beta shape\n // (`data`/`pathParams`/`queryParams`/`headerParams`) to `body`/`path`/`query`/`headers` so the\n // type matches the runtime client. Drop this note once v5 leaves beta.\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({ name: 'body', required: hasBody && node.requestBody?.required === true, schema: body }),\n ...groups\n .filter(({ name, params }) => name !== 'cookies' || params.length > 0)\n .map(({ name, params, resolve }) => {\n const required = name !== 'cookies' && params.some((param) => param.required)\n\n return ast.factory.createProperty({\n name,\n required,\n schema:\n params.length > 0\n ? ast.factory.createSchema({ type: 'ref', name: resolve.call(resolver.param, node, params[0]!), optional: !required })\n : createNever(),\n })\n }),\n ...extra,\n ],\n })\n\n const variants =\n pairContentTypes && ast.http.getRequestGroups(node).hasContentTypeChoice\n ? resolveContentTypeVariants(node.requestBody?.content ?? [], resolver.response.body(node))\n : []\n if (variants.length < 2) {\n return createOptions(hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever())\n }\n\n // The first media type is the runtime default, so only the others must pass `contentType`. A bare string sets the\n // request content type at runtime, so it is accepted next to the `{ request }` form.\n return ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant, index) => {\n const contentType = ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] })\n\n return createOptions(ast.factory.createSchema({ type: 'ref', name: variant.name }), [\n ast.factory.createProperty({\n name: 'contentType',\n required: index > 0,\n schema: ast.factory.createSchema({\n type: 'union',\n members: [\n contentType,\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [ast.factory.createProperty({ name: 'request', required: true, schema: contentType })],\n }),\n ],\n }),\n }),\n ])\n }),\n })\n}\n\n/**\n * The schema a status occupies in the `<Name>Responses` record. A status that documents several\n * content types becomes a `{ contentType; data }` union so the runtime can surface the negotiated type\n * on `result.parsed`, while the standalone `<Name>StatusNNN` alias stays the plain body union that the\n * query hooks and `result.data` use. With `streamData`, the stream variant of a 2xx status holds that schema, since the\n * client returns its body unread.\n */\nfunction buildResponseRecordEntry(\n node: ast.OperationNode,\n res: ast.ResponseNode,\n resolver: ResponseStatusNameResolver,\n streamData: ast.SchemaNode | undefined,\n): ast.SchemaNode {\n const statusName = resolver.response.status(node, res.statusCode)\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length <= 1) {\n return ast.factory.createSchema({ type: 'ref', name: statusName })\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: resolveContentTypeVariants(variants, statusName).map((variant) =>\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'contentType',\n required: true,\n // The runtime reports the bare media type, without parameters such as `charset` or `profile`.\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [ast.mediaType.getBase(variant)] }),\n }),\n ast.factory.createProperty({\n name: 'data',\n required: true,\n schema:\n streamData && ast.http.status.isSuccess(res) && ast.mediaType.isStream(variant)\n ? streamData\n : ast.factory.createSchema({ type: 'ref', name: variant.name }),\n }),\n ],\n }),\n ),\n })\n}\n\n/**\n * Builds the per-status `<Name>Responses` record for an operation, referencing the already-resolved\n * `<Name>StatusNNN` names. Shared by `@kubb/plugin-ts`'s `Responses` type and `@kubb/plugin-zod`'s\n * inferred responses schema, so both emit the same shape from the same inputs.\n *\n * Always emits the keyed record, even when an operation declares no responses. An operation with no\n * responses renders as an empty object, which keeps every consumer's import (for example the axios\n * SDK's `RequestResult<XResponses>`) resolvable instead of pointing at a missing export.\n *\n * `streamData` is the type of a stream variant's `data`, such as a `ReadableStream<Uint8Array>` reference.\n */\nexport function buildResponses(\n node: ast.OperationNode,\n resolver: ResponseStatusNameResolver,\n { streamData }: { streamData?: ast.SchemaNode } = {},\n): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: node.responses.map((res) =>\n ast.factory.createProperty({\n name: String(res.statusCode),\n required: true,\n schema: buildResponseRecordEntry(node, res, resolver, streamData),\n }),\n ),\n })\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return ast.http.responses.filterError(node).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return ast.http.responses.filterSuccess(node).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.response.status(node, response.statusCode))\n}\n\n/**\n * Lists the type names an operation's types file declares, computed once per resolver and `options` so every\n * dependent reads the same list.\n */\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver & Pick<Resolver, 'memo'>,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const key = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n return resolver.memo(`operationTypeNames:${key}`, () => {\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ...cookie.map((param) => resolver.param.cookies(node, param)),\n ]\n const bodyAndResponseNames = [ast.http.requestBody.getSchema(node) ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n return names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n })\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = Number(response.statusCode)\n if (Number.isNaN(code)) {\n continue\n }\n\n types.push([code, ast.http.status.isSuccess(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n\n/**\n * One object schema for a list of parameters or response headers, with each schema inline.\n */\nexport function buildParamsSchema(params: Array<ast.ParameterNode>): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n // `primitive: 'object'` makes a printer emit an object schema and not a record.\n primitive: 'object',\n properties: params.map((param) => ast.factory.createProperty({ name: param.name, required: param.required, schema: param.schema })),\n })\n}\n\n/**\n * One object schema for the parameters of an operation, where each key points at the const of\n * that parameter. The const already has its optional wrapper, so every key is required here.\n */\nexport function buildParamRefsSchema({\n node,\n params,\n resolver,\n}: {\n node: ast.OperationNode\n params: Array<ast.ParameterNode>\n resolver: { param: { name(node: ast.OperationNode, param: ast.ParameterNode): string } }\n}): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: params.map((param) =>\n ast.factory.createProperty({\n name: param.name,\n required: true,\n schema: ast.factory.createSchema({ type: 'ref', name: resolver.param.name(node, param) }),\n }),\n ),\n })\n}\n\ntype SchemaEntry = { schema: ast.SchemaNode; name: string; keysToOmit?: Array<string> | null }\n\n/**\n * The schemas a name with several content types needs: one per content type, then the union of\n * them under `baseName`.\n */\nexport function buildContentTypeEntries(\n entries: Array<ContentVariantInput>,\n baseName: string,\n decorate: (schema: ast.SchemaNode) => ast.SchemaNode = (schema) => schema,\n): Array<SchemaEntry> {\n const variants = resolveContentTypeVariants(entries, baseName)\n const union = ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant) => ast.factory.createSchema({ type: 'ref', name: variant.name })),\n })\n\n return [\n ...variants.map((variant) => ({ schema: decorate(variant.schema), name: variant.name, keysToOmit: variant.keysToOmit })),\n { schema: union, name: baseName },\n ]\n}\n\n/**\n * The schema behind a response or error name: a union of the per-status schemas. Returns `null`\n * when a response is a `$ref` to a component whose name is already `name`, which would declare it twice.\n */\nexport function buildResponseUnionSchema({\n node,\n responses,\n name,\n resolver,\n fallbackUnknown,\n}: {\n node: ast.OperationNode\n responses: Array<ast.ResponseNode>\n name: string\n resolver: { name(name: string): string; response: { status(node: ast.OperationNode, statusCode: ast.StatusCode): string } }\n /**\n * Print an unknown schema when no response has one, so the name still resolves.\n */\n fallbackUnknown: boolean\n}): ast.SchemaNode | null {\n const importedNames = new Set(ast.http.responses.getImportedNames(responses).map((refName) => resolver.name(refName)))\n if (importedNames.has(name)) return null\n\n const members = responses.map((res) => ast.factory.createSchema({ type: 'ref', name: resolver.response.status(node, res.statusCode) }))\n if (members.length === 0) return fallbackUnknown ? ast.factory.createSchema({ type: 'unknown' }) : null\n\n return members.length === 1 ? members[0]! : ast.factory.createSchema({ type: 'union', members })\n}\n","import { ast } from '@internals/ast'\nimport { ensureValidVarName } from '@internals/utils'\nimport { casing, memo, useKubb } from '@kubb/kit'\nimport type { FileTarget, GeneratorContext, Group, Output, PrinterContext, Resolver, ResolverFileParams } from '@kubb/kit'\n\n/**\n * The shared top-level `name` of the operation plugins, computed once per operation name and build.\n */\nexport function resolveOperationName(this: Resolver, name: string): string {\n return this.memo(`operation:${name}`, () => ensureValidVarName(casing.camel(name)))\n}\n\n/** `ctx.file(node)` for a file that no single node owns, such as `handlers.ts`: path, banner and footer from the current plugin. */\nexport function namedFile(entry: Pick<ResolverFileParams, 'name' | 'tag'> & { extname?: ResolverFileParams['extname'] }): FileTarget {\n const ctx = useKubb<GeneratorContext>()\n const { output, group } = ctx.options as { output: Output; group?: Group | null }\n const file = ctx.resolver.file({ extname: '.ts', ...entry, root: ctx.root, output, group: group ?? undefined })\n const fileContext = { output, config: ctx.config, file: { path: file.path, baseName: file.baseName } }\n\n return {\n baseName: file.baseName,\n path: file.path,\n meta: file.meta,\n banner: ctx.resolver.default.banner(ctx.meta, fileContext),\n footer: ctx.resolver.default.footer(ctx.meta, fileContext),\n }\n}\n\n/**\n * Names of the schemas in a circular reference chain, computed once per build. Reads the current context, so call it\n * in a generator or a printer factory.\n */\nexport function getCircularNames(): ReadonlySet<string> {\n return memo('circularNames:set', () => ast.graph.getCircularNames(useKubb<PrinterContext>().schemas))\n}\n\n/**\n * Names of the schemas whose type is `enum`, computed once per build. Reads the current context, so call it\n * in a generator or a printer factory.\n */\nexport function getEnumNames(): ReadonlySet<string> {\n return memo(\n 'enumNames:set',\n () => new Set(useKubb<PrinterContext>().schemas.flatMap((schema) => (schema.type === 'enum' && schema.name ? [schema.name] : []))),\n )\n}\n\ndeclare global {\n namespace Kubb {\n interface MemoRegistry {\n operation: string\n file: ast.FileNode['baseName']\n operationTypeNames: Array<string>\n }\n }\n}\n","import { ast } from '@internals/ast'\nimport { buildRequestParamsSignature } from '@internals/shared'\n\nimport { text, Url } from '@kubb/kit'\nimport type { ResolverTs } from '@kubb/plugin-ts'\nimport { Function } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n /**\n * AST operation node\n */\n node: ast.HttpOperationNode\n /**\n * TypeScript resolver for resolving param/data/response type names\n */\n resolver: ResolverTs\n baseURL: string | null | undefined\n}\n\nexport function Request({ baseURL = '', name, resolver, node }: Props): KubbReactNode {\n const { signature, groups } = buildRequestParamsSignature(node, resolver, { isConfigurable: false })\n const paramsSignature = [signature, 'options: Partial<Cypress.RequestOptions> = {}'].filter(Boolean).join(', ')\n\n const responseType = resolver.response.response(node)\n const returnType = `Cypress.Chainable<${responseType}>`\n\n // Bracket-access the path object with the raw OpenAPI param names, matching the generated `path` type's keys.\n const urlTemplate = Url.toGroupedTemplateString(node.path, { prefix: baseURL })\n\n // `cy.request` has no cookie option, so the cookie group goes out as a `Cookie` header. An array joins with commas, a Date\n // is ISO 8601, and an object is JSON.\n const cookieText =\n \"value instanceof Date ? value.toISOString() : Array.isArray(value) ? value.join(',') : typeof value === 'object' ? JSON.stringify(value) : String(value)\"\n // The OpenAPI 3.2 `cookie` style sends a value as it is, and throws on one it cannot send, like the generated clients do.\n // With `explode` (its default) an array sends one cookie per item and an object one cookie per key, otherwise both join with commas.\n const rawParameters = node.parameters.filter((parameter) => parameter.in === 'cookie' && parameter.style === 'cookie')\n // Only an array or object needs the join and explode code. A value with one primitive type goes out as one cookie.\n const isComposite = (parameter: ast.ParameterNode) =>\n !['string', 'number', 'integer', 'bigint', 'boolean'].includes(ast.ref.getSchema(parameter.schema).primitive ?? '')\n const isExploded = (parameter: ast.ParameterNode) => parameter.explode !== false && isComposite(parameter)\n const explodedCookies = rawParameters.filter(isExploded).map((parameter) => text.quote(parameter.name))\n const joinedCookies = rawParameters.filter((parameter) => !isExploded(parameter)).map((parameter) => text.quote(parameter.name))\n // A `form` cookie explodes only when the spec sets `explode: true`, like the generated clients, and its items stay percent-encoded.\n const explodedFormCookies = node.parameters\n .filter((parameter) => parameter.in === 'cookie' && parameter.style !== 'cookie' && parameter.explode === true && isComposite(parameter))\n .map((parameter) => text.quote(parameter.name))\n const compositeLines = rawParameters.some(isComposite)\n ? ` if (Array.isArray(value)) return value.filter((item) => item != null).map(rawCookie).join(',')\n if (typeof value === 'object' && value !== null && !(value instanceof Date)) return Object.entries(value).filter(([, item]) => item != null).flat().map(rawCookie).join(',')\\n`\n : ''\n const explodeCookieLine =\n explodedCookies.length || explodedFormCookies.length\n ? `const explodeCookie = (name: string, value: unknown, encode: (item: unknown) => string): Array<string> => {\n if (Array.isArray(value)) return value.filter((item) => item != null).map((item) => \\`\\${name}=\\${encode(item)}\\`)\n if (typeof value === 'object' && value !== null && !(value instanceof Date)) return Object.entries(value).filter(([, item]) => item != null).map(([key, item]) => \\`\\${encode(key)}=\\${encode(item)}\\`)\n return [\\`\\${name}=\\${encode(value)}\\`]\n}\\n`\n : ''\n const formCookieLine = explodedFormCookies.length\n ? 'const formCookie = (item: unknown): string => encodeURIComponent(item instanceof Date ? item.toISOString() : String(item))\\n'\n : ''\n // Keep the cookie-octet pattern in step with `rawCookieValue` in plugin-client's `templates/serializers.ts`.\n const rawCookieLine = rawParameters.length\n ? `const rawCookie = (value: unknown): string => {\n${compositeLines} const text = value instanceof Date ? value.toISOString() : String(value)\n if (!/^[\\\\x21\\\\x23-\\\\x2B\\\\x2D-\\\\x3A\\\\x3C-\\\\x5B\\\\x5D-\\\\x7E]*$/.test(text)) throw new TypeError('A cookie has characters the cookie style cannot send, escape it first.')\n return text\n}\\n`\n : ''\n const encodeCookie = joinedCookies.length\n ? `([${joinedCookies.join(', ')}].includes(name) ? rawCookie(value) : encodeURIComponent(${cookieText}))`\n : `encodeURIComponent(${cookieText})`\n const explodeRaw = explodedCookies.length ? `[${explodedCookies.join(', ')}].includes(name) ? explodeCookie(name, value, rawCookie) : ` : ''\n const explodeForm = explodedFormCookies.length ? `[${explodedFormCookies.join(', ')}].includes(name) ? explodeCookie(name, value, formCookie) : ` : ''\n const toCookies =\n explodeRaw || explodeForm\n ? `.flatMap(([name, value]) => (${explodeRaw}${explodeForm}[\\`\\${name}=\\${${encodeCookie}}\\`]))`\n : `.map(([name, value]) => \\`\\${name}=\\${${encodeCookie}}\\`)`\n // Built first and sent only when non-empty, so a call without cookies keeps the cookies Cypress attaches itself.\n const cookieLine = `${rawCookieLine}${explodeCookieLine}${formCookieLine}const cookie = (Object.entries(cookies ?? {}) as Array<[string, unknown]>).filter(([, value]) => value != null)${toCookies}.join('; ')\\n`\n\n // Cypress types a body as a string or an object, so a body that is one number or has no schema type is cast.\n const requestSchema = ast.http.requestBody.getSchema(node)\n const bodySchema = requestSchema && ast.ref.getSchema(requestSchema)\n const castBody = bodySchema && (['number', 'integer'].includes(bodySchema.primitive ?? '') || ['unknown', 'any'].includes(bodySchema.type))\n\n const requestOptions = [\n `method: ${text.quote(node.method)}`,\n `url: ${urlTemplate}`,\n groups.query && 'qs: query',\n groups.cookies ? `headers: { ${groups.headers ? '...headers, ' : ''}...(cookie ? { Cookie: cookie } : {}) }` : groups.headers && 'headers',\n groups.body && (castBody ? 'body: body as unknown as Cypress.RequestBody' : 'body'),\n '...options',\n ].filter(Boolean)\n\n // Cypress's catch-all `then` overload types a union body as `Chainable<Response | Pet> | Chainable<Response | string>`, so cast to the declared return type.\n const requestCall = `${groups.cookies ? cookieLine : ''}return cy.request<${responseType}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body) as ${returnType}`\n\n return (\n <Function name={name} export params={paramsSignature} returnType={returnType}>\n {requestCall}\n </Function>\n )\n}\n","import { ast } from '@internals/ast'\nimport { resolveOperationTypeNames } from '@internals/shared'\nimport { code, defineTemplate, operationKey } from '@kubb/kit'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/renderer-jsx'\nimport { Request } from '../components/Request.tsx'\nimport type { PluginCypress } from '../types.ts'\n\n/**\n * Built-in template for `@kubb/plugin-cypress`. Emits one typed\n * `cy.request()` wrapper per OpenAPI operation, ready to call inside Cypress\n * test specs and custom commands.\n */\nexport const cypressOperation = defineTemplate<PluginCypress>({\n kind: ast.node.kinds.operation,\n render(node, ctx) {\n if (!ast.http.isOperation(node)) return null\n const { baseURL } = ctx.options\n\n const types = ctx.from(pluginTsName)\n const tsResolver = ctx.getResolver(pluginTsName)\n const { imports } = code.join([\n types.resolver.response.options(node),\n ...resolveOperationTypeNames(node, tsResolver, { includeParams: false }).map((typeName) => types.ref(node, typeName)),\n ])\n const name = ctx.resolver.name(node.operationId)\n\n const meta = {\n name: ctx.resolver.resolveName({ key: operationKey(node), name }),\n file: ctx.file(node),\n } as const\n\n return (\n <File {...meta.file}>\n {imports.map((imp) => (\n <File.Import key={imp.path} names={ast.imports.asType(imp)} root={meta.file.path} path={imp.path} />\n ))}\n <Request name={meta.name} node={node} resolver={tsResolver} baseURL={baseURL} />\n </File>\n )\n },\n})\n","","","import { resolveOperationName } from '@internals/shared'\nimport { createResolver } from '@kubb/kit'\nimport type { PluginCypress } from '../types.ts'\n\n/**\n * Default resolver used by `@kubb/plugin-cypress`. Decides the names and file\n * paths for every generated `cy.request()` wrapper. Functions and files use\n * camelCase, matching the convention from `@kubb/plugin-axios` and `@kubb/plugin-fetch`.\n *\n * @example Resolve a helper name\n * ```ts\n * import { resolverCypress } from '@kubb/plugin-cypress'\n *\n * resolverCypress.name('list pets') // 'listPets'\n * ```\n */\nexport const resolverCypress = createResolver<PluginCypress>({\n pluginName: 'plugin-cypress',\n name: resolveOperationName,\n})\n","import { addMacro, addTemplate, defineExtension, Resolver, setResolver } from '@kubb/kit'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressOperation } from './templates/cypress.tsx'\nimport { resolverCypress } from './resolvers/resolverCypress.ts'\nimport type { PluginCypress, ResolverCypress } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-cypress`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\n/**\n * Generates one typed `cy.request()` wrapper per OpenAPI operation. Each helper\n * has typed path params, body, query, and a typed response, so failing API\n * calls in Cypress show up at compile time instead of inside the test runner.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginTs } from '@kubb/plugin-ts'\n * import { pluginCypress } from '@kubb/plugin-cypress'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [\n * pluginTs(),\n * pluginCypress({\n * output: { path: './cypress' },\n * }),\n * ],\n * })\n * ```\n */\nexport const pluginCypress = defineExtension<PluginCypress>({\n kind: 'plugin',\n meta: { name: pluginCypressName, version, compatibility },\n dependencies: { [pluginTsName]: {} },\n setup(options) {\n const {\n output = { path: 'cypress', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n baseURL,\n resolver: userResolver,\n macros: userMacros,\n } = options\n\n const resolver = userResolver ? Resolver.merge<ResolverCypress>(resolverCypress, ...[userResolver].flat()) : resolverCypress\n\n setResolver(resolver)\n addMacro(...(userMacros ?? []))\n addTemplate(cypressOperation)\n\n return {\n output,\n exclude,\n include,\n override,\n group: group ?? null,\n baseURL,\n }\n },\n})\n\nexport default pluginCypress\n"],"mappings":";;;;;;;;;;;AAGA,SAAgB,UAAU,MAAkE;CAC1F,OAAO,KAAK,aAAa,UAAU,EAAE,EAAE;AACzC;;ACDA,MAAM,+BAAe,IAAI,IAAI;CAC3B,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;AACX,CAAC;;AAGD,SAAS,YAAY,OAAmC;CACtD,MAAM,aAAa,OAAO,UAAU,WAAW,MAAM,aAAa;CAClE,MAAM,aAAa,aAAa,IAAI,OAAO,UAAU,CAAC;CACtD,IAAI,YAAY,OAAO;CACvB,MAAM,OAAO,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AC3E;;CAEV;AACF,CAAC;;;;;;;;;;;;;;;;;;;;;AGzBD,MAAa,mBAAA,GAAkBC,UAAAA,eAAAA,CAA8B;CAC3D,YAAY;CACZ,MAAM;AACR,CAAC;;;;;;ACPD,MAAa,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;AAyBjC,MAAa,iBAAA,GAAgBC,UAAAA,gBAAAA,CAA+B;CAC1D,MAAM;CACN,MAAM;EAAE,MAAM;EAAmB;EAAS;CAAc;CACxD,cAAc,GAAGC,gBAAAA,eAAe,CAAC,EAAE;CACnC,MAAM,SAAS;EACb,MAAM,EACJ,SAAS;GAAE,MAAM;GAAW,QAAQ,EAAE,MAAM,QAAQ;EAAE,GACtD,OACA,UAAU,CAAC,GACX,SACA,WAAW,CAAC,GACZ,SACA,UAAU,cACV,QAAQ,eACN;EAEJ,MAAM,WAAW,eAAeC,UAAAA,SAAS,MAAuB,iBAAiB,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,IAAI;EAE7G,CAAA,GAAA,UAAA,YAAA,CAAY,QAAQ;EACpB,CAAA,GAAA,UAAA,SAAA,CAAS,GAAI,cAAc,CAAC,CAAE;EAC9B,CAAA,GAAA,UAAA,YAAA,CAAY,gBAAgB;EAE5B,OAAO;GACL;GACA;GACA;GACA;GACA,OAAO,SAAS;GAChB;EACF;CACF;AACF,CAAC"}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { HttpOperationNode, Macro } from "@kubb/ast";
1
+ import { HttpOperationNode, Macro, OperationNode } from "@kubb/ast";
2
2
  import { ResolverTs } from "@kubb/plugin-ts";
3
3
  import { KubbReactNode } from "@kubb/renderer-jsx";
4
4
  import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverInput } from "@kubb/kit";
@@ -83,11 +83,14 @@ declare global {
83
83
  }
84
84
  }
85
85
  /**
86
- * Built-in generator for `@kubb/plugin-cypress`. Emits one typed
86
+ * Built-in template for `@kubb/plugin-cypress`. Emits one typed
87
87
  * `cy.request()` wrapper per OpenAPI operation, ready to call inside Cypress
88
88
  * test specs and custom commands.
89
89
  */
90
- export declare const cypressGenerator: import("@kubb/kit").Generator<PluginCypress, unknown>;
90
+ export declare const cypressOperation: {
91
+ kind: "Operation";
92
+ render(node: OperationNode, ctx: import("@kubb/kit").TemplateContext<PluginCypress>): unknown;
93
+ } & ThisType<import("@kubb/kit").TemplateContext<PluginCypress>>;
91
94
  /**
92
95
  * Canonical plugin name for `@kubb/plugin-cypress`. Used for driver lookups and
93
96
  * cross-plugin dependency references.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { HttpOperationNode, Macro } from "@kubb/ast";
1
+ import { HttpOperationNode, Macro, OperationNode } from "@kubb/ast";
2
2
  import { ResolverTs } from "@kubb/plugin-ts";
3
3
  import { KubbReactNode } from "@kubb/renderer-jsx";
4
4
  import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverInput } from "@kubb/kit";
@@ -83,11 +83,14 @@ declare global {
83
83
  }
84
84
  }
85
85
  /**
86
- * Built-in generator for `@kubb/plugin-cypress`. Emits one typed
86
+ * Built-in template for `@kubb/plugin-cypress`. Emits one typed
87
87
  * `cy.request()` wrapper per OpenAPI operation, ready to call inside Cypress
88
88
  * test specs and custom commands.
89
89
  */
90
- export declare const cypressGenerator: import("@kubb/kit").Generator<PluginCypress, unknown>;
90
+ export declare const cypressOperation: {
91
+ kind: "Operation";
92
+ render(node: OperationNode, ctx: import("@kubb/kit").TemplateContext<PluginCypress>): unknown;
93
+ } & ThisType<import("@kubb/kit").TemplateContext<PluginCypress>>;
91
94
  /**
92
95
  * Canonical plugin name for `@kubb/plugin-cypress`. Used for driver lookups and
93
96
  * cross-plugin dependency references.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { ast, file as file$1, ref } from "@kubb/ast";
2
- import { Resolver, Url, addGenerator, casing, code, createResolver, defineExtension, defineGenerator, operationKey, setMacros, setResolver, text } from "@kubb/kit";
3
- import { File, Function, jsxRenderer } from "@kubb/renderer-jsx";
1
+ import { ast, file as file$1, node, ref } from "@kubb/ast";
2
+ import { Resolver, Url, addMacro, addTemplate, casing, code, createResolver, defineExtension, defineTemplate, operationKey, setResolver, text } from "@kubb/kit";
3
+ import { File, Function } from "@kubb/renderer-jsx";
4
4
  import { jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
5
5
  import { pluginTsName } from "@kubb/plugin-ts";
6
6
  // ../../internals/ast/src/http/requestBody.ts
@@ -432,16 +432,15 @@ ${compositeLines} const text = value instanceof Date ? value.toISOString() : St
432
432
  children: requestCall
433
433
  });
434
434
  }
435
- // src/generators/cypressGenerator.tsx
435
+ // src/templates/cypress.tsx
436
436
  /**
437
- * Built-in generator for `@kubb/plugin-cypress`. Emits one typed
437
+ * Built-in template for `@kubb/plugin-cypress`. Emits one typed
438
438
  * `cy.request()` wrapper per OpenAPI operation, ready to call inside Cypress
439
439
  * test specs and custom commands.
440
440
  */
441
- const cypressGenerator = defineGenerator({
442
- name: "cypress",
443
- renderer: jsxRenderer,
444
- operation(node, ctx) {
441
+ const cypressOperation = defineTemplate({
442
+ kind: node.kinds.operation,
443
+ render(node, ctx) {
445
444
  if (!isOperation(node)) return null;
446
445
  const { baseURL } = ctx.options;
447
446
  const types = ctx.from(pluginTsName);
@@ -476,7 +475,7 @@ var compatibility = {
476
475
  "node": ">=22.22"
477
476
  };
478
477
  // package.json
479
- var version = "5.5.0-canary.20261123T120417";
478
+ var version = "5.5.0";
480
479
  // src/resolvers/resolverCypress.ts
481
480
  /**
482
481
  * Default resolver used by `@kubb/plugin-cypress`. Decides the names and file
@@ -538,8 +537,8 @@ const pluginCypress = defineExtension({
538
537
  }, group, exclude = [], include, override = [], baseURL, resolver: userResolver, macros: userMacros } = options;
539
538
  const resolver = userResolver ? Resolver.merge(resolverCypress, ...[userResolver].flat()) : resolverCypress;
540
539
  setResolver(resolver);
541
- if (userMacros?.length) setMacros(userMacros);
542
- addGenerator(cypressGenerator);
540
+ addMacro(...userMacros ?? []);
541
+ addTemplate(cypressOperation);
543
542
  return {
544
543
  output,
545
544
  exclude,
@@ -550,6 +549,6 @@ const pluginCypress = defineExtension({
550
549
  };
551
550
  }
552
551
  });
553
- export { Request, cypressGenerator, pluginCypress as default, pluginCypress, pluginCypressName, resolverCypress };
552
+ export { Request, cypressOperation, pluginCypress as default, pluginCypress, pluginCypressName, resolverCypress };
554
553
 
555
554
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["file","ast.http.getRequestGroups","ast.http.responses.findPrimary","ast.http.responses.filterError","ast.http.groupParameters","ast.http.requestBody.getSchema","ast.http.requestBody.getSchema","ast.http.isOperation","ast.imports.asType"],"sources":["../../../internals/ast/src/http/requestBody.ts","../../../internals/ast/src/http/status.ts","../../../internals/ast/src/http/responses.ts","../../../internals/ast/src/http/index.ts","../../../internals/ast/src/imports.ts","../../../internals/utils/src/reserved.ts","../../../internals/shared/src/operation.ts","../../../internals/shared/src/resolver.ts","../src/components/Request.tsx","../src/generators/cypressGenerator.tsx","../kubb-extension.json","../package.json","../src/resolvers/resolverCypress.ts","../src/plugin.ts"],"sourcesContent":["import type { OperationNode, SchemaNode } from '@kubb/ast'\n\n/** The schema of the first request body entry, else `undefined` when the operation takes no body. */\nexport function getSchema(node: Pick<OperationNode, 'requestBody'>): SchemaNode | undefined {\n return node.requestBody?.content?.[0]?.schema\n}\n","import type { ResponseNode, StatusCode } from '@kubb/ast'\n\ntype StatusInput = StatusCode | number | (string & {}) | Pick<ResponseNode, 'statusCode'>\n\nconst classByRange = new Map([\n ['1xx', 1],\n ['2xx', 2],\n ['3xx', 3],\n ['4xx', 4],\n ['5xx', 5],\n])\n\n/** The class digit of a status code or range: `2` for `201` and `2xx`, `null` for `default`. */\nfunction statusClass(input: StatusInput): number | null {\n const statusCode = typeof input === 'object' ? input.statusCode : input\n const rangeClass = classByRange.get(String(statusCode))\n if (rangeClass) return rangeClass\n const code = Number(statusCode)\n return Number.isNaN(code) ? null : Math.floor(code / 100)\n}\n\nexport { statusClass as getClass }\n\nexport function isSuccess(statusCode: StatusInput): boolean {\n return statusClass(statusCode) === 2\n}\n\nexport function isError(statusCode: StatusInput): boolean {\n const code = statusClass(statusCode)\n return code !== null && code >= 4\n}\n\n/** One concrete code for a status or range: `200` for `2xx` and `default`, the code itself otherwise. */\nexport function toCode(input: StatusInput): number {\n const statusCode = typeof input === 'object' ? input.statusCode : input\n const code = Number(statusCode)\n return Number.isNaN(code) ? (statusClass(statusCode) ?? 2) * 100 : code\n}\n","import { ast, type HttpOperationNode, type OperationNode, type ResponseNode, type SchemaNode } from '@kubb/ast'\nimport { isError, isSuccess } from './status.ts'\n\n/** The `4xx` and `5xx` responses, ranges included. */\nexport function filterError(node: Pick<HttpOperationNode, 'responses'>): Array<ResponseNode> {\n return node.responses.filter((response) => isError(response.statusCode))\n}\n\n/** The ref names the response bodies import, in order, with repeats. */\nexport function getImportedNames(responses: ReadonlyArray<ResponseNode>): Array<string> {\n return responses.flatMap((response) => (response.content ?? []).flatMap((entry) => (entry.schema ? ast.graph.getImportedNames(entry.schema) : [])))\n}\n\nexport function filterSuccess(node: Pick<HttpOperationNode, 'responses'>): Array<ResponseNode> {\n return node.responses.filter((response) => isSuccess(response.statusCode))\n}\n\n/** The success response a client returns: one with a body first, then an exact code over a `2xx` range. */\nexport function findPrimary(node: Pick<HttpOperationNode, 'responses'>): ResponseNode | null {\n const responses = filterSuccess(node)\n const withBody = responses.filter((response) => response.content?.some((entry) => entry.contentType))\n const candidates = withBody.length ? withBody : responses\n return candidates.find((response) => !Number.isNaN(Number(response.statusCode))) ?? candidates[0] ?? null\n}\n\n/** A union of refs to the success responses with a body, else every response with a body, else `null`. */\nexport function getUnion<TNode extends Pick<OperationNode, 'responses'>>(\n node: TNode,\n resolver: { response: { status(node: TNode, statusCode: ResponseNode['statusCode']): string } },\n): SchemaNode | null {\n const withSchema = node.responses.filter((response) => response.content?.some((entry) => entry.schema))\n const success = withSchema.filter((response) => isSuccess(response.statusCode))\n const responses = success.length > 0 ? success : withSchema\n if (responses.length === 0) return null\n\n return ast.factory.createSchema({\n type: 'union',\n members: responses.map((response) => ast.factory.createSchema({ type: 'ref', name: resolver.response.status(node, response.statusCode) })),\n })\n}\n","import { ast, type HttpOperationNode, type InputServer, type ParameterNode } from '@kubb/ast'\n\nexport const isOperation = ast.http.isOperation\nexport * as requestBody from './requestBody.ts'\nexport * as responses from './responses.ts'\nexport * as status from './status.ts'\n\n/** The server's URL when it is absolute and has no template variables, else `undefined`. */\nexport function getBaseURL(server: InputServer | undefined): string | undefined {\n if (!server || server.variables || server.url.includes('{') || !server.url.includes('://')) return undefined\n return URL.canParse(server.url) ? server.url : undefined\n}\n\n/** Computes once per key; generators visit the same node many times. */\nfunction cached<TKey extends object, TValue>(store: WeakMap<TKey, TValue>, key: TKey, compute: () => TValue): TValue {\n if (!store.has(key)) store.set(key, compute())\n return store.get(key)!\n}\n\ntype ParameterGroups = Record<'path' | 'query' | 'header' | 'cookie', Array<ParameterNode>>\n\n// Every plugin's generator visits the same node, so the groups are built once per node.\nconst parametersByNode = new WeakMap<Pick<HttpOperationNode, 'parameters'>, ParameterGroups>()\n\n/** The operation's parameters by location, with a `querystring` parameter in `query`. A repeated name keeps its first parameter. */\nexport function groupParameters(node: Pick<HttpOperationNode, 'parameters'>): ParameterGroups {\n return cached(parametersByNode, node, () => {\n const group = (...locations: Array<ParameterNode['in']>) => {\n const seen = new Set<string>()\n return locations.flatMap((location) =>\n 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 // A `querystring` parameter left whole, such as a JSON one, is sent as the query string, so it joins the query group.\n return { path: group('path'), query: group('query', 'querystring'), header: group('header'), cookie: group('cookie') }\n })\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n cookies: boolean\n /** `cookies` is never required: a browser sends its cookies itself. */\n required: { path: boolean; query: boolean; headers: boolean; body: boolean }\n /** No group holds a required member. */\n isOptional: boolean\n contentTypes: Array<string>\n /** More than one body media type has a schema, so a caller must pick one. */\n hasContentTypeChoice: boolean\n}\n\nconst requestGroupsByNode = new WeakMap<Pick<HttpOperationNode, 'parameters' | 'requestBody'>, RequestGroups>()\n\n/** Which request groups are present, which hold a required member, and the body's media types. Built once per operation. */\nexport function getRequestGroups(node: Pick<HttpOperationNode, 'parameters' | 'requestBody'>): RequestGroups {\n return cached(requestGroupsByNode, node, () => {\n const { path, query, header, cookie } = groupParameters(node)\n const content = node.requestBody?.content ?? []\n const body = Boolean(content[0]?.schema)\n const required = {\n path: path.some((param) => param.required),\n query: query.some((param) => param.required),\n headers: header.some((param) => param.required),\n body: body && node.requestBody?.required === true,\n }\n\n return {\n path: path.length > 0,\n query: query.length > 0,\n body,\n headers: header.length > 0,\n cookies: cookie.length > 0,\n required,\n isOptional: !required.path && !required.query && !required.headers && !required.body,\n contentTypes: content.map((entry) => entry.contentType),\n hasContentTypeChoice: content.filter((entry) => entry.schema).length > 1,\n }\n })\n}\n","import { file } from '@kubb/ast'\nimport type { ImportNode, ModuleName } from '@kubb/ast'\n\n/**\n * Returns the names of `imp`, each marked as a type, for an import that only types use.\n *\n * @example\n * ```tsx\n * <File.Import names={ast.imports.asType(imp)} path={imp.path} root={file.path} />\n * ```\n */\nexport function asType(imp: ImportNode): Array<ModuleName> {\n return file.getNames(imp).map((item) => ({ ...item, space: 'type' }))\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 { ast } from '@internals/ast'\nimport { jsDocEscape } from '@internals/utils'\nimport type { Resolver } from '@kubb/kit'\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n cookies(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type BuildOperationCommentsOptions = {\n splitLines?: boolean\n}\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\n/**\n * The operation's method and path as plain text, such as `` `GET /pet/{petId}` ``. A path is not a valid `{@link}` target.\n */\nfunction getOperationRequestLine(node: ast.OperationNode): string | null {\n return ast.http.isOperation(node) && node.path ? `\\`${node.method.toUpperCase()} ${node.path}\\`` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(ast.http.getRequestGroups(node).contentTypes)\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(ast.http.responses.findPrimary(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\n/** How an operation streams its success responses, as {@link getStream} returns it. */\nexport type ResponseStream = {\n /** `event` for a whole typed event, `data` for a typed payload, `line` for a JSON Lines value. */\n shape: 'event' | 'data' | 'line' | null\n /** Whether events keep `data` as text: all of them, the named ones, or none. */\n textEvents: boolean | Array<string>\n /** Whether the primary success response offers `text/event-stream`. */\n hasEventStream: boolean\n /** Whether a success response offers a stream next to other content types. */\n hasVariant: boolean\n}\n\nconst isText = (schema: ast.SchemaNode | null | undefined) => !!schema && ast.schema.is(schema, 'text', { follow: ['ref'] })\n\nfunction getTextEvents(entry: ast.ContentNode, shape: ResponseStream['shape']): ResponseStream['textEvents'] {\n if (shape === 'data') return isText(entry.stream?.schema ?? entry.schema)\n if (shape !== 'event' || !entry.stream?.schema) return false\n\n const item = ast.ref.getSchema(entry.stream.schema)\n const events = ast.schema.narrow(item, 'union')?.members ?? [item]\n // A discriminator makes each event an intersection of its `$ref` and the pinned `event`, so every part is read.\n const propertySchemas = (event: ast.SchemaNode, propertyName: string) => ast.schema.findProperties({ node: event, propertyName }).map(({ schema }) => schema)\n const textEvents = events.filter((event) => {\n const dataSchemas = propertySchemas(event, 'data')\n return dataSchemas.length > 0 && dataSchemas.every(isText)\n })\n if (textEvents.length === events.length) return events.length > 0\n\n const eventNames = textEvents.map((event) => propertySchemas(event, 'event').flatMap((schema) => ast.schema.getLiterals(ast.ref.getSchema(schema))))\n // An event without a fixed name cannot be told apart from the others.\n if (!eventNames.length || eventNames.some((values) => !values.length)) return false\n return [...new Set(eventNames.flat().map(String))]\n}\n\n/** How an operation streams its success responses, or `null` when none offers a stream. */\nexport function getStream(node: Pick<ast.HttpOperationNode, 'responses'>): ResponseStream | null {\n const entries = ast.http.responses.findPrimary(node)?.content ?? []\n const entry = entries.length === 1 ? entries[0] : undefined\n const kind = entry ? ast.mediaType.getKind(entry) : null\n const shape = kind === 'eventStream' ? (entry?.stream?.shape ?? 'data') : kind === 'lineStream' ? 'line' : null\n // Next to another type, a stream without a schema gets no typed variant, so it keeps the plain call.\n const hasEventStream = entries.some((item) => ast.mediaType.getKind(item) === 'eventStream' && (entries.length === 1 || !!item.schema))\n const hasVariant = ast.http.responses.filterSuccess(node).some((response) => {\n const variants = (response.content ?? []).filter((item) => item.schema)\n return variants.length > 1 && variants.some(ast.mediaType.isStream)\n })\n if (!shape && !hasEventStream && !hasVariant) return null\n\n return { shape, textEvents: entry ? getTextEvents(entry, shape) : false, hasEventStream, hasVariant }\n}\n\ntype ResponseType = 'blob' | 'text' | 'stream'\n\ntype ResponseContentEntry = { contentType: string; schema?: ast.SchemaNode | null; stream?: ast.ContentNode['stream'] }\n\nconst responseTypes: Partial<Record<NonNullable<ReturnType<typeof ast.mediaType.getKind>>, ResponseType>> = {\n eventStream: 'stream',\n lineStream: 'stream',\n binary: 'blob',\n text: 'text',\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n // Keeps the original case, unlike ast.mediaType.getBase, so generated names stay stable.\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Returns the entry with the schema of the value the client returns: `string` for a body read as text, such as `Pet` on\n * `application/xml`, and `blob` for `image/*`, `audio/*`, `video/*`, PDF, and octet-stream. A binary schema elsewhere is a `Blob`\n * only through `parseAs: 'blob'`, which needs every entry in `entries` binary. JSON, vendor (`application/vnd.*`), stream,\n * schemaless, and wildcard entries keep their schema. `entries` is the response's full list of content types.\n */\nexport function toResponseContent<T extends ContentVariantInput & ResponseContentEntry>(entry: T, entries: ReadonlyArray<ResponseContentEntry> = [entry]): T {\n const { contentType, schema } = entry\n if (!schema || entry.stream) return entry\n\n const baseType = ast.mediaType.getBase(contentType)\n const resolved = ast.ref.getSchema(schema)\n if (ast.mediaType.getKind(baseType) === 'binary') {\n return resolved.type === 'blob' ? entry : { ...entry, schema: ast.factory.createSchema({ type: 'blob' }), keysToOmit: null }\n }\n const isPlainMediaType = Boolean(baseType) && !ast.mediaType.isJson(baseType) && !baseType.includes('*')\n if (resolved.type === 'blob') {\n // shortcut: an error response never gets `parseAs`, so a lone binary schema there reads as text too but stays `Blob`.\n const readsAsText = isPlainMediaType && !entries.every((item) => item.schema?.type === 'blob')\n return readsAsText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n }\n if (resolved.primitive === 'string') return entry\n\n const kind = ast.mediaType.getKind(entry)\n const responseType = kind ? responseTypes[kind] : undefined\n // A response without a body, such as a 405, has no schema to read. Only `text/*` is always text.\n if (responseType !== 'text' && (resolved.type === 'unknown' || resolved.type === 'any' || resolved.type === 'void')) return entry\n const isVendorJson = /^[^/]+\\/vnd\\./.test(baseType) && !/(xml|yaml|yml|csv)$/.test(baseType)\n const isText = responseType === 'text' || (!responseType && isPlainMediaType && !isVendorJson)\n\n return isText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n}\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...): `RequestConfig` minus what the\n * hook fills in, which is every request group and `throwOnError`. Unlike {@link buildRequestConfigType},\n * it never narrows `contentType`: query hooks wrap GET operations, which carry no request body to select\n * a content type for.\n */\nexport function buildClientOptionType(options: { omit?: Array<string> } = {}): string {\n const keys = [...requestGroupOrder, 'url', ...(options.omit ?? []), 'throwOnError']\n return `Partial<Omit<RequestConfig, ${keys.map((key) => `'${key}'`).join(' | ')}>>`\n}\n\n/**\n * The `client?:` option type of a mutation hook. When the operation has a request content type choice,\n * the mutation variables carry `contentType`, so the config leaves it out. Otherwise the ambiguous side is\n * narrowed to the operation's media types; a single-type side has nothing to pick, so it stays baked in the\n * generated call.\n */\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n if (ast.http.getRequestGroups(node).hasContentTypeChoice) {\n return buildClientOptionType({ omit: ['contentType'] })\n }\n\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n const base = buildClientOptionType()\n return members.length ? `${base} & { contentType?: { ${members.join('; ')} } }` : base\n}\n\n/** The grouped request options, in the order generated signatures and calls list them. */\nexport const requestGroupOrder = ['path', 'query', 'body', 'headers', 'cookies'] as const\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers, cookies }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: ast.http.RequestGroups; names: Array<(typeof requestGroupOrder)[number]> } {\n const { isConfigurable = true } = options\n const groups = ast.http.getRequestGroups(node)\n\n const names = requestGroupOrder.filter((key) => groups[key])\n\n // These callers never carry the `contentType` that several media types require.\n const optionsType = groups.hasContentTypeChoice\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}${groups.isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n names,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { splitLines = false } = options\n // The request line leads: free text after a block tag would belong to that tag.\n const comments = [\n getOperationRequestLine(node),\n node.description && `@description ${node.description}`,\n node.summary && `@summary ${node.summary}`,\n node.deprecated && '@deprecated',\n node.externalDocs && `@see ${jsDocEscape([node.externalDocs.url, node.externalDocs.description].filter(Boolean).join(' '))}`,\n ]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\n/**\n * Casts a call argument to the client's parameter type; a `'plain'` client is non-generic.\n */\nexport function castToClientOptions(callArg: string, clientName: string, returnType: 'full' | 'data' | 'plain' = 'full'): string {\n return `${callArg} as Parameters<typeof ${clientName}${returnType === 'plain' ? '' : '<true>'}>[0]`\n}\n\n/**\n * Builds the combined `{ body, path, query, headers, cookies }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. `cookies` appears only on an operation\n * with a cookie parameter, and stays optional because a browser sends its cookies itself. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same shape from the same inputs.\n * `primitive: 'object'` is a no-op for the TS printer and tells the Zod printer to emit `z.object(…)` rather\n * than a record.\n */\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver, { pairContentTypes = false } = {}): ast.SchemaNode {\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n const hasBody = Boolean(ast.http.requestBody.getSchema(node))\n const createNever = () => ast.factory.createSchema({ type: 'never', primitive: undefined, optional: true })\n const groups = [\n { name: 'path', params: path, resolve: resolver.param.path },\n { name: 'query', params: query, resolve: resolver.param.query },\n { name: 'headers', params: header, resolve: resolver.param.headers },\n { name: 'cookies', params: cookie, resolve: resolver.param.cookies },\n ] as const\n\n const createOptions = (body: ast.SchemaNode, extra: Array<ast.PropertyNode> = []) =>\n // NOTE(v5-stable): the fields were renamed from the legacy beta shape\n // (`data`/`pathParams`/`queryParams`/`headerParams`) to `body`/`path`/`query`/`headers` so the\n // type matches the runtime client. Drop this note once v5 leaves beta.\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({ name: 'body', required: hasBody && node.requestBody?.required === true, schema: body }),\n ...groups\n .filter(({ name, params }) => name !== 'cookies' || params.length > 0)\n .map(({ name, params, resolve }) => {\n const required = name !== 'cookies' && params.some((param) => param.required)\n\n return ast.factory.createProperty({\n name,\n required,\n schema:\n params.length > 0\n ? ast.factory.createSchema({ type: 'ref', name: resolve.call(resolver.param, node, params[0]!), optional: !required })\n : createNever(),\n })\n }),\n ...extra,\n ],\n })\n\n const variants =\n pairContentTypes && ast.http.getRequestGroups(node).hasContentTypeChoice\n ? resolveContentTypeVariants(node.requestBody?.content ?? [], resolver.response.body(node))\n : []\n if (variants.length < 2) {\n return createOptions(hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever())\n }\n\n // The first media type is the runtime default, so only the others must pass `contentType`. A bare string sets the\n // request content type at runtime, so it is accepted next to the `{ request }` form.\n return ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant, index) => {\n const contentType = ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] })\n\n return createOptions(ast.factory.createSchema({ type: 'ref', name: variant.name }), [\n ast.factory.createProperty({\n name: 'contentType',\n required: index > 0,\n schema: ast.factory.createSchema({\n type: 'union',\n members: [\n contentType,\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [ast.factory.createProperty({ name: 'request', required: true, schema: contentType })],\n }),\n ],\n }),\n }),\n ])\n }),\n })\n}\n\n/**\n * The schema a status occupies in the `<Name>Responses` record. A status that documents several\n * content types becomes a `{ contentType; data }` union so the runtime can surface the negotiated type\n * on `result.parsed`, while the standalone `<Name>StatusNNN` alias stays the plain body union that the\n * query hooks and `result.data` use. With `streamData`, the stream variant of a 2xx status holds that schema, since the\n * client returns its body unread.\n */\nfunction buildResponseRecordEntry(\n node: ast.OperationNode,\n res: ast.ResponseNode,\n resolver: ResponseStatusNameResolver,\n streamData: ast.SchemaNode | undefined,\n): ast.SchemaNode {\n const statusName = resolver.response.status(node, res.statusCode)\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length <= 1) {\n return ast.factory.createSchema({ type: 'ref', name: statusName })\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: resolveContentTypeVariants(variants, statusName).map((variant) =>\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'contentType',\n required: true,\n // The runtime reports the bare media type, without parameters such as `charset` or `profile`.\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [ast.mediaType.getBase(variant)] }),\n }),\n ast.factory.createProperty({\n name: 'data',\n required: true,\n schema:\n streamData && ast.http.status.isSuccess(res) && ast.mediaType.isStream(variant)\n ? streamData\n : ast.factory.createSchema({ type: 'ref', name: variant.name }),\n }),\n ],\n }),\n ),\n })\n}\n\n/**\n * Builds the per-status `<Name>Responses` record for an operation, referencing the already-resolved\n * `<Name>StatusNNN` names. Shared by `@kubb/plugin-ts`'s `Responses` type and `@kubb/plugin-zod`'s\n * inferred responses schema, so both emit the same shape from the same inputs.\n *\n * Always emits the keyed record, even when an operation declares no responses. An operation with no\n * responses renders as an empty object, which keeps every consumer's import (for example the axios\n * SDK's `RequestResult<XResponses>`) resolvable instead of pointing at a missing export.\n *\n * `streamData` is the type of a stream variant's `data`, such as a `ReadableStream<Uint8Array>` reference.\n */\nexport function buildResponses(\n node: ast.OperationNode,\n resolver: ResponseStatusNameResolver,\n { streamData }: { streamData?: ast.SchemaNode } = {},\n): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: node.responses.map((res) =>\n ast.factory.createProperty({\n name: String(res.statusCode),\n required: true,\n schema: buildResponseRecordEntry(node, res, resolver, streamData),\n }),\n ),\n })\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return ast.http.responses.filterError(node).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return ast.http.responses.filterSuccess(node).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.response.status(node, response.statusCode))\n}\n\n/**\n * Lists the type names an operation's types file declares, computed once per resolver and `options` so every\n * dependent reads the same list.\n */\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver & Pick<Resolver, 'memo'>,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const key = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n return resolver.memo(`operationTypeNames:${key}`, () => {\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ...cookie.map((param) => resolver.param.cookies(node, param)),\n ]\n const bodyAndResponseNames = [ast.http.requestBody.getSchema(node) ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n return names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n })\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = Number(response.statusCode)\n if (Number.isNaN(code)) {\n continue\n }\n\n types.push([code, ast.http.status.isSuccess(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n\n/**\n * One object schema for a list of parameters or response headers, with each schema inline.\n */\nexport function buildParamsSchema(params: Array<ast.ParameterNode>): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n // `primitive: 'object'` makes a printer emit an object schema and not a record.\n primitive: 'object',\n properties: params.map((param) => ast.factory.createProperty({ name: param.name, required: param.required, schema: param.schema })),\n })\n}\n\n/**\n * One object schema for the parameters of an operation, where each key points at the const of\n * that parameter. The const already has its optional wrapper, so every key is required here.\n */\nexport function buildParamRefsSchema({\n node,\n params,\n resolver,\n}: {\n node: ast.OperationNode\n params: Array<ast.ParameterNode>\n resolver: { param: { name(node: ast.OperationNode, param: ast.ParameterNode): string } }\n}): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: params.map((param) =>\n ast.factory.createProperty({\n name: param.name,\n required: true,\n schema: ast.factory.createSchema({ type: 'ref', name: resolver.param.name(node, param) }),\n }),\n ),\n })\n}\n\ntype SchemaEntry = { schema: ast.SchemaNode; name: string; keysToOmit?: Array<string> | null }\n\n/**\n * The schemas a name with several content types needs: one per content type, then the union of\n * them under `baseName`.\n */\nexport function buildContentTypeEntries(\n entries: Array<ContentVariantInput>,\n baseName: string,\n decorate: (schema: ast.SchemaNode) => ast.SchemaNode = (schema) => schema,\n): Array<SchemaEntry> {\n const variants = resolveContentTypeVariants(entries, baseName)\n const union = ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant) => ast.factory.createSchema({ type: 'ref', name: variant.name })),\n })\n\n return [\n ...variants.map((variant) => ({ schema: decorate(variant.schema), name: variant.name, keysToOmit: variant.keysToOmit })),\n { schema: union, name: baseName },\n ]\n}\n\n/**\n * The schema behind a response or error name: a union of the per-status schemas. Returns `null`\n * when a response is a `$ref` to a component whose name is already `name`, which would declare it twice.\n */\nexport function buildResponseUnionSchema({\n node,\n responses,\n name,\n resolver,\n fallbackUnknown,\n}: {\n node: ast.OperationNode\n responses: Array<ast.ResponseNode>\n name: string\n resolver: { name(name: string): string; response: { status(node: ast.OperationNode, statusCode: ast.StatusCode): string } }\n /**\n * Print an unknown schema when no response has one, so the name still resolves.\n */\n fallbackUnknown: boolean\n}): ast.SchemaNode | null {\n const importedNames = new Set(ast.http.responses.getImportedNames(responses).map((refName) => resolver.name(refName)))\n if (importedNames.has(name)) return null\n\n const members = responses.map((res) => ast.factory.createSchema({ type: 'ref', name: resolver.response.status(node, res.statusCode) }))\n if (members.length === 0) return fallbackUnknown ? ast.factory.createSchema({ type: 'unknown' }) : null\n\n return members.length === 1 ? members[0]! : ast.factory.createSchema({ type: 'union', members })\n}\n","import { ast } from '@internals/ast'\nimport { ensureValidVarName } from '@internals/utils'\nimport { casing, memo, useKubb } from '@kubb/kit'\nimport type { FileTarget, GeneratorContext, Group, Output, PrinterContext, Resolver, ResolverFileParams } from '@kubb/kit'\n\n/**\n * The shared top-level `name` of the operation plugins, computed once per operation name and build.\n */\nexport function resolveOperationName(this: Resolver, name: string): string {\n return this.memo(`operation:${name}`, () => ensureValidVarName(casing.camel(name)))\n}\n\n/** `ctx.file(node)` for a file that no single node owns, such as `handlers.ts`: path, banner and footer from the current plugin. */\nexport function namedFile(entry: Pick<ResolverFileParams, 'name' | 'tag'> & { extname?: ResolverFileParams['extname'] }): FileTarget {\n const ctx = useKubb<GeneratorContext>()\n const { output, group } = ctx.options as { output: Output; group?: Group | null }\n const file = ctx.resolver.file({ extname: '.ts', ...entry, root: ctx.root, output, group: group ?? undefined })\n const fileContext = { output, config: ctx.config, file: { path: file.path, baseName: file.baseName } }\n\n return {\n baseName: file.baseName,\n path: file.path,\n meta: file.meta,\n banner: ctx.resolver.default.banner(ctx.meta, fileContext),\n footer: ctx.resolver.default.footer(ctx.meta, fileContext),\n }\n}\n\n/**\n * Names of the schemas in a circular reference chain, computed once per build. Reads the current context, so call it\n * in a generator or a printer factory.\n */\nexport function getCircularNames(): ReadonlySet<string> {\n return memo('circularNames:set', () => ast.graph.getCircularNames(useKubb<PrinterContext>().schemas))\n}\n\n/**\n * Names of the schemas whose type is `enum`, computed once per build. Reads the current context, so call it\n * in a generator or a printer factory.\n */\nexport function getEnumNames(): ReadonlySet<string> {\n return memo(\n 'enumNames:set',\n () => new Set(useKubb<PrinterContext>().schemas.flatMap((schema) => (schema.type === 'enum' && schema.name ? [schema.name] : []))),\n )\n}\n\ndeclare global {\n namespace Kubb {\n interface MemoRegistry {\n operation: string\n file: ast.FileNode['baseName']\n operationTypeNames: Array<string>\n }\n }\n}\n","import { ast } from '@internals/ast'\nimport { buildRequestParamsSignature } from '@internals/shared'\n\nimport { text, Url } from '@kubb/kit'\nimport type { ResolverTs } from '@kubb/plugin-ts'\nimport { Function } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n /**\n * AST operation node\n */\n node: ast.HttpOperationNode\n /**\n * TypeScript resolver for resolving param/data/response type names\n */\n resolver: ResolverTs\n baseURL: string | null | undefined\n}\n\nexport function Request({ baseURL = '', name, resolver, node }: Props): KubbReactNode {\n const { signature, groups } = buildRequestParamsSignature(node, resolver, { isConfigurable: false })\n const paramsSignature = [signature, 'options: Partial<Cypress.RequestOptions> = {}'].filter(Boolean).join(', ')\n\n const responseType = resolver.response.response(node)\n const returnType = `Cypress.Chainable<${responseType}>`\n\n // Bracket-access the path object with the raw OpenAPI param names, matching the generated `path` type's keys.\n const urlTemplate = Url.toGroupedTemplateString(node.path, { prefix: baseURL })\n\n // `cy.request` has no cookie option, so the cookie group goes out as a `Cookie` header. An array joins with commas, a Date\n // is ISO 8601, and an object is JSON.\n const cookieText =\n \"value instanceof Date ? value.toISOString() : Array.isArray(value) ? value.join(',') : typeof value === 'object' ? JSON.stringify(value) : String(value)\"\n // The OpenAPI 3.2 `cookie` style sends a value as it is, and throws on one it cannot send, like the generated clients do.\n // With `explode` (its default) an array sends one cookie per item and an object one cookie per key, otherwise both join with commas.\n const rawParameters = node.parameters.filter((parameter) => parameter.in === 'cookie' && parameter.style === 'cookie')\n // Only an array or object needs the join and explode code. A value with one primitive type goes out as one cookie.\n const isComposite = (parameter: ast.ParameterNode) =>\n !['string', 'number', 'integer', 'bigint', 'boolean'].includes(ast.ref.getSchema(parameter.schema).primitive ?? '')\n const isExploded = (parameter: ast.ParameterNode) => parameter.explode !== false && isComposite(parameter)\n const explodedCookies = rawParameters.filter(isExploded).map((parameter) => text.quote(parameter.name))\n const joinedCookies = rawParameters.filter((parameter) => !isExploded(parameter)).map((parameter) => text.quote(parameter.name))\n // A `form` cookie explodes only when the spec sets `explode: true`, like the generated clients, and its items stay percent-encoded.\n const explodedFormCookies = node.parameters\n .filter((parameter) => parameter.in === 'cookie' && parameter.style !== 'cookie' && parameter.explode === true && isComposite(parameter))\n .map((parameter) => text.quote(parameter.name))\n const compositeLines = rawParameters.some(isComposite)\n ? ` if (Array.isArray(value)) return value.filter((item) => item != null).map(rawCookie).join(',')\n if (typeof value === 'object' && value !== null && !(value instanceof Date)) return Object.entries(value).filter(([, item]) => item != null).flat().map(rawCookie).join(',')\\n`\n : ''\n const explodeCookieLine =\n explodedCookies.length || explodedFormCookies.length\n ? `const explodeCookie = (name: string, value: unknown, encode: (item: unknown) => string): Array<string> => {\n if (Array.isArray(value)) return value.filter((item) => item != null).map((item) => \\`\\${name}=\\${encode(item)}\\`)\n if (typeof value === 'object' && value !== null && !(value instanceof Date)) return Object.entries(value).filter(([, item]) => item != null).map(([key, item]) => \\`\\${encode(key)}=\\${encode(item)}\\`)\n return [\\`\\${name}=\\${encode(value)}\\`]\n}\\n`\n : ''\n const formCookieLine = explodedFormCookies.length\n ? 'const formCookie = (item: unknown): string => encodeURIComponent(item instanceof Date ? item.toISOString() : String(item))\\n'\n : ''\n // Keep the cookie-octet pattern in step with `rawCookieValue` in plugin-client's `templates/serializers.ts`.\n const rawCookieLine = rawParameters.length\n ? `const rawCookie = (value: unknown): string => {\n${compositeLines} const text = value instanceof Date ? value.toISOString() : String(value)\n if (!/^[\\\\x21\\\\x23-\\\\x2B\\\\x2D-\\\\x3A\\\\x3C-\\\\x5B\\\\x5D-\\\\x7E]*$/.test(text)) throw new TypeError('A cookie has characters the cookie style cannot send, escape it first.')\n return text\n}\\n`\n : ''\n const encodeCookie = joinedCookies.length\n ? `([${joinedCookies.join(', ')}].includes(name) ? rawCookie(value) : encodeURIComponent(${cookieText}))`\n : `encodeURIComponent(${cookieText})`\n const explodeRaw = explodedCookies.length ? `[${explodedCookies.join(', ')}].includes(name) ? explodeCookie(name, value, rawCookie) : ` : ''\n const explodeForm = explodedFormCookies.length ? `[${explodedFormCookies.join(', ')}].includes(name) ? explodeCookie(name, value, formCookie) : ` : ''\n const toCookies =\n explodeRaw || explodeForm\n ? `.flatMap(([name, value]) => (${explodeRaw}${explodeForm}[\\`\\${name}=\\${${encodeCookie}}\\`]))`\n : `.map(([name, value]) => \\`\\${name}=\\${${encodeCookie}}\\`)`\n // Built first and sent only when non-empty, so a call without cookies keeps the cookies Cypress attaches itself.\n const cookieLine = `${rawCookieLine}${explodeCookieLine}${formCookieLine}const cookie = (Object.entries(cookies ?? {}) as Array<[string, unknown]>).filter(([, value]) => value != null)${toCookies}.join('; ')\\n`\n\n // Cypress types a body as a string or an object, so a body that is one number or has no schema type is cast.\n const requestSchema = ast.http.requestBody.getSchema(node)\n const bodySchema = requestSchema && ast.ref.getSchema(requestSchema)\n const castBody = bodySchema && (['number', 'integer'].includes(bodySchema.primitive ?? '') || ['unknown', 'any'].includes(bodySchema.type))\n\n const requestOptions = [\n `method: ${text.quote(node.method)}`,\n `url: ${urlTemplate}`,\n groups.query && 'qs: query',\n groups.cookies ? `headers: { ${groups.headers ? '...headers, ' : ''}...(cookie ? { Cookie: cookie } : {}) }` : groups.headers && 'headers',\n groups.body && (castBody ? 'body: body as unknown as Cypress.RequestBody' : 'body'),\n '...options',\n ].filter(Boolean)\n\n // Cypress's catch-all `then` overload types a union body as `Chainable<Response | Pet> | Chainable<Response | string>`, so cast to the declared return type.\n const requestCall = `${groups.cookies ? cookieLine : ''}return cy.request<${responseType}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body) as ${returnType}`\n\n return (\n <Function name={name} export params={paramsSignature} returnType={returnType}>\n {requestCall}\n </Function>\n )\n}\n","import { ast } from '@internals/ast'\nimport { resolveOperationTypeNames } from '@internals/shared'\nimport { code, defineGenerator, operationKey } from '@kubb/kit'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Request } from '../components/Request.tsx'\nimport type { PluginCypress } from '../types.ts'\n\n/**\n * Built-in generator for `@kubb/plugin-cypress`. Emits one typed\n * `cy.request()` wrapper per OpenAPI operation, ready to call inside Cypress\n * test specs and custom commands.\n */\nexport const cypressGenerator = defineGenerator<PluginCypress>({\n name: 'cypress',\n renderer: jsxRenderer,\n operation(node, ctx) {\n if (!ast.http.isOperation(node)) return null\n const { baseURL } = ctx.options\n\n const types = ctx.from(pluginTsName)\n const tsResolver = ctx.getResolver(pluginTsName)\n const { imports } = code.join([\n types.resolver.response.options(node),\n ...resolveOperationTypeNames(node, tsResolver, { includeParams: false }).map((typeName) => types.ref(node, typeName)),\n ])\n const name = ctx.resolver.name(node.operationId)\n\n const meta = {\n name: ctx.resolver.resolveName({ key: operationKey(node), name }),\n file: ctx.file(node),\n } as const\n\n return (\n <File {...meta.file}>\n {imports.map((imp) => (\n <File.Import key={imp.path} names={ast.imports.asType(imp)} root={meta.file.path} path={imp.path} />\n ))}\n <Request name={meta.name} node={node} resolver={tsResolver} baseURL={baseURL} />\n </File>\n )\n },\n})\n","","","import { resolveOperationName } from '@internals/shared'\nimport { createResolver } from '@kubb/kit'\nimport type { PluginCypress } from '../types.ts'\n\n/**\n * Default resolver used by `@kubb/plugin-cypress`. Decides the names and file\n * paths for every generated `cy.request()` wrapper. Functions and files use\n * camelCase, matching the convention from `@kubb/plugin-axios` and `@kubb/plugin-fetch`.\n *\n * @example Resolve a helper name\n * ```ts\n * import { resolverCypress } from '@kubb/plugin-cypress'\n *\n * resolverCypress.name('list pets') // 'listPets'\n * ```\n */\nexport const resolverCypress = createResolver<PluginCypress>({\n pluginName: 'plugin-cypress',\n name: resolveOperationName,\n})\n","import { 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 { cypressGenerator } from './generators/cypressGenerator.tsx'\nimport { resolverCypress } from './resolvers/resolverCypress.ts'\nimport type { PluginCypress, ResolverCypress } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-cypress`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\n/**\n * Generates one typed `cy.request()` wrapper per OpenAPI operation. Each helper\n * has typed path params, body, query, and a typed response, so failing API\n * calls in Cypress show up at compile time instead of inside the test runner.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginTs } from '@kubb/plugin-ts'\n * import { pluginCypress } from '@kubb/plugin-cypress'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [\n * pluginTs(),\n * pluginCypress({\n * output: { path: './cypress' },\n * }),\n * ],\n * })\n * ```\n */\nexport const pluginCypress = defineExtension<PluginCypress>({\n kind: 'plugin',\n meta: { name: pluginCypressName, version, compatibility },\n dependencies: { [pluginTsName]: {} },\n setup(options) {\n const {\n output = { path: 'cypress', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n baseURL,\n resolver: userResolver,\n macros: userMacros,\n } = options\n\n const resolver = userResolver ? Resolver.merge<ResolverCypress>(resolverCypress, ...[userResolver].flat()) : resolverCypress\n\n setResolver(resolver)\n if (userMacros?.length) {\n setMacros(userMacros)\n }\n addGenerator(cypressGenerator)\n\n return {\n output,\n exclude,\n include,\n override,\n group: group ?? null,\n baseURL,\n }\n },\n})\n\nexport default pluginCypress\n"],"mappings":";;;;;;;AAGA,SAAgB,UAAU,MAAkE;CAC1F,OAAO,KAAK,aAAa,UAAU,EAAE,EAAE;AACzC;;ACDA,MAAM,+BAAe,IAAI,IAAI;CAC3B,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;AACX,CAAC;;AAGD,SAAS,YAAY,OAAmC;CACtD,MAAM,aAAa,OAAO,UAAU,WAAW,MAAM,aAAa;CAClE,MAAM,aAAa,aAAa,IAAI,OAAO,UAAU,CAAC;CACtD,IAAI,YAAY,OAAO;CACvB,MAAM,OAAO,OAAO,UAAU;CAC9B,OAAO,OAAO,MAAM,IAAI,IAAI,OAAO,KAAK,MAAM,OAAO,GAAG;AAC1D;AAIA,SAAgB,UAAU,YAAkC;CAC1D,OAAO,YAAY,UAAU,MAAM;AACrC;AAEA,SAAgB,QAAQ,YAAkC;CACxD,MAAM,OAAO,YAAY,UAAU;CACnC,OAAO,SAAS,QAAQ,QAAQ;AAClC;;;AC1BA,SAAgB,YAAY,MAAiE;CAC3F,OAAO,KAAK,UAAU,QAAQ,a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QACd,UAAU,UAAU;EAEtB,aAAa,gBAAgB;EAE7B,OAAO;GACL;GACA;GACA;GACA;GACA,OAAO,SAAS;GAChB;EACF;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"index.js","names":["file","ast.http.getRequestGroups","ast.http.responses.findPrimary","ast.http.responses.filterError","ast.http.groupParameters","ast.http.requestBody.getSchema","ast.http.requestBody.getSchema","ast.http.isOperation","ast.imports.asType"],"sources":["../../../internals/ast/src/http/requestBody.ts","../../../internals/ast/src/http/status.ts","../../../internals/ast/src/http/responses.ts","../../../internals/ast/src/http/index.ts","../../../internals/ast/src/imports.ts","../../../internals/utils/src/reserved.ts","../../../internals/shared/src/operation.ts","../../../internals/shared/src/resolver.ts","../src/components/Request.tsx","../src/templates/cypress.tsx","../kubb-extension.json","../package.json","../src/resolvers/resolverCypress.ts","../src/plugin.ts"],"sourcesContent":["import type { OperationNode, SchemaNode } from '@kubb/ast'\n\n/** The schema of the first request body entry, else `undefined` when the operation takes no body. */\nexport function getSchema(node: Pick<OperationNode, 'requestBody'>): SchemaNode | undefined {\n return node.requestBody?.content?.[0]?.schema\n}\n","import type { ResponseNode, StatusCode } from '@kubb/ast'\n\ntype StatusInput = StatusCode | number | (string & {}) | Pick<ResponseNode, 'statusCode'>\n\nconst classByRange = new Map([\n ['1xx', 1],\n ['2xx', 2],\n ['3xx', 3],\n ['4xx', 4],\n ['5xx', 5],\n])\n\n/** The class digit of a status code or range: `2` for `201` and `2xx`, `null` for `default`. */\nfunction statusClass(input: StatusInput): number | null {\n const statusCode = typeof input === 'object' ? input.statusCode : input\n const rangeClass = classByRange.get(String(statusCode))\n if (rangeClass) return rangeClass\n const code = Number(statusCode)\n return Number.isNaN(code) ? null : Math.floor(code / 100)\n}\n\nexport { statusClass as getClass }\n\nexport function isSuccess(statusCode: StatusInput): boolean {\n return statusClass(statusCode) === 2\n}\n\nexport function isError(statusCode: StatusInput): boolean {\n const code = statusClass(statusCode)\n return code !== null && code >= 4\n}\n\n/** One concrete code for a status or range: `200` for `2xx` and `default`, the code itself otherwise. */\nexport function toCode(input: StatusInput): number {\n const statusCode = typeof input === 'object' ? input.statusCode : input\n const code = Number(statusCode)\n return Number.isNaN(code) ? (statusClass(statusCode) ?? 2) * 100 : code\n}\n","import { ast, type HttpOperationNode, type OperationNode, type ResponseNode, type SchemaNode } from '@kubb/ast'\nimport { isError, isSuccess } from './status.ts'\n\n/** The `4xx` and `5xx` responses, ranges included. */\nexport function filterError(node: Pick<HttpOperationNode, 'responses'>): Array<ResponseNode> {\n return node.responses.filter((response) => isError(response.statusCode))\n}\n\n/** The ref names the response bodies import, in order, with repeats. */\nexport function getImportedNames(responses: ReadonlyArray<ResponseNode>): Array<string> {\n return responses.flatMap((response) => (response.content ?? []).flatMap((entry) => (entry.schema ? ast.graph.getImportedNames(entry.schema) : [])))\n}\n\nexport function filterSuccess(node: Pick<HttpOperationNode, 'responses'>): Array<ResponseNode> {\n return node.responses.filter((response) => isSuccess(response.statusCode))\n}\n\n/** The success response a client returns: one with a body first, then an exact code over a `2xx` range. */\nexport function findPrimary(node: Pick<HttpOperationNode, 'responses'>): ResponseNode | null {\n const responses = filterSuccess(node)\n const withBody = responses.filter((response) => response.content?.some((entry) => entry.contentType))\n const candidates = withBody.length ? withBody : responses\n return candidates.find((response) => !Number.isNaN(Number(response.statusCode))) ?? candidates[0] ?? null\n}\n\n/** A union of refs to the success responses with a body, else every response with a body, else `null`. */\nexport function getUnion<TNode extends Pick<OperationNode, 'responses'>>(\n node: TNode,\n resolver: { response: { status(node: TNode, statusCode: ResponseNode['statusCode']): string } },\n): SchemaNode | null {\n const withSchema = node.responses.filter((response) => response.content?.some((entry) => entry.schema))\n const success = withSchema.filter((response) => isSuccess(response.statusCode))\n const responses = success.length > 0 ? success : withSchema\n if (responses.length === 0) return null\n\n return ast.factory.createSchema({\n type: 'union',\n members: responses.map((response) => ast.factory.createSchema({ type: 'ref', name: resolver.response.status(node, response.statusCode) })),\n })\n}\n","import { ast, type HttpOperationNode, type InputServer, type ParameterNode } from '@kubb/ast'\n\nexport const isOperation = ast.http.isOperation\nexport * as requestBody from './requestBody.ts'\nexport * as responses from './responses.ts'\nexport * as status from './status.ts'\n\n/** The server's URL when it is absolute and has no template variables, else `undefined`. */\nexport function getBaseURL(server: InputServer | undefined): string | undefined {\n if (!server || server.variables || server.url.includes('{') || !server.url.includes('://')) return undefined\n return URL.canParse(server.url) ? server.url : undefined\n}\n\n/** Computes once per key; generators visit the same node many times. */\nfunction cached<TKey extends object, TValue>(store: WeakMap<TKey, TValue>, key: TKey, compute: () => TValue): TValue {\n if (!store.has(key)) store.set(key, compute())\n return store.get(key)!\n}\n\ntype ParameterGroups = Record<'path' | 'query' | 'header' | 'cookie', Array<ParameterNode>>\n\n// Every plugin's generator visits the same node, so the groups are built once per node.\nconst parametersByNode = new WeakMap<Pick<HttpOperationNode, 'parameters'>, ParameterGroups>()\n\n/** The operation's parameters by location, with a `querystring` parameter in `query`. A repeated name keeps its first parameter. */\nexport function groupParameters(node: Pick<HttpOperationNode, 'parameters'>): ParameterGroups {\n return cached(parametersByNode, node, () => {\n const group = (...locations: Array<ParameterNode['in']>) => {\n const seen = new Set<string>()\n return locations.flatMap((location) =>\n 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 // A `querystring` parameter left whole, such as a JSON one, is sent as the query string, so it joins the query group.\n return { path: group('path'), query: group('query', 'querystring'), header: group('header'), cookie: group('cookie') }\n })\n}\n\nexport type RequestGroups = {\n path: boolean\n query: boolean\n body: boolean\n headers: boolean\n cookies: boolean\n /** `cookies` is never required: a browser sends its cookies itself. */\n required: { path: boolean; query: boolean; headers: boolean; body: boolean }\n /** No group holds a required member. */\n isOptional: boolean\n contentTypes: Array<string>\n /** More than one body media type has a schema, so a caller must pick one. */\n hasContentTypeChoice: boolean\n}\n\nconst requestGroupsByNode = new WeakMap<Pick<HttpOperationNode, 'parameters' | 'requestBody'>, RequestGroups>()\n\n/** Which request groups are present, which hold a required member, and the body's media types. Built once per operation. */\nexport function getRequestGroups(node: Pick<HttpOperationNode, 'parameters' | 'requestBody'>): RequestGroups {\n return cached(requestGroupsByNode, node, () => {\n const { path, query, header, cookie } = groupParameters(node)\n const content = node.requestBody?.content ?? []\n const body = Boolean(content[0]?.schema)\n const required = {\n path: path.some((param) => param.required),\n query: query.some((param) => param.required),\n headers: header.some((param) => param.required),\n body: body && node.requestBody?.required === true,\n }\n\n return {\n path: path.length > 0,\n query: query.length > 0,\n body,\n headers: header.length > 0,\n cookies: cookie.length > 0,\n required,\n isOptional: !required.path && !required.query && !required.headers && !required.body,\n contentTypes: content.map((entry) => entry.contentType),\n hasContentTypeChoice: content.filter((entry) => entry.schema).length > 1,\n }\n })\n}\n","import { file } from '@kubb/ast'\nimport type { ImportNode, ModuleName } from '@kubb/ast'\n\n/**\n * Returns the names of `imp`, each marked as a type, for an import that only types use.\n *\n * @example\n * ```tsx\n * <File.Import names={ast.imports.asType(imp)} path={imp.path} root={file.path} />\n * ```\n */\nexport function asType(imp: ImportNode): Array<ModuleName> {\n return file.getNames(imp).map((item) => ({ ...item, space: 'type' }))\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 { ast } from '@internals/ast'\nimport { jsDocEscape } from '@internals/utils'\nimport type { Resolver } from '@kubb/kit'\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n response: {\n body(node: ast.OperationNode): string\n }\n}\n\nexport type ResponseStatusNameResolver = {\n response: {\n status(node: ast.OperationNode, statusCode: ast.StatusCode): string\n }\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n response: {\n response(node: ast.OperationNode): string\n }\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n param: {\n path(node: ast.OperationNode, param: ast.ParameterNode): string\n query(node: ast.OperationNode, param: ast.ParameterNode): string\n headers(node: ast.OperationNode, param: ast.ParameterNode): string\n cookies(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n }\n\nexport type BuildOperationCommentsOptions = {\n splitLines?: boolean\n}\n\nexport type ResolveOperationTypeNameOptions = {\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n /**\n * Include the individual `Path`/`Query`/`Headers` group type names. Set to `false` for clients\n * that reference the grouped `Options` type instead of the per-group types.\n */\n includeParams?: boolean\n}\n\n/**\n * The operation's method and path as plain text, such as `` `GET /pet/{petId}` ``. A path is not a valid `{@link}` target.\n */\nfunction getOperationRequestLine(node: ast.OperationNode): string | null {\n return ast.http.isOperation(node) && node.path ? `\\`${node.method.toUpperCase()} ${node.path}\\`` : null\n}\n\n/**\n * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several\n * are present and the union, default, and form-data flags the client uses to pick one.\n */\nfunction buildContentTypeInfo(contentTypes: string[]): ContentTypeInfo {\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(ast.http.getRequestGroups(node).contentTypes)\n}\n\n/**\n * The request-body counterpart for the primary success response: the content types it documents and\n * whether several are present, so the client can let a caller pick which one to accept.\n */\nexport function getResponseContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n return buildContentTypeInfo(ast.http.responses.findPrimary(node)?.content?.map((e) => e.contentType) ?? [])\n}\n\n/** How an operation streams its success responses, as {@link getStream} returns it. */\nexport type ResponseStream = {\n /** `event` for a whole typed event, `data` for a typed payload, `line` for a JSON Lines value. */\n shape: 'event' | 'data' | 'line' | null\n /** Whether events keep `data` as text: all of them, the named ones, or none. */\n textEvents: boolean | Array<string>\n /** Whether the primary success response offers `text/event-stream`. */\n hasEventStream: boolean\n /** Whether a success response offers a stream next to other content types. */\n hasVariant: boolean\n}\n\nconst isText = (schema: ast.SchemaNode | null | undefined) => !!schema && ast.schema.is(schema, 'text', { follow: ['ref'] })\n\nfunction getTextEvents(entry: ast.ContentNode, shape: ResponseStream['shape']): ResponseStream['textEvents'] {\n if (shape === 'data') return isText(entry.stream?.schema ?? entry.schema)\n if (shape !== 'event' || !entry.stream?.schema) return false\n\n const item = ast.ref.getSchema(entry.stream.schema)\n const events = ast.schema.narrow(item, 'union')?.members ?? [item]\n // A discriminator makes each event an intersection of its `$ref` and the pinned `event`, so every part is read.\n const propertySchemas = (event: ast.SchemaNode, propertyName: string) => ast.schema.findProperties({ node: event, propertyName }).map(({ schema }) => schema)\n const textEvents = events.filter((event) => {\n const dataSchemas = propertySchemas(event, 'data')\n return dataSchemas.length > 0 && dataSchemas.every(isText)\n })\n if (textEvents.length === events.length) return events.length > 0\n\n const eventNames = textEvents.map((event) => propertySchemas(event, 'event').flatMap((schema) => ast.schema.getLiterals(ast.ref.getSchema(schema))))\n // An event without a fixed name cannot be told apart from the others.\n if (!eventNames.length || eventNames.some((values) => !values.length)) return false\n return [...new Set(eventNames.flat().map(String))]\n}\n\n/** How an operation streams its success responses, or `null` when none offers a stream. */\nexport function getStream(node: Pick<ast.HttpOperationNode, 'responses'>): ResponseStream | null {\n const entries = ast.http.responses.findPrimary(node)?.content ?? []\n const entry = entries.length === 1 ? entries[0] : undefined\n const kind = entry ? ast.mediaType.getKind(entry) : null\n const shape = kind === 'eventStream' ? (entry?.stream?.shape ?? 'data') : kind === 'lineStream' ? 'line' : null\n // Next to another type, a stream without a schema gets no typed variant, so it keeps the plain call.\n const hasEventStream = entries.some((item) => ast.mediaType.getKind(item) === 'eventStream' && (entries.length === 1 || !!item.schema))\n const hasVariant = ast.http.responses.filterSuccess(node).some((response) => {\n const variants = (response.content ?? []).filter((item) => item.schema)\n return variants.length > 1 && variants.some(ast.mediaType.isStream)\n })\n if (!shape && !hasEventStream && !hasVariant) return null\n\n return { shape, textEvents: entry ? getTextEvents(entry, shape) : false, hasEventStream, hasVariant }\n}\n\ntype ResponseType = 'blob' | 'text' | 'stream'\n\ntype ResponseContentEntry = { contentType: string; schema?: ast.SchemaNode | null; stream?: ast.ContentNode['stream'] }\n\nconst responseTypes: Partial<Record<NonNullable<ReturnType<typeof ast.mediaType.getKind>>, ResponseType>> = {\n eventStream: 'stream',\n lineStream: 'stream',\n binary: 'blob',\n text: 'text',\n}\n\n/**\n * Maps a content type to the PascalCase suffix used to name per-content-type variants\n * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).\n */\nfunction getContentTypeSuffix(contentType: string): string {\n // Keeps the original case, unlike ast.mediaType.getBase, so generated names stay stable.\n const baseType = contentType.split(';')[0]!.trim()\n if (baseType === 'application/json') return 'Json'\n if (baseType === 'multipart/form-data') return 'FormData'\n if (baseType === 'application/x-www-form-urlencoded') return 'FormUrlEncoded'\n const subtype = baseType.split('/').pop() ?? baseType\n const parts = subtype.split(/[^a-zA-Z0-9]+/).filter(Boolean)\n if (parts.length === 0) return 'Unknown'\n return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('')\n}\n\n/**\n * Appends a content-type suffix to a base name, keeping a trailing `Data` segment last\n * (e.g. `AddPetData` + `Json` → `AddPetJsonData`, `AddPetStatus200` + `Xml` → `AddPetStatus200Xml`).\n */\nexport function getPerContentTypeName(baseName: string, suffix: string): string {\n if (baseName.endsWith('Data')) {\n return suffix.endsWith('Data') ? baseName.slice(0, -4) + suffix : `${baseName.slice(0, -4)}${suffix}Data`\n }\n return baseName + suffix\n}\n\nexport type ContentVariantInput = { contentType: string; schema?: ast.SchemaNode | null; keysToOmit?: Array<string> | null }\nexport type ContentVariant = { name: string; suffix: string; schema: ast.SchemaNode; keysToOmit?: Array<string> | null; contentType: string }\n\n/**\n * Returns the entry with the schema of the value the client returns: `string` for a body read as text, such as `Pet` on\n * `application/xml`, and `blob` for `image/*`, `audio/*`, `video/*`, PDF, and octet-stream. A binary schema elsewhere is a `Blob`\n * only through `parseAs: 'blob'`, which needs every entry in `entries` binary. JSON, vendor (`application/vnd.*`), stream,\n * schemaless, and wildcard entries keep their schema. `entries` is the response's full list of content types.\n */\nexport function toResponseContent<T extends ContentVariantInput & ResponseContentEntry>(entry: T, entries: ReadonlyArray<ResponseContentEntry> = [entry]): T {\n const { contentType, schema } = entry\n if (!schema || entry.stream) return entry\n\n const baseType = ast.mediaType.getBase(contentType)\n const resolved = ast.ref.getSchema(schema)\n if (ast.mediaType.getKind(baseType) === 'binary') {\n return resolved.type === 'blob' ? entry : { ...entry, schema: ast.factory.createSchema({ type: 'blob' }), keysToOmit: null }\n }\n const isPlainMediaType = Boolean(baseType) && !ast.mediaType.isJson(baseType) && !baseType.includes('*')\n if (resolved.type === 'blob') {\n // shortcut: an error response never gets `parseAs`, so a lone binary schema there reads as text too but stays `Blob`.\n const readsAsText = isPlainMediaType && !entries.every((item) => item.schema?.type === 'blob')\n return readsAsText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n }\n if (resolved.primitive === 'string') return entry\n\n const kind = ast.mediaType.getKind(entry)\n const responseType = kind ? responseTypes[kind] : undefined\n // A response without a body, such as a 405, has no schema to read. Only `text/*` is always text.\n if (responseType !== 'text' && (resolved.type === 'unknown' || resolved.type === 'any' || resolved.type === 'void')) return entry\n const isVendorJson = /^[^/]+\\/vnd\\./.test(baseType) && !/(xml|yaml|yml|csv)$/.test(baseType)\n const isText = responseType === 'text' || (!responseType && isPlainMediaType && !isVendorJson)\n\n return isText ? { ...entry, schema: ast.factory.createSchema({ type: 'string' }), keysToOmit: null } : entry\n}\n\n/**\n * Resolves per-content-type variant names for a set of content entries, deduplicating suffix\n * collisions with a numeric counter. Entries without a schema are skipped. The returned `suffix` is\n * the final (possibly counter-augmented) value, so callers can derive parallel names in another\n * namespace (e.g. plugin-faker deriving the matching plugin-ts type name).\n */\nexport function resolveContentTypeVariants(entries: Array<ContentVariantInput>, baseName: string): Array<ContentVariant> {\n const usedNames = new Set<string>()\n return entries\n .filter((entry) => entry.schema)\n .map((entry) => {\n const baseSuffix = getContentTypeSuffix(entry.contentType)\n let suffix = baseSuffix\n let name = getPerContentTypeName(baseName, suffix)\n let counter = 2\n while (usedNames.has(name)) {\n suffix = `${baseSuffix}${counter++}`\n name = getPerContentTypeName(baseName, suffix)\n }\n usedNames.add(name)\n return { name, suffix, schema: entry.schema!, keysToOmit: entry.keysToOmit, contentType: entry.contentType }\n })\n}\n\n/**\n * Builds the `client?:` option type shared by the generated query hooks (`useQuery`,\n * `useInfiniteQuery`, `useSWR`, ...): `RequestConfig` minus what the\n * hook fills in, which is every request group and `throwOnError`. Unlike {@link buildRequestConfigType},\n * it never narrows `contentType`: query hooks wrap GET operations, which carry no request body to select\n * a content type for.\n */\nexport function buildClientOptionType(options: { omit?: Array<string> } = {}): string {\n const keys = [...requestGroupOrder, 'url', ...(options.omit ?? []), 'throwOnError']\n return `Partial<Omit<RequestConfig, ${keys.map((key) => `'${key}'`).join(' | ')}>>`\n}\n\n/**\n * The `client?:` option type of a mutation hook. When the operation has a request content type choice,\n * the mutation variables carry `contentType`, so the config leaves it out. Otherwise the ambiguous side is\n * narrowed to the operation's media types; a single-type side has nothing to pick, so it stays baked in the\n * generated call.\n */\nexport function buildRequestConfigType(node: ast.OperationNode): string {\n if (ast.http.getRequestGroups(node).hasContentTypeChoice) {\n return buildClientOptionType({ omit: ['contentType'] })\n }\n\n const request = getContentTypeInfo(node)\n const response = getResponseContentTypeInfo(node)\n const members = [\n request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null,\n response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null,\n ].filter(Boolean)\n\n const base = buildClientOptionType()\n return members.length ? `${base} & { contentType?: { ${members.join('; ')} } }` : base\n}\n\n/** The grouped request options, in the order generated signatures and calls list them. */\nexport const requestGroupOrder = ['path', 'query', 'body', 'headers', 'cookies'] as const\n\nexport type RequestOptionsNameResolver = RequestConfigResolver & {\n response: {\n options(node: ast.OperationNode): string\n }\n}\n\n/**\n * Builds the grouped `{ path, query, body, headers, cookies }` parameter for a generated client\n * function, typed from the operation's `Options` (minus `url`). Only the groups the\n * operation actually has are destructured. The trailing `config` parameter carries the\n * runtime `RequestConfig` overrides plus `client`.\n */\nexport function buildRequestParamsSignature(\n node: ast.OperationNode,\n resolver: RequestOptionsNameResolver,\n options: { isConfigurable?: boolean } = {},\n): { signature: string; groups: ast.http.RequestGroups; names: Array<(typeof requestGroupOrder)[number]> } {\n const { isConfigurable = true } = options\n const groups = ast.http.getRequestGroups(node)\n\n const names = requestGroupOrder.filter((key) => groups[key])\n\n // These callers never carry the `contentType` that several media types require.\n const optionsType = groups.hasContentTypeChoice\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}${groups.isOptional ? ' = {}' : ''}` : null\n const configParam = isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null\n\n return {\n signature: [firstParam, configParam].filter(Boolean).join(', '),\n groups,\n names,\n }\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { splitLines = false } = options\n // The request line leads: free text after a block tag would belong to that tag.\n const comments = [\n getOperationRequestLine(node),\n node.description && `@description ${node.description}`,\n node.summary && `@summary ${node.summary}`,\n node.deprecated && '@deprecated',\n node.externalDocs && `@see ${jsDocEscape([node.externalDocs.url, node.externalDocs.description].filter(Boolean).join(' '))}`,\n ]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\n/**\n * Casts a call argument to the client's parameter type; a `'plain'` client is non-generic.\n */\nexport function castToClientOptions(callArg: string, clientName: string, returnType: 'full' | 'data' | 'plain' = 'full'): string {\n return `${callArg} as Parameters<typeof ${clientName}${returnType === 'plain' ? '' : '<true>'}>[0]`\n}\n\n/**\n * Builds the combined `{ body, path, query, headers, cookies }` options object schema for an operation,\n * referencing the already-resolved body and grouped param names. `cookies` appears only on an operation\n * with a cookie parameter, and stays optional because a browser sends its cookies itself. Shared by `@kubb/plugin-ts`'s\n * `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same shape from the same inputs.\n * `primitive: 'object'` is a no-op for the TS printer and tells the Zod printer to emit `z.object(…)` rather\n * than a record.\n */\nexport function buildOptionsSchema(node: ast.OperationNode, resolver: OperationTypeNameResolver, { pairContentTypes = false } = {}): ast.SchemaNode {\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n const hasBody = Boolean(ast.http.requestBody.getSchema(node))\n const createNever = () => ast.factory.createSchema({ type: 'never', primitive: undefined, optional: true })\n const groups = [\n { name: 'path', params: path, resolve: resolver.param.path },\n { name: 'query', params: query, resolve: resolver.param.query },\n { name: 'headers', params: header, resolve: resolver.param.headers },\n { name: 'cookies', params: cookie, resolve: resolver.param.cookies },\n ] as const\n\n const createOptions = (body: ast.SchemaNode, extra: Array<ast.PropertyNode> = []) =>\n // NOTE(v5-stable): the fields were renamed from the legacy beta shape\n // (`data`/`pathParams`/`queryParams`/`headerParams`) to `body`/`path`/`query`/`headers` so the\n // type matches the runtime client. Drop this note once v5 leaves beta.\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n deprecated: node.deprecated,\n properties: [\n ast.factory.createProperty({ name: 'body', required: hasBody && node.requestBody?.required === true, schema: body }),\n ...groups\n .filter(({ name, params }) => name !== 'cookies' || params.length > 0)\n .map(({ name, params, resolve }) => {\n const required = name !== 'cookies' && params.some((param) => param.required)\n\n return ast.factory.createProperty({\n name,\n required,\n schema:\n params.length > 0\n ? ast.factory.createSchema({ type: 'ref', name: resolve.call(resolver.param, node, params[0]!), optional: !required })\n : createNever(),\n })\n }),\n ...extra,\n ],\n })\n\n const variants =\n pairContentTypes && ast.http.getRequestGroups(node).hasContentTypeChoice\n ? resolveContentTypeVariants(node.requestBody?.content ?? [], resolver.response.body(node))\n : []\n if (variants.length < 2) {\n return createOptions(hasBody ? ast.factory.createSchema({ type: 'ref', name: resolver.response.body(node) }) : createNever())\n }\n\n // The first media type is the runtime default, so only the others must pass `contentType`. A bare string sets the\n // request content type at runtime, so it is accepted next to the `{ request }` form.\n return ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant, index) => {\n const contentType = ast.factory.createSchema({ type: 'enum', enumValues: [variant.contentType] })\n\n return createOptions(ast.factory.createSchema({ type: 'ref', name: variant.name }), [\n ast.factory.createProperty({\n name: 'contentType',\n required: index > 0,\n schema: ast.factory.createSchema({\n type: 'union',\n members: [\n contentType,\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [ast.factory.createProperty({ name: 'request', required: true, schema: contentType })],\n }),\n ],\n }),\n }),\n ])\n }),\n })\n}\n\n/**\n * The schema a status occupies in the `<Name>Responses` record. A status that documents several\n * content types becomes a `{ contentType; data }` union so the runtime can surface the negotiated type\n * on `result.parsed`, while the standalone `<Name>StatusNNN` alias stays the plain body union that the\n * query hooks and `result.data` use. With `streamData`, the stream variant of a 2xx status holds that schema, since the\n * client returns its body unread.\n */\nfunction buildResponseRecordEntry(\n node: ast.OperationNode,\n res: ast.ResponseNode,\n resolver: ResponseStatusNameResolver,\n streamData: ast.SchemaNode | undefined,\n): ast.SchemaNode {\n const statusName = resolver.response.status(node, res.statusCode)\n const variants = (res.content ?? []).filter((entry) => entry.schema)\n if (variants.length <= 1) {\n return ast.factory.createSchema({ type: 'ref', name: statusName })\n }\n\n return ast.factory.createSchema({\n type: 'union',\n members: resolveContentTypeVariants(variants, statusName).map((variant) =>\n ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n ast.factory.createProperty({\n name: 'contentType',\n required: true,\n // The runtime reports the bare media type, without parameters such as `charset` or `profile`.\n schema: ast.factory.createSchema({ type: 'enum', enumValues: [ast.mediaType.getBase(variant)] }),\n }),\n ast.factory.createProperty({\n name: 'data',\n required: true,\n schema:\n streamData && ast.http.status.isSuccess(res) && ast.mediaType.isStream(variant)\n ? streamData\n : ast.factory.createSchema({ type: 'ref', name: variant.name }),\n }),\n ],\n }),\n ),\n })\n}\n\n/**\n * Builds the per-status `<Name>Responses` record for an operation, referencing the already-resolved\n * `<Name>StatusNNN` names. Shared by `@kubb/plugin-ts`'s `Responses` type and `@kubb/plugin-zod`'s\n * inferred responses schema, so both emit the same shape from the same inputs.\n *\n * Always emits the keyed record, even when an operation declares no responses. An operation with no\n * responses renders as an empty object, which keeps every consumer's import (for example the axios\n * SDK's `RequestResult<XResponses>`) resolvable instead of pointing at a missing export.\n *\n * `streamData` is the type of a stream variant's `data`, such as a `ReadableStream<Uint8Array>` reference.\n */\nexport function buildResponses(\n node: ast.OperationNode,\n resolver: ResponseStatusNameResolver,\n { streamData }: { streamData?: ast.SchemaNode } = {},\n): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: node.responses.map((res) =>\n ast.factory.createProperty({\n name: String(res.statusCode),\n required: true,\n schema: buildResponseRecordEntry(node, res, resolver, streamData),\n }),\n ),\n })\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return ast.http.responses.filterError(node).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveSuccessNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return ast.http.responses.filterSuccess(node).map((response) => resolver.response.status(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.response.status(node, response.statusCode))\n}\n\n/**\n * Lists the type names an operation's types file declares, computed once per resolver and `options` so every\n * dependent reads the same list.\n */\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver & Pick<Resolver, 'memo'>,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const key = `${node.operationId}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${options.includeParams === false ? 'noparams' : ''}\\0${(options.exclude ?? []).join(',')}`\n return resolver.memo(`operationTypeNames:${key}`, () => {\n const { path, query, header, cookie } = ast.http.groupParameters(node)\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames =\n options.includeParams === false\n ? []\n : [\n ...path.map((param) => resolver.param.path(node, param)),\n ...query.map((param) => resolver.param.query(node, param)),\n ...header.map((param) => resolver.param.headers(node, param)),\n ...cookie.map((param) => resolver.param.cookies(node, param)),\n ]\n const bodyAndResponseNames = [ast.http.requestBody.getSchema(node) ? resolver.response.body(node) : null, resolver.response.response(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n return names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n })\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.response.response(node)])\n continue\n }\n\n const code = Number(response.statusCode)\n if (Number.isNaN(code)) {\n continue\n }\n\n types.push([code, ast.http.status.isSuccess(code) ? resolver.response.response(node) : resolver.response.status(node, response.statusCode)])\n }\n\n return types\n}\n\n/**\n * One object schema for a list of parameters or response headers, with each schema inline.\n */\nexport function buildParamsSchema(params: Array<ast.ParameterNode>): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n // `primitive: 'object'` makes a printer emit an object schema and not a record.\n primitive: 'object',\n properties: params.map((param) => ast.factory.createProperty({ name: param.name, required: param.required, schema: param.schema })),\n })\n}\n\n/**\n * One object schema for the parameters of an operation, where each key points at the const of\n * that parameter. The const already has its optional wrapper, so every key is required here.\n */\nexport function buildParamRefsSchema({\n node,\n params,\n resolver,\n}: {\n node: ast.OperationNode\n params: Array<ast.ParameterNode>\n resolver: { param: { name(node: ast.OperationNode, param: ast.ParameterNode): string } }\n}): ast.SchemaNode {\n return ast.factory.createSchema({\n type: 'object',\n primitive: 'object',\n properties: params.map((param) =>\n ast.factory.createProperty({\n name: param.name,\n required: true,\n schema: ast.factory.createSchema({ type: 'ref', name: resolver.param.name(node, param) }),\n }),\n ),\n })\n}\n\ntype SchemaEntry = { schema: ast.SchemaNode; name: string; keysToOmit?: Array<string> | null }\n\n/**\n * The schemas a name with several content types needs: one per content type, then the union of\n * them under `baseName`.\n */\nexport function buildContentTypeEntries(\n entries: Array<ContentVariantInput>,\n baseName: string,\n decorate: (schema: ast.SchemaNode) => ast.SchemaNode = (schema) => schema,\n): Array<SchemaEntry> {\n const variants = resolveContentTypeVariants(entries, baseName)\n const union = ast.factory.createSchema({\n type: 'union',\n members: variants.map((variant) => ast.factory.createSchema({ type: 'ref', name: variant.name })),\n })\n\n return [\n ...variants.map((variant) => ({ schema: decorate(variant.schema), name: variant.name, keysToOmit: variant.keysToOmit })),\n { schema: union, name: baseName },\n ]\n}\n\n/**\n * The schema behind a response or error name: a union of the per-status schemas. Returns `null`\n * when a response is a `$ref` to a component whose name is already `name`, which would declare it twice.\n */\nexport function buildResponseUnionSchema({\n node,\n responses,\n name,\n resolver,\n fallbackUnknown,\n}: {\n node: ast.OperationNode\n responses: Array<ast.ResponseNode>\n name: string\n resolver: { name(name: string): string; response: { status(node: ast.OperationNode, statusCode: ast.StatusCode): string } }\n /**\n * Print an unknown schema when no response has one, so the name still resolves.\n */\n fallbackUnknown: boolean\n}): ast.SchemaNode | null {\n const importedNames = new Set(ast.http.responses.getImportedNames(responses).map((refName) => resolver.name(refName)))\n if (importedNames.has(name)) return null\n\n const members = responses.map((res) => ast.factory.createSchema({ type: 'ref', name: resolver.response.status(node, res.statusCode) }))\n if (members.length === 0) return fallbackUnknown ? ast.factory.createSchema({ type: 'unknown' }) : null\n\n return members.length === 1 ? members[0]! : ast.factory.createSchema({ type: 'union', members })\n}\n","import { ast } from '@internals/ast'\nimport { ensureValidVarName } from '@internals/utils'\nimport { casing, memo, useKubb } from '@kubb/kit'\nimport type { FileTarget, GeneratorContext, Group, Output, PrinterContext, Resolver, ResolverFileParams } from '@kubb/kit'\n\n/**\n * The shared top-level `name` of the operation plugins, computed once per operation name and build.\n */\nexport function resolveOperationName(this: Resolver, name: string): string {\n return this.memo(`operation:${name}`, () => ensureValidVarName(casing.camel(name)))\n}\n\n/** `ctx.file(node)` for a file that no single node owns, such as `handlers.ts`: path, banner and footer from the current plugin. */\nexport function namedFile(entry: Pick<ResolverFileParams, 'name' | 'tag'> & { extname?: ResolverFileParams['extname'] }): FileTarget {\n const ctx = useKubb<GeneratorContext>()\n const { output, group } = ctx.options as { output: Output; group?: Group | null }\n const file = ctx.resolver.file({ extname: '.ts', ...entry, root: ctx.root, output, group: group ?? undefined })\n const fileContext = { output, config: ctx.config, file: { path: file.path, baseName: file.baseName } }\n\n return {\n baseName: file.baseName,\n path: file.path,\n meta: file.meta,\n banner: ctx.resolver.default.banner(ctx.meta, fileContext),\n footer: ctx.resolver.default.footer(ctx.meta, fileContext),\n }\n}\n\n/**\n * Names of the schemas in a circular reference chain, computed once per build. Reads the current context, so call it\n * in a generator or a printer factory.\n */\nexport function getCircularNames(): ReadonlySet<string> {\n return memo('circularNames:set', () => ast.graph.getCircularNames(useKubb<PrinterContext>().schemas))\n}\n\n/**\n * Names of the schemas whose type is `enum`, computed once per build. Reads the current context, so call it\n * in a generator or a printer factory.\n */\nexport function getEnumNames(): ReadonlySet<string> {\n return memo(\n 'enumNames:set',\n () => new Set(useKubb<PrinterContext>().schemas.flatMap((schema) => (schema.type === 'enum' && schema.name ? [schema.name] : []))),\n )\n}\n\ndeclare global {\n namespace Kubb {\n interface MemoRegistry {\n operation: string\n file: ast.FileNode['baseName']\n operationTypeNames: Array<string>\n }\n }\n}\n","import { ast } from '@internals/ast'\nimport { buildRequestParamsSignature } from '@internals/shared'\n\nimport { text, Url } from '@kubb/kit'\nimport type { ResolverTs } from '@kubb/plugin-ts'\nimport { Function } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n /**\n * AST operation node\n */\n node: ast.HttpOperationNode\n /**\n * TypeScript resolver for resolving param/data/response type names\n */\n resolver: ResolverTs\n baseURL: string | null | undefined\n}\n\nexport function Request({ baseURL = '', name, resolver, node }: Props): KubbReactNode {\n const { signature, groups } = buildRequestParamsSignature(node, resolver, { isConfigurable: false })\n const paramsSignature = [signature, 'options: Partial<Cypress.RequestOptions> = {}'].filter(Boolean).join(', ')\n\n const responseType = resolver.response.response(node)\n const returnType = `Cypress.Chainable<${responseType}>`\n\n // Bracket-access the path object with the raw OpenAPI param names, matching the generated `path` type's keys.\n const urlTemplate = Url.toGroupedTemplateString(node.path, { prefix: baseURL })\n\n // `cy.request` has no cookie option, so the cookie group goes out as a `Cookie` header. An array joins with commas, a Date\n // is ISO 8601, and an object is JSON.\n const cookieText =\n \"value instanceof Date ? value.toISOString() : Array.isArray(value) ? value.join(',') : typeof value === 'object' ? JSON.stringify(value) : String(value)\"\n // The OpenAPI 3.2 `cookie` style sends a value as it is, and throws on one it cannot send, like the generated clients do.\n // With `explode` (its default) an array sends one cookie per item and an object one cookie per key, otherwise both join with commas.\n const rawParameters = node.parameters.filter((parameter) => parameter.in === 'cookie' && parameter.style === 'cookie')\n // Only an array or object needs the join and explode code. A value with one primitive type goes out as one cookie.\n const isComposite = (parameter: ast.ParameterNode) =>\n !['string', 'number', 'integer', 'bigint', 'boolean'].includes(ast.ref.getSchema(parameter.schema).primitive ?? '')\n const isExploded = (parameter: ast.ParameterNode) => parameter.explode !== false && isComposite(parameter)\n const explodedCookies = rawParameters.filter(isExploded).map((parameter) => text.quote(parameter.name))\n const joinedCookies = rawParameters.filter((parameter) => !isExploded(parameter)).map((parameter) => text.quote(parameter.name))\n // A `form` cookie explodes only when the spec sets `explode: true`, like the generated clients, and its items stay percent-encoded.\n const explodedFormCookies = node.parameters\n .filter((parameter) => parameter.in === 'cookie' && parameter.style !== 'cookie' && parameter.explode === true && isComposite(parameter))\n .map((parameter) => text.quote(parameter.name))\n const compositeLines = rawParameters.some(isComposite)\n ? ` if (Array.isArray(value)) return value.filter((item) => item != null).map(rawCookie).join(',')\n if (typeof value === 'object' && value !== null && !(value instanceof Date)) return Object.entries(value).filter(([, item]) => item != null).flat().map(rawCookie).join(',')\\n`\n : ''\n const explodeCookieLine =\n explodedCookies.length || explodedFormCookies.length\n ? `const explodeCookie = (name: string, value: unknown, encode: (item: unknown) => string): Array<string> => {\n if (Array.isArray(value)) return value.filter((item) => item != null).map((item) => \\`\\${name}=\\${encode(item)}\\`)\n if (typeof value === 'object' && value !== null && !(value instanceof Date)) return Object.entries(value).filter(([, item]) => item != null).map(([key, item]) => \\`\\${encode(key)}=\\${encode(item)}\\`)\n return [\\`\\${name}=\\${encode(value)}\\`]\n}\\n`\n : ''\n const formCookieLine = explodedFormCookies.length\n ? 'const formCookie = (item: unknown): string => encodeURIComponent(item instanceof Date ? item.toISOString() : String(item))\\n'\n : ''\n // Keep the cookie-octet pattern in step with `rawCookieValue` in plugin-client's `templates/serializers.ts`.\n const rawCookieLine = rawParameters.length\n ? `const rawCookie = (value: unknown): string => {\n${compositeLines} const text = value instanceof Date ? value.toISOString() : String(value)\n if (!/^[\\\\x21\\\\x23-\\\\x2B\\\\x2D-\\\\x3A\\\\x3C-\\\\x5B\\\\x5D-\\\\x7E]*$/.test(text)) throw new TypeError('A cookie has characters the cookie style cannot send, escape it first.')\n return text\n}\\n`\n : ''\n const encodeCookie = joinedCookies.length\n ? `([${joinedCookies.join(', ')}].includes(name) ? rawCookie(value) : encodeURIComponent(${cookieText}))`\n : `encodeURIComponent(${cookieText})`\n const explodeRaw = explodedCookies.length ? `[${explodedCookies.join(', ')}].includes(name) ? explodeCookie(name, value, rawCookie) : ` : ''\n const explodeForm = explodedFormCookies.length ? `[${explodedFormCookies.join(', ')}].includes(name) ? explodeCookie(name, value, formCookie) : ` : ''\n const toCookies =\n explodeRaw || explodeForm\n ? `.flatMap(([name, value]) => (${explodeRaw}${explodeForm}[\\`\\${name}=\\${${encodeCookie}}\\`]))`\n : `.map(([name, value]) => \\`\\${name}=\\${${encodeCookie}}\\`)`\n // Built first and sent only when non-empty, so a call without cookies keeps the cookies Cypress attaches itself.\n const cookieLine = `${rawCookieLine}${explodeCookieLine}${formCookieLine}const cookie = (Object.entries(cookies ?? {}) as Array<[string, unknown]>).filter(([, value]) => value != null)${toCookies}.join('; ')\\n`\n\n // Cypress types a body as a string or an object, so a body that is one number or has no schema type is cast.\n const requestSchema = ast.http.requestBody.getSchema(node)\n const bodySchema = requestSchema && ast.ref.getSchema(requestSchema)\n const castBody = bodySchema && (['number', 'integer'].includes(bodySchema.primitive ?? '') || ['unknown', 'any'].includes(bodySchema.type))\n\n const requestOptions = [\n `method: ${text.quote(node.method)}`,\n `url: ${urlTemplate}`,\n groups.query && 'qs: query',\n groups.cookies ? `headers: { ${groups.headers ? '...headers, ' : ''}...(cookie ? { Cookie: cookie } : {}) }` : groups.headers && 'headers',\n groups.body && (castBody ? 'body: body as unknown as Cypress.RequestBody' : 'body'),\n '...options',\n ].filter(Boolean)\n\n // Cypress's catch-all `then` overload types a union body as `Chainable<Response | Pet> | Chainable<Response | string>`, so cast to the declared return type.\n const requestCall = `${groups.cookies ? cookieLine : ''}return cy.request<${responseType}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body) as ${returnType}`\n\n return (\n <Function name={name} export params={paramsSignature} returnType={returnType}>\n {requestCall}\n </Function>\n )\n}\n","import { ast } from '@internals/ast'\nimport { resolveOperationTypeNames } from '@internals/shared'\nimport { code, defineTemplate, operationKey } from '@kubb/kit'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/renderer-jsx'\nimport { Request } from '../components/Request.tsx'\nimport type { PluginCypress } from '../types.ts'\n\n/**\n * Built-in template for `@kubb/plugin-cypress`. Emits one typed\n * `cy.request()` wrapper per OpenAPI operation, ready to call inside Cypress\n * test specs and custom commands.\n */\nexport const cypressOperation = defineTemplate<PluginCypress>({\n kind: ast.node.kinds.operation,\n render(node, ctx) {\n if (!ast.http.isOperation(node)) return null\n const { baseURL } = ctx.options\n\n const types = ctx.from(pluginTsName)\n const tsResolver = ctx.getResolver(pluginTsName)\n const { imports } = code.join([\n types.resolver.response.options(node),\n ...resolveOperationTypeNames(node, tsResolver, { includeParams: false }).map((typeName) => types.ref(node, typeName)),\n ])\n const name = ctx.resolver.name(node.operationId)\n\n const meta = {\n name: ctx.resolver.resolveName({ key: operationKey(node), name }),\n file: ctx.file(node),\n } as const\n\n return (\n <File {...meta.file}>\n {imports.map((imp) => (\n <File.Import key={imp.path} names={ast.imports.asType(imp)} root={meta.file.path} path={imp.path} />\n ))}\n <Request name={meta.name} node={node} resolver={tsResolver} baseURL={baseURL} />\n </File>\n )\n },\n})\n","","","import { resolveOperationName } from '@internals/shared'\nimport { createResolver } from '@kubb/kit'\nimport type { PluginCypress } from '../types.ts'\n\n/**\n * Default resolver used by `@kubb/plugin-cypress`. Decides the names and file\n * paths for every generated `cy.request()` wrapper. Functions and files use\n * camelCase, matching the convention from `@kubb/plugin-axios` and `@kubb/plugin-fetch`.\n *\n * @example Resolve a helper name\n * ```ts\n * import { resolverCypress } from '@kubb/plugin-cypress'\n *\n * resolverCypress.name('list pets') // 'listPets'\n * ```\n */\nexport const resolverCypress = createResolver<PluginCypress>({\n pluginName: 'plugin-cypress',\n name: resolveOperationName,\n})\n","import { addMacro, addTemplate, defineExtension, Resolver, setResolver } from '@kubb/kit'\nimport { compatibility } from '../kubb-extension.json'\nimport { version } from '../package.json'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressOperation } from './templates/cypress.tsx'\nimport { resolverCypress } from './resolvers/resolverCypress.ts'\nimport type { PluginCypress, ResolverCypress } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-cypress`. Used for driver lookups and\n * cross-plugin dependency references.\n */\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\n/**\n * Generates one typed `cy.request()` wrapper per OpenAPI operation. Each helper\n * has typed path params, body, query, and a typed response, so failing API\n * calls in Cypress show up at compile time instead of inside the test runner.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb/config'\n * import { pluginTs } from '@kubb/plugin-ts'\n * import { pluginCypress } from '@kubb/plugin-cypress'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [\n * pluginTs(),\n * pluginCypress({\n * output: { path: './cypress' },\n * }),\n * ],\n * })\n * ```\n */\nexport const pluginCypress = defineExtension<PluginCypress>({\n kind: 'plugin',\n meta: { name: pluginCypressName, version, compatibility },\n dependencies: { [pluginTsName]: {} },\n setup(options) {\n const {\n output = { path: 'cypress', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n baseURL,\n resolver: userResolver,\n macros: userMacros,\n } = options\n\n const resolver = userResolver ? Resolver.merge<ResolverCypress>(resolverCypress, ...[userResolver].flat()) : resolverCypress\n\n setResolver(resolver)\n addMacro(...(userMacros ?? []))\n addTemplate(cypressOperation)\n\n return {\n output,\n exclude,\n include,\n override,\n group: group ?? null,\n baseURL,\n }\n },\n})\n\nexport default pluginCypress\n"],"mappings":";;;;;;;AAGA,SAAgB,UAAU,MAAkE;CAC1F,OAAO,KAAK,aAAa,UAAU,EAAE,EAAE;AACzC;;ACDA,MAAM,+BAAe,IAAI,IAAI;CAC3B,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;AACX,CAAC;;AAGD,SAAS,YAAY,OAAmC;CACtD,MAAM,aAAa,OAAO,UAAU,WAAW,MAAM,aAAa;CAClE,MAAM,aAAa,aAAa,IAAI,OAAO,UAAU,CAAC;CACtD,IAAI,YAAY,OAAO;CACvB,MAAM,OAAO,OAAO,UAAU;CAC9B,OAAO,OAAO,MAAM,IAAI,IAAI,OAAO,KAAK,MAAM,OAAO,GAAG;AAC1D;AAIA,SAAgB,UAAU,YAAkC;CAC1D,OAAO,YAAY,UAAU,MAAM;AACrC;AAEA,SAAgB,QAAQ,YAAkC;CACxD,MAAM,OAAO,YAAY,UAAU;CACnC,OAAO,SAAS,QAAQ,QAAQ;AAClC;;;AC1BA,SAAgB,YAAY,MAAiE;CAC3F,OAAO,KAAK,UAAU,QAAQ,aAAa,QAAQ,SAAS,UAAU,CAAC;AACzE;AAOA,SAAgB,cAAc,MAAiE;CAC7F,OAAO,KAAK,UAAU,QAAQ,aAAa,UAAU,SAAS,UAAU,CAAC;AAC3E;;AAGA,SAAgB,YAAY,MAAiE;CAC3F,MAAM,YAAY,cAAc,IAAI;CACpC,MAAM,WAAW,UAAU,QAAQ,aAAa,SAAS,SAAS,MAAM,UAAU,MAAM,WA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X,MAAM,IAAI,SAAS,YAAY;IAAE,KAAK,aAAa,IAAI;IAAG;GAAK,CAAC;GAChE,MAAM,IAAI,KAAK,IAAI;EACrB;EAEA,OACE,qBAAC,MAAD;GAAM,GAAI,KAAK;GAAf,UAAA,CACG,QAAQ,KAAK,QACZ,oBAAC,KAAK,QAAN;IAA4B,OAAOC,OAAmB,GAAG;IAAG,MAAM,KAAK,KAAK;IAAM,MAAM,IAAI;GAAO,GAAjF,IAAI,IAA6E,CACpG,GACD,oBAAC,SAAD;IAAS,MAAM,KAAK;IAAY;IAAM,UAAU;IAAqB;GAAU,CAAA,CAC3E;;CAEV;AACF,CAAC;;;;;;;;;;;;;;;;;;;;;AGzBD,MAAa,kBAAkB,eAA8B;CAC3D,YAAY;CACZ,MAAM;AACR,CAAC;;;;;;ACPD,MAAa,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;AAyBjC,MAAa,gBAAgB,gBAA+B;CAC1D,MAAM;CACN,MAAM;EAAE,MAAM;EAAmB;EAAS;CAAc;CACxD,cAAc,GAAG,eAAe,CAAC,EAAE;CACnC,MAAM,SAAS;EACb,MAAM,EACJ,SAAS;GAAE,MAAM;GAAW,QAAQ,EAAE,MAAM,QAAQ;EAAE,GACtD,OACA,UAAU,CAAC,GACX,SACA,WAAW,CAAC,GACZ,SACA,UAAU,cACV,QAAQ,eACN;EAEJ,MAAM,WAAW,eAAe,SAAS,MAAuB,iBAAiB,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,IAAI;EAE7G,YAAY,QAAQ;EACpB,SAAS,GAAI,cAAc,CAAC,CAAE;EAC9B,YAAY,gBAAgB;EAE5B,OAAO;GACL;GACA;GACA;GACA;GACA,OAAO,SAAS;GAChB;EACF;CACF;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-cypress",
3
- "version": "5.5.0-canary.20261123T120417",
3
+ "version": "5.5.0",
4
4
  "description": "Generate Cypress request commands and e2e test fixtures with Kubb for automated API testing.",
5
5
  "keywords": [
6
6
  "code-generation",
@@ -68,15 +68,15 @@
68
68
  "registry": "https://registry.npmjs.org/"
69
69
  },
70
70
  "dependencies": {
71
- "@kubb/ast": "^5.23.5",
72
- "@kubb/kit": "^5.23.5",
73
- "@kubb/plugin-ts": "^5.7.0-canary.20261123T120417",
74
- "@kubb/renderer-jsx": "^5.23.5"
71
+ "@kubb/ast": "^5.24.0",
72
+ "@kubb/kit": "^5.24.0",
73
+ "@kubb/plugin-ts": "^5.7.0",
74
+ "@kubb/renderer-jsx": "^5.24.0"
75
75
  },
76
76
  "devDependencies": {
77
- "@internals/ast": "0.1.0-canary.20261123T120417",
78
- "@internals/shared": "0.1.0-canary.20261123T120417",
79
- "@internals/utils": "0.1.0-canary.20261123T120417",
77
+ "@internals/ast": "0.0.0",
78
+ "@internals/shared": "0.0.0",
79
+ "@internals/utils": "0.0.0",
80
80
  "cypress": "^16.3.0"
81
81
  },
82
82
  "peerDependencies": {