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