@kubb/plugin-cypress 5.0.0-beta.22 → 5.0.0-beta.25

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
@@ -218,12 +218,12 @@ var URLPath = class {
218
218
  get object() {
219
219
  return this.toObject();
220
220
  }
221
- /** Returns a map of path parameter names, or `undefined` when the path has no parameters.
221
+ /** Returns a map of path parameter names, or `null` when the path has no parameters.
222
222
  *
223
223
  * @example
224
224
  * ```ts
225
225
  * new URLPath('/pet/{petId}').params // { petId: 'petId' }
226
- * new URLPath('/pet').params // undefined
226
+ * new URLPath('/pet').params // null
227
227
  * ```
228
228
  */
229
229
  get params() {
@@ -286,7 +286,7 @@ var URLPath = class {
286
286
  const key = replacer ? replacer(param) : param;
287
287
  params[key] = key;
288
288
  });
289
- return Object.keys(params).length > 0 ? params : void 0;
289
+ return Object.keys(params).length > 0 ? params : null;
290
290
  }
291
291
  /** Converts the OpenAPI path to Express-style colon syntax.
292
292
  *
@@ -312,11 +312,11 @@ function getOperationParameters(node, options = {}) {
312
312
  }
313
313
  function getStatusCodeNumber(statusCode) {
314
314
  const code = Number(statusCode);
315
- return Number.isNaN(code) ? void 0 : code;
315
+ return Number.isNaN(code) ? null : code;
316
316
  }
317
317
  function isErrorStatusCode(statusCode) {
318
318
  const code = getStatusCodeNumber(statusCode);
319
- return code !== void 0 && code >= 400;
319
+ return code !== null && code >= 400;
320
320
  }
321
321
  function resolveErrorNames(node, resolver) {
322
322
  return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
@@ -343,7 +343,7 @@ function resolveOperationTypeNames(node, resolver, options = {}) {
343
343
  ...query.map((param) => resolver.resolveQueryParamsName(node, param)),
344
344
  ...header.map((param) => resolver.resolveHeaderParamsName(node, param))
345
345
  ];
346
- const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0, resolver.resolveResponseName(node)];
346
+ const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null, resolver.resolveResponseName(node)];
347
347
  const result = (options.order === "body-response-first" ? [
348
348
  ...bodyAndResponseNames,
349
349
  ...paramNames,
@@ -421,6 +421,11 @@ function Request({ baseURL = "", name, dataReturnType, resolver, node, paramsTyp
421
421
  }
422
422
  //#endregion
423
423
  //#region src/generators/cypressGenerator.tsx
424
+ /**
425
+ * Built-in generator for `@kubb/plugin-cypress`. Emits one typed
426
+ * `cy.request()` wrapper per OpenAPI operation, ready to call inside Cypress
427
+ * test specs and custom commands.
428
+ */
424
429
  const cypressGenerator = (0, _kubb_core.defineGenerator)({
425
430
  name: "cypress",
426
431
  renderer: _kubb_renderer_jsx.jsxRendererSync,
@@ -441,7 +446,7 @@ const cypressGenerator = (0, _kubb_core.defineGenerator)({
441
446
  }, {
442
447
  root,
443
448
  output,
444
- group
449
+ group: group ?? void 0
445
450
  }),
446
451
  fileTs: tsResolver.resolveFile({
447
452
  name: node.operationId,
@@ -451,7 +456,7 @@ const cypressGenerator = (0, _kubb_core.defineGenerator)({
451
456
  }, {
452
457
  root,
453
458
  output: pluginTs.options?.output ?? output,
454
- group: pluginTs.options?.group
459
+ group: pluginTs.options?.group ?? void 0
455
460
  })
456
461
  };
457
462
  return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
@@ -487,12 +492,16 @@ const cypressGenerator = (0, _kubb_core.defineGenerator)({
487
492
  //#endregion
488
493
  //#region src/resolvers/resolverCypress.ts
489
494
  /**
490
- * Naming convention resolver for Cypress plugin.
495
+ * Default resolver used by `@kubb/plugin-cypress`. Decides the names and file
496
+ * paths for every generated `cy.request()` wrapper. Functions and files use
497
+ * camelCase, matching the convention from `@kubb/plugin-client`.
491
498
  *
492
- * Provides default naming helpers using camelCase for functions and file paths.
499
+ * @example Resolve a helper name
500
+ * ```ts
501
+ * import { resolverCypress } from '@kubb/plugin-cypress'
493
502
  *
494
- * @example
495
- * `resolverCypress.default('list pets', 'function') // → 'listPets'`
503
+ * resolverCypress.default('list pets', 'function') // 'listPets'
504
+ * ```
496
505
  */
497
506
  const resolverCypress = (0, _kubb_core.defineResolver)(() => ({
498
507
  name: "default",
@@ -510,23 +519,30 @@ const resolverCypress = (0, _kubb_core.defineResolver)(() => ({
510
519
  //#endregion
511
520
  //#region src/plugin.ts
512
521
  /**
513
- * Canonical plugin name for `@kubb/plugin-cypress`, used to identify the plugin
514
- * in driver lookups and warnings.
522
+ * Canonical plugin name for `@kubb/plugin-cypress`. Used for driver lookups and
523
+ * cross-plugin dependency references.
515
524
  */
516
525
  const pluginCypressName = "plugin-cypress";
517
526
  /**
518
- * The `@kubb/plugin-cypress` plugin factory.
519
- *
520
- * Generates Cypress `cy.request()` test functions from an OpenAPI/AST `RootNode`.
521
- * Walks operations, delegates rendering to the active generators,
522
- * and writes barrel files based on `output.barrelType`.
527
+ * Generates one typed `cy.request()` wrapper per OpenAPI operation. Each helper
528
+ * has typed path params, body, query, and a typed response, so failing API
529
+ * calls in Cypress show up at compile time instead of inside the test runner.
523
530
  *
524
531
  * @example
525
532
  * ```ts
526
- * import pluginCypress from '@kubb/plugin-cypress'
533
+ * import { defineConfig } from 'kubb'
534
+ * import { pluginTs } from '@kubb/plugin-ts'
535
+ * import { pluginCypress } from '@kubb/plugin-cypress'
527
536
  *
528
537
  * export default defineConfig({
529
- * plugins: [pluginCypress({ output: { path: 'cypress' } })],
538
+ * input: { path: './petStore.yaml' },
539
+ * output: { path: './src/gen' },
540
+ * plugins: [
541
+ * pluginTs(),
542
+ * pluginCypress({
543
+ * output: { path: './cypress' },
544
+ * }),
545
+ * ],
530
546
  * })
531
547
  * ```
532
548
  */
@@ -541,7 +557,7 @@ const pluginCypress = (0, _kubb_core.definePlugin)((options) => {
541
557
  if (group.type === "path") return `${ctx.group.split("/")[1]}`;
542
558
  return `${camelCase(ctx.group)}Requests`;
543
559
  }
544
- } : void 0;
560
+ } : null;
545
561
  return {
546
562
  name: pluginCypressName,
547
563
  options,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["#options","#transformParam","#eachParam","ast","ast","File","Function","jsxRendererSync","pluginTsName","File","pluginTsName"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/urlPath.ts","../../../internals/shared/src/operation.ts","../src/components/Request.tsx","../src/generators/cypressGenerator.tsx","../src/resolvers/resolverCypress.ts","../src/plugin.ts"],"sourcesContent":["type Options = {\n /**\n * When `true`, dot-separated segments are split on `.` and joined with `/` after casing.\n */\n isFile?: boolean\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n *\n * Only splits on dots followed by a letter so that version numbers\n * embedded in operationIds (e.g. `v2025.0`) are kept intact.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split(/\\.(?=[a-zA-Z])/)\n return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * snakeCase('helloWorld') // 'hello_world'\n * snakeCase('Hello-World') // 'hello_world'\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * screamingSnakeCase('helloWorld') // 'HELLO_WORLD'\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\nexport type URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `undefined` when the path has none.\n */\n params?: Record<string, string>\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Optional transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n}\n\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype Options = {\n /**\n * Casing strategy applied to path parameter names.\n * @default undefined (original identifier preserved)\n */\n casing?: PathCasing\n}\n\n/**\n * Parses and transforms an OpenAPI/Swagger path string into various URL formats.\n *\n * @example\n * const p = new URLPath('/pet/{petId}')\n * p.URL // '/pet/:petId'\n * p.template // '`/pet/${petId}`'\n */\nexport class URLPath {\n /**\n * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.\n */\n path: string\n\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').URL // '/pet/:petId'\n * ```\n */\n get URL(): string {\n return this.toURLPath()\n }\n\n /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).\n *\n * @example\n * ```ts\n * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true\n * new URLPath('/pet/{petId}').isURL // false\n * ```\n */\n get isURL(): boolean {\n try {\n return !!new URL(this.path).href\n } catch {\n return false\n }\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n *\n * @example\n * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'\n * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'\n */\n get template(): string {\n return this.toTemplateString()\n }\n\n /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').object\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n * ```\n */\n get object(): URLObject | string {\n return this.toObject()\n }\n\n /** Returns a map of path parameter names, or `undefined` when the path has no parameters.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').params // { petId: 'petId' }\n * new URLPath('/pet').params // undefined\n * ```\n */\n get params(): Record<string, string> | undefined {\n return this.toParamsObject()\n }\n\n #transformParam(raw: string): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return this.#options.casing === 'camelcase' ? camelCase(param) : param\n }\n\n /**\n * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.\n */\n #eachParam(fn: (raw: string, param: string) => void): void {\n for (const match of this.path.matchAll(/\\{([^}]+)\\}/g)) {\n const raw = match[1]!\n fn(raw, this.#transformParam(raw))\n }\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.toParamsObject(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n * An optional `replacer` can transform each extracted parameter name before interpolation.\n *\n * @example\n * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'\n */\n toTemplateString({ prefix, replacer }: { prefix?: string | null; replacer?: (pathParam: string) => string } = {}): string {\n const parts = this.path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = this.#transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Extracts all `{param}` segments from the path and returns them as a key-value map.\n * An optional `replacer` transforms each parameter name in both key and value positions.\n * Returns `undefined` when no path parameters are found.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}/tag/{tagId}').toParamsObject()\n * // { petId: 'petId', tagId: 'tagId' }\n * ```\n */\n toParamsObject(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const params: Record<string, string> = {}\n\n this.#eachParam((_raw, param) => {\n const key = replacer ? replacer(param) : param\n params[key] = key\n })\n\n return Object.keys(params).length > 0 ? params : undefined\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'\n * ```\n */\n toURLPath(): string {\n return this.path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n}\n","import { URLPath } from '@internals/utils'\nimport { ast } from '@kubb/core'\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n resolveDataName(node: ast.OperationNode): string\n}\n\nexport type ResponseStatusNameResolver = {\n resolveResponseStatusName(node: ast.OperationNode, statusCode: ast.StatusCode): string\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n resolveResponseName(node: ast.OperationNode): string\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n\nexport type OperationCommentLink = 'pathTemplate' | 'urlPath' | false | ((node: ast.OperationNode) => string | undefined)\n\nexport type BuildOperationCommentsOptions = {\n link?: OperationCommentLink\n linkPosition?: 'beforeDeprecated' | 'afterDeprecated'\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<ast.ParameterNode['in'], Array<ast.ParameterNode>>\n\nexport type ResolveOperationTypeNameOptions = {\n paramsCasing?: 'camelcase'\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n}\n\nfunction getOperationLink(node: ast.OperationNode, link: OperationCommentLink): string | undefined {\n if (!link) {\n return undefined\n }\n\n if (typeof link === 'function') {\n return link(node)\n }\n\n if (link === 'urlPath') {\n return node.path ? `{@link ${new URLPath(node.path).URL}}` : undefined\n }\n\n return `{@link ${node.path.replaceAll('{', ':').replaceAll('}', '')}}`\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n const contentTypes = node.requestBody?.content?.map((e) => e.contentType) ?? []\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function buildRequestConfigType(node: ast.OperationNode, resolver: RequestConfigResolver): string {\n const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : undefined\n const { isMultipleContentTypes, contentTypeUnion } = getContentTypeInfo(node)\n const configType = requestName ? `Partial<RequestConfig<${requestName}>>` : 'Partial<RequestConfig>'\n const configProps = ['client?: Client', isMultipleContentTypes ? `contentType?: ${contentTypeUnion}` : undefined].filter(Boolean).join('; ')\n\n return `${configType} & { ${configProps} }`\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { link = 'pathTemplate', linkPosition = 'afterDeprecated', splitLines = false } = options\n const linkComment = getOperationLink(node, link)\n const comments =\n linkPosition === 'beforeDeprecated'\n ? [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, linkComment, node.deprecated && '@deprecated']\n : [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, node.deprecated && '@deprecated', linkComment]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\nexport function getOperationParameters(node: ast.OperationNode, options: { paramsCasing?: 'camelcase' } = {}): OperationParameterGroups {\n const params = ast.caseParams(node.parameters, options.paramsCasing)\n\n return {\n path: params.filter((param) => param.in === 'path'),\n query: params.filter((param) => param.in === 'query'),\n header: params.filter((param) => param.in === 'header'),\n cookie: params.filter((param) => param.in === 'cookie'),\n }\n}\n\nexport function getStatusCodeNumber(statusCode: ast.StatusCode | number | string): number | undefined {\n const code = Number(statusCode)\n\n return Number.isNaN(code) ? undefined : code\n}\n\nexport function isSuccessStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== undefined && code >= 200 && code < 300\n}\n\nexport function isErrorStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== undefined && code >= 400\n}\n\nexport function getSuccessResponses<TResponse extends ResponseLike>(responses: ReadonlyArray<TResponse>): Array<TResponse> {\n return responses.filter((response) => isSuccessStatusCode(response.statusCode))\n}\n\nexport function getOperationSuccessResponses(node: ast.OperationNode): Array<ast.ResponseNode> {\n return getSuccessResponses(node.responses)\n}\n\nexport function getPrimarySuccessResponse(node: ast.OperationNode): ast.ResponseNode | undefined {\n return getOperationSuccessResponses(node)[0]\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses\n .filter((response) => isErrorStatusCode(response.statusCode))\n .map((response) => resolver.resolveResponseStatusName(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.resolveResponseStatusName(node, response.statusCode))\n}\n\nconst typeNamesByResolver = new WeakMap<OperationTypeNameResolver, Map<string, string[]>>()\n\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const cacheKey = `${node.operationId}\\0${options.paramsCasing ?? ''}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${(options.exclude ?? []).join(',')}`\n let byResolver = typeNamesByResolver.get(resolver)\n if (byResolver) {\n const cached = byResolver.get(cacheKey)\n if (cached) return cached\n } else {\n byResolver = new Map()\n typeNamesByResolver.set(resolver, byResolver)\n }\n\n const { path, query, header } = getOperationParameters(node, { paramsCasing: options.paramsCasing })\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames = [\n ...path.map((param) => resolver.resolvePathParamsName(node, param)),\n ...query.map((param) => resolver.resolveQueryParamsName(node, param)),\n ...header.map((param) => resolver.resolveHeaderParamsName(node, param)),\n ]\n const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : undefined, resolver.resolveResponseName(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n const result = names.filter((name): name is string => Boolean(name) && !exclude.has(name))\n byResolver.set(cacheKey, result)\n return result\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.resolveResponseName(node)])\n continue\n }\n\n const code = getStatusCodeNumber(response.statusCode)\n if (code === undefined) {\n continue\n }\n\n types.push([code, isSuccessStatusCode(code) ? resolver.resolveResponseName(node) : resolver.resolveResponseStatusName(node, response.statusCode)])\n }\n\n return types\n}\n\nexport function findSuccessStatusCode(responses: Array<{ statusCode: ast.StatusCode | number | string }>): ast.StatusCode | undefined {\n for (const response of responses) {\n if (isSuccessStatusCode(response.statusCode)) {\n return response.statusCode as ast.StatusCode\n }\n }\n\n return undefined\n}\n","import { getOperationParameters } from '@internals/shared'\nimport { camelCase, URLPath } from '@internals/utils'\nimport { ast } from '@kubb/core'\nimport type { ResolverTs } from '@kubb/plugin-ts'\nimport { functionPrinter } from '@kubb/plugin-ts'\nimport { File, Function } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx/types'\nimport type { PluginCypress } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n /**\n * AST operation node\n */\n node: ast.OperationNode\n /**\n * TypeScript resolver for resolving param/data/response type names\n */\n resolver: ResolverTs\n baseURL: string | null | undefined\n dataReturnType: PluginCypress['resolvedOptions']['dataReturnType']\n paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n}\n\nconst declarationPrinter = functionPrinter({ mode: 'declaration' })\n\nexport function Request({ baseURL = '', name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }: Props): KubbReactNode {\n const paramsNode = ast.createOperationParams(node, {\n paramsType,\n pathParamsType,\n paramsCasing,\n resolver,\n extraParams: [\n ast.createFunctionParameter({\n name: 'options',\n type: ast.createParamsType({ variant: 'reference', name: 'Partial<Cypress.RequestOptions>' }),\n default: '{}',\n }),\n ],\n })\n const paramsSignature = declarationPrinter.print(paramsNode) ?? ''\n\n const responseType = resolver.resolveResponseName(node)\n const returnType = dataReturnType === 'data' ? `Cypress.Chainable<${responseType}>` : `Cypress.Chainable<Cypress.Response<${responseType}>>`\n\n const casedPathParams = getOperationParameters(node, { paramsCasing }).path\n // Build a lookup keyed by camelCase-normalized name so that path-template names\n // (e.g. `{pet_id}`) correctly resolve to the function-parameter name (`petId`)\n // even when the OpenAPI spec has inconsistent casing between the two.\n const pathParamNameMap = new Map(casedPathParams.map((p) => [camelCase(p.name), p.name]))\n\n const urlPath = new URLPath(node.path, { casing: paramsCasing })\n const urlTemplate = urlPath.toTemplateString({\n prefix: baseURL,\n replacer: (param) => pathParamNameMap.get(camelCase(param)) ?? param,\n })\n\n const requestOptions: string[] = [`method: '${node.method}'`, `url: ${urlTemplate}`]\n\n const queryParams = getOperationParameters(node).query\n if (queryParams.length > 0) {\n const casedQueryParams = getOperationParameters(node, { paramsCasing }).query\n // When paramsCasing renames query params (e.g. page_size → pageSize), we must remap\n // the camelCase keys back to the original API names before passing them to `qs`.\n const needsQsTransform = casedQueryParams.some((p, i) => p.name !== queryParams[i]!.name)\n if (needsQsTransform) {\n const pairs = queryParams.map((orig, i) => `${orig.name}: params.${casedQueryParams[i]!.name}`).join(', ')\n requestOptions.push(`qs: params ? { ${pairs} } : undefined`)\n } else {\n requestOptions.push('qs: params')\n }\n }\n\n const headerParams = getOperationParameters(node).header\n if (headerParams.length > 0) {\n const casedHeaderParams = getOperationParameters(node, { paramsCasing }).header\n // When paramsCasing renames header params (e.g. x-api-key → xApiKey), we must remap\n // the camelCase keys back to the original API names before passing them to `headers`.\n const needsHeaderTransform = casedHeaderParams.some((p, i) => p.name !== headerParams[i]!.name)\n if (needsHeaderTransform) {\n const pairs = headerParams.map((orig, i) => `'${orig.name}': headers.${casedHeaderParams[i]!.name}`).join(', ')\n requestOptions.push(`headers: headers ? { ${pairs} } : undefined`)\n } else {\n requestOptions.push('headers')\n }\n }\n\n if (node.requestBody?.content?.[0]?.schema) {\n requestOptions.push('body: data')\n }\n\n requestOptions.push('...options')\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={paramsSignature} returnType={returnType}>\n {dataReturnType === 'data'\n ? `return cy.request<${responseType}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body)`\n : `return cy.request<${responseType}>({\n ${requestOptions.join(',\\n ')}\n})`}\n </Function>\n </File.Source>\n )\n}\n","import { resolveOperationTypeNames } from '@internals/shared'\nimport { defineGenerator } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, jsxRendererSync } from '@kubb/renderer-jsx'\nimport { Request } from '../components/Request.tsx'\nimport type { PluginCypress } from '../types.ts'\n\nexport const cypressGenerator = defineGenerator<PluginCypress>({\n name: 'cypress',\n renderer: jsxRendererSync,\n operation(node, ctx) {\n const { config, resolver, driver, root } = ctx\n const { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType, group } = ctx.options\n\n const pluginTs = driver.getPlugin(pluginTsName)\n\n if (!pluginTs) {\n return null\n }\n\n const tsResolver = driver.getResolver(pluginTsName)\n\n const importedTypeNames = resolveOperationTypeNames(node, tsResolver, { paramsCasing })\n\n const meta = {\n name: resolver.resolveName(node.operationId),\n file: resolver.resolveFile({ name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path }, { root, output, group }),\n fileTs: tsResolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n {\n root,\n output: pluginTs.options?.output ?? output,\n group: pluginTs.options?.group,\n },\n ),\n } as const\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.resolveBanner(ctx.meta, { output, config })}\n footer={resolver.resolveFooter(ctx.meta, { output, config })}\n >\n {meta.fileTs && importedTypeNames.length > 0 && <File.Import name={importedTypeNames} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />}\n <Request\n name={meta.name}\n node={node}\n resolver={tsResolver}\n dataReturnType={dataReturnType}\n paramsCasing={paramsCasing}\n paramsType={paramsType}\n pathParamsType={pathParamsType}\n baseURL={baseURL}\n />\n </File>\n )\n },\n})\n","import { camelCase } from '@internals/utils'\nimport { defineResolver } from '@kubb/core'\nimport type { PluginCypress } from '../types.ts'\n\n/**\n * Naming convention resolver for Cypress plugin.\n *\n * Provides default naming helpers using camelCase for functions and file paths.\n *\n * @example\n * `resolverCypress.default('list pets', 'function') // → 'listPets'`\n */\nexport const resolverCypress = defineResolver<PluginCypress>(() => ({\n name: 'default',\n pluginName: 'plugin-cypress',\n default(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n resolveName(name) {\n return this.default(name, 'function')\n },\n resolvePathName(name, type) {\n return this.default(name, type)\n },\n}))\n","import { camelCase } from '@internals/utils'\nimport { definePlugin, type Group } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressGenerator } from './generators/cypressGenerator.tsx'\nimport { resolverCypress } from './resolvers/resolverCypress.ts'\nimport type { PluginCypress } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-cypress`, used to identify the plugin\n * in driver lookups and warnings.\n */\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\n/**\n * The `@kubb/plugin-cypress` plugin factory.\n *\n * Generates Cypress `cy.request()` test functions from an OpenAPI/AST `RootNode`.\n * Walks operations, delegates rendering to the active generators,\n * and writes barrel files based on `output.barrelType`.\n *\n * @example\n * ```ts\n * import pluginCypress from '@kubb/plugin-cypress'\n *\n * export default defineConfig({\n * plugins: [pluginCypress({ output: { path: 'cypress' } })],\n * })\n * ```\n */\nexport const pluginCypress = definePlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n dataReturnType = 'data',\n baseURL,\n paramsCasing,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n resolver: userResolver,\n transformer: userTransformer,\n generators: userGenerators = [],\n } = options\n\n const groupConfig = group\n ? ({\n ...group,\n name: group.name\n ? group.name\n : (ctx: { group: string }) => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n },\n } satisfies Group)\n : undefined\n\n return {\n name: pluginCypressName,\n options,\n dependencies: [pluginTsName],\n hooks: {\n 'kubb:plugin:setup'(ctx) {\n const resolver = userResolver ? { ...resolverCypress, ...userResolver } : resolverCypress\n\n ctx.setOptions({\n output,\n exclude,\n include,\n override,\n dataReturnType,\n group: groupConfig,\n baseURL,\n paramsCasing,\n paramsType,\n pathParamsType,\n resolver,\n })\n ctx.setResolver(resolver)\n if (userTransformer) {\n ctx.setTransformer(userTransformer)\n }\n ctx.addGenerator(cypressGenerator)\n for (const gen of userGenerators) {\n ctx.addGenerator(gen)\n }\n },\n },\n }\n})\n\nexport default pluginCypress\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;CAS9D,OARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAEH,CAAC,MAAM,gBAAgB,CAAC,OAAO,QAE3C,CACT,KAAK,MAAM,MAAM;EAEhB,IADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,EACjD,OAAO;EACrB,IAAI,MAAM,KAAK,CAAC,QAAQ,OAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;EAC3E,OAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;GACnD,CACD,KAAK,GAAG,CACR,QAAQ,iBAAiB,GAAG;;;;;;;;;;AAWjC,SAAS,iBAAiB,MAAc,eAAkE;CACxG,MAAM,QAAQ,KAAK,MAAM,iBAAiB;CAC1C,OAAO,MAAM,KAAK,MAAM,MAAM,cAAc,MAAM,MAAM,MAAM,SAAS,EAAE,CAAC,CAAC,KAAK,IAAI;;;;;;;;;;AAWtF,SAAgB,UAAU,MAAc,EAAE,QAAQ,SAAS,IAAI,SAAS,OAAgB,EAAE,EAAU;CAClG,IAAI,QACF,OAAO,iBAAiB,OAAO,MAAM,WAAW,UAAU,MAAM,SAAS;EAAE;EAAQ;EAAQ,GAAG,EAAE,CAAC,CAAC;CAGpG,OAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU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;EACH,MAAM,MAAM,OACR,MAAM,QACL,QAA2B;GAC1B,IAAI,MAAM,SAAS,QACjB,OAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;GAEjC,OAAO,GAAG,UAAU,IAAI,MAAM,CAAC;;EAEtC,GACD,KAAA;CAEJ,OAAO;EACL,MAAM;EACN;EACA,cAAc,CAACC,gBAAAA,aAAa;EAC5B,OAAO,EACL,oBAAoB,KAAK;GACvB,MAAM,WAAW,eAAe;IAAE,GAAG;IAAiB,GAAG;IAAc,GAAG;GAE1E,IAAI,WAAW;IACb;IACA;IACA;IACA;IACA;IACA,OAAO;IACP;IACA;IACA;IACA;IACA;IACD,CAAC;GACF,IAAI,YAAY,SAAS;GACzB,IAAI,iBACF,IAAI,eAAe,gBAAgB;GAErC,IAAI,aAAa,iBAAiB;GAClC,KAAK,MAAM,OAAO,gBAChB,IAAI,aAAa,IAAI;KAG1B;EACF;EACD"}
1
+ {"version":3,"file":"index.cjs","names":["#options","#transformParam","#eachParam","ast","ast","File","Function","jsxRendererSync","pluginTsName","File","pluginTsName"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/urlPath.ts","../../../internals/shared/src/operation.ts","../src/components/Request.tsx","../src/generators/cypressGenerator.tsx","../src/resolvers/resolverCypress.ts","../src/plugin.ts"],"sourcesContent":["type Options = {\n /**\n * When `true`, dot-separated segments are split on `.` and joined with `/` after casing.\n */\n isFile?: boolean\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n *\n * Only splits on dots followed by a letter so that version numbers\n * embedded in operationIds (e.g. `v2025.0`) are kept intact.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split(/\\.(?=[a-zA-Z])/)\n return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * snakeCase('helloWorld') // 'hello_world'\n * snakeCase('Hello-World') // 'hello_world'\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * screamingSnakeCase('helloWorld') // 'HELLO_WORLD'\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\nexport type URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `null` when the path has none.\n */\n params: Record<string, string> | null\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Optional transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n}\n\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype Options = {\n /**\n * Casing strategy applied to path parameter names.\n * @default undefined (original identifier preserved)\n */\n casing?: PathCasing\n}\n\n/**\n * Parses and transforms an OpenAPI/Swagger path string into various URL formats.\n *\n * @example\n * const p = new URLPath('/pet/{petId}')\n * p.URL // '/pet/:petId'\n * p.template // '`/pet/${petId}`'\n */\nexport class URLPath {\n /**\n * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.\n */\n path: string\n\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').URL // '/pet/:petId'\n * ```\n */\n get URL(): string {\n return this.toURLPath()\n }\n\n /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).\n *\n * @example\n * ```ts\n * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true\n * new URLPath('/pet/{petId}').isURL // false\n * ```\n */\n get isURL(): boolean {\n try {\n return !!new URL(this.path).href\n } catch {\n return false\n }\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n *\n * @example\n * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'\n * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'\n */\n get template(): string {\n return this.toTemplateString()\n }\n\n /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').object\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n * ```\n */\n get object(): URLObject | string {\n return this.toObject()\n }\n\n /** Returns a map of path parameter names, or `null` when the path has no parameters.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').params // { petId: 'petId' }\n * new URLPath('/pet').params // null\n * ```\n */\n get params(): Record<string, string> | null {\n return this.toParamsObject()\n }\n\n #transformParam(raw: string): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return this.#options.casing === 'camelcase' ? camelCase(param) : param\n }\n\n /**\n * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.\n */\n #eachParam(fn: (raw: string, param: string) => undefined): undefined {\n for (const match of this.path.matchAll(/\\{([^}]+)\\}/g)) {\n const raw = match[1]!\n fn(raw, this.#transformParam(raw))\n }\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.toParamsObject(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Converts the OpenAPI path to a TypeScript template literal string.\n * An optional `replacer` can transform each extracted parameter name before interpolation.\n *\n * @example\n * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'\n */\n toTemplateString({ prefix, replacer }: { prefix?: string | null; replacer?: (pathParam: string) => string } = {}): string {\n const parts = this.path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = this.#transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Extracts all `{param}` segments from the path and returns them as a key-value map.\n * An optional `replacer` transforms each parameter name in both key and value positions.\n * Returns `undefined` when no path parameters are found.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}/tag/{tagId}').toParamsObject()\n * // { petId: 'petId', tagId: 'tagId' }\n * ```\n */\n toParamsObject(replacer?: (pathParam: string) => string): Record<string, string> | null {\n const params: Record<string, string> = {}\n\n this.#eachParam((_raw, param) => {\n const key = replacer ? replacer(param) : param\n params[key] = key\n })\n\n return Object.keys(params).length > 0 ? params : null\n }\n\n /** Converts the OpenAPI path to Express-style colon syntax.\n *\n * @example\n * ```ts\n * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'\n * ```\n */\n toURLPath(): string {\n return this.path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n}\n","import { URLPath } from '@internals/utils'\nimport { ast } from '@kubb/core'\n\nexport type ContentTypeInfo = {\n contentTypes: string[]\n isMultipleContentTypes: boolean\n contentTypeUnion: string\n defaultContentType: string\n hasFormData: boolean\n}\n\nexport type RequestConfigResolver = {\n resolveDataName(node: ast.OperationNode): string\n}\n\nexport type ResponseStatusNameResolver = {\n resolveResponseStatusName(node: ast.OperationNode, statusCode: ast.StatusCode): string\n}\n\nexport type ResponseNameResolver = ResponseStatusNameResolver & {\n resolveResponseName(node: ast.OperationNode): string\n}\n\nexport type OperationTypeNameResolver = RequestConfigResolver &\n ResponseNameResolver & {\n resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string\n }\n\nexport type OperationCommentLink = 'pathTemplate' | 'urlPath' | false | ((node: ast.OperationNode) => string | undefined)\n\nexport type BuildOperationCommentsOptions = {\n link?: OperationCommentLink\n linkPosition?: 'beforeDeprecated' | 'afterDeprecated'\n splitLines?: boolean\n}\n\ntype ResponseLike = {\n statusCode: ast.StatusCode | number | string\n}\n\nexport type OperationParameterGroups = Record<ast.ParameterNode['in'], Array<ast.ParameterNode>>\n\nexport type ResolveOperationTypeNameOptions = {\n paramsCasing?: 'camelcase'\n responseStatusNames?: boolean | 'error'\n exclude?: ReadonlyArray<string | undefined>\n order?: 'params-first' | 'body-response-first'\n}\n\nfunction getOperationLink(node: ast.OperationNode, link: OperationCommentLink): string | null {\n if (!link) {\n return null\n }\n\n if (typeof link === 'function') {\n return link(node) ?? null\n }\n\n if (link === 'urlPath') {\n return node.path ? `{@link ${new URLPath(node.path).URL}}` : null\n }\n\n return `{@link ${node.path.replaceAll('{', ':').replaceAll('}', '')}}`\n}\n\nexport function getContentTypeInfo(node: ast.OperationNode): ContentTypeInfo {\n const contentTypes = node.requestBody?.content?.map((e) => e.contentType) ?? []\n const isMultipleContentTypes = contentTypes.length > 1\n\n return {\n contentTypes,\n isMultipleContentTypes,\n contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(' | ') : '',\n defaultContentType: contentTypes[0] ?? 'application/json',\n hasFormData: contentTypes.some((ct) => ct === 'multipart/form-data'),\n }\n}\n\nexport function buildRequestConfigType(node: ast.OperationNode, resolver: RequestConfigResolver): string {\n const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null\n const { isMultipleContentTypes, contentTypeUnion } = getContentTypeInfo(node)\n const configType = requestName ? `Partial<RequestConfig<${requestName}>>` : 'Partial<RequestConfig>'\n const configProps = ['client?: Client', isMultipleContentTypes ? `contentType?: ${contentTypeUnion}` : null].filter(Boolean).join('; ')\n\n return `${configType} & { ${configProps} }`\n}\n\nexport function buildOperationComments(node: ast.OperationNode, options: BuildOperationCommentsOptions = {}): Array<string> {\n const { link = 'pathTemplate', linkPosition = 'afterDeprecated', splitLines = false } = options\n const linkComment = getOperationLink(node, link)\n const comments =\n linkPosition === 'beforeDeprecated'\n ? [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, linkComment, node.deprecated && '@deprecated']\n : [node.description && `@description ${node.description}`, node.summary && `@summary ${node.summary}`, node.deprecated && '@deprecated', linkComment]\n\n const filteredComments = comments.filter((comment): comment is string => Boolean(comment))\n\n if (!splitLines) {\n return filteredComments\n }\n\n return filteredComments.flatMap((text) => text.split(/\\r?\\n/).map((line) => line.trim())).filter((comment): comment is string => Boolean(comment))\n}\n\nexport function getOperationParameters(node: ast.OperationNode, options: { paramsCasing?: 'camelcase' } = {}): OperationParameterGroups {\n const params = ast.caseParams(node.parameters, options.paramsCasing)\n\n return {\n path: params.filter((param) => param.in === 'path'),\n query: params.filter((param) => param.in === 'query'),\n header: params.filter((param) => param.in === 'header'),\n cookie: params.filter((param) => param.in === 'cookie'),\n }\n}\n\nexport function getStatusCodeNumber(statusCode: ast.StatusCode | number | string): number | null {\n const code = Number(statusCode)\n\n return Number.isNaN(code) ? null : code\n}\n\nexport function isSuccessStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 200 && code < 300\n}\n\nexport function isErrorStatusCode(statusCode: ast.StatusCode | number | string): boolean {\n const code = getStatusCodeNumber(statusCode)\n\n return code !== null && code >= 400\n}\n\nexport function getSuccessResponses<TResponse extends ResponseLike>(responses: ReadonlyArray<TResponse>): Array<TResponse> {\n return responses.filter((response) => isSuccessStatusCode(response.statusCode))\n}\n\nexport function getOperationSuccessResponses(node: ast.OperationNode): Array<ast.ResponseNode> {\n return getSuccessResponses(node.responses)\n}\n\nexport function getPrimarySuccessResponse(node: ast.OperationNode): ast.ResponseNode | null {\n return getOperationSuccessResponses(node)[0] ?? null\n}\n\nexport function resolveErrorNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses\n .filter((response) => isErrorStatusCode(response.statusCode))\n .map((response) => resolver.resolveResponseStatusName(node, response.statusCode))\n}\n\nexport function resolveStatusCodeNames(node: ast.OperationNode, resolver: ResponseStatusNameResolver): string[] {\n return node.responses.map((response) => resolver.resolveResponseStatusName(node, response.statusCode))\n}\n\nconst typeNamesByResolver = new WeakMap<OperationTypeNameResolver, Map<string, string[]>>()\n\nexport function resolveOperationTypeNames(\n node: ast.OperationNode,\n resolver: OperationTypeNameResolver,\n options: ResolveOperationTypeNameOptions = {},\n): string[] {\n const cacheKey = `${node.operationId}\\0${options.paramsCasing ?? ''}\\0${options.order ?? ''}\\0${options.responseStatusNames ?? ''}\\0${(options.exclude ?? []).join(',')}`\n let byResolver = typeNamesByResolver.get(resolver)\n if (byResolver) {\n const cached = byResolver.get(cacheKey)\n if (cached) return cached\n } else {\n byResolver = new Map()\n typeNamesByResolver.set(resolver, byResolver)\n }\n\n const { path, query, header } = getOperationParameters(node, { paramsCasing: options.paramsCasing })\n const responseStatusNames =\n options.responseStatusNames === 'error'\n ? resolveErrorNames(node, resolver)\n : options.responseStatusNames === false\n ? []\n : resolveStatusCodeNames(node, resolver)\n const exclude = new Set(options.exclude ?? [])\n const paramNames = [\n ...path.map((param) => resolver.resolvePathParamsName(node, param)),\n ...query.map((param) => resolver.resolveQueryParamsName(node, param)),\n ...header.map((param) => resolver.resolveHeaderParamsName(node, param)),\n ]\n const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null, resolver.resolveResponseName(node)]\n const names =\n options.order === 'body-response-first'\n ? [...bodyAndResponseNames, ...paramNames, ...responseStatusNames]\n : [...paramNames, ...bodyAndResponseNames, ...responseStatusNames]\n\n const result = names.filter((name): name is string => Boolean(name) && !exclude.has(name as string))\n byResolver.set(cacheKey, result)\n return result\n}\n\nexport function resolveResponseTypes(node: ast.OperationNode, resolver: ResponseNameResolver): Array<[statusCode: number | 'default', typeName: string]> {\n const types: Array<[number | 'default', string]> = []\n\n for (const response of node.responses) {\n if (response.statusCode === 'default') {\n types.push(['default', resolver.resolveResponseName(node)])\n continue\n }\n\n const code = getStatusCodeNumber(response.statusCode)\n if (code === null) {\n continue\n }\n\n types.push([code, isSuccessStatusCode(code) ? resolver.resolveResponseName(node) : resolver.resolveResponseStatusName(node, response.statusCode)])\n }\n\n return types\n}\n\nexport function findSuccessStatusCode(responses: Array<{ statusCode: ast.StatusCode | number | string }>): ast.StatusCode | null {\n for (const response of responses) {\n if (isSuccessStatusCode(response.statusCode)) {\n return response.statusCode as ast.StatusCode\n }\n }\n\n return null\n}\n","import { getOperationParameters } from '@internals/shared'\nimport { camelCase, URLPath } from '@internals/utils'\nimport { ast } from '@kubb/core'\nimport type { ResolverTs } from '@kubb/plugin-ts'\nimport { functionPrinter } from '@kubb/plugin-ts'\nimport { File, Function } from '@kubb/renderer-jsx'\nimport type { KubbReactNode } from '@kubb/renderer-jsx/types'\nimport type { PluginCypress } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n /**\n * AST operation node\n */\n node: ast.OperationNode\n /**\n * TypeScript resolver for resolving param/data/response type names\n */\n resolver: ResolverTs\n baseURL: string | null | undefined\n dataReturnType: PluginCypress['resolvedOptions']['dataReturnType']\n paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n}\n\nconst declarationPrinter = functionPrinter({ mode: 'declaration' })\n\nexport function Request({ baseURL = '', name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }: Props): KubbReactNode {\n const paramsNode = ast.createOperationParams(node, {\n paramsType,\n pathParamsType,\n paramsCasing,\n resolver,\n extraParams: [\n ast.createFunctionParameter({\n name: 'options',\n type: ast.createParamsType({ variant: 'reference', name: 'Partial<Cypress.RequestOptions>' }),\n default: '{}',\n }),\n ],\n })\n const paramsSignature = declarationPrinter.print(paramsNode) ?? ''\n\n const responseType = resolver.resolveResponseName(node)\n const returnType = dataReturnType === 'data' ? `Cypress.Chainable<${responseType}>` : `Cypress.Chainable<Cypress.Response<${responseType}>>`\n\n const casedPathParams = getOperationParameters(node, { paramsCasing }).path\n // Build a lookup keyed by camelCase-normalized name so that path-template names\n // (e.g. `{pet_id}`) correctly resolve to the function-parameter name (`petId`)\n // even when the OpenAPI spec has inconsistent casing between the two.\n const pathParamNameMap = new Map(casedPathParams.map((p) => [camelCase(p.name), p.name]))\n\n const urlPath = new URLPath(node.path, { casing: paramsCasing })\n const urlTemplate = urlPath.toTemplateString({\n prefix: baseURL,\n replacer: (param) => pathParamNameMap.get(camelCase(param)) ?? param,\n })\n\n const requestOptions: Array<string> = [`method: '${node.method}'`, `url: ${urlTemplate}`]\n\n const queryParams = getOperationParameters(node).query\n if (queryParams.length > 0) {\n const casedQueryParams = getOperationParameters(node, { paramsCasing }).query\n // When paramsCasing renames query params (e.g. page_size → pageSize), we must remap\n // the camelCase keys back to the original API names before passing them to `qs`.\n const needsQsTransform = casedQueryParams.some((p, i) => p.name !== queryParams[i]!.name)\n if (needsQsTransform) {\n const pairs = queryParams.map((orig, i) => `${orig.name}: params.${casedQueryParams[i]!.name}`).join(', ')\n requestOptions.push(`qs: params ? { ${pairs} } : undefined`)\n } else {\n requestOptions.push('qs: params')\n }\n }\n\n const headerParams = getOperationParameters(node).header\n if (headerParams.length > 0) {\n const casedHeaderParams = getOperationParameters(node, { paramsCasing }).header\n // When paramsCasing renames header params (e.g. x-api-key → xApiKey), we must remap\n // the camelCase keys back to the original API names before passing them to `headers`.\n const needsHeaderTransform = casedHeaderParams.some((p, i) => p.name !== headerParams[i]!.name)\n if (needsHeaderTransform) {\n const pairs = headerParams.map((orig, i) => `'${orig.name}': headers.${casedHeaderParams[i]!.name}`).join(', ')\n requestOptions.push(`headers: headers ? { ${pairs} } : undefined`)\n } else {\n requestOptions.push('headers')\n }\n }\n\n if (node.requestBody?.content?.[0]?.schema) {\n requestOptions.push('body: data')\n }\n\n requestOptions.push('...options')\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={paramsSignature} returnType={returnType}>\n {dataReturnType === 'data'\n ? `return cy.request<${responseType}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body)`\n : `return cy.request<${responseType}>({\n ${requestOptions.join(',\\n ')}\n})`}\n </Function>\n </File.Source>\n )\n}\n","import { resolveOperationTypeNames } from '@internals/shared'\nimport { defineGenerator } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, jsxRendererSync } 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: jsxRendererSync,\n operation(node, ctx) {\n const { config, resolver, driver, root } = ctx\n const { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType, group } = ctx.options\n\n const pluginTs = driver.getPlugin(pluginTsName)\n\n if (!pluginTs) {\n return null\n }\n\n const tsResolver = driver.getResolver(pluginTsName)\n\n const importedTypeNames = resolveOperationTypeNames(node, tsResolver, { paramsCasing })\n\n const meta = {\n name: resolver.resolveName(node.operationId),\n file: resolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output, group: group ?? undefined },\n ),\n fileTs: tsResolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n {\n root,\n output: pluginTs.options?.output ?? output,\n group: pluginTs.options?.group ?? undefined,\n },\n ),\n } as const\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.resolveBanner(ctx.meta, { output, config })}\n footer={resolver.resolveFooter(ctx.meta, { output, config })}\n >\n {meta.fileTs && importedTypeNames.length > 0 && <File.Import name={importedTypeNames} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />}\n <Request\n name={meta.name}\n node={node}\n resolver={tsResolver}\n dataReturnType={dataReturnType}\n paramsCasing={paramsCasing}\n paramsType={paramsType}\n pathParamsType={pathParamsType}\n baseURL={baseURL}\n />\n </File>\n )\n },\n})\n","import { camelCase } from '@internals/utils'\nimport { defineResolver } from '@kubb/core'\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-client`.\n *\n * @example Resolve a helper name\n * ```ts\n * import { resolverCypress } from '@kubb/plugin-cypress'\n *\n * resolverCypress.default('list pets', 'function') // 'listPets'\n * ```\n */\nexport const resolverCypress = defineResolver<PluginCypress>(() => ({\n name: 'default',\n pluginName: 'plugin-cypress',\n default(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n resolveName(name) {\n return this.default(name, 'function')\n },\n resolvePathName(name, type) {\n return this.default(name, type)\n },\n}))\n","import { camelCase } from '@internals/utils'\nimport { definePlugin, type Group } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressGenerator } from './generators/cypressGenerator.tsx'\nimport { resolverCypress } from './resolvers/resolverCypress.ts'\nimport type { PluginCypress } 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'\n * import { pluginTs } from '@kubb/plugin-ts'\n * import { pluginCypress } from '@kubb/plugin-cypress'\n *\n * export default defineConfig({\n * input: { path: './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 = definePlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n dataReturnType = 'data',\n baseURL,\n paramsCasing,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n resolver: userResolver,\n transformer: userTransformer,\n generators: userGenerators = [],\n } = options\n\n const groupConfig = group\n ? ({\n ...group,\n name: group.name\n ? group.name\n : (ctx: { group: string }) => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n },\n } satisfies Group)\n : null\n\n return {\n name: pluginCypressName,\n options,\n dependencies: [pluginTsName],\n hooks: {\n 'kubb:plugin:setup'(ctx) {\n const resolver = userResolver ? { ...resolverCypress, ...userResolver } : resolverCypress\n\n ctx.setOptions({\n output,\n exclude,\n include,\n override,\n dataReturnType,\n group: groupConfig,\n baseURL,\n paramsCasing,\n paramsType,\n pathParamsType,\n resolver,\n })\n ctx.setResolver(resolver)\n if (userTransformer) {\n ctx.setTransformer(userTransformer)\n }\n ctx.addGenerator(cypressGenerator)\n for (const gen of userGenerators) {\n ctx.addGenerator(gen)\n }\n },\n },\n }\n})\n\nexport default pluginCypress\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;CAS9D,OARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QA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;GACF,IAAI,YAAY,SAAS;GACzB,IAAI,iBACF,IAAI,eAAe,gBAAgB;GAErC,IAAI,aAAa,iBAAiB;GAClC,KAAK,MAAM,OAAO,gBAChB,IAAI,aAAa,IAAI;KAG1B;EACF;EACD"}
package/dist/index.d.ts CHANGED
@@ -26,20 +26,22 @@ type ResolverCypress = Resolver & {
26
26
  */
27
27
  type ParamsTypeOptions = {
28
28
  /**
29
- * All parameters merged into a single destructured object.
29
+ * Every operation parameter is wrapped in a single destructured object argument.
30
30
  */
31
31
  paramsType: 'object';
32
32
  /**
33
- * Not applicable when all parameters are merged into a single object.
33
+ * `pathParamsType` has no effect when `paramsType` is `'object'`.
34
34
  */
35
35
  pathParamsType?: never;
36
36
  } | {
37
37
  /**
38
- * Each parameter group emitted as a separate function argument.
38
+ * Each parameter group is emitted as a separate positional function argument.
39
39
  */
40
40
  paramsType?: 'inline';
41
41
  /**
42
- * How path parameters are arranged: grouped in an object or spread inline.
42
+ * How URL path parameters are arranged inside the inline argument list.
43
+ * - `'object'` groups them into one destructured object.
44
+ * - `'inline'` emits each path param as its own argument.
43
45
  *
44
46
  * @default 'inline'
45
47
  */
@@ -47,50 +49,56 @@ type ParamsTypeOptions = {
47
49
  };
48
50
  type Options = {
49
51
  /**
50
- * Specify the export location for the files and define the behavior of the output.
51
- * @default { path: 'cypress', barrelType: 'named' }
52
+ * Where the generated Cypress helpers are written and how they are exported.
53
+ *
54
+ * @default { path: 'cypress', barrel: { type: 'named' } }
52
55
  */
53
56
  output?: Output;
54
57
  /**
55
- * Return type when calling cy.request: response data only or full response.
58
+ * Shape of the value returned from each helper.
59
+ * - `'data'` — only the response body.
60
+ * - `'full'` — the full Cypress response object (headers, status, body).
56
61
  *
57
62
  * @default 'data'
58
63
  */
59
64
  dataReturnType?: 'data' | 'full';
60
65
  /**
61
- * Apply casing to parameter names.
66
+ * Rename parameter properties in the generated helpers (path, query, headers).
67
+ *
68
+ * @note Must match the value of `paramsCasing` on `@kubb/plugin-ts`.
62
69
  */
63
70
  paramsCasing?: 'camelcase';
64
71
  /**
65
- * Base URL prepended to every generated request URL.
72
+ * Base URL prepended to every request URL. When omitted, falls back to the
73
+ * adapter's server URL (typically `servers[0].url`).
66
74
  */
67
75
  baseURL?: string;
68
76
  /**
69
- * Group the Cypress requests based on the provided name.
77
+ * Split generated files into subfolders based on the operation's tag.
70
78
  */
71
79
  group?: Group;
72
80
  /**
73
- * Tags, operations, or paths to exclude from generation.
81
+ * Skip operations matching at least one entry in the list.
74
82
  */
75
83
  exclude?: Array<Exclude>;
76
84
  /**
77
- * Tags, operations, or paths to include in generation.
85
+ * Restrict generation to operations matching at least one entry in the list.
78
86
  */
79
87
  include?: Array<Include>;
80
88
  /**
81
- * Override options for specific tags, operations, or paths.
89
+ * Apply a different options object to operations matching a pattern.
82
90
  */
83
91
  override?: Array<Override<ResolvedOptions>>;
84
92
  /**
85
- * Override naming conventions for function names and types.
93
+ * Override how helper names and file paths are built.
86
94
  */
87
95
  resolver?: Partial<ResolverCypress> & ThisType<ResolverCypress>;
88
96
  /**
89
- * AST visitor to transform generated nodes.
97
+ * AST visitor applied to each operation node before printing.
90
98
  */
91
99
  transformer?: ast.Visitor;
92
100
  /**
93
- * Additional generators alongside the default generators.
101
+ * Custom generators that run alongside the built-in Cypress generators.
94
102
  */
95
103
  generators?: Array<Generator<PluginCypress>>;
96
104
  } & ParamsTypeOptions;
@@ -99,7 +107,7 @@ type ResolvedOptions = {
99
107
  exclude: Array<Exclude>;
100
108
  include: Array<Include> | undefined;
101
109
  override: Array<Override<ResolvedOptions>>;
102
- group: Group | undefined;
110
+ group: Group | null;
103
111
  baseURL: Options['baseURL'] | undefined;
104
112
  dataReturnType: NonNullable<Options['dataReturnType']>;
105
113
  pathParamsType: NonNullable<NonNullable<Options['pathParamsType']>>;
@@ -148,27 +156,39 @@ declare function Request({
148
156
  }: Props): KubbReactNode;
149
157
  //#endregion
150
158
  //#region src/generators/cypressGenerator.d.ts
159
+ /**
160
+ * Built-in generator for `@kubb/plugin-cypress`. Emits one typed
161
+ * `cy.request()` wrapper per OpenAPI operation, ready to call inside Cypress
162
+ * test specs and custom commands.
163
+ */
151
164
  declare const cypressGenerator: _$_kubb_core0.Generator<PluginCypress, unknown>;
152
165
  //#endregion
153
166
  //#region src/plugin.d.ts
154
167
  /**
155
- * Canonical plugin name for `@kubb/plugin-cypress`, used to identify the plugin
156
- * in driver lookups and warnings.
168
+ * Canonical plugin name for `@kubb/plugin-cypress`. Used for driver lookups and
169
+ * cross-plugin dependency references.
157
170
  */
158
171
  declare const pluginCypressName = "plugin-cypress";
159
172
  /**
160
- * The `@kubb/plugin-cypress` plugin factory.
161
- *
162
- * Generates Cypress `cy.request()` test functions from an OpenAPI/AST `RootNode`.
163
- * Walks operations, delegates rendering to the active generators,
164
- * and writes barrel files based on `output.barrelType`.
173
+ * Generates one typed `cy.request()` wrapper per OpenAPI operation. Each helper
174
+ * has typed path params, body, query, and a typed response, so failing API
175
+ * calls in Cypress show up at compile time instead of inside the test runner.
165
176
  *
166
177
  * @example
167
178
  * ```ts
168
- * import pluginCypress from '@kubb/plugin-cypress'
179
+ * import { defineConfig } from 'kubb'
180
+ * import { pluginTs } from '@kubb/plugin-ts'
181
+ * import { pluginCypress } from '@kubb/plugin-cypress'
169
182
  *
170
183
  * export default defineConfig({
171
- * plugins: [pluginCypress({ output: { path: 'cypress' } })],
184
+ * input: { path: './petStore.yaml' },
185
+ * output: { path: './src/gen' },
186
+ * plugins: [
187
+ * pluginTs(),
188
+ * pluginCypress({
189
+ * output: { path: './cypress' },
190
+ * }),
191
+ * ],
172
192
  * })
173
193
  * ```
174
194
  */
@@ -176,12 +196,16 @@ declare const pluginCypress: (options?: Options | undefined) => _$_kubb_core0.Pl
176
196
  //#endregion
177
197
  //#region src/resolvers/resolverCypress.d.ts
178
198
  /**
179
- * Naming convention resolver for Cypress plugin.
199
+ * Default resolver used by `@kubb/plugin-cypress`. Decides the names and file
200
+ * paths for every generated `cy.request()` wrapper. Functions and files use
201
+ * camelCase, matching the convention from `@kubb/plugin-client`.
180
202
  *
181
- * Provides default naming helpers using camelCase for functions and file paths.
203
+ * @example Resolve a helper name
204
+ * ```ts
205
+ * import { resolverCypress } from '@kubb/plugin-cypress'
182
206
  *
183
- * @example
184
- * `resolverCypress.default('list pets', 'function') // → 'listPets'`
207
+ * resolverCypress.default('list pets', 'function') // 'listPets'
208
+ * ```
185
209
  */
186
210
  declare const resolverCypress: ResolverCypress;
187
211
  //#endregion