@kubb/plugin-client 5.0.0-alpha.31 → 5.0.0-alpha.33
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 +132 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -9
- package/dist/index.js +31 -35
- package/dist/index.js.map +1 -1
- package/package.json +8 -10
- package/src/components/ClassClient.tsx +4 -4
- package/src/components/Client.tsx +7 -6
- package/src/components/ClientLegacy.tsx +7 -5
- package/src/components/Operations.tsx +3 -3
- package/src/components/StaticClassClient.tsx +4 -4
- package/src/components/Url.tsx +3 -3
- package/src/components/WrapperClient.tsx +3 -3
- package/src/generators/classClientGenerator.tsx +13 -14
- package/src/generators/clientGenerator.tsx +4 -4
- package/src/generators/groupedClientGenerator.tsx +5 -5
- package/src/generators/operationsGenerator.tsx +3 -3
- package/src/generators/staticClassClientGenerator.tsx +11 -12
- package/src/plugin.ts +29 -28
- package/src/utils.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,10 +6,10 @@ const require_templates_config_source = require("./templates/config.source.cjs")
|
|
|
6
6
|
let node_path = require("node:path");
|
|
7
7
|
node_path = require_chunk.__toESM(node_path);
|
|
8
8
|
let _kubb_ast = require("@kubb/ast");
|
|
9
|
-
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
10
|
-
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
11
|
-
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
12
9
|
let _kubb_core = require("@kubb/core");
|
|
10
|
+
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
11
|
+
let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
|
|
12
|
+
let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
13
13
|
let _kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
14
14
|
//#region ../../internals/utils/src/casing.ts
|
|
15
15
|
/**
|
|
@@ -287,7 +287,7 @@ function buildGenerics(node, tsResolver) {
|
|
|
287
287
|
function buildClassClientParams({ node, path, baseURL, tsResolver, isFormData, headers }) {
|
|
288
288
|
const queryParamsName = node.parameters.filter((p) => p.in === "query").length > 0 ? tsResolver.resolveQueryParamsName(node, node.parameters.filter((p) => p.in === "query")[0]) : void 0;
|
|
289
289
|
const requestName = node.requestBody?.schema ? tsResolver.resolveDataName(node) : void 0;
|
|
290
|
-
return
|
|
290
|
+
return _kubb_core.FunctionParams.factory({ config: {
|
|
291
291
|
mode: "object",
|
|
292
292
|
children: {
|
|
293
293
|
requestConfig: { mode: "inlineSpread" },
|
|
@@ -345,22 +345,22 @@ function Url({ name, isExportable = true, isIndexable = true, baseURL, paramsTyp
|
|
|
345
345
|
const originalPathParams = node.parameters.filter((p) => p.in === "path");
|
|
346
346
|
const casedPathParams = (0, _kubb_ast.caseParams)(originalPathParams, paramsCasing);
|
|
347
347
|
const pathParamsMapping = paramsCasing ? buildParamsMapping(originalPathParams, casedPathParams) : void 0;
|
|
348
|
-
return /* @__PURE__ */ (0,
|
|
348
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
349
349
|
name,
|
|
350
350
|
isExportable,
|
|
351
351
|
isIndexable,
|
|
352
|
-
children: /* @__PURE__ */ (0,
|
|
352
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.Function, {
|
|
353
353
|
name,
|
|
354
354
|
export: isExportable,
|
|
355
355
|
params: paramsSignature,
|
|
356
356
|
children: [
|
|
357
357
|
pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => isValidVarName(originalName) && originalName !== camelCaseName).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
|
|
358
|
-
pathParamsMapping && Object.keys(pathParamsMapping).length > 0 && /* @__PURE__ */ (0,
|
|
359
|
-
/* @__PURE__ */ (0,
|
|
358
|
+
pathParamsMapping && Object.keys(pathParamsMapping).length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
359
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Const, {
|
|
360
360
|
name: "res",
|
|
361
361
|
children: `{ method: '${node.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`
|
|
362
362
|
}),
|
|
363
|
-
/* @__PURE__ */ (0,
|
|
363
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
364
364
|
"return res"
|
|
365
365
|
]
|
|
366
366
|
})
|
|
@@ -379,7 +379,7 @@ function getParams$1({ paramsType, paramsCasing, pathParamsType, node, tsResolve
|
|
|
379
379
|
resolver: tsResolver,
|
|
380
380
|
extraParams: isConfigurable ? [(0, _kubb_ast.createFunctionParameter)({
|
|
381
381
|
name: "config",
|
|
382
|
-
type: (0, _kubb_ast.
|
|
382
|
+
type: (0, _kubb_ast.createParamsType)({
|
|
383
383
|
variant: "reference",
|
|
384
384
|
name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
|
|
385
385
|
}),
|
|
@@ -433,7 +433,7 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, bas
|
|
|
433
433
|
tsResolver
|
|
434
434
|
});
|
|
435
435
|
const urlParamsCall = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" }).print(urlParamsNode) ?? "";
|
|
436
|
-
const clientParams =
|
|
436
|
+
const clientParams = _kubb_core.FunctionParams.factory({ config: {
|
|
437
437
|
mode: "object",
|
|
438
438
|
children: {
|
|
439
439
|
method: { value: JSON.stringify(node.method.toUpperCase()) },
|
|
@@ -445,17 +445,17 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, bas
|
|
|
445
445
|
headers: headers.length ? { value: isConfigurable ? `{ ${headers.join(", ")}, ...requestConfig.headers }` : `{ ${headers.join(", ")} }` } : void 0
|
|
446
446
|
}
|
|
447
447
|
} });
|
|
448
|
-
const childrenElement = children ? children : /* @__PURE__ */ (0,
|
|
448
|
+
const childrenElement = children ? children : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
449
449
|
dataReturnType === "full" && parser === "zod" && zodResponseName && `return {...res, data: ${zodResponseName}.parse(res.data)}`,
|
|
450
450
|
dataReturnType === "data" && parser === "zod" && zodResponseName && `return ${zodResponseName}.parse(res.data)`,
|
|
451
451
|
dataReturnType === "full" && parser === "client" && "return res",
|
|
452
452
|
dataReturnType === "data" && parser === "client" && "return res.data"
|
|
453
453
|
] });
|
|
454
|
-
return /* @__PURE__ */ (0,
|
|
454
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
455
455
|
name,
|
|
456
456
|
isExportable,
|
|
457
457
|
isIndexable,
|
|
458
|
-
children: /* @__PURE__ */ (0,
|
|
458
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.Function, {
|
|
459
459
|
name,
|
|
460
460
|
async: true,
|
|
461
461
|
export: isExportable,
|
|
@@ -464,26 +464,26 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, bas
|
|
|
464
464
|
returnType,
|
|
465
465
|
children: [
|
|
466
466
|
isConfigurable ? "const { client: request = fetch, ...requestConfig } = config" : "",
|
|
467
|
-
/* @__PURE__ */ (0,
|
|
468
|
-
/* @__PURE__ */ (0,
|
|
467
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
468
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
469
469
|
pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => isValidVarName(originalName) && originalName !== camelCaseName).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
|
|
470
|
-
pathParamsMapping && /* @__PURE__ */ (0,
|
|
471
|
-
queryParamsMapping && queryParamsName && /* @__PURE__ */ (0,
|
|
470
|
+
pathParamsMapping && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})] }),
|
|
471
|
+
queryParamsMapping && queryParamsName && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
472
472
|
`const mappedParams = params ? { ${Object.entries(queryParamsMapping).map(([originalName, camelCaseName]) => `"${originalName}": params.${camelCaseName}`).join(", ")} } : undefined`,
|
|
473
|
-
/* @__PURE__ */ (0,
|
|
474
|
-
/* @__PURE__ */ (0,
|
|
473
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
474
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})
|
|
475
475
|
] }),
|
|
476
|
-
headerParamsMapping && headerParamsName && /* @__PURE__ */ (0,
|
|
476
|
+
headerParamsMapping && headerParamsName && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
477
477
|
`const mappedHeaders = headers ? { ${Object.entries(headerParamsMapping).map(([originalName, camelCaseName]) => `"${originalName}": headers.${camelCaseName}`).join(", ")} } : undefined`,
|
|
478
|
-
/* @__PURE__ */ (0,
|
|
479
|
-
/* @__PURE__ */ (0,
|
|
478
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
479
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})
|
|
480
480
|
] }),
|
|
481
481
|
parser === "zod" && zodRequestName ? `const requestData = ${zodRequestName}.parse(data)` : requestName && "const requestData = data",
|
|
482
|
-
/* @__PURE__ */ (0,
|
|
482
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
483
483
|
isFormData && requestName && "const formData = buildFormData(requestData)",
|
|
484
|
-
/* @__PURE__ */ (0,
|
|
484
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
485
485
|
isConfigurable ? `const res = await request<${generics.join(", ")}>(${clientParams.toCall()})` : `const res = await fetch<${generics.join(", ")}>(${clientParams.toCall()})`,
|
|
486
|
-
/* @__PURE__ */ (0,
|
|
486
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
487
487
|
childrenElement
|
|
488
488
|
]
|
|
489
489
|
})
|
|
@@ -580,7 +580,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isCo
|
|
|
580
580
|
} : void 0
|
|
581
581
|
};
|
|
582
582
|
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
583
|
-
return
|
|
583
|
+
return _kubb_core.FunctionParams.factory({
|
|
584
584
|
data: {
|
|
585
585
|
mode: "object",
|
|
586
586
|
children,
|
|
@@ -592,7 +592,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isCo
|
|
|
592
592
|
} : void 0
|
|
593
593
|
});
|
|
594
594
|
}
|
|
595
|
-
return
|
|
595
|
+
return _kubb_core.FunctionParams.factory({
|
|
596
596
|
pathParams: typeSchemas.pathParams?.name ? {
|
|
597
597
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
598
598
|
children: legacyGetPathParams(typeSchemas.pathParams, {
|
|
@@ -646,7 +646,7 @@ function ClientLegacy({ name, isExportable = true, isIndexable = true, returnTyp
|
|
|
646
646
|
pathParamsType,
|
|
647
647
|
typeSchemas
|
|
648
648
|
});
|
|
649
|
-
const clientParams =
|
|
649
|
+
const clientParams = _kubb_core.FunctionParams.factory({ config: {
|
|
650
650
|
mode: "object",
|
|
651
651
|
children: {
|
|
652
652
|
method: { value: JSON.stringify(operation.method.toUpperCase()) },
|
|
@@ -658,17 +658,17 @@ function ClientLegacy({ name, isExportable = true, isIndexable = true, returnTyp
|
|
|
658
658
|
headers: headers.length ? { value: isConfigurable ? `{ ${headers.join(", ")}, ...requestConfig.headers }` : `{ ${headers.join(", ")} }` } : void 0
|
|
659
659
|
}
|
|
660
660
|
} });
|
|
661
|
-
const childrenElement = children ? children : /* @__PURE__ */ (0,
|
|
661
|
+
const childrenElement = children ? children : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
662
662
|
dataReturnType === "full" && parser === "zod" && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`,
|
|
663
663
|
dataReturnType === "data" && parser === "zod" && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`,
|
|
664
664
|
dataReturnType === "full" && parser === "client" && "return res",
|
|
665
665
|
dataReturnType === "data" && parser === "client" && "return res.data"
|
|
666
666
|
] });
|
|
667
|
-
return /* @__PURE__ */ (0,
|
|
667
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
668
668
|
name,
|
|
669
669
|
isExportable,
|
|
670
670
|
isIndexable,
|
|
671
|
-
children: /* @__PURE__ */ (0,
|
|
671
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.Function, {
|
|
672
672
|
name,
|
|
673
673
|
async: true,
|
|
674
674
|
export: isExportable,
|
|
@@ -677,26 +677,26 @@ function ClientLegacy({ name, isExportable = true, isIndexable = true, returnTyp
|
|
|
677
677
|
returnType,
|
|
678
678
|
children: [
|
|
679
679
|
isConfigurable ? "const { client: request = fetch, ...requestConfig } = config" : "",
|
|
680
|
-
/* @__PURE__ */ (0,
|
|
681
|
-
/* @__PURE__ */ (0,
|
|
680
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
681
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
682
682
|
pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => originalName !== camelCaseName && isValidVarName(originalName)).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
|
|
683
|
-
pathParamsMapping && /* @__PURE__ */ (0,
|
|
684
|
-
queryParamsMapping && typeSchemas.queryParams?.name && /* @__PURE__ */ (0,
|
|
683
|
+
pathParamsMapping && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})] }),
|
|
684
|
+
queryParamsMapping && typeSchemas.queryParams?.name && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
685
685
|
`const mappedParams = params ? { ${Object.entries(queryParamsMapping).map(([originalName, camelCaseName]) => `"${originalName}": params.${camelCaseName}`).join(", ")} } : undefined`,
|
|
686
|
-
/* @__PURE__ */ (0,
|
|
687
|
-
/* @__PURE__ */ (0,
|
|
686
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
687
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})
|
|
688
688
|
] }),
|
|
689
|
-
headerParamsMapping && typeSchemas.headerParams?.name && /* @__PURE__ */ (0,
|
|
689
|
+
headerParamsMapping && typeSchemas.headerParams?.name && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
690
690
|
`const mappedHeaders = headers ? { ${Object.entries(headerParamsMapping).map(([originalName, camelCaseName]) => `"${originalName}": headers.${camelCaseName}`).join(", ")} } : undefined`,
|
|
691
|
-
/* @__PURE__ */ (0,
|
|
692
|
-
/* @__PURE__ */ (0,
|
|
691
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
692
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})
|
|
693
693
|
] }),
|
|
694
694
|
parser === "zod" && zodSchemas?.request?.name ? `const requestData = ${zodSchemas.request.name}.parse(data)` : typeSchemas?.request?.name && "const requestData = data",
|
|
695
|
-
/* @__PURE__ */ (0,
|
|
695
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
696
696
|
isFormData && typeSchemas?.request?.name && "const formData = buildFormData(requestData)",
|
|
697
|
-
/* @__PURE__ */ (0,
|
|
697
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
698
698
|
isConfigurable ? `const res = await request<${generics.join(", ")}>(${clientParams.toCall()})` : `const res = await fetch<${generics.join(", ")}>(${clientParams.toCall()})`,
|
|
699
|
-
/* @__PURE__ */ (0,
|
|
699
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
700
700
|
childrenElement
|
|
701
701
|
]
|
|
702
702
|
})
|
|
@@ -709,12 +709,12 @@ function getUrlParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
|
|
|
709
709
|
typed: true,
|
|
710
710
|
casing: paramsCasing
|
|
711
711
|
});
|
|
712
|
-
return
|
|
712
|
+
return _kubb_core.FunctionParams.factory({ data: {
|
|
713
713
|
mode: "object",
|
|
714
714
|
children: { ...pathParams }
|
|
715
715
|
} });
|
|
716
716
|
}
|
|
717
|
-
return
|
|
717
|
+
return _kubb_core.FunctionParams.factory({ pathParams: typeSchemas.pathParams?.name ? {
|
|
718
718
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
719
719
|
children: legacyGetPathParams(typeSchemas.pathParams, {
|
|
720
720
|
typed: true,
|
|
@@ -732,22 +732,22 @@ function UrlLegacy({ name, isExportable = true, isIndexable = true, typeSchemas,
|
|
|
732
732
|
typeSchemas
|
|
733
733
|
});
|
|
734
734
|
const pathParamsMapping = paramsCasing ? legacyGetParamsMapping(typeSchemas.pathParams, { casing: paramsCasing }) : void 0;
|
|
735
|
-
return /* @__PURE__ */ (0,
|
|
735
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
736
736
|
name,
|
|
737
737
|
isExportable,
|
|
738
738
|
isIndexable,
|
|
739
|
-
children: /* @__PURE__ */ (0,
|
|
739
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.Function, {
|
|
740
740
|
name,
|
|
741
741
|
export: isExportable,
|
|
742
742
|
params: params.toConstructor(),
|
|
743
743
|
children: [
|
|
744
744
|
pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => originalName !== camelCaseName && isValidVarName(originalName)).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
|
|
745
|
-
pathParamsMapping && /* @__PURE__ */ (0,
|
|
746
|
-
/* @__PURE__ */ (0,
|
|
745
|
+
pathParamsMapping && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
746
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Const, {
|
|
747
747
|
name: "res",
|
|
748
748
|
children: `{ method: '${operation.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`
|
|
749
749
|
}),
|
|
750
|
-
/* @__PURE__ */ (0,
|
|
750
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
751
751
|
"return res"
|
|
752
752
|
]
|
|
753
753
|
})
|
|
@@ -824,7 +824,7 @@ ${operations.map(({ node, name: methodName, tsResolver, zodResolver }) => genera
|
|
|
824
824
|
pathParamsType
|
|
825
825
|
})).join("\n\n")}
|
|
826
826
|
}`;
|
|
827
|
-
return /* @__PURE__ */ (0,
|
|
827
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File.Source, {
|
|
828
828
|
name,
|
|
829
829
|
isExportable,
|
|
830
830
|
isIndexable,
|
|
@@ -842,7 +842,7 @@ ${classNames.map((className) => ` readonly ${camelCase(className)}: ${className
|
|
|
842
842
|
${classNames.map((className) => ` this.${camelCase(className)} = new ${className}(config)`).join("\n")}
|
|
843
843
|
}
|
|
844
844
|
}`;
|
|
845
|
-
return /* @__PURE__ */ (0,
|
|
845
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
846
846
|
name,
|
|
847
847
|
isExportable,
|
|
848
848
|
isIndexable,
|
|
@@ -871,7 +871,7 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
871
871
|
operations(nodes, options) {
|
|
872
872
|
const { adapter, config, driver, resolver, root } = this;
|
|
873
873
|
const { output, group, dataReturnType, paramsCasing, paramsType, pathParamsType, parser, importPath, wrapper } = options;
|
|
874
|
-
const baseURL = options.baseURL ?? adapter.
|
|
874
|
+
const baseURL = options.baseURL ?? adapter.inputNode?.meta?.baseURL;
|
|
875
875
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
876
876
|
if (!pluginTs?.resolver) return null;
|
|
877
877
|
const tsResolver = pluginTs.resolver;
|
|
@@ -993,29 +993,29 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
993
993
|
zodFilesByPath: /* @__PURE__ */ new Map()
|
|
994
994
|
};
|
|
995
995
|
const hasFormData = ops.some((op) => op.node.requestBody?.contentType === "multipart/form-data");
|
|
996
|
-
return /* @__PURE__ */ (0,
|
|
996
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
997
997
|
baseName: file.baseName,
|
|
998
998
|
path: file.path,
|
|
999
999
|
meta: file.meta,
|
|
1000
|
-
banner: resolver.resolveBanner(adapter.
|
|
1000
|
+
banner: resolver.resolveBanner(adapter.inputNode, {
|
|
1001
1001
|
output,
|
|
1002
1002
|
config
|
|
1003
1003
|
}),
|
|
1004
|
-
footer: resolver.resolveFooter(adapter.
|
|
1004
|
+
footer: resolver.resolveFooter(adapter.inputNode, {
|
|
1005
1005
|
output,
|
|
1006
1006
|
config
|
|
1007
1007
|
}),
|
|
1008
1008
|
children: [
|
|
1009
|
-
importPath ? /* @__PURE__ */ (0,
|
|
1010
|
-
/* @__PURE__ */ (0,
|
|
1009
|
+
importPath ? /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1010
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1011
1011
|
name: "fetch",
|
|
1012
1012
|
path: importPath
|
|
1013
1013
|
}),
|
|
1014
|
-
/* @__PURE__ */ (0,
|
|
1014
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1015
1015
|
name: ["mergeConfig"],
|
|
1016
1016
|
path: importPath
|
|
1017
1017
|
}),
|
|
1018
|
-
/* @__PURE__ */ (0,
|
|
1018
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1019
1019
|
name: [
|
|
1020
1020
|
"Client",
|
|
1021
1021
|
"RequestConfig",
|
|
@@ -1024,18 +1024,18 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1024
1024
|
path: importPath,
|
|
1025
1025
|
isTypeOnly: true
|
|
1026
1026
|
})
|
|
1027
|
-
] }) : /* @__PURE__ */ (0,
|
|
1028
|
-
/* @__PURE__ */ (0,
|
|
1027
|
+
] }) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1028
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1029
1029
|
name: ["fetch"],
|
|
1030
1030
|
root: file.path,
|
|
1031
1031
|
path: node_path.default.resolve(root, ".kubb/fetch.ts")
|
|
1032
1032
|
}),
|
|
1033
|
-
/* @__PURE__ */ (0,
|
|
1033
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1034
1034
|
name: ["mergeConfig"],
|
|
1035
1035
|
root: file.path,
|
|
1036
1036
|
path: node_path.default.resolve(root, ".kubb/fetch.ts")
|
|
1037
1037
|
}),
|
|
1038
|
-
/* @__PURE__ */ (0,
|
|
1038
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1039
1039
|
name: [
|
|
1040
1040
|
"Client",
|
|
1041
1041
|
"RequestConfig",
|
|
@@ -1046,7 +1046,7 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1046
1046
|
isTypeOnly: true
|
|
1047
1047
|
})
|
|
1048
1048
|
] }),
|
|
1049
|
-
hasFormData && /* @__PURE__ */ (0,
|
|
1049
|
+
hasFormData && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1050
1050
|
name: ["buildFormData"],
|
|
1051
1051
|
root: file.path,
|
|
1052
1052
|
path: node_path.default.resolve(root, ".kubb/config.ts")
|
|
@@ -1056,7 +1056,7 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1056
1056
|
if (!typeFile) return null;
|
|
1057
1057
|
const importNames = Array.from(importSet).filter(Boolean);
|
|
1058
1058
|
if (importNames.length === 0) return null;
|
|
1059
|
-
return /* @__PURE__ */ (0,
|
|
1059
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1060
1060
|
name: importNames,
|
|
1061
1061
|
root: file.path,
|
|
1062
1062
|
path: typeFile.path,
|
|
@@ -1068,13 +1068,13 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1068
1068
|
if (!zodFile) return null;
|
|
1069
1069
|
const importNames = Array.from(importSet).filter(Boolean);
|
|
1070
1070
|
if (importNames.length === 0) return null;
|
|
1071
|
-
return /* @__PURE__ */ (0,
|
|
1071
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1072
1072
|
name: importNames,
|
|
1073
1073
|
root: file.path,
|
|
1074
1074
|
path: zodFile.path
|
|
1075
1075
|
}, filePath);
|
|
1076
1076
|
}),
|
|
1077
|
-
/* @__PURE__ */ (0,
|
|
1077
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(ClassClient, {
|
|
1078
1078
|
name,
|
|
1079
1079
|
operations: ops,
|
|
1080
1080
|
baseURL,
|
|
@@ -1096,42 +1096,42 @@ const classClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1096
1096
|
output,
|
|
1097
1097
|
group
|
|
1098
1098
|
});
|
|
1099
|
-
files.push(/* @__PURE__ */ (0,
|
|
1099
|
+
files.push(/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
1100
1100
|
baseName: wrapperFile.baseName,
|
|
1101
1101
|
path: wrapperFile.path,
|
|
1102
1102
|
meta: wrapperFile.meta,
|
|
1103
|
-
banner: resolver.resolveBanner(adapter.
|
|
1103
|
+
banner: resolver.resolveBanner(adapter.inputNode, {
|
|
1104
1104
|
output,
|
|
1105
1105
|
config
|
|
1106
1106
|
}),
|
|
1107
|
-
footer: resolver.resolveFooter(adapter.
|
|
1107
|
+
footer: resolver.resolveFooter(adapter.inputNode, {
|
|
1108
1108
|
output,
|
|
1109
1109
|
config
|
|
1110
1110
|
}),
|
|
1111
1111
|
children: [
|
|
1112
|
-
importPath ? /* @__PURE__ */ (0,
|
|
1112
|
+
importPath ? /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1113
1113
|
name: ["Client", "RequestConfig"],
|
|
1114
1114
|
path: importPath,
|
|
1115
1115
|
isTypeOnly: true
|
|
1116
|
-
}) : /* @__PURE__ */ (0,
|
|
1116
|
+
}) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1117
1117
|
name: ["Client", "RequestConfig"],
|
|
1118
1118
|
root: wrapperFile.path,
|
|
1119
1119
|
path: node_path.default.resolve(root, ".kubb/fetch.ts"),
|
|
1120
1120
|
isTypeOnly: true
|
|
1121
1121
|
}),
|
|
1122
|
-
controllers.map(({ name, file }) => /* @__PURE__ */ (0,
|
|
1122
|
+
controllers.map(({ name, file }) => /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1123
1123
|
name: [name],
|
|
1124
1124
|
root: wrapperFile.path,
|
|
1125
1125
|
path: file.path
|
|
1126
1126
|
}, name)),
|
|
1127
|
-
/* @__PURE__ */ (0,
|
|
1127
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(WrapperClient, {
|
|
1128
1128
|
name: wrapper.className,
|
|
1129
1129
|
classNames: controllers.map(({ name }) => name)
|
|
1130
1130
|
})
|
|
1131
1131
|
]
|
|
1132
1132
|
}, wrapperFile.path));
|
|
1133
1133
|
}
|
|
1134
|
-
return /* @__PURE__ */ (0,
|
|
1134
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: files });
|
|
1135
1135
|
}
|
|
1136
1136
|
});
|
|
1137
1137
|
//#endregion
|
|
@@ -1141,7 +1141,7 @@ const clientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1141
1141
|
operation(node, options) {
|
|
1142
1142
|
const { adapter, config, driver, resolver, root } = this;
|
|
1143
1143
|
const { output, urlType, dataReturnType, paramsCasing, paramsType, pathParamsType, parser, importPath, group } = options;
|
|
1144
|
-
const baseURL = options.baseURL ?? adapter.
|
|
1144
|
+
const baseURL = options.baseURL ?? adapter.inputNode?.meta?.baseURL;
|
|
1145
1145
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1146
1146
|
if (!pluginTs?.resolver) return null;
|
|
1147
1147
|
const tsResolver = pluginTs.resolver;
|
|
@@ -1195,23 +1195,23 @@ const clientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1195
1195
|
}) : void 0
|
|
1196
1196
|
};
|
|
1197
1197
|
const isFormData = node.requestBody?.contentType === "multipart/form-data";
|
|
1198
|
-
return /* @__PURE__ */ (0,
|
|
1198
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
1199
1199
|
baseName: meta.file.baseName,
|
|
1200
1200
|
path: meta.file.path,
|
|
1201
1201
|
meta: meta.file.meta,
|
|
1202
|
-
banner: resolver.resolveBanner(adapter.
|
|
1202
|
+
banner: resolver.resolveBanner(adapter.inputNode, {
|
|
1203
1203
|
output,
|
|
1204
1204
|
config
|
|
1205
1205
|
}),
|
|
1206
|
-
footer: resolver.resolveFooter(adapter.
|
|
1206
|
+
footer: resolver.resolveFooter(adapter.inputNode, {
|
|
1207
1207
|
output,
|
|
1208
1208
|
config
|
|
1209
1209
|
}),
|
|
1210
1210
|
children: [
|
|
1211
|
-
importPath ? /* @__PURE__ */ (0,
|
|
1211
|
+
importPath ? /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1212
1212
|
name: "fetch",
|
|
1213
1213
|
path: importPath
|
|
1214
|
-
}), /* @__PURE__ */ (0,
|
|
1214
|
+
}), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1215
1215
|
name: [
|
|
1216
1216
|
"Client",
|
|
1217
1217
|
"RequestConfig",
|
|
@@ -1219,11 +1219,11 @@ const clientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1219
1219
|
],
|
|
1220
1220
|
path: importPath,
|
|
1221
1221
|
isTypeOnly: true
|
|
1222
|
-
})] }) : /* @__PURE__ */ (0,
|
|
1222
|
+
})] }) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1223
1223
|
name: ["fetch"],
|
|
1224
1224
|
root: meta.file.path,
|
|
1225
1225
|
path: node_path.default.resolve(root, ".kubb/fetch.ts")
|
|
1226
|
-
}), /* @__PURE__ */ (0,
|
|
1226
|
+
}), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1227
1227
|
name: [
|
|
1228
1228
|
"Client",
|
|
1229
1229
|
"RequestConfig",
|
|
@@ -1233,23 +1233,23 @@ const clientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1233
1233
|
path: node_path.default.resolve(root, ".kubb/fetch.ts"),
|
|
1234
1234
|
isTypeOnly: true
|
|
1235
1235
|
})] }),
|
|
1236
|
-
isFormData && node.requestBody?.schema && /* @__PURE__ */ (0,
|
|
1236
|
+
isFormData && node.requestBody?.schema && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1237
1237
|
name: ["buildFormData"],
|
|
1238
1238
|
root: meta.file.path,
|
|
1239
1239
|
path: node_path.default.resolve(root, ".kubb/config.ts")
|
|
1240
1240
|
}),
|
|
1241
|
-
meta.fileZod && importedZodNames.length > 0 && /* @__PURE__ */ (0,
|
|
1241
|
+
meta.fileZod && importedZodNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1242
1242
|
name: importedZodNames,
|
|
1243
1243
|
root: meta.file.path,
|
|
1244
1244
|
path: meta.fileZod.path
|
|
1245
1245
|
}),
|
|
1246
|
-
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0,
|
|
1246
|
+
meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1247
1247
|
name: Array.from(new Set(importedTypeNames)),
|
|
1248
1248
|
root: meta.file.path,
|
|
1249
1249
|
path: meta.fileTs.path,
|
|
1250
1250
|
isTypeOnly: true
|
|
1251
1251
|
}),
|
|
1252
|
-
/* @__PURE__ */ (0,
|
|
1252
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(Url, {
|
|
1253
1253
|
name: meta.urlName,
|
|
1254
1254
|
baseURL,
|
|
1255
1255
|
pathParamsType,
|
|
@@ -1260,7 +1260,7 @@ const clientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1260
1260
|
isIndexable: urlType === "export",
|
|
1261
1261
|
isExportable: urlType === "export"
|
|
1262
1262
|
}),
|
|
1263
|
-
/* @__PURE__ */ (0,
|
|
1263
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(Client, {
|
|
1264
1264
|
name: meta.name,
|
|
1265
1265
|
urlName: meta.urlName,
|
|
1266
1266
|
baseURL,
|
|
@@ -1284,7 +1284,7 @@ const groupedClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1284
1284
|
operations(nodes, options) {
|
|
1285
1285
|
const { config, resolver, adapter, root } = this;
|
|
1286
1286
|
const { output, group } = options;
|
|
1287
|
-
return /* @__PURE__ */ (0,
|
|
1287
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: nodes.reduce((acc, operationNode) => {
|
|
1288
1288
|
if (group?.type === "tag") {
|
|
1289
1289
|
const tag = operationNode.tags[0];
|
|
1290
1290
|
const name = tag ? group?.name?.({ group: camelCase(tag) }) : void 0;
|
|
@@ -1322,27 +1322,27 @@ const groupedClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1322
1322
|
}
|
|
1323
1323
|
return acc;
|
|
1324
1324
|
}, []).map(({ name, file, clients }) => {
|
|
1325
|
-
return /* @__PURE__ */ (0,
|
|
1325
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
1326
1326
|
baseName: file.baseName,
|
|
1327
1327
|
path: file.path,
|
|
1328
1328
|
meta: file.meta,
|
|
1329
|
-
banner: resolver.resolveBanner(adapter.
|
|
1329
|
+
banner: resolver.resolveBanner(adapter.inputNode, {
|
|
1330
1330
|
output,
|
|
1331
1331
|
config
|
|
1332
1332
|
}),
|
|
1333
|
-
footer: resolver.resolveFooter(adapter.
|
|
1333
|
+
footer: resolver.resolveFooter(adapter.inputNode, {
|
|
1334
1334
|
output,
|
|
1335
1335
|
config
|
|
1336
1336
|
}),
|
|
1337
|
-
children: [clients.map((client) => /* @__PURE__ */ (0,
|
|
1337
|
+
children: [clients.map((client) => /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1338
1338
|
name: [client.name],
|
|
1339
1339
|
root: file.path,
|
|
1340
1340
|
path: client.file.path
|
|
1341
|
-
}, client.name)), /* @__PURE__ */ (0,
|
|
1341
|
+
}, client.name)), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
1342
1342
|
name,
|
|
1343
1343
|
isExportable: true,
|
|
1344
1344
|
isIndexable: true,
|
|
1345
|
-
children: /* @__PURE__ */ (0,
|
|
1345
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
|
|
1346
1346
|
export: true,
|
|
1347
1347
|
name,
|
|
1348
1348
|
children: `return { ${clients.map((client) => client.name).join(", ")} }`
|
|
@@ -1362,11 +1362,11 @@ function Operations({ name, nodes }) {
|
|
|
1362
1362
|
method: node.method.toLowerCase()
|
|
1363
1363
|
};
|
|
1364
1364
|
});
|
|
1365
|
-
return /* @__PURE__ */ (0,
|
|
1365
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
1366
1366
|
name,
|
|
1367
1367
|
isExportable: true,
|
|
1368
1368
|
isIndexable: true,
|
|
1369
|
-
children: /* @__PURE__ */ (0,
|
|
1369
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Const, {
|
|
1370
1370
|
name,
|
|
1371
1371
|
export: true,
|
|
1372
1372
|
children: JSON.stringify(operationsObject, void 0, 2)
|
|
@@ -1389,19 +1389,19 @@ const operationsGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1389
1389
|
output,
|
|
1390
1390
|
group
|
|
1391
1391
|
});
|
|
1392
|
-
return /* @__PURE__ */ (0,
|
|
1392
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File, {
|
|
1393
1393
|
baseName: file.baseName,
|
|
1394
1394
|
path: file.path,
|
|
1395
1395
|
meta: file.meta,
|
|
1396
|
-
banner: resolver.resolveBanner(adapter.
|
|
1396
|
+
banner: resolver.resolveBanner(adapter.inputNode, {
|
|
1397
1397
|
output,
|
|
1398
1398
|
config
|
|
1399
1399
|
}),
|
|
1400
|
-
footer: resolver.resolveFooter(adapter.
|
|
1400
|
+
footer: resolver.resolveFooter(adapter.inputNode, {
|
|
1401
1401
|
output,
|
|
1402
1402
|
config
|
|
1403
1403
|
}),
|
|
1404
|
-
children: /* @__PURE__ */ (0,
|
|
1404
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(Operations, {
|
|
1405
1405
|
name,
|
|
1406
1406
|
nodes
|
|
1407
1407
|
})
|
|
@@ -1469,7 +1469,7 @@ function StaticClassClient({ name, isExportable = true, isIndexable = true, oper
|
|
|
1469
1469
|
paramsCasing,
|
|
1470
1470
|
pathParamsType
|
|
1471
1471
|
})).join("\n\n")}\n}`;
|
|
1472
|
-
return /* @__PURE__ */ (0,
|
|
1472
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File.Source, {
|
|
1473
1473
|
name,
|
|
1474
1474
|
isExportable,
|
|
1475
1475
|
isIndexable,
|
|
@@ -1497,7 +1497,7 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1497
1497
|
operations(nodes, options) {
|
|
1498
1498
|
const { adapter, config, driver, resolver, root } = this;
|
|
1499
1499
|
const { output, group, dataReturnType, paramsCasing, paramsType, pathParamsType, parser, importPath } = options;
|
|
1500
|
-
const baseURL = options.baseURL ?? adapter.
|
|
1500
|
+
const baseURL = options.baseURL ?? adapter.inputNode?.meta?.baseURL;
|
|
1501
1501
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
1502
1502
|
if (!pluginTs?.resolver) return null;
|
|
1503
1503
|
const tsResolver = pluginTs.resolver;
|
|
@@ -1612,36 +1612,36 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1612
1612
|
zodFilesByPath
|
|
1613
1613
|
};
|
|
1614
1614
|
}
|
|
1615
|
-
return /* @__PURE__ */ (0,
|
|
1615
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: controllers.map(({ name, file, operations: ops }) => {
|
|
1616
1616
|
const { typeImportsByFile, typeFilesByPath } = collectTypeImports(ops);
|
|
1617
1617
|
const { zodImportsByFile, zodFilesByPath } = parser === "zod" ? collectZodImports(ops) : {
|
|
1618
1618
|
zodImportsByFile: /* @__PURE__ */ new Map(),
|
|
1619
1619
|
zodFilesByPath: /* @__PURE__ */ new Map()
|
|
1620
1620
|
};
|
|
1621
1621
|
const hasFormData = ops.some((op) => op.node.requestBody?.contentType === "multipart/form-data");
|
|
1622
|
-
return /* @__PURE__ */ (0,
|
|
1622
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
1623
1623
|
baseName: file.baseName,
|
|
1624
1624
|
path: file.path,
|
|
1625
1625
|
meta: file.meta,
|
|
1626
|
-
banner: resolver.resolveBanner(adapter.
|
|
1626
|
+
banner: resolver.resolveBanner(adapter.inputNode, {
|
|
1627
1627
|
output,
|
|
1628
1628
|
config
|
|
1629
1629
|
}),
|
|
1630
|
-
footer: resolver.resolveFooter(adapter.
|
|
1630
|
+
footer: resolver.resolveFooter(adapter.inputNode, {
|
|
1631
1631
|
output,
|
|
1632
1632
|
config
|
|
1633
1633
|
}),
|
|
1634
1634
|
children: [
|
|
1635
|
-
importPath ? /* @__PURE__ */ (0,
|
|
1636
|
-
/* @__PURE__ */ (0,
|
|
1635
|
+
importPath ? /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1636
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1637
1637
|
name: "fetch",
|
|
1638
1638
|
path: importPath
|
|
1639
1639
|
}),
|
|
1640
|
-
/* @__PURE__ */ (0,
|
|
1640
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1641
1641
|
name: ["mergeConfig"],
|
|
1642
1642
|
path: importPath
|
|
1643
1643
|
}),
|
|
1644
|
-
/* @__PURE__ */ (0,
|
|
1644
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1645
1645
|
name: [
|
|
1646
1646
|
"Client",
|
|
1647
1647
|
"RequestConfig",
|
|
@@ -1650,18 +1650,18 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1650
1650
|
path: importPath,
|
|
1651
1651
|
isTypeOnly: true
|
|
1652
1652
|
})
|
|
1653
|
-
] }) : /* @__PURE__ */ (0,
|
|
1654
|
-
/* @__PURE__ */ (0,
|
|
1653
|
+
] }) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
1654
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1655
1655
|
name: ["fetch"],
|
|
1656
1656
|
root: file.path,
|
|
1657
1657
|
path: node_path.default.resolve(root, ".kubb/fetch.ts")
|
|
1658
1658
|
}),
|
|
1659
|
-
/* @__PURE__ */ (0,
|
|
1659
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1660
1660
|
name: ["mergeConfig"],
|
|
1661
1661
|
root: file.path,
|
|
1662
1662
|
path: node_path.default.resolve(root, ".kubb/fetch.ts")
|
|
1663
1663
|
}),
|
|
1664
|
-
/* @__PURE__ */ (0,
|
|
1664
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1665
1665
|
name: [
|
|
1666
1666
|
"Client",
|
|
1667
1667
|
"RequestConfig",
|
|
@@ -1672,7 +1672,7 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1672
1672
|
isTypeOnly: true
|
|
1673
1673
|
})
|
|
1674
1674
|
] }),
|
|
1675
|
-
hasFormData && /* @__PURE__ */ (0,
|
|
1675
|
+
hasFormData && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1676
1676
|
name: ["buildFormData"],
|
|
1677
1677
|
root: file.path,
|
|
1678
1678
|
path: node_path.default.resolve(root, ".kubb/config.ts")
|
|
@@ -1682,7 +1682,7 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1682
1682
|
if (!typeFile) return null;
|
|
1683
1683
|
const importNames = Array.from(importSet).filter(Boolean);
|
|
1684
1684
|
if (importNames.length === 0) return null;
|
|
1685
|
-
return /* @__PURE__ */ (0,
|
|
1685
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1686
1686
|
name: importNames,
|
|
1687
1687
|
root: file.path,
|
|
1688
1688
|
path: typeFile.path,
|
|
@@ -1694,13 +1694,13 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1694
1694
|
if (!zodFile) return null;
|
|
1695
1695
|
const importNames = Array.from(importSet).filter(Boolean);
|
|
1696
1696
|
if (importNames.length === 0) return null;
|
|
1697
|
-
return /* @__PURE__ */ (0,
|
|
1697
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
1698
1698
|
name: importNames,
|
|
1699
1699
|
root: file.path,
|
|
1700
1700
|
path: zodFile.path
|
|
1701
1701
|
}, filePath);
|
|
1702
1702
|
}),
|
|
1703
|
-
/* @__PURE__ */ (0,
|
|
1703
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(StaticClassClient, {
|
|
1704
1704
|
name,
|
|
1705
1705
|
operations: ops,
|
|
1706
1706
|
baseURL,
|
|
@@ -1717,7 +1717,7 @@ const staticClassClientGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1717
1717
|
});
|
|
1718
1718
|
//#endregion
|
|
1719
1719
|
//#region package.json
|
|
1720
|
-
var version = "5.0.0-alpha.
|
|
1720
|
+
var version = "5.0.0-alpha.33";
|
|
1721
1721
|
//#endregion
|
|
1722
1722
|
//#region src/resolvers/resolverClient.ts
|
|
1723
1723
|
/**
|
|
@@ -1901,30 +1901,26 @@ const pluginClient = (0, _kubb_core.createPlugin)((options) => {
|
|
|
1901
1901
|
async buildStart() {
|
|
1902
1902
|
const { plugin } = this;
|
|
1903
1903
|
const root = this.root;
|
|
1904
|
-
if (bundle && !plugin.options.importPath) await this.addFile({
|
|
1904
|
+
if (bundle && !plugin.options.importPath) await this.addFile((0, _kubb_ast.createFile)({
|
|
1905
1905
|
baseName: "fetch.ts",
|
|
1906
1906
|
path: node_path.default.resolve(root, ".kubb/fetch.ts"),
|
|
1907
|
-
sources: [{
|
|
1907
|
+
sources: [(0, _kubb_ast.createSource)({
|
|
1908
1908
|
name: "fetch",
|
|
1909
|
-
|
|
1909
|
+
nodes: [(0, _kubb_ast.createText)(plugin.options.client === "fetch" ? require_templates_clients_fetch_source.source : require_templates_clients_axios_source.source)],
|
|
1910
1910
|
isExportable: true,
|
|
1911
1911
|
isIndexable: true
|
|
1912
|
-
}]
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
});
|
|
1916
|
-
await this.addFile({
|
|
1912
|
+
})]
|
|
1913
|
+
}));
|
|
1914
|
+
await this.addFile((0, _kubb_ast.createFile)({
|
|
1917
1915
|
baseName: "config.ts",
|
|
1918
1916
|
path: node_path.default.resolve(root, ".kubb/config.ts"),
|
|
1919
|
-
sources: [{
|
|
1917
|
+
sources: [(0, _kubb_ast.createSource)({
|
|
1920
1918
|
name: "config",
|
|
1921
|
-
|
|
1919
|
+
nodes: [(0, _kubb_ast.createText)(require_templates_config_source.source)],
|
|
1922
1920
|
isExportable: false,
|
|
1923
1921
|
isIndexable: false
|
|
1924
|
-
}]
|
|
1925
|
-
|
|
1926
|
-
exports: []
|
|
1927
|
-
});
|
|
1922
|
+
})]
|
|
1923
|
+
}));
|
|
1928
1924
|
}
|
|
1929
1925
|
};
|
|
1930
1926
|
});
|