@d1g1tal/transportr 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/transportr.js +887 -0
- package/dist/transportr.min.js +4 -0
- package/dist/transportr.min.js.map +7 -0
- package/index.d.ts +5 -0
- package/index.js +5 -0
- package/package.json +70 -0
- package/src/http-media-type.d.ts +149 -0
- package/src/http-media-type.js +150 -0
- package/src/http-request-headers.d.ts +43 -0
- package/src/http-request-headers.js +306 -0
- package/src/http-request-methods.d.ts +12 -0
- package/src/http-request-methods.js +271 -0
- package/src/http-response-headers.d.ts +46 -0
- package/src/http-response-headers.js +344 -0
- package/src/transportr.d.ts +509 -0
- package/src/transportr.js +462 -0
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
export default class Transportr {
|
|
2
|
+
/**
|
|
3
|
+
* @static
|
|
4
|
+
* @constant {Object<string, MediaType>}
|
|
5
|
+
*/
|
|
6
|
+
static "__#2@#MediaType": {
|
|
7
|
+
JSON: MediaType;
|
|
8
|
+
XML: MediaType;
|
|
9
|
+
HTML: MediaType;
|
|
10
|
+
SCRIPT: MediaType;
|
|
11
|
+
TEXT: MediaType;
|
|
12
|
+
CSS: MediaType;
|
|
13
|
+
WEBP: MediaType;
|
|
14
|
+
PNG: MediaType;
|
|
15
|
+
GIF: MediaType;
|
|
16
|
+
JPG: MediaType;
|
|
17
|
+
OTF: MediaType;
|
|
18
|
+
WOFF: MediaType;
|
|
19
|
+
WOFF2: MediaType;
|
|
20
|
+
TTF: MediaType;
|
|
21
|
+
PDF: MediaType;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* @static
|
|
25
|
+
* @type {SetMultiMap<ResponseHandler<ResponseBody>, string>}
|
|
26
|
+
*/
|
|
27
|
+
static "__#2@#contentTypeHandlers": SetMultiMap<ResponseHandler<ResponseBody>, string>;
|
|
28
|
+
/**
|
|
29
|
+
* @static
|
|
30
|
+
* @constant {Object<string, 'GET'|'POST'|'PUT'|'PATCH'|'DELETE'|'HEAD'|'OPTIONS'|'TRACE'|'CONNECT'>}
|
|
31
|
+
*/
|
|
32
|
+
static Method: Readonly<{
|
|
33
|
+
OPTIONS: string;
|
|
34
|
+
GET: string;
|
|
35
|
+
HEAD: string;
|
|
36
|
+
POST: string;
|
|
37
|
+
PUT: string; /**
|
|
38
|
+
* TODO - Do I need this? What special handling might this need??
|
|
39
|
+
*
|
|
40
|
+
* @async
|
|
41
|
+
* @param {string} path
|
|
42
|
+
* @param {RequestOptions} [options = {}]
|
|
43
|
+
* @returns {Promise<string>}
|
|
44
|
+
*/
|
|
45
|
+
DELETE: string;
|
|
46
|
+
TRACE: string;
|
|
47
|
+
CONNECT: string;
|
|
48
|
+
PATCH: string;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* @static
|
|
52
|
+
* @constant {Object<string, string>}
|
|
53
|
+
*/
|
|
54
|
+
static MediaType: {
|
|
55
|
+
AAC: string;
|
|
56
|
+
ABW: string;
|
|
57
|
+
ARC: string;
|
|
58
|
+
AVIF: string;
|
|
59
|
+
AVI: string;
|
|
60
|
+
AZW: string;
|
|
61
|
+
/** @typedef {Object<string, (boolean|string|number|Array)>} JsonObject */
|
|
62
|
+
/** @typedef {Blob|ArrayBuffer|TypedArray|DataView|FormData|URLSearchParams|string|ReadableStream} RequestBody */
|
|
63
|
+
/** @typedef {Blob|ArrayBuffer|FormData|string|ReadableStream} ResponseBody */
|
|
64
|
+
/** @typedef {'default'|'force-cache'|'no-cache'|'no-store'|'only-if-cached'|'reload'} RequestCache */
|
|
65
|
+
/** @typedef {'include'|'omit'|'same-origin'} RequestCredentials */
|
|
66
|
+
/** @typedef {Headers|Object<string, string>} RequestHeaders */
|
|
67
|
+
/** @typedef {'GET'|'POST'|'PUT'|'PATCH'|'DELETE'|'HEAD'|'OPTIONS'} RequestMethod */
|
|
68
|
+
/** @typedef {'cors'|'navigate'|'no-cors'|'same-origin'} RequestMode */
|
|
69
|
+
/** @typedef {'error'|'follow'|'manual'} RequestRedirect */
|
|
70
|
+
/** @typedef {''|'no-referrer'|'no-referrer-when-downgrade'|'origin'|'origin-when-cross-origin'|'same-origin'|'strict-origin'|'strict-origin-when-cross-origin'|'unsafe-url'} ReferrerPolicy */
|
|
71
|
+
/** @typedef {Int8Array|Uint8Array|Uint8ClampedArray|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array|BigInt64Array|BigUint64Array} TypedArray */
|
|
72
|
+
/**
|
|
73
|
+
* The options for a {@link Request} object or the second parameter of a {@link fetch} request
|
|
74
|
+
*
|
|
75
|
+
* @typedef {Object} RequestOptions
|
|
76
|
+
* @property {RequestBody} body A RequestInit object or null to set request's body.
|
|
77
|
+
* @property {RequestCache} cache A string indicating how the request will interact with the browser's cache to set request's cache.
|
|
78
|
+
* @property {RequestCredentials} credentials 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.
|
|
79
|
+
* @property {RequestHeaders} headers A Headers object, an object literal, or an array of two-item arrays to set request's headers.
|
|
80
|
+
* @property {string} integrity A cryptographic hash of the resource to be fetched by request. Sets request's integrity.
|
|
81
|
+
* @property {boolean} keepalive A boolean to set request's keepalive.
|
|
82
|
+
* @property {RequestMethod} method A string to set request's method.
|
|
83
|
+
* @property {RequestMode} mode A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.
|
|
84
|
+
* @property {RequestRedirect} redirect 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.
|
|
85
|
+
* @property {string} referrer A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer.
|
|
86
|
+
* @property {ReferrerPolicy} referrerPolicy A referrer policy to set request's referrerPolicy.
|
|
87
|
+
* @property {AbortSignal} signal An AbortSignal to set request's signal.
|
|
88
|
+
* @property {null} window Can only be null. Used to disassociate request from any Window.
|
|
89
|
+
*/
|
|
90
|
+
/** @extends Error */
|
|
91
|
+
BIN: string;
|
|
92
|
+
BMP: string; /** @typedef {Object<string, (boolean|string|number|Array)>} JsonObject */
|
|
93
|
+
BZIP: string;
|
|
94
|
+
BZIP2: string;
|
|
95
|
+
CDA: string;
|
|
96
|
+
CSH: string;
|
|
97
|
+
CSS: string;
|
|
98
|
+
CSV: string;
|
|
99
|
+
DOC: string;
|
|
100
|
+
DOCX: string;
|
|
101
|
+
EOT: string;
|
|
102
|
+
EPUB: string;
|
|
103
|
+
GZIP: string;
|
|
104
|
+
GIF: string;
|
|
105
|
+
HTML: string;
|
|
106
|
+
ICO: string;
|
|
107
|
+
ICS: string;
|
|
108
|
+
JAR: string;
|
|
109
|
+
JPEG: string;
|
|
110
|
+
JAVA_SCRIPT: string;
|
|
111
|
+
JSON: string;
|
|
112
|
+
JSON_LD: string;
|
|
113
|
+
MID: string;
|
|
114
|
+
X_MID: string;
|
|
115
|
+
MP3: string;
|
|
116
|
+
MP4A: string;
|
|
117
|
+
MP4: string;
|
|
118
|
+
MPEG: string;
|
|
119
|
+
MPKG: string;
|
|
120
|
+
ODP: string;
|
|
121
|
+
ODS: string;
|
|
122
|
+
ODT: string;
|
|
123
|
+
OGA: string;
|
|
124
|
+
OGV: string;
|
|
125
|
+
OGX: string;
|
|
126
|
+
OPUS: string;
|
|
127
|
+
OTF: string;
|
|
128
|
+
PNG: string;
|
|
129
|
+
PDF: string;
|
|
130
|
+
PHP: string;
|
|
131
|
+
PPT: string;
|
|
132
|
+
PPTX: string;
|
|
133
|
+
RAR: string;
|
|
134
|
+
RTF: string;
|
|
135
|
+
SH: string;
|
|
136
|
+
SVG: string;
|
|
137
|
+
TAR: string;
|
|
138
|
+
TIFF: string;
|
|
139
|
+
TRANSPORT_STREAM: string;
|
|
140
|
+
TTF: string;
|
|
141
|
+
TEXT: string;
|
|
142
|
+
VSD: string;
|
|
143
|
+
WAV: string;
|
|
144
|
+
WEBA: string;
|
|
145
|
+
WEBM: string;
|
|
146
|
+
WEBP: string;
|
|
147
|
+
WOFF: string;
|
|
148
|
+
WOFF2: string;
|
|
149
|
+
XHTML: string;
|
|
150
|
+
XLS: string;
|
|
151
|
+
XLSX: string;
|
|
152
|
+
XML: string;
|
|
153
|
+
XUL: string;
|
|
154
|
+
ZIP: string;
|
|
155
|
+
'3GP': string;
|
|
156
|
+
'3G2': string;
|
|
157
|
+
'7Z': string;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* @static
|
|
161
|
+
* @constant {Object<string, string>}
|
|
162
|
+
*/
|
|
163
|
+
static RequestHeader: {
|
|
164
|
+
ACCEPT: string;
|
|
165
|
+
ACCEPT_CHARSET: string;
|
|
166
|
+
ACCEPT_ENCODING: string;
|
|
167
|
+
ACCEPT_LANGUAGE: string;
|
|
168
|
+
AUTHORIZATION: string;
|
|
169
|
+
CACHE_CONTROL: string;
|
|
170
|
+
CONNECTION: string;
|
|
171
|
+
COOKIE: string;
|
|
172
|
+
CONTENT_LENGTH: string;
|
|
173
|
+
CONTENT_MD5: string;
|
|
174
|
+
CONTENT_TYPE: string;
|
|
175
|
+
DATE: string;
|
|
176
|
+
EXPECT: string;
|
|
177
|
+
FROM: string;
|
|
178
|
+
HOST: string;
|
|
179
|
+
IF_MATCH: string;
|
|
180
|
+
IF_MODIFIED_SINCE: string;
|
|
181
|
+
IF_NONE_MATCH: string;
|
|
182
|
+
IF_RANGE: string;
|
|
183
|
+
IF_UNMODIFIED_SINCE: string;
|
|
184
|
+
MAX_FORWARDS: string;
|
|
185
|
+
ORIGIN: string;
|
|
186
|
+
PRAGMA: string;
|
|
187
|
+
PROXY_AUTHORIZATION: string;
|
|
188
|
+
RANGE: string;
|
|
189
|
+
REFERER: string;
|
|
190
|
+
TE: string;
|
|
191
|
+
USER_AGENT: string;
|
|
192
|
+
UPGRADE: string;
|
|
193
|
+
VIA: string;
|
|
194
|
+
WARNING: string;
|
|
195
|
+
X_REQUESTED_WITH: string;
|
|
196
|
+
DNT: string;
|
|
197
|
+
X_FORWARDED_FOR: string;
|
|
198
|
+
X_FORWARDED_HOST: string;
|
|
199
|
+
X_FORWARDED_PROTO: string;
|
|
200
|
+
FRONT_END_HTTPS: string;
|
|
201
|
+
X_HTTP_METHOD_OVERRIDE: string;
|
|
202
|
+
X_ATT_DEVICE_ID: string;
|
|
203
|
+
X_WAP_PROFILE: string;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* @static
|
|
207
|
+
* @constant {Object<string, string>}
|
|
208
|
+
*/
|
|
209
|
+
static ResponseHeader: Readonly<{
|
|
210
|
+
PROXY_CONNECTION: string;
|
|
211
|
+
X_UIDH: string;
|
|
212
|
+
X_CSRF_TOKEN: string;
|
|
213
|
+
ACCESS_CONTROL_ALLOW_ORIGIN: string;
|
|
214
|
+
ACCEPT_PATCH: string;
|
|
215
|
+
ACCEPT_RANGES: string;
|
|
216
|
+
AGE: string;
|
|
217
|
+
ALLOW: string;
|
|
218
|
+
CACHE_CONTROL: string;
|
|
219
|
+
CONNECTION: string;
|
|
220
|
+
CONTENT_DISPOSITION: string;
|
|
221
|
+
CONTENT_ENCODING: string;
|
|
222
|
+
CONTENT_LANGUAGE: string;
|
|
223
|
+
CONTENT_LENGTH: string;
|
|
224
|
+
CONTENT_LOCATION: string;
|
|
225
|
+
CONTENT_RANGE: string;
|
|
226
|
+
CONTENT_TYPE: string;
|
|
227
|
+
DATE: string;
|
|
228
|
+
ETAG: string;
|
|
229
|
+
EXPIRES: string;
|
|
230
|
+
LAST_MODIFIED: string;
|
|
231
|
+
LINK: string;
|
|
232
|
+
LOCATION: string;
|
|
233
|
+
P3P: string;
|
|
234
|
+
PRAGMA: string;
|
|
235
|
+
PROXY_AUTHENTICATION: string;
|
|
236
|
+
PUBLIC_KEY_PINS: string;
|
|
237
|
+
RETRY_AFTER: string;
|
|
238
|
+
SERVER: string;
|
|
239
|
+
SET_COOKIE: string;
|
|
240
|
+
STATUS: string;
|
|
241
|
+
STRICT_TRANSPORT_SECURITY: string;
|
|
242
|
+
TRAILER: string;
|
|
243
|
+
TRANSFER_ENCODING: string;
|
|
244
|
+
UPGRADE: string;
|
|
245
|
+
VARY: string;
|
|
246
|
+
VIA: string;
|
|
247
|
+
WARNING: string;
|
|
248
|
+
WWW_AUTHENTICATE: string;
|
|
249
|
+
X_XSS_PROTECTION: string;
|
|
250
|
+
CONTENT_SECURITY_POLICY: string;
|
|
251
|
+
X_CONTENT_TYPE_OPTIONS: string;
|
|
252
|
+
X_POWERED_BY: string;
|
|
253
|
+
}>;
|
|
254
|
+
static CachingPolicy: {
|
|
255
|
+
DEFAULT: string;
|
|
256
|
+
FORCE_CACHE: string;
|
|
257
|
+
NO_CACHE: string;
|
|
258
|
+
NO_STORE: string;
|
|
259
|
+
ONLY_IF_CACHED: string;
|
|
260
|
+
RELOAD: string;
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* @static
|
|
264
|
+
* @type {Object<string, string>}
|
|
265
|
+
*/
|
|
266
|
+
static CredentialsPolicy: {
|
|
267
|
+
[x: string]: string;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
*
|
|
271
|
+
* @private
|
|
272
|
+
* @static
|
|
273
|
+
* @param {URL} url
|
|
274
|
+
* @param {string} path
|
|
275
|
+
* @param {Object} [searchParams = {}]
|
|
276
|
+
* @returns {URL}
|
|
277
|
+
*/
|
|
278
|
+
private static "__#2@#createUrl";
|
|
279
|
+
/**
|
|
280
|
+
*
|
|
281
|
+
* @private
|
|
282
|
+
* @static
|
|
283
|
+
* @async
|
|
284
|
+
* @param {Response} response
|
|
285
|
+
* @returns {Promise<ResponseBody|Response>}
|
|
286
|
+
*/
|
|
287
|
+
private static "__#2@#processResponse";
|
|
288
|
+
/**
|
|
289
|
+
* Create a new Transportr instance with the provided location or origin and context path.
|
|
290
|
+
*
|
|
291
|
+
* @param {URL | string} [url = location.origin] The URL for {@link fetch} requests.
|
|
292
|
+
*/
|
|
293
|
+
constructor(url?: URL | string);
|
|
294
|
+
/**
|
|
295
|
+
*
|
|
296
|
+
* @returns {URL} The base URL used for requests
|
|
297
|
+
*/
|
|
298
|
+
get baseUrl(): URL;
|
|
299
|
+
/**
|
|
300
|
+
*
|
|
301
|
+
* @async
|
|
302
|
+
* @param {string} path
|
|
303
|
+
* @param {RequestOptions} [options = {}]
|
|
304
|
+
* @returns {Promise<*>}
|
|
305
|
+
*/
|
|
306
|
+
get(path: string, options?: RequestOptions): Promise<any>;
|
|
307
|
+
/**
|
|
308
|
+
*
|
|
309
|
+
* @async
|
|
310
|
+
* @param {string} path
|
|
311
|
+
* @param {Object} body
|
|
312
|
+
* @param {RequestOptions} [options = {}]
|
|
313
|
+
* @returns {Promise<*>}
|
|
314
|
+
*/
|
|
315
|
+
post(path: string, body: any, options?: RequestOptions): Promise<any>;
|
|
316
|
+
/**
|
|
317
|
+
*
|
|
318
|
+
* @async
|
|
319
|
+
* @param {string} path
|
|
320
|
+
* @param {RequestOptions} [options = {}]
|
|
321
|
+
* @returns {Promise<*>}
|
|
322
|
+
*/
|
|
323
|
+
put(path: string, options?: RequestOptions): Promise<any>;
|
|
324
|
+
/**
|
|
325
|
+
*
|
|
326
|
+
* @async
|
|
327
|
+
* @param {string} path
|
|
328
|
+
* @param {RequestOptions} [options = {}]
|
|
329
|
+
* @returns {Promise<*>}
|
|
330
|
+
*/
|
|
331
|
+
patch(path: string, options?: RequestOptions): Promise<any>;
|
|
332
|
+
/**
|
|
333
|
+
*
|
|
334
|
+
* @async
|
|
335
|
+
* @param {string} path
|
|
336
|
+
* @param {RequestOptions} [options = {}]
|
|
337
|
+
* @returns {Promise<*>}
|
|
338
|
+
*/
|
|
339
|
+
delete(path: string, options?: RequestOptions): Promise<any>;
|
|
340
|
+
/**
|
|
341
|
+
*
|
|
342
|
+
* @async
|
|
343
|
+
* @param {string} path
|
|
344
|
+
* @param {RequestOptions} [options = {}]
|
|
345
|
+
* @returns {Promise<*>}
|
|
346
|
+
*/
|
|
347
|
+
head(path: string, options?: RequestOptions): Promise<any>;
|
|
348
|
+
/**
|
|
349
|
+
*
|
|
350
|
+
* @async
|
|
351
|
+
* @param {string} path
|
|
352
|
+
* @param {RequestOptions} [options = {}]
|
|
353
|
+
* @returns {Promise<*>}
|
|
354
|
+
*/
|
|
355
|
+
options(path: string, options?: RequestOptions): Promise<any>;
|
|
356
|
+
/**
|
|
357
|
+
*
|
|
358
|
+
* @async
|
|
359
|
+
* @param {string} path
|
|
360
|
+
* @param {RequestOptions} [options = {}]
|
|
361
|
+
* @returns {Promise<*>}
|
|
362
|
+
*/
|
|
363
|
+
request(path: string, options?: RequestOptions): Promise<any>;
|
|
364
|
+
/**
|
|
365
|
+
*
|
|
366
|
+
* @async
|
|
367
|
+
* @param {string} path
|
|
368
|
+
* @param {RequestOptions} [options = {}]
|
|
369
|
+
* @returns {Promise<JsonObject>}
|
|
370
|
+
*/
|
|
371
|
+
getJson(path: string, options?: RequestOptions): Promise<JsonObject>;
|
|
372
|
+
/**
|
|
373
|
+
*
|
|
374
|
+
* @async
|
|
375
|
+
* @param {string} path
|
|
376
|
+
* @param {RequestOptions} [options = {}]
|
|
377
|
+
* @returns {Promise<Document>}
|
|
378
|
+
*/
|
|
379
|
+
getXml(path: string, options?: RequestOptions): Promise<Document>;
|
|
380
|
+
/**
|
|
381
|
+
* TODO - Add way to return portion of the retrieved HTML using a selector. Like jQuery.
|
|
382
|
+
*
|
|
383
|
+
* @async
|
|
384
|
+
* @param {string} path
|
|
385
|
+
* @param {RequestOptions} [options = {}]
|
|
386
|
+
* @returns {Promise<string>}
|
|
387
|
+
*/
|
|
388
|
+
getHtml(path: string, options?: RequestOptions): Promise<string>;
|
|
389
|
+
/**
|
|
390
|
+
* TODO - Do I need this? What special handling might this need??
|
|
391
|
+
*
|
|
392
|
+
* @async
|
|
393
|
+
* @param {string} path
|
|
394
|
+
* @param {RequestOptions} [options = {}]
|
|
395
|
+
* @returns {Promise<string>}
|
|
396
|
+
*/
|
|
397
|
+
getScript(path: string, options?: RequestOptions): Promise<string>;
|
|
398
|
+
/**
|
|
399
|
+
*
|
|
400
|
+
* @async
|
|
401
|
+
* @param {string} path
|
|
402
|
+
* @param {RequestOptions} [options = {}]
|
|
403
|
+
* @returns {Promise<Blob>}
|
|
404
|
+
*/
|
|
405
|
+
getBlob(path: string, options?: RequestOptions): Promise<Blob>;
|
|
406
|
+
/**
|
|
407
|
+
*
|
|
408
|
+
* @async
|
|
409
|
+
* @param {string} path
|
|
410
|
+
* @param {RequestOptions} [options = {}]
|
|
411
|
+
* @returns {Promise<string>}
|
|
412
|
+
*/
|
|
413
|
+
getImage(path: string, options?: RequestOptions): Promise<string>;
|
|
414
|
+
/**
|
|
415
|
+
*
|
|
416
|
+
* @async
|
|
417
|
+
* @param {string} path
|
|
418
|
+
* @param {RequestOptions} [options = {}]
|
|
419
|
+
* @returns {Promise<ArrayBuffer>}
|
|
420
|
+
*/
|
|
421
|
+
getBuffer(path: string, options?: RequestOptions): Promise<ArrayBuffer>;
|
|
422
|
+
/**
|
|
423
|
+
*
|
|
424
|
+
* @async
|
|
425
|
+
* @param {string} path
|
|
426
|
+
* @param {RequestOptions} [options = {}]
|
|
427
|
+
* @returns {Promise<ReadableStream<Uint8Array>}
|
|
428
|
+
*/
|
|
429
|
+
getStream(path: string, options?: RequestOptions): Promise<ReadableStream<Uint8Array>>;
|
|
430
|
+
#private;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* <T>
|
|
434
|
+
*/
|
|
435
|
+
export type ResponseHandler<T> = (arg0: Response) => Promise<T>;
|
|
436
|
+
export type JsonObject = {
|
|
437
|
+
[x: string]: (boolean | string | number | any[]);
|
|
438
|
+
};
|
|
439
|
+
export type RequestBody = Blob | ArrayBuffer | TypedArray | DataView | FormData | URLSearchParams | string | ReadableStream;
|
|
440
|
+
export type ResponseBody = Blob | ArrayBuffer | FormData | string | ReadableStream;
|
|
441
|
+
export type RequestCache = 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
|
|
442
|
+
export type RequestCredentials = 'include' | 'omit' | 'same-origin';
|
|
443
|
+
export type RequestHeaders = Headers | {
|
|
444
|
+
[x: string]: string;
|
|
445
|
+
};
|
|
446
|
+
export type RequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
447
|
+
export type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin';
|
|
448
|
+
export type RequestRedirect = 'error' | 'follow' | 'manual';
|
|
449
|
+
export type ReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
450
|
+
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
451
|
+
/**
|
|
452
|
+
* The options for a {@link Request } object or the second parameter of a {@link fetch } request
|
|
453
|
+
*/
|
|
454
|
+
export type RequestOptions = {
|
|
455
|
+
/**
|
|
456
|
+
* A RequestInit object or null to set request's body.
|
|
457
|
+
*/
|
|
458
|
+
body: RequestBody;
|
|
459
|
+
/**
|
|
460
|
+
* A string indicating how the request will interact with the browser's cache to set request's cache.
|
|
461
|
+
*/
|
|
462
|
+
cache: RequestCache;
|
|
463
|
+
/**
|
|
464
|
+
* 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.
|
|
465
|
+
*/
|
|
466
|
+
credentials: RequestCredentials;
|
|
467
|
+
/**
|
|
468
|
+
* A Headers object, an object literal, or an array of two-item arrays to set request's headers.
|
|
469
|
+
*/
|
|
470
|
+
headers: RequestHeaders;
|
|
471
|
+
/**
|
|
472
|
+
* A cryptographic hash of the resource to be fetched by request. Sets request's integrity.
|
|
473
|
+
*/
|
|
474
|
+
integrity: string;
|
|
475
|
+
/**
|
|
476
|
+
* A boolean to set request's keepalive.
|
|
477
|
+
*/
|
|
478
|
+
keepalive: boolean;
|
|
479
|
+
/**
|
|
480
|
+
* A string to set request's method.
|
|
481
|
+
*/
|
|
482
|
+
method: RequestMethod;
|
|
483
|
+
/**
|
|
484
|
+
* A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.
|
|
485
|
+
*/
|
|
486
|
+
mode: RequestMode;
|
|
487
|
+
/**
|
|
488
|
+
* 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.
|
|
489
|
+
*/
|
|
490
|
+
redirect: RequestRedirect;
|
|
491
|
+
/**
|
|
492
|
+
* A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer.
|
|
493
|
+
*/
|
|
494
|
+
referrer: string;
|
|
495
|
+
/**
|
|
496
|
+
* A referrer policy to set request's referrerPolicy.
|
|
497
|
+
*/
|
|
498
|
+
referrerPolicy: ReferrerPolicy;
|
|
499
|
+
/**
|
|
500
|
+
* An AbortSignal to set request's signal.
|
|
501
|
+
*/
|
|
502
|
+
signal: AbortSignal;
|
|
503
|
+
/**
|
|
504
|
+
* Can only be null. Used to disassociate request from any Window.
|
|
505
|
+
*/
|
|
506
|
+
window: null;
|
|
507
|
+
};
|
|
508
|
+
import { MediaType } from "@d1g1tal/media-type";
|
|
509
|
+
import { SetMultiMap } from "@d1g1tal/collections";
|