@kubb/plugin-react-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 (52) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +1 -3
  3. package/dist/components-DTGLu4UV.js +1451 -0
  4. package/dist/components-DTGLu4UV.js.map +1 -0
  5. package/dist/components-dAKJEn9b.cjs +1571 -0
  6. package/dist/components-dAKJEn9b.cjs.map +1 -0
  7. package/dist/components.cjs +1 -1
  8. package/dist/components.d.ts +105 -161
  9. package/dist/components.js +1 -1
  10. package/dist/generators-CWEQsdO9.cjs +1502 -0
  11. package/dist/generators-CWEQsdO9.cjs.map +1 -0
  12. package/dist/generators-C_fbcjpG.js +1460 -0
  13. package/dist/generators-C_fbcjpG.js.map +1 -0
  14. package/dist/generators.cjs +1 -1
  15. package/dist/generators.d.ts +9 -476
  16. package/dist/generators.js +1 -1
  17. package/dist/index.cjs +114 -126
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +110 -126
  21. package/dist/index.js.map +1 -1
  22. package/dist/{types-D5S7Ny9r.d.ts → types-DfaFRSBf.d.ts} +100 -86
  23. package/package.json +59 -62
  24. package/src/components/InfiniteQuery.tsx +75 -139
  25. package/src/components/InfiniteQueryOptions.tsx +62 -164
  26. package/src/components/Mutation.tsx +58 -113
  27. package/src/components/MutationOptions.tsx +61 -80
  28. package/src/components/Query.tsx +67 -140
  29. package/src/components/QueryOptions.tsx +75 -135
  30. package/src/components/SuspenseInfiniteQuery.tsx +75 -139
  31. package/src/components/SuspenseInfiniteQueryOptions.tsx +62 -164
  32. package/src/components/SuspenseQuery.tsx +67 -150
  33. package/src/generators/customHookOptionsFileGenerator.tsx +33 -45
  34. package/src/generators/hookOptionsGenerator.tsx +115 -175
  35. package/src/generators/infiniteQueryGenerator.tsx +183 -176
  36. package/src/generators/mutationGenerator.tsx +127 -138
  37. package/src/generators/queryGenerator.tsx +141 -141
  38. package/src/generators/suspenseInfiniteQueryGenerator.tsx +175 -155
  39. package/src/generators/suspenseQueryGenerator.tsx +149 -148
  40. package/src/index.ts +1 -1
  41. package/src/plugin.ts +133 -183
  42. package/src/resolvers/resolverReactQuery.ts +22 -0
  43. package/src/types.ts +67 -45
  44. package/src/utils.ts +40 -0
  45. package/dist/components-BHQT9ZLc.cjs +0 -1634
  46. package/dist/components-BHQT9ZLc.cjs.map +0 -1
  47. package/dist/components-CpyHYGOw.js +0 -1520
  48. package/dist/components-CpyHYGOw.js.map +0 -1
  49. package/dist/generators-DP07m3rH.cjs +0 -1469
  50. package/dist/generators-DP07m3rH.cjs.map +0 -1
  51. package/dist/generators-DkQwKTc2.js +0 -1427
  52. package/dist/generators-DkQwKTc2.js.map +0 -1
@@ -0,0 +1,1571 @@
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$10 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
339
+ function getParams$6() {
340
+ return _kubb_core.ast.createFunctionParameters({ params: [] });
341
+ }
342
+ __name(getParams$6, "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$6();
348
+ const paramsSignature = declarationPrinter$10.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$6;
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 ../../internals/tanstack-query/src/components/QueryKey.tsx
542
+ const declarationPrinter$9 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
543
+ const callPrinter$9 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
544
+ function getParams$5(node, options) {
545
+ return buildQueryKeyParams(node, options);
546
+ }
547
+ __name(getParams$5, "getParams");
548
+ const getTransformer = ({ node, casing }) => {
549
+ const path = new URLPath(node.path, { casing });
550
+ const hasQueryParams = node.parameters.some((p) => p.in === "query");
551
+ const hasRequestBody = !!node.requestBody?.content?.[0]?.schema;
552
+ return [
553
+ path.toObject({
554
+ type: "path",
555
+ stringify: true
556
+ }),
557
+ hasQueryParams ? "...(params ? [params] : [])" : void 0,
558
+ hasRequestBody ? "...(data ? [data] : [])" : void 0
559
+ ].filter(Boolean);
560
+ };
561
+ function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeName, transformer = getTransformer }) {
562
+ const paramsNode = getParams$5(node, {
563
+ pathParamsType,
564
+ paramsCasing,
565
+ resolver: tsResolver
566
+ });
567
+ const paramsSignature = declarationPrinter$9.print(paramsNode) ?? "";
568
+ const keys = transformer({
569
+ node,
570
+ casing: paramsCasing
571
+ });
572
+ 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, {
573
+ name,
574
+ isExportable: true,
575
+ isIndexable: true,
576
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function.Arrow, {
577
+ name,
578
+ export: true,
579
+ params: paramsSignature,
580
+ singleLine: true,
581
+ children: `[${keys.join(", ")}] as const`
582
+ })
583
+ }), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
584
+ name: typeName,
585
+ isTypeOnly: true,
586
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Type, {
587
+ name: typeName,
588
+ children: `ReturnType<typeof ${name}>`
589
+ })
590
+ })] });
591
+ }
592
+ QueryKey.getParams = getParams$5;
593
+ QueryKey.getTransformer = getTransformer;
594
+ QueryKey.callPrinter = callPrinter$9;
595
+ //#endregion
596
+ //#region src/utils.ts
597
+ function transformName(name, type, transformers) {
598
+ return transformers?.name?.(name, type) || name;
599
+ }
600
+ function matchesPattern(node, ov) {
601
+ const { type, pattern } = ov;
602
+ const matches = (value) => typeof pattern === "string" ? value === pattern : pattern.test(value);
603
+ if (type === "operationId") return matches(node.operationId);
604
+ if (type === "tag") return node.tags.some((t) => matches(t));
605
+ if (type === "path") return matches(node.path);
606
+ if (type === "method") return matches(node.method);
607
+ return false;
608
+ }
609
+ /**
610
+ * Resolves per-operation overrides (first matching override wins), mirroring v4 OperationGenerator.getOptions().
611
+ */
612
+ function resolveOperationOverrides(node, override) {
613
+ if (!override) return {};
614
+ return override.find((ov) => matchesPattern(node, ov))?.options ?? {};
615
+ }
616
+ //#endregion
617
+ //#region src/components/QueryOptions.tsx
618
+ const declarationPrinter$8 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
619
+ const callPrinter$8 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
620
+ function getQueryOptionsParams(node, options) {
621
+ const { paramsType, paramsCasing, pathParamsType, resolver } = options;
622
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
623
+ return _kubb_core.ast.createOperationParams(node, {
624
+ paramsType,
625
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
626
+ paramsCasing,
627
+ resolver,
628
+ extraParams: [_kubb_core.ast.createFunctionParameter({
629
+ name: "config",
630
+ type: _kubb_core.ast.createParamsType({
631
+ variant: "reference",
632
+ name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
633
+ }),
634
+ default: "{}"
635
+ })]
636
+ });
637
+ }
638
+ function buildEnabledCheck(paramsNode) {
639
+ const required = [];
640
+ for (const param of paramsNode.params) if ("kind" in param && param.kind === "ParameterGroup") {
641
+ const group = param;
642
+ for (const child of group.properties) if (!child.optional && child.default === void 0) required.push(child.name);
643
+ } else {
644
+ const fp = param;
645
+ if (!fp.optional && fp.default === void 0) required.push(fp.name);
646
+ }
647
+ return required.join(" && ");
648
+ }
649
+ function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
650
+ const responseName = tsResolver.resolveResponseName(node);
651
+ const errorNames = resolveErrorNames(node, tsResolver);
652
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
653
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
654
+ const paramsNode = getQueryOptionsParams(node, {
655
+ paramsType,
656
+ paramsCasing,
657
+ pathParamsType,
658
+ resolver: tsResolver
659
+ });
660
+ const paramsSignature = declarationPrinter$8.print(paramsNode) ?? "";
661
+ const clientCallStr = (callPrinter$8.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
662
+ const queryKeyParamsNode = QueryKey.getParams(node, {
663
+ pathParamsType,
664
+ paramsCasing,
665
+ resolver: tsResolver
666
+ });
667
+ const queryKeyParamsCall = callPrinter$8.print(queryKeyParamsNode) ?? "";
668
+ const enabledSource = buildEnabledCheck(queryKeyParamsNode);
669
+ const enabledText = enabledSource ? `enabled: !!(${enabledSource}),` : "";
670
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
671
+ name,
672
+ isExportable: true,
673
+ isIndexable: true,
674
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
675
+ name,
676
+ export: true,
677
+ params: paramsSignature,
678
+ children: `
679
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
680
+ return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({
681
+ ${enabledText}
682
+ queryKey,
683
+ queryFn: async ({ signal }) => {
684
+ return ${clientName}(${clientCallStr})
685
+ },
686
+ })
687
+ `
688
+ })
689
+ });
690
+ }
691
+ QueryOptions.getParams = getQueryOptionsParams;
692
+ //#endregion
693
+ //#region src/components/InfiniteQuery.tsx
694
+ const declarationPrinter$7 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
695
+ const callPrinter$7 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
696
+ function getParams$4(node, options) {
697
+ const { paramsType, paramsCasing, pathParamsType, resolver, pageParamGeneric } = options;
698
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
699
+ const optionsParam = _kubb_core.ast.createFunctionParameter({
700
+ name: "options",
701
+ type: _kubb_core.ast.createParamsType({
702
+ variant: "reference",
703
+ name: `{
704
+ query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
705
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
706
+ }`
707
+ }),
708
+ default: "{}"
709
+ });
710
+ return _kubb_core.ast.createOperationParams(node, {
711
+ paramsType,
712
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
713
+ paramsCasing,
714
+ resolver,
715
+ extraParams: [optionsParam]
716
+ });
717
+ }
718
+ __name(getParams$4, "getParams");
719
+ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, initialPageParam, queryParam, customOptions }) {
720
+ const responseName = tsResolver.resolveResponseName(node);
721
+ const errorNames = resolveErrorNames(node, tsResolver);
722
+ const responseType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
723
+ const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
724
+ const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
725
+ const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
726
+ const parts = initialPageParam.split(" as ");
727
+ return parts[parts.length - 1] ?? "unknown";
728
+ })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
729
+ const rawQueryParams = node.parameters.filter((p) => p.in === "query");
730
+ const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
731
+ const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
732
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
733
+ })() : void 0;
734
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
735
+ const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
736
+ const returnType = "UseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
737
+ const generics = [
738
+ `TQueryFnData = ${responseType}`,
739
+ `TError = ${errorType}`,
740
+ "TData = InfiniteData<TQueryFnData>",
741
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
742
+ `TPageParam = ${pageParamType}`
743
+ ];
744
+ const queryKeyParamsNode = QueryKey.getParams(node, {
745
+ pathParamsType,
746
+ paramsCasing,
747
+ resolver: tsResolver
748
+ });
749
+ const queryKeyParamsCall = callPrinter$7.print(queryKeyParamsNode) ?? "";
750
+ const queryOptionsParamsNode = getQueryOptionsParams(node, {
751
+ paramsType,
752
+ paramsCasing,
753
+ pathParamsType,
754
+ resolver: tsResolver
755
+ });
756
+ const queryOptionsParamsCall = callPrinter$7.print(queryOptionsParamsNode) ?? "";
757
+ const paramsNode = getParams$4(node, {
758
+ paramsType,
759
+ paramsCasing,
760
+ pathParamsType,
761
+ dataReturnType,
762
+ resolver: tsResolver,
763
+ pageParamGeneric: "TPageParam"
764
+ });
765
+ const paramsSignature = declarationPrinter$7.print(paramsNode) ?? "";
766
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
767
+ name,
768
+ isExportable: true,
769
+ isIndexable: true,
770
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
771
+ name,
772
+ export: true,
773
+ generics: generics.join(", "),
774
+ params: paramsSignature,
775
+ returnType: void 0,
776
+ JSDoc: { comments: getComments(node) },
777
+ children: `
778
+ const { query: queryConfig = {}, client: config = {} } = options ?? {}
779
+ const { client: queryClient, ...resolvedOptions } = queryConfig
780
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
781
+ ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
782
+
783
+ const query = useInfiniteQuery({
784
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
785
+ ...resolvedOptions,
786
+ queryKey,
787
+ } as unknown as InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
788
+
789
+ query.queryKey = queryKey as TQueryKey
790
+
791
+ return query
792
+ `
793
+ })
794
+ });
795
+ }
796
+ InfiniteQuery.getParams = getParams$4;
797
+ //#endregion
798
+ //#region src/components/InfiniteQueryOptions.tsx
799
+ const declarationPrinter$6 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
800
+ const callPrinter$6 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
801
+ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
802
+ const responseName = tsResolver.resolveResponseName(node);
803
+ const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
804
+ const errorNames = resolveErrorNames(node, tsResolver);
805
+ const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
806
+ const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
807
+ const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
808
+ const parts = initialPageParam.split(" as ");
809
+ return parts[parts.length - 1] ?? "unknown";
810
+ })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
811
+ const rawQueryParams = node.parameters.filter((p) => p.in === "query");
812
+ const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
813
+ const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
814
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
815
+ })() : void 0;
816
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
817
+ const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
818
+ const paramsNode = getQueryOptionsParams(node, {
819
+ paramsType,
820
+ paramsCasing,
821
+ pathParamsType,
822
+ resolver: tsResolver
823
+ });
824
+ const paramsSignature = declarationPrinter$6.print(paramsNode) ?? "";
825
+ const clientCallStr = (callPrinter$6.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
826
+ const queryKeyParamsNode = QueryKey.getParams(node, {
827
+ pathParamsType,
828
+ paramsCasing,
829
+ resolver: tsResolver
830
+ });
831
+ const queryKeyParamsCall = callPrinter$6.print(queryKeyParamsNode) ?? "";
832
+ const enabledSource = buildEnabledCheck(queryKeyParamsNode);
833
+ const enabledText = enabledSource ? `enabled: !!(${enabledSource}),` : "";
834
+ const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
835
+ let getNextPageParamExpr;
836
+ let getPreviousPageParamExpr;
837
+ if (hasNewParams) {
838
+ if (nextParam) {
839
+ const accessor = getNestedAccessor(nextParam, "lastPage");
840
+ if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
841
+ }
842
+ if (previousParam) {
843
+ const accessor = getNestedAccessor(previousParam, "firstPage");
844
+ if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
845
+ }
846
+ } else if (cursorParam) {
847
+ getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
848
+ getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
849
+ } else {
850
+ if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
851
+ else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
852
+ getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
853
+ }
854
+ const queryOptionsArr = [
855
+ `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
856
+ getNextPageParamExpr,
857
+ getPreviousPageParamExpr
858
+ ].filter(Boolean);
859
+ const infiniteOverrideParams = queryParam && queryParamsTypeName ? `
860
+ params = {
861
+ ...(params ?? {}),
862
+ ['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
863
+ } as ${queryParamsTypeName}` : "";
864
+ if (infiniteOverrideParams) return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
865
+ name,
866
+ isExportable: true,
867
+ isIndexable: true,
868
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
869
+ name,
870
+ export: true,
871
+ params: paramsSignature,
872
+ children: `
873
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
874
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
875
+ ${enabledText}
876
+ queryKey,
877
+ queryFn: async ({ signal, pageParam }) => {
878
+ ${infiniteOverrideParams}
879
+ return ${clientName}(${clientCallStr})
880
+ },
881
+ ${queryOptionsArr.join(",\n")}
882
+ })
883
+ `
884
+ })
885
+ });
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
+ params: paramsSignature,
894
+ children: `
895
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
896
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
897
+ ${enabledText}
898
+ queryKey,
899
+ queryFn: async ({ signal }) => {
900
+ return ${clientName}(${clientCallStr})
901
+ },
902
+ ${queryOptionsArr.join(",\n")}
903
+ })
904
+ `
905
+ })
906
+ });
907
+ }
908
+ InfiniteQueryOptions.getParams = (node, options) => getQueryOptionsParams(node, options);
909
+ //#endregion
910
+ //#region src/components/MutationOptions.tsx
911
+ const declarationPrinter$5 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
912
+ const callPrinter$5 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
913
+ const keysPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "keys" });
914
+ function getConfigParam(node, resolver) {
915
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
916
+ return _kubb_core.ast.createFunctionParameters({ params: [_kubb_core.ast.createFunctionParameter({
917
+ name: "config",
918
+ type: _kubb_core.ast.createParamsType({
919
+ variant: "reference",
920
+ name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
921
+ }),
922
+ default: "{}"
923
+ })] });
924
+ }
925
+ function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, mutationKeyName }) {
926
+ const responseName = tsResolver.resolveResponseName(node);
927
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
928
+ const errorNames = resolveErrorNames(node, tsResolver);
929
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
930
+ const configParamsNode = getConfigParam(node, tsResolver);
931
+ const paramsSignature = declarationPrinter$5.print(configParamsNode) ?? "";
932
+ const mutationArgParamsNode = buildMutationArgParams(node, {
933
+ paramsCasing,
934
+ resolver: tsResolver
935
+ });
936
+ const hasMutationParams = mutationArgParamsNode.params.length > 0;
937
+ const TRequest = hasMutationParams ? declarationPrinter$5.print(mutationArgParamsNode) ?? "" : "";
938
+ const argKeysStr = hasMutationParams ? keysPrinter.print(mutationArgParamsNode) ?? "" : "";
939
+ const clientCallParamsNode = _kubb_core.ast.createOperationParams(node, {
940
+ paramsType,
941
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
942
+ paramsCasing,
943
+ resolver: tsResolver,
944
+ extraParams: [_kubb_core.ast.createFunctionParameter({
945
+ name: "config",
946
+ type: _kubb_core.ast.createParamsType({
947
+ variant: "reference",
948
+ name: node.requestBody?.content?.[0]?.schema ? `Partial<RequestConfig<${tsResolver.resolveDataName(node)}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
949
+ }),
950
+ default: "{}"
951
+ })]
952
+ });
953
+ const clientCallStr = callPrinter$5.print(clientCallParamsNode) ?? "";
954
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
955
+ name,
956
+ isExportable: true,
957
+ isIndexable: true,
958
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
959
+ name,
960
+ export: true,
961
+ params: paramsSignature,
962
+ generics: ["TContext = unknown"],
963
+ children: `
964
+ const mutationKey = ${mutationKeyName}()
965
+ return mutationOptions<${TData}, ${TError}, ${TRequest ? `{${TRequest}}` : "void"}, TContext>({
966
+ mutationKey,
967
+ mutationFn: async(${hasMutationParams ? `{ ${argKeysStr} }` : "_"}) => {
968
+ return ${clientName}(${clientCallStr})
969
+ },
970
+ })
971
+ `
972
+ })
973
+ });
974
+ }
975
+ MutationOptions.getParams = getConfigParam;
976
+ //#endregion
977
+ //#region src/components/Mutation.tsx
978
+ const declarationPrinter$4 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
979
+ const callPrinter$4 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
980
+ function getParams$3(node, options) {
981
+ const { paramsCasing, dataReturnType, resolver } = options;
982
+ const responseName = resolver.resolveResponseName(node);
983
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
984
+ const errorNames = resolveErrorNames(node, resolver);
985
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
986
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
987
+ const mutationArgParamsNode = buildMutationArgParams(node, {
988
+ paramsCasing,
989
+ resolver
990
+ });
991
+ const TRequest = mutationArgParamsNode.params.length > 0 ? declarationPrinter$4.print(mutationArgParamsNode) ?? "" : "";
992
+ const generics = [
993
+ TData,
994
+ TError,
995
+ TRequest ? `{${TRequest}}` : "void",
996
+ "TContext"
997
+ ].join(", ");
998
+ return _kubb_core.ast.createFunctionParameters({ params: [_kubb_core.ast.createFunctionParameter({
999
+ name: "options",
1000
+ type: _kubb_core.ast.createParamsType({
1001
+ variant: "reference",
1002
+ name: `{
1003
+ mutation?: UseMutationOptions<${generics}> & { client?: QueryClient },
1004
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"},
1005
+ }`
1006
+ }),
1007
+ default: "{}"
1008
+ })] });
1009
+ }
1010
+ __name(getParams$3, "getParams");
1011
+ function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, node, tsResolver, mutationKeyName, customOptions }) {
1012
+ const responseName = tsResolver.resolveResponseName(node);
1013
+ const errorNames = resolveErrorNames(node, tsResolver);
1014
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1015
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1016
+ const mutationArgParamsNode = buildMutationArgParams(node, {
1017
+ paramsCasing,
1018
+ resolver: tsResolver
1019
+ });
1020
+ const TRequest = mutationArgParamsNode.params.length > 0 ? declarationPrinter$4.print(mutationArgParamsNode) ?? "" : "";
1021
+ const generics = [
1022
+ TData,
1023
+ TError,
1024
+ TRequest ? `{${TRequest}}` : "void",
1025
+ "TContext"
1026
+ ].join(", ");
1027
+ const returnType = `UseMutationResult<${generics}>`;
1028
+ const mutationOptionsConfigNode = MutationOptions.getParams(node, tsResolver);
1029
+ const mutationOptionsParamsCall = callPrinter$4.print(mutationOptionsConfigNode) ?? "";
1030
+ const paramsNode = getParams$3(node, {
1031
+ paramsCasing,
1032
+ dataReturnType,
1033
+ resolver: tsResolver
1034
+ });
1035
+ const paramsSignature = declarationPrinter$4.print(paramsNode) ?? "";
1036
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1037
+ name,
1038
+ isExportable: true,
1039
+ isIndexable: true,
1040
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
1041
+ name,
1042
+ export: true,
1043
+ params: paramsSignature,
1044
+ JSDoc: { comments: getComments(node) },
1045
+ generics: ["TContext"],
1046
+ children: `
1047
+ const { mutation = {}, client: config = {} } = options ?? {}
1048
+ const { client: queryClient, ...mutationOptions } = mutation;
1049
+ const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}()
1050
+
1051
+ const baseOptions = ${mutationOptionsName}(${mutationOptionsParamsCall}) as UseMutationOptions<${generics}>
1052
+ ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' }) as UseMutationOptions<${generics}>` : ""}
1053
+
1054
+ return useMutation<${generics}>({
1055
+ ...baseOptions,${customOptions ? "\n...customOptions," : ""}
1056
+ mutationKey,
1057
+ ...mutationOptions,
1058
+ }, queryClient) as ${returnType}
1059
+ `
1060
+ })
1061
+ });
1062
+ }
1063
+ Mutation.getParams = getParams$3;
1064
+ //#endregion
1065
+ //#region src/components/Query.tsx
1066
+ const declarationPrinter$3 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
1067
+ const callPrinter$3 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
1068
+ function getParams$2(node, options) {
1069
+ const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options;
1070
+ const responseName = resolver.resolveResponseName(node);
1071
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1072
+ const errorNames = resolveErrorNames(node, resolver);
1073
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1074
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1075
+ const optionsParam = _kubb_core.ast.createFunctionParameter({
1076
+ name: "options",
1077
+ type: _kubb_core.ast.createParamsType({
1078
+ variant: "reference",
1079
+ name: `{
1080
+ query?: Partial<QueryObserverOptions<${[
1081
+ TData,
1082
+ TError,
1083
+ "TData",
1084
+ "TQueryData",
1085
+ "TQueryKey"
1086
+ ].join(", ")}>> & { client?: QueryClient },
1087
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
1088
+ }`
1089
+ }),
1090
+ default: "{}"
1091
+ });
1092
+ return _kubb_core.ast.createOperationParams(node, {
1093
+ paramsType,
1094
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1095
+ paramsCasing,
1096
+ resolver,
1097
+ extraParams: [optionsParam]
1098
+ });
1099
+ }
1100
+ __name(getParams$2, "getParams");
1101
+ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions }) {
1102
+ const responseName = tsResolver.resolveResponseName(node);
1103
+ const errorNames = resolveErrorNames(node, tsResolver);
1104
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1105
+ const returnType = `UseQueryResult<TData, ${`ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`}> & { queryKey: TQueryKey }`;
1106
+ const generics = [
1107
+ `TData = ${TData}`,
1108
+ `TQueryData = ${TData}`,
1109
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`
1110
+ ];
1111
+ const queryKeyParamsNode = QueryKey.getParams(node, {
1112
+ pathParamsType,
1113
+ paramsCasing,
1114
+ resolver: tsResolver
1115
+ });
1116
+ const queryKeyParamsCall = callPrinter$3.print(queryKeyParamsNode) ?? "";
1117
+ const queryOptionsParamsNode = getQueryOptionsParams(node, {
1118
+ paramsType,
1119
+ paramsCasing,
1120
+ pathParamsType,
1121
+ resolver: tsResolver
1122
+ });
1123
+ const queryOptionsParamsCall = callPrinter$3.print(queryOptionsParamsNode) ?? "";
1124
+ const paramsNode = getParams$2(node, {
1125
+ paramsType,
1126
+ paramsCasing,
1127
+ pathParamsType,
1128
+ dataReturnType,
1129
+ resolver: tsResolver
1130
+ });
1131
+ const paramsSignature = declarationPrinter$3.print(paramsNode) ?? "";
1132
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1133
+ name,
1134
+ isExportable: true,
1135
+ isIndexable: true,
1136
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
1137
+ name,
1138
+ export: true,
1139
+ generics: generics.join(", "),
1140
+ params: paramsSignature,
1141
+ returnType: void 0,
1142
+ JSDoc: { comments: getComments(node) },
1143
+ children: `
1144
+ const { query: queryConfig = {}, client: config = {} } = options ?? {}
1145
+ const { client: queryClient, ...resolvedOptions } = queryConfig
1146
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
1147
+ ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1148
+
1149
+ const query = useQuery({
1150
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
1151
+ ...resolvedOptions,
1152
+ queryKey,
1153
+ } as unknown as QueryObserverOptions, queryClient) as ${returnType}
1154
+
1155
+ query.queryKey = queryKey as TQueryKey
1156
+
1157
+ return query
1158
+ `
1159
+ })
1160
+ });
1161
+ }
1162
+ Query.getParams = getParams$2;
1163
+ //#endregion
1164
+ //#region src/components/SuspenseInfiniteQuery.tsx
1165
+ const declarationPrinter$2 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
1166
+ const callPrinter$2 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
1167
+ function getParams$1(node, options) {
1168
+ const { paramsType, paramsCasing, pathParamsType, resolver, pageParamGeneric } = options;
1169
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1170
+ const optionsParam = _kubb_core.ast.createFunctionParameter({
1171
+ name: "options",
1172
+ type: _kubb_core.ast.createParamsType({
1173
+ variant: "reference",
1174
+ name: `{
1175
+ query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
1176
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
1177
+ }`
1178
+ }),
1179
+ default: "{}"
1180
+ });
1181
+ return _kubb_core.ast.createOperationParams(node, {
1182
+ paramsType,
1183
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1184
+ paramsCasing,
1185
+ resolver,
1186
+ extraParams: [optionsParam]
1187
+ });
1188
+ }
1189
+ __name(getParams$1, "getParams");
1190
+ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions, initialPageParam, queryParam }) {
1191
+ const responseName = tsResolver.resolveResponseName(node);
1192
+ const errorNames = resolveErrorNames(node, tsResolver);
1193
+ const responseType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1194
+ const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1195
+ const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
1196
+ const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
1197
+ const parts = initialPageParam.split(" as ");
1198
+ return parts[parts.length - 1] ?? "unknown";
1199
+ })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
1200
+ const rawQueryParams = node.parameters.filter((p) => p.in === "query");
1201
+ const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
1202
+ const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
1203
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
1204
+ })() : void 0;
1205
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
1206
+ const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
1207
+ const returnType = "UseSuspenseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
1208
+ const generics = [
1209
+ `TQueryFnData = ${responseType}`,
1210
+ `TError = ${errorType}`,
1211
+ "TData = InfiniteData<TQueryFnData>",
1212
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
1213
+ `TPageParam = ${pageParamType}`
1214
+ ];
1215
+ const queryKeyParamsNode = QueryKey.getParams(node, {
1216
+ pathParamsType,
1217
+ paramsCasing,
1218
+ resolver: tsResolver
1219
+ });
1220
+ const queryKeyParamsCall = callPrinter$2.print(queryKeyParamsNode) ?? "";
1221
+ const queryOptionsParamsNode = getQueryOptionsParams(node, {
1222
+ paramsType,
1223
+ paramsCasing,
1224
+ pathParamsType,
1225
+ resolver: tsResolver
1226
+ });
1227
+ const queryOptionsParamsCall = callPrinter$2.print(queryOptionsParamsNode) ?? "";
1228
+ const paramsNode = getParams$1(node, {
1229
+ paramsType,
1230
+ paramsCasing,
1231
+ pathParamsType,
1232
+ dataReturnType,
1233
+ resolver: tsResolver,
1234
+ pageParamGeneric: "TPageParam"
1235
+ });
1236
+ const paramsSignature = declarationPrinter$2.print(paramsNode) ?? "";
1237
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1238
+ name,
1239
+ isExportable: true,
1240
+ isIndexable: true,
1241
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
1242
+ name,
1243
+ export: true,
1244
+ generics: generics.join(", "),
1245
+ params: paramsSignature,
1246
+ returnType: void 0,
1247
+ JSDoc: { comments: getComments(node) },
1248
+ children: `
1249
+ const { query: queryConfig = {}, client: config = {} } = options ?? {}
1250
+ const { client: queryClient, ...resolvedOptions } = queryConfig
1251
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
1252
+ ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1253
+
1254
+ const query = useSuspenseInfiniteQuery({
1255
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
1256
+ ...resolvedOptions,
1257
+ queryKey,
1258
+ } as unknown as UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
1259
+
1260
+ query.queryKey = queryKey as TQueryKey
1261
+
1262
+ return query
1263
+ `
1264
+ })
1265
+ });
1266
+ }
1267
+ SuspenseInfiniteQuery.getParams = getParams$1;
1268
+ //#endregion
1269
+ //#region src/components/SuspenseInfiniteQueryOptions.tsx
1270
+ const declarationPrinter$1 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
1271
+ const callPrinter$1 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
1272
+ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
1273
+ const responseName = tsResolver.resolveResponseName(node);
1274
+ const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1275
+ const errorNames = resolveErrorNames(node, tsResolver);
1276
+ const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1277
+ const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
1278
+ const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
1279
+ const parts = initialPageParam.split(" as ");
1280
+ return parts[parts.length - 1] ?? "unknown";
1281
+ })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
1282
+ const rawQueryParams = node.parameters.filter((p) => p.in === "query");
1283
+ const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
1284
+ const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
1285
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
1286
+ })() : void 0;
1287
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
1288
+ const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
1289
+ const paramsNode = getQueryOptionsParams(node, {
1290
+ paramsType,
1291
+ paramsCasing,
1292
+ pathParamsType,
1293
+ resolver: tsResolver
1294
+ });
1295
+ const paramsSignature = declarationPrinter$1.print(paramsNode) ?? "";
1296
+ const clientCallStr = (callPrinter$1.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
1297
+ const queryKeyParamsNode = QueryKey.getParams(node, {
1298
+ pathParamsType,
1299
+ paramsCasing,
1300
+ resolver: tsResolver
1301
+ });
1302
+ const queryKeyParamsCall = callPrinter$1.print(queryKeyParamsNode) ?? "";
1303
+ const enabledSource = buildEnabledCheck(queryKeyParamsNode);
1304
+ const enabledText = enabledSource ? `enabled: !!(${enabledSource}),` : "";
1305
+ const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
1306
+ let getNextPageParamExpr;
1307
+ let getPreviousPageParamExpr;
1308
+ if (hasNewParams) {
1309
+ if (nextParam) {
1310
+ const accessor = getNestedAccessor(nextParam, "lastPage");
1311
+ if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
1312
+ }
1313
+ if (previousParam) {
1314
+ const accessor = getNestedAccessor(previousParam, "firstPage");
1315
+ if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
1316
+ }
1317
+ } else if (cursorParam) {
1318
+ getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
1319
+ getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
1320
+ } else {
1321
+ if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
1322
+ else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
1323
+ getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
1324
+ }
1325
+ const queryOptionsArr = [
1326
+ `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
1327
+ getNextPageParamExpr,
1328
+ getPreviousPageParamExpr
1329
+ ].filter(Boolean);
1330
+ const infiniteOverrideParams = queryParam && queryParamsTypeName ? `
1331
+ params = {
1332
+ ...(params ?? {}),
1333
+ ['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
1334
+ } as ${queryParamsTypeName}` : "";
1335
+ if (infiniteOverrideParams) return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1336
+ name,
1337
+ isExportable: true,
1338
+ isIndexable: true,
1339
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
1340
+ name,
1341
+ export: true,
1342
+ params: paramsSignature,
1343
+ children: `
1344
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1345
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
1346
+ ${enabledText}
1347
+ queryKey,
1348
+ queryFn: async ({ signal, pageParam }) => {
1349
+ ${infiniteOverrideParams}
1350
+ return ${clientName}(${clientCallStr})
1351
+ },
1352
+ ${queryOptionsArr.join(",\n")}
1353
+ })
1354
+ `
1355
+ })
1356
+ });
1357
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1358
+ name,
1359
+ isExportable: true,
1360
+ isIndexable: true,
1361
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
1362
+ name,
1363
+ export: true,
1364
+ params: paramsSignature,
1365
+ children: `
1366
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1367
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
1368
+ ${enabledText}
1369
+ queryKey,
1370
+ queryFn: async ({ signal }) => {
1371
+ return ${clientName}(${clientCallStr})
1372
+ },
1373
+ ${queryOptionsArr.join(",\n")}
1374
+ })
1375
+ `
1376
+ })
1377
+ });
1378
+ }
1379
+ SuspenseInfiniteQueryOptions.getParams = (node, options) => getQueryOptionsParams(node, options);
1380
+ //#endregion
1381
+ //#region src/components/SuspenseQuery.tsx
1382
+ const declarationPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
1383
+ const callPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
1384
+ function getParams(node, options) {
1385
+ const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options;
1386
+ const responseName = resolver.resolveResponseName(node);
1387
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1388
+ const errorNames = resolveErrorNames(node, resolver);
1389
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1390
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1391
+ const optionsParam = _kubb_core.ast.createFunctionParameter({
1392
+ name: "options",
1393
+ type: _kubb_core.ast.createParamsType({
1394
+ variant: "reference",
1395
+ name: `{
1396
+ query?: Partial<UseSuspenseQueryOptions<${[
1397
+ TData,
1398
+ TError,
1399
+ "TData",
1400
+ "TQueryKey"
1401
+ ].join(", ")}>> & { client?: QueryClient },
1402
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
1403
+ }`
1404
+ }),
1405
+ default: "{}"
1406
+ });
1407
+ return _kubb_core.ast.createOperationParams(node, {
1408
+ paramsType,
1409
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1410
+ paramsCasing,
1411
+ resolver,
1412
+ extraParams: [optionsParam]
1413
+ });
1414
+ }
1415
+ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions }) {
1416
+ const responseName = tsResolver.resolveResponseName(node);
1417
+ const errorNames = resolveErrorNames(node, tsResolver);
1418
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1419
+ const returnType = `UseSuspenseQueryResult<TData, ${`ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`}> & { queryKey: TQueryKey }`;
1420
+ const generics = [`TData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
1421
+ const queryKeyParamsNode = QueryKey.getParams(node, {
1422
+ pathParamsType,
1423
+ paramsCasing,
1424
+ resolver: tsResolver
1425
+ });
1426
+ const queryKeyParamsCall = callPrinter.print(queryKeyParamsNode) ?? "";
1427
+ const queryOptionsParamsNode = getQueryOptionsParams(node, {
1428
+ paramsType,
1429
+ paramsCasing,
1430
+ pathParamsType,
1431
+ resolver: tsResolver
1432
+ });
1433
+ const queryOptionsParamsCall = callPrinter.print(queryOptionsParamsNode) ?? "";
1434
+ const paramsNode = getParams(node, {
1435
+ paramsType,
1436
+ paramsCasing,
1437
+ pathParamsType,
1438
+ dataReturnType,
1439
+ resolver: tsResolver
1440
+ });
1441
+ const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
1442
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1443
+ name,
1444
+ isExportable: true,
1445
+ isIndexable: true,
1446
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
1447
+ name,
1448
+ export: true,
1449
+ generics: generics.join(", "),
1450
+ params: paramsSignature,
1451
+ returnType: void 0,
1452
+ JSDoc: { comments: getComments(node) },
1453
+ children: `
1454
+ const { query: queryConfig = {}, client: config = {} } = options ?? {}
1455
+ const { client: queryClient, ...resolvedOptions } = queryConfig
1456
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
1457
+ ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1458
+
1459
+ const query = useSuspenseQuery({
1460
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
1461
+ ...resolvedOptions,
1462
+ queryKey,
1463
+ } as unknown as UseSuspenseQueryOptions, queryClient) as ${returnType}
1464
+
1465
+ query.queryKey = queryKey as TQueryKey
1466
+
1467
+ return query
1468
+ `
1469
+ })
1470
+ });
1471
+ }
1472
+ SuspenseQuery.getParams = getParams;
1473
+ //#endregion
1474
+ Object.defineProperty(exports, "InfiniteQuery", {
1475
+ enumerable: true,
1476
+ get: function() {
1477
+ return InfiniteQuery;
1478
+ }
1479
+ });
1480
+ Object.defineProperty(exports, "InfiniteQueryOptions", {
1481
+ enumerable: true,
1482
+ get: function() {
1483
+ return InfiniteQueryOptions;
1484
+ }
1485
+ });
1486
+ Object.defineProperty(exports, "Mutation", {
1487
+ enumerable: true,
1488
+ get: function() {
1489
+ return Mutation;
1490
+ }
1491
+ });
1492
+ Object.defineProperty(exports, "MutationKey", {
1493
+ enumerable: true,
1494
+ get: function() {
1495
+ return MutationKey;
1496
+ }
1497
+ });
1498
+ Object.defineProperty(exports, "MutationOptions", {
1499
+ enumerable: true,
1500
+ get: function() {
1501
+ return MutationOptions;
1502
+ }
1503
+ });
1504
+ Object.defineProperty(exports, "Query", {
1505
+ enumerable: true,
1506
+ get: function() {
1507
+ return Query;
1508
+ }
1509
+ });
1510
+ Object.defineProperty(exports, "QueryKey", {
1511
+ enumerable: true,
1512
+ get: function() {
1513
+ return QueryKey;
1514
+ }
1515
+ });
1516
+ Object.defineProperty(exports, "QueryOptions", {
1517
+ enumerable: true,
1518
+ get: function() {
1519
+ return QueryOptions;
1520
+ }
1521
+ });
1522
+ Object.defineProperty(exports, "SuspenseInfiniteQuery", {
1523
+ enumerable: true,
1524
+ get: function() {
1525
+ return SuspenseInfiniteQuery;
1526
+ }
1527
+ });
1528
+ Object.defineProperty(exports, "SuspenseInfiniteQueryOptions", {
1529
+ enumerable: true,
1530
+ get: function() {
1531
+ return SuspenseInfiniteQueryOptions;
1532
+ }
1533
+ });
1534
+ Object.defineProperty(exports, "SuspenseQuery", {
1535
+ enumerable: true,
1536
+ get: function() {
1537
+ return SuspenseQuery;
1538
+ }
1539
+ });
1540
+ Object.defineProperty(exports, "__name", {
1541
+ enumerable: true,
1542
+ get: function() {
1543
+ return __name;
1544
+ }
1545
+ });
1546
+ Object.defineProperty(exports, "__toESM", {
1547
+ enumerable: true,
1548
+ get: function() {
1549
+ return __toESM;
1550
+ }
1551
+ });
1552
+ Object.defineProperty(exports, "camelCase", {
1553
+ enumerable: true,
1554
+ get: function() {
1555
+ return camelCase;
1556
+ }
1557
+ });
1558
+ Object.defineProperty(exports, "resolveOperationOverrides", {
1559
+ enumerable: true,
1560
+ get: function() {
1561
+ return resolveOperationOverrides;
1562
+ }
1563
+ });
1564
+ Object.defineProperty(exports, "transformName", {
1565
+ enumerable: true,
1566
+ get: function() {
1567
+ return transformName;
1568
+ }
1569
+ });
1570
+
1571
+ //# sourceMappingURL=components-dAKJEn9b.cjs.map