@kubb/plugin-vue-query 5.2.0-canary.20261007T095624 → 5.2.1
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 +29 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +16 -5
- package/dist/index.js +29 -22
- package/dist/index.js.map +1 -1
- package/package.json +10 -13
package/dist/index.cjs
CHANGED
|
@@ -676,7 +676,8 @@ function MutationKey({ name, node, transformer }) {
|
|
|
676
676
|
const paramsSignature = declarationPrinter$6.print(paramsNode) ?? "";
|
|
677
677
|
const keys = (transformer ?? mutationKeyTransformer)({
|
|
678
678
|
node,
|
|
679
|
-
casing: "camelcase"
|
|
679
|
+
casing: "camelcase",
|
|
680
|
+
variant: "mutation"
|
|
680
681
|
});
|
|
681
682
|
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
682
683
|
name,
|
|
@@ -745,16 +746,17 @@ function createMutationResolver() {
|
|
|
745
746
|
};
|
|
746
747
|
}
|
|
747
748
|
(0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
748
|
-
const queryKeyTransformer = ({ node }) => {
|
|
749
|
+
const queryKeyTransformer = ({ node, variant }) => {
|
|
749
750
|
if (!node.path) return [];
|
|
750
|
-
const
|
|
751
|
-
const
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
].
|
|
751
|
+
const { path, query } = getOperationParameters(node);
|
|
752
|
+
const isInfinite = variant === "infiniteQuery" || variant === "suspenseInfiniteQuery";
|
|
753
|
+
const urlFields = [`url: '${kubb_kit.Url.toPath(node.path)}'`];
|
|
754
|
+
if (path.length > 0) urlFields.push("params: path");
|
|
755
|
+
if (isInfinite) urlFields.push("infinite: true");
|
|
756
|
+
const result = [`{ ${urlFields.join(", ")} }`];
|
|
757
|
+
if (query.length > 0) result.push("...(query ? [query] : [])");
|
|
758
|
+
if (node.requestBody?.content?.[0]?.schema) result.push("...(body ? [body] : [])");
|
|
759
|
+
return result;
|
|
758
760
|
};
|
|
759
761
|
//#endregion
|
|
760
762
|
//#region ../../internals/client/src/resolveClient.ts
|
|
@@ -767,8 +769,8 @@ const queryKeyTransformer = ({ node }) => {
|
|
|
767
769
|
*
|
|
768
770
|
* - `contract` — a registered contract client plugin owns the `<op>` functions and the consumer
|
|
769
771
|
* imports and calls them.
|
|
770
|
-
* - `error` — no client plugin is registered, several are registered without a selector,
|
|
771
|
-
* requested one is missing.
|
|
772
|
+
* - `error` — no client plugin is registered, several are registered without a selector, the
|
|
773
|
+
* requested one is missing, or `client` is not a known selector.
|
|
772
774
|
*
|
|
773
775
|
* The `client` string selects explicitly (`'fetch'` / `'axios'`); when it is unset a lone registered
|
|
774
776
|
* contract client plugin is picked up automatically.
|
|
@@ -809,6 +811,10 @@ function resolveClient(options) {
|
|
|
809
811
|
pluginName
|
|
810
812
|
};
|
|
811
813
|
}
|
|
814
|
+
if (client !== void 0) return {
|
|
815
|
+
kind: "error",
|
|
816
|
+
message: `Option \`client\` is ${typeof client === "string" ? `'${client}'` : String(client)}, but it must be one of 'fetch', 'axios'. Drop \`client\` to use the registered client plugin.`
|
|
817
|
+
};
|
|
812
818
|
const registered = contractPlugins.filter(has);
|
|
813
819
|
if (registered.length === 1) return {
|
|
814
820
|
kind: "contract",
|
|
@@ -910,12 +916,13 @@ function buildQueryKeyParamsNode(node, options) {
|
|
|
910
916
|
});
|
|
911
917
|
return (0, _kubb_plugin_ts.createFunctionParameters)({ params: groupedParam ? [groupedParam] : [] });
|
|
912
918
|
}
|
|
913
|
-
function QueryKey({ name, node, tsResolver, typeName, transformer }) {
|
|
919
|
+
function QueryKey({ name, node, tsResolver, typeName, transformer, variant = "query" }) {
|
|
914
920
|
const paramsNode = buildQueryKeyParamsNode(node, { resolver: tsResolver });
|
|
915
921
|
const paramsSignature = declarationPrinter$4.print(paramsNode) ?? "";
|
|
916
922
|
const keys = (transformer ?? queryKeyTransformer)({
|
|
917
923
|
node,
|
|
918
|
-
casing: "camelcase"
|
|
924
|
+
casing: "camelcase",
|
|
925
|
+
variant
|
|
919
926
|
});
|
|
920
927
|
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
921
928
|
name,
|
|
@@ -1219,8 +1226,7 @@ const infiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1219
1226
|
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1220
1227
|
const { config, driver, resolver, root } = ctx;
|
|
1221
1228
|
const { output, query, mutation, infinite, client, group, hooks } = ctx.options;
|
|
1222
|
-
const pluginTs =
|
|
1223
|
-
if (!pluginTs) return null;
|
|
1229
|
+
const pluginTs = ctx.requirePlugin(_kubb_plugin_ts.pluginTsName);
|
|
1224
1230
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
1225
1231
|
const { isQuery, isMutation } = classifyOperation(node, {
|
|
1226
1232
|
query,
|
|
@@ -1328,7 +1334,8 @@ const infiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1328
1334
|
typeName: queryKeyTypeName,
|
|
1329
1335
|
node,
|
|
1330
1336
|
tsResolver,
|
|
1331
|
-
transformer: ctx.options.queryKey
|
|
1337
|
+
transformer: ctx.options.queryKey,
|
|
1338
|
+
variant: "infiniteQuery"
|
|
1332
1339
|
}),
|
|
1333
1340
|
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1334
1341
|
name: ["InfiniteData"],
|
|
@@ -1394,8 +1401,7 @@ const mutationGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1394
1401
|
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1395
1402
|
const { config, driver, resolver, root } = ctx;
|
|
1396
1403
|
const { output, query, mutation, client, group, hooks } = ctx.options;
|
|
1397
|
-
const pluginTs =
|
|
1398
|
-
if (!pluginTs) return null;
|
|
1404
|
+
const pluginTs = ctx.requirePlugin(_kubb_plugin_ts.pluginTsName);
|
|
1399
1405
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
1400
1406
|
const { isMutation } = classifyOperation(node, {
|
|
1401
1407
|
query,
|
|
@@ -1528,8 +1534,7 @@ const queryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1528
1534
|
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1529
1535
|
const { config, driver, resolver, root } = ctx;
|
|
1530
1536
|
const { output, query, mutation, client, group, hooks } = ctx.options;
|
|
1531
|
-
const pluginTs =
|
|
1532
|
-
if (!pluginTs) return null;
|
|
1537
|
+
const pluginTs = ctx.requirePlugin(_kubb_plugin_ts.pluginTsName);
|
|
1533
1538
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
1534
1539
|
const { isQuery, isMutation } = classifyOperation(node, {
|
|
1535
1540
|
query,
|
|
@@ -1624,7 +1629,8 @@ const queryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1624
1629
|
typeName: queryKeyTypeName,
|
|
1625
1630
|
node,
|
|
1626
1631
|
tsResolver,
|
|
1627
|
-
transformer: ctx.options.queryKey
|
|
1632
|
+
transformer: ctx.options.queryKey,
|
|
1633
|
+
variant: "query"
|
|
1628
1634
|
}),
|
|
1629
1635
|
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1630
1636
|
name: ["queryOptions"],
|
|
@@ -1744,6 +1750,7 @@ const pluginVueQuery = (0, kubb_kit.definePlugin)((options) => {
|
|
|
1744
1750
|
options,
|
|
1745
1751
|
dependencies: [_kubb_plugin_ts.pluginTsName],
|
|
1746
1752
|
hooks: { "kubb:plugin:setup"(ctx) {
|
|
1753
|
+
ctx.requirePlugin(_kubb_plugin_ts.pluginTsName);
|
|
1747
1754
|
const resolver = userResolver ? kubb_kit.Resolver.merge(resolverVueQuery, userResolver) : resolverVueQuery;
|
|
1748
1755
|
ctx.setOptions({
|
|
1749
1756
|
output,
|