@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.js
CHANGED
|
@@ -526,11 +526,11 @@ function resolveMutationConfig(mutation, options) {
|
|
|
526
526
|
}
|
|
527
527
|
/**
|
|
528
528
|
* Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
|
|
529
|
-
*
|
|
530
|
-
*
|
|
529
|
+
* Disabled query and mutation configs do not claim operations, and a method already claimed by an
|
|
530
|
+
* enabled query config never counts as a mutation.
|
|
531
531
|
*/
|
|
532
532
|
function classifyOperation(node, { query, mutation }) {
|
|
533
|
-
const isQuery =
|
|
533
|
+
const isQuery = !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
|
|
534
534
|
const queryMethods = new Set(query ? query.methods : []);
|
|
535
535
|
return {
|
|
536
536
|
isQuery,
|
|
@@ -813,34 +813,44 @@ function resolveContractClient(options) {
|
|
|
813
813
|
* Resolves the contract client `<op>` a consumer (query hook, MCP handler) imports, by looking up
|
|
814
814
|
* the registered contract client plugin's resolver and output. Works for any contract client plugin
|
|
815
815
|
* (plugin-fetch or plugin-axios). Returns `null` when no contract plugin is in play (the inline
|
|
816
|
-
* path)
|
|
817
|
-
*
|
|
816
|
+
* path), or when the client plugin's `exclude` / `include` leaves this operation out, since it then
|
|
817
|
+
* emits no `<op>` to import. The plugin injects `.kubb/client.ts` at the global output root, the
|
|
818
|
+
* same path consumers read `RequestConfig` / `ResponseErrorConfig` from.
|
|
818
819
|
*
|
|
819
820
|
* The result is cached in the current node's `cache` (`ctx.cache`) under the client plugin's name,
|
|
820
821
|
* so several dependents reading the same client plugin for one operation in a single pass
|
|
821
822
|
* (react-query's query/mutation/infinite generators, vue-query, swr, the MCP handler, ...) share
|
|
822
823
|
* one computed result instead of each re-deriving the name and path.
|
|
823
824
|
*
|
|
824
|
-
* `returnType`
|
|
825
|
-
*
|
|
825
|
+
* `returnType`, `output`, and `group` are the client plugin's options for this operation, after its
|
|
826
|
+
* `override` entries, the same resolution its own generator sees. A dependent's generated call body
|
|
827
|
+
* and import path therefore match the `<op>` actually emitted, even when an `override` changes it.
|
|
826
828
|
*/
|
|
827
829
|
function resolveClientOperation(options) {
|
|
828
830
|
const { clientPlugin, driver, node, root, output, cache } = options;
|
|
829
831
|
if (!clientPlugin) return null;
|
|
830
832
|
return cache.ensureItem(`${clientPlugin.pluginName}:clientOperation`, () => {
|
|
831
833
|
const resolver = driver.getResolver(clientPlugin.pluginName);
|
|
832
|
-
const
|
|
834
|
+
const pluginOptions = driver.getPlugin(clientPlugin.pluginName)?.options ?? {};
|
|
835
|
+
const { exclude, include, override } = pluginOptions;
|
|
836
|
+
const operationOptions = Boolean(exclude?.length || include?.length || override?.length) && resolver.default ? resolver.default.options(node, {
|
|
837
|
+
options: pluginOptions,
|
|
838
|
+
exclude,
|
|
839
|
+
include,
|
|
840
|
+
override
|
|
841
|
+
}) : pluginOptions;
|
|
842
|
+
if (!operationOptions) return null;
|
|
833
843
|
const file = resolver.file({
|
|
834
844
|
...operationFileEntry(node, node.operationId),
|
|
835
845
|
root,
|
|
836
|
-
output:
|
|
837
|
-
group:
|
|
846
|
+
output: operationOptions.output ?? output,
|
|
847
|
+
group: operationOptions.group ?? void 0
|
|
838
848
|
});
|
|
839
849
|
return {
|
|
840
850
|
name: resolver.name(node.operationId),
|
|
841
851
|
path: file.path,
|
|
842
852
|
clientPath: path.resolve(root, ".kubb/client.ts"),
|
|
843
|
-
returnType:
|
|
853
|
+
returnType: operationOptions.returnType ?? "full"
|
|
844
854
|
};
|
|
845
855
|
});
|
|
846
856
|
}
|