@kubb/plugin-vue-query 5.1.3 → 5.1.5
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 +21 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -11
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -556,11 +556,11 @@ function resolveMutationConfig(mutation, options) {
|
|
|
556
556
|
}
|
|
557
557
|
/**
|
|
558
558
|
* Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
|
|
559
|
-
*
|
|
560
|
-
*
|
|
559
|
+
* Disabled query and mutation configs do not claim operations, and a method already claimed by an
|
|
560
|
+
* enabled query config never counts as a mutation.
|
|
561
561
|
*/
|
|
562
562
|
function classifyOperation(node, { query, mutation }) {
|
|
563
|
-
const isQuery =
|
|
563
|
+
const isQuery = !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
|
|
564
564
|
const queryMethods = new Set(query ? query.methods : []);
|
|
565
565
|
return {
|
|
566
566
|
isQuery,
|
|
@@ -843,34 +843,44 @@ function resolveContractClient(options) {
|
|
|
843
843
|
* Resolves the contract client `<op>` a consumer (query hook, MCP handler) imports, by looking up
|
|
844
844
|
* the registered contract client plugin's resolver and output. Works for any contract client plugin
|
|
845
845
|
* (plugin-fetch or plugin-axios). Returns `null` when no contract plugin is in play (the inline
|
|
846
|
-
* path)
|
|
847
|
-
*
|
|
846
|
+
* path), or when the client plugin's `exclude` / `include` leaves this operation out, since it then
|
|
847
|
+
* emits no `<op>` to import. The plugin injects `.kubb/client.ts` at the global output root, the
|
|
848
|
+
* same path consumers read `RequestConfig` / `ResponseErrorConfig` from.
|
|
848
849
|
*
|
|
849
850
|
* The result is cached in the current node's `cache` (`ctx.cache`) under the client plugin's name,
|
|
850
851
|
* so several dependents reading the same client plugin for one operation in a single pass
|
|
851
852
|
* (react-query's query/mutation/infinite generators, vue-query, swr, the MCP handler, ...) share
|
|
852
853
|
* one computed result instead of each re-deriving the name and path.
|
|
853
854
|
*
|
|
854
|
-
* `returnType`
|
|
855
|
-
*
|
|
855
|
+
* `returnType`, `output`, and `group` are the client plugin's options for this operation, after its
|
|
856
|
+
* `override` entries, the same resolution its own generator sees. A dependent's generated call body
|
|
857
|
+
* and import path therefore match the `<op>` actually emitted, even when an `override` changes it.
|
|
856
858
|
*/
|
|
857
859
|
function resolveClientOperation(options) {
|
|
858
860
|
const { clientPlugin, driver, node, root, output, cache } = options;
|
|
859
861
|
if (!clientPlugin) return null;
|
|
860
862
|
return cache.ensureItem(`${clientPlugin.pluginName}:clientOperation`, () => {
|
|
861
863
|
const resolver = driver.getResolver(clientPlugin.pluginName);
|
|
862
|
-
const
|
|
864
|
+
const pluginOptions = driver.getPlugin(clientPlugin.pluginName)?.options ?? {};
|
|
865
|
+
const { exclude, include, override } = pluginOptions;
|
|
866
|
+
const operationOptions = Boolean(exclude?.length || include?.length || override?.length) && resolver.default ? resolver.default.options(node, {
|
|
867
|
+
options: pluginOptions,
|
|
868
|
+
exclude,
|
|
869
|
+
include,
|
|
870
|
+
override
|
|
871
|
+
}) : pluginOptions;
|
|
872
|
+
if (!operationOptions) return null;
|
|
863
873
|
const file = resolver.file({
|
|
864
874
|
...operationFileEntry(node, node.operationId),
|
|
865
875
|
root,
|
|
866
|
-
output:
|
|
867
|
-
group:
|
|
876
|
+
output: operationOptions.output ?? output,
|
|
877
|
+
group: operationOptions.group ?? void 0
|
|
868
878
|
});
|
|
869
879
|
return {
|
|
870
880
|
name: resolver.name(node.operationId),
|
|
871
881
|
path: file.path,
|
|
872
882
|
clientPath: node_path.default.resolve(root, ".kubb/client.ts"),
|
|
873
|
-
returnType:
|
|
883
|
+
returnType: operationOptions.returnType ?? "full"
|
|
874
884
|
};
|
|
875
885
|
});
|
|
876
886
|
}
|