@kubb/plugin-cypress 5.0.0-alpha.26 → 5.0.0-alpha.28
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 +15 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -24
- package/dist/index.js +16 -24
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/Request.tsx +2 -21
- package/src/generators/cypressGenerator.tsx +5 -5
- package/src/plugin.ts +7 -6
- package/src/presets.ts +2 -2
- package/src/types.ts +7 -9
package/dist/index.cjs
CHANGED
|
@@ -239,7 +239,7 @@ var URLPath = class {
|
|
|
239
239
|
//#endregion
|
|
240
240
|
//#region src/components/Request.tsx
|
|
241
241
|
const declarationPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
242
|
-
function
|
|
242
|
+
function Request({ baseURL = "", name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }) {
|
|
243
243
|
const paramsNode = (0, _kubb_ast.createOperationParams)(node, {
|
|
244
244
|
paramsType,
|
|
245
245
|
pathParamsType,
|
|
@@ -254,16 +254,7 @@ function getParams({ paramsType, pathParamsType, paramsCasing, resolver, node })
|
|
|
254
254
|
default: "{}"
|
|
255
255
|
})]
|
|
256
256
|
});
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
function Request({ baseURL = "", name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }) {
|
|
260
|
-
const paramsSignature = getParams({
|
|
261
|
-
paramsType,
|
|
262
|
-
pathParamsType,
|
|
263
|
-
paramsCasing,
|
|
264
|
-
resolver,
|
|
265
|
-
node
|
|
266
|
-
});
|
|
257
|
+
const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
|
|
267
258
|
const responseType = resolver.resolveResponseName(node);
|
|
268
259
|
const returnType = dataReturnType === "data" ? `Cypress.Chainable<${responseType}>` : `Cypress.Chainable<Cypress.Response<${responseType}>>`;
|
|
269
260
|
const casedPathParams = (0, _kubb_ast.caseParams)(node.parameters.filter((p) => p.in === "path"), paramsCasing);
|
|
@@ -308,18 +299,17 @@ function Request({ baseURL = "", name, dataReturnType, resolver, node, paramsTyp
|
|
|
308
299
|
})
|
|
309
300
|
});
|
|
310
301
|
}
|
|
311
|
-
Request.getParams = getParams;
|
|
312
302
|
//#endregion
|
|
313
303
|
//#region src/generators/cypressGenerator.tsx
|
|
314
304
|
const cypressGenerator = (0, _kubb_core.defineGenerator)({
|
|
315
305
|
name: "cypress",
|
|
316
306
|
type: "react",
|
|
317
|
-
Operation({ node, adapter, options, config, driver, resolver }) {
|
|
318
|
-
const { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType, group
|
|
307
|
+
Operation({ node, adapter, options, config, driver, resolver, plugin }) {
|
|
308
|
+
const { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType, group } = options;
|
|
319
309
|
const root = node_path.default.resolve(config.root, config.output.path);
|
|
320
310
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
321
|
-
if (!pluginTs) return null;
|
|
322
|
-
const transformedNode = (0, _kubb_ast.transform)(node,
|
|
311
|
+
if (!pluginTs?.resolver) return null;
|
|
312
|
+
const transformedNode = plugin.transformer ? (0, _kubb_ast.transform)(node, plugin.transformer) : node;
|
|
323
313
|
const casedParams = (0, _kubb_ast.caseParams)(transformedNode.parameters, paramsCasing);
|
|
324
314
|
const pathParams = casedParams.filter((p) => p.in === "path");
|
|
325
315
|
const queryParams = casedParams.filter((p) => p.in === "query");
|
|
@@ -419,12 +409,12 @@ const resolverCypress = (0, _kubb_core.defineResolver)(() => ({
|
|
|
419
409
|
const presets = (0, _kubb_core.definePresets)({
|
|
420
410
|
default: {
|
|
421
411
|
name: "default",
|
|
422
|
-
|
|
412
|
+
resolver: resolverCypress,
|
|
423
413
|
generators: [cypressGenerator]
|
|
424
414
|
},
|
|
425
415
|
kubbV4: {
|
|
426
416
|
name: "kubbV4",
|
|
427
|
-
|
|
417
|
+
resolver: resolverCypress,
|
|
428
418
|
generators: [cypressGenerator]
|
|
429
419
|
}
|
|
430
420
|
});
|
|
@@ -455,12 +445,12 @@ const pluginCypress = (0, _kubb_core.createPlugin)((options) => {
|
|
|
455
445
|
const { output = {
|
|
456
446
|
path: "cypress",
|
|
457
447
|
barrelType: "named"
|
|
458
|
-
}, group, dataReturnType = "data", exclude = [], include, override = [], baseURL, paramsCasing, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", compatibilityPreset = "default",
|
|
448
|
+
}, group, dataReturnType = "data", exclude = [], include, override = [], baseURL, paramsCasing, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", compatibilityPreset = "default", resolver: userResolver, transformer: userTransformer, generators: userGenerators = [] } = options;
|
|
459
449
|
const preset = (0, _kubb_core.getPreset)({
|
|
460
450
|
preset: compatibilityPreset,
|
|
461
451
|
presets,
|
|
462
|
-
|
|
463
|
-
|
|
452
|
+
resolver: userResolver,
|
|
453
|
+
transformer: userTransformer,
|
|
464
454
|
generators: userGenerators
|
|
465
455
|
});
|
|
466
456
|
return {
|
|
@@ -468,6 +458,9 @@ const pluginCypress = (0, _kubb_core.createPlugin)((options) => {
|
|
|
468
458
|
get resolver() {
|
|
469
459
|
return preset.resolver;
|
|
470
460
|
},
|
|
461
|
+
get transformer() {
|
|
462
|
+
return preset.transformer;
|
|
463
|
+
},
|
|
471
464
|
get options() {
|
|
472
465
|
return {
|
|
473
466
|
output,
|
|
@@ -483,8 +476,7 @@ const pluginCypress = (0, _kubb_core.createPlugin)((options) => {
|
|
|
483
476
|
paramsCasing,
|
|
484
477
|
paramsType,
|
|
485
478
|
pathParamsType,
|
|
486
|
-
resolver: preset.resolver
|
|
487
|
-
transformers: preset.transformers
|
|
479
|
+
resolver: preset.resolver
|
|
488
480
|
};
|
|
489
481
|
},
|
|
490
482
|
pre: [_kubb_plugin_ts.pluginTsName].filter(Boolean),
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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, composeTransformers, transform } 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, transformers } = 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 transformedNode = transform(node, composeTransformers(...transformers))\n\n const casedParams = caseParams(transformedNode.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) => pluginTs.resolver.resolvePathParamsName(transformedNode, p)),\n ...queryParams.map((p) => pluginTs.resolver.resolveQueryParamsName(transformedNode, p)),\n ...headerParams.map((p) => pluginTs.resolver.resolveHeaderParamsName(transformedNode, p)),\n transformedNode.requestBody?.schema ? pluginTs.resolver.resolveDataName(transformedNode) : undefined,\n pluginTs.resolver.resolveResponseName(transformedNode),\n ].filter(Boolean)\n\n const meta = {\n name: resolver.resolveName(transformedNode.operationId),\n file: resolver.resolveFile(\n { name: transformedNode.operationId, extname: '.ts', tag: transformedNode.tags[0] ?? 'default', path: transformedNode.path },\n { root, output, group },\n ),\n fileTs: pluginTs.resolver.resolveFile(\n { name: transformedNode.operationId, extname: '.ts', tag: transformedNode.tags[0] ?? 'default', path: transformedNode.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.rootNode, { output, config })}\n footer={resolver.resolveFooter(adapter.rootNode, { 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={transformedNode}\n resolver={pluginTs.resolver}\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 type { OperationNode } from '@kubb/ast/types'\nimport { createPlugin, type Group, getBarrelFiles, getPreset, runGeneratorOperation, runGeneratorOperations, runGeneratorSchema } 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 ...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 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 const collectedOperations: Array<OperationNode> = []\n const generatorContext = { generators: preset.generators, plugin, resolver, exclude, include, override, fabric, adapter, config, driver }\n\n await walk(rootNode, {\n depth: 'shallow',\n async schema(schemaNode) {\n await runGeneratorSchema(schemaNode, generatorContext)\n },\n async operation(operationNode) {\n const baseOptions = resolver.resolveOptions(operationNode, { options: plugin.options, exclude, include, override })\n\n if (baseOptions !== null) {\n collectedOperations.push(operationNode)\n }\n\n await runGeneratorOperation(operationNode, generatorContext)\n },\n })\n\n await runGeneratorOperations(collectedOperations, generatorContext)\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,MAAuB;AACpD,KAAI;AACF,MAAI,SAAS,OAAO,OAAO;SACrB;AACN,SAAO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AC;;KAEtC,GACD,KAAA;IACJ;IACA;IACA;IACA;IACA,UAAU,OAAO;IACjB,cAAc,OAAO;IACtB;;EAEH,KAAK,CAACC,gBAAAA,aAAa,CAAC,OAAO,QAAQ;EACnC,MAAM,UAAU;GACd,MAAM,EAAE,QAAQ,QAAQ,QAAQ,SAAS,UAAU,WAAW;GAC9D,MAAM,OAAOC,UAAAA,QAAK,QAAQ,OAAO,MAAM,OAAO,OAAO,KAAK;GAC1D,MAAM,WAAW,OAAO;AAExB,OAAI,CAAC,QACH,OAAM,IAAI,MAAM,+CAA+C;GAGjE,MAAM,sBAA4C,EAAE;GACpD,MAAM,mBAAmB;IAAE,YAAY,OAAO;IAAY;IAAQ;IAAU;IAAS;IAAS;IAAU;IAAQ;IAAS;IAAQ;IAAQ;AAEzI,UAAA,GAAA,UAAA,MAAW,UAAU;IACnB,OAAO;IACP,MAAM,OAAO,YAAY;AACvB,YAAA,GAAA,WAAA,oBAAyB,YAAY,iBAAiB;;IAExD,MAAM,UAAU,eAAe;AAG7B,SAFoB,SAAS,eAAe,eAAe;MAAE,SAAS,OAAO;MAAS;MAAS;MAAS;MAAU,CAAC,KAE/F,KAClB,qBAAoB,KAAK,cAAc;AAGzC,YAAA,GAAA,WAAA,uBAA4B,eAAe,iBAAiB;;IAE/D,CAAC;AAEF,UAAA,GAAA,WAAA,wBAA6B,qBAAqB,iBAAiB;GAEnE,MAAM,cAAc,OAAA,GAAA,WAAA,gBAAqB,KAAK,OAAO,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\nexport function Request({ baseURL = '', name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }: Props): FabricReactNode {\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 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 = 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","import path from 'node:path'\nimport { caseParams, transform } 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, plugin }) {\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?.resolver) {\n return null\n }\n\n const transformedNode = plugin.transformer ? transform(node, plugin.transformer) : node\n\n const casedParams = caseParams(transformedNode.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) => pluginTs.resolver.resolvePathParamsName(transformedNode, p)),\n ...queryParams.map((p) => pluginTs.resolver.resolveQueryParamsName(transformedNode, p)),\n ...headerParams.map((p) => pluginTs.resolver.resolveHeaderParamsName(transformedNode, p)),\n transformedNode.requestBody?.schema ? pluginTs.resolver.resolveDataName(transformedNode) : undefined,\n pluginTs.resolver.resolveResponseName(transformedNode),\n ].filter(Boolean)\n\n const meta = {\n name: resolver.resolveName(transformedNode.operationId),\n file: resolver.resolveFile(\n { name: transformedNode.operationId, extname: '.ts', tag: transformedNode.tags[0] ?? 'default', path: transformedNode.path },\n { root, output, group },\n ),\n fileTs: pluginTs.resolver.resolveFile(\n { name: transformedNode.operationId, extname: '.ts', tag: transformedNode.tags[0] ?? 'default', path: transformedNode.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.rootNode, { output, config })}\n footer={resolver.resolveFooter(adapter.rootNode, { 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={transformedNode}\n resolver={pluginTs.resolver}\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 resolver: resolverCypress,\n generators: [cypressGenerator],\n },\n kubbV4: {\n name: 'kubbV4',\n resolver: resolverCypress,\n generators: [cypressGenerator],\n },\n})\n","import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { walk } from '@kubb/ast'\nimport type { OperationNode } from '@kubb/ast/types'\nimport { createPlugin, type Group, getBarrelFiles, getPreset, runGeneratorOperation, runGeneratorOperations, runGeneratorSchema } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { presets } from './presets.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 resolver: userResolver,\n transformer: userTransformer,\n generators: userGenerators = [],\n } = options\n\n const preset = getPreset({\n preset: compatibilityPreset,\n presets,\n resolver: userResolver,\n transformer: userTransformer,\n generators: userGenerators,\n })\n\n return {\n name: pluginCypressName,\n get resolver() {\n return preset.resolver\n },\n get transformer() {\n return preset.transformer\n },\n get options() {\n return {\n output,\n dataReturnType,\n group: 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 baseURL,\n paramsCasing,\n paramsType,\n pathParamsType,\n resolver: preset.resolver,\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 const collectedOperations: Array<OperationNode> = []\n const generatorContext = { generators: preset.generators, plugin, resolver, exclude, include, override, fabric, adapter, config, driver }\n\n await walk(rootNode, {\n depth: 'shallow',\n async schema(schemaNode) {\n await runGeneratorSchema(schemaNode, generatorContext)\n },\n async operation(operationNode) {\n const baseOptions = resolver.resolveOptions(operationNode, { options: plugin.options, exclude, include, override })\n\n if (baseOptions !== null) {\n collectedOperations.push(operationNode)\n }\n\n await runGeneratorOperation(operationNode, generatorContext)\n },\n })\n\n await runGeneratorOperations(collectedOperations, generatorContext)\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,OA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KAAK,cAAc;AAGzC,YAAA,GAAA,WAAA,uBAA4B,eAAe,iBAAiB;;IAE/D,CAAC;AAEF,UAAA,GAAA,WAAA,wBAA6B,qBAAqB,iBAAiB;GAEnE,MAAM,cAAc,OAAA,GAAA,WAAA,gBAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ type ResolverCypress = Resolver & {
|
|
|
16
16
|
* @example
|
|
17
17
|
* resolver.resolveName('show pet by id') // -> 'showPetById'
|
|
18
18
|
*/
|
|
19
|
-
resolveName(name: string): string;
|
|
19
|
+
resolveName(this: ResolverCypress, name: string): string;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
22
|
* Discriminated union that ties `pathParamsType` to the `paramsType` values where it is meaningful.
|
|
@@ -99,16 +99,15 @@ type Options = {
|
|
|
99
99
|
*/
|
|
100
100
|
compatibilityPreset?: CompatibilityPreset;
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* @default [resolverCypress]
|
|
102
|
+
* A single resolver whose methods override the default resolver's naming conventions.
|
|
103
|
+
* When a method returns `null` or `undefined`, the default resolver's result is used instead.
|
|
105
104
|
*/
|
|
106
|
-
|
|
105
|
+
resolver?: Partial<ResolverCypress> & ThisType<ResolverCypress>;
|
|
107
106
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
107
|
+
* A single AST visitor applied before printing.
|
|
108
|
+
* When a visitor method returns `null` or `undefined`, the preset transformer's result is used instead.
|
|
110
109
|
*/
|
|
111
|
-
|
|
110
|
+
transformer?: Visitor;
|
|
112
111
|
/**
|
|
113
112
|
* Define some generators next to the default generators.
|
|
114
113
|
*/
|
|
@@ -123,7 +122,6 @@ type ResolvedOptions = {
|
|
|
123
122
|
paramsType: NonNullable<Options['paramsType']>;
|
|
124
123
|
paramsCasing: Options['paramsCasing'];
|
|
125
124
|
resolver: ResolverCypress;
|
|
126
|
-
transformers: Array<Visitor>;
|
|
127
125
|
};
|
|
128
126
|
type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options, ResolvedOptions, never, ResolvePathOptions, ResolverCypress>;
|
|
129
127
|
//#endregion
|
|
@@ -157,21 +155,6 @@ declare function Request({
|
|
|
157
155
|
pathParamsType,
|
|
158
156
|
paramsCasing
|
|
159
157
|
}: 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
158
|
//#endregion
|
|
176
159
|
//#region src/generators/cypressGenerator.d.ts
|
|
177
160
|
declare const cypressGenerator: _$_kubb_core0.ReactGeneratorV2<PluginCypress>;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { caseParams,
|
|
3
|
+
import { caseParams, createFunctionParameter, createOperationParams, createTypeNode, transform, walk } from "@kubb/ast";
|
|
4
4
|
import { functionPrinter, pluginTsName } from "@kubb/plugin-ts";
|
|
5
5
|
import { File, Function as Function$1 } from "@kubb/react-fabric";
|
|
6
6
|
import { jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
@@ -216,7 +216,7 @@ var URLPath = class {
|
|
|
216
216
|
//#endregion
|
|
217
217
|
//#region src/components/Request.tsx
|
|
218
218
|
const declarationPrinter = functionPrinter({ mode: "declaration" });
|
|
219
|
-
function
|
|
219
|
+
function Request({ baseURL = "", name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }) {
|
|
220
220
|
const paramsNode = createOperationParams(node, {
|
|
221
221
|
paramsType,
|
|
222
222
|
pathParamsType,
|
|
@@ -231,16 +231,7 @@ function getParams({ paramsType, pathParamsType, paramsCasing, resolver, node })
|
|
|
231
231
|
default: "{}"
|
|
232
232
|
})]
|
|
233
233
|
});
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
function Request({ baseURL = "", name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }) {
|
|
237
|
-
const paramsSignature = getParams({
|
|
238
|
-
paramsType,
|
|
239
|
-
pathParamsType,
|
|
240
|
-
paramsCasing,
|
|
241
|
-
resolver,
|
|
242
|
-
node
|
|
243
|
-
});
|
|
234
|
+
const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
|
|
244
235
|
const responseType = resolver.resolveResponseName(node);
|
|
245
236
|
const returnType = dataReturnType === "data" ? `Cypress.Chainable<${responseType}>` : `Cypress.Chainable<Cypress.Response<${responseType}>>`;
|
|
246
237
|
const casedPathParams = caseParams(node.parameters.filter((p) => p.in === "path"), paramsCasing);
|
|
@@ -285,18 +276,17 @@ function Request({ baseURL = "", name, dataReturnType, resolver, node, paramsTyp
|
|
|
285
276
|
})
|
|
286
277
|
});
|
|
287
278
|
}
|
|
288
|
-
Request.getParams = getParams;
|
|
289
279
|
//#endregion
|
|
290
280
|
//#region src/generators/cypressGenerator.tsx
|
|
291
281
|
const cypressGenerator = defineGenerator({
|
|
292
282
|
name: "cypress",
|
|
293
283
|
type: "react",
|
|
294
|
-
Operation({ node, adapter, options, config, driver, resolver }) {
|
|
295
|
-
const { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType, group
|
|
284
|
+
Operation({ node, adapter, options, config, driver, resolver, plugin }) {
|
|
285
|
+
const { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType, group } = options;
|
|
296
286
|
const root = path.resolve(config.root, config.output.path);
|
|
297
287
|
const pluginTs = driver.getPlugin(pluginTsName);
|
|
298
|
-
if (!pluginTs) return null;
|
|
299
|
-
const transformedNode = transform(node,
|
|
288
|
+
if (!pluginTs?.resolver) return null;
|
|
289
|
+
const transformedNode = plugin.transformer ? transform(node, plugin.transformer) : node;
|
|
300
290
|
const casedParams = caseParams(transformedNode.parameters, paramsCasing);
|
|
301
291
|
const pathParams = casedParams.filter((p) => p.in === "path");
|
|
302
292
|
const queryParams = casedParams.filter((p) => p.in === "query");
|
|
@@ -396,12 +386,12 @@ const resolverCypress = defineResolver(() => ({
|
|
|
396
386
|
const presets = definePresets({
|
|
397
387
|
default: {
|
|
398
388
|
name: "default",
|
|
399
|
-
|
|
389
|
+
resolver: resolverCypress,
|
|
400
390
|
generators: [cypressGenerator]
|
|
401
391
|
},
|
|
402
392
|
kubbV4: {
|
|
403
393
|
name: "kubbV4",
|
|
404
|
-
|
|
394
|
+
resolver: resolverCypress,
|
|
405
395
|
generators: [cypressGenerator]
|
|
406
396
|
}
|
|
407
397
|
});
|
|
@@ -432,12 +422,12 @@ const pluginCypress = createPlugin((options) => {
|
|
|
432
422
|
const { output = {
|
|
433
423
|
path: "cypress",
|
|
434
424
|
barrelType: "named"
|
|
435
|
-
}, group, dataReturnType = "data", exclude = [], include, override = [], baseURL, paramsCasing, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", compatibilityPreset = "default",
|
|
425
|
+
}, group, dataReturnType = "data", exclude = [], include, override = [], baseURL, paramsCasing, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", compatibilityPreset = "default", resolver: userResolver, transformer: userTransformer, generators: userGenerators = [] } = options;
|
|
436
426
|
const preset = getPreset({
|
|
437
427
|
preset: compatibilityPreset,
|
|
438
428
|
presets,
|
|
439
|
-
|
|
440
|
-
|
|
429
|
+
resolver: userResolver,
|
|
430
|
+
transformer: userTransformer,
|
|
441
431
|
generators: userGenerators
|
|
442
432
|
});
|
|
443
433
|
return {
|
|
@@ -445,6 +435,9 @@ const pluginCypress = createPlugin((options) => {
|
|
|
445
435
|
get resolver() {
|
|
446
436
|
return preset.resolver;
|
|
447
437
|
},
|
|
438
|
+
get transformer() {
|
|
439
|
+
return preset.transformer;
|
|
440
|
+
},
|
|
448
441
|
get options() {
|
|
449
442
|
return {
|
|
450
443
|
output,
|
|
@@ -460,8 +453,7 @@ const pluginCypress = createPlugin((options) => {
|
|
|
460
453
|
paramsCasing,
|
|
461
454
|
paramsType,
|
|
462
455
|
pathParamsType,
|
|
463
|
-
resolver: preset.resolver
|
|
464
|
-
transformers: preset.transformers
|
|
456
|
+
resolver: preset.resolver
|
|
465
457
|
};
|
|
466
458
|
},
|
|
467
459
|
pre: [pluginTsName].filter(Boolean),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["#options","#transformParam","#eachParam","Function"],"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, composeTransformers, transform } 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, transformers } = 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 transformedNode = transform(node, composeTransformers(...transformers))\n\n const casedParams = caseParams(transformedNode.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) => pluginTs.resolver.resolvePathParamsName(transformedNode, p)),\n ...queryParams.map((p) => pluginTs.resolver.resolveQueryParamsName(transformedNode, p)),\n ...headerParams.map((p) => pluginTs.resolver.resolveHeaderParamsName(transformedNode, p)),\n transformedNode.requestBody?.schema ? pluginTs.resolver.resolveDataName(transformedNode) : undefined,\n pluginTs.resolver.resolveResponseName(transformedNode),\n ].filter(Boolean)\n\n const meta = {\n name: resolver.resolveName(transformedNode.operationId),\n file: resolver.resolveFile(\n { name: transformedNode.operationId, extname: '.ts', tag: transformedNode.tags[0] ?? 'default', path: transformedNode.path },\n { root, output, group },\n ),\n fileTs: pluginTs.resolver.resolveFile(\n { name: transformedNode.operationId, extname: '.ts', tag: transformedNode.tags[0] ?? 'default', path: transformedNode.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.rootNode, { output, config })}\n footer={resolver.resolveFooter(adapter.rootNode, { 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={transformedNode}\n resolver={pluginTs.resolver}\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 type { OperationNode } from '@kubb/ast/types'\nimport { createPlugin, type Group, getBarrelFiles, getPreset, runGeneratorOperation, runGeneratorOperations, runGeneratorSchema } 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 ...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 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 const collectedOperations: Array<OperationNode> = []\n const generatorContext = { generators: preset.generators, plugin, resolver, exclude, include, override, fabric, adapter, config, driver }\n\n await walk(rootNode, {\n depth: 'shallow',\n async schema(schemaNode) {\n await runGeneratorSchema(schemaNode, generatorContext)\n },\n async operation(operationNode) {\n const baseOptions = resolver.resolveOptions(operationNode, { options: plugin.options, exclude, include, override })\n\n if (baseOptions !== null) {\n collectedOperations.push(operationNode)\n }\n\n await runGeneratorOperation(operationNode, generatorContext)\n },\n })\n\n await runGeneratorOperations(collectedOperations, generatorContext)\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;;;;;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options","#transformParam","#eachParam","Function"],"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\nexport function Request({ baseURL = '', name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }: Props): FabricReactNode {\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 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 = 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","import path from 'node:path'\nimport { caseParams, transform } 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, plugin }) {\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?.resolver) {\n return null\n }\n\n const transformedNode = plugin.transformer ? transform(node, plugin.transformer) : node\n\n const casedParams = caseParams(transformedNode.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) => pluginTs.resolver.resolvePathParamsName(transformedNode, p)),\n ...queryParams.map((p) => pluginTs.resolver.resolveQueryParamsName(transformedNode, p)),\n ...headerParams.map((p) => pluginTs.resolver.resolveHeaderParamsName(transformedNode, p)),\n transformedNode.requestBody?.schema ? pluginTs.resolver.resolveDataName(transformedNode) : undefined,\n pluginTs.resolver.resolveResponseName(transformedNode),\n ].filter(Boolean)\n\n const meta = {\n name: resolver.resolveName(transformedNode.operationId),\n file: resolver.resolveFile(\n { name: transformedNode.operationId, extname: '.ts', tag: transformedNode.tags[0] ?? 'default', path: transformedNode.path },\n { root, output, group },\n ),\n fileTs: pluginTs.resolver.resolveFile(\n { name: transformedNode.operationId, extname: '.ts', tag: transformedNode.tags[0] ?? 'default', path: transformedNode.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.rootNode, { output, config })}\n footer={resolver.resolveFooter(adapter.rootNode, { 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={transformedNode}\n resolver={pluginTs.resolver}\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 resolver: resolverCypress,\n generators: [cypressGenerator],\n },\n kubbV4: {\n name: 'kubbV4',\n resolver: resolverCypress,\n generators: [cypressGenerator],\n },\n})\n","import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { walk } from '@kubb/ast'\nimport type { OperationNode } from '@kubb/ast/types'\nimport { createPlugin, type Group, getBarrelFiles, getPreset, runGeneratorOperation, runGeneratorOperations, runGeneratorSchema } from '@kubb/core'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { presets } from './presets.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 resolver: userResolver,\n transformer: userTransformer,\n generators: userGenerators = [],\n } = options\n\n const preset = getPreset({\n preset: compatibilityPreset,\n presets,\n resolver: userResolver,\n transformer: userTransformer,\n generators: userGenerators,\n })\n\n return {\n name: pluginCypressName,\n get resolver() {\n return preset.resolver\n },\n get transformer() {\n return preset.transformer\n },\n get options() {\n return {\n output,\n dataReturnType,\n group: 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 baseURL,\n paramsCasing,\n paramsType,\n pathParamsType,\n resolver: preset.resolver,\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 const collectedOperations: Array<OperationNode> = []\n const generatorContext = { generators: preset.generators, plugin, resolver, exclude, include, override, fabric, adapter, config, driver }\n\n await walk(rootNode, {\n depth: 'shallow',\n async schema(schemaNode) {\n await runGeneratorSchema(schemaNode, generatorContext)\n },\n async operation(operationNode) {\n const baseOptions = resolver.resolveOptions(operationNode, { options: plugin.options, exclude, include, override })\n\n if (baseOptions !== null) {\n collectedOperations.push(operationNode)\n }\n\n await runGeneratorOperation(operationNode, generatorContext)\n },\n })\n\n await runGeneratorOperations(collectedOperations, generatorContext)\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,SA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ExC;EACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-cypress",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.28",
|
|
4
4
|
"description": "Cypress test generator plugin for Kubb, creating end-to-end tests from OpenAPI specifications for automated API testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cypress",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@kubb/react-fabric": "0.15.1",
|
|
57
|
-
"@kubb/ast": "5.0.0-alpha.
|
|
58
|
-
"@kubb/core": "5.0.0-alpha.
|
|
59
|
-
"@kubb/plugin-ts": "5.0.0-alpha.
|
|
57
|
+
"@kubb/ast": "5.0.0-alpha.28",
|
|
58
|
+
"@kubb/core": "5.0.0-alpha.28",
|
|
59
|
+
"@kubb/plugin-ts": "5.0.0-alpha.28"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=22"
|
|
@@ -29,19 +29,7 @@ type Props = {
|
|
|
29
29
|
|
|
30
30
|
const declarationPrinter = functionPrinter({ mode: 'declaration' })
|
|
31
31
|
|
|
32
|
-
function
|
|
33
|
-
paramsType,
|
|
34
|
-
pathParamsType,
|
|
35
|
-
paramsCasing,
|
|
36
|
-
resolver,
|
|
37
|
-
node,
|
|
38
|
-
}: {
|
|
39
|
-
paramsType: PluginCypress['resolvedOptions']['paramsType']
|
|
40
|
-
pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']
|
|
41
|
-
paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']
|
|
42
|
-
resolver: ResolverTs
|
|
43
|
-
node: OperationNode
|
|
44
|
-
}): string {
|
|
32
|
+
export function Request({ baseURL = '', name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }: Props): FabricReactNode {
|
|
45
33
|
const paramsNode = createOperationParams(node, {
|
|
46
34
|
paramsType,
|
|
47
35
|
pathParamsType,
|
|
@@ -51,12 +39,7 @@ function getParams({
|
|
|
51
39
|
createFunctionParameter({ name: 'options', type: createTypeNode({ variant: 'reference', name: 'Partial<Cypress.RequestOptions>' }), default: '{}' }),
|
|
52
40
|
],
|
|
53
41
|
})
|
|
54
|
-
|
|
55
|
-
return declarationPrinter.print(paramsNode) ?? ''
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function Request({ baseURL = '', name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }: Props): FabricReactNode {
|
|
59
|
-
const paramsSignature = getParams({ paramsType, pathParamsType, paramsCasing, resolver, node })
|
|
42
|
+
const paramsSignature = declarationPrinter.print(paramsNode) ?? ''
|
|
60
43
|
|
|
61
44
|
const responseType = resolver.resolveResponseName(node)
|
|
62
45
|
const returnType = dataReturnType === 'data' ? `Cypress.Chainable<${responseType}>` : `Cypress.Chainable<Cypress.Response<${responseType}>>`
|
|
@@ -126,5 +109,3 @@ export function Request({ baseURL = '', name, dataReturnType, resolver, node, pa
|
|
|
126
109
|
</File.Source>
|
|
127
110
|
)
|
|
128
111
|
}
|
|
129
|
-
|
|
130
|
-
Request.getParams = getParams
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import { caseParams,
|
|
2
|
+
import { caseParams, transform } from '@kubb/ast'
|
|
3
3
|
import { defineGenerator } from '@kubb/core'
|
|
4
4
|
import type { PluginTs } from '@kubb/plugin-ts'
|
|
5
5
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
@@ -10,17 +10,17 @@ import type { PluginCypress } from '../types.ts'
|
|
|
10
10
|
export const cypressGenerator = defineGenerator<PluginCypress>({
|
|
11
11
|
name: 'cypress',
|
|
12
12
|
type: 'react',
|
|
13
|
-
Operation({ node, adapter, options, config, driver, resolver }) {
|
|
14
|
-
const { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType, group
|
|
13
|
+
Operation({ node, adapter, options, config, driver, resolver, plugin }) {
|
|
14
|
+
const { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType, group } = options
|
|
15
15
|
const root = path.resolve(config.root, config.output.path)
|
|
16
16
|
|
|
17
17
|
const pluginTs = driver.getPlugin<PluginTs>(pluginTsName)
|
|
18
18
|
|
|
19
|
-
if (!pluginTs) {
|
|
19
|
+
if (!pluginTs?.resolver) {
|
|
20
20
|
return null
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const transformedNode = transform(node,
|
|
23
|
+
const transformedNode = plugin.transformer ? transform(node, plugin.transformer) : node
|
|
24
24
|
|
|
25
25
|
const casedParams = caseParams(transformedNode.parameters, paramsCasing)
|
|
26
26
|
|
package/src/plugin.ts
CHANGED
|
@@ -5,7 +5,6 @@ import type { OperationNode } from '@kubb/ast/types'
|
|
|
5
5
|
import { createPlugin, type Group, getBarrelFiles, getPreset, runGeneratorOperation, runGeneratorOperations, runGeneratorSchema } from '@kubb/core'
|
|
6
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
7
7
|
import { presets } from './presets.ts'
|
|
8
|
-
import { resolverCypress } from './resolvers/resolverCypress.ts'
|
|
9
8
|
import type { PluginCypress } from './types.ts'
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -43,16 +42,16 @@ export const pluginCypress = createPlugin<PluginCypress>((options) => {
|
|
|
43
42
|
paramsType = 'inline',
|
|
44
43
|
pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',
|
|
45
44
|
compatibilityPreset = 'default',
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
resolver: userResolver,
|
|
46
|
+
transformer: userTransformer,
|
|
48
47
|
generators: userGenerators = [],
|
|
49
48
|
} = options
|
|
50
49
|
|
|
51
50
|
const preset = getPreset({
|
|
52
51
|
preset: compatibilityPreset,
|
|
53
52
|
presets,
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
resolver: userResolver,
|
|
54
|
+
transformer: userTransformer,
|
|
56
55
|
generators: userGenerators,
|
|
57
56
|
})
|
|
58
57
|
|
|
@@ -61,6 +60,9 @@ export const pluginCypress = createPlugin<PluginCypress>((options) => {
|
|
|
61
60
|
get resolver() {
|
|
62
61
|
return preset.resolver
|
|
63
62
|
},
|
|
63
|
+
get transformer() {
|
|
64
|
+
return preset.transformer
|
|
65
|
+
},
|
|
64
66
|
get options() {
|
|
65
67
|
return {
|
|
66
68
|
output,
|
|
@@ -83,7 +85,6 @@ export const pluginCypress = createPlugin<PluginCypress>((options) => {
|
|
|
83
85
|
paramsType,
|
|
84
86
|
pathParamsType,
|
|
85
87
|
resolver: preset.resolver,
|
|
86
|
-
transformers: preset.transformers,
|
|
87
88
|
}
|
|
88
89
|
},
|
|
89
90
|
pre: [pluginTsName].filter(Boolean),
|
package/src/presets.ts
CHANGED
|
@@ -12,12 +12,12 @@ import type { ResolverCypress } from './types.ts'
|
|
|
12
12
|
export const presets = definePresets<ResolverCypress>({
|
|
13
13
|
default: {
|
|
14
14
|
name: 'default',
|
|
15
|
-
|
|
15
|
+
resolver: resolverCypress,
|
|
16
16
|
generators: [cypressGenerator],
|
|
17
17
|
},
|
|
18
18
|
kubbV4: {
|
|
19
19
|
name: 'kubbV4',
|
|
20
|
-
|
|
20
|
+
resolver: resolverCypress,
|
|
21
21
|
generators: [cypressGenerator],
|
|
22
22
|
},
|
|
23
23
|
})
|
package/src/types.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type ResolverCypress = Resolver & {
|
|
|
23
23
|
* @example
|
|
24
24
|
* resolver.resolveName('show pet by id') // -> 'showPetById'
|
|
25
25
|
*/
|
|
26
|
-
resolveName(name: string): string
|
|
26
|
+
resolveName(this: ResolverCypress, name: string): string
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -110,16 +110,15 @@ export type Options = {
|
|
|
110
110
|
*/
|
|
111
111
|
compatibilityPreset?: CompatibilityPreset
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* @default [resolverCypress]
|
|
113
|
+
* A single resolver whose methods override the default resolver's naming conventions.
|
|
114
|
+
* When a method returns `null` or `undefined`, the default resolver's result is used instead.
|
|
116
115
|
*/
|
|
117
|
-
|
|
116
|
+
resolver?: Partial<ResolverCypress> & ThisType<ResolverCypress>
|
|
118
117
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
118
|
+
* A single AST visitor applied before printing.
|
|
119
|
+
* When a visitor method returns `null` or `undefined`, the preset transformer's result is used instead.
|
|
121
120
|
*/
|
|
122
|
-
|
|
121
|
+
transformer?: Visitor
|
|
123
122
|
/**
|
|
124
123
|
* Define some generators next to the default generators.
|
|
125
124
|
*/
|
|
@@ -135,7 +134,6 @@ type ResolvedOptions = {
|
|
|
135
134
|
paramsType: NonNullable<Options['paramsType']>
|
|
136
135
|
paramsCasing: Options['paramsCasing']
|
|
137
136
|
resolver: ResolverCypress
|
|
138
|
-
transformers: Array<Visitor>
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
export type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options, ResolvedOptions, never, ResolvePathOptions, ResolverCypress>
|