@kubb/plugin-client 5.10.0-canary.20261105T162357 → 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.
@@ -0,0 +1,190 @@
1
+ type HeaderValue = string | number | boolean | null | undefined | object;
2
+ type HeadersInit = Array<[string, HeaderValue]> | Record<string, HeaderValue>;
3
+ /**
4
+ * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit`
5
+ * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare.
6
+ */
7
+ type RequestBody = NonNullable<RequestInit['body']>;
8
+ type HttpMethod = 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'QUERY';
9
+ /**
10
+ * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and
11
+ * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as
12
+ * `key[prop]=value`.
13
+ */
14
+ type QueryStyle = 'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
15
+ /**
16
+ * The serialization metadata shared by the styled parameter locations: the OpenAPI `style` (typed per
17
+ * location through `TStyle`), `explode`, and `allowReserved` (keeps RFC 3986 reserved characters
18
+ * unencoded, used by query and request bodies).
19
+ */
20
+ type SerializationStyle<TStyle = string> = {
21
+ style?: TStyle;
22
+ explode?: boolean;
23
+ allowReserved?: boolean;
24
+ };
25
+ /** The media type of a parameter described with `content`; JSON sends one JSON-encoded value. */
26
+ type ParamContentType = {
27
+ contentType?: string;
28
+ };
29
+ /**
30
+ * The per-parameter query serialization metadata carried by the generated request. `querystring` marks an OpenAPI 3.2
31
+ * `in: querystring` parameter, whose JSON value is the whole query string, sent without its name.
32
+ */
33
+ type QueryParamStyle = SerializationStyle<QueryStyle> & ParamContentType & {
34
+ querystring?: boolean;
35
+ };
36
+ /**
37
+ * Serializes the query object into a search string. The optional second argument carries the
38
+ * per-parameter OpenAPI `style` / `explode` / `allowReserved` metadata; without it arrays explode
39
+ * into repeated keys and nested objects use the `deepObject` style.
40
+ */
41
+ type QuerySerializer = (params: Record<string, unknown>, options?: Record<string, QueryParamStyle>) => string;
42
+ /**
43
+ * The per-parameter cookie serialization metadata carried by the generated request. Cookies use the
44
+ * OpenAPI `form` style, so only `explode` is configurable.
45
+ */
46
+ type CookieParamStyle = ParamContentType & {
47
+ explode?: boolean;
48
+ };
49
+ /**
50
+ * The per-parameter header serialization metadata carried by the generated request. Headers use the
51
+ * OpenAPI `simple` style, so only `explode` is configurable.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * // styles.header: { 'X-Ids': { explode: false } }, header [3, 4] -> 'X-Ids: 3,4'
56
+ * // styles.header: { 'X-Filter': { explode: true } }, header { role: 'admin' } -> 'X-Filter: role=admin'
57
+ * ```
58
+ */
59
+ type HeaderParamStyle = ParamContentType & {
60
+ explode?: boolean;
61
+ };
62
+ /**
63
+ * The per-property `encoding` metadata for an `application/x-www-form-urlencoded` or
64
+ * `multipart/form-data` request body. `contentType` overrides the part's media type; `style` /
65
+ * `explode` / `allowReserved` follow the OpenAPI query rules for urlencoded bodies.
66
+ */
67
+ type BodyEncoding = SerializationStyle<QueryStyle> & {
68
+ contentType?: string;
69
+ };
70
+ /**
71
+ * Serializes the request body. JSON by default; `FormData`, `URLSearchParams`, `Blob`,
72
+ * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries
73
+ * the per-property OpenAPI `encoding` metadata for form bodies.
74
+ */
75
+ type BodySerializer = (args: {
76
+ body: unknown;
77
+ contentType?: string;
78
+ encoding?: Record<string, BodyEncoding>;
79
+ }) => RequestBody | undefined;
80
+ /**
81
+ * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value;
82
+ * `label` prefixes a `.` and `matrix` prefixes a `;name=` segment.
83
+ */
84
+ type PathStyle = 'simple' | 'label' | 'matrix';
85
+ /**
86
+ * The per-parameter serialization metadata carried by the generated request. `style` selects the
87
+ * OpenAPI style and `explode` controls how arrays and objects expand.
88
+ */
89
+ type PathParamStyle = SerializationStyle<PathStyle>;
90
+ /**
91
+ * Serializes a single path parameter for interpolation into the URL, honoring the OpenAPI `style` /
92
+ * `explode` passed as `options`. Defaults to `simple` style with `explode: false`: primitives are
93
+ * URL-encoded, arrays join their members with commas, and objects flatten to `key,value` pairs.
94
+ */
95
+ type PathSerializer = (args: {
96
+ name: string;
97
+ value: unknown;
98
+ options?: PathParamStyle;
99
+ }) => string;
100
+ /**
101
+ * The per-concern serializers, grouped so they can be set in one place and overridden per client or
102
+ * per call. Each field falls back to the matching `default*Serializer` when omitted.
103
+ */
104
+ type Serializers = {
105
+ query?: QuerySerializer;
106
+ body?: BodySerializer;
107
+ path?: PathSerializer;
108
+ };
109
+ /**
110
+ * The per-parameter OpenAPI `style` / `explode` metadata a generated request carries, grouped by
111
+ * location and keyed by parameter name. Mirrors the `serializer` grouping and feeds the default
112
+ * serializers; `body` carries the form `encoding` for a urlencoded or multipart body.
113
+ */
114
+ type Styles = {
115
+ path?: Record<string, PathParamStyle>;
116
+ query?: Record<string, QueryParamStyle>;
117
+ header?: Record<string, HeaderParamStyle>;
118
+ cookie?: Record<string, CookieParamStyle>;
119
+ body?: Record<string, BodyEncoding>;
120
+ };
121
+ declare function isDefaultJsonBody(body: unknown): boolean;
122
+ /**
123
+ * Default body serializer: passes binary/form bodies through and JSON-serializes everything else.
124
+ * For `multipart/form-data` plain objects become `FormData` and for
125
+ * `application/x-www-form-urlencoded` they become `URLSearchParams`. When `encoding` is supplied each
126
+ * urlencoded property follows its OpenAPI `style` / `explode` / `allowReserved`.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * defaultBodySerializer({ body: { name: 'odie' } }) // '{"name":"odie"}'
131
+ * defaultBodySerializer({ body: { field: 'x' }, contentType: 'multipart/form-data' }) // FormData
132
+ * defaultBodySerializer({ body: { tags: ['a', 'b'] }, contentType: 'application/x-www-form-urlencoded', encoding: { tags: { explode: false } } }) // 'tags=a,b'
133
+ * defaultBodySerializer({ body: { meta: { a: 1 } }, contentType: 'multipart/form-data', encoding: { meta: { contentType: 'application/json' } } }) // FormData with a typed Blob part
134
+ * ```
135
+ */
136
+ declare const defaultBodySerializer: BodySerializer;
137
+ /**
138
+ * The media type of a `Content-Type` value without its parameters, in lower case: `application/json; charset=utf-8` gives `application/json`.
139
+ */
140
+ declare function baseContentType(value: string | null | undefined): string | undefined;
141
+ /** Whether a content type carries JSON: `application/json`, `text/json`, or a `+json` suffix. */
142
+ declare function isJsonMediaType(contentType: string | null | undefined): boolean;
143
+ /**
144
+ * Serializes cookie parameters into a `Cookie` header value using the OpenAPI `form` style, joined
145
+ * with `; `. Values are URL-encoded and `explode` is honored per parameter.
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * serializeCookies({ session: 'abc', ids: [1, 2] }) // 'session=abc; ids=1,2'
150
+ * serializeCookies({ ids: [1, 2] }, { ids: { explode: true } }) // 'ids=1; ids=2'
151
+ * ```
152
+ */
153
+ declare function serializeCookies(cookies: Record<string, unknown>, styles?: Record<string, CookieParamStyle>): string;
154
+ /**
155
+ * Default query serializer. Members with `options` metadata follow their OpenAPI `style` / `explode`
156
+ * / `allowReserved`. Members without it keep the defaults: arrays explode into repeated keys and
157
+ * nested objects use the `deepObject` style (`key[prop]=value`).
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * defaultQuerySerializer({ id: [3, 4, 5] }) // 'id=3&id=4&id=5'
162
+ * defaultQuerySerializer({ id: [3, 4, 5] }, { id: { style: 'form', explode: false } }) // 'id=3,4,5'
163
+ * defaultQuerySerializer({ id: [3, 4, 5] }, { id: { style: 'spaceDelimited', explode: false } }) // 'id=3%204%205'
164
+ * defaultQuerySerializer({ id: [3, 4, 5] }, { id: { style: 'pipeDelimited', explode: false } }) // 'id=3|4|5'
165
+ * defaultQuerySerializer({ a: { b: 1 } }, { a: { style: 'deepObject' } }) // 'a%5Bb%5D=1'
166
+ * defaultQuerySerializer({ a: { b: { c: 1 } } }, { a: { style: 'deepObject' } }) // 'a%5Bb%5D%5Bc%5D=1'
167
+ * ```
168
+ */
169
+ declare const defaultQuerySerializer: QuerySerializer;
170
+ /**
171
+ * Default path serializer honoring the OpenAPI `style` / `explode` metadata. Without metadata it
172
+ * falls back to `simple` style with `explode: false`. Replaces the previous `String(value)`
173
+ * interpolation, which emitted `[object Object]` for object path params.
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * defaultPathSerializer({ name: 'id', value: [3, 4, 5] }) // '3,4,5'
178
+ * defaultPathSerializer({ name: 'id', value: [3, 4, 5], options: { style: 'label', explode: true } }) // '.3.4.5'
179
+ * defaultPathSerializer({ name: 'id', value: [3, 4, 5], options: { style: 'matrix', explode: true } }) // ';id=3;id=4;id=5'
180
+ * defaultPathSerializer({ name: 'pt', value: { x: 1, y: 2 } }) // 'x,1,y,2'
181
+ * ```
182
+ */
183
+ declare const defaultPathSerializer: PathSerializer;
184
+ /**
185
+ * Serializes array and object header parameters with the OpenAPI `simple` style before they are
186
+ * merged. Header values are not URL-encoded. Primitive values and headers without metadata pass
187
+ * through untouched.
188
+ */
189
+ declare function applyHeaderStyles(headers: HeadersInit | undefined, styles: Record<string, HeaderParamStyle> | undefined): HeadersInit | undefined;
190
+ export { defaultQuerySerializer as C, serializeCookies as E, defaultPathSerializer as S, isJsonMediaType as T, Serializers as _, HeaderValue as a, baseContentType as b, ParamContentType as c, PathStyle as d, QueryParamStyle as f, SerializationStyle as g, RequestBody as h, HeaderParamStyle as i, PathParamStyle as l, QueryStyle as m, BodySerializer as n, HeadersInit as o, QuerySerializer as p, CookieParamStyle as r, HttpMethod as s, BodyEncoding as t, PathSerializer as u, Styles as v, isDefaultJsonBody as w, defaultBodySerializer as x, applyHeaderStyles as y };
@@ -0,0 +1,104 @@
1
+ /**
2
+ * A Standard Schema-compatible validator: a minimal duck-type covering Zod v3/v4, valibot, and
3
+ * arktype schemas. Only the `~standard.validate` method is required at runtime.
4
+ */
5
+ type StandardSchemaValidator<TOutput = unknown> = {
6
+ readonly '~standard': {
7
+ validate(value: unknown): StandardSchemaResult<TOutput> | Promise<StandardSchemaResult<TOutput>>;
8
+ };
9
+ };
10
+ /**
11
+ * The two possible outcomes of a Standard Schema `validate` call. A successful result carries
12
+ * `value`; a failed result carries `issues`.
13
+ */
14
+ type StandardSchemaResult<TOutput> = {
15
+ readonly value: TOutput;
16
+ readonly issues?: undefined;
17
+ } | {
18
+ readonly issues: ReadonlyArray<StandardSchemaIssue>;
19
+ };
20
+ /**
21
+ * One validation issue from a Standard Schema `validate` call.
22
+ */
23
+ type StandardSchemaIssue = {
24
+ readonly message?: string;
25
+ readonly path?: ReadonlyArray<PropertyKey | {
26
+ readonly key: PropertyKey;
27
+ }>;
28
+ };
29
+ /**
30
+ * Thrown by `validateStandardSchema` when validation fails. Carries the raw `issues` array from
31
+ * the schema's `validate` result so callers receive a uniform error shape regardless of which
32
+ * schema library is in use.
33
+ */
34
+ declare class ParseError extends Error {
35
+ readonly issues: ReadonlyArray<StandardSchemaIssue>;
36
+ constructor({ issues, message }: {
37
+ issues: ReadonlyArray<StandardSchemaIssue>;
38
+ message?: string;
39
+ });
40
+ }
41
+ /**
42
+ * Validates `value` against a Standard Schema-compatible `schema`. Returns the parsed output on
43
+ * success; throws `ParseError` with the schema's `issues` on failure. Handles both sync and async
44
+ * `validate` implementations transparently.
45
+ *
46
+ * @example
47
+ * const pet = await validateStandardSchema(PetSchema, rawData)
48
+ */
49
+ declare function validateStandardSchema<TOutput>(schema: StandardSchemaValidator<TOutput>, value: unknown): Promise<TOutput>;
50
+ /**
51
+ * Wraps an object schema so its keys match case-insensitively.
52
+ * Keys the schema does not declare pass through untouched.
53
+ * The declared keys are validated with `schema` under their declared names.
54
+ * Every key, and every issue path, keeps the casing the caller used.
55
+ *
56
+ * @param schema Standard Schema-compatible object schema.
57
+ * @param entries The record of keys the passed object schema validates.
58
+ * @example
59
+ * ```ts
60
+ * validator: { headers: toHeadersStandardSchema(putEventHeadersSchema, putEventHeadersSchema.shape) }
61
+ * ```
62
+ */
63
+ declare function toHeadersStandardSchema(schema: StandardSchemaValidator, entries: Record<string, unknown>): StandardSchemaValidator;
64
+ /**
65
+ * Identifies the value and request that failed validation in `onValidationError`.
66
+ */
67
+ type ValidationErrorContext = {
68
+ value: unknown;
69
+ direction: 'request' | 'response' | 'error';
70
+ source: 'body' | 'path' | 'query' | 'headers';
71
+ method?: string;
72
+ url?: string;
73
+ status?: number;
74
+ };
75
+ /**
76
+ * Return `{ value }` to substitute a failed value, including `undefined`. Returning nothing rethrows the `ParseError`.
77
+ */
78
+ type ValidationErrorHandler = (error: ParseError, context: ValidationErrorContext) => {
79
+ value: unknown;
80
+ } | void | Promise<{
81
+ value: unknown;
82
+ } | void>;
83
+ /**
84
+ * Turns generated validation on or off. `false` skips every validator, an object skips only the directions set to `false`:
85
+ * `request` is the body, `params` are path, query, and header params, `response` and `error` are the response bodies.
86
+ * @default true
87
+ */
88
+ type ValidateOption = boolean | {
89
+ request?: boolean;
90
+ params?: boolean;
91
+ response?: boolean;
92
+ error?: boolean;
93
+ };
94
+ declare function isValidationEnabled(validate: ValidateOption | undefined, direction: 'request' | 'params' | 'response' | 'error'): boolean;
95
+ /**
96
+ * Runs a validator when there is one, handing a `ParseError` to `onValidationError` first, which may substitute the value.
97
+ */
98
+ declare function runValidator<T>({ validator, value, context, onValidationError }: {
99
+ validator: StandardSchemaValidator<T> | undefined;
100
+ value: T;
101
+ context: Omit<ValidationErrorContext, 'value'>;
102
+ onValidationError: ValidationErrorHandler | undefined;
103
+ }): Promise<T>;
104
+ export { ValidateOption as a, isValidationEnabled as c, validateStandardSchema as d, StandardSchemaValidator as i, runValidator as l, StandardSchemaIssue as n, ValidationErrorContext as o, StandardSchemaResult as r, ValidationErrorHandler as s, ParseError as t, toHeadersStandardSchema as u };
@@ -0,0 +1,2 @@
1
+ import { S as RequestResult, k as SuccessOf, n as NativeResponse, p as DataShape, t as NativeRequest, y as Options } from "../client-CiHb_Cfg.js";
2
+ export { type DataShape, NativeRequest, NativeResponse, type Options, type RequestResult, type SuccessOf };
@@ -0,0 +1,3 @@
1
+ import { a as ValidateOption, o as ValidationErrorContext, s as ValidationErrorHandler } from "../standardSchema-BShJWz2i.js";
2
+ import { A as SuccessResultUnion, B as createClientCore, C as ResolvedRequest, D as ResultByStatus, E as ResponseType, F as TransportResult, G as unwrapResult, H as getResponseContentType, I as Unwrappable, K as withUnwrap, L as UnwrappedResult, M as SuccessVariant, N as ToStatusNumber, O as ResultUnion, P as Transport, R as UrlConfig, S as RequestResult, T as ResponseErrorConfig, U as isStreamed, V as createInterceptorStack, W as resolveAuth, _ as InterceptorStack, a as AuthToken, b as RequestConfig, c as ClientInstance, d as ContentType, f as DataOf, g as InterceptorFn, h as ErrorOf, i as AuthResolver, j as SuccessStatusCode, k as SuccessOf, l as Codec, m as Deserializer, o as CallResult, p as DataShape, r as Auth, s as ClientConfig, u as ContentBodySerializer, v as Interceptors, w as ResponseError, x as RequestCredentials, y as Options, z as Validator } from "../client-CiHb_Cfg.js";
3
+ export { Auth, AuthResolver, AuthToken, CallResult, ClientConfig, ClientInstance, Codec, ContentBodySerializer, ContentType, DataOf, DataShape, Deserializer, ErrorOf, InterceptorFn, InterceptorStack, Interceptors, Options, RequestConfig, RequestCredentials, RequestResult, ResolvedRequest, ResponseError, ResponseErrorConfig, ResponseType, ResultByStatus, ResultUnion, SuccessOf, SuccessResultUnion, SuccessStatusCode, SuccessVariant, ToStatusNumber, Transport, TransportResult, Unwrappable, UnwrappedResult, UrlConfig, type ValidateOption, type ValidationErrorContext, type ValidationErrorHandler, Validator, createClientCore, createInterceptorStack, getResponseContentType, isStreamed, resolveAuth, unwrapResult, withUnwrap };
@@ -0,0 +1,2 @@
1
+ import { C as defaultQuerySerializer, E as serializeCookies, S as defaultPathSerializer, T as isJsonMediaType, _ as Serializers, a as HeaderValue, b as baseContentType, c as ParamContentType, d as PathStyle, f as QueryParamStyle, g as SerializationStyle, h as RequestBody, i as HeaderParamStyle, l as PathParamStyle, m as QueryStyle, n as BodySerializer, o as HeadersInit, p as QuerySerializer, r as CookieParamStyle, s as HttpMethod, t as BodyEncoding, u as PathSerializer, v as Styles, w as isDefaultJsonBody, x as defaultBodySerializer, y as applyHeaderStyles } from "../serializers-Ds8zZwOO.js";
2
+ export { BodyEncoding, BodySerializer, CookieParamStyle, HeaderParamStyle, HeaderValue, HeadersInit, HttpMethod, ParamContentType, PathParamStyle, PathSerializer, PathStyle, QueryParamStyle, QuerySerializer, QueryStyle, RequestBody, SerializationStyle, Serializers, Styles, applyHeaderStyles, baseContentType, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, isJsonMediaType, serializeCookies };
@@ -0,0 +1,124 @@
1
+ import { a as ValidateOption, i as StandardSchemaValidator, s as ValidationErrorHandler } from "../standardSchema-BShJWz2i.js";
2
+ import { S as RequestResult, k as SuccessOf, n as NativeResponse, p as DataShape, t as NativeRequest, y as Options } from "../client-CiHb_Cfg.js";
3
+ /**
4
+ * One decoded Server-Sent Event. `data` is parsed as JSON when valid and kept as the raw string otherwise,
5
+ * `event` is `message` when the server sent no `event` field, and `id` is the last event ID the stream has set.
6
+ */
7
+ export type ServerSentEvent<TData = unknown> = {
8
+ data: TData;
9
+ event: string;
10
+ id?: string;
11
+ retry?: number;
12
+ };
13
+ /** An event the document types by name: the member's own `event` and `data`, plus the `id` and `retry` any event may carry. */
14
+ export type TypedEvent<TEvent> = TEvent & Pick<ServerSentEvent, 'id' | 'retry'>;
15
+ /** Per-call options of a streamed operation, passed next to its request params. */
16
+ export type EventStreamOptions = {
17
+ /**
18
+ * The largest number of characters, line breaks included, one event may hold before the blank line that ends it.
19
+ * A larger event throws a `RangeError` and cancels the stream. Set `Infinity` to turn the limit off.
20
+ * @default 16777216
21
+ */
22
+ maxEventSize?: number;
23
+ /**
24
+ * Ends the stream when an event's raw `data` equals this value, such as `[DONE]`.
25
+ */
26
+ terminator?: string;
27
+ /**
28
+ * Maps each event before validation.
29
+ */
30
+ transform?: (event: ServerSentEvent) => ServerSentEvent;
31
+ };
32
+ /** The options of a streamed operation: the call's `Options` with the per-call stream options, as `Options` is for a regular call. */
33
+ export type StreamOptions<TData extends DataShape, ThrowOnError extends boolean = true> = Options<TData, ThrowOnError> & EventStreamOptions;
34
+ /**
35
+ * The validation settings a call or its client may set.
36
+ */
37
+ type ValidationSettings = {
38
+ validate?: ValidateOption;
39
+ onValidationError?: ValidationErrorHandler;
40
+ };
41
+ /**
42
+ * What the client resolves a streamed call to: the body as a stream or a decoded value, its content type, and the native response.
43
+ */
44
+ export type EventStreamCall<TResponse> = {
45
+ data: unknown;
46
+ error?: unknown;
47
+ status?: number;
48
+ contentType?: string;
49
+ request?: NativeRequest;
50
+ response: TResponse;
51
+ };
52
+ /** The payload wrapped in `ServerSentEvent`, or the item itself when the document types it as a whole event. */
53
+ type StreamEvent<TData> = TData extends {
54
+ event: string;
55
+ } ? TData : ServerSentEvent<TData>;
56
+ /** Parsed events with the fields a `RequestResult` carries. `TData` is the payload, or the typed event. Iterating the result reads `stream`. */
57
+ export type EventStreamResult<TData = unknown, TResponse = NativeResponse> = AsyncIterable<StreamEvent<TData>> & {
58
+ stream: AsyncGenerator<StreamEvent<TData>>;
59
+ /** The same events as `stream` on a 2xx response, so `.unwrap()` and `returnType: 'data'` return them. */
60
+ data: AsyncGenerator<StreamEvent<TData>> | undefined;
61
+ status: number | undefined;
62
+ /** The error body of a failed call with `throwOnError: false`, whose `stream` then yields nothing. */
63
+ error: unknown;
64
+ contentType: string | undefined;
65
+ request: NativeRequest | undefined;
66
+ response: TResponse;
67
+ /**
68
+ * The last event ID the server sent, to resume from with a `Last-Event-ID` header on a new call. Empty until the server sends `id`.
69
+ */
70
+ readonly lastEventId: string;
71
+ };
72
+ type StreamParts<TData> = AsyncIterable<StreamEvent<TData>> & {
73
+ stream: AsyncGenerator<StreamEvent<TData>>;
74
+ readonly lastEventId: string;
75
+ };
76
+ type WithEvents<TResult, TData> = TResult extends {
77
+ error: undefined;
78
+ } ? Omit<TResult, 'data'> & {
79
+ data: AsyncGenerator<StreamEvent<TData>>;
80
+ } : TResult;
81
+ /** A stream call's result, as `RequestResult` is a regular call's: `status` narrows `error`, and the events are its `data`. Branching on `ThrowOnError` lets a generated call cast to it. */
82
+ export type StreamResult<TResponses, ThrowOnError extends boolean = true, TData = SuccessOf<TResponses>> = ThrowOnError extends true ? WithEvents<RequestResult<TResponses, true>, TData> & StreamParts<TData> : WithEvents<RequestResult<TResponses, false>, TData> & StreamParts<TData>;
83
+ /** What a stream operation returns with `returnType: 'data'`, as `UnwrappedResult` is for a regular call. */
84
+ export type UnwrappedStreamResult<TResponses, ThrowOnError extends boolean = true, TData = SuccessOf<TResponses>> = ThrowOnError extends true ? AsyncGenerator<StreamEvent<TData>> : StreamResult<TResponses, false, TData>;
85
+ /** The last event ID, shared with the result so it can be read after the loop. */
86
+ type Cursor = {
87
+ lastEventId: string;
88
+ };
89
+ /**
90
+ * Parses a `text/event-stream` body as the WHATWG event stream specification does: an event is dispatched at its blank line
91
+ * when it holds `data`, `event` defaults to `message`, `id` carries across events until an empty `id` resets it, `retry` needs
92
+ * all digits, and an unfinished event at the end is dropped. `data` is parsed as JSON when it is valid and kept as text
93
+ * otherwise. Consume with `for await`, and break the loop to cancel the stream.
94
+ */
95
+ type EventStreamInput = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>;
96
+ export declare function parseEventStream<TData = unknown>(input: EventStreamInput | (Pick<EventStreamOptions, 'maxEventSize' | 'terminator'> & {
97
+ stream: EventStreamInput;
98
+ cursor?: Cursor;
99
+ })): AsyncGenerator<ServerSentEvent<TData>>;
100
+ /**
101
+ * Reads a call as typed Server-Sent Events, transformed and validated one by one, until the terminator or the end of the
102
+ * stream. A successful call whose body is not a stream, such as a decoded JSON answer, throws a `TypeError` with the body
103
+ * as its `cause`. A dropped connection ends the loop with the transport's error; `lastEventId` on the result is the ID
104
+ * to resume from.
105
+ */
106
+ export declare function toEventStream<TData = unknown, TResponse = NativeResponse>(call: Promise<EventStreamCall<TResponse>>, { client, config: options, ...meta }?: {
107
+ /**
108
+ * The client the call went through, for the validation settings a call does not set itself.
109
+ */
110
+ client?: {
111
+ getConfig: () => ValidationSettings;
112
+ };
113
+ config?: EventStreamOptions & ValidationSettings;
114
+ /**
115
+ * `event` when the document types each event with its own `event` and `data`, or `data` when it types only the payload.
116
+ * @default 'data'
117
+ */
118
+ shape?: 'event' | 'data';
119
+ /**
120
+ * Validates each event (`shape: 'event'`) or its `data` (`shape: 'data'`), after `transform`.
121
+ */
122
+ validator?: StandardSchemaValidator;
123
+ }): Promise<EventStreamResult<TData, TResponse>>;
124
+ export {};
@@ -0,0 +1,2 @@
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-BShJWz2i.js";
2
+ export { ParseError, StandardSchemaIssue, StandardSchemaResult, StandardSchemaValidator, ValidateOption, ValidationErrorContext, ValidationErrorHandler, isValidationEnabled, runValidator, toHeadersStandardSchema, validateStandardSchema };
@@ -10,7 +10,7 @@ The generated functions import your module through [`importPath`](https://kubb.d
10
10
  | `Options` | type | The grouped options object a generated function accepts. |
11
11
  | `RequestResult` | type | What a generated function resolves to. |
12
12
 
13
- If your spec has server-sent event operations, also export `toEventStream` and the `EventStreamResult` and `SuccessOf` types.
13
+ If your spec has server-sent event operations, also export `toEventStream` and the `EventStreamResult`, `SuccessOf`, and `TypedEvent` types. A generated function calls `toEventStream<TData>(promise)` with the promise your `client` returns and nothing else, and leaves the response validator on `config.validator.response`, so your module decides how to validate events.
14
14
 
15
15
  The query plugins (`@kubb/plugin-react-query`, `@kubb/plugin-vue-query`, `@kubb/plugin-swr`) and `@kubb/plugin-mcp` call the generated functions with `throwOnError: true` and read `data` off the result. The query plugins also import two more types from your module:
16
16
 
package/docs/overview.md CHANGED
@@ -6,7 +6,7 @@ Each function takes grouped `path`, `query`, `headers`, and `body` parameters an
6
6
 
7
7
  ## Setup
8
8
 
9
- - Set the required `importPath` option to your client module. The module must export `client` and the `Options` and `RequestResult` types. When the spec has server-sent event operations, it must also export `toEventStream` and the `EventStreamResult` and `SuccessOf` types.
9
+ - Set the required `importPath` option to your client module. The module must export `client` and the `Options` and `RequestResult` types. When the spec has server-sent event operations, it must also export `toEventStream` and the `EventStreamResult`, `SuccessOf`, and `TypedEvent` types.
10
10
  - Add `@kubb/plugin-ts` for the operation types, or `@kubb/plugin-zod` with `inferred: true`.
11
11
  - Add `@kubb/plugin-zod` when you set `validator`, and install `zod` v4. Generation fails without the plugin.
12
12
 
@@ -20,7 +20,7 @@
20
20
  "dependencies": ["plugin-ts"],
21
21
  "optionalDependencies": ["plugin-zod"],
22
22
  "compatibility": {
23
- "kubb": ">=5.14.6",
23
+ "kubb": ">=5.16.0",
24
24
  "node": ">=22.22"
25
25
  },
26
26
  "options": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "5.10.0-canary.20261105T162357",
3
+ "version": "5.10.0",
4
4
  "description": "Generate typed API operations against your own client module.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -22,6 +22,7 @@
22
22
  "files": [
23
23
  "src",
24
24
  "dist",
25
+ "templates",
25
26
  "kubb-extension.json",
26
27
  "docs",
27
28
  "!/**/**.test.**",
@@ -45,21 +46,29 @@
45
46
  }
46
47
  },
47
48
  "./package.json": "./package.json",
48
- "./kubb-extension.json": "./kubb-extension.json"
49
+ "./kubb-extension.json": "./kubb-extension.json",
50
+ "./templates/*.ts": {
51
+ "types": "./dist/templates/*.d.ts",
52
+ "default": "./templates/*.ts"
53
+ },
54
+ "./templates/*.js": {
55
+ "types": "./dist/templates/*.d.ts"
56
+ },
57
+ "./templates/*": "./templates/*"
49
58
  },
50
59
  "publishConfig": {
51
60
  "access": "public",
52
61
  "registry": "https://registry.npmjs.org/"
53
62
  },
54
63
  "dependencies": {
55
- "@kubb/kit": "^5.15.4",
56
- "@kubb/plugin-ts": "^5.5.0-canary.20261105T162357",
57
- "@kubb/plugin-zod": "^5.9.0-canary.20261105T162357",
58
- "@kubb/renderer-jsx": "^5.15.4"
64
+ "@kubb/kit": "^5.16.0",
65
+ "@kubb/plugin-ts": "^5.4.1",
66
+ "@kubb/plugin-zod": "^5.8.2",
67
+ "@kubb/renderer-jsx": "^5.16.0"
59
68
  },
60
69
  "devDependencies": {
61
- "@internals/client": "0.1.0-canary.20261105T162357",
62
- "@internals/shared": "0.1.0-canary.20261105T162357",
70
+ "@internals/client": "0.0.0",
71
+ "@internals/shared": "0.0.0",
63
72
  "typescript": "^7.0.2"
64
73
  },
65
74
  "peerDependencies": {},
@@ -0,0 +1,5 @@
1
+ // Stands in for the transport's `client.ts` next to `sse.ts`, so the shared templates typecheck on their own. In the
2
+ // generated `.kubb/` folder, `sse.ts` reads these from the real client; this file is never copied.
3
+ export type { DataShape, Options, RequestResult, SuccessOf } from './core.ts'
4
+ export type NativeRequest = unknown
5
+ export type NativeResponse = unknown