@@ -28,34 +28,100 @@ export interface CommonHttpClientFetchRequestHeaders {
28
28
[ headerName : string ] : string ;
29
29
}
30
30
31
+ /**
32
+ * Request prepared for the fetch function.
33
+ */
31
34
export interface CommonHttpClientFetchRequest {
35
+ /**
36
+ * HTTP Method.
37
+ */
32
38
method : 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'PATCH' ;
39
+ /**
40
+ * Request headers.
41
+ */
33
42
headers : CommonHttpClientFetchRequestHeaders ;
43
+ /**
44
+ * Request body.
45
+ */
34
46
body ?: BodyInit ;
47
+ /**
48
+ * Cache mode.
49
+ */
35
50
cache : 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload' ;
51
+ /**
52
+ * Credentials mode.
53
+ */
36
54
credentials : 'include' | 'omit' | 'same-origin' ;
55
+ /**
56
+ * Redirect mode.
57
+ */
37
58
redirect : 'error' | 'follow' | 'manual' ;
59
+ /**
60
+ * Custom request properties. Can be used to pass metadata to the fetch function.
61
+ */
38
62
customRequestProps ?: Record < string , unknown > ;
39
63
}
40
64
65
+ /**
66
+ * Request in terms of OpenAPI.
67
+ */
41
68
export type CommonHttpClientRequest = Omit <
42
69
CommonHttpClientFetchRequest ,
43
70
'body' | 'headers' | 'cache' | 'credentials' | 'redirect'
44
71
> & {
72
+ /**
73
+ * Path to the resource.
74
+ */
45
75
path : string ;
76
+ /**
77
+ * Path parameters, i.e. {id}.
78
+ */
46
79
pathParams ?: Record < string , unknown > ;
80
+ /**
81
+ * Query parameters.
82
+ */
47
83
query ?: Record < string , unknown > ;
84
+ /**
85
+ * Request body.
86
+ */
48
87
body ?: unknown ;
88
+ /**
89
+ * Request headers.
90
+ */
49
91
headers ?: CommonHttpClientRequestHeaders ;
50
92
} & Partial < Pick < CommonHttpClientFetchRequest , 'cache' | 'credentials' | 'redirect' > > ;
51
93
94
+ /**
95
+ * Response of the fetch function.
96
+ */
52
97
export interface CommonHttpClientFetchResponse {
98
+ /**
99
+ * HTTP status code.
100
+ */
53
101
status : number ;
102
+ /**
103
+ * HTTP status code explanation.
104
+ */
54
105
statusText : string ;
106
+ /**
107
+ * Response body.
108
+ */
55
109
body : CommonHttpClientFetchResponseBody ;
110
+ /**
111
+ * Whether the request was successful. True for 2xx status codes.
112
+ */
56
113
ok : boolean ;
114
+ /**
115
+ * The final URL of the request (after redirects).
116
+ */
57
117
url : string ;
118
+ /**
119
+ * Response headers.
120
+ */
58
121
headers : CommonHttpClientResponseHeaders ;
122
+ /**
123
+ * Custom request properties. Can be used to pass metadata outside the fetch function.
124
+ */
59
125
customRequestProps ?: Record < string , unknown > ;
60
126
}
61
127
0 commit comments