@kubb/plugin-vue-query 5.0.0-beta.80 → 5.0.0-beta.84
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 +180 -277
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -173
- package/dist/index.js +113 -210
- package/dist/index.js.map +1 -1
- package/package.json +4 -7
package/dist/index.cjs
CHANGED
|
@@ -26,12 +26,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
//#endregion
|
|
27
27
|
let node_path = require("node:path");
|
|
28
28
|
node_path = __toESM(node_path, 1);
|
|
29
|
-
let
|
|
29
|
+
let kubb_kit = require("kubb/kit");
|
|
30
30
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
31
|
-
let
|
|
32
|
-
let
|
|
33
|
-
let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
34
|
-
let _kubb_ast_utils = require("@kubb/ast/utils");
|
|
31
|
+
let kubb_jsx = require("kubb/jsx");
|
|
32
|
+
let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
|
|
35
33
|
//#region ../../internals/utils/src/casing.ts
|
|
36
34
|
/**
|
|
37
35
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
@@ -555,109 +553,6 @@ function createGroupConfig(group) {
|
|
|
555
553
|
};
|
|
556
554
|
}
|
|
557
555
|
//#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
556
|
//#region ../../internals/tanstack-query/src/components/MutationKey.tsx
|
|
662
557
|
const declarationPrinter$7 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
663
558
|
const mutationKeyTransformer = ({ node }) => {
|
|
@@ -671,11 +566,11 @@ function MutationKey({ name, node, transformer }) {
|
|
|
671
566
|
node,
|
|
672
567
|
casing: "camelcase"
|
|
673
568
|
});
|
|
674
|
-
return /* @__PURE__ */ (0,
|
|
569
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
675
570
|
name,
|
|
676
571
|
isExportable: true,
|
|
677
572
|
isIndexable: true,
|
|
678
|
-
children: /* @__PURE__ */ (0,
|
|
573
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function.Arrow, {
|
|
679
574
|
name,
|
|
680
575
|
export: true,
|
|
681
576
|
params: paramsSignature,
|
|
@@ -772,51 +667,6 @@ function buildQueryOptionsParams(node, options) {
|
|
|
772
667
|
default: "{}"
|
|
773
668
|
})].filter((param) => param !== null) });
|
|
774
669
|
}
|
|
775
|
-
/**
|
|
776
|
-
* Returns `'zod'` when response-direction parsing is enabled.
|
|
777
|
-
* The string shorthand `'zod'` also enables response parsing.
|
|
778
|
-
*/
|
|
779
|
-
function resolveResponseParser(parser) {
|
|
780
|
-
if (!parser) return null;
|
|
781
|
-
if (parser === "zod") return "zod";
|
|
782
|
-
return parser.response ?? null;
|
|
783
|
-
}
|
|
784
|
-
/**
|
|
785
|
-
* Returns `'zod'` when request body parsing is enabled.
|
|
786
|
-
* The string shorthand `'zod'` also enables request body parsing (existing behavior).
|
|
787
|
-
*/
|
|
788
|
-
function resolveRequestParser(parser) {
|
|
789
|
-
if (!parser) return null;
|
|
790
|
-
if (parser === "zod") return "zod";
|
|
791
|
-
return parser.request ?? null;
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* Returns `'zod'` when query-params parsing is enabled.
|
|
795
|
-
* Only the object form `{ request: 'zod' }` enables this. `parser: 'zod'` does not.
|
|
796
|
-
*/
|
|
797
|
-
function resolveQueryParamsParser(parser) {
|
|
798
|
-
if (!parser || parser === "zod") return null;
|
|
799
|
-
return parser.request ?? null;
|
|
800
|
-
}
|
|
801
|
-
/**
|
|
802
|
-
* Collects the Zod schema import names for an operation based on the active parser directions.
|
|
803
|
-
*
|
|
804
|
-
* - `parser: 'zod'`: response and request body names (backward-compatible behavior).
|
|
805
|
-
* - `parser: { request: 'zod' }`: request body and query params names.
|
|
806
|
-
* - `parser: { response: 'zod' }`: response name only.
|
|
807
|
-
* - `parser: { request: 'zod', response: 'zod' }`: all three.
|
|
808
|
-
*
|
|
809
|
-
* Returns an empty array when no resolver is provided or `parser` is falsy.
|
|
810
|
-
*/
|
|
811
|
-
function resolveZodSchemaNames(node, zodResolver, parser) {
|
|
812
|
-
if (!zodResolver || !parser) return [];
|
|
813
|
-
const { query: queryParams } = getOperationParameters(node, { paramsCasing: "original" });
|
|
814
|
-
return [
|
|
815
|
-
resolveResponseParser(parser) === "zod" ? zodResolver.resolveResponseName?.(node) : null,
|
|
816
|
-
resolveRequestParser(parser) === "zod" && node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : null,
|
|
817
|
-
resolveQueryParamsParser(parser) === "zod" && queryParams.length > 0 ? zodResolver.resolveQueryParamsName?.(node, queryParams[0]) : null
|
|
818
|
-
].filter((n) => Boolean(n));
|
|
819
|
-
}
|
|
820
670
|
(0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
821
671
|
const queryKeyTransformer = ({ node }) => {
|
|
822
672
|
if (!node.path) return [];
|
|
@@ -830,6 +680,99 @@ const queryKeyTransformer = ({ node }) => {
|
|
|
830
680
|
].filter(Boolean);
|
|
831
681
|
};
|
|
832
682
|
//#endregion
|
|
683
|
+
//#region ../../internals/client/src/resolveClient.ts
|
|
684
|
+
/**
|
|
685
|
+
* Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
|
|
686
|
+
* operation, shared so the selection rules and diagnostics stay in one place.
|
|
687
|
+
*
|
|
688
|
+
* Every client runtime lives in a dedicated client plugin, so a consumer always calls a registered
|
|
689
|
+
* contract client plugin (plugin-fetch or plugin-axios) and never emits its own inline client:
|
|
690
|
+
*
|
|
691
|
+
* - `contract` — a registered contract client plugin owns the `<op>` functions and the consumer
|
|
692
|
+
* imports and calls them.
|
|
693
|
+
* - `error` — no client plugin is registered, several are registered without a selector, or the
|
|
694
|
+
* requested one is missing.
|
|
695
|
+
*
|
|
696
|
+
* The `client` string selects explicitly (`'fetch'` / `'axios'`); when it is unset a lone registered
|
|
697
|
+
* contract client plugin is picked up automatically.
|
|
698
|
+
*/
|
|
699
|
+
const pluginFetchName = "plugin-fetch";
|
|
700
|
+
const pluginAxiosName = "plugin-axios";
|
|
701
|
+
const selectorToPlugin = {
|
|
702
|
+
fetch: pluginFetchName,
|
|
703
|
+
axios: pluginAxiosName
|
|
704
|
+
};
|
|
705
|
+
const contractPlugins = [pluginFetchName, pluginAxiosName];
|
|
706
|
+
/**
|
|
707
|
+
* Applies the `client` resolution rules. See the module comment for the strategy shape.
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* ```ts
|
|
711
|
+
* resolveClient({ client: 'fetch', pluginNames: ['plugin-ts', 'plugin-fetch'] })
|
|
712
|
+
* // { kind: 'contract', pluginName: 'plugin-fetch' }
|
|
713
|
+
* ```
|
|
714
|
+
*
|
|
715
|
+
* @example
|
|
716
|
+
* ```ts
|
|
717
|
+
* resolveClient({ client: undefined, pluginNames: ['plugin-ts'] })
|
|
718
|
+
* // { kind: 'error', message: 'No client plugin is registered…' }
|
|
719
|
+
* ```
|
|
720
|
+
*/
|
|
721
|
+
function resolveClient(options) {
|
|
722
|
+
const { client, pluginNames } = options;
|
|
723
|
+
const has = (name) => pluginNames.includes(name);
|
|
724
|
+
if (client === "fetch" || client === "axios") {
|
|
725
|
+
const pluginName = selectorToPlugin[client];
|
|
726
|
+
if (!has(pluginName)) return {
|
|
727
|
+
kind: "error",
|
|
728
|
+
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.`
|
|
729
|
+
};
|
|
730
|
+
return {
|
|
731
|
+
kind: "contract",
|
|
732
|
+
pluginName
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
const registered = contractPlugins.filter(has);
|
|
736
|
+
if (registered.length === 1) return {
|
|
737
|
+
kind: "contract",
|
|
738
|
+
pluginName: registered[0]
|
|
739
|
+
};
|
|
740
|
+
if (registered.length > 1) return {
|
|
741
|
+
kind: "error",
|
|
742
|
+
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.`
|
|
743
|
+
};
|
|
744
|
+
return {
|
|
745
|
+
kind: "error",
|
|
746
|
+
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."
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region ../../internals/client/src/resolveClientOperation.ts
|
|
751
|
+
/**
|
|
752
|
+
* Resolves the contract client `<op>` a consumer (query hook, MCP handler) imports, by looking up
|
|
753
|
+
* the registered contract client plugin's resolver and output. Works for any contract client plugin
|
|
754
|
+
* (plugin-fetch or plugin-axios). Returns `null` when no contract plugin is in play (the inline
|
|
755
|
+
* path). The plugin injects `.kubb/client.ts` at the global output root, the same path consumers
|
|
756
|
+
* read `RequestConfig` / `ResponseErrorConfig` from.
|
|
757
|
+
*/
|
|
758
|
+
function resolveClientOperation(options) {
|
|
759
|
+
const { clientPlugin, driver, node, root, output } = options;
|
|
760
|
+
if (!clientPlugin) return null;
|
|
761
|
+
const resolver = driver.getResolver(clientPlugin.pluginName);
|
|
762
|
+
if (!resolver) return null;
|
|
763
|
+
const plugin = driver.getPlugin(clientPlugin.pluginName);
|
|
764
|
+
const file = resolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
765
|
+
root,
|
|
766
|
+
output: plugin?.options?.output ?? output,
|
|
767
|
+
group: plugin?.options?.group ?? void 0
|
|
768
|
+
});
|
|
769
|
+
return {
|
|
770
|
+
name: resolver.resolveName(node.operationId),
|
|
771
|
+
path: file.path,
|
|
772
|
+
clientPath: node_path.default.resolve(root, ".kubb/client.ts")
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
//#endregion
|
|
833
776
|
//#region src/utils.ts
|
|
834
777
|
const requestGroupOrder = [
|
|
835
778
|
"path",
|
|
@@ -876,23 +819,23 @@ function QueryKey({ name, node, tsResolver, typeName, transformer }) {
|
|
|
876
819
|
node,
|
|
877
820
|
casing: "camelcase"
|
|
878
821
|
});
|
|
879
|
-
return /* @__PURE__ */ (0,
|
|
822
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
880
823
|
name,
|
|
881
824
|
isExportable: true,
|
|
882
825
|
isIndexable: true,
|
|
883
|
-
children: /* @__PURE__ */ (0,
|
|
826
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function.Arrow, {
|
|
884
827
|
name,
|
|
885
828
|
export: true,
|
|
886
829
|
params: paramsSignature,
|
|
887
830
|
singleLine: true,
|
|
888
831
|
children: `[${keys.join(", ")}] as const`
|
|
889
832
|
})
|
|
890
|
-
}), /* @__PURE__ */ (0,
|
|
833
|
+
}), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
891
834
|
name: typeName,
|
|
892
835
|
isExportable: true,
|
|
893
836
|
isIndexable: true,
|
|
894
837
|
isTypeOnly: true,
|
|
895
|
-
children: /* @__PURE__ */ (0,
|
|
838
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Type, {
|
|
896
839
|
name: typeName,
|
|
897
840
|
export: true,
|
|
898
841
|
children: `ReturnType<typeof ${name}>`
|
|
@@ -924,11 +867,11 @@ function QueryOptions({ name, clientName, node, tsResolver, queryKeyName }) {
|
|
|
924
867
|
signal: true
|
|
925
868
|
})}
|
|
926
869
|
return data`;
|
|
927
|
-
return /* @__PURE__ */ (0,
|
|
870
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
928
871
|
name,
|
|
929
872
|
isExportable: true,
|
|
930
873
|
isIndexable: true,
|
|
931
|
-
children: /* @__PURE__ */ (0,
|
|
874
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
932
875
|
name,
|
|
933
876
|
export: true,
|
|
934
877
|
params: paramsSignature,
|
|
@@ -990,11 +933,11 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
990
933
|
const queryOptionsParamsCall = callPrinter$3.print(queryOptionsParamsNode) ?? "";
|
|
991
934
|
const paramsNode = buildInfiniteQueryParamsNode(node, { resolver: tsResolver });
|
|
992
935
|
const paramsSignature = declarationPrinter$3.print(paramsNode) ?? "";
|
|
993
|
-
return /* @__PURE__ */ (0,
|
|
936
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
994
937
|
name,
|
|
995
938
|
isExportable: true,
|
|
996
939
|
isIndexable: true,
|
|
997
|
-
children: /* @__PURE__ */ (0,
|
|
940
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
998
941
|
name,
|
|
999
942
|
export: true,
|
|
1000
943
|
generics: generics.join(", "),
|
|
@@ -1051,8 +994,8 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
1051
994
|
const hasNewParams = nextParam != null || previousParam != null;
|
|
1052
995
|
const [getNextPageParamExpr, getPreviousPageParamExpr] = (() => {
|
|
1053
996
|
if (hasNewParams) {
|
|
1054
|
-
const nextAccessor = nextParam ?
|
|
1055
|
-
const prevAccessor = previousParam ?
|
|
997
|
+
const nextAccessor = nextParam ? kubb_kit.ast.getNestedAccessor(nextParam, "lastPage") : null;
|
|
998
|
+
const prevAccessor = previousParam ? kubb_kit.ast.getNestedAccessor(previousParam, "firstPage") : null;
|
|
1056
999
|
return [nextAccessor ? `getNextPageParam: (lastPage) => ${nextAccessor}` : null, prevAccessor ? `getPreviousPageParam: (firstPage) => ${prevAccessor}` : null];
|
|
1057
1000
|
}
|
|
1058
1001
|
if (cursorParam) return [`getNextPageParam: (lastPage) => lastPage['${cursorParam}']`, `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`];
|
|
@@ -1067,11 +1010,11 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
1067
1010
|
...(query ?? {}),
|
|
1068
1011
|
['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
|
|
1069
1012
|
} as ${queryParamsTypeName}` : "";
|
|
1070
|
-
if (infiniteOverrideParams) return /* @__PURE__ */ (0,
|
|
1013
|
+
if (infiniteOverrideParams) return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1071
1014
|
name,
|
|
1072
1015
|
isExportable: true,
|
|
1073
1016
|
isIndexable: true,
|
|
1074
|
-
children: /* @__PURE__ */ (0,
|
|
1017
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1075
1018
|
name,
|
|
1076
1019
|
export: true,
|
|
1077
1020
|
params: paramsSignature,
|
|
@@ -1088,11 +1031,11 @@ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${que
|
|
|
1088
1031
|
`
|
|
1089
1032
|
})
|
|
1090
1033
|
});
|
|
1091
|
-
return /* @__PURE__ */ (0,
|
|
1034
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1092
1035
|
name,
|
|
1093
1036
|
isExportable: true,
|
|
1094
1037
|
isIndexable: true,
|
|
1095
|
-
children: /* @__PURE__ */ (0,
|
|
1038
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1096
1039
|
name,
|
|
1097
1040
|
export: true,
|
|
1098
1041
|
params: paramsSignature,
|
|
@@ -1160,11 +1103,11 @@ function Mutation({ name, clientName, node, tsResolver, mutationKeyName }) {
|
|
|
1160
1103
|
const mutationKeyParamsCall = callPrinter$1.print(mutationKeyParamsNode) ?? "";
|
|
1161
1104
|
const paramsNode = buildMutationParamsNode(node, { resolver: tsResolver });
|
|
1162
1105
|
const paramsSignature = declarationPrinter$1.print(paramsNode) ?? "";
|
|
1163
|
-
return /* @__PURE__ */ (0,
|
|
1106
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1164
1107
|
name,
|
|
1165
1108
|
isExportable: true,
|
|
1166
1109
|
isIndexable: true,
|
|
1167
|
-
children: /* @__PURE__ */ (0,
|
|
1110
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1168
1111
|
name,
|
|
1169
1112
|
export: true,
|
|
1170
1113
|
params: paramsSignature,
|
|
@@ -1232,11 +1175,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
|
|
|
1232
1175
|
const queryOptionsParamsCall = callPrinter.print(queryOptionsParamsNode) ?? "";
|
|
1233
1176
|
const paramsNode = buildQueryParamsNode(node, { resolver: tsResolver });
|
|
1234
1177
|
const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
|
|
1235
|
-
return /* @__PURE__ */ (0,
|
|
1178
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1236
1179
|
name,
|
|
1237
1180
|
isExportable: true,
|
|
1238
1181
|
isIndexable: true,
|
|
1239
|
-
children: /* @__PURE__ */ (0,
|
|
1182
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1240
1183
|
name,
|
|
1241
1184
|
export: true,
|
|
1242
1185
|
generics: generics.join(", "),
|
|
@@ -1268,13 +1211,13 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
|
|
|
1268
1211
|
* composable per query operation, wiring the configured cursor path into
|
|
1269
1212
|
* TanStack Query's cursor-based pagination.
|
|
1270
1213
|
*/
|
|
1271
|
-
const infiniteQueryGenerator = (0,
|
|
1214
|
+
const infiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
1272
1215
|
name: "vue-query-infinite",
|
|
1273
|
-
renderer:
|
|
1216
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
1274
1217
|
operation(node, ctx) {
|
|
1275
|
-
if (!
|
|
1218
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1276
1219
|
const { config, driver, resolver, root } = ctx;
|
|
1277
|
-
const { output, query, mutation, infinite,
|
|
1220
|
+
const { output, query, mutation, infinite, client, group, hooks } = ctx.options;
|
|
1278
1221
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1279
1222
|
if (!pluginTs) return null;
|
|
1280
1223
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1324,16 +1267,8 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1324
1267
|
includeParams: false
|
|
1325
1268
|
})
|
|
1326
1269
|
].filter((name) => Boolean(name));
|
|
1327
|
-
const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : null;
|
|
1328
|
-
const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : null;
|
|
1329
|
-
const fileZod = zodResolver ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
1330
|
-
root,
|
|
1331
|
-
output: pluginZod?.options?.output ?? output,
|
|
1332
|
-
group: pluginZod?.options?.group ?? void 0
|
|
1333
|
-
}) : null;
|
|
1334
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, validator);
|
|
1335
1270
|
const calledClientName = contractOp.name;
|
|
1336
|
-
return /* @__PURE__ */ (0,
|
|
1271
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1337
1272
|
baseName: meta.file.baseName,
|
|
1338
1273
|
path: meta.file.path,
|
|
1339
1274
|
meta: meta.file.meta,
|
|
@@ -1354,54 +1289,49 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1354
1289
|
}
|
|
1355
1290
|
}),
|
|
1356
1291
|
children: [
|
|
1357
|
-
|
|
1358
|
-
name: zodSchemaNames,
|
|
1359
|
-
root: meta.file.path,
|
|
1360
|
-
path: fileZod.path
|
|
1361
|
-
}),
|
|
1362
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1292
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1363
1293
|
name: [contractOp.name],
|
|
1364
1294
|
root: meta.file.path,
|
|
1365
1295
|
path: contractOp.path
|
|
1366
1296
|
}),
|
|
1367
|
-
/* @__PURE__ */ (0,
|
|
1297
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1368
1298
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
1369
1299
|
root: meta.file.path,
|
|
1370
1300
|
path: contractOp.clientPath,
|
|
1371
1301
|
isTypeOnly: true
|
|
1372
1302
|
}),
|
|
1373
|
-
/* @__PURE__ */ (0,
|
|
1303
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1374
1304
|
name: ["toValue"],
|
|
1375
1305
|
path: "vue"
|
|
1376
1306
|
}),
|
|
1377
|
-
/* @__PURE__ */ (0,
|
|
1307
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1378
1308
|
name: ["MaybeRefOrGetter"],
|
|
1379
1309
|
path: "vue",
|
|
1380
1310
|
isTypeOnly: true
|
|
1381
1311
|
}),
|
|
1382
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
1312
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1383
1313
|
name: Array.from(new Set(importedTypeNames)),
|
|
1384
1314
|
root: meta.file.path,
|
|
1385
1315
|
path: meta.fileTs.path,
|
|
1386
1316
|
isTypeOnly: true
|
|
1387
1317
|
}),
|
|
1388
|
-
/* @__PURE__ */ (0,
|
|
1318
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
1389
1319
|
name: queryKeyName,
|
|
1390
1320
|
typeName: queryKeyTypeName,
|
|
1391
1321
|
node,
|
|
1392
1322
|
tsResolver,
|
|
1393
1323
|
transformer: ctx.options.queryKey
|
|
1394
1324
|
}),
|
|
1395
|
-
/* @__PURE__ */ (0,
|
|
1325
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1396
1326
|
name: ["InfiniteData"],
|
|
1397
1327
|
isTypeOnly: true,
|
|
1398
1328
|
path: importPath
|
|
1399
1329
|
}),
|
|
1400
|
-
/* @__PURE__ */ (0,
|
|
1330
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1401
1331
|
name: ["infiniteQueryOptions"],
|
|
1402
1332
|
path: importPath
|
|
1403
1333
|
}),
|
|
1404
|
-
/* @__PURE__ */ (0,
|
|
1334
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(InfiniteQueryOptions, {
|
|
1405
1335
|
name: queryOptionsName,
|
|
1406
1336
|
clientName: calledClientName,
|
|
1407
1337
|
queryKeyName,
|
|
@@ -1413,12 +1343,12 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1413
1343
|
initialPageParam: infiniteOptions.initialPageParam,
|
|
1414
1344
|
queryParam: infiniteOptions.queryParam
|
|
1415
1345
|
}),
|
|
1416
|
-
hooks && /* @__PURE__ */ (0,
|
|
1417
|
-
/* @__PURE__ */ (0,
|
|
1346
|
+
hooks && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
1347
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1418
1348
|
name: ["useInfiniteQuery"],
|
|
1419
1349
|
path: importPath
|
|
1420
1350
|
}),
|
|
1421
|
-
/* @__PURE__ */ (0,
|
|
1351
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1422
1352
|
name: [
|
|
1423
1353
|
"QueryKey",
|
|
1424
1354
|
"QueryClient",
|
|
@@ -1428,7 +1358,7 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1428
1358
|
path: importPath,
|
|
1429
1359
|
isTypeOnly: true
|
|
1430
1360
|
}),
|
|
1431
|
-
/* @__PURE__ */ (0,
|
|
1361
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(InfiniteQuery, {
|
|
1432
1362
|
name: queryName,
|
|
1433
1363
|
queryOptionsName,
|
|
1434
1364
|
queryKeyName,
|
|
@@ -1450,13 +1380,13 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1450
1380
|
* `useFooMutation` composable per POST/PUT/DELETE operation (configurable
|
|
1451
1381
|
* via `mutation.methods`) plus the matching `fooMutationKey` helper.
|
|
1452
1382
|
*/
|
|
1453
|
-
const mutationGenerator = (0,
|
|
1383
|
+
const mutationGenerator = (0, kubb_kit.defineGenerator)({
|
|
1454
1384
|
name: "vue-query-mutation",
|
|
1455
|
-
renderer:
|
|
1385
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
1456
1386
|
operation(node, ctx) {
|
|
1457
|
-
if (!
|
|
1387
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1458
1388
|
const { config, driver, resolver, root } = ctx;
|
|
1459
|
-
const { output, query, mutation,
|
|
1389
|
+
const { output, query, mutation, client, group, hooks } = ctx.options;
|
|
1460
1390
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1461
1391
|
if (!pluginTs) return null;
|
|
1462
1392
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1491,18 +1421,10 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1491
1421
|
order: "body-response-first",
|
|
1492
1422
|
includeParams: false
|
|
1493
1423
|
})].filter((name) => Boolean(name));
|
|
1494
|
-
const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : null;
|
|
1495
|
-
const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : null;
|
|
1496
|
-
const fileZod = zodResolver ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
1497
|
-
root,
|
|
1498
|
-
output: pluginZod?.options?.output ?? output,
|
|
1499
|
-
group: pluginZod?.options?.group ?? void 0
|
|
1500
|
-
}) : null;
|
|
1501
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, validator);
|
|
1502
1424
|
const calledClientName = contractOp.name;
|
|
1503
1425
|
const groups = getRequestGroups(node);
|
|
1504
1426
|
const hasRequestGroups = groups.path || groups.query || groups.body || groups.headers;
|
|
1505
|
-
return /* @__PURE__ */ (0,
|
|
1427
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1506
1428
|
baseName: meta.file.baseName,
|
|
1507
1429
|
path: meta.file.path,
|
|
1508
1430
|
meta: meta.file.meta,
|
|
@@ -1523,53 +1445,48 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1523
1445
|
}
|
|
1524
1446
|
}),
|
|
1525
1447
|
children: [
|
|
1526
|
-
|
|
1527
|
-
name: zodSchemaNames,
|
|
1528
|
-
root: meta.file.path,
|
|
1529
|
-
path: fileZod.path
|
|
1530
|
-
}),
|
|
1531
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1448
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1532
1449
|
name: [contractOp.name],
|
|
1533
1450
|
root: meta.file.path,
|
|
1534
1451
|
path: contractOp.path
|
|
1535
1452
|
}),
|
|
1536
|
-
/* @__PURE__ */ (0,
|
|
1453
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1537
1454
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
1538
1455
|
root: meta.file.path,
|
|
1539
1456
|
path: contractOp.clientPath,
|
|
1540
1457
|
isTypeOnly: true
|
|
1541
1458
|
}),
|
|
1542
|
-
hasRequestGroups && /* @__PURE__ */ (0,
|
|
1459
|
+
hasRequestGroups && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1543
1460
|
name: ["toValue"],
|
|
1544
1461
|
path: "vue"
|
|
1545
1462
|
}),
|
|
1546
|
-
/* @__PURE__ */ (0,
|
|
1463
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1547
1464
|
name: ["MaybeRefOrGetter"],
|
|
1548
1465
|
path: "vue",
|
|
1549
1466
|
isTypeOnly: true
|
|
1550
1467
|
}),
|
|
1551
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
1468
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1552
1469
|
name: Array.from(new Set(importedTypeNames)),
|
|
1553
1470
|
root: meta.file.path,
|
|
1554
1471
|
path: meta.fileTs.path,
|
|
1555
1472
|
isTypeOnly: true
|
|
1556
1473
|
}),
|
|
1557
|
-
/* @__PURE__ */ (0,
|
|
1474
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(MutationKey, {
|
|
1558
1475
|
name: mutationKeyName,
|
|
1559
1476
|
node,
|
|
1560
1477
|
transformer: ctx.options.mutationKey
|
|
1561
1478
|
}),
|
|
1562
|
-
mutation && hooks && /* @__PURE__ */ (0,
|
|
1563
|
-
/* @__PURE__ */ (0,
|
|
1479
|
+
mutation && hooks && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
1480
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1564
1481
|
name: ["useMutation"],
|
|
1565
1482
|
path: importPath
|
|
1566
1483
|
}),
|
|
1567
|
-
/* @__PURE__ */ (0,
|
|
1484
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1568
1485
|
name: ["MutationObserverOptions", "QueryClient"],
|
|
1569
1486
|
path: importPath,
|
|
1570
1487
|
isTypeOnly: true
|
|
1571
1488
|
}),
|
|
1572
|
-
/* @__PURE__ */ (0,
|
|
1489
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Mutation, {
|
|
1573
1490
|
name: mutationHookName,
|
|
1574
1491
|
clientName: calledClientName,
|
|
1575
1492
|
typeName: mutationTypeName,
|
|
@@ -1589,13 +1506,13 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1589
1506
|
* composable per GET operation (configurable via `query.methods`) plus the
|
|
1590
1507
|
* matching `fooQueryKey` / `fooQueryOptions` helpers.
|
|
1591
1508
|
*/
|
|
1592
|
-
const queryGenerator = (0,
|
|
1509
|
+
const queryGenerator = (0, kubb_kit.defineGenerator)({
|
|
1593
1510
|
name: "vue-query",
|
|
1594
|
-
renderer:
|
|
1511
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
1595
1512
|
operation(node, ctx) {
|
|
1596
|
-
if (!
|
|
1513
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1597
1514
|
const { config, driver, resolver, root } = ctx;
|
|
1598
|
-
const { output, query, mutation,
|
|
1515
|
+
const { output, query, mutation, client, group, hooks } = ctx.options;
|
|
1599
1516
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1600
1517
|
if (!pluginTs) return null;
|
|
1601
1518
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1633,16 +1550,8 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1633
1550
|
order: "body-response-first",
|
|
1634
1551
|
includeParams: false
|
|
1635
1552
|
})].filter((name) => Boolean(name));
|
|
1636
|
-
const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : null;
|
|
1637
|
-
const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : null;
|
|
1638
|
-
const fileZod = zodResolver ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
1639
|
-
root,
|
|
1640
|
-
output: pluginZod?.options?.output ?? output,
|
|
1641
|
-
group: pluginZod?.options?.group ?? void 0
|
|
1642
|
-
}) : null;
|
|
1643
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, validator);
|
|
1644
1553
|
const calledClientName = contractOp.name;
|
|
1645
|
-
return /* @__PURE__ */ (0,
|
|
1554
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1646
1555
|
baseName: meta.file.baseName,
|
|
1647
1556
|
path: meta.file.path,
|
|
1648
1557
|
meta: meta.file.meta,
|
|
@@ -1663,61 +1572,56 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1663
1572
|
}
|
|
1664
1573
|
}),
|
|
1665
1574
|
children: [
|
|
1666
|
-
|
|
1667
|
-
name: zodSchemaNames,
|
|
1668
|
-
root: meta.file.path,
|
|
1669
|
-
path: fileZod.path
|
|
1670
|
-
}),
|
|
1671
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1575
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1672
1576
|
name: [contractOp.name],
|
|
1673
1577
|
root: meta.file.path,
|
|
1674
1578
|
path: contractOp.path
|
|
1675
1579
|
}),
|
|
1676
|
-
/* @__PURE__ */ (0,
|
|
1580
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1677
1581
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
1678
1582
|
root: meta.file.path,
|
|
1679
1583
|
path: contractOp.clientPath,
|
|
1680
1584
|
isTypeOnly: true
|
|
1681
1585
|
}),
|
|
1682
|
-
/* @__PURE__ */ (0,
|
|
1586
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1683
1587
|
name: ["toValue"],
|
|
1684
1588
|
path: "vue"
|
|
1685
1589
|
}),
|
|
1686
|
-
/* @__PURE__ */ (0,
|
|
1590
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1687
1591
|
name: ["MaybeRefOrGetter"],
|
|
1688
1592
|
path: "vue",
|
|
1689
1593
|
isTypeOnly: true
|
|
1690
1594
|
}),
|
|
1691
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
1595
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1692
1596
|
name: Array.from(new Set(importedTypeNames)),
|
|
1693
1597
|
root: meta.file.path,
|
|
1694
1598
|
path: meta.fileTs.path,
|
|
1695
1599
|
isTypeOnly: true
|
|
1696
1600
|
}),
|
|
1697
|
-
/* @__PURE__ */ (0,
|
|
1601
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
1698
1602
|
name: queryKeyName,
|
|
1699
1603
|
typeName: queryKeyTypeName,
|
|
1700
1604
|
node,
|
|
1701
1605
|
tsResolver,
|
|
1702
1606
|
transformer: ctx.options.queryKey
|
|
1703
1607
|
}),
|
|
1704
|
-
/* @__PURE__ */ (0,
|
|
1608
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1705
1609
|
name: ["queryOptions"],
|
|
1706
1610
|
path: importPath
|
|
1707
1611
|
}),
|
|
1708
|
-
/* @__PURE__ */ (0,
|
|
1612
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryOptions, {
|
|
1709
1613
|
name: queryOptionsName,
|
|
1710
1614
|
clientName: calledClientName,
|
|
1711
1615
|
queryKeyName,
|
|
1712
1616
|
node,
|
|
1713
1617
|
tsResolver
|
|
1714
1618
|
}),
|
|
1715
|
-
query && hooks && /* @__PURE__ */ (0,
|
|
1716
|
-
/* @__PURE__ */ (0,
|
|
1619
|
+
query && hooks && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
1620
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1717
1621
|
name: ["useQuery"],
|
|
1718
1622
|
path: importPath
|
|
1719
1623
|
}),
|
|
1720
|
-
/* @__PURE__ */ (0,
|
|
1624
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1721
1625
|
name: [
|
|
1722
1626
|
"QueryKey",
|
|
1723
1627
|
"QueryClient",
|
|
@@ -1727,7 +1631,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1727
1631
|
path: importPath,
|
|
1728
1632
|
isTypeOnly: true
|
|
1729
1633
|
}),
|
|
1730
|
-
/* @__PURE__ */ (0,
|
|
1634
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Query, {
|
|
1731
1635
|
name: queryName,
|
|
1732
1636
|
queryOptionsName,
|
|
1733
1637
|
queryKeyName,
|
|
@@ -1747,8 +1651,8 @@ function capitalize(name) {
|
|
|
1747
1651
|
}
|
|
1748
1652
|
/**
|
|
1749
1653
|
* Default resolver used by `@kubb/plugin-vue-query`. Decides the names and
|
|
1750
|
-
* file paths for every generated TanStack Query composable (`
|
|
1751
|
-
* `
|
|
1654
|
+
* file paths for every generated TanStack Query composable (`useFoo`,
|
|
1655
|
+
* `useFooInfinite`) and its companion helpers.
|
|
1752
1656
|
*
|
|
1753
1657
|
* Functions and files use camelCase; composables get the `use` prefix.
|
|
1754
1658
|
*
|
|
@@ -1761,7 +1665,7 @@ function capitalize(name) {
|
|
|
1761
1665
|
* resolverVueQuery.resolveQueryOptionsName(operationNode) // 'getPetByIdQueryOptions'
|
|
1762
1666
|
* ```
|
|
1763
1667
|
*/
|
|
1764
|
-
const resolverVueQuery = (0,
|
|
1668
|
+
const resolverVueQuery = (0, kubb_kit.defineResolver)(() => ({
|
|
1765
1669
|
name: "default",
|
|
1766
1670
|
pluginName: "plugin-vue-query",
|
|
1767
1671
|
default(name, type) {
|
|
@@ -1822,13 +1726,13 @@ const resolverVueQuery = (0, _kubb_core.defineResolver)(() => ({
|
|
|
1822
1726
|
const pluginVueQueryName = "plugin-vue-query";
|
|
1823
1727
|
/**
|
|
1824
1728
|
* Generates one TanStack Query composable per OpenAPI operation for Vue's
|
|
1825
|
-
* Composition API. Queries become `
|
|
1826
|
-
* `
|
|
1729
|
+
* Composition API. Queries become `useFoo` (and optionally
|
|
1730
|
+
* `useFooInfinite`). Mutations become `useFoo` as well. Each composable
|
|
1827
1731
|
* is fully typed end to end.
|
|
1828
1732
|
*
|
|
1829
1733
|
* @example
|
|
1830
1734
|
* ```ts
|
|
1831
|
-
* import { defineConfig } from 'kubb'
|
|
1735
|
+
* import { defineConfig } from 'kubb/config'
|
|
1832
1736
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
1833
1737
|
* import { pluginVueQuery } from '@kubb/plugin-vue-query'
|
|
1834
1738
|
*
|
|
@@ -1844,11 +1748,11 @@ const pluginVueQueryName = "plugin-vue-query";
|
|
|
1844
1748
|
* })
|
|
1845
1749
|
* ```
|
|
1846
1750
|
*/
|
|
1847
|
-
const pluginVueQuery = (0,
|
|
1751
|
+
const pluginVueQuery = (0, kubb_kit.definePlugin)((options) => {
|
|
1848
1752
|
const { output = {
|
|
1849
1753
|
path: "hooks",
|
|
1850
1754
|
barrel: { type: "named" }
|
|
1851
|
-
}, group, exclude = [], include, override = [],
|
|
1755
|
+
}, group, exclude = [], include, override = [], infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, hooks = false, client, resolver: userResolver, macros: userMacros } = options;
|
|
1852
1756
|
const selectedGenerators = [
|
|
1853
1757
|
queryGenerator,
|
|
1854
1758
|
infiniteQueryGenerator,
|
|
@@ -1858,7 +1762,7 @@ const pluginVueQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
1858
1762
|
return {
|
|
1859
1763
|
name: pluginVueQueryName,
|
|
1860
1764
|
options,
|
|
1861
|
-
dependencies: [_kubb_plugin_ts.pluginTsName
|
|
1765
|
+
dependencies: [_kubb_plugin_ts.pluginTsName],
|
|
1862
1766
|
hooks: { "kubb:plugin:setup"(ctx) {
|
|
1863
1767
|
const resolver = userResolver ? {
|
|
1864
1768
|
...resolverVueQuery,
|
|
@@ -1879,17 +1783,17 @@ const pluginVueQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
1879
1783
|
queryKey,
|
|
1880
1784
|
query: query === false ? false : {
|
|
1881
1785
|
importPath: "@tanstack/vue-query",
|
|
1882
|
-
methods: ["
|
|
1786
|
+
methods: ["GET"],
|
|
1883
1787
|
...query
|
|
1884
1788
|
},
|
|
1885
1789
|
mutationKey,
|
|
1886
1790
|
mutation: mutation === false ? false : {
|
|
1887
1791
|
importPath: "@tanstack/vue-query",
|
|
1888
1792
|
methods: [
|
|
1889
|
-
"
|
|
1890
|
-
"
|
|
1891
|
-
"
|
|
1892
|
-
"
|
|
1793
|
+
"POST",
|
|
1794
|
+
"PUT",
|
|
1795
|
+
"PATCH",
|
|
1796
|
+
"DELETE"
|
|
1893
1797
|
],
|
|
1894
1798
|
...mutation
|
|
1895
1799
|
},
|
|
@@ -1902,7 +1806,6 @@ const pluginVueQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
1902
1806
|
...infinite
|
|
1903
1807
|
} : false,
|
|
1904
1808
|
hooks,
|
|
1905
|
-
validator,
|
|
1906
1809
|
group: groupConfig,
|
|
1907
1810
|
exclude,
|
|
1908
1811
|
include,
|