@kubb/plugin-react-query 5.0.0-alpha.8 → 5.0.0-beta.10

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 (54) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +34 -85
  3. package/dist/components-Dow6tde8.js +1459 -0
  4. package/dist/components-Dow6tde8.js.map +1 -0
  5. package/dist/components-HwdCDefj.cjs +1603 -0
  6. package/dist/components-HwdCDefj.cjs.map +1 -0
  7. package/dist/components.cjs +1 -1
  8. package/dist/components.d.ts +49 -179
  9. package/dist/components.js +1 -1
  10. package/dist/generators-CcOmnTPa.cjs +1454 -0
  11. package/dist/generators-CcOmnTPa.cjs.map +1 -0
  12. package/dist/generators-yfZr_qfT.js +1412 -0
  13. package/dist/generators-yfZr_qfT.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 +197 -126
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +193 -126
  21. package/dist/index.js.map +1 -1
  22. package/dist/types-DG_OxOym.d.ts +363 -0
  23. package/extension.yaml +911 -0
  24. package/package.json +59 -64
  25. package/src/components/InfiniteQuery.tsx +79 -138
  26. package/src/components/InfiniteQueryOptions.tsx +55 -166
  27. package/src/components/Mutation.tsx +74 -111
  28. package/src/components/MutationOptions.tsx +61 -80
  29. package/src/components/Query.tsx +66 -142
  30. package/src/components/QueryOptions.tsx +56 -138
  31. package/src/components/SuspenseInfiniteQuery.tsx +79 -138
  32. package/src/components/SuspenseInfiniteQueryOptions.tsx +55 -166
  33. package/src/components/SuspenseQuery.tsx +66 -152
  34. package/src/generators/customHookOptionsFileGenerator.tsx +37 -51
  35. package/src/generators/hookOptionsGenerator.tsx +111 -174
  36. package/src/generators/infiniteQueryGenerator.tsx +158 -178
  37. package/src/generators/mutationGenerator.tsx +112 -139
  38. package/src/generators/queryGenerator.tsx +128 -142
  39. package/src/generators/suspenseInfiniteQueryGenerator.tsx +157 -156
  40. package/src/generators/suspenseQueryGenerator.tsx +126 -152
  41. package/src/index.ts +1 -1
  42. package/src/plugin.ts +134 -187
  43. package/src/resolvers/resolverReactQuery.ts +107 -0
  44. package/src/types.ts +172 -49
  45. package/src/utils.ts +10 -0
  46. package/dist/components-BHQT9ZLc.cjs +0 -1634
  47. package/dist/components-BHQT9ZLc.cjs.map +0 -1
  48. package/dist/components-CpyHYGOw.js +0 -1520
  49. package/dist/components-CpyHYGOw.js.map +0 -1
  50. package/dist/generators-DP07m3rH.cjs +0 -1469
  51. package/dist/generators-DP07m3rH.cjs.map +0 -1
  52. package/dist/generators-DkQwKTc2.js +0 -1427
  53. package/dist/generators-DkQwKTc2.js.map +0 -1
  54. package/dist/types-D5S7Ny9r.d.ts +0 -270
@@ -0,0 +1,1459 @@
1
+ import "./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.toParamsObject();
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.toParamsObject()
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}').toParamsObject()
289
+ * // { petId: 'petId', tagId: 'tagId' }
290
+ * ```
291
+ */
292
+ toParamsObject(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
+ const mutationKeyTransformer = ({ node, casing }) => {
315
+ return [`{ url: '${new URLPath(node.path, { casing }).toURLPath()}' }`];
316
+ };
317
+ function MutationKey({ name, paramsCasing, node, transformer = mutationKeyTransformer }) {
318
+ const paramsNode = ast.createFunctionParameters({ params: [] });
319
+ const paramsSignature = declarationPrinter$10.print(paramsNode) ?? "";
320
+ const keys = transformer({
321
+ node,
322
+ casing: paramsCasing
323
+ });
324
+ return /* @__PURE__ */ jsx(File.Source, {
325
+ name,
326
+ isExportable: true,
327
+ isIndexable: true,
328
+ children: /* @__PURE__ */ jsx(Function.Arrow, {
329
+ name,
330
+ export: true,
331
+ params: paramsSignature,
332
+ singleLine: true,
333
+ children: `[${keys.join(", ")}] as const`
334
+ })
335
+ });
336
+ }
337
+ //#endregion
338
+ //#region ../../internals/shared/src/operation.ts
339
+ function getOperationLink(node, link) {
340
+ if (!link) return;
341
+ if (typeof link === "function") return link(node);
342
+ if (link === "urlPath") return node.path ? `{@link ${new URLPath(node.path).URL}}` : void 0;
343
+ return `{@link ${node.path.replaceAll("{", ":").replaceAll("}", "")}}`;
344
+ }
345
+ function getContentTypeInfo(node) {
346
+ const contentTypes = node.requestBody?.content?.map((e) => e.contentType) ?? [];
347
+ const isMultipleContentTypes = contentTypes.length > 1;
348
+ return {
349
+ contentTypes,
350
+ isMultipleContentTypes,
351
+ contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(" | ") : "",
352
+ defaultContentType: contentTypes[0] ?? "application/json",
353
+ hasFormData: contentTypes.some((ct) => ct === "multipart/form-data")
354
+ };
355
+ }
356
+ function buildRequestConfigType(node, resolver) {
357
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
358
+ const { isMultipleContentTypes, contentTypeUnion } = getContentTypeInfo(node);
359
+ return `${requestName ? `Partial<RequestConfig<${requestName}>>` : "Partial<RequestConfig>"} & { ${["client?: Client", isMultipleContentTypes ? `contentType?: ${contentTypeUnion}` : void 0].filter(Boolean).join("; ")} }`;
360
+ }
361
+ function buildOperationComments(node, options = {}) {
362
+ const { link = "pathTemplate", linkPosition = "afterDeprecated", splitLines = false } = options;
363
+ const linkComment = getOperationLink(node, link);
364
+ const filteredComments = (linkPosition === "beforeDeprecated" ? [
365
+ node.description && `@description ${node.description}`,
366
+ node.summary && `@summary ${node.summary}`,
367
+ linkComment,
368
+ node.deprecated && "@deprecated"
369
+ ] : [
370
+ node.description && `@description ${node.description}`,
371
+ node.summary && `@summary ${node.summary}`,
372
+ node.deprecated && "@deprecated",
373
+ linkComment
374
+ ]).filter((comment) => Boolean(comment));
375
+ if (!splitLines) return filteredComments;
376
+ return filteredComments.flatMap((text) => text.split(/\r?\n/).map((line) => line.trim())).filter((comment) => Boolean(comment));
377
+ }
378
+ function getOperationParameters(node, options = {}) {
379
+ const params = ast.caseParams(node.parameters, options.paramsCasing);
380
+ return {
381
+ path: params.filter((param) => param.in === "path"),
382
+ query: params.filter((param) => param.in === "query"),
383
+ header: params.filter((param) => param.in === "header"),
384
+ cookie: params.filter((param) => param.in === "cookie")
385
+ };
386
+ }
387
+ function getStatusCodeNumber(statusCode) {
388
+ const code = Number(statusCode);
389
+ return Number.isNaN(code) ? void 0 : code;
390
+ }
391
+ function isErrorStatusCode(statusCode) {
392
+ const code = getStatusCodeNumber(statusCode);
393
+ return code !== void 0 && code >= 400;
394
+ }
395
+ function resolveErrorNames(node, resolver) {
396
+ return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
397
+ }
398
+ function resolveStatusCodeNames(node, resolver) {
399
+ return node.responses.map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
400
+ }
401
+ function resolveOperationTypeNames(node, resolver, options = {}) {
402
+ const { path, query, header } = getOperationParameters(node, { paramsCasing: options.paramsCasing });
403
+ const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
404
+ const exclude = new Set(options.exclude ?? []);
405
+ const paramNames = [
406
+ ...path.map((param) => resolver.resolvePathParamsName(node, param)),
407
+ ...query.map((param) => resolver.resolveQueryParamsName(node, param)),
408
+ ...header.map((param) => resolver.resolveHeaderParamsName(node, param))
409
+ ];
410
+ const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0, resolver.resolveResponseName(node)];
411
+ return (options.order === "body-response-first" ? [
412
+ ...bodyAndResponseNames,
413
+ ...paramNames,
414
+ ...responseStatusNames
415
+ ] : [
416
+ ...paramNames,
417
+ ...bodyAndResponseNames,
418
+ ...responseStatusNames
419
+ ]).filter((name) => Boolean(name) && !exclude.has(name));
420
+ }
421
+ //#endregion
422
+ //#region ../../internals/tanstack-query/src/utils.ts
423
+ function matchesPattern(node, ov) {
424
+ const { type, pattern } = ov;
425
+ const matches = (value) => typeof pattern === "string" ? value === pattern : pattern.test(value);
426
+ if (type === "operationId") return matches(node.operationId);
427
+ if (type === "tag") return node.tags.some((t) => matches(t));
428
+ if (type === "path") return matches(node.path);
429
+ if (type === "method") return matches(node.method);
430
+ return false;
431
+ }
432
+ /**
433
+ * Resolves per-operation overrides (first matching override wins).
434
+ *
435
+ * @example
436
+ * ```ts
437
+ * const opts = resolveOperationOverrides(node, override)
438
+ * const queryOpts = 'query' in opts ? opts.query : defaultQuery
439
+ * ```
440
+ */
441
+ function resolveOperationOverrides(node, override) {
442
+ if (!override) return {};
443
+ return override.find((ov) => matchesPattern(node, ov))?.options ?? {};
444
+ }
445
+ /**
446
+ * Collects the Zod schema import names for an operation (response + request body).
447
+ *
448
+ * Returns an empty array when no resolver is provided or the operation has no request body schema.
449
+ */
450
+ function resolveZodSchemaNames(node, zodResolver) {
451
+ if (!zodResolver) return [];
452
+ return [zodResolver.resolveResponseName?.(node), node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : void 0].filter((n) => Boolean(n));
453
+ }
454
+ /**
455
+ * Resolve the type for a single path parameter.
456
+ *
457
+ * - When the resolver's group name differs from the individual param name
458
+ * (e.g. kubbV4) → `GroupName['paramName']` (member access).
459
+ * - When they match (v5 default) → `TypeName` (direct reference).
460
+ */
461
+ function resolvePathParamType(node, param, resolver) {
462
+ const individualName = resolver.resolveParamName(node, param);
463
+ const groupName = resolver.resolvePathParamsName(node, param);
464
+ if (groupName !== individualName) return ast.createParamsType({
465
+ variant: "member",
466
+ base: groupName,
467
+ key: param.name
468
+ });
469
+ return ast.createParamsType({
470
+ variant: "reference",
471
+ name: individualName
472
+ });
473
+ }
474
+ /**
475
+ * Derive a query-params group type from the resolver.
476
+ * Returns `undefined` when no query params exist or when the group name
477
+ * equals the individual param name (no real group).
478
+ */
479
+ function resolveQueryGroupType(node, params, resolver) {
480
+ if (!params.length) return void 0;
481
+ const firstParam = params[0];
482
+ const groupName = resolver.resolveQueryParamsName(node, firstParam);
483
+ if (groupName === resolver.resolveParamName(node, firstParam)) return void 0;
484
+ return {
485
+ type: ast.createParamsType({
486
+ variant: "reference",
487
+ name: groupName
488
+ }),
489
+ optional: params.every((p) => !p.required)
490
+ };
491
+ }
492
+ /**
493
+ * Build a single `FunctionParameterNode` for a query or header group.
494
+ */
495
+ function buildGroupParam(name, node, params, groupType, resolver) {
496
+ if (groupType) return [ast.createFunctionParameter({
497
+ name,
498
+ type: groupType.type,
499
+ optional: groupType.optional
500
+ })];
501
+ if (params.length) {
502
+ const structProps = params.map((p) => ({
503
+ name: p.name,
504
+ type: ast.createParamsType({
505
+ variant: "reference",
506
+ name: resolver.resolveParamName(node, p)
507
+ }),
508
+ optional: !p.required
509
+ }));
510
+ return [ast.createFunctionParameter({
511
+ name,
512
+ type: ast.createParamsType({
513
+ variant: "struct",
514
+ properties: structProps
515
+ }),
516
+ optional: params.every((p) => !p.required)
517
+ })];
518
+ }
519
+ return [];
520
+ }
521
+ /**
522
+ * Build QueryKey params: pathParams + data + queryParams (NO headers, NO config).
523
+ */
524
+ function buildQueryKeyParams(node, options) {
525
+ const { pathParamsType, paramsCasing, resolver } = options;
526
+ const casedParams = ast.caseParams(node.parameters, paramsCasing);
527
+ const pathParams = casedParams.filter((p) => p.in === "path");
528
+ const queryParams = casedParams.filter((p) => p.in === "query");
529
+ const queryGroupType = resolveQueryGroupType(node, queryParams, resolver);
530
+ const bodyType = node.requestBody?.content?.[0]?.schema ? ast.createParamsType({
531
+ variant: "reference",
532
+ name: resolver.resolveDataName(node)
533
+ }) : void 0;
534
+ const bodyRequired = node.requestBody?.required ?? false;
535
+ const params = [];
536
+ if (pathParams.length) {
537
+ const pathChildren = pathParams.map((p) => ast.createFunctionParameter({
538
+ name: p.name,
539
+ type: resolvePathParamType(node, p, resolver),
540
+ optional: !p.required
541
+ }));
542
+ params.push({
543
+ kind: "ParameterGroup",
544
+ properties: pathChildren,
545
+ inline: pathParamsType === "inline",
546
+ default: pathChildren.every((c) => c.optional) ? "{}" : void 0
547
+ });
548
+ }
549
+ if (bodyType) params.push(ast.createFunctionParameter({
550
+ name: "data",
551
+ type: bodyType,
552
+ optional: !bodyRequired
553
+ }));
554
+ params.push(...buildGroupParam("params", node, queryParams, queryGroupType, resolver));
555
+ return ast.createFunctionParameters({ params });
556
+ }
557
+ function buildEnabledCheck(paramsNode) {
558
+ const required = [];
559
+ for (const param of paramsNode.params) if ("kind" in param && param.kind === "ParameterGroup") {
560
+ const group = param;
561
+ for (const child of group.properties) if (!child.optional && child.default === void 0) required.push(child.name);
562
+ } else {
563
+ const fp = param;
564
+ if (!fp.optional && fp.default === void 0) required.push(fp.name);
565
+ }
566
+ return required.join(" && ");
567
+ }
568
+ //#endregion
569
+ //#region ../../internals/tanstack-query/src/components/QueryKey.tsx
570
+ const declarationPrinter$9 = functionPrinter({ mode: "declaration" });
571
+ const queryKeyTransformer = ({ node, casing }) => {
572
+ const path = new URLPath(node.path, { casing });
573
+ const hasQueryParams = getOperationParameters(node).query.length > 0;
574
+ const hasRequestBody = !!node.requestBody?.content?.[0]?.schema;
575
+ return [
576
+ path.toObject({
577
+ type: "path",
578
+ stringify: true
579
+ }),
580
+ hasQueryParams ? "...(params ? [params] : [])" : void 0,
581
+ hasRequestBody ? "...(data ? [data] : [])" : void 0
582
+ ].filter(Boolean);
583
+ };
584
+ function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeName, transformer = queryKeyTransformer }) {
585
+ const paramsNode = buildQueryKeyParams(node, {
586
+ pathParamsType,
587
+ paramsCasing,
588
+ resolver: tsResolver
589
+ });
590
+ const paramsSignature = declarationPrinter$9.print(paramsNode) ?? "";
591
+ const keys = transformer({
592
+ node,
593
+ casing: paramsCasing
594
+ });
595
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
596
+ name,
597
+ isExportable: true,
598
+ isIndexable: true,
599
+ children: /* @__PURE__ */ jsx(Function.Arrow, {
600
+ name,
601
+ export: true,
602
+ params: paramsSignature,
603
+ singleLine: true,
604
+ children: `[${keys.join(", ")}] as const`
605
+ })
606
+ }), /* @__PURE__ */ jsx(File.Source, {
607
+ name: typeName,
608
+ isTypeOnly: true,
609
+ children: /* @__PURE__ */ jsx(Type, {
610
+ name: typeName,
611
+ children: `ReturnType<typeof ${name}>`
612
+ })
613
+ })] });
614
+ }
615
+ //#endregion
616
+ //#region src/components/QueryOptions.tsx
617
+ const declarationPrinter$8 = functionPrinter({ mode: "declaration" });
618
+ const callPrinter$8 = functionPrinter({ mode: "call" });
619
+ function getQueryOptionsParams(node, options) {
620
+ const { paramsType, paramsCasing, pathParamsType, resolver } = options;
621
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
622
+ return ast.createOperationParams(node, {
623
+ paramsType,
624
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
625
+ paramsCasing,
626
+ resolver,
627
+ extraParams: [ast.createFunctionParameter({
628
+ name: "config",
629
+ type: ast.createParamsType({
630
+ variant: "reference",
631
+ name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
632
+ }),
633
+ default: "{}"
634
+ })]
635
+ });
636
+ }
637
+ function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
638
+ const responseName = tsResolver.resolveResponseName(node);
639
+ const errorNames = resolveErrorNames(node, tsResolver);
640
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
641
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
642
+ const paramsNode = getQueryOptionsParams(node, {
643
+ paramsType,
644
+ paramsCasing,
645
+ pathParamsType,
646
+ resolver: tsResolver
647
+ });
648
+ const paramsSignature = declarationPrinter$8.print(paramsNode) ?? "";
649
+ const clientCallStr = (callPrinter$8.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
650
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
651
+ pathParamsType,
652
+ paramsCasing,
653
+ resolver: tsResolver
654
+ });
655
+ const queryKeyParamsCall = callPrinter$8.print(queryKeyParamsNode) ?? "";
656
+ const enabledSource = buildEnabledCheck(queryKeyParamsNode);
657
+ const enabledText = enabledSource ? `enabled: !!(${enabledSource}),` : "";
658
+ return /* @__PURE__ */ jsx(File.Source, {
659
+ name,
660
+ isExportable: true,
661
+ isIndexable: true,
662
+ children: /* @__PURE__ */ jsx(Function, {
663
+ name,
664
+ export: true,
665
+ params: paramsSignature,
666
+ children: `
667
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
668
+ return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({
669
+ ${enabledText}
670
+ queryKey,
671
+ queryFn: async ({ signal }) => {
672
+ return ${clientName}(${clientCallStr})
673
+ },
674
+ })
675
+ `
676
+ })
677
+ });
678
+ }
679
+ //#endregion
680
+ //#region src/components/InfiniteQuery.tsx
681
+ const declarationPrinter$7 = functionPrinter({ mode: "declaration" });
682
+ const callPrinter$7 = functionPrinter({ mode: "call" });
683
+ function buildInfiniteQueryParamsNode(node, options) {
684
+ const { paramsType, paramsCasing, pathParamsType, resolver, pageParamGeneric } = options;
685
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
686
+ const optionsParam = ast.createFunctionParameter({
687
+ name: "options",
688
+ type: ast.createParamsType({
689
+ variant: "reference",
690
+ name: `{
691
+ query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
692
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
693
+ }`
694
+ }),
695
+ default: "{}"
696
+ });
697
+ return ast.createOperationParams(node, {
698
+ paramsType,
699
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
700
+ paramsCasing,
701
+ resolver,
702
+ extraParams: [optionsParam]
703
+ });
704
+ }
705
+ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, initialPageParam, queryParam, customOptions }) {
706
+ const responseName = tsResolver.resolveResponseName(node);
707
+ const errorNames = resolveErrorNames(node, tsResolver);
708
+ const responseType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
709
+ const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
710
+ const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
711
+ const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
712
+ const parts = initialPageParam.split(" as ");
713
+ return parts[parts.length - 1] ?? "unknown";
714
+ })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
715
+ const rawQueryParams = getOperationParameters(node).query;
716
+ const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
717
+ const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
718
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
719
+ })() : void 0;
720
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
721
+ const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
722
+ const returnType = "UseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
723
+ const generics = [
724
+ `TQueryFnData = ${responseType}`,
725
+ `TError = ${errorType}`,
726
+ "TData = InfiniteData<TQueryFnData>",
727
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
728
+ `TPageParam = ${pageParamType}`
729
+ ];
730
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
731
+ pathParamsType,
732
+ paramsCasing,
733
+ resolver: tsResolver
734
+ });
735
+ const queryKeyParamsCall = callPrinter$7.print(queryKeyParamsNode) ?? "";
736
+ const queryOptionsParamsNode = getQueryOptionsParams(node, {
737
+ paramsType,
738
+ paramsCasing,
739
+ pathParamsType,
740
+ resolver: tsResolver
741
+ });
742
+ const queryOptionsParamsCall = callPrinter$7.print(queryOptionsParamsNode) ?? "";
743
+ const paramsNode = buildInfiniteQueryParamsNode(node, {
744
+ paramsType,
745
+ paramsCasing,
746
+ pathParamsType,
747
+ dataReturnType,
748
+ resolver: tsResolver,
749
+ pageParamGeneric: "TPageParam"
750
+ });
751
+ const paramsSignature = declarationPrinter$7.print(paramsNode) ?? "";
752
+ return /* @__PURE__ */ jsx(File.Source, {
753
+ name,
754
+ isExportable: true,
755
+ isIndexable: true,
756
+ children: /* @__PURE__ */ jsx(Function, {
757
+ name,
758
+ export: true,
759
+ generics: generics.join(", "),
760
+ params: paramsSignature,
761
+ returnType: void 0,
762
+ JSDoc: { comments: buildOperationComments(node) },
763
+ children: `
764
+ const { query: queryConfig = {}, client: config = {} } = options ?? {}
765
+ const { client: queryClient, ...resolvedOptions } = queryConfig
766
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
767
+ ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
768
+
769
+ const query = useInfiniteQuery({
770
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
771
+ ...resolvedOptions,
772
+ queryKey,
773
+ } as unknown as InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
774
+
775
+ query.queryKey = queryKey as TQueryKey
776
+
777
+ return query
778
+ `
779
+ })
780
+ });
781
+ }
782
+ //#endregion
783
+ //#region src/components/InfiniteQueryOptions.tsx
784
+ const declarationPrinter$6 = functionPrinter({ mode: "declaration" });
785
+ const callPrinter$6 = functionPrinter({ mode: "call" });
786
+ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
787
+ const responseName = tsResolver.resolveResponseName(node);
788
+ const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
789
+ const errorNames = resolveErrorNames(node, tsResolver);
790
+ const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
791
+ const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
792
+ const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
793
+ const parts = initialPageParam.split(" as ");
794
+ return parts[parts.length - 1] ?? "unknown";
795
+ })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
796
+ const rawQueryParams = getOperationParameters(node).query;
797
+ const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
798
+ const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
799
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
800
+ })() : void 0;
801
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
802
+ const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
803
+ const paramsNode = getQueryOptionsParams(node, {
804
+ paramsType,
805
+ paramsCasing,
806
+ pathParamsType,
807
+ resolver: tsResolver
808
+ });
809
+ const paramsSignature = declarationPrinter$6.print(paramsNode) ?? "";
810
+ const clientCallStr = (callPrinter$6.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
811
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
812
+ pathParamsType,
813
+ paramsCasing,
814
+ resolver: tsResolver
815
+ });
816
+ const queryKeyParamsCall = callPrinter$6.print(queryKeyParamsNode) ?? "";
817
+ const enabledSource = buildEnabledCheck(queryKeyParamsNode);
818
+ const enabledText = enabledSource ? `enabled: !!(${enabledSource}),` : "";
819
+ const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
820
+ let getNextPageParamExpr;
821
+ let getPreviousPageParamExpr;
822
+ if (hasNewParams) {
823
+ if (nextParam) {
824
+ const accessor = getNestedAccessor(nextParam, "lastPage");
825
+ if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
826
+ }
827
+ if (previousParam) {
828
+ const accessor = getNestedAccessor(previousParam, "firstPage");
829
+ if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
830
+ }
831
+ } else if (cursorParam) {
832
+ getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
833
+ getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
834
+ } else {
835
+ if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
836
+ else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
837
+ getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
838
+ }
839
+ const queryOptionsArr = [
840
+ `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
841
+ getNextPageParamExpr,
842
+ getPreviousPageParamExpr
843
+ ].filter(Boolean);
844
+ const infiniteOverrideParams = queryParam && queryParamsTypeName ? `
845
+ params = {
846
+ ...(params ?? {}),
847
+ ['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
848
+ } as ${queryParamsTypeName}` : "";
849
+ if (infiniteOverrideParams) return /* @__PURE__ */ jsx(File.Source, {
850
+ name,
851
+ isExportable: true,
852
+ isIndexable: true,
853
+ children: /* @__PURE__ */ jsx(Function, {
854
+ name,
855
+ export: true,
856
+ params: paramsSignature,
857
+ children: `
858
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
859
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
860
+ ${enabledText}
861
+ queryKey,
862
+ queryFn: async ({ signal, pageParam }) => {
863
+ ${infiniteOverrideParams}
864
+ return ${clientName}(${clientCallStr})
865
+ },
866
+ ${queryOptionsArr.join(",\n")}
867
+ })
868
+ `
869
+ })
870
+ });
871
+ return /* @__PURE__ */ jsx(File.Source, {
872
+ name,
873
+ isExportable: true,
874
+ isIndexable: true,
875
+ children: /* @__PURE__ */ jsx(Function, {
876
+ name,
877
+ export: true,
878
+ params: paramsSignature,
879
+ children: `
880
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
881
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
882
+ ${enabledText}
883
+ queryKey,
884
+ queryFn: async ({ signal }) => {
885
+ return ${clientName}(${clientCallStr})
886
+ },
887
+ ${queryOptionsArr.join(",\n")}
888
+ })
889
+ `
890
+ })
891
+ });
892
+ }
893
+ //#endregion
894
+ //#region src/components/MutationOptions.tsx
895
+ const declarationPrinter$5 = functionPrinter({ mode: "declaration" });
896
+ const callPrinter$5 = functionPrinter({ mode: "call" });
897
+ const keysPrinter = functionPrinter({ mode: "keys" });
898
+ function buildMutationConfigParamsNode(node, resolver) {
899
+ return ast.createFunctionParameters({ params: [ast.createFunctionParameter({
900
+ name: "config",
901
+ type: ast.createParamsType({
902
+ variant: "reference",
903
+ name: buildRequestConfigType(node, resolver)
904
+ }),
905
+ default: "{}"
906
+ })] });
907
+ }
908
+ function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, mutationKeyName }) {
909
+ const responseName = tsResolver.resolveResponseName(node);
910
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
911
+ const errorNames = resolveErrorNames(node, tsResolver);
912
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
913
+ const configParamsNode = buildMutationConfigParamsNode(node, tsResolver);
914
+ const paramsSignature = declarationPrinter$5.print(configParamsNode) ?? "";
915
+ const mutationArgParamsNode = ast.createOperationParams(node, {
916
+ paramsType: "inline",
917
+ pathParamsType: "inline",
918
+ paramsCasing,
919
+ resolver: tsResolver
920
+ });
921
+ const hasMutationParams = mutationArgParamsNode.params.length > 0;
922
+ const TRequest = hasMutationParams ? declarationPrinter$5.print(mutationArgParamsNode) ?? "" : "";
923
+ const argKeysStr = hasMutationParams ? keysPrinter.print(mutationArgParamsNode) ?? "" : "";
924
+ const clientCallParamsNode = ast.createOperationParams(node, {
925
+ paramsType,
926
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
927
+ paramsCasing,
928
+ resolver: tsResolver,
929
+ extraParams: [ast.createFunctionParameter({
930
+ name: "config",
931
+ type: ast.createParamsType({
932
+ variant: "reference",
933
+ name: buildRequestConfigType(node, tsResolver)
934
+ }),
935
+ default: "{}"
936
+ })]
937
+ });
938
+ const clientCallStr = callPrinter$5.print(clientCallParamsNode) ?? "";
939
+ return /* @__PURE__ */ jsx(File.Source, {
940
+ name,
941
+ isExportable: true,
942
+ isIndexable: true,
943
+ children: /* @__PURE__ */ jsx(Function, {
944
+ name,
945
+ export: true,
946
+ params: paramsSignature,
947
+ generics: ["TContext = unknown"],
948
+ children: `
949
+ const mutationKey = ${mutationKeyName}()
950
+ return mutationOptions<${TData}, ${TError}, ${TRequest ? `{${TRequest}}` : "void"}, TContext>({
951
+ mutationKey,
952
+ mutationFn: async(${hasMutationParams ? `{ ${argKeysStr} }` : "_"}) => {
953
+ return ${clientName}(${clientCallStr})
954
+ },
955
+ })
956
+ `
957
+ })
958
+ });
959
+ }
960
+ //#endregion
961
+ //#region src/components/Mutation.tsx
962
+ const declarationPrinter$4 = functionPrinter({ mode: "declaration" });
963
+ const callPrinter$4 = functionPrinter({ mode: "call" });
964
+ function createMutationArgParams(node, options) {
965
+ return ast.createOperationParams(node, {
966
+ paramsType: "inline",
967
+ pathParamsType: "inline",
968
+ paramsCasing: options.paramsCasing,
969
+ resolver: options.resolver
970
+ });
971
+ }
972
+ function buildMutationParamsNode(node, options) {
973
+ const { paramsCasing, dataReturnType, resolver } = options;
974
+ const responseName = resolver.resolveResponseName(node);
975
+ const errorNames = resolveErrorNames(node, resolver);
976
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
977
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
978
+ const mutationArgParamsNode = createMutationArgParams(node, {
979
+ paramsCasing,
980
+ resolver
981
+ });
982
+ const TRequest = mutationArgParamsNode.params.length > 0 ? declarationPrinter$4.print(mutationArgParamsNode) ?? "" : "";
983
+ const generics = [
984
+ TData,
985
+ TError,
986
+ TRequest ? `{${TRequest}}` : "void",
987
+ "TContext"
988
+ ].join(", ");
989
+ return ast.createFunctionParameters({ params: [ast.createFunctionParameter({
990
+ name: "options",
991
+ type: ast.createParamsType({
992
+ variant: "reference",
993
+ name: `{
994
+ mutation?: UseMutationOptions<${generics}> & { client?: QueryClient },
995
+ client?: ${buildRequestConfigType(node, resolver)},
996
+ }`
997
+ }),
998
+ default: "{}"
999
+ })] });
1000
+ }
1001
+ function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, node, tsResolver, mutationKeyName, customOptions }) {
1002
+ const responseName = tsResolver.resolveResponseName(node);
1003
+ const errorNames = resolveErrorNames(node, tsResolver);
1004
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1005
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1006
+ const mutationArgParamsNode = createMutationArgParams(node, {
1007
+ paramsCasing,
1008
+ resolver: tsResolver
1009
+ });
1010
+ const TRequest = mutationArgParamsNode.params.length > 0 ? declarationPrinter$4.print(mutationArgParamsNode) ?? "" : "";
1011
+ const generics = [
1012
+ TData,
1013
+ TError,
1014
+ TRequest ? `{${TRequest}}` : "void",
1015
+ "TContext"
1016
+ ].join(", ");
1017
+ const returnType = `UseMutationResult<${generics}>`;
1018
+ const mutationOptionsConfigNode = buildMutationConfigParamsNode(node, tsResolver);
1019
+ const mutationOptionsParamsCall = callPrinter$4.print(mutationOptionsConfigNode) ?? "";
1020
+ const paramsNode = buildMutationParamsNode(node, {
1021
+ paramsCasing,
1022
+ dataReturnType,
1023
+ resolver: tsResolver
1024
+ });
1025
+ const paramsSignature = declarationPrinter$4.print(paramsNode) ?? "";
1026
+ return /* @__PURE__ */ jsx(File.Source, {
1027
+ name,
1028
+ isExportable: true,
1029
+ isIndexable: true,
1030
+ children: /* @__PURE__ */ jsx(Function, {
1031
+ name,
1032
+ export: true,
1033
+ params: paramsSignature,
1034
+ JSDoc: { comments: buildOperationComments(node) },
1035
+ generics: ["TContext"],
1036
+ children: `
1037
+ const { mutation = {}, client: config = {} } = options ?? {}
1038
+ const { client: queryClient, ...mutationOptions } = mutation;
1039
+ const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}()
1040
+
1041
+ const baseOptions = ${mutationOptionsName}(${mutationOptionsParamsCall}) as UseMutationOptions<${generics}>
1042
+ ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' }) as UseMutationOptions<${generics}>` : ""}
1043
+
1044
+ return useMutation<${generics}>({
1045
+ ...baseOptions,${customOptions ? "\n...customOptions," : ""}
1046
+ mutationKey,
1047
+ ...mutationOptions,
1048
+ }, queryClient) as ${returnType}
1049
+ `
1050
+ })
1051
+ });
1052
+ }
1053
+ //#endregion
1054
+ //#region src/components/Query.tsx
1055
+ const declarationPrinter$3 = functionPrinter({ mode: "declaration" });
1056
+ const callPrinter$3 = functionPrinter({ mode: "call" });
1057
+ function buildQueryParamsNode(node, options) {
1058
+ const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options;
1059
+ const responseName = resolver.resolveResponseName(node);
1060
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1061
+ const errorNames = resolveErrorNames(node, resolver);
1062
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1063
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1064
+ const optionsParam = ast.createFunctionParameter({
1065
+ name: "options",
1066
+ type: ast.createParamsType({
1067
+ variant: "reference",
1068
+ name: `{
1069
+ query?: Partial<QueryObserverOptions<${[
1070
+ TData,
1071
+ TError,
1072
+ "TData",
1073
+ "TQueryData",
1074
+ "TQueryKey"
1075
+ ].join(", ")}>> & { client?: QueryClient },
1076
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
1077
+ }`
1078
+ }),
1079
+ default: "{}"
1080
+ });
1081
+ return ast.createOperationParams(node, {
1082
+ paramsType,
1083
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1084
+ paramsCasing,
1085
+ resolver,
1086
+ extraParams: [optionsParam]
1087
+ });
1088
+ }
1089
+ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions }) {
1090
+ const responseName = tsResolver.resolveResponseName(node);
1091
+ const errorNames = resolveErrorNames(node, tsResolver);
1092
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1093
+ const returnType = `UseQueryResult<TData, ${`ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`}> & { queryKey: TQueryKey }`;
1094
+ const generics = [
1095
+ `TData = ${TData}`,
1096
+ `TQueryData = ${TData}`,
1097
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`
1098
+ ];
1099
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1100
+ pathParamsType,
1101
+ paramsCasing,
1102
+ resolver: tsResolver
1103
+ });
1104
+ const queryKeyParamsCall = callPrinter$3.print(queryKeyParamsNode) ?? "";
1105
+ const queryOptionsParamsNode = getQueryOptionsParams(node, {
1106
+ paramsType,
1107
+ paramsCasing,
1108
+ pathParamsType,
1109
+ resolver: tsResolver
1110
+ });
1111
+ const queryOptionsParamsCall = callPrinter$3.print(queryOptionsParamsNode) ?? "";
1112
+ const paramsNode = buildQueryParamsNode(node, {
1113
+ paramsType,
1114
+ paramsCasing,
1115
+ pathParamsType,
1116
+ dataReturnType,
1117
+ resolver: tsResolver
1118
+ });
1119
+ const paramsSignature = declarationPrinter$3.print(paramsNode) ?? "";
1120
+ return /* @__PURE__ */ jsx(File.Source, {
1121
+ name,
1122
+ isExportable: true,
1123
+ isIndexable: true,
1124
+ children: /* @__PURE__ */ jsx(Function, {
1125
+ name,
1126
+ export: true,
1127
+ generics: generics.join(", "),
1128
+ params: paramsSignature,
1129
+ returnType: void 0,
1130
+ JSDoc: { comments: buildOperationComments(node) },
1131
+ children: `
1132
+ const { query: queryConfig = {}, client: config = {} } = options ?? {}
1133
+ const { client: queryClient, ...resolvedOptions } = queryConfig
1134
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
1135
+ ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1136
+
1137
+ const query = useQuery({
1138
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
1139
+ ...resolvedOptions,
1140
+ queryKey,
1141
+ } as unknown as QueryObserverOptions, queryClient) as ${returnType}
1142
+
1143
+ query.queryKey = queryKey as TQueryKey
1144
+
1145
+ return query
1146
+ `
1147
+ })
1148
+ });
1149
+ }
1150
+ //#endregion
1151
+ //#region src/components/SuspenseInfiniteQuery.tsx
1152
+ const declarationPrinter$2 = functionPrinter({ mode: "declaration" });
1153
+ const callPrinter$2 = functionPrinter({ mode: "call" });
1154
+ function buildSuspenseInfiniteQueryParamsNode(node, options) {
1155
+ const { paramsType, paramsCasing, pathParamsType, resolver, pageParamGeneric } = options;
1156
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1157
+ const optionsParam = ast.createFunctionParameter({
1158
+ name: "options",
1159
+ type: ast.createParamsType({
1160
+ variant: "reference",
1161
+ name: `{
1162
+ query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
1163
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
1164
+ }`
1165
+ }),
1166
+ default: "{}"
1167
+ });
1168
+ return ast.createOperationParams(node, {
1169
+ paramsType,
1170
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1171
+ paramsCasing,
1172
+ resolver,
1173
+ extraParams: [optionsParam]
1174
+ });
1175
+ }
1176
+ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions, initialPageParam, queryParam }) {
1177
+ const responseName = tsResolver.resolveResponseName(node);
1178
+ const errorNames = resolveErrorNames(node, tsResolver);
1179
+ const responseType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1180
+ const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1181
+ const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
1182
+ const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
1183
+ const parts = initialPageParam.split(" as ");
1184
+ return parts[parts.length - 1] ?? "unknown";
1185
+ })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
1186
+ const rawQueryParams = getOperationParameters(node).query;
1187
+ const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
1188
+ const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
1189
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
1190
+ })() : void 0;
1191
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
1192
+ const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
1193
+ const returnType = "UseSuspenseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
1194
+ const generics = [
1195
+ `TQueryFnData = ${responseType}`,
1196
+ `TError = ${errorType}`,
1197
+ "TData = InfiniteData<TQueryFnData>",
1198
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
1199
+ `TPageParam = ${pageParamType}`
1200
+ ];
1201
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1202
+ pathParamsType,
1203
+ paramsCasing,
1204
+ resolver: tsResolver
1205
+ });
1206
+ const queryKeyParamsCall = callPrinter$2.print(queryKeyParamsNode) ?? "";
1207
+ const queryOptionsParamsNode = getQueryOptionsParams(node, {
1208
+ paramsType,
1209
+ paramsCasing,
1210
+ pathParamsType,
1211
+ resolver: tsResolver
1212
+ });
1213
+ const queryOptionsParamsCall = callPrinter$2.print(queryOptionsParamsNode) ?? "";
1214
+ const paramsNode = buildSuspenseInfiniteQueryParamsNode(node, {
1215
+ paramsType,
1216
+ paramsCasing,
1217
+ pathParamsType,
1218
+ dataReturnType,
1219
+ resolver: tsResolver,
1220
+ pageParamGeneric: "TPageParam"
1221
+ });
1222
+ const paramsSignature = declarationPrinter$2.print(paramsNode) ?? "";
1223
+ return /* @__PURE__ */ jsx(File.Source, {
1224
+ name,
1225
+ isExportable: true,
1226
+ isIndexable: true,
1227
+ children: /* @__PURE__ */ jsx(Function, {
1228
+ name,
1229
+ export: true,
1230
+ generics: generics.join(", "),
1231
+ params: paramsSignature,
1232
+ returnType: void 0,
1233
+ JSDoc: { comments: buildOperationComments(node) },
1234
+ children: `
1235
+ const { query: queryConfig = {}, client: config = {} } = options ?? {}
1236
+ const { client: queryClient, ...resolvedOptions } = queryConfig
1237
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
1238
+ ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1239
+
1240
+ const query = useSuspenseInfiniteQuery({
1241
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
1242
+ ...resolvedOptions,
1243
+ queryKey,
1244
+ } as unknown as UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
1245
+
1246
+ query.queryKey = queryKey as TQueryKey
1247
+
1248
+ return query
1249
+ `
1250
+ })
1251
+ });
1252
+ }
1253
+ //#endregion
1254
+ //#region src/components/SuspenseInfiniteQueryOptions.tsx
1255
+ const declarationPrinter$1 = functionPrinter({ mode: "declaration" });
1256
+ const callPrinter$1 = functionPrinter({ mode: "call" });
1257
+ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
1258
+ const responseName = tsResolver.resolveResponseName(node);
1259
+ const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1260
+ const errorNames = resolveErrorNames(node, tsResolver);
1261
+ const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1262
+ const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
1263
+ const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
1264
+ const parts = initialPageParam.split(" as ");
1265
+ return parts[parts.length - 1] ?? "unknown";
1266
+ })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
1267
+ const rawQueryParams = getOperationParameters(node).query;
1268
+ const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
1269
+ const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
1270
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
1271
+ })() : void 0;
1272
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
1273
+ const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
1274
+ const paramsNode = getQueryOptionsParams(node, {
1275
+ paramsType,
1276
+ paramsCasing,
1277
+ pathParamsType,
1278
+ resolver: tsResolver
1279
+ });
1280
+ const paramsSignature = declarationPrinter$1.print(paramsNode) ?? "";
1281
+ const clientCallStr = (callPrinter$1.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
1282
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1283
+ pathParamsType,
1284
+ paramsCasing,
1285
+ resolver: tsResolver
1286
+ });
1287
+ const queryKeyParamsCall = callPrinter$1.print(queryKeyParamsNode) ?? "";
1288
+ const enabledSource = buildEnabledCheck(queryKeyParamsNode);
1289
+ const enabledText = enabledSource ? `enabled: !!(${enabledSource}),` : "";
1290
+ const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
1291
+ let getNextPageParamExpr;
1292
+ let getPreviousPageParamExpr;
1293
+ if (hasNewParams) {
1294
+ if (nextParam) {
1295
+ const accessor = getNestedAccessor(nextParam, "lastPage");
1296
+ if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
1297
+ }
1298
+ if (previousParam) {
1299
+ const accessor = getNestedAccessor(previousParam, "firstPage");
1300
+ if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
1301
+ }
1302
+ } else if (cursorParam) {
1303
+ getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
1304
+ getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
1305
+ } else {
1306
+ if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
1307
+ else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
1308
+ getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
1309
+ }
1310
+ const queryOptionsArr = [
1311
+ `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
1312
+ getNextPageParamExpr,
1313
+ getPreviousPageParamExpr
1314
+ ].filter(Boolean);
1315
+ const infiniteOverrideParams = queryParam && queryParamsTypeName ? `
1316
+ params = {
1317
+ ...(params ?? {}),
1318
+ ['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
1319
+ } as ${queryParamsTypeName}` : "";
1320
+ if (infiniteOverrideParams) return /* @__PURE__ */ jsx(File.Source, {
1321
+ name,
1322
+ isExportable: true,
1323
+ isIndexable: true,
1324
+ children: /* @__PURE__ */ jsx(Function, {
1325
+ name,
1326
+ export: true,
1327
+ params: paramsSignature,
1328
+ children: `
1329
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1330
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
1331
+ ${enabledText}
1332
+ queryKey,
1333
+ queryFn: async ({ signal, pageParam }) => {
1334
+ ${infiniteOverrideParams}
1335
+ return ${clientName}(${clientCallStr})
1336
+ },
1337
+ ${queryOptionsArr.join(",\n")}
1338
+ })
1339
+ `
1340
+ })
1341
+ });
1342
+ return /* @__PURE__ */ jsx(File.Source, {
1343
+ name,
1344
+ isExportable: true,
1345
+ isIndexable: true,
1346
+ children: /* @__PURE__ */ jsx(Function, {
1347
+ name,
1348
+ export: true,
1349
+ params: paramsSignature,
1350
+ children: `
1351
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1352
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
1353
+ ${enabledText}
1354
+ queryKey,
1355
+ queryFn: async ({ signal }) => {
1356
+ return ${clientName}(${clientCallStr})
1357
+ },
1358
+ ${queryOptionsArr.join(",\n")}
1359
+ })
1360
+ `
1361
+ })
1362
+ });
1363
+ }
1364
+ //#endregion
1365
+ //#region src/components/SuspenseQuery.tsx
1366
+ const declarationPrinter = functionPrinter({ mode: "declaration" });
1367
+ const callPrinter = functionPrinter({ mode: "call" });
1368
+ function buildSuspenseQueryParamsNode(node, options) {
1369
+ const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options;
1370
+ const responseName = resolver.resolveResponseName(node);
1371
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1372
+ const errorNames = resolveErrorNames(node, resolver);
1373
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1374
+ const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1375
+ const optionsParam = ast.createFunctionParameter({
1376
+ name: "options",
1377
+ type: ast.createParamsType({
1378
+ variant: "reference",
1379
+ name: `{
1380
+ query?: Partial<UseSuspenseQueryOptions<${[
1381
+ TData,
1382
+ TError,
1383
+ "TData",
1384
+ "TQueryKey"
1385
+ ].join(", ")}>> & { client?: QueryClient },
1386
+ client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
1387
+ }`
1388
+ }),
1389
+ default: "{}"
1390
+ });
1391
+ return ast.createOperationParams(node, {
1392
+ paramsType,
1393
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1394
+ paramsCasing,
1395
+ resolver,
1396
+ extraParams: [optionsParam]
1397
+ });
1398
+ }
1399
+ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions }) {
1400
+ const responseName = tsResolver.resolveResponseName(node);
1401
+ const errorNames = resolveErrorNames(node, tsResolver);
1402
+ const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1403
+ const returnType = `UseSuspenseQueryResult<TData, ${`ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`}> & { queryKey: TQueryKey }`;
1404
+ const generics = [`TData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
1405
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1406
+ pathParamsType,
1407
+ paramsCasing,
1408
+ resolver: tsResolver
1409
+ });
1410
+ const queryKeyParamsCall = callPrinter.print(queryKeyParamsNode) ?? "";
1411
+ const queryOptionsParamsNode = getQueryOptionsParams(node, {
1412
+ paramsType,
1413
+ paramsCasing,
1414
+ pathParamsType,
1415
+ resolver: tsResolver
1416
+ });
1417
+ const queryOptionsParamsCall = callPrinter.print(queryOptionsParamsNode) ?? "";
1418
+ const paramsNode = buildSuspenseQueryParamsNode(node, {
1419
+ paramsType,
1420
+ paramsCasing,
1421
+ pathParamsType,
1422
+ dataReturnType,
1423
+ resolver: tsResolver
1424
+ });
1425
+ const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
1426
+ return /* @__PURE__ */ jsx(File.Source, {
1427
+ name,
1428
+ isExportable: true,
1429
+ isIndexable: true,
1430
+ children: /* @__PURE__ */ jsx(Function, {
1431
+ name,
1432
+ export: true,
1433
+ generics: generics.join(", "),
1434
+ params: paramsSignature,
1435
+ returnType: void 0,
1436
+ JSDoc: { comments: buildOperationComments(node) },
1437
+ children: `
1438
+ const { query: queryConfig = {}, client: config = {} } = options ?? {}
1439
+ const { client: queryClient, ...resolvedOptions } = queryConfig
1440
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
1441
+ ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1442
+
1443
+ const query = useSuspenseQuery({
1444
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
1445
+ ...resolvedOptions,
1446
+ queryKey,
1447
+ } as unknown as UseSuspenseQueryOptions, queryClient) as ${returnType}
1448
+
1449
+ query.queryKey = queryKey as TQueryKey
1450
+
1451
+ return query
1452
+ `
1453
+ })
1454
+ });
1455
+ }
1456
+ //#endregion
1457
+ export { mutationKeyTransformer as _, Mutation as a, InfiniteQuery as c, queryKeyTransformer as d, resolveOperationOverrides as f, MutationKey as g, resolveOperationTypeNames as h, Query as i, QueryOptions as l, getOperationParameters as m, SuspenseInfiniteQueryOptions as n, MutationOptions as o, resolveZodSchemaNames as p, SuspenseInfiniteQuery as r, InfiniteQueryOptions as s, SuspenseQuery as t, QueryKey as u, camelCase as v };
1458
+
1459
+ //# sourceMappingURL=components-Dow6tde8.js.map