@kubb/plugin-fetch 5.10.0-canary.20261025T201031 → 5.10.1
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 +89 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -8
- package/dist/index.d.ts +0 -8
- package/dist/index.js +85 -114
- package/dist/index.js.map +1 -1
- package/dist/templates/fetch.d.ts +1 -3
- package/dist/templates/serializers.d.ts +1 -3
- package/dist/templates/standardSchema.d.ts +1 -3
- package/kubb-extension.json +1 -1
- package/package.json +7 -7
- package/templates/fetch.ts +1 -1
- package/templates/serializers.ts +5 -3
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
|
|
5
|
+
// \0rolldown/runtime.js
|
|
6
6
|
var __create = Object.create;
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
8
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -23,7 +23,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
value: mod,
|
|
24
24
|
enumerable: true
|
|
25
25
|
}) : target, mod));
|
|
26
|
-
//#endregion
|
|
27
26
|
let kubb_kit = require("kubb/kit");
|
|
28
27
|
let node_path = require("node:path");
|
|
29
28
|
node_path = __toESM(node_path, 1);
|
|
@@ -32,7 +31,7 @@ let kubb_jsx = require("kubb/jsx");
|
|
|
32
31
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
33
32
|
let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
|
|
34
33
|
let node_url = require("node:url");
|
|
35
|
-
|
|
34
|
+
// ../../internals/shared/src/operation.ts
|
|
36
35
|
/**
|
|
37
36
|
* Builds the `ResolverFileParams` every operation generator passes to
|
|
38
37
|
* `resolver.file`: a file named `name`, tagged by the operation's first
|
|
@@ -210,6 +209,16 @@ function getOperationParameters(node) {
|
|
|
210
209
|
operationParameterGroupsByNode.set(node, groups);
|
|
211
210
|
return groups;
|
|
212
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Builds the combined `{ body, path, query, headers }` options object schema for an operation,
|
|
214
|
+
* referencing the already-resolved body and grouped param names. Shared by `@kubb/plugin-ts`'s
|
|
215
|
+
* `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same
|
|
216
|
+
* shape from the same inputs. `primitive: 'object'` is a no-op for the TS printer and tells the Zod
|
|
217
|
+
* printer to emit `z.object(…)` rather than a record.
|
|
218
|
+
*/
|
|
219
|
+
function hasRequestContentTypeChoice(node) {
|
|
220
|
+
return (node.requestBody?.content ?? []).filter((entry) => entry.schema).length > 1;
|
|
221
|
+
}
|
|
213
222
|
function getStatusCodeNumber(statusCode) {
|
|
214
223
|
const code = Number(statusCode);
|
|
215
224
|
return Number.isNaN(code) ? null : code;
|
|
@@ -227,58 +236,7 @@ function getOperationSuccessResponses(node) {
|
|
|
227
236
|
function getPrimarySuccessResponse(node) {
|
|
228
237
|
return getOperationSuccessResponses(node)[0] ?? null;
|
|
229
238
|
}
|
|
230
|
-
|
|
231
|
-
//#region ../../internals/utils/src/casing.ts
|
|
232
|
-
/**
|
|
233
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
234
|
-
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
235
|
-
* and capitalizes each word according to `pascal`.
|
|
236
|
-
*
|
|
237
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
238
|
-
*/
|
|
239
|
-
function convert(text, pascal) {
|
|
240
|
-
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
241
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
242
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
243
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
244
|
-
}
|
|
245
|
-
const cache = /* @__PURE__ */ new Map();
|
|
246
|
-
const cacheLimit = 1e4;
|
|
247
|
-
function toCamelOrPascal(text, pascal) {
|
|
248
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
249
|
-
const cached = cache.get(key);
|
|
250
|
-
if (cached !== void 0) return cached;
|
|
251
|
-
const result = convert(text, pascal);
|
|
252
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
253
|
-
cache.set(key, result);
|
|
254
|
-
return result;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Converts `text` to camelCase.
|
|
258
|
-
*
|
|
259
|
-
* @example Word boundaries
|
|
260
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
261
|
-
*
|
|
262
|
-
* @example With a prefix
|
|
263
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
264
|
-
*/
|
|
265
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
266
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Converts `text` to PascalCase.
|
|
270
|
-
*
|
|
271
|
-
* @example Word boundaries
|
|
272
|
-
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
273
|
-
*
|
|
274
|
-
* @example With a suffix
|
|
275
|
-
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
276
|
-
*/
|
|
277
|
-
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
278
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
279
|
-
}
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region ../../internals/utils/src/reserved.ts
|
|
239
|
+
// ../../internals/utils/src/reserved.ts
|
|
282
240
|
/**
|
|
283
241
|
* JavaScript and Java reserved words.
|
|
284
242
|
* @link https://github.com/jonschlinkert/reserved/blob/master/index.js
|
|
@@ -286,6 +244,7 @@ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
|
286
244
|
const reservedWords = /* @__PURE__ */ new Set([
|
|
287
245
|
"abstract",
|
|
288
246
|
"arguments",
|
|
247
|
+
"await",
|
|
289
248
|
"boolean",
|
|
290
249
|
"break",
|
|
291
250
|
"byte",
|
|
@@ -416,8 +375,7 @@ function ensureValidVarName(name) {
|
|
|
416
375
|
function isIdentifier(name) {
|
|
417
376
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
418
377
|
}
|
|
419
|
-
|
|
420
|
-
//#region ../../internals/utils/src/codegen.ts
|
|
378
|
+
// ../../internals/utils/src/codegen.ts
|
|
421
379
|
/**
|
|
422
380
|
* Builds a JSDoc comment block from an array of lines. Returns `fallback` when there are no
|
|
423
381
|
* comments.
|
|
@@ -433,8 +391,32 @@ function buildJSDoc(comments, options = {}) {
|
|
|
433
391
|
if (comments.length === 0) return fallback;
|
|
434
392
|
return `/**\n${comments.map((c) => `${indent}${c}`).join("\n")}\n */${suffix}`;
|
|
435
393
|
}
|
|
436
|
-
|
|
437
|
-
|
|
394
|
+
// ../../internals/shared/src/resolver.ts
|
|
395
|
+
/**
|
|
396
|
+
* The shared top-level `name` of the operation plugins, computed once per operation name and build.
|
|
397
|
+
*/
|
|
398
|
+
function resolveOperationName(name) {
|
|
399
|
+
return this.memo(`operation:${name}`, () => ensureValidVarName((0, kubb_kit.camelCase)(name)));
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Builds the allocation key for a declaration an operation owns. `scope` names which declaration
|
|
403
|
+
* it is, so two of them never share an allocation even when a custom resolver gives both the same
|
|
404
|
+
* name. Leave `scope` empty for the operation's own declaration.
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```ts
|
|
408
|
+
* resolver.resolveName({ key: operationKey(node, 'response', 'status', 404), name })
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
function operationKey(node, ...scope) {
|
|
412
|
+
return [
|
|
413
|
+
"operation",
|
|
414
|
+
node.method,
|
|
415
|
+
node.path,
|
|
416
|
+
...scope.map(String)
|
|
417
|
+
];
|
|
418
|
+
}
|
|
419
|
+
// ../../internals/shared/src/group.ts
|
|
438
420
|
/**
|
|
439
421
|
* Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the
|
|
440
422
|
* shared default naming so every plugin groups output consistently:
|
|
@@ -457,15 +439,14 @@ function createGroupConfig(group) {
|
|
|
457
439
|
if (!group) return null;
|
|
458
440
|
const defaultName = (ctx) => {
|
|
459
441
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
460
|
-
return camelCase(ctx.group);
|
|
442
|
+
return (0, kubb_kit.camelCase)(ctx.group);
|
|
461
443
|
};
|
|
462
444
|
return {
|
|
463
445
|
...group,
|
|
464
446
|
name: group.name ? group.name : defaultName
|
|
465
447
|
};
|
|
466
448
|
}
|
|
467
|
-
|
|
468
|
-
//#region ../../internals/client/src/builders/validatorOptions.ts
|
|
449
|
+
// ../../internals/client/src/builders/validatorOptions.ts
|
|
469
450
|
/**
|
|
470
451
|
* Returns `true` when any direction of the validator uses zod (used for dependency checks).
|
|
471
452
|
*/
|
|
@@ -508,8 +489,7 @@ function buildZodErrorParse(node, zodResolver) {
|
|
|
508
489
|
if (!node.responses.some((res) => !isSuccessStatusCode(res.statusCode) && res.content?.some((entry) => entry.schema))) return null;
|
|
509
490
|
return zodResolver.response.error?.(node) || null;
|
|
510
491
|
}
|
|
511
|
-
|
|
512
|
-
//#region ../../internals/client/src/builders/security.ts
|
|
492
|
+
// ../../internals/client/src/builders/security.ts
|
|
513
493
|
function serializeAuth(auth) {
|
|
514
494
|
const parts = [`type: '${auth.type}'`];
|
|
515
495
|
if (auth.scheme) parts.push(`scheme: '${auth.scheme}'`);
|
|
@@ -580,8 +560,7 @@ function buildSecurityMetadata({ security }) {
|
|
|
580
560
|
if (!security?.length) return null;
|
|
581
561
|
return `[${security.map(serializeAuth).join(", ")}]`;
|
|
582
562
|
}
|
|
583
|
-
|
|
584
|
-
//#region ../../internals/client/src/builders/validator.ts
|
|
563
|
+
// ../../internals/client/src/builders/validator.ts
|
|
585
564
|
/**
|
|
586
565
|
* Builds the validator-hook references for one operation. Request body and params validation run before the send.
|
|
587
566
|
* Response validation runs on the success body only. Returns `null` references when the matching
|
|
@@ -623,17 +602,16 @@ function buildValidatorLiteral(hooks, keys) {
|
|
|
623
602
|
const entries = keys.flatMap((key) => hooks?.[key] ? [`${key}: ${hooks[key]}`] : []);
|
|
624
603
|
return entries.length ? `validator: { ${entries.join(", ")} }` : null;
|
|
625
604
|
}
|
|
626
|
-
|
|
627
|
-
//#region ../../internals/client/src/builders/contentType.ts
|
|
605
|
+
// ../../internals/client/src/builders/contentType.ts
|
|
628
606
|
/**
|
|
629
|
-
* Builds the `contentType` entry baked into the call config, or `null`
|
|
607
|
+
* Builds the `contentType` entry baked into the call config, or `null` without a request body.
|
|
630
608
|
*
|
|
631
609
|
* `merge` is `true` when the generated function must destructure `contentType` from `options` and
|
|
632
610
|
* merge it over the baked request default, because the caller can also pick a response content type.
|
|
633
611
|
*/
|
|
634
612
|
function buildContentType({ node }) {
|
|
635
613
|
const { defaultContentType } = getContentTypeInfo(node);
|
|
636
|
-
const requestContentType = Boolean(node.requestBody?.content?.[0]?.schema)
|
|
614
|
+
const requestContentType = Boolean(node.requestBody?.content?.[0]?.schema) ? defaultContentType : null;
|
|
637
615
|
if (!requestContentType) return {
|
|
638
616
|
literal: null,
|
|
639
617
|
merge: false
|
|
@@ -644,8 +622,7 @@ function buildContentType({ node }) {
|
|
|
644
622
|
literal: merge ? `contentType: { request: '${requestContentType}', ...(typeof contentType === 'string' ? { request: contentType } : contentType) }` : `contentType: { request: '${requestContentType}' }`
|
|
645
623
|
};
|
|
646
624
|
}
|
|
647
|
-
|
|
648
|
-
//#region ../../internals/client/src/builders/generics.ts
|
|
625
|
+
// ../../internals/client/src/builders/generics.ts
|
|
649
626
|
/**
|
|
650
627
|
* Builds the `RequestResult` generic arguments for one operation: the per-status responses record
|
|
651
628
|
* plus the per-call `ThrowOnError` flag. `SuccessOf` / `ErrorOf` split the record inside the
|
|
@@ -676,8 +653,7 @@ function buildResultType({ node, types, returnType }) {
|
|
|
676
653
|
if (returnType === "plain") return `Promise<RequestResult<${generics}>>`;
|
|
677
654
|
return `Unwrappable<RequestResult<${generics}>>`;
|
|
678
655
|
}
|
|
679
|
-
|
|
680
|
-
//#region ../../internals/client/src/builders/returnStatement.ts
|
|
656
|
+
// ../../internals/client/src/builders/returnStatement.ts
|
|
681
657
|
/**
|
|
682
658
|
* Builds the return statement of a generated operation function. With the default
|
|
683
659
|
* `returnType: 'full'` the runtime call already resolves to `{ data, error, request, response }`.
|
|
@@ -701,22 +677,22 @@ function buildResultType({ node, types, returnType }) {
|
|
|
701
677
|
* `return request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>`
|
|
702
678
|
*/
|
|
703
679
|
function buildReturnStatement({ node, types, callConfig, returnType, throwOnErrorDefault }) {
|
|
704
|
-
|
|
680
|
+
const request = returnType !== "plain" && hasRequestContentTypeChoice(node) ? `request<${types.response.options(node)}['body']>` : "request";
|
|
681
|
+
if (returnType === "data") return `return unwrapResult(${request}(${callConfig}), config.throwOnError ?? ${throwOnErrorDefault}) as ${buildResultType({
|
|
705
682
|
node,
|
|
706
683
|
types,
|
|
707
684
|
returnType
|
|
708
685
|
})}`;
|
|
709
|
-
if (returnType === "plain") return `return request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
|
|
686
|
+
if (returnType === "plain") return `return ${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
|
|
710
687
|
node,
|
|
711
688
|
types
|
|
712
689
|
})}>>`;
|
|
713
|
-
return `return withUnwrap(request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
|
|
690
|
+
return `return withUnwrap(${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
|
|
714
691
|
node,
|
|
715
692
|
types
|
|
716
693
|
})}>>)`;
|
|
717
694
|
}
|
|
718
|
-
|
|
719
|
-
//#region ../../internals/client/src/builders/signature.ts
|
|
695
|
+
// ../../internals/client/src/builders/signature.ts
|
|
720
696
|
const declarationPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
721
697
|
/**
|
|
722
698
|
* Builds the grouped-options signature for one operation: a single `options` object whose `TData`
|
|
@@ -744,8 +720,7 @@ function buildGroupedOptionsSignature({ node, types, returnType, throwOnErrorDef
|
|
|
744
720
|
generics: [`ThrowOnError extends boolean = ${throwOnErrorDefault}`]
|
|
745
721
|
};
|
|
746
722
|
}
|
|
747
|
-
|
|
748
|
-
//#region ../../internals/client/src/builders/styles.ts
|
|
723
|
+
// ../../internals/client/src/builders/styles.ts
|
|
749
724
|
/**
|
|
750
725
|
* Renders a parameter name as an object-literal key, quoted when it is not a bare identifier. Every
|
|
751
726
|
* location keeps the spec name: the runtime looks path styles up by the `{name}` placeholder in the
|
|
@@ -817,8 +792,7 @@ function buildStyles({ node }) {
|
|
|
817
792
|
const entries = [...Object.keys(groups).filter((location) => groups[location].length > 0).map((location) => `${location}: { ${groups[location].join(", ")} }`), serializeBodyEncoding(node)].filter(Boolean);
|
|
818
793
|
return entries.length > 0 ? `{ ${entries.join(", ")} }` : null;
|
|
819
794
|
}
|
|
820
|
-
|
|
821
|
-
//#region ../../internals/client/src/components/Operation.tsx
|
|
795
|
+
// ../../internals/client/src/components/Operation.tsx
|
|
822
796
|
/**
|
|
823
797
|
* Renders one client operation: the grouped `<Name>Request` type and the function that forwards a
|
|
824
798
|
* single `options` object to the resolved client and returns the `Unwrappable<RequestResult>`. The
|
|
@@ -895,8 +869,7 @@ function Operation({ name, node, types, zodResolver, validator, returnType, thro
|
|
|
895
869
|
})
|
|
896
870
|
});
|
|
897
871
|
}
|
|
898
|
-
|
|
899
|
-
//#region ../../internals/client/src/resolveOperationTypes.ts
|
|
872
|
+
// ../../internals/client/src/resolveOperationTypes.ts
|
|
900
873
|
/**
|
|
901
874
|
* A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
|
|
902
875
|
* exports next to each schema, so code written against `plugin-ts` names picks up the zod types.
|
|
@@ -906,6 +879,7 @@ function toZodTypeResolver(resolver) {
|
|
|
906
879
|
return {
|
|
907
880
|
...resolver,
|
|
908
881
|
file: resolver.file.bind(resolver),
|
|
882
|
+
memo: (key, compute) => resolver.memo(`zodTypes:${key}`, compute),
|
|
909
883
|
param: {
|
|
910
884
|
name: (node, p) => type(resolver.param.name(node, p)),
|
|
911
885
|
path: (node, p) => type(resolver.param.path(node, p)),
|
|
@@ -962,8 +936,7 @@ function resolveOperationTypes(driver, pluginName) {
|
|
|
962
936
|
group: pluginZod.options.group ?? void 0
|
|
963
937
|
};
|
|
964
938
|
}
|
|
965
|
-
|
|
966
|
-
//#region ../../internals/client/src/generators/clientGenerator.tsx
|
|
939
|
+
// ../../internals/client/src/generators/clientGenerator.tsx
|
|
967
940
|
/**
|
|
968
941
|
* Builds the built-in per-operation generator shared by the client plugins (`@kubb/plugin-fetch`,
|
|
969
942
|
* `@kubb/plugin-axios`). Emits one async function per OpenAPI operation using the shared
|
|
@@ -990,8 +963,12 @@ function createClientGenerator(name, resolveClientPath) {
|
|
|
990
963
|
zodResolver
|
|
991
964
|
});
|
|
992
965
|
const importedZodNames = validatorHooks.importedZodNames;
|
|
966
|
+
const operationName = resolver.name(node.operationId);
|
|
993
967
|
const meta = {
|
|
994
|
-
name: resolver.
|
|
968
|
+
name: resolver.resolveName({
|
|
969
|
+
key: operationKey(node),
|
|
970
|
+
name: operationName
|
|
971
|
+
}),
|
|
995
972
|
file: resolver.file({
|
|
996
973
|
...operationFileEntry(node, node.operationId),
|
|
997
974
|
root,
|
|
@@ -1106,8 +1083,7 @@ function createClientGenerator(name, resolveClientPath) {
|
|
|
1106
1083
|
}
|
|
1107
1084
|
});
|
|
1108
1085
|
}
|
|
1109
|
-
|
|
1110
|
-
//#region ../../internals/client/src/components/SdkClient.tsx
|
|
1086
|
+
// ../../internals/client/src/components/SdkClient.tsx
|
|
1111
1087
|
/**
|
|
1112
1088
|
* Builds the call config literal forwarded to the contract client; the `throwOnError` fallback is applied after the `...config` spread.
|
|
1113
1089
|
*/
|
|
@@ -1197,8 +1173,7 @@ function SdkClient({ name, operations, returnType, throwOnErrorDefault }) {
|
|
|
1197
1173
|
children: classCode
|
|
1198
1174
|
});
|
|
1199
1175
|
}
|
|
1200
|
-
|
|
1201
|
-
//#region ../../internals/client/src/components/SdkFacade.tsx
|
|
1176
|
+
// ../../internals/client/src/components/SdkFacade.tsx
|
|
1202
1177
|
/**
|
|
1203
1178
|
* Renders a composed root SDK class that instantiates every tag client from one shared config, so
|
|
1204
1179
|
* `new PetStore({ baseURL }).petClient.getPetById(...)` reaches an operation through a single entry
|
|
@@ -1221,8 +1196,7 @@ function SdkFacade({ name, members }) {
|
|
|
1221
1196
|
children: classCode
|
|
1222
1197
|
});
|
|
1223
1198
|
}
|
|
1224
|
-
|
|
1225
|
-
//#region ../../internals/client/src/generators/sdkGenerator.tsx
|
|
1199
|
+
// ../../internals/client/src/generators/sdkGenerator.tsx
|
|
1226
1200
|
function resolveTypeImportNames(node, types) {
|
|
1227
1201
|
return [types.response.options(node), types.response.responses(node)];
|
|
1228
1202
|
}
|
|
@@ -1259,9 +1233,13 @@ function buildControllers(nodes, ctx, types) {
|
|
|
1259
1233
|
validator,
|
|
1260
1234
|
zodResolver
|
|
1261
1235
|
}) : null;
|
|
1236
|
+
const name = resolver.name(node.operationId);
|
|
1262
1237
|
return {
|
|
1263
1238
|
node,
|
|
1264
|
-
name: resolver.
|
|
1239
|
+
name: resolver.resolveName({
|
|
1240
|
+
key: operationKey(node),
|
|
1241
|
+
name
|
|
1242
|
+
}),
|
|
1265
1243
|
types,
|
|
1266
1244
|
typeFile,
|
|
1267
1245
|
zodFile,
|
|
@@ -1272,7 +1250,7 @@ function buildControllers(nodes, ctx, types) {
|
|
|
1272
1250
|
return nodes.reduce((acc, operationNode) => {
|
|
1273
1251
|
if (!kubb_kit.ast.isHttpOperationNode(operationNode)) return acc;
|
|
1274
1252
|
const tag = operationNode.tags[0];
|
|
1275
|
-
const name = tag ? group?.name?.({ group: camelCase(tag) }) ?? resolver.groupName(tag) : resolver.className("ApiClient");
|
|
1253
|
+
const name = tag ? ensureValidVarName(group?.name?.({ group: (0, kubb_kit.camelCase)(tag) }) ?? resolver.groupName(tag)) : resolver.className("ApiClient");
|
|
1276
1254
|
const file = resolver.file({
|
|
1277
1255
|
name,
|
|
1278
1256
|
extname: ".ts",
|
|
@@ -1474,19 +1452,17 @@ function createSdkGenerator() {
|
|
|
1474
1452
|
}
|
|
1475
1453
|
});
|
|
1476
1454
|
}
|
|
1477
|
-
|
|
1478
|
-
//#region ../../internals/client/src/macros.ts
|
|
1455
|
+
// ../../internals/client/src/macros.ts
|
|
1479
1456
|
/**
|
|
1480
1457
|
* Macros the client plugins apply by default, ahead of any user macros. `macroSimplifyUnion`
|
|
1481
1458
|
* drops union members a broader scalar already covers, keeping the generated response and error
|
|
1482
1459
|
* unions tidy. A plugin wires them with `ctx.setMacros([...defaultMacros, ...userMacros])`.
|
|
1483
1460
|
*/
|
|
1484
1461
|
const defaultMacros = [kubb_kit.macroSimplifyUnion];
|
|
1485
|
-
|
|
1486
|
-
//#region ../../internals/client/src/resolver.ts
|
|
1462
|
+
// ../../internals/client/src/resolver.ts
|
|
1487
1463
|
/**
|
|
1488
|
-
* Default resolver shared by the client plugins. Functions
|
|
1489
|
-
*
|
|
1464
|
+
* Default resolver shared by the client plugins. Functions use safe camelCase identifiers and
|
|
1465
|
+
* files inherit the built-in casing; classes and tag groups use PascalCase.
|
|
1490
1466
|
*
|
|
1491
1467
|
* @example
|
|
1492
1468
|
* ```ts
|
|
@@ -1496,35 +1472,32 @@ const defaultMacros = [kubb_kit.macroSimplifyUnion];
|
|
|
1496
1472
|
*/
|
|
1497
1473
|
const resolverClient = (0, kubb_kit.createResolver)({
|
|
1498
1474
|
pluginName: "plugin-contract-client",
|
|
1475
|
+
name: resolveOperationName,
|
|
1499
1476
|
className(name) {
|
|
1500
|
-
return ensureValidVarName(pascalCase(name));
|
|
1477
|
+
return ensureValidVarName((0, kubb_kit.pascalCase)(name));
|
|
1501
1478
|
},
|
|
1502
1479
|
groupName(name) {
|
|
1503
|
-
return ensureValidVarName(pascalCase(`${name} Client`));
|
|
1480
|
+
return ensureValidVarName((0, kubb_kit.pascalCase)(`${name} Client`));
|
|
1504
1481
|
},
|
|
1505
1482
|
propertyName(name) {
|
|
1506
|
-
return ensureValidVarName(camelCase(name));
|
|
1483
|
+
return ensureValidVarName((0, kubb_kit.camelCase)(name));
|
|
1507
1484
|
}
|
|
1508
1485
|
});
|
|
1509
|
-
|
|
1510
|
-
//#region src/generators/clientGenerator.tsx
|
|
1486
|
+
// src/generators/clientGenerator.tsx
|
|
1511
1487
|
/**
|
|
1512
1488
|
* Built-in operation generator for `@kubb/plugin-fetch`. Emits one async function per OpenAPI
|
|
1513
1489
|
* operation using the shared `Operation` component: a grouped `<Name>Request` type and a function
|
|
1514
1490
|
* that forwards a single `options` object to the bundled `client` and returns the `RequestResult`.
|
|
1515
1491
|
*/
|
|
1516
1492
|
const clientGenerator = createClientGenerator("fetch");
|
|
1517
|
-
|
|
1518
|
-
//#region kubb-extension.json
|
|
1493
|
+
// kubb-extension.json
|
|
1519
1494
|
var compatibility = {
|
|
1520
|
-
"kubb": ">=5.
|
|
1495
|
+
"kubb": ">=5.14.6",
|
|
1521
1496
|
"node": ">=22.22"
|
|
1522
1497
|
};
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
//#endregion
|
|
1527
|
-
//#region src/templates.ts
|
|
1498
|
+
// package.json
|
|
1499
|
+
var version = "5.10.1";
|
|
1500
|
+
// src/templates.ts
|
|
1528
1501
|
/** Absolute path to the fetch client template, copied into `.kubb/client.ts`. */
|
|
1529
1502
|
const fetchClientTemplatePath = (0, node_url.fileURLToPath)(new URL("../templates/fetch.ts", require("url").pathToFileURL(__filename).href));
|
|
1530
1503
|
/** Absolute path to the fetch serializers template, copied into `.kubb/serializers.ts`. */
|
|
@@ -1534,8 +1507,7 @@ const fetchSerializersTemplatePath = (0, node_url.fileURLToPath)(new URL("../tem
|
|
|
1534
1507
|
* emit the helper into the generated `.kubb/standardSchema.ts` verbatim.
|
|
1535
1508
|
*/
|
|
1536
1509
|
const standardSchemaTemplatePath = (0, node_url.fileURLToPath)(new URL("../templates/standardSchema.ts", require("url").pathToFileURL(__filename).href));
|
|
1537
|
-
|
|
1538
|
-
//#region src/plugin.ts
|
|
1510
|
+
// src/plugin.ts
|
|
1539
1511
|
/**
|
|
1540
1512
|
* Canonical plugin name for `@kubb/plugin-fetch`. Used for driver lookups and cross-plugin
|
|
1541
1513
|
* dependency references.
|
|
@@ -1620,7 +1592,6 @@ const pluginFetch = (0, kubb_kit.defineExtension)({
|
|
|
1620
1592
|
return resolved;
|
|
1621
1593
|
}
|
|
1622
1594
|
});
|
|
1623
|
-
//#endregion
|
|
1624
1595
|
exports.clientGenerator = clientGenerator;
|
|
1625
1596
|
exports.default = pluginFetch;
|
|
1626
1597
|
exports.pluginFetch = pluginFetch;
|