@kubb/plugin-cypress 5.0.0-alpha.22 → 5.0.0-alpha.24

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["cypressGenerator","pluginOasName","pluginTsName","path","camelCase","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { createPlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressGenerator } from './generators'\nimport type { PluginCypress } from './types.ts'\n\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\nexport const pluginCypress = createPlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n dataReturnType = 'data',\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [cypressGenerator].filter(Boolean),\n contentType,\n baseURL,\n paramsCasing,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n } = options\n\n return {\n name: pluginCypressName,\n options: {\n output,\n dataReturnType,\n group,\n baseURL,\n\n paramsCasing,\n paramsType,\n pathParamsType,\n },\n pre: [pluginOasName, pluginTsName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AAQA,MAAa,oBAAoB;AAEjC,MAAa,iBAAA,GAAA,WAAA,eAA6C,YAAY;CACpE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,iBAAiB,QACjB,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAACA,mBAAAA,iBAAiB,CAAC,OAAO,QAAQ,EAC/C,aACA,SACA,cACA,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,aAC9E;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GAEA;GACA;GACA;GACD;EACD,KAAK,CAACC,iBAAAA,eAAeC,gBAAAA,aAAa,CAAC,OAAO,QAAQ;EAClD,YAAY,UAAU,UAAU,SAAS;GACvC,MAAM,OAAOC,UAAAA,QAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,aAAA,GAAA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O,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
1
+ {"version":3,"file":"index.cjs","names":["#options","#transformParam","#eachParam","File","Function","path","pluginTsName","File","pluginTsName","path"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/urlPath.ts","../src/components/Request.tsx","../src/generators/cypressGenerator.tsx","../src/resolvers/resolverCypress.ts","../src/presets.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 * Prefixes `word` with `_` when it is a reserved JavaScript/Java identifier or starts with a digit.\n *\n * @example\n * ```ts\n * transformReservedWord('class') // '_class'\n * transformReservedWord('42foo') // '_42foo'\n * transformReservedWord('status') // 'status'\n * ```\n */\nexport function transformReservedWord(word: string): string {\n const firstChar = word.charCodeAt(0)\n if (word && (reservedWords.has(word as 'valueOf') || (firstChar >= 48 && firstChar <= 57))) {\n return `_${word}`\n }\n return word\n}\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 try {\n new Function(`var ${name}`)\n } catch {\n return false\n }\n return true\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.getParams()\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.getParams(),\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; 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}').getParams()\n * // { petId: 'petId', tagId: 'tagId' }\n * ```\n */\n getParams(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 { camelCase, URLPath } from '@internals/utils'\nimport { caseParams, createFunctionParameter, createOperationParams, createTypeNode } from '@kubb/ast'\nimport type { OperationNode } from '@kubb/ast/types'\nimport type { ResolverTs } from '@kubb/plugin-ts'\nimport { functionPrinter } from '@kubb/plugin-ts'\nimport { File, Function } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/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: OperationNode\n /**\n * TypeScript resolver for resolving param/data/response type names\n */\n resolver: ResolverTs\n baseURL: string | 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\nfunction getParams({\n paramsType,\n pathParamsType,\n paramsCasing,\n resolver,\n node,\n}: {\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n resolver: ResolverTs\n node: OperationNode\n}): string {\n const paramsNode = createOperationParams(node, {\n paramsType,\n pathParamsType,\n paramsCasing,\n resolver,\n extraParams: [\n createFunctionParameter({ name: 'options', type: createTypeNode({ variant: 'reference', name: 'Partial<Cypress.RequestOptions>' }), default: '{}' }),\n ],\n })\n\n return declarationPrinter.print(paramsNode) ?? ''\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }: Props): FabricReactNode {\n const paramsSignature = getParams({ paramsType, pathParamsType, paramsCasing, resolver, node })\n\n const responseType = resolver.resolveResponseName(node)\n const returnType = dataReturnType === 'data' ? `Cypress.Chainable<${responseType}>` : `Cypress.Chainable<Cypress.Response<${responseType}>>`\n\n const casedPathParams = caseParams(\n node.parameters.filter((p) => p.in === 'path'),\n paramsCasing,\n )\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 = node.parameters.filter((p) => p.in === 'query')\n if (queryParams.length > 0) {\n const casedQueryParams = caseParams(queryParams, paramsCasing)\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 = node.parameters.filter((p) => p.in === 'header')\n if (headerParams.length > 0) {\n const casedHeaderParams = caseParams(headerParams, paramsCasing)\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?.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\nRequest.getParams = getParams\n","import path from 'node:path'\nimport { caseParams } from '@kubb/ast'\nimport { defineGenerator } from '@kubb/core'\nimport type { PluginTs } from '@kubb/plugin-ts'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport { Request } from '../components/Request.tsx'\nimport type { PluginCypress } from '../types.ts'\n\nexport const cypressGenerator = defineGenerator<PluginCypress>({\n name: 'cypress',\n type: 'react',\n Operation({ node, adapter, options, config, driver, resolver }) {\n const { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType, group } = options\n const root = path.resolve(config.root, config.output.path)\n\n const pluginTs = driver.getPlugin<PluginTs>(pluginTsName)\n\n if (!pluginTs) {\n return null\n }\n\n const file = resolver.resolveFile({ name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path }, { root, output, group })\n const tsFile = pluginTs.resolver.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\n const name = resolver.resolveName(node.operationId)\n\n const casedParams = caseParams(node.parameters, paramsCasing)\n const tsResolver = pluginTs.resolver\n\n const pathParams = casedParams.filter((p) => p.in === 'path')\n const queryParams = casedParams.filter((p) => p.in === 'query')\n const headerParams = casedParams.filter((p) => p.in === 'header')\n\n const importedTypeNames = [\n ...(pathParams.length && tsResolver.resolvePathParamsName\n ? pathParams.map((p) => tsResolver.resolvePathParamsName!(node, p))\n : pathParams.map((p) => tsResolver.resolveParamName(node, p))),\n ...(queryParams.length && tsResolver.resolveQueryParamsName\n ? queryParams.map((p) => tsResolver.resolveQueryParamsName!(node, p))\n : queryParams.map((p) => tsResolver.resolveParamName(node, p))),\n ...(headerParams.length && tsResolver.resolveHeaderParamsName\n ? headerParams.map((p) => tsResolver.resolveHeaderParamsName!(node, p))\n : headerParams.map((p) => tsResolver.resolveParamName(node, p))),\n node.requestBody?.schema ? tsResolver.resolveDataName(node) : undefined,\n tsResolver.resolveResponseName(node),\n ].filter(Boolean)\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={resolver.resolveBanner(adapter.rootNode, { output, config })}\n footer={resolver.resolveFooter(adapter.rootNode, { output, config })}\n >\n {tsFile && importedTypeNames.length > 0 && <File.Import name={Array.from(new Set(importedTypeNames))} root={file.path} path={tsFile.path} isTypeOnly />}\n <Request\n name={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 * Resolver for `@kubb/plugin-cypress` that provides the default naming\n * and path-resolution helpers used by the plugin.\n *\n * @example\n * ```ts\n * import { resolverCypress } from '@kubb/plugin-cypress'\n *\n * resolverCypress.default('list pets', 'function') // -> 'listPets'\n * resolverCypress.resolveName('show pet by id') // -> 'showPetById'\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}))\n","import { definePresets } from '@kubb/core'\nimport { cypressGenerator } from './generators/cypressGenerator.tsx'\nimport { resolverCypress } from './resolvers/resolverCypress.ts'\nimport type { ResolverCypress } from './types.ts'\n\n/**\n * Built-in preset registry for `@kubb/plugin-cypress`.\n *\n * - `default` — uses `resolverCypress` and `cypressGenerator`.\n * - `kubbV4` — uses `resolverCypress` and `cypressGenerator`.\n */\nexport const presets = definePresets<ResolverCypress>({\n default: {\n name: 'default',\n resolvers: [resolverCypress],\n generators: [cypressGenerator],\n },\n kubbV4: {\n name: 'kubbV4',\n resolvers: [resolverCypress],\n generators: [cypressGenerator],\n },\n})\n","import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { walk } from '@kubb/ast'\nimport { createPlugin, type Group, getBarrelFiles, getPreset, renderOperation } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { presets } from './presets.ts'\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 = createPlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n dataReturnType = 'data',\n exclude = [],\n include,\n override = [],\n baseURL,\n paramsCasing,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n compatibilityPreset = 'default',\n resolvers: userResolvers = [],\n transformers: userTransformers = [],\n generators: userGenerators = [],\n } = options\n\n const preset = getPreset({\n preset: compatibilityPreset,\n presets,\n resolvers: [resolverCypress, ...userResolvers],\n transformers: userTransformers,\n generators: userGenerators,\n })\n\n return {\n name: pluginCypressName,\n get resolver() {\n return preset.resolver\n },\n get options() {\n return {\n output,\n dataReturnType,\n group: group\n ? ({\n ...options.group,\n name: options.group?.name\n ? options.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 } as Group)\n : undefined,\n baseURL,\n paramsCasing,\n paramsType,\n pathParamsType,\n resolver: preset.resolver,\n transformers: preset.transformers,\n }\n },\n pre: [pluginTsName].filter(Boolean),\n async install() {\n const { config, fabric, plugin, adapter, rootNode, driver } = this\n const root = path.resolve(config.root, config.output.path)\n const resolver = preset.resolver\n\n if (!adapter) {\n throw new Error('Plugin cannot work without adapter being set')\n }\n\n await walk(rootNode, {\n depth: 'shallow',\n async operation(operationNode) {\n const writeTasks = preset.generators.map(async (generator) => {\n if (generator.type === 'react' && generator.version === '2') {\n const resolvedOptions = resolver.resolveOptions(operationNode, {\n options: plugin.options,\n exclude,\n include,\n override,\n })\n\n if (resolvedOptions === null) {\n return\n }\n\n await renderOperation(operationNode, {\n options: resolvedOptions,\n adapter,\n config,\n fabric,\n Component: generator.Operation,\n plugin,\n driver,\n resolver,\n })\n }\n })\n\n await Promise.all(writeTasks)\n },\n })\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;AAS9D,QARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAAQ,CAEV,MAAM,gBAAgB,CAAC,OAAO,QAAQ,CAG5D,KAAK,MAAM,MAAM;AAEhB,MADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACjD,QAAO;AACrB,MAAI,MAAM,KAAK,CAAC,OAAQ,QAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;AAC3E,SAAO,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;AAC1C,QAAO,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;AAClG,KAAI,OACF,QAAO,iBAAiB,OAAO,MAAM,WAAW,UAAU,MAAM,SAAS;EAAE;EAAQ;EAAQ,GAAG,EAAE,CAAC,CAAC;AAGpG,QAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,MAAM;;;;;;;;;;;;;;ACgD9D,SAAgB,eAAe,MA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Cypress, t as Options } from "./types-BzXXi6dv.js";
3
- import * as _kubb_core0 from "@kubb/core";
2
+ import { ResolverTs } from "@kubb/plugin-ts";
3
+ import * as _$_kubb_core0 from "@kubb/core";
4
+ import { CompatibilityPreset, Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, ResolvePathOptions, Resolver, UserGroup } from "@kubb/core";
5
+ import { OperationNode, Visitor } from "@kubb/ast/types";
6
+ import { FabricReactNode } from "@kubb/react-fabric/types";
4
7
 
8
+ //#region src/types.d.ts
9
+ /**
10
+ * The concrete resolver type for `@kubb/plugin-cypress`.
11
+ * Extends the base `Resolver` with a `resolveName` helper for operation function names.
12
+ */
13
+ type ResolverCypress = Resolver & {
14
+ /**
15
+ * Resolves the function name for a given raw operation name.
16
+ * @example
17
+ * resolver.resolveName('show pet by id') // -> 'showPetById'
18
+ */
19
+ resolveName(name: string): string;
20
+ };
21
+ /**
22
+ * Discriminated union that ties `pathParamsType` to the `paramsType` values where it is meaningful.
23
+ *
24
+ * - `paramsType: 'object'` — all parameters (including path params) are merged into a single
25
+ * destructured object. `pathParamsType` is never reached in this code path and has no effect.
26
+ * - `paramsType?: 'inline'` (or omitted) — each parameter group is a separate function argument.
27
+ * `pathParamsType` controls whether the path-param group itself is destructured (`'object'`)
28
+ * or spread as individual arguments (`'inline'`).
29
+ */
30
+ type ParamsTypeOptions = {
31
+ /**
32
+ * All parameters — path, query, headers, and body — are merged into a single
33
+ * destructured object argument.
34
+ * - 'object' returns the params and pathParams as an object.
35
+ * @default 'inline'
36
+ */
37
+ paramsType: 'object';
38
+ /**
39
+ * `pathParamsType` has no effect when `paramsType` is `'object'`.
40
+ * Path params are already inside the single destructured object.
41
+ */
42
+ pathParamsType?: never;
43
+ } | {
44
+ /**
45
+ * Each parameter group is emitted as a separate function argument.
46
+ * - 'inline' returns the params as comma separated params.
47
+ * @default 'inline'
48
+ */
49
+ paramsType?: 'inline';
50
+ /**
51
+ * Controls how path parameters are arranged within the inline argument list.
52
+ * - 'object' groups path params into a destructured object: `{ petId }: PathParams`.
53
+ * - 'inline' emits each path param as its own argument: `petId: string`.
54
+ * @default 'inline'
55
+ */
56
+ pathParamsType?: 'object' | 'inline';
57
+ };
58
+ type Options = {
59
+ /**
60
+ * Specify the export location for the files and define the behavior of the output.
61
+ * @default { path: 'cypress', barrelType: 'named' }
62
+ */
63
+ output?: Output;
64
+ /**
65
+ * Return type when calling cy.request.
66
+ * - 'data' returns ResponseConfig[data].
67
+ * - 'full' returns ResponseConfig.
68
+ * @default 'data'
69
+ */
70
+ dataReturnType?: 'data' | 'full';
71
+ /**
72
+ * How to style your params, by default no casing is applied.
73
+ * - 'camelcase' uses camelCase for the params names.
74
+ */
75
+ paramsCasing?: 'camelcase';
76
+ /**
77
+ * Base URL prepended to every generated request URL.
78
+ */
79
+ baseURL?: string;
80
+ /**
81
+ * Group the Cypress requests based on the provided name.
82
+ */
83
+ group?: UserGroup;
84
+ /**
85
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
86
+ */
87
+ exclude?: Array<Exclude>;
88
+ /**
89
+ * Array containing include parameters to include tags/operations/methods/paths.
90
+ */
91
+ include?: Array<Include>;
92
+ /**
93
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
94
+ */
95
+ override?: Array<Override<ResolvedOptions>>;
96
+ /**
97
+ * Apply a compatibility naming preset.
98
+ * @default 'default'
99
+ */
100
+ compatibilityPreset?: CompatibilityPreset;
101
+ /**
102
+ * Array of named resolvers that control naming conventions.
103
+ * Later entries override earlier ones (last wins).
104
+ * @default [resolverCypress]
105
+ */
106
+ resolvers?: Array<ResolverCypress>;
107
+ /**
108
+ * Array of AST visitors applied to each node before printing.
109
+ * Uses `transform()` from `@kubb/ast`.
110
+ */
111
+ transformers?: Array<Visitor>;
112
+ /**
113
+ * Define some generators next to the default generators.
114
+ */
115
+ generators?: Array<Generator<PluginCypress>>;
116
+ } & ParamsTypeOptions;
117
+ type ResolvedOptions = {
118
+ output: Output;
119
+ group: Group | undefined;
120
+ baseURL: Options['baseURL'] | undefined;
121
+ dataReturnType: NonNullable<Options['dataReturnType']>;
122
+ pathParamsType: NonNullable<NonNullable<Options['pathParamsType']>>;
123
+ paramsType: NonNullable<Options['paramsType']>;
124
+ paramsCasing: Options['paramsCasing'];
125
+ resolver: ResolverCypress;
126
+ transformers: Array<Visitor>;
127
+ };
128
+ type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options, ResolvedOptions, never, ResolvePathOptions, ResolverCypress>;
129
+ //#endregion
130
+ //#region src/components/Request.d.ts
131
+ type Props = {
132
+ /**
133
+ * Name of the function
134
+ */
135
+ name: string;
136
+ /**
137
+ * AST operation node
138
+ */
139
+ node: OperationNode;
140
+ /**
141
+ * TypeScript resolver for resolving param/data/response type names
142
+ */
143
+ resolver: ResolverTs;
144
+ baseURL: string | undefined;
145
+ dataReturnType: PluginCypress['resolvedOptions']['dataReturnType'];
146
+ paramsCasing: PluginCypress['resolvedOptions']['paramsCasing'];
147
+ paramsType: PluginCypress['resolvedOptions']['paramsType'];
148
+ pathParamsType: PluginCypress['resolvedOptions']['pathParamsType'];
149
+ };
150
+ declare function Request({
151
+ baseURL,
152
+ name,
153
+ dataReturnType,
154
+ resolver,
155
+ node,
156
+ paramsType,
157
+ pathParamsType,
158
+ paramsCasing
159
+ }: Props): FabricReactNode;
160
+ declare namespace Request {
161
+ var getParams: ({
162
+ paramsType,
163
+ pathParamsType,
164
+ paramsCasing,
165
+ resolver,
166
+ node
167
+ }: {
168
+ paramsType: PluginCypress["resolvedOptions"]["paramsType"];
169
+ pathParamsType: PluginCypress["resolvedOptions"]["pathParamsType"];
170
+ paramsCasing: PluginCypress["resolvedOptions"]["paramsCasing"];
171
+ resolver: ResolverTs;
172
+ node: OperationNode;
173
+ }) => string;
174
+ }
175
+ //#endregion
176
+ //#region src/generators/cypressGenerator.d.ts
177
+ declare const cypressGenerator: _$_kubb_core0.ReactGeneratorV2<PluginCypress>;
178
+ //#endregion
5
179
  //#region src/plugin.d.ts
180
+ /**
181
+ * Canonical plugin name for `@kubb/plugin-cypress`, used to identify the plugin
182
+ * in driver lookups and warnings.
183
+ */
6
184
  declare const pluginCypressName = "plugin-cypress";
7
- declare const pluginCypress: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginCypress>;
185
+ /**
186
+ * The `@kubb/plugin-cypress` plugin factory.
187
+ *
188
+ * Generates Cypress `cy.request()` test functions from an OpenAPI/AST `RootNode`.
189
+ * Walks operations, delegates rendering to the active generators,
190
+ * and writes barrel files based on `output.barrelType`.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * import { pluginCypress } from '@kubb/plugin-cypress'
195
+ *
196
+ * export default defineConfig({
197
+ * plugins: [pluginCypress({ output: { path: 'cypress' } })],
198
+ * })
199
+ * ```
200
+ */
201
+ declare const pluginCypress: (options?: Options | undefined) => _$_kubb_core0.UserPluginWithLifeCycle<PluginCypress>;
202
+ //#endregion
203
+ //#region src/resolvers/resolverCypress.d.ts
204
+ /**
205
+ * Resolver for `@kubb/plugin-cypress` that provides the default naming
206
+ * and path-resolution helpers used by the plugin.
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * import { resolverCypress } from '@kubb/plugin-cypress'
211
+ *
212
+ * resolverCypress.default('list pets', 'function') // -> 'listPets'
213
+ * resolverCypress.resolveName('show pet by id') // -> 'showPetById'
214
+ * ```
215
+ */
216
+ declare const resolverCypress: ResolverCypress;
8
217
  //#endregion
9
- export { type PluginCypress, pluginCypress, pluginCypressName };
218
+ export { type PluginCypress, Request, type ResolverCypress, cypressGenerator, pluginCypress, pluginCypressName, resolverCypress };
10
219
  //# sourceMappingURL=index.d.ts.map