@kubb/plugin-client 6.0.0 → 6.0.1

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,119 +0,0 @@
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,82 +0,0 @@
1
- /**
2
- * A Standard Schema validator, such as a Zod, Valibot, or ArkType schema.
3
- */
4
- type StandardSchemaValidator<TOutput = unknown> = {
5
- readonly '~standard': {
6
- validate(value: unknown): StandardSchemaResult<TOutput> | Promise<StandardSchemaResult<TOutput>>;
7
- };
8
- };
9
- type StandardSchemaResult<TOutput> = {
10
- readonly value: TOutput;
11
- readonly issues?: undefined;
12
- } | {
13
- readonly issues: ReadonlyArray<StandardSchemaIssue>;
14
- };
15
- 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
- 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
- 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
- declare function toHeadersStandardSchema(schema: StandardSchemaValidator, entries: Record<string, unknown>): StandardSchemaValidator;
46
- /**
47
- * Which value and request failed validation.
48
- */
49
- 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
- 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
- type ValidateOption = boolean | {
70
- request?: boolean;
71
- params?: boolean;
72
- response?: boolean;
73
- error?: boolean;
74
- };
75
- declare function isValidationEnabled(validate: ValidateOption | undefined, direction: 'request' | 'params' | 'response' | 'error'): boolean;
76
- 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>;
82
- 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 };