@kubb/plugin-react-query 5.0.0-beta.81 → 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 +142 -143
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +15 -16
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
package/dist/index.cjs
CHANGED
|
@@ -26,13 +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
|
|
31
|
+
let kubb_jsx = require("kubb/jsx");
|
|
32
|
+
let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
|
|
33
33
|
let node_fs = require("node:fs");
|
|
34
34
|
node_fs = __toESM(node_fs, 1);
|
|
35
|
-
let _kubb_ast_utils = require("@kubb/ast/utils");
|
|
36
35
|
//#region ../../internals/utils/src/casing.ts
|
|
37
36
|
/**
|
|
38
37
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
@@ -662,11 +661,11 @@ function MutationKey({ name, node, transformer }) {
|
|
|
662
661
|
node,
|
|
663
662
|
casing: "camelcase"
|
|
664
663
|
});
|
|
665
|
-
return /* @__PURE__ */ (0,
|
|
664
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
666
665
|
name,
|
|
667
666
|
isExportable: true,
|
|
668
667
|
isIndexable: true,
|
|
669
|
-
children: /* @__PURE__ */ (0,
|
|
668
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function.Arrow, {
|
|
670
669
|
name,
|
|
671
670
|
export: true,
|
|
672
671
|
params: paramsSignature,
|
|
@@ -835,21 +834,21 @@ function QueryKey({ name, node, tsResolver, typeName, transformer }) {
|
|
|
835
834
|
node,
|
|
836
835
|
casing: "camelcase"
|
|
837
836
|
});
|
|
838
|
-
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, {
|
|
839
838
|
name,
|
|
840
839
|
isExportable: true,
|
|
841
840
|
isIndexable: true,
|
|
842
|
-
children: /* @__PURE__ */ (0,
|
|
841
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function.Arrow, {
|
|
843
842
|
name,
|
|
844
843
|
export: true,
|
|
845
844
|
params: paramsSignature,
|
|
846
845
|
singleLine: true,
|
|
847
846
|
children: `[${keys.join(", ")}] as const`
|
|
848
847
|
})
|
|
849
|
-
}), /* @__PURE__ */ (0,
|
|
848
|
+
}), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
850
849
|
name: typeName,
|
|
851
850
|
isTypeOnly: true,
|
|
852
|
-
children: /* @__PURE__ */ (0,
|
|
851
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Type, {
|
|
853
852
|
name: typeName,
|
|
854
853
|
children: `ReturnType<typeof ${name}>`
|
|
855
854
|
})
|
|
@@ -863,9 +862,9 @@ function QueryKey({ name, node, tsResolver, typeName, transformer }) {
|
|
|
863
862
|
* only created when it does not already exist, so user edits persist across
|
|
864
863
|
* regeneration.
|
|
865
864
|
*/
|
|
866
|
-
const customHookOptionsFileGenerator = (0,
|
|
865
|
+
const customHookOptionsFileGenerator = (0, kubb_kit.defineGenerator)({
|
|
867
866
|
name: "react-query-custom-hook-options-file",
|
|
868
|
-
renderer:
|
|
867
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
869
868
|
operations(nodes, ctx) {
|
|
870
869
|
const { resolver, root } = ctx;
|
|
871
870
|
const { output, customOptions, query, group } = ctx.options;
|
|
@@ -901,29 +900,29 @@ const customHookOptionsFileGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
901
900
|
path: node_path.default.resolve(basePath, actualFilePath)
|
|
902
901
|
};
|
|
903
902
|
if (node_fs.default.existsSync(file.path)) return null;
|
|
904
|
-
return /* @__PURE__ */ (0,
|
|
903
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
905
904
|
baseName: file.baseName,
|
|
906
905
|
path: file.path,
|
|
907
906
|
children: [
|
|
908
|
-
/* @__PURE__ */ (0,
|
|
907
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
909
908
|
name: ["QueryClient"],
|
|
910
909
|
path: reactQueryImportPath,
|
|
911
910
|
isTypeOnly: true
|
|
912
911
|
}),
|
|
913
|
-
/* @__PURE__ */ (0,
|
|
912
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
914
913
|
name: ["useQueryClient"],
|
|
915
914
|
path: reactQueryImportPath
|
|
916
915
|
}),
|
|
917
|
-
/* @__PURE__ */ (0,
|
|
916
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
918
917
|
name: [hookOptionsName],
|
|
919
918
|
root: file.path,
|
|
920
919
|
path: node_path.default.resolve(root, "./index.ts")
|
|
921
920
|
}),
|
|
922
|
-
/* @__PURE__ */ (0,
|
|
921
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File.Source, {
|
|
923
922
|
name: file.name,
|
|
924
923
|
isExportable: true,
|
|
925
924
|
isIndexable: true,
|
|
926
|
-
children: [/* @__PURE__ */ (0,
|
|
925
|
+
children: [/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
927
926
|
name: customHookOptionsName,
|
|
928
927
|
params: "{ queryClient }: { queryClient: QueryClient }",
|
|
929
928
|
returnType: `Partial<${hookOptionsName}>`,
|
|
@@ -936,7 +935,7 @@ const customHookOptionsFileGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
936
935
|
// }
|
|
937
936
|
// }
|
|
938
937
|
}`
|
|
939
|
-
}), /* @__PURE__ */ (0,
|
|
938
|
+
}), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
940
939
|
name,
|
|
941
940
|
generics: `T extends keyof ${hookOptionsName}`,
|
|
942
941
|
params: "{ hookName, operationId }: { hookName: T, operationId: string }",
|
|
@@ -983,9 +982,9 @@ function buildResolvedRequestParams(node) {
|
|
|
983
982
|
* every hook keyed by name so user-supplied options stay in sync with the
|
|
984
983
|
* generated hooks at compile time.
|
|
985
984
|
*/
|
|
986
|
-
const hookOptionsGenerator = (0,
|
|
985
|
+
const hookOptionsGenerator = (0, kubb_kit.defineGenerator)({
|
|
987
986
|
name: "react-query-hook-options",
|
|
988
|
-
renderer:
|
|
987
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
989
988
|
operations(nodes, ctx) {
|
|
990
989
|
const { resolver, config, root } = ctx;
|
|
991
990
|
const { output, customOptions, query, mutation, suspense, infinite, group, override, hooks } = ctx.options;
|
|
@@ -1007,7 +1006,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1007
1006
|
const imports = [];
|
|
1008
1007
|
const hookOptions = {};
|
|
1009
1008
|
for (const node of nodes) {
|
|
1010
|
-
if (!
|
|
1009
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) continue;
|
|
1011
1010
|
const opOverrides = resolveOperationOverrides(node, override);
|
|
1012
1011
|
const nodeQuery = "query" in opOverrides ? opOverrides.query : query;
|
|
1013
1012
|
const nodeMutation = "mutation" in opOverrides ? opOverrides.mutation : mutation;
|
|
@@ -1026,7 +1025,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1026
1025
|
output,
|
|
1027
1026
|
group: group ?? void 0
|
|
1028
1027
|
});
|
|
1029
|
-
imports.push(/* @__PURE__ */ (0,
|
|
1028
|
+
imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1030
1029
|
name: [queryOptionsName],
|
|
1031
1030
|
root: hookOptionsFile.path,
|
|
1032
1031
|
path: queryHookFile.path
|
|
@@ -1040,7 +1039,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1040
1039
|
output,
|
|
1041
1040
|
group: group ?? void 0
|
|
1042
1041
|
});
|
|
1043
|
-
imports.push(/* @__PURE__ */ (0,
|
|
1042
|
+
imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1044
1043
|
name: [suspenseOptionsName],
|
|
1045
1044
|
root: hookOptionsFile.path,
|
|
1046
1045
|
path: suspenseHookFile.path
|
|
@@ -1058,7 +1057,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1058
1057
|
output,
|
|
1059
1058
|
group: group ?? void 0
|
|
1060
1059
|
});
|
|
1061
|
-
imports.push(/* @__PURE__ */ (0,
|
|
1060
|
+
imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1062
1061
|
name: [infiniteOptionsName],
|
|
1063
1062
|
root: hookOptionsFile.path,
|
|
1064
1063
|
path: infiniteHookFile.path
|
|
@@ -1072,7 +1071,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1072
1071
|
output,
|
|
1073
1072
|
group: group ?? void 0
|
|
1074
1073
|
});
|
|
1075
|
-
imports.push(/* @__PURE__ */ (0,
|
|
1074
|
+
imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1076
1075
|
name: [suspenseInfiniteOptionsName],
|
|
1077
1076
|
root: hookOptionsFile.path,
|
|
1078
1077
|
path: suspenseInfiniteHookFile.path
|
|
@@ -1090,7 +1089,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1090
1089
|
output,
|
|
1091
1090
|
group: group ?? void 0
|
|
1092
1091
|
});
|
|
1093
|
-
imports.push(/* @__PURE__ */ (0,
|
|
1092
|
+
imports.push(/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1094
1093
|
name: [mutationOptionsName],
|
|
1095
1094
|
root: hookOptionsFile.path,
|
|
1096
1095
|
path: mutationHookFile.path
|
|
@@ -1098,7 +1097,7 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1098
1097
|
hookOptions[mutationHookName] = `Partial<ReturnType<typeof ${mutationOptionsName}>>`;
|
|
1099
1098
|
}
|
|
1100
1099
|
}
|
|
1101
|
-
return /* @__PURE__ */ (0,
|
|
1100
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1102
1101
|
baseName: hookOptionsFile.baseName,
|
|
1103
1102
|
path: hookOptionsFile.path,
|
|
1104
1103
|
meta: hookOptionsFile.meta,
|
|
@@ -1118,12 +1117,12 @@ const hookOptionsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1118
1117
|
baseName: hookOptionsFile.baseName
|
|
1119
1118
|
}
|
|
1120
1119
|
}),
|
|
1121
|
-
children: [imports, /* @__PURE__ */ (0,
|
|
1120
|
+
children: [imports, /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1122
1121
|
name,
|
|
1123
1122
|
isExportable: true,
|
|
1124
1123
|
isIndexable: true,
|
|
1125
1124
|
isTypeOnly: true,
|
|
1126
|
-
children: /* @__PURE__ */ (0,
|
|
1125
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Type, {
|
|
1127
1126
|
export: true,
|
|
1128
1127
|
name,
|
|
1129
1128
|
children: `{ ${Object.keys(hookOptions).map((key) => `${JSON.stringify(key)}: ${hookOptions[key]}`).join(", ")} }`
|
|
@@ -1184,11 +1183,11 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
1184
1183
|
pageParamGeneric: "TPageParam"
|
|
1185
1184
|
});
|
|
1186
1185
|
const paramsSignature = declarationPrinter$8.print(paramsNode) ?? "";
|
|
1187
|
-
return /* @__PURE__ */ (0,
|
|
1186
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1188
1187
|
name,
|
|
1189
1188
|
isExportable: true,
|
|
1190
1189
|
isIndexable: true,
|
|
1191
|
-
children: /* @__PURE__ */ (0,
|
|
1190
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1192
1191
|
name,
|
|
1193
1192
|
export: true,
|
|
1194
1193
|
generics: generics.join(", "),
|
|
@@ -1235,11 +1234,11 @@ function QueryOptions({ name, clientName, node, tsResolver, queryKeyName }) {
|
|
|
1235
1234
|
signal: true
|
|
1236
1235
|
})}
|
|
1237
1236
|
return data`;
|
|
1238
|
-
return /* @__PURE__ */ (0,
|
|
1237
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1239
1238
|
name,
|
|
1240
1239
|
isExportable: true,
|
|
1241
1240
|
isIndexable: true,
|
|
1242
|
-
children: /* @__PURE__ */ (0,
|
|
1241
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1243
1242
|
name,
|
|
1244
1243
|
export: true,
|
|
1245
1244
|
params: paramsSignature,
|
|
@@ -1288,8 +1287,8 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
1288
1287
|
const hasNewParams = nextParam != null || previousParam != null;
|
|
1289
1288
|
const [getNextPageParamExpr, getPreviousPageParamExpr] = (() => {
|
|
1290
1289
|
if (hasNewParams) {
|
|
1291
|
-
const nextAccessor = nextParam ?
|
|
1292
|
-
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;
|
|
1293
1292
|
return [nextAccessor ? `getNextPageParam: (lastPage) => ${nextAccessor}` : null, prevAccessor ? `getPreviousPageParam: (firstPage) => ${prevAccessor}` : null];
|
|
1294
1293
|
}
|
|
1295
1294
|
if (cursorParam) return [`getNextPageParam: (lastPage) => lastPage['${cursorParam}']`, `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`];
|
|
@@ -1304,11 +1303,11 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
1304
1303
|
...(query ?? {}),
|
|
1305
1304
|
['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
|
|
1306
1305
|
} as ${queryParamsTypeName}` : "";
|
|
1307
|
-
if (infiniteOverrideParams) return /* @__PURE__ */ (0,
|
|
1306
|
+
if (infiniteOverrideParams) return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1308
1307
|
name,
|
|
1309
1308
|
isExportable: true,
|
|
1310
1309
|
isIndexable: true,
|
|
1311
|
-
children: /* @__PURE__ */ (0,
|
|
1310
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1312
1311
|
name,
|
|
1313
1312
|
export: true,
|
|
1314
1313
|
params: paramsSignature,
|
|
@@ -1325,11 +1324,11 @@ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${que
|
|
|
1325
1324
|
`
|
|
1326
1325
|
})
|
|
1327
1326
|
});
|
|
1328
|
-
return /* @__PURE__ */ (0,
|
|
1327
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1329
1328
|
name,
|
|
1330
1329
|
isExportable: true,
|
|
1331
1330
|
isIndexable: true,
|
|
1332
|
-
children: /* @__PURE__ */ (0,
|
|
1331
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1333
1332
|
name,
|
|
1334
1333
|
export: true,
|
|
1335
1334
|
params: paramsSignature,
|
|
@@ -1374,11 +1373,11 @@ function MutationOptions({ name, clientName, node, tsResolver, mutationKeyName }
|
|
|
1374
1373
|
signal: false
|
|
1375
1374
|
})}
|
|
1376
1375
|
return data`;
|
|
1377
|
-
return /* @__PURE__ */ (0,
|
|
1376
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1378
1377
|
name,
|
|
1379
1378
|
isExportable: true,
|
|
1380
1379
|
isIndexable: true,
|
|
1381
|
-
children: /* @__PURE__ */ (0,
|
|
1380
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1382
1381
|
name,
|
|
1383
1382
|
export: true,
|
|
1384
1383
|
params: paramsSignature,
|
|
@@ -1436,11 +1435,11 @@ function Mutation({ name, mutationOptionsName, node, tsResolver, mutationKeyName
|
|
|
1436
1435
|
const mutationOptionsParamsCall = callPrinter$1.print(mutationOptionsConfigNode) ?? "";
|
|
1437
1436
|
const paramsNode = buildMutationParamsNode(node, { resolver: tsResolver });
|
|
1438
1437
|
const paramsSignature = declarationPrinter$4.print(paramsNode) ?? "";
|
|
1439
|
-
return /* @__PURE__ */ (0,
|
|
1438
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1440
1439
|
name,
|
|
1441
1440
|
isExportable: true,
|
|
1442
1441
|
isIndexable: true,
|
|
1443
|
-
children: /* @__PURE__ */ (0,
|
|
1442
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1444
1443
|
name,
|
|
1445
1444
|
export: true,
|
|
1446
1445
|
params: paramsSignature,
|
|
@@ -1505,11 +1504,11 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
|
|
|
1505
1504
|
const queryOptionsArgs = resolvedParams ? "resolvedParams, config" : "config";
|
|
1506
1505
|
const paramsNode = buildQueryParamsNode(node, { resolver: tsResolver });
|
|
1507
1506
|
const paramsSignature = declarationPrinter$3.print(paramsNode) ?? "";
|
|
1508
|
-
return /* @__PURE__ */ (0,
|
|
1507
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1509
1508
|
name,
|
|
1510
1509
|
isExportable: true,
|
|
1511
1510
|
isIndexable: true,
|
|
1512
|
-
children: /* @__PURE__ */ (0,
|
|
1511
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1513
1512
|
name,
|
|
1514
1513
|
export: true,
|
|
1515
1514
|
generics: generics.join(", "),
|
|
@@ -1586,11 +1585,11 @@ function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, query
|
|
|
1586
1585
|
pageParamGeneric: "TPageParam"
|
|
1587
1586
|
});
|
|
1588
1587
|
const paramsSignature = declarationPrinter$2.print(paramsNode) ?? "";
|
|
1589
|
-
return /* @__PURE__ */ (0,
|
|
1588
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1590
1589
|
name,
|
|
1591
1590
|
isExportable: true,
|
|
1592
1591
|
isIndexable: true,
|
|
1593
|
-
children: /* @__PURE__ */ (0,
|
|
1592
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1594
1593
|
name,
|
|
1595
1594
|
export: true,
|
|
1596
1595
|
generics: generics.join(", "),
|
|
@@ -1648,8 +1647,8 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
|
|
|
1648
1647
|
const hasNewParams = nextParam != null || previousParam != null;
|
|
1649
1648
|
const [getNextPageParamExpr, getPreviousPageParamExpr] = (() => {
|
|
1650
1649
|
if (hasNewParams) {
|
|
1651
|
-
const nextAccessor = nextParam ?
|
|
1652
|
-
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;
|
|
1653
1652
|
return [nextAccessor ? `getNextPageParam: (lastPage) => ${nextAccessor}` : null, prevAccessor ? `getPreviousPageParam: (firstPage) => ${prevAccessor}` : null];
|
|
1654
1653
|
}
|
|
1655
1654
|
if (cursorParam) return [`getNextPageParam: (lastPage) => lastPage['${cursorParam}']`, `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`];
|
|
@@ -1664,11 +1663,11 @@ function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, curs
|
|
|
1664
1663
|
...(query ?? {}),
|
|
1665
1664
|
['${queryParam}']: pageParam as unknown as ${queryParamsTypeName}['${queryParam}'],
|
|
1666
1665
|
} as ${queryParamsTypeName}` : "";
|
|
1667
|
-
if (infiniteOverrideParams) return /* @__PURE__ */ (0,
|
|
1666
|
+
if (infiniteOverrideParams) return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1668
1667
|
name,
|
|
1669
1668
|
isExportable: true,
|
|
1670
1669
|
isIndexable: true,
|
|
1671
|
-
children: /* @__PURE__ */ (0,
|
|
1670
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1672
1671
|
name,
|
|
1673
1672
|
export: true,
|
|
1674
1673
|
params: paramsSignature,
|
|
@@ -1685,11 +1684,11 @@ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${que
|
|
|
1685
1684
|
`
|
|
1686
1685
|
})
|
|
1687
1686
|
});
|
|
1688
|
-
return /* @__PURE__ */ (0,
|
|
1687
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1689
1688
|
name,
|
|
1690
1689
|
isExportable: true,
|
|
1691
1690
|
isIndexable: true,
|
|
1692
|
-
children: /* @__PURE__ */ (0,
|
|
1691
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1693
1692
|
name,
|
|
1694
1693
|
export: true,
|
|
1695
1694
|
params: paramsSignature,
|
|
@@ -1744,11 +1743,11 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
1744
1743
|
const queryOptionsArgs = resolvedParams ? "resolvedParams, config" : "config";
|
|
1745
1744
|
const paramsNode = buildSuspenseQueryParamsNode(node, { resolver: tsResolver });
|
|
1746
1745
|
const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
|
|
1747
|
-
return /* @__PURE__ */ (0,
|
|
1746
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1748
1747
|
name,
|
|
1749
1748
|
isExportable: true,
|
|
1750
1749
|
isIndexable: true,
|
|
1751
|
-
children: /* @__PURE__ */ (0,
|
|
1750
|
+
children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.Function, {
|
|
1752
1751
|
name,
|
|
1753
1752
|
export: true,
|
|
1754
1753
|
generics: generics.join(", "),
|
|
@@ -1781,11 +1780,11 @@ function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
1781
1780
|
* hook per query operation, wiring the configured `nextParam` /
|
|
1782
1781
|
* `previousParam` paths into TanStack Query's cursor-based pagination.
|
|
1783
1782
|
*/
|
|
1784
|
-
const infiniteQueryGenerator = (0,
|
|
1783
|
+
const infiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
1785
1784
|
name: "react-infinite-query",
|
|
1786
|
-
renderer:
|
|
1785
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
1787
1786
|
operation(node, ctx) {
|
|
1788
|
-
if (!
|
|
1787
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1789
1788
|
const { config, driver, resolver, root } = ctx;
|
|
1790
1789
|
const { output, query, mutation, infinite, client, group, customOptions, hooks } = ctx.options;
|
|
1791
1790
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1838,7 +1837,7 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1838
1837
|
})
|
|
1839
1838
|
].filter((name) => Boolean(name));
|
|
1840
1839
|
const calledClientName = contractOp.name;
|
|
1841
|
-
return /* @__PURE__ */ (0,
|
|
1840
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1842
1841
|
baseName: meta.file.baseName,
|
|
1843
1842
|
path: meta.file.path,
|
|
1844
1843
|
meta: meta.file.meta,
|
|
@@ -1859,44 +1858,44 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1859
1858
|
}
|
|
1860
1859
|
}),
|
|
1861
1860
|
children: [
|
|
1862
|
-
/* @__PURE__ */ (0,
|
|
1861
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1863
1862
|
name: [contractOp.name],
|
|
1864
1863
|
root: meta.file.path,
|
|
1865
1864
|
path: contractOp.path
|
|
1866
1865
|
}),
|
|
1867
|
-
/* @__PURE__ */ (0,
|
|
1866
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1868
1867
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
1869
1868
|
root: meta.file.path,
|
|
1870
1869
|
path: contractOp.clientPath,
|
|
1871
1870
|
isTypeOnly: true
|
|
1872
1871
|
}),
|
|
1873
|
-
customOptions && /* @__PURE__ */ (0,
|
|
1872
|
+
customOptions && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1874
1873
|
name: [customOptions.name],
|
|
1875
1874
|
path: customOptions.importPath
|
|
1876
1875
|
}),
|
|
1877
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
1876
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1878
1877
|
name: Array.from(new Set(importedTypeNames)),
|
|
1879
1878
|
root: meta.file.path,
|
|
1880
1879
|
path: meta.fileTs.path,
|
|
1881
1880
|
isTypeOnly: true
|
|
1882
1881
|
}),
|
|
1883
|
-
/* @__PURE__ */ (0,
|
|
1882
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
1884
1883
|
name: queryKeyName,
|
|
1885
1884
|
typeName: queryKeyTypeName,
|
|
1886
1885
|
node,
|
|
1887
1886
|
tsResolver,
|
|
1888
1887
|
transformer: ctx.options.queryKey
|
|
1889
1888
|
}),
|
|
1890
|
-
/* @__PURE__ */ (0,
|
|
1889
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1891
1890
|
name: ["InfiniteData"],
|
|
1892
1891
|
isTypeOnly: true,
|
|
1893
1892
|
path: importPath
|
|
1894
1893
|
}),
|
|
1895
|
-
/* @__PURE__ */ (0,
|
|
1894
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1896
1895
|
name: ["infiniteQueryOptions"],
|
|
1897
1896
|
path: importPath
|
|
1898
1897
|
}),
|
|
1899
|
-
/* @__PURE__ */ (0,
|
|
1898
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(InfiniteQueryOptions, {
|
|
1900
1899
|
name: queryOptionsName,
|
|
1901
1900
|
clientName: calledClientName,
|
|
1902
1901
|
queryKeyName,
|
|
@@ -1908,12 +1907,12 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1908
1907
|
initialPageParam: infiniteOptions.initialPageParam,
|
|
1909
1908
|
queryParam: infiniteOptions.queryParam
|
|
1910
1909
|
}),
|
|
1911
|
-
hooks && /* @__PURE__ */ (0,
|
|
1912
|
-
/* @__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, {
|
|
1913
1912
|
name: ["useInfiniteQuery"],
|
|
1914
1913
|
path: importPath
|
|
1915
1914
|
}),
|
|
1916
|
-
/* @__PURE__ */ (0,
|
|
1915
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1917
1916
|
name: [
|
|
1918
1917
|
"QueryKey",
|
|
1919
1918
|
"QueryClient",
|
|
@@ -1923,7 +1922,7 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1923
1922
|
path: importPath,
|
|
1924
1923
|
isTypeOnly: true
|
|
1925
1924
|
}),
|
|
1926
|
-
/* @__PURE__ */ (0,
|
|
1925
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(InfiniteQuery, {
|
|
1927
1926
|
name: queryName,
|
|
1928
1927
|
queryOptionsName,
|
|
1929
1928
|
queryKeyName,
|
|
@@ -1946,11 +1945,11 @@ const infiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1946
1945
|
* per POST/PUT/DELETE operation (configurable via `mutation.methods`) plus
|
|
1947
1946
|
* the matching `fooMutationKey` / `fooMutationOptions` helpers.
|
|
1948
1947
|
*/
|
|
1949
|
-
const mutationGenerator = (0,
|
|
1948
|
+
const mutationGenerator = (0, kubb_kit.defineGenerator)({
|
|
1950
1949
|
name: "react-query-mutation",
|
|
1951
|
-
renderer:
|
|
1950
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
1952
1951
|
operation(node, ctx) {
|
|
1953
|
-
if (!
|
|
1952
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1954
1953
|
const { config, driver, resolver, root } = ctx;
|
|
1955
1954
|
const { output, query, mutation, client, group, customOptions, hooks } = ctx.options;
|
|
1956
1955
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
@@ -1989,7 +1988,7 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1989
1988
|
includeParams: false
|
|
1990
1989
|
})].filter((name) => Boolean(name));
|
|
1991
1990
|
const calledClientName = contractOp.name;
|
|
1992
|
-
return /* @__PURE__ */ (0,
|
|
1991
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1993
1992
|
baseName: meta.file.baseName,
|
|
1994
1993
|
path: meta.file.path,
|
|
1995
1994
|
meta: meta.file.meta,
|
|
@@ -2010,49 +2009,49 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2010
2009
|
}
|
|
2011
2010
|
}),
|
|
2012
2011
|
children: [
|
|
2013
|
-
/* @__PURE__ */ (0,
|
|
2012
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2014
2013
|
name: [contractOp.name],
|
|
2015
2014
|
root: meta.file.path,
|
|
2016
2015
|
path: contractOp.path
|
|
2017
2016
|
}),
|
|
2018
|
-
/* @__PURE__ */ (0,
|
|
2017
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2019
2018
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
2020
2019
|
root: meta.file.path,
|
|
2021
2020
|
path: contractOp.clientPath,
|
|
2022
2021
|
isTypeOnly: true
|
|
2023
2022
|
}),
|
|
2024
|
-
customOptions && /* @__PURE__ */ (0,
|
|
2023
|
+
customOptions && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2025
2024
|
name: [customOptions.name],
|
|
2026
2025
|
path: customOptions.importPath
|
|
2027
2026
|
}),
|
|
2028
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
2027
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2029
2028
|
name: Array.from(new Set(importedTypeNames)),
|
|
2030
2029
|
root: meta.file.path,
|
|
2031
2030
|
path: meta.fileTs.path,
|
|
2032
2031
|
isTypeOnly: true
|
|
2033
2032
|
}),
|
|
2034
|
-
/* @__PURE__ */ (0,
|
|
2033
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(MutationKey, {
|
|
2035
2034
|
name: mutationKeyName,
|
|
2036
2035
|
node,
|
|
2037
2036
|
transformer: ctx.options.mutationKey
|
|
2038
2037
|
}),
|
|
2039
|
-
/* @__PURE__ */ (0,
|
|
2038
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2040
2039
|
name: ["mutationOptions"],
|
|
2041
2040
|
path: importPath
|
|
2042
2041
|
}),
|
|
2043
|
-
/* @__PURE__ */ (0,
|
|
2042
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(MutationOptions, {
|
|
2044
2043
|
name: mutationOptionsName,
|
|
2045
2044
|
clientName: calledClientName,
|
|
2046
2045
|
mutationKeyName,
|
|
2047
2046
|
node,
|
|
2048
2047
|
tsResolver
|
|
2049
2048
|
}),
|
|
2050
|
-
mutation && hooks && /* @__PURE__ */ (0,
|
|
2051
|
-
/* @__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, {
|
|
2052
2051
|
name: ["useMutation"],
|
|
2053
2052
|
path: importPath
|
|
2054
2053
|
}),
|
|
2055
|
-
/* @__PURE__ */ (0,
|
|
2054
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2056
2055
|
name: [
|
|
2057
2056
|
"UseMutationOptions",
|
|
2058
2057
|
"UseMutationResult",
|
|
@@ -2061,7 +2060,7 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2061
2060
|
path: importPath,
|
|
2062
2061
|
isTypeOnly: true
|
|
2063
2062
|
}),
|
|
2064
|
-
/* @__PURE__ */ (0,
|
|
2063
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Mutation, {
|
|
2065
2064
|
name: mutationHookName,
|
|
2066
2065
|
typeName: mutationTypeName,
|
|
2067
2066
|
mutationOptionsName,
|
|
@@ -2082,11 +2081,11 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2082
2081
|
* GET operation (configurable via `query.methods`) plus the matching
|
|
2083
2082
|
* `fooQueryKey` / `fooQueryOptions` helpers.
|
|
2084
2083
|
*/
|
|
2085
|
-
const queryGenerator = (0,
|
|
2084
|
+
const queryGenerator = (0, kubb_kit.defineGenerator)({
|
|
2086
2085
|
name: "react-query",
|
|
2087
|
-
renderer:
|
|
2086
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
2088
2087
|
operation(node, ctx) {
|
|
2089
|
-
if (!
|
|
2088
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
2090
2089
|
const { config, driver, resolver, root } = ctx;
|
|
2091
2090
|
const { output, query, mutation, client, group, customOptions, hooks } = ctx.options;
|
|
2092
2091
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
@@ -2127,7 +2126,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2127
2126
|
includeParams: false
|
|
2128
2127
|
})].filter((name) => Boolean(name));
|
|
2129
2128
|
const calledClientName = contractOp.name;
|
|
2130
|
-
return /* @__PURE__ */ (0,
|
|
2129
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
2131
2130
|
baseName: meta.file.baseName,
|
|
2132
2131
|
path: meta.file.path,
|
|
2133
2132
|
meta: meta.file.meta,
|
|
@@ -2148,51 +2147,51 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2148
2147
|
}
|
|
2149
2148
|
}),
|
|
2150
2149
|
children: [
|
|
2151
|
-
/* @__PURE__ */ (0,
|
|
2150
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2152
2151
|
name: [contractOp.name],
|
|
2153
2152
|
root: meta.file.path,
|
|
2154
2153
|
path: contractOp.path
|
|
2155
2154
|
}),
|
|
2156
|
-
/* @__PURE__ */ (0,
|
|
2155
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2157
2156
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
2158
2157
|
root: meta.file.path,
|
|
2159
2158
|
path: contractOp.clientPath,
|
|
2160
2159
|
isTypeOnly: true
|
|
2161
2160
|
}),
|
|
2162
|
-
customOptions && /* @__PURE__ */ (0,
|
|
2161
|
+
customOptions && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2163
2162
|
name: [customOptions.name],
|
|
2164
2163
|
path: customOptions.importPath
|
|
2165
2164
|
}),
|
|
2166
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
2165
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2167
2166
|
name: Array.from(new Set(importedTypeNames)),
|
|
2168
2167
|
root: meta.file.path,
|
|
2169
2168
|
path: meta.fileTs.path,
|
|
2170
2169
|
isTypeOnly: true
|
|
2171
2170
|
}),
|
|
2172
|
-
/* @__PURE__ */ (0,
|
|
2171
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
2173
2172
|
name: queryKeyName,
|
|
2174
2173
|
typeName: queryKeyTypeName,
|
|
2175
2174
|
node,
|
|
2176
2175
|
tsResolver,
|
|
2177
2176
|
transformer: ctx.options.queryKey
|
|
2178
2177
|
}),
|
|
2179
|
-
/* @__PURE__ */ (0,
|
|
2178
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2180
2179
|
name: ["queryOptions"],
|
|
2181
2180
|
path: importPath
|
|
2182
2181
|
}),
|
|
2183
|
-
/* @__PURE__ */ (0,
|
|
2182
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryOptions, {
|
|
2184
2183
|
name: queryOptionsName,
|
|
2185
2184
|
clientName: calledClientName,
|
|
2186
2185
|
queryKeyName,
|
|
2187
2186
|
node,
|
|
2188
2187
|
tsResolver
|
|
2189
2188
|
}),
|
|
2190
|
-
query && hooks && /* @__PURE__ */ (0,
|
|
2191
|
-
/* @__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, {
|
|
2192
2191
|
name: ["useQuery"],
|
|
2193
2192
|
path: importPath
|
|
2194
2193
|
}),
|
|
2195
|
-
/* @__PURE__ */ (0,
|
|
2194
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2196
2195
|
name: [
|
|
2197
2196
|
"QueryKey",
|
|
2198
2197
|
"QueryClient",
|
|
@@ -2202,7 +2201,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2202
2201
|
path: importPath,
|
|
2203
2202
|
isTypeOnly: true
|
|
2204
2203
|
}),
|
|
2205
|
-
/* @__PURE__ */ (0,
|
|
2204
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Query, {
|
|
2206
2205
|
name: queryName,
|
|
2207
2206
|
queryOptionsName,
|
|
2208
2207
|
queryKeyName,
|
|
@@ -2224,11 +2223,11 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2224
2223
|
* cursor-based pagination. Handlers throw promises while loading and pull
|
|
2225
2224
|
* additional pages on demand.
|
|
2226
2225
|
*/
|
|
2227
|
-
const suspenseInfiniteQueryGenerator = (0,
|
|
2226
|
+
const suspenseInfiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
2228
2227
|
name: "react-suspense-infinite-query",
|
|
2229
|
-
renderer:
|
|
2228
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
2230
2229
|
operation(node, ctx) {
|
|
2231
|
-
if (!
|
|
2230
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
2232
2231
|
const { config, driver, resolver, root } = ctx;
|
|
2233
2232
|
const { output, query, mutation, infinite, suspense, client, group, customOptions, hooks } = ctx.options;
|
|
2234
2233
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
@@ -2281,7 +2280,7 @@ const suspenseInfiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2281
2280
|
})
|
|
2282
2281
|
].filter((name) => Boolean(name));
|
|
2283
2282
|
const calledClientName = contractOp.name;
|
|
2284
|
-
return /* @__PURE__ */ (0,
|
|
2283
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
2285
2284
|
baseName: meta.file.baseName,
|
|
2286
2285
|
path: meta.file.path,
|
|
2287
2286
|
meta: meta.file.meta,
|
|
@@ -2302,44 +2301,44 @@ const suspenseInfiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2302
2301
|
}
|
|
2303
2302
|
}),
|
|
2304
2303
|
children: [
|
|
2305
|
-
/* @__PURE__ */ (0,
|
|
2304
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2306
2305
|
name: [contractOp.name],
|
|
2307
2306
|
root: meta.file.path,
|
|
2308
2307
|
path: contractOp.path
|
|
2309
2308
|
}),
|
|
2310
|
-
/* @__PURE__ */ (0,
|
|
2309
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2311
2310
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
2312
2311
|
root: meta.file.path,
|
|
2313
2312
|
path: contractOp.clientPath,
|
|
2314
2313
|
isTypeOnly: true
|
|
2315
2314
|
}),
|
|
2316
|
-
customOptions && /* @__PURE__ */ (0,
|
|
2315
|
+
customOptions && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2317
2316
|
name: [customOptions.name],
|
|
2318
2317
|
path: customOptions.importPath
|
|
2319
2318
|
}),
|
|
2320
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
2319
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2321
2320
|
name: Array.from(new Set(importedTypeNames)),
|
|
2322
2321
|
root: meta.file.path,
|
|
2323
2322
|
path: meta.fileTs.path,
|
|
2324
2323
|
isTypeOnly: true
|
|
2325
2324
|
}),
|
|
2326
|
-
/* @__PURE__ */ (0,
|
|
2325
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
2327
2326
|
name: queryKeyName,
|
|
2328
2327
|
typeName: queryKeyTypeName,
|
|
2329
2328
|
node,
|
|
2330
2329
|
tsResolver,
|
|
2331
2330
|
transformer: ctx.options.queryKey
|
|
2332
2331
|
}),
|
|
2333
|
-
/* @__PURE__ */ (0,
|
|
2332
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2334
2333
|
name: ["InfiniteData"],
|
|
2335
2334
|
isTypeOnly: true,
|
|
2336
2335
|
path: importPath
|
|
2337
2336
|
}),
|
|
2338
|
-
/* @__PURE__ */ (0,
|
|
2337
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2339
2338
|
name: ["infiniteQueryOptions"],
|
|
2340
2339
|
path: importPath
|
|
2341
2340
|
}),
|
|
2342
|
-
/* @__PURE__ */ (0,
|
|
2341
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(SuspenseInfiniteQueryOptions, {
|
|
2343
2342
|
name: queryOptionsName,
|
|
2344
2343
|
clientName: calledClientName,
|
|
2345
2344
|
queryKeyName,
|
|
@@ -2351,12 +2350,12 @@ const suspenseInfiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2351
2350
|
initialPageParam: infiniteOptions.initialPageParam,
|
|
2352
2351
|
queryParam: infiniteOptions.queryParam
|
|
2353
2352
|
}),
|
|
2354
|
-
hooks && /* @__PURE__ */ (0,
|
|
2355
|
-
/* @__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, {
|
|
2356
2355
|
name: ["useSuspenseInfiniteQuery"],
|
|
2357
2356
|
path: importPath
|
|
2358
2357
|
}),
|
|
2359
|
-
/* @__PURE__ */ (0,
|
|
2358
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2360
2359
|
name: [
|
|
2361
2360
|
"QueryKey",
|
|
2362
2361
|
"QueryClient",
|
|
@@ -2366,7 +2365,7 @@ const suspenseInfiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2366
2365
|
path: importPath,
|
|
2367
2366
|
isTypeOnly: true
|
|
2368
2367
|
}),
|
|
2369
|
-
/* @__PURE__ */ (0,
|
|
2368
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(SuspenseInfiniteQuery, {
|
|
2370
2369
|
name: queryName,
|
|
2371
2370
|
queryOptionsName,
|
|
2372
2371
|
queryKeyName,
|
|
@@ -2390,11 +2389,11 @@ const suspenseInfiniteQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2390
2389
|
* per query operation. Suspense queries throw promises while loading and
|
|
2391
2390
|
* require a `<Suspense>` boundary in the React tree. TanStack Query v5+ only.
|
|
2392
2391
|
*/
|
|
2393
|
-
const suspenseQueryGenerator = (0,
|
|
2392
|
+
const suspenseQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
2394
2393
|
name: "react-suspense-query",
|
|
2395
|
-
renderer:
|
|
2394
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
2396
2395
|
operation(node, ctx) {
|
|
2397
|
-
if (!
|
|
2396
|
+
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
2398
2397
|
const { config, driver, resolver, root } = ctx;
|
|
2399
2398
|
const { output, query, mutation, suspense, client, group, customOptions, hooks } = ctx.options;
|
|
2400
2399
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
@@ -2435,7 +2434,7 @@ const suspenseQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2435
2434
|
includeParams: false
|
|
2436
2435
|
})].filter((name) => Boolean(name));
|
|
2437
2436
|
const calledClientName = contractOp.name;
|
|
2438
|
-
return /* @__PURE__ */ (0,
|
|
2437
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
2439
2438
|
baseName: meta.file.baseName,
|
|
2440
2439
|
path: meta.file.path,
|
|
2441
2440
|
meta: meta.file.meta,
|
|
@@ -2456,51 +2455,51 @@ const suspenseQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2456
2455
|
}
|
|
2457
2456
|
}),
|
|
2458
2457
|
children: [
|
|
2459
|
-
/* @__PURE__ */ (0,
|
|
2458
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2460
2459
|
name: [contractOp.name],
|
|
2461
2460
|
root: meta.file.path,
|
|
2462
2461
|
path: contractOp.path
|
|
2463
2462
|
}),
|
|
2464
|
-
/* @__PURE__ */ (0,
|
|
2463
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2465
2464
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
2466
2465
|
root: meta.file.path,
|
|
2467
2466
|
path: contractOp.clientPath,
|
|
2468
2467
|
isTypeOnly: true
|
|
2469
2468
|
}),
|
|
2470
|
-
customOptions && /* @__PURE__ */ (0,
|
|
2469
|
+
customOptions && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2471
2470
|
name: [customOptions.name],
|
|
2472
2471
|
path: customOptions.importPath
|
|
2473
2472
|
}),
|
|
2474
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
2473
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2475
2474
|
name: Array.from(new Set(importedTypeNames)),
|
|
2476
2475
|
root: meta.file.path,
|
|
2477
2476
|
path: meta.fileTs.path,
|
|
2478
2477
|
isTypeOnly: true
|
|
2479
2478
|
}),
|
|
2480
|
-
/* @__PURE__ */ (0,
|
|
2479
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryKey, {
|
|
2481
2480
|
name: queryKeyName,
|
|
2482
2481
|
typeName: queryKeyTypeName,
|
|
2483
2482
|
node,
|
|
2484
2483
|
tsResolver,
|
|
2485
2484
|
transformer: ctx.options.queryKey
|
|
2486
2485
|
}),
|
|
2487
|
-
/* @__PURE__ */ (0,
|
|
2486
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2488
2487
|
name: ["queryOptions"],
|
|
2489
2488
|
path: importPath
|
|
2490
2489
|
}),
|
|
2491
|
-
/* @__PURE__ */ (0,
|
|
2490
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(QueryOptions, {
|
|
2492
2491
|
name: queryOptionsName,
|
|
2493
2492
|
clientName: calledClientName,
|
|
2494
2493
|
queryKeyName,
|
|
2495
2494
|
node,
|
|
2496
2495
|
tsResolver
|
|
2497
2496
|
}),
|
|
2498
|
-
suspense && hooks && /* @__PURE__ */ (0,
|
|
2499
|
-
/* @__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, {
|
|
2500
2499
|
name: ["useSuspenseQuery"],
|
|
2501
2500
|
path: importPath
|
|
2502
2501
|
}),
|
|
2503
|
-
/* @__PURE__ */ (0,
|
|
2502
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
2504
2503
|
name: [
|
|
2505
2504
|
"QueryKey",
|
|
2506
2505
|
"QueryClient",
|
|
@@ -2510,7 +2509,7 @@ const suspenseQueryGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
2510
2509
|
path: importPath,
|
|
2511
2510
|
isTypeOnly: true
|
|
2512
2511
|
}),
|
|
2513
|
-
/* @__PURE__ */ (0,
|
|
2512
|
+
/* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(SuspenseQuery, {
|
|
2514
2513
|
name: queryName,
|
|
2515
2514
|
queryOptionsName,
|
|
2516
2515
|
queryKeyName,
|
|
@@ -2531,8 +2530,8 @@ function capitalize(name) {
|
|
|
2531
2530
|
}
|
|
2532
2531
|
/**
|
|
2533
2532
|
* Default resolver used by `@kubb/plugin-react-query`. Decides the names and
|
|
2534
|
-
* file paths for every generated TanStack Query hook (`
|
|
2535
|
-
* `
|
|
2533
|
+
* file paths for every generated TanStack Query hook (`useFoo`,
|
|
2534
|
+
* `useFooSuspense`, `useFooInfinite`, ...) and its companion helpers
|
|
2536
2535
|
* (`fooQueryKey`, `fooQueryOptions`).
|
|
2537
2536
|
*
|
|
2538
2537
|
* Functions and files use camelCase; hooks get the `use` prefix; suspense and
|
|
@@ -2548,7 +2547,7 @@ function capitalize(name) {
|
|
|
2548
2547
|
* resolverReactQuery.resolveQueryOptionsName(operationNode) // 'getPetByIdQueryOptions'
|
|
2549
2548
|
* ```
|
|
2550
2549
|
*/
|
|
2551
|
-
const resolverReactQuery = (0,
|
|
2550
|
+
const resolverReactQuery = (0, kubb_kit.defineResolver)(() => ({
|
|
2552
2551
|
name: "default",
|
|
2553
2552
|
pluginName: "plugin-react-query",
|
|
2554
2553
|
default(name, type) {
|
|
@@ -2654,7 +2653,7 @@ const pluginReactQueryName = "plugin-react-query";
|
|
|
2654
2653
|
*
|
|
2655
2654
|
* @example
|
|
2656
2655
|
* ```ts
|
|
2657
|
-
* import { defineConfig } from 'kubb'
|
|
2656
|
+
* import { defineConfig } from 'kubb/config'
|
|
2658
2657
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
2659
2658
|
* import { pluginReactQuery } from '@kubb/plugin-react-query'
|
|
2660
2659
|
*
|
|
@@ -2671,7 +2670,7 @@ const pluginReactQueryName = "plugin-react-query";
|
|
|
2671
2670
|
* })
|
|
2672
2671
|
* ```
|
|
2673
2672
|
*/
|
|
2674
|
-
const pluginReactQuery = (0,
|
|
2673
|
+
const pluginReactQuery = (0, kubb_kit.definePlugin)((options) => {
|
|
2675
2674
|
const { output = {
|
|
2676
2675
|
path: "hooks",
|
|
2677
2676
|
barrel: { type: "named" }
|
|
@@ -2710,17 +2709,17 @@ const pluginReactQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
2710
2709
|
queryKey,
|
|
2711
2710
|
query: query === false ? false : {
|
|
2712
2711
|
importPath: "@tanstack/react-query",
|
|
2713
|
-
methods: ["
|
|
2712
|
+
methods: ["GET"],
|
|
2714
2713
|
...query
|
|
2715
2714
|
},
|
|
2716
2715
|
mutationKey,
|
|
2717
2716
|
mutation: mutation === false ? false : {
|
|
2718
2717
|
importPath: "@tanstack/react-query",
|
|
2719
2718
|
methods: [
|
|
2720
|
-
"
|
|
2721
|
-
"
|
|
2722
|
-
"
|
|
2723
|
-
"
|
|
2719
|
+
"POST",
|
|
2720
|
+
"PUT",
|
|
2721
|
+
"PATCH",
|
|
2722
|
+
"DELETE"
|
|
2724
2723
|
],
|
|
2725
2724
|
...mutation
|
|
2726
2725
|
},
|