@kubb/plugin-vue-query 5.0.0-beta.79 → 5.0.0-beta.81
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 +139 -225
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +16 -167
- package/dist/index.js +139 -225
- package/dist/index.js.map +1 -1
- package/package.json +8 -9
package/dist/index.cjs
CHANGED
|
@@ -28,7 +28,6 @@ let node_path = require("node:path");
|
|
|
28
28
|
node_path = __toESM(node_path, 1);
|
|
29
29
|
let _kubb_core = require("@kubb/core");
|
|
30
30
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
31
|
-
let _kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
32
31
|
let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
|
|
33
32
|
let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
34
33
|
let _kubb_ast_utils = require("@kubb/ast/utils");
|
|
@@ -555,109 +554,6 @@ function createGroupConfig(group) {
|
|
|
555
554
|
};
|
|
556
555
|
}
|
|
557
556
|
//#endregion
|
|
558
|
-
//#region ../../internals/client/src/builders/validatorOptions.ts
|
|
559
|
-
/**
|
|
560
|
-
* Returns `true` when any direction of the validator uses zod (used for dependency checks).
|
|
561
|
-
*/
|
|
562
|
-
function isValidatorEnabled(validator) {
|
|
563
|
-
if (!validator) return false;
|
|
564
|
-
if (validator === "zod") return true;
|
|
565
|
-
return Boolean(validator.request || validator.response);
|
|
566
|
-
}
|
|
567
|
-
//#endregion
|
|
568
|
-
//#region ../../internals/client/src/resolveClient.ts
|
|
569
|
-
/**
|
|
570
|
-
* Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
|
|
571
|
-
* operation, shared so the selection rules and diagnostics stay in one place.
|
|
572
|
-
*
|
|
573
|
-
* Every client runtime lives in a dedicated client plugin, so a consumer always calls a registered
|
|
574
|
-
* contract client plugin (plugin-fetch or plugin-axios) and never emits its own inline client:
|
|
575
|
-
*
|
|
576
|
-
* - `contract` — a registered contract client plugin owns the `<op>` functions and the consumer
|
|
577
|
-
* imports and calls them.
|
|
578
|
-
* - `error` — no client plugin is registered, several are registered without a selector, or the
|
|
579
|
-
* requested one is missing.
|
|
580
|
-
*
|
|
581
|
-
* The `client` string selects explicitly (`'fetch'` / `'axios'`); when it is unset a lone registered
|
|
582
|
-
* contract client plugin is picked up automatically.
|
|
583
|
-
*/
|
|
584
|
-
const pluginFetchName = "plugin-fetch";
|
|
585
|
-
const pluginAxiosName = "plugin-axios";
|
|
586
|
-
const selectorToPlugin = {
|
|
587
|
-
fetch: pluginFetchName,
|
|
588
|
-
axios: pluginAxiosName
|
|
589
|
-
};
|
|
590
|
-
const contractPlugins = [pluginFetchName, pluginAxiosName];
|
|
591
|
-
/**
|
|
592
|
-
* Applies the `client` resolution rules. See the module comment for the strategy shape.
|
|
593
|
-
*
|
|
594
|
-
* @example
|
|
595
|
-
* ```ts
|
|
596
|
-
* resolveClient({ client: 'fetch', pluginNames: ['plugin-ts', 'plugin-fetch'] })
|
|
597
|
-
* // { kind: 'contract', pluginName: 'plugin-fetch' }
|
|
598
|
-
* ```
|
|
599
|
-
*
|
|
600
|
-
* @example
|
|
601
|
-
* ```ts
|
|
602
|
-
* resolveClient({ client: undefined, pluginNames: ['plugin-ts'] })
|
|
603
|
-
* // { kind: 'error', message: 'No client plugin is registered…' }
|
|
604
|
-
* ```
|
|
605
|
-
*/
|
|
606
|
-
function resolveClient(options) {
|
|
607
|
-
const { client, pluginNames } = options;
|
|
608
|
-
const has = (name) => pluginNames.includes(name);
|
|
609
|
-
if (client === "fetch" || client === "axios") {
|
|
610
|
-
const pluginName = selectorToPlugin[client];
|
|
611
|
-
if (!has(pluginName)) return {
|
|
612
|
-
kind: "error",
|
|
613
|
-
message: `\`client: '${client}'\` is set but \`@kubb/plugin-${client}\` is not registered in \`plugins\`. Add it, or drop \`client\` to use a different client plugin.`
|
|
614
|
-
};
|
|
615
|
-
return {
|
|
616
|
-
kind: "contract",
|
|
617
|
-
pluginName
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
|
-
const registered = contractPlugins.filter(has);
|
|
621
|
-
if (registered.length === 1) return {
|
|
622
|
-
kind: "contract",
|
|
623
|
-
pluginName: registered[0]
|
|
624
|
-
};
|
|
625
|
-
if (registered.length > 1) return {
|
|
626
|
-
kind: "error",
|
|
627
|
-
message: `Multiple client plugins are registered (${registered.map((name) => `\`@kubb/${name}\``).join(", ")}). Set \`client: 'fetch' | 'axios'\` to choose which client the hooks call, or register a single client plugin.`
|
|
628
|
-
};
|
|
629
|
-
return {
|
|
630
|
-
kind: "error",
|
|
631
|
-
message: "No client plugin is registered. Add `@kubb/plugin-axios` or `@kubb/plugin-fetch` to `plugins` so the generated code has an HTTP client to call."
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
//#endregion
|
|
635
|
-
//#region ../../internals/client/src/resolveClientOperation.ts
|
|
636
|
-
/**
|
|
637
|
-
* Resolves the contract client `<op>` a consumer (query hook, MCP handler) imports, by looking up
|
|
638
|
-
* the registered contract client plugin's resolver and output. Works for any contract client plugin
|
|
639
|
-
* (plugin-fetch or plugin-axios). Returns `null` when no contract plugin is in play (the inline
|
|
640
|
-
* path). The plugin injects `.kubb/client.ts` at the global output root, the same path consumers
|
|
641
|
-
* read `RequestConfig` / `ResponseErrorConfig` from.
|
|
642
|
-
*/
|
|
643
|
-
function resolveClientOperation(options) {
|
|
644
|
-
const { clientPlugin, driver, node, root, output } = options;
|
|
645
|
-
if (!clientPlugin) return null;
|
|
646
|
-
const resolver = driver.getResolver(clientPlugin.pluginName);
|
|
647
|
-
if (!resolver) return null;
|
|
648
|
-
const plugin = driver.getPlugin(clientPlugin.pluginName);
|
|
649
|
-
const file = resolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
650
|
-
root,
|
|
651
|
-
output: plugin?.options?.output ?? output,
|
|
652
|
-
group: plugin?.options?.group ?? void 0
|
|
653
|
-
});
|
|
654
|
-
return {
|
|
655
|
-
name: resolver.resolveName(node.operationId),
|
|
656
|
-
path: file.path,
|
|
657
|
-
clientPath: node_path.default.resolve(root, ".kubb/client.ts")
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
//#endregion
|
|
661
557
|
//#region ../../internals/tanstack-query/src/components/MutationKey.tsx
|
|
662
558
|
const declarationPrinter$7 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
663
559
|
const mutationKeyTransformer = ({ node }) => {
|
|
@@ -697,6 +593,19 @@ const requestGroupOrder$1 = [
|
|
|
697
593
|
"headers"
|
|
698
594
|
];
|
|
699
595
|
/**
|
|
596
|
+
* Widens a request-group member type so a generated TanStack hook accepts either the value or a
|
|
597
|
+
* deferred value. Both plugins apply this through the `memberTypeWrapper` of `buildGroupedRequestParam`;
|
|
598
|
+
* they only differ in how the deferred form is later resolved.
|
|
599
|
+
*
|
|
600
|
+
* `maybeRefOrGetter` is used by vue-query, which keeps the ref/getter live and unwraps it lazily with
|
|
601
|
+
* `toValue` because vue-query keys are reactive. `maybeValueOrGetter` is used by react-query, which
|
|
602
|
+
* resolves the getter once at the hook boundary and forwards a plain value because React Query hashes
|
|
603
|
+
* keys structurally and cannot hold a function.
|
|
604
|
+
*/
|
|
605
|
+
function maybeRefOrGetter(type) {
|
|
606
|
+
return `MaybeRefOrGetter<${type}>`;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
700
609
|
* Builds the grouped `{ path, query, body, headers }` parameter that mirrors the client
|
|
701
610
|
* function signature. Only the groups the operation carries are emitted, typed from the
|
|
702
611
|
* operation's `RequestConfig`. `keys` narrows the emitted groups, used by the query key which
|
|
@@ -759,51 +668,6 @@ function buildQueryOptionsParams(node, options) {
|
|
|
759
668
|
default: "{}"
|
|
760
669
|
})].filter((param) => param !== null) });
|
|
761
670
|
}
|
|
762
|
-
/**
|
|
763
|
-
* Returns `'zod'` when response-direction parsing is enabled.
|
|
764
|
-
* The string shorthand `'zod'` also enables response parsing.
|
|
765
|
-
*/
|
|
766
|
-
function resolveResponseParser(parser) {
|
|
767
|
-
if (!parser) return null;
|
|
768
|
-
if (parser === "zod") return "zod";
|
|
769
|
-
return parser.response ?? null;
|
|
770
|
-
}
|
|
771
|
-
/**
|
|
772
|
-
* Returns `'zod'` when request body parsing is enabled.
|
|
773
|
-
* The string shorthand `'zod'` also enables request body parsing (existing behavior).
|
|
774
|
-
*/
|
|
775
|
-
function resolveRequestParser(parser) {
|
|
776
|
-
if (!parser) return null;
|
|
777
|
-
if (parser === "zod") return "zod";
|
|
778
|
-
return parser.request ?? null;
|
|
779
|
-
}
|
|
780
|
-
/**
|
|
781
|
-
* Returns `'zod'` when query-params parsing is enabled.
|
|
782
|
-
* Only the object form `{ request: 'zod' }` enables this. `parser: 'zod'` does not.
|
|
783
|
-
*/
|
|
784
|
-
function resolveQueryParamsParser(parser) {
|
|
785
|
-
if (!parser || parser === "zod") return null;
|
|
786
|
-
return parser.request ?? null;
|
|
787
|
-
}
|
|
788
|
-
/**
|
|
789
|
-
* Collects the Zod schema import names for an operation based on the active parser directions.
|
|
790
|
-
*
|
|
791
|
-
* - `parser: 'zod'`: response and request body names (backward-compatible behavior).
|
|
792
|
-
* - `parser: { request: 'zod' }`: request body and query params names.
|
|
793
|
-
* - `parser: { response: 'zod' }`: response name only.
|
|
794
|
-
* - `parser: { request: 'zod', response: 'zod' }`: all three.
|
|
795
|
-
*
|
|
796
|
-
* Returns an empty array when no resolver is provided or `parser` is falsy.
|
|
797
|
-
*/
|
|
798
|
-
function resolveZodSchemaNames(node, zodResolver, parser) {
|
|
799
|
-
if (!zodResolver || !parser) return [];
|
|
800
|
-
const { query: queryParams } = getOperationParameters(node, { paramsCasing: "original" });
|
|
801
|
-
return [
|
|
802
|
-
resolveResponseParser(parser) === "zod" ? zodResolver.resolveResponseName?.(node) : null,
|
|
803
|
-
resolveRequestParser(parser) === "zod" && node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : null,
|
|
804
|
-
resolveQueryParamsParser(parser) === "zod" && queryParams.length > 0 ? zodResolver.resolveQueryParamsName?.(node, queryParams[0]) : null
|
|
805
|
-
].filter((n) => Boolean(n));
|
|
806
|
-
}
|
|
807
671
|
(0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
808
672
|
const queryKeyTransformer = ({ node }) => {
|
|
809
673
|
if (!node.path) return [];
|
|
@@ -817,13 +681,100 @@ const queryKeyTransformer = ({ node }) => {
|
|
|
817
681
|
].filter(Boolean);
|
|
818
682
|
};
|
|
819
683
|
//#endregion
|
|
820
|
-
//#region src/
|
|
684
|
+
//#region ../../internals/client/src/resolveClient.ts
|
|
685
|
+
/**
|
|
686
|
+
* Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
|
|
687
|
+
* operation, shared so the selection rules and diagnostics stay in one place.
|
|
688
|
+
*
|
|
689
|
+
* Every client runtime lives in a dedicated client plugin, so a consumer always calls a registered
|
|
690
|
+
* contract client plugin (plugin-fetch or plugin-axios) and never emits its own inline client:
|
|
691
|
+
*
|
|
692
|
+
* - `contract` — a registered contract client plugin owns the `<op>` functions and the consumer
|
|
693
|
+
* imports and calls them.
|
|
694
|
+
* - `error` — no client plugin is registered, several are registered without a selector, or the
|
|
695
|
+
* requested one is missing.
|
|
696
|
+
*
|
|
697
|
+
* The `client` string selects explicitly (`'fetch'` / `'axios'`); when it is unset a lone registered
|
|
698
|
+
* contract client plugin is picked up automatically.
|
|
699
|
+
*/
|
|
700
|
+
const pluginFetchName = "plugin-fetch";
|
|
701
|
+
const pluginAxiosName = "plugin-axios";
|
|
702
|
+
const selectorToPlugin = {
|
|
703
|
+
fetch: pluginFetchName,
|
|
704
|
+
axios: pluginAxiosName
|
|
705
|
+
};
|
|
706
|
+
const contractPlugins = [pluginFetchName, pluginAxiosName];
|
|
821
707
|
/**
|
|
822
|
-
*
|
|
708
|
+
* Applies the `client` resolution rules. See the module comment for the strategy shape.
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* ```ts
|
|
712
|
+
* resolveClient({ client: 'fetch', pluginNames: ['plugin-ts', 'plugin-fetch'] })
|
|
713
|
+
* // { kind: 'contract', pluginName: 'plugin-fetch' }
|
|
714
|
+
* ```
|
|
715
|
+
*
|
|
716
|
+
* @example
|
|
717
|
+
* ```ts
|
|
718
|
+
* resolveClient({ client: undefined, pluginNames: ['plugin-ts'] })
|
|
719
|
+
* // { kind: 'error', message: 'No client plugin is registered…' }
|
|
720
|
+
* ```
|
|
823
721
|
*/
|
|
824
|
-
function
|
|
825
|
-
|
|
722
|
+
function resolveClient(options) {
|
|
723
|
+
const { client, pluginNames } = options;
|
|
724
|
+
const has = (name) => pluginNames.includes(name);
|
|
725
|
+
if (client === "fetch" || client === "axios") {
|
|
726
|
+
const pluginName = selectorToPlugin[client];
|
|
727
|
+
if (!has(pluginName)) return {
|
|
728
|
+
kind: "error",
|
|
729
|
+
message: `\`client: '${client}'\` is set but \`@kubb/plugin-${client}\` is not registered in \`plugins\`. Add it, or drop \`client\` to use a different client plugin.`
|
|
730
|
+
};
|
|
731
|
+
return {
|
|
732
|
+
kind: "contract",
|
|
733
|
+
pluginName
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
const registered = contractPlugins.filter(has);
|
|
737
|
+
if (registered.length === 1) return {
|
|
738
|
+
kind: "contract",
|
|
739
|
+
pluginName: registered[0]
|
|
740
|
+
};
|
|
741
|
+
if (registered.length > 1) return {
|
|
742
|
+
kind: "error",
|
|
743
|
+
message: `Multiple client plugins are registered (${registered.map((name) => `\`@kubb/${name}\``).join(", ")}). Set \`client: 'fetch' | 'axios'\` to choose which client the hooks call, or register a single client plugin.`
|
|
744
|
+
};
|
|
745
|
+
return {
|
|
746
|
+
kind: "error",
|
|
747
|
+
message: "No client plugin is registered. Add `@kubb/plugin-axios` or `@kubb/plugin-fetch` to `plugins` so the generated code has an HTTP client to call."
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
//#endregion
|
|
751
|
+
//#region ../../internals/client/src/resolveClientOperation.ts
|
|
752
|
+
/**
|
|
753
|
+
* Resolves the contract client `<op>` a consumer (query hook, MCP handler) imports, by looking up
|
|
754
|
+
* the registered contract client plugin's resolver and output. Works for any contract client plugin
|
|
755
|
+
* (plugin-fetch or plugin-axios). Returns `null` when no contract plugin is in play (the inline
|
|
756
|
+
* path). The plugin injects `.kubb/client.ts` at the global output root, the same path consumers
|
|
757
|
+
* read `RequestConfig` / `ResponseErrorConfig` from.
|
|
758
|
+
*/
|
|
759
|
+
function resolveClientOperation(options) {
|
|
760
|
+
const { clientPlugin, driver, node, root, output } = options;
|
|
761
|
+
if (!clientPlugin) return null;
|
|
762
|
+
const resolver = driver.getResolver(clientPlugin.pluginName);
|
|
763
|
+
if (!resolver) return null;
|
|
764
|
+
const plugin = driver.getPlugin(clientPlugin.pluginName);
|
|
765
|
+
const file = resolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
766
|
+
root,
|
|
767
|
+
output: plugin?.options?.output ?? output,
|
|
768
|
+
group: plugin?.options?.group ?? void 0
|
|
769
|
+
});
|
|
770
|
+
return {
|
|
771
|
+
name: resolver.resolveName(node.operationId),
|
|
772
|
+
path: file.path,
|
|
773
|
+
clientPath: node_path.default.resolve(root, ".kubb/client.ts")
|
|
774
|
+
};
|
|
826
775
|
}
|
|
776
|
+
//#endregion
|
|
777
|
+
//#region src/utils.ts
|
|
827
778
|
const requestGroupOrder = [
|
|
828
779
|
"path",
|
|
829
780
|
"query",
|
|
@@ -1267,7 +1218,7 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1267
1218
|
operation(node, ctx) {
|
|
1268
1219
|
if (!_kubb_core.ast.isHttpOperationNode(node)) return null;
|
|
1269
1220
|
const { config, driver, resolver, root } = ctx;
|
|
1270
|
-
const { output, query, mutation, infinite,
|
|
1221
|
+
const { output, query, mutation, infinite, client, group, hooks } = ctx.options;
|
|
1271
1222
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1272
1223
|
if (!pluginTs) return null;
|
|
1273
1224
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1317,14 +1268,6 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1317
1268
|
includeParams: false
|
|
1318
1269
|
})
|
|
1319
1270
|
].filter((name) => Boolean(name));
|
|
1320
|
-
const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : null;
|
|
1321
|
-
const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : null;
|
|
1322
|
-
const fileZod = zodResolver ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
1323
|
-
root,
|
|
1324
|
-
output: pluginZod?.options?.output ?? output,
|
|
1325
|
-
group: pluginZod?.options?.group ?? void 0
|
|
1326
|
-
}) : null;
|
|
1327
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, validator);
|
|
1328
1271
|
const calledClientName = contractOp.name;
|
|
1329
1272
|
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
1330
1273
|
baseName: meta.file.baseName,
|
|
@@ -1347,11 +1290,6 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1347
1290
|
}
|
|
1348
1291
|
}),
|
|
1349
1292
|
children: [
|
|
1350
|
-
fileZod && zodSchemaNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1351
|
-
name: zodSchemaNames,
|
|
1352
|
-
root: meta.file.path,
|
|
1353
|
-
path: fileZod.path
|
|
1354
|
-
}),
|
|
1355
1293
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1356
1294
|
name: [contractOp.name],
|
|
1357
1295
|
root: meta.file.path,
|
|
@@ -1406,30 +1344,32 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1406
1344
|
initialPageParam: infiniteOptions.initialPageParam,
|
|
1407
1345
|
queryParam: infiniteOptions.queryParam
|
|
1408
1346
|
}),
|
|
1409
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1347
|
+
hooks && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1348
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1349
|
+
name: ["useInfiniteQuery"],
|
|
1350
|
+
path: importPath
|
|
1351
|
+
}),
|
|
1352
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1353
|
+
name: [
|
|
1354
|
+
"QueryKey",
|
|
1355
|
+
"QueryClient",
|
|
1356
|
+
"UseInfiniteQueryOptions",
|
|
1357
|
+
"UseInfiniteQueryReturnType"
|
|
1358
|
+
],
|
|
1359
|
+
path: importPath,
|
|
1360
|
+
isTypeOnly: true
|
|
1361
|
+
}),
|
|
1362
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(InfiniteQuery, {
|
|
1363
|
+
name: queryName,
|
|
1364
|
+
queryOptionsName,
|
|
1365
|
+
queryKeyName,
|
|
1366
|
+
queryKeyTypeName,
|
|
1367
|
+
node,
|
|
1368
|
+
tsResolver,
|
|
1369
|
+
initialPageParam: infiniteOptions.initialPageParam,
|
|
1370
|
+
queryParam: infiniteOptions.queryParam
|
|
1371
|
+
})
|
|
1372
|
+
] })
|
|
1433
1373
|
]
|
|
1434
1374
|
});
|
|
1435
1375
|
}
|
|
@@ -1447,7 +1387,7 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1447
1387
|
operation(node, ctx) {
|
|
1448
1388
|
if (!_kubb_core.ast.isHttpOperationNode(node)) return null;
|
|
1449
1389
|
const { config, driver, resolver, root } = ctx;
|
|
1450
|
-
const { output, query, mutation,
|
|
1390
|
+
const { output, query, mutation, client, group, hooks } = ctx.options;
|
|
1451
1391
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1452
1392
|
if (!pluginTs) return null;
|
|
1453
1393
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1482,14 +1422,6 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1482
1422
|
order: "body-response-first",
|
|
1483
1423
|
includeParams: false
|
|
1484
1424
|
})].filter((name) => Boolean(name));
|
|
1485
|
-
const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : null;
|
|
1486
|
-
const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : null;
|
|
1487
|
-
const fileZod = zodResolver ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
1488
|
-
root,
|
|
1489
|
-
output: pluginZod?.options?.output ?? output,
|
|
1490
|
-
group: pluginZod?.options?.group ?? void 0
|
|
1491
|
-
}) : null;
|
|
1492
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, validator);
|
|
1493
1425
|
const calledClientName = contractOp.name;
|
|
1494
1426
|
const groups = getRequestGroups(node);
|
|
1495
1427
|
const hasRequestGroups = groups.path || groups.query || groups.body || groups.headers;
|
|
@@ -1514,11 +1446,6 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1514
1446
|
}
|
|
1515
1447
|
}),
|
|
1516
1448
|
children: [
|
|
1517
|
-
fileZod && zodSchemaNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1518
|
-
name: zodSchemaNames,
|
|
1519
|
-
root: meta.file.path,
|
|
1520
|
-
path: fileZod.path
|
|
1521
|
-
}),
|
|
1522
1449
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1523
1450
|
name: [contractOp.name],
|
|
1524
1451
|
root: meta.file.path,
|
|
@@ -1550,7 +1477,7 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1550
1477
|
node,
|
|
1551
1478
|
transformer: ctx.options.mutationKey
|
|
1552
1479
|
}),
|
|
1553
|
-
mutation && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1480
|
+
mutation && hooks && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1554
1481
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1555
1482
|
name: ["useMutation"],
|
|
1556
1483
|
path: importPath
|
|
@@ -1586,7 +1513,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1586
1513
|
operation(node, ctx) {
|
|
1587
1514
|
if (!_kubb_core.ast.isHttpOperationNode(node)) return null;
|
|
1588
1515
|
const { config, driver, resolver, root } = ctx;
|
|
1589
|
-
const { output, query, mutation,
|
|
1516
|
+
const { output, query, mutation, client, group, hooks } = ctx.options;
|
|
1590
1517
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1591
1518
|
if (!pluginTs) return null;
|
|
1592
1519
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1624,14 +1551,6 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1624
1551
|
order: "body-response-first",
|
|
1625
1552
|
includeParams: false
|
|
1626
1553
|
})].filter((name) => Boolean(name));
|
|
1627
|
-
const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : null;
|
|
1628
|
-
const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : null;
|
|
1629
|
-
const fileZod = zodResolver ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
1630
|
-
root,
|
|
1631
|
-
output: pluginZod?.options?.output ?? output,
|
|
1632
|
-
group: pluginZod?.options?.group ?? void 0
|
|
1633
|
-
}) : null;
|
|
1634
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, validator);
|
|
1635
1554
|
const calledClientName = contractOp.name;
|
|
1636
1555
|
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
1637
1556
|
baseName: meta.file.baseName,
|
|
@@ -1654,11 +1573,6 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1654
1573
|
}
|
|
1655
1574
|
}),
|
|
1656
1575
|
children: [
|
|
1657
|
-
fileZod && zodSchemaNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1658
|
-
name: zodSchemaNames,
|
|
1659
|
-
root: meta.file.path,
|
|
1660
|
-
path: fileZod.path
|
|
1661
|
-
}),
|
|
1662
1576
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1663
1577
|
name: [contractOp.name],
|
|
1664
1578
|
root: meta.file.path,
|
|
@@ -1703,7 +1617,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1703
1617
|
node,
|
|
1704
1618
|
tsResolver
|
|
1705
1619
|
}),
|
|
1706
|
-
query && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1620
|
+
query && hooks && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1707
1621
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1708
1622
|
name: ["useQuery"],
|
|
1709
1623
|
path: importPath
|
|
@@ -1814,7 +1728,7 @@ const pluginVueQueryName = "plugin-vue-query";
|
|
|
1814
1728
|
/**
|
|
1815
1729
|
* Generates one TanStack Query composable per OpenAPI operation for Vue's
|
|
1816
1730
|
* Composition API. Queries become `useFooQuery` (and optionally
|
|
1817
|
-
* `useFooInfiniteQuery`)
|
|
1731
|
+
* `useFooInfiniteQuery`). Mutations become `useFooMutation`. Each composable
|
|
1818
1732
|
* is fully typed end to end.
|
|
1819
1733
|
*
|
|
1820
1734
|
* @example
|
|
@@ -1839,7 +1753,7 @@ const pluginVueQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
1839
1753
|
const { output = {
|
|
1840
1754
|
path: "hooks",
|
|
1841
1755
|
barrel: { type: "named" }
|
|
1842
|
-
}, group, exclude = [], include, override = [],
|
|
1756
|
+
}, group, exclude = [], include, override = [], infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, hooks = false, client, resolver: userResolver, macros: userMacros } = options;
|
|
1843
1757
|
const selectedGenerators = [
|
|
1844
1758
|
queryGenerator,
|
|
1845
1759
|
infiniteQueryGenerator,
|
|
@@ -1849,7 +1763,7 @@ const pluginVueQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
1849
1763
|
return {
|
|
1850
1764
|
name: pluginVueQueryName,
|
|
1851
1765
|
options,
|
|
1852
|
-
dependencies: [_kubb_plugin_ts.pluginTsName
|
|
1766
|
+
dependencies: [_kubb_plugin_ts.pluginTsName],
|
|
1853
1767
|
hooks: { "kubb:plugin:setup"(ctx) {
|
|
1854
1768
|
const resolver = userResolver ? {
|
|
1855
1769
|
...resolverVueQuery,
|
|
@@ -1892,7 +1806,7 @@ const pluginVueQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
1892
1806
|
previousParam: null,
|
|
1893
1807
|
...infinite
|
|
1894
1808
|
} : false,
|
|
1895
|
-
|
|
1809
|
+
hooks,
|
|
1896
1810
|
group: groupConfig,
|
|
1897
1811
|
exclude,
|
|
1898
1812
|
include,
|