@kubb/plugin-react-query 5.0.0-alpha.9 → 5.0.0-beta.15

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