@kubb/plugin-fetch 5.7.0-canary.20261016T084648 → 5.7.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 +1 -1
- package/dist/index.js +1 -1
- package/dist/templates/fetch.d.ts +4 -0
- package/docs/guides/transport.md +12 -0
- package/package.json +5 -5
- package/templates/fetch.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1430,7 +1430,7 @@ var compatibility = {
|
|
|
1430
1430
|
};
|
|
1431
1431
|
//#endregion
|
|
1432
1432
|
//#region package.json
|
|
1433
|
-
var version = "5.7.0
|
|
1433
|
+
var version = "5.7.0";
|
|
1434
1434
|
//#endregion
|
|
1435
1435
|
//#region src/templates.ts
|
|
1436
1436
|
/** Absolute path to the fetch client template, copied into `.kubb/client.ts`. */
|
package/dist/index.js
CHANGED
|
@@ -1404,7 +1404,7 @@ var compatibility = {
|
|
|
1404
1404
|
};
|
|
1405
1405
|
//#endregion
|
|
1406
1406
|
//#region package.json
|
|
1407
|
-
var version = "5.7.0
|
|
1407
|
+
var version = "5.7.0";
|
|
1408
1408
|
//#endregion
|
|
1409
1409
|
//#region src/templates.ts
|
|
1410
1410
|
/** Absolute path to the fetch client template, copied into `.kubb/client.ts`. */
|
|
@@ -380,6 +380,10 @@ export declare function resolveAuth(params: {
|
|
|
380
380
|
export declare function createClientCore<TRequest = Request, TResponse = Response>(options: {
|
|
381
381
|
defaultTransport: Transport<TRequest, TResponse>;
|
|
382
382
|
} & ClientConfig<TRequest, TResponse>): ClientInstance<TRequest, TResponse>;
|
|
383
|
+
/**
|
|
384
|
+
* The default transport that sends the resolved request through `globalThis.fetch` and returns the parsed body with the native request and response.
|
|
385
|
+
*/
|
|
386
|
+
export declare const defaultTransport: Transport;
|
|
383
387
|
/**
|
|
384
388
|
* One decoded Server-Sent Event, with `data` parsed as JSON when valid and kept as the raw string otherwise.
|
|
385
389
|
*/
|
package/docs/guides/transport.md
CHANGED
|
@@ -63,3 +63,15 @@ Pass the isolated client per operation or to a query plugin.
|
|
|
63
63
|
## Where to set it
|
|
64
64
|
|
|
65
65
|
Use `client.setConfig({ transport })` for shared configuration, `createClient({ transport })` for an isolated instance, or pass `transport` on an operation to override it for one call.
|
|
66
|
+
|
|
67
|
+
## Wrap the default transport
|
|
68
|
+
|
|
69
|
+
The generated client exports `defaultTransport`, the `fetch`-based send it uses when no transport is set. Wrap it to add tracing, timing, or headers and keep the built-in request and response handling:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { client, defaultTransport } from './gen/.kubb/client'
|
|
73
|
+
|
|
74
|
+
client.setConfig({
|
|
75
|
+
transport: (request) => withSpan(request, () => defaultTransport(request)),
|
|
76
|
+
})
|
|
77
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-fetch",
|
|
3
|
-
"version": "5.7.0
|
|
3
|
+
"version": "5.7.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,12 +80,12 @@
|
|
|
80
80
|
"registry": "https://registry.npmjs.org/"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@kubb/plugin-ts": "^5.
|
|
84
|
-
"@kubb/plugin-zod": "^5.
|
|
83
|
+
"@kubb/plugin-ts": "^5.0.14",
|
|
84
|
+
"@kubb/plugin-zod": "^5.4.12"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@internals/client": "0.
|
|
88
|
-
"@internals/shared": "0.
|
|
87
|
+
"@internals/client": "0.0.0",
|
|
88
|
+
"@internals/shared": "0.0.0",
|
|
89
89
|
"kubb": "^5.10.3",
|
|
90
90
|
"typescript": "^6.0.3"
|
|
91
91
|
},
|
package/templates/fetch.ts
CHANGED
|
@@ -814,7 +814,7 @@ async function parseResponse(response: Response, responseType?: ResponseType): P
|
|
|
814
814
|
/**
|
|
815
815
|
* The default transport that sends the resolved request through `globalThis.fetch` and returns the parsed body with the native request and response.
|
|
816
816
|
*/
|
|
817
|
-
const defaultTransport: Transport = async (request: ResolvedRequest): Promise<TransportResult> => {
|
|
817
|
+
export const defaultTransport: Transport = async (request: ResolvedRequest): Promise<TransportResult> => {
|
|
818
818
|
const init: RequestInit = {
|
|
819
819
|
...request.options, // cache, mode, redirect, keepalive, duplex, next, …
|
|
820
820
|
method: request.method,
|