@kubb/plugin-vue-query 5.0.0-alpha.8 → 5.0.0-beta.3

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 (46) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +1 -3
  3. package/dist/components-D1UhYFgY.js +1277 -0
  4. package/dist/components-D1UhYFgY.js.map +1 -0
  5. package/dist/components-qfOFRSoM.cjs +1367 -0
  6. package/dist/components-qfOFRSoM.cjs.map +1 -0
  7. package/dist/components.cjs +1 -1
  8. package/dist/components.d.ts +118 -109
  9. package/dist/components.js +1 -1
  10. package/dist/generators-C4gs_P1i.cjs +726 -0
  11. package/dist/generators-C4gs_P1i.cjs.map +1 -0
  12. package/dist/generators-CbnIVBgY.js +709 -0
  13. package/dist/generators-CbnIVBgY.js.map +1 -0
  14. package/dist/generators.cjs +1 -1
  15. package/dist/generators.d.ts +5 -472
  16. package/dist/generators.js +1 -1
  17. package/dist/index.cjs +106 -121
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +102 -121
  21. package/dist/index.js.map +1 -1
  22. package/dist/types-nVDTfuS1.d.ts +194 -0
  23. package/package.json +61 -64
  24. package/src/components/InfiniteQuery.tsx +104 -153
  25. package/src/components/InfiniteQueryOptions.tsx +122 -162
  26. package/src/components/Mutation.tsx +110 -136
  27. package/src/components/Query.tsx +102 -151
  28. package/src/components/QueryKey.tsx +68 -58
  29. package/src/components/QueryOptions.tsx +147 -139
  30. package/src/generators/infiniteQueryGenerator.tsx +165 -170
  31. package/src/generators/mutationGenerator.tsx +117 -124
  32. package/src/generators/queryGenerator.tsx +138 -136
  33. package/src/index.ts +1 -1
  34. package/src/plugin.ts +124 -175
  35. package/src/resolvers/resolverVueQuery.ts +19 -0
  36. package/src/types.ts +68 -48
  37. package/src/utils.ts +37 -0
  38. package/dist/components-Yjoe78Y7.cjs +0 -1119
  39. package/dist/components-Yjoe78Y7.cjs.map +0 -1
  40. package/dist/components-_AMBl0g-.js +0 -1029
  41. package/dist/components-_AMBl0g-.js.map +0 -1
  42. package/dist/generators-CR34GjVu.js +0 -661
  43. package/dist/generators-CR34GjVu.js.map +0 -1
  44. package/dist/generators-DH8VkK1q.cjs +0 -678
  45. package/dist/generators-DH8VkK1q.cjs.map +0 -1
  46. package/dist/types-CgDFUvfZ.d.ts +0 -211
@@ -0,0 +1,1367 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", {
5
+ value,
6
+ configurable: true
7
+ });
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
+ key = keys[i];
15
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: ((k) => from[k]).bind(null, key),
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+ //#endregion
27
+ let _kubb_core = require("@kubb/core");
28
+ let _kubb_plugin_ts = require("@kubb/plugin-ts");
29
+ let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
30
+ let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
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/object.ts
75
+ /**
76
+ * Converts a dot-notation path or string array into an optional-chaining accessor expression.
77
+ *
78
+ * @example
79
+ * getNestedAccessor('pagination.next.id', 'lastPage')
80
+ * // → "lastPage?.['pagination']?.['next']?.['id']"
81
+ */
82
+ function getNestedAccessor(param, accessor) {
83
+ const parts = Array.isArray(param) ? param : param.split(".");
84
+ if (parts.length === 0 || parts.length === 1 && parts[0] === "") return null;
85
+ return `${accessor}?.['${`${parts.join("']?.['")}']`}`;
86
+ }
87
+ //#endregion
88
+ //#region ../../internals/utils/src/reserved.ts
89
+ /**
90
+ * JavaScript and Java reserved words.
91
+ * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
92
+ */
93
+ const reservedWords = new Set([
94
+ "abstract",
95
+ "arguments",
96
+ "boolean",
97
+ "break",
98
+ "byte",
99
+ "case",
100
+ "catch",
101
+ "char",
102
+ "class",
103
+ "const",
104
+ "continue",
105
+ "debugger",
106
+ "default",
107
+ "delete",
108
+ "do",
109
+ "double",
110
+ "else",
111
+ "enum",
112
+ "eval",
113
+ "export",
114
+ "extends",
115
+ "false",
116
+ "final",
117
+ "finally",
118
+ "float",
119
+ "for",
120
+ "function",
121
+ "goto",
122
+ "if",
123
+ "implements",
124
+ "import",
125
+ "in",
126
+ "instanceof",
127
+ "int",
128
+ "interface",
129
+ "let",
130
+ "long",
131
+ "native",
132
+ "new",
133
+ "null",
134
+ "package",
135
+ "private",
136
+ "protected",
137
+ "public",
138
+ "return",
139
+ "short",
140
+ "static",
141
+ "super",
142
+ "switch",
143
+ "synchronized",
144
+ "this",
145
+ "throw",
146
+ "throws",
147
+ "transient",
148
+ "true",
149
+ "try",
150
+ "typeof",
151
+ "var",
152
+ "void",
153
+ "volatile",
154
+ "while",
155
+ "with",
156
+ "yield",
157
+ "Array",
158
+ "Date",
159
+ "hasOwnProperty",
160
+ "Infinity",
161
+ "isFinite",
162
+ "isNaN",
163
+ "isPrototypeOf",
164
+ "length",
165
+ "Math",
166
+ "name",
167
+ "NaN",
168
+ "Number",
169
+ "Object",
170
+ "prototype",
171
+ "String",
172
+ "toString",
173
+ "undefined",
174
+ "valueOf"
175
+ ]);
176
+ /**
177
+ * Returns `true` when `name` is a syntactically valid JavaScript variable name.
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * isValidVarName('status') // true
182
+ * isValidVarName('class') // false (reserved word)
183
+ * isValidVarName('42foo') // false (starts with digit)
184
+ * ```
185
+ */
186
+ function isValidVarName(name) {
187
+ if (!name || reservedWords.has(name)) return false;
188
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
189
+ }
190
+ //#endregion
191
+ //#region ../../internals/utils/src/urlPath.ts
192
+ /**
193
+ * Parses and transforms an OpenAPI/Swagger path string into various URL formats.
194
+ *
195
+ * @example
196
+ * const p = new URLPath('/pet/{petId}')
197
+ * p.URL // '/pet/:petId'
198
+ * p.template // '`/pet/${petId}`'
199
+ */
200
+ var URLPath = class {
201
+ /**
202
+ * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
203
+ */
204
+ path;
205
+ #options;
206
+ constructor(path, options = {}) {
207
+ this.path = path;
208
+ this.#options = options;
209
+ }
210
+ /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * new URLPath('/pet/{petId}').URL // '/pet/:petId'
215
+ * ```
216
+ */
217
+ get URL() {
218
+ return this.toURLPath();
219
+ }
220
+ /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
225
+ * new URLPath('/pet/{petId}').isURL // false
226
+ * ```
227
+ */
228
+ get isURL() {
229
+ try {
230
+ return !!new URL(this.path).href;
231
+ } catch {
232
+ return false;
233
+ }
234
+ }
235
+ /**
236
+ * Converts the OpenAPI path to a TypeScript template literal string.
237
+ *
238
+ * @example
239
+ * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
240
+ * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
241
+ */
242
+ get template() {
243
+ return this.toTemplateString();
244
+ }
245
+ /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * new URLPath('/pet/{petId}').object
250
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
251
+ * ```
252
+ */
253
+ get object() {
254
+ return this.toObject();
255
+ }
256
+ /** Returns a map of path parameter names, or `undefined` when the path has no parameters.
257
+ *
258
+ * @example
259
+ * ```ts
260
+ * new URLPath('/pet/{petId}').params // { petId: 'petId' }
261
+ * new URLPath('/pet').params // undefined
262
+ * ```
263
+ */
264
+ get params() {
265
+ return this.getParams();
266
+ }
267
+ #transformParam(raw) {
268
+ const param = isValidVarName(raw) ? raw : camelCase(raw);
269
+ return this.#options.casing === "camelcase" ? camelCase(param) : param;
270
+ }
271
+ /**
272
+ * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.
273
+ */
274
+ #eachParam(fn) {
275
+ for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
276
+ const raw = match[1];
277
+ fn(raw, this.#transformParam(raw));
278
+ }
279
+ }
280
+ toObject({ type = "path", replacer, stringify } = {}) {
281
+ const object = {
282
+ url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
283
+ params: this.getParams()
284
+ };
285
+ if (stringify) {
286
+ if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
287
+ if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
288
+ return `{ url: '${object.url}' }`;
289
+ }
290
+ return object;
291
+ }
292
+ /**
293
+ * Converts the OpenAPI path to a TypeScript template literal string.
294
+ * An optional `replacer` can transform each extracted parameter name before interpolation.
295
+ *
296
+ * @example
297
+ * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
298
+ */
299
+ toTemplateString({ prefix = "", replacer } = {}) {
300
+ return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
301
+ if (i % 2 === 0) return part;
302
+ const param = this.#transformParam(part);
303
+ return `\${${replacer ? replacer(param) : param}}`;
304
+ }).join("")}\``;
305
+ }
306
+ /**
307
+ * Extracts all `{param}` segments from the path and returns them as a key-value map.
308
+ * An optional `replacer` transforms each parameter name in both key and value positions.
309
+ * Returns `undefined` when no path parameters are found.
310
+ *
311
+ * @example
312
+ * ```ts
313
+ * new URLPath('/pet/{petId}/tag/{tagId}').getParams()
314
+ * // { petId: 'petId', tagId: 'tagId' }
315
+ * ```
316
+ */
317
+ getParams(replacer) {
318
+ const params = {};
319
+ this.#eachParam((_raw, param) => {
320
+ const key = replacer ? replacer(param) : param;
321
+ params[key] = key;
322
+ });
323
+ return Object.keys(params).length > 0 ? params : void 0;
324
+ }
325
+ /** Converts the OpenAPI path to Express-style colon syntax.
326
+ *
327
+ * @example
328
+ * ```ts
329
+ * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
330
+ * ```
331
+ */
332
+ toURLPath() {
333
+ return this.path.replace(/\{([^}]+)\}/g, ":$1");
334
+ }
335
+ };
336
+ //#endregion
337
+ //#region ../../internals/tanstack-query/src/components/MutationKey.tsx
338
+ const declarationPrinter$6 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
339
+ function getParams$4() {
340
+ return _kubb_core.ast.createFunctionParameters({ params: [] });
341
+ }
342
+ __name(getParams$4, "getParams");
343
+ const getTransformer$1 = /* @__PURE__ */ __name(({ node, casing }) => {
344
+ return [`{ url: '${new URLPath(node.path, { casing }).toURLPath()}' }`];
345
+ }, "getTransformer");
346
+ function MutationKey({ name, paramsCasing, node, transformer = getTransformer$1 }) {
347
+ const paramsNode = getParams$4();
348
+ const paramsSignature = declarationPrinter$6.print(paramsNode) ?? "";
349
+ const keys = transformer({
350
+ node,
351
+ casing: paramsCasing
352
+ });
353
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
354
+ name,
355
+ isExportable: true,
356
+ isIndexable: true,
357
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function.Arrow, {
358
+ name,
359
+ export: true,
360
+ params: paramsSignature,
361
+ singleLine: true,
362
+ children: `[${keys.join(", ")}] as const`
363
+ })
364
+ });
365
+ }
366
+ MutationKey.getParams = getParams$4;
367
+ MutationKey.getTransformer = getTransformer$1;
368
+ //#endregion
369
+ //#region ../../internals/tanstack-query/src/utils.ts
370
+ /**
371
+ * Build JSDoc comment lines from an OperationNode.
372
+ */
373
+ function getComments(node) {
374
+ return [
375
+ node.description && `@description ${node.description}`,
376
+ node.summary && `@summary ${node.summary}`,
377
+ node.deprecated && "@deprecated",
378
+ `{@link ${node.path.replaceAll("{", ":").replaceAll("}", "")}}`
379
+ ].filter((x) => Boolean(x));
380
+ }
381
+ /**
382
+ * Resolve error type names from operation responses.
383
+ */
384
+ function resolveErrorNames(node, tsResolver) {
385
+ return node.responses.filter((r) => {
386
+ return Number.parseInt(r.statusCode, 10) >= 400;
387
+ }).map((r) => tsResolver.resolveResponseStatusName(node, r.statusCode));
388
+ }
389
+ /**
390
+ * Resolve the type for a single path parameter.
391
+ *
392
+ * - When the resolver's group name differs from the individual param name
393
+ * (e.g. kubbV4) → `GroupName['paramName']` (member access).
394
+ * - When they match (v5 default) → `TypeName` (direct reference).
395
+ */
396
+ function resolvePathParamType(node, param, resolver) {
397
+ const individualName = resolver.resolveParamName(node, param);
398
+ const groupName = resolver.resolvePathParamsName(node, param);
399
+ if (groupName !== individualName) return _kubb_core.ast.createParamsType({
400
+ variant: "member",
401
+ base: groupName,
402
+ key: param.name
403
+ });
404
+ return _kubb_core.ast.createParamsType({
405
+ variant: "reference",
406
+ name: individualName
407
+ });
408
+ }
409
+ /**
410
+ * Derive a query-params group type from the resolver.
411
+ * Returns `undefined` when no query params exist or when the group name
412
+ * equals the individual param name (no real group).
413
+ */
414
+ function resolveQueryGroupType(node, params, resolver) {
415
+ if (!params.length) return void 0;
416
+ const firstParam = params[0];
417
+ const groupName = resolver.resolveQueryParamsName(node, firstParam);
418
+ if (groupName === resolver.resolveParamName(node, firstParam)) return void 0;
419
+ return {
420
+ type: _kubb_core.ast.createParamsType({
421
+ variant: "reference",
422
+ name: groupName
423
+ }),
424
+ optional: params.every((p) => !p.required)
425
+ };
426
+ }
427
+ /**
428
+ * Derive a header-params group type from the resolver.
429
+ */
430
+ function resolveHeaderGroupType(node, params, resolver) {
431
+ if (!params.length) return void 0;
432
+ const firstParam = params[0];
433
+ const groupName = resolver.resolveHeaderParamsName(node, firstParam);
434
+ if (groupName === resolver.resolveParamName(node, firstParam)) return void 0;
435
+ return {
436
+ type: _kubb_core.ast.createParamsType({
437
+ variant: "reference",
438
+ name: groupName
439
+ }),
440
+ optional: params.every((p) => !p.required)
441
+ };
442
+ }
443
+ /**
444
+ * Build a single `FunctionParameterNode` for a query or header group.
445
+ */
446
+ function buildGroupParam(name, node, params, groupType, resolver) {
447
+ if (groupType) return [_kubb_core.ast.createFunctionParameter({
448
+ name,
449
+ type: groupType.type,
450
+ optional: groupType.optional
451
+ })];
452
+ if (params.length) {
453
+ const structProps = params.map((p) => ({
454
+ name: p.name,
455
+ type: _kubb_core.ast.createParamsType({
456
+ variant: "reference",
457
+ name: resolver.resolveParamName(node, p)
458
+ }),
459
+ optional: !p.required
460
+ }));
461
+ return [_kubb_core.ast.createFunctionParameter({
462
+ name,
463
+ type: _kubb_core.ast.createParamsType({
464
+ variant: "struct",
465
+ properties: structProps
466
+ }),
467
+ optional: params.every((p) => !p.required)
468
+ })];
469
+ }
470
+ return [];
471
+ }
472
+ /**
473
+ * Build QueryKey params: pathParams + data + queryParams (NO headers, NO config).
474
+ */
475
+ function buildQueryKeyParams(node, options) {
476
+ const { pathParamsType, paramsCasing, resolver } = options;
477
+ const casedParams = _kubb_core.ast.caseParams(node.parameters, paramsCasing);
478
+ const pathParams = casedParams.filter((p) => p.in === "path");
479
+ const queryParams = casedParams.filter((p) => p.in === "query");
480
+ const queryGroupType = resolveQueryGroupType(node, queryParams, resolver);
481
+ const bodyType = node.requestBody?.content?.[0]?.schema ? _kubb_core.ast.createParamsType({
482
+ variant: "reference",
483
+ name: resolver.resolveDataName(node)
484
+ }) : void 0;
485
+ const bodyRequired = node.requestBody?.required ?? false;
486
+ const params = [];
487
+ if (pathParams.length) {
488
+ const pathChildren = pathParams.map((p) => _kubb_core.ast.createFunctionParameter({
489
+ name: p.name,
490
+ type: resolvePathParamType(node, p, resolver),
491
+ optional: !p.required
492
+ }));
493
+ params.push({
494
+ kind: "ParameterGroup",
495
+ properties: pathChildren,
496
+ inline: pathParamsType === "inline",
497
+ default: pathChildren.every((c) => c.optional) ? "{}" : void 0
498
+ });
499
+ }
500
+ if (bodyType) params.push(_kubb_core.ast.createFunctionParameter({
501
+ name: "data",
502
+ type: bodyType,
503
+ optional: !bodyRequired
504
+ }));
505
+ params.push(...buildGroupParam("params", node, queryParams, queryGroupType, resolver));
506
+ return _kubb_core.ast.createFunctionParameters({ params });
507
+ }
508
+ /**
509
+ * Build mutation arg params for paramsToTrigger mode.
510
+ * Contains pathParams + data + queryParams + headers (all flattened, for type alias).
511
+ */
512
+ function buildMutationArgParams(node, options) {
513
+ const { paramsCasing, resolver } = options;
514
+ const casedParams = _kubb_core.ast.caseParams(node.parameters, paramsCasing);
515
+ const pathParams = casedParams.filter((p) => p.in === "path");
516
+ const queryParams = casedParams.filter((p) => p.in === "query");
517
+ const headerParams = casedParams.filter((p) => p.in === "header");
518
+ const queryGroupType = resolveQueryGroupType(node, queryParams, resolver);
519
+ const headerGroupType = resolveHeaderGroupType(node, headerParams, resolver);
520
+ const bodyType = node.requestBody?.content?.[0]?.schema ? _kubb_core.ast.createParamsType({
521
+ variant: "reference",
522
+ name: resolver.resolveDataName(node)
523
+ }) : void 0;
524
+ const bodyRequired = node.requestBody?.required ?? false;
525
+ const params = [];
526
+ for (const p of pathParams) params.push(_kubb_core.ast.createFunctionParameter({
527
+ name: p.name,
528
+ type: resolvePathParamType(node, p, resolver),
529
+ optional: !p.required
530
+ }));
531
+ if (bodyType) params.push(_kubb_core.ast.createFunctionParameter({
532
+ name: "data",
533
+ type: bodyType,
534
+ optional: !bodyRequired
535
+ }));
536
+ params.push(...buildGroupParam("params", node, queryParams, queryGroupType, resolver));
537
+ params.push(...buildGroupParam("headers", node, headerParams, headerGroupType, resolver));
538
+ return _kubb_core.ast.createFunctionParameters({ params });
539
+ }
540
+ //#endregion
541
+ //#region src/utils.ts
542
+ function transformName(name, type, transformers) {
543
+ return transformers?.name?.(name, type) || name;
544
+ }
545
+ //#endregion
546
+ //#region src/components/QueryKey.tsx
547
+ const declarationPrinter$5 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
548
+ const callPrinter$5 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
549
+ function wrapWithMaybeRefOrGetter(paramsNode) {
550
+ const wrappedParams = paramsNode.params.map((param) => {
551
+ if ("kind" in param && param.kind === "ParameterGroup") {
552
+ const group = param;
553
+ return {
554
+ ...group,
555
+ properties: group.properties.map((p) => ({
556
+ ...p,
557
+ type: p.type ? _kubb_core.ast.createParamsType({
558
+ variant: "reference",
559
+ name: `MaybeRefOrGetter<${printType$4(p.type)}>`
560
+ }) : p.type
561
+ }))
562
+ };
563
+ }
564
+ const fp = param;
565
+ return {
566
+ ...fp,
567
+ type: fp.type ? _kubb_core.ast.createParamsType({
568
+ variant: "reference",
569
+ name: `MaybeRefOrGetter<${printType$4(fp.type)}>`
570
+ }) : fp.type
571
+ };
572
+ });
573
+ return _kubb_core.ast.createFunctionParameters({ params: wrappedParams });
574
+ }
575
+ function printType$4(typeNode) {
576
+ if (!typeNode) return "unknown";
577
+ if (typeNode.variant === "reference") return typeNode.name;
578
+ if (typeNode.variant === "member") return `${typeNode.base}['${typeNode.key}']`;
579
+ if (typeNode.variant === "struct") return `{ ${typeNode.properties.map((p) => {
580
+ const typeStr = printType$4(p.type);
581
+ const key = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p.name) ? p.name : JSON.stringify(p.name);
582
+ return p.optional ? `${key}?: ${typeStr}` : `${key}: ${typeStr}`;
583
+ }).join("; ")} }`;
584
+ return "unknown";
585
+ }
586
+ __name(printType$4, "printType");
587
+ function getParams$3(node, options) {
588
+ return wrapWithMaybeRefOrGetter(buildQueryKeyParams(node, options));
589
+ }
590
+ __name(getParams$3, "getParams");
591
+ const getTransformer = ({ node, casing }) => {
592
+ const path = new URLPath(node.path, { casing });
593
+ const hasQueryParams = node.parameters.some((p) => p.in === "query");
594
+ const hasRequestBody = !!node.requestBody?.content?.[0]?.schema;
595
+ return [
596
+ path.toObject({
597
+ type: "path",
598
+ stringify: true
599
+ }),
600
+ hasQueryParams ? "...(params ? [params] : [])" : void 0,
601
+ hasRequestBody ? "...(data ? [data] : [])" : void 0
602
+ ].filter(Boolean);
603
+ };
604
+ function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeName, transformer = getTransformer }) {
605
+ const paramsNode = getParams$3(node, {
606
+ pathParamsType,
607
+ paramsCasing,
608
+ resolver: tsResolver
609
+ });
610
+ const paramsSignature = declarationPrinter$5.print(paramsNode) ?? "";
611
+ const keys = transformer({
612
+ node,
613
+ casing: paramsCasing
614
+ });
615
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
616
+ name,
617
+ isExportable: true,
618
+ isIndexable: true,
619
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function.Arrow, {
620
+ name,
621
+ export: true,
622
+ params: paramsSignature,
623
+ singleLine: true,
624
+ children: `[${keys.join(", ")}] as const`
625
+ })
626
+ }), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
627
+ name: typeName,
628
+ isExportable: true,
629
+ isIndexable: true,
630
+ isTypeOnly: true,
631
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Type, {
632
+ name: typeName,
633
+ export: true,
634
+ children: `ReturnType<typeof ${name}>`
635
+ })
636
+ })] });
637
+ }
638
+ QueryKey.getParams = getParams$3;
639
+ QueryKey.getTransformer = getTransformer;
640
+ QueryKey.callPrinter = callPrinter$5;
641
+ //#endregion
642
+ //#region src/components/QueryOptions.tsx
643
+ const declarationPrinter$4 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
644
+ const callPrinter$4 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
645
+ function getQueryOptionsParams(node, options) {
646
+ const { paramsType, paramsCasing, pathParamsType, resolver } = options;
647
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
648
+ return wrapOperationParamsWithMaybeRef$2(_kubb_core.ast.createOperationParams(node, {
649
+ paramsType,
650
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
651
+ paramsCasing,
652
+ resolver,
653
+ extraParams: [_kubb_core.ast.createFunctionParameter({
654
+ name: "config",
655
+ type: _kubb_core.ast.createParamsType({
656
+ variant: "reference",
657
+ name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
658
+ }),
659
+ default: "{}"
660
+ })]
661
+ }));
662
+ }
663
+ function wrapOperationParamsWithMaybeRef$2(paramsNode) {
664
+ const wrappedParams = paramsNode.params.map((param) => {
665
+ if ("kind" in param && param.kind === "ParameterGroup") {
666
+ const group = param;
667
+ return {
668
+ ...group,
669
+ properties: group.properties.map((p) => ({
670
+ ...p,
671
+ type: p.type ? _kubb_core.ast.createParamsType({
672
+ variant: "reference",
673
+ name: `MaybeRefOrGetter<${printType$3(p.type)}>`
674
+ }) : p.type
675
+ }))
676
+ };
677
+ }
678
+ const fp = param;
679
+ if (fp.name === "config") return fp;
680
+ return {
681
+ ...fp,
682
+ type: fp.type ? _kubb_core.ast.createParamsType({
683
+ variant: "reference",
684
+ name: `MaybeRefOrGetter<${printType$3(fp.type)}>`
685
+ }) : fp.type
686
+ };
687
+ });
688
+ return _kubb_core.ast.createFunctionParameters({ params: wrappedParams });
689
+ }
690
+ __name(wrapOperationParamsWithMaybeRef$2, "wrapOperationParamsWithMaybeRef");
691
+ function printType$3(typeNode) {
692
+ if (!typeNode) return "unknown";
693
+ if (typeNode.variant === "reference") return typeNode.name;
694
+ if (typeNode.variant === "member") return `${typeNode.base}['${typeNode.key}']`;
695
+ if (typeNode.variant === "struct") return `{ ${typeNode.properties.map((p) => {
696
+ const typeStr = printType$3(p.type);
697
+ const key = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p.name) ? p.name : JSON.stringify(p.name);
698
+ return p.optional ? `${key}?: ${typeStr}` : `${key}: ${typeStr}`;
699
+ }).join("; ")} }`;
700
+ return "unknown";
701
+ }
702
+ __name(printType$3, "printType");
703
+ function buildEnabledCheck(paramsNode) {
704
+ const required = [];
705
+ for (const param of paramsNode.params) if ("kind" in param && param.kind === "ParameterGroup") {
706
+ const group = param;
707
+ for (const child of group.properties) if (!child.optional && child.default === void 0) required.push(child.name);
708
+ } else {
709
+ const fp = param;
710
+ if (!fp.optional && fp.default === void 0) required.push(fp.name);
711
+ }
712
+ return required.join(" && ");
713
+ }
714
+ function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
715
+ const responseName = tsResolver.resolveResponseName(node);
716
+ const errorNames = resolveErrorNames(node, tsResolver);
717
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
718
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
719
+ const paramsNode = getQueryOptionsParams(node, {
720
+ paramsType,
721
+ paramsCasing,
722
+ pathParamsType,
723
+ resolver: tsResolver
724
+ });
725
+ const paramsSignature = declarationPrinter$4.print(paramsNode) ?? "";
726
+ const clientCallStr = (callPrinter$4.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
727
+ const queryKeyParamsNode = QueryKey.getParams(node, {
728
+ pathParamsType,
729
+ paramsCasing,
730
+ resolver: tsResolver
731
+ });
732
+ const queryKeyParamsCall = callPrinter$4.print(queryKeyParamsNode) ?? "";
733
+ const enabledSource = buildEnabledCheck(queryKeyParamsNode);
734
+ const enabledText = enabledSource ? `enabled: () => !!(${enabledSource}),` : "";
735
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
736
+ name,
737
+ isExportable: true,
738
+ isIndexable: true,
739
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
740
+ name,
741
+ export: true,
742
+ params: paramsSignature,
743
+ children: `
744
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
745
+ return queryOptions<${TData}, ${TError}, ${TData}>({
746
+ ${enabledText}
747
+ queryKey,
748
+ queryFn: async ({ signal }) => {
749
+ return ${clientName}(${addToValueCalls$1(clientCallStr)})
750
+ },
751
+ })
752
+ `
753
+ })
754
+ });
755
+ }
756
+ /**
757
+ * Wraps parameter names with `toValue()` in the client call string,
758
+ * except for 'config'-related params (which are already plain objects).
759
+ *
760
+ * Handles both inline params (`petId, config`) and object shorthand
761
+ * params (`{ petId }, config`) by expanding to `{ petId: toValue(petId) }`.
762
+ */
763
+ function addToValueCalls$1(callStr) {
764
+ let result = callStr.replace(/\{\s*([\w,\s]+)\s*\}(?=\s*,)/g, (match, inner) => {
765
+ if (inner.includes(":") || inner.includes("...")) return match;
766
+ return `{ ${inner.split(",").map((k) => k.trim()).filter(Boolean).map((k) => `${k}: toValue(${k})`).join(", ")} }`;
767
+ });
768
+ result = result.replace(/(?<![{.:?])\b(\w+)\b(?=\s*,)/g, (match, name) => {
769
+ if (name === "config" || name === "signal" || name === "undefined") return match;
770
+ if (match.includes("toValue(")) return match;
771
+ return `toValue(${name})`;
772
+ });
773
+ return result;
774
+ }
775
+ __name(addToValueCalls$1, "addToValueCalls");
776
+ QueryOptions.getParams = getQueryOptionsParams;
777
+ //#endregion
778
+ //#region src/components/InfiniteQuery.tsx
779
+ const declarationPrinter$3 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
780
+ const callPrinter$3 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
781
+ function getParams$2(node, options) {
782
+ const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options;
783
+ const responseName = resolver.resolveResponseName(node);
784
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
785
+ const errorNames = resolveErrorNames(node, resolver);
786
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
787
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
788
+ const optionsParam = _kubb_core.ast.createFunctionParameter({
789
+ name: "options",
790
+ type: _kubb_core.ast.createParamsType({
791
+ variant: "reference",
792
+ name: `{
793
+ query?: Partial<UseInfiniteQueryOptions<${[
794
+ TData,
795
+ TError,
796
+ "TQueryData",
797
+ "TQueryKey",
798
+ "TQueryData"
799
+ ].join(", ")}>> & { client?: QueryClient },
800
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
801
+ }`
802
+ }),
803
+ default: "{}"
804
+ });
805
+ return wrapOperationParamsWithMaybeRef$1(_kubb_core.ast.createOperationParams(node, {
806
+ paramsType,
807
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
808
+ paramsCasing,
809
+ resolver,
810
+ extraParams: [optionsParam]
811
+ }));
812
+ }
813
+ __name(getParams$2, "getParams");
814
+ function wrapOperationParamsWithMaybeRef$1(paramsNode) {
815
+ const wrappedParams = paramsNode.params.map((param) => {
816
+ if ("kind" in param && param.kind === "ParameterGroup") {
817
+ const group = param;
818
+ return {
819
+ ...group,
820
+ properties: group.properties.map((p) => ({
821
+ ...p,
822
+ type: p.type ? _kubb_core.ast.createParamsType({
823
+ variant: "reference",
824
+ name: `MaybeRefOrGetter<${printType$2(p.type)}>`
825
+ }) : p.type
826
+ }))
827
+ };
828
+ }
829
+ const fp = param;
830
+ if (fp.name === "options") return fp;
831
+ return {
832
+ ...fp,
833
+ type: fp.type ? _kubb_core.ast.createParamsType({
834
+ variant: "reference",
835
+ name: `MaybeRefOrGetter<${printType$2(fp.type)}>`
836
+ }) : fp.type
837
+ };
838
+ });
839
+ return _kubb_core.ast.createFunctionParameters({ params: wrappedParams });
840
+ }
841
+ __name(wrapOperationParamsWithMaybeRef$1, "wrapOperationParamsWithMaybeRef");
842
+ function printType$2(typeNode) {
843
+ if (!typeNode) return "unknown";
844
+ if (typeNode.variant === "reference") return typeNode.name;
845
+ if (typeNode.variant === "member") return `${typeNode.base}['${typeNode.key}']`;
846
+ if (typeNode.variant === "struct") return `{ ${typeNode.properties.map((p) => {
847
+ const typeStr = printType$2(p.type);
848
+ const key = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p.name) ? p.name : JSON.stringify(p.name);
849
+ return p.optional ? `${key}?: ${typeStr}` : `${key}: ${typeStr}`;
850
+ }).join("; ")} }`;
851
+ return "unknown";
852
+ }
853
+ __name(printType$2, "printType");
854
+ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver }) {
855
+ const responseName = tsResolver.resolveResponseName(node);
856
+ const errorNames = resolveErrorNames(node, tsResolver);
857
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
858
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
859
+ const returnType = `UseInfiniteQueryReturnType<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
860
+ const generics = [
861
+ `TData = InfiniteData<${TData}>`,
862
+ `TQueryData = ${TData}`,
863
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`
864
+ ];
865
+ const queryKeyParamsNode = QueryKey.getParams(node, {
866
+ pathParamsType,
867
+ paramsCasing,
868
+ resolver: tsResolver
869
+ });
870
+ const queryKeyParamsCall = callPrinter$3.print(queryKeyParamsNode) ?? "";
871
+ const queryOptionsParamsNode = getQueryOptionsParams(node, {
872
+ paramsType,
873
+ paramsCasing,
874
+ pathParamsType,
875
+ resolver: tsResolver
876
+ });
877
+ const queryOptionsParamsCall = callPrinter$3.print(queryOptionsParamsNode) ?? "";
878
+ const paramsNode = getParams$2(node, {
879
+ paramsType,
880
+ paramsCasing,
881
+ pathParamsType,
882
+ dataReturnType,
883
+ resolver: tsResolver
884
+ });
885
+ const paramsSignature = declarationPrinter$3.print(paramsNode) ?? "";
886
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
887
+ name,
888
+ isExportable: true,
889
+ isIndexable: true,
890
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
891
+ name,
892
+ export: true,
893
+ generics: generics.join(", "),
894
+ params: paramsSignature,
895
+ JSDoc: { comments: getComments(node) },
896
+ children: `
897
+ const { query: queryConfig = {}, client: config = {} } = options ?? {}
898
+ const { client: queryClient, ...resolvedOptions } = queryConfig
899
+ const queryKey = (resolvedOptions && 'queryKey' in resolvedOptions ? toValue(resolvedOptions.queryKey) : undefined) ?? ${queryKeyName}(${queryKeyParamsCall})
900
+
901
+ const query = useInfiniteQuery({
902
+ ...${queryOptionsName}(${queryOptionsParamsCall}),
903
+ ...resolvedOptions,
904
+ queryKey
905
+ } as unknown as UseInfiniteQueryOptions<${TData}, ${TError}, ${TData}, TQueryKey, ${TData}>, toValue(queryClient)) as ${returnType}
906
+
907
+ query.queryKey = queryKey as TQueryKey
908
+
909
+ return query
910
+ `
911
+ })
912
+ });
913
+ }
914
+ InfiniteQuery.getParams = getParams$2;
915
+ //#endregion
916
+ //#region src/components/InfiniteQueryOptions.tsx
917
+ const declarationPrinter$2 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
918
+ const callPrinter$2 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
919
+ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
920
+ const responseName = tsResolver.resolveResponseName(node);
921
+ const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
922
+ const errorNames = resolveErrorNames(node, tsResolver);
923
+ const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
924
+ const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
925
+ const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
926
+ const parts = initialPageParam.split(" as ");
927
+ return parts[parts.length - 1] ?? "unknown";
928
+ })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
929
+ const rawQueryParams = node.parameters.filter((p) => p.in === "query");
930
+ const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
931
+ const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
932
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
933
+ })() : void 0;
934
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
935
+ const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
936
+ const paramsNode = getQueryOptionsParams(node, {
937
+ paramsType,
938
+ paramsCasing,
939
+ pathParamsType,
940
+ resolver: tsResolver
941
+ });
942
+ const paramsSignature = declarationPrinter$2.print(paramsNode) ?? "";
943
+ const clientCallStr = (callPrinter$2.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
944
+ const queryKeyParamsNode = QueryKey.getParams(node, {
945
+ pathParamsType,
946
+ paramsCasing,
947
+ resolver: tsResolver
948
+ });
949
+ const queryKeyParamsCall = callPrinter$2.print(queryKeyParamsNode) ?? "";
950
+ const enabledSource = buildEnabledCheck(queryKeyParamsNode);
951
+ const enabledText = enabledSource ? `enabled: () => !!(${enabledSource}),` : "";
952
+ const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
953
+ let getNextPageParamExpr;
954
+ let getPreviousPageParamExpr;
955
+ if (hasNewParams) {
956
+ if (nextParam) {
957
+ const accessor = getNestedAccessor(nextParam, "lastPage");
958
+ if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
959
+ }
960
+ if (previousParam) {
961
+ const accessor = getNestedAccessor(previousParam, "firstPage");
962
+ if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
963
+ }
964
+ } else if (cursorParam) {
965
+ getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
966
+ getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
967
+ } else {
968
+ if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
969
+ else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
970
+ getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
971
+ }
972
+ const queryOptionsArr = [
973
+ `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
974
+ getNextPageParamExpr,
975
+ getPreviousPageParamExpr
976
+ ].filter(Boolean);
977
+ const infiniteOverrideParams = queryParam && queryParamsTypeName ? `
978
+ params = {
979
+ ...(params ?? {}),
980
+ ['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
981
+ } as ${queryParamsTypeName}` : "";
982
+ if (infiniteOverrideParams) return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
983
+ name,
984
+ isExportable: true,
985
+ isIndexable: true,
986
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
987
+ name,
988
+ export: true,
989
+ params: paramsSignature,
990
+ children: `
991
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
992
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, QueryKey, ${pageParamType}>({
993
+ ${enabledText}
994
+ queryKey,
995
+ queryFn: async ({ signal, pageParam }) => {
996
+ ${infiniteOverrideParams}
997
+ return ${clientName}(${addToValueCalls(clientCallStr)})
998
+ },
999
+ ${queryOptionsArr.join(",\n")}
1000
+ })
1001
+ `
1002
+ })
1003
+ });
1004
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1005
+ name,
1006
+ isExportable: true,
1007
+ isIndexable: true,
1008
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
1009
+ name,
1010
+ export: true,
1011
+ params: paramsSignature,
1012
+ children: `
1013
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1014
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, QueryKey, ${pageParamType}>({
1015
+ ${enabledText}
1016
+ queryKey,
1017
+ queryFn: async ({ signal }) => {
1018
+ return ${clientName}(${addToValueCalls(clientCallStr)})
1019
+ },
1020
+ ${queryOptionsArr.join(",\n")}
1021
+ })
1022
+ `
1023
+ })
1024
+ });
1025
+ }
1026
+ function addToValueCalls(callStr) {
1027
+ let result = callStr.replace(/\{\s*([\w,\s]+)\s*\}(?=\s*,)/g, (match, inner) => {
1028
+ if (inner.includes(":") || inner.includes("...")) return match;
1029
+ return `{ ${inner.split(",").map((k) => k.trim()).filter(Boolean).map((k) => `${k}: toValue(${k})`).join(", ")} }`;
1030
+ });
1031
+ result = result.replace(/(?<![{.:?])\b(\w+)\b(?=\s*,)/g, (match, name) => {
1032
+ if (name === "config" || name === "signal" || name === "undefined") return match;
1033
+ if (match.includes("toValue(")) return match;
1034
+ return `toValue(${name})`;
1035
+ });
1036
+ return result;
1037
+ }
1038
+ InfiniteQueryOptions.getParams = (node, options) => getQueryOptionsParams(node, options);
1039
+ //#endregion
1040
+ //#region src/components/Mutation.tsx
1041
+ const declarationPrinter$1 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
1042
+ const callPrinter$1 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
1043
+ const keysPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "keys" });
1044
+ function getParams$1(node, options) {
1045
+ const { paramsCasing, dataReturnType, resolver } = options;
1046
+ const responseName = resolver.resolveResponseName(node);
1047
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1048
+ const errorNames = resolveErrorNames(node, resolver);
1049
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1050
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1051
+ const mutationArgWrapped = buildMutationArgParams(node, {
1052
+ paramsCasing,
1053
+ resolver
1054
+ }).params.map((param) => {
1055
+ const fp = param;
1056
+ return {
1057
+ ...fp,
1058
+ type: fp.type ? _kubb_core.ast.createParamsType({
1059
+ variant: "reference",
1060
+ name: `MaybeRefOrGetter<${printType$1(fp.type)}>`
1061
+ }) : fp.type
1062
+ };
1063
+ });
1064
+ const wrappedParamsNode = _kubb_core.ast.createFunctionParameters({ params: mutationArgWrapped });
1065
+ const TRequestWrapped = wrappedParamsNode.params.length > 0 ? declarationPrinter$1.print(wrappedParamsNode) ?? "" : "";
1066
+ return _kubb_core.ast.createFunctionParameters({ params: [_kubb_core.ast.createFunctionParameter({
1067
+ name: "options",
1068
+ type: _kubb_core.ast.createParamsType({
1069
+ variant: "reference",
1070
+ name: `{
1071
+ mutation?: MutationObserverOptions<${[
1072
+ TData,
1073
+ TError,
1074
+ TRequestWrapped ? `{${TRequestWrapped}}` : "void",
1075
+ "TContext"
1076
+ ].join(", ")}> & { client?: QueryClient },
1077
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"},
1078
+ }`
1079
+ }),
1080
+ default: "{}"
1081
+ })] });
1082
+ }
1083
+ __name(getParams$1, "getParams");
1084
+ function printType$1(typeNode) {
1085
+ if (!typeNode) return "unknown";
1086
+ if (typeNode.variant === "reference") return typeNode.name;
1087
+ if (typeNode.variant === "member") return `${typeNode.base}['${typeNode.key}']`;
1088
+ if (typeNode.variant === "struct") return `{ ${typeNode.properties.map((p) => {
1089
+ const typeStr = printType$1(p.type);
1090
+ const key = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p.name) ? p.name : JSON.stringify(p.name);
1091
+ return p.optional ? `${key}?: ${typeStr}` : `${key}: ${typeStr}`;
1092
+ }).join("; ")} }`;
1093
+ return "unknown";
1094
+ }
1095
+ __name(printType$1, "printType");
1096
+ function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, node, tsResolver, mutationKeyName }) {
1097
+ const responseName = tsResolver.resolveResponseName(node);
1098
+ const errorNames = resolveErrorNames(node, tsResolver);
1099
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1100
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1101
+ const mutationArgParamsNode = buildMutationArgParams(node, {
1102
+ paramsCasing,
1103
+ resolver: tsResolver
1104
+ });
1105
+ const hasMutationParams = mutationArgParamsNode.params.length > 0;
1106
+ const TRequest = hasMutationParams ? declarationPrinter$1.print(mutationArgParamsNode) ?? "" : "";
1107
+ const argKeysStr = hasMutationParams ? keysPrinter.print(mutationArgParamsNode) ?? "" : "";
1108
+ const generics = [
1109
+ TData,
1110
+ TError,
1111
+ TRequest ? `{${TRequest}}` : "void",
1112
+ "TContext"
1113
+ ].join(", ");
1114
+ const mutationKeyParamsNode = MutationKey.getParams();
1115
+ const mutationKeyParamsCall = callPrinter$1.print(mutationKeyParamsNode) ?? "";
1116
+ const clientCallParamsNode = _kubb_core.ast.createOperationParams(node, {
1117
+ paramsType,
1118
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1119
+ paramsCasing,
1120
+ resolver: tsResolver,
1121
+ extraParams: [_kubb_core.ast.createFunctionParameter({
1122
+ name: "config",
1123
+ type: _kubb_core.ast.createParamsType({
1124
+ variant: "reference",
1125
+ name: node.requestBody?.content?.[0]?.schema ? `Partial<RequestConfig<${tsResolver.resolveDataName(node)}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
1126
+ }),
1127
+ default: "{}"
1128
+ })]
1129
+ });
1130
+ const clientCallStr = callPrinter$1.print(clientCallParamsNode) ?? "";
1131
+ const paramsNode = getParams$1(node, {
1132
+ paramsCasing,
1133
+ dataReturnType,
1134
+ resolver: tsResolver
1135
+ });
1136
+ const paramsSignature = declarationPrinter$1.print(paramsNode) ?? "";
1137
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1138
+ name,
1139
+ isExportable: true,
1140
+ isIndexable: true,
1141
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
1142
+ name,
1143
+ export: true,
1144
+ params: paramsSignature,
1145
+ JSDoc: { comments: getComments(node) },
1146
+ generics: ["TContext"],
1147
+ children: `
1148
+ const { mutation = {}, client: config = {} } = options ?? {}
1149
+ const { client: queryClient, ...mutationOptions } = mutation;
1150
+ const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParamsCall})
1151
+
1152
+ return useMutation<${generics}>({
1153
+ mutationFn: async(${hasMutationParams ? `{ ${argKeysStr} }` : ""}) => {
1154
+ return ${clientName}(${clientCallStr})
1155
+ },
1156
+ mutationKey,
1157
+ ...mutationOptions
1158
+ }, queryClient)
1159
+ `
1160
+ })
1161
+ });
1162
+ }
1163
+ Mutation.getParams = getParams$1;
1164
+ //#endregion
1165
+ //#region src/components/Query.tsx
1166
+ const declarationPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
1167
+ const callPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
1168
+ function getParams(node, options) {
1169
+ const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options;
1170
+ const responseName = resolver.resolveResponseName(node);
1171
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1172
+ const errorNames = resolveErrorNames(node, resolver);
1173
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1174
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1175
+ const optionsParam = _kubb_core.ast.createFunctionParameter({
1176
+ name: "options",
1177
+ type: _kubb_core.ast.createParamsType({
1178
+ variant: "reference",
1179
+ name: `{
1180
+ query?: Partial<UseQueryOptions<${[
1181
+ TData,
1182
+ TError,
1183
+ "TData",
1184
+ "TQueryData",
1185
+ "TQueryKey"
1186
+ ].join(", ")}>> & { client?: QueryClient },
1187
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
1188
+ }`
1189
+ }),
1190
+ default: "{}"
1191
+ });
1192
+ return wrapOperationParamsWithMaybeRef(_kubb_core.ast.createOperationParams(node, {
1193
+ paramsType,
1194
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1195
+ paramsCasing,
1196
+ resolver,
1197
+ extraParams: [optionsParam]
1198
+ }));
1199
+ }
1200
+ function wrapOperationParamsWithMaybeRef(paramsNode) {
1201
+ const wrappedParams = paramsNode.params.map((param) => {
1202
+ if ("kind" in param && param.kind === "ParameterGroup") {
1203
+ const group = param;
1204
+ return {
1205
+ ...group,
1206
+ properties: group.properties.map((p) => ({
1207
+ ...p,
1208
+ type: p.type ? _kubb_core.ast.createParamsType({
1209
+ variant: "reference",
1210
+ name: `MaybeRefOrGetter<${printType(p.type)}>`
1211
+ }) : p.type
1212
+ }))
1213
+ };
1214
+ }
1215
+ const fp = param;
1216
+ if (fp.name === "options") return fp;
1217
+ return {
1218
+ ...fp,
1219
+ type: fp.type ? _kubb_core.ast.createParamsType({
1220
+ variant: "reference",
1221
+ name: `MaybeRefOrGetter<${printType(fp.type)}>`
1222
+ }) : fp.type
1223
+ };
1224
+ });
1225
+ return _kubb_core.ast.createFunctionParameters({ params: wrappedParams });
1226
+ }
1227
+ function printType(typeNode) {
1228
+ if (!typeNode) return "unknown";
1229
+ if (typeNode.variant === "reference") return typeNode.name;
1230
+ if (typeNode.variant === "member") return `${typeNode.base}['${typeNode.key}']`;
1231
+ if (typeNode.variant === "struct") return `{ ${typeNode.properties.map((p) => {
1232
+ const typeStr = printType(p.type);
1233
+ const key = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p.name) ? p.name : JSON.stringify(p.name);
1234
+ return p.optional ? `${key}?: ${typeStr}` : `${key}: ${typeStr}`;
1235
+ }).join("; ")} }`;
1236
+ return "unknown";
1237
+ }
1238
+ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver }) {
1239
+ const responseName = tsResolver.resolveResponseName(node);
1240
+ const errorNames = resolveErrorNames(node, tsResolver);
1241
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1242
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1243
+ const returnType = `UseQueryReturnType<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
1244
+ const generics = [
1245
+ `TData = ${TData}`,
1246
+ `TQueryData = ${TData}`,
1247
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`
1248
+ ];
1249
+ const queryKeyParamsNode = QueryKey.getParams(node, {
1250
+ pathParamsType,
1251
+ paramsCasing,
1252
+ resolver: tsResolver
1253
+ });
1254
+ const queryKeyParamsCall = callPrinter.print(queryKeyParamsNode) ?? "";
1255
+ const queryOptionsParamsNode = getQueryOptionsParams(node, {
1256
+ paramsType,
1257
+ paramsCasing,
1258
+ pathParamsType,
1259
+ resolver: tsResolver
1260
+ });
1261
+ const queryOptionsParamsCall = callPrinter.print(queryOptionsParamsNode) ?? "";
1262
+ const paramsNode = getParams(node, {
1263
+ paramsType,
1264
+ paramsCasing,
1265
+ pathParamsType,
1266
+ dataReturnType,
1267
+ resolver: tsResolver
1268
+ });
1269
+ const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
1270
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1271
+ name,
1272
+ isExportable: true,
1273
+ isIndexable: true,
1274
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
1275
+ name,
1276
+ export: true,
1277
+ generics: generics.join(", "),
1278
+ params: paramsSignature,
1279
+ JSDoc: { comments: getComments(node) },
1280
+ children: `
1281
+ const { query: queryConfig = {}, client: config = {} } = options ?? {}
1282
+ const { client: queryClient, ...resolvedOptions } = queryConfig
1283
+ const queryKey = (resolvedOptions && 'queryKey' in resolvedOptions ? toValue(resolvedOptions.queryKey) : undefined) ?? ${queryKeyName}(${queryKeyParamsCall})
1284
+
1285
+ const query = useQuery({
1286
+ ...${queryOptionsName}(${queryOptionsParamsCall}),
1287
+ ...resolvedOptions,
1288
+ queryKey
1289
+ } as unknown as UseQueryOptions<${TData}, ${TError}, TData, ${TData}, TQueryKey>, toValue(queryClient)) as ${returnType}
1290
+
1291
+ query.queryKey = queryKey as TQueryKey
1292
+
1293
+ return query
1294
+ `
1295
+ })
1296
+ });
1297
+ }
1298
+ Query.getParams = getParams;
1299
+ //#endregion
1300
+ Object.defineProperty(exports, "InfiniteQuery", {
1301
+ enumerable: true,
1302
+ get: function() {
1303
+ return InfiniteQuery;
1304
+ }
1305
+ });
1306
+ Object.defineProperty(exports, "InfiniteQueryOptions", {
1307
+ enumerable: true,
1308
+ get: function() {
1309
+ return InfiniteQueryOptions;
1310
+ }
1311
+ });
1312
+ Object.defineProperty(exports, "Mutation", {
1313
+ enumerable: true,
1314
+ get: function() {
1315
+ return Mutation;
1316
+ }
1317
+ });
1318
+ Object.defineProperty(exports, "MutationKey", {
1319
+ enumerable: true,
1320
+ get: function() {
1321
+ return MutationKey;
1322
+ }
1323
+ });
1324
+ Object.defineProperty(exports, "Query", {
1325
+ enumerable: true,
1326
+ get: function() {
1327
+ return Query;
1328
+ }
1329
+ });
1330
+ Object.defineProperty(exports, "QueryKey", {
1331
+ enumerable: true,
1332
+ get: function() {
1333
+ return QueryKey;
1334
+ }
1335
+ });
1336
+ Object.defineProperty(exports, "QueryOptions", {
1337
+ enumerable: true,
1338
+ get: function() {
1339
+ return QueryOptions;
1340
+ }
1341
+ });
1342
+ Object.defineProperty(exports, "__name", {
1343
+ enumerable: true,
1344
+ get: function() {
1345
+ return __name;
1346
+ }
1347
+ });
1348
+ Object.defineProperty(exports, "__toESM", {
1349
+ enumerable: true,
1350
+ get: function() {
1351
+ return __toESM;
1352
+ }
1353
+ });
1354
+ Object.defineProperty(exports, "camelCase", {
1355
+ enumerable: true,
1356
+ get: function() {
1357
+ return camelCase;
1358
+ }
1359
+ });
1360
+ Object.defineProperty(exports, "transformName", {
1361
+ enumerable: true,
1362
+ get: function() {
1363
+ return transformName;
1364
+ }
1365
+ });
1366
+
1367
+ //# sourceMappingURL=components-qfOFRSoM.cjs.map