Skip to content

Commit 3735172

Browse files
chore: add docs to RequestOptions type
1 parent b5a043b commit 3735172

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ export interface ClientOptions {
215215
*
216216
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
217217
* much longer than this timeout before the promise succeeds or fails.
218+
*
219+
* @unit milliseconds
218220
*/
219221
timeout?: number | undefined;
220222
/**

src/internal/request-options.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,70 @@ import { type HeadersLike } from './headers';
1010
export type FinalRequestOptions = RequestOptions & { method: HTTPMethod; path: string };
1111

1212
export type RequestOptions = {
13+
/**
14+
* The HTTP method for the request (e.g., 'get', 'post', 'put', 'delete').
15+
*/
1316
method?: HTTPMethod;
17+
18+
/**
19+
* The URL path for the request.
20+
*
21+
* @example "/v1/foo"
22+
*/
1423
path?: string;
24+
25+
/**
26+
* Query parameters to include in the request URL.
27+
*/
1528
query?: object | undefined | null;
29+
30+
/**
31+
* The request body. Can be a string, JSON object, FormData, or other supported types.
32+
*/
1633
body?: unknown;
34+
35+
/**
36+
* HTTP headers to include with the request. Can be a Headers object, plain object, or array of tuples.
37+
*/
1738
headers?: HeadersLike;
39+
40+
/**
41+
* The maximum number of times that the client will retry a request in case of a
42+
* temporary failure, like a network error or a 5XX error from the server.
43+
*
44+
* @default 2
45+
*/
1846
maxRetries?: number;
47+
1948
stream?: boolean | undefined;
49+
50+
/**
51+
* The maximum amount of time (in milliseconds) that the client should wait for a response
52+
* from the server before timing out a single request.
53+
*
54+
* @unit milliseconds
55+
*/
2056
timeout?: number;
57+
58+
/**
59+
* Additional `RequestInit` options to be passed to the underlying `fetch` call.
60+
* These options will be merged with the client's default fetch options.
61+
*/
2162
fetchOptions?: MergedRequestInit;
63+
64+
/**
65+
* An AbortSignal that can be used to cancel the request.
66+
*/
2267
signal?: AbortSignal | undefined | null;
68+
69+
/**
70+
* A unique key for this request to enable idempotency.
71+
*/
2372
idempotencyKey?: string;
73+
74+
/**
75+
* Override the default base URL for this specific request.
76+
*/
2477
defaultBaseURL?: string | undefined;
2578

2679
__metadata?: Record<string, unknown>;

0 commit comments

Comments
 (0)