@kubb/plugin-client 6.0.0 → 6.0.2

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.
@@ -1,3 +1,3 @@
1
- import { $ as createClientCore, A as ResultByStatus, B as SuccessVariant, C as RequestResult, D as ResponseErrorConfig, E as ResponseError, F as StreamResult, G as Unwrappable, H as Transport, I as StreamResultWithHeaders, J as UnwrappedResultWithHeaders, K as Unwrapped, L as SuccessOf, M as SecurityRequirement, N as ServerSentEvent, O as ResponseErrorOf, P as StreamOptions, Q as Validator, R as SuccessResultUnion, S as RequestCredentials, T as ResolvedRequest, U as TransportResult, V as ToStatusNumber, W as TypedEvent, X as UnwrappedStreamResultWithHeaders, Y as UnwrappedStreamResult, Z as UrlConfig, _ as InterceptorStack, a as AuthResolver, at as resolveThrowOnError, b as ParseAs, c as ClientInstance, ct as withUnwrap, d as DataShape, dt as MediaTypes, et as createInterceptorStack, f as DecodedResponse, ft as defaultMediaTypes, g as InterceptorFn, h as EventStreamOptions, ht as resolveMediaType, i as Auth, it as resolveAuth, j as ResultUnion, k as ResponseHeaders, l as ContentType, lt as MediaType, m as ErrorOf, mt as parseJson, n as NativeRequest, nt as getHeader, o as AuthToken, ot as toRequestInit, p as EmptyErrorBody, pt as isEncodedBody, q as UnwrappedResult, r as NativeResponse, rt as isResponseError, s as ClientConfig, st as unwrapResult, t as NativeOptions, tt as createLazyClient, u as DataOf, ut as MediaTypeContext, v as Interceptors, w as RequestResultWithHeaders, x as RequestConfig, y as Options, z as SuccessStatusCode } from "../client-Dq0z61hu.js";
2
- import { a as ValidateOption, o as ValidationErrorContext, s as ValidationErrorHandler } from "../standardSchema-CGuiSK7F.js";
1
+ import { $ as createClientCore, A as ResultByStatus, B as SuccessVariant, C as RequestResult, D as ResponseErrorConfig, E as ResponseError, F as StreamResult, G as Unwrappable, H as Transport, I as StreamResultWithHeaders, J as UnwrappedResultWithHeaders, K as Unwrapped, L as SuccessOf, M as SecurityRequirement, N as ServerSentEvent, O as ResponseErrorOf, P as StreamOptions, Q as Validator, R as SuccessResultUnion, S as RequestCredentials, T as ResolvedRequest, U as TransportResult, V as ToStatusNumber, W as TypedEvent, X as UnwrappedStreamResultWithHeaders, Y as UnwrappedStreamResult, Z as UrlConfig, _ as InterceptorStack, a as AuthResolver, at as resolveThrowOnError, b as ParseAs, c as ClientInstance, ct as withUnwrap, d as DataShape, dt as MediaTypes, et as createInterceptorStack, f as DecodedResponse, ft as defaultMediaTypes, g as InterceptorFn, h as EventStreamOptions, ht as resolveMediaType, i as Auth, it as resolveAuth, j as ResultUnion, k as ResponseHeaders, l as ContentType, lt as MediaType, m as ErrorOf, mt as parseJson, n as NativeRequest, nt as getHeader, o as AuthToken, ot as toRequestInit, p as EmptyErrorBody, pt as isEncodedBody, q as UnwrappedResult, r as NativeResponse, rt as isResponseError, s as ClientConfig, st as unwrapResult, t as NativeOptions, tt as createLazyClient, u as DataOf, ut as MediaTypeContext, v as Interceptors, w as RequestResultWithHeaders, x as RequestConfig, y as Options, z as SuccessStatusCode } from "../client-C-0-puI2.js";
2
+ import { ValidateOption, ValidationErrorContext, ValidationErrorHandler } from "./standardSchema.js";
3
3
  export { type Auth, type AuthResolver, type AuthToken, type ClientConfig, type ClientInstance, type ContentType, type DataOf, type DataShape, type DecodedResponse, type EmptyErrorBody, type ErrorOf, type EventStreamOptions, type InterceptorFn, type InterceptorStack, type Interceptors, type MediaType, type MediaTypeContext, type MediaTypes, NativeOptions, NativeRequest, NativeResponse, type Options, type ParseAs, type RequestConfig, type RequestCredentials, type RequestResult, type RequestResultWithHeaders, type ResolvedRequest, type ResponseError, type ResponseErrorConfig, type ResponseErrorOf, type ResponseHeaders, type ResultByStatus, type ResultUnion, type SecurityRequirement, type ServerSentEvent, type StreamOptions, type StreamResult, type StreamResultWithHeaders, type SuccessOf, type SuccessResultUnion, type SuccessStatusCode, type SuccessVariant, type ToStatusNumber, type Transport, type TransportResult, type TypedEvent, type Unwrappable, type Unwrapped, type UnwrappedResult, type UnwrappedResultWithHeaders, type UnwrappedStreamResult, type UnwrappedStreamResultWithHeaders, type UrlConfig, type ValidateOption, type ValidationErrorContext, type ValidationErrorHandler, type Validator, type createClientCore, type createInterceptorStack, type createLazyClient, type defaultMediaTypes, type getHeader, type isEncodedBody, type isResponseError, type parseJson, type resolveAuth, type resolveMediaType, type resolveThrowOnError, type toRequestInit, type unwrapResult, type withUnwrap };
@@ -1,3 +1,3 @@
1
- import { $ as createClientCore, A as ResultByStatus, B as SuccessVariant, C as RequestResult, D as ResponseErrorConfig, E as ResponseError, F as StreamResult, G as Unwrappable, H as Transport, I as StreamResultWithHeaders, J as UnwrappedResultWithHeaders, K as Unwrapped, L as SuccessOf, M as SecurityRequirement, N as ServerSentEvent, O as ResponseErrorOf, P as StreamOptions, Q as Validator, R as SuccessResultUnion, S as RequestCredentials, T as ResolvedRequest, U as TransportResult, V as ToStatusNumber, W as TypedEvent, X as UnwrappedStreamResultWithHeaders, Y as UnwrappedStreamResult, Z as UrlConfig, _ as InterceptorStack, a as AuthResolver, at as resolveThrowOnError, b as ParseAs, c as ClientInstance, ct as withUnwrap, d as DataShape, dt as MediaTypes, et as createInterceptorStack, f as DecodedResponse, ft as defaultMediaTypes, g as InterceptorFn, h as EventStreamOptions, ht as resolveMediaType, i as Auth, it as resolveAuth, j as ResultUnion, k as ResponseHeaders, l as ContentType, lt as MediaType, m as ErrorOf, mt as parseJson, nt as getHeader, o as AuthToken, ot as toRequestInit, p as EmptyErrorBody, pt as isEncodedBody, q as UnwrappedResult, rt as isResponseError, s as ClientConfig, st as unwrapResult, tt as createLazyClient, u as DataOf, ut as MediaTypeContext, v as Interceptors, w as RequestResultWithHeaders, x as RequestConfig, y as Options, z as SuccessStatusCode } from "../client-Dq0z61hu.js";
2
- import { a as ValidateOption, o as ValidationErrorContext, s as ValidationErrorHandler } from "../standardSchema-CGuiSK7F.js";
1
+ import { $ as createClientCore, A as ResultByStatus, B as SuccessVariant, C as RequestResult, D as ResponseErrorConfig, E as ResponseError, F as StreamResult, G as Unwrappable, H as Transport, I as StreamResultWithHeaders, J as UnwrappedResultWithHeaders, K as Unwrapped, L as SuccessOf, M as SecurityRequirement, N as ServerSentEvent, O as ResponseErrorOf, P as StreamOptions, Q as Validator, R as SuccessResultUnion, S as RequestCredentials, T as ResolvedRequest, U as TransportResult, V as ToStatusNumber, W as TypedEvent, X as UnwrappedStreamResultWithHeaders, Y as UnwrappedStreamResult, Z as UrlConfig, _ as InterceptorStack, a as AuthResolver, at as resolveThrowOnError, b as ParseAs, c as ClientInstance, ct as withUnwrap, d as DataShape, dt as MediaTypes, et as createInterceptorStack, f as DecodedResponse, ft as defaultMediaTypes, g as InterceptorFn, h as EventStreamOptions, ht as resolveMediaType, i as Auth, it as resolveAuth, j as ResultUnion, k as ResponseHeaders, l as ContentType, lt as MediaType, m as ErrorOf, mt as parseJson, nt as getHeader, o as AuthToken, ot as toRequestInit, p as EmptyErrorBody, pt as isEncodedBody, q as UnwrappedResult, rt as isResponseError, s as ClientConfig, st as unwrapResult, tt as createLazyClient, u as DataOf, ut as MediaTypeContext, v as Interceptors, w as RequestResultWithHeaders, x as RequestConfig, y as Options, z as SuccessStatusCode } from "../client-C-0-puI2.js";
2
+ import { ValidateOption, ValidationErrorContext, ValidationErrorHandler } from "./standardSchema.js";
3
3
  export { Auth, AuthResolver, AuthToken, ClientConfig, ClientInstance, ContentType, DataOf, DataShape, DecodedResponse, EmptyErrorBody, ErrorOf, EventStreamOptions, InterceptorFn, InterceptorStack, Interceptors, MediaType, MediaTypeContext, MediaTypes, Options, ParseAs, RequestConfig, RequestCredentials, RequestResult, RequestResultWithHeaders, ResolvedRequest, ResponseError, ResponseErrorConfig, ResponseErrorOf, ResponseHeaders, ResultByStatus, ResultUnion, SecurityRequirement, ServerSentEvent, StreamOptions, StreamResult, StreamResultWithHeaders, SuccessOf, SuccessResultUnion, SuccessStatusCode, SuccessVariant, ToStatusNumber, Transport, TransportResult, TypedEvent, Unwrappable, Unwrapped, UnwrappedResult, UnwrappedResultWithHeaders, UnwrappedStreamResult, UnwrappedStreamResultWithHeaders, UrlConfig, type ValidateOption, type ValidationErrorContext, type ValidationErrorHandler, Validator, createClientCore, createInterceptorStack, createLazyClient, defaultMediaTypes, getHeader, isEncodedBody, isResponseError, parseJson, resolveAuth, resolveMediaType, resolveThrowOnError, toRequestInit, unwrapResult, withUnwrap };
@@ -1,4 +1,4 @@
1
- import { lt as MediaType } from "../../client-Dq0z61hu.js";
1
+ import { lt as MediaType } from "../../client-C-0-puI2.js";
2
2
  /**
3
3
  * The `multipart/form-data` handler, which follows `config.styles.body`.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { lt as MediaType } from "../../client-Dq0z61hu.js";
1
+ import { lt as MediaType } from "../../client-C-0-puI2.js";
2
2
  /**
3
3
  * The `application/x-www-form-urlencoded` handler, which follows `config.styles.body`.
4
4
  */
@@ -1,2 +1,2 @@
1
- import { dt as MediaTypes, ft as defaultMediaTypes, ht as resolveMediaType, lt as MediaType, mt as parseJson, pt as isEncodedBody, ut as MediaTypeContext } from "../client-Dq0z61hu.js";
1
+ import { dt as MediaTypes, ft as defaultMediaTypes, ht as resolveMediaType, lt as MediaType, mt as parseJson, pt as isEncodedBody, ut as MediaTypeContext } from "../client-C-0-puI2.js";
2
2
  export { MediaType, MediaTypeContext, MediaTypes, defaultMediaTypes, isEncodedBody, parseJson, resolveMediaType };
@@ -1,4 +1,4 @@
1
- import { r as CookieSerializer } from "../../serializers-BRgfPGr1.js";
1
+ import { CookieSerializer } from "../serializers.js";
2
2
  /**
3
3
  * Joins cookie parameters into a `Cookie` header value with the OpenAPI `form` style, or the `cookie` style when a parameter sets it.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { a as HeaderSerializer } from "../../serializers-BRgfPGr1.js";
1
+ import { HeaderSerializer } from "../serializers.js";
2
2
  /**
3
3
  * Serializes array and object headers with the OpenAPI `simple` style.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { d as PathSerializer } from "../../serializers-BRgfPGr1.js";
1
+ import { PathSerializer } from "../serializers.js";
2
2
  /**
3
3
  * The path serializer for the `simple` style, which `serializeStyledPath` also uses.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { d as PathSerializer } from "../../serializers-BRgfPGr1.js";
1
+ import { PathSerializer } from "../serializers.js";
2
2
  /**
3
3
  * The path serializer for the OpenAPI `label` and `matrix` styles. A `simple` parameter uses `serializePath`.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { m as QuerySerializer } from "../../serializers-BRgfPGr1.js";
1
+ import { QuerySerializer } from "../serializers.js";
2
2
  /**
3
3
  * The query serializer for a spec without styled query parameters: arrays repeat their key, objects use `form` with explode.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { m as QuerySerializer, p as QueryParamStyle } from "../../serializers-BRgfPGr1.js";
1
+ import { QueryParamStyle, QuerySerializer } from "../serializers.js";
2
2
  /**
3
3
  * One query parameter or form field with its OpenAPI style, as encoded pairs.
4
4
  */
@@ -1,2 +1,118 @@
1
- import { C as isRecord, D as toValue, E as serializeDefaultQueryParam, S as isJsonMediaType, T as notNullish, _ as SerializationStyle, a as HeaderSerializer, b as baseContentType, c as HttpMethod, d as PathSerializer, f as PathStyle, g as RequestBody, h as QueryStyle, i as HeaderParamStyle, l as ParamContentType, m as QuerySerializer, n as CookieParamStyle, o as HeaderValue, p as QueryParamStyle, r as CookieSerializer, s as HeadersInit, t as BodyEncoding, u as PathParamStyle, v as Serializers, w as jsonReplacer, x as encodeComponent, y as Styles } from "../serializers-BRgfPGr1.js";
2
- export { BodyEncoding, CookieParamStyle, CookieSerializer, HeaderParamStyle, HeaderSerializer, HeaderValue, HeadersInit, HttpMethod, ParamContentType, PathParamStyle, PathSerializer, PathStyle, QueryParamStyle, QuerySerializer, QueryStyle, RequestBody, SerializationStyle, Serializers, Styles, baseContentType, encodeComponent, isJsonMediaType, isRecord, jsonReplacer, notNullish, serializeDefaultQueryParam, toValue };
1
+ export type HeaderValue = string | number | boolean | null | undefined | object;
2
+ export type HeadersInit = Array<[string, HeaderValue]> | Record<string, HeaderValue>;
3
+ /**
4
+ * A body `fetch` accepts, read from `RequestInit` so a project without the `dom` lib still has it.
5
+ */
6
+ export type RequestBody = NonNullable<RequestInit['body']>;
7
+ export type HttpMethod = 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'QUERY' | 'TRACE' | (string & {});
8
+ /**
9
+ * The OpenAPI query style. `form` is the default.
10
+ */
11
+ export type QueryStyle = 'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
12
+ export type SerializationStyle<TStyle = string> = {
13
+ style?: TStyle;
14
+ explode?: boolean;
15
+ allowReserved?: boolean;
16
+ };
17
+ /**
18
+ * The media type of a parameter described with `content`. JSON sends one JSON-encoded value.
19
+ */
20
+ export type ParamContentType = {
21
+ contentType?: string;
22
+ };
23
+ /**
24
+ * `querystring` marks an OpenAPI 3.2 `in: querystring` parameter, sent as the whole query string.
25
+ */
26
+ export type QueryParamStyle = SerializationStyle<QueryStyle> & ParamContentType & {
27
+ querystring?: boolean;
28
+ };
29
+ /**
30
+ * Turns the query object into a search string, following each parameter's OpenAPI style when given.
31
+ */
32
+ export type QuerySerializer = (params: Record<string, unknown>, options?: Record<string, QueryParamStyle>) => string;
33
+ /**
34
+ * `cookie` is the OpenAPI 3.2 style that sends values as they are, without percent-encoding (RFC 6265). `form` is the default.
35
+ */
36
+ export type CookieParamStyle = ParamContentType & {
37
+ style?: 'form' | 'cookie';
38
+ explode?: boolean;
39
+ };
40
+ export type HeaderParamStyle = ParamContentType & {
41
+ explode?: boolean;
42
+ };
43
+ /**
44
+ * The OpenAPI `encoding` of one form body property. `contentType` sets a multipart part's media type.
45
+ */
46
+ export type BodyEncoding = SerializationStyle<QueryStyle> & {
47
+ contentType?: string;
48
+ };
49
+ /**
50
+ * The OpenAPI path style. `simple` is the default.
51
+ */
52
+ export type PathStyle = 'simple' | 'label' | 'matrix';
53
+ export type PathParamStyle = SerializationStyle<PathStyle>;
54
+ /**
55
+ * Joins the cookie parameters of a call into a `Cookie` header value.
56
+ */
57
+ export type CookieSerializer = (cookies: Record<string, unknown>, styles?: Record<string, CookieParamStyle>) => string;
58
+ /**
59
+ * Serializes the header parameters of a call that are arrays or objects.
60
+ */
61
+ export type HeaderSerializer = (headers: HeadersInit | undefined, styles?: Record<string, HeaderParamStyle>) => HeadersInit | undefined;
62
+ /**
63
+ * Turns one path parameter into its URL segment.
64
+ */
65
+ export type PathSerializer = (args: {
66
+ name: string;
67
+ value: unknown;
68
+ options?: PathParamStyle | undefined;
69
+ }) => string;
70
+ /**
71
+ * Parameter serializers, set per client or per call. `.kubb/client.ts` registers the ones the spec needs. Bodies are
72
+ * encoded by `mediaTypes`.
73
+ */
74
+ export type Serializers = {
75
+ query?: QuerySerializer;
76
+ path?: PathSerializer;
77
+ /**
78
+ * Turns array and object header values into strings. Without one, such a value is sent as JSON.
79
+ */
80
+ header?: HeaderSerializer;
81
+ /**
82
+ * Sends the `cookies` of a call. Kubb registers `serializeCookies` when the spec has a cookie parameter.
83
+ */
84
+ cookie?: CookieSerializer;
85
+ };
86
+ /**
87
+ * The OpenAPI styles of a generated call's parameters, by location and name. `body` holds the form `encoding`.
88
+ */
89
+ export type Styles = {
90
+ path?: Record<string, PathParamStyle>;
91
+ query?: Record<string, QueryParamStyle>;
92
+ header?: Record<string, HeaderParamStyle>;
93
+ cookie?: Record<string, CookieParamStyle>;
94
+ body?: Record<string, BodyEncoding>;
95
+ };
96
+ /**
97
+ * Sends a `bigint` as a JSON number, and throws past the safe-integer range instead of losing precision.
98
+ */
99
+ export declare function jsonReplacer(_key: string, value: unknown): unknown;
100
+ /**
101
+ * A `Content-Type` without its parameters, in lower case.
102
+ */
103
+ export declare function baseContentType(value: string | null | undefined): string | undefined;
104
+ /**
105
+ * Whether a media type is JSON, such as `application/json` or `application/problem+json`.
106
+ */
107
+ export declare function isJsonMediaType(contentType: string | null | undefined): boolean;
108
+ export declare function notNullish(value: unknown): boolean;
109
+ /**
110
+ * Renders a parameter value as a string. A `Date` becomes ISO-8601, so it does not depend on the locale.
111
+ */
112
+ export declare function toValue(value: unknown): string;
113
+ export declare function encodeComponent(value: unknown): string;
114
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
115
+ /**
116
+ * One parameter as form pairs, with an array repeating its key and an object as `key[prop]`.
117
+ */
118
+ export declare function serializeDefaultQueryParam(key: string, value: unknown): Array<string>;
@@ -1,4 +1,4 @@
1
- import { N as ServerSentEvent, dt as MediaTypes, h as EventStreamOptions, lt as MediaType } from "../client-Dq0z61hu.js";
1
+ import { N as ServerSentEvent, dt as MediaTypes, h as EventStreamOptions, lt as MediaType } from "../client-C-0-puI2.js";
2
2
  type Cursor = {
3
3
  lastEventId: string;
4
4
  };
@@ -1,2 +1,81 @@
1
- import { a as ValidateOption, c as isValidationEnabled, d as validateStandardSchema, i as StandardSchemaValidator, l as runValidator, n as StandardSchemaIssue, o as ValidationErrorContext, r as StandardSchemaResult, s as ValidationErrorHandler, t as ParseError, u as toHeadersStandardSchema } from "../standardSchema-CGuiSK7F.js";
2
- export { ParseError, StandardSchemaIssue, StandardSchemaResult, StandardSchemaValidator, ValidateOption, ValidationErrorContext, ValidationErrorHandler, isValidationEnabled, runValidator, toHeadersStandardSchema, validateStandardSchema };
1
+ /**
2
+ * A Standard Schema validator, such as a Zod, Valibot, or ArkType schema.
3
+ */
4
+ export type StandardSchemaValidator<TOutput = unknown> = {
5
+ readonly '~standard': {
6
+ validate(value: unknown): StandardSchemaResult<TOutput> | Promise<StandardSchemaResult<TOutput>>;
7
+ };
8
+ };
9
+ export type StandardSchemaResult<TOutput> = {
10
+ readonly value: TOutput;
11
+ readonly issues?: undefined;
12
+ } | {
13
+ readonly issues: ReadonlyArray<StandardSchemaIssue>;
14
+ };
15
+ export type StandardSchemaIssue = {
16
+ readonly message?: string;
17
+ readonly path?: ReadonlyArray<PropertyKey | {
18
+ readonly key: PropertyKey;
19
+ }> | undefined;
20
+ };
21
+ /**
22
+ * Thrown when validation fails, with the schema's `issues`.
23
+ */
24
+ export declare class ParseError extends Error {
25
+ readonly issues: ReadonlyArray<StandardSchemaIssue>;
26
+ readonly cause?: unknown;
27
+ constructor({ issues, message, cause }: {
28
+ issues: ReadonlyArray<StandardSchemaIssue>;
29
+ message?: string;
30
+ cause?: unknown;
31
+ });
32
+ }
33
+ /**
34
+ * Returns the parsed value, or throws a `ParseError` with the schema's `issues`.
35
+ */
36
+ export declare function validateStandardSchema<TOutput>(schema: StandardSchemaValidator<TOutput>, value: unknown): Promise<TOutput>;
37
+ /**
38
+ * Wraps an object schema so its keys match in any letter case. `entries` are the keys the schema declares.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * validator: { headers: toHeadersStandardSchema(putEventHeadersSchema, putEventHeadersSchema.shape) }
43
+ * ```
44
+ */
45
+ export declare function toHeadersStandardSchema(schema: StandardSchemaValidator, entries: Record<string, unknown>): StandardSchemaValidator;
46
+ /**
47
+ * Which value and request failed validation.
48
+ */
49
+ export type ValidationErrorContext = {
50
+ value: unknown;
51
+ direction: 'request' | 'response' | 'error';
52
+ source: 'body' | 'path' | 'query' | 'headers' | 'cookies';
53
+ method?: string | undefined;
54
+ url?: string | undefined;
55
+ status?: number | undefined;
56
+ };
57
+ /**
58
+ * Return `{ value }` to use instead of a failed value. Return nothing to rethrow the `ParseError`.
59
+ */
60
+ export type ValidationErrorHandler = (error: ParseError, context: ValidationErrorContext) => {
61
+ value: unknown;
62
+ } | void | Promise<{
63
+ value: unknown;
64
+ } | void>;
65
+ /**
66
+ * Turns generated validation on or off, for every direction or per direction.
67
+ * @default true
68
+ */
69
+ export type ValidateOption = boolean | {
70
+ request?: boolean;
71
+ params?: boolean;
72
+ response?: boolean;
73
+ error?: boolean;
74
+ };
75
+ export declare function isValidationEnabled(validate: ValidateOption | undefined, direction: 'request' | 'params' | 'response' | 'error'): boolean;
76
+ export declare function runValidator<T>({ validator, value, context, onValidationError }: {
77
+ validator: StandardSchemaValidator<T> | undefined;
78
+ value: T;
79
+ context: Omit<ValidationErrorContext, 'value'>;
80
+ onValidationError: ValidationErrorHandler | undefined;
81
+ }): Promise<T>;
@@ -62,7 +62,7 @@ setAuth(async () => readTokenFromSecretsStore())
62
62
 
63
63
  ## Sign requests or use several auth methods
64
64
 
65
- Read `config.security` and pick per operation, or pass a different `client` on a call. This works for request signing, such as AWS SigV4, and for services that use different credentials:
65
+ Read `config.security` and pick per operation, or pass a different `client` on a call. Both ways work for request signing, such as AWS SigV4, and for services that use different credentials:
66
66
 
67
67
  ```typescript
68
68
  import { createSignedClient } from './clients/iam'
@@ -70,4 +70,6 @@ import { createSignedClient } from './clients/iam'
70
70
  await getPetById({ path: { petId: 1 }, client: createSignedClient() })
71
71
  ```
72
72
 
73
+ The examples set [`integerType: 'number'`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#integertype) on the adapter, so an `int64` id such as `petId` is a `number`. With the default it is a `bigint` and the call takes `1n`.
74
+
73
75
  A client passed on a call replaces the default for that call only.
@@ -8,20 +8,24 @@ import { addPet, getPetById } from './gen/clients'
8
8
  const created = await addPet({ body: { name: 'Odie', photoUrls: [] } })
9
9
  console.log(created.data, created.response.status)
10
10
 
11
- const pet = await getPetById({ path: { petId: 1n } })
11
+ const pet = await getPetById({ path: { petId: 1 } })
12
12
  ```
13
13
 
14
- The keys are `path`, `query`, `headers`, and `body`. Kubb types each from the spec, so a wrong key or value fails at compile time.
14
+ The examples set [`integerType: 'number'`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#integertype) on the adapter, so an `int64` id such as `petId` is a `number`. With the default it is a `bigint` and the call takes `1n`.
15
+
16
+ Path keys keep the names from the spec, so a `{pet-id}` placeholder is passed as `path: { 'pet-id': 1 }`. Set [`pathParamsCasing: 'camelcase'`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#pathparamscasing) on the adapter (`@kubb/adapter-oas` 5.20.0 or later) to pass `path: { petId: 1 }` instead, the name MSW handlers and query keys already use. The HTTP request stays the same.
17
+
18
+ The keys are `path`, `query`, `headers`, `cookies`, and `body`. Kubb types each from the spec, so a wrong key or value fails at compile time.
15
19
 
16
20
  ## Errors
17
21
 
18
- `throwOnError` defaults to `true` (see [`throwOnErrorDefault`](https://kubb.dev/extensions/kubb-labs/plugin-client/options#throwonerrordefault)). What that means is up to your client. With the example client, a non-2xx status throws, and `throwOnError: false` returns the error as a value:
22
+ `throwOnError` defaults to `true` (see [`throwOnErrorDefault`](https://kubb.dev/extensions/kubb-labs/plugin-client/options#throwonerrordefault)). What that means is up to your client. With the [minimal client](https://kubb.dev/extensions/kubb-labs/plugin-client/guides/write-your-client#a-minimal-client), a non-2xx status throws, and `throwOnError: false` returns the error as a value:
19
23
 
20
24
  ```typescript
21
- const result = await getPetById({ path: { petId: 1n }, throwOnError: false })
25
+ const result = await getPetById({ path: { petId: 1 }, throwOnError: false })
22
26
 
23
27
  if (result.error === undefined) {
24
- console.log('pet', result.data.name)
28
+ console.log('pet', result.data)
25
29
  }
26
30
  if (result.error !== undefined) {
27
31
  console.log('failed', result.response.status)
@@ -33,5 +37,5 @@ if (result.error !== undefined) {
33
37
  Pass `client` to send one call through another function:
34
38
 
35
39
  ```typescript
36
- await getPetById({ path: { petId: 2n }, client: tenantClient })
40
+ await getPetById({ path: { petId: 2 }, client: tenantClient })
37
41
  ```
@@ -26,7 +26,7 @@ export default defineConfig({
26
26
  Each generated call now includes the schemas:
27
27
 
28
28
  ```typescript
29
- request({
29
+ apiClient<AddPetResponses, ThrowOnError>({
30
30
  method: 'POST',
31
31
  url: '/pet',
32
32
  ...config,
@@ -61,10 +61,10 @@ Set `validator: { request: 'zod' }` or `{ response: 'zod' }` to pass one directi
61
61
 
62
62
  ## Validate params
63
63
 
64
- With `validator: { params: 'zod' }`, each call also passes the schemas for its path, query, and header params:
64
+ With `validator: { params: 'zod' }`, each call also passes the schemas for its path, query, header, and cookie params:
65
65
 
66
66
  ```typescript
67
- request({
67
+ apiClient<PutEventResponses, ThrowOnError>({
68
68
  method: 'PUT',
69
69
  url: '/events/{day}',
70
70
  ...config,
@@ -77,8 +77,8 @@ request({
77
77
  })
78
78
  ```
79
79
 
80
- Add `path`, `query`, and `headers` to the `validator` field of your `RequestConfig`. Run them on `config.path`, `config.query`, and `config.headers` before you build the URL and headers, and send the values they return.
80
+ Add `path`, `query`, `headers`, and `cookies` to the `validator` field of your `RequestConfig`. Run them on `config.path`, `config.query`, `config.headers`, and `config.cookies` before you build the URL and headers, and send the values they return.
81
81
 
82
82
  The path and query schemas strip keys the spec does not declare, so only declared params are sent. Headers your client adds itself, such as `Authorization`, are not declared, so the headers schema passes undeclared keys through.
83
83
 
84
- The generated call imports `toHeadersStandardSchema` from your `importPath` module, so that module must export it, or the generated code does not compile. It takes a Standard Schema and the object's declared keys, and returns a Standard Schema that matches the declared headers in any casing and passes undeclared headers through. Copy it from the `.kubb/standardSchema.ts` file that `@kubb/plugin-fetch` generates. Returning the schema unchanged is not enough: the plain object schema strips undeclared headers such as `Authorization`.
84
+ The generated call imports `toHeadersStandardSchema` from your `importPath` module, so that module must export it, or the generated code does not compile. `toHeadersStandardSchema` takes a Standard Schema and the object's declared keys, and returns a Standard Schema that matches the declared headers in any casing and passes undeclared headers through. Copy it from the `.kubb/standardSchema.ts` file that `@kubb/plugin-fetch` generates. Returning the schema unchanged is not enough: the plain object schema strips undeclared headers such as `Authorization`.
@@ -44,7 +44,7 @@ To reuse the runtime of the fetch and axios clients instead of writing your own
44
44
 
45
45
  ```typescript
46
46
  import type { Options, RequestResult } from '../../../client'
47
- import type { GetPetByIdOptions, GetPetByIdResponses } from '../../models/pet/GetPetById'
47
+ import type { GetPetByIdOptions, GetPetByIdResponses } from '../../types/GetPetById'
48
48
  import { client } from '../../../client'
49
49
 
50
50
  export function getPetById<ThrowOnError extends boolean = true>(
package/docs/options.md CHANGED
@@ -71,6 +71,8 @@ pluginClient({ importPath: '../../client', returnType: 'full' })
71
71
  // const pet = await getPetById({ path: { petId: 1 } }).unwrap()
72
72
  ```
73
73
 
74
+ The examples set [`integerType: 'number'`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#integertype) on the adapter, so an `int64` id such as `petId` is a `number`. With the default it is a `bigint` and the call takes `1n`.
75
+
74
76
  The setting applies to the whole plugin, so you cannot set it in `override`.
75
77
 
76
78
  ### validator
@@ -94,7 +96,7 @@ Passes the response and error schemas.
94
96
  :::
95
97
 
96
98
  :::field{name="{ request?: 'zod', params?: 'zod', response?: 'zod' }"}
97
- Opts in per direction. `request` passes the request body schema, `params` the path, query, and header params schemas, and `response` the response and error schemas.
99
+ Opts in per direction. `request` passes the request body schema, `params` the path, query, header, and cookie params schemas, and `response` the response and error schemas.
98
100
  :::
99
101
 
100
102
  ::
package/docs/overview.md CHANGED
@@ -24,12 +24,14 @@ The config below groups the generated functions by tag and points them at the cl
24
24
 
25
25
  ```typescript [kubb.config.ts]
26
26
  import { defineConfig } from 'kubb/config'
27
+ import { adapterOas } from '@kubb/adapter-oas'
27
28
  import { pluginTs } from '@kubb/plugin-ts'
28
29
  import { pluginClient } from '@kubb/plugin-client'
29
30
 
30
31
  export default defineConfig({
31
32
  input: './petStore.yaml',
32
33
  output: { path: './src/gen' },
34
+ adapter: adapterOas({ integerType: 'number' }),
33
35
  plugins: [
34
36
  pluginTs(),
35
37
  pluginClient({
@@ -17,8 +17,7 @@
17
17
  "github": "stijnvanhulle"
18
18
  }
19
19
  ],
20
- "dependencies": ["plugin-ts"],
21
- "optionalDependencies": ["plugin-zod"],
20
+ "optionalDependencies": ["plugin-ts", "plugin-zod"],
22
21
  "compatibility": {
23
22
  "kubb": ">=5.18.4",
24
23
  "node": ">=22.22"
@@ -165,6 +164,25 @@
165
164
  "pattern": "$item"
166
165
  }
167
166
  },
167
+ {
168
+ "key": "returnType",
169
+ "path": ["returnType"],
170
+ "label": "Return Type",
171
+ "description": "What a generated function resolves to. plain is what your client returns, full is the whole result with status and error, and data is only the success body when it throws. full and data need the unwrap helpers exported from your client module",
172
+ "type": "select",
173
+ "default": "plain",
174
+ "choices": [
175
+ {
176
+ "value": "plain"
177
+ },
178
+ {
179
+ "value": "full"
180
+ },
181
+ {
182
+ "value": "data"
183
+ }
184
+ ]
185
+ },
168
186
  {
169
187
  "key": "throwOnErrorDefault",
170
188
  "path": ["throwOnErrorDefault"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "6.0.0",
3
+ "version": "6.0.2",
4
4
  "description": "Generate typed API operations against your own client module.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -61,10 +61,10 @@
61
61
  "registry": "https://registry.npmjs.org/"
62
62
  },
63
63
  "dependencies": {
64
- "@kubb/kit": "^5.18.6",
65
- "@kubb/plugin-ts": "^5.5.0",
66
- "@kubb/plugin-zod": "^5.9.0",
67
- "@kubb/renderer-jsx": "^5.18.6"
64
+ "@kubb/kit": "^5.19.0",
65
+ "@kubb/plugin-ts": "^5.5.2",
66
+ "@kubb/plugin-zod": "^5.9.2",
67
+ "@kubb/renderer-jsx": "^5.19.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@internals/client": "0.0.0",
@@ -84,9 +84,9 @@ export type ClientOptions = OutputOptions & {
84
84
  validator?: ValidatorOptions
85
85
  /**
86
86
  * Shape of the value a generated operation function resolves to. Applies to the standalone
87
- * functions and the class-based SDK; not to the query-hook plugins (`@kubb/plugin-react-query`,
88
- * `@kubb/plugin-vue-query`, `@kubb/plugin-swr`), which keep calling the client directly and
89
- * expect the full result.
87
+ * functions and the class-based SDK. The query-hook plugins (`@kubb/plugin-react-query`,
88
+ * `@kubb/plugin-vue-query`, `@kubb/plugin-swr`) and `@kubb/plugin-mcp` read it to unwrap the
89
+ * call they make, and their own `returnType` sets what a hook resolves to.
90
90
  *
91
91
  * @default 'full'
92
92
  * @example
@@ -2,7 +2,7 @@ import path from 'node:path'
2
2
  import { type OperationTypeSource, resolveOperationTypes, resultTypeName } from '@internals/client'
3
3
  import { isEventStream } from '@internals/shared'
4
4
  import { ensureValidVarName } from '@internals/utils'
5
- import { ast, defineGenerator, Diagnostics } from '@kubb/kit'
5
+ import { ast, defineGenerator, Diagnostics, memo } from '@kubb/kit'
6
6
  import type { Generator } from '@kubb/kit'
7
7
  import { File, jsxRenderer } from '@kubb/renderer-jsx'
8
8
  import { type GeneratorContext, type OperationData, resolveOperationData } from '../builders/operationData.ts'
@@ -55,8 +55,7 @@ function collectImportsByFile(ops: Array<OperationData>, pick: (op: OperationDat
55
55
  ops.forEach((op) => {
56
56
  const { file, names } = pick(op)
57
57
  if (!file || names.length === 0) return
58
- if (!namesByPath.has(file.path)) namesByPath.set(file.path, new Set())
59
- const set = namesByPath.get(file.path)!
58
+ const set = memo(namesByPath, file.path, () => new Set<string>())
60
59
  names.forEach((n) => set.add(n))
61
60
  filesByPath.set(file.path, file)
62
61
  })