forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
39 lines (34 loc) · 1.03 KB
/
Copy pathtypes.ts
File metadata and controls
39 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
export type HttpHeaders = HeadersInit;
export interface RetryPolicy {
retries: number;
retryDelayMs: number;
retryableStatusCodes: number[];
}
export interface HttpRequest<TBody = unknown> {
method: HttpMethod;
path: string;
headers?: HttpHeaders;
query?: Record<
string,
string | number | boolean | (string | number)[] | undefined
>;
body?: TBody;
/** Request timeout in milliseconds. Set to `0` to disable the timeout for this request. */
timeoutMs?: number;
signal?: AbortSignal;
}
export interface HttpResponse<TData = unknown> {
status: number;
headers: Headers;
data: TData;
/** Number of attempts made (including the initial request). 1 means no retries. */
attempts?: number;
/** True if at least one retry was performed before receiving this response. */
retried?: boolean;
}
export interface HttpClient {
request<TResponse, TRequest = unknown>(
request: HttpRequest<TRequest>,
): Promise<HttpResponse<TResponse>>;
}