@kubb/plugin-client 5.0.0-alpha.27 → 5.0.0-alpha.29

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.
Files changed (41) hide show
  1. package/dist/index.cjs +1911 -62
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +468 -2
  4. package/dist/index.js +1903 -65
  5. package/dist/index.js.map +1 -1
  6. package/package.json +5 -20
  7. package/src/components/ClassClient.tsx +42 -138
  8. package/src/components/Client.tsx +85 -125
  9. package/src/components/ClientLegacy.tsx +501 -0
  10. package/src/components/Operations.tsx +8 -8
  11. package/src/components/StaticClassClient.tsx +41 -135
  12. package/src/components/Url.tsx +37 -46
  13. package/src/generators/classClientGenerator.tsx +121 -131
  14. package/src/generators/clientGenerator.tsx +104 -80
  15. package/src/generators/groupedClientGenerator.tsx +28 -30
  16. package/src/generators/operationsGenerator.tsx +11 -17
  17. package/src/generators/staticClassClientGenerator.tsx +115 -121
  18. package/src/index.ts +11 -1
  19. package/src/plugin.ts +121 -92
  20. package/src/presets.ts +25 -0
  21. package/src/resolvers/resolverClient.ts +26 -0
  22. package/src/resolvers/resolverClientLegacy.ts +26 -0
  23. package/src/types.ts +93 -39
  24. package/src/utils.ts +148 -0
  25. package/dist/StaticClassClient-D6v3vhZL.js +0 -695
  26. package/dist/StaticClassClient-D6v3vhZL.js.map +0 -1
  27. package/dist/StaticClassClient-GyNiWMHA.cjs +0 -736
  28. package/dist/StaticClassClient-GyNiWMHA.cjs.map +0 -1
  29. package/dist/components.cjs +0 -7
  30. package/dist/components.d.ts +0 -216
  31. package/dist/components.js +0 -2
  32. package/dist/generators-C0t5dIvZ.js +0 -723
  33. package/dist/generators-C0t5dIvZ.js.map +0 -1
  34. package/dist/generators-D8A8QE4S.cjs +0 -753
  35. package/dist/generators-D8A8QE4S.cjs.map +0 -1
  36. package/dist/generators.cjs +0 -7
  37. package/dist/generators.d.ts +0 -21
  38. package/dist/generators.js +0 -2
  39. package/dist/types-jdcuAELq.d.ts +0 -169
  40. package/src/components/index.ts +0 -5
  41. package/src/generators/index.ts +0 -5
package/dist/index.js CHANGED
@@ -1,79 +1,1907 @@
1
- import "./chunk--u3MIqq1.js";
2
- import { o as camelCase } from "./StaticClassClient-D6v3vhZL.js";
3
- import { a as classClientGenerator, i as clientGenerator, n as operationsGenerator, r as groupedClientGenerator, t as staticClassClientGenerator } from "./generators-C0t5dIvZ.js";
1
+ import { t as __name } from "./chunk--u3MIqq1.js";
4
2
  import { source } from "./templates/clients/axios.source.js";
5
3
  import { source as source$1 } from "./templates/clients/fetch.source.js";
6
4
  import { source as source$2 } from "./templates/config.source.js";
7
5
  import path from "node:path";
8
- import { createPlugin, getBarrelFiles, getMode } from "@kubb/core";
9
- import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
6
+ import { caseParams, createFunctionParameter, createOperationParams, createTypeNode, transform, walk } from "@kubb/ast";
7
+ import { functionPrinter, pluginTsName } from "@kubb/plugin-ts";
8
+ import { Const, File, Function as Function$1, FunctionParams } from "@kubb/react-fabric";
9
+ import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
10
+ import { createPlugin, defineGenerator, definePresets, defineResolver, getBarrelFiles, getPreset, runGeneratorOperation, runGeneratorOperations } from "@kubb/core";
10
11
  import { pluginZodName } from "@kubb/plugin-zod";
12
+ //#region ../../internals/utils/src/casing.ts
13
+ /**
14
+ * Shared implementation for camelCase and PascalCase conversion.
15
+ * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
16
+ * and capitalizes each word according to `pascal`.
17
+ *
18
+ * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
19
+ */
20
+ function toCamelOrPascal(text, pascal) {
21
+ 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) => {
22
+ if (word.length > 1 && word === word.toUpperCase()) return word;
23
+ if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
24
+ return word.charAt(0).toUpperCase() + word.slice(1);
25
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
26
+ }
27
+ /**
28
+ * Splits `text` on `.` and applies `transformPart` to each segment.
29
+ * The last segment receives `isLast = true`, all earlier segments receive `false`.
30
+ * Segments are joined with `/` to form a file path.
31
+ *
32
+ * Only splits on dots followed by a letter so that version numbers
33
+ * embedded in operationIds (e.g. `v2025.0`) are kept intact.
34
+ */
35
+ function applyToFileParts(text, transformPart) {
36
+ const parts = text.split(/\.(?=[a-zA-Z])/);
37
+ return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
38
+ }
39
+ /**
40
+ * Converts `text` to camelCase.
41
+ * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
42
+ *
43
+ * @example
44
+ * camelCase('hello-world') // 'helloWorld'
45
+ * camelCase('pet.petId', { isFile: true }) // 'pet/petId'
46
+ */
47
+ function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
48
+ if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
49
+ prefix,
50
+ suffix
51
+ } : {}));
52
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
53
+ }
54
+ /**
55
+ * Converts `text` to PascalCase.
56
+ * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.
57
+ *
58
+ * @example
59
+ * pascalCase('hello-world') // 'HelloWorld'
60
+ * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'
61
+ */
62
+ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
63
+ if (isFile) return applyToFileParts(text, (part, isLast) => isLast ? pascalCase(part, {
64
+ prefix,
65
+ suffix
66
+ }) : camelCase(part));
67
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
68
+ }
69
+ //#endregion
70
+ //#region ../../internals/utils/src/jsdoc.ts
71
+ /**
72
+ * Builds a JSDoc comment block from an array of lines.
73
+ * Returns `fallback` when `comments` is empty so callers always get a usable string.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * buildJSDoc(['@type string', '@example hello'])
78
+ * // '/**\n * @type string\n * @example hello\n *\/\n '
79
+ * ```
80
+ */
81
+ function buildJSDoc(comments, options = {}) {
82
+ const { indent = " * ", suffix = "\n ", fallback = " " } = options;
83
+ if (comments.length === 0) return fallback;
84
+ return `/**\n${comments.map((c) => `${indent}${c}`).join("\n")}\n */${suffix}`;
85
+ }
86
+ //#endregion
87
+ //#region ../../internals/utils/src/reserved.ts
88
+ /**
89
+ * Returns `true` when `name` is a syntactically valid JavaScript variable name.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * isValidVarName('status') // true
94
+ * isValidVarName('class') // false (reserved word)
95
+ * isValidVarName('42foo') // false (starts with digit)
96
+ * ```
97
+ */
98
+ function isValidVarName(name) {
99
+ try {
100
+ new Function(`var ${name}`);
101
+ } catch {
102
+ return false;
103
+ }
104
+ return true;
105
+ }
106
+ //#endregion
107
+ //#region ../../internals/utils/src/urlPath.ts
108
+ /**
109
+ * Parses and transforms an OpenAPI/Swagger path string into various URL formats.
110
+ *
111
+ * @example
112
+ * const p = new URLPath('/pet/{petId}')
113
+ * p.URL // '/pet/:petId'
114
+ * p.template // '`/pet/${petId}`'
115
+ */
116
+ var URLPath = class {
117
+ /**
118
+ * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
119
+ */
120
+ path;
121
+ #options;
122
+ constructor(path, options = {}) {
123
+ this.path = path;
124
+ this.#options = options;
125
+ }
126
+ /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * new URLPath('/pet/{petId}').URL // '/pet/:petId'
131
+ * ```
132
+ */
133
+ get URL() {
134
+ return this.toURLPath();
135
+ }
136
+ /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
141
+ * new URLPath('/pet/{petId}').isURL // false
142
+ * ```
143
+ */
144
+ get isURL() {
145
+ try {
146
+ return !!new URL(this.path).href;
147
+ } catch {
148
+ return false;
149
+ }
150
+ }
151
+ /**
152
+ * Converts the OpenAPI path to a TypeScript template literal string.
153
+ *
154
+ * @example
155
+ * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
156
+ * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
157
+ */
158
+ get template() {
159
+ return this.toTemplateString();
160
+ }
161
+ /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * new URLPath('/pet/{petId}').object
166
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
167
+ * ```
168
+ */
169
+ get object() {
170
+ return this.toObject();
171
+ }
172
+ /** Returns a map of path parameter names, or `undefined` when the path has no parameters.
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * new URLPath('/pet/{petId}').params // { petId: 'petId' }
177
+ * new URLPath('/pet').params // undefined
178
+ * ```
179
+ */
180
+ get params() {
181
+ return this.getParams();
182
+ }
183
+ #transformParam(raw) {
184
+ const param = isValidVarName(raw) ? raw : camelCase(raw);
185
+ return this.#options.casing === "camelcase" ? camelCase(param) : param;
186
+ }
187
+ /**
188
+ * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.
189
+ */
190
+ #eachParam(fn) {
191
+ for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
192
+ const raw = match[1];
193
+ fn(raw, this.#transformParam(raw));
194
+ }
195
+ }
196
+ toObject({ type = "path", replacer, stringify } = {}) {
197
+ const object = {
198
+ url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
199
+ params: this.getParams()
200
+ };
201
+ if (stringify) {
202
+ if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
203
+ if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
204
+ return `{ url: '${object.url}' }`;
205
+ }
206
+ return object;
207
+ }
208
+ /**
209
+ * Converts the OpenAPI path to a TypeScript template literal string.
210
+ * An optional `replacer` can transform each extracted parameter name before interpolation.
211
+ *
212
+ * @example
213
+ * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
214
+ */
215
+ toTemplateString({ prefix = "", replacer } = {}) {
216
+ return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
217
+ if (i % 2 === 0) return part;
218
+ const param = this.#transformParam(part);
219
+ return `\${${replacer ? replacer(param) : param}}`;
220
+ }).join("")}\``;
221
+ }
222
+ /**
223
+ * Extracts all `{param}` segments from the path and returns them as a key-value map.
224
+ * An optional `replacer` transforms each parameter name in both key and value positions.
225
+ * Returns `undefined` when no path parameters are found.
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * new URLPath('/pet/{petId}/tag/{tagId}').getParams()
230
+ * // { petId: 'petId', tagId: 'tagId' }
231
+ * ```
232
+ */
233
+ getParams(replacer) {
234
+ const params = {};
235
+ this.#eachParam((_raw, param) => {
236
+ const key = replacer ? replacer(param) : param;
237
+ params[key] = key;
238
+ });
239
+ return Object.keys(params).length > 0 ? params : void 0;
240
+ }
241
+ /** Converts the OpenAPI path to Express-style colon syntax.
242
+ *
243
+ * @example
244
+ * ```ts
245
+ * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
246
+ * ```
247
+ */
248
+ toURLPath() {
249
+ return this.path.replace(/\{([^}]+)\}/g, ":$1");
250
+ }
251
+ };
252
+ //#endregion
253
+ //#region src/utils.ts
254
+ function getComments(node) {
255
+ return [
256
+ node.description && `@description ${node.description}`,
257
+ node.summary && `@summary ${node.summary}`,
258
+ node.path && `{@link ${new URLPath(node.path).URL}}`,
259
+ node.deprecated && "@deprecated"
260
+ ].filter((x) => Boolean(x)).flatMap((text) => text.split(/\r?\n/).map((line) => line.trim())).filter((x) => Boolean(x));
261
+ }
262
+ function buildParamsMapping(originalParams, casedParams) {
263
+ const mapping = {};
264
+ let hasChanged = false;
265
+ originalParams.forEach((param, i) => {
266
+ const casedName = casedParams[i]?.name ?? param.name;
267
+ mapping[param.name] = casedName;
268
+ if (param.name !== casedName) hasChanged = true;
269
+ });
270
+ return hasChanged ? mapping : void 0;
271
+ }
272
+ function buildHeaders(contentType, hasHeaderParams) {
273
+ return [contentType !== "application/json" && contentType !== "multipart/form-data" ? `'Content-Type': '${contentType}'` : void 0, hasHeaderParams ? "...headers" : void 0].filter(Boolean);
274
+ }
275
+ function buildGenerics(node, tsResolver) {
276
+ const responseName = tsResolver.resolveResponseName(node);
277
+ const requestName = node.requestBody?.schema ? tsResolver.resolveDataName(node) : void 0;
278
+ const errorNames = node.responses.filter((r) => Number.parseInt(r.statusCode, 10) >= 400).map((r) => tsResolver.resolveResponseStatusName(node, r.statusCode));
279
+ return [
280
+ responseName,
281
+ `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`,
282
+ requestName || "unknown"
283
+ ].filter(Boolean);
284
+ }
285
+ function buildClassClientParams({ node, path, baseURL, tsResolver, isFormData, headers }) {
286
+ const queryParamsName = node.parameters.filter((p) => p.in === "query").length > 0 ? tsResolver.resolveQueryParamsName(node, node.parameters.filter((p) => p.in === "query")[0]) : void 0;
287
+ const requestName = node.requestBody?.schema ? tsResolver.resolveDataName(node) : void 0;
288
+ return FunctionParams.factory({ config: {
289
+ mode: "object",
290
+ children: {
291
+ requestConfig: { mode: "inlineSpread" },
292
+ method: { value: JSON.stringify(node.method.toUpperCase()) },
293
+ url: { value: path.template },
294
+ baseURL: baseURL ? { value: JSON.stringify(baseURL) } : void 0,
295
+ params: queryParamsName ? {} : void 0,
296
+ data: requestName ? { value: isFormData ? "formData as FormData" : "requestData" } : void 0,
297
+ headers: headers.length ? { value: `{ ${headers.join(", ")}, ...requestConfig.headers }` } : void 0
298
+ }
299
+ } });
300
+ }
301
+ function buildRequestDataLine({ parser, node, zodResolver }) {
302
+ const zodRequestName = zodResolver && parser === "zod" && node.requestBody?.schema ? zodResolver.resolveDataName?.(node) : void 0;
303
+ if (parser === "zod" && zodRequestName) return `const requestData = ${zodRequestName}.parse(data)`;
304
+ if (node.requestBody?.schema) return "const requestData = data";
305
+ return "";
306
+ }
307
+ function buildFormDataLine(isFormData, hasRequest) {
308
+ return isFormData && hasRequest ? "const formData = buildFormData(requestData)" : "";
309
+ }
310
+ function buildReturnStatement({ dataReturnType, parser, node, zodResolver }) {
311
+ const zodResponseName = zodResolver && parser === "zod" ? zodResolver.resolveResponseName?.(node) : void 0;
312
+ if (dataReturnType === "full" && parser === "zod" && zodResponseName) return `return {...res, data: ${zodResponseName}.parse(res.data)}`;
313
+ if (dataReturnType === "data" && parser === "zod" && zodResponseName) return `return ${zodResponseName}.parse(res.data)`;
314
+ if (dataReturnType === "full" && parser === "client") return "return res";
315
+ return "return res.data";
316
+ }
317
+ //#endregion
318
+ //#region src/components/Url.tsx
319
+ const declarationPrinter$3 = functionPrinter({ mode: "declaration" });
320
+ function getParams$2({ paramsType, paramsCasing, pathParamsType, node, tsResolver }) {
321
+ return createOperationParams({
322
+ ...node,
323
+ parameters: node.parameters.filter((p) => p.in === "path"),
324
+ requestBody: void 0
325
+ }, {
326
+ paramsType: paramsType === "object" ? "object" : "inline",
327
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
328
+ paramsCasing,
329
+ resolver: tsResolver
330
+ });
331
+ }
332
+ __name(getParams$2, "getParams");
333
+ function Url({ name, isExportable = true, isIndexable = true, baseURL, paramsType, paramsCasing, pathParamsType, node, tsResolver }) {
334
+ const path = new URLPath(node.path);
335
+ const paramsNode = getParams$2({
336
+ paramsType,
337
+ paramsCasing,
338
+ pathParamsType,
339
+ node,
340
+ tsResolver
341
+ });
342
+ const paramsSignature = declarationPrinter$3.print(paramsNode) ?? "";
343
+ const originalPathParams = node.parameters.filter((p) => p.in === "path");
344
+ const casedPathParams = caseParams(originalPathParams, paramsCasing);
345
+ const pathParamsMapping = paramsCasing ? buildParamsMapping(originalPathParams, casedPathParams) : void 0;
346
+ return /* @__PURE__ */ jsx(File.Source, {
347
+ name,
348
+ isExportable,
349
+ isIndexable,
350
+ children: /* @__PURE__ */ jsxs(Function$1, {
351
+ name,
352
+ export: isExportable,
353
+ params: paramsSignature,
354
+ children: [
355
+ pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => isValidVarName(originalName) && originalName !== camelCaseName).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
356
+ pathParamsMapping && Object.keys(pathParamsMapping).length > 0 && /* @__PURE__ */ jsx("br", {}),
357
+ /* @__PURE__ */ jsx(Const, {
358
+ name: "res",
359
+ children: `{ method: '${node.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`
360
+ }),
361
+ /* @__PURE__ */ jsx("br", {}),
362
+ "return res"
363
+ ]
364
+ })
365
+ });
366
+ }
367
+ Url.getParams = getParams$2;
368
+ //#endregion
369
+ //#region src/components/Client.tsx
370
+ const declarationPrinter$2 = functionPrinter({ mode: "declaration" });
371
+ function getParams$1({ paramsType, paramsCasing, pathParamsType, node, tsResolver, isConfigurable }) {
372
+ const requestName = node.requestBody?.schema ? tsResolver.resolveDataName(node) : void 0;
373
+ return createOperationParams(node, {
374
+ paramsType,
375
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
376
+ paramsCasing,
377
+ resolver: tsResolver,
378
+ extraParams: isConfigurable ? [createFunctionParameter({
379
+ name: "config",
380
+ type: createTypeNode({
381
+ variant: "reference",
382
+ name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
383
+ }),
384
+ default: "{}"
385
+ })] : []
386
+ });
387
+ }
388
+ __name(getParams$1, "getParams");
389
+ function Client({ name, isExportable = true, isIndexable = true, returnType, baseURL, dataReturnType, parser, paramsType, paramsCasing, pathParamsType, node, tsResolver, zodResolver, urlName, children, isConfigurable = true }) {
390
+ const path = new URLPath(node.path);
391
+ const contentType = node.requestBody?.contentType ?? "application/json";
392
+ const isFormData = contentType === "multipart/form-data";
393
+ const originalPathParams = node.parameters.filter((p) => p.in === "path");
394
+ const casedPathParams = caseParams(originalPathParams, paramsCasing);
395
+ const originalQueryParams = node.parameters.filter((p) => p.in === "query");
396
+ const casedQueryParams = caseParams(originalQueryParams, paramsCasing);
397
+ const originalHeaderParams = node.parameters.filter((p) => p.in === "header");
398
+ const casedHeaderParams = caseParams(originalHeaderParams, paramsCasing);
399
+ const pathParamsMapping = paramsCasing && !urlName ? buildParamsMapping(originalPathParams, casedPathParams) : void 0;
400
+ const queryParamsMapping = paramsCasing ? buildParamsMapping(originalQueryParams, casedQueryParams) : void 0;
401
+ const headerParamsMapping = paramsCasing ? buildParamsMapping(originalHeaderParams, casedHeaderParams) : void 0;
402
+ const requestName = node.requestBody?.schema ? tsResolver.resolveDataName(node) : void 0;
403
+ const responseName = tsResolver.resolveResponseName(node);
404
+ const queryParamsName = originalQueryParams.length > 0 ? tsResolver.resolveQueryParamsName(node, originalQueryParams[0]) : void 0;
405
+ const headerParamsName = originalHeaderParams.length > 0 ? tsResolver.resolveHeaderParamsName(node, originalHeaderParams[0]) : void 0;
406
+ const zodResponseName = zodResolver && parser === "zod" ? zodResolver.resolveResponseName?.(node) : void 0;
407
+ const zodRequestName = zodResolver && parser === "zod" && node.requestBody?.schema ? zodResolver.resolveDataName?.(node) : void 0;
408
+ const errorNames = node.responses.filter((r) => {
409
+ return Number.parseInt(r.statusCode, 10) >= 400;
410
+ }).map((r) => tsResolver.resolveResponseStatusName(node, r.statusCode));
411
+ const headers = [contentType !== "application/json" && contentType !== "multipart/form-data" ? `'Content-Type': '${contentType}'` : void 0, headerParamsName ? headerParamsMapping ? "...mappedHeaders" : "...headers" : void 0].filter(Boolean);
412
+ const generics = [
413
+ responseName,
414
+ `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`,
415
+ requestName || "unknown"
416
+ ].filter(Boolean);
417
+ const paramsNode = getParams$1({
418
+ paramsType,
419
+ paramsCasing,
420
+ pathParamsType,
421
+ node,
422
+ tsResolver,
423
+ isConfigurable
424
+ });
425
+ const paramsSignature = declarationPrinter$2.print(paramsNode) ?? "";
426
+ const urlParamsNode = Url.getParams({
427
+ paramsType,
428
+ paramsCasing,
429
+ pathParamsType,
430
+ node,
431
+ tsResolver
432
+ });
433
+ const urlParamsCall = functionPrinter({ mode: "call" }).print(urlParamsNode) ?? "";
434
+ const clientParams = FunctionParams.factory({ config: {
435
+ mode: "object",
436
+ children: {
437
+ method: { value: JSON.stringify(node.method.toUpperCase()) },
438
+ url: { value: urlName ? `${urlName}(${urlParamsCall}).url.toString()` : path.template },
439
+ baseURL: baseURL && !urlName ? { value: `\`${baseURL}\`` } : void 0,
440
+ params: queryParamsName ? queryParamsMapping ? { value: "mappedParams" } : {} : void 0,
441
+ data: requestName ? { value: isFormData ? "formData as FormData" : "requestData" } : void 0,
442
+ requestConfig: isConfigurable ? { mode: "inlineSpread" } : void 0,
443
+ headers: headers.length ? { value: isConfigurable ? `{ ${headers.join(", ")}, ...requestConfig.headers }` : `{ ${headers.join(", ")} }` } : void 0
444
+ }
445
+ } });
446
+ const childrenElement = children ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
447
+ dataReturnType === "full" && parser === "zod" && zodResponseName && `return {...res, data: ${zodResponseName}.parse(res.data)}`,
448
+ dataReturnType === "data" && parser === "zod" && zodResponseName && `return ${zodResponseName}.parse(res.data)`,
449
+ dataReturnType === "full" && parser === "client" && "return res",
450
+ dataReturnType === "data" && parser === "client" && "return res.data"
451
+ ] });
452
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("br", {}), /* @__PURE__ */ jsx(File.Source, {
453
+ name,
454
+ isExportable,
455
+ isIndexable,
456
+ children: /* @__PURE__ */ jsxs(Function$1, {
457
+ name,
458
+ async: true,
459
+ export: isExportable,
460
+ params: paramsSignature,
461
+ JSDoc: { comments: getComments(node) },
462
+ returnType,
463
+ children: [
464
+ isConfigurable ? "const { client: request = fetch, ...requestConfig } = config" : "",
465
+ /* @__PURE__ */ jsx("br", {}),
466
+ /* @__PURE__ */ jsx("br", {}),
467
+ pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => isValidVarName(originalName) && originalName !== camelCaseName).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
468
+ pathParamsMapping && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("br", {}), /* @__PURE__ */ jsx("br", {})] }),
469
+ queryParamsMapping && queryParamsName && /* @__PURE__ */ jsxs(Fragment, { children: [
470
+ `const mappedParams = params ? { ${Object.entries(queryParamsMapping).map(([originalName, camelCaseName]) => `"${originalName}": params.${camelCaseName}`).join(", ")} } : undefined`,
471
+ /* @__PURE__ */ jsx("br", {}),
472
+ /* @__PURE__ */ jsx("br", {})
473
+ ] }),
474
+ headerParamsMapping && headerParamsName && /* @__PURE__ */ jsxs(Fragment, { children: [
475
+ `const mappedHeaders = headers ? { ${Object.entries(headerParamsMapping).map(([originalName, camelCaseName]) => `"${originalName}": headers.${camelCaseName}`).join(", ")} } : undefined`,
476
+ /* @__PURE__ */ jsx("br", {}),
477
+ /* @__PURE__ */ jsx("br", {})
478
+ ] }),
479
+ parser === "zod" && zodRequestName ? `const requestData = ${zodRequestName}.parse(data)` : requestName && "const requestData = data",
480
+ /* @__PURE__ */ jsx("br", {}),
481
+ isFormData && requestName && "const formData = buildFormData(requestData)",
482
+ /* @__PURE__ */ jsx("br", {}),
483
+ isConfigurable ? `const res = await request<${generics.join(", ")}>(${clientParams.toCall()})` : `const res = await fetch<${generics.join(", ")}>(${clientParams.toCall()})`,
484
+ /* @__PURE__ */ jsx("br", {}),
485
+ childrenElement
486
+ ]
487
+ })
488
+ })] });
489
+ }
490
+ Client.getParams = getParams$1;
491
+ //#endregion
492
+ //#region src/components/ClientLegacy.tsx
493
+ function isSchemaRequired(schema) {
494
+ if (!schema) return false;
495
+ return Array.isArray(schema.required) ? !!schema.required.length : !!schema.required;
496
+ }
497
+ function isSchemaOptional(schema) {
498
+ return !isSchemaRequired(schema);
499
+ }
500
+ function isAllOptionalDeep(schema) {
501
+ if (!schema) return true;
502
+ if (Array.isArray(schema.required) && schema.required.length > 0) return false;
503
+ if (schema.allOf) return schema.allOf.every(isAllOptionalDeep);
504
+ return true;
505
+ }
506
+ function getSchemaDefaultValue(schema) {
507
+ if (!schema || !isSchemaOptional(schema)) return void 0;
508
+ if (schema.type === "array") return "[]";
509
+ if (schema.anyOf || schema.oneOf) {
510
+ const variants = schema.anyOf || schema.oneOf;
511
+ if (!Array.isArray(variants)) return void 0;
512
+ if (variants.some(isAllOptionalDeep)) return "{}";
513
+ return;
514
+ }
515
+ if (schema.type === "object" || schema.properties) return "{}";
516
+ }
517
+ function legacyGetPathParams(operationSchema, options = {}) {
518
+ if (!operationSchema?.schema?.properties || !operationSchema.name) return {};
519
+ const requiredFields = Array.isArray(operationSchema.schema.required) ? operationSchema.schema.required : [];
520
+ return Object.entries(operationSchema.schema.properties).reduce((acc, [name]) => {
521
+ if (!name) return acc;
522
+ let paramName = name;
523
+ if (options.casing === "camelcase") paramName = camelCase(name);
524
+ else if (!isValidVarName(name)) paramName = camelCase(name);
525
+ const accessName = options.casing === "camelcase" ? camelCase(name) : name;
526
+ acc[paramName] = {
527
+ default: void 0,
528
+ type: options.typed ? `${operationSchema.name}["${accessName}"]` : void 0,
529
+ optional: !requiredFields.includes(name)
530
+ };
531
+ return acc;
532
+ }, {});
533
+ }
534
+ function legacyGetParamsMapping(operationSchema, options = {}) {
535
+ if (!operationSchema?.schema?.properties) return void 0;
536
+ const allEntries = [];
537
+ let hasTransformation = false;
538
+ Object.entries(operationSchema.schema.properties).forEach(([originalName]) => {
539
+ let transformedName = originalName;
540
+ if (options.casing === "camelcase") transformedName = camelCase(originalName);
541
+ else if (!isValidVarName(originalName)) transformedName = camelCase(originalName);
542
+ allEntries.push([originalName, transformedName]);
543
+ if (transformedName !== originalName) hasTransformation = true;
544
+ });
545
+ if (options.casing === "camelcase" && hasTransformation) return Object.fromEntries(allEntries);
546
+ const mapping = {};
547
+ allEntries.forEach(([originalName, transformedName]) => {
548
+ if (transformedName !== originalName) mapping[originalName] = transformedName;
549
+ });
550
+ return Object.keys(mapping).length > 0 ? mapping : void 0;
551
+ }
552
+ function legacyGetComments(operation) {
553
+ return [
554
+ operation.getDescription?.() && `@description ${operation.getDescription()}`,
555
+ operation.getSummary?.() && `@summary ${operation.getSummary()}`,
556
+ operation.path && `{@link ${new URLPath(operation.path).URL}}`,
557
+ operation.isDeprecated?.() && "@deprecated"
558
+ ].filter((x) => Boolean(x)).flatMap((text) => text.split(/\r?\n/).map((line) => line.trim())).filter((x) => Boolean(x));
559
+ }
560
+ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable }) {
561
+ if (paramsType === "object") {
562
+ const children = {
563
+ ...legacyGetPathParams(typeSchemas.pathParams, {
564
+ typed: true,
565
+ casing: paramsCasing
566
+ }),
567
+ data: typeSchemas.request?.name ? {
568
+ type: typeSchemas.request?.name,
569
+ optional: isSchemaOptional(typeSchemas.request?.schema)
570
+ } : void 0,
571
+ params: typeSchemas.queryParams?.name ? {
572
+ type: typeSchemas.queryParams?.name,
573
+ optional: isSchemaOptional(typeSchemas.queryParams?.schema)
574
+ } : void 0,
575
+ headers: typeSchemas.headerParams?.name ? {
576
+ type: typeSchemas.headerParams?.name,
577
+ optional: isSchemaOptional(typeSchemas.headerParams?.schema)
578
+ } : void 0
579
+ };
580
+ const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
581
+ return FunctionParams.factory({
582
+ data: {
583
+ mode: "object",
584
+ children,
585
+ default: allChildrenAreOptional ? "{}" : void 0
586
+ },
587
+ config: isConfigurable ? {
588
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
589
+ default: "{}"
590
+ } : void 0
591
+ });
592
+ }
593
+ return FunctionParams.factory({
594
+ pathParams: typeSchemas.pathParams?.name ? {
595
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
596
+ children: legacyGetPathParams(typeSchemas.pathParams, {
597
+ typed: true,
598
+ casing: paramsCasing
599
+ }),
600
+ default: getSchemaDefaultValue(typeSchemas.pathParams?.schema)
601
+ } : void 0,
602
+ data: typeSchemas.request?.name ? {
603
+ type: typeSchemas.request?.name,
604
+ optional: isSchemaOptional(typeSchemas.request?.schema)
605
+ } : void 0,
606
+ params: typeSchemas.queryParams?.name ? {
607
+ type: typeSchemas.queryParams?.name,
608
+ optional: isSchemaOptional(typeSchemas.queryParams?.schema)
609
+ } : void 0,
610
+ headers: typeSchemas.headerParams?.name ? {
611
+ type: typeSchemas.headerParams?.name,
612
+ optional: isSchemaOptional(typeSchemas.headerParams?.schema)
613
+ } : void 0,
614
+ config: isConfigurable ? {
615
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
616
+ default: "{}"
617
+ } : void 0
618
+ });
619
+ }
620
+ function ClientLegacy({ name, isExportable = true, isIndexable = true, returnType, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, paramsCasing, pathParamsType, operation, urlName, children, isConfigurable = true }) {
621
+ const path = new URLPath(operation.path);
622
+ const contentType = operation.getContentType?.() ?? "application/json";
623
+ const isFormData = contentType === "multipart/form-data";
624
+ const pathParamsMapping = paramsCasing && !urlName ? legacyGetParamsMapping(typeSchemas.pathParams, { casing: paramsCasing }) : void 0;
625
+ const queryParamsMapping = paramsCasing ? legacyGetParamsMapping(typeSchemas.queryParams, { casing: paramsCasing }) : void 0;
626
+ const headerParamsMapping = paramsCasing ? legacyGetParamsMapping(typeSchemas.headerParams, { casing: paramsCasing }) : void 0;
627
+ const headers = [contentType !== "application/json" && contentType !== "multipart/form-data" ? `'Content-Type': '${contentType}'` : void 0, typeSchemas.headerParams?.name ? headerParamsMapping ? "...mappedHeaders" : "...headers" : void 0].filter(Boolean);
628
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
629
+ const generics = [
630
+ typeSchemas.response.name,
631
+ TError,
632
+ typeSchemas.request?.name || "unknown"
633
+ ].filter(Boolean);
634
+ const params = getParams({
635
+ paramsType,
636
+ paramsCasing,
637
+ pathParamsType,
638
+ typeSchemas,
639
+ isConfigurable
640
+ });
641
+ const urlParams = UrlLegacy.getParams({
642
+ paramsType,
643
+ paramsCasing,
644
+ pathParamsType,
645
+ typeSchemas
646
+ });
647
+ const clientParams = FunctionParams.factory({ config: {
648
+ mode: "object",
649
+ children: {
650
+ method: { value: JSON.stringify(operation.method.toUpperCase()) },
651
+ url: { value: urlName ? `${urlName}(${urlParams.toCall()}).url.toString()` : path.template },
652
+ baseURL: baseURL && !urlName ? { value: `\`${baseURL}\`` } : void 0,
653
+ params: typeSchemas.queryParams?.name ? queryParamsMapping ? { value: "mappedParams" } : {} : void 0,
654
+ data: typeSchemas.request?.name ? { value: isFormData ? "formData as FormData" : "requestData" } : void 0,
655
+ requestConfig: isConfigurable ? { mode: "inlineSpread" } : void 0,
656
+ headers: headers.length ? { value: isConfigurable ? `{ ${headers.join(", ")}, ...requestConfig.headers }` : `{ ${headers.join(", ")} }` } : void 0
657
+ }
658
+ } });
659
+ const childrenElement = children ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
660
+ dataReturnType === "full" && parser === "zod" && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`,
661
+ dataReturnType === "data" && parser === "zod" && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`,
662
+ dataReturnType === "full" && parser === "client" && "return res",
663
+ dataReturnType === "data" && parser === "client" && "return res.data"
664
+ ] });
665
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("br", {}), /* @__PURE__ */ jsx(File.Source, {
666
+ name,
667
+ isExportable,
668
+ isIndexable,
669
+ children: /* @__PURE__ */ jsxs(Function$1, {
670
+ name,
671
+ async: true,
672
+ export: isExportable,
673
+ params: params.toConstructor(),
674
+ JSDoc: { comments: legacyGetComments(operation) },
675
+ returnType,
676
+ children: [
677
+ isConfigurable ? "const { client: request = fetch, ...requestConfig } = config" : "",
678
+ /* @__PURE__ */ jsx("br", {}),
679
+ /* @__PURE__ */ jsx("br", {}),
680
+ pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => originalName !== camelCaseName && isValidVarName(originalName)).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
681
+ pathParamsMapping && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("br", {}), /* @__PURE__ */ jsx("br", {})] }),
682
+ queryParamsMapping && typeSchemas.queryParams?.name && /* @__PURE__ */ jsxs(Fragment, { children: [
683
+ `const mappedParams = params ? { ${Object.entries(queryParamsMapping).map(([originalName, camelCaseName]) => `"${originalName}": params.${camelCaseName}`).join(", ")} } : undefined`,
684
+ /* @__PURE__ */ jsx("br", {}),
685
+ /* @__PURE__ */ jsx("br", {})
686
+ ] }),
687
+ headerParamsMapping && typeSchemas.headerParams?.name && /* @__PURE__ */ jsxs(Fragment, { children: [
688
+ `const mappedHeaders = headers ? { ${Object.entries(headerParamsMapping).map(([originalName, camelCaseName]) => `"${originalName}": headers.${camelCaseName}`).join(", ")} } : undefined`,
689
+ /* @__PURE__ */ jsx("br", {}),
690
+ /* @__PURE__ */ jsx("br", {})
691
+ ] }),
692
+ parser === "zod" && zodSchemas?.request?.name ? `const requestData = ${zodSchemas.request.name}.parse(data)` : typeSchemas?.request?.name && "const requestData = data",
693
+ /* @__PURE__ */ jsx("br", {}),
694
+ isFormData && typeSchemas?.request?.name && "const formData = buildFormData(requestData)",
695
+ /* @__PURE__ */ jsx("br", {}),
696
+ isConfigurable ? `const res = await request<${generics.join(", ")}>(${clientParams.toCall()})` : `const res = await fetch<${generics.join(", ")}>(${clientParams.toCall()})`,
697
+ /* @__PURE__ */ jsx("br", {}),
698
+ childrenElement
699
+ ]
700
+ })
701
+ })] });
702
+ }
703
+ ClientLegacy.getParams = getParams;
704
+ function getUrlParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
705
+ if (paramsType === "object") {
706
+ const pathParams = legacyGetPathParams(typeSchemas.pathParams, {
707
+ typed: true,
708
+ casing: paramsCasing
709
+ });
710
+ return FunctionParams.factory({ data: {
711
+ mode: "object",
712
+ children: { ...pathParams }
713
+ } });
714
+ }
715
+ return FunctionParams.factory({ pathParams: typeSchemas.pathParams?.name ? {
716
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
717
+ children: legacyGetPathParams(typeSchemas.pathParams, {
718
+ typed: true,
719
+ casing: paramsCasing
720
+ }),
721
+ default: getSchemaDefaultValue(typeSchemas.pathParams?.schema)
722
+ } : void 0 });
723
+ }
724
+ function UrlLegacy({ name, isExportable = true, isIndexable = true, typeSchemas, baseURL, paramsType, paramsCasing, pathParamsType, operation }) {
725
+ const path = new URLPath(operation.path);
726
+ const params = getUrlParams({
727
+ paramsType,
728
+ paramsCasing,
729
+ pathParamsType,
730
+ typeSchemas
731
+ });
732
+ const pathParamsMapping = paramsCasing ? legacyGetParamsMapping(typeSchemas.pathParams, { casing: paramsCasing }) : void 0;
733
+ return /* @__PURE__ */ jsx(File.Source, {
734
+ name,
735
+ isExportable,
736
+ isIndexable,
737
+ children: /* @__PURE__ */ jsxs(Function$1, {
738
+ name,
739
+ export: isExportable,
740
+ params: params.toConstructor(),
741
+ children: [
742
+ pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => originalName !== camelCaseName && isValidVarName(originalName)).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
743
+ pathParamsMapping && /* @__PURE__ */ jsx("br", {}),
744
+ /* @__PURE__ */ jsx(Const, {
745
+ name: "res",
746
+ children: `{ method: '${operation.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`
747
+ }),
748
+ /* @__PURE__ */ jsx("br", {}),
749
+ "return res"
750
+ ]
751
+ })
752
+ });
753
+ }
754
+ UrlLegacy.getParams = getUrlParams;
755
+ //#endregion
756
+ //#region src/components/ClassClient.tsx
757
+ const declarationPrinter$1 = functionPrinter({ mode: "declaration" });
758
+ function generateMethod$1({ node, name, tsResolver, zodResolver, baseURL, dataReturnType, parser, paramsType, paramsCasing, pathParamsType }) {
759
+ const path = new URLPath(node.path, { casing: paramsCasing });
760
+ const contentType = node.requestBody?.contentType ?? "application/json";
761
+ const isFormData = contentType === "multipart/form-data";
762
+ const headers = buildHeaders(contentType, !!(node.parameters.filter((p) => p.in === "header").length > 0 ? tsResolver.resolveHeaderParamsName(node, node.parameters.filter((p) => p.in === "header")[0]) : void 0));
763
+ const generics = buildGenerics(node, tsResolver);
764
+ const paramsNode = ClassClient.getParams({
765
+ paramsType,
766
+ paramsCasing,
767
+ pathParamsType,
768
+ node,
769
+ tsResolver,
770
+ isConfigurable: true
771
+ });
772
+ const paramsSignature = declarationPrinter$1.print(paramsNode) ?? "";
773
+ const clientParams = buildClassClientParams({
774
+ node,
775
+ path,
776
+ baseURL,
777
+ tsResolver,
778
+ isFormData,
779
+ headers
780
+ });
781
+ const jsdoc = buildJSDoc(getComments(node));
782
+ const requestDataLine = buildRequestDataLine({
783
+ parser,
784
+ node,
785
+ zodResolver
786
+ });
787
+ const formDataLine = buildFormDataLine(isFormData, !!node.requestBody?.schema);
788
+ const returnStatement = buildReturnStatement({
789
+ dataReturnType,
790
+ parser,
791
+ node,
792
+ zodResolver
793
+ });
794
+ return `${jsdoc}async ${name}(${paramsSignature}) {\n${[
795
+ "const { client: request = fetch, ...requestConfig } = mergeConfig(this.#config, config)",
796
+ "",
797
+ requestDataLine,
798
+ formDataLine,
799
+ `const res = await request<${generics.join(", ")}>(${clientParams.toCall()})`,
800
+ returnStatement
801
+ ].filter(Boolean).map((line) => ` ${line}`).join("\n")}\n }`;
802
+ }
803
+ __name(generateMethod$1, "generateMethod");
804
+ function ClassClient({ name, isExportable = true, isIndexable = true, operations, baseURL, dataReturnType, parser, paramsType, paramsCasing, pathParamsType, children }) {
805
+ const classCode = `export class ${name} {
806
+ #config: Partial<RequestConfig> & { client?: Client }
807
+
808
+ constructor(config: Partial<RequestConfig> & { client?: Client } = {}) {
809
+ this.#config = config
810
+ }
811
+
812
+ ${operations.map(({ node, name: methodName, tsResolver, zodResolver }) => generateMethod$1({
813
+ node,
814
+ name: methodName,
815
+ tsResolver,
816
+ zodResolver,
817
+ baseURL,
818
+ dataReturnType,
819
+ parser,
820
+ paramsType,
821
+ paramsCasing,
822
+ pathParamsType
823
+ })).join("\n\n")}
824
+ }`;
825
+ return /* @__PURE__ */ jsxs(File.Source, {
826
+ name,
827
+ isExportable,
828
+ isIndexable,
829
+ children: [classCode, children]
830
+ });
831
+ }
832
+ ClassClient.getParams = Client.getParams;
833
+ //#endregion
834
+ //#region src/components/WrapperClient.tsx
835
+ function WrapperClient({ name, classNames, isExportable = true, isIndexable = true }) {
836
+ const classCode = `export class ${name} {
837
+ ${classNames.map((className) => ` readonly ${camelCase(className)}: ${className}`).join("\n")}
838
+
839
+ constructor(config: Partial<RequestConfig> & { client?: Client } = {}) {
840
+ ${classNames.map((className) => ` this.${camelCase(className)} = new ${className}(config)`).join("\n")}
841
+ }
842
+ }`;
843
+ return /* @__PURE__ */ jsx(File.Source, {
844
+ name,
845
+ isExportable,
846
+ isIndexable,
847
+ children: classCode
848
+ });
849
+ }
850
+ //#endregion
851
+ //#region src/generators/classClientGenerator.tsx
852
+ function resolveTypeImportNames$1(node, tsResolver) {
853
+ return [
854
+ node.requestBody?.schema ? tsResolver.resolveDataName(node) : void 0,
855
+ tsResolver.resolveResponseName(node),
856
+ ...node.parameters.filter((p) => p.in === "path").map((p) => tsResolver.resolvePathParamsName(node, p)),
857
+ ...node.parameters.filter((p) => p.in === "query").map((p) => tsResolver.resolveQueryParamsName(node, p)),
858
+ ...node.parameters.filter((p) => p.in === "header").map((p) => tsResolver.resolveHeaderParamsName(node, p)),
859
+ ...node.responses.map((res) => tsResolver.resolveResponseStatusName(node, res.statusCode))
860
+ ].filter((n) => Boolean(n));
861
+ }
862
+ __name(resolveTypeImportNames$1, "resolveTypeImportNames");
863
+ function resolveZodImportNames$1(node, zodResolver) {
864
+ return [zodResolver.resolveResponseName?.(node), node.requestBody?.schema ? zodResolver.resolveDataName?.(node) : void 0].filter((n) => Boolean(n));
865
+ }
866
+ __name(resolveZodImportNames$1, "resolveZodImportNames");
867
+ const classClientGenerator = defineGenerator({
868
+ name: "classClient",
869
+ type: "react",
870
+ Operations({ nodes, options, config, driver, resolver, adapter, plugin }) {
871
+ const { output, group, dataReturnType, paramsCasing, paramsType, pathParamsType, parser, importPath, wrapper } = options;
872
+ const baseURL = options.baseURL ?? adapter.rootNode?.meta?.baseURL;
873
+ const root = path.resolve(config.root, config.output.path);
874
+ const pluginTs = driver.getPlugin(pluginTsName);
875
+ if (!pluginTs?.resolver) return null;
876
+ const tsResolver = pluginTs.resolver;
877
+ const tsPluginOptions = pluginTs.options;
878
+ const pluginZod = parser === "zod" ? driver.getPlugin(pluginZodName) : void 0;
879
+ const zodResolver = pluginZod?.resolver;
880
+ function buildOperationData(node) {
881
+ const transformedNode = plugin.transformer ? transform(node, plugin.transformer) : node;
882
+ const typeFile = tsResolver.resolveFile({
883
+ name: transformedNode.operationId,
884
+ extname: ".ts",
885
+ tag: transformedNode.tags[0] ?? "default",
886
+ path: transformedNode.path
887
+ }, {
888
+ root,
889
+ output: tsPluginOptions?.output ?? output,
890
+ group: tsPluginOptions?.group
891
+ });
892
+ const zodFile = zodResolver && pluginZod?.options ? zodResolver.resolveFile({
893
+ name: transformedNode.operationId,
894
+ extname: ".ts",
895
+ tag: transformedNode.tags[0] ?? "default",
896
+ path: transformedNode.path
897
+ }, {
898
+ root,
899
+ output: pluginZod.options.output ?? output,
900
+ group: pluginZod.options.group
901
+ }) : void 0;
902
+ return {
903
+ node: transformedNode,
904
+ name: resolver.resolveName(transformedNode.operationId),
905
+ tsResolver,
906
+ zodResolver,
907
+ typeFile,
908
+ zodFile
909
+ };
910
+ }
911
+ const controllers = nodes.reduce((acc, operationNode) => {
912
+ const tag = operationNode.tags[0];
913
+ const groupName = tag ? group?.name?.({ group: camelCase(tag) }) ?? pascalCase(tag) : "Client";
914
+ if (!tag && !group) {
915
+ const name = "ApiClient";
916
+ const file = resolver.resolveFile({
917
+ name,
918
+ extname: ".ts"
919
+ }, {
920
+ root,
921
+ output,
922
+ group
923
+ });
924
+ const operationData = buildOperationData(operationNode);
925
+ const previous = acc.find((item) => item.file.path === file.path);
926
+ if (previous) previous.operations.push(operationData);
927
+ else acc.push({
928
+ name,
929
+ file,
930
+ operations: [operationData]
931
+ });
932
+ } else if (tag) {
933
+ const name = groupName;
934
+ const file = resolver.resolveFile({
935
+ name,
936
+ extname: ".ts",
937
+ tag
938
+ }, {
939
+ root,
940
+ output,
941
+ group
942
+ });
943
+ const operationData = buildOperationData(operationNode);
944
+ const previous = acc.find((item) => item.file.path === file.path);
945
+ if (previous) previous.operations.push(operationData);
946
+ else acc.push({
947
+ name,
948
+ file,
949
+ operations: [operationData]
950
+ });
951
+ }
952
+ return acc;
953
+ }, []);
954
+ function collectTypeImports(ops) {
955
+ const typeImportsByFile = /* @__PURE__ */ new Map();
956
+ const typeFilesByPath = /* @__PURE__ */ new Map();
957
+ ops.forEach((op) => {
958
+ const names = resolveTypeImportNames$1(op.node, tsResolver);
959
+ if (!typeImportsByFile.has(op.typeFile.path)) typeImportsByFile.set(op.typeFile.path, /* @__PURE__ */ new Set());
960
+ const imports = typeImportsByFile.get(op.typeFile.path);
961
+ names.forEach((n) => {
962
+ imports.add(n);
963
+ });
964
+ typeFilesByPath.set(op.typeFile.path, op.typeFile);
965
+ });
966
+ return {
967
+ typeImportsByFile,
968
+ typeFilesByPath
969
+ };
970
+ }
971
+ function collectZodImports(ops) {
972
+ const zodImportsByFile = /* @__PURE__ */ new Map();
973
+ const zodFilesByPath = /* @__PURE__ */ new Map();
974
+ ops.forEach((op) => {
975
+ if (!op.zodFile || !zodResolver) return;
976
+ const names = resolveZodImportNames$1(op.node, zodResolver);
977
+ if (!zodImportsByFile.has(op.zodFile.path)) zodImportsByFile.set(op.zodFile.path, /* @__PURE__ */ new Set());
978
+ const imports = zodImportsByFile.get(op.zodFile.path);
979
+ names.forEach((n) => {
980
+ imports.add(n);
981
+ });
982
+ zodFilesByPath.set(op.zodFile.path, op.zodFile);
983
+ });
984
+ return {
985
+ zodImportsByFile,
986
+ zodFilesByPath
987
+ };
988
+ }
989
+ const files = controllers.map(({ name, file, operations: ops }) => {
990
+ const { typeImportsByFile, typeFilesByPath } = collectTypeImports(ops);
991
+ const { zodImportsByFile, zodFilesByPath } = parser === "zod" ? collectZodImports(ops) : {
992
+ zodImportsByFile: /* @__PURE__ */ new Map(),
993
+ zodFilesByPath: /* @__PURE__ */ new Map()
994
+ };
995
+ const hasFormData = ops.some((op) => op.node.requestBody?.contentType === "multipart/form-data");
996
+ return /* @__PURE__ */ jsxs(File, {
997
+ baseName: file.baseName,
998
+ path: file.path,
999
+ meta: file.meta,
1000
+ banner: resolver.resolveBanner(adapter.rootNode, {
1001
+ output,
1002
+ config
1003
+ }),
1004
+ footer: resolver.resolveFooter(adapter.rootNode, {
1005
+ output,
1006
+ config
1007
+ }),
1008
+ children: [
1009
+ importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
1010
+ /* @__PURE__ */ jsx(File.Import, {
1011
+ name: "fetch",
1012
+ path: importPath
1013
+ }),
1014
+ /* @__PURE__ */ jsx(File.Import, {
1015
+ name: ["mergeConfig"],
1016
+ path: importPath
1017
+ }),
1018
+ /* @__PURE__ */ jsx(File.Import, {
1019
+ name: [
1020
+ "Client",
1021
+ "RequestConfig",
1022
+ "ResponseErrorConfig"
1023
+ ],
1024
+ path: importPath,
1025
+ isTypeOnly: true
1026
+ })
1027
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1028
+ /* @__PURE__ */ jsx(File.Import, {
1029
+ name: ["fetch"],
1030
+ root: file.path,
1031
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
1032
+ }),
1033
+ /* @__PURE__ */ jsx(File.Import, {
1034
+ name: ["mergeConfig"],
1035
+ root: file.path,
1036
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
1037
+ }),
1038
+ /* @__PURE__ */ jsx(File.Import, {
1039
+ name: [
1040
+ "Client",
1041
+ "RequestConfig",
1042
+ "ResponseErrorConfig"
1043
+ ],
1044
+ root: file.path,
1045
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
1046
+ isTypeOnly: true
1047
+ })
1048
+ ] }),
1049
+ hasFormData && /* @__PURE__ */ jsx(File.Import, {
1050
+ name: ["buildFormData"],
1051
+ root: file.path,
1052
+ path: path.resolve(config.root, config.output.path, ".kubb/config.ts")
1053
+ }),
1054
+ Array.from(typeImportsByFile.entries()).map(([filePath, importSet]) => {
1055
+ const typeFile = typeFilesByPath.get(filePath);
1056
+ if (!typeFile) return null;
1057
+ const importNames = Array.from(importSet).filter(Boolean);
1058
+ if (importNames.length === 0) return null;
1059
+ return /* @__PURE__ */ jsx(File.Import, {
1060
+ name: importNames,
1061
+ root: file.path,
1062
+ path: typeFile.path,
1063
+ isTypeOnly: true
1064
+ }, filePath);
1065
+ }),
1066
+ parser === "zod" && Array.from(zodImportsByFile.entries()).map(([filePath, importSet]) => {
1067
+ const zodFile = zodFilesByPath.get(filePath);
1068
+ if (!zodFile) return null;
1069
+ const importNames = Array.from(importSet).filter(Boolean);
1070
+ if (importNames.length === 0) return null;
1071
+ return /* @__PURE__ */ jsx(File.Import, {
1072
+ name: importNames,
1073
+ root: file.path,
1074
+ path: zodFile.path
1075
+ }, filePath);
1076
+ }),
1077
+ /* @__PURE__ */ jsx(ClassClient, {
1078
+ name,
1079
+ operations: ops,
1080
+ baseURL,
1081
+ dataReturnType,
1082
+ pathParamsType,
1083
+ paramsCasing,
1084
+ paramsType,
1085
+ parser
1086
+ })
1087
+ ]
1088
+ }, file.path);
1089
+ });
1090
+ if (wrapper) {
1091
+ const wrapperFile = resolver.resolveFile({
1092
+ name: wrapper.className,
1093
+ extname: ".ts"
1094
+ }, {
1095
+ root,
1096
+ output,
1097
+ group
1098
+ });
1099
+ files.push(/* @__PURE__ */ jsxs(File, {
1100
+ baseName: wrapperFile.baseName,
1101
+ path: wrapperFile.path,
1102
+ meta: wrapperFile.meta,
1103
+ banner: resolver.resolveBanner(adapter.rootNode, {
1104
+ output,
1105
+ config
1106
+ }),
1107
+ footer: resolver.resolveFooter(adapter.rootNode, {
1108
+ output,
1109
+ config
1110
+ }),
1111
+ children: [
1112
+ importPath ? /* @__PURE__ */ jsx(File.Import, {
1113
+ name: ["Client", "RequestConfig"],
1114
+ path: importPath,
1115
+ isTypeOnly: true
1116
+ }) : /* @__PURE__ */ jsx(File.Import, {
1117
+ name: ["Client", "RequestConfig"],
1118
+ root: wrapperFile.path,
1119
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
1120
+ isTypeOnly: true
1121
+ }),
1122
+ controllers.map(({ name, file }) => /* @__PURE__ */ jsx(File.Import, {
1123
+ name: [name],
1124
+ root: wrapperFile.path,
1125
+ path: file.path
1126
+ }, name)),
1127
+ /* @__PURE__ */ jsx(WrapperClient, {
1128
+ name: wrapper.className,
1129
+ classNames: controllers.map(({ name }) => name)
1130
+ })
1131
+ ]
1132
+ }, wrapperFile.path));
1133
+ }
1134
+ return files;
1135
+ }
1136
+ });
1137
+ //#endregion
1138
+ //#region src/generators/clientGenerator.tsx
1139
+ const clientGenerator = defineGenerator({
1140
+ name: "client",
1141
+ type: "react",
1142
+ Operation({ node, adapter, options, config, driver, resolver, plugin }) {
1143
+ const { output, urlType, dataReturnType, paramsCasing, paramsType, pathParamsType, parser, importPath, group } = options;
1144
+ const baseURL = options.baseURL ?? adapter.rootNode?.meta?.baseURL;
1145
+ const root = path.resolve(config.root, config.output.path);
1146
+ const pluginTs = driver.getPlugin(pluginTsName);
1147
+ if (!pluginTs?.resolver) return null;
1148
+ const tsResolver = pluginTs.resolver;
1149
+ const pluginZod = parser === "zod" ? driver.getPlugin(pluginZodName) : void 0;
1150
+ const zodResolver = pluginZod?.resolver;
1151
+ const transformedNode = plugin.transformer ? transform(node, plugin.transformer) : node;
1152
+ const casedParams = caseParams(transformedNode.parameters, paramsCasing);
1153
+ const pathParams = casedParams.filter((p) => p.in === "path");
1154
+ const queryParams = casedParams.filter((p) => p.in === "query");
1155
+ const headerParams = casedParams.filter((p) => p.in === "header");
1156
+ const importedTypeNames = [
1157
+ ...pathParams.map((p) => tsResolver.resolvePathParamsName(transformedNode, p)),
1158
+ ...queryParams.map((p) => tsResolver.resolveQueryParamsName(transformedNode, p)),
1159
+ ...headerParams.map((p) => tsResolver.resolveHeaderParamsName(transformedNode, p)),
1160
+ transformedNode.requestBody?.schema ? tsResolver.resolveDataName(transformedNode) : void 0,
1161
+ tsResolver.resolveResponseName(transformedNode),
1162
+ ...transformedNode.responses.map((res) => tsResolver.resolveResponseStatusName(transformedNode, res.statusCode))
1163
+ ].filter(Boolean);
1164
+ const importedZodNames = zodResolver && parser === "zod" ? [zodResolver.resolveResponseName?.(transformedNode), transformedNode.requestBody?.schema ? zodResolver.resolveDataName?.(transformedNode) : void 0].filter(Boolean) : [];
1165
+ const meta = {
1166
+ name: resolver.resolveName(transformedNode.operationId),
1167
+ urlName: `get${resolver.resolveName(transformedNode.operationId).charAt(0).toUpperCase()}${resolver.resolveName(transformedNode.operationId).slice(1)}Url`,
1168
+ file: resolver.resolveFile({
1169
+ name: transformedNode.operationId,
1170
+ extname: ".ts",
1171
+ tag: transformedNode.tags[0] ?? "default",
1172
+ path: transformedNode.path
1173
+ }, {
1174
+ root,
1175
+ output,
1176
+ group
1177
+ }),
1178
+ fileTs: tsResolver.resolveFile({
1179
+ name: transformedNode.operationId,
1180
+ extname: ".ts",
1181
+ tag: transformedNode.tags[0] ?? "default",
1182
+ path: transformedNode.path
1183
+ }, {
1184
+ root,
1185
+ output: pluginTs.options?.output ?? output,
1186
+ group: pluginTs.options?.group
1187
+ }),
1188
+ fileZod: zodResolver && pluginZod?.options ? zodResolver.resolveFile({
1189
+ name: transformedNode.operationId,
1190
+ extname: ".ts",
1191
+ tag: transformedNode.tags[0] ?? "default",
1192
+ path: transformedNode.path
1193
+ }, {
1194
+ root,
1195
+ output: pluginZod.options.output ?? output,
1196
+ group: pluginZod.options.group
1197
+ }) : void 0
1198
+ };
1199
+ const isFormData = transformedNode.requestBody?.contentType === "multipart/form-data";
1200
+ return /* @__PURE__ */ jsxs(File, {
1201
+ baseName: meta.file.baseName,
1202
+ path: meta.file.path,
1203
+ meta: meta.file.meta,
1204
+ banner: resolver.resolveBanner(adapter.rootNode, {
1205
+ output,
1206
+ config
1207
+ }),
1208
+ footer: resolver.resolveFooter(adapter.rootNode, {
1209
+ output,
1210
+ config
1211
+ }),
1212
+ children: [
1213
+ importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Import, {
1214
+ name: "fetch",
1215
+ path: importPath
1216
+ }), /* @__PURE__ */ jsx(File.Import, {
1217
+ name: [
1218
+ "Client",
1219
+ "RequestConfig",
1220
+ "ResponseErrorConfig"
1221
+ ],
1222
+ path: importPath,
1223
+ isTypeOnly: true
1224
+ })] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Import, {
1225
+ name: ["fetch"],
1226
+ root: meta.file.path,
1227
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
1228
+ }), /* @__PURE__ */ jsx(File.Import, {
1229
+ name: [
1230
+ "Client",
1231
+ "RequestConfig",
1232
+ "ResponseErrorConfig"
1233
+ ],
1234
+ root: meta.file.path,
1235
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
1236
+ isTypeOnly: true
1237
+ })] }),
1238
+ isFormData && transformedNode.requestBody?.schema && /* @__PURE__ */ jsx(File.Import, {
1239
+ name: ["buildFormData"],
1240
+ root: meta.file.path,
1241
+ path: path.resolve(config.root, config.output.path, ".kubb/config.ts")
1242
+ }),
1243
+ meta.fileZod && importedZodNames.length > 0 && /* @__PURE__ */ jsx(File.Import, {
1244
+ name: importedZodNames,
1245
+ root: meta.file.path,
1246
+ path: meta.fileZod.path
1247
+ }),
1248
+ meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ jsx(File.Import, {
1249
+ name: Array.from(new Set(importedTypeNames)),
1250
+ root: meta.file.path,
1251
+ path: meta.fileTs.path,
1252
+ isTypeOnly: true
1253
+ }),
1254
+ /* @__PURE__ */ jsx(Url, {
1255
+ name: meta.urlName,
1256
+ baseURL,
1257
+ pathParamsType,
1258
+ paramsCasing,
1259
+ paramsType,
1260
+ node: transformedNode,
1261
+ tsResolver,
1262
+ isIndexable: urlType === "export",
1263
+ isExportable: urlType === "export"
1264
+ }),
1265
+ /* @__PURE__ */ jsx(Client, {
1266
+ name: meta.name,
1267
+ urlName: meta.urlName,
1268
+ baseURL,
1269
+ dataReturnType,
1270
+ pathParamsType,
1271
+ paramsCasing,
1272
+ paramsType,
1273
+ node: transformedNode,
1274
+ tsResolver,
1275
+ zodResolver,
1276
+ parser
1277
+ })
1278
+ ]
1279
+ });
1280
+ }
1281
+ });
1282
+ //#endregion
1283
+ //#region src/generators/groupedClientGenerator.tsx
1284
+ const groupedClientGenerator = defineGenerator({
1285
+ name: "groupedClient",
1286
+ type: "react",
1287
+ Operations({ nodes, options, config, resolver, adapter, plugin }) {
1288
+ const { output, group } = options;
1289
+ const root = path.resolve(config.root, config.output.path);
1290
+ return nodes.reduce((acc, operationNode) => {
1291
+ if (group?.type === "tag") {
1292
+ const tag = operationNode.tags[0];
1293
+ const name = tag ? group?.name?.({ group: camelCase(tag) }) : void 0;
1294
+ if (!tag || !name) return acc;
1295
+ const transformedNode = plugin.transformer ? transform(operationNode, plugin.transformer) : operationNode;
1296
+ const file = resolver.resolveFile({
1297
+ name,
1298
+ extname: ".ts",
1299
+ tag
1300
+ }, {
1301
+ root,
1302
+ output,
1303
+ group
1304
+ });
1305
+ const clientFile = resolver.resolveFile({
1306
+ name: transformedNode.operationId,
1307
+ extname: ".ts",
1308
+ tag: transformedNode.tags[0] ?? "default",
1309
+ path: transformedNode.path
1310
+ }, {
1311
+ root,
1312
+ output,
1313
+ group
1314
+ });
1315
+ const client = {
1316
+ name: resolver.resolveName(transformedNode.operationId),
1317
+ file: clientFile
1318
+ };
1319
+ const previous = acc.find((item) => item.file.path === file.path);
1320
+ if (previous) previous.clients.push(client);
1321
+ else acc.push({
1322
+ name,
1323
+ file,
1324
+ clients: [client]
1325
+ });
1326
+ }
1327
+ return acc;
1328
+ }, []).map(({ name, file, clients }) => {
1329
+ return /* @__PURE__ */ jsxs(File, {
1330
+ baseName: file.baseName,
1331
+ path: file.path,
1332
+ meta: file.meta,
1333
+ banner: resolver.resolveBanner(adapter.rootNode, {
1334
+ output,
1335
+ config
1336
+ }),
1337
+ footer: resolver.resolveFooter(adapter.rootNode, {
1338
+ output,
1339
+ config
1340
+ }),
1341
+ children: [clients.map((client) => /* @__PURE__ */ jsx(File.Import, {
1342
+ name: [client.name],
1343
+ root: file.path,
1344
+ path: client.file.path
1345
+ }, client.name)), /* @__PURE__ */ jsx(File.Source, {
1346
+ name,
1347
+ isExportable: true,
1348
+ isIndexable: true,
1349
+ children: /* @__PURE__ */ jsx(Function$1, {
1350
+ export: true,
1351
+ name,
1352
+ children: `return { ${clients.map((client) => client.name).join(", ")} }`
1353
+ })
1354
+ })]
1355
+ }, file.path);
1356
+ });
1357
+ }
1358
+ });
1359
+ //#endregion
1360
+ //#region src/components/Operations.tsx
1361
+ function Operations({ name, nodes }) {
1362
+ const operationsObject = {};
1363
+ nodes.forEach((node) => {
1364
+ operationsObject[node.operationId] = {
1365
+ path: new URLPath(node.path).URL,
1366
+ method: node.method.toLowerCase()
1367
+ };
1368
+ });
1369
+ return /* @__PURE__ */ jsx(File.Source, {
1370
+ name,
1371
+ isExportable: true,
1372
+ isIndexable: true,
1373
+ children: /* @__PURE__ */ jsx(Const, {
1374
+ name,
1375
+ export: true,
1376
+ children: JSON.stringify(operationsObject, void 0, 2)
1377
+ })
1378
+ });
1379
+ }
1380
+ //#endregion
1381
+ //#region src/generators/operationsGenerator.tsx
1382
+ const operationsGenerator = defineGenerator({
1383
+ name: "client",
1384
+ type: "react",
1385
+ Operations({ nodes, options, config, resolver, adapter }) {
1386
+ const { output, group } = options;
1387
+ const root = path.resolve(config.root, config.output.path);
1388
+ const name = "operations";
1389
+ const file = resolver.resolveFile({
1390
+ name,
1391
+ extname: ".ts"
1392
+ }, {
1393
+ root,
1394
+ output,
1395
+ group
1396
+ });
1397
+ return /* @__PURE__ */ jsx(File, {
1398
+ baseName: file.baseName,
1399
+ path: file.path,
1400
+ meta: file.meta,
1401
+ banner: resolver.resolveBanner(adapter.rootNode, {
1402
+ output,
1403
+ config
1404
+ }),
1405
+ footer: resolver.resolveFooter(adapter.rootNode, {
1406
+ output,
1407
+ config
1408
+ }),
1409
+ children: /* @__PURE__ */ jsx(Operations, {
1410
+ name,
1411
+ nodes
1412
+ })
1413
+ });
1414
+ }
1415
+ });
1416
+ //#endregion
1417
+ //#region src/components/StaticClassClient.tsx
1418
+ const declarationPrinter = functionPrinter({ mode: "declaration" });
1419
+ function generateMethod({ node, name, tsResolver, zodResolver, baseURL, dataReturnType, parser, paramsType, paramsCasing, pathParamsType }) {
1420
+ const path = new URLPath(node.path, { casing: paramsCasing });
1421
+ const contentType = node.requestBody?.contentType ?? "application/json";
1422
+ const isFormData = contentType === "multipart/form-data";
1423
+ const headers = buildHeaders(contentType, !!(node.parameters.filter((p) => p.in === "header").length > 0 ? tsResolver.resolveHeaderParamsName(node, node.parameters.filter((p) => p.in === "header")[0]) : void 0));
1424
+ const generics = buildGenerics(node, tsResolver);
1425
+ const paramsNode = Client.getParams({
1426
+ paramsType,
1427
+ paramsCasing,
1428
+ pathParamsType,
1429
+ node,
1430
+ tsResolver,
1431
+ isConfigurable: true
1432
+ });
1433
+ const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
1434
+ const clientParams = buildClassClientParams({
1435
+ node,
1436
+ path,
1437
+ baseURL,
1438
+ tsResolver,
1439
+ isFormData,
1440
+ headers
1441
+ });
1442
+ const jsdoc = buildJSDoc(getComments(node));
1443
+ const requestDataLine = buildRequestDataLine({
1444
+ parser,
1445
+ node,
1446
+ zodResolver
1447
+ });
1448
+ const formDataLine = buildFormDataLine(isFormData, !!node.requestBody?.schema);
1449
+ const returnStatement = buildReturnStatement({
1450
+ dataReturnType,
1451
+ parser,
1452
+ node,
1453
+ zodResolver
1454
+ });
1455
+ return `${jsdoc} static async ${name}(${paramsSignature}) {\n${[
1456
+ "const { client: request = fetch, ...requestConfig } = mergeConfig(this.#config, config)",
1457
+ "",
1458
+ requestDataLine,
1459
+ formDataLine,
1460
+ `const res = await request<${generics.join(", ")}>(${clientParams.toCall()})`,
1461
+ returnStatement
1462
+ ].filter(Boolean).map((line) => ` ${line}`).join("\n")}\n }`;
1463
+ }
1464
+ function StaticClassClient({ name, isExportable = true, isIndexable = true, operations, baseURL, dataReturnType, parser, paramsType, paramsCasing, pathParamsType, children }) {
1465
+ const classCode = `export class ${name} {\n static #config: Partial<RequestConfig> & { client?: Client } = {}\n\n${operations.map(({ node, name: methodName, tsResolver, zodResolver }) => generateMethod({
1466
+ node,
1467
+ name: methodName,
1468
+ tsResolver,
1469
+ zodResolver,
1470
+ baseURL,
1471
+ dataReturnType,
1472
+ parser,
1473
+ paramsType,
1474
+ paramsCasing,
1475
+ pathParamsType
1476
+ })).join("\n\n")}\n}`;
1477
+ return /* @__PURE__ */ jsxs(File.Source, {
1478
+ name,
1479
+ isExportable,
1480
+ isIndexable,
1481
+ children: [classCode, children]
1482
+ });
1483
+ }
1484
+ StaticClassClient.getParams = Client.getParams;
1485
+ //#endregion
1486
+ //#region src/generators/staticClassClientGenerator.tsx
1487
+ function resolveTypeImportNames(node, tsResolver) {
1488
+ return [
1489
+ node.requestBody?.schema ? tsResolver.resolveDataName(node) : void 0,
1490
+ tsResolver.resolveResponseName(node),
1491
+ ...node.parameters.filter((p) => p.in === "path").map((p) => tsResolver.resolvePathParamsName(node, p)),
1492
+ ...node.parameters.filter((p) => p.in === "query").map((p) => tsResolver.resolveQueryParamsName(node, p)),
1493
+ ...node.parameters.filter((p) => p.in === "header").map((p) => tsResolver.resolveHeaderParamsName(node, p)),
1494
+ ...node.responses.map((res) => tsResolver.resolveResponseStatusName(node, res.statusCode))
1495
+ ].filter((n) => Boolean(n));
1496
+ }
1497
+ function resolveZodImportNames(node, zodResolver) {
1498
+ return [zodResolver.resolveResponseName?.(node), node.requestBody?.schema ? zodResolver.resolveDataName?.(node) : void 0].filter((n) => Boolean(n));
1499
+ }
1500
+ const staticClassClientGenerator = defineGenerator({
1501
+ name: "staticClassClient",
1502
+ type: "react",
1503
+ Operations({ nodes, options, config, driver, resolver, adapter, plugin }) {
1504
+ const { output, group, dataReturnType, paramsCasing, paramsType, pathParamsType, parser, importPath } = options;
1505
+ const baseURL = options.baseURL ?? adapter.rootNode?.meta?.baseURL;
1506
+ const root = path.resolve(config.root, config.output.path);
1507
+ const pluginTs = driver.getPlugin(pluginTsName);
1508
+ if (!pluginTs?.resolver) return null;
1509
+ const tsResolver = pluginTs.resolver;
1510
+ const tsPluginOptions = pluginTs.options;
1511
+ const pluginZod = parser === "zod" ? driver.getPlugin(pluginZodName) : void 0;
1512
+ const zodResolver = pluginZod?.resolver;
1513
+ function buildOperationData(node) {
1514
+ const transformedNode = plugin.transformer ? transform(node, plugin.transformer) : node;
1515
+ const typeFile = tsResolver.resolveFile({
1516
+ name: transformedNode.operationId,
1517
+ extname: ".ts",
1518
+ tag: transformedNode.tags[0] ?? "default",
1519
+ path: transformedNode.path
1520
+ }, {
1521
+ root,
1522
+ output: tsPluginOptions?.output ?? output,
1523
+ group: tsPluginOptions?.group
1524
+ });
1525
+ const zodFile = zodResolver && pluginZod?.options ? zodResolver.resolveFile({
1526
+ name: transformedNode.operationId,
1527
+ extname: ".ts",
1528
+ tag: transformedNode.tags[0] ?? "default",
1529
+ path: transformedNode.path
1530
+ }, {
1531
+ root,
1532
+ output: pluginZod.options.output ?? output,
1533
+ group: pluginZod.options.group
1534
+ }) : void 0;
1535
+ return {
1536
+ node: transformedNode,
1537
+ name: resolver.resolveName(transformedNode.operationId),
1538
+ tsResolver,
1539
+ zodResolver,
1540
+ typeFile,
1541
+ zodFile
1542
+ };
1543
+ }
1544
+ const controllers = nodes.reduce((acc, operationNode) => {
1545
+ const tag = operationNode.tags[0];
1546
+ const groupName = tag ? group?.name?.({ group: camelCase(tag) }) ?? pascalCase(tag) : "Client";
1547
+ if (!tag && !group) {
1548
+ const name = "ApiClient";
1549
+ const file = resolver.resolveFile({
1550
+ name,
1551
+ extname: ".ts"
1552
+ }, {
1553
+ root,
1554
+ output,
1555
+ group
1556
+ });
1557
+ const operationData = buildOperationData(operationNode);
1558
+ const previous = acc.find((item) => item.file.path === file.path);
1559
+ if (previous) previous.operations.push(operationData);
1560
+ else acc.push({
1561
+ name,
1562
+ file,
1563
+ operations: [operationData]
1564
+ });
1565
+ } else if (tag) {
1566
+ const name = groupName;
1567
+ const file = resolver.resolveFile({
1568
+ name,
1569
+ extname: ".ts",
1570
+ tag
1571
+ }, {
1572
+ root,
1573
+ output,
1574
+ group
1575
+ });
1576
+ const operationData = buildOperationData(operationNode);
1577
+ const previous = acc.find((item) => item.file.path === file.path);
1578
+ if (previous) previous.operations.push(operationData);
1579
+ else acc.push({
1580
+ name,
1581
+ file,
1582
+ operations: [operationData]
1583
+ });
1584
+ }
1585
+ return acc;
1586
+ }, []);
1587
+ function collectTypeImports(ops) {
1588
+ const typeImportsByFile = /* @__PURE__ */ new Map();
1589
+ const typeFilesByPath = /* @__PURE__ */ new Map();
1590
+ ops.forEach((op) => {
1591
+ const names = resolveTypeImportNames(op.node, tsResolver);
1592
+ if (!typeImportsByFile.has(op.typeFile.path)) typeImportsByFile.set(op.typeFile.path, /* @__PURE__ */ new Set());
1593
+ const imports = typeImportsByFile.get(op.typeFile.path);
1594
+ names.forEach((n) => {
1595
+ imports.add(n);
1596
+ });
1597
+ typeFilesByPath.set(op.typeFile.path, op.typeFile);
1598
+ });
1599
+ return {
1600
+ typeImportsByFile,
1601
+ typeFilesByPath
1602
+ };
1603
+ }
1604
+ function collectZodImports(ops) {
1605
+ const zodImportsByFile = /* @__PURE__ */ new Map();
1606
+ const zodFilesByPath = /* @__PURE__ */ new Map();
1607
+ ops.forEach((op) => {
1608
+ if (!op.zodFile || !zodResolver) return;
1609
+ const names = resolveZodImportNames(op.node, zodResolver);
1610
+ if (!zodImportsByFile.has(op.zodFile.path)) zodImportsByFile.set(op.zodFile.path, /* @__PURE__ */ new Set());
1611
+ const imports = zodImportsByFile.get(op.zodFile.path);
1612
+ names.forEach((n) => {
1613
+ imports.add(n);
1614
+ });
1615
+ zodFilesByPath.set(op.zodFile.path, op.zodFile);
1616
+ });
1617
+ return {
1618
+ zodImportsByFile,
1619
+ zodFilesByPath
1620
+ };
1621
+ }
1622
+ return controllers.map(({ name, file, operations: ops }) => {
1623
+ const { typeImportsByFile, typeFilesByPath } = collectTypeImports(ops);
1624
+ const { zodImportsByFile, zodFilesByPath } = parser === "zod" ? collectZodImports(ops) : {
1625
+ zodImportsByFile: /* @__PURE__ */ new Map(),
1626
+ zodFilesByPath: /* @__PURE__ */ new Map()
1627
+ };
1628
+ const hasFormData = ops.some((op) => op.node.requestBody?.contentType === "multipart/form-data");
1629
+ return /* @__PURE__ */ jsxs(File, {
1630
+ baseName: file.baseName,
1631
+ path: file.path,
1632
+ meta: file.meta,
1633
+ banner: resolver.resolveBanner(adapter.rootNode, {
1634
+ output,
1635
+ config
1636
+ }),
1637
+ footer: resolver.resolveFooter(adapter.rootNode, {
1638
+ output,
1639
+ config
1640
+ }),
1641
+ children: [
1642
+ importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
1643
+ /* @__PURE__ */ jsx(File.Import, {
1644
+ name: "fetch",
1645
+ path: importPath
1646
+ }),
1647
+ /* @__PURE__ */ jsx(File.Import, {
1648
+ name: ["mergeConfig"],
1649
+ path: importPath
1650
+ }),
1651
+ /* @__PURE__ */ jsx(File.Import, {
1652
+ name: [
1653
+ "Client",
1654
+ "RequestConfig",
1655
+ "ResponseErrorConfig"
1656
+ ],
1657
+ path: importPath,
1658
+ isTypeOnly: true
1659
+ })
1660
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1661
+ /* @__PURE__ */ jsx(File.Import, {
1662
+ name: ["fetch"],
1663
+ root: file.path,
1664
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
1665
+ }),
1666
+ /* @__PURE__ */ jsx(File.Import, {
1667
+ name: ["mergeConfig"],
1668
+ root: file.path,
1669
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
1670
+ }),
1671
+ /* @__PURE__ */ jsx(File.Import, {
1672
+ name: [
1673
+ "Client",
1674
+ "RequestConfig",
1675
+ "ResponseErrorConfig"
1676
+ ],
1677
+ root: file.path,
1678
+ path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
1679
+ isTypeOnly: true
1680
+ })
1681
+ ] }),
1682
+ hasFormData && /* @__PURE__ */ jsx(File.Import, {
1683
+ name: ["buildFormData"],
1684
+ root: file.path,
1685
+ path: path.resolve(config.root, config.output.path, ".kubb/config.ts")
1686
+ }),
1687
+ Array.from(typeImportsByFile.entries()).map(([filePath, importSet]) => {
1688
+ const typeFile = typeFilesByPath.get(filePath);
1689
+ if (!typeFile) return null;
1690
+ const importNames = Array.from(importSet).filter(Boolean);
1691
+ if (importNames.length === 0) return null;
1692
+ return /* @__PURE__ */ jsx(File.Import, {
1693
+ name: importNames,
1694
+ root: file.path,
1695
+ path: typeFile.path,
1696
+ isTypeOnly: true
1697
+ }, filePath);
1698
+ }),
1699
+ parser === "zod" && Array.from(zodImportsByFile.entries()).map(([filePath, importSet]) => {
1700
+ const zodFile = zodFilesByPath.get(filePath);
1701
+ if (!zodFile) return null;
1702
+ const importNames = Array.from(importSet).filter(Boolean);
1703
+ if (importNames.length === 0) return null;
1704
+ return /* @__PURE__ */ jsx(File.Import, {
1705
+ name: importNames,
1706
+ root: file.path,
1707
+ path: zodFile.path
1708
+ }, filePath);
1709
+ }),
1710
+ /* @__PURE__ */ jsx(StaticClassClient, {
1711
+ name,
1712
+ operations: ops,
1713
+ baseURL,
1714
+ dataReturnType,
1715
+ pathParamsType,
1716
+ paramsCasing,
1717
+ paramsType,
1718
+ parser
1719
+ })
1720
+ ]
1721
+ }, file.path);
1722
+ });
1723
+ }
1724
+ });
1725
+ //#endregion
1726
+ //#region src/resolvers/resolverClient.ts
1727
+ /**
1728
+ * Resolver for `@kubb/plugin-client` that provides the default naming
1729
+ * and path-resolution helpers used by the plugin.
1730
+ *
1731
+ * @example
1732
+ * ```ts
1733
+ * import { resolverClient } from '@kubb/plugin-client'
1734
+ *
1735
+ * resolverClient.default('list pets', 'function') // -> 'listPets'
1736
+ * resolverClient.resolveName('show pet by id') // -> 'showPetById'
1737
+ * ```
1738
+ */
1739
+ const resolverClient = defineResolver(() => ({
1740
+ name: "default",
1741
+ pluginName: "plugin-client",
1742
+ default(name, type) {
1743
+ return camelCase(name, { isFile: type === "file" });
1744
+ },
1745
+ resolveName(name) {
1746
+ return this.default(name, "function");
1747
+ }
1748
+ }));
1749
+ //#endregion
1750
+ //#region src/resolvers/resolverClientLegacy.ts
1751
+ /**
1752
+ * Legacy resolver for `@kubb/plugin-client` that provides backward-compatible
1753
+ * naming conventions matching the v4 behavior.
1754
+ *
1755
+ * @example
1756
+ * ```ts
1757
+ * import { resolverClientLegacy } from '@kubb/plugin-client'
1758
+ *
1759
+ * resolverClientLegacy.default('list pets', 'function') // -> 'listPets'
1760
+ * resolverClientLegacy.resolveName('show pet by id') // -> 'showPetById'
1761
+ * ```
1762
+ */
1763
+ const resolverClientLegacy = defineResolver(() => ({
1764
+ name: "kubbV4",
1765
+ pluginName: "plugin-client",
1766
+ default(name, type) {
1767
+ return camelCase(name, { isFile: type === "file" });
1768
+ },
1769
+ resolveName(name) {
1770
+ return this.default(name, "function");
1771
+ }
1772
+ }));
1773
+ //#endregion
1774
+ //#region src/presets.ts
1775
+ /**
1776
+ * Built-in preset registry for `@kubb/plugin-client`.
1777
+ *
1778
+ * - `default` — uses `resolverClient` with v5 naming conventions.
1779
+ * - `kubbV4` — uses `resolverClientLegacy` with backward-compatible naming.
1780
+ *
1781
+ * Note: Unlike plugin-ts/plugin-zod, generators are not defined here because
1782
+ * plugin-client selects generators dynamically based on `clientType`, `group`,
1783
+ * and `operations` options. Generator selection happens in `plugin.ts`.
1784
+ */
1785
+ const presets = definePresets({
1786
+ default: {
1787
+ name: "default",
1788
+ resolver: resolverClient
1789
+ },
1790
+ kubbV4: {
1791
+ name: "kubbV4",
1792
+ resolver: resolverClientLegacy
1793
+ }
1794
+ });
1795
+ //#endregion
11
1796
  //#region src/plugin.ts
1797
+ /**
1798
+ * Canonical plugin name for `@kubb/plugin-client`, used to identify the plugin
1799
+ * in driver lookups and warnings.
1800
+ */
12
1801
  const pluginClientName = "plugin-client";
1802
+ /**
1803
+ * The `@kubb/plugin-client` plugin factory.
1804
+ *
1805
+ * Generates type-safe HTTP client functions (or classes) from an OpenAPI/AST `RootNode`.
1806
+ * Walks operations, delegates rendering to the active generators,
1807
+ * and writes barrel files based on `output.barrelType`.
1808
+ *
1809
+ * @example
1810
+ * ```ts
1811
+ * import { pluginClient } from '@kubb/plugin-client'
1812
+ *
1813
+ * export default defineConfig({
1814
+ * plugins: [pluginClient({ output: { path: 'clients' } })],
1815
+ * })
1816
+ * ```
1817
+ */
13
1818
  const pluginClient = createPlugin((options) => {
14
1819
  const { output = {
15
1820
  path: "clients",
16
1821
  barrelType: "named"
17
- }, group, urlType = false, exclude = [], include, override = [], transformers = {}, dataReturnType = "data", paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", operations = false, baseURL, paramsCasing, clientType = "function", parser = "client", client = "axios", importPath, contentType, bundle = false, wrapper } = options;
1822
+ }, group, urlType = false, exclude = [], include, override = [], dataReturnType = "data", paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", operations = false, paramsCasing, clientType = "function", parser = "client", client = "axios", importPath, bundle = false, wrapper, baseURL, compatibilityPreset = "default", resolver: userResolver, transformer: userTransformer } = options;
18
1823
  const resolvedImportPath = importPath ?? (!bundle ? `@kubb/plugin-client/clients/${client}` : void 0);
19
- const defaultGenerators = [
20
- clientType === "staticClass" ? staticClassClientGenerator : clientType === "class" ? classClientGenerator : clientGenerator,
21
- group && clientType === "function" ? groupedClientGenerator : void 0,
22
- operations ? operationsGenerator : void 0
23
- ].filter((x) => Boolean(x));
24
- const generators = options.generators ?? defaultGenerators;
1824
+ const preset = getPreset({
1825
+ preset: compatibilityPreset,
1826
+ presets,
1827
+ resolver: userResolver,
1828
+ transformer: userTransformer,
1829
+ generators: options.generators ?? [
1830
+ clientType === "staticClass" ? staticClassClientGenerator : clientType === "class" ? classClientGenerator : clientGenerator,
1831
+ group && clientType === "function" ? groupedClientGenerator : void 0,
1832
+ operations ? operationsGenerator : void 0
1833
+ ].filter((x) => Boolean(x))
1834
+ });
1835
+ let resolveNameWarning = false;
1836
+ let resolvePathWarning = false;
25
1837
  return {
26
1838
  name: pluginClientName,
27
- options: {
28
- client,
29
- clientType,
30
- bundle,
31
- output,
32
- group,
33
- parser,
34
- dataReturnType,
35
- importPath: resolvedImportPath,
36
- paramsType,
37
- paramsCasing,
38
- pathParamsType,
39
- baseURL,
40
- urlType,
41
- wrapper
1839
+ get resolver() {
1840
+ return preset.resolver;
1841
+ },
1842
+ get transformer() {
1843
+ return preset.transformer;
42
1844
  },
43
- pre: [pluginOasName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
1845
+ get options() {
1846
+ return {
1847
+ client,
1848
+ clientType,
1849
+ bundle,
1850
+ output,
1851
+ group: group ? {
1852
+ ...group,
1853
+ name: group.name ? group.name : (ctx) => {
1854
+ if (group.type === "path") return `${ctx.group.split("/")[1]}`;
1855
+ return `${camelCase(ctx.group)}Controller`;
1856
+ }
1857
+ } : void 0,
1858
+ parser,
1859
+ dataReturnType,
1860
+ importPath: resolvedImportPath,
1861
+ baseURL,
1862
+ paramsType,
1863
+ paramsCasing,
1864
+ pathParamsType,
1865
+ urlType,
1866
+ wrapper,
1867
+ resolver: preset.resolver
1868
+ };
1869
+ },
1870
+ pre: [pluginTsName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
44
1871
  resolvePath(baseName, pathMode, options) {
45
- const root = path.resolve(this.config.root, this.config.output.path);
46
- if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
47
- /**
48
- * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
49
- * Other plugins then need to call addOrAppend instead of just add from the fileManager class
50
- */
51
- return path.resolve(root, output.path);
52
- if (group && (options?.group?.path || options?.group?.tag)) {
53
- const groupName = group?.name ? group.name : (ctx) => {
54
- if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
55
- return `${camelCase(ctx.group)}Controller`;
56
- };
57
- return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
1872
+ if (!resolvePathWarning) {
1873
+ this.events.emit("warn", "Do not use resolvePath for pluginClient, use resolverClient.resolvePath instead");
1874
+ resolvePathWarning = true;
58
1875
  }
59
- return path.resolve(root, output.path, baseName);
1876
+ return this.plugin.resolver.resolvePath({
1877
+ baseName,
1878
+ pathMode,
1879
+ tag: options?.group?.tag,
1880
+ path: options?.group?.path
1881
+ }, {
1882
+ root: path.resolve(this.config.root, this.config.output.path),
1883
+ output,
1884
+ group: this.plugin.options.group
1885
+ });
60
1886
  },
61
1887
  resolveName(name, type) {
62
- const resolvedName = camelCase(name, { isFile: type === "file" });
63
- if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
64
- return resolvedName;
1888
+ if (!resolveNameWarning) {
1889
+ this.events.emit("warn", "Do not use resolveName for pluginClient, use resolverClient.default instead");
1890
+ resolveNameWarning = true;
1891
+ }
1892
+ return this.plugin.resolver.default(name, type);
65
1893
  },
66
1894
  async install() {
67
- const root = path.resolve(this.config.root, this.config.output.path);
68
- const mode = getMode(path.resolve(root, output.path));
69
- const oas = await this.getOas();
70
- const baseURL = await this.getBaseURL();
71
- if (bundle && !this.plugin.options.importPath) await this.addFile({
1895
+ const { config, fabric, plugin, adapter, rootNode, driver } = this;
1896
+ const root = path.resolve(config.root, config.output.path);
1897
+ const resolver = preset.resolver;
1898
+ if (!adapter) throw new Error("Plugin cannot work without adapter being set");
1899
+ if (bundle && !plugin.options.importPath) await this.addFile({
72
1900
  baseName: "fetch.ts",
73
1901
  path: path.resolve(root, ".kubb/fetch.ts"),
74
1902
  sources: [{
75
1903
  name: "fetch",
76
- value: this.plugin.options.client === "fetch" ? source$1 : source,
1904
+ value: plugin.options.client === "fetch" ? source$1 : source,
77
1905
  isExportable: true,
78
1906
  isIndexable: true
79
1907
  }],
@@ -92,22 +1920,32 @@ const pluginClient = createPlugin((options) => {
92
1920
  imports: [],
93
1921
  exports: []
94
1922
  });
95
- const files = await new OperationGenerator(baseURL ? {
96
- ...this.plugin.options,
97
- baseURL
98
- } : this.plugin.options, {
99
- fabric: this.fabric,
100
- oas,
101
- driver: this.driver,
102
- events: this.events,
103
- plugin: this.plugin,
104
- contentType,
1923
+ const collectedOperations = [];
1924
+ const generatorContext = {
1925
+ generators: preset.generators,
1926
+ plugin,
1927
+ resolver,
105
1928
  exclude,
106
1929
  include,
107
1930
  override,
108
- mode
109
- }).build(...generators);
110
- await this.upsertFile(...files);
1931
+ fabric,
1932
+ adapter,
1933
+ config,
1934
+ driver
1935
+ };
1936
+ await walk(rootNode, {
1937
+ depth: "shallow",
1938
+ async operation(operationNode) {
1939
+ if (resolver.resolveOptions(operationNode, {
1940
+ options: plugin.options,
1941
+ exclude,
1942
+ include,
1943
+ override
1944
+ }) !== null) collectedOperations.push(operationNode);
1945
+ await runGeneratorOperation(operationNode, generatorContext);
1946
+ }
1947
+ });
1948
+ await runGeneratorOperations(collectedOperations, generatorContext);
111
1949
  const barrelFiles = await getBarrelFiles(this.fabric.files, {
112
1950
  type: output.barrelType ?? "named",
113
1951
  root,
@@ -119,6 +1957,6 @@ const pluginClient = createPlugin((options) => {
119
1957
  };
120
1958
  });
121
1959
  //#endregion
122
- export { pluginClient, pluginClientName };
1960
+ export { Client, ClientLegacy, UrlLegacy, classClientGenerator, clientGenerator, groupedClientGenerator, operationsGenerator, pluginClient, pluginClientName, presets, resolverClient, resolverClientLegacy, staticClassClientGenerator };
123
1961
 
124
1962
  //# sourceMappingURL=index.js.map