@kubb/plugin-client 5.12.0-canary.20261109T134631 → 6.0.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.
Files changed (72) hide show
  1. package/README.md +1 -1
  2. package/dist/client-Dq0z61hu.d.ts +554 -0
  3. package/dist/index.cjs +1396 -802
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +126 -74
  6. package/dist/index.d.ts +126 -74
  7. package/dist/index.js +1394 -804
  8. package/dist/index.js.map +1 -1
  9. package/dist/serializers-BRgfPGr1.d.ts +119 -0
  10. package/dist/{standardSchema-BShJWz2i.d.ts → standardSchema-CGuiSK7F.d.ts} +15 -37
  11. package/dist/templates/client.d.ts +3 -2
  12. package/dist/templates/core.d.ts +3 -3
  13. package/dist/templates/mediaTypes/formData.d.ts +5 -0
  14. package/dist/templates/mediaTypes/urlencoded.d.ts +5 -0
  15. package/dist/templates/mediaTypes.d.ts +2 -0
  16. package/dist/templates/serializers/cookies.d.ts +5 -0
  17. package/dist/templates/serializers/headers.d.ts +5 -0
  18. package/dist/templates/serializers/path.d.ts +5 -0
  19. package/dist/templates/serializers/pathStyles.d.ts +5 -0
  20. package/dist/templates/serializers/query.d.ts +5 -0
  21. package/dist/templates/serializers/queryStyles.d.ts +14 -0
  22. package/dist/templates/serializers.d.ts +2 -2
  23. package/dist/templates/sse.d.ts +20 -113
  24. package/dist/templates/standardSchema.d.ts +1 -1
  25. package/docs/guides/authentication.md +9 -1
  26. package/docs/guides/migrate-to-v6.md +139 -0
  27. package/docs/guides/validate-requests-and-responses.md +8 -3
  28. package/docs/guides/write-your-client.md +117 -11
  29. package/docs/options.md +24 -0
  30. package/docs/overview.md +1 -1
  31. package/kubb-extension.json +1 -1
  32. package/package.json +8 -7
  33. package/src/builders/callConfig.ts +80 -0
  34. package/src/builders/contentType.ts +35 -0
  35. package/src/builders/generics.ts +29 -0
  36. package/src/builders/operationBody.ts +43 -0
  37. package/src/builders/operationData.ts +64 -0
  38. package/src/builders/returnStatement.ts +103 -0
  39. package/src/builders/security.ts +125 -0
  40. package/src/builders/signature.ts +71 -0
  41. package/src/builders/styles.ts +94 -0
  42. package/src/builders/validator.ts +84 -0
  43. package/src/builders/validatorOptions.ts +53 -0
  44. package/src/clientTypes.ts +195 -0
  45. package/src/components/ClientRuntime.tsx +97 -0
  46. package/src/components/Operation.tsx +72 -0
  47. package/src/components/SdkClient.tsx +100 -0
  48. package/src/components/SdkFacade.tsx +35 -0
  49. package/src/generators/clientGenerator.tsx +91 -6
  50. package/src/generators/sdkGenerator.tsx +209 -0
  51. package/src/index.ts +3 -1
  52. package/src/macros.ts +9 -0
  53. package/src/plugin.ts +9 -9
  54. package/src/resolver.ts +28 -0
  55. package/src/setup.ts +90 -0
  56. package/src/types.ts +16 -2
  57. package/templates/client.ts +2 -1
  58. package/templates/core.ts +735 -286
  59. package/templates/mediaTypes/formData.ts +59 -0
  60. package/templates/mediaTypes/urlencoded.ts +33 -0
  61. package/templates/mediaTypes.ts +147 -0
  62. package/templates/serializers/cookies.ts +58 -0
  63. package/templates/serializers/headers.ts +35 -0
  64. package/templates/serializers/path.ts +19 -0
  65. package/templates/serializers/pathStyles.ts +27 -0
  66. package/templates/serializers/query.ts +21 -0
  67. package/templates/serializers/queryStyles.ts +107 -0
  68. package/templates/serializers.ts +48 -364
  69. package/templates/sse.ts +87 -178
  70. package/templates/standardSchema.ts +16 -37
  71. package/dist/client-BxO6Dygu.d.ts +0 -355
  72. package/dist/serializers-Ds8zZwOO.d.ts +0 -190
@@ -0,0 +1,119 @@
1
+ type HeaderValue = string | number | boolean | null | undefined | object;
2
+ 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
+ type RequestBody = NonNullable<RequestInit['body']>;
7
+ type HttpMethod = 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'QUERY' | 'TRACE' | (string & {});
8
+ /**
9
+ * The OpenAPI query style. `form` is the default.
10
+ */
11
+ type QueryStyle = 'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
12
+ 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
+ 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
+ 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
+ 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
+ type CookieParamStyle = ParamContentType & {
37
+ style?: 'form' | 'cookie';
38
+ explode?: boolean;
39
+ };
40
+ 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
+ type BodyEncoding = SerializationStyle<QueryStyle> & {
47
+ contentType?: string;
48
+ };
49
+ /**
50
+ * The OpenAPI path style. `simple` is the default.
51
+ */
52
+ type PathStyle = 'simple' | 'label' | 'matrix';
53
+ type PathParamStyle = SerializationStyle<PathStyle>;
54
+ /**
55
+ * Joins the cookie parameters of a call into a `Cookie` header value.
56
+ */
57
+ 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
+ type HeaderSerializer = (headers: HeadersInit | undefined, styles?: Record<string, HeaderParamStyle>) => HeadersInit | undefined;
62
+ /**
63
+ * Turns one path parameter into its URL segment.
64
+ */
65
+ 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
+ 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
+ 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
+ declare function jsonReplacer(_key: string, value: unknown): unknown;
100
+ /**
101
+ * A `Content-Type` without its parameters, in lower case.
102
+ */
103
+ 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
+ declare function isJsonMediaType(contentType: string | null | undefined): boolean;
108
+ 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
+ declare function toValue(value: unknown): string;
113
+ declare function encodeComponent(value: unknown): string;
114
+ 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
+ declare function serializeDefaultQueryParam(key: string, value: unknown): Array<string>;
119
+ export { isRecord as C, toValue as D, serializeDefaultQueryParam as E, isJsonMediaType as S, notNullish as T, SerializationStyle as _, HeaderSerializer as a, baseContentType as b, HttpMethod as c, PathSerializer as d, PathStyle as f, RequestBody as g, QueryStyle as h, HeaderParamStyle as i, ParamContentType as l, QuerySerializer as m, CookieParamStyle as n, HeaderValue as o, QueryParamStyle as p, CookieSerializer as r, HeadersInit as s, BodyEncoding as t, PathParamStyle as u, Serializers as v, jsonReplacer as w, encodeComponent as x, Styles as y };
@@ -1,60 +1,42 @@
1
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.
2
+ * A Standard Schema validator, such as a Zod, Valibot, or ArkType schema.
4
3
  */
5
4
  type StandardSchemaValidator<TOutput = unknown> = {
6
5
  readonly '~standard': {
7
6
  validate(value: unknown): StandardSchemaResult<TOutput> | Promise<StandardSchemaResult<TOutput>>;
8
7
  };
9
8
  };
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
9
  type StandardSchemaResult<TOutput> = {
15
10
  readonly value: TOutput;
16
11
  readonly issues?: undefined;
17
12
  } | {
18
13
  readonly issues: ReadonlyArray<StandardSchemaIssue>;
19
14
  };
20
- /**
21
- * One validation issue from a Standard Schema `validate` call.
22
- */
23
15
  type StandardSchemaIssue = {
24
16
  readonly message?: string;
25
17
  readonly path?: ReadonlyArray<PropertyKey | {
26
18
  readonly key: PropertyKey;
27
- }>;
19
+ }> | undefined;
28
20
  };
29
21
  /**
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.
22
+ * Thrown when validation fails, with the schema's `issues`.
33
23
  */
34
24
  declare class ParseError extends Error {
35
25
  readonly issues: ReadonlyArray<StandardSchemaIssue>;
36
- constructor({ issues, message }: {
26
+ readonly cause?: unknown;
27
+ constructor({ issues, message, cause }: {
37
28
  issues: ReadonlyArray<StandardSchemaIssue>;
38
29
  message?: string;
30
+ cause?: unknown;
39
31
  });
40
32
  }
41
33
  /**
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)
34
+ * Returns the parsed value, or throws a `ParseError` with the schema's `issues`.
48
35
  */
49
36
  declare function validateStandardSchema<TOutput>(schema: StandardSchemaValidator<TOutput>, value: unknown): Promise<TOutput>;
50
37
  /**
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.
38
+ * Wraps an object schema so its keys match in any letter case. `entries` are the keys the schema declares.
55
39
  *
56
- * @param schema Standard Schema-compatible object schema.
57
- * @param entries The record of keys the passed object schema validates.
58
40
  * @example
59
41
  * ```ts
60
42
  * validator: { headers: toHeadersStandardSchema(putEventHeadersSchema, putEventHeadersSchema.shape) }
@@ -62,18 +44,18 @@ declare function validateStandardSchema<TOutput>(schema: StandardSchemaValidator
62
44
  */
63
45
  declare function toHeadersStandardSchema(schema: StandardSchemaValidator, entries: Record<string, unknown>): StandardSchemaValidator;
64
46
  /**
65
- * Identifies the value and request that failed validation in `onValidationError`.
47
+ * Which value and request failed validation.
66
48
  */
67
49
  type ValidationErrorContext = {
68
50
  value: unknown;
69
51
  direction: 'request' | 'response' | 'error';
70
- source: 'body' | 'path' | 'query' | 'headers';
71
- method?: string;
72
- url?: string;
73
- status?: number;
52
+ source: 'body' | 'path' | 'query' | 'headers' | 'cookies';
53
+ method?: string | undefined;
54
+ url?: string | undefined;
55
+ status?: number | undefined;
74
56
  };
75
57
  /**
76
- * Return `{ value }` to substitute a failed value, including `undefined`. Returning nothing rethrows the `ParseError`.
58
+ * Return `{ value }` to use instead of a failed value. Return nothing to rethrow the `ParseError`.
77
59
  */
78
60
  type ValidationErrorHandler = (error: ParseError, context: ValidationErrorContext) => {
79
61
  value: unknown;
@@ -81,8 +63,7 @@ type ValidationErrorHandler = (error: ParseError, context: ValidationErrorContex
81
63
  value: unknown;
82
64
  } | void>;
83
65
  /**
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.
66
+ * Turns generated validation on or off, for every direction or per direction.
86
67
  * @default true
87
68
  */
88
69
  type ValidateOption = boolean | {
@@ -92,9 +73,6 @@ type ValidateOption = boolean | {
92
73
  error?: boolean;
93
74
  };
94
75
  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
76
  declare function runValidator<T>({ validator, value, context, onValidationError }: {
99
77
  validator: StandardSchemaValidator<T> | undefined;
100
78
  value: T;
@@ -1,2 +1,3 @@
1
- import { A as SuccessOf, S as RequestResult, n as NativeResponse, p as DataShape, t as NativeRequest, y as Options } from "../client-BxO6Dygu.js";
2
- export { type DataShape, NativeRequest, NativeResponse, type Options, type RequestResult, type SuccessOf };
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";
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 { a as ValidateOption, o as ValidationErrorContext, s as ValidationErrorHandler } from "../standardSchema-BShJWz2i.js";
2
- import { A as SuccessOf, B as Validator, C as ResolvedRequest, D as ResponseTypeMap, E as ResponseType, F as Transport, G as resolveAuth, H as createInterceptorStack, I as TransportResult, J as withUnwrap, K as resolveResponseType, L as Unwrappable, M as SuccessStatusCode, N as SuccessVariant, O as ResultByStatus, P as ToStatusNumber, R as UnwrappedResult, S as RequestResult, T as ResponseErrorConfig, U as getResponseContentType, V as createClientCore, W as isStreamed, _ 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 SuccessResultUnion, k as ResultUnion, l as Codec, m as Deserializer, o as CallResult, p as DataShape, q as unwrapResult, r as Auth, s as ClientConfig, u as ContentBodySerializer, v as Interceptors, w as ResponseError, x as RequestCredentials, y as Options, z as UrlConfig } from "../client-BxO6Dygu.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, ResponseTypeMap, ResultByStatus, ResultUnion, SuccessOf, SuccessResultUnion, SuccessStatusCode, SuccessVariant, ToStatusNumber, Transport, TransportResult, Unwrappable, UnwrappedResult, UrlConfig, type ValidateOption, type ValidationErrorContext, type ValidationErrorHandler, Validator, createClientCore, createInterceptorStack, getResponseContentType, isStreamed, resolveAuth, resolveResponseType, unwrapResult, withUnwrap };
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";
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 };
@@ -0,0 +1,5 @@
1
+ import { lt as MediaType } from "../../client-Dq0z61hu.js";
2
+ /**
3
+ * The `multipart/form-data` handler, which follows `config.styles.body`.
4
+ */
5
+ export declare const multipartFormData: MediaType;
@@ -0,0 +1,5 @@
1
+ import { lt as MediaType } from "../../client-Dq0z61hu.js";
2
+ /**
3
+ * The `application/x-www-form-urlencoded` handler, which follows `config.styles.body`.
4
+ */
5
+ export declare const urlencoded: MediaType;
@@ -0,0 +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";
2
+ export { MediaType, MediaTypeContext, MediaTypes, defaultMediaTypes, isEncodedBody, parseJson, resolveMediaType };
@@ -0,0 +1,5 @@
1
+ import { r as CookieSerializer } from "../../serializers-BRgfPGr1.js";
2
+ /**
3
+ * Joins cookie parameters into a `Cookie` header value with the OpenAPI `form` style, or the `cookie` style when a parameter sets it.
4
+ */
5
+ export declare const serializeCookies: CookieSerializer;
@@ -0,0 +1,5 @@
1
+ import { a as HeaderSerializer } from "../../serializers-BRgfPGr1.js";
2
+ /**
3
+ * Serializes array and object headers with the OpenAPI `simple` style.
4
+ */
5
+ export declare const serializeHeaders: HeaderSerializer;
@@ -0,0 +1,5 @@
1
+ import { d as PathSerializer } from "../../serializers-BRgfPGr1.js";
2
+ /**
3
+ * The path serializer for the `simple` style, which `serializeStyledPath` also uses.
4
+ */
5
+ export declare const serializePath: PathSerializer;
@@ -0,0 +1,5 @@
1
+ import { d as PathSerializer } from "../../serializers-BRgfPGr1.js";
2
+ /**
3
+ * The path serializer for the OpenAPI `label` and `matrix` styles. A `simple` parameter uses `serializePath`.
4
+ */
5
+ export declare const serializeStyledPath: PathSerializer;
@@ -0,0 +1,5 @@
1
+ import { m as QuerySerializer } from "../../serializers-BRgfPGr1.js";
2
+ /**
3
+ * The query serializer for a spec without styled query parameters: arrays repeat their key, objects use `form` with explode.
4
+ */
5
+ export declare const serializeQuery: QuerySerializer;
@@ -0,0 +1,14 @@
1
+ import { m as QuerySerializer, p as QueryParamStyle } from "../../serializers-BRgfPGr1.js";
2
+ /**
3
+ * One query parameter or form field with its OpenAPI style, as encoded pairs.
4
+ */
5
+ export declare function serializeStyledQueryParam({ key, value, options }: {
6
+ key: string;
7
+ value: unknown;
8
+ options: QueryParamStyle;
9
+ }): Array<string>;
10
+ /**
11
+ * The query serializer for a spec with styled query parameters: an OpenAPI style, `allowReserved` or a JSON content
12
+ * type. Without a style entry, arrays repeat their key and objects use `form` with explode.
13
+ */
14
+ export declare const serializeStyledQuery: QuerySerializer;
@@ -1,2 +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 };
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,124 +1,31 @@
1
- import { a as ValidateOption, i as StandardSchemaValidator, s as ValidationErrorHandler } from "../standardSchema-BShJWz2i.js";
2
- import { A as SuccessOf, S as RequestResult, n as NativeResponse, p as DataShape, t as NativeRequest, y as Options } from "../client-BxO6Dygu.js";
1
+ import { N as ServerSentEvent, dt as MediaTypes, h as EventStreamOptions, lt as MediaType } from "../client-Dq0z61hu.js";
2
+ type Cursor = {
3
+ lastEventId: string;
4
+ };
5
+ type EventStreamInput = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>;
3
6
  /**
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.
7
+ * Parses a `text/event-stream` body into events, as the WHATWG spec does. Break the loop to cancel the stream.
6
8
  */
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;
9
+ export declare function parseEventStream<TData = unknown>(input: EventStreamInput | (Pick<EventStreamOptions, 'maxEventSize' | 'terminator' | 'rawData'> & {
10
+ stream: EventStreamInput;
11
+ cursor?: Cursor | undefined;
12
+ })): AsyncGenerator<ServerSentEvent<TData>>;
34
13
  /**
35
- * The validation settings a call or its client may set.
14
+ * Parses a JSON Lines body into one value per line. Break the loop to cancel the stream.
36
15
  */
37
- type ValidationSettings = {
38
- validate?: ValidateOption;
39
- onValidationError?: ValidationErrorHandler;
40
- };
16
+ export declare function parseJsonLines<TData = unknown>({ stream, maxEventSize, terminator }: Pick<EventStreamOptions, 'maxEventSize' | 'terminator'> & {
17
+ stream: EventStreamInput;
18
+ }): AsyncGenerator<TData>;
41
19
  /**
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.
20
+ * The `text/event-stream` handler. A whole body, such as an error, is read as text.
43
21
  */
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
- };
22
+ export declare const eventStream: MediaType;
89
23
  /**
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.
24
+ * The JSON Lines handler. A whole body, such as an error, is read as text.
94
25
  */
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>>;
26
+ export declare const jsonLines: MediaType;
100
27
  /**
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.
28
+ * The Server-Sent Events and JSON Lines handlers, registered when the document streams.
105
29
  */
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>>;
30
+ export declare const streamMediaTypes: MediaTypes;
124
31
  export {};
@@ -1,2 +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";
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
2
  export { ParseError, StandardSchemaIssue, StandardSchemaResult, StandardSchemaValidator, ValidateOption, ValidationErrorContext, ValidationErrorHandler, isValidationEnabled, runValidator, toHeadersStandardSchema, validateStandardSchema };
@@ -7,7 +7,7 @@ Auth lives in your `client`. The plugin does not send credentials itself. It tel
7
7
  Each generated function passes the operation's security schemes from the spec as `security`:
8
8
 
9
9
  ```typescript
10
- request({
10
+ apiClient<GetPetByIdResponses, ThrowOnError>({
11
11
  method: 'GET',
12
12
  url: '/pet/{petId}',
13
13
  security: [{ type: 'apiKey', name: 'api_key', in: 'header' }, { type: 'oauth2' }],
@@ -15,8 +15,16 @@ request({
15
15
  })
16
16
  ```
17
17
 
18
+ Each entry is one security requirement, and meeting one is enough. A requirement that needs several schemes together, such as an API key and a session cookie, is an array, and your client sends all of them: `security: [[{ type: 'apiKey', name: 'api_key', in: 'header' }, { type: 'apiKey', name: 'sid', in: 'cookie' }]]`.
19
+
18
20
  An operation without security requirements passes no `security` field. Use that to skip auth on public endpoints.
19
21
 
22
+ An `oauth2` entry carries its `flows` with their URLs, and its `metadataUrl` when the spec sets `oauth2MetadataUrl`. An `openIdConnect` entry carries its discovery `url`. Your client can use them to run the flow, such as the OpenAPI 3.2 `deviceAuthorization` flow, and then send the token as a bearer token:
23
+
24
+ ```typescript
25
+ security: [{ type: 'oauth2', flows: { deviceAuthorization: { deviceAuthorizationUrl: 'https://auth.example.com/device', tokenUrl: 'https://auth.example.com/token' } }, scopes: ['read'] }]
26
+ ```
27
+
20
28
  ## Add a bearer token from an async source
21
29
 
22
30
  The client can `await` anything before it sends the request. The client below awaits a token function you register with `setAuth`, so the token can come from a secrets store or a refresh call: