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

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 (49) hide show
  1. package/README.md +38 -91
  2. package/dist/{components-dAKJEn9b.cjs → components-DQAYLQW0.cjs} +409 -279
  3. package/dist/components-DQAYLQW0.cjs.map +1 -0
  4. package/dist/{components-DTGLu4UV.js → components-IArDg-DO.js} +379 -279
  5. package/dist/components-IArDg-DO.js.map +1 -0
  6. package/dist/components.cjs +1 -1
  7. package/dist/components.d.ts +5 -77
  8. package/dist/components.js +1 -1
  9. package/dist/{generators-C_fbcjpG.js → generators-B86BJkmW.js} +346 -419
  10. package/dist/generators-B86BJkmW.js.map +1 -0
  11. package/dist/{generators-CWEQsdO9.cjs → generators-BqGaMUH6.cjs} +344 -417
  12. package/dist/generators-BqGaMUH6.cjs.map +1 -0
  13. package/dist/generators.cjs +1 -1
  14. package/dist/generators.d.ts +49 -10
  15. package/dist/generators.js +1 -1
  16. package/dist/index.cjs +176 -26
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +32 -4
  19. package/dist/index.js +177 -27
  20. package/dist/index.js.map +1 -1
  21. package/dist/types-Dh4HNR9K.d.ts +400 -0
  22. package/extension.yaml +910 -364
  23. package/package.json +15 -17
  24. package/src/components/InfiniteQuery.tsx +24 -13
  25. package/src/components/InfiniteQueryOptions.tsx +37 -55
  26. package/src/components/Mutation.tsx +35 -15
  27. package/src/components/MutationOptions.tsx +14 -13
  28. package/src/components/Query.tsx +14 -10
  29. package/src/components/QueryOptions.tsx +17 -34
  30. package/src/components/SuspenseInfiniteQuery.tsx +19 -13
  31. package/src/components/SuspenseInfiniteQueryOptions.tsx +28 -52
  32. package/src/components/SuspenseQuery.tsx +9 -10
  33. package/src/generators/customHookOptionsFileGenerator.tsx +18 -14
  34. package/src/generators/hookOptionsGenerator.tsx +44 -51
  35. package/src/generators/infiniteQueryGenerator.tsx +57 -78
  36. package/src/generators/mutationGenerator.tsx +53 -64
  37. package/src/generators/queryGenerator.tsx +54 -63
  38. package/src/generators/suspenseInfiniteQueryGenerator.tsx +52 -65
  39. package/src/generators/suspenseQueryGenerator.tsx +56 -76
  40. package/src/plugin.ts +45 -31
  41. package/src/resolvers/resolverReactQuery.ts +102 -6
  42. package/src/types.ts +199 -61
  43. package/src/utils.ts +10 -33
  44. package/dist/components-DTGLu4UV.js.map +0 -1
  45. package/dist/components-dAKJEn9b.cjs.map +0 -1
  46. package/dist/generators-CWEQsdO9.cjs.map +0 -1
  47. package/dist/generators-C_fbcjpG.js.map +0 -1
  48. package/dist/types-DfaFRSBf.d.ts +0 -284
  49. /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
@@ -253,16 +253,16 @@ var URLPath = class {
253
253
  get object() {
254
254
  return this.toObject();
255
255
  }
256
- /** Returns a map of path parameter names, or `undefined` when the path has no parameters.
256
+ /** Returns a map of path parameter names, or `null` when the path has no parameters.
257
257
  *
258
258
  * @example
259
259
  * ```ts
260
260
  * new URLPath('/pet/{petId}').params // { petId: 'petId' }
261
- * new URLPath('/pet').params // undefined
261
+ * new URLPath('/pet').params // null
262
262
  * ```
263
263
  */
264
264
  get params() {
265
- return this.getParams();
265
+ return this.toParamsObject();
266
266
  }
267
267
  #transformParam(raw) {
268
268
  const param = isValidVarName(raw) ? raw : camelCase(raw);
@@ -280,7 +280,7 @@ var URLPath = class {
280
280
  toObject({ type = "path", replacer, stringify } = {}) {
281
281
  const object = {
282
282
  url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
283
- params: this.getParams()
283
+ params: this.toParamsObject()
284
284
  };
285
285
  if (stringify) {
286
286
  if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
@@ -296,12 +296,13 @@ var URLPath = class {
296
296
  * @example
297
297
  * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
298
298
  */
299
- toTemplateString({ prefix = "", replacer } = {}) {
300
- return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
299
+ toTemplateString({ prefix, replacer } = {}) {
300
+ const result = this.path.split(/\{([^}]+)\}/).map((part, i) => {
301
301
  if (i % 2 === 0) return part;
302
302
  const param = this.#transformParam(part);
303
303
  return `\${${replacer ? replacer(param) : param}}`;
304
- }).join("")}\``;
304
+ }).join("");
305
+ return `\`${prefix ?? ""}${result}\``;
305
306
  }
306
307
  /**
307
308
  * Extracts all `{param}` segments from the path and returns them as a key-value map.
@@ -310,17 +311,17 @@ var URLPath = class {
310
311
  *
311
312
  * @example
312
313
  * ```ts
313
- * new URLPath('/pet/{petId}/tag/{tagId}').getParams()
314
+ * new URLPath('/pet/{petId}/tag/{tagId}').toParamsObject()
314
315
  * // { petId: 'petId', tagId: 'tagId' }
315
316
  * ```
316
317
  */
317
- getParams(replacer) {
318
+ toParamsObject(replacer) {
318
319
  const params = {};
319
320
  this.#eachParam((_raw, param) => {
320
321
  const key = replacer ? replacer(param) : param;
321
322
  params[key] = key;
322
323
  });
323
- return Object.keys(params).length > 0 ? params : void 0;
324
+ return Object.keys(params).length > 0 ? params : null;
324
325
  }
325
326
  /** Converts the OpenAPI path to Express-style colon syntax.
326
327
  *
@@ -334,19 +335,138 @@ var URLPath = class {
334
335
  }
335
336
  };
336
337
  //#endregion
338
+ //#region ../../internals/shared/src/operation.ts
339
+ /**
340
+ * Builds the `ResolverFileParams` every operation generator passes to
341
+ * `resolver.resolveFile`: a file named `name`, tagged by the operation's first
342
+ * tag (or `'default'`), at the operation's path. Centralizes the entry object
343
+ * that was repeated at dozens of call sites across the client and query plugins.
344
+ *
345
+ * @example
346
+ * ```ts
347
+ * resolver.resolveFile(operationFileEntry(node, node.operationId), { root, output, group })
348
+ * ```
349
+ */
350
+ function operationFileEntry(node, name, extname = ".ts") {
351
+ return {
352
+ name,
353
+ extname,
354
+ tag: node.tags[0] ?? "default",
355
+ path: node.path
356
+ };
357
+ }
358
+ function getOperationLink(node, link) {
359
+ if (!link) return null;
360
+ if (typeof link === "function") return link(node) ?? null;
361
+ if (link === "urlPath") return node.path ? `{@link ${new URLPath(node.path).URL}}` : null;
362
+ return node.path ? `{@link ${node.path.replaceAll("{", ":").replaceAll("}", "")}}` : null;
363
+ }
364
+ function getContentTypeInfo(node) {
365
+ const contentTypes = node.requestBody?.content?.map((e) => e.contentType) ?? [];
366
+ const isMultipleContentTypes = contentTypes.length > 1;
367
+ return {
368
+ contentTypes,
369
+ isMultipleContentTypes,
370
+ contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(" | ") : "",
371
+ defaultContentType: contentTypes[0] ?? "application/json",
372
+ hasFormData: contentTypes.some((ct) => ct === "multipart/form-data")
373
+ };
374
+ }
375
+ function buildRequestConfigType(node, resolver) {
376
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
377
+ const { isMultipleContentTypes, contentTypeUnion } = getContentTypeInfo(node);
378
+ return `${requestName ? `Partial<RequestConfig<${requestName}>>` : "Partial<RequestConfig>"} & { ${["client?: Client", isMultipleContentTypes ? `contentType?: ${contentTypeUnion}` : null].filter(Boolean).join("; ")} }`;
379
+ }
380
+ function buildOperationComments(node, options = {}) {
381
+ const { link = "pathTemplate", linkPosition = "afterDeprecated", splitLines = false } = options;
382
+ const linkComment = getOperationLink(node, link);
383
+ const filteredComments = (linkPosition === "beforeDeprecated" ? [
384
+ node.description && `@description ${node.description}`,
385
+ node.summary && `@summary ${node.summary}`,
386
+ linkComment,
387
+ node.deprecated && "@deprecated"
388
+ ] : [
389
+ node.description && `@description ${node.description}`,
390
+ node.summary && `@summary ${node.summary}`,
391
+ node.deprecated && "@deprecated",
392
+ linkComment
393
+ ]).filter((comment) => Boolean(comment));
394
+ if (!splitLines) return filteredComments;
395
+ return filteredComments.flatMap((text) => text.split(/\r?\n/).map((line) => line.trim())).filter((comment) => Boolean(comment));
396
+ }
397
+ function getOperationParameters(node, options = {}) {
398
+ const params = _kubb_core.ast.caseParams(node.parameters, options.paramsCasing);
399
+ return {
400
+ path: params.filter((param) => param.in === "path"),
401
+ query: params.filter((param) => param.in === "query"),
402
+ header: params.filter((param) => param.in === "header"),
403
+ cookie: params.filter((param) => param.in === "cookie")
404
+ };
405
+ }
406
+ function getStatusCodeNumber(statusCode) {
407
+ const code = Number(statusCode);
408
+ return Number.isNaN(code) ? null : code;
409
+ }
410
+ function isSuccessStatusCode(statusCode) {
411
+ const code = getStatusCodeNumber(statusCode);
412
+ return code !== null && code >= 200 && code < 300;
413
+ }
414
+ function isErrorStatusCode(statusCode) {
415
+ const code = getStatusCodeNumber(statusCode);
416
+ return code !== null && code >= 400;
417
+ }
418
+ function resolveErrorNames(node, resolver) {
419
+ return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
420
+ }
421
+ function resolveSuccessNames(node, resolver) {
422
+ return node.responses.filter((response) => isSuccessStatusCode(response.statusCode)).map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
423
+ }
424
+ function resolveStatusCodeNames(node, resolver) {
425
+ return node.responses.map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
426
+ }
427
+ const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
428
+ function resolveOperationTypeNames(node, resolver, options = {}) {
429
+ const cacheKey = `${node.operationId}\0${options.paramsCasing ?? ""}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${(options.exclude ?? []).join(",")}`;
430
+ let byResolver = typeNamesByResolver.get(resolver);
431
+ if (byResolver) {
432
+ const cached = byResolver.get(cacheKey);
433
+ if (cached) return cached;
434
+ } else {
435
+ byResolver = /* @__PURE__ */ new Map();
436
+ typeNamesByResolver.set(resolver, byResolver);
437
+ }
438
+ const { path, query, header } = getOperationParameters(node, { paramsCasing: options.paramsCasing });
439
+ const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
440
+ const exclude = new Set(options.exclude ?? []);
441
+ const paramNames = [
442
+ ...path.map((param) => resolver.resolvePathParamsName(node, param)),
443
+ ...query.map((param) => resolver.resolveQueryParamsName(node, param)),
444
+ ...header.map((param) => resolver.resolveHeaderParamsName(node, param))
445
+ ];
446
+ const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null, resolver.resolveResponseName(node)];
447
+ const result = (options.order === "body-response-first" ? [
448
+ ...bodyAndResponseNames,
449
+ ...paramNames,
450
+ ...responseStatusNames
451
+ ] : [
452
+ ...paramNames,
453
+ ...bodyAndResponseNames,
454
+ ...responseStatusNames
455
+ ]).filter((name) => Boolean(name) && !exclude.has(name));
456
+ byResolver.set(cacheKey, result);
457
+ return result;
458
+ }
459
+ //#endregion
337
460
  //#region ../../internals/tanstack-query/src/components/MutationKey.tsx
338
461
  const declarationPrinter$10 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
339
- function getParams$6() {
340
- return _kubb_core.ast.createFunctionParameters({ params: [] });
341
- }
342
- __name(getParams$6, "getParams");
343
- const getTransformer$1 = /* @__PURE__ */ __name(({ node, casing }) => {
462
+ const mutationKeyTransformer = ({ node, casing }) => {
463
+ if (!node.path) return [];
344
464
  return [`{ url: '${new URLPath(node.path, { casing }).toURLPath()}' }`];
345
- }, "getTransformer");
346
- function MutationKey({ name, paramsCasing, node, transformer = getTransformer$1 }) {
347
- const paramsNode = getParams$6();
465
+ };
466
+ function MutationKey({ name, paramsCasing, node, transformer }) {
467
+ const paramsNode = _kubb_core.ast.createFunctionParameters({ params: [] });
348
468
  const paramsSignature = declarationPrinter$10.print(paramsNode) ?? "";
349
- const keys = transformer({
469
+ const keys = (transformer ?? mutationKeyTransformer)({
350
470
  node,
351
471
  casing: paramsCasing
352
472
  });
@@ -363,28 +483,38 @@ function MutationKey({ name, paramsCasing, node, transformer = getTransformer$1
363
483
  })
364
484
  });
365
485
  }
366
- MutationKey.getParams = getParams$6;
367
- MutationKey.getTransformer = getTransformer$1;
368
486
  //#endregion
369
487
  //#region ../../internals/tanstack-query/src/utils.ts
488
+ function matchesPattern(node, ov) {
489
+ const { type, pattern } = ov;
490
+ const matches = (value) => typeof pattern === "string" ? value === pattern : pattern.test(value);
491
+ if (type === "operationId") return matches(node.operationId);
492
+ if (type === "tag") return node.tags.some((t) => matches(t));
493
+ if (type === "path") return node.path !== void 0 && matches(node.path);
494
+ if (type === "method") return node.method !== void 0 && matches(node.method);
495
+ return false;
496
+ }
370
497
  /**
371
- * Build JSDoc comment lines from an OperationNode.
498
+ * Resolves per-operation overrides (first matching override wins).
499
+ *
500
+ * @example
501
+ * ```ts
502
+ * const opts = resolveOperationOverrides(node, override)
503
+ * const queryOpts = 'query' in opts ? opts.query : defaultQuery
504
+ * ```
372
505
  */
373
- function getComments(node) {
374
- return [
375
- node.description && `@description ${node.description}`,
376
- node.summary && `@summary ${node.summary}`,
377
- node.deprecated && "@deprecated",
378
- `{@link ${node.path.replaceAll("{", ":").replaceAll("}", "")}}`
379
- ].filter((x) => Boolean(x));
506
+ function resolveOperationOverrides(node, override) {
507
+ if (!override) return {};
508
+ return override.find((ov) => matchesPattern(node, ov))?.options ?? {};
380
509
  }
381
510
  /**
382
- * Resolve error type names from operation responses.
511
+ * Collects the Zod schema import names for an operation (response + request body).
512
+ *
513
+ * Returns an empty array when no resolver is provided or the operation has no request body schema.
383
514
  */
384
- function resolveErrorNames(node, tsResolver) {
385
- return node.responses.filter((r) => {
386
- return Number.parseInt(r.statusCode, 10) >= 400;
387
- }).map((r) => tsResolver.resolveResponseStatusName(node, r.statusCode));
515
+ function resolveZodSchemaNames(node, zodResolver) {
516
+ if (!zodResolver) return [];
517
+ return [zodResolver.resolveResponseName?.(node), node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : null].filter((n) => Boolean(n));
388
518
  }
389
519
  /**
390
520
  * Resolve the type for a single path parameter.
@@ -408,30 +538,14 @@ function resolvePathParamType(node, param, resolver) {
408
538
  }
409
539
  /**
410
540
  * Derive a query-params group type from the resolver.
411
- * Returns `undefined` when no query params exist or when the group name
541
+ * Returns `null` when no query params exist or when the group name
412
542
  * equals the individual param name (no real group).
413
543
  */
414
544
  function resolveQueryGroupType(node, params, resolver) {
415
- if (!params.length) return void 0;
545
+ if (!params.length) return null;
416
546
  const firstParam = params[0];
417
547
  const groupName = resolver.resolveQueryParamsName(node, firstParam);
418
- if (groupName === resolver.resolveParamName(node, firstParam)) return void 0;
419
- return {
420
- type: _kubb_core.ast.createParamsType({
421
- variant: "reference",
422
- name: groupName
423
- }),
424
- optional: params.every((p) => !p.required)
425
- };
426
- }
427
- /**
428
- * Derive a header-params group type from the resolver.
429
- */
430
- function resolveHeaderGroupType(node, params, resolver) {
431
- if (!params.length) return void 0;
432
- const firstParam = params[0];
433
- const groupName = resolver.resolveHeaderParamsName(node, firstParam);
434
- if (groupName === resolver.resolveParamName(node, firstParam)) return void 0;
548
+ if (groupName === resolver.resolveParamName(node, firstParam)) return null;
435
549
  return {
436
550
  type: _kubb_core.ast.createParamsType({
437
551
  variant: "reference",
@@ -481,7 +595,7 @@ function buildQueryKeyParams(node, options) {
481
595
  const bodyType = node.requestBody?.content?.[0]?.schema ? _kubb_core.ast.createParamsType({
482
596
  variant: "reference",
483
597
  name: resolver.resolveDataName(node)
484
- }) : void 0;
598
+ }) : null;
485
599
  const bodyRequired = node.requestBody?.required ?? false;
486
600
  const params = [];
487
601
  if (pathParams.length) {
@@ -506,66 +620,101 @@ function buildQueryKeyParams(node, options) {
506
620
  return _kubb_core.ast.createFunctionParameters({ params });
507
621
  }
508
622
  /**
509
- * Build mutation arg params for paramsToTrigger mode.
510
- * Contains pathParams + data + queryParams + headers (all flattened, for type alias).
623
+ * Collect the names of the required params (no default) that drive the `enabled`
624
+ * guard. These are exactly the params that should be made optional in the
625
+ * generated signatures so callers can pass `undefined` to reach the disabled state.
511
626
  */
512
- function buildMutationArgParams(node, options) {
513
- const { paramsCasing, resolver } = options;
514
- const casedParams = _kubb_core.ast.caseParams(node.parameters, paramsCasing);
515
- const pathParams = casedParams.filter((p) => p.in === "path");
516
- const queryParams = casedParams.filter((p) => p.in === "query");
517
- const headerParams = casedParams.filter((p) => p.in === "header");
518
- const queryGroupType = resolveQueryGroupType(node, queryParams, resolver);
519
- const headerGroupType = resolveHeaderGroupType(node, headerParams, resolver);
520
- const bodyType = node.requestBody?.content?.[0]?.schema ? _kubb_core.ast.createParamsType({
521
- variant: "reference",
522
- name: resolver.resolveDataName(node)
523
- }) : void 0;
524
- const bodyRequired = node.requestBody?.required ?? false;
525
- const params = [];
526
- for (const p of pathParams) params.push(_kubb_core.ast.createFunctionParameter({
527
- name: p.name,
528
- type: resolvePathParamType(node, p, resolver),
529
- optional: !p.required
530
- }));
531
- if (bodyType) params.push(_kubb_core.ast.createFunctionParameter({
532
- name: "data",
533
- type: bodyType,
534
- optional: !bodyRequired
535
- }));
536
- params.push(...buildGroupParam("params", node, queryParams, queryGroupType, resolver));
537
- params.push(...buildGroupParam("headers", node, headerParams, headerGroupType, resolver));
627
+ function getEnabledParamNames(paramsNode) {
628
+ const required = [];
629
+ for (const param of paramsNode.params) if ("kind" in param && param.kind === "ParameterGroup") {
630
+ const group = param;
631
+ for (const child of group.properties) if (!child.optional && child.default === void 0) required.push(child.name);
632
+ } else {
633
+ const fp = param;
634
+ if (!fp.optional && fp.default === void 0) required.push(fp.name);
635
+ }
636
+ return required;
637
+ }
638
+ /**
639
+ * Return a copy of `paramsNode` with the named params marked optional.
640
+ *
641
+ * Used to align signatures with the `enabled` guard: the guard already disables
642
+ * the query while a param is falsy, so the param should accept `undefined`. The
643
+ * change is type-only the `queryFn` keeps calling the client with a non-null
644
+ * assertion (see `injectNonNullAssertions`), so the emitted runtime is unchanged.
645
+ */
646
+ function markParamsOptional(paramsNode, names) {
647
+ if (names.length === 0) return paramsNode;
648
+ const nameSet = new Set(names);
649
+ const params = paramsNode.params.map((param) => {
650
+ if ("kind" in param && param.kind === "ParameterGroup") {
651
+ const group = param;
652
+ return {
653
+ ...group,
654
+ properties: group.properties.map((child) => nameSet.has(child.name) ? _kubb_core.ast.createFunctionParameter({
655
+ name: child.name,
656
+ type: child.type,
657
+ rest: child.rest,
658
+ optional: true
659
+ }) : child)
660
+ };
661
+ }
662
+ const fp = param;
663
+ return nameSet.has(fp.name) ? _kubb_core.ast.createFunctionParameter({
664
+ name: fp.name,
665
+ type: fp.type,
666
+ rest: fp.rest,
667
+ optional: true
668
+ }) : fp;
669
+ });
538
670
  return _kubb_core.ast.createFunctionParameters({ params });
539
671
  }
672
+ /**
673
+ * Add a non-null assertion (`!`) to the named params inside a printed client-call
674
+ * string. Bridges the type gap created by `markParamsOptional` while keeping the
675
+ * runtime identical (the `!` is erased at compile time).
676
+ *
677
+ * Handles destructured shorthand groups (`{ petId }` → `{ petId: petId! }`) and
678
+ * standalone identifiers (`params` → `params!`).
679
+ */
680
+ function injectNonNullAssertions(callStr, names) {
681
+ if (names.length === 0) return callStr;
682
+ const nameSet = new Set(names);
683
+ let result = callStr.replace(/\{\s*([\w,\s]+)\s*\}(?=\s*,)/g, (match, inner) => {
684
+ if (inner.includes(":") || inner.includes("...")) return match;
685
+ const keys = inner.split(",").map((k) => k.trim()).filter(Boolean);
686
+ if (!keys.some((k) => nameSet.has(k))) return match;
687
+ return `{ ${keys.map((k) => nameSet.has(k) ? `${k}: ${k}!` : k).join(", ")} }`;
688
+ });
689
+ result = result.replace(/(?<![{.:?])\b(\w+)\b(?=\s*,)/g, (match, name) => nameSet.has(name) ? `${name}!` : match);
690
+ return result;
691
+ }
540
692
  //#endregion
541
693
  //#region ../../internals/tanstack-query/src/components/QueryKey.tsx
542
694
  const declarationPrinter$9 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
543
- const callPrinter$9 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
544
- function getParams$5(node, options) {
545
- return buildQueryKeyParams(node, options);
546
- }
547
- __name(getParams$5, "getParams");
548
- const getTransformer = ({ node, casing }) => {
695
+ const queryKeyTransformer = ({ node, casing }) => {
696
+ if (!node.path) return [];
549
697
  const path = new URLPath(node.path, { casing });
550
- const hasQueryParams = node.parameters.some((p) => p.in === "query");
698
+ const hasQueryParams = getOperationParameters(node).query.length > 0;
551
699
  const hasRequestBody = !!node.requestBody?.content?.[0]?.schema;
552
700
  return [
553
701
  path.toObject({
554
702
  type: "path",
555
703
  stringify: true
556
704
  }),
557
- hasQueryParams ? "...(params ? [params] : [])" : void 0,
558
- hasRequestBody ? "...(data ? [data] : [])" : void 0
705
+ hasQueryParams ? "...(params ? [params] : [])" : null,
706
+ hasRequestBody ? "...(data ? [data] : [])" : null
559
707
  ].filter(Boolean);
560
708
  };
561
- function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeName, transformer = getTransformer }) {
562
- const paramsNode = getParams$5(node, {
709
+ function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeName, transformer }) {
710
+ const baseParamsNode = buildQueryKeyParams(node, {
563
711
  pathParamsType,
564
712
  paramsCasing,
565
713
  resolver: tsResolver
566
714
  });
715
+ const paramsNode = markParamsOptional(baseParamsNode, getEnabledParamNames(baseParamsNode));
567
716
  const paramsSignature = declarationPrinter$9.print(paramsNode) ?? "";
568
- const keys = transformer({
717
+ const keys = (transformer ?? queryKeyTransformer)({
569
718
  node,
570
719
  casing: paramsCasing
571
720
  });
@@ -589,37 +738,13 @@ function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeNa
589
738
  })
590
739
  })] });
591
740
  }
592
- QueryKey.getParams = getParams$5;
593
- QueryKey.getTransformer = getTransformer;
594
- QueryKey.callPrinter = callPrinter$9;
595
- //#endregion
596
- //#region src/utils.ts
597
- function transformName(name, type, transformers) {
598
- return transformers?.name?.(name, type) || name;
599
- }
600
- function matchesPattern(node, ov) {
601
- const { type, pattern } = ov;
602
- const matches = (value) => typeof pattern === "string" ? value === pattern : pattern.test(value);
603
- if (type === "operationId") return matches(node.operationId);
604
- if (type === "tag") return node.tags.some((t) => matches(t));
605
- if (type === "path") return matches(node.path);
606
- if (type === "method") return matches(node.method);
607
- return false;
608
- }
609
- /**
610
- * Resolves per-operation overrides (first matching override wins), mirroring v4 OperationGenerator.getOptions().
611
- */
612
- function resolveOperationOverrides(node, override) {
613
- if (!override) return {};
614
- return override.find((ov) => matchesPattern(node, ov))?.options ?? {};
615
- }
616
741
  //#endregion
617
742
  //#region src/components/QueryOptions.tsx
618
743
  const declarationPrinter$8 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
619
744
  const callPrinter$8 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
620
745
  function getQueryOptionsParams(node, options) {
621
746
  const { paramsType, paramsCasing, pathParamsType, resolver } = options;
622
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
747
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
623
748
  return _kubb_core.ast.createOperationParams(node, {
624
749
  paramsType,
625
750
  pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
@@ -635,38 +760,29 @@ function getQueryOptionsParams(node, options) {
635
760
  })]
636
761
  });
637
762
  }
638
- function buildEnabledCheck(paramsNode) {
639
- const required = [];
640
- for (const param of paramsNode.params) if ("kind" in param && param.kind === "ParameterGroup") {
641
- const group = param;
642
- for (const child of group.properties) if (!child.optional && child.default === void 0) required.push(child.name);
643
- } else {
644
- const fp = param;
645
- if (!fp.optional && fp.default === void 0) required.push(fp.name);
646
- }
647
- return required.join(" && ");
648
- }
649
- function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
650
- const responseName = tsResolver.resolveResponseName(node);
763
+ function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, queryKeyName, suspense }) {
764
+ const successNames = resolveSuccessNames(node, tsResolver);
765
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
651
766
  const errorNames = resolveErrorNames(node, tsResolver);
652
767
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
653
768
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
654
- const paramsNode = getQueryOptionsParams(node, {
655
- paramsType,
656
- paramsCasing,
657
- pathParamsType,
658
- resolver: tsResolver
659
- });
660
- const paramsSignature = declarationPrinter$8.print(paramsNode) ?? "";
661
- const clientCallStr = (callPrinter$8.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
662
- const queryKeyParamsNode = QueryKey.getParams(node, {
769
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
663
770
  pathParamsType,
664
771
  paramsCasing,
665
772
  resolver: tsResolver
666
773
  });
667
774
  const queryKeyParamsCall = callPrinter$8.print(queryKeyParamsNode) ?? "";
668
- const enabledSource = buildEnabledCheck(queryKeyParamsNode);
669
- const enabledText = enabledSource ? `enabled: !!(${enabledSource}),` : "";
775
+ const enabledNames = getEnabledParamNames(queryKeyParamsNode);
776
+ const optionalNames = suspense ? [] : enabledNames;
777
+ const enabledText = suspense ? "" : enabledNames.length ? `enabled: !!(${enabledNames.join(" && ")}),` : "";
778
+ const paramsNode = markParamsOptional(getQueryOptionsParams(node, {
779
+ paramsType,
780
+ paramsCasing,
781
+ pathParamsType,
782
+ resolver: tsResolver
783
+ }), optionalNames);
784
+ const paramsSignature = declarationPrinter$8.print(paramsNode) ?? "";
785
+ const clientCallStr = injectNonNullAssertions((callPrinter$8.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }"), optionalNames);
670
786
  return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
671
787
  name,
672
788
  isExportable: true,
@@ -688,14 +804,13 @@ function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, para
688
804
  })
689
805
  });
690
806
  }
691
- QueryOptions.getParams = getQueryOptionsParams;
692
807
  //#endregion
693
808
  //#region src/components/InfiniteQuery.tsx
694
809
  const declarationPrinter$7 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
695
810
  const callPrinter$7 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
696
- function getParams$4(node, options) {
811
+ function buildInfiniteQueryParamsNode(node, options) {
697
812
  const { paramsType, paramsCasing, pathParamsType, resolver, pageParamGeneric } = options;
698
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
813
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
699
814
  const optionsParam = _kubb_core.ast.createFunctionParameter({
700
815
  name: "options",
701
816
  type: _kubb_core.ast.createParamsType({
@@ -715,9 +830,9 @@ function getParams$4(node, options) {
715
830
  extraParams: [optionsParam]
716
831
  });
717
832
  }
718
- __name(getParams$4, "getParams");
719
833
  function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, initialPageParam, queryParam, customOptions }) {
720
- const responseName = tsResolver.resolveResponseName(node);
834
+ const successNames = resolveSuccessNames(node, tsResolver);
835
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
721
836
  const errorNames = resolveErrorNames(node, tsResolver);
722
837
  const responseType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
723
838
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -726,12 +841,12 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
726
841
  const parts = initialPageParam.split(" as ");
727
842
  return parts[parts.length - 1] ?? "unknown";
728
843
  })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
729
- const rawQueryParams = node.parameters.filter((p) => p.in === "query");
844
+ const rawQueryParams = getOperationParameters(node).query;
730
845
  const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
731
846
  const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
732
- return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
733
- })() : void 0;
734
- const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
847
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : null;
848
+ })() : null;
849
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : null;
735
850
  const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
736
851
  const returnType = "UseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
737
852
  const generics = [
@@ -741,12 +856,13 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
741
856
  `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
742
857
  `TPageParam = ${pageParamType}`
743
858
  ];
744
- const queryKeyParamsNode = QueryKey.getParams(node, {
859
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
745
860
  pathParamsType,
746
861
  paramsCasing,
747
862
  resolver: tsResolver
748
863
  });
749
864
  const queryKeyParamsCall = callPrinter$7.print(queryKeyParamsNode) ?? "";
865
+ const enabledNames = getEnabledParamNames(queryKeyParamsNode);
750
866
  const queryOptionsParamsNode = getQueryOptionsParams(node, {
751
867
  paramsType,
752
868
  paramsCasing,
@@ -754,14 +870,14 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
754
870
  resolver: tsResolver
755
871
  });
756
872
  const queryOptionsParamsCall = callPrinter$7.print(queryOptionsParamsNode) ?? "";
757
- const paramsNode = getParams$4(node, {
873
+ const paramsNode = markParamsOptional(buildInfiniteQueryParamsNode(node, {
758
874
  paramsType,
759
875
  paramsCasing,
760
876
  pathParamsType,
761
877
  dataReturnType,
762
878
  resolver: tsResolver,
763
879
  pageParamGeneric: "TPageParam"
764
- });
880
+ }), enabledNames);
765
881
  const paramsSignature = declarationPrinter$7.print(paramsNode) ?? "";
766
882
  return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
767
883
  name,
@@ -773,7 +889,7 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
773
889
  generics: generics.join(", "),
774
890
  params: paramsSignature,
775
891
  returnType: void 0,
776
- JSDoc: { comments: getComments(node) },
892
+ JSDoc: { comments: buildOperationComments(node) },
777
893
  children: `
778
894
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
779
895
  const { client: queryClient, ...resolvedOptions } = queryConfig
@@ -793,13 +909,13 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
793
909
  })
794
910
  });
795
911
  }
796
- InfiniteQuery.getParams = getParams$4;
797
912
  //#endregion
798
913
  //#region src/components/InfiniteQueryOptions.tsx
799
914
  const declarationPrinter$6 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
800
915
  const callPrinter$6 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
801
916
  function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
802
- const responseName = tsResolver.resolveResponseName(node);
917
+ const successNames = resolveSuccessNames(node, tsResolver);
918
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
803
919
  const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
804
920
  const errorNames = resolveErrorNames(node, tsResolver);
805
921
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -808,49 +924,39 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
808
924
  const parts = initialPageParam.split(" as ");
809
925
  return parts[parts.length - 1] ?? "unknown";
810
926
  })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
811
- const rawQueryParams = node.parameters.filter((p) => p.in === "query");
927
+ const rawQueryParams = getOperationParameters(node).query;
812
928
  const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
813
929
  const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
814
- return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
815
- })() : void 0;
816
- const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
930
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : null;
931
+ })() : null;
932
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : null;
817
933
  const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
818
- const paramsNode = getQueryOptionsParams(node, {
819
- paramsType,
820
- paramsCasing,
821
- pathParamsType,
822
- resolver: tsResolver
823
- });
824
- const paramsSignature = declarationPrinter$6.print(paramsNode) ?? "";
825
- const clientCallStr = (callPrinter$6.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
826
- const queryKeyParamsNode = QueryKey.getParams(node, {
934
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
827
935
  pathParamsType,
828
936
  paramsCasing,
829
937
  resolver: tsResolver
830
938
  });
831
939
  const queryKeyParamsCall = callPrinter$6.print(queryKeyParamsNode) ?? "";
832
- const enabledSource = buildEnabledCheck(queryKeyParamsNode);
833
- const enabledText = enabledSource ? `enabled: !!(${enabledSource}),` : "";
834
- const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
835
- let getNextPageParamExpr;
836
- let getPreviousPageParamExpr;
837
- if (hasNewParams) {
838
- if (nextParam) {
839
- const accessor = getNestedAccessor(nextParam, "lastPage");
840
- if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
841
- }
842
- if (previousParam) {
843
- const accessor = getNestedAccessor(previousParam, "firstPage");
844
- if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
940
+ const enabledNames = getEnabledParamNames(queryKeyParamsNode);
941
+ const enabledText = enabledNames.length ? `enabled: !!(${enabledNames.join(" && ")}),` : "";
942
+ const paramsNode = markParamsOptional(getQueryOptionsParams(node, {
943
+ paramsType,
944
+ paramsCasing,
945
+ pathParamsType,
946
+ resolver: tsResolver
947
+ }), enabledNames);
948
+ const paramsSignature = declarationPrinter$6.print(paramsNode) ?? "";
949
+ const clientCallStr = injectNonNullAssertions((callPrinter$6.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }"), enabledNames);
950
+ const hasNewParams = nextParam != null || previousParam != null;
951
+ const [getNextPageParamExpr, getPreviousPageParamExpr] = (() => {
952
+ if (hasNewParams) {
953
+ const nextAccessor = nextParam ? getNestedAccessor(nextParam, "lastPage") : null;
954
+ const prevAccessor = previousParam ? getNestedAccessor(previousParam, "firstPage") : null;
955
+ return [nextAccessor ? `getNextPageParam: (lastPage) => ${nextAccessor}` : null, prevAccessor ? `getPreviousPageParam: (firstPage) => ${prevAccessor}` : null];
845
956
  }
846
- } else if (cursorParam) {
847
- getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
848
- getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
849
- } else {
850
- if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
851
- else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
852
- getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
853
- }
957
+ if (cursorParam) return [`getNextPageParam: (lastPage) => lastPage['${cursorParam}']`, `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`];
958
+ return [dataReturnType === "full" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1" : "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1", "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1"];
959
+ })();
854
960
  const queryOptionsArr = [
855
961
  `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
856
962
  getNextPageParamExpr,
@@ -905,31 +1011,32 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
905
1011
  })
906
1012
  });
907
1013
  }
908
- InfiniteQueryOptions.getParams = (node, options) => getQueryOptionsParams(node, options);
909
1014
  //#endregion
910
1015
  //#region src/components/MutationOptions.tsx
911
1016
  const declarationPrinter$5 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
912
1017
  const callPrinter$5 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
913
1018
  const keysPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "keys" });
914
- function getConfigParam(node, resolver) {
915
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1019
+ function buildMutationConfigParamsNode(node, resolver) {
916
1020
  return _kubb_core.ast.createFunctionParameters({ params: [_kubb_core.ast.createFunctionParameter({
917
1021
  name: "config",
918
1022
  type: _kubb_core.ast.createParamsType({
919
1023
  variant: "reference",
920
- name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
1024
+ name: buildRequestConfigType(node, resolver)
921
1025
  }),
922
1026
  default: "{}"
923
1027
  })] });
924
1028
  }
925
1029
  function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, mutationKeyName }) {
926
- const responseName = tsResolver.resolveResponseName(node);
1030
+ const successNames = resolveSuccessNames(node, tsResolver);
1031
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
927
1032
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
928
1033
  const errorNames = resolveErrorNames(node, tsResolver);
929
1034
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
930
- const configParamsNode = getConfigParam(node, tsResolver);
1035
+ const configParamsNode = buildMutationConfigParamsNode(node, tsResolver);
931
1036
  const paramsSignature = declarationPrinter$5.print(configParamsNode) ?? "";
932
- const mutationArgParamsNode = buildMutationArgParams(node, {
1037
+ const mutationArgParamsNode = _kubb_core.ast.createOperationParams(node, {
1038
+ paramsType: "inline",
1039
+ pathParamsType: "inline",
933
1040
  paramsCasing,
934
1041
  resolver: tsResolver
935
1042
  });
@@ -945,7 +1052,7 @@ function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, p
945
1052
  name: "config",
946
1053
  type: _kubb_core.ast.createParamsType({
947
1054
  variant: "reference",
948
- name: node.requestBody?.content?.[0]?.schema ? `Partial<RequestConfig<${tsResolver.resolveDataName(node)}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
1055
+ name: buildRequestConfigType(node, tsResolver)
949
1056
  }),
950
1057
  default: "{}"
951
1058
  })]
@@ -962,7 +1069,7 @@ function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, p
962
1069
  generics: ["TContext = unknown"],
963
1070
  children: `
964
1071
  const mutationKey = ${mutationKeyName}()
965
- return mutationOptions<${TData}, ${TError}, ${TRequest ? `{${TRequest}}` : "void"}, TContext>({
1072
+ return mutationOptions<${TData}, ${TError}, ${TRequest ? `{${TRequest}}` : "undefined"}, TContext>({
966
1073
  mutationKey,
967
1074
  mutationFn: async(${hasMutationParams ? `{ ${argKeysStr} }` : "_"}) => {
968
1075
  return ${clientName}(${clientCallStr})
@@ -972,19 +1079,26 @@ function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, p
972
1079
  })
973
1080
  });
974
1081
  }
975
- MutationOptions.getParams = getConfigParam;
976
1082
  //#endregion
977
1083
  //#region src/components/Mutation.tsx
978
1084
  const declarationPrinter$4 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
979
1085
  const callPrinter$4 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
980
- function getParams$3(node, options) {
1086
+ function createMutationArgParams(node, options) {
1087
+ return _kubb_core.ast.createOperationParams(node, {
1088
+ paramsType: "inline",
1089
+ pathParamsType: "inline",
1090
+ paramsCasing: options.paramsCasing,
1091
+ resolver: options.resolver
1092
+ });
1093
+ }
1094
+ function buildMutationParamsNode(node, options) {
981
1095
  const { paramsCasing, dataReturnType, resolver } = options;
982
- const responseName = resolver.resolveResponseName(node);
983
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1096
+ const successNames = resolveSuccessNames(node, resolver);
1097
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
984
1098
  const errorNames = resolveErrorNames(node, resolver);
985
1099
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
986
1100
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
987
- const mutationArgParamsNode = buildMutationArgParams(node, {
1101
+ const mutationArgParamsNode = createMutationArgParams(node, {
988
1102
  paramsCasing,
989
1103
  resolver
990
1104
  });
@@ -992,7 +1106,7 @@ function getParams$3(node, options) {
992
1106
  const generics = [
993
1107
  TData,
994
1108
  TError,
995
- TRequest ? `{${TRequest}}` : "void",
1109
+ TRequest ? `{${TRequest}}` : "undefined",
996
1110
  "TContext"
997
1111
  ].join(", ");
998
1112
  return _kubb_core.ast.createFunctionParameters({ params: [_kubb_core.ast.createFunctionParameter({
@@ -1001,19 +1115,19 @@ function getParams$3(node, options) {
1001
1115
  variant: "reference",
1002
1116
  name: `{
1003
1117
  mutation?: UseMutationOptions<${generics}> & { client?: QueryClient },
1004
- client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"},
1118
+ client?: ${buildRequestConfigType(node, resolver)},
1005
1119
  }`
1006
1120
  }),
1007
1121
  default: "{}"
1008
1122
  })] });
1009
1123
  }
1010
- __name(getParams$3, "getParams");
1011
1124
  function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, node, tsResolver, mutationKeyName, customOptions }) {
1012
- const responseName = tsResolver.resolveResponseName(node);
1125
+ const successNames = resolveSuccessNames(node, tsResolver);
1126
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1013
1127
  const errorNames = resolveErrorNames(node, tsResolver);
1014
1128
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1015
1129
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
1016
- const mutationArgParamsNode = buildMutationArgParams(node, {
1130
+ const mutationArgParamsNode = createMutationArgParams(node, {
1017
1131
  paramsCasing,
1018
1132
  resolver: tsResolver
1019
1133
  });
@@ -1021,13 +1135,13 @@ function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, nod
1021
1135
  const generics = [
1022
1136
  TData,
1023
1137
  TError,
1024
- TRequest ? `{${TRequest}}` : "void",
1138
+ TRequest ? `{${TRequest}}` : "undefined",
1025
1139
  "TContext"
1026
1140
  ].join(", ");
1027
1141
  const returnType = `UseMutationResult<${generics}>`;
1028
- const mutationOptionsConfigNode = MutationOptions.getParams(node, tsResolver);
1142
+ const mutationOptionsConfigNode = buildMutationConfigParamsNode(node, tsResolver);
1029
1143
  const mutationOptionsParamsCall = callPrinter$4.print(mutationOptionsConfigNode) ?? "";
1030
- const paramsNode = getParams$3(node, {
1144
+ const paramsNode = buildMutationParamsNode(node, {
1031
1145
  paramsCasing,
1032
1146
  dataReturnType,
1033
1147
  resolver: tsResolver
@@ -1041,7 +1155,7 @@ function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, nod
1041
1155
  name,
1042
1156
  export: true,
1043
1157
  params: paramsSignature,
1044
- JSDoc: { comments: getComments(node) },
1158
+ JSDoc: { comments: buildOperationComments(node) },
1045
1159
  generics: ["TContext"],
1046
1160
  children: `
1047
1161
  const { mutation = {}, client: config = {} } = options ?? {}
@@ -1060,15 +1174,15 @@ function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, nod
1060
1174
  })
1061
1175
  });
1062
1176
  }
1063
- Mutation.getParams = getParams$3;
1064
1177
  //#endregion
1065
1178
  //#region src/components/Query.tsx
1066
1179
  const declarationPrinter$3 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
1067
1180
  const callPrinter$3 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
1068
- function getParams$2(node, options) {
1181
+ function buildQueryParamsNode(node, options) {
1069
1182
  const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options;
1070
- const responseName = resolver.resolveResponseName(node);
1071
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1183
+ const successNames = resolveSuccessNames(node, resolver);
1184
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
1185
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
1072
1186
  const errorNames = resolveErrorNames(node, resolver);
1073
1187
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1074
1188
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -1097,9 +1211,9 @@ function getParams$2(node, options) {
1097
1211
  extraParams: [optionsParam]
1098
1212
  });
1099
1213
  }
1100
- __name(getParams$2, "getParams");
1101
1214
  function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions }) {
1102
- const responseName = tsResolver.resolveResponseName(node);
1215
+ const successNames = resolveSuccessNames(node, tsResolver);
1216
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1103
1217
  const errorNames = resolveErrorNames(node, tsResolver);
1104
1218
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1105
1219
  const returnType = `UseQueryResult<TData, ${`ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`}> & { queryKey: TQueryKey }`;
@@ -1108,12 +1222,13 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
1108
1222
  `TQueryData = ${TData}`,
1109
1223
  `TQueryKey extends QueryKey = ${queryKeyTypeName}`
1110
1224
  ];
1111
- const queryKeyParamsNode = QueryKey.getParams(node, {
1225
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1112
1226
  pathParamsType,
1113
1227
  paramsCasing,
1114
1228
  resolver: tsResolver
1115
1229
  });
1116
1230
  const queryKeyParamsCall = callPrinter$3.print(queryKeyParamsNode) ?? "";
1231
+ const enabledNames = getEnabledParamNames(queryKeyParamsNode);
1117
1232
  const queryOptionsParamsNode = getQueryOptionsParams(node, {
1118
1233
  paramsType,
1119
1234
  paramsCasing,
@@ -1121,13 +1236,13 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
1121
1236
  resolver: tsResolver
1122
1237
  });
1123
1238
  const queryOptionsParamsCall = callPrinter$3.print(queryOptionsParamsNode) ?? "";
1124
- const paramsNode = getParams$2(node, {
1239
+ const paramsNode = markParamsOptional(buildQueryParamsNode(node, {
1125
1240
  paramsType,
1126
1241
  paramsCasing,
1127
1242
  pathParamsType,
1128
1243
  dataReturnType,
1129
1244
  resolver: tsResolver
1130
- });
1245
+ }), enabledNames);
1131
1246
  const paramsSignature = declarationPrinter$3.print(paramsNode) ?? "";
1132
1247
  return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1133
1248
  name,
@@ -1139,7 +1254,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
1139
1254
  generics: generics.join(", "),
1140
1255
  params: paramsSignature,
1141
1256
  returnType: void 0,
1142
- JSDoc: { comments: getComments(node) },
1257
+ JSDoc: { comments: buildOperationComments(node) },
1143
1258
  children: `
1144
1259
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
1145
1260
  const { client: queryClient, ...resolvedOptions } = queryConfig
@@ -1159,14 +1274,13 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
1159
1274
  })
1160
1275
  });
1161
1276
  }
1162
- Query.getParams = getParams$2;
1163
1277
  //#endregion
1164
1278
  //#region src/components/SuspenseInfiniteQuery.tsx
1165
1279
  const declarationPrinter$2 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
1166
1280
  const callPrinter$2 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
1167
- function getParams$1(node, options) {
1281
+ function buildSuspenseInfiniteQueryParamsNode(node, options) {
1168
1282
  const { paramsType, paramsCasing, pathParamsType, resolver, pageParamGeneric } = options;
1169
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1283
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
1170
1284
  const optionsParam = _kubb_core.ast.createFunctionParameter({
1171
1285
  name: "options",
1172
1286
  type: _kubb_core.ast.createParamsType({
@@ -1186,9 +1300,9 @@ function getParams$1(node, options) {
1186
1300
  extraParams: [optionsParam]
1187
1301
  });
1188
1302
  }
1189
- __name(getParams$1, "getParams");
1190
1303
  function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions, initialPageParam, queryParam }) {
1191
- const responseName = tsResolver.resolveResponseName(node);
1304
+ const successNames = resolveSuccessNames(node, tsResolver);
1305
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1192
1306
  const errorNames = resolveErrorNames(node, tsResolver);
1193
1307
  const responseType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1194
1308
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -1197,12 +1311,12 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1197
1311
  const parts = initialPageParam.split(" as ");
1198
1312
  return parts[parts.length - 1] ?? "unknown";
1199
1313
  })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
1200
- const rawQueryParams = node.parameters.filter((p) => p.in === "query");
1314
+ const rawQueryParams = getOperationParameters(node).query;
1201
1315
  const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
1202
1316
  const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
1203
- return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
1204
- })() : void 0;
1205
- const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
1317
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : null;
1318
+ })() : null;
1319
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : null;
1206
1320
  const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
1207
1321
  const returnType = "UseSuspenseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
1208
1322
  const generics = [
@@ -1212,7 +1326,7 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1212
1326
  `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
1213
1327
  `TPageParam = ${pageParamType}`
1214
1328
  ];
1215
- const queryKeyParamsNode = QueryKey.getParams(node, {
1329
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1216
1330
  pathParamsType,
1217
1331
  paramsCasing,
1218
1332
  resolver: tsResolver
@@ -1225,7 +1339,7 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1225
1339
  resolver: tsResolver
1226
1340
  });
1227
1341
  const queryOptionsParamsCall = callPrinter$2.print(queryOptionsParamsNode) ?? "";
1228
- const paramsNode = getParams$1(node, {
1342
+ const paramsNode = buildSuspenseInfiniteQueryParamsNode(node, {
1229
1343
  paramsType,
1230
1344
  paramsCasing,
1231
1345
  pathParamsType,
@@ -1244,7 +1358,7 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1244
1358
  generics: generics.join(", "),
1245
1359
  params: paramsSignature,
1246
1360
  returnType: void 0,
1247
- JSDoc: { comments: getComments(node) },
1361
+ JSDoc: { comments: buildOperationComments(node) },
1248
1362
  children: `
1249
1363
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
1250
1364
  const { client: queryClient, ...resolvedOptions } = queryConfig
@@ -1264,13 +1378,13 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1264
1378
  })
1265
1379
  });
1266
1380
  }
1267
- SuspenseInfiniteQuery.getParams = getParams$1;
1268
1381
  //#endregion
1269
1382
  //#region src/components/SuspenseInfiniteQueryOptions.tsx
1270
1383
  const declarationPrinter$1 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
1271
1384
  const callPrinter$1 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
1272
1385
  function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
1273
- const responseName = tsResolver.resolveResponseName(node);
1386
+ const successNames = resolveSuccessNames(node, tsResolver);
1387
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1274
1388
  const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1275
1389
  const errorNames = resolveErrorNames(node, tsResolver);
1276
1390
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -1279,12 +1393,12 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1279
1393
  const parts = initialPageParam.split(" as ");
1280
1394
  return parts[parts.length - 1] ?? "unknown";
1281
1395
  })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
1282
- const rawQueryParams = node.parameters.filter((p) => p.in === "query");
1396
+ const rawQueryParams = getOperationParameters(node).query;
1283
1397
  const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
1284
1398
  const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
1285
- return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
1286
- })() : void 0;
1287
- const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
1399
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : null;
1400
+ })() : null;
1401
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : null;
1288
1402
  const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
1289
1403
  const paramsNode = getQueryOptionsParams(node, {
1290
1404
  paramsType,
@@ -1294,34 +1408,22 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1294
1408
  });
1295
1409
  const paramsSignature = declarationPrinter$1.print(paramsNode) ?? "";
1296
1410
  const clientCallStr = (callPrinter$1.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
1297
- const queryKeyParamsNode = QueryKey.getParams(node, {
1411
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1298
1412
  pathParamsType,
1299
1413
  paramsCasing,
1300
1414
  resolver: tsResolver
1301
1415
  });
1302
1416
  const queryKeyParamsCall = callPrinter$1.print(queryKeyParamsNode) ?? "";
1303
- const enabledSource = buildEnabledCheck(queryKeyParamsNode);
1304
- const enabledText = enabledSource ? `enabled: !!(${enabledSource}),` : "";
1305
- const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
1306
- let getNextPageParamExpr;
1307
- let getPreviousPageParamExpr;
1308
- if (hasNewParams) {
1309
- if (nextParam) {
1310
- const accessor = getNestedAccessor(nextParam, "lastPage");
1311
- if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
1417
+ const hasNewParams = nextParam != null || previousParam != null;
1418
+ const [getNextPageParamExpr, getPreviousPageParamExpr] = (() => {
1419
+ if (hasNewParams) {
1420
+ const nextAccessor = nextParam ? getNestedAccessor(nextParam, "lastPage") : null;
1421
+ const prevAccessor = previousParam ? getNestedAccessor(previousParam, "firstPage") : null;
1422
+ return [nextAccessor ? `getNextPageParam: (lastPage) => ${nextAccessor}` : null, prevAccessor ? `getPreviousPageParam: (firstPage) => ${prevAccessor}` : null];
1312
1423
  }
1313
- if (previousParam) {
1314
- const accessor = getNestedAccessor(previousParam, "firstPage");
1315
- if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
1316
- }
1317
- } else if (cursorParam) {
1318
- getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
1319
- getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
1320
- } else {
1321
- if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
1322
- else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
1323
- getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
1324
- }
1424
+ if (cursorParam) return [`getNextPageParam: (lastPage) => lastPage['${cursorParam}']`, `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`];
1425
+ return [dataReturnType === "full" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1" : "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1", "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1"];
1426
+ })();
1325
1427
  const queryOptionsArr = [
1326
1428
  `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
1327
1429
  getNextPageParamExpr,
@@ -1343,7 +1445,6 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1343
1445
  children: `
1344
1446
  const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1345
1447
  return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
1346
- ${enabledText}
1347
1448
  queryKey,
1348
1449
  queryFn: async ({ signal, pageParam }) => {
1349
1450
  ${infiniteOverrideParams}
@@ -1365,7 +1466,6 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1365
1466
  children: `
1366
1467
  const queryKey = ${queryKeyName}(${queryKeyParamsCall})
1367
1468
  return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
1368
- ${enabledText}
1369
1469
  queryKey,
1370
1470
  queryFn: async ({ signal }) => {
1371
1471
  return ${clientName}(${clientCallStr})
@@ -1376,15 +1476,15 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1376
1476
  })
1377
1477
  });
1378
1478
  }
1379
- SuspenseInfiniteQueryOptions.getParams = (node, options) => getQueryOptionsParams(node, options);
1380
1479
  //#endregion
1381
1480
  //#region src/components/SuspenseQuery.tsx
1382
1481
  const declarationPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
1383
1482
  const callPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
1384
- function getParams(node, options) {
1483
+ function buildSuspenseQueryParamsNode(node, options) {
1385
1484
  const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options;
1386
- const responseName = resolver.resolveResponseName(node);
1387
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1485
+ const successNames = resolveSuccessNames(node, resolver);
1486
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
1487
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
1388
1488
  const errorNames = resolveErrorNames(node, resolver);
1389
1489
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1390
1490
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -1413,12 +1513,13 @@ function getParams(node, options) {
1413
1513
  });
1414
1514
  }
1415
1515
  function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions }) {
1416
- const responseName = tsResolver.resolveResponseName(node);
1516
+ const successNames = resolveSuccessNames(node, tsResolver);
1517
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1417
1518
  const errorNames = resolveErrorNames(node, tsResolver);
1418
1519
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1419
1520
  const returnType = `UseSuspenseQueryResult<TData, ${`ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`}> & { queryKey: TQueryKey }`;
1420
1521
  const generics = [`TData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
1421
- const queryKeyParamsNode = QueryKey.getParams(node, {
1522
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1422
1523
  pathParamsType,
1423
1524
  paramsCasing,
1424
1525
  resolver: tsResolver
@@ -1431,7 +1532,7 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
1431
1532
  resolver: tsResolver
1432
1533
  });
1433
1534
  const queryOptionsParamsCall = callPrinter.print(queryOptionsParamsNode) ?? "";
1434
- const paramsNode = getParams(node, {
1535
+ const paramsNode = buildSuspenseQueryParamsNode(node, {
1435
1536
  paramsType,
1436
1537
  paramsCasing,
1437
1538
  pathParamsType,
@@ -1449,7 +1550,7 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
1449
1550
  generics: generics.join(", "),
1450
1551
  params: paramsSignature,
1451
1552
  returnType: void 0,
1452
- JSDoc: { comments: getComments(node) },
1553
+ JSDoc: { comments: buildOperationComments(node) },
1453
1554
  children: `
1454
1555
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
1455
1556
  const { client: queryClient, ...resolvedOptions } = queryConfig
@@ -1469,7 +1570,6 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
1469
1570
  })
1470
1571
  });
1471
1572
  }
1472
- SuspenseQuery.getParams = getParams;
1473
1573
  //#endregion
1474
1574
  Object.defineProperty(exports, "InfiniteQuery", {
1475
1575
  enumerable: true,
@@ -1555,17 +1655,47 @@ Object.defineProperty(exports, "camelCase", {
1555
1655
  return camelCase;
1556
1656
  }
1557
1657
  });
1658
+ Object.defineProperty(exports, "getOperationParameters", {
1659
+ enumerable: true,
1660
+ get: function() {
1661
+ return getOperationParameters;
1662
+ }
1663
+ });
1664
+ Object.defineProperty(exports, "mutationKeyTransformer", {
1665
+ enumerable: true,
1666
+ get: function() {
1667
+ return mutationKeyTransformer;
1668
+ }
1669
+ });
1670
+ Object.defineProperty(exports, "operationFileEntry", {
1671
+ enumerable: true,
1672
+ get: function() {
1673
+ return operationFileEntry;
1674
+ }
1675
+ });
1676
+ Object.defineProperty(exports, "queryKeyTransformer", {
1677
+ enumerable: true,
1678
+ get: function() {
1679
+ return queryKeyTransformer;
1680
+ }
1681
+ });
1558
1682
  Object.defineProperty(exports, "resolveOperationOverrides", {
1559
1683
  enumerable: true,
1560
1684
  get: function() {
1561
1685
  return resolveOperationOverrides;
1562
1686
  }
1563
1687
  });
1564
- Object.defineProperty(exports, "transformName", {
1688
+ Object.defineProperty(exports, "resolveOperationTypeNames", {
1689
+ enumerable: true,
1690
+ get: function() {
1691
+ return resolveOperationTypeNames;
1692
+ }
1693
+ });
1694
+ Object.defineProperty(exports, "resolveZodSchemaNames", {
1565
1695
  enumerable: true,
1566
1696
  get: function() {
1567
- return transformName;
1697
+ return resolveZodSchemaNames;
1568
1698
  }
1569
1699
  });
1570
1700
 
1571
- //# sourceMappingURL=components-dAKJEn9b.cjs.map
1701
+ //# sourceMappingURL=components-DQAYLQW0.cjs.map