@kubb/plugin-client 5.0.0-alpha.29 → 5.0.0-alpha.30
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 +91 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.js +93 -123
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/generators/classClientGenerator.tsx +14 -27
- package/src/generators/clientGenerator.tsx +24 -37
- package/src/generators/groupedClientGenerator.tsx +29 -30
- package/src/generators/operationsGenerator.tsx +2 -4
- package/src/generators/staticClassClientGenerator.tsx +77 -76
- package/src/plugin.ts +22 -44
- package/src/types.ts +11 -0
package/dist/index.cjs
CHANGED
|
@@ -868,11 +868,10 @@ function resolveZodImportNames$1(node, zodResolver) {
|
|
|
868
868
|
require_chunk.__name(resolveZodImportNames$1, "resolveZodImportNames");
|
|
869
869
|
const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
870
870
|
name: "classClient",
|
|
871
|
-
|
|
872
|
-
|
|
871
|
+
operations(nodes, options) {
|
|
872
|
+
const { adapter, config, driver, resolver, root } = this;
|
|
873
873
|
const { output, group, dataReturnType, paramsCasing, paramsType, pathParamsType, parser, importPath, wrapper } = options;
|
|
874
874
|
const baseURL = options.baseURL ?? adapter.rootNode?.meta?.baseURL;
|
|
875
|
-
const root = node_path.default.resolve(config.root, config.output.path);
|
|
876
875
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
877
876
|
if (!pluginTs?.resolver) return null;
|
|
878
877
|
const tsResolver = pluginTs.resolver;
|
|
@@ -880,30 +879,29 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
880
879
|
const pluginZod = parser === "zod" ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : void 0;
|
|
881
880
|
const zodResolver = pluginZod?.resolver;
|
|
882
881
|
function buildOperationData(node) {
|
|
883
|
-
const transformedNode = plugin.transformer ? (0, _kubb_ast.transform)(node, plugin.transformer) : node;
|
|
884
882
|
const typeFile = tsResolver.resolveFile({
|
|
885
|
-
name:
|
|
883
|
+
name: node.operationId,
|
|
886
884
|
extname: ".ts",
|
|
887
|
-
tag:
|
|
888
|
-
path:
|
|
885
|
+
tag: node.tags[0] ?? "default",
|
|
886
|
+
path: node.path
|
|
889
887
|
}, {
|
|
890
888
|
root,
|
|
891
889
|
output: tsPluginOptions?.output ?? output,
|
|
892
890
|
group: tsPluginOptions?.group
|
|
893
891
|
});
|
|
894
892
|
const zodFile = zodResolver && pluginZod?.options ? zodResolver.resolveFile({
|
|
895
|
-
name:
|
|
893
|
+
name: node.operationId,
|
|
896
894
|
extname: ".ts",
|
|
897
|
-
tag:
|
|
898
|
-
path:
|
|
895
|
+
tag: node.tags[0] ?? "default",
|
|
896
|
+
path: node.path
|
|
899
897
|
}, {
|
|
900
898
|
root,
|
|
901
899
|
output: pluginZod.options.output ?? output,
|
|
902
900
|
group: pluginZod.options.group
|
|
903
901
|
}) : void 0;
|
|
904
902
|
return {
|
|
905
|
-
node
|
|
906
|
-
name: resolver.resolveName(
|
|
903
|
+
node,
|
|
904
|
+
name: resolver.resolveName(node.operationId),
|
|
907
905
|
tsResolver,
|
|
908
906
|
zodResolver,
|
|
909
907
|
typeFile,
|
|
@@ -1030,12 +1028,12 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1030
1028
|
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1031
1029
|
name: ["fetch"],
|
|
1032
1030
|
root: file.path,
|
|
1033
|
-
path: node_path.default.resolve(
|
|
1031
|
+
path: node_path.default.resolve(root, ".kubb/fetch.ts")
|
|
1034
1032
|
}),
|
|
1035
1033
|
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1036
1034
|
name: ["mergeConfig"],
|
|
1037
1035
|
root: file.path,
|
|
1038
|
-
path: node_path.default.resolve(
|
|
1036
|
+
path: node_path.default.resolve(root, ".kubb/fetch.ts")
|
|
1039
1037
|
}),
|
|
1040
1038
|
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1041
1039
|
name: [
|
|
@@ -1044,14 +1042,14 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1044
1042
|
"ResponseErrorConfig"
|
|
1045
1043
|
],
|
|
1046
1044
|
root: file.path,
|
|
1047
|
-
path: node_path.default.resolve(
|
|
1045
|
+
path: node_path.default.resolve(root, ".kubb/fetch.ts"),
|
|
1048
1046
|
isTypeOnly: true
|
|
1049
1047
|
})
|
|
1050
1048
|
] }),
|
|
1051
1049
|
hasFormData && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1052
1050
|
name: ["buildFormData"],
|
|
1053
1051
|
root: file.path,
|
|
1054
|
-
path: node_path.default.resolve(
|
|
1052
|
+
path: node_path.default.resolve(root, ".kubb/config.ts")
|
|
1055
1053
|
}),
|
|
1056
1054
|
Array.from(typeImportsByFile.entries()).map(([filePath, importSet]) => {
|
|
1057
1055
|
const typeFile = typeFilesByPath.get(filePath);
|
|
@@ -1118,7 +1116,7 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1118
1116
|
}) : /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1119
1117
|
name: ["Client", "RequestConfig"],
|
|
1120
1118
|
root: wrapperFile.path,
|
|
1121
|
-
path: node_path.default.resolve(
|
|
1119
|
+
path: node_path.default.resolve(root, ".kubb/fetch.ts"),
|
|
1122
1120
|
isTypeOnly: true
|
|
1123
1121
|
}),
|
|
1124
1122
|
controllers.map(({ name, file }) => /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
@@ -1133,72 +1131,70 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1133
1131
|
]
|
|
1134
1132
|
}, wrapperFile.path));
|
|
1135
1133
|
}
|
|
1136
|
-
return files;
|
|
1134
|
+
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric_jsx_runtime.Fragment, { children: files });
|
|
1137
1135
|
}
|
|
1138
1136
|
});
|
|
1139
1137
|
//#endregion
|
|
1140
1138
|
//#region src/generators/clientGenerator.tsx
|
|
1141
1139
|
const clientGenerator = (0, _kubb_core.defineGenerator)({
|
|
1142
1140
|
name: "client",
|
|
1143
|
-
|
|
1144
|
-
|
|
1141
|
+
operation(node, options) {
|
|
1142
|
+
const { adapter, config, driver, resolver, root } = this;
|
|
1145
1143
|
const { output, urlType, dataReturnType, paramsCasing, paramsType, pathParamsType, parser, importPath, group } = options;
|
|
1146
1144
|
const baseURL = options.baseURL ?? adapter.rootNode?.meta?.baseURL;
|
|
1147
|
-
const root = node_path.default.resolve(config.root, config.output.path);
|
|
1148
1145
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1149
1146
|
if (!pluginTs?.resolver) return null;
|
|
1150
1147
|
const tsResolver = pluginTs.resolver;
|
|
1151
1148
|
const pluginZod = parser === "zod" ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : void 0;
|
|
1152
1149
|
const zodResolver = pluginZod?.resolver;
|
|
1153
|
-
const
|
|
1154
|
-
const casedParams = (0, _kubb_ast.caseParams)(transformedNode.parameters, paramsCasing);
|
|
1150
|
+
const casedParams = (0, _kubb_ast.caseParams)(node.parameters, paramsCasing);
|
|
1155
1151
|
const pathParams = casedParams.filter((p) => p.in === "path");
|
|
1156
1152
|
const queryParams = casedParams.filter((p) => p.in === "query");
|
|
1157
1153
|
const headerParams = casedParams.filter((p) => p.in === "header");
|
|
1158
1154
|
const importedTypeNames = [
|
|
1159
|
-
...pathParams.map((p) => tsResolver.resolvePathParamsName(
|
|
1160
|
-
...queryParams.map((p) => tsResolver.resolveQueryParamsName(
|
|
1161
|
-
...headerParams.map((p) => tsResolver.resolveHeaderParamsName(
|
|
1162
|
-
|
|
1163
|
-
tsResolver.resolveResponseName(
|
|
1164
|
-
...
|
|
1155
|
+
...pathParams.map((p) => tsResolver.resolvePathParamsName(node, p)),
|
|
1156
|
+
...queryParams.map((p) => tsResolver.resolveQueryParamsName(node, p)),
|
|
1157
|
+
...headerParams.map((p) => tsResolver.resolveHeaderParamsName(node, p)),
|
|
1158
|
+
node.requestBody?.schema ? tsResolver.resolveDataName(node) : void 0,
|
|
1159
|
+
tsResolver.resolveResponseName(node),
|
|
1160
|
+
...node.responses.map((res) => tsResolver.resolveResponseStatusName(node, res.statusCode))
|
|
1165
1161
|
].filter(Boolean);
|
|
1166
|
-
const importedZodNames = zodResolver && parser === "zod" ? [zodResolver.resolveResponseName?.(
|
|
1162
|
+
const importedZodNames = zodResolver && parser === "zod" ? [zodResolver.resolveResponseName?.(node), node.requestBody?.schema ? zodResolver.resolveDataName?.(node) : void 0].filter(Boolean) : [];
|
|
1167
1163
|
const meta = {
|
|
1168
|
-
name: resolver.resolveName(
|
|
1169
|
-
urlName: `get${resolver.resolveName(
|
|
1164
|
+
name: resolver.resolveName(node.operationId),
|
|
1165
|
+
urlName: `get${resolver.resolveName(node.operationId).charAt(0).toUpperCase()}${resolver.resolveName(node.operationId).slice(1)}Url`,
|
|
1170
1166
|
file: resolver.resolveFile({
|
|
1171
|
-
name:
|
|
1167
|
+
name: node.operationId,
|
|
1172
1168
|
extname: ".ts",
|
|
1173
|
-
tag:
|
|
1174
|
-
path:
|
|
1169
|
+
tag: node.tags[0] ?? "default",
|
|
1170
|
+
path: node.path
|
|
1175
1171
|
}, {
|
|
1176
1172
|
root,
|
|
1177
1173
|
output,
|
|
1178
1174
|
group
|
|
1179
1175
|
}),
|
|
1180
1176
|
fileTs: tsResolver.resolveFile({
|
|
1181
|
-
name:
|
|
1177
|
+
name: node.operationId,
|
|
1182
1178
|
extname: ".ts",
|
|
1183
|
-
tag:
|
|
1184
|
-
path:
|
|
1179
|
+
tag: node.tags[0] ?? "default",
|
|
1180
|
+
path: node.path
|
|
1185
1181
|
}, {
|
|
1186
1182
|
root,
|
|
1187
1183
|
output: pluginTs.options?.output ?? output,
|
|
1188
1184
|
group: pluginTs.options?.group
|
|
1189
1185
|
}),
|
|
1190
1186
|
fileZod: zodResolver && pluginZod?.options ? zodResolver.resolveFile({
|
|
1191
|
-
name:
|
|
1187
|
+
name: node.operationId,
|
|
1192
1188
|
extname: ".ts",
|
|
1193
|
-
tag:
|
|
1194
|
-
path:
|
|
1189
|
+
tag: node.tags[0] ?? "default",
|
|
1190
|
+
path: node.path
|
|
1195
1191
|
}, {
|
|
1196
1192
|
root,
|
|
1197
1193
|
output: pluginZod.options.output ?? output,
|
|
1198
1194
|
group: pluginZod.options.group
|
|
1199
1195
|
}) : void 0
|
|
1200
1196
|
};
|
|
1201
|
-
const isFormData =
|
|
1197
|
+
const isFormData = node.requestBody?.contentType === "multipart/form-data";
|
|
1202
1198
|
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
|
|
1203
1199
|
baseName: meta.file.baseName,
|
|
1204
1200
|
path: meta.file.path,
|
|
@@ -1226,7 +1222,7 @@ const clientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1226
1222
|
})] }) : /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1227
1223
|
name: ["fetch"],
|
|
1228
1224
|
root: meta.file.path,
|
|
1229
|
-
path: node_path.default.resolve(
|
|
1225
|
+
path: node_path.default.resolve(root, ".kubb/fetch.ts")
|
|
1230
1226
|
}), /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1231
1227
|
name: [
|
|
1232
1228
|
"Client",
|
|
@@ -1234,13 +1230,13 @@ const clientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1234
1230
|
"ResponseErrorConfig"
|
|
1235
1231
|
],
|
|
1236
1232
|
root: meta.file.path,
|
|
1237
|
-
path: node_path.default.resolve(
|
|
1233
|
+
path: node_path.default.resolve(root, ".kubb/fetch.ts"),
|
|
1238
1234
|
isTypeOnly: true
|
|
1239
1235
|
})] }),
|
|
1240
|
-
isFormData &&
|
|
1236
|
+
isFormData && node.requestBody?.schema && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1241
1237
|
name: ["buildFormData"],
|
|
1242
1238
|
root: meta.file.path,
|
|
1243
|
-
path: node_path.default.resolve(
|
|
1239
|
+
path: node_path.default.resolve(root, ".kubb/config.ts")
|
|
1244
1240
|
}),
|
|
1245
1241
|
meta.fileZod && importedZodNames.length > 0 && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1246
1242
|
name: importedZodNames,
|
|
@@ -1259,7 +1255,7 @@ const clientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1259
1255
|
pathParamsType,
|
|
1260
1256
|
paramsCasing,
|
|
1261
1257
|
paramsType,
|
|
1262
|
-
node
|
|
1258
|
+
node,
|
|
1263
1259
|
tsResolver,
|
|
1264
1260
|
isIndexable: urlType === "export",
|
|
1265
1261
|
isExportable: urlType === "export"
|
|
@@ -1272,7 +1268,7 @@ const clientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1272
1268
|
pathParamsType,
|
|
1273
1269
|
paramsCasing,
|
|
1274
1270
|
paramsType,
|
|
1275
|
-
node
|
|
1271
|
+
node,
|
|
1276
1272
|
tsResolver,
|
|
1277
1273
|
zodResolver,
|
|
1278
1274
|
parser
|
|
@@ -1285,16 +1281,14 @@ const clientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1285
1281
|
//#region src/generators/groupedClientGenerator.tsx
|
|
1286
1282
|
const groupedClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
1287
1283
|
name: "groupedClient",
|
|
1288
|
-
|
|
1289
|
-
|
|
1284
|
+
operations(nodes, options) {
|
|
1285
|
+
const { config, resolver, adapter, root } = this;
|
|
1290
1286
|
const { output, group } = options;
|
|
1291
|
-
|
|
1292
|
-
return nodes.reduce((acc, operationNode) => {
|
|
1287
|
+
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric_jsx_runtime.Fragment, { children: nodes.reduce((acc, operationNode) => {
|
|
1293
1288
|
if (group?.type === "tag") {
|
|
1294
1289
|
const tag = operationNode.tags[0];
|
|
1295
1290
|
const name = tag ? group?.name?.({ group: camelCase(tag) }) : void 0;
|
|
1296
1291
|
if (!tag || !name) return acc;
|
|
1297
|
-
const transformedNode = plugin.transformer ? (0, _kubb_ast.transform)(operationNode, plugin.transformer) : operationNode;
|
|
1298
1292
|
const file = resolver.resolveFile({
|
|
1299
1293
|
name,
|
|
1300
1294
|
extname: ".ts",
|
|
@@ -1305,17 +1299,17 @@ const groupedClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1305
1299
|
group
|
|
1306
1300
|
});
|
|
1307
1301
|
const clientFile = resolver.resolveFile({
|
|
1308
|
-
name:
|
|
1302
|
+
name: operationNode.operationId,
|
|
1309
1303
|
extname: ".ts",
|
|
1310
|
-
tag:
|
|
1311
|
-
path:
|
|
1304
|
+
tag: operationNode.tags[0] ?? "default",
|
|
1305
|
+
path: operationNode.path
|
|
1312
1306
|
}, {
|
|
1313
1307
|
root,
|
|
1314
1308
|
output,
|
|
1315
1309
|
group
|
|
1316
1310
|
});
|
|
1317
1311
|
const client = {
|
|
1318
|
-
name: resolver.resolveName(
|
|
1312
|
+
name: resolver.resolveName(operationNode.operationId),
|
|
1319
1313
|
file: clientFile
|
|
1320
1314
|
};
|
|
1321
1315
|
const previous = acc.find((item) => item.file.path === file.path);
|
|
@@ -1355,7 +1349,7 @@ const groupedClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1355
1349
|
})
|
|
1356
1350
|
})]
|
|
1357
1351
|
}, file.path);
|
|
1358
|
-
});
|
|
1352
|
+
}) });
|
|
1359
1353
|
}
|
|
1360
1354
|
});
|
|
1361
1355
|
//#endregion
|
|
@@ -1383,10 +1377,9 @@ function Operations({ name, nodes }) {
|
|
|
1383
1377
|
//#region src/generators/operationsGenerator.tsx
|
|
1384
1378
|
const operationsGenerator = (0, _kubb_core.defineGenerator)({
|
|
1385
1379
|
name: "client",
|
|
1386
|
-
|
|
1387
|
-
|
|
1380
|
+
operations(nodes, options) {
|
|
1381
|
+
const { config, resolver, adapter, root } = this;
|
|
1388
1382
|
const { output, group } = options;
|
|
1389
|
-
const root = node_path.default.resolve(config.root, config.output.path);
|
|
1390
1383
|
const name = "operations";
|
|
1391
1384
|
const file = resolver.resolveFile({
|
|
1392
1385
|
name,
|
|
@@ -1501,11 +1494,10 @@ function resolveZodImportNames(node, zodResolver) {
|
|
|
1501
1494
|
}
|
|
1502
1495
|
const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
1503
1496
|
name: "staticClassClient",
|
|
1504
|
-
|
|
1505
|
-
|
|
1497
|
+
operations(nodes, options) {
|
|
1498
|
+
const { adapter, config, driver, resolver, root } = this;
|
|
1506
1499
|
const { output, group, dataReturnType, paramsCasing, paramsType, pathParamsType, parser, importPath } = options;
|
|
1507
1500
|
const baseURL = options.baseURL ?? adapter.rootNode?.meta?.baseURL;
|
|
1508
|
-
const root = node_path.default.resolve(config.root, config.output.path);
|
|
1509
1501
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1510
1502
|
if (!pluginTs?.resolver) return null;
|
|
1511
1503
|
const tsResolver = pluginTs.resolver;
|
|
@@ -1513,30 +1505,29 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1513
1505
|
const pluginZod = parser === "zod" ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : void 0;
|
|
1514
1506
|
const zodResolver = pluginZod?.resolver;
|
|
1515
1507
|
function buildOperationData(node) {
|
|
1516
|
-
const transformedNode = plugin.transformer ? (0, _kubb_ast.transform)(node, plugin.transformer) : node;
|
|
1517
1508
|
const typeFile = tsResolver.resolveFile({
|
|
1518
|
-
name:
|
|
1509
|
+
name: node.operationId,
|
|
1519
1510
|
extname: ".ts",
|
|
1520
|
-
tag:
|
|
1521
|
-
path:
|
|
1511
|
+
tag: node.tags[0] ?? "default",
|
|
1512
|
+
path: node.path
|
|
1522
1513
|
}, {
|
|
1523
1514
|
root,
|
|
1524
1515
|
output: tsPluginOptions?.output ?? output,
|
|
1525
1516
|
group: tsPluginOptions?.group
|
|
1526
1517
|
});
|
|
1527
1518
|
const zodFile = zodResolver && pluginZod?.options ? zodResolver.resolveFile({
|
|
1528
|
-
name:
|
|
1519
|
+
name: node.operationId,
|
|
1529
1520
|
extname: ".ts",
|
|
1530
|
-
tag:
|
|
1531
|
-
path:
|
|
1521
|
+
tag: node.tags[0] ?? "default",
|
|
1522
|
+
path: node.path
|
|
1532
1523
|
}, {
|
|
1533
1524
|
root,
|
|
1534
1525
|
output: pluginZod.options.output ?? output,
|
|
1535
1526
|
group: pluginZod.options.group
|
|
1536
1527
|
}) : void 0;
|
|
1537
1528
|
return {
|
|
1538
|
-
node
|
|
1539
|
-
name: resolver.resolveName(
|
|
1529
|
+
node,
|
|
1530
|
+
name: resolver.resolveName(node.operationId),
|
|
1540
1531
|
tsResolver,
|
|
1541
1532
|
zodResolver,
|
|
1542
1533
|
typeFile,
|
|
@@ -1621,7 +1612,7 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1621
1612
|
zodFilesByPath
|
|
1622
1613
|
};
|
|
1623
1614
|
}
|
|
1624
|
-
return controllers.map(({ name, file, operations: ops }) => {
|
|
1615
|
+
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric_jsx_runtime.Fragment, { children: controllers.map(({ name, file, operations: ops }) => {
|
|
1625
1616
|
const { typeImportsByFile, typeFilesByPath } = collectTypeImports(ops);
|
|
1626
1617
|
const { zodImportsByFile, zodFilesByPath } = parser === "zod" ? collectZodImports(ops) : {
|
|
1627
1618
|
zodImportsByFile: /* @__PURE__ */ new Map(),
|
|
@@ -1663,12 +1654,12 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1663
1654
|
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1664
1655
|
name: ["fetch"],
|
|
1665
1656
|
root: file.path,
|
|
1666
|
-
path: node_path.default.resolve(
|
|
1657
|
+
path: node_path.default.resolve(root, ".kubb/fetch.ts")
|
|
1667
1658
|
}),
|
|
1668
1659
|
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1669
1660
|
name: ["mergeConfig"],
|
|
1670
1661
|
root: file.path,
|
|
1671
|
-
path: node_path.default.resolve(
|
|
1662
|
+
path: node_path.default.resolve(root, ".kubb/fetch.ts")
|
|
1672
1663
|
}),
|
|
1673
1664
|
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1674
1665
|
name: [
|
|
@@ -1677,14 +1668,14 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1677
1668
|
"ResponseErrorConfig"
|
|
1678
1669
|
],
|
|
1679
1670
|
root: file.path,
|
|
1680
|
-
path: node_path.default.resolve(
|
|
1671
|
+
path: node_path.default.resolve(root, ".kubb/fetch.ts"),
|
|
1681
1672
|
isTypeOnly: true
|
|
1682
1673
|
})
|
|
1683
1674
|
] }),
|
|
1684
1675
|
hasFormData && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
1685
1676
|
name: ["buildFormData"],
|
|
1686
1677
|
root: file.path,
|
|
1687
|
-
path: node_path.default.resolve(
|
|
1678
|
+
path: node_path.default.resolve(root, ".kubb/config.ts")
|
|
1688
1679
|
}),
|
|
1689
1680
|
Array.from(typeImportsByFile.entries()).map(([filePath, importSet]) => {
|
|
1690
1681
|
const typeFile = typeFilesByPath.get(filePath);
|
|
@@ -1721,10 +1712,13 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1721
1712
|
})
|
|
1722
1713
|
]
|
|
1723
1714
|
}, file.path);
|
|
1724
|
-
});
|
|
1715
|
+
}) });
|
|
1725
1716
|
}
|
|
1726
1717
|
});
|
|
1727
1718
|
//#endregion
|
|
1719
|
+
//#region package.json
|
|
1720
|
+
var version = "5.0.0-alpha.30";
|
|
1721
|
+
//#endregion
|
|
1728
1722
|
//#region src/resolvers/resolverClient.ts
|
|
1729
1723
|
/**
|
|
1730
1724
|
* Resolver for `@kubb/plugin-client` that provides the default naming
|
|
@@ -1821,7 +1815,7 @@ const pluginClient = (0, _kubb_core.createPlugin)((options) => {
|
|
|
1821
1815
|
const { output = {
|
|
1822
1816
|
path: "clients",
|
|
1823
1817
|
barrelType: "named"
|
|
1824
|
-
}, group,
|
|
1818
|
+
}, group, exclude = [], include, override = [], urlType = false, dataReturnType = "data", paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", operations = false, paramsCasing, clientType = "function", parser = "client", client = "axios", importPath, bundle = false, wrapper, baseURL, compatibilityPreset = "default", resolver: userResolver, transformer: userTransformer } = options;
|
|
1825
1819
|
const resolvedImportPath = importPath ?? (!bundle ? `@kubb/plugin-client/clients/${client}` : void 0);
|
|
1826
1820
|
const preset = (0, _kubb_core.getPreset)({
|
|
1827
1821
|
preset: compatibilityPreset,
|
|
@@ -1834,10 +1828,12 @@ const pluginClient = (0, _kubb_core.createPlugin)((options) => {
|
|
|
1834
1828
|
operations ? operationsGenerator : void 0
|
|
1835
1829
|
].filter((x) => Boolean(x))
|
|
1836
1830
|
});
|
|
1831
|
+
const mergedGenerator = (0, _kubb_core.mergeGenerators)(preset.generators ?? []);
|
|
1837
1832
|
let resolveNameWarning = false;
|
|
1838
1833
|
let resolvePathWarning = false;
|
|
1839
1834
|
return {
|
|
1840
1835
|
name: pluginClientName,
|
|
1836
|
+
version,
|
|
1841
1837
|
get resolver() {
|
|
1842
1838
|
return preset.resolver;
|
|
1843
1839
|
},
|
|
@@ -1850,6 +1846,9 @@ const pluginClient = (0, _kubb_core.createPlugin)((options) => {
|
|
|
1850
1846
|
clientType,
|
|
1851
1847
|
bundle,
|
|
1852
1848
|
output,
|
|
1849
|
+
exclude,
|
|
1850
|
+
include,
|
|
1851
|
+
override,
|
|
1853
1852
|
group: group ? {
|
|
1854
1853
|
...group,
|
|
1855
1854
|
name: group.name ? group.name : (ctx) => {
|
|
@@ -1872,7 +1871,7 @@ const pluginClient = (0, _kubb_core.createPlugin)((options) => {
|
|
|
1872
1871
|
pre: [_kubb_plugin_ts.pluginTsName, parser === "zod" ? _kubb_plugin_zod.pluginZodName : void 0].filter(Boolean),
|
|
1873
1872
|
resolvePath(baseName, pathMode, options) {
|
|
1874
1873
|
if (!resolvePathWarning) {
|
|
1875
|
-
this.
|
|
1874
|
+
this.warn("Do not use resolvePath for pluginClient, use resolverClient.resolvePath instead");
|
|
1876
1875
|
resolvePathWarning = true;
|
|
1877
1876
|
}
|
|
1878
1877
|
return this.plugin.resolver.resolvePath({
|
|
@@ -1881,23 +1880,27 @@ const pluginClient = (0, _kubb_core.createPlugin)((options) => {
|
|
|
1881
1880
|
tag: options?.group?.tag,
|
|
1882
1881
|
path: options?.group?.path
|
|
1883
1882
|
}, {
|
|
1884
|
-
root:
|
|
1883
|
+
root: this.root,
|
|
1885
1884
|
output,
|
|
1886
1885
|
group: this.plugin.options.group
|
|
1887
1886
|
});
|
|
1888
1887
|
},
|
|
1889
1888
|
resolveName(name, type) {
|
|
1890
1889
|
if (!resolveNameWarning) {
|
|
1891
|
-
this.
|
|
1890
|
+
this.warn("Do not use resolveName for pluginClient, use resolverClient.default instead");
|
|
1892
1891
|
resolveNameWarning = true;
|
|
1893
1892
|
}
|
|
1894
1893
|
return this.plugin.resolver.default(name, type);
|
|
1895
1894
|
},
|
|
1896
|
-
async
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1895
|
+
async operation(node, options) {
|
|
1896
|
+
return mergedGenerator.operation?.call(this, node, options);
|
|
1897
|
+
},
|
|
1898
|
+
async operations(nodes, options) {
|
|
1899
|
+
return mergedGenerator.operations?.call(this, nodes, options);
|
|
1900
|
+
},
|
|
1901
|
+
async buildStart() {
|
|
1902
|
+
const { plugin } = this;
|
|
1903
|
+
const root = this.root;
|
|
1901
1904
|
if (bundle && !plugin.options.importPath) await this.addFile({
|
|
1902
1905
|
baseName: "fetch.ts",
|
|
1903
1906
|
path: node_path.default.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -1922,39 +1925,6 @@ const pluginClient = (0, _kubb_core.createPlugin)((options) => {
|
|
|
1922
1925
|
imports: [],
|
|
1923
1926
|
exports: []
|
|
1924
1927
|
});
|
|
1925
|
-
const collectedOperations = [];
|
|
1926
|
-
const generatorContext = {
|
|
1927
|
-
generators: preset.generators,
|
|
1928
|
-
plugin,
|
|
1929
|
-
resolver,
|
|
1930
|
-
exclude,
|
|
1931
|
-
include,
|
|
1932
|
-
override,
|
|
1933
|
-
fabric,
|
|
1934
|
-
adapter,
|
|
1935
|
-
config,
|
|
1936
|
-
driver
|
|
1937
|
-
};
|
|
1938
|
-
await (0, _kubb_ast.walk)(rootNode, {
|
|
1939
|
-
depth: "shallow",
|
|
1940
|
-
async operation(operationNode) {
|
|
1941
|
-
if (resolver.resolveOptions(operationNode, {
|
|
1942
|
-
options: plugin.options,
|
|
1943
|
-
exclude,
|
|
1944
|
-
include,
|
|
1945
|
-
override
|
|
1946
|
-
}) !== null) collectedOperations.push(operationNode);
|
|
1947
|
-
await (0, _kubb_core.runGeneratorOperation)(operationNode, generatorContext);
|
|
1948
|
-
}
|
|
1949
|
-
});
|
|
1950
|
-
await (0, _kubb_core.runGeneratorOperations)(collectedOperations, generatorContext);
|
|
1951
|
-
const barrelFiles = await (0, _kubb_core.getBarrelFiles)(this.fabric.files, {
|
|
1952
|
-
type: output.barrelType ?? "named",
|
|
1953
|
-
root,
|
|
1954
|
-
output,
|
|
1955
|
-
meta: { pluginName: this.plugin.name }
|
|
1956
|
-
});
|
|
1957
|
-
await this.upsertFile(...barrelFiles);
|
|
1958
1928
|
}
|
|
1959
1929
|
};
|
|
1960
1930
|
});
|