@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.js CHANGED
@@ -572,6 +572,19 @@ function resolveMutationConfig(mutation, options) {
572
572
  };
573
573
  }
574
574
  /**
575
+ * Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
576
+ * `query: false` still marks the operation as a query so the query-family generators keep matching it,
577
+ * and a method already claimed by `query` never counts as a mutation.
578
+ */
579
+ function classifyOperation(node, { query, mutation }) {
580
+ const isQuery = query === false || !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
581
+ const queryMethods = new Set(query ? query.methods : []);
582
+ return {
583
+ isQuery,
584
+ isMutation: mutation !== false && !isQuery && (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase())
585
+ };
586
+ }
587
+ /**
575
588
  * Applies the shared infinite-query defaults during plugin setup: a falsy value disables infinite
576
589
  * queries, and an object merges over `queryParam: 'id'` and `initialPageParam: 0` with the cursor
577
590
  * paths cleared.
@@ -941,19 +954,6 @@ function buildResolvedRequestParams(node) {
941
954
  if (names.length === 0) return null;
942
955
  return `{ ${names.map((name) => `${name}: typeof ${name} === 'function' ? ${name}() : ${name}`).join(", ")} }`;
943
956
  }
944
- /**
945
- * Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
946
- * `query: false` still marks the operation as a query so the query-family generators keep matching it,
947
- * and a method already claimed by `query` never counts as a mutation.
948
- */
949
- function classifyOperation(node, { query, mutation }) {
950
- const isQuery = query === false || !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
951
- const queryMethods = new Set(query ? query.methods : []);
952
- return {
953
- isQuery,
954
- isMutation: mutation !== false && !isQuery && (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase())
955
- };
956
- }
957
957
  //#endregion
958
958
  //#region src/generators/hookOptionsGenerator.tsx
959
959
  /**
@@ -1378,14 +1378,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
1378
1378
  //#region src/components/QueryOptions.tsx
1379
1379
  const declarationPrinter = functionPrinter({ mode: "declaration" });
1380
1380
  const callPrinter = functionPrinter({ mode: "call" });
1381
- function getQueryOptionsParams(node, options) {
1382
- return buildQueryOptionsParams(node, options);
1383
- }
1384
1381
  function QueryOptions({ name, clientName, node, tsResolver, queryKeyName }) {
1385
1382
  const { TData, TError } = buildResponseTypes(node, tsResolver);
1386
1383
  const queryKeyParamsNode = buildQueryKeyParams(node, { resolver: tsResolver });
1387
1384
  const queryKeyParamsCall = callPrinter.print(queryKeyParamsNode) ?? "";
1388
- const paramsNode = getQueryOptionsParams(node, { resolver: tsResolver });
1385
+ const paramsNode = buildQueryOptionsParams(node, { resolver: tsResolver });
1389
1386
  const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
1390
1387
  const queryFnBody = `const { data } = await ${buildClientCall(node, {
1391
1388
  clientName,
@@ -1467,8 +1464,11 @@ const infiniteQueryGenerator = defineGenerator({
1467
1464
  group: pluginTs.options?.group ?? void 0
1468
1465
  })
1469
1466
  };
1470
- const rawQueryParams = getOperationParameters(node).query;
1471
- const queryParamsTypeName = rawQueryParams.length > 0 && tsResolver.param.query(node, rawQueryParams[0]) !== tsResolver.param.name(node, rawQueryParams[0]) ? tsResolver.param.query(node, rawQueryParams[0]) : null;
1467
+ const { queryParamsTypeName } = resolvePageParamType(node, {
1468
+ resolver: tsResolver,
1469
+ initialPageParam: infiniteOptions.initialPageParam,
1470
+ queryParam: infiniteOptions.queryParam
1471
+ });
1472
1472
  const importedTypeNames = [
1473
1473
  tsResolver.response.options(node),
1474
1474
  queryParamsTypeName,