@kubb/plugin-fetch 5.11.0-canary.20261029T093900 → 5.11.0
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 +67 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/package.json +8 -9
- package/src/plugin.ts +1 -1
- package/src/types.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23,13 +23,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
value: mod,
|
|
24
24
|
enumerable: true
|
|
25
25
|
}) : target, mod));
|
|
26
|
-
let
|
|
26
|
+
let _kubb_kit = require("@kubb/kit");
|
|
27
27
|
let node_path = require("node:path");
|
|
28
28
|
node_path = __toESM(node_path, 1);
|
|
29
29
|
let _kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
30
|
-
let
|
|
30
|
+
let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
|
|
31
31
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
32
|
-
let
|
|
32
|
+
let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
33
33
|
let node_url = require("node:url");
|
|
34
34
|
// ../../internals/shared/src/operation.ts
|
|
35
35
|
/**
|
|
@@ -52,19 +52,19 @@ function operationFileEntry(node, name, extname = ".ts") {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* Resolves a dependency plugin's generated file for `node.operationId`, cached in `
|
|
56
|
-
*
|
|
55
|
+
* Resolves a dependency plugin's generated file for `node.operationId`, cached in `memo` (the
|
|
56
|
+
* build's `ctx.memo`) under the resolver's own plugin name and the operation. Several dependents reading the
|
|
57
57
|
* same dependency for the same operation in one pass (a query plugin's several hook generators, the
|
|
58
58
|
* MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.
|
|
59
59
|
*
|
|
60
60
|
* @example Cache `plugin-ts`'s file for the current operation
|
|
61
61
|
* ```ts
|
|
62
|
-
* const fileTs = resolveDependencyOperationFile({
|
|
62
|
+
* const fileTs = resolveDependencyOperationFile({ memo: ctx.memo, node, resolver: tsResolver, root, output })
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
65
|
function resolveDependencyOperationFile(options) {
|
|
66
|
-
const {
|
|
67
|
-
return
|
|
66
|
+
const { memo, node, resolver, root, output, group } = options;
|
|
67
|
+
return memo(`${resolver.pluginName}:operationFile:${node.operationId}`, () => resolver.file({
|
|
68
68
|
...operationFileEntry(node, node.operationId),
|
|
69
69
|
root,
|
|
70
70
|
output,
|
|
@@ -74,7 +74,7 @@ function resolveDependencyOperationFile(options) {
|
|
|
74
74
|
function getOperationLink(node, link) {
|
|
75
75
|
if (!link) return null;
|
|
76
76
|
if (typeof link === "function") return link(node) ?? null;
|
|
77
|
-
return node.path ? `{@link ${
|
|
77
|
+
return node.path ? `{@link ${_kubb_kit.Url.toPath(node.path)}}` : null;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several
|
|
@@ -396,7 +396,7 @@ function buildJSDoc(comments, options = {}) {
|
|
|
396
396
|
* The shared top-level `name` of the operation plugins, computed once per operation name and build.
|
|
397
397
|
*/
|
|
398
398
|
function resolveOperationName(name) {
|
|
399
|
-
return this.memo(`operation:${name}`, () => ensureValidVarName((0,
|
|
399
|
+
return this.memo(`operation:${name}`, () => ensureValidVarName((0, _kubb_kit.camelCase)(name)));
|
|
400
400
|
}
|
|
401
401
|
/**
|
|
402
402
|
* Builds the allocation key for a declaration an operation owns. `scope` names which declaration
|
|
@@ -439,7 +439,7 @@ function createGroupConfig(group) {
|
|
|
439
439
|
if (!group) return null;
|
|
440
440
|
const defaultName = (ctx) => {
|
|
441
441
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
442
|
-
return (0,
|
|
442
|
+
return (0, _kubb_kit.camelCase)(ctx.group);
|
|
443
443
|
};
|
|
444
444
|
return {
|
|
445
445
|
...group,
|
|
@@ -679,7 +679,7 @@ function serializeBodyEncoding(node) {
|
|
|
679
679
|
* ```
|
|
680
680
|
*/
|
|
681
681
|
function buildStyles({ node }) {
|
|
682
|
-
if (!
|
|
682
|
+
if (!_kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
683
683
|
const groups = {
|
|
684
684
|
path: [],
|
|
685
685
|
query: [],
|
|
@@ -848,7 +848,7 @@ function buildGroupedOptionsSignature({ node, types, returnType, throwOnErrorDef
|
|
|
848
848
|
* the source.
|
|
849
849
|
*/
|
|
850
850
|
function Operation({ name, node, types, validatorHooks, returnType, throwOnErrorDefault, security }) {
|
|
851
|
-
if (!
|
|
851
|
+
if (!_kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
852
852
|
const signature = buildGroupedOptionsSignature({
|
|
853
853
|
node,
|
|
854
854
|
types,
|
|
@@ -874,11 +874,11 @@ function Operation({ name, node, types, validatorHooks, returnType, throwOnError
|
|
|
874
874
|
returnType,
|
|
875
875
|
throwOnErrorDefault
|
|
876
876
|
});
|
|
877
|
-
return /* @__PURE__ */ (0,
|
|
877
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
878
878
|
name,
|
|
879
879
|
isExportable: true,
|
|
880
880
|
isIndexable: true,
|
|
881
|
-
children: /* @__PURE__ */ (0,
|
|
881
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.Function, {
|
|
882
882
|
name,
|
|
883
883
|
export: true,
|
|
884
884
|
generics: signature.generics,
|
|
@@ -891,7 +891,7 @@ function Operation({ name, node, types, validatorHooks, returnType, throwOnError
|
|
|
891
891
|
}) },
|
|
892
892
|
children: [
|
|
893
893
|
mergeContentType ? "const { client: request = client, contentType, ...config } = options" : "const { client: request = client, ...config } = options",
|
|
894
|
-
/* @__PURE__ */ (0,
|
|
894
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
895
895
|
returnStatement
|
|
896
896
|
]
|
|
897
897
|
})
|
|
@@ -949,8 +949,8 @@ function resolveOperationTypes(driver, pluginName) {
|
|
|
949
949
|
group: pluginTs.options?.group ?? void 0
|
|
950
950
|
};
|
|
951
951
|
}
|
|
952
|
-
if (!pluginZod?.options?.inferred) throw new
|
|
953
|
-
code:
|
|
952
|
+
if (!pluginZod?.options?.inferred) throw new _kubb_kit.Diagnostics.Error({
|
|
953
|
+
code: _kubb_kit.Diagnostics.code.missingDependency,
|
|
954
954
|
severity: "error",
|
|
955
955
|
message: `Plugin "${pluginName}" has no source for operation types.`,
|
|
956
956
|
help: `Add \`pluginTs()\` before "${pluginName}", or add \`pluginZod({ inferred: true })\`.`,
|
|
@@ -976,11 +976,11 @@ function resolveOperationTypes(driver, pluginName) {
|
|
|
976
976
|
* identical.
|
|
977
977
|
*/
|
|
978
978
|
function createClientGenerator(name) {
|
|
979
|
-
return (0,
|
|
979
|
+
return (0, _kubb_kit.defineGenerator)({
|
|
980
980
|
name,
|
|
981
|
-
renderer:
|
|
981
|
+
renderer: _kubb_renderer_jsx.jsxRenderer,
|
|
982
982
|
operation(node, ctx) {
|
|
983
|
-
if (!
|
|
983
|
+
if (!_kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
984
984
|
const { config, driver, resolver, root } = ctx;
|
|
985
985
|
const { output, validator, returnType, throwOnErrorDefault, group, importPath } = ctx.options;
|
|
986
986
|
const types = resolveOperationTypes(driver, ctx.plugin.name);
|
|
@@ -1006,7 +1006,7 @@ function createClientGenerator(name) {
|
|
|
1006
1006
|
group: group ?? void 0
|
|
1007
1007
|
}),
|
|
1008
1008
|
fileTypes: resolveDependencyOperationFile({
|
|
1009
|
-
|
|
1009
|
+
memo: ctx.memo,
|
|
1010
1010
|
node,
|
|
1011
1011
|
resolver: types.resolver,
|
|
1012
1012
|
root,
|
|
@@ -1049,7 +1049,7 @@ function createClientGenerator(name) {
|
|
|
1049
1049
|
"RequestResult"
|
|
1050
1050
|
];
|
|
1051
1051
|
})();
|
|
1052
|
-
return /* @__PURE__ */ (0,
|
|
1052
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
1053
1053
|
baseName: meta.file.baseName,
|
|
1054
1054
|
path: meta.file.path,
|
|
1055
1055
|
meta: meta.file.meta,
|
|
@@ -1070,34 +1070,34 @@ function createClientGenerator(name) {
|
|
|
1070
1070
|
}
|
|
1071
1071
|
}),
|
|
1072
1072
|
children: [
|
|
1073
|
-
/* @__PURE__ */ (0,
|
|
1073
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1074
1074
|
name: clientValueImports,
|
|
1075
1075
|
root: clientRoot,
|
|
1076
1076
|
path: clientPath
|
|
1077
1077
|
}),
|
|
1078
|
-
/* @__PURE__ */ (0,
|
|
1078
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1079
1079
|
name: clientTypeImports,
|
|
1080
1080
|
root: clientRoot,
|
|
1081
1081
|
path: clientPath,
|
|
1082
1082
|
isTypeOnly: true
|
|
1083
1083
|
}),
|
|
1084
|
-
meta.fileTypes && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
1084
|
+
meta.fileTypes && importedTypeNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1085
1085
|
name: Array.from(new Set(importedTypeNames)),
|
|
1086
1086
|
root: meta.file.path,
|
|
1087
1087
|
path: meta.fileTypes.path,
|
|
1088
1088
|
isTypeOnly: true
|
|
1089
1089
|
}),
|
|
1090
|
-
meta.fileZod && importedZodNames.length > 0 && /* @__PURE__ */ (0,
|
|
1090
|
+
meta.fileZod && importedZodNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1091
1091
|
name: importedZodNames,
|
|
1092
1092
|
root: meta.file.path,
|
|
1093
1093
|
path: meta.fileZod.path
|
|
1094
1094
|
}),
|
|
1095
|
-
validatorHooks.headers && /* @__PURE__ */ (0,
|
|
1095
|
+
validatorHooks.headers && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1096
1096
|
name: ["toHeadersStandardSchema"],
|
|
1097
1097
|
root: clientRoot,
|
|
1098
1098
|
path: standardSchemaPath
|
|
1099
1099
|
}),
|
|
1100
|
-
/* @__PURE__ */ (0,
|
|
1100
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(Operation, {
|
|
1101
1101
|
name: meta.name,
|
|
1102
1102
|
node,
|
|
1103
1103
|
types,
|
|
@@ -1116,7 +1116,7 @@ function createClientGenerator(name) {
|
|
|
1116
1116
|
* Builds one instance method of a generated SDK class; a per-call `options.client` overrides `this.client`.
|
|
1117
1117
|
*/
|
|
1118
1118
|
function buildSdkMethod({ node, name, types, validatorHooks, security, returnType, throwOnErrorDefault }) {
|
|
1119
|
-
if (!
|
|
1119
|
+
if (!_kubb_kit.ast.isHttpOperationNode(node)) return "";
|
|
1120
1120
|
const signature = buildGroupedOptionsSignature({
|
|
1121
1121
|
node,
|
|
1122
1122
|
types,
|
|
@@ -1178,7 +1178,7 @@ function SdkClient({ name, operations, returnType, throwOnErrorDefault }) {
|
|
|
1178
1178
|
" this.client = createClient(config)",
|
|
1179
1179
|
" }"
|
|
1180
1180
|
].join("\n")}\n\n${methods.join("\n\n")}\n}`;
|
|
1181
|
-
return /* @__PURE__ */ (0,
|
|
1181
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
1182
1182
|
name,
|
|
1183
1183
|
isExportable: true,
|
|
1184
1184
|
isIndexable: true,
|
|
@@ -1201,7 +1201,7 @@ function SdkFacade({ name, members }) {
|
|
|
1201
1201
|
...assignments,
|
|
1202
1202
|
" }"
|
|
1203
1203
|
].join("\n")}\n}`;
|
|
1204
|
-
return /* @__PURE__ */ (0,
|
|
1204
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
1205
1205
|
name,
|
|
1206
1206
|
isExportable: true,
|
|
1207
1207
|
isIndexable: true,
|
|
@@ -1235,7 +1235,7 @@ function buildControllers(nodes, ctx, types, validatorEnabled) {
|
|
|
1235
1235
|
output: pluginZod.options?.output ?? output,
|
|
1236
1236
|
group: pluginZod.options?.group ?? void 0
|
|
1237
1237
|
}) : null;
|
|
1238
|
-
const security =
|
|
1238
|
+
const security = _kubb_kit.ast.isHttpOperationNode(node) ? getOperationSecurity({
|
|
1239
1239
|
document,
|
|
1240
1240
|
method: node.method,
|
|
1241
1241
|
path: node.path
|
|
@@ -1260,9 +1260,9 @@ function buildControllers(nodes, ctx, types, validatorEnabled) {
|
|
|
1260
1260
|
};
|
|
1261
1261
|
}
|
|
1262
1262
|
return nodes.reduce((acc, operationNode) => {
|
|
1263
|
-
if (!
|
|
1263
|
+
if (!_kubb_kit.ast.isHttpOperationNode(operationNode)) return acc;
|
|
1264
1264
|
const tag = operationNode.tags[0];
|
|
1265
|
-
const name = tag ? ensureValidVarName(group?.name?.({ group: (0,
|
|
1265
|
+
const name = tag ? ensureValidVarName(group?.name?.({ group: (0, _kubb_kit.camelCase)(tag) }) ?? resolver.groupName(tag)) : resolver.className("ApiClient");
|
|
1266
1266
|
const file = resolver.file({
|
|
1267
1267
|
name,
|
|
1268
1268
|
extname: ".ts",
|
|
@@ -1311,15 +1311,15 @@ function collectImportsByFile(ops, pick) {
|
|
|
1311
1311
|
* direct method.
|
|
1312
1312
|
*/
|
|
1313
1313
|
function createSdkGenerator() {
|
|
1314
|
-
return (0,
|
|
1314
|
+
return (0, _kubb_kit.defineGenerator)({
|
|
1315
1315
|
name: "sdk",
|
|
1316
|
-
renderer:
|
|
1316
|
+
renderer: _kubb_renderer_jsx.jsxRenderer,
|
|
1317
1317
|
operations(nodes, ctx) {
|
|
1318
1318
|
const { config, resolver, root } = ctx;
|
|
1319
1319
|
const { output, group, validator, returnType, throwOnErrorDefault, sdk } = ctx.options;
|
|
1320
1320
|
if (!sdk) return null;
|
|
1321
|
-
if (sdk.mode === "tag" && output.mode === "file") throw new
|
|
1322
|
-
code:
|
|
1321
|
+
if (sdk.mode === "tag" && output.mode === "file") throw new _kubb_kit.Diagnostics.Error({
|
|
1322
|
+
code: _kubb_kit.Diagnostics.code.invalidPluginOptions,
|
|
1323
1323
|
severity: "error",
|
|
1324
1324
|
message: `Plugin "${ctx.plugin.name}" resolves \`output.mode\` to 'file' but also configures \`sdk.mode: 'tag'\`.`,
|
|
1325
1325
|
help: "A single-file output has nothing to split tag classes into. Set `sdk.mode: 'flat'` to emit one class into that file, or give `output.path` an extensionless directory name (or set `output.mode: 'directory'` explicitly) so each tag gets its own file.",
|
|
@@ -1361,14 +1361,14 @@ function createSdkGenerator() {
|
|
|
1361
1361
|
};
|
|
1362
1362
|
const hasEventStream = ops.some((op) => isEventStream(op.node));
|
|
1363
1363
|
const hasResult = ops.some((op) => !isEventStream(op.node));
|
|
1364
|
-
return /* @__PURE__ */ (0,
|
|
1364
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
1365
1365
|
baseName: file.baseName,
|
|
1366
1366
|
path: file.path,
|
|
1367
1367
|
meta: file.meta,
|
|
1368
1368
|
banner: banner(file),
|
|
1369
1369
|
footer: footer(file),
|
|
1370
1370
|
children: [
|
|
1371
|
-
/* @__PURE__ */ (0,
|
|
1371
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1372
1372
|
name: [
|
|
1373
1373
|
"createClient",
|
|
1374
1374
|
...hasResult ? [returnType === "data" ? "unwrapResult" : "withUnwrap"] : [],
|
|
@@ -1377,7 +1377,7 @@ function createSdkGenerator() {
|
|
|
1377
1377
|
root: file.path,
|
|
1378
1378
|
path: clientPath
|
|
1379
1379
|
}),
|
|
1380
|
-
/* @__PURE__ */ (0,
|
|
1380
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1381
1381
|
name: [
|
|
1382
1382
|
"ClientConfig",
|
|
1383
1383
|
"ClientInstance",
|
|
@@ -1389,28 +1389,28 @@ function createSdkGenerator() {
|
|
|
1389
1389
|
path: clientPath,
|
|
1390
1390
|
isTypeOnly: true
|
|
1391
1391
|
}),
|
|
1392
|
-
validator === "zod" && ops.some((op) => op.node.requestBody?.content?.[0]?.schema != null) && /* @__PURE__ */ (0,
|
|
1392
|
+
validator === "zod" && ops.some((op) => op.node.requestBody?.content?.[0]?.schema != null) && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1393
1393
|
name: ["z"],
|
|
1394
1394
|
path: "zod",
|
|
1395
1395
|
isTypeOnly: true
|
|
1396
1396
|
}),
|
|
1397
|
-
Array.from(typeNamesByPath.entries()).map(([filePath, set]) => /* @__PURE__ */ (0,
|
|
1397
|
+
Array.from(typeNamesByPath.entries()).map(([filePath, set]) => /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1398
1398
|
name: Array.from(set),
|
|
1399
1399
|
root: file.path,
|
|
1400
1400
|
path: typeFilesByPath.get(filePath).path,
|
|
1401
1401
|
isTypeOnly: true
|
|
1402
1402
|
}, filePath)),
|
|
1403
|
-
validatorEnabled && Array.from(zodNamesByPath.entries()).map(([filePath, set]) => /* @__PURE__ */ (0,
|
|
1403
|
+
validatorEnabled && Array.from(zodNamesByPath.entries()).map(([filePath, set]) => /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1404
1404
|
name: Array.from(set),
|
|
1405
1405
|
root: file.path,
|
|
1406
1406
|
path: zodFilesByPath.get(filePath).path
|
|
1407
1407
|
}, filePath)),
|
|
1408
|
-
ops.some((op) => op.validatorHooks?.headers) && /* @__PURE__ */ (0,
|
|
1408
|
+
ops.some((op) => op.validatorHooks?.headers) && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1409
1409
|
name: ["toHeadersStandardSchema"],
|
|
1410
1410
|
root: file.path,
|
|
1411
1411
|
path: standardSchemaPath
|
|
1412
1412
|
}),
|
|
1413
|
-
/* @__PURE__ */ (0,
|
|
1413
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(SdkClient, {
|
|
1414
1414
|
name: className,
|
|
1415
1415
|
operations: ops,
|
|
1416
1416
|
returnType,
|
|
@@ -1427,7 +1427,7 @@ function createSdkGenerator() {
|
|
|
1427
1427
|
group: group ?? void 0
|
|
1428
1428
|
}), controllers.flatMap((controller) => controller.operations));
|
|
1429
1429
|
const classFiles = controllers.map(({ name, file, operations: ops }) => renderClassFile(name, file, ops));
|
|
1430
|
-
if (!sdk.name) return /* @__PURE__ */ (0,
|
|
1430
|
+
if (!sdk.name) return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: classFiles });
|
|
1431
1431
|
const sdkFile = resolver.file({
|
|
1432
1432
|
name: sdk.name,
|
|
1433
1433
|
extname: ".ts",
|
|
@@ -1440,25 +1440,25 @@ function createSdkGenerator() {
|
|
|
1440
1440
|
className: name,
|
|
1441
1441
|
propName: resolver.propertyName(tag ?? name)
|
|
1442
1442
|
}));
|
|
1443
|
-
return /* @__PURE__ */ (0,
|
|
1443
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [classFiles, /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
1444
1444
|
baseName: sdkFile.baseName,
|
|
1445
1445
|
path: sdkFile.path,
|
|
1446
1446
|
meta: sdkFile.meta,
|
|
1447
1447
|
banner: banner(sdkFile),
|
|
1448
1448
|
footer: footer(sdkFile),
|
|
1449
1449
|
children: [
|
|
1450
|
-
/* @__PURE__ */ (0,
|
|
1450
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1451
1451
|
name: ["ClientConfig"],
|
|
1452
1452
|
root: sdkFile.path,
|
|
1453
1453
|
path: clientPath,
|
|
1454
1454
|
isTypeOnly: true
|
|
1455
1455
|
}),
|
|
1456
|
-
controllers.map(({ name, file }) => /* @__PURE__ */ (0,
|
|
1456
|
+
controllers.map(({ name, file }) => /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1457
1457
|
name: [name],
|
|
1458
1458
|
root: sdkFile.path,
|
|
1459
1459
|
path: file.path
|
|
1460
1460
|
}, name)),
|
|
1461
|
-
/* @__PURE__ */ (0,
|
|
1461
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(SdkFacade, {
|
|
1462
1462
|
name: facadeName,
|
|
1463
1463
|
members
|
|
1464
1464
|
})
|
|
@@ -1473,7 +1473,7 @@ function createSdkGenerator() {
|
|
|
1473
1473
|
* drops union members a broader scalar already covers, keeping the generated response and error
|
|
1474
1474
|
* unions tidy. A plugin wires them with `ctx.setMacros([...defaultMacros, ...userMacros])`.
|
|
1475
1475
|
*/
|
|
1476
|
-
const defaultMacros = [
|
|
1476
|
+
const defaultMacros = [_kubb_kit.macroSimplifyUnion];
|
|
1477
1477
|
// ../../internals/client/src/resolver.ts
|
|
1478
1478
|
/**
|
|
1479
1479
|
* Default resolver shared by the client plugins. Functions use safe camelCase identifiers and
|
|
@@ -1485,17 +1485,17 @@ const defaultMacros = [kubb_kit.macroSimplifyUnion];
|
|
|
1485
1485
|
* resolverClient.groupName('pet') // 'PetClient'
|
|
1486
1486
|
* ```
|
|
1487
1487
|
*/
|
|
1488
|
-
const resolverClient = (0,
|
|
1488
|
+
const resolverClient = (0, _kubb_kit.createResolver)({
|
|
1489
1489
|
pluginName: "plugin-contract-client",
|
|
1490
1490
|
name: resolveOperationName,
|
|
1491
1491
|
className(name) {
|
|
1492
|
-
return ensureValidVarName((0,
|
|
1492
|
+
return ensureValidVarName((0, _kubb_kit.pascalCase)(name));
|
|
1493
1493
|
},
|
|
1494
1494
|
groupName(name) {
|
|
1495
|
-
return ensureValidVarName((0,
|
|
1495
|
+
return ensureValidVarName((0, _kubb_kit.pascalCase)(`${name} Client`));
|
|
1496
1496
|
},
|
|
1497
1497
|
propertyName(name) {
|
|
1498
|
-
return ensureValidVarName((0,
|
|
1498
|
+
return ensureValidVarName((0, _kubb_kit.camelCase)(name));
|
|
1499
1499
|
}
|
|
1500
1500
|
});
|
|
1501
1501
|
// src/generators/clientGenerator.tsx
|
|
@@ -1511,7 +1511,7 @@ var compatibility = {
|
|
|
1511
1511
|
"node": ">=22.22"
|
|
1512
1512
|
};
|
|
1513
1513
|
// package.json
|
|
1514
|
-
var version = "5.11.0
|
|
1514
|
+
var version = "5.11.0";
|
|
1515
1515
|
// src/templates.ts
|
|
1516
1516
|
/** Absolute path to the fetch client template, copied into `.kubb/client.ts`. */
|
|
1517
1517
|
const fetchClientTemplatePath = (0, node_url.fileURLToPath)(new URL("../templates/fetch.ts", require("url").pathToFileURL(__filename).href));
|
|
@@ -1550,7 +1550,7 @@ const pluginFetchName = "plugin-fetch";
|
|
|
1550
1550
|
* })
|
|
1551
1551
|
* ```
|
|
1552
1552
|
*/
|
|
1553
|
-
const pluginFetch = (0,
|
|
1553
|
+
const pluginFetch = (0, _kubb_kit.defineExtension)({
|
|
1554
1554
|
kind: "plugin",
|
|
1555
1555
|
meta: {
|
|
1556
1556
|
name: pluginFetchName,
|
|
@@ -1562,7 +1562,7 @@ const pluginFetch = (0, kubb_kit.defineExtension)({
|
|
|
1562
1562
|
[_kubb_plugin_zod.pluginZodName]: { optional: !isValidatorEnabled(options.validator) }
|
|
1563
1563
|
}),
|
|
1564
1564
|
setup(options) {
|
|
1565
|
-
const config = (0,
|
|
1565
|
+
const config = (0, _kubb_kit.useConfig)();
|
|
1566
1566
|
const { output = {
|
|
1567
1567
|
path: "clients",
|
|
1568
1568
|
barrel: { type: "named" }
|
|
@@ -1581,25 +1581,25 @@ const pluginFetch = (0, kubb_kit.defineExtension)({
|
|
|
1581
1581
|
mode: sdk.mode ?? "tag",
|
|
1582
1582
|
name: sdk.name
|
|
1583
1583
|
} : void 0,
|
|
1584
|
-
resolver: userResolver ?
|
|
1584
|
+
resolver: userResolver ? _kubb_kit.Resolver.merge(resolverClient, userResolver) : resolverClient
|
|
1585
1585
|
};
|
|
1586
|
-
(0,
|
|
1587
|
-
(0,
|
|
1588
|
-
(0,
|
|
1586
|
+
(0, _kubb_kit.setResolver)(resolved.resolver);
|
|
1587
|
+
(0, _kubb_kit.setMacros)([...defaultMacros, ...options.macros ?? []]);
|
|
1588
|
+
(0, _kubb_kit.addGenerator)(resolved.sdk ? createSdkGenerator() : clientGenerator);
|
|
1589
1589
|
const root = node_path.default.resolve(config.root, config.output.path);
|
|
1590
1590
|
const baseURLExpression = baseURL ? baseURL.includes("${") ? `\`${baseURL.replaceAll("`", "\\`")}\`` : JSON.stringify(baseURL) : void 0;
|
|
1591
|
-
(0,
|
|
1591
|
+
(0, _kubb_kit.injectFile)({
|
|
1592
1592
|
baseName: "serializers.ts",
|
|
1593
1593
|
path: node_path.default.resolve(root, ".kubb/serializers.ts"),
|
|
1594
1594
|
copy: fetchSerializersTemplatePath
|
|
1595
1595
|
});
|
|
1596
|
-
(0,
|
|
1596
|
+
(0, _kubb_kit.injectFile)({
|
|
1597
1597
|
baseName: "client.ts",
|
|
1598
1598
|
path: node_path.default.resolve(root, ".kubb/client.ts"),
|
|
1599
1599
|
copy: fetchClientTemplatePath,
|
|
1600
1600
|
footer: baseURLExpression ? `client.setConfig({ baseURL: ${baseURLExpression} })` : void 0
|
|
1601
1601
|
});
|
|
1602
|
-
(0,
|
|
1602
|
+
(0, _kubb_kit.injectFile)({
|
|
1603
1603
|
baseName: "standardSchema.ts",
|
|
1604
1604
|
path: node_path.default.resolve(root, ".kubb/standardSchema.ts"),
|
|
1605
1605
|
copy: standardSchemaTemplatePath
|