@kubb/plugin-react-query 5.1.1 → 5.1.3
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 +22 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/package.json +10 -3
package/dist/index.cjs
CHANGED
|
@@ -436,34 +436,44 @@ function resolveContractClient(options) {
|
|
|
436
436
|
* Resolves the contract client `<op>` a consumer (query hook, MCP handler) imports, by looking up
|
|
437
437
|
* the registered contract client plugin's resolver and output. Works for any contract client plugin
|
|
438
438
|
* (plugin-fetch or plugin-axios). Returns `null` when no contract plugin is in play (the inline
|
|
439
|
-
* path)
|
|
440
|
-
*
|
|
439
|
+
* path), or when the client plugin's `exclude` / `include` leaves this operation out, since it then
|
|
440
|
+
* emits no `<op>` to import. The plugin injects `.kubb/client.ts` at the global output root, the
|
|
441
|
+
* same path consumers read `RequestConfig` / `ResponseErrorConfig` from.
|
|
441
442
|
*
|
|
442
443
|
* The result is cached in the current node's `cache` (`ctx.cache`) under the client plugin's name,
|
|
443
444
|
* so several dependents reading the same client plugin for one operation in a single pass
|
|
444
445
|
* (react-query's query/mutation/infinite generators, vue-query, swr, the MCP handler, ...) share
|
|
445
446
|
* one computed result instead of each re-deriving the name and path.
|
|
446
447
|
*
|
|
447
|
-
* `returnType`
|
|
448
|
-
*
|
|
448
|
+
* `returnType`, `output`, and `group` are the client plugin's options for this operation, after its
|
|
449
|
+
* `override` entries, the same resolution its own generator sees. A dependent's generated call body
|
|
450
|
+
* and import path therefore match the `<op>` actually emitted, even when an `override` changes it.
|
|
449
451
|
*/
|
|
450
452
|
function resolveClientOperation(options) {
|
|
451
453
|
const { clientPlugin, driver, node, root, output, cache } = options;
|
|
452
454
|
if (!clientPlugin) return null;
|
|
453
455
|
return cache.ensureItem(`${clientPlugin.pluginName}:clientOperation`, () => {
|
|
454
456
|
const resolver = driver.getResolver(clientPlugin.pluginName);
|
|
455
|
-
const
|
|
457
|
+
const pluginOptions = driver.getPlugin(clientPlugin.pluginName)?.options ?? {};
|
|
458
|
+
const { exclude, include, override } = pluginOptions;
|
|
459
|
+
const operationOptions = Boolean(exclude?.length || include?.length || override?.length) && resolver.default ? resolver.default.options(node, {
|
|
460
|
+
options: pluginOptions,
|
|
461
|
+
exclude,
|
|
462
|
+
include,
|
|
463
|
+
override
|
|
464
|
+
}) : pluginOptions;
|
|
465
|
+
if (!operationOptions) return null;
|
|
456
466
|
const file = resolver.file({
|
|
457
467
|
...operationFileEntry(node, node.operationId),
|
|
458
468
|
root,
|
|
459
|
-
output:
|
|
460
|
-
group:
|
|
469
|
+
output: operationOptions.output ?? output,
|
|
470
|
+
group: operationOptions.group ?? void 0
|
|
461
471
|
});
|
|
462
472
|
return {
|
|
463
473
|
name: resolver.name(node.operationId),
|
|
464
474
|
path: file.path,
|
|
465
475
|
clientPath: node_path.default.resolve(root, ".kubb/client.ts"),
|
|
466
|
-
returnType:
|
|
476
|
+
returnType: operationOptions.returnType ?? "full"
|
|
467
477
|
};
|
|
468
478
|
});
|
|
469
479
|
}
|
|
@@ -662,11 +672,11 @@ function resolveMutationConfig(mutation, options) {
|
|
|
662
672
|
}
|
|
663
673
|
/**
|
|
664
674
|
* Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
|
|
665
|
-
*
|
|
666
|
-
*
|
|
675
|
+
* Disabled query and mutation configs do not claim operations, and a method already claimed by an
|
|
676
|
+
* enabled query config never counts as a mutation.
|
|
667
677
|
*/
|
|
668
678
|
function classifyOperation(node, { query, mutation }) {
|
|
669
|
-
const isQuery =
|
|
679
|
+
const isQuery = !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
|
|
670
680
|
const queryMethods = new Set(query ? query.methods : []);
|
|
671
681
|
return {
|
|
672
682
|
isQuery,
|
|
@@ -974,7 +984,6 @@ const customHookOptionsFileGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
974
984
|
const actualFilePath = ensureExtension(importPath, ".ts");
|
|
975
985
|
const file = {
|
|
976
986
|
baseName: node_path.default.basename(actualFilePath),
|
|
977
|
-
name: node_path.default.basename(actualFilePath, node_path.default.extname(actualFilePath)),
|
|
978
987
|
path: node_path.default.resolve(basePath, actualFilePath)
|
|
979
988
|
};
|
|
980
989
|
if (node_fs.default.existsSync(file.path)) return null;
|
|
@@ -997,7 +1006,7 @@ const customHookOptionsFileGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
997
1006
|
path: node_path.default.resolve(root, "./index.ts")
|
|
998
1007
|
}),
|
|
999
1008
|
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File.Source, {
|
|
1000
|
-
name
|
|
1009
|
+
name,
|
|
1001
1010
|
isExportable: true,
|
|
1002
1011
|
isIndexable: true,
|
|
1003
1012
|
children: [/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|