@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.cjs +46 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +46 -36
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -697,6 +697,19 @@ const requestGroupOrder$1 = [
|
|
|
697
697
|
"headers"
|
|
698
698
|
];
|
|
699
699
|
/**
|
|
700
|
+
* Widens a request-group member type so a generated TanStack hook accepts either the value or a
|
|
701
|
+
* deferred value. Both plugins apply this through the `memberTypeWrapper` of `buildGroupedRequestParam`;
|
|
702
|
+
* they only differ in how the deferred form is later resolved.
|
|
703
|
+
*
|
|
704
|
+
* `maybeRefOrGetter` is used by vue-query, which keeps the ref/getter live and unwraps it lazily with
|
|
705
|
+
* `toValue` because vue-query keys are reactive. `maybeValueOrGetter` is used by react-query, which
|
|
706
|
+
* resolves the getter once at the hook boundary and forwards a plain value because React Query hashes
|
|
707
|
+
* keys structurally and cannot hold a function.
|
|
708
|
+
*/
|
|
709
|
+
function maybeRefOrGetter(type) {
|
|
710
|
+
return `MaybeRefOrGetter<${type}>`;
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
700
713
|
* Builds the grouped `{ path, query, body, headers }` parameter that mirrors the client
|
|
701
714
|
* function signature. Only the groups the operation carries are emitted, typed from the
|
|
702
715
|
* operation's `RequestConfig`. `keys` narrows the emitted groups, used by the query key which
|
|
@@ -818,12 +831,6 @@ const queryKeyTransformer = ({ node }) => {
|
|
|
818
831
|
};
|
|
819
832
|
//#endregion
|
|
820
833
|
//#region src/utils.ts
|
|
821
|
-
/**
|
|
822
|
-
* Wraps a type string in `MaybeRefOrGetter<…>` so a vue-query signature accepts refs or getters.
|
|
823
|
-
*/
|
|
824
|
-
function maybeRefOrGetter(type) {
|
|
825
|
-
return `MaybeRefOrGetter<${type}>`;
|
|
826
|
-
}
|
|
827
834
|
const requestGroupOrder = [
|
|
828
835
|
"path",
|
|
829
836
|
"query",
|
|
@@ -1267,7 +1274,7 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1267
1274
|
operation(node, ctx) {
|
|
1268
1275
|
if (!_kubb_core.ast.isHttpOperationNode(node)) return null;
|
|
1269
1276
|
const { config, driver, resolver, root } = ctx;
|
|
1270
|
-
const { output, query, mutation, infinite, validator, client, group } = ctx.options;
|
|
1277
|
+
const { output, query, mutation, infinite, validator, client, group, hooks } = ctx.options;
|
|
1271
1278
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1272
1279
|
if (!pluginTs) return null;
|
|
1273
1280
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1406,30 +1413,32 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1406
1413
|
initialPageParam: infiniteOptions.initialPageParam,
|
|
1407
1414
|
queryParam: infiniteOptions.queryParam
|
|
1408
1415
|
}),
|
|
1409
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1416
|
+
hooks && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1417
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1418
|
+
name: ["useInfiniteQuery"],
|
|
1419
|
+
path: importPath
|
|
1420
|
+
}),
|
|
1421
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1422
|
+
name: [
|
|
1423
|
+
"QueryKey",
|
|
1424
|
+
"QueryClient",
|
|
1425
|
+
"UseInfiniteQueryOptions",
|
|
1426
|
+
"UseInfiniteQueryReturnType"
|
|
1427
|
+
],
|
|
1428
|
+
path: importPath,
|
|
1429
|
+
isTypeOnly: true
|
|
1430
|
+
}),
|
|
1431
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(InfiniteQuery, {
|
|
1432
|
+
name: queryName,
|
|
1433
|
+
queryOptionsName,
|
|
1434
|
+
queryKeyName,
|
|
1435
|
+
queryKeyTypeName,
|
|
1436
|
+
node,
|
|
1437
|
+
tsResolver,
|
|
1438
|
+
initialPageParam: infiniteOptions.initialPageParam,
|
|
1439
|
+
queryParam: infiniteOptions.queryParam
|
|
1440
|
+
})
|
|
1441
|
+
] })
|
|
1433
1442
|
]
|
|
1434
1443
|
});
|
|
1435
1444
|
}
|
|
@@ -1447,7 +1456,7 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1447
1456
|
operation(node, ctx) {
|
|
1448
1457
|
if (!_kubb_core.ast.isHttpOperationNode(node)) return null;
|
|
1449
1458
|
const { config, driver, resolver, root } = ctx;
|
|
1450
|
-
const { output, query, mutation, validator, client, group } = ctx.options;
|
|
1459
|
+
const { output, query, mutation, validator, client, group, hooks } = ctx.options;
|
|
1451
1460
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1452
1461
|
if (!pluginTs) return null;
|
|
1453
1462
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1550,7 +1559,7 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1550
1559
|
node,
|
|
1551
1560
|
transformer: ctx.options.mutationKey
|
|
1552
1561
|
}),
|
|
1553
|
-
mutation && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1562
|
+
mutation && hooks && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1554
1563
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1555
1564
|
name: ["useMutation"],
|
|
1556
1565
|
path: importPath
|
|
@@ -1586,7 +1595,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1586
1595
|
operation(node, ctx) {
|
|
1587
1596
|
if (!_kubb_core.ast.isHttpOperationNode(node)) return null;
|
|
1588
1597
|
const { config, driver, resolver, root } = ctx;
|
|
1589
|
-
const { output, query, mutation, validator, client, group } = ctx.options;
|
|
1598
|
+
const { output, query, mutation, validator, client, group, hooks } = ctx.options;
|
|
1590
1599
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1591
1600
|
if (!pluginTs) return null;
|
|
1592
1601
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1703,7 +1712,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1703
1712
|
node,
|
|
1704
1713
|
tsResolver
|
|
1705
1714
|
}),
|
|
1706
|
-
query && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1715
|
+
query && hooks && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1707
1716
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1708
1717
|
name: ["useQuery"],
|
|
1709
1718
|
path: importPath
|
|
@@ -1839,7 +1848,7 @@ const pluginVueQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
1839
1848
|
const { output = {
|
|
1840
1849
|
path: "hooks",
|
|
1841
1850
|
barrel: { type: "named" }
|
|
1842
|
-
}, group, exclude = [], include, override = [], validator = false, infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, client, resolver: userResolver, macros: userMacros } = options;
|
|
1851
|
+
}, group, exclude = [], include, override = [], validator = false, infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, hooks = false, client, resolver: userResolver, macros: userMacros } = options;
|
|
1843
1852
|
const selectedGenerators = [
|
|
1844
1853
|
queryGenerator,
|
|
1845
1854
|
infiniteQueryGenerator,
|
|
@@ -1892,6 +1901,7 @@ const pluginVueQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
1892
1901
|
previousParam: null,
|
|
1893
1902
|
...infinite
|
|
1894
1903
|
} : false,
|
|
1904
|
+
hooks,
|
|
1895
1905
|
validator,
|
|
1896
1906
|
group: groupConfig,
|
|
1897
1907
|
exclude,
|