@kubb/plugin-vue-query 5.0.0-beta.79 → 5.0.0-beta.80

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.d.ts CHANGED
@@ -387,6 +387,13 @@ type Options = OutputOptions & {
387
387
  * Override how composable names and file paths are built.
388
388
  */
389
389
  resolver?: Partial<ResolverVueQuery> & ThisType<ResolverVueQuery>;
390
+ /**
391
+ * Set to `false` to skip generating `use*` composable functions. `queryOptions`,
392
+ * `mutationOptions`, `queryKey`, and `mutationKey` helpers are still emitted.
393
+ *
394
+ * @default false
395
+ */
396
+ hooks?: boolean;
390
397
  /**
391
398
  * Macros applied to each operation node before printing.
392
399
  */
@@ -419,6 +426,7 @@ type ResolvedOptions = {
419
426
  query: NonNullable<Required<Query>> | false;
420
427
  mutationKey: MutationKey | null;
421
428
  mutation: NonNullable<Required<Mutation>> | false;
429
+ hooks: boolean;
422
430
  resolver: ResolverVueQuery;
423
431
  };
424
432
  type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, ResolverVueQuery>;
package/dist/index.js CHANGED
@@ -671,6 +671,19 @@ const requestGroupOrder$1 = [
671
671
  "headers"
672
672
  ];
673
673
  /**
674
+ * Widens a request-group member type so a generated TanStack hook accepts either the value or a
675
+ * deferred value. Both plugins apply this through the `memberTypeWrapper` of `buildGroupedRequestParam`;
676
+ * they only differ in how the deferred form is later resolved.
677
+ *
678
+ * `maybeRefOrGetter` is used by vue-query, which keeps the ref/getter live and unwraps it lazily with
679
+ * `toValue` because vue-query keys are reactive. `maybeValueOrGetter` is used by react-query, which
680
+ * resolves the getter once at the hook boundary and forwards a plain value because React Query hashes
681
+ * keys structurally and cannot hold a function.
682
+ */
683
+ function maybeRefOrGetter(type) {
684
+ return `MaybeRefOrGetter<${type}>`;
685
+ }
686
+ /**
674
687
  * Builds the grouped `{ path, query, body, headers }` parameter that mirrors the client
675
688
  * function signature. Only the groups the operation carries are emitted, typed from the
676
689
  * operation's `RequestConfig`. `keys` narrows the emitted groups, used by the query key which
@@ -792,12 +805,6 @@ const queryKeyTransformer = ({ node }) => {
792
805
  };
793
806
  //#endregion
794
807
  //#region src/utils.ts
795
- /**
796
- * Wraps a type string in `MaybeRefOrGetter<…>` so a vue-query signature accepts refs or getters.
797
- */
798
- function maybeRefOrGetter(type) {
799
- return `MaybeRefOrGetter<${type}>`;
800
- }
801
808
  const requestGroupOrder = [
802
809
  "path",
803
810
  "query",
@@ -1241,7 +1248,7 @@ const infiniteQueryGenerator = defineGenerator({
1241
1248
  operation(node, ctx) {
1242
1249
  if (!ast.isHttpOperationNode(node)) return null;
1243
1250
  const { config, driver, resolver, root } = ctx;
1244
- const { output, query, mutation, infinite, validator, client, group } = ctx.options;
1251
+ const { output, query, mutation, infinite, validator, client, group, hooks } = ctx.options;
1245
1252
  const pluginTs = driver.getPlugin(pluginTsName);
1246
1253
  if (!pluginTs) return null;
1247
1254
  const tsResolver = driver.getResolver(pluginTsName);
@@ -1380,30 +1387,32 @@ const infiniteQueryGenerator = defineGenerator({
1380
1387
  initialPageParam: infiniteOptions.initialPageParam,
1381
1388
  queryParam: infiniteOptions.queryParam
1382
1389
  }),
1383
- /* @__PURE__ */ jsx(File.Import, {
1384
- name: ["useInfiniteQuery"],
1385
- path: importPath
1386
- }),
1387
- /* @__PURE__ */ jsx(File.Import, {
1388
- name: [
1389
- "QueryKey",
1390
- "QueryClient",
1391
- "UseInfiniteQueryOptions",
1392
- "UseInfiniteQueryReturnType"
1393
- ],
1394
- path: importPath,
1395
- isTypeOnly: true
1396
- }),
1397
- /* @__PURE__ */ jsx(InfiniteQuery, {
1398
- name: queryName,
1399
- queryOptionsName,
1400
- queryKeyName,
1401
- queryKeyTypeName,
1402
- node,
1403
- tsResolver,
1404
- initialPageParam: infiniteOptions.initialPageParam,
1405
- queryParam: infiniteOptions.queryParam
1406
- })
1390
+ hooks && /* @__PURE__ */ jsxs(Fragment, { children: [
1391
+ /* @__PURE__ */ jsx(File.Import, {
1392
+ name: ["useInfiniteQuery"],
1393
+ path: importPath
1394
+ }),
1395
+ /* @__PURE__ */ jsx(File.Import, {
1396
+ name: [
1397
+ "QueryKey",
1398
+ "QueryClient",
1399
+ "UseInfiniteQueryOptions",
1400
+ "UseInfiniteQueryReturnType"
1401
+ ],
1402
+ path: importPath,
1403
+ isTypeOnly: true
1404
+ }),
1405
+ /* @__PURE__ */ jsx(InfiniteQuery, {
1406
+ name: queryName,
1407
+ queryOptionsName,
1408
+ queryKeyName,
1409
+ queryKeyTypeName,
1410
+ node,
1411
+ tsResolver,
1412
+ initialPageParam: infiniteOptions.initialPageParam,
1413
+ queryParam: infiniteOptions.queryParam
1414
+ })
1415
+ ] })
1407
1416
  ]
1408
1417
  });
1409
1418
  }
@@ -1421,7 +1430,7 @@ const mutationGenerator = defineGenerator({
1421
1430
  operation(node, ctx) {
1422
1431
  if (!ast.isHttpOperationNode(node)) return null;
1423
1432
  const { config, driver, resolver, root } = ctx;
1424
- const { output, query, mutation, validator, client, group } = ctx.options;
1433
+ const { output, query, mutation, validator, client, group, hooks } = ctx.options;
1425
1434
  const pluginTs = driver.getPlugin(pluginTsName);
1426
1435
  if (!pluginTs) return null;
1427
1436
  const tsResolver = driver.getResolver(pluginTsName);
@@ -1524,7 +1533,7 @@ const mutationGenerator = defineGenerator({
1524
1533
  node,
1525
1534
  transformer: ctx.options.mutationKey
1526
1535
  }),
1527
- mutation && /* @__PURE__ */ jsxs(Fragment, { children: [
1536
+ mutation && hooks && /* @__PURE__ */ jsxs(Fragment, { children: [
1528
1537
  /* @__PURE__ */ jsx(File.Import, {
1529
1538
  name: ["useMutation"],
1530
1539
  path: importPath
@@ -1560,7 +1569,7 @@ const queryGenerator = defineGenerator({
1560
1569
  operation(node, ctx) {
1561
1570
  if (!ast.isHttpOperationNode(node)) return null;
1562
1571
  const { config, driver, resolver, root } = ctx;
1563
- const { output, query, mutation, validator, client, group } = ctx.options;
1572
+ const { output, query, mutation, validator, client, group, hooks } = ctx.options;
1564
1573
  const pluginTs = driver.getPlugin(pluginTsName);
1565
1574
  if (!pluginTs) return null;
1566
1575
  const tsResolver = driver.getResolver(pluginTsName);
@@ -1677,7 +1686,7 @@ const queryGenerator = defineGenerator({
1677
1686
  node,
1678
1687
  tsResolver
1679
1688
  }),
1680
- query && /* @__PURE__ */ jsxs(Fragment, { children: [
1689
+ query && hooks && /* @__PURE__ */ jsxs(Fragment, { children: [
1681
1690
  /* @__PURE__ */ jsx(File.Import, {
1682
1691
  name: ["useQuery"],
1683
1692
  path: importPath
@@ -1813,7 +1822,7 @@ const pluginVueQuery = definePlugin((options) => {
1813
1822
  const { output = {
1814
1823
  path: "hooks",
1815
1824
  barrel: { type: "named" }
1816
- }, group, exclude = [], include, override = [], validator = false, infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, client, resolver: userResolver, macros: userMacros } = options;
1825
+ }, group, exclude = [], include, override = [], validator = false, infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, hooks = false, client, resolver: userResolver, macros: userMacros } = options;
1817
1826
  const selectedGenerators = [
1818
1827
  queryGenerator,
1819
1828
  infiniteQueryGenerator,
@@ -1866,6 +1875,7 @@ const pluginVueQuery = definePlugin((options) => {
1866
1875
  previousParam: null,
1867
1876
  ...infinite
1868
1877
  } : false,
1878
+ hooks,
1869
1879
  validator,
1870
1880
  group: groupConfig,
1871
1881
  exclude,