@kubb/plugin-cypress 5.0.0-alpha.23 → 5.0.0-alpha.25

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,527 @@
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, transformers } = 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 transformedNode = (0, _kubb_ast.transform)(node, (0, _kubb_ast.composeTransformers)(...transformers));
323
+ const casedParams = (0, _kubb_ast.caseParams)(transformedNode.parameters, paramsCasing);
324
+ const pathParams = casedParams.filter((p) => p.in === "path");
325
+ const queryParams = casedParams.filter((p) => p.in === "query");
326
+ const headerParams = casedParams.filter((p) => p.in === "header");
327
+ const importedTypeNames = [
328
+ ...pathParams.map((p) => pluginTs.resolver.resolvePathParamsName(transformedNode, p)),
329
+ ...queryParams.map((p) => pluginTs.resolver.resolveQueryParamsName(transformedNode, p)),
330
+ ...headerParams.map((p) => pluginTs.resolver.resolveHeaderParamsName(transformedNode, p)),
331
+ transformedNode.requestBody?.schema ? pluginTs.resolver.resolveDataName(transformedNode) : void 0,
332
+ pluginTs.resolver.resolveResponseName(transformedNode)
333
+ ].filter(Boolean);
334
+ const meta = {
335
+ name: resolver.resolveName(transformedNode.operationId),
336
+ file: resolver.resolveFile({
337
+ name: transformedNode.operationId,
338
+ extname: ".ts",
339
+ tag: transformedNode.tags[0] ?? "default",
340
+ path: transformedNode.path
341
+ }, {
342
+ root,
343
+ output,
344
+ group
345
+ }),
346
+ fileTs: pluginTs.resolver.resolveFile({
347
+ name: transformedNode.operationId,
348
+ extname: ".ts",
349
+ tag: transformedNode.tags[0] ?? "default",
350
+ path: transformedNode.path
351
+ }, {
352
+ root,
353
+ output: pluginTs.options?.output ?? output,
354
+ group: pluginTs.options?.group
355
+ })
356
+ };
357
+ return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
358
+ baseName: meta.file.baseName,
359
+ path: meta.file.path,
360
+ meta: meta.file.meta,
361
+ banner: resolver.resolveBanner(adapter.rootNode, {
362
+ output,
363
+ config
364
+ }),
365
+ footer: resolver.resolveFooter(adapter.rootNode, {
366
+ output,
367
+ config
368
+ }),
369
+ children: [meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
370
+ name: Array.from(new Set(importedTypeNames)),
371
+ root: meta.file.path,
372
+ path: meta.fileTs.path,
373
+ isTypeOnly: true
374
+ }), /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(Request, {
375
+ name: meta.name,
376
+ node: transformedNode,
377
+ resolver: pluginTs.resolver,
378
+ dataReturnType,
379
+ paramsCasing,
380
+ paramsType,
381
+ pathParamsType,
382
+ baseURL
383
+ })]
384
+ });
385
+ }
386
+ });
387
+ //#endregion
388
+ //#region src/resolvers/resolverCypress.ts
389
+ /**
390
+ * Resolver for `@kubb/plugin-cypress` that provides the default naming
391
+ * and path-resolution helpers used by the plugin.
392
+ *
393
+ * @example
394
+ * ```ts
395
+ * import { resolverCypress } from '@kubb/plugin-cypress'
396
+ *
397
+ * resolverCypress.default('list pets', 'function') // -> 'listPets'
398
+ * resolverCypress.resolveName('show pet by id') // -> 'showPetById'
399
+ * ```
400
+ */
401
+ const resolverCypress = (0, _kubb_core.defineResolver)(() => ({
402
+ name: "default",
403
+ pluginName: "plugin-cypress",
404
+ default(name, type) {
405
+ return camelCase(name, { isFile: type === "file" });
406
+ },
407
+ resolveName(name) {
408
+ return this.default(name, "function");
409
+ }
410
+ }));
411
+ //#endregion
412
+ //#region src/presets.ts
413
+ /**
414
+ * Built-in preset registry for `@kubb/plugin-cypress`.
415
+ *
416
+ * - `default` — uses `resolverCypress` and `cypressGenerator`.
417
+ * - `kubbV4` — uses `resolverCypress` and `cypressGenerator`.
418
+ */
419
+ const presets = (0, _kubb_core.definePresets)({
420
+ default: {
421
+ name: "default",
422
+ resolvers: [resolverCypress],
423
+ generators: [cypressGenerator]
424
+ },
425
+ kubbV4: {
426
+ name: "kubbV4",
427
+ resolvers: [resolverCypress],
428
+ generators: [cypressGenerator]
429
+ }
430
+ });
431
+ //#endregion
9
432
  //#region src/plugin.ts
433
+ /**
434
+ * Canonical plugin name for `@kubb/plugin-cypress`, used to identify the plugin
435
+ * in driver lookups and warnings.
436
+ */
10
437
  const pluginCypressName = "plugin-cypress";
438
+ /**
439
+ * The `@kubb/plugin-cypress` plugin factory.
440
+ *
441
+ * Generates Cypress `cy.request()` test functions from an OpenAPI/AST `RootNode`.
442
+ * Walks operations, delegates rendering to the active generators,
443
+ * and writes barrel files based on `output.barrelType`.
444
+ *
445
+ * @example
446
+ * ```ts
447
+ * import { pluginCypress } from '@kubb/plugin-cypress'
448
+ *
449
+ * export default defineConfig({
450
+ * plugins: [pluginCypress({ output: { path: 'cypress' } })],
451
+ * })
452
+ * ```
453
+ */
11
454
  const pluginCypress = (0, _kubb_core.createPlugin)((options) => {
12
455
  const { output = {
13
456
  path: "cypress",
14
457
  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;
458
+ }, 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;
459
+ const preset = (0, _kubb_core.getPreset)({
460
+ preset: compatibilityPreset,
461
+ presets,
462
+ resolvers: [resolverCypress, ...userResolvers],
463
+ transformers: userTransformers,
464
+ generators: userGenerators
465
+ });
16
466
  return {
17
467
  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);
468
+ get resolver() {
469
+ return preset.resolver;
44
470
  },
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;
471
+ get options() {
472
+ return {
473
+ output,
474
+ dataReturnType,
475
+ group: group ? {
476
+ ...group,
477
+ name: group.name ? group.name : (ctx) => {
478
+ if (group.type === "path") return `${ctx.group.split("/")[1]}`;
479
+ return `${camelCase(ctx.group)}Requests`;
480
+ }
481
+ } : void 0,
482
+ baseURL,
483
+ paramsCasing,
484
+ paramsType,
485
+ pathParamsType,
486
+ resolver: preset.resolver,
487
+ transformers: preset.transformers
488
+ };
49
489
  },
490
+ pre: [_kubb_plugin_ts.pluginTsName].filter(Boolean),
50
491
  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,
492
+ const { config, fabric, plugin, adapter, rootNode, driver } = this;
493
+ const root = node_path.default.resolve(config.root, config.output.path);
494
+ const resolver = preset.resolver;
495
+ if (!adapter) throw new Error("Plugin cannot work without adapter being set");
496
+ const collectedOperations = [];
497
+ const generatorContext = {
498
+ generators: preset.generators,
499
+ plugin,
500
+ resolver,
61
501
  exclude,
62
502
  include,
63
503
  override,
64
- mode
65
- }).build(...generators);
66
- await this.upsertFile(...files);
504
+ fabric,
505
+ adapter,
506
+ config,
507
+ driver
508
+ };
509
+ await (0, _kubb_ast.walk)(rootNode, {
510
+ depth: "shallow",
511
+ async schema(schemaNode) {
512
+ await (0, _kubb_core.runGeneratorSchema)(schemaNode, generatorContext);
513
+ },
514
+ async operation(operationNode) {
515
+ if (resolver.resolveOptions(operationNode, {
516
+ options: plugin.options,
517
+ exclude,
518
+ include,
519
+ override
520
+ }) !== null) collectedOperations.push(operationNode);
521
+ await (0, _kubb_core.runGeneratorOperation)(operationNode, generatorContext);
522
+ }
523
+ });
524
+ await (0, _kubb_core.runGeneratorOperations)(collectedOperations, generatorContext);
67
525
  const barrelFiles = await (0, _kubb_core.getBarrelFiles)(this.fabric.files, {
68
526
  type: output.barrelType ?? "named",
69
527
  root,
@@ -75,7 +533,10 @@ const pluginCypress = (0, _kubb_core.createPlugin)((options) => {
75
533
  };
76
534
  });
77
535
  //#endregion
536
+ exports.Request = Request;
537
+ exports.cypressGenerator = cypressGenerator;
78
538
  exports.pluginCypress = pluginCypress;
79
539
  exports.pluginCypressName = pluginCypressName;
540
+ exports.resolverCypress = resolverCypress;
80
541
 
81
542
  //# sourceMappingURL=index.cjs.map