Skip to content

Commit 353d74b

Browse files
committed
chore(ofetch): enhance jsdoc for Config interface
1 parent 13ea452 commit 353d74b

File tree

1 file changed

+32
-3
lines changed
  • packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle

1 file changed

+32
-3
lines changed

packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/types.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,24 @@ export type ResponseStyle = 'data' | 'fields';
2020
export interface Config<T extends ClientOptions = ClientOptions>
2121
extends Omit<RequestInit, 'body' | 'headers' | 'method'>,
2222
CoreConfig {
23+
/**
24+
* HTTP(S) agent configuration (Node.js only). Passed through to ofetch.
25+
*/
2326
agent?: OfetchOptions['agent'];
2427
/**
2528
* Base URL for all requests made by this client.
2629
*/
2730
baseUrl?: T['baseUrl'];
28-
/** Node-only proxy/agent options */
31+
/**
32+
* Node-only proxy/agent options.
33+
*/
2934
dispatcher?: OfetchOptions['dispatcher'];
30-
/** Optional fetch instance used for SSE streaming */
35+
/**
36+
* Fetch API implementation. Used for SSE streaming. You can use this option
37+
* to provide a custom fetch instance.
38+
*
39+
* @default globalThis.fetch
40+
*/
3141
fetch?: typeof fetch;
3242
// No custom fetch option: provide custom instance via `ofetch` instead
3343
/**
@@ -42,10 +52,23 @@ export interface Config<T extends ClientOptions = ClientOptions>
4252
* be used for requests instead of the default `ofetch` export.
4353
*/
4454
ofetch?: typeof ofetch;
45-
/** ofetch interceptors and runtime options */
55+
/**
56+
* ofetch hook called before a request is sent.
57+
*/
4658
onRequest?: OfetchOptions['onRequest'];
59+
/**
60+
* ofetch hook called when a request fails before receiving a response
61+
* (e.g., network errors or aborted requests).
62+
*/
4763
onRequestError?: OfetchOptions['onRequestError'];
64+
/**
65+
* ofetch hook called after a successful response is received and parsed.
66+
*/
4867
onResponse?: OfetchOptions['onResponse'];
68+
/**
69+
* ofetch hook called when the response indicates an error (non-ok status)
70+
* or when response parsing fails.
71+
*/
4972
onResponseError?: OfetchOptions['onResponseError'];
5073
/**
5174
* Return the response data parsed in a specified format. By default, `auto`
@@ -80,7 +103,13 @@ export interface Config<T extends ClientOptions = ClientOptions>
80103
* Automatically retry failed requests.
81104
*/
82105
retry?: OfetchOptions['retry'];
106+
/**
107+
* Delay (in ms) between retry attempts.
108+
*/
83109
retryDelay?: OfetchOptions['retryDelay'];
110+
/**
111+
* HTTP status codes that should trigger a retry.
112+
*/
84113
retryStatusCodes?: OfetchOptions['retryStatusCodes'];
85114
/**
86115
* Throw an error instead of returning it in the response?

0 commit comments

Comments
 (0)