-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathFetchAPI.res
More file actions
284 lines (265 loc) · 9.92 KB
/
FetchAPI.res
File metadata and controls
284 lines (265 loc) · 9.92 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
@@warning("-30")
open Prelude
open EventAPI
open FileAPI
type responseType =
| @as("basic") Basic
| @as("cors") Cors
| @as("default") Default
| @as("error") Error
| @as("opaque") Opaque
| @as("opaqueredirect") Opaqueredirect
type requestDestination =
| @as("audio") Audio
| @as("audioworklet") Audioworklet
| @as("document") Document
| @as("embed") Embed
| @as("font") Font
| @as("frame") Frame
| @as("iframe") Iframe
| @as("image") Image
| @as("manifest") Manifest
| @as("object") Object
| @as("paintworklet") Paintworklet
| @as("report") Report
| @as("script") Script
| @as("sharedworker") Sharedworker
| @as("style") Style
| @as("track") Track
| @as("video") Video
| @as("worker") Worker
| @as("xslt") Xslt
type referrerPolicy =
| @as("no-referrer") NoReferrer
| @as("no-referrer-when-downgrade") NoReferrerWhenDowngrade
| @as("origin") Origin
| @as("origin-when-cross-origin") OriginWhenCrossOrigin
| @as("same-origin") SameOrigin
| @as("strict-origin") StrictOrigin
| @as("strict-origin-when-cross-origin") StrictOriginWhenCrossOrigin
| @as("unsafe-url") UnsafeUrl
type requestMode =
| @as("cors") Cors
| @as("navigate") Navigate
| @as("no-cors") NoCors
| @as("same-origin") SameOrigin
type requestCredentials =
| @as("include") Include
| @as("omit") Omit
| @as("same-origin") SameOrigin
type requestCache =
| @as("default") Default
| @as("force-cache") ForceCache
| @as("no-cache") NoCache
| @as("no-store") NoStore
| @as("only-if-cached") OnlyIfCached
| @as("reload") Reload
type requestRedirect =
| @as("error") Error
| @as("follow") Follow
| @as("manual") Manual
type requestPriority =
| @as("auto") Auto
| @as("high") High
| @as("low") Low
/**
@editor.completeFrom(Response) This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.
[See Headers on MDN](https://developer.mozilla.org/docs/Web/API/Headers)
*/
@editor.completeFrom(Headers)
type headers = {}
/**
This Fetch API interface represents a resource request.
[See Request on MDN](https://developer.mozilla.org/docs/Web/API/Request)
*/
@editor.completeFrom(Request)
type request = {
/**
Returns request's HTTP method, which is "GET" by default.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/method)
*/
method: string,
/**
Returns the URL of request as a string.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/url)
*/
url: string,
/**
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/headers)
*/
headers: headers,
/**
Returns the kind of resource requested by request, e.g., "document" or "script".
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/destination)
*/
destination: requestDestination,
/**
Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/referrer)
*/
referrer: string,
/**
Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/referrerPolicy)
*/
referrerPolicy: referrerPolicy,
/**
Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/mode)
*/
mode: requestMode,
/**
Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/credentials)
*/
credentials: requestCredentials,
/**
Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/cache)
*/
cache: requestCache,
/**
Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/redirect)
*/
redirect: requestRedirect,
/**
Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI]
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/integrity)
*/
integrity: string,
/**
Returns a boolean indicating whether or not request can outlive the global in which it was created.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
*/
keepalive: bool,
/**
Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/signal)
*/
signal: abortSignal,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/body)
*/
body: Null.t<readableStream<array<int>>>,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed)
*/
bodyUsed: bool,
}
/**
This Fetch API interface represents the response to a request.
[See Response on MDN](https://developer.mozilla.org/docs/Web/API/Response)
*/
@editor.completeFrom(Response)
type response = {
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Response/type)
*/
@as("type")
type_: responseType,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Response/url)
*/
url: string,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Response/redirected)
*/
redirected: bool,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Response/status)
*/
status: int,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Response/ok)
*/
ok: bool,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Response/statusText)
*/
statusText: string,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Response/headers)
*/
headers: headers,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/body)
*/
body: Null.t<readableStream<array<int>>>,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed)
*/
bodyUsed: bool,
}
/**
Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data".
[See FormData on MDN](https://developer.mozilla.org/docs/Web/API/FormData)
*/
@editor.completeFrom(FormData)
type formData = {}
@editor.completeFrom(HeadersInit) type headersInit
@editor.completeFrom(BodyInit) type bodyInit
type requestInfo = any
@editor.completeFrom(FormDataEntryValue)
type formDataEntryValue
type requestInit = {
/**
A string to set request's method.
*/
mutable method?: string,
/**
A Headers object, an object literal, or an array of two-item arrays to set request's headers.
*/
mutable headers?: headersInit,
/**
A BodyInit object or null to set request's body.
*/
mutable body?: bodyInit,
/**
A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer.
*/
mutable referrer?: string,
/**
A referrer policy to set request's referrerPolicy.
*/
mutable referrerPolicy?: referrerPolicy,
/**
A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.
*/
mutable mode?: requestMode,
/**
A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials.
*/
mutable credentials?: requestCredentials,
/**
A string indicating how the request will interact with the browser's cache to set request's cache.
*/
mutable cache?: requestCache,
/**
A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect.
*/
mutable redirect?: requestRedirect,
/**
A cryptographic hash of the resource to be fetched by request. Sets request's integrity.
*/
mutable integrity?: string,
/**
A boolean to set request's keepalive.
*/
mutable keepalive?: bool,
/**
An AbortSignal to set request's signal.
*/
mutable signal?: Null.t<abortSignal>,
mutable priority?: requestPriority,
/**
Can only be null. Used to disassociate request from any Window.
*/
mutable window?: Null.t<unit>,
}
type responseInit = {
mutable status?: int,
mutable statusText?: string,
mutable headers?: headersInit,
}