@kubb/plugin-vue-query 5.0.0-beta.100 → 5.0.0-beta.101
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 +31 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -474,6 +474,19 @@ function resolveMutationConfig(mutation, options) {
|
|
|
474
474
|
};
|
|
475
475
|
}
|
|
476
476
|
/**
|
|
477
|
+
* Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
|
|
478
|
+
* `query: false` still marks the operation as a query so the query-family generators keep matching it,
|
|
479
|
+
* and a method already claimed by `query` never counts as a mutation.
|
|
480
|
+
*/
|
|
481
|
+
function classifyOperation(node, { query, mutation }) {
|
|
482
|
+
const isQuery = query === false || !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
|
|
483
|
+
const queryMethods = new Set(query ? query.methods : []);
|
|
484
|
+
return {
|
|
485
|
+
isQuery,
|
|
486
|
+
isMutation: mutation !== false && !isQuery && (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase())
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
477
490
|
* Applies the shared infinite-query defaults during plugin setup: a falsy value disables infinite
|
|
478
491
|
* queries, and an object merges over `queryParam: 'id'` and `initialPageParam: 0` with the cursor
|
|
479
492
|
* paths cleared.
|
|
@@ -1103,9 +1116,10 @@ const infiniteQueryGenerator = defineGenerator({
|
|
|
1103
1116
|
const pluginTs = driver.getPlugin(pluginTsName);
|
|
1104
1117
|
if (!pluginTs) return null;
|
|
1105
1118
|
const tsResolver = driver.getResolver(pluginTsName);
|
|
1106
|
-
const isQuery
|
|
1107
|
-
|
|
1108
|
-
|
|
1119
|
+
const { isQuery, isMutation } = classifyOperation(node, {
|
|
1120
|
+
query,
|
|
1121
|
+
mutation
|
|
1122
|
+
});
|
|
1109
1123
|
const infiniteOptions = infinite && typeof infinite === "object" ? infinite : null;
|
|
1110
1124
|
if (!isQuery || isMutation || !infiniteOptions || !hooks) return null;
|
|
1111
1125
|
const normalizeKey = (key) => key.replace(/\?$/, "");
|
|
@@ -1138,8 +1152,11 @@ const infiniteQueryGenerator = defineGenerator({
|
|
|
1138
1152
|
group: pluginTs.options?.group ?? void 0
|
|
1139
1153
|
})
|
|
1140
1154
|
};
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1155
|
+
const { queryParamsTypeName } = resolvePageParamType(node, {
|
|
1156
|
+
resolver: tsResolver,
|
|
1157
|
+
initialPageParam: infiniteOptions.initialPageParam,
|
|
1158
|
+
queryParam: infiniteOptions.queryParam
|
|
1159
|
+
});
|
|
1143
1160
|
const importedTypeNames = [
|
|
1144
1161
|
tsResolver.response.options(node),
|
|
1145
1162
|
queryParamsTypeName,
|
|
@@ -1270,9 +1287,11 @@ const mutationGenerator = defineGenerator({
|
|
|
1270
1287
|
const pluginTs = driver.getPlugin(pluginTsName);
|
|
1271
1288
|
if (!pluginTs) return null;
|
|
1272
1289
|
const tsResolver = driver.getResolver(pluginTsName);
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1290
|
+
const { isMutation } = classifyOperation(node, {
|
|
1291
|
+
query,
|
|
1292
|
+
mutation
|
|
1293
|
+
});
|
|
1294
|
+
if (!isMutation) return null;
|
|
1276
1295
|
const importPath = mutation ? mutation.importPath : "@tanstack/vue-query";
|
|
1277
1296
|
const contractOp = resolveClientOperation({
|
|
1278
1297
|
clientPlugin: { pluginName: client.pluginName },
|
|
@@ -1398,9 +1417,10 @@ const queryGenerator = defineGenerator({
|
|
|
1398
1417
|
const pluginTs = driver.getPlugin(pluginTsName);
|
|
1399
1418
|
if (!pluginTs) return null;
|
|
1400
1419
|
const tsResolver = driver.getResolver(pluginTsName);
|
|
1401
|
-
const isQuery
|
|
1402
|
-
|
|
1403
|
-
|
|
1420
|
+
const { isQuery, isMutation } = classifyOperation(node, {
|
|
1421
|
+
query,
|
|
1422
|
+
mutation
|
|
1423
|
+
});
|
|
1404
1424
|
if (!isQuery || isMutation) return null;
|
|
1405
1425
|
const importPath = query ? query.importPath : "@tanstack/vue-query";
|
|
1406
1426
|
const contractOp = resolveClientOperation({
|