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

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