@kubb/plugin-fetch 5.10.0-canary.20261025T201031 → 5.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +81 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -8
- package/dist/index.d.ts +0 -8
- package/dist/index.js +80 -64
- package/dist/index.js.map +1 -1
- package/dist/templates/fetch.d.ts +1 -3
- package/dist/templates/serializers.d.ts +1 -3
- package/dist/templates/standardSchema.d.ts +1 -3
- package/kubb-extension.json +1 -1
- package/package.json +7 -7
- package/templates/fetch.ts +1 -1
- package/templates/serializers.ts +5 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { HeadersInit, RequestBody, Serializers, Styles } from "./serializers.js";
|
|
2
2
|
import { ParseError, StandardSchemaValidator } from "./standardSchema.js";
|
|
3
|
-
//#region templates/fetch.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* HTTP status codes treated as a success, everything else is an error.
|
|
6
5
|
*/
|
|
@@ -391,5 +390,4 @@ export declare function toEventStream<TData = unknown>(result: Promise<{
|
|
|
391
390
|
response: Response;
|
|
392
391
|
}>): Promise<EventStreamResult<TData>>;
|
|
393
392
|
export declare const client: ClientInstance<Request, Response>;
|
|
394
|
-
export declare const createClient: (config?: Parameters<typeof client.createClient>[0]) => ClientInstance<Request, Response>;
|
|
395
|
-
//#endregion
|
|
393
|
+
export declare const createClient: (config?: Parameters<typeof client.createClient>[0]) => ClientInstance<Request, Response>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region templates/serializers.d.ts
|
|
2
1
|
export type HeaderValue = string | number | boolean | null | undefined | object;
|
|
3
2
|
export type HeadersInit = Array<[string, HeaderValue]> | Record<string, HeaderValue>;
|
|
4
3
|
/**
|
|
@@ -177,5 +176,4 @@ export declare const defaultPathSerializer: PathSerializer;
|
|
|
177
176
|
* merged. Header values are not URL-encoded. Primitive values and headers without metadata pass
|
|
178
177
|
* through untouched.
|
|
179
178
|
*/
|
|
180
|
-
export declare function applyHeaderStyles(headers: HeadersInit | undefined, styles: Record<string, HeaderParamStyle> | undefined): HeadersInit | undefined;
|
|
181
|
-
//#endregion
|
|
179
|
+
export declare function applyHeaderStyles(headers: HeadersInit | undefined, styles: Record<string, HeaderParamStyle> | undefined): HeadersInit | undefined;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region templates/standardSchema.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* A Standard Schema-compatible validator: a minimal duck-type covering Zod v3/v4, valibot, and
|
|
4
3
|
* arktype schemas. Only the `~standard.validate` method is required at runtime.
|
|
@@ -61,5 +60,4 @@ export declare function validateStandardSchema<TOutput>(schema: StandardSchemaVa
|
|
|
61
60
|
* validator: { headers: toHeadersStandardSchema(putEventHeadersSchema, putEventHeadersSchema.shape) }
|
|
62
61
|
* ```
|
|
63
62
|
*/
|
|
64
|
-
export declare function toHeadersStandardSchema(schema: StandardSchemaValidator, entries: Record<string, unknown>): StandardSchemaValidator;
|
|
65
|
-
//#endregion
|
|
63
|
+
export declare function toHeadersStandardSchema(schema: StandardSchemaValidator, entries: Record<string, unknown>): StandardSchemaValidator;
|
package/kubb-extension.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-fetch",
|
|
3
|
-
"version": "5.10.0
|
|
3
|
+
"version": "5.10.0",
|
|
4
4
|
"description": "Generate a slim, type-safe HTTP client with Kubb based on the native Fetch api.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-client",
|
|
@@ -80,17 +80,17 @@
|
|
|
80
80
|
"registry": "https://registry.npmjs.org/"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@kubb/plugin-ts": "^5.3.0
|
|
84
|
-
"@kubb/plugin-zod": "^5.
|
|
83
|
+
"@kubb/plugin-ts": "^5.3.0",
|
|
84
|
+
"@kubb/plugin-zod": "^5.7.3"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@internals/client": "0.
|
|
88
|
-
"@internals/shared": "0.
|
|
89
|
-
"kubb": "^5.14.
|
|
87
|
+
"@internals/client": "0.0.0",
|
|
88
|
+
"@internals/shared": "0.0.0",
|
|
89
|
+
"kubb": "^5.14.6",
|
|
90
90
|
"typescript": "^7.0.2"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
|
-
"kubb": "^5.14.
|
|
93
|
+
"kubb": "^5.14.6"
|
|
94
94
|
},
|
|
95
95
|
"engines": {
|
|
96
96
|
"node": ">=22.22"
|
package/templates/fetch.ts
CHANGED
|
@@ -474,7 +474,7 @@ export async function resolveAuth(params: {
|
|
|
474
474
|
|
|
475
475
|
if (scheme.type !== 'apiKey') {
|
|
476
476
|
if (getHeader(headers, 'Authorization') === undefined) {
|
|
477
|
-
headers['Authorization'] = scheme.scheme === 'basic' ? `Basic ${btoa(token)}` : `Bearer ${token}`
|
|
477
|
+
headers['Authorization'] = scheme.scheme === 'basic' ? `Basic ${btoa(String.fromCharCode(...new TextEncoder().encode(token)))}` : `Bearer ${token}`
|
|
478
478
|
}
|
|
479
479
|
return
|
|
480
480
|
}
|
package/templates/serializers.ts
CHANGED
|
@@ -179,8 +179,10 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData:
|
|
|
179
179
|
*/
|
|
180
180
|
export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => {
|
|
181
181
|
if (body === undefined || body === null) return undefined
|
|
182
|
+
if (typeof body === 'string' && isJsonMediaType(contentType)) return JSON.stringify(body)
|
|
182
183
|
if (isFormBody(body)) return body as RequestBody
|
|
183
|
-
|
|
184
|
+
const normalizedContentType = contentType?.toLowerCase()
|
|
185
|
+
if (normalizedContentType?.includes('multipart/form-data')) {
|
|
184
186
|
const formData = new FormData()
|
|
185
187
|
for (const [key, value] of Object.entries(body as Record<string, unknown>)) {
|
|
186
188
|
const partContentType = encoding?.[key]?.contentType
|
|
@@ -192,9 +194,9 @@ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encod
|
|
|
192
194
|
}
|
|
193
195
|
return formData
|
|
194
196
|
}
|
|
195
|
-
if (
|
|
197
|
+
if (normalizedContentType?.includes('application/x-www-form-urlencoded')) {
|
|
196
198
|
if (encoding) return serializeUrlencodedBody(body as Record<string, unknown>, encoding)
|
|
197
|
-
return new URLSearchParams(body as Record<string,
|
|
199
|
+
return new URLSearchParams(serializeUrlencodedBody(body as Record<string, unknown>, {}))
|
|
198
200
|
}
|
|
199
201
|
return JSON.stringify(body, jsonReplacer)
|
|
200
202
|
}
|