@kubb/plugin-fetch 5.7.0-canary.20261016T084648 → 5.7.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.
- package/dist/index.cjs +13 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/templates/fetch.d.ts +4 -0
- package/docs/guides/transport.md +12 -0
- package/kubb-extension.json +41 -0
- package/package.json +8 -8
- package/templates/fetch.ts +1 -1
|
@@ -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/kubb-extension.json
CHANGED
|
@@ -194,6 +194,47 @@
|
|
|
194
194
|
"label": "SDK Name",
|
|
195
195
|
"description": "Root client name for the generated SDK",
|
|
196
196
|
"type": "text"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"key": "returnType",
|
|
200
|
+
"path": ["returnType"],
|
|
201
|
+
"label": "Return Type",
|
|
202
|
+
"description": "What a generated function resolves to. full is the whole result with status and error, data is only the success body when it throws, and plain is the client's own promise",
|
|
203
|
+
"type": "select",
|
|
204
|
+
"default": "full",
|
|
205
|
+
"choices": [
|
|
206
|
+
{
|
|
207
|
+
"value": "full"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"value": "data"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"value": "plain"
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"key": "throwOnErrorDefault",
|
|
219
|
+
"path": ["throwOnErrorDefault"],
|
|
220
|
+
"label": "Throw on Error",
|
|
221
|
+
"description": "Throw when a request fails. A per-call throwOnError overrides it",
|
|
222
|
+
"type": "boolean",
|
|
223
|
+
"default": true
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"key": "banner",
|
|
227
|
+
"path": ["output", "banner"],
|
|
228
|
+
"label": "Banner",
|
|
229
|
+
"description": "Text added at the top of every generated file",
|
|
230
|
+
"type": "text"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"key": "footer",
|
|
234
|
+
"path": ["output", "footer"],
|
|
235
|
+
"label": "Footer",
|
|
236
|
+
"description": "Text added at the end of every generated file",
|
|
237
|
+
"type": "text"
|
|
197
238
|
}
|
|
198
239
|
]
|
|
199
240
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-fetch",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.1",
|
|
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.
|
|
84
|
-
"@kubb/plugin-zod": "^5.
|
|
83
|
+
"@kubb/plugin-ts": "^5.0.15",
|
|
84
|
+
"@kubb/plugin-zod": "^5.4.13"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@internals/client": "0.
|
|
88
|
-
"@internals/shared": "0.
|
|
89
|
-
"kubb": "^5.
|
|
90
|
-
"typescript": "^
|
|
87
|
+
"@internals/client": "0.0.0",
|
|
88
|
+
"@internals/shared": "0.0.0",
|
|
89
|
+
"kubb": "^5.12.5",
|
|
90
|
+
"typescript": "^7.0.2"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
|
-
"kubb": "^5.
|
|
93
|
+
"kubb": "^5.12.5"
|
|
94
94
|
},
|
|
95
95
|
"engines": {
|
|
96
96
|
"node": ">=22.12"
|
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,
|