@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.js
CHANGED
|
@@ -409,34 +409,44 @@ function resolveContractClient(options) {
|
|
|
409
409
|
* Resolves the contract client `<op>` a consumer (query hook, MCP handler) imports, by looking up
|
|
410
410
|
* the registered contract client plugin's resolver and output. Works for any contract client plugin
|
|
411
411
|
* (plugin-fetch or plugin-axios). Returns `null` when no contract plugin is in play (the inline
|
|
412
|
-
* path)
|
|
413
|
-
*
|
|
412
|
+
* path), or when the client plugin's `exclude` / `include` leaves this operation out, since it then
|
|
413
|
+
* emits no `<op>` to import. The plugin injects `.kubb/client.ts` at the global output root, the
|
|
414
|
+
* same path consumers read `RequestConfig` / `ResponseErrorConfig` from.
|
|
414
415
|
*
|
|
415
416
|
* The result is cached in the current node's `cache` (`ctx.cache`) under the client plugin's name,
|
|
416
417
|
* so several dependents reading the same client plugin for one operation in a single pass
|
|
417
418
|
* (react-query's query/mutation/infinite generators, vue-query, swr, the MCP handler, ...) share
|
|
418
419
|
* one computed result instead of each re-deriving the name and path.
|
|
419
420
|
*
|
|
420
|
-
* `returnType`
|
|
421
|
-
*
|
|
421
|
+
* `returnType`, `output`, and `group` are the client plugin's options for this operation, after its
|
|
422
|
+
* `override` entries, the same resolution its own generator sees. A dependent's generated call body
|
|
423
|
+
* and import path therefore match the `<op>` actually emitted, even when an `override` changes it.
|
|
422
424
|
*/
|
|
423
425
|
function resolveClientOperation(options) {
|
|
424
426
|
const { clientPlugin, driver, node, root, output, cache } = options;
|
|
425
427
|
if (!clientPlugin) return null;
|
|
426
428
|
return cache.ensureItem(`${clientPlugin.pluginName}:clientOperation`, () => {
|
|
427
429
|
const resolver = driver.getResolver(clientPlugin.pluginName);
|
|
428
|
-
const
|
|
430
|
+
const pluginOptions = driver.getPlugin(clientPlugin.pluginName)?.options ?? {};
|
|
431
|
+
const { exclude, include, override } = pluginOptions;
|
|
432
|
+
const operationOptions = Boolean(exclude?.length || include?.length || override?.length) && resolver.default ? resolver.default.options(node, {
|
|
433
|
+
options: pluginOptions,
|
|
434
|
+
exclude,
|
|
435
|
+
include,
|
|
436
|
+
override
|
|
437
|
+
}) : pluginOptions;
|
|
438
|
+
if (!operationOptions) return null;
|
|
429
439
|
const file = resolver.file({
|
|
430
440
|
...operationFileEntry(node, node.operationId),
|
|
431
441
|
root,
|
|
432
|
-
output:
|
|
433
|
-
group:
|
|
442
|
+
output: operationOptions.output ?? output,
|
|
443
|
+
group: operationOptions.group ?? void 0
|
|
434
444
|
});
|
|
435
445
|
return {
|
|
436
446
|
name: resolver.name(node.operationId),
|
|
437
447
|
path: file.path,
|
|
438
448
|
clientPath: path.resolve(root, ".kubb/client.ts"),
|
|
439
|
-
returnType:
|
|
449
|
+
returnType: operationOptions.returnType ?? "full"
|
|
440
450
|
};
|
|
441
451
|
});
|
|
442
452
|
}
|
|
@@ -635,11 +645,11 @@ function resolveMutationConfig(mutation, options) {
|
|
|
635
645
|
}
|
|
636
646
|
/**
|
|
637
647
|
* Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
|
|
638
|
-
*
|
|
639
|
-
*
|
|
648
|
+
* Disabled query and mutation configs do not claim operations, and a method already claimed by an
|
|
649
|
+
* enabled query config never counts as a mutation.
|
|
640
650
|
*/
|
|
641
651
|
function classifyOperation(node, { query, mutation }) {
|
|
642
|
-
const isQuery =
|
|
652
|
+
const isQuery = !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
|
|
643
653
|
const queryMethods = new Set(query ? query.methods : []);
|
|
644
654
|
return {
|
|
645
655
|
isQuery,
|
|
@@ -947,7 +957,6 @@ const customHookOptionsFileGenerator = defineGenerator({
|
|
|
947
957
|
const actualFilePath = ensureExtension(importPath, ".ts");
|
|
948
958
|
const file = {
|
|
949
959
|
baseName: path.basename(actualFilePath),
|
|
950
|
-
name: path.basename(actualFilePath, path.extname(actualFilePath)),
|
|
951
960
|
path: path.resolve(basePath, actualFilePath)
|
|
952
961
|
};
|
|
953
962
|
if (fs.existsSync(file.path)) return null;
|
|
@@ -970,7 +979,7 @@ const customHookOptionsFileGenerator = defineGenerator({
|
|
|
970
979
|
path: path.resolve(root, "./index.ts")
|
|
971
980
|
}),
|
|
972
981
|
/* @__PURE__ */ jsxs(File.Source, {
|
|
973
|
-
name
|
|
982
|
+
name,
|
|
974
983
|
isExportable: true,
|
|
975
984
|
isIndexable: true,
|
|
976
985
|
children: [/* @__PURE__ */ jsx(Function, {
|