@kubb/plugin-react-query 5.0.0-beta.3 → 5.0.0-beta.30

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 (48) hide show
  1. package/README.md +34 -83
  2. package/dist/{components-DTGLu4UV.js → components-CDmg-RPi.js} +275 -255
  3. package/dist/components-CDmg-RPi.js.map +1 -0
  4. package/dist/{components-dAKJEn9b.cjs → components-MPBTffPl.cjs} +299 -255
  5. package/dist/components-MPBTffPl.cjs.map +1 -0
  6. package/dist/components.cjs +1 -1
  7. package/dist/components.d.ts +1 -75
  8. package/dist/components.js +1 -1
  9. package/dist/{generators-C_fbcjpG.js → generators-Bma51Uar.js} +301 -261
  10. package/dist/generators-Bma51Uar.js.map +1 -0
  11. package/dist/{generators-CWEQsdO9.cjs → generators-BtsWNz-6.cjs} +299 -259
  12. package/dist/generators-BtsWNz-6.cjs.map +1 -0
  13. package/dist/generators.cjs +1 -1
  14. package/dist/generators.d.ts +41 -1
  15. package/dist/generators.js +1 -1
  16. package/dist/index.cjs +143 -20
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +30 -1
  19. package/dist/index.js +143 -20
  20. package/dist/index.js.map +1 -1
  21. package/dist/types-DiZPLTXl.d.ts +400 -0
  22. package/extension.yaml +1507 -0
  23. package/package.json +16 -18
  24. package/src/components/InfiniteQuery.tsx +19 -13
  25. package/src/components/InfiniteQueryOptions.tsx +29 -47
  26. package/src/components/Mutation.tsx +35 -15
  27. package/src/components/MutationOptions.tsx +14 -13
  28. package/src/components/Query.tsx +9 -10
  29. package/src/components/QueryOptions.tsx +6 -27
  30. package/src/components/SuspenseInfiniteQuery.tsx +19 -13
  31. package/src/components/SuspenseInfiniteQueryOptions.tsx +29 -47
  32. package/src/components/SuspenseQuery.tsx +9 -10
  33. package/src/generators/customHookOptionsFileGenerator.tsx +18 -14
  34. package/src/generators/hookOptionsGenerator.tsx +36 -33
  35. package/src/generators/infiniteQueryGenerator.tsx +46 -64
  36. package/src/generators/mutationGenerator.tsx +42 -50
  37. package/src/generators/queryGenerator.tsx +43 -49
  38. package/src/generators/suspenseInfiniteQueryGenerator.tsx +41 -51
  39. package/src/generators/suspenseQueryGenerator.tsx +44 -62
  40. package/src/plugin.ts +42 -16
  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
@@ -1,4 +1,4 @@
1
- import { t as __name } from "./chunk--u3MIqq1.js";
1
+ import "./chunk--u3MIqq1.js";
2
2
  import { ast } from "@kubb/core";
3
3
  import { functionPrinter } from "@kubb/plugin-ts";
4
4
  import { File, Function, Type } from "@kubb/renderer-jsx";
@@ -228,16 +228,16 @@ var URLPath = class {
228
228
  get object() {
229
229
  return this.toObject();
230
230
  }
231
- /** Returns a map of path parameter names, or `undefined` when the path has no parameters.
231
+ /** Returns a map of path parameter names, or `null` when the path has no parameters.
232
232
  *
233
233
  * @example
234
234
  * ```ts
235
235
  * new URLPath('/pet/{petId}').params // { petId: 'petId' }
236
- * new URLPath('/pet').params // undefined
236
+ * new URLPath('/pet').params // null
237
237
  * ```
238
238
  */
239
239
  get params() {
240
- return this.getParams();
240
+ return this.toParamsObject();
241
241
  }
242
242
  #transformParam(raw) {
243
243
  const param = isValidVarName(raw) ? raw : camelCase(raw);
@@ -255,7 +255,7 @@ var URLPath = class {
255
255
  toObject({ type = "path", replacer, stringify } = {}) {
256
256
  const object = {
257
257
  url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
258
- params: this.getParams()
258
+ params: this.toParamsObject()
259
259
  };
260
260
  if (stringify) {
261
261
  if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
@@ -271,12 +271,13 @@ var URLPath = class {
271
271
  * @example
272
272
  * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
273
273
  */
274
- toTemplateString({ prefix = "", replacer } = {}) {
275
- return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
274
+ toTemplateString({ prefix, replacer } = {}) {
275
+ const result = this.path.split(/\{([^}]+)\}/).map((part, i) => {
276
276
  if (i % 2 === 0) return part;
277
277
  const param = this.#transformParam(part);
278
278
  return `\${${replacer ? replacer(param) : param}}`;
279
- }).join("")}\``;
279
+ }).join("");
280
+ return `\`${prefix ?? ""}${result}\``;
280
281
  }
281
282
  /**
282
283
  * Extracts all `{param}` segments from the path and returns them as a key-value map.
@@ -285,17 +286,17 @@ var URLPath = class {
285
286
  *
286
287
  * @example
287
288
  * ```ts
288
- * new URLPath('/pet/{petId}/tag/{tagId}').getParams()
289
+ * new URLPath('/pet/{petId}/tag/{tagId}').toParamsObject()
289
290
  * // { petId: 'petId', tagId: 'tagId' }
290
291
  * ```
291
292
  */
292
- getParams(replacer) {
293
+ toParamsObject(replacer) {
293
294
  const params = {};
294
295
  this.#eachParam((_raw, param) => {
295
296
  const key = replacer ? replacer(param) : param;
296
297
  params[key] = key;
297
298
  });
298
- return Object.keys(params).length > 0 ? params : void 0;
299
+ return Object.keys(params).length > 0 ? params : null;
299
300
  }
300
301
  /** Converts the OpenAPI path to Express-style colon syntax.
301
302
  *
@@ -311,17 +312,13 @@ var URLPath = class {
311
312
  //#endregion
312
313
  //#region ../../internals/tanstack-query/src/components/MutationKey.tsx
313
314
  const declarationPrinter$10 = functionPrinter({ mode: "declaration" });
314
- function getParams$6() {
315
- return ast.createFunctionParameters({ params: [] });
316
- }
317
- __name(getParams$6, "getParams");
318
- const getTransformer$1 = /* @__PURE__ */ __name(({ node, casing }) => {
315
+ const mutationKeyTransformer = ({ node, casing }) => {
319
316
  return [`{ url: '${new URLPath(node.path, { casing }).toURLPath()}' }`];
320
- }, "getTransformer");
321
- function MutationKey({ name, paramsCasing, node, transformer = getTransformer$1 }) {
322
- const paramsNode = getParams$6();
317
+ };
318
+ function MutationKey({ name, paramsCasing, node, transformer }) {
319
+ const paramsNode = ast.createFunctionParameters({ params: [] });
323
320
  const paramsSignature = declarationPrinter$10.print(paramsNode) ?? "";
324
- const keys = transformer({
321
+ const keys = (transformer ?? mutationKeyTransformer)({
325
322
  node,
326
323
  casing: paramsCasing
327
324
  });
@@ -338,28 +335,141 @@ function MutationKey({ name, paramsCasing, node, transformer = getTransformer$1
338
335
  })
339
336
  });
340
337
  }
341
- MutationKey.getParams = getParams$6;
342
- MutationKey.getTransformer = getTransformer$1;
343
338
  //#endregion
344
- //#region ../../internals/tanstack-query/src/utils.ts
345
- /**
346
- * Build JSDoc comment lines from an OperationNode.
347
- */
348
- function getComments(node) {
349
- return [
339
+ //#region ../../internals/shared/src/operation.ts
340
+ function getOperationLink(node, link) {
341
+ if (!link) return null;
342
+ if (typeof link === "function") return link(node) ?? null;
343
+ if (link === "urlPath") return node.path ? `{@link ${new URLPath(node.path).URL}}` : null;
344
+ return `{@link ${node.path.replaceAll("{", ":").replaceAll("}", "")}}`;
345
+ }
346
+ function getContentTypeInfo(node) {
347
+ const contentTypes = node.requestBody?.content?.map((e) => e.contentType) ?? [];
348
+ const isMultipleContentTypes = contentTypes.length > 1;
349
+ return {
350
+ contentTypes,
351
+ isMultipleContentTypes,
352
+ contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(" | ") : "",
353
+ defaultContentType: contentTypes[0] ?? "application/json",
354
+ hasFormData: contentTypes.some((ct) => ct === "multipart/form-data")
355
+ };
356
+ }
357
+ function buildRequestConfigType(node, resolver) {
358
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
359
+ const { isMultipleContentTypes, contentTypeUnion } = getContentTypeInfo(node);
360
+ return `${requestName ? `Partial<RequestConfig<${requestName}>>` : "Partial<RequestConfig>"} & { ${["client?: Client", isMultipleContentTypes ? `contentType?: ${contentTypeUnion}` : null].filter(Boolean).join("; ")} }`;
361
+ }
362
+ function buildOperationComments(node, options = {}) {
363
+ const { link = "pathTemplate", linkPosition = "afterDeprecated", splitLines = false } = options;
364
+ const linkComment = getOperationLink(node, link);
365
+ const filteredComments = (linkPosition === "beforeDeprecated" ? [
366
+ node.description && `@description ${node.description}`,
367
+ node.summary && `@summary ${node.summary}`,
368
+ linkComment,
369
+ node.deprecated && "@deprecated"
370
+ ] : [
350
371
  node.description && `@description ${node.description}`,
351
372
  node.summary && `@summary ${node.summary}`,
352
373
  node.deprecated && "@deprecated",
353
- `{@link ${node.path.replaceAll("{", ":").replaceAll("}", "")}}`
354
- ].filter((x) => Boolean(x));
374
+ linkComment
375
+ ]).filter((comment) => Boolean(comment));
376
+ if (!splitLines) return filteredComments;
377
+ return filteredComments.flatMap((text) => text.split(/\r?\n/).map((line) => line.trim())).filter((comment) => Boolean(comment));
378
+ }
379
+ function getOperationParameters(node, options = {}) {
380
+ const params = ast.caseParams(node.parameters, options.paramsCasing);
381
+ return {
382
+ path: params.filter((param) => param.in === "path"),
383
+ query: params.filter((param) => param.in === "query"),
384
+ header: params.filter((param) => param.in === "header"),
385
+ cookie: params.filter((param) => param.in === "cookie")
386
+ };
387
+ }
388
+ function getStatusCodeNumber(statusCode) {
389
+ const code = Number(statusCode);
390
+ return Number.isNaN(code) ? null : code;
391
+ }
392
+ function isSuccessStatusCode(statusCode) {
393
+ const code = getStatusCodeNumber(statusCode);
394
+ return code !== null && code >= 200 && code < 300;
395
+ }
396
+ function isErrorStatusCode(statusCode) {
397
+ const code = getStatusCodeNumber(statusCode);
398
+ return code !== null && code >= 400;
399
+ }
400
+ function resolveErrorNames(node, resolver) {
401
+ return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
402
+ }
403
+ function resolveSuccessNames(node, resolver) {
404
+ return node.responses.filter((response) => isSuccessStatusCode(response.statusCode)).map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
405
+ }
406
+ function resolveStatusCodeNames(node, resolver) {
407
+ return node.responses.map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
408
+ }
409
+ const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
410
+ function resolveOperationTypeNames(node, resolver, options = {}) {
411
+ const cacheKey = `${node.operationId}\0${options.paramsCasing ?? ""}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${(options.exclude ?? []).join(",")}`;
412
+ let byResolver = typeNamesByResolver.get(resolver);
413
+ if (byResolver) {
414
+ const cached = byResolver.get(cacheKey);
415
+ if (cached) return cached;
416
+ } else {
417
+ byResolver = /* @__PURE__ */ new Map();
418
+ typeNamesByResolver.set(resolver, byResolver);
419
+ }
420
+ const { path, query, header } = getOperationParameters(node, { paramsCasing: options.paramsCasing });
421
+ const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
422
+ const exclude = new Set(options.exclude ?? []);
423
+ const paramNames = [
424
+ ...path.map((param) => resolver.resolvePathParamsName(node, param)),
425
+ ...query.map((param) => resolver.resolveQueryParamsName(node, param)),
426
+ ...header.map((param) => resolver.resolveHeaderParamsName(node, param))
427
+ ];
428
+ const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null, resolver.resolveResponseName(node)];
429
+ const result = (options.order === "body-response-first" ? [
430
+ ...bodyAndResponseNames,
431
+ ...paramNames,
432
+ ...responseStatusNames
433
+ ] : [
434
+ ...paramNames,
435
+ ...bodyAndResponseNames,
436
+ ...responseStatusNames
437
+ ]).filter((name) => Boolean(name) && !exclude.has(name));
438
+ byResolver.set(cacheKey, result);
439
+ return result;
440
+ }
441
+ //#endregion
442
+ //#region ../../internals/tanstack-query/src/utils.ts
443
+ function matchesPattern(node, ov) {
444
+ const { type, pattern } = ov;
445
+ const matches = (value) => typeof pattern === "string" ? value === pattern : pattern.test(value);
446
+ if (type === "operationId") return matches(node.operationId);
447
+ if (type === "tag") return node.tags.some((t) => matches(t));
448
+ if (type === "path") return matches(node.path);
449
+ if (type === "method") return matches(node.method);
450
+ return false;
451
+ }
452
+ /**
453
+ * Resolves per-operation overrides (first matching override wins).
454
+ *
455
+ * @example
456
+ * ```ts
457
+ * const opts = resolveOperationOverrides(node, override)
458
+ * const queryOpts = 'query' in opts ? opts.query : defaultQuery
459
+ * ```
460
+ */
461
+ function resolveOperationOverrides(node, override) {
462
+ if (!override) return {};
463
+ return override.find((ov) => matchesPattern(node, ov))?.options ?? {};
355
464
  }
356
465
  /**
357
- * Resolve error type names from operation responses.
466
+ * Collects the Zod schema import names for an operation (response + request body).
467
+ *
468
+ * Returns an empty array when no resolver is provided or the operation has no request body schema.
358
469
  */
359
- function resolveErrorNames(node, tsResolver) {
360
- return node.responses.filter((r) => {
361
- return Number.parseInt(r.statusCode, 10) >= 400;
362
- }).map((r) => tsResolver.resolveResponseStatusName(node, r.statusCode));
470
+ function resolveZodSchemaNames(node, zodResolver) {
471
+ if (!zodResolver) return [];
472
+ return [zodResolver.resolveResponseName?.(node), node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : null].filter((n) => Boolean(n));
363
473
  }
364
474
  /**
365
475
  * Resolve the type for a single path parameter.
@@ -383,30 +493,14 @@ function resolvePathParamType(node, param, resolver) {
383
493
  }
384
494
  /**
385
495
  * Derive a query-params group type from the resolver.
386
- * Returns `undefined` when no query params exist or when the group name
496
+ * Returns `null` when no query params exist or when the group name
387
497
  * equals the individual param name (no real group).
388
498
  */
389
499
  function resolveQueryGroupType(node, params, resolver) {
390
- if (!params.length) return void 0;
500
+ if (!params.length) return null;
391
501
  const firstParam = params[0];
392
502
  const groupName = resolver.resolveQueryParamsName(node, firstParam);
393
- if (groupName === resolver.resolveParamName(node, firstParam)) return void 0;
394
- return {
395
- type: ast.createParamsType({
396
- variant: "reference",
397
- name: groupName
398
- }),
399
- optional: params.every((p) => !p.required)
400
- };
401
- }
402
- /**
403
- * Derive a header-params group type from the resolver.
404
- */
405
- function resolveHeaderGroupType(node, params, resolver) {
406
- if (!params.length) return void 0;
407
- const firstParam = params[0];
408
- const groupName = resolver.resolveHeaderParamsName(node, firstParam);
409
- if (groupName === resolver.resolveParamName(node, firstParam)) return void 0;
503
+ if (groupName === resolver.resolveParamName(node, firstParam)) return null;
410
504
  return {
411
505
  type: ast.createParamsType({
412
506
  variant: "reference",
@@ -456,7 +550,7 @@ function buildQueryKeyParams(node, options) {
456
550
  const bodyType = node.requestBody?.content?.[0]?.schema ? ast.createParamsType({
457
551
  variant: "reference",
458
552
  name: resolver.resolveDataName(node)
459
- }) : void 0;
553
+ }) : null;
460
554
  const bodyRequired = node.requestBody?.required ?? false;
461
555
  const params = [];
462
556
  if (pathParams.length) {
@@ -480,67 +574,41 @@ function buildQueryKeyParams(node, options) {
480
574
  params.push(...buildGroupParam("params", node, queryParams, queryGroupType, resolver));
481
575
  return ast.createFunctionParameters({ params });
482
576
  }
483
- /**
484
- * Build mutation arg params for paramsToTrigger mode.
485
- * Contains pathParams + data + queryParams + headers (all flattened, for type alias).
486
- */
487
- function buildMutationArgParams(node, options) {
488
- const { paramsCasing, resolver } = options;
489
- const casedParams = ast.caseParams(node.parameters, paramsCasing);
490
- const pathParams = casedParams.filter((p) => p.in === "path");
491
- const queryParams = casedParams.filter((p) => p.in === "query");
492
- const headerParams = casedParams.filter((p) => p.in === "header");
493
- const queryGroupType = resolveQueryGroupType(node, queryParams, resolver);
494
- const headerGroupType = resolveHeaderGroupType(node, headerParams, resolver);
495
- const bodyType = node.requestBody?.content?.[0]?.schema ? ast.createParamsType({
496
- variant: "reference",
497
- name: resolver.resolveDataName(node)
498
- }) : void 0;
499
- const bodyRequired = node.requestBody?.required ?? false;
500
- const params = [];
501
- for (const p of pathParams) params.push(ast.createFunctionParameter({
502
- name: p.name,
503
- type: resolvePathParamType(node, p, resolver),
504
- optional: !p.required
505
- }));
506
- if (bodyType) params.push(ast.createFunctionParameter({
507
- name: "data",
508
- type: bodyType,
509
- optional: !bodyRequired
510
- }));
511
- params.push(...buildGroupParam("params", node, queryParams, queryGroupType, resolver));
512
- params.push(...buildGroupParam("headers", node, headerParams, headerGroupType, resolver));
513
- return ast.createFunctionParameters({ params });
577
+ function buildEnabledCheck(paramsNode) {
578
+ const required = [];
579
+ for (const param of paramsNode.params) if ("kind" in param && param.kind === "ParameterGroup") {
580
+ const group = param;
581
+ for (const child of group.properties) if (!child.optional && child.default === void 0) required.push(child.name);
582
+ } else {
583
+ const fp = param;
584
+ if (!fp.optional && fp.default === void 0) required.push(fp.name);
585
+ }
586
+ return required.join(" && ");
514
587
  }
515
588
  //#endregion
516
589
  //#region ../../internals/tanstack-query/src/components/QueryKey.tsx
517
590
  const declarationPrinter$9 = functionPrinter({ mode: "declaration" });
518
- const callPrinter$9 = functionPrinter({ mode: "call" });
519
- function getParams$5(node, options) {
520
- return buildQueryKeyParams(node, options);
521
- }
522
- __name(getParams$5, "getParams");
523
- const getTransformer = ({ node, casing }) => {
591
+ const queryKeyTransformer = ({ node, casing }) => {
524
592
  const path = new URLPath(node.path, { casing });
525
- const hasQueryParams = node.parameters.some((p) => p.in === "query");
593
+ const hasQueryParams = getOperationParameters(node).query.length > 0;
526
594
  const hasRequestBody = !!node.requestBody?.content?.[0]?.schema;
527
595
  return [
528
596
  path.toObject({
529
597
  type: "path",
530
598
  stringify: true
531
599
  }),
532
- hasQueryParams ? "...(params ? [params] : [])" : void 0,
533
- hasRequestBody ? "...(data ? [data] : [])" : void 0
600
+ hasQueryParams ? "...(params ? [params] : [])" : null,
601
+ hasRequestBody ? "...(data ? [data] : [])" : null
534
602
  ].filter(Boolean);
535
603
  };
536
- function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeName, transformer = getTransformer }) {
537
- const paramsNode = getParams$5(node, {
604
+ function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeName, transformer }) {
605
+ const paramsNode = buildQueryKeyParams(node, {
538
606
  pathParamsType,
539
607
  paramsCasing,
540
608
  resolver: tsResolver
541
609
  });
542
610
  const paramsSignature = declarationPrinter$9.print(paramsNode) ?? "";
543
- const keys = transformer({
611
+ const keys = (transformer ?? queryKeyTransformer)({
544
612
  node,
545
613
  casing: paramsCasing
546
614
  });
@@ -564,37 +632,13 @@ function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeNa
564
632
  })
565
633
  })] });
566
634
  }
567
- QueryKey.getParams = getParams$5;
568
- QueryKey.getTransformer = getTransformer;
569
- QueryKey.callPrinter = callPrinter$9;
570
- //#endregion
571
- //#region src/utils.ts
572
- function transformName(name, type, transformers) {
573
- return transformers?.name?.(name, type) || name;
574
- }
575
- function matchesPattern(node, ov) {
576
- const { type, pattern } = ov;
577
- const matches = (value) => typeof pattern === "string" ? value === pattern : pattern.test(value);
578
- if (type === "operationId") return matches(node.operationId);
579
- if (type === "tag") return node.tags.some((t) => matches(t));
580
- if (type === "path") return matches(node.path);
581
- if (type === "method") return matches(node.method);
582
- return false;
583
- }
584
- /**
585
- * Resolves per-operation overrides (first matching override wins), mirroring v4 OperationGenerator.getOptions().
586
- */
587
- function resolveOperationOverrides(node, override) {
588
- if (!override) return {};
589
- return override.find((ov) => matchesPattern(node, ov))?.options ?? {};
590
- }
591
635
  //#endregion
592
636
  //#region src/components/QueryOptions.tsx
593
637
  const declarationPrinter$8 = functionPrinter({ mode: "declaration" });
594
638
  const callPrinter$8 = functionPrinter({ mode: "call" });
595
639
  function getQueryOptionsParams(node, options) {
596
640
  const { paramsType, paramsCasing, pathParamsType, resolver } = options;
597
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
641
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
598
642
  return ast.createOperationParams(node, {
599
643
  paramsType,
600
644
  pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
@@ -610,19 +654,9 @@ function getQueryOptionsParams(node, options) {
610
654
  })]
611
655
  });
612
656
  }
613
- function buildEnabledCheck(paramsNode) {
614
- const required = [];
615
- for (const param of paramsNode.params) if ("kind" in param && param.kind === "ParameterGroup") {
616
- const group = param;
617
- for (const child of group.properties) if (!child.optional && child.default === void 0) required.push(child.name);
618
- } else {
619
- const fp = param;
620
- if (!fp.optional && fp.default === void 0) required.push(fp.name);
621
- }
622
- return required.join(" && ");
623
- }
624
657
  function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
625
- const responseName = tsResolver.resolveResponseName(node);
658
+ const successNames = resolveSuccessNames(node, tsResolver);
659
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
626
660
  const errorNames = resolveErrorNames(node, tsResolver);
627
661
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
628
662
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -634,7 +668,7 @@ function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, para
634
668
  });
635
669
  const paramsSignature = declarationPrinter$8.print(paramsNode) ?? "";
636
670
  const clientCallStr = (callPrinter$8.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
637
- const queryKeyParamsNode = QueryKey.getParams(node, {
671
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
638
672
  pathParamsType,
639
673
  paramsCasing,
640
674
  resolver: tsResolver
@@ -663,14 +697,13 @@ function QueryOptions({ name, clientName, dataReturnType, node, tsResolver, para
663
697
  })
664
698
  });
665
699
  }
666
- QueryOptions.getParams = getQueryOptionsParams;
667
700
  //#endregion
668
701
  //#region src/components/InfiniteQuery.tsx
669
702
  const declarationPrinter$7 = functionPrinter({ mode: "declaration" });
670
703
  const callPrinter$7 = functionPrinter({ mode: "call" });
671
- function getParams$4(node, options) {
704
+ function buildInfiniteQueryParamsNode(node, options) {
672
705
  const { paramsType, paramsCasing, pathParamsType, resolver, pageParamGeneric } = options;
673
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
706
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
674
707
  const optionsParam = ast.createFunctionParameter({
675
708
  name: "options",
676
709
  type: ast.createParamsType({
@@ -690,9 +723,9 @@ function getParams$4(node, options) {
690
723
  extraParams: [optionsParam]
691
724
  });
692
725
  }
693
- __name(getParams$4, "getParams");
694
726
  function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, initialPageParam, queryParam, customOptions }) {
695
- const responseName = tsResolver.resolveResponseName(node);
727
+ const successNames = resolveSuccessNames(node, tsResolver);
728
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
696
729
  const errorNames = resolveErrorNames(node, tsResolver);
697
730
  const responseType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
698
731
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -701,12 +734,12 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
701
734
  const parts = initialPageParam.split(" as ");
702
735
  return parts[parts.length - 1] ?? "unknown";
703
736
  })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
704
- const rawQueryParams = node.parameters.filter((p) => p.in === "query");
737
+ const rawQueryParams = getOperationParameters(node).query;
705
738
  const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
706
739
  const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
707
- return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
708
- })() : void 0;
709
- const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
740
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : null;
741
+ })() : null;
742
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : null;
710
743
  const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
711
744
  const returnType = "UseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
712
745
  const generics = [
@@ -716,7 +749,7 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
716
749
  `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
717
750
  `TPageParam = ${pageParamType}`
718
751
  ];
719
- const queryKeyParamsNode = QueryKey.getParams(node, {
752
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
720
753
  pathParamsType,
721
754
  paramsCasing,
722
755
  resolver: tsResolver
@@ -729,7 +762,7 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
729
762
  resolver: tsResolver
730
763
  });
731
764
  const queryOptionsParamsCall = callPrinter$7.print(queryOptionsParamsNode) ?? "";
732
- const paramsNode = getParams$4(node, {
765
+ const paramsNode = buildInfiniteQueryParamsNode(node, {
733
766
  paramsType,
734
767
  paramsCasing,
735
768
  pathParamsType,
@@ -748,7 +781,7 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
748
781
  generics: generics.join(", "),
749
782
  params: paramsSignature,
750
783
  returnType: void 0,
751
- JSDoc: { comments: getComments(node) },
784
+ JSDoc: { comments: buildOperationComments(node) },
752
785
  children: `
753
786
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
754
787
  const { client: queryClient, ...resolvedOptions } = queryConfig
@@ -768,13 +801,13 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
768
801
  })
769
802
  });
770
803
  }
771
- InfiniteQuery.getParams = getParams$4;
772
804
  //#endregion
773
805
  //#region src/components/InfiniteQueryOptions.tsx
774
806
  const declarationPrinter$6 = functionPrinter({ mode: "declaration" });
775
807
  const callPrinter$6 = functionPrinter({ mode: "call" });
776
808
  function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
777
- const responseName = tsResolver.resolveResponseName(node);
809
+ const successNames = resolveSuccessNames(node, tsResolver);
810
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
778
811
  const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
779
812
  const errorNames = resolveErrorNames(node, tsResolver);
780
813
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -783,12 +816,12 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
783
816
  const parts = initialPageParam.split(" as ");
784
817
  return parts[parts.length - 1] ?? "unknown";
785
818
  })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
786
- const rawQueryParams = node.parameters.filter((p) => p.in === "query");
819
+ const rawQueryParams = getOperationParameters(node).query;
787
820
  const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
788
821
  const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
789
- return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
790
- })() : void 0;
791
- const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
822
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : null;
823
+ })() : null;
824
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : null;
792
825
  const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
793
826
  const paramsNode = getQueryOptionsParams(node, {
794
827
  paramsType,
@@ -798,7 +831,7 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
798
831
  });
799
832
  const paramsSignature = declarationPrinter$6.print(paramsNode) ?? "";
800
833
  const clientCallStr = (callPrinter$6.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
801
- const queryKeyParamsNode = QueryKey.getParams(node, {
834
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
802
835
  pathParamsType,
803
836
  paramsCasing,
804
837
  resolver: tsResolver
@@ -806,26 +839,16 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
806
839
  const queryKeyParamsCall = callPrinter$6.print(queryKeyParamsNode) ?? "";
807
840
  const enabledSource = buildEnabledCheck(queryKeyParamsNode);
808
841
  const enabledText = enabledSource ? `enabled: !!(${enabledSource}),` : "";
809
- const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
810
- let getNextPageParamExpr;
811
- let getPreviousPageParamExpr;
812
- if (hasNewParams) {
813
- if (nextParam) {
814
- const accessor = getNestedAccessor(nextParam, "lastPage");
815
- if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
842
+ const hasNewParams = nextParam != null || previousParam != null;
843
+ const [getNextPageParamExpr, getPreviousPageParamExpr] = (() => {
844
+ if (hasNewParams) {
845
+ const nextAccessor = nextParam ? getNestedAccessor(nextParam, "lastPage") : null;
846
+ const prevAccessor = previousParam ? getNestedAccessor(previousParam, "firstPage") : null;
847
+ return [nextAccessor ? `getNextPageParam: (lastPage) => ${nextAccessor}` : null, prevAccessor ? `getPreviousPageParam: (firstPage) => ${prevAccessor}` : null];
816
848
  }
817
- if (previousParam) {
818
- const accessor = getNestedAccessor(previousParam, "firstPage");
819
- if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
820
- }
821
- } else if (cursorParam) {
822
- getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
823
- getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
824
- } else {
825
- if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
826
- else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
827
- getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
828
- }
849
+ if (cursorParam) return [`getNextPageParam: (lastPage) => lastPage['${cursorParam}']`, `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`];
850
+ 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"];
851
+ })();
829
852
  const queryOptionsArr = [
830
853
  `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
831
854
  getNextPageParamExpr,
@@ -880,31 +903,32 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
880
903
  })
881
904
  });
882
905
  }
883
- InfiniteQueryOptions.getParams = (node, options) => getQueryOptionsParams(node, options);
884
906
  //#endregion
885
907
  //#region src/components/MutationOptions.tsx
886
908
  const declarationPrinter$5 = functionPrinter({ mode: "declaration" });
887
909
  const callPrinter$5 = functionPrinter({ mode: "call" });
888
910
  const keysPrinter = functionPrinter({ mode: "keys" });
889
- function getConfigParam(node, resolver) {
890
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
911
+ function buildMutationConfigParamsNode(node, resolver) {
891
912
  return ast.createFunctionParameters({ params: [ast.createFunctionParameter({
892
913
  name: "config",
893
914
  type: ast.createParamsType({
894
915
  variant: "reference",
895
- name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
916
+ name: buildRequestConfigType(node, resolver)
896
917
  }),
897
918
  default: "{}"
898
919
  })] });
899
920
  }
900
921
  function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, paramsCasing, paramsType, pathParamsType, mutationKeyName }) {
901
- const responseName = tsResolver.resolveResponseName(node);
922
+ const successNames = resolveSuccessNames(node, tsResolver);
923
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
902
924
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
903
925
  const errorNames = resolveErrorNames(node, tsResolver);
904
926
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
905
- const configParamsNode = getConfigParam(node, tsResolver);
927
+ const configParamsNode = buildMutationConfigParamsNode(node, tsResolver);
906
928
  const paramsSignature = declarationPrinter$5.print(configParamsNode) ?? "";
907
- const mutationArgParamsNode = buildMutationArgParams(node, {
929
+ const mutationArgParamsNode = ast.createOperationParams(node, {
930
+ paramsType: "inline",
931
+ pathParamsType: "inline",
908
932
  paramsCasing,
909
933
  resolver: tsResolver
910
934
  });
@@ -920,7 +944,7 @@ function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, p
920
944
  name: "config",
921
945
  type: ast.createParamsType({
922
946
  variant: "reference",
923
- name: node.requestBody?.content?.[0]?.schema ? `Partial<RequestConfig<${tsResolver.resolveDataName(node)}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
947
+ name: buildRequestConfigType(node, tsResolver)
924
948
  }),
925
949
  default: "{}"
926
950
  })]
@@ -937,7 +961,7 @@ function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, p
937
961
  generics: ["TContext = unknown"],
938
962
  children: `
939
963
  const mutationKey = ${mutationKeyName}()
940
- return mutationOptions<${TData}, ${TError}, ${TRequest ? `{${TRequest}}` : "void"}, TContext>({
964
+ return mutationOptions<${TData}, ${TError}, ${TRequest ? `{${TRequest}}` : "undefined"}, TContext>({
941
965
  mutationKey,
942
966
  mutationFn: async(${hasMutationParams ? `{ ${argKeysStr} }` : "_"}) => {
943
967
  return ${clientName}(${clientCallStr})
@@ -947,19 +971,26 @@ function MutationOptions({ name, clientName, dataReturnType, node, tsResolver, p
947
971
  })
948
972
  });
949
973
  }
950
- MutationOptions.getParams = getConfigParam;
951
974
  //#endregion
952
975
  //#region src/components/Mutation.tsx
953
976
  const declarationPrinter$4 = functionPrinter({ mode: "declaration" });
954
977
  const callPrinter$4 = functionPrinter({ mode: "call" });
955
- function getParams$3(node, options) {
978
+ function createMutationArgParams(node, options) {
979
+ return ast.createOperationParams(node, {
980
+ paramsType: "inline",
981
+ pathParamsType: "inline",
982
+ paramsCasing: options.paramsCasing,
983
+ resolver: options.resolver
984
+ });
985
+ }
986
+ function buildMutationParamsNode(node, options) {
956
987
  const { paramsCasing, dataReturnType, resolver } = options;
957
- const responseName = resolver.resolveResponseName(node);
958
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
988
+ const successNames = resolveSuccessNames(node, resolver);
989
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
959
990
  const errorNames = resolveErrorNames(node, resolver);
960
991
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
961
992
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
962
- const mutationArgParamsNode = buildMutationArgParams(node, {
993
+ const mutationArgParamsNode = createMutationArgParams(node, {
963
994
  paramsCasing,
964
995
  resolver
965
996
  });
@@ -967,7 +998,7 @@ function getParams$3(node, options) {
967
998
  const generics = [
968
999
  TData,
969
1000
  TError,
970
- TRequest ? `{${TRequest}}` : "void",
1001
+ TRequest ? `{${TRequest}}` : "undefined",
971
1002
  "TContext"
972
1003
  ].join(", ");
973
1004
  return ast.createFunctionParameters({ params: [ast.createFunctionParameter({
@@ -976,19 +1007,19 @@ function getParams$3(node, options) {
976
1007
  variant: "reference",
977
1008
  name: `{
978
1009
  mutation?: UseMutationOptions<${generics}> & { client?: QueryClient },
979
- client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"},
1010
+ client?: ${buildRequestConfigType(node, resolver)},
980
1011
  }`
981
1012
  }),
982
1013
  default: "{}"
983
1014
  })] });
984
1015
  }
985
- __name(getParams$3, "getParams");
986
1016
  function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, node, tsResolver, mutationKeyName, customOptions }) {
987
- const responseName = tsResolver.resolveResponseName(node);
1017
+ const successNames = resolveSuccessNames(node, tsResolver);
1018
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
988
1019
  const errorNames = resolveErrorNames(node, tsResolver);
989
1020
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
990
1021
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
991
- const mutationArgParamsNode = buildMutationArgParams(node, {
1022
+ const mutationArgParamsNode = createMutationArgParams(node, {
992
1023
  paramsCasing,
993
1024
  resolver: tsResolver
994
1025
  });
@@ -996,13 +1027,13 @@ function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, nod
996
1027
  const generics = [
997
1028
  TData,
998
1029
  TError,
999
- TRequest ? `{${TRequest}}` : "void",
1030
+ TRequest ? `{${TRequest}}` : "undefined",
1000
1031
  "TContext"
1001
1032
  ].join(", ");
1002
1033
  const returnType = `UseMutationResult<${generics}>`;
1003
- const mutationOptionsConfigNode = MutationOptions.getParams(node, tsResolver);
1034
+ const mutationOptionsConfigNode = buildMutationConfigParamsNode(node, tsResolver);
1004
1035
  const mutationOptionsParamsCall = callPrinter$4.print(mutationOptionsConfigNode) ?? "";
1005
- const paramsNode = getParams$3(node, {
1036
+ const paramsNode = buildMutationParamsNode(node, {
1006
1037
  paramsCasing,
1007
1038
  dataReturnType,
1008
1039
  resolver: tsResolver
@@ -1016,7 +1047,7 @@ function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, nod
1016
1047
  name,
1017
1048
  export: true,
1018
1049
  params: paramsSignature,
1019
- JSDoc: { comments: getComments(node) },
1050
+ JSDoc: { comments: buildOperationComments(node) },
1020
1051
  generics: ["TContext"],
1021
1052
  children: `
1022
1053
  const { mutation = {}, client: config = {} } = options ?? {}
@@ -1035,15 +1066,15 @@ function Mutation({ name, mutationOptionsName, paramsCasing, dataReturnType, nod
1035
1066
  })
1036
1067
  });
1037
1068
  }
1038
- Mutation.getParams = getParams$3;
1039
1069
  //#endregion
1040
1070
  //#region src/components/Query.tsx
1041
1071
  const declarationPrinter$3 = functionPrinter({ mode: "declaration" });
1042
1072
  const callPrinter$3 = functionPrinter({ mode: "call" });
1043
- function getParams$2(node, options) {
1073
+ function buildQueryParamsNode(node, options) {
1044
1074
  const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options;
1045
- const responseName = resolver.resolveResponseName(node);
1046
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1075
+ const successNames = resolveSuccessNames(node, resolver);
1076
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
1077
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
1047
1078
  const errorNames = resolveErrorNames(node, resolver);
1048
1079
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1049
1080
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -1072,9 +1103,9 @@ function getParams$2(node, options) {
1072
1103
  extraParams: [optionsParam]
1073
1104
  });
1074
1105
  }
1075
- __name(getParams$2, "getParams");
1076
1106
  function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions }) {
1077
- const responseName = tsResolver.resolveResponseName(node);
1107
+ const successNames = resolveSuccessNames(node, tsResolver);
1108
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1078
1109
  const errorNames = resolveErrorNames(node, tsResolver);
1079
1110
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1080
1111
  const returnType = `UseQueryResult<TData, ${`ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`}> & { queryKey: TQueryKey }`;
@@ -1083,7 +1114,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
1083
1114
  `TQueryData = ${TData}`,
1084
1115
  `TQueryKey extends QueryKey = ${queryKeyTypeName}`
1085
1116
  ];
1086
- const queryKeyParamsNode = QueryKey.getParams(node, {
1117
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1087
1118
  pathParamsType,
1088
1119
  paramsCasing,
1089
1120
  resolver: tsResolver
@@ -1096,7 +1127,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
1096
1127
  resolver: tsResolver
1097
1128
  });
1098
1129
  const queryOptionsParamsCall = callPrinter$3.print(queryOptionsParamsNode) ?? "";
1099
- const paramsNode = getParams$2(node, {
1130
+ const paramsNode = buildQueryParamsNode(node, {
1100
1131
  paramsType,
1101
1132
  paramsCasing,
1102
1133
  pathParamsType,
@@ -1114,7 +1145,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
1114
1145
  generics: generics.join(", "),
1115
1146
  params: paramsSignature,
1116
1147
  returnType: void 0,
1117
- JSDoc: { comments: getComments(node) },
1148
+ JSDoc: { comments: buildOperationComments(node) },
1118
1149
  children: `
1119
1150
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
1120
1151
  const { client: queryClient, ...resolvedOptions } = queryConfig
@@ -1134,14 +1165,13 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
1134
1165
  })
1135
1166
  });
1136
1167
  }
1137
- Query.getParams = getParams$2;
1138
1168
  //#endregion
1139
1169
  //#region src/components/SuspenseInfiniteQuery.tsx
1140
1170
  const declarationPrinter$2 = functionPrinter({ mode: "declaration" });
1141
1171
  const callPrinter$2 = functionPrinter({ mode: "call" });
1142
- function getParams$1(node, options) {
1172
+ function buildSuspenseInfiniteQueryParamsNode(node, options) {
1143
1173
  const { paramsType, paramsCasing, pathParamsType, resolver, pageParamGeneric } = options;
1144
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1174
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
1145
1175
  const optionsParam = ast.createFunctionParameter({
1146
1176
  name: "options",
1147
1177
  type: ast.createParamsType({
@@ -1161,9 +1191,9 @@ function getParams$1(node, options) {
1161
1191
  extraParams: [optionsParam]
1162
1192
  });
1163
1193
  }
1164
- __name(getParams$1, "getParams");
1165
1194
  function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions, initialPageParam, queryParam }) {
1166
- const responseName = tsResolver.resolveResponseName(node);
1195
+ const successNames = resolveSuccessNames(node, tsResolver);
1196
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1167
1197
  const errorNames = resolveErrorNames(node, tsResolver);
1168
1198
  const responseType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1169
1199
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -1172,12 +1202,12 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1172
1202
  const parts = initialPageParam.split(" as ");
1173
1203
  return parts[parts.length - 1] ?? "unknown";
1174
1204
  })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
1175
- const rawQueryParams = node.parameters.filter((p) => p.in === "query");
1205
+ const rawQueryParams = getOperationParameters(node).query;
1176
1206
  const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
1177
1207
  const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
1178
- return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
1179
- })() : void 0;
1180
- const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
1208
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : null;
1209
+ })() : null;
1210
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : null;
1181
1211
  const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
1182
1212
  const returnType = "UseSuspenseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
1183
1213
  const generics = [
@@ -1187,7 +1217,7 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1187
1217
  `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
1188
1218
  `TPageParam = ${pageParamType}`
1189
1219
  ];
1190
- const queryKeyParamsNode = QueryKey.getParams(node, {
1220
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1191
1221
  pathParamsType,
1192
1222
  paramsCasing,
1193
1223
  resolver: tsResolver
@@ -1200,7 +1230,7 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1200
1230
  resolver: tsResolver
1201
1231
  });
1202
1232
  const queryOptionsParamsCall = callPrinter$2.print(queryOptionsParamsNode) ?? "";
1203
- const paramsNode = getParams$1(node, {
1233
+ const paramsNode = buildSuspenseInfiniteQueryParamsNode(node, {
1204
1234
  paramsType,
1205
1235
  paramsCasing,
1206
1236
  pathParamsType,
@@ -1219,7 +1249,7 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1219
1249
  generics: generics.join(", "),
1220
1250
  params: paramsSignature,
1221
1251
  returnType: void 0,
1222
- JSDoc: { comments: getComments(node) },
1252
+ JSDoc: { comments: buildOperationComments(node) },
1223
1253
  children: `
1224
1254
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
1225
1255
  const { client: queryClient, ...resolvedOptions } = queryConfig
@@ -1239,13 +1269,13 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
1239
1269
  })
1240
1270
  });
1241
1271
  }
1242
- SuspenseInfiniteQuery.getParams = getParams$1;
1243
1272
  //#endregion
1244
1273
  //#region src/components/SuspenseInfiniteQueryOptions.tsx
1245
1274
  const declarationPrinter$1 = functionPrinter({ mode: "declaration" });
1246
1275
  const callPrinter$1 = functionPrinter({ mode: "call" });
1247
1276
  function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, node, tsResolver, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
1248
- const responseName = tsResolver.resolveResponseName(node);
1277
+ const successNames = resolveSuccessNames(node, tsResolver);
1278
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1249
1279
  const queryFnDataType = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1250
1280
  const errorNames = resolveErrorNames(node, tsResolver);
1251
1281
  const errorType = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -1254,12 +1284,12 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1254
1284
  const parts = initialPageParam.split(" as ");
1255
1285
  return parts[parts.length - 1] ?? "unknown";
1256
1286
  })() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
1257
- const rawQueryParams = node.parameters.filter((p) => p.in === "query");
1287
+ const rawQueryParams = getOperationParameters(node).query;
1258
1288
  const queryParamsTypeName = rawQueryParams.length > 0 ? (() => {
1259
1289
  const groupName = tsResolver.resolveQueryParamsName(node, rawQueryParams[0]);
1260
- return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : void 0;
1261
- })() : void 0;
1262
- const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : void 0;
1290
+ return groupName !== tsResolver.resolveParamName(node, rawQueryParams[0]) ? groupName : null;
1291
+ })() : null;
1292
+ const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : null;
1263
1293
  const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
1264
1294
  const paramsNode = getQueryOptionsParams(node, {
1265
1295
  paramsType,
@@ -1269,7 +1299,7 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1269
1299
  });
1270
1300
  const paramsSignature = declarationPrinter$1.print(paramsNode) ?? "";
1271
1301
  const clientCallStr = (callPrinter$1.print(paramsNode) ?? "").replace(/\bconfig\b(?=[^,]*$)/, "{ ...config, signal: config.signal ?? signal }");
1272
- const queryKeyParamsNode = QueryKey.getParams(node, {
1302
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1273
1303
  pathParamsType,
1274
1304
  paramsCasing,
1275
1305
  resolver: tsResolver
@@ -1277,26 +1307,16 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1277
1307
  const queryKeyParamsCall = callPrinter$1.print(queryKeyParamsNode) ?? "";
1278
1308
  const enabledSource = buildEnabledCheck(queryKeyParamsNode);
1279
1309
  const enabledText = enabledSource ? `enabled: !!(${enabledSource}),` : "";
1280
- const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
1281
- let getNextPageParamExpr;
1282
- let getPreviousPageParamExpr;
1283
- if (hasNewParams) {
1284
- if (nextParam) {
1285
- const accessor = getNestedAccessor(nextParam, "lastPage");
1286
- if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
1310
+ const hasNewParams = nextParam != null || previousParam != null;
1311
+ const [getNextPageParamExpr, getPreviousPageParamExpr] = (() => {
1312
+ if (hasNewParams) {
1313
+ const nextAccessor = nextParam ? getNestedAccessor(nextParam, "lastPage") : null;
1314
+ const prevAccessor = previousParam ? getNestedAccessor(previousParam, "firstPage") : null;
1315
+ return [nextAccessor ? `getNextPageParam: (lastPage) => ${nextAccessor}` : null, prevAccessor ? `getPreviousPageParam: (firstPage) => ${prevAccessor}` : null];
1287
1316
  }
1288
- if (previousParam) {
1289
- const accessor = getNestedAccessor(previousParam, "firstPage");
1290
- if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
1291
- }
1292
- } else if (cursorParam) {
1293
- getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
1294
- getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
1295
- } else {
1296
- if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
1297
- else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
1298
- getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
1299
- }
1317
+ if (cursorParam) return [`getNextPageParam: (lastPage) => lastPage['${cursorParam}']`, `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`];
1318
+ 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"];
1319
+ })();
1300
1320
  const queryOptionsArr = [
1301
1321
  `initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
1302
1322
  getNextPageParamExpr,
@@ -1351,15 +1371,15 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
1351
1371
  })
1352
1372
  });
1353
1373
  }
1354
- SuspenseInfiniteQueryOptions.getParams = (node, options) => getQueryOptionsParams(node, options);
1355
1374
  //#endregion
1356
1375
  //#region src/components/SuspenseQuery.tsx
1357
1376
  const declarationPrinter = functionPrinter({ mode: "declaration" });
1358
1377
  const callPrinter = functionPrinter({ mode: "call" });
1359
- function getParams(node, options) {
1378
+ function buildSuspenseQueryParamsNode(node, options) {
1360
1379
  const { paramsType, paramsCasing, pathParamsType, dataReturnType, resolver } = options;
1361
- const responseName = resolver.resolveResponseName(node);
1362
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
1380
+ const successNames = resolveSuccessNames(node, resolver);
1381
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.resolveResponseName(node);
1382
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
1363
1383
  const errorNames = resolveErrorNames(node, resolver);
1364
1384
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1365
1385
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
@@ -1388,12 +1408,13 @@ function getParams(node, options) {
1388
1408
  });
1389
1409
  }
1390
1410
  function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, node, tsResolver, customOptions }) {
1391
- const responseName = tsResolver.resolveResponseName(node);
1411
+ const successNames = resolveSuccessNames(node, tsResolver);
1412
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : tsResolver.resolveResponseName(node);
1392
1413
  const errorNames = resolveErrorNames(node, tsResolver);
1393
1414
  const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
1394
1415
  const returnType = `UseSuspenseQueryResult<TData, ${`ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`}> & { queryKey: TQueryKey }`;
1395
1416
  const generics = [`TData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
1396
- const queryKeyParamsNode = QueryKey.getParams(node, {
1417
+ const queryKeyParamsNode = buildQueryKeyParams(node, {
1397
1418
  pathParamsType,
1398
1419
  paramsCasing,
1399
1420
  resolver: tsResolver
@@ -1406,7 +1427,7 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
1406
1427
  resolver: tsResolver
1407
1428
  });
1408
1429
  const queryOptionsParamsCall = callPrinter.print(queryOptionsParamsNode) ?? "";
1409
- const paramsNode = getParams(node, {
1430
+ const paramsNode = buildSuspenseQueryParamsNode(node, {
1410
1431
  paramsType,
1411
1432
  paramsCasing,
1412
1433
  pathParamsType,
@@ -1424,7 +1445,7 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
1424
1445
  generics: generics.join(", "),
1425
1446
  params: paramsSignature,
1426
1447
  returnType: void 0,
1427
- JSDoc: { comments: getComments(node) },
1448
+ JSDoc: { comments: buildOperationComments(node) },
1428
1449
  children: `
1429
1450
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
1430
1451
  const { client: queryClient, ...resolvedOptions } = queryConfig
@@ -1444,8 +1465,7 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
1444
1465
  })
1445
1466
  });
1446
1467
  }
1447
- SuspenseQuery.getParams = getParams;
1448
1468
  //#endregion
1449
- export { Mutation as a, InfiniteQuery as c, transformName as d, QueryKey as f, Query as i, QueryOptions as l, camelCase as m, SuspenseInfiniteQueryOptions as n, MutationOptions as o, MutationKey as p, SuspenseInfiniteQuery as r, InfiniteQueryOptions as s, SuspenseQuery as t, resolveOperationOverrides as u };
1469
+ export { mutationKeyTransformer as _, Mutation as a, InfiniteQuery as c, queryKeyTransformer as d, resolveOperationOverrides as f, MutationKey as g, resolveOperationTypeNames as h, Query as i, QueryOptions as l, getOperationParameters as m, SuspenseInfiniteQueryOptions as n, MutationOptions as o, resolveZodSchemaNames as p, SuspenseInfiniteQuery as r, InfiniteQueryOptions as s, SuspenseQuery as t, QueryKey as u, camelCase as v };
1450
1470
 
1451
- //# sourceMappingURL=components-DTGLu4UV.js.map
1471
+ //# sourceMappingURL=components-CDmg-RPi.js.map