@kubb/plugin-axios 5.10.0-canary.20261025T201031 → 5.10.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 +81 -65
- 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 +80 -64
- package/dist/index.js.map +1 -1
- package/dist/templates/axios.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/axios.ts +1 -1
- package/templates/serializers.ts +5 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
2
2
|
import "@kubb/plugin-zod";
|
|
3
3
|
import "@kubb/plugin-ts";
|
|
4
|
-
//#region ../../internals/client/src/types.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Validator applied to the request and response using schemas from `@kubb/plugin-zod`.
|
|
7
6
|
* - `false`: no validation.
|
|
@@ -181,8 +180,6 @@ type ResolvedOptions = {
|
|
|
181
180
|
} | undefined;
|
|
182
181
|
resolver: ResolverClient;
|
|
183
182
|
};
|
|
184
|
-
//#endregion
|
|
185
|
-
//#region src/types.d.ts
|
|
186
183
|
/**
|
|
187
184
|
* The plugin factory type for `@kubb/plugin-axios`. Shares the options surface, resolver, and
|
|
188
185
|
* resolved-options shape with the other client plugins; only the plugin name and transport
|
|
@@ -196,16 +193,12 @@ declare global {
|
|
|
196
193
|
}
|
|
197
194
|
}
|
|
198
195
|
}
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/generators/clientGenerator.d.ts
|
|
201
196
|
/**
|
|
202
197
|
* Built-in operation generator for `@kubb/plugin-axios`. Emits one async function per OpenAPI
|
|
203
198
|
* operation using the shared `Operation` component: a grouped `<Name>Request` type and a function
|
|
204
199
|
* that forwards a single `options` object to the bundled `client` and returns the `RequestResult`.
|
|
205
200
|
*/
|
|
206
201
|
export declare const clientGenerator: import("kubb/kit").Generator<PluginAxios>;
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/plugin.d.ts
|
|
209
202
|
/**
|
|
210
203
|
* Canonical plugin name for `@kubb/plugin-axios`. Used for driver lookups and cross-plugin
|
|
211
204
|
* dependency references.
|
|
@@ -234,6 +227,5 @@ export declare const pluginAxiosName = "plugin-axios";
|
|
|
234
227
|
* ```
|
|
235
228
|
*/
|
|
236
229
|
export declare const pluginAxios: import("kubb/kit").PluginFactory<PluginAxios>;
|
|
237
|
-
//#endregion
|
|
238
230
|
export { type Options, type PluginAxios, type ResolvedOptions, type ResolverClient, pluginAxios as default };
|
|
239
231
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
2
2
|
import "@kubb/plugin-zod";
|
|
3
3
|
import "@kubb/plugin-ts";
|
|
4
|
-
//#region ../../internals/client/src/types.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Validator applied to the request and response using schemas from `@kubb/plugin-zod`.
|
|
7
6
|
* - `false`: no validation.
|
|
@@ -181,8 +180,6 @@ type ResolvedOptions = {
|
|
|
181
180
|
} | undefined;
|
|
182
181
|
resolver: ResolverClient;
|
|
183
182
|
};
|
|
184
|
-
//#endregion
|
|
185
|
-
//#region src/types.d.ts
|
|
186
183
|
/**
|
|
187
184
|
* The plugin factory type for `@kubb/plugin-axios`. Shares the options surface, resolver, and
|
|
188
185
|
* resolved-options shape with the other client plugins; only the plugin name and transport
|
|
@@ -196,16 +193,12 @@ declare global {
|
|
|
196
193
|
}
|
|
197
194
|
}
|
|
198
195
|
}
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/generators/clientGenerator.d.ts
|
|
201
196
|
/**
|
|
202
197
|
* Built-in operation generator for `@kubb/plugin-axios`. Emits one async function per OpenAPI
|
|
203
198
|
* operation using the shared `Operation` component: a grouped `<Name>Request` type and a function
|
|
204
199
|
* that forwards a single `options` object to the bundled `client` and returns the `RequestResult`.
|
|
205
200
|
*/
|
|
206
201
|
export declare const clientGenerator: import("kubb/kit").Generator<PluginAxios>;
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/plugin.d.ts
|
|
209
202
|
/**
|
|
210
203
|
* Canonical plugin name for `@kubb/plugin-axios`. Used for driver lookups and cross-plugin
|
|
211
204
|
* dependency references.
|
|
@@ -234,6 +227,5 @@ export declare const pluginAxiosName = "plugin-axios";
|
|
|
234
227
|
* ```
|
|
235
228
|
*/
|
|
236
229
|
export declare const pluginAxios: import("kubb/kit").PluginFactory<PluginAxios>;
|
|
237
|
-
//#endregion
|
|
238
230
|
export { type Options, type PluginAxios, type ResolvedOptions, type ResolverClient, pluginAxios as default };
|
|
239
231
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,7 @@ import { File, Function, jsxRenderer } from "kubb/jsx";
|
|
|
5
5
|
import { createFunctionParameter, createFunctionParameters, functionPrinter, pluginTsName } from "@kubb/plugin-ts";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
-
|
|
9
|
-
//#region ../../internals/shared/src/operation.ts
|
|
8
|
+
// ../../internals/shared/src/operation.ts
|
|
10
9
|
/**
|
|
11
10
|
* Builds the `ResolverFileParams` every operation generator passes to
|
|
12
11
|
* `resolver.file`: a file named `name`, tagged by the operation's first
|
|
@@ -184,6 +183,16 @@ function getOperationParameters(node) {
|
|
|
184
183
|
operationParameterGroupsByNode.set(node, groups);
|
|
185
184
|
return groups;
|
|
186
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Builds the combined `{ body, path, query, headers }` options object schema for an operation,
|
|
188
|
+
* referencing the already-resolved body and grouped param names. Shared by `@kubb/plugin-ts`'s
|
|
189
|
+
* `Options` type and `@kubb/plugin-zod`'s inferred options schema, so both printers emit the same
|
|
190
|
+
* shape from the same inputs. `primitive: 'object'` is a no-op for the TS printer and tells the Zod
|
|
191
|
+
* printer to emit `z.object(…)` rather than a record.
|
|
192
|
+
*/
|
|
193
|
+
function hasRequestContentTypeChoice(node) {
|
|
194
|
+
return (node.requestBody?.content ?? []).filter((entry) => entry.schema).length > 1;
|
|
195
|
+
}
|
|
187
196
|
function getStatusCodeNumber(statusCode) {
|
|
188
197
|
const code = Number(statusCode);
|
|
189
198
|
return Number.isNaN(code) ? null : code;
|
|
@@ -201,8 +210,7 @@ function getOperationSuccessResponses(node) {
|
|
|
201
210
|
function getPrimarySuccessResponse(node) {
|
|
202
211
|
return getOperationSuccessResponses(node)[0] ?? null;
|
|
203
212
|
}
|
|
204
|
-
|
|
205
|
-
//#region ../../internals/utils/src/casing.ts
|
|
213
|
+
// ../../internals/utils/src/casing.ts
|
|
206
214
|
/**
|
|
207
215
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
208
216
|
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
@@ -251,8 +259,7 @@ function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
|
251
259
|
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
252
260
|
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
253
261
|
}
|
|
254
|
-
|
|
255
|
-
//#region ../../internals/utils/src/reserved.ts
|
|
262
|
+
// ../../internals/utils/src/reserved.ts
|
|
256
263
|
/**
|
|
257
264
|
* JavaScript and Java reserved words.
|
|
258
265
|
* @link https://github.com/jonschlinkert/reserved/blob/master/index.js
|
|
@@ -260,6 +267,7 @@ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
|
260
267
|
const reservedWords = /* @__PURE__ */ new Set([
|
|
261
268
|
"abstract",
|
|
262
269
|
"arguments",
|
|
270
|
+
"await",
|
|
263
271
|
"boolean",
|
|
264
272
|
"break",
|
|
265
273
|
"byte",
|
|
@@ -390,8 +398,7 @@ function ensureValidVarName(name) {
|
|
|
390
398
|
function isIdentifier(name) {
|
|
391
399
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
392
400
|
}
|
|
393
|
-
|
|
394
|
-
//#region ../../internals/utils/src/codegen.ts
|
|
401
|
+
// ../../internals/utils/src/codegen.ts
|
|
395
402
|
/**
|
|
396
403
|
* Builds a JSDoc comment block from an array of lines. Returns `fallback` when there are no
|
|
397
404
|
* comments.
|
|
@@ -407,8 +414,29 @@ function buildJSDoc(comments, options = {}) {
|
|
|
407
414
|
if (comments.length === 0) return fallback;
|
|
408
415
|
return `/**\n${comments.map((c) => `${indent}${c}`).join("\n")}\n */${suffix}`;
|
|
409
416
|
}
|
|
410
|
-
|
|
411
|
-
|
|
417
|
+
// ../../internals/shared/src/resolver.ts
|
|
418
|
+
function resolveOperationName(name) {
|
|
419
|
+
return ensureValidVarName(camelCase(name));
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Builds the allocation key for a declaration an operation owns. `scope` names which declaration
|
|
423
|
+
* it is, so two of them never share an allocation even when a custom resolver gives both the same
|
|
424
|
+
* name. Leave `scope` empty for the operation's own declaration.
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```ts
|
|
428
|
+
* resolver.resolveName({ key: operationKey(node, 'response', 'status', 404), name })
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
function operationKey(node, ...scope) {
|
|
432
|
+
return [
|
|
433
|
+
"operation",
|
|
434
|
+
node.method,
|
|
435
|
+
node.path,
|
|
436
|
+
...scope.map(String)
|
|
437
|
+
];
|
|
438
|
+
}
|
|
439
|
+
// ../../internals/shared/src/group.ts
|
|
412
440
|
/**
|
|
413
441
|
* Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the
|
|
414
442
|
* shared default naming so every plugin groups output consistently:
|
|
@@ -438,8 +466,7 @@ function createGroupConfig(group) {
|
|
|
438
466
|
name: group.name ? group.name : defaultName
|
|
439
467
|
};
|
|
440
468
|
}
|
|
441
|
-
|
|
442
|
-
//#region ../../internals/client/src/builders/validatorOptions.ts
|
|
469
|
+
// ../../internals/client/src/builders/validatorOptions.ts
|
|
443
470
|
/**
|
|
444
471
|
* Returns `true` when any direction of the validator uses zod (used for dependency checks).
|
|
445
472
|
*/
|
|
@@ -482,8 +509,7 @@ function buildZodErrorParse(node, zodResolver) {
|
|
|
482
509
|
if (!node.responses.some((res) => !isSuccessStatusCode(res.statusCode) && res.content?.some((entry) => entry.schema))) return null;
|
|
483
510
|
return zodResolver.response.error?.(node) || null;
|
|
484
511
|
}
|
|
485
|
-
|
|
486
|
-
//#region ../../internals/client/src/builders/security.ts
|
|
512
|
+
// ../../internals/client/src/builders/security.ts
|
|
487
513
|
function serializeAuth(auth) {
|
|
488
514
|
const parts = [`type: '${auth.type}'`];
|
|
489
515
|
if (auth.scheme) parts.push(`scheme: '${auth.scheme}'`);
|
|
@@ -554,8 +580,7 @@ function buildSecurityMetadata({ security }) {
|
|
|
554
580
|
if (!security?.length) return null;
|
|
555
581
|
return `[${security.map(serializeAuth).join(", ")}]`;
|
|
556
582
|
}
|
|
557
|
-
|
|
558
|
-
//#region ../../internals/client/src/builders/validator.ts
|
|
583
|
+
// ../../internals/client/src/builders/validator.ts
|
|
559
584
|
/**
|
|
560
585
|
* Builds the validator-hook references for one operation. Request body and params validation run before the send.
|
|
561
586
|
* Response validation runs on the success body only. Returns `null` references when the matching
|
|
@@ -597,17 +622,16 @@ function buildValidatorLiteral(hooks, keys) {
|
|
|
597
622
|
const entries = keys.flatMap((key) => hooks?.[key] ? [`${key}: ${hooks[key]}`] : []);
|
|
598
623
|
return entries.length ? `validator: { ${entries.join(", ")} }` : null;
|
|
599
624
|
}
|
|
600
|
-
|
|
601
|
-
//#region ../../internals/client/src/builders/contentType.ts
|
|
625
|
+
// ../../internals/client/src/builders/contentType.ts
|
|
602
626
|
/**
|
|
603
|
-
* Builds the `contentType` entry baked into the call config, or `null`
|
|
627
|
+
* Builds the `contentType` entry baked into the call config, or `null` without a request body.
|
|
604
628
|
*
|
|
605
629
|
* `merge` is `true` when the generated function must destructure `contentType` from `options` and
|
|
606
630
|
* merge it over the baked request default, because the caller can also pick a response content type.
|
|
607
631
|
*/
|
|
608
632
|
function buildContentType({ node }) {
|
|
609
633
|
const { defaultContentType } = getContentTypeInfo(node);
|
|
610
|
-
const requestContentType = Boolean(node.requestBody?.content?.[0]?.schema)
|
|
634
|
+
const requestContentType = Boolean(node.requestBody?.content?.[0]?.schema) ? defaultContentType : null;
|
|
611
635
|
if (!requestContentType) return {
|
|
612
636
|
literal: null,
|
|
613
637
|
merge: false
|
|
@@ -618,8 +642,7 @@ function buildContentType({ node }) {
|
|
|
618
642
|
literal: merge ? `contentType: { request: '${requestContentType}', ...(typeof contentType === 'string' ? { request: contentType } : contentType) }` : `contentType: { request: '${requestContentType}' }`
|
|
619
643
|
};
|
|
620
644
|
}
|
|
621
|
-
|
|
622
|
-
//#region ../../internals/client/src/builders/generics.ts
|
|
645
|
+
// ../../internals/client/src/builders/generics.ts
|
|
623
646
|
/**
|
|
624
647
|
* Builds the `RequestResult` generic arguments for one operation: the per-status responses record
|
|
625
648
|
* plus the per-call `ThrowOnError` flag. `SuccessOf` / `ErrorOf` split the record inside the
|
|
@@ -650,8 +673,7 @@ function buildResultType({ node, types, returnType }) {
|
|
|
650
673
|
if (returnType === "plain") return `Promise<RequestResult<${generics}>>`;
|
|
651
674
|
return `Unwrappable<RequestResult<${generics}>>`;
|
|
652
675
|
}
|
|
653
|
-
|
|
654
|
-
//#region ../../internals/client/src/builders/returnStatement.ts
|
|
676
|
+
// ../../internals/client/src/builders/returnStatement.ts
|
|
655
677
|
/**
|
|
656
678
|
* Builds the return statement of a generated operation function. With the default
|
|
657
679
|
* `returnType: 'full'` the runtime call already resolves to `{ data, error, request, response }`.
|
|
@@ -675,22 +697,22 @@ function buildResultType({ node, types, returnType }) {
|
|
|
675
697
|
* `return request({ method: 'POST', url: '/pet', ...config }) as Promise<RequestResult<AddPetResponses, ThrowOnError>>`
|
|
676
698
|
*/
|
|
677
699
|
function buildReturnStatement({ node, types, callConfig, returnType, throwOnErrorDefault }) {
|
|
678
|
-
|
|
700
|
+
const request = returnType !== "plain" && hasRequestContentTypeChoice(node) ? `request<${types.response.options(node)}['body']>` : "request";
|
|
701
|
+
if (returnType === "data") return `return unwrapResult(${request}(${callConfig}), config.throwOnError ?? ${throwOnErrorDefault}) as ${buildResultType({
|
|
679
702
|
node,
|
|
680
703
|
types,
|
|
681
704
|
returnType
|
|
682
705
|
})}`;
|
|
683
|
-
if (returnType === "plain") return `return request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
|
|
706
|
+
if (returnType === "plain") return `return ${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
|
|
684
707
|
node,
|
|
685
708
|
types
|
|
686
709
|
})}>>`;
|
|
687
|
-
return `return withUnwrap(request(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
|
|
710
|
+
return `return withUnwrap(${request}(${callConfig}) as Promise<RequestResult<${buildRequestResultGenerics({
|
|
688
711
|
node,
|
|
689
712
|
types
|
|
690
713
|
})}>>)`;
|
|
691
714
|
}
|
|
692
|
-
|
|
693
|
-
//#region ../../internals/client/src/builders/signature.ts
|
|
715
|
+
// ../../internals/client/src/builders/signature.ts
|
|
694
716
|
const declarationPrinter = functionPrinter({ mode: "declaration" });
|
|
695
717
|
/**
|
|
696
718
|
* Builds the grouped-options signature for one operation: a single `options` object whose `TData`
|
|
@@ -718,8 +740,7 @@ function buildGroupedOptionsSignature({ node, types, returnType, throwOnErrorDef
|
|
|
718
740
|
generics: [`ThrowOnError extends boolean = ${throwOnErrorDefault}`]
|
|
719
741
|
};
|
|
720
742
|
}
|
|
721
|
-
|
|
722
|
-
//#region ../../internals/client/src/builders/styles.ts
|
|
743
|
+
// ../../internals/client/src/builders/styles.ts
|
|
723
744
|
/**
|
|
724
745
|
* Renders a parameter name as an object-literal key, quoted when it is not a bare identifier. Every
|
|
725
746
|
* location keeps the spec name: the runtime looks path styles up by the `{name}` placeholder in the
|
|
@@ -791,8 +812,7 @@ function buildStyles({ node }) {
|
|
|
791
812
|
const entries = [...Object.keys(groups).filter((location) => groups[location].length > 0).map((location) => `${location}: { ${groups[location].join(", ")} }`), serializeBodyEncoding(node)].filter(Boolean);
|
|
792
813
|
return entries.length > 0 ? `{ ${entries.join(", ")} }` : null;
|
|
793
814
|
}
|
|
794
|
-
|
|
795
|
-
//#region ../../internals/client/src/components/Operation.tsx
|
|
815
|
+
// ../../internals/client/src/components/Operation.tsx
|
|
796
816
|
/**
|
|
797
817
|
* Renders one client operation: the grouped `<Name>Request` type and the function that forwards a
|
|
798
818
|
* single `options` object to the resolved client and returns the `Unwrappable<RequestResult>`. The
|
|
@@ -869,8 +889,7 @@ function Operation({ name, node, types, zodResolver, validator, returnType, thro
|
|
|
869
889
|
})
|
|
870
890
|
});
|
|
871
891
|
}
|
|
872
|
-
|
|
873
|
-
//#region ../../internals/client/src/resolveOperationTypes.ts
|
|
892
|
+
// ../../internals/client/src/resolveOperationTypes.ts
|
|
874
893
|
/**
|
|
875
894
|
* A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
|
|
876
895
|
* exports next to each schema, so code written against `plugin-ts` names picks up the zod types.
|
|
@@ -936,8 +955,7 @@ function resolveOperationTypes(driver, pluginName) {
|
|
|
936
955
|
group: pluginZod.options.group ?? void 0
|
|
937
956
|
};
|
|
938
957
|
}
|
|
939
|
-
|
|
940
|
-
//#region ../../internals/client/src/generators/clientGenerator.tsx
|
|
958
|
+
// ../../internals/client/src/generators/clientGenerator.tsx
|
|
941
959
|
/**
|
|
942
960
|
* Builds the built-in per-operation generator shared by the client plugins (`@kubb/plugin-fetch`,
|
|
943
961
|
* `@kubb/plugin-axios`). Emits one async function per OpenAPI operation using the shared
|
|
@@ -964,8 +982,12 @@ function createClientGenerator(name, resolveClientPath) {
|
|
|
964
982
|
zodResolver
|
|
965
983
|
});
|
|
966
984
|
const importedZodNames = validatorHooks.importedZodNames;
|
|
985
|
+
const operationName = resolver.name(node.operationId);
|
|
967
986
|
const meta = {
|
|
968
|
-
name: resolver.
|
|
987
|
+
name: resolver.resolveName({
|
|
988
|
+
key: operationKey(node),
|
|
989
|
+
name: operationName
|
|
990
|
+
}),
|
|
969
991
|
file: resolver.file({
|
|
970
992
|
...operationFileEntry(node, node.operationId),
|
|
971
993
|
root,
|
|
@@ -1080,8 +1102,7 @@ function createClientGenerator(name, resolveClientPath) {
|
|
|
1080
1102
|
}
|
|
1081
1103
|
});
|
|
1082
1104
|
}
|
|
1083
|
-
|
|
1084
|
-
//#region ../../internals/client/src/components/SdkClient.tsx
|
|
1105
|
+
// ../../internals/client/src/components/SdkClient.tsx
|
|
1085
1106
|
/**
|
|
1086
1107
|
* Builds the call config literal forwarded to the contract client; the `throwOnError` fallback is applied after the `...config` spread.
|
|
1087
1108
|
*/
|
|
@@ -1171,8 +1192,7 @@ function SdkClient({ name, operations, returnType, throwOnErrorDefault }) {
|
|
|
1171
1192
|
children: classCode
|
|
1172
1193
|
});
|
|
1173
1194
|
}
|
|
1174
|
-
|
|
1175
|
-
//#region ../../internals/client/src/components/SdkFacade.tsx
|
|
1195
|
+
// ../../internals/client/src/components/SdkFacade.tsx
|
|
1176
1196
|
/**
|
|
1177
1197
|
* Renders a composed root SDK class that instantiates every tag client from one shared config, so
|
|
1178
1198
|
* `new PetStore({ baseURL }).petClient.getPetById(...)` reaches an operation through a single entry
|
|
@@ -1195,8 +1215,7 @@ function SdkFacade({ name, members }) {
|
|
|
1195
1215
|
children: classCode
|
|
1196
1216
|
});
|
|
1197
1217
|
}
|
|
1198
|
-
|
|
1199
|
-
//#region ../../internals/client/src/generators/sdkGenerator.tsx
|
|
1218
|
+
// ../../internals/client/src/generators/sdkGenerator.tsx
|
|
1200
1219
|
function resolveTypeImportNames(node, types) {
|
|
1201
1220
|
return [types.response.options(node), types.response.responses(node)];
|
|
1202
1221
|
}
|
|
@@ -1233,9 +1252,13 @@ function buildControllers(nodes, ctx, types) {
|
|
|
1233
1252
|
validator,
|
|
1234
1253
|
zodResolver
|
|
1235
1254
|
}) : null;
|
|
1255
|
+
const name = resolver.name(node.operationId);
|
|
1236
1256
|
return {
|
|
1237
1257
|
node,
|
|
1238
|
-
name: resolver.
|
|
1258
|
+
name: resolver.resolveName({
|
|
1259
|
+
key: operationKey(node),
|
|
1260
|
+
name
|
|
1261
|
+
}),
|
|
1239
1262
|
types,
|
|
1240
1263
|
typeFile,
|
|
1241
1264
|
zodFile,
|
|
@@ -1448,19 +1471,17 @@ function createSdkGenerator() {
|
|
|
1448
1471
|
}
|
|
1449
1472
|
});
|
|
1450
1473
|
}
|
|
1451
|
-
|
|
1452
|
-
//#region ../../internals/client/src/macros.ts
|
|
1474
|
+
// ../../internals/client/src/macros.ts
|
|
1453
1475
|
/**
|
|
1454
1476
|
* Macros the client plugins apply by default, ahead of any user macros. `macroSimplifyUnion`
|
|
1455
1477
|
* drops union members a broader scalar already covers, keeping the generated response and error
|
|
1456
1478
|
* unions tidy. A plugin wires them with `ctx.setMacros([...defaultMacros, ...userMacros])`.
|
|
1457
1479
|
*/
|
|
1458
1480
|
const defaultMacros = [macroSimplifyUnion];
|
|
1459
|
-
|
|
1460
|
-
//#region ../../internals/client/src/resolver.ts
|
|
1481
|
+
// ../../internals/client/src/resolver.ts
|
|
1461
1482
|
/**
|
|
1462
|
-
* Default resolver shared by the client plugins. Functions
|
|
1463
|
-
*
|
|
1483
|
+
* Default resolver shared by the client plugins. Functions use safe camelCase identifiers and
|
|
1484
|
+
* files inherit the built-in casing; classes and tag groups use PascalCase.
|
|
1464
1485
|
*
|
|
1465
1486
|
* @example
|
|
1466
1487
|
* ```ts
|
|
@@ -1470,6 +1491,7 @@ const defaultMacros = [macroSimplifyUnion];
|
|
|
1470
1491
|
*/
|
|
1471
1492
|
const resolverClient = createResolver({
|
|
1472
1493
|
pluginName: "plugin-contract-client",
|
|
1494
|
+
name: resolveOperationName,
|
|
1473
1495
|
className(name) {
|
|
1474
1496
|
return ensureValidVarName(pascalCase(name));
|
|
1475
1497
|
},
|
|
@@ -1480,25 +1502,21 @@ const resolverClient = createResolver({
|
|
|
1480
1502
|
return ensureValidVarName(camelCase(name));
|
|
1481
1503
|
}
|
|
1482
1504
|
});
|
|
1483
|
-
|
|
1484
|
-
//#region src/generators/clientGenerator.tsx
|
|
1505
|
+
// src/generators/clientGenerator.tsx
|
|
1485
1506
|
/**
|
|
1486
1507
|
* Built-in operation generator for `@kubb/plugin-axios`. Emits one async function per OpenAPI
|
|
1487
1508
|
* operation using the shared `Operation` component: a grouped `<Name>Request` type and a function
|
|
1488
1509
|
* that forwards a single `options` object to the bundled `client` and returns the `RequestResult`.
|
|
1489
1510
|
*/
|
|
1490
1511
|
const clientGenerator = createClientGenerator("axios");
|
|
1491
|
-
|
|
1492
|
-
//#region kubb-extension.json
|
|
1512
|
+
// kubb-extension.json
|
|
1493
1513
|
var compatibility = {
|
|
1494
|
-
"kubb": ">=5.
|
|
1514
|
+
"kubb": ">=5.14.6",
|
|
1495
1515
|
"node": ">=22.22"
|
|
1496
1516
|
};
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
//#endregion
|
|
1501
|
-
//#region src/templates.ts
|
|
1517
|
+
// package.json
|
|
1518
|
+
var version = "5.10.0";
|
|
1519
|
+
// src/templates.ts
|
|
1502
1520
|
/** Absolute path to the axios client template, copied into `.kubb/client.ts`. */
|
|
1503
1521
|
const axiosClientTemplatePath = fileURLToPath(new URL("../templates/axios.ts", import.meta.url));
|
|
1504
1522
|
/** Absolute path to the axios serializers template, copied into `.kubb/serializers.ts`. */
|
|
@@ -1508,8 +1526,7 @@ const axiosSerializersTemplatePath = fileURLToPath(new URL("../templates/seriali
|
|
|
1508
1526
|
* emit the helper into the generated `.kubb/standardSchema.ts` verbatim.
|
|
1509
1527
|
*/
|
|
1510
1528
|
const standardSchemaTemplatePath = fileURLToPath(new URL("../templates/standardSchema.ts", import.meta.url));
|
|
1511
|
-
|
|
1512
|
-
//#region src/plugin.ts
|
|
1529
|
+
// src/plugin.ts
|
|
1513
1530
|
/**
|
|
1514
1531
|
* Canonical plugin name for `@kubb/plugin-axios`. Used for driver lookups and cross-plugin
|
|
1515
1532
|
* dependency references.
|
|
@@ -1594,7 +1611,6 @@ const pluginAxios = defineExtension({
|
|
|
1594
1611
|
return resolved;
|
|
1595
1612
|
}
|
|
1596
1613
|
});
|
|
1597
|
-
//#endregion
|
|
1598
1614
|
export { clientGenerator, pluginAxios as default, pluginAxios, pluginAxiosName };
|
|
1599
1615
|
|
|
1600
1616
|
//# sourceMappingURL=index.js.map
|