@kubb/plugin-react-query 5.0.0-beta.100 → 5.0.0-beta.103

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
@@ -599,6 +599,19 @@ function resolveMutationConfig(mutation, options) {
599
599
  };
600
600
  }
601
601
  /**
602
+ * Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
603
+ * `query: false` still marks the operation as a query so the query-family generators keep matching it,
604
+ * and a method already claimed by `query` never counts as a mutation.
605
+ */
606
+ function classifyOperation(node, { query, mutation }) {
607
+ const isQuery = query === false || !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
608
+ const queryMethods = new Set(query ? query.methods : []);
609
+ return {
610
+ isQuery,
611
+ isMutation: mutation !== false && !isQuery && (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase())
612
+ };
613
+ }
614
+ /**
602
615
  * Applies the shared infinite-query defaults during plugin setup: a falsy value disables infinite
603
616
  * queries, and an object merges over `queryParam: 'id'` and `initialPageParam: 0` with the cursor
604
617
  * paths cleared.
@@ -968,19 +981,6 @@ function buildResolvedRequestParams(node) {
968
981
  if (names.length === 0) return null;
969
982
  return `{ ${names.map((name) => `${name}: typeof ${name} === 'function' ? ${name}() : ${name}`).join(", ")} }`;
970
983
  }
971
- /**
972
- * Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
973
- * `query: false` still marks the operation as a query so the query-family generators keep matching it,
974
- * and a method already claimed by `query` never counts as a mutation.
975
- */
976
- function classifyOperation(node, { query, mutation }) {
977
- const isQuery = query === false || !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
978
- const queryMethods = new Set(query ? query.methods : []);
979
- return {
980
- isQuery,
981
- isMutation: mutation !== false && !isQuery && (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase())
982
- };
983
- }
984
984
  //#endregion
985
985
  //#region src/generators/hookOptionsGenerator.tsx
986
986
  /**
@@ -1405,14 +1405,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
1405
1405
  //#region src/components/QueryOptions.tsx
1406
1406
  const declarationPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
1407
1407
  const callPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
1408
- function getQueryOptionsParams(node, options) {
1409
- return buildQueryOptionsParams(node, options);
1410
- }
1411
1408
  function QueryOptions({ name, clientName, node, tsResolver, queryKeyName }) {
1412
1409
  const { TData, TError } = buildResponseTypes(node, tsResolver);
1413
1410
  const queryKeyParamsNode = buildQueryKeyParams(node, { resolver: tsResolver });
1414
1411
  const queryKeyParamsCall = callPrinter.print(queryKeyParamsNode) ?? "";
1415
- const paramsNode = getQueryOptionsParams(node, { resolver: tsResolver });
1412
+ const paramsNode = buildQueryOptionsParams(node, { resolver: tsResolver });
1416
1413
  const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
1417
1414
  const queryFnBody = `const { data } = await ${buildClientCall(node, {
1418
1415
  clientName,
@@ -1494,8 +1491,11 @@ const infiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
1494
1491
  group: pluginTs.options?.group ?? void 0
1495
1492
  })
1496
1493
  };
1497
- const rawQueryParams = getOperationParameters(node).query;
1498
- const queryParamsTypeName = rawQueryParams.length > 0 && tsResolver.param.query(node, rawQueryParams[0]) !== tsResolver.param.name(node, rawQueryParams[0]) ? tsResolver.param.query(node, rawQueryParams[0]) : null;
1494
+ const { queryParamsTypeName } = resolvePageParamType(node, {
1495
+ resolver: tsResolver,
1496
+ initialPageParam: infiniteOptions.initialPageParam,
1497
+ queryParam: infiniteOptions.queryParam
1498
+ });
1499
1499
  const importedTypeNames = [
1500
1500
  tsResolver.response.options(node),
1501
1501
  queryParamsTypeName,