@kubb/plugin-vue-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.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.cjs
CHANGED
|
@@ -504,6 +504,19 @@ function resolveMutationConfig(mutation, options) {
|
|
|
504
504
|
};
|
|
505
505
|
}
|
|
506
506
|
/**
|
|
507
|
+
* Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
|
|
508
|
+
* `query: false` still marks the operation as a query so the query-family generators keep matching it,
|
|
509
|
+
* and a method already claimed by `query` never counts as a mutation.
|
|
510
|
+
*/
|
|
511
|
+
function classifyOperation(node, { query, mutation }) {
|
|
512
|
+
const isQuery = query === false || !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
|
|
513
|
+
const queryMethods = new Set(query ? query.methods : []);
|
|
514
|
+
return {
|
|
515
|
+
isQuery,
|
|
516
|
+
isMutation: mutation !== false && !isQuery && (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase())
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
507
520
|
* Applies the shared infinite-query defaults during plugin setup: a falsy value disables infinite
|
|
508
521
|
* queries, and an object merges over `queryParam: 'id'` and `initialPageParam: 0` with the cursor
|
|
509
522
|
* paths cleared.
|
|
@@ -1133,9 +1146,10 @@ const infiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1133
1146
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1134
1147
|
if (!pluginTs) return null;
|
|
1135
1148
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
1136
|
-
const isQuery
|
|
1137
|
-
|
|
1138
|
-
|
|
1149
|
+
const { isQuery, isMutation } = classifyOperation(node, {
|
|
1150
|
+
query,
|
|
1151
|
+
mutation
|
|
1152
|
+
});
|
|
1139
1153
|
const infiniteOptions = infinite && typeof infinite === "object" ? infinite : null;
|
|
1140
1154
|
if (!isQuery || isMutation || !infiniteOptions || !hooks) return null;
|
|
1141
1155
|
const normalizeKey = (key) => key.replace(/\?$/, "");
|
|
@@ -1168,8 +1182,11 @@ const infiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1168
1182
|
group: pluginTs.options?.group ?? void 0
|
|
1169
1183
|
})
|
|
1170
1184
|
};
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1185
|
+
const { queryParamsTypeName } = resolvePageParamType(node, {
|
|
1186
|
+
resolver: tsResolver,
|
|
1187
|
+
initialPageParam: infiniteOptions.initialPageParam,
|
|
1188
|
+
queryParam: infiniteOptions.queryParam
|
|
1189
|
+
});
|
|
1173
1190
|
const importedTypeNames = [
|
|
1174
1191
|
tsResolver.response.options(node),
|
|
1175
1192
|
queryParamsTypeName,
|
|
@@ -1300,9 +1317,11 @@ const mutationGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1300
1317
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1301
1318
|
if (!pluginTs) return null;
|
|
1302
1319
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
1303
|
-
const
|
|
1304
|
-
|
|
1305
|
-
|
|
1320
|
+
const { isMutation } = classifyOperation(node, {
|
|
1321
|
+
query,
|
|
1322
|
+
mutation
|
|
1323
|
+
});
|
|
1324
|
+
if (!isMutation) return null;
|
|
1306
1325
|
const importPath = mutation ? mutation.importPath : "@tanstack/vue-query";
|
|
1307
1326
|
const contractOp = resolveClientOperation({
|
|
1308
1327
|
clientPlugin: { pluginName: client.pluginName },
|
|
@@ -1428,9 +1447,10 @@ const queryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1428
1447
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1429
1448
|
if (!pluginTs) return null;
|
|
1430
1449
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
1431
|
-
const isQuery
|
|
1432
|
-
|
|
1433
|
-
|
|
1450
|
+
const { isQuery, isMutation } = classifyOperation(node, {
|
|
1451
|
+
query,
|
|
1452
|
+
mutation
|
|
1453
|
+
});
|
|
1434
1454
|
if (!isQuery || isMutation) return null;
|
|
1435
1455
|
const importPath = query ? query.importPath : "@tanstack/vue-query";
|
|
1436
1456
|
const contractOp = resolveClientOperation({
|