@kubb/plugin-react-query 5.0.0-beta.42 → 5.0.0-beta.64

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 (51) hide show
  1. package/dist/{components-DQAYLQW0.cjs → components-B0j2b6y8.cjs} +298 -416
  2. package/dist/components-B0j2b6y8.cjs.map +1 -0
  3. package/dist/{components-IArDg-DO.js → components-Ds-e_nnK.js} +294 -412
  4. package/dist/components-Ds-e_nnK.js.map +1 -0
  5. package/dist/components.cjs +1 -1
  6. package/dist/components.d.ts +1 -1
  7. package/dist/components.js +1 -1
  8. package/dist/{generators-BqGaMUH6.cjs → generators-CU6zfet7.cjs} +149 -229
  9. package/dist/generators-CU6zfet7.cjs.map +1 -0
  10. package/dist/{generators-B86BJkmW.js → generators-nnZhtlrk.js} +151 -231
  11. package/dist/generators-nnZhtlrk.js.map +1 -0
  12. package/dist/generators.cjs +1 -1
  13. package/dist/generators.d.ts +1 -1
  14. package/dist/generators.js +1 -1
  15. package/dist/index.cjs +41 -18
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +42 -19
  19. package/dist/index.js.map +1 -1
  20. package/dist/{types-Dh4HNR9K.d.ts → types-ANQXv7Gr.d.ts} +13 -17
  21. package/package.json +10 -18
  22. package/dist/components-DQAYLQW0.cjs.map +0 -1
  23. package/dist/components-IArDg-DO.js.map +0 -1
  24. package/dist/generators-B86BJkmW.js.map +0 -1
  25. package/dist/generators-BqGaMUH6.cjs.map +0 -1
  26. package/extension.yaml +0 -1484
  27. package/src/components/InfiniteQuery.tsx +0 -167
  28. package/src/components/InfiniteQueryOptions.tsx +0 -169
  29. package/src/components/Mutation.tsx +0 -123
  30. package/src/components/MutationKey.tsx +0 -1
  31. package/src/components/MutationOptions.tsx +0 -104
  32. package/src/components/Query.tsx +0 -125
  33. package/src/components/QueryKey.tsx +0 -1
  34. package/src/components/QueryOptions.tsx +0 -104
  35. package/src/components/SuspenseInfiniteQuery.tsx +0 -162
  36. package/src/components/SuspenseInfiniteQueryOptions.tsx +0 -163
  37. package/src/components/SuspenseQuery.tsx +0 -120
  38. package/src/components/index.ts +0 -11
  39. package/src/generators/customHookOptionsFileGenerator.tsx +0 -90
  40. package/src/generators/hookOptionsGenerator.tsx +0 -129
  41. package/src/generators/index.ts +0 -7
  42. package/src/generators/infiniteQueryGenerator.tsx +0 -200
  43. package/src/generators/mutationGenerator.tsx +0 -173
  44. package/src/generators/queryGenerator.tsx +0 -185
  45. package/src/generators/suspenseInfiniteQueryGenerator.tsx +0 -209
  46. package/src/generators/suspenseQueryGenerator.tsx +0 -188
  47. package/src/index.ts +0 -2
  48. package/src/plugin.ts +0 -203
  49. package/src/resolvers/resolverReactQuery.ts +0 -118
  50. package/src/types.ts +0 -365
  51. package/src/utils.ts +0 -17
@@ -1,5 +1,6 @@
1
1
  import "./chunk-C0LytTxp.js";
2
2
  import { ast } from "@kubb/core";
3
+ import { buildGroupParam, caseParams, createOperationParams, getNestedAccessor, resolveGroupType, resolveParamType } from "@kubb/ast/utils";
3
4
  import { functionPrinter } from "@kubb/plugin-ts";
4
5
  import { File, Function, Type } from "@kubb/renderer-jsx";
5
6
  import { Fragment, jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
@@ -14,50 +15,20 @@ import { Fragment, jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
14
15
  function toCamelOrPascal(text, pascal) {
15
16
  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
17
  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);
18
+ return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
19
19
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
20
20
  }
21
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
22
  * Converts `text` to camelCase.
35
- * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
36
23
  *
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.
24
+ * @example Word boundaries
25
+ * `camelCase('hello-world') // 'helloWorld'`
52
26
  *
53
- * @example
54
- * getNestedAccessor('pagination.next.id', 'lastPage')
55
- * // → "lastPage?.['pagination']?.['next']?.['id']"
27
+ * @example With a prefix
28
+ * `camelCase('tag', { prefix: 'create' }) // 'createTag'`
56
29
  */
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("']?.['")}']`}`;
30
+ function camelCase(text, { prefix = "", suffix = "" } = {}) {
31
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
61
32
  }
62
33
  //#endregion
63
34
  //#region ../../internals/utils/src/reserved.ts
@@ -163,99 +134,80 @@ function isValidVarName(name) {
163
134
  return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
164
135
  }
165
136
  //#endregion
166
- //#region ../../internals/utils/src/urlPath.ts
137
+ //#region ../../internals/utils/src/url.ts
138
+ function transformParam(raw, casing) {
139
+ const param = isValidVarName(raw) ? raw : camelCase(raw);
140
+ return casing === "camelcase" ? camelCase(param) : param;
141
+ }
142
+ function toParamsObject(path, { replacer, casing } = {}) {
143
+ const params = {};
144
+ for (const match of path.matchAll(/\{([^}]+)\}/g)) {
145
+ const param = transformParam(match[1], casing);
146
+ const key = replacer ? replacer(param) : param;
147
+ params[key] = key;
148
+ }
149
+ return Object.keys(params).length > 0 ? params : null;
150
+ }
167
151
  /**
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}`'
152
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
174
153
  */
175
- var URLPath = class {
154
+ var Url = class Url {
176
155
  /**
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`.
156
+ * Reports whether `url` is a parseable absolute URL. Delegates to the native `URL.canParse`.
186
157
  *
187
158
  * @example
188
- * ```ts
189
- * new URLPath('/pet/{petId}').URL // '/pet/:petId'
190
- * ```
159
+ * Url.canParse('https://petstore.swagger.io/v2') // true
160
+ * Url.canParse('/pet/{petId}') // false
191
161
  */
192
- get URL() {
193
- return this.toURLPath();
162
+ static canParse(url, base) {
163
+ return URL.canParse(url, base);
194
164
  }
195
- /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
165
+ /**
166
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
196
167
  *
197
168
  * @example
198
- * ```ts
199
- * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
200
- * new URLPath('/pet/{petId}').isURL // false
201
- * ```
169
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
202
170
  */
203
- get isURL() {
204
- try {
205
- return !!new URL(this.path).href;
206
- } catch {
207
- return false;
208
- }
171
+ static toPath(path) {
172
+ return path.replace(/\{([^}]+)\}/g, ":$1");
209
173
  }
210
174
  /**
211
- * Converts the OpenAPI path to a TypeScript template literal string.
175
+ * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
176
+ * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,
177
+ * and `casing` controls parameter identifier casing.
212
178
  *
213
179
  * @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.
180
+ * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
221
181
  *
222
182
  * @example
223
- * ```ts
224
- * new URLPath('/pet/{petId}').object
225
- * // { url: '/pet/:petId', params: { petId: 'petId' } }
226
- * ```
183
+ * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
227
184
  */
228
- get object() {
229
- return this.toObject();
185
+ static toTemplateString(path, { prefix, replacer, casing } = {}) {
186
+ const result = path.split(/\{([^}]+)\}/).map((part, i) => {
187
+ if (i % 2 === 0) return part;
188
+ const param = transformParam(part, casing);
189
+ return `\${${replacer ? replacer(param) : param}}`;
190
+ }).join("");
191
+ return `\`${prefix ?? ""}${result}\``;
230
192
  }
231
- /** Returns a map of path parameter names, or `null` when the path has no parameters.
193
+ /**
194
+ * Returns the path and its extracted params as a structured `URLObject`, or as a stringified
195
+ * expression when `stringify` is set.
232
196
  *
233
197
  * @example
234
- * ```ts
235
- * new URLPath('/pet/{petId}').params // { petId: 'petId' }
236
- * new URLPath('/pet').params // null
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.
198
+ * Url.toObject('/pet/{petId}')
199
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
248
200
  */
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 } = {}) {
201
+ static toObject(path, { type = "path", replacer, stringify, casing } = {}) {
256
202
  const object = {
257
- url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
258
- params: this.toParamsObject()
203
+ url: type === "path" ? Url.toPath(path) : Url.toTemplateString(path, {
204
+ replacer,
205
+ casing
206
+ }),
207
+ params: toParamsObject(path, {
208
+ replacer,
209
+ casing
210
+ })
259
211
  };
260
212
  if (stringify) {
261
213
  if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
@@ -264,50 +216,6 @@ var URLPath = class {
264
216
  }
265
217
  return object;
266
218
  }
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
- const result = 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
- return `\`${prefix ?? ""}${result}\``;
281
- }
282
- /**
283
- * Extracts all `{param}` segments from the path and returns them as a key-value map.
284
- * An optional `replacer` transforms each parameter name in both key and value positions.
285
- * Returns `undefined` when no path parameters are found.
286
- *
287
- * @example
288
- * ```ts
289
- * new URLPath('/pet/{petId}/tag/{tagId}').toParamsObject()
290
- * // { petId: 'petId', tagId: 'tagId' }
291
- * ```
292
- */
293
- toParamsObject(replacer) {
294
- const params = {};
295
- this.#eachParam((_raw, param) => {
296
- const key = replacer ? replacer(param) : param;
297
- params[key] = key;
298
- });
299
- return Object.keys(params).length > 0 ? params : null;
300
- }
301
- /** Converts the OpenAPI path to Express-style colon syntax.
302
- *
303
- * @example
304
- * ```ts
305
- * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
306
- * ```
307
- */
308
- toURLPath() {
309
- return this.path.replace(/\{([^}]+)\}/g, ":$1");
310
- }
311
219
  };
312
220
  //#endregion
313
221
  //#region ../../internals/shared/src/operation.ts
@@ -333,7 +241,7 @@ function operationFileEntry(node, name, extname = ".ts") {
333
241
  function getOperationLink(node, link) {
334
242
  if (!link) return null;
335
243
  if (typeof link === "function") return link(node) ?? null;
336
- if (link === "urlPath") return node.path ? `{@link ${new URLPath(node.path).URL}}` : null;
244
+ if (link === "urlPath") return node.path ? `{@link ${Url.toPath(node.path)}}` : null;
337
245
  return node.path ? `{@link ${node.path.replaceAll("{", ":").replaceAll("}", "")}}` : null;
338
246
  }
339
247
  function getContentTypeInfo(node) {
@@ -370,7 +278,7 @@ function buildOperationComments(node, options = {}) {
370
278
  return filteredComments.flatMap((text) => text.split(/\r?\n/).map((line) => line.trim())).filter((comment) => Boolean(comment));
371
279
  }
372
280
  function getOperationParameters(node, options = {}) {
373
- const params = ast.caseParams(node.parameters, options.paramsCasing);
281
+ const params = caseParams(node.parameters, options.paramsCasing);
374
282
  return {
375
283
  path: params.filter((param) => param.in === "path"),
376
284
  query: params.filter((param) => param.in === "query"),
@@ -399,6 +307,19 @@ function resolveSuccessNames(node, resolver) {
399
307
  function resolveStatusCodeNames(node, resolver) {
400
308
  return node.responses.map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
401
309
  }
310
+ /**
311
+ * Builds the discriminated union type string for `dataReturnType: 'full'` return shapes.
312
+ * Each member is `{ status: N; data: StatusNType; statusText: string }`.
313
+ */
314
+ function buildStatusUnionType(node, resolver) {
315
+ const members = node.responses.map((r) => {
316
+ const typeName = resolver.resolveResponseStatusName(node, r.statusCode);
317
+ const statusCode = Number.parseInt(r.statusCode, 10);
318
+ return `{ status: ${Number.isNaN(statusCode) ? "number" : String(statusCode)}; data: ${typeName}; statusText: string }`;
319
+ });
320
+ if (members.length === 1) return members[0];
321
+ return `(${members.join(" | ")})`;
322
+ }
402
323
  const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
403
324
  function resolveOperationTypeNames(node, resolver, options = {}) {
404
325
  const cacheKey = `${node.operationId}\0${options.paramsCasing ?? ""}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${(options.exclude ?? []).join(",")}`;
@@ -434,12 +355,12 @@ function resolveOperationTypeNames(node, resolver, options = {}) {
434
355
  //#endregion
435
356
  //#region ../../internals/tanstack-query/src/components/MutationKey.tsx
436
357
  const declarationPrinter$10 = functionPrinter({ mode: "declaration" });
437
- const mutationKeyTransformer = ({ node, casing }) => {
358
+ const mutationKeyTransformer = ({ node }) => {
438
359
  if (!node.path) return [];
439
- return [`{ url: '${new URLPath(node.path, { casing }).toURLPath()}' }`];
360
+ return [`{ url: '${Url.toPath(node.path)}' }`];
440
361
  };
441
362
  function MutationKey({ name, paramsCasing, node, transformer }) {
442
- const paramsNode = ast.createFunctionParameters({ params: [] });
363
+ const paramsNode = ast.factory.createFunctionParameters({ params: [] });
443
364
  const paramsSignature = declarationPrinter$10.print(paramsNode) ?? "";
444
365
  const keys = (transformer ?? mutationKeyTransformer)({
445
366
  node,
@@ -460,6 +381,35 @@ function MutationKey({ name, paramsCasing, node, transformer }) {
460
381
  }
461
382
  //#endregion
462
383
  //#region ../../internals/tanstack-query/src/utils.ts
384
+ /**
385
+ * Returns the `TypeLiteral` members of a destructured group parameter, or `null`
386
+ * for a plain named parameter.
387
+ */
388
+ function groupMembers(param) {
389
+ if (typeof param.name === "string") return null;
390
+ return param.type && typeof param.type !== "string" && param.type.kind === "TypeLiteral" ? param.type.members : [];
391
+ }
392
+ /**
393
+ * Builds the shared `(…params, config = {})` parameter list for a TanStack
394
+ * query-options function. The trailing `config` parameter is typed as a partial
395
+ * `RequestConfig` with an optional `client`. Framework plugins wrap the result
396
+ * when needed, for example vue-query applies `MaybeRefOrGetter`.
397
+ */
398
+ function buildQueryOptionsParams(node, options) {
399
+ const { paramsType, paramsCasing, pathParamsType, resolver } = options;
400
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
401
+ return createOperationParams(node, {
402
+ paramsType,
403
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
404
+ paramsCasing,
405
+ resolver,
406
+ extraParams: [ast.factory.createFunctionParameter({
407
+ name: "config",
408
+ type: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
409
+ default: "{}"
410
+ })]
411
+ });
412
+ }
463
413
  function matchesPattern(node, ov) {
464
414
  const { type, pattern } = ov;
465
415
  const matches = (value) => typeof pattern === "string" ? value === pattern : pattern.test(value);
@@ -483,116 +433,97 @@ function resolveOperationOverrides(node, override) {
483
433
  return override.find((ov) => matchesPattern(node, ov))?.options ?? {};
484
434
  }
485
435
  /**
486
- * Collects the Zod schema import names for an operation (response + request body).
487
- *
488
- * Returns an empty array when no resolver is provided or the operation has no request body schema.
436
+ * Returns `'zod'` when response-direction parsing is enabled.
437
+ * The string shorthand `'zod'` also enables response parsing.
489
438
  */
490
- function resolveZodSchemaNames(node, zodResolver) {
491
- if (!zodResolver) return [];
492
- return [zodResolver.resolveResponseName?.(node), node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : null].filter((n) => Boolean(n));
439
+ function resolveResponseParser(parser) {
440
+ if (!parser) return null;
441
+ if (parser === "zod") return "zod";
442
+ return parser.response ?? null;
493
443
  }
494
444
  /**
495
- * Resolve the type for a single path parameter.
496
- *
497
- * - When the resolver's group name differs from the individual param name
498
- * (e.g. kubbV4) → `GroupName['paramName']` (member access).
499
- * - When they match (v5 default) → `TypeName` (direct reference).
445
+ * Returns `'zod'` when request body parsing is enabled.
446
+ * The string shorthand `'zod'` also enables request body parsing (existing behavior).
500
447
  */
501
- function resolvePathParamType(node, param, resolver) {
502
- const individualName = resolver.resolveParamName(node, param);
503
- const groupName = resolver.resolvePathParamsName(node, param);
504
- if (groupName !== individualName) return ast.createParamsType({
505
- variant: "member",
506
- base: groupName,
507
- key: param.name
508
- });
509
- return ast.createParamsType({
510
- variant: "reference",
511
- name: individualName
512
- });
448
+ function resolveRequestParser(parser) {
449
+ if (!parser) return null;
450
+ if (parser === "zod") return "zod";
451
+ return parser.request ?? null;
513
452
  }
514
453
  /**
515
- * Derive a query-params group type from the resolver.
516
- * Returns `null` when no query params exist or when the group name
517
- * equals the individual param name (no real group).
454
+ * Returns `'zod'` when query-params parsing is enabled.
455
+ * Only the object form `{ request: 'zod' }` enables this. `parser: 'zod'` does not.
518
456
  */
519
- function resolveQueryGroupType(node, params, resolver) {
520
- if (!params.length) return null;
521
- const firstParam = params[0];
522
- const groupName = resolver.resolveQueryParamsName(node, firstParam);
523
- if (groupName === resolver.resolveParamName(node, firstParam)) return null;
524
- return {
525
- type: ast.createParamsType({
526
- variant: "reference",
527
- name: groupName
528
- }),
529
- optional: params.every((p) => !p.required)
530
- };
457
+ function resolveQueryParamsParser(parser) {
458
+ if (!parser || parser === "zod") return null;
459
+ return parser.request ?? null;
531
460
  }
532
461
  /**
533
- * Build a single `FunctionParameterNode` for a query or header group.
462
+ * Collects the Zod schema import names for an operation based on the active parser directions.
463
+ *
464
+ * - `parser: 'zod'`: response and request body names (backward-compatible behavior).
465
+ * - `parser: { request: 'zod' }`: request body and query params names.
466
+ * - `parser: { response: 'zod' }`: response name only.
467
+ * - `parser: { request: 'zod', response: 'zod' }`: all three.
468
+ *
469
+ * Returns an empty array when no resolver is provided or `parser` is falsy.
534
470
  */
535
- function buildGroupParam(name, node, params, groupType, resolver) {
536
- if (groupType) return [ast.createFunctionParameter({
537
- name,
538
- type: groupType.type,
539
- optional: groupType.optional
540
- })];
541
- if (params.length) {
542
- const structProps = params.map((p) => ({
543
- name: p.name,
544
- type: ast.createParamsType({
545
- variant: "reference",
546
- name: resolver.resolveParamName(node, p)
547
- }),
548
- optional: !p.required
549
- }));
550
- return [ast.createFunctionParameter({
551
- name,
552
- type: ast.createParamsType({
553
- variant: "struct",
554
- properties: structProps
555
- }),
556
- optional: params.every((p) => !p.required)
557
- })];
558
- }
559
- return [];
471
+ function resolveZodSchemaNames(node, zodResolver, parser) {
472
+ if (!zodResolver || !parser) return [];
473
+ const { query: queryParams } = getOperationParameters(node);
474
+ return [
475
+ resolveResponseParser(parser) === "zod" ? zodResolver.resolveResponseName?.(node) : null,
476
+ resolveRequestParser(parser) === "zod" && node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : null,
477
+ resolveQueryParamsParser(parser) === "zod" && queryParams.length > 0 ? zodResolver.resolveQueryParamsName?.(node, queryParams[0]) : null
478
+ ].filter((n) => Boolean(n));
560
479
  }
561
480
  /**
562
481
  * Build QueryKey params: pathParams + data + queryParams (NO headers, NO config).
563
482
  */
564
483
  function buildQueryKeyParams(node, options) {
565
484
  const { pathParamsType, paramsCasing, resolver } = options;
566
- const casedParams = ast.caseParams(node.parameters, paramsCasing);
485
+ const casedParams = caseParams(node.parameters, paramsCasing);
567
486
  const pathParams = casedParams.filter((p) => p.in === "path");
568
487
  const queryParams = casedParams.filter((p) => p.in === "query");
569
- const queryGroupType = resolveQueryGroupType(node, queryParams, resolver);
570
- const bodyType = node.requestBody?.content?.[0]?.schema ? ast.createParamsType({
571
- variant: "reference",
572
- name: resolver.resolveDataName(node)
573
- }) : null;
488
+ const queryGroupType = resolveGroupType({
489
+ node,
490
+ params: queryParams,
491
+ group: "query",
492
+ resolver
493
+ });
494
+ const bodyType = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
574
495
  const bodyRequired = node.requestBody?.required ?? false;
575
496
  const params = [];
576
497
  if (pathParams.length) {
577
- const pathChildren = pathParams.map((p) => ast.createFunctionParameter({
498
+ const pathChildren = pathParams.map((p) => ({
578
499
  name: p.name,
579
- type: resolvePathParamType(node, p, resolver),
500
+ type: resolveParamType({
501
+ node,
502
+ param: p,
503
+ resolver
504
+ }),
580
505
  optional: !p.required
581
506
  }));
582
- params.push({
583
- kind: "ParameterGroup",
507
+ if (pathParamsType === "object") params.push(ast.factory.createFunctionParameter({
584
508
  properties: pathChildren,
585
- inline: pathParamsType === "inline",
586
509
  default: pathChildren.every((c) => c.optional) ? "{}" : void 0
587
- });
510
+ }));
511
+ else params.push(...pathChildren.map((child) => ast.factory.createFunctionParameter(child)));
588
512
  }
589
- if (bodyType) params.push(ast.createFunctionParameter({
513
+ if (bodyType) params.push(ast.factory.createFunctionParameter({
590
514
  name: "data",
591
515
  type: bodyType,
592
516
  optional: !bodyRequired
593
517
  }));
594
- params.push(...buildGroupParam("params", node, queryParams, queryGroupType, resolver));
595
- return ast.createFunctionParameters({ params });
518
+ params.push(...buildGroupParam({
519
+ name: "params",
520
+ node,
521
+ params: queryParams,
522
+ groupType: queryGroupType,
523
+ resolver,
524
+ wrapType: (type) => type
525
+ }));
526
+ return ast.factory.createFunctionParameters({ params });
596
527
  }
597
528
  /**
598
529
  * Collect the names of the required params (no default) that drive the `enabled`
@@ -601,12 +532,11 @@ function buildQueryKeyParams(node, options) {
601
532
  */
602
533
  function getEnabledParamNames(paramsNode) {
603
534
  const required = [];
604
- for (const param of paramsNode.params) if ("kind" in param && param.kind === "ParameterGroup") {
605
- const group = param;
606
- for (const child of group.properties) if (!child.optional && child.default === void 0) required.push(child.name);
607
- } else {
608
- const fp = param;
609
- if (!fp.optional && fp.default === void 0) required.push(fp.name);
535
+ for (const param of paramsNode.params) {
536
+ const members = groupMembers(param);
537
+ if (members) {
538
+ for (const member of members) if (!member.optional) required.push(member.name);
539
+ } else if (typeof param.name === "string" && !param.optional && param.default === void 0) required.push(param.name);
610
540
  }
611
541
  return required;
612
542
  }
@@ -622,27 +552,25 @@ function markParamsOptional(paramsNode, names) {
622
552
  if (names.length === 0) return paramsNode;
623
553
  const nameSet = new Set(names);
624
554
  const params = paramsNode.params.map((param) => {
625
- if ("kind" in param && param.kind === "ParameterGroup") {
626
- const group = param;
555
+ const members = groupMembers(param);
556
+ if (members) {
557
+ const next = members.map((member) => nameSet.has(member.name) ? {
558
+ ...member,
559
+ optional: true
560
+ } : member);
627
561
  return {
628
- ...group,
629
- properties: group.properties.map((child) => nameSet.has(child.name) ? ast.createFunctionParameter({
630
- name: child.name,
631
- type: child.type,
632
- rest: child.rest,
633
- optional: true
634
- }) : child)
562
+ ...param,
563
+ type: ast.factory.createTypeLiteral({ members: next })
635
564
  };
636
565
  }
637
- const fp = param;
638
- return nameSet.has(fp.name) ? ast.createFunctionParameter({
639
- name: fp.name,
640
- type: fp.type,
641
- rest: fp.rest,
566
+ return typeof param.name === "string" && nameSet.has(param.name) ? ast.factory.createFunctionParameter({
567
+ name: param.name,
568
+ type: param.type,
569
+ rest: param.rest,
642
570
  optional: true
643
- }) : fp;
571
+ }) : param;
644
572
  });
645
- return ast.createFunctionParameters({ params });
573
+ return ast.factory.createFunctionParameters({ params });
646
574
  }
647
575
  /**
648
576
  * Add a non-null assertion (`!`) to the named params inside a printed client-call
@@ -669,13 +597,13 @@ function injectNonNullAssertions(callStr, names) {
669
597
  const declarationPrinter$9 = functionPrinter({ mode: "declaration" });
670
598
  const queryKeyTransformer = ({ node, casing }) => {
671
599
  if (!node.path) return [];
672
- const path = new URLPath(node.path, { casing });
673
600
  const hasQueryParams = getOperationParameters(node).query.length > 0;
674
601
  const hasRequestBody = !!node.requestBody?.content?.[0]?.schema;
675
602
  return [
676
- path.toObject({
603
+ Url.toObject(node.path, {
677
604
  type: "path",
678
- stringify: true
605
+ stringify: true,
606
+ casing
679
607
  }),
680
608
  hasQueryParams ? "...(params ? [params] : [])" : null,
681
609
  hasRequestBody ? "...(data ? [data] : [])" : null
@@ -718,28 +646,13 @@ function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeNa
718
646
  const declarationPrinter$8 = functionPrinter({ mode: "declaration" });
719
647
  const callPrinter$8 = functionPrinter({ mode: "call" });
720
648
  function getQueryOptionsParams(node, options) {
721
- const { paramsType, paramsCasing, pathParamsType, resolver } = options;
722
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
723
- return ast.createOperationParams(node, {
724
- paramsType,
725
- pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
726
- paramsCasing,
727
- resolver,
728
- extraParams: [ast.createFunctionParameter({
729
- name: "config",
730
- type: ast.createParamsType({
731
- variant: "reference",
732
- name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
733
- }),
734
- default: "{}"
735
- })]
736
- });
649
+ return buildQueryOptionsParams(node, options);
737
650
  }
738
651
  function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, queryKeyName, suspense }) {
739
652
  const successNames = resolveSuccessNames(node, tsResolver);
740
653
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
741
654
  const errorNames = resolveErrorNames(node, tsResolver);
742
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
655
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
743
656
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
744
657
  const queryKeyParamsNode = buildQueryKeyParams(node, {
745
658
  pathParamsType,
@@ -768,8 +681,7 @@ function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, para
768
681
  params: paramsSignature,
769
682
  children: `
770
683
  const queryKey = ${queryKeyName}(${queryKeyParamsCall})
771
- return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({
772
- ${enabledText}
684
+ return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({${enabledText ? `\n ${enabledText}` : ""}
773
685
  queryKey,
774
686
  queryFn: async ({ signal }) => {
775
687
  return ${clientName}(${clientCallStr})
@@ -786,18 +698,15 @@ const callPrinter$7 = functionPrinter({ mode: "call" });
786
698
  function buildInfiniteQueryParamsNode(node, options) {
787
699
  const { paramsType, paramsCasing, pathParamsType, resolver, pageParamGeneric } = options;
788
700
  const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
789
- const optionsParam = ast.createFunctionParameter({
701
+ const optionsParam = ast.factory.createFunctionParameter({
790
702
  name: "options",
791
- type: ast.createParamsType({
792
- variant: "reference",
793
- name: `{
703
+ type: `{
794
704
  query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
795
705
  client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
796
- }`
797
- }),
706
+ }`,
798
707
  default: "{}"
799
708
  });
800
- return ast.createOperationParams(node, {
709
+ return createOperationParams(node, {
801
710
  paramsType,
802
711
  pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
803
712
  paramsCasing,
@@ -809,7 +718,7 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
809
718
  const successNames = resolveSuccessNames(node, tsResolver);
810
719
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
811
720
  const errorNames = resolveErrorNames(node, tsResolver);
812
- const responseType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
721
+ const responseType = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
813
722
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
814
723
  const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
815
724
  const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
@@ -868,11 +777,10 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
868
777
  children: `
869
778
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
870
779
  const { client: queryClient, ...resolvedOptions } = queryConfig
871
- const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
872
- ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
780
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})${customOptions ? `\n const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
873
781
 
874
782
  const query = useInfiniteQuery({
875
- ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
783
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n ...customOptions," : ""}
876
784
  ...resolvedOptions,
877
785
  queryKey,
878
786
  } as unknown as InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
@@ -891,7 +799,7 @@ const callPrinter$6 = functionPrinter({ mode: "call" });
891
799
  function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
892
800
  const successNames = resolveSuccessNames(node, tsResolver);
893
801
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
894
- const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
802
+ const queryFnDataType = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
895
803
  const errorNames = resolveErrorNames(node, tsResolver);
896
804
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
897
805
  const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
@@ -937,11 +845,10 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
937
845
  getNextPageParamExpr,
938
846
  getPreviousPageParamExpr
939
847
  ].filter(Boolean);
940
- const infiniteOverrideParams = queryParam && queryParamsTypeName ? `
941
- params = {
942
- ...(params ?? {}),
943
- ['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
944
- } as ${queryParamsTypeName}` : "";
848
+ const infiniteOverrideParams = queryParam && queryParamsTypeName ? `params = {
849
+ ...(params ?? {}),
850
+ ['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
851
+ } as ${queryParamsTypeName}` : "";
945
852
  if (infiniteOverrideParams) return /* @__PURE__ */ jsx(File.Source, {
946
853
  name,
947
854
  isExportable: true,
@@ -951,16 +858,15 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
951
858
  export: true,
952
859
  params: paramsSignature,
953
860
  children: `
954
- const queryKey = ${queryKeyName}(${queryKeyParamsCall})
955
- return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
956
- ${enabledText}
957
- queryKey,
958
- queryFn: async ({ signal, pageParam }) => {
959
- ${infiniteOverrideParams}
960
- return ${clientName}(${clientCallStr})
961
- },
962
- ${queryOptionsArr.join(",\n")}
963
- })
861
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
862
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({${enabledText ? `\n ${enabledText}` : ""}
863
+ queryKey,
864
+ queryFn: async ({ signal, pageParam }) => {
865
+ ${infiniteOverrideParams}
866
+ return ${clientName}(${clientCallStr})
867
+ },
868
+ ${queryOptionsArr.join(",\n ")}
869
+ })
964
870
  `
965
871
  })
966
872
  });
@@ -973,15 +879,14 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
973
879
  export: true,
974
880
  params: paramsSignature,
975
881
  children: `
976
- const queryKey = ${queryKeyName}(${queryKeyParamsCall})
977
- return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
978
- ${enabledText}
979
- queryKey,
980
- queryFn: async ({ signal }) => {
981
- return ${clientName}(${clientCallStr})
982
- },
983
- ${queryOptionsArr.join(",\n")}
984
- })
882
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
883
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({${enabledText ? `\n ${enabledText}` : ""}
884
+ queryKey,
885
+ queryFn: async ({ signal }) => {
886
+ return ${clientName}(${clientCallStr})
887
+ },
888
+ ${queryOptionsArr.join(",\n ")}
889
+ })
985
890
  `
986
891
  })
987
892
  });
@@ -990,26 +895,23 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
990
895
  //#region src/components/MutationOptions.tsx
991
896
  const declarationPrinter$5 = functionPrinter({ mode: "declaration" });
992
897
  const callPrinter$5 = functionPrinter({ mode: "call" });
993
- const keysPrinter = functionPrinter({ mode: "keys" });
898
+ const keysPrinter = functionPrinter({ mode: "call" });
994
899
  function buildMutationConfigParamsNode(node, resolver) {
995
- return ast.createFunctionParameters({ params: [ast.createFunctionParameter({
900
+ return ast.factory.createFunctionParameters({ params: [ast.factory.createFunctionParameter({
996
901
  name: "config",
997
- type: ast.createParamsType({
998
- variant: "reference",
999
- name: buildRequestConfigType(node, resolver)
1000
- }),
902
+ type: buildRequestConfigType(node, resolver),
1001
903
  default: "{}"
1002
904
  })] });
1003
905
  }
1004
906
  function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, mutationKeyName }) {
1005
907
  const successNames = resolveSuccessNames(node, tsResolver);
1006
908
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1007
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
909
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
1008
910
  const errorNames = resolveErrorNames(node, tsResolver);
1009
911
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1010
912
  const configParamsNode = buildMutationConfigParamsNode(node, tsResolver);
1011
913
  const paramsSignature = declarationPrinter$5.print(configParamsNode) ?? "";
1012
- const mutationArgParamsNode = ast.createOperationParams(node, {
914
+ const mutationArgParamsNode = createOperationParams(node, {
1013
915
  paramsType: "inline",
1014
916
  pathParamsType: "inline",
1015
917
  paramsCasing,
@@ -1018,17 +920,14 @@ function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, p
1018
920
  const hasMutationParams = mutationArgParamsNode.params.length > 0;
1019
921
  const TRequest = hasMutationParams ? declarationPrinter$5.print(mutationArgParamsNode) ?? "" : "";
1020
922
  const argKeysStr = hasMutationParams ? keysPrinter.print(mutationArgParamsNode) ?? "" : "";
1021
- const clientCallParamsNode = ast.createOperationParams(node, {
923
+ const clientCallParamsNode = createOperationParams(node, {
1022
924
  paramsType,
1023
925
  pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1024
926
  paramsCasing,
1025
927
  resolver: tsResolver,
1026
- extraParams: [ast.createFunctionParameter({
928
+ extraParams: [ast.factory.createFunctionParameter({
1027
929
  name: "config",
1028
- type: ast.createParamsType({
1029
- variant: "reference",
1030
- name: buildRequestConfigType(node, tsResolver)
1031
- }),
930
+ type: buildRequestConfigType(node, tsResolver),
1032
931
  default: "{}"
1033
932
  })]
1034
933
  });
@@ -1059,7 +958,7 @@ function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, p
1059
958
  const declarationPrinter$4 = functionPrinter({ mode: "declaration" });
1060
959
  const callPrinter$4 = functionPrinter({ mode: "call" });
1061
960
  function createMutationArgParams(node, options) {
1062
- return ast.createOperationParams(node, {
961
+ return createOperationParams(node, {
1063
962
  paramsType: "inline",
1064
963
  pathParamsType: "inline",
1065
964
  paramsCasing: options.paramsCasing,
@@ -1071,7 +970,7 @@ function buildMutationParamsNode(node, options) {
1071
970
  const successNames = resolveSuccessNames(node, resolver);
1072
971
  const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
1073
972
  const errorNames = resolveErrorNames(node, resolver);
1074
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
973
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, resolver);
1075
974
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1076
975
  const mutationArgParamsNode = createMutationArgParams(node, {
1077
976
  paramsCasing,
@@ -1084,15 +983,12 @@ function buildMutationParamsNode(node, options) {
1084
983
  TRequest ? `{${TRequest}}` : "undefined",
1085
984
  "TContext"
1086
985
  ].join(", ");
1087
- return ast.createFunctionParameters({ params: [ast.createFunctionParameter({
986
+ return ast.factory.createFunctionParameters({ params: [ast.factory.createFunctionParameter({
1088
987
  name: "options",
1089
- type: ast.createParamsType({
1090
- variant: "reference",
1091
- name: `{
988
+ type: `{
1092
989
  mutation?: UseMutationOptions<${generics}> & { client?: QueryClient },
1093
990
  client?: ${buildRequestConfigType(node, resolver)},
1094
- }`
1095
- }),
991
+ }`,
1096
992
  default: "{}"
1097
993
  })] });
1098
994
  }
@@ -1100,7 +996,7 @@ function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, nod
1100
996
  const successNames = resolveSuccessNames(node, tsResolver);
1101
997
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1102
998
  const errorNames = resolveErrorNames(node, tsResolver);
1103
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
999
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
1104
1000
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1105
1001
  const mutationArgParamsNode = createMutationArgParams(node, {
1106
1002
  paramsCasing,
@@ -1137,11 +1033,10 @@ function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, nod
1137
1033
  const { client: queryClient, ...mutationOptions } = mutation;
1138
1034
  const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}()
1139
1035
 
1140
- const baseOptions = ${mutationOptionsName}(${mutationOptionsParamsCall}) as UseMutationOptions<${generics}>
1141
- ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' }) as UseMutationOptions<${generics}>` : ""}
1036
+ const baseOptions = ${mutationOptionsName}(${mutationOptionsParamsCall}) as UseMutationOptions<${generics}>${customOptions ? `\n const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' }) as UseMutationOptions<${generics}>` : ""}
1142
1037
 
1143
1038
  return useMutation<${generics}>({
1144
- ...baseOptions,${customOptions ? "\n...customOptions," : ""}
1039
+ ...baseOptions,${customOptions ? "\n ...customOptions," : ""}
1145
1040
  mutationKey,
1146
1041
  ...mutationOptions,
1147
1042
  }, queryClient) as ${returnType}
@@ -1159,26 +1054,23 @@ function buildQueryParamsNode(node, options) {
1159
1054
  const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
1160
1055
  const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
1161
1056
  const errorNames = resolveErrorNames(node, resolver);
1162
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1057
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, resolver);
1163
1058
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1164
- const optionsParam = ast.createFunctionParameter({
1059
+ const optionsParam = ast.factory.createFunctionParameter({
1165
1060
  name: "options",
1166
- type: ast.createParamsType({
1167
- variant: "reference",
1168
- name: `{
1061
+ type: `{
1169
1062
  query?: Partial<QueryObserverOptions<${[
1170
- TData,
1171
- TError,
1172
- "TData",
1173
- "TQueryData",
1174
- "TQueryKey"
1175
- ].join(", ")}>> & { client?: QueryClient },
1063
+ TData,
1064
+ TError,
1065
+ "TData",
1066
+ "TQueryData",
1067
+ "TQueryKey"
1068
+ ].join(", ")}>> & { client?: QueryClient },
1176
1069
  client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
1177
- }`
1178
- }),
1070
+ }`,
1179
1071
  default: "{}"
1180
1072
  });
1181
- return ast.createOperationParams(node, {
1073
+ return createOperationParams(node, {
1182
1074
  paramsType,
1183
1075
  pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1184
1076
  paramsCasing,
@@ -1190,7 +1082,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
1190
1082
  const successNames = resolveSuccessNames(node, tsResolver);
1191
1083
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1192
1084
  const errorNames = resolveErrorNames(node, tsResolver);
1193
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1085
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
1194
1086
  const returnType = `UseQueryResult<TData, ${`ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`}> & { queryKey: TQueryKey }`;
1195
1087
  const generics = [
1196
1088
  `TData = ${TData}`,
@@ -1233,11 +1125,10 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
1233
1125
  children: `
1234
1126
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
1235
1127
  const { client: queryClient, ...resolvedOptions } = queryConfig
1236
- const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
1237
- ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1128
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})${customOptions ? `\n const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1238
1129
 
1239
1130
  const query = useQuery({
1240
- ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
1131
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n ...customOptions," : ""}
1241
1132
  ...resolvedOptions,
1242
1133
  queryKey,
1243
1134
  } as unknown as QueryObserverOptions, queryClient) as ${returnType}
@@ -1256,18 +1147,15 @@ const callPrinter$2 = functionPrinter({ mode: "call" });
1256
1147
  function buildSuspenseInfiniteQueryParamsNode(node, options) {
1257
1148
  const { paramsType, paramsCasing, pathParamsType, resolver, pageParamGeneric } = options;
1258
1149
  const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
1259
- const optionsParam = ast.createFunctionParameter({
1150
+ const optionsParam = ast.factory.createFunctionParameter({
1260
1151
  name: "options",
1261
- type: ast.createParamsType({
1262
- variant: "reference",
1263
- name: `{
1152
+ type: `{
1264
1153
  query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
1265
1154
  client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
1266
- }`
1267
- }),
1155
+ }`,
1268
1156
  default: "{}"
1269
1157
  });
1270
- return ast.createOperationParams(node, {
1158
+ return createOperationParams(node, {
1271
1159
  paramsType,
1272
1160
  pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1273
1161
  paramsCasing,
@@ -1279,7 +1167,7 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1279
1167
  const successNames = resolveSuccessNames(node, tsResolver);
1280
1168
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1281
1169
  const errorNames = resolveErrorNames(node, tsResolver);
1282
- const responseType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1170
+ const responseType = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
1283
1171
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1284
1172
  const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
1285
1173
  const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
@@ -1337,11 +1225,10 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1337
1225
  children: `
1338
1226
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
1339
1227
  const { client: queryClient, ...resolvedOptions } = queryConfig
1340
- const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
1341
- ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1228
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})${customOptions ? `\n const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1342
1229
 
1343
1230
  const query = useSuspenseInfiniteQuery({
1344
- ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
1231
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n ...customOptions," : ""}
1345
1232
  ...resolvedOptions,
1346
1233
  queryKey,
1347
1234
  } as unknown as UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
@@ -1360,7 +1247,7 @@ const callPrinter$1 = functionPrinter({ mode: "call" });
1360
1247
  function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
1361
1248
  const successNames = resolveSuccessNames(node, tsResolver);
1362
1249
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1363
- const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1250
+ const queryFnDataType = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
1364
1251
  const errorNames = resolveErrorNames(node, tsResolver);
1365
1252
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1366
1253
  const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
@@ -1404,11 +1291,10 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1404
1291
  getNextPageParamExpr,
1405
1292
  getPreviousPageParamExpr
1406
1293
  ].filter(Boolean);
1407
- const infiniteOverrideParams = queryParam && queryParamsTypeName ? `
1408
- params = {
1409
- ...(params ?? {}),
1410
- ['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
1411
- } as ${queryParamsTypeName}` : "";
1294
+ const infiniteOverrideParams = queryParam && queryParamsTypeName ? `params = {
1295
+ ...(params ?? {}),
1296
+ ['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
1297
+ } as ${queryParamsTypeName}` : "";
1412
1298
  if (infiniteOverrideParams) return /* @__PURE__ */ jsx(File.Source, {
1413
1299
  name,
1414
1300
  isExportable: true,
@@ -1418,15 +1304,15 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1418
1304
  export: true,
1419
1305
  params: paramsSignature,
1420
1306
  children: `
1421
- const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1422
- return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
1423
- queryKey,
1424
- queryFn: async ({ signal, pageParam }) => {
1425
- ${infiniteOverrideParams}
1426
- return ${clientName}(${clientCallStr})
1427
- },
1428
- ${queryOptionsArr.join(",\n")}
1429
- })
1307
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1308
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
1309
+ queryKey,
1310
+ queryFn: async ({ signal, pageParam }) => {
1311
+ ${infiniteOverrideParams}
1312
+ return ${clientName}(${clientCallStr})
1313
+ },
1314
+ ${queryOptionsArr.join(",\n ")}
1315
+ })
1430
1316
  `
1431
1317
  })
1432
1318
  });
@@ -1439,14 +1325,14 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1439
1325
  export: true,
1440
1326
  params: paramsSignature,
1441
1327
  children: `
1442
- const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1443
- return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
1444
- queryKey,
1445
- queryFn: async ({ signal }) => {
1446
- return ${clientName}(${clientCallStr})
1447
- },
1448
- ${queryOptionsArr.join(",\n")}
1449
- })
1328
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1329
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
1330
+ queryKey,
1331
+ queryFn: async ({ signal }) => {
1332
+ return ${clientName}(${clientCallStr})
1333
+ },
1334
+ ${queryOptionsArr.join(",\n ")}
1335
+ })
1450
1336
  `
1451
1337
  })
1452
1338
  });
@@ -1461,25 +1347,22 @@ function buildSuspenseQueryParamsNode(node, options) {
1461
1347
  const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
1462
1348
  const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
1463
1349
  const errorNames = resolveErrorNames(node, resolver);
1464
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1350
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, resolver);
1465
1351
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1466
- const optionsParam = ast.createFunctionParameter({
1352
+ const optionsParam = ast.factory.createFunctionParameter({
1467
1353
  name: "options",
1468
- type: ast.createParamsType({
1469
- variant: "reference",
1470
- name: `{
1354
+ type: `{
1471
1355
  query?: Partial<UseSuspenseQueryOptions<${[
1472
- TData,
1473
- TError,
1474
- "TData",
1475
- "TQueryKey"
1476
- ].join(", ")}>> & { client?: QueryClient },
1356
+ TData,
1357
+ TError,
1358
+ "TData",
1359
+ "TQueryKey"
1360
+ ].join(", ")}>> & { client?: QueryClient },
1477
1361
  client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
1478
- }`
1479
- }),
1362
+ }`,
1480
1363
  default: "{}"
1481
1364
  });
1482
- return ast.createOperationParams(node, {
1365
+ return createOperationParams(node, {
1483
1366
  paramsType,
1484
1367
  pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
1485
1368
  paramsCasing,
@@ -1491,7 +1374,7 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
1491
1374
  const successNames = resolveSuccessNames(node, tsResolver);
1492
1375
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1493
1376
  const errorNames = resolveErrorNames(node, tsResolver);
1494
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1377
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
1495
1378
  const returnType = `UseSuspenseQueryResult<TData, ${`ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`}> & { queryKey: TQueryKey }`;
1496
1379
  const generics = [`TData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
1497
1380
  const queryKeyParamsNode = buildQueryKeyParams(node, {
@@ -1529,11 +1412,10 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
1529
1412
  children: `
1530
1413
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
1531
1414
  const { client: queryClient, ...resolvedOptions } = queryConfig
1532
- const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
1533
- ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1415
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})${customOptions ? `\n const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ""}
1534
1416
 
1535
1417
  const query = useSuspenseQuery({
1536
- ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n...customOptions," : ""}
1418
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? "\n ...customOptions," : ""}
1537
1419
  ...resolvedOptions,
1538
1420
  queryKey,
1539
1421
  } as unknown as UseSuspenseQueryOptions, queryClient) as ${returnType}
@@ -1548,4 +1430,4 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
1548
1430
  //#endregion
1549
1431
  export { operationFileEntry as _, Mutation as a, InfiniteQuery as c, queryKeyTransformer as d, resolveOperationOverrides as f, getOperationParameters as g, mutationKeyTransformer as h, Query as i, QueryOptions as l, MutationKey as m, SuspenseInfiniteQueryOptions as n, MutationOptions as o, resolveZodSchemaNames as p, SuspenseInfiniteQuery as r, InfiniteQueryOptions as s, SuspenseQuery as t, QueryKey as u, resolveOperationTypeNames as v, camelCase as y };
1550
1432
 
1551
- //# sourceMappingURL=components-IArDg-DO.js.map
1433
+ //# sourceMappingURL=components-Ds-e_nnK.js.map