@kubb/plugin-cypress 5.0.0-alpha.8 → 5.0.0-beta.3

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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,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","ast","File","Function","jsxRenderer","pluginTsName","ast","File","pluginTsName"],"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/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.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 { 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 | 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 = ast.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 = ast.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 = ast.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?.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 { ast, defineGenerator } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Request } from '../components/Request.tsx'\nimport type { PluginCypress } from '../types.ts'\n\nexport const cypressGenerator = defineGenerator<PluginCypress>({\n name: 'cypress',\n renderer: jsxRenderer,\n operation(node, ctx) {\n const { adapter, 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 casedParams = ast.caseParams(node.parameters, paramsCasing)\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.map((p) => tsResolver.resolvePathParamsName(node, p)),\n ...queryParams.map((p) => tsResolver.resolveQueryParamsName(node, p)),\n ...headerParams.map((p) => tsResolver.resolveHeaderParamsName(node, p)),\n node.requestBody?.content?.[0]?.schema ? tsResolver.resolveDataName(node) : undefined,\n tsResolver.resolveResponseName(node),\n ].filter(Boolean)\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(adapter.inputNode, { output, config })}\n footer={resolver.resolveFooter(adapter.inputNode, { output, config })}\n >\n {meta.fileTs && importedTypeNames.length > 0 && (\n <File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />\n )}\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>((ctx) => ({\n name: 'default',\n pluginName: 'plugin-cypress',\n default(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n resolveName(name) {\n return ctx.default(name, 'function')\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;AAS9D,QARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAEH,CAAC,MAAM,gBAAgB,CAAC,OAAO,QAE3C,CACT,KAAK,MAAM,MAAM;AAEhB,MADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACjD,QAAO;AACrB,MAAI,MA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Aa,iBAAA,GAAA,WAAA,eAA6C,YAAY;CACpE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,iBAAiB,QACjB,SACA,cACA,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,UAAU,cACV,aAAa,iBACb,YAAY,iBAAiB,EAAE,KAC7B;CAEJ,MAAM,cAAc,QACf;EACC,GAAG;EACH,MAAM,MAAM,OACR,MAAM,QACL,QAA2B;AAC1B,OAAI,MAAM,SAAS,OACjB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,UAAO,GAAG,UAAU,IAAI,MAAM,CAAC;;EAEtC,GACD,KAAA;AAEJ,QAAO;EACL,MAAM;EACN;EACA,cAAc,CAACC,gBAAAA,aAAa;EAC5B,OAAO,EACL,oBAAoB,KAAK;GACvB,MAAM,WAAW,eAAe;IAAE,GAAG;IAAiB,GAAG;IAAc,GAAG;AAE1E,OAAI,WAAW;IACb;IACA;IACA;IACA;IACA;IACA,OAAO;IACP;IACA;IACA;IACA;IACA;IACD,CAAC;AACF,OAAI,YAAY,SAAS;AACzB,OAAI,gBACF,KAAI,eAAe,gBAAgB;AAErC,OAAI,aAAa,iBAAiB;AAClC,QAAK,MAAM,OAAO,eAChB,KAAI,aAAa,IAAI;KAG1B;EACF;EACD"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,185 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { n as PluginCypress, t as Options } from "./types-DGvL0jsn.js";
3
- import * as _kubb_core0 from "@kubb/core";
2
+ import * as _$_kubb_core0 from "@kubb/core";
3
+ import { Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
4
+ import { ResolverTs } from "@kubb/plugin-ts";
5
+ import { KubbReactNode } from "@kubb/renderer-jsx/types";
4
6
 
7
+ //#region src/types.d.ts
8
+ /**
9
+ * Resolver for Cypress that provides naming methods for test functions.
10
+ */
11
+ type ResolverCypress = Resolver & {
12
+ /**
13
+ * Resolves the function name for an operation.
14
+ *
15
+ * @example Resolving function names
16
+ * `resolver.resolveName('show pet by id') // -> 'showPetById'`
17
+ */
18
+ resolveName(this: ResolverCypress, name: string): string;
19
+ };
20
+ /**
21
+ * Parameter handling mode that determines how path params and query/body params are arranged in function signatures.
22
+ */
23
+ type ParamsTypeOptions = {
24
+ /**
25
+ * All parameters merged into a single destructured object.
26
+ */
27
+ paramsType: 'object';
28
+ /**
29
+ * Not applicable when all parameters are merged into a single object.
30
+ */
31
+ pathParamsType?: never;
32
+ } | {
33
+ /**
34
+ * Each parameter group emitted as a separate function argument.
35
+ */
36
+ paramsType?: 'inline';
37
+ /**
38
+ * How path parameters are arranged: grouped in an object or spread inline.
39
+ *
40
+ * @default 'inline'
41
+ */
42
+ pathParamsType?: 'object' | 'inline';
43
+ };
44
+ type Options = {
45
+ /**
46
+ * Specify the export location for the files and define the behavior of the output.
47
+ * @default { path: 'cypress', barrelType: 'named' }
48
+ */
49
+ output?: Output;
50
+ /**
51
+ * Return type when calling cy.request: response data only or full response.
52
+ *
53
+ * @default 'data'
54
+ */
55
+ dataReturnType?: 'data' | 'full';
56
+ /**
57
+ * Apply casing to parameter names.
58
+ */
59
+ paramsCasing?: 'camelcase';
60
+ /**
61
+ * Base URL prepended to every generated request URL.
62
+ */
63
+ baseURL?: string;
64
+ /**
65
+ * Group the Cypress requests based on the provided name.
66
+ */
67
+ group?: Group;
68
+ /**
69
+ * Tags, operations, or paths to exclude from generation.
70
+ */
71
+ exclude?: Array<Exclude>;
72
+ /**
73
+ * Tags, operations, or paths to include in generation.
74
+ */
75
+ include?: Array<Include>;
76
+ /**
77
+ * Override options for specific tags, operations, or paths.
78
+ */
79
+ override?: Array<Override<ResolvedOptions>>;
80
+ /**
81
+ * Override naming conventions for function names and types.
82
+ */
83
+ resolver?: Partial<ResolverCypress> & ThisType<ResolverCypress>;
84
+ /**
85
+ * AST visitor to transform generated nodes.
86
+ */
87
+ transformer?: ast.Visitor;
88
+ /**
89
+ * Additional generators alongside the default generators.
90
+ */
91
+ generators?: Array<Generator<PluginCypress>>;
92
+ } & ParamsTypeOptions;
93
+ type ResolvedOptions = {
94
+ output: Output;
95
+ exclude: Array<Exclude>;
96
+ include: Array<Include> | undefined;
97
+ override: Array<Override<ResolvedOptions>>;
98
+ group: Group | undefined;
99
+ baseURL: Options['baseURL'] | undefined;
100
+ dataReturnType: NonNullable<Options['dataReturnType']>;
101
+ pathParamsType: NonNullable<NonNullable<Options['pathParamsType']>>;
102
+ paramsType: NonNullable<Options['paramsType']>;
103
+ paramsCasing: Options['paramsCasing'];
104
+ resolver: ResolverCypress;
105
+ };
106
+ type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options, ResolvedOptions, ResolverCypress>;
107
+ declare global {
108
+ namespace Kubb {
109
+ interface PluginRegistry {
110
+ 'plugin-cypress': PluginCypress;
111
+ }
112
+ }
113
+ }
114
+ //#endregion
115
+ //#region src/components/Request.d.ts
116
+ type Props = {
117
+ /**
118
+ * Name of the function
119
+ */
120
+ name: string;
121
+ /**
122
+ * AST operation node
123
+ */
124
+ node: ast.OperationNode;
125
+ /**
126
+ * TypeScript resolver for resolving param/data/response type names
127
+ */
128
+ resolver: ResolverTs;
129
+ baseURL: string | undefined;
130
+ dataReturnType: PluginCypress['resolvedOptions']['dataReturnType'];
131
+ paramsCasing: PluginCypress['resolvedOptions']['paramsCasing'];
132
+ paramsType: PluginCypress['resolvedOptions']['paramsType'];
133
+ pathParamsType: PluginCypress['resolvedOptions']['pathParamsType'];
134
+ };
135
+ declare function Request({
136
+ baseURL,
137
+ name,
138
+ dataReturnType,
139
+ resolver,
140
+ node,
141
+ paramsType,
142
+ pathParamsType,
143
+ paramsCasing
144
+ }: Props): KubbReactNode;
145
+ //#endregion
146
+ //#region src/generators/cypressGenerator.d.ts
147
+ declare const cypressGenerator: _$_kubb_core0.Generator<PluginCypress, unknown>;
148
+ //#endregion
5
149
  //#region src/plugin.d.ts
150
+ /**
151
+ * Canonical plugin name for `@kubb/plugin-cypress`, used to identify the plugin
152
+ * in driver lookups and warnings.
153
+ */
6
154
  declare const pluginCypressName = "plugin-cypress";
7
- declare const pluginCypress: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginCypress>;
155
+ /**
156
+ * The `@kubb/plugin-cypress` plugin factory.
157
+ *
158
+ * Generates Cypress `cy.request()` test functions from an OpenAPI/AST `RootNode`.
159
+ * Walks operations, delegates rendering to the active generators,
160
+ * and writes barrel files based on `output.barrelType`.
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * import pluginCypress from '@kubb/plugin-cypress'
165
+ *
166
+ * export default defineConfig({
167
+ * plugins: [pluginCypress({ output: { path: 'cypress' } })],
168
+ * })
169
+ * ```
170
+ */
171
+ declare const pluginCypress: (options?: Options | undefined) => _$_kubb_core0.Plugin<PluginCypress>;
172
+ //#endregion
173
+ //#region src/resolvers/resolverCypress.d.ts
174
+ /**
175
+ * Naming convention resolver for Cypress plugin.
176
+ *
177
+ * Provides default naming helpers using camelCase for functions and file paths.
178
+ *
179
+ * @example
180
+ * `resolverCypress.default('list pets', 'function') // → 'listPets'`
181
+ */
182
+ declare const resolverCypress: ResolverCypress;
8
183
  //#endregion
9
- export { type PluginCypress, pluginCypress, pluginCypressName };
184
+ export { type PluginCypress, Request, type ResolverCypress, cypressGenerator, pluginCypress as default, pluginCypress, pluginCypressName, resolverCypress };
10
185
  //# sourceMappingURL=index.d.ts.map