@kubb/plugin-cypress 5.0.0-alpha.9 → 5.0.0-beta.15

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.js CHANGED
@@ -1,79 +1,572 @@
1
1
  import "./chunk--u3MIqq1.js";
2
- import { n as camelCase } from "./components-BK_6GU4v.js";
3
- import { t as cypressGenerator } from "./generators-B3FWG2Ck.js";
4
- import path from "node:path";
5
- import { createPlugin, getBarrelFiles, getMode } from "@kubb/core";
6
- import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
7
- import { pluginTsName } from "@kubb/plugin-ts";
2
+ import { ast, defineGenerator, definePlugin, defineResolver } from "@kubb/core";
3
+ import { functionPrinter, pluginTsName } from "@kubb/plugin-ts";
4
+ import { File, Function, jsxRendererSync } from "@kubb/renderer-jsx";
5
+ import { jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
6
+ //#region ../../internals/utils/src/casing.ts
7
+ /**
8
+ * Shared implementation for camelCase and PascalCase conversion.
9
+ * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
10
+ * and capitalizes each word according to `pascal`.
11
+ *
12
+ * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
13
+ */
14
+ function toCamelOrPascal(text, pascal) {
15
+ return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
16
+ if (word.length > 1 && word === word.toUpperCase()) return word;
17
+ if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
18
+ return word.charAt(0).toUpperCase() + word.slice(1);
19
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
20
+ }
21
+ /**
22
+ * Splits `text` on `.` and applies `transformPart` to each segment.
23
+ * The last segment receives `isLast = true`, all earlier segments receive `false`.
24
+ * Segments are joined with `/` to form a file path.
25
+ *
26
+ * Only splits on dots followed by a letter so that version numbers
27
+ * embedded in operationIds (e.g. `v2025.0`) are kept intact.
28
+ */
29
+ function applyToFileParts(text, transformPart) {
30
+ const parts = text.split(/\.(?=[a-zA-Z])/);
31
+ return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
32
+ }
33
+ /**
34
+ * Converts `text` to camelCase.
35
+ * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
36
+ *
37
+ * @example
38
+ * camelCase('hello-world') // 'helloWorld'
39
+ * camelCase('pet.petId', { isFile: true }) // 'pet/petId'
40
+ */
41
+ function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
42
+ if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
43
+ prefix,
44
+ suffix
45
+ } : {}));
46
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
47
+ }
48
+ //#endregion
49
+ //#region ../../internals/utils/src/reserved.ts
50
+ /**
51
+ * JavaScript and Java reserved words.
52
+ * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
53
+ */
54
+ const reservedWords = new Set([
55
+ "abstract",
56
+ "arguments",
57
+ "boolean",
58
+ "break",
59
+ "byte",
60
+ "case",
61
+ "catch",
62
+ "char",
63
+ "class",
64
+ "const",
65
+ "continue",
66
+ "debugger",
67
+ "default",
68
+ "delete",
69
+ "do",
70
+ "double",
71
+ "else",
72
+ "enum",
73
+ "eval",
74
+ "export",
75
+ "extends",
76
+ "false",
77
+ "final",
78
+ "finally",
79
+ "float",
80
+ "for",
81
+ "function",
82
+ "goto",
83
+ "if",
84
+ "implements",
85
+ "import",
86
+ "in",
87
+ "instanceof",
88
+ "int",
89
+ "interface",
90
+ "let",
91
+ "long",
92
+ "native",
93
+ "new",
94
+ "null",
95
+ "package",
96
+ "private",
97
+ "protected",
98
+ "public",
99
+ "return",
100
+ "short",
101
+ "static",
102
+ "super",
103
+ "switch",
104
+ "synchronized",
105
+ "this",
106
+ "throw",
107
+ "throws",
108
+ "transient",
109
+ "true",
110
+ "try",
111
+ "typeof",
112
+ "var",
113
+ "void",
114
+ "volatile",
115
+ "while",
116
+ "with",
117
+ "yield",
118
+ "Array",
119
+ "Date",
120
+ "hasOwnProperty",
121
+ "Infinity",
122
+ "isFinite",
123
+ "isNaN",
124
+ "isPrototypeOf",
125
+ "length",
126
+ "Math",
127
+ "name",
128
+ "NaN",
129
+ "Number",
130
+ "Object",
131
+ "prototype",
132
+ "String",
133
+ "toString",
134
+ "undefined",
135
+ "valueOf"
136
+ ]);
137
+ /**
138
+ * Returns `true` when `name` is a syntactically valid JavaScript variable name.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * isValidVarName('status') // true
143
+ * isValidVarName('class') // false (reserved word)
144
+ * isValidVarName('42foo') // false (starts with digit)
145
+ * ```
146
+ */
147
+ function isValidVarName(name) {
148
+ if (!name || reservedWords.has(name)) return false;
149
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
150
+ }
151
+ //#endregion
152
+ //#region ../../internals/utils/src/urlPath.ts
153
+ /**
154
+ * Parses and transforms an OpenAPI/Swagger path string into various URL formats.
155
+ *
156
+ * @example
157
+ * const p = new URLPath('/pet/{petId}')
158
+ * p.URL // '/pet/:petId'
159
+ * p.template // '`/pet/${petId}`'
160
+ */
161
+ var URLPath = class {
162
+ /**
163
+ * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
164
+ */
165
+ path;
166
+ #options;
167
+ constructor(path, options = {}) {
168
+ this.path = path;
169
+ this.#options = options;
170
+ }
171
+ /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * new URLPath('/pet/{petId}').URL // '/pet/:petId'
176
+ * ```
177
+ */
178
+ get URL() {
179
+ return this.toURLPath();
180
+ }
181
+ /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
186
+ * new URLPath('/pet/{petId}').isURL // false
187
+ * ```
188
+ */
189
+ get isURL() {
190
+ try {
191
+ return !!new URL(this.path).href;
192
+ } catch {
193
+ return false;
194
+ }
195
+ }
196
+ /**
197
+ * Converts the OpenAPI path to a TypeScript template literal string.
198
+ *
199
+ * @example
200
+ * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
201
+ * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
202
+ */
203
+ get template() {
204
+ return this.toTemplateString();
205
+ }
206
+ /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * new URLPath('/pet/{petId}').object
211
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
212
+ * ```
213
+ */
214
+ get object() {
215
+ return this.toObject();
216
+ }
217
+ /** Returns a map of path parameter names, or `undefined` when the path has no parameters.
218
+ *
219
+ * @example
220
+ * ```ts
221
+ * new URLPath('/pet/{petId}').params // { petId: 'petId' }
222
+ * new URLPath('/pet').params // undefined
223
+ * ```
224
+ */
225
+ get params() {
226
+ return this.toParamsObject();
227
+ }
228
+ #transformParam(raw) {
229
+ const param = isValidVarName(raw) ? raw : camelCase(raw);
230
+ return this.#options.casing === "camelcase" ? camelCase(param) : param;
231
+ }
232
+ /**
233
+ * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.
234
+ */
235
+ #eachParam(fn) {
236
+ for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
237
+ const raw = match[1];
238
+ fn(raw, this.#transformParam(raw));
239
+ }
240
+ }
241
+ toObject({ type = "path", replacer, stringify } = {}) {
242
+ const object = {
243
+ url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
244
+ params: this.toParamsObject()
245
+ };
246
+ if (stringify) {
247
+ if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
248
+ if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
249
+ return `{ url: '${object.url}' }`;
250
+ }
251
+ return object;
252
+ }
253
+ /**
254
+ * Converts the OpenAPI path to a TypeScript template literal string.
255
+ * An optional `replacer` can transform each extracted parameter name before interpolation.
256
+ *
257
+ * @example
258
+ * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
259
+ */
260
+ toTemplateString({ prefix = "", replacer } = {}) {
261
+ return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
262
+ if (i % 2 === 0) return part;
263
+ const param = this.#transformParam(part);
264
+ return `\${${replacer ? replacer(param) : param}}`;
265
+ }).join("")}\``;
266
+ }
267
+ /**
268
+ * Extracts all `{param}` segments from the path and returns them as a key-value map.
269
+ * An optional `replacer` transforms each parameter name in both key and value positions.
270
+ * Returns `undefined` when no path parameters are found.
271
+ *
272
+ * @example
273
+ * ```ts
274
+ * new URLPath('/pet/{petId}/tag/{tagId}').toParamsObject()
275
+ * // { petId: 'petId', tagId: 'tagId' }
276
+ * ```
277
+ */
278
+ toParamsObject(replacer) {
279
+ const params = {};
280
+ this.#eachParam((_raw, param) => {
281
+ const key = replacer ? replacer(param) : param;
282
+ params[key] = key;
283
+ });
284
+ return Object.keys(params).length > 0 ? params : void 0;
285
+ }
286
+ /** Converts the OpenAPI path to Express-style colon syntax.
287
+ *
288
+ * @example
289
+ * ```ts
290
+ * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
291
+ * ```
292
+ */
293
+ toURLPath() {
294
+ return this.path.replace(/\{([^}]+)\}/g, ":$1");
295
+ }
296
+ };
297
+ //#endregion
298
+ //#region ../../internals/shared/src/operation.ts
299
+ function getOperationParameters(node, options = {}) {
300
+ const params = ast.caseParams(node.parameters, options.paramsCasing);
301
+ return {
302
+ path: params.filter((param) => param.in === "path"),
303
+ query: params.filter((param) => param.in === "query"),
304
+ header: params.filter((param) => param.in === "header"),
305
+ cookie: params.filter((param) => param.in === "cookie")
306
+ };
307
+ }
308
+ function getStatusCodeNumber(statusCode) {
309
+ const code = Number(statusCode);
310
+ return Number.isNaN(code) ? void 0 : code;
311
+ }
312
+ function isErrorStatusCode(statusCode) {
313
+ const code = getStatusCodeNumber(statusCode);
314
+ return code !== void 0 && code >= 400;
315
+ }
316
+ function resolveErrorNames(node, resolver) {
317
+ return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
318
+ }
319
+ function resolveStatusCodeNames(node, resolver) {
320
+ return node.responses.map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
321
+ }
322
+ const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
323
+ function resolveOperationTypeNames(node, resolver, options = {}) {
324
+ const cacheKey = `${node.operationId}\0${options.paramsCasing ?? ""}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${(options.exclude ?? []).join(",")}`;
325
+ let byResolver = typeNamesByResolver.get(resolver);
326
+ if (byResolver) {
327
+ const cached = byResolver.get(cacheKey);
328
+ if (cached) return cached;
329
+ } else {
330
+ byResolver = /* @__PURE__ */ new Map();
331
+ typeNamesByResolver.set(resolver, byResolver);
332
+ }
333
+ const { path, query, header } = getOperationParameters(node, { paramsCasing: options.paramsCasing });
334
+ const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
335
+ const exclude = new Set(options.exclude ?? []);
336
+ const paramNames = [
337
+ ...path.map((param) => resolver.resolvePathParamsName(node, param)),
338
+ ...query.map((param) => resolver.resolveQueryParamsName(node, param)),
339
+ ...header.map((param) => resolver.resolveHeaderParamsName(node, param))
340
+ ];
341
+ const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0, resolver.resolveResponseName(node)];
342
+ const result = (options.order === "body-response-first" ? [
343
+ ...bodyAndResponseNames,
344
+ ...paramNames,
345
+ ...responseStatusNames
346
+ ] : [
347
+ ...paramNames,
348
+ ...bodyAndResponseNames,
349
+ ...responseStatusNames
350
+ ]).filter((name) => Boolean(name) && !exclude.has(name));
351
+ byResolver.set(cacheKey, result);
352
+ return result;
353
+ }
354
+ //#endregion
355
+ //#region src/components/Request.tsx
356
+ const declarationPrinter = functionPrinter({ mode: "declaration" });
357
+ function Request({ baseURL = "", name, dataReturnType, resolver, node, paramsType, pathParamsType, paramsCasing }) {
358
+ const paramsNode = ast.createOperationParams(node, {
359
+ paramsType,
360
+ pathParamsType,
361
+ paramsCasing,
362
+ resolver,
363
+ extraParams: [ast.createFunctionParameter({
364
+ name: "options",
365
+ type: ast.createParamsType({
366
+ variant: "reference",
367
+ name: "Partial<Cypress.RequestOptions>"
368
+ }),
369
+ default: "{}"
370
+ })]
371
+ });
372
+ const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
373
+ const responseType = resolver.resolveResponseName(node);
374
+ const returnType = dataReturnType === "data" ? `Cypress.Chainable<${responseType}>` : `Cypress.Chainable<Cypress.Response<${responseType}>>`;
375
+ const casedPathParams = getOperationParameters(node, { paramsCasing }).path;
376
+ const pathParamNameMap = new Map(casedPathParams.map((p) => [camelCase(p.name), p.name]));
377
+ const urlTemplate = new URLPath(node.path, { casing: paramsCasing }).toTemplateString({
378
+ prefix: baseURL,
379
+ replacer: (param) => pathParamNameMap.get(camelCase(param)) ?? param
380
+ });
381
+ const requestOptions = [`method: '${node.method}'`, `url: ${urlTemplate}`];
382
+ const queryParams = getOperationParameters(node).query;
383
+ if (queryParams.length > 0) {
384
+ const casedQueryParams = getOperationParameters(node, { paramsCasing }).query;
385
+ if (casedQueryParams.some((p, i) => p.name !== queryParams[i].name)) {
386
+ const pairs = queryParams.map((orig, i) => `${orig.name}: params.${casedQueryParams[i].name}`).join(", ");
387
+ requestOptions.push(`qs: params ? { ${pairs} } : undefined`);
388
+ } else requestOptions.push("qs: params");
389
+ }
390
+ const headerParams = getOperationParameters(node).header;
391
+ if (headerParams.length > 0) {
392
+ const casedHeaderParams = getOperationParameters(node, { paramsCasing }).header;
393
+ if (casedHeaderParams.some((p, i) => p.name !== headerParams[i].name)) {
394
+ const pairs = headerParams.map((orig, i) => `'${orig.name}': headers.${casedHeaderParams[i].name}`).join(", ");
395
+ requestOptions.push(`headers: headers ? { ${pairs} } : undefined`);
396
+ } else requestOptions.push("headers");
397
+ }
398
+ if (node.requestBody?.content?.[0]?.schema) requestOptions.push("body: data");
399
+ requestOptions.push("...options");
400
+ return /* @__PURE__ */ jsx(File.Source, {
401
+ name,
402
+ isIndexable: true,
403
+ isExportable: true,
404
+ children: /* @__PURE__ */ jsx(Function, {
405
+ name,
406
+ export: true,
407
+ params: paramsSignature,
408
+ returnType,
409
+ children: dataReturnType === "data" ? `return cy.request<${responseType}>({
410
+ ${requestOptions.join(",\n ")}
411
+ }).then((res) => res.body)` : `return cy.request<${responseType}>({
412
+ ${requestOptions.join(",\n ")}
413
+ })`
414
+ })
415
+ });
416
+ }
417
+ //#endregion
418
+ //#region src/generators/cypressGenerator.tsx
419
+ const cypressGenerator = defineGenerator({
420
+ name: "cypress",
421
+ renderer: jsxRendererSync,
422
+ operation(node, ctx) {
423
+ const { config, resolver, driver, root, inputNode } = ctx;
424
+ const { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType, group } = ctx.options;
425
+ const pluginTs = driver.getPlugin(pluginTsName);
426
+ if (!pluginTs) return null;
427
+ const tsResolver = driver.getResolver(pluginTsName);
428
+ const importedTypeNames = resolveOperationTypeNames(node, tsResolver, { paramsCasing });
429
+ const meta = {
430
+ name: resolver.resolveName(node.operationId),
431
+ file: resolver.resolveFile({
432
+ name: node.operationId,
433
+ extname: ".ts",
434
+ tag: node.tags[0] ?? "default",
435
+ path: node.path
436
+ }, {
437
+ root,
438
+ output,
439
+ group
440
+ }),
441
+ fileTs: tsResolver.resolveFile({
442
+ name: node.operationId,
443
+ extname: ".ts",
444
+ tag: node.tags[0] ?? "default",
445
+ path: node.path
446
+ }, {
447
+ root,
448
+ output: pluginTs.options?.output ?? output,
449
+ group: pluginTs.options?.group
450
+ })
451
+ };
452
+ return /* @__PURE__ */ jsxs(File, {
453
+ baseName: meta.file.baseName,
454
+ path: meta.file.path,
455
+ meta: meta.file.meta,
456
+ banner: resolver.resolveBanner(inputNode, {
457
+ output,
458
+ config
459
+ }),
460
+ footer: resolver.resolveFooter(inputNode, {
461
+ output,
462
+ config
463
+ }),
464
+ children: [meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ jsx(File.Import, {
465
+ name: importedTypeNames,
466
+ root: meta.file.path,
467
+ path: meta.fileTs.path,
468
+ isTypeOnly: true
469
+ }), /* @__PURE__ */ jsx(Request, {
470
+ name: meta.name,
471
+ node,
472
+ resolver: tsResolver,
473
+ dataReturnType,
474
+ paramsCasing,
475
+ paramsType,
476
+ pathParamsType,
477
+ baseURL
478
+ })]
479
+ });
480
+ }
481
+ });
482
+ //#endregion
483
+ //#region src/resolvers/resolverCypress.ts
484
+ /**
485
+ * Naming convention resolver for Cypress plugin.
486
+ *
487
+ * Provides default naming helpers using camelCase for functions and file paths.
488
+ *
489
+ * @example
490
+ * `resolverCypress.default('list pets', 'function') // → 'listPets'`
491
+ */
492
+ const resolverCypress = defineResolver(() => ({
493
+ name: "default",
494
+ pluginName: "plugin-cypress",
495
+ default(name, type) {
496
+ return camelCase(name, { isFile: type === "file" });
497
+ },
498
+ resolveName(name) {
499
+ return this.default(name, "function");
500
+ },
501
+ resolvePathName(name, type) {
502
+ return this.default(name, type);
503
+ }
504
+ }));
505
+ //#endregion
8
506
  //#region src/plugin.ts
507
+ /**
508
+ * Canonical plugin name for `@kubb/plugin-cypress`, used to identify the plugin
509
+ * in driver lookups and warnings.
510
+ */
9
511
  const pluginCypressName = "plugin-cypress";
10
- const pluginCypress = createPlugin((options) => {
512
+ /**
513
+ * The `@kubb/plugin-cypress` plugin factory.
514
+ *
515
+ * Generates Cypress `cy.request()` test functions from an OpenAPI/AST `RootNode`.
516
+ * Walks operations, delegates rendering to the active generators,
517
+ * and writes barrel files based on `output.barrelType`.
518
+ *
519
+ * @example
520
+ * ```ts
521
+ * import pluginCypress from '@kubb/plugin-cypress'
522
+ *
523
+ * export default defineConfig({
524
+ * plugins: [pluginCypress({ output: { path: 'cypress' } })],
525
+ * })
526
+ * ```
527
+ */
528
+ const pluginCypress = definePlugin((options) => {
11
529
  const { output = {
12
530
  path: "cypress",
13
531
  barrelType: "named"
14
- }, group, dataReturnType = "data", exclude = [], include, override = [], transformers = {}, generators = [cypressGenerator].filter(Boolean), contentType, baseURL, paramsCasing, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline" } = options;
532
+ }, group, exclude = [], include, override = [], dataReturnType = "data", baseURL, paramsCasing, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", resolver: userResolver, transformer: userTransformer, generators: userGenerators = [] } = options;
533
+ const groupConfig = group ? {
534
+ ...group,
535
+ name: group.name ? group.name : (ctx) => {
536
+ if (group.type === "path") return `${ctx.group.split("/")[1]}`;
537
+ return `${camelCase(ctx.group)}Requests`;
538
+ }
539
+ } : void 0;
15
540
  return {
16
541
  name: pluginCypressName,
17
- options: {
18
- output,
19
- dataReturnType,
20
- group,
21
- baseURL,
22
- paramsCasing,
23
- paramsType,
24
- pathParamsType
25
- },
26
- pre: [pluginOasName, pluginTsName].filter(Boolean),
27
- resolvePath(baseName, pathMode, options) {
28
- const root = path.resolve(this.config.root, this.config.output.path);
29
- if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
30
- /**
31
- * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
32
- * Other plugins then need to call addOrAppend instead of just add from the fileManager class
33
- */
34
- return path.resolve(root, output.path);
35
- if (group && (options?.group?.path || options?.group?.tag)) {
36
- const groupName = group?.name ? group.name : (ctx) => {
37
- if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
38
- return `${camelCase(ctx.group)}Requests`;
39
- };
40
- return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
41
- }
42
- return path.resolve(root, output.path, baseName);
43
- },
44
- resolveName(name, type) {
45
- const resolvedName = camelCase(name, { isFile: type === "file" });
46
- if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
47
- return resolvedName;
48
- },
49
- async install() {
50
- const root = path.resolve(this.config.root, this.config.output.path);
51
- const mode = getMode(path.resolve(root, output.path));
52
- const oas = await this.getOas();
53
- const files = await new OperationGenerator(this.plugin.options, {
54
- fabric: this.fabric,
55
- oas,
56
- driver: this.driver,
57
- events: this.events,
58
- plugin: this.plugin,
59
- contentType,
542
+ options,
543
+ dependencies: [pluginTsName],
544
+ hooks: { "kubb:plugin:setup"(ctx) {
545
+ const resolver = userResolver ? {
546
+ ...resolverCypress,
547
+ ...userResolver
548
+ } : resolverCypress;
549
+ ctx.setOptions({
550
+ output,
60
551
  exclude,
61
552
  include,
62
553
  override,
63
- mode
64
- }).build(...generators);
65
- await this.upsertFile(...files);
66
- const barrelFiles = await getBarrelFiles(this.fabric.files, {
67
- type: output.barrelType ?? "named",
68
- root,
69
- output,
70
- meta: { pluginName: this.plugin.name }
554
+ dataReturnType,
555
+ group: groupConfig,
556
+ baseURL,
557
+ paramsCasing,
558
+ paramsType,
559
+ pathParamsType,
560
+ resolver
71
561
  });
72
- await this.upsertFile(...barrelFiles);
73
- }
562
+ ctx.setResolver(resolver);
563
+ if (userTransformer) ctx.setTransformer(userTransformer);
564
+ ctx.addGenerator(cypressGenerator);
565
+ for (const gen of userGenerators) ctx.addGenerator(gen);
566
+ } }
74
567
  };
75
568
  });
76
569
  //#endregion
77
- export { pluginCypress, pluginCypressName };
570
+ export { Request, cypressGenerator, pluginCypress as default, pluginCypress, pluginCypressName, resolverCypress };
78
571
 
79
572
  //# sourceMappingURL=index.js.map