@kubb/plugin-react-query 5.8.0-canary.20261028T230157 → 5.8.0-canary.20261029T082933

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.
package/dist/index.cjs CHANGED
@@ -510,7 +510,7 @@ var compatibility = {
510
510
  "node": ">=22.22"
511
511
  };
512
512
  // package.json
513
- var version = "5.8.0-canary.20261028T230157";
513
+ var version = "5.8.0-canary.20261029T082933";
514
514
  // ../../internals/client/src/resolveOperationTypes.ts
515
515
  /**
516
516
  * A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
@@ -551,32 +551,34 @@ function toZodTypeResolver(resolver) {
551
551
  * ```
552
552
  */
553
553
  function resolveOperationTypes(driver, pluginName) {
554
- const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
555
- const pluginZod = driver.getPlugin(_kubb_plugin_zod.pluginZodName);
556
- if (pluginTs && pluginZod?.options?.inferred !== "codec") {
557
- const resolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
554
+ return driver.memo(`operationTypes:${pluginName}`, () => {
555
+ const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
556
+ const pluginZod = driver.getPlugin(_kubb_plugin_zod.pluginZodName);
557
+ if (pluginTs && pluginZod?.options?.inferred !== "codec") {
558
+ const resolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
559
+ return {
560
+ response: resolver.response,
561
+ resolver,
562
+ output: pluginTs.options?.output,
563
+ group: pluginTs.options?.group ?? void 0
564
+ };
565
+ }
566
+ if (!pluginZod?.options?.inferred) throw new kubb_kit.Diagnostics.Error({
567
+ code: kubb_kit.Diagnostics.code.missingDependency,
568
+ severity: "error",
569
+ message: `Plugin "${pluginName}" has no source for operation types.`,
570
+ help: `Add \`pluginTs()\` before "${pluginName}", or add \`pluginZod({ inferred: true })\`.`,
571
+ location: { kind: "config" },
572
+ plugin: pluginName
573
+ });
574
+ const resolver = toZodTypeResolver(driver.getResolver(_kubb_plugin_zod.pluginZodName));
558
575
  return {
559
576
  response: resolver.response,
560
577
  resolver,
561
- output: pluginTs.options?.output,
562
- group: pluginTs.options?.group ?? void 0
578
+ output: pluginZod.options.output,
579
+ group: pluginZod.options.group ?? void 0
563
580
  };
564
- }
565
- if (!pluginZod?.options?.inferred) throw new kubb_kit.Diagnostics.Error({
566
- code: kubb_kit.Diagnostics.code.missingDependency,
567
- severity: "error",
568
- message: `Plugin "${pluginName}" has no source for operation types.`,
569
- help: `Add \`pluginTs()\` before "${pluginName}", or add \`pluginZod({ inferred: true })\`.`,
570
- location: { kind: "config" },
571
- plugin: pluginName
572
581
  });
573
- const resolver = toZodTypeResolver(driver.getResolver(_kubb_plugin_zod.pluginZodName));
574
- return {
575
- response: resolver.response,
576
- resolver,
577
- output: pluginZod.options.output,
578
- group: pluginZod.options.group ?? void 0
579
- };
580
582
  }
581
583
  // ../../internals/client/src/resolveClient.ts
582
584
  /**
@@ -977,13 +979,15 @@ function buildCallResultBody(call, options = {}) {
977
979
  * success responses into `TData` and wrapping the error responses in `ResponseErrorConfig<...>`.
978
980
  */
979
981
  function buildResponseTypes(node, resolver) {
980
- const successNames = resolveSuccessNames(node, resolver);
981
- const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.response.response(node);
982
- const errorNames = resolveErrorNames(node, resolver);
983
- return {
984
- TData: responseName,
985
- TError: `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`
986
- };
982
+ return resolver.memo(`responseTypes:${node.method}\0${node.path}`, () => {
983
+ const successNames = resolveSuccessNames(node, resolver);
984
+ const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.response.response(node);
985
+ const errorNames = resolveErrorNames(node, resolver);
986
+ return {
987
+ TData: responseName,
988
+ TError: `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`
989
+ };
990
+ });
987
991
  }
988
992
  function resolveFallbackPageParamType(initialPageParam) {
989
993
  if (typeof initialPageParam === "number") return "number";
@@ -1371,20 +1375,13 @@ function createQueryResolver(variant = "") {
1371
1375
  key: operationKey(node, "query", variant, "keyTypeName"),
1372
1376
  name
1373
1377
  });
1374
- },
1375
- clientName(node) {
1376
- const name = `${this.name(node.operationId)}${variant}`;
1377
- return this.resolveName({
1378
- key: operationKey(node, "query", variant, "clientName"),
1379
- name
1380
- });
1381
1378
  }
1382
1379
  };
1383
1380
  }
1384
1381
  /**
1385
1382
  * Builds the shared mutation namespace. Spread the result into
1386
1383
  * `createResolver` and add plugin-specific methods (`optionsName`,
1387
- * `typeName`, `argTypeName`) next to it.
1384
+ * `argTypeName`) next to it.
1388
1385
  *
1389
1386
  * @example
1390
1387
  * ```ts
@@ -1600,93 +1597,35 @@ const hookOptionsGenerator = (0, kubb_kit.defineGenerator)({
1600
1597
  const nodeMutation = "mutation" in opOverrides ? opOverrides.mutation : mutation;
1601
1598
  const nodeInfinite = "infinite" in opOverrides ? opOverrides.infinite : infinite;
1602
1599
  const nodeInfiniteOptions = nodeInfinite && typeof nodeInfinite === "object" ? nodeInfinite : null;
1603
- const { isQuery: isQueryOp, isMutation: isMutationOp } = classifyOperation(node, {
1604
- query: nodeQuery === false ? query : nodeQuery,
1600
+ const { isQuery, isMutation } = classifyOperation(node, {
1601
+ query: nodeQuery,
1605
1602
  mutation: nodeMutation
1606
1603
  });
1607
- const isSuspenseOp = !!suspense;
1608
- const isInfiniteOp = !!nodeInfiniteOptions;
1609
- if (isQueryOp) {
1610
- const queryOptionsName = resolver.query.optionsName(node);
1611
- const queryHookName = resolver.query.name(node);
1612
- const queryHookFile = resolver.file({
1613
- ...operationFileEntry(node, queryHookName),
1614
- root,
1615
- output,
1616
- group: group ?? void 0
1617
- });
1618
- imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1619
- name: [queryOptionsName],
1620
- root: hookOptionsFile.path,
1621
- path: queryHookFile.path
1622
- }));
1623
- hookOptions[queryHookName] = `Partial<ReturnType<typeof ${queryOptionsName}>>`;
1624
- if (isSuspenseOp) {
1625
- const suspenseOptionsName = resolver.suspenseQuery.optionsName(node);
1626
- const suspenseHookName = resolver.suspenseQuery.name(node);
1627
- const suspenseHookFile = resolver.file({
1628
- ...operationFileEntry(node, suspenseHookName),
1629
- root,
1630
- output,
1631
- group: group ?? void 0
1632
- });
1633
- imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1634
- name: [suspenseOptionsName],
1635
- root: hookOptionsFile.path,
1636
- path: suspenseHookFile.path
1637
- }));
1638
- hookOptions[suspenseHookName] = `Partial<ReturnType<typeof ${suspenseOptionsName}>>`;
1639
- }
1640
- if (isInfiniteOp) {
1641
- if (matchesInfinite(node, nodeInfiniteOptions)) {
1642
- const infiniteOptionsName = resolver.infiniteQuery.optionsName(node);
1643
- const infiniteHookName = resolver.infiniteQuery.name(node);
1644
- const infiniteHookFile = resolver.file({
1645
- ...operationFileEntry(node, infiniteHookName),
1646
- root,
1647
- output,
1648
- group: group ?? void 0
1649
- });
1650
- imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1651
- name: [infiniteOptionsName],
1652
- root: hookOptionsFile.path,
1653
- path: infiniteHookFile.path
1654
- }));
1655
- hookOptions[infiniteHookName] = `Partial<ReturnType<typeof ${infiniteOptionsName}>>`;
1656
- if (isSuspenseOp) {
1657
- const suspenseInfiniteOptionsName = resolver.suspenseInfiniteQuery.optionsName(node);
1658
- const suspenseInfiniteHookName = resolver.suspenseInfiniteQuery.name(node);
1659
- const suspenseInfiniteHookFile = resolver.file({
1660
- ...operationFileEntry(node, suspenseInfiniteHookName),
1661
- root,
1662
- output,
1663
- group: group ?? void 0
1664
- });
1665
- imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1666
- name: [suspenseInfiniteOptionsName],
1667
- root: hookOptionsFile.path,
1668
- path: suspenseInfiniteHookFile.path
1669
- }));
1670
- hookOptions[suspenseInfiniteHookName] = `Partial<ReturnType<typeof ${suspenseInfiniteOptionsName}>>`;
1671
- }
1672
- }
1673
- }
1674
- }
1675
- if (isMutationOp) {
1676
- const mutationOptionsName = resolver.mutation.optionsName(node);
1677
- const mutationHookName = resolver.mutation.name(node);
1678
- const mutationHookFile = resolver.file({
1679
- ...operationFileEntry(node, mutationHookName),
1604
+ const isSuspense = !!suspense;
1605
+ const isInfinite = isQuery && !!nodeInfiniteOptions && matchesInfinite(node, nodeInfiniteOptions);
1606
+ const namespaces = [
1607
+ [resolver.query, isQuery],
1608
+ [resolver.suspenseQuery, isQuery && isSuspense],
1609
+ [resolver.infiniteQuery, isInfinite],
1610
+ [resolver.suspenseInfiniteQuery, isInfinite && isSuspense],
1611
+ [resolver.mutation, isMutation]
1612
+ ];
1613
+ for (const [ns, enabled] of namespaces) {
1614
+ if (!enabled) continue;
1615
+ const optionsName = ns.optionsName(node);
1616
+ const hookName = ns.name(node);
1617
+ const hookFile = resolver.file({
1618
+ ...operationFileEntry(node, hookName),
1680
1619
  root,
1681
1620
  output,
1682
1621
  group: group ?? void 0
1683
1622
  });
1684
1623
  imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1685
- name: [mutationOptionsName],
1624
+ name: [optionsName],
1686
1625
  root: hookOptionsFile.path,
1687
- path: mutationHookFile.path
1626
+ path: hookFile.path
1688
1627
  }));
1689
- hookOptions[mutationHookName] = `Partial<ReturnType<typeof ${mutationOptionsName}>>`;
1628
+ hookOptions[hookName] = `Partial<ReturnType<typeof ${optionsName}>>`;
1690
1629
  }
1691
1630
  }
1692
1631
  return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
@@ -2306,13 +2245,6 @@ const resolverReactQuery = (0, kubb_kit.createResolver)({
2306
2245
  key: operationKey(node, "mutation", "optionsName"),
2307
2246
  name
2308
2247
  });
2309
- },
2310
- typeName(node) {
2311
- const name = capitalize(this.name(node.operationId));
2312
- return this.resolveName({
2313
- key: operationKey(node, "mutation", "typeName"),
2314
- name
2315
- });
2316
2248
  }
2317
2249
  },
2318
2250
  hook: {