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

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