@kubb/plugin-react-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 +152 -275
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -174
- package/dist/index.js +25 -148
- package/dist/index.js.map +1 -1
- package/package.json +4 -7
package/dist/index.cjs
CHANGED
|
@@ -26,14 +26,12 @@ 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");
|
|
31
|
+
let kubb_jsx = require("kubb/jsx");
|
|
32
|
+
let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
|
|
34
33
|
let node_fs = require("node:fs");
|
|
35
34
|
node_fs = __toESM(node_fs, 1);
|
|
36
|
-
let _kubb_ast_utils = require("@kubb/ast/utils");
|
|
37
35
|
//#region ../../internals/utils/src/casing.ts
|
|
38
36
|
/**
|
|
39
37
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
@@ -557,16 +555,6 @@ function createGroupConfig(group) {
|
|
|
557
555
|
};
|
|
558
556
|
}
|
|
559
557
|
//#endregion
|
|
560
|
-
//#region ../../internals/client/src/builders/validatorOptions.ts
|
|
561
|
-
/**
|
|
562
|
-
* Returns `true` when any direction of the validator uses zod (used for dependency checks).
|
|
563
|
-
*/
|
|
564
|
-
function isValidatorEnabled(validator) {
|
|
565
|
-
if (!validator) return false;
|
|
566
|
-
if (validator === "zod") return true;
|
|
567
|
-
return Boolean(validator.request || validator.response);
|
|
568
|
-
}
|
|
569
|
-
//#endregion
|
|
570
558
|
//#region ../../internals/client/src/resolveClient.ts
|
|
571
559
|
/**
|
|
572
560
|
* Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
|
|
@@ -673,11 +661,11 @@ function MutationKey({ name, node, transformer }) {
|
|
|
673
661
|
node,
|
|
674
662
|
casing: "camelcase"
|
|
675
663
|
});
|
|
676
|
-
return /* @__PURE__ */ (0,
|
|
664
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
677
665
|
name,
|
|
678
666
|
isExportable: true,
|
|
679
667
|
isIndexable: true,
|
|
680
|
-
children: /* @__PURE__ */ (0,
|
|
668
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function.Arrow, {
|
|
681
669
|
name,
|
|
682
670
|
export: true,
|
|
683
671
|
params: paramsSignature,
|
|
@@ -809,51 +797,6 @@ function resolveOperationOverrides(node, override) {
|
|
|
809
797
|
return override.find((ov) => matchesPattern(node, ov))?.options ?? {};
|
|
810
798
|
}
|
|
811
799
|
/**
|
|
812
|
-
* Returns `'zod'` when response-direction parsing is enabled.
|
|
813
|
-
* The string shorthand `'zod'` also enables response parsing.
|
|
814
|
-
*/
|
|
815
|
-
function resolveResponseParser(parser) {
|
|
816
|
-
if (!parser) return null;
|
|
817
|
-
if (parser === "zod") return "zod";
|
|
818
|
-
return parser.response ?? null;
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
|
-
* Returns `'zod'` when request body parsing is enabled.
|
|
822
|
-
* The string shorthand `'zod'` also enables request body parsing (existing behavior).
|
|
823
|
-
*/
|
|
824
|
-
function resolveRequestParser(parser) {
|
|
825
|
-
if (!parser) return null;
|
|
826
|
-
if (parser === "zod") return "zod";
|
|
827
|
-
return parser.request ?? null;
|
|
828
|
-
}
|
|
829
|
-
/**
|
|
830
|
-
* Returns `'zod'` when query-params parsing is enabled.
|
|
831
|
-
* Only the object form `{ request: 'zod' }` enables this. `parser: 'zod'` does not.
|
|
832
|
-
*/
|
|
833
|
-
function resolveQueryParamsParser(parser) {
|
|
834
|
-
if (!parser || parser === "zod") return null;
|
|
835
|
-
return parser.request ?? null;
|
|
836
|
-
}
|
|
837
|
-
/**
|
|
838
|
-
* Collects the Zod schema import names for an operation based on the active parser directions.
|
|
839
|
-
*
|
|
840
|
-
* - `parser: 'zod'`: response and request body names (backward-compatible behavior).
|
|
841
|
-
* - `parser: { request: 'zod' }`: request body and query params names.
|
|
842
|
-
* - `parser: { response: 'zod' }`: response name only.
|
|
843
|
-
* - `parser: { request: 'zod', response: 'zod' }`: all three.
|
|
844
|
-
*
|
|
845
|
-
* Returns an empty array when no resolver is provided or `parser` is falsy.
|
|
846
|
-
*/
|
|
847
|
-
function resolveZodSchemaNames(node, zodResolver, parser) {
|
|
848
|
-
if (!zodResolver || !parser) return [];
|
|
849
|
-
const { query: queryParams } = getOperationParameters(node, { paramsCasing: "original" });
|
|
850
|
-
return [
|
|
851
|
-
resolveResponseParser(parser) === "zod" ? zodResolver.resolveResponseName?.(node) : null,
|
|
852
|
-
resolveRequestParser(parser) === "zod" && node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : null,
|
|
853
|
-
resolveQueryParamsParser(parser) === "zod" && queryParams.length > 0 ? zodResolver.resolveQueryParamsName?.(node, queryParams[0]) : null
|
|
854
|
-
].filter((n) => Boolean(n));
|
|
855
|
-
}
|
|
856
|
-
/**
|
|
857
800
|
* Build QueryKey params as the grouped `{ path, query, body }` object (NO headers, NO config),
|
|
858
801
|
* typed from the operation's `RequestConfig` minus `url`. The query key transformer reads the
|
|
859
802
|
* grouped `path`/`query`/`body` bindings.
|
|
@@ -891,21 +834,21 @@ function QueryKey({ name, node, tsResolver, typeName, transformer }) {
|
|
|
891
834
|
node,
|
|
892
835
|
casing: "camelcase"
|
|
893
836
|
});
|
|
894
|
-
return /* @__PURE__ */ (0,
|
|
837
|
+
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, {
|
|
895
838
|
name,
|
|
896
839
|
isExportable: true,
|
|
897
840
|
isIndexable: true,
|
|
898
|
-
children: /* @__PURE__ */ (0,
|
|
841
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function.Arrow, {
|
|
899
842
|
name,
|
|
900
843
|
export: true,
|
|
901
844
|
params: paramsSignature,
|
|
902
845
|
singleLine: true,
|
|
903
846
|
children: `[${keys.join(", ")}] as const`
|
|
904
847
|
})
|
|
905
|
-
}), /* @__PURE__ */ (0,
|
|
848
|
+
}), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
906
849
|
name: typeName,
|
|
907
850
|
isTypeOnly: true,
|
|
908
|
-
children: /* @__PURE__ */ (0,
|
|
851
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Type, {
|
|
909
852
|
name: typeName,
|
|
910
853
|
children: `ReturnType<typeof ${name}>`
|
|
911
854
|
})
|
|
@@ -919,9 +862,9 @@ function QueryKey({ name, node, tsResolver, typeName, transformer }) {
|
|
|
919
862
|
* only created when it does not already exist, so user edits persist across
|
|
920
863
|
* regeneration.
|
|
921
864
|
*/
|
|
922
|
-
const customHookOptionsFileGenerator = (0,
|
|
865
|
+
const customHookOptionsFileGenerator = (0, kubb_kit.defineGenerator)({
|
|
923
866
|
name: "react-query-custom-hook-options-file",
|
|
924
|
-
renderer:
|
|
867
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
925
868
|
operations(nodes, ctx) {
|
|
926
869
|
const { resolver, root } = ctx;
|
|
927
870
|
const { output, customOptions, query, group } = ctx.options;
|
|
@@ -957,29 +900,29 @@ const customHookOptionsFileGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
957
900
|
path: node_path.default.resolve(basePath, actualFilePath)
|
|
958
901
|
};
|
|
959
902
|
if (node_fs.default.existsSync(file.path)) return null;
|
|
960
|
-
return /* @__PURE__ */ (0,
|
|
903
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
961
904
|
baseName: file.baseName,
|
|
962
905
|
path: file.path,
|
|
963
906
|
children: [
|
|
964
|
-
/* @__PURE__ */ (0,
|
|
907
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
965
908
|
name: ["QueryClient"],
|
|
966
909
|
path: reactQueryImportPath,
|
|
967
910
|
isTypeOnly: true
|
|
968
911
|
}),
|
|
969
|
-
/* @__PURE__ */ (0,
|
|
912
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
970
913
|
name: ["useQueryClient"],
|
|
971
914
|
path: reactQueryImportPath
|
|
972
915
|
}),
|
|
973
|
-
/* @__PURE__ */ (0,
|
|
916
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
974
917
|
name: [hookOptionsName],
|
|
975
918
|
root: file.path,
|
|
976
919
|
path: node_path.default.resolve(root, "./index.ts")
|
|
977
920
|
}),
|
|
978
|
-
/* @__PURE__ */ (0,
|
|
921
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File.Source, {
|
|
979
922
|
name: file.name,
|
|
980
923
|
isExportable: true,
|
|
981
924
|
isIndexable: true,
|
|
982
|
-
children: [/* @__PURE__ */ (0,
|
|
925
|
+
children: [/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
983
926
|
name: customHookOptionsName,
|
|
984
927
|
params: "{ queryClient }: { queryClient: QueryClient }",
|
|
985
928
|
returnType: `Partial<${hookOptionsName}>`,
|
|
@@ -992,7 +935,7 @@ const customHookOptionsFileGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
992
935
|
// }
|
|
993
936
|
// }
|
|
994
937
|
}`
|
|
995
|
-
}), /* @__PURE__ */ (0,
|
|
938
|
+
}), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
996
939
|
name,
|
|
997
940
|
generics: `T extends keyof ${hookOptionsName}`,
|
|
998
941
|
params: "{ hookName, operationId }: { hookName: T, operationId: string }",
|
|
@@ -1039,9 +982,9 @@ function buildResolvedRequestParams(node) {
|
|
|
1039
982
|
* every hook keyed by name so user-supplied options stay in sync with the
|
|
1040
983
|
* generated hooks at compile time.
|
|
1041
984
|
*/
|
|
1042
|
-
const hookOptionsGenerator = (0,
|
|
985
|
+
const hookOptionsGenerator = (0, kubb_kit.defineGenerator)({
|
|
1043
986
|
name: "react-query-hook-options",
|
|
1044
|
-
renderer:
|
|
987
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
1045
988
|
operations(nodes, ctx) {
|
|
1046
989
|
const { resolver, config, root } = ctx;
|
|
1047
990
|
const { output, customOptions, query, mutation, suspense, infinite, group, override, hooks } = ctx.options;
|
|
@@ -1063,7 +1006,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1063
1006
|
const imports = [];
|
|
1064
1007
|
const hookOptions = {};
|
|
1065
1008
|
for (const node of nodes) {
|
|
1066
|
-
if (!
|
|
1009
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) continue;
|
|
1067
1010
|
const opOverrides = resolveOperationOverrides(node, override);
|
|
1068
1011
|
const nodeQuery = "query" in opOverrides ? opOverrides.query : query;
|
|
1069
1012
|
const nodeMutation = "mutation" in opOverrides ? opOverrides.mutation : mutation;
|
|
@@ -1082,7 +1025,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1082
1025
|
output,
|
|
1083
1026
|
group: group ?? void 0
|
|
1084
1027
|
});
|
|
1085
|
-
imports.push(/* @__PURE__ */ (0,
|
|
1028
|
+
imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1086
1029
|
name: [queryOptionsName],
|
|
1087
1030
|
root: hookOptionsFile.path,
|
|
1088
1031
|
path: queryHookFile.path
|
|
@@ -1096,7 +1039,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1096
1039
|
output,
|
|
1097
1040
|
group: group ?? void 0
|
|
1098
1041
|
});
|
|
1099
|
-
imports.push(/* @__PURE__ */ (0,
|
|
1042
|
+
imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1100
1043
|
name: [suspenseOptionsName],
|
|
1101
1044
|
root: hookOptionsFile.path,
|
|
1102
1045
|
path: suspenseHookFile.path
|
|
@@ -1114,7 +1057,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1114
1057
|
output,
|
|
1115
1058
|
group: group ?? void 0
|
|
1116
1059
|
});
|
|
1117
|
-
imports.push(/* @__PURE__ */ (0,
|
|
1060
|
+
imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1118
1061
|
name: [infiniteOptionsName],
|
|
1119
1062
|
root: hookOptionsFile.path,
|
|
1120
1063
|
path: infiniteHookFile.path
|
|
@@ -1128,7 +1071,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1128
1071
|
output,
|
|
1129
1072
|
group: group ?? void 0
|
|
1130
1073
|
});
|
|
1131
|
-
imports.push(/* @__PURE__ */ (0,
|
|
1074
|
+
imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1132
1075
|
name: [suspenseInfiniteOptionsName],
|
|
1133
1076
|
root: hookOptionsFile.path,
|
|
1134
1077
|
path: suspenseInfiniteHookFile.path
|
|
@@ -1146,7 +1089,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1146
1089
|
output,
|
|
1147
1090
|
group: group ?? void 0
|
|
1148
1091
|
});
|
|
1149
|
-
imports.push(/* @__PURE__ */ (0,
|
|
1092
|
+
imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1150
1093
|
name: [mutationOptionsName],
|
|
1151
1094
|
root: hookOptionsFile.path,
|
|
1152
1095
|
path: mutationHookFile.path
|
|
@@ -1154,7 +1097,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1154
1097
|
hookOptions[mutationHookName] = `Partial<ReturnType<typeof ${mutationOptionsName}>>`;
|
|
1155
1098
|
}
|
|
1156
1099
|
}
|
|
1157
|
-
return /* @__PURE__ */ (0,
|
|
1100
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1158
1101
|
baseName: hookOptionsFile.baseName,
|
|
1159
1102
|
path: hookOptionsFile.path,
|
|
1160
1103
|
meta: hookOptionsFile.meta,
|
|
@@ -1174,12 +1117,12 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1174
1117
|
baseName: hookOptionsFile.baseName
|
|
1175
1118
|
}
|
|
1176
1119
|
}),
|
|
1177
|
-
children: [imports, /* @__PURE__ */ (0,
|
|
1120
|
+
children: [imports, /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1178
1121
|
name,
|
|
1179
1122
|
isExportable: true,
|
|
1180
1123
|
isIndexable: true,
|
|
1181
1124
|
isTypeOnly: true,
|
|
1182
|
-
children: /* @__PURE__ */ (0,
|
|
1125
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Type, {
|
|
1183
1126
|
export: true,
|
|
1184
1127
|
name,
|
|
1185
1128
|
children: `{ ${Object.keys(hookOptions).map((key) => `${JSON.stringify(key)}: ${hookOptions[key]}`).join(", ")} }`
|
|
@@ -1240,11 +1183,11 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
1240
1183
|
pageParamGeneric: "TPageParam"
|
|
1241
1184
|
});
|
|
1242
1185
|
const paramsSignature = declarationPrinter$8.print(paramsNode) ?? "";
|
|
1243
|
-
return /* @__PURE__ */ (0,
|
|
1186
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1244
1187
|
name,
|
|
1245
1188
|
isExportable: true,
|
|
1246
1189
|
isIndexable: true,
|
|
1247
|
-
children: /* @__PURE__ */ (0,
|
|
1190
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1248
1191
|
name,
|
|
1249
1192
|
export: true,
|
|
1250
1193
|
generics: generics.join(", "),
|
|
@@ -1291,11 +1234,11 @@ function QueryOptions({ name, clientName, node, tsResolver, queryKeyName }) {
|
|
|
1291
1234
|
signal: true
|
|
1292
1235
|
})}
|
|
1293
1236
|
return data`;
|
|
1294
|
-
return /* @__PURE__ */ (0,
|
|
1237
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1295
1238
|
name,
|
|
1296
1239
|
isExportable: true,
|
|
1297
1240
|
isIndexable: true,
|
|
1298
|
-
children: /* @__PURE__ */ (0,
|
|
1241
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1299
1242
|
name,
|
|
1300
1243
|
export: true,
|
|
1301
1244
|
params: paramsSignature,
|
|
@@ -1344,8 +1287,8 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
1344
1287
|
const hasNewParams = nextParam != null || previousParam != null;
|
|
1345
1288
|
const [getNextPageParamExpr, getPreviousPageParamExpr] = (() => {
|
|
1346
1289
|
if (hasNewParams) {
|
|
1347
|
-
const nextAccessor = nextParam ?
|
|
1348
|
-
const prevAccessor = previousParam ?
|
|
1290
|
+
const nextAccessor = nextParam ? kubb_kit.ast.getNestedAccessor(nextParam, "lastPage") : null;
|
|
1291
|
+
const prevAccessor = previousParam ? kubb_kit.ast.getNestedAccessor(previousParam, "firstPage") : null;
|
|
1349
1292
|
return [nextAccessor ? `getNextPageParam: (lastPage) => ${nextAccessor}` : null, prevAccessor ? `getPreviousPageParam: (firstPage) => ${prevAccessor}` : null];
|
|
1350
1293
|
}
|
|
1351
1294
|
if (cursorParam) return [`getNextPageParam: (lastPage) => lastPage['${cursorParam}']`, `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`];
|
|
@@ -1360,11 +1303,11 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
1360
1303
|
...(query ?? {}),
|
|
1361
1304
|
['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
|
|
1362
1305
|
} as ${queryParamsTypeName}` : "";
|
|
1363
|
-
if (infiniteOverrideParams) return /* @__PURE__ */ (0,
|
|
1306
|
+
if (infiniteOverrideParams) return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1364
1307
|
name,
|
|
1365
1308
|
isExportable: true,
|
|
1366
1309
|
isIndexable: true,
|
|
1367
|
-
children: /* @__PURE__ */ (0,
|
|
1310
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1368
1311
|
name,
|
|
1369
1312
|
export: true,
|
|
1370
1313
|
params: paramsSignature,
|
|
@@ -1381,11 +1324,11 @@ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${que
|
|
|
1381
1324
|
`
|
|
1382
1325
|
})
|
|
1383
1326
|
});
|
|
1384
|
-
return /* @__PURE__ */ (0,
|
|
1327
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1385
1328
|
name,
|
|
1386
1329
|
isExportable: true,
|
|
1387
1330
|
isIndexable: true,
|
|
1388
|
-
children: /* @__PURE__ */ (0,
|
|
1331
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1389
1332
|
name,
|
|
1390
1333
|
export: true,
|
|
1391
1334
|
params: paramsSignature,
|
|
@@ -1430,11 +1373,11 @@ function MutationOptions({ name, clientName, node, tsResolver, mutationKeyName }
|
|
|
1430
1373
|
signal: false
|
|
1431
1374
|
})}
|
|
1432
1375
|
return data`;
|
|
1433
|
-
return /* @__PURE__ */ (0,
|
|
1376
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1434
1377
|
name,
|
|
1435
1378
|
isExportable: true,
|
|
1436
1379
|
isIndexable: true,
|
|
1437
|
-
children: /* @__PURE__ */ (0,
|
|
1380
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1438
1381
|
name,
|
|
1439
1382
|
export: true,
|
|
1440
1383
|
params: paramsSignature,
|
|
@@ -1492,11 +1435,11 @@ function Mutation({ name, mutationOptionsName, node, tsResolver, mutationKeyName
|
|
|
1492
1435
|
const mutationOptionsParamsCall = callPrinter$1.print(mutationOptionsConfigNode) ?? "";
|
|
1493
1436
|
const paramsNode = buildMutationParamsNode(node, { resolver: tsResolver });
|
|
1494
1437
|
const paramsSignature = declarationPrinter$4.print(paramsNode) ?? "";
|
|
1495
|
-
return /* @__PURE__ */ (0,
|
|
1438
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1496
1439
|
name,
|
|
1497
1440
|
isExportable: true,
|
|
1498
1441
|
isIndexable: true,
|
|
1499
|
-
children: /* @__PURE__ */ (0,
|
|
1442
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1500
1443
|
name,
|
|
1501
1444
|
export: true,
|
|
1502
1445
|
params: paramsSignature,
|
|
@@ -1561,11 +1504,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
|
|
|
1561
1504
|
const queryOptionsArgs = resolvedParams ? "resolvedParams, config" : "config";
|
|
1562
1505
|
const paramsNode = buildQueryParamsNode(node, { resolver: tsResolver });
|
|
1563
1506
|
const paramsSignature = declarationPrinter$3.print(paramsNode) ?? "";
|
|
1564
|
-
return /* @__PURE__ */ (0,
|
|
1507
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1565
1508
|
name,
|
|
1566
1509
|
isExportable: true,
|
|
1567
1510
|
isIndexable: true,
|
|
1568
|
-
children: /* @__PURE__ */ (0,
|
|
1511
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1569
1512
|
name,
|
|
1570
1513
|
export: true,
|
|
1571
1514
|
generics: generics.join(", "),
|
|
@@ -1642,11 +1585,11 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
|
|
|
1642
1585
|
pageParamGeneric: "TPageParam"
|
|
1643
1586
|
});
|
|
1644
1587
|
const paramsSignature = declarationPrinter$2.print(paramsNode) ?? "";
|
|
1645
|
-
return /* @__PURE__ */ (0,
|
|
1588
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1646
1589
|
name,
|
|
1647
1590
|
isExportable: true,
|
|
1648
1591
|
isIndexable: true,
|
|
1649
|
-
children: /* @__PURE__ */ (0,
|
|
1592
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1650
1593
|
name,
|
|
1651
1594
|
export: true,
|
|
1652
1595
|
generics: generics.join(", "),
|
|
@@ -1704,8 +1647,8 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
|
|
|
1704
1647
|
const hasNewParams = nextParam != null || previousParam != null;
|
|
1705
1648
|
const [getNextPageParamExpr, getPreviousPageParamExpr] = (() => {
|
|
1706
1649
|
if (hasNewParams) {
|
|
1707
|
-
const nextAccessor = nextParam ?
|
|
1708
|
-
const prevAccessor = previousParam ?
|
|
1650
|
+
const nextAccessor = nextParam ? kubb_kit.ast.getNestedAccessor(nextParam, "lastPage") : null;
|
|
1651
|
+
const prevAccessor = previousParam ? kubb_kit.ast.getNestedAccessor(previousParam, "firstPage") : null;
|
|
1709
1652
|
return [nextAccessor ? `getNextPageParam: (lastPage) => ${nextAccessor}` : null, prevAccessor ? `getPreviousPageParam: (firstPage) => ${prevAccessor}` : null];
|
|
1710
1653
|
}
|
|
1711
1654
|
if (cursorParam) return [`getNextPageParam: (lastPage) => lastPage['${cursorParam}']`, `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`];
|
|
@@ -1720,11 +1663,11 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
|
|
|
1720
1663
|
...(query ?? {}),
|
|
1721
1664
|
['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
|
|
1722
1665
|
} as ${queryParamsTypeName}` : "";
|
|
1723
|
-
if (infiniteOverrideParams) return /* @__PURE__ */ (0,
|
|
1666
|
+
if (infiniteOverrideParams) return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1724
1667
|
name,
|
|
1725
1668
|
isExportable: true,
|
|
1726
1669
|
isIndexable: true,
|
|
1727
|
-
children: /* @__PURE__ */ (0,
|
|
1670
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1728
1671
|
name,
|
|
1729
1672
|
export: true,
|
|
1730
1673
|
params: paramsSignature,
|
|
@@ -1741,11 +1684,11 @@ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${que
|
|
|
1741
1684
|
`
|
|
1742
1685
|
})
|
|
1743
1686
|
});
|
|
1744
|
-
return /* @__PURE__ */ (0,
|
|
1687
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1745
1688
|
name,
|
|
1746
1689
|
isExportable: true,
|
|
1747
1690
|
isIndexable: true,
|
|
1748
|
-
children: /* @__PURE__ */ (0,
|
|
1691
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1749
1692
|
name,
|
|
1750
1693
|
export: true,
|
|
1751
1694
|
params: paramsSignature,
|
|
@@ -1800,11 +1743,11 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
1800
1743
|
const queryOptionsArgs = resolvedParams ? "resolvedParams, config" : "config";
|
|
1801
1744
|
const paramsNode = buildSuspenseQueryParamsNode(node, { resolver: tsResolver });
|
|
1802
1745
|
const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
|
|
1803
|
-
return /* @__PURE__ */ (0,
|
|
1746
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1804
1747
|
name,
|
|
1805
1748
|
isExportable: true,
|
|
1806
1749
|
isIndexable: true,
|
|
1807
|
-
children: /* @__PURE__ */ (0,
|
|
1750
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1808
1751
|
name,
|
|
1809
1752
|
export: true,
|
|
1810
1753
|
generics: generics.join(", "),
|
|
@@ -1837,13 +1780,13 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
1837
1780
|
* hook per query operation, wiring the configured `nextParam` /
|
|
1838
1781
|
* `previousParam` paths into TanStack Query's cursor-based pagination.
|
|
1839
1782
|
*/
|
|
1840
|
-
const infiniteQueryGenerator = (0,
|
|
1783
|
+
const infiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
1841
1784
|
name: "react-infinite-query",
|
|
1842
|
-
renderer:
|
|
1785
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
1843
1786
|
operation(node, ctx) {
|
|
1844
|
-
if (!
|
|
1787
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1845
1788
|
const { config, driver, resolver, root } = ctx;
|
|
1846
|
-
const { output, query, mutation, infinite,
|
|
1789
|
+
const { output, query, mutation, infinite, client, group, customOptions, hooks } = ctx.options;
|
|
1847
1790
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1848
1791
|
if (!pluginTs) return null;
|
|
1849
1792
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1893,16 +1836,8 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1893
1836
|
includeParams: false
|
|
1894
1837
|
})
|
|
1895
1838
|
].filter((name) => Boolean(name));
|
|
1896
|
-
const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : null;
|
|
1897
|
-
const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : null;
|
|
1898
|
-
const fileZod = zodResolver ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
1899
|
-
root,
|
|
1900
|
-
output: pluginZod?.options?.output ?? output,
|
|
1901
|
-
group: pluginZod?.options?.group ?? void 0
|
|
1902
|
-
}) : null;
|
|
1903
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, validator);
|
|
1904
1839
|
const calledClientName = contractOp.name;
|
|
1905
|
-
return /* @__PURE__ */ (0,
|
|
1840
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1906
1841
|
baseName: meta.file.baseName,
|
|
1907
1842
|
path: meta.file.path,
|
|
1908
1843
|
meta: meta.file.meta,
|
|
@@ -1923,49 +1858,44 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1923
1858
|
}
|
|
1924
1859
|
}),
|
|
1925
1860
|
children: [
|
|
1926
|
-
|
|
1927
|
-
name: zodSchemaNames,
|
|
1928
|
-
root: meta.file.path,
|
|
1929
|
-
path: fileZod.path
|
|
1930
|
-
}),
|
|
1931
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1861
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1932
1862
|
name: [contractOp.name],
|
|
1933
1863
|
root: meta.file.path,
|
|
1934
1864
|
path: contractOp.path
|
|
1935
1865
|
}),
|
|
1936
|
-
/* @__PURE__ */ (0,
|
|
1866
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1937
1867
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
1938
1868
|
root: meta.file.path,
|
|
1939
1869
|
path: contractOp.clientPath,
|
|
1940
1870
|
isTypeOnly: true
|
|
1941
1871
|
}),
|
|
1942
|
-
customOptions && /* @__PURE__ */ (0,
|
|
1872
|
+
customOptions && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1943
1873
|
name: [customOptions.name],
|
|
1944
1874
|
path: customOptions.importPath
|
|
1945
1875
|
}),
|
|
1946
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
1876
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1947
1877
|
name: Array.from(new Set(importedTypeNames)),
|
|
1948
1878
|
root: meta.file.path,
|
|
1949
1879
|
path: meta.fileTs.path,
|
|
1950
1880
|
isTypeOnly: true
|
|
1951
1881
|
}),
|
|
1952
|
-
/* @__PURE__ */ (0,
|
|
1882
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
1953
1883
|
name: queryKeyName,
|
|
1954
1884
|
typeName: queryKeyTypeName,
|
|
1955
1885
|
node,
|
|
1956
1886
|
tsResolver,
|
|
1957
1887
|
transformer: ctx.options.queryKey
|
|
1958
1888
|
}),
|
|
1959
|
-
/* @__PURE__ */ (0,
|
|
1889
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1960
1890
|
name: ["InfiniteData"],
|
|
1961
1891
|
isTypeOnly: true,
|
|
1962
1892
|
path: importPath
|
|
1963
1893
|
}),
|
|
1964
|
-
/* @__PURE__ */ (0,
|
|
1894
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1965
1895
|
name: ["infiniteQueryOptions"],
|
|
1966
1896
|
path: importPath
|
|
1967
1897
|
}),
|
|
1968
|
-
/* @__PURE__ */ (0,
|
|
1898
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(InfiniteQueryOptions, {
|
|
1969
1899
|
name: queryOptionsName,
|
|
1970
1900
|
clientName: calledClientName,
|
|
1971
1901
|
queryKeyName,
|
|
@@ -1977,12 +1907,12 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1977
1907
|
initialPageParam: infiniteOptions.initialPageParam,
|
|
1978
1908
|
queryParam: infiniteOptions.queryParam
|
|
1979
1909
|
}),
|
|
1980
|
-
hooks && /* @__PURE__ */ (0,
|
|
1981
|
-
/* @__PURE__ */ (0,
|
|
1910
|
+
hooks && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
1911
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1982
1912
|
name: ["useInfiniteQuery"],
|
|
1983
1913
|
path: importPath
|
|
1984
1914
|
}),
|
|
1985
|
-
/* @__PURE__ */ (0,
|
|
1915
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1986
1916
|
name: [
|
|
1987
1917
|
"QueryKey",
|
|
1988
1918
|
"QueryClient",
|
|
@@ -1992,7 +1922,7 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1992
1922
|
path: importPath,
|
|
1993
1923
|
isTypeOnly: true
|
|
1994
1924
|
}),
|
|
1995
|
-
/* @__PURE__ */ (0,
|
|
1925
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(InfiniteQuery, {
|
|
1996
1926
|
name: queryName,
|
|
1997
1927
|
queryOptionsName,
|
|
1998
1928
|
queryKeyName,
|
|
@@ -2015,13 +1945,13 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2015
1945
|
* per POST/PUT/DELETE operation (configurable via `mutation.methods`) plus
|
|
2016
1946
|
* the matching `fooMutationKey` / `fooMutationOptions` helpers.
|
|
2017
1947
|
*/
|
|
2018
|
-
const mutationGenerator = (0,
|
|
1948
|
+
const mutationGenerator = (0, kubb_kit.defineGenerator)({
|
|
2019
1949
|
name: "react-query-mutation",
|
|
2020
|
-
renderer:
|
|
1950
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
2021
1951
|
operation(node, ctx) {
|
|
2022
|
-
if (!
|
|
1952
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
2023
1953
|
const { config, driver, resolver, root } = ctx;
|
|
2024
|
-
const { output, query, mutation,
|
|
1954
|
+
const { output, query, mutation, client, group, customOptions, hooks } = ctx.options;
|
|
2025
1955
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
2026
1956
|
if (!pluginTs) return null;
|
|
2027
1957
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -2057,16 +1987,8 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2057
1987
|
order: "body-response-first",
|
|
2058
1988
|
includeParams: false
|
|
2059
1989
|
})].filter((name) => Boolean(name));
|
|
2060
|
-
const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : null;
|
|
2061
|
-
const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : null;
|
|
2062
|
-
const fileZod = zodResolver ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
2063
|
-
root,
|
|
2064
|
-
output: pluginZod?.options?.output ?? output,
|
|
2065
|
-
group: pluginZod?.options?.group ?? void 0
|
|
2066
|
-
}) : null;
|
|
2067
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, validator);
|
|
2068
1990
|
const calledClientName = contractOp.name;
|
|
2069
|
-
return /* @__PURE__ */ (0,
|
|
1991
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
2070
1992
|
baseName: meta.file.baseName,
|
|
2071
1993
|
path: meta.file.path,
|
|
2072
1994
|
meta: meta.file.meta,
|
|
@@ -2087,54 +2009,49 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2087
2009
|
}
|
|
2088
2010
|
}),
|
|
2089
2011
|
children: [
|
|
2090
|
-
|
|
2091
|
-
name: zodSchemaNames,
|
|
2092
|
-
root: meta.file.path,
|
|
2093
|
-
path: fileZod.path
|
|
2094
|
-
}),
|
|
2095
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
2012
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2096
2013
|
name: [contractOp.name],
|
|
2097
2014
|
root: meta.file.path,
|
|
2098
2015
|
path: contractOp.path
|
|
2099
2016
|
}),
|
|
2100
|
-
/* @__PURE__ */ (0,
|
|
2017
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2101
2018
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
2102
2019
|
root: meta.file.path,
|
|
2103
2020
|
path: contractOp.clientPath,
|
|
2104
2021
|
isTypeOnly: true
|
|
2105
2022
|
}),
|
|
2106
|
-
customOptions && /* @__PURE__ */ (0,
|
|
2023
|
+
customOptions && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2107
2024
|
name: [customOptions.name],
|
|
2108
2025
|
path: customOptions.importPath
|
|
2109
2026
|
}),
|
|
2110
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
2027
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2111
2028
|
name: Array.from(new Set(importedTypeNames)),
|
|
2112
2029
|
root: meta.file.path,
|
|
2113
2030
|
path: meta.fileTs.path,
|
|
2114
2031
|
isTypeOnly: true
|
|
2115
2032
|
}),
|
|
2116
|
-
/* @__PURE__ */ (0,
|
|
2033
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(MutationKey, {
|
|
2117
2034
|
name: mutationKeyName,
|
|
2118
2035
|
node,
|
|
2119
2036
|
transformer: ctx.options.mutationKey
|
|
2120
2037
|
}),
|
|
2121
|
-
/* @__PURE__ */ (0,
|
|
2038
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2122
2039
|
name: ["mutationOptions"],
|
|
2123
2040
|
path: importPath
|
|
2124
2041
|
}),
|
|
2125
|
-
/* @__PURE__ */ (0,
|
|
2042
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(MutationOptions, {
|
|
2126
2043
|
name: mutationOptionsName,
|
|
2127
2044
|
clientName: calledClientName,
|
|
2128
2045
|
mutationKeyName,
|
|
2129
2046
|
node,
|
|
2130
2047
|
tsResolver
|
|
2131
2048
|
}),
|
|
2132
|
-
mutation && hooks && /* @__PURE__ */ (0,
|
|
2133
|
-
/* @__PURE__ */ (0,
|
|
2049
|
+
mutation && hooks && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
2050
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2134
2051
|
name: ["useMutation"],
|
|
2135
2052
|
path: importPath
|
|
2136
2053
|
}),
|
|
2137
|
-
/* @__PURE__ */ (0,
|
|
2054
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2138
2055
|
name: [
|
|
2139
2056
|
"UseMutationOptions",
|
|
2140
2057
|
"UseMutationResult",
|
|
@@ -2143,7 +2060,7 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2143
2060
|
path: importPath,
|
|
2144
2061
|
isTypeOnly: true
|
|
2145
2062
|
}),
|
|
2146
|
-
/* @__PURE__ */ (0,
|
|
2063
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Mutation, {
|
|
2147
2064
|
name: mutationHookName,
|
|
2148
2065
|
typeName: mutationTypeName,
|
|
2149
2066
|
mutationOptionsName,
|
|
@@ -2164,13 +2081,13 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2164
2081
|
* GET operation (configurable via `query.methods`) plus the matching
|
|
2165
2082
|
* `fooQueryKey` / `fooQueryOptions` helpers.
|
|
2166
2083
|
*/
|
|
2167
|
-
const queryGenerator = (0,
|
|
2084
|
+
const queryGenerator = (0, kubb_kit.defineGenerator)({
|
|
2168
2085
|
name: "react-query",
|
|
2169
|
-
renderer:
|
|
2086
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
2170
2087
|
operation(node, ctx) {
|
|
2171
|
-
if (!
|
|
2088
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
2172
2089
|
const { config, driver, resolver, root } = ctx;
|
|
2173
|
-
const { output, query, mutation,
|
|
2090
|
+
const { output, query, mutation, client, group, customOptions, hooks } = ctx.options;
|
|
2174
2091
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
2175
2092
|
if (!pluginTs) return null;
|
|
2176
2093
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -2208,16 +2125,8 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2208
2125
|
order: "body-response-first",
|
|
2209
2126
|
includeParams: false
|
|
2210
2127
|
})].filter((name) => Boolean(name));
|
|
2211
|
-
const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : null;
|
|
2212
|
-
const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : null;
|
|
2213
|
-
const fileZod = zodResolver ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
2214
|
-
root,
|
|
2215
|
-
output: pluginZod?.options?.output ?? output,
|
|
2216
|
-
group: pluginZod?.options?.group ?? void 0
|
|
2217
|
-
}) : null;
|
|
2218
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, validator);
|
|
2219
2128
|
const calledClientName = contractOp.name;
|
|
2220
|
-
return /* @__PURE__ */ (0,
|
|
2129
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
2221
2130
|
baseName: meta.file.baseName,
|
|
2222
2131
|
path: meta.file.path,
|
|
2223
2132
|
meta: meta.file.meta,
|
|
@@ -2238,56 +2147,51 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2238
2147
|
}
|
|
2239
2148
|
}),
|
|
2240
2149
|
children: [
|
|
2241
|
-
|
|
2242
|
-
name: zodSchemaNames,
|
|
2243
|
-
root: meta.file.path,
|
|
2244
|
-
path: fileZod.path
|
|
2245
|
-
}),
|
|
2246
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
2150
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2247
2151
|
name: [contractOp.name],
|
|
2248
2152
|
root: meta.file.path,
|
|
2249
2153
|
path: contractOp.path
|
|
2250
2154
|
}),
|
|
2251
|
-
/* @__PURE__ */ (0,
|
|
2155
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2252
2156
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
2253
2157
|
root: meta.file.path,
|
|
2254
2158
|
path: contractOp.clientPath,
|
|
2255
2159
|
isTypeOnly: true
|
|
2256
2160
|
}),
|
|
2257
|
-
customOptions && /* @__PURE__ */ (0,
|
|
2161
|
+
customOptions && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2258
2162
|
name: [customOptions.name],
|
|
2259
2163
|
path: customOptions.importPath
|
|
2260
2164
|
}),
|
|
2261
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
2165
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2262
2166
|
name: Array.from(new Set(importedTypeNames)),
|
|
2263
2167
|
root: meta.file.path,
|
|
2264
2168
|
path: meta.fileTs.path,
|
|
2265
2169
|
isTypeOnly: true
|
|
2266
2170
|
}),
|
|
2267
|
-
/* @__PURE__ */ (0,
|
|
2171
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
2268
2172
|
name: queryKeyName,
|
|
2269
2173
|
typeName: queryKeyTypeName,
|
|
2270
2174
|
node,
|
|
2271
2175
|
tsResolver,
|
|
2272
2176
|
transformer: ctx.options.queryKey
|
|
2273
2177
|
}),
|
|
2274
|
-
/* @__PURE__ */ (0,
|
|
2178
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2275
2179
|
name: ["queryOptions"],
|
|
2276
2180
|
path: importPath
|
|
2277
2181
|
}),
|
|
2278
|
-
/* @__PURE__ */ (0,
|
|
2182
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryOptions, {
|
|
2279
2183
|
name: queryOptionsName,
|
|
2280
2184
|
clientName: calledClientName,
|
|
2281
2185
|
queryKeyName,
|
|
2282
2186
|
node,
|
|
2283
2187
|
tsResolver
|
|
2284
2188
|
}),
|
|
2285
|
-
query && hooks && /* @__PURE__ */ (0,
|
|
2286
|
-
/* @__PURE__ */ (0,
|
|
2189
|
+
query && hooks && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
2190
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2287
2191
|
name: ["useQuery"],
|
|
2288
2192
|
path: importPath
|
|
2289
2193
|
}),
|
|
2290
|
-
/* @__PURE__ */ (0,
|
|
2194
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2291
2195
|
name: [
|
|
2292
2196
|
"QueryKey",
|
|
2293
2197
|
"QueryClient",
|
|
@@ -2297,7 +2201,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2297
2201
|
path: importPath,
|
|
2298
2202
|
isTypeOnly: true
|
|
2299
2203
|
}),
|
|
2300
|
-
/* @__PURE__ */ (0,
|
|
2204
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Query, {
|
|
2301
2205
|
name: queryName,
|
|
2302
2206
|
queryOptionsName,
|
|
2303
2207
|
queryKeyName,
|
|
@@ -2316,16 +2220,16 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2316
2220
|
/**
|
|
2317
2221
|
* Built-in generator for `useSuspenseInfiniteQuery` hooks. Enabled when both
|
|
2318
2222
|
* `suspense` and `infinite` are configured. Combines suspense semantics with
|
|
2319
|
-
* cursor-based pagination
|
|
2223
|
+
* cursor-based pagination. Handlers throw promises while loading and pull
|
|
2320
2224
|
* additional pages on demand.
|
|
2321
2225
|
*/
|
|
2322
|
-
const suspenseInfiniteQueryGenerator = (0,
|
|
2226
|
+
const suspenseInfiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
2323
2227
|
name: "react-suspense-infinite-query",
|
|
2324
|
-
renderer:
|
|
2228
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
2325
2229
|
operation(node, ctx) {
|
|
2326
|
-
if (!
|
|
2230
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
2327
2231
|
const { config, driver, resolver, root } = ctx;
|
|
2328
|
-
const { output, query, mutation, infinite, suspense,
|
|
2232
|
+
const { output, query, mutation, infinite, suspense, client, group, customOptions, hooks } = ctx.options;
|
|
2329
2233
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
2330
2234
|
if (!pluginTs) return null;
|
|
2331
2235
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -2375,16 +2279,8 @@ const suspenseInfiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2375
2279
|
includeParams: false
|
|
2376
2280
|
})
|
|
2377
2281
|
].filter((name) => Boolean(name));
|
|
2378
|
-
const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : null;
|
|
2379
|
-
const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : null;
|
|
2380
|
-
const fileZod = zodResolver ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
2381
|
-
root,
|
|
2382
|
-
output: pluginZod?.options?.output ?? output,
|
|
2383
|
-
group: pluginZod?.options?.group ?? void 0
|
|
2384
|
-
}) : null;
|
|
2385
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, validator);
|
|
2386
2282
|
const calledClientName = contractOp.name;
|
|
2387
|
-
return /* @__PURE__ */ (0,
|
|
2283
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
2388
2284
|
baseName: meta.file.baseName,
|
|
2389
2285
|
path: meta.file.path,
|
|
2390
2286
|
meta: meta.file.meta,
|
|
@@ -2405,49 +2301,44 @@ const suspenseInfiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2405
2301
|
}
|
|
2406
2302
|
}),
|
|
2407
2303
|
children: [
|
|
2408
|
-
|
|
2409
|
-
name: zodSchemaNames,
|
|
2410
|
-
root: meta.file.path,
|
|
2411
|
-
path: fileZod.path
|
|
2412
|
-
}),
|
|
2413
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
2304
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2414
2305
|
name: [contractOp.name],
|
|
2415
2306
|
root: meta.file.path,
|
|
2416
2307
|
path: contractOp.path
|
|
2417
2308
|
}),
|
|
2418
|
-
/* @__PURE__ */ (0,
|
|
2309
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2419
2310
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
2420
2311
|
root: meta.file.path,
|
|
2421
2312
|
path: contractOp.clientPath,
|
|
2422
2313
|
isTypeOnly: true
|
|
2423
2314
|
}),
|
|
2424
|
-
customOptions && /* @__PURE__ */ (0,
|
|
2315
|
+
customOptions && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2425
2316
|
name: [customOptions.name],
|
|
2426
2317
|
path: customOptions.importPath
|
|
2427
2318
|
}),
|
|
2428
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
2319
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2429
2320
|
name: Array.from(new Set(importedTypeNames)),
|
|
2430
2321
|
root: meta.file.path,
|
|
2431
2322
|
path: meta.fileTs.path,
|
|
2432
2323
|
isTypeOnly: true
|
|
2433
2324
|
}),
|
|
2434
|
-
/* @__PURE__ */ (0,
|
|
2325
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
2435
2326
|
name: queryKeyName,
|
|
2436
2327
|
typeName: queryKeyTypeName,
|
|
2437
2328
|
node,
|
|
2438
2329
|
tsResolver,
|
|
2439
2330
|
transformer: ctx.options.queryKey
|
|
2440
2331
|
}),
|
|
2441
|
-
/* @__PURE__ */ (0,
|
|
2332
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2442
2333
|
name: ["InfiniteData"],
|
|
2443
2334
|
isTypeOnly: true,
|
|
2444
2335
|
path: importPath
|
|
2445
2336
|
}),
|
|
2446
|
-
/* @__PURE__ */ (0,
|
|
2337
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2447
2338
|
name: ["infiniteQueryOptions"],
|
|
2448
2339
|
path: importPath
|
|
2449
2340
|
}),
|
|
2450
|
-
/* @__PURE__ */ (0,
|
|
2341
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(SuspenseInfiniteQueryOptions, {
|
|
2451
2342
|
name: queryOptionsName,
|
|
2452
2343
|
clientName: calledClientName,
|
|
2453
2344
|
queryKeyName,
|
|
@@ -2459,12 +2350,12 @@ const suspenseInfiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2459
2350
|
initialPageParam: infiniteOptions.initialPageParam,
|
|
2460
2351
|
queryParam: infiniteOptions.queryParam
|
|
2461
2352
|
}),
|
|
2462
|
-
hooks && /* @__PURE__ */ (0,
|
|
2463
|
-
/* @__PURE__ */ (0,
|
|
2353
|
+
hooks && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
2354
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2464
2355
|
name: ["useSuspenseInfiniteQuery"],
|
|
2465
2356
|
path: importPath
|
|
2466
2357
|
}),
|
|
2467
|
-
/* @__PURE__ */ (0,
|
|
2358
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2468
2359
|
name: [
|
|
2469
2360
|
"QueryKey",
|
|
2470
2361
|
"QueryClient",
|
|
@@ -2474,7 +2365,7 @@ const suspenseInfiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2474
2365
|
path: importPath,
|
|
2475
2366
|
isTypeOnly: true
|
|
2476
2367
|
}),
|
|
2477
|
-
/* @__PURE__ */ (0,
|
|
2368
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(SuspenseInfiniteQuery, {
|
|
2478
2369
|
name: queryName,
|
|
2479
2370
|
queryOptionsName,
|
|
2480
2371
|
queryKeyName,
|
|
@@ -2498,13 +2389,13 @@ const suspenseInfiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2498
2389
|
* per query operation. Suspense queries throw promises while loading and
|
|
2499
2390
|
* require a `<Suspense>` boundary in the React tree. TanStack Query v5+ only.
|
|
2500
2391
|
*/
|
|
2501
|
-
const suspenseQueryGenerator = (0,
|
|
2392
|
+
const suspenseQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
2502
2393
|
name: "react-suspense-query",
|
|
2503
|
-
renderer:
|
|
2394
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
2504
2395
|
operation(node, ctx) {
|
|
2505
|
-
if (!
|
|
2396
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
2506
2397
|
const { config, driver, resolver, root } = ctx;
|
|
2507
|
-
const { output, query, mutation, suspense,
|
|
2398
|
+
const { output, query, mutation, suspense, client, group, customOptions, hooks } = ctx.options;
|
|
2508
2399
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
2509
2400
|
if (!pluginTs) return null;
|
|
2510
2401
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
@@ -2542,16 +2433,8 @@ const suspenseQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2542
2433
|
order: "body-response-first",
|
|
2543
2434
|
includeParams: false
|
|
2544
2435
|
})].filter((name) => Boolean(name));
|
|
2545
|
-
const pluginZod = isValidatorEnabled(validator) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : null;
|
|
2546
|
-
const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : null;
|
|
2547
|
-
const fileZod = zodResolver ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
2548
|
-
root,
|
|
2549
|
-
output: pluginZod?.options?.output ?? output,
|
|
2550
|
-
group: pluginZod?.options?.group ?? void 0
|
|
2551
|
-
}) : null;
|
|
2552
|
-
const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, validator);
|
|
2553
2436
|
const calledClientName = contractOp.name;
|
|
2554
|
-
return /* @__PURE__ */ (0,
|
|
2437
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
2555
2438
|
baseName: meta.file.baseName,
|
|
2556
2439
|
path: meta.file.path,
|
|
2557
2440
|
meta: meta.file.meta,
|
|
@@ -2572,56 +2455,51 @@ const suspenseQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2572
2455
|
}
|
|
2573
2456
|
}),
|
|
2574
2457
|
children: [
|
|
2575
|
-
|
|
2576
|
-
name: zodSchemaNames,
|
|
2577
|
-
root: meta.file.path,
|
|
2578
|
-
path: fileZod.path
|
|
2579
|
-
}),
|
|
2580
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
2458
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2581
2459
|
name: [contractOp.name],
|
|
2582
2460
|
root: meta.file.path,
|
|
2583
2461
|
path: contractOp.path
|
|
2584
2462
|
}),
|
|
2585
|
-
/* @__PURE__ */ (0,
|
|
2463
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2586
2464
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
2587
2465
|
root: meta.file.path,
|
|
2588
2466
|
path: contractOp.clientPath,
|
|
2589
2467
|
isTypeOnly: true
|
|
2590
2468
|
}),
|
|
2591
|
-
customOptions && /* @__PURE__ */ (0,
|
|
2469
|
+
customOptions && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2592
2470
|
name: [customOptions.name],
|
|
2593
2471
|
path: customOptions.importPath
|
|
2594
2472
|
}),
|
|
2595
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
2473
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2596
2474
|
name: Array.from(new Set(importedTypeNames)),
|
|
2597
2475
|
root: meta.file.path,
|
|
2598
2476
|
path: meta.fileTs.path,
|
|
2599
2477
|
isTypeOnly: true
|
|
2600
2478
|
}),
|
|
2601
|
-
/* @__PURE__ */ (0,
|
|
2479
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
2602
2480
|
name: queryKeyName,
|
|
2603
2481
|
typeName: queryKeyTypeName,
|
|
2604
2482
|
node,
|
|
2605
2483
|
tsResolver,
|
|
2606
2484
|
transformer: ctx.options.queryKey
|
|
2607
2485
|
}),
|
|
2608
|
-
/* @__PURE__ */ (0,
|
|
2486
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2609
2487
|
name: ["queryOptions"],
|
|
2610
2488
|
path: importPath
|
|
2611
2489
|
}),
|
|
2612
|
-
/* @__PURE__ */ (0,
|
|
2490
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryOptions, {
|
|
2613
2491
|
name: queryOptionsName,
|
|
2614
2492
|
clientName: calledClientName,
|
|
2615
2493
|
queryKeyName,
|
|
2616
2494
|
node,
|
|
2617
2495
|
tsResolver
|
|
2618
2496
|
}),
|
|
2619
|
-
suspense && hooks && /* @__PURE__ */ (0,
|
|
2620
|
-
/* @__PURE__ */ (0,
|
|
2497
|
+
suspense && hooks && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [
|
|
2498
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2621
2499
|
name: ["useSuspenseQuery"],
|
|
2622
2500
|
path: importPath
|
|
2623
2501
|
}),
|
|
2624
|
-
/* @__PURE__ */ (0,
|
|
2502
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2625
2503
|
name: [
|
|
2626
2504
|
"QueryKey",
|
|
2627
2505
|
"QueryClient",
|
|
@@ -2631,7 +2509,7 @@ const suspenseQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2631
2509
|
path: importPath,
|
|
2632
2510
|
isTypeOnly: true
|
|
2633
2511
|
}),
|
|
2634
|
-
/* @__PURE__ */ (0,
|
|
2512
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(SuspenseQuery, {
|
|
2635
2513
|
name: queryName,
|
|
2636
2514
|
queryOptionsName,
|
|
2637
2515
|
queryKeyName,
|
|
@@ -2652,8 +2530,8 @@ function capitalize(name) {
|
|
|
2652
2530
|
}
|
|
2653
2531
|
/**
|
|
2654
2532
|
* Default resolver used by `@kubb/plugin-react-query`. Decides the names and
|
|
2655
|
-
* file paths for every generated TanStack Query hook (`
|
|
2656
|
-
* `
|
|
2533
|
+
* file paths for every generated TanStack Query hook (`useFoo`,
|
|
2534
|
+
* `useFooSuspense`, `useFooInfinite`, ...) and its companion helpers
|
|
2657
2535
|
* (`fooQueryKey`, `fooQueryOptions`).
|
|
2658
2536
|
*
|
|
2659
2537
|
* Functions and files use camelCase; hooks get the `use` prefix; suspense and
|
|
@@ -2669,7 +2547,7 @@ function capitalize(name) {
|
|
|
2669
2547
|
* resolverReactQuery.resolveQueryOptionsName(operationNode) // 'getPetByIdQueryOptions'
|
|
2670
2548
|
* ```
|
|
2671
2549
|
*/
|
|
2672
|
-
const resolverReactQuery = (0,
|
|
2550
|
+
const resolverReactQuery = (0, kubb_kit.defineResolver)(() => ({
|
|
2673
2551
|
name: "default",
|
|
2674
2552
|
pluginName: "plugin-react-query",
|
|
2675
2553
|
default(name, type) {
|
|
@@ -2769,13 +2647,13 @@ const resolverReactQuery = (0, _kubb_core.defineResolver)(() => ({
|
|
|
2769
2647
|
const pluginReactQueryName = "plugin-react-query";
|
|
2770
2648
|
/**
|
|
2771
2649
|
* Generates one TanStack Query hook per OpenAPI operation for React. Queries
|
|
2772
|
-
* become `
|
|
2773
|
-
* become `
|
|
2650
|
+
* become `useFoo`, with `useFooSuspense` and `useFooInfinite` variants.
|
|
2651
|
+
* Mutations become `useFoo`. Each hook is fully typed: query keys, input
|
|
2774
2652
|
* variables, response data, and error shape all come from the spec.
|
|
2775
2653
|
*
|
|
2776
2654
|
* @example
|
|
2777
2655
|
* ```ts
|
|
2778
|
-
* import { defineConfig } from 'kubb'
|
|
2656
|
+
* import { defineConfig } from 'kubb/config'
|
|
2779
2657
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
2780
2658
|
* import { pluginReactQuery } from '@kubb/plugin-react-query'
|
|
2781
2659
|
*
|
|
@@ -2792,11 +2670,11 @@ const pluginReactQueryName = "plugin-react-query";
|
|
|
2792
2670
|
* })
|
|
2793
2671
|
* ```
|
|
2794
2672
|
*/
|
|
2795
|
-
const pluginReactQuery = (0,
|
|
2673
|
+
const pluginReactQuery = (0, kubb_kit.definePlugin)((options) => {
|
|
2796
2674
|
const { output = {
|
|
2797
2675
|
path: "hooks",
|
|
2798
2676
|
barrel: { type: "named" }
|
|
2799
|
-
}, group, exclude = [], include, override = [],
|
|
2677
|
+
}, group, exclude = [], include, override = [], suspense = {}, infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, customOptions, hooks = false, client, resolver: userResolver, macros: userMacros } = options;
|
|
2800
2678
|
const selectedGenerators = [
|
|
2801
2679
|
queryGenerator,
|
|
2802
2680
|
suspenseQueryGenerator,
|
|
@@ -2810,7 +2688,7 @@ const pluginReactQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
2810
2688
|
return {
|
|
2811
2689
|
name: pluginReactQueryName,
|
|
2812
2690
|
options,
|
|
2813
|
-
dependencies: [_kubb_plugin_ts.pluginTsName
|
|
2691
|
+
dependencies: [_kubb_plugin_ts.pluginTsName],
|
|
2814
2692
|
hooks: { "kubb:plugin:setup"(ctx) {
|
|
2815
2693
|
const resolver = userResolver ? {
|
|
2816
2694
|
...resolverReactQuery,
|
|
@@ -2831,17 +2709,17 @@ const pluginReactQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
2831
2709
|
queryKey,
|
|
2832
2710
|
query: query === false ? false : {
|
|
2833
2711
|
importPath: "@tanstack/react-query",
|
|
2834
|
-
methods: ["
|
|
2712
|
+
methods: ["GET"],
|
|
2835
2713
|
...query
|
|
2836
2714
|
},
|
|
2837
2715
|
mutationKey,
|
|
2838
2716
|
mutation: mutation === false ? false : {
|
|
2839
2717
|
importPath: "@tanstack/react-query",
|
|
2840
2718
|
methods: [
|
|
2841
|
-
"
|
|
2842
|
-
"
|
|
2843
|
-
"
|
|
2844
|
-
"
|
|
2719
|
+
"POST",
|
|
2720
|
+
"PUT",
|
|
2721
|
+
"PATCH",
|
|
2722
|
+
"DELETE"
|
|
2845
2723
|
],
|
|
2846
2724
|
...mutation
|
|
2847
2725
|
},
|
|
@@ -2859,7 +2737,6 @@ const pluginReactQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
2859
2737
|
...customOptions
|
|
2860
2738
|
} : null,
|
|
2861
2739
|
hooks,
|
|
2862
|
-
validator,
|
|
2863
2740
|
group: groupConfig,
|
|
2864
2741
|
exclude,
|
|
2865
2742
|
include,
|