@kubb/plugin-vue-query 5.0.0-beta.42 → 5.0.0-beta.56

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 (38) hide show
  1. package/dist/{components-Bxe1EuWf.js → components-B79Gljyl.js} +176 -214
  2. package/dist/components-B79Gljyl.js.map +1 -0
  3. package/dist/{components-BwFPMwK7.cjs → components-D3xIZ9FA.cjs} +178 -216
  4. package/dist/components-D3xIZ9FA.cjs.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-BSN6A0ED.cjs → generators-BTtcGtUY.cjs} +91 -137
  9. package/dist/generators-BTtcGtUY.cjs.map +1 -0
  10. package/dist/{generators-D9TUvYRN.js → generators-D95ddIFV.js} +93 -139
  11. package/dist/generators-D95ddIFV.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 +35 -12
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +36 -13
  19. package/dist/index.js.map +1 -1
  20. package/dist/{types-HHnnlEhK.d.ts → types-CwabLiFK.d.ts} +10 -14
  21. package/package.json +10 -17
  22. package/src/components/InfiniteQuery.tsx +3 -3
  23. package/src/components/InfiniteQueryOptions.tsx +24 -27
  24. package/src/components/Mutation.tsx +3 -3
  25. package/src/components/Query.tsx +3 -3
  26. package/src/components/QueryOptions.tsx +6 -27
  27. package/src/generators/infiniteQueryGenerator.tsx +5 -9
  28. package/src/generators/mutationGenerator.tsx +8 -9
  29. package/src/generators/queryGenerator.tsx +5 -9
  30. package/src/plugin.ts +4 -4
  31. package/src/resolvers/resolverVueQuery.ts +2 -2
  32. package/src/types.ts +9 -13
  33. package/src/utils.ts +1 -0
  34. package/dist/components-BwFPMwK7.cjs.map +0 -1
  35. package/dist/components-Bxe1EuWf.js.map +0 -1
  36. package/dist/generators-BSN6A0ED.cjs.map +0 -1
  37. package/dist/generators-D9TUvYRN.js.map +0 -1
  38. package/extension.yaml +0 -1248
@@ -28,6 +28,7 @@ let _kubb_core = require("@kubb/core");
28
28
  let _kubb_plugin_ts = require("@kubb/plugin-ts");
29
29
  let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
30
30
  let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
31
+ let _kubb_ast_utils = require("@kubb/ast/utils");
31
32
  //#region ../../internals/utils/src/casing.ts
32
33
  /**
33
34
  * Shared implementation for camelCase and PascalCase conversion.
@@ -39,50 +40,20 @@ let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
39
40
  function toCamelOrPascal(text, pascal) {
40
41
  return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
41
42
  if (word.length > 1 && word === word.toUpperCase()) return word;
42
- if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
43
- return word.charAt(0).toUpperCase() + word.slice(1);
43
+ return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
44
44
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
45
45
  }
46
46
  /**
47
- * Splits `text` on `.` and applies `transformPart` to each segment.
48
- * The last segment receives `isLast = true`, all earlier segments receive `false`.
49
- * Segments are joined with `/` to form a file path.
50
- *
51
- * Only splits on dots followed by a letter so that version numbers
52
- * embedded in operationIds (e.g. `v2025.0`) are kept intact.
53
- */
54
- function applyToFileParts(text, transformPart) {
55
- const parts = text.split(/\.(?=[a-zA-Z])/);
56
- return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
57
- }
58
- /**
59
47
  * Converts `text` to camelCase.
60
- * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
61
48
  *
62
- * @example
63
- * camelCase('hello-world') // 'helloWorld'
64
- * camelCase('pet.petId', { isFile: true }) // 'pet/petId'
65
- */
66
- function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
67
- if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
68
- prefix,
69
- suffix
70
- } : {}));
71
- return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
72
- }
73
- //#endregion
74
- //#region ../../internals/utils/src/object.ts
75
- /**
76
- * Converts a dot-notation path or string array into an optional-chaining accessor expression.
49
+ * @example Word boundaries
50
+ * `camelCase('hello-world') // 'helloWorld'`
77
51
  *
78
- * @example
79
- * getNestedAccessor('pagination.next.id', 'lastPage')
80
- * // → "lastPage?.['pagination']?.['next']?.['id']"
52
+ * @example With a prefix
53
+ * `camelCase('tag', { prefix: 'create' }) // 'createTag'`
81
54
  */
82
- function getNestedAccessor(param, accessor) {
83
- const parts = Array.isArray(param) ? param : param.split(".");
84
- if (parts.length === 0 || parts.length === 1 && parts[0] === "") return null;
85
- return `${accessor}?.['${`${parts.join("']?.['")}']`}`;
55
+ function camelCase(text, { prefix = "", suffix = "" } = {}) {
56
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
86
57
  }
87
58
  //#endregion
88
59
  //#region ../../internals/utils/src/reserved.ts
@@ -188,99 +159,80 @@ function isValidVarName(name) {
188
159
  return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
189
160
  }
190
161
  //#endregion
191
- //#region ../../internals/utils/src/urlPath.ts
162
+ //#region ../../internals/utils/src/url.ts
163
+ function transformParam(raw, casing) {
164
+ const param = isValidVarName(raw) ? raw : camelCase(raw);
165
+ return casing === "camelcase" ? camelCase(param) : param;
166
+ }
167
+ function toParamsObject(path, { replacer, casing } = {}) {
168
+ const params = {};
169
+ for (const match of path.matchAll(/\{([^}]+)\}/g)) {
170
+ const param = transformParam(match[1], casing);
171
+ const key = replacer ? replacer(param) : param;
172
+ params[key] = key;
173
+ }
174
+ return Object.keys(params).length > 0 ? params : null;
175
+ }
192
176
  /**
193
- * Parses and transforms an OpenAPI/Swagger path string into various URL formats.
194
- *
195
- * @example
196
- * const p = new URLPath('/pet/{petId}')
197
- * p.URL // '/pet/:petId'
198
- * p.template // '`/pet/${petId}`'
177
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
199
178
  */
200
- var URLPath = class {
179
+ var Url = class Url {
201
180
  /**
202
- * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
203
- */
204
- path;
205
- #options;
206
- constructor(path, options = {}) {
207
- this.path = path;
208
- this.#options = options;
209
- }
210
- /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
181
+ * Reports whether `url` is a parseable absolute URL. Delegates to the native `URL.canParse`.
211
182
  *
212
183
  * @example
213
- * ```ts
214
- * new URLPath('/pet/{petId}').URL // '/pet/:petId'
215
- * ```
184
+ * Url.canParse('https://petstore.swagger.io/v2') // true
185
+ * Url.canParse('/pet/{petId}') // false
216
186
  */
217
- get URL() {
218
- return this.toURLPath();
187
+ static canParse(url, base) {
188
+ return URL.canParse(url, base);
219
189
  }
220
- /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
190
+ /**
191
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
221
192
  *
222
193
  * @example
223
- * ```ts
224
- * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
225
- * new URLPath('/pet/{petId}').isURL // false
226
- * ```
194
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
227
195
  */
228
- get isURL() {
229
- try {
230
- return !!new URL(this.path).href;
231
- } catch {
232
- return false;
233
- }
196
+ static toPath(path) {
197
+ return path.replace(/\{([^}]+)\}/g, ":$1");
234
198
  }
235
199
  /**
236
- * Converts the OpenAPI path to a TypeScript template literal string.
200
+ * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
201
+ * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,
202
+ * and `casing` controls parameter identifier casing.
237
203
  *
238
204
  * @example
239
- * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
240
- * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
241
- */
242
- get template() {
243
- return this.toTemplateString();
244
- }
245
- /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
205
+ * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
246
206
  *
247
207
  * @example
248
- * ```ts
249
- * new URLPath('/pet/{petId}').object
250
- * // { url: '/pet/:petId', params: { petId: 'petId' } }
251
- * ```
208
+ * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
252
209
  */
253
- get object() {
254
- return this.toObject();
210
+ static toTemplateString(path, { prefix, replacer, casing } = {}) {
211
+ const result = path.split(/\{([^}]+)\}/).map((part, i) => {
212
+ if (i % 2 === 0) return part;
213
+ const param = transformParam(part, casing);
214
+ return `\${${replacer ? replacer(param) : param}}`;
215
+ }).join("");
216
+ return `\`${prefix ?? ""}${result}\``;
255
217
  }
256
- /** Returns a map of path parameter names, or `null` when the path has no parameters.
218
+ /**
219
+ * Returns the path and its extracted params as a structured `URLObject`, or as a stringified
220
+ * expression when `stringify` is set.
257
221
  *
258
222
  * @example
259
- * ```ts
260
- * new URLPath('/pet/{petId}').params // { petId: 'petId' }
261
- * new URLPath('/pet').params // null
262
- * ```
263
- */
264
- get params() {
265
- return this.toParamsObject();
266
- }
267
- #transformParam(raw) {
268
- const param = isValidVarName(raw) ? raw : camelCase(raw);
269
- return this.#options.casing === "camelcase" ? camelCase(param) : param;
270
- }
271
- /**
272
- * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.
223
+ * Url.toObject('/pet/{petId}')
224
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
273
225
  */
274
- #eachParam(fn) {
275
- for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
276
- const raw = match[1];
277
- fn(raw, this.#transformParam(raw));
278
- }
279
- }
280
- toObject({ type = "path", replacer, stringify } = {}) {
226
+ static toObject(path, { type = "path", replacer, stringify, casing } = {}) {
281
227
  const object = {
282
- url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
283
- params: this.toParamsObject()
228
+ url: type === "path" ? Url.toPath(path) : Url.toTemplateString(path, {
229
+ replacer,
230
+ casing
231
+ }),
232
+ params: toParamsObject(path, {
233
+ replacer,
234
+ casing
235
+ })
284
236
  };
285
237
  if (stringify) {
286
238
  if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
@@ -289,50 +241,6 @@ var URLPath = class {
289
241
  }
290
242
  return object;
291
243
  }
292
- /**
293
- * Converts the OpenAPI path to a TypeScript template literal string.
294
- * An optional `replacer` can transform each extracted parameter name before interpolation.
295
- *
296
- * @example
297
- * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
298
- */
299
- toTemplateString({ prefix, replacer } = {}) {
300
- const result = this.path.split(/\{([^}]+)\}/).map((part, i) => {
301
- if (i % 2 === 0) return part;
302
- const param = this.#transformParam(part);
303
- return `\${${replacer ? replacer(param) : param}}`;
304
- }).join("");
305
- return `\`${prefix ?? ""}${result}\``;
306
- }
307
- /**
308
- * Extracts all `{param}` segments from the path and returns them as a key-value map.
309
- * An optional `replacer` transforms each parameter name in both key and value positions.
310
- * Returns `undefined` when no path parameters are found.
311
- *
312
- * @example
313
- * ```ts
314
- * new URLPath('/pet/{petId}/tag/{tagId}').toParamsObject()
315
- * // { petId: 'petId', tagId: 'tagId' }
316
- * ```
317
- */
318
- toParamsObject(replacer) {
319
- const params = {};
320
- this.#eachParam((_raw, param) => {
321
- const key = replacer ? replacer(param) : param;
322
- params[key] = key;
323
- });
324
- return Object.keys(params).length > 0 ? params : null;
325
- }
326
- /** Converts the OpenAPI path to Express-style colon syntax.
327
- *
328
- * @example
329
- * ```ts
330
- * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
331
- * ```
332
- */
333
- toURLPath() {
334
- return this.path.replace(/\{([^}]+)\}/g, ":$1");
335
- }
336
244
  };
337
245
  //#endregion
338
246
  //#region ../../internals/shared/src/operation.ts
@@ -358,7 +266,7 @@ function operationFileEntry(node, name, extname = ".ts") {
358
266
  function getOperationLink(node, link) {
359
267
  if (!link) return null;
360
268
  if (typeof link === "function") return link(node) ?? null;
361
- if (link === "urlPath") return node.path ? `{@link ${new URLPath(node.path).URL}}` : null;
269
+ if (link === "urlPath") return node.path ? `{@link ${Url.toPath(node.path)}}` : null;
362
270
  return node.path ? `{@link ${node.path.replaceAll("{", ":").replaceAll("}", "")}}` : null;
363
271
  }
364
272
  function getContentTypeInfo(node) {
@@ -424,6 +332,19 @@ function resolveSuccessNames(node, resolver) {
424
332
  function resolveStatusCodeNames(node, resolver) {
425
333
  return node.responses.map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
426
334
  }
335
+ /**
336
+ * Builds the discriminated union type string for `dataReturnType: 'full'` return shapes.
337
+ * Each member is `{ status: N; data: StatusNType; statusText: string }`.
338
+ */
339
+ function buildStatusUnionType(node, resolver) {
340
+ const members = node.responses.map((r) => {
341
+ const typeName = resolver.resolveResponseStatusName(node, r.statusCode);
342
+ const statusCode = Number.parseInt(r.statusCode, 10);
343
+ return `{ status: ${Number.isNaN(statusCode) ? "number" : String(statusCode)}; data: ${typeName}; statusText: string }`;
344
+ });
345
+ if (members.length === 1) return members[0];
346
+ return `(${members.join(" | ")})`;
347
+ }
427
348
  const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
428
349
  function resolveOperationTypeNames(node, resolver, options = {}) {
429
350
  const cacheKey = `${node.operationId}\0${options.paramsCasing ?? ""}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${(options.exclude ?? []).join(",")}`;
@@ -459,9 +380,9 @@ function resolveOperationTypeNames(node, resolver, options = {}) {
459
380
  //#endregion
460
381
  //#region ../../internals/tanstack-query/src/components/MutationKey.tsx
461
382
  const declarationPrinter$7 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
462
- const mutationKeyTransformer = ({ node, casing }) => {
383
+ const mutationKeyTransformer = ({ node }) => {
463
384
  if (!node.path) return [];
464
- return [`{ url: '${new URLPath(node.path, { casing }).toURLPath()}' }`];
385
+ return [`{ url: '${Url.toPath(node.path)}' }`];
465
386
  };
466
387
  function MutationKey({ name, paramsCasing, node, transformer }) {
467
388
  const paramsNode = _kubb_core.ast.createFunctionParameters({ params: [] });
@@ -486,13 +407,73 @@ function MutationKey({ name, paramsCasing, node, transformer }) {
486
407
  //#endregion
487
408
  //#region ../../internals/tanstack-query/src/utils.ts
488
409
  /**
489
- * Collects the Zod schema import names for an operation (response + request body).
410
+ * Builds the shared `(…params, config = {})` parameter list for a TanStack
411
+ * query-options function. The trailing `config` parameter is typed as a partial
412
+ * `RequestConfig` with an optional `client`. Framework plugins wrap the result
413
+ * when needed, for example vue-query applies `MaybeRefOrGetter`.
414
+ */
415
+ function buildQueryOptionsParams(node, options) {
416
+ const { paramsType, paramsCasing, pathParamsType, resolver } = options;
417
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
418
+ return _kubb_core.ast.createOperationParams(node, {
419
+ paramsType,
420
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
421
+ paramsCasing,
422
+ resolver,
423
+ extraParams: [_kubb_core.ast.createFunctionParameter({
424
+ name: "config",
425
+ type: _kubb_core.ast.createParamsType({
426
+ variant: "reference",
427
+ name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
428
+ }),
429
+ default: "{}"
430
+ })]
431
+ });
432
+ }
433
+ /**
434
+ * Returns `'zod'` when response-direction parsing is enabled.
435
+ * The string shorthand `'zod'` also enables response parsing.
436
+ */
437
+ function resolveResponseParser(parser) {
438
+ if (!parser) return null;
439
+ if (parser === "zod") return "zod";
440
+ return parser.response ?? null;
441
+ }
442
+ /**
443
+ * Returns `'zod'` when request body parsing is enabled.
444
+ * The string shorthand `'zod'` also enables request body parsing (existing behavior).
445
+ */
446
+ function resolveRequestParser(parser) {
447
+ if (!parser) return null;
448
+ if (parser === "zod") return "zod";
449
+ return parser.request ?? null;
450
+ }
451
+ /**
452
+ * Returns `'zod'` when query-params parsing is enabled.
453
+ * Only the object form `{ request: 'zod' }` enables this. `parser: 'zod'` does not.
454
+ */
455
+ function resolveQueryParamsParser(parser) {
456
+ if (!parser || parser === "zod") return null;
457
+ return parser.request ?? null;
458
+ }
459
+ /**
460
+ * Collects the Zod schema import names for an operation based on the active parser directions.
461
+ *
462
+ * - `parser: 'zod'`: response and request body names (backward-compatible behavior).
463
+ * - `parser: { request: 'zod' }`: request body and query params names.
464
+ * - `parser: { response: 'zod' }`: response name only.
465
+ * - `parser: { request: 'zod', response: 'zod' }`: all three.
490
466
  *
491
- * Returns an empty array when no resolver is provided or the operation has no request body schema.
467
+ * Returns an empty array when no resolver is provided or `parser` is falsy.
492
468
  */
493
- function resolveZodSchemaNames(node, zodResolver) {
494
- if (!zodResolver) return [];
495
- return [zodResolver.resolveResponseName?.(node), node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : null].filter((n) => Boolean(n));
469
+ function resolveZodSchemaNames(node, zodResolver, parser) {
470
+ if (!zodResolver || !parser) return [];
471
+ const { query: queryParams } = getOperationParameters(node);
472
+ return [
473
+ resolveResponseParser(parser) === "zod" ? zodResolver.resolveResponseName?.(node) : null,
474
+ resolveRequestParser(parser) === "zod" && node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : null,
475
+ resolveQueryParamsParser(parser) === "zod" && queryParams.length > 0 ? zodResolver.resolveQueryParamsName?.(node, queryParams[0]) : null
476
+ ].filter((n) => Boolean(n));
496
477
  }
497
478
  /**
498
479
  * Resolve the type for a single path parameter.
@@ -650,13 +631,13 @@ function markParamsOptional(paramsNode, names) {
650
631
  (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
651
632
  const queryKeyTransformer = ({ node, casing }) => {
652
633
  if (!node.path) return [];
653
- const path = new URLPath(node.path, { casing });
654
634
  const hasQueryParams = getOperationParameters(node).query.length > 0;
655
635
  const hasRequestBody = !!node.requestBody?.content?.[0]?.schema;
656
636
  return [
657
- path.toObject({
637
+ Url.toObject(node.path, {
658
638
  type: "path",
659
- stringify: true
639
+ stringify: true,
640
+ casing
660
641
  }),
661
642
  hasQueryParams ? "...(params ? [params] : [])" : null,
662
643
  hasRequestBody ? "...(data ? [data] : [])" : null
@@ -748,28 +729,13 @@ function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeNa
748
729
  const declarationPrinter$4 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
749
730
  const callPrinter$4 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
750
731
  function getQueryOptionsParams(node, options) {
751
- const { paramsType, paramsCasing, pathParamsType, resolver } = options;
752
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
753
- return wrapWithMaybeRefOrGetter(_kubb_core.ast.createOperationParams(node, {
754
- paramsType,
755
- pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
756
- paramsCasing,
757
- resolver,
758
- extraParams: [_kubb_core.ast.createFunctionParameter({
759
- name: "config",
760
- type: _kubb_core.ast.createParamsType({
761
- variant: "reference",
762
- name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
763
- }),
764
- default: "{}"
765
- })]
766
- }), (name) => name === "config");
732
+ return wrapWithMaybeRefOrGetter(buildQueryOptionsParams(node, options), (name) => name === "config");
767
733
  }
768
734
  function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
769
735
  const successNames = resolveSuccessNames(node, tsResolver);
770
736
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
771
737
  const errorNames = resolveErrorNames(node, tsResolver);
772
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
738
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
773
739
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
774
740
  const queryKeyParamsNode = buildQueryKeyParamsNode(node, {
775
741
  pathParamsType,
@@ -797,8 +763,7 @@ function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, para
797
763
  params: paramsSignature,
798
764
  children: `
799
765
  const queryKey = ${queryKeyName}(${queryKeyParamsCall})
800
- return queryOptions<${TData}, ${TError}, ${TData}>({
801
- ${enabledText}
766
+ return queryOptions<${TData}, ${TError}, ${TData}>({${enabledText ? `\n ${enabledText}` : ""}
802
767
  queryKey,
803
768
  queryFn: async ({ signal }) => {
804
769
  return ${clientName}(${addToValueCalls$1(clientCallStr, enabledNames)})
@@ -839,7 +804,7 @@ function buildInfiniteQueryParamsNode(node, options) {
839
804
  const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
840
805
  const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
841
806
  const errorNames = resolveErrorNames(node, resolver);
842
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
807
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, resolver);
843
808
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
844
809
  const optionsParam = _kubb_core.ast.createFunctionParameter({
845
810
  name: "options",
@@ -870,7 +835,7 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
870
835
  const successNames = resolveSuccessNames(node, tsResolver);
871
836
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
872
837
  const errorNames = resolveErrorNames(node, tsResolver);
873
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
838
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
874
839
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
875
840
  const returnType = `UseInfiniteQueryReturnType<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
876
841
  const generics = [
@@ -935,7 +900,7 @@ const callPrinter$2 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
935
900
  function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
936
901
  const successNames = resolveSuccessNames(node, tsResolver);
937
902
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
938
- const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
903
+ const queryFnDataType = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
939
904
  const errorNames = resolveErrorNames(node, tsResolver);
940
905
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
941
906
  const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
@@ -969,8 +934,8 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
969
934
  const hasNewParams = nextParam != null || previousParam != null;
970
935
  const [getNextPageParamExpr, getPreviousPageParamExpr] = (() => {
971
936
  if (hasNewParams) {
972
- const nextAccessor = nextParam ? getNestedAccessor(nextParam, "lastPage") : null;
973
- const prevAccessor = previousParam ? getNestedAccessor(previousParam, "firstPage") : null;
937
+ const nextAccessor = nextParam ? (0, _kubb_ast_utils.getNestedAccessor)(nextParam, "lastPage") : null;
938
+ const prevAccessor = previousParam ? (0, _kubb_ast_utils.getNestedAccessor)(previousParam, "firstPage") : null;
974
939
  return [nextAccessor ? `getNextPageParam: (lastPage) => ${nextAccessor}` : null, prevAccessor ? `getPreviousPageParam: (firstPage) => ${prevAccessor}` : null];
975
940
  }
976
941
  if (cursorParam) return [`getNextPageParam: (lastPage) => lastPage['${cursorParam}']`, `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`];
@@ -981,11 +946,10 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
981
946
  getNextPageParamExpr,
982
947
  getPreviousPageParamExpr
983
948
  ].filter(Boolean);
984
- const infiniteOverrideParams = queryParam && queryParamsTypeName ? `
985
- params = {
986
- ...(params ?? {}),
987
- ['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
988
- } as ${queryParamsTypeName}` : "";
949
+ const infiniteOverrideParams = queryParam && queryParamsTypeName ? `params = {
950
+ ...(params ?? {}),
951
+ ['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
952
+ } as ${queryParamsTypeName}` : "";
989
953
  if (infiniteOverrideParams) return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
990
954
  name,
991
955
  isExportable: true,
@@ -995,16 +959,15 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
995
959
  export: true,
996
960
  params: paramsSignature,
997
961
  children: `
998
- const queryKey = ${queryKeyName}(${queryKeyParamsCall})
999
- return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, QueryKey, ${pageParamType}>({
1000
- ${enabledText}
1001
- queryKey,
1002
- queryFn: async ({ signal, pageParam }) => {
1003
- ${infiniteOverrideParams}
1004
- return ${clientName}(${addToValueCalls(clientCallStr, enabledNames)})
1005
- },
1006
- ${queryOptionsArr.join(",\n")}
1007
- })
962
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
963
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, QueryKey, ${pageParamType}>({${enabledText ? `\n ${enabledText}` : ""}
964
+ queryKey,
965
+ queryFn: async ({ signal, pageParam }) => {
966
+ ${infiniteOverrideParams}
967
+ return ${clientName}(${addToValueCalls(clientCallStr, enabledNames)})
968
+ },
969
+ ${queryOptionsArr.join(",\n ")}
970
+ })
1008
971
  `
1009
972
  })
1010
973
  });
@@ -1017,15 +980,14 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
1017
980
  export: true,
1018
981
  params: paramsSignature,
1019
982
  children: `
1020
- const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1021
- return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, QueryKey, ${pageParamType}>({
1022
- ${enabledText}
1023
- queryKey,
1024
- queryFn: async ({ signal }) => {
1025
- return ${clientName}(${addToValueCalls(clientCallStr, enabledNames)})
1026
- },
1027
- ${queryOptionsArr.join(",\n")}
1028
- })
983
+ const queryKey = ${queryKeyName}(${queryKeyParamsCall})
984
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, QueryKey, ${pageParamType}>({${enabledText ? `\n ${enabledText}` : ""}
985
+ queryKey,
986
+ queryFn: async ({ signal }) => {
987
+ return ${clientName}(${addToValueCalls(clientCallStr, enabledNames)})
988
+ },
989
+ ${queryOptionsArr.join(",\n ")}
990
+ })
1029
991
  `
1030
992
  })
1031
993
  });
@@ -1061,7 +1023,7 @@ function buildMutationParamsNode(node, options) {
1061
1023
  const successNames = resolveSuccessNames(node, resolver);
1062
1024
  const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
1063
1025
  const errorNames = resolveErrorNames(node, resolver);
1064
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1026
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, resolver);
1065
1027
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1066
1028
  const wrappedParamsNode = wrapWithMaybeRefOrGetter(createMutationArgParams(node, {
1067
1029
  paramsCasing,
@@ -1089,7 +1051,7 @@ function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType,
1089
1051
  const successNames = resolveSuccessNames(node, tsResolver);
1090
1052
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1091
1053
  const errorNames = resolveErrorNames(node, tsResolver);
1092
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1054
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
1093
1055
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1094
1056
  const mutationArgParamsNode = createMutationArgParams(node, {
1095
1057
  paramsCasing,
@@ -1163,7 +1125,7 @@ function buildQueryParamsNode(node, options) {
1163
1125
  const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
1164
1126
  const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
1165
1127
  const errorNames = resolveErrorNames(node, resolver);
1166
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1128
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, resolver);
1167
1129
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1168
1130
  const optionsParam = _kubb_core.ast.createFunctionParameter({
1169
1131
  name: "options",
@@ -1194,7 +1156,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
1194
1156
  const successNames = resolveSuccessNames(node, tsResolver);
1195
1157
  const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1196
1158
  const errorNames = resolveErrorNames(node, tsResolver);
1197
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1159
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
1198
1160
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1199
1161
  const returnType = `UseQueryReturnType<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
1200
1162
  const generics = [
@@ -1350,4 +1312,4 @@ Object.defineProperty(exports, "resolveZodSchemaNames", {
1350
1312
  }
1351
1313
  });
1352
1314
 
1353
- //# sourceMappingURL=components-BwFPMwK7.cjs.map
1315
+ //# sourceMappingURL=components-D3xIZ9FA.cjs.map