@kubb/plugin-axios 5.10.0-canary.20261025T193221 → 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 +88 -74
- 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 +87 -73
- 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,16 +740,14 @@ 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
|
-
* Renders a parameter name as an object-literal key, quoted when it is not a bare identifier.
|
|
725
|
-
*
|
|
726
|
-
*
|
|
745
|
+
* Renders a parameter name as an object-literal key, quoted when it is not a bare identifier. Every
|
|
746
|
+
* location keeps the spec name: the runtime looks path styles up by the `{name}` placeholder in the
|
|
747
|
+
* URL, and the other locations by the key it serializes.
|
|
727
748
|
*/
|
|
728
|
-
function toKey(name
|
|
729
|
-
|
|
730
|
-
return isValidVarName(key) ? key : JSON.stringify(key);
|
|
749
|
+
function toKey(name) {
|
|
750
|
+
return isValidVarName(name) ? name : JSON.stringify(name);
|
|
731
751
|
}
|
|
732
752
|
/**
|
|
733
753
|
* Serializes one parameter's metadata into a `{ style, explode, allowReserved, contentType }`
|
|
@@ -764,8 +784,7 @@ function serializeBodyEncoding(node) {
|
|
|
764
784
|
}
|
|
765
785
|
/**
|
|
766
786
|
* Builds the per-operation `styles` literal from the operation's parameters, grouped by location.
|
|
767
|
-
*
|
|
768
|
-
* header, and cookie entries keep the spec name to match the keys the runtime serializes.
|
|
787
|
+
* Entries are keyed by the spec name of the parameter.
|
|
769
788
|
* Only parameters whose source defines `style`, `explode`, `allowReserved`, or `contentType` are
|
|
770
789
|
* emitted, so calls without serialization metadata keep the runtime defaults and existing output
|
|
771
790
|
* is unchanged. A form request body adds a `body` group keyed by property name from its `encoding`.
|
|
@@ -788,13 +807,12 @@ function buildStyles({ node }) {
|
|
|
788
807
|
for (const parameter of node.parameters) {
|
|
789
808
|
const literal = serializeParameter(parameter);
|
|
790
809
|
if (!literal) continue;
|
|
791
|
-
groups[parameter.in].push(`${toKey(parameter.name
|
|
810
|
+
groups[parameter.in].push(`${toKey(parameter.name)}: ${literal}`);
|
|
792
811
|
}
|
|
793
812
|
const entries = [...Object.keys(groups).filter((location) => groups[location].length > 0).map((location) => `${location}: { ${groups[location].join(", ")} }`), serializeBodyEncoding(node)].filter(Boolean);
|
|
794
813
|
return entries.length > 0 ? `{ ${entries.join(", ")} }` : null;
|
|
795
814
|
}
|
|
796
|
-
|
|
797
|
-
//#region ../../internals/client/src/components/Operation.tsx
|
|
815
|
+
// ../../internals/client/src/components/Operation.tsx
|
|
798
816
|
/**
|
|
799
817
|
* Renders one client operation: the grouped `<Name>Request` type and the function that forwards a
|
|
800
818
|
* single `options` object to the resolved client and returns the `Unwrappable<RequestResult>`. The
|
|
@@ -871,8 +889,7 @@ function Operation({ name, node, types, zodResolver, validator, returnType, thro
|
|
|
871
889
|
})
|
|
872
890
|
});
|
|
873
891
|
}
|
|
874
|
-
|
|
875
|
-
//#region ../../internals/client/src/resolveOperationTypes.ts
|
|
892
|
+
// ../../internals/client/src/resolveOperationTypes.ts
|
|
876
893
|
/**
|
|
877
894
|
* A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
|
|
878
895
|
* exports next to each schema, so code written against `plugin-ts` names picks up the zod types.
|
|
@@ -938,8 +955,7 @@ function resolveOperationTypes(driver, pluginName) {
|
|
|
938
955
|
group: pluginZod.options.group ?? void 0
|
|
939
956
|
};
|
|
940
957
|
}
|
|
941
|
-
|
|
942
|
-
//#region ../../internals/client/src/generators/clientGenerator.tsx
|
|
958
|
+
// ../../internals/client/src/generators/clientGenerator.tsx
|
|
943
959
|
/**
|
|
944
960
|
* Builds the built-in per-operation generator shared by the client plugins (`@kubb/plugin-fetch`,
|
|
945
961
|
* `@kubb/plugin-axios`). Emits one async function per OpenAPI operation using the shared
|
|
@@ -966,8 +982,12 @@ function createClientGenerator(name, resolveClientPath) {
|
|
|
966
982
|
zodResolver
|
|
967
983
|
});
|
|
968
984
|
const importedZodNames = validatorHooks.importedZodNames;
|
|
985
|
+
const operationName = resolver.name(node.operationId);
|
|
969
986
|
const meta = {
|
|
970
|
-
name: resolver.
|
|
987
|
+
name: resolver.resolveName({
|
|
988
|
+
key: operationKey(node),
|
|
989
|
+
name: operationName
|
|
990
|
+
}),
|
|
971
991
|
file: resolver.file({
|
|
972
992
|
...operationFileEntry(node, node.operationId),
|
|
973
993
|
root,
|
|
@@ -1082,8 +1102,7 @@ function createClientGenerator(name, resolveClientPath) {
|
|
|
1082
1102
|
}
|
|
1083
1103
|
});
|
|
1084
1104
|
}
|
|
1085
|
-
|
|
1086
|
-
//#region ../../internals/client/src/components/SdkClient.tsx
|
|
1105
|
+
// ../../internals/client/src/components/SdkClient.tsx
|
|
1087
1106
|
/**
|
|
1088
1107
|
* Builds the call config literal forwarded to the contract client; the `throwOnError` fallback is applied after the `...config` spread.
|
|
1089
1108
|
*/
|
|
@@ -1173,8 +1192,7 @@ function SdkClient({ name, operations, returnType, throwOnErrorDefault }) {
|
|
|
1173
1192
|
children: classCode
|
|
1174
1193
|
});
|
|
1175
1194
|
}
|
|
1176
|
-
|
|
1177
|
-
//#region ../../internals/client/src/components/SdkFacade.tsx
|
|
1195
|
+
// ../../internals/client/src/components/SdkFacade.tsx
|
|
1178
1196
|
/**
|
|
1179
1197
|
* Renders a composed root SDK class that instantiates every tag client from one shared config, so
|
|
1180
1198
|
* `new PetStore({ baseURL }).petClient.getPetById(...)` reaches an operation through a single entry
|
|
@@ -1197,8 +1215,7 @@ function SdkFacade({ name, members }) {
|
|
|
1197
1215
|
children: classCode
|
|
1198
1216
|
});
|
|
1199
1217
|
}
|
|
1200
|
-
|
|
1201
|
-
//#region ../../internals/client/src/generators/sdkGenerator.tsx
|
|
1218
|
+
// ../../internals/client/src/generators/sdkGenerator.tsx
|
|
1202
1219
|
function resolveTypeImportNames(node, types) {
|
|
1203
1220
|
return [types.response.options(node), types.response.responses(node)];
|
|
1204
1221
|
}
|
|
@@ -1235,9 +1252,13 @@ function buildControllers(nodes, ctx, types) {
|
|
|
1235
1252
|
validator,
|
|
1236
1253
|
zodResolver
|
|
1237
1254
|
}) : null;
|
|
1255
|
+
const name = resolver.name(node.operationId);
|
|
1238
1256
|
return {
|
|
1239
1257
|
node,
|
|
1240
|
-
name: resolver.
|
|
1258
|
+
name: resolver.resolveName({
|
|
1259
|
+
key: operationKey(node),
|
|
1260
|
+
name
|
|
1261
|
+
}),
|
|
1241
1262
|
types,
|
|
1242
1263
|
typeFile,
|
|
1243
1264
|
zodFile,
|
|
@@ -1450,19 +1471,17 @@ function createSdkGenerator() {
|
|
|
1450
1471
|
}
|
|
1451
1472
|
});
|
|
1452
1473
|
}
|
|
1453
|
-
|
|
1454
|
-
//#region ../../internals/client/src/macros.ts
|
|
1474
|
+
// ../../internals/client/src/macros.ts
|
|
1455
1475
|
/**
|
|
1456
1476
|
* Macros the client plugins apply by default, ahead of any user macros. `macroSimplifyUnion`
|
|
1457
1477
|
* drops union members a broader scalar already covers, keeping the generated response and error
|
|
1458
1478
|
* unions tidy. A plugin wires them with `ctx.setMacros([...defaultMacros, ...userMacros])`.
|
|
1459
1479
|
*/
|
|
1460
1480
|
const defaultMacros = [macroSimplifyUnion];
|
|
1461
|
-
|
|
1462
|
-
//#region ../../internals/client/src/resolver.ts
|
|
1481
|
+
// ../../internals/client/src/resolver.ts
|
|
1463
1482
|
/**
|
|
1464
|
-
* Default resolver shared by the client plugins. Functions
|
|
1465
|
-
*
|
|
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.
|
|
1466
1485
|
*
|
|
1467
1486
|
* @example
|
|
1468
1487
|
* ```ts
|
|
@@ -1472,6 +1491,7 @@ const defaultMacros = [macroSimplifyUnion];
|
|
|
1472
1491
|
*/
|
|
1473
1492
|
const resolverClient = createResolver({
|
|
1474
1493
|
pluginName: "plugin-contract-client",
|
|
1494
|
+
name: resolveOperationName,
|
|
1475
1495
|
className(name) {
|
|
1476
1496
|
return ensureValidVarName(pascalCase(name));
|
|
1477
1497
|
},
|
|
@@ -1482,25 +1502,21 @@ const resolverClient = createResolver({
|
|
|
1482
1502
|
return ensureValidVarName(camelCase(name));
|
|
1483
1503
|
}
|
|
1484
1504
|
});
|
|
1485
|
-
|
|
1486
|
-
//#region src/generators/clientGenerator.tsx
|
|
1505
|
+
// src/generators/clientGenerator.tsx
|
|
1487
1506
|
/**
|
|
1488
1507
|
* Built-in operation generator for `@kubb/plugin-axios`. Emits one async function per OpenAPI
|
|
1489
1508
|
* operation using the shared `Operation` component: a grouped `<Name>Request` type and a function
|
|
1490
1509
|
* that forwards a single `options` object to the bundled `client` and returns the `RequestResult`.
|
|
1491
1510
|
*/
|
|
1492
1511
|
const clientGenerator = createClientGenerator("axios");
|
|
1493
|
-
|
|
1494
|
-
//#region kubb-extension.json
|
|
1512
|
+
// kubb-extension.json
|
|
1495
1513
|
var compatibility = {
|
|
1496
|
-
"kubb": ">=5.
|
|
1514
|
+
"kubb": ">=5.14.6",
|
|
1497
1515
|
"node": ">=22.22"
|
|
1498
1516
|
};
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
//#endregion
|
|
1503
|
-
//#region src/templates.ts
|
|
1517
|
+
// package.json
|
|
1518
|
+
var version = "5.10.0";
|
|
1519
|
+
// src/templates.ts
|
|
1504
1520
|
/** Absolute path to the axios client template, copied into `.kubb/client.ts`. */
|
|
1505
1521
|
const axiosClientTemplatePath = fileURLToPath(new URL("../templates/axios.ts", import.meta.url));
|
|
1506
1522
|
/** Absolute path to the axios serializers template, copied into `.kubb/serializers.ts`. */
|
|
@@ -1510,8 +1526,7 @@ const axiosSerializersTemplatePath = fileURLToPath(new URL("../templates/seriali
|
|
|
1510
1526
|
* emit the helper into the generated `.kubb/standardSchema.ts` verbatim.
|
|
1511
1527
|
*/
|
|
1512
1528
|
const standardSchemaTemplatePath = fileURLToPath(new URL("../templates/standardSchema.ts", import.meta.url));
|
|
1513
|
-
|
|
1514
|
-
//#region src/plugin.ts
|
|
1529
|
+
// src/plugin.ts
|
|
1515
1530
|
/**
|
|
1516
1531
|
* Canonical plugin name for `@kubb/plugin-axios`. Used for driver lookups and cross-plugin
|
|
1517
1532
|
* dependency references.
|
|
@@ -1596,7 +1611,6 @@ const pluginAxios = defineExtension({
|
|
|
1596
1611
|
return resolved;
|
|
1597
1612
|
}
|
|
1598
1613
|
});
|
|
1599
|
-
//#endregion
|
|
1600
1614
|
export { clientGenerator, pluginAxios as default, pluginAxios, pluginAxiosName };
|
|
1601
1615
|
|
|
1602
1616
|
//# sourceMappingURL=index.js.map
|