@utiliread/http 1.19.6 → 1.20.1
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/dist/event-aggregator.d.ts +11 -0
- package/dist/events.d.ts +11 -0
- package/dist/header-names.d.ts +182 -0
- package/dist/helpers.d.ts +5 -0
- package/dist/http-builder.d.ts +61 -0
- package/dist/http-error.d.ts +10 -0
- package/dist/http-response.d.ts +18 -0
- package/dist/http.d.ts +33 -0
- package/dist/http.spec.d.ts +1 -0
- package/dist/index.d.ts +16 -231
- package/dist/index.js +616 -242
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +601 -215
- package/dist/index.mjs.map +1 -1
- package/dist/mapper.d.ts +9 -0
- package/dist/pagination.d.ts +23 -0
- package/dist/{json.d.ts → plugins/json/index.d.ts} +1 -2
- package/dist/plugins/json/index.js +87 -0
- package/dist/plugins/json/index.js.map +1 -0
- package/dist/plugins/json/index.mjs +85 -0
- package/dist/plugins/json/index.mjs.map +1 -0
- package/dist/{jsonpatch.d.ts → plugins/jsonpatch/index.d.ts} +0 -2
- package/dist/plugins/jsonpatch/index.js +21 -0
- package/dist/plugins/jsonpatch/index.js.map +1 -0
- package/dist/plugins/jsonpatch/index.mjs +19 -0
- package/dist/plugins/jsonpatch/index.mjs.map +1 -0
- package/dist/{msgpack.d.ts → plugins/msgpack/index.d.ts} +1 -2
- package/dist/plugins/msgpack/index.js +41 -0
- package/dist/plugins/msgpack/index.js.map +1 -0
- package/dist/plugins/msgpack/index.mjs +39 -0
- package/dist/plugins/msgpack/index.mjs.map +1 -0
- package/dist/problem-details.d.ts +7 -0
- package/dist/query-string.d.ts +6 -0
- package/dist/query-string.spec.d.ts +1 -0
- package/dist/status-codes.d.ts +65 -0
- package/dist/timeout-error.d.ts +3 -0
- package/json.d.ts +1 -1
- package/json.rollup.config.mjs +32 -0
- package/jsonpatch.d.ts +1 -1
- package/jsonpatch.rollup.config.mjs +32 -0
- package/msgpack.d.ts +1 -1
- package/msgpack.rollup.config.mjs +37 -0
- package/package.json +24 -24
- package/rollup.config.mjs +31 -0
- package/src/header-names.ts +273 -0
- package/src/index.ts +2 -1
- package/{plugins/json/src → src/plugins/json}/index.ts +138 -142
- package/{plugins/jsonpatch/src → src/plugins/jsonpatch}/index.ts +36 -36
- package/{plugins/msgpack/src → src/plugins/msgpack}/index.ts +69 -66
- package/src/status-codes.ts +65 -67
- package/tsconfig.json +6 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/json.d.ts.map +0 -1
- package/dist/json.js +0 -93
- package/dist/json.js.map +0 -1
- package/dist/json.mjs +0 -82
- package/dist/json.mjs.map +0 -1
- package/dist/jsonpatch.d.ts.map +0 -1
- package/dist/jsonpatch.js +0 -33
- package/dist/jsonpatch.js.map +0 -1
- package/dist/jsonpatch.mjs +0 -22
- package/dist/jsonpatch.mjs.map +0 -1
- package/dist/msgpack.d.ts.map +0 -1
- package/dist/msgpack.js +0 -50
- package/dist/msgpack.js.map +0 -1
- package/dist/msgpack.mjs +0 -39
- package/dist/msgpack.mjs.map +0 -1
- package/plugins/json/node_modules/@utiliread/http/package.json +0 -4
- package/plugins/json/package.json +0 -15
- package/plugins/json/tsconfig.json +0 -7
- package/plugins/jsonpatch/node_modules/@utiliread/http/package.json +0 -4
- package/plugins/jsonpatch/package.json +0 -16
- package/plugins/jsonpatch/tsconfig.json +0 -7
- package/plugins/msgpack/node_modules/@utiliread/http/package.json +0 -4
- package/plugins/msgpack/package.json +0 -16
- package/plugins/msgpack/tsconfig.json +0 -7
package/dist/index.js
CHANGED
|
@@ -1,86 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
var luxon = require('luxon');
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return;
|
|
5
|
+
class EventAggregator {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.callbacks = [];
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(dest, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return source[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return dest;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function $parcel$export(e, n, v, s) {
|
|
22
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
$parcel$export(module.exports, "Http", () => $071fc1f89bbb01d6$export$2a5b27776dbece47);
|
|
26
|
-
$parcel$export(module.exports, "QueryString", () => $2d2fb1ca67e3fdc1$export$eada748df1dd417f);
|
|
27
|
-
$parcel$export(module.exports, "HttpResponse", () => $ddf5c8852ff85dec$export$1d94dfe0d9d1f1e7);
|
|
28
|
-
$parcel$export(module.exports, "HttpResponseOfT", () => $ddf5c8852ff85dec$export$bcbae67b865a76d2);
|
|
29
|
-
$parcel$export(module.exports, "HttpBuilder", () => $b95ba42a6fda4623$export$fc624c0231d0f8a);
|
|
30
|
-
$parcel$export(module.exports, "HttpBuilderOfT", () => $b95ba42a6fda4623$export$7dfcf6a5b7becec8);
|
|
31
|
-
$parcel$export(module.exports, "HttpError", () => $22d313d0e1bb48b4$export$65bd6083489bd8bb);
|
|
32
|
-
$parcel$export(module.exports, "TimeoutError", () => $2449c0a03f7caf8c$export$66d311bf29d5c89c);
|
|
33
|
-
$parcel$export(module.exports, "events", () => $a541277566782c5f$export$4bf9923669ad6c63);
|
|
34
|
-
$parcel$export(module.exports, "statusCodes", () => $a6d3c6600287d438$export$5b6a6a9b6e9a7920);
|
|
35
|
-
class $0a30027052ee48d0$export$f93b90549b868d0 {
|
|
36
9
|
get any() {
|
|
37
10
|
return this.callbacks.length > 0;
|
|
38
11
|
}
|
|
39
12
|
subscribe(callback) {
|
|
40
13
|
this.callbacks.push(callback);
|
|
41
14
|
return {
|
|
42
|
-
dispose: ()=>{
|
|
15
|
+
dispose: () => {
|
|
43
16
|
const index = this.callbacks.indexOf(callback);
|
|
44
|
-
if (index >= 0)
|
|
45
|
-
|
|
17
|
+
if (index >= 0) {
|
|
18
|
+
this.callbacks.splice(index, 1);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
46
21
|
};
|
|
47
22
|
}
|
|
48
23
|
async publish(...params) {
|
|
49
24
|
const callbacks = this.callbacks.slice();
|
|
50
|
-
for (const callback of callbacks)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.callbacks = [];
|
|
25
|
+
for (const callback of callbacks) {
|
|
26
|
+
await Promise.resolve(callback.apply(this, params));
|
|
27
|
+
}
|
|
54
28
|
}
|
|
55
29
|
}
|
|
56
30
|
|
|
57
|
-
|
|
58
|
-
class $22d313d0e1bb48b4$export$65bd6083489bd8bb extends Error {
|
|
31
|
+
class HttpError extends Error {
|
|
59
32
|
get hasDetails() {
|
|
60
33
|
const contentType = this.response?.rawResponse?.headers.get("Content-Type");
|
|
61
34
|
return contentType?.includes("application/problem+json");
|
|
62
35
|
}
|
|
63
|
-
constructor(statusCode, response){
|
|
36
|
+
constructor(statusCode, response = undefined) {
|
|
64
37
|
super(`The response was not successful: ${statusCode}`);
|
|
65
38
|
this.statusCode = statusCode;
|
|
66
39
|
this.response = response;
|
|
67
40
|
this.name = "HttpError";
|
|
68
41
|
// Set the prototype explicitly to allow for "... instanceof HttpError",
|
|
69
42
|
// see https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
70
|
-
Object.setPrototypeOf(this,
|
|
43
|
+
Object.setPrototypeOf(this, HttpError.prototype);
|
|
71
44
|
}
|
|
72
45
|
details() {
|
|
73
46
|
const rawResponse = this.response?.rawResponse;
|
|
74
47
|
if (rawResponse && this.hasDetails) {
|
|
75
|
-
this.detailsPromise
|
|
76
|
-
|
|
48
|
+
this.detailsPromise ?? (this.detailsPromise = rawResponse
|
|
49
|
+
.json()
|
|
50
|
+
.then((details) => details));
|
|
51
|
+
return this.detailsPromise.then((details) => details);
|
|
77
52
|
}
|
|
78
53
|
return Promise.reject(new Error("There are no problem details in the response"));
|
|
79
54
|
}
|
|
80
55
|
}
|
|
81
56
|
|
|
82
|
-
|
|
83
|
-
class $ddf5c8852ff85dec$export$1d94dfe0d9d1f1e7 {
|
|
57
|
+
class HttpResponse {
|
|
84
58
|
get url() {
|
|
85
59
|
return this.rawResponse.url;
|
|
86
60
|
}
|
|
@@ -105,16 +79,18 @@ class $ddf5c8852ff85dec$export$1d94dfe0d9d1f1e7 {
|
|
|
105
79
|
get isServerError() {
|
|
106
80
|
return this.statusCode >= 500 && this.statusCode < 600;
|
|
107
81
|
}
|
|
108
|
-
constructor(rawResponse){
|
|
82
|
+
constructor(rawResponse) {
|
|
109
83
|
this.rawResponse = rawResponse;
|
|
110
84
|
}
|
|
111
85
|
ensureSuccessfulStatusCode() {
|
|
112
|
-
if (!this.isSuccessful)
|
|
86
|
+
if (!this.isSuccessful) {
|
|
87
|
+
throw new HttpError(this.statusCode, this);
|
|
88
|
+
}
|
|
113
89
|
return this;
|
|
114
90
|
}
|
|
115
91
|
}
|
|
116
|
-
class
|
|
117
|
-
constructor(rawResponse, handler){
|
|
92
|
+
class HttpResponseOfT extends HttpResponse {
|
|
93
|
+
constructor(rawResponse, handler) {
|
|
118
94
|
super(rawResponse);
|
|
119
95
|
this.handler = handler;
|
|
120
96
|
}
|
|
@@ -123,27 +99,25 @@ class $ddf5c8852ff85dec$export$bcbae67b865a76d2 extends $ddf5c8852ff85dec$export
|
|
|
123
99
|
}
|
|
124
100
|
}
|
|
125
101
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
constructor(){
|
|
102
|
+
class TimeoutError extends Error {
|
|
103
|
+
constructor() {
|
|
129
104
|
super("Timeout: The request was not successful");
|
|
130
105
|
this.name = "TimeoutError";
|
|
131
106
|
// Set the prototype explicitly to allow for "... instanceof TimeoutError",
|
|
132
107
|
// see https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
133
|
-
Object.setPrototypeOf(this,
|
|
108
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
134
109
|
}
|
|
135
110
|
}
|
|
136
111
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
constructor(message, options, /** @internal */ http){
|
|
112
|
+
class HttpBuilder {
|
|
113
|
+
constructor(message, options,
|
|
114
|
+
/** @internal */ http) {
|
|
141
115
|
this.message = message;
|
|
142
116
|
this.options = options;
|
|
143
117
|
this.http = http;
|
|
144
118
|
this._ensureSuccessStatusCode = true;
|
|
145
|
-
this._onSend = new (
|
|
146
|
-
this._onSent = new (
|
|
119
|
+
this._onSend = new EventAggregator();
|
|
120
|
+
this._onSent = new EventAggregator();
|
|
147
121
|
}
|
|
148
122
|
onSend(callback) {
|
|
149
123
|
this._onSend.subscribe(callback);
|
|
@@ -154,10 +128,12 @@ class $b95ba42a6fda4623$export$fc624c0231d0f8a {
|
|
|
154
128
|
return this;
|
|
155
129
|
}
|
|
156
130
|
useHandler(handler) {
|
|
157
|
-
return new
|
|
131
|
+
return new HttpBuilderOfT(this, handler);
|
|
158
132
|
}
|
|
159
133
|
async send(abortSignal) {
|
|
160
|
-
if (this.message.contentType)
|
|
134
|
+
if (this.message.contentType) {
|
|
135
|
+
this.message.headers.set("Content-Type", this.message.contentType);
|
|
136
|
+
}
|
|
161
137
|
// Resolve the final url and assign it to the message
|
|
162
138
|
// This makes the final url apper in onSend, onSent, and on Received handlers
|
|
163
139
|
this.message.url = this.getUrl();
|
|
@@ -167,40 +143,57 @@ class $b95ba42a6fda4623$export$fc624c0231d0f8a {
|
|
|
167
143
|
method: this.message.method,
|
|
168
144
|
body: this.message.content,
|
|
169
145
|
headers: this.message.headers,
|
|
170
|
-
mode: this.message.mode
|
|
146
|
+
mode: this.message.mode,
|
|
171
147
|
};
|
|
172
148
|
if (abortSignal || this.options.timeout) {
|
|
173
149
|
var outerController = new AbortController();
|
|
174
|
-
if (abortSignal)
|
|
175
|
-
|
|
176
|
-
|
|
150
|
+
if (abortSignal) {
|
|
151
|
+
abortSignal.addEventListener("abort", () => {
|
|
152
|
+
outerController.abort();
|
|
153
|
+
});
|
|
154
|
+
}
|
|
177
155
|
init.signal = outerController.signal;
|
|
178
156
|
}
|
|
179
157
|
const fetchResponsePromise = this.options.fetch(this.message.url, init);
|
|
180
158
|
let fetchResponse;
|
|
181
|
-
if (this.options.timeout)
|
|
182
|
-
|
|
183
|
-
|
|
159
|
+
if (this.options.timeout) {
|
|
160
|
+
fetchResponse = await Promise.race([
|
|
161
|
+
fetchResponsePromise,
|
|
162
|
+
new Promise((_, reject) => setTimeout(() => {
|
|
184
163
|
outerController.abort();
|
|
185
|
-
reject(new (
|
|
186
|
-
}, this.options.timeout))
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
164
|
+
reject(new TimeoutError());
|
|
165
|
+
}, this.options.timeout)),
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
fetchResponse = await fetchResponsePromise;
|
|
170
|
+
}
|
|
171
|
+
const httpResponse = new HttpResponse(fetchResponse);
|
|
172
|
+
if (this._ensureSuccessStatusCode) {
|
|
173
|
+
httpResponse.ensureSuccessfulStatusCode();
|
|
174
|
+
}
|
|
191
175
|
await this._onSent.publish(httpResponse, this.message);
|
|
192
176
|
await this.http._onSent.publish(httpResponse, this.message);
|
|
193
177
|
return httpResponse;
|
|
194
178
|
}
|
|
195
179
|
getUrl() {
|
|
196
180
|
let baseUrl = this.options.baseUrl;
|
|
197
|
-
if (!baseUrl)
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
181
|
+
if (!baseUrl) {
|
|
182
|
+
return this.message.url;
|
|
183
|
+
}
|
|
184
|
+
if (baseUrl.endsWith("/")) {
|
|
185
|
+
baseUrl = baseUrl.substr(0, baseUrl.length - 1);
|
|
186
|
+
}
|
|
187
|
+
if (this.message.url.startsWith("/")) {
|
|
188
|
+
return baseUrl + this.message.url;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
return baseUrl + "/" + this.message.url;
|
|
192
|
+
}
|
|
201
193
|
}
|
|
202
194
|
ensureSuccessStatusCode(ensureSuccessStatusCode) {
|
|
203
|
-
this._ensureSuccessStatusCode =
|
|
195
|
+
this._ensureSuccessStatusCode =
|
|
196
|
+
ensureSuccessStatusCode === false ? false : true;
|
|
204
197
|
return this;
|
|
205
198
|
}
|
|
206
199
|
useCors(mode) {
|
|
@@ -229,22 +222,22 @@ class $b95ba42a6fda4623$export$fc624c0231d0f8a {
|
|
|
229
222
|
}
|
|
230
223
|
// Expect Extensions
|
|
231
224
|
expectString() {
|
|
232
|
-
return this.useHandler((response)=>{
|
|
225
|
+
return this.useHandler((response) => {
|
|
233
226
|
return response.rawResponse.text();
|
|
234
227
|
});
|
|
235
228
|
}
|
|
236
229
|
expectBinary() {
|
|
237
|
-
return this.useHandler((response)=>{
|
|
230
|
+
return this.useHandler((response) => {
|
|
238
231
|
return response.rawResponse.arrayBuffer();
|
|
239
232
|
});
|
|
240
233
|
}
|
|
241
234
|
}
|
|
242
|
-
class
|
|
243
|
-
constructor(inner, handler){
|
|
235
|
+
class HttpBuilderOfT extends HttpBuilder {
|
|
236
|
+
constructor(inner, handler) {
|
|
244
237
|
super(inner.message, inner.options, inner.http);
|
|
245
238
|
this.inner = inner;
|
|
246
239
|
this.handler = handler;
|
|
247
|
-
this._onReceived = new (
|
|
240
|
+
this._onReceived = new EventAggregator();
|
|
248
241
|
}
|
|
249
242
|
onSend(callback) {
|
|
250
243
|
this.inner.onSend(callback);
|
|
@@ -267,9 +260,13 @@ class $b95ba42a6fda4623$export$7dfcf6a5b7becec8 extends $b95ba42a6fda4623$export
|
|
|
267
260
|
return this;
|
|
268
261
|
}
|
|
269
262
|
allowEmptyResponse() {
|
|
270
|
-
if (this._onReceived.any)
|
|
271
|
-
|
|
272
|
-
|
|
263
|
+
if (this._onReceived.any) {
|
|
264
|
+
throw new Error("onReceived() must be called after allowEmptyResponse() because the callback type changes");
|
|
265
|
+
}
|
|
266
|
+
return new HttpBuilderOfT(this.inner, (response) => {
|
|
267
|
+
if (response.statusCode === 204) {
|
|
268
|
+
return Promise.resolve(null);
|
|
269
|
+
}
|
|
273
270
|
return this.handler(response);
|
|
274
271
|
});
|
|
275
272
|
}
|
|
@@ -278,11 +275,13 @@ class $b95ba42a6fda4623$export$7dfcf6a5b7becec8 extends $b95ba42a6fda4623$export
|
|
|
278
275
|
return this;
|
|
279
276
|
}
|
|
280
277
|
send(abortSignal) {
|
|
281
|
-
const responsePromise = this.inner
|
|
282
|
-
|
|
278
|
+
const responsePromise = this.inner
|
|
279
|
+
.send(abortSignal)
|
|
280
|
+
.then((x) => new HttpResponseOfT(x.rawResponse, this.handler));
|
|
281
|
+
return asSendPromise(responsePromise, () => responsePromise.then((response) => this.handleReceive(response)));
|
|
283
282
|
}
|
|
284
283
|
transfer(abortSignal) {
|
|
285
|
-
return this.send(abortSignal).then((response)=>this.handleReceive(response));
|
|
284
|
+
return this.send(abortSignal).then((response) => this.handleReceive(response));
|
|
286
285
|
}
|
|
287
286
|
async handleReceive(response) {
|
|
288
287
|
const request = this.message;
|
|
@@ -292,23 +291,27 @@ class $b95ba42a6fda4623$export$7dfcf6a5b7becec8 extends $b95ba42a6fda4623$export
|
|
|
292
291
|
return value;
|
|
293
292
|
}
|
|
294
293
|
}
|
|
295
|
-
function
|
|
294
|
+
function asSendPromise(responsePromise, thenReceive) {
|
|
296
295
|
const sendPromise = responsePromise;
|
|
297
296
|
sendPromise.thenReceive = thenReceive;
|
|
298
297
|
return sendPromise;
|
|
299
298
|
}
|
|
300
299
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
class $2d2fb1ca67e3fdc1$export$eada748df1dd417f {
|
|
300
|
+
class QueryString {
|
|
304
301
|
static serialize(params) {
|
|
305
|
-
if (!params)
|
|
302
|
+
if (!params) {
|
|
303
|
+
return "";
|
|
304
|
+
}
|
|
306
305
|
const serialized = this._serializeQueryString(params);
|
|
307
|
-
if (!serialized.length)
|
|
306
|
+
if (!serialized.length) {
|
|
307
|
+
return "";
|
|
308
|
+
}
|
|
308
309
|
return "?" + serialized;
|
|
309
310
|
}
|
|
310
311
|
static append(url, params) {
|
|
311
|
-
if (!params)
|
|
312
|
+
if (!params) {
|
|
313
|
+
return url;
|
|
314
|
+
}
|
|
312
315
|
const any = url.indexOf("?") >= 0;
|
|
313
316
|
const separator = any ? "&" : "?";
|
|
314
317
|
return url + separator + this._serializeQueryString(params);
|
|
@@ -317,39 +320,56 @@ class $2d2fb1ca67e3fdc1$export$eada748df1dd417f {
|
|
|
317
320
|
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
|
|
318
321
|
const match = regex.exec(window.location.href);
|
|
319
322
|
if (match) {
|
|
320
|
-
if (match[1].length > 0)
|
|
321
|
-
|
|
323
|
+
if (match[1].length > 0) {
|
|
324
|
+
return decodeURIComponent(match[2]);
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
322
329
|
}
|
|
323
330
|
}
|
|
324
331
|
static _serializeQueryString(source, prefix) {
|
|
325
332
|
const parts = [];
|
|
326
|
-
for(const propertyName in source)
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
for (const propertyName in source) {
|
|
334
|
+
if (source.hasOwnProperty(propertyName)) {
|
|
335
|
+
const key = prefix != null
|
|
336
|
+
? prefix +
|
|
337
|
+
(Array.isArray(source)
|
|
338
|
+
? "[" + encodeURIComponent(propertyName) + "]"
|
|
339
|
+
: "." + encodeURIComponent(propertyName))
|
|
340
|
+
: encodeURIComponent(propertyName);
|
|
341
|
+
const value = source[propertyName];
|
|
342
|
+
if (value instanceof luxon.DateTime) {
|
|
343
|
+
if (value.isValid) {
|
|
344
|
+
parts.push(key + "=" + encodeURIComponent(value.toISO()));
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
else if (value === null) {
|
|
348
|
+
parts.push(key);
|
|
349
|
+
}
|
|
350
|
+
else if (value !== undefined) {
|
|
351
|
+
if (typeof value === "object") {
|
|
352
|
+
parts.push(this._serializeQueryString(value, key));
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
parts.push(key + "=" + encodeURIComponent(value));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
335
358
|
}
|
|
336
359
|
}
|
|
337
360
|
return parts.join("&");
|
|
338
361
|
}
|
|
339
362
|
}
|
|
340
363
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
this.
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
/** @internal */ this._onSent = new (0, $0a30027052ee48d0$export$f93b90549b868d0)();
|
|
351
|
-
/** @internal */ this._onReceived = new (0, $0a30027052ee48d0$export$f93b90549b868d0)();
|
|
352
|
-
this.options = Object.assign({}, $071fc1f89bbb01d6$export$2a5b27776dbece47.defaults, options); // Later sources' properties overwrite earlier ones.
|
|
364
|
+
class Http {
|
|
365
|
+
constructor(options) {
|
|
366
|
+
/** @internal */
|
|
367
|
+
this._onSend = new EventAggregator();
|
|
368
|
+
/** @internal */
|
|
369
|
+
this._onSent = new EventAggregator();
|
|
370
|
+
/** @internal */
|
|
371
|
+
this._onReceived = new EventAggregator();
|
|
372
|
+
this.options = Object.assign({}, Http.defaults, options); // Later sources' properties overwrite earlier ones.
|
|
353
373
|
}
|
|
354
374
|
static request(method, url, params) {
|
|
355
375
|
return this.getInstance().request(method, url, params);
|
|
@@ -374,25 +394,27 @@ class $071fc1f89bbb01d6$export$2a5b27776dbece47 {
|
|
|
374
394
|
}
|
|
375
395
|
static getInstance() {
|
|
376
396
|
if (!this.instance) {
|
|
377
|
-
this.instance = new
|
|
397
|
+
this.instance = new Http();
|
|
378
398
|
// The singleton instance should always use the static options
|
|
379
|
-
this.instance.options =
|
|
399
|
+
this.instance.options = Http.defaults;
|
|
380
400
|
}
|
|
381
401
|
return this.instance;
|
|
382
402
|
}
|
|
383
403
|
request(method, url, params) {
|
|
384
404
|
const message = {
|
|
385
|
-
method
|
|
386
|
-
url: url +
|
|
405
|
+
method,
|
|
406
|
+
url: url + QueryString.serialize(params),
|
|
387
407
|
headers: new Headers(),
|
|
388
|
-
properties: {}
|
|
408
|
+
properties: {},
|
|
389
409
|
};
|
|
390
410
|
const fetch = this.options.fetch;
|
|
391
|
-
if (!fetch)
|
|
392
|
-
|
|
393
|
-
|
|
411
|
+
if (!fetch) {
|
|
412
|
+
throw Error("fetch() is not properly configured");
|
|
413
|
+
}
|
|
414
|
+
const builder = new HttpBuilder(message, {
|
|
415
|
+
fetch,
|
|
394
416
|
timeout: this.options.timeout,
|
|
395
|
-
baseUrl: this.options.baseUrl
|
|
417
|
+
baseUrl: this.options.baseUrl,
|
|
396
418
|
}, this);
|
|
397
419
|
return builder;
|
|
398
420
|
}
|
|
@@ -424,141 +446,493 @@ class $071fc1f89bbb01d6$export$2a5b27776dbece47 {
|
|
|
424
446
|
return this._onReceived.subscribe(callback);
|
|
425
447
|
}
|
|
426
448
|
}
|
|
449
|
+
Http.defaults = {
|
|
450
|
+
fetch: self.fetch ? self.fetch.bind(self) : undefined,
|
|
451
|
+
};
|
|
427
452
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
function $a541277566782c5f$export$4bf9923669ad6c63(action, configure) {
|
|
436
|
-
return function(...params) {
|
|
453
|
+
function events(action, configure) {
|
|
454
|
+
return function (...params) {
|
|
437
455
|
const builder = action(...params);
|
|
438
456
|
const events = configure(...params);
|
|
439
|
-
if (events.sent)
|
|
440
|
-
|
|
457
|
+
if (events.sent) {
|
|
458
|
+
builder.onSent(events.sent);
|
|
459
|
+
}
|
|
460
|
+
if (builder instanceof HttpBuilderOfT && events.received) {
|
|
461
|
+
builder.onReceived(events.received);
|
|
462
|
+
}
|
|
441
463
|
return builder;
|
|
442
464
|
};
|
|
443
465
|
}
|
|
444
466
|
|
|
445
|
-
|
|
446
|
-
var $dfecd32049fa58e9$exports = {};
|
|
447
|
-
|
|
448
|
-
$parcel$export($dfecd32049fa58e9$exports, "isHttpError", () => $dfecd32049fa58e9$export$97b788730ba59845);
|
|
449
|
-
$parcel$export($dfecd32049fa58e9$exports, "isAbortError", () => $dfecd32049fa58e9$export$d2c30ea522b3259e);
|
|
450
|
-
$parcel$export($dfecd32049fa58e9$exports, "isTimeoutError", () => $dfecd32049fa58e9$export$f47339bf28a93789);
|
|
451
|
-
function $dfecd32049fa58e9$export$97b788730ba59845(error) {
|
|
467
|
+
function isHttpError(error) {
|
|
452
468
|
return error.name === "HttpError";
|
|
453
469
|
}
|
|
454
|
-
function
|
|
470
|
+
function isAbortError(error) {
|
|
455
471
|
return error.name === "AbortError";
|
|
456
472
|
}
|
|
457
|
-
function
|
|
473
|
+
function isTimeoutError(error) {
|
|
458
474
|
return error.name === "TimeoutError";
|
|
459
475
|
}
|
|
460
476
|
|
|
461
|
-
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
477
|
+
/** Gets the `Accept` HTTP header name. */
|
|
478
|
+
const accept = "Accept";
|
|
479
|
+
/** Gets the `Accept-Charset` HTTP header name. */
|
|
480
|
+
const acceptCharset = "Accept-Charset";
|
|
481
|
+
/** Gets the `Accept-Encoding` HTTP header name. */
|
|
482
|
+
const acceptEncoding = "Accept-Encoding";
|
|
483
|
+
/** Gets the `Accept-Language` HTTP header name. */
|
|
484
|
+
const acceptLanguage = "Accept-Language";
|
|
485
|
+
/** Gets the `Accept-Ranges` HTTP header name. */
|
|
486
|
+
const acceptRanges = "Accept-Ranges";
|
|
487
|
+
/** Gets the `Access-Control-Allow-Credentials` HTTP header name. */
|
|
488
|
+
const accessControlAllowCredentials = "Access-Control-Allow-Credentials";
|
|
489
|
+
/** Gets the `Access-Control-Allow-Headers` HTTP header name. */
|
|
490
|
+
const accessControlAllowHeaders = "Access-Control-Allow-Headers";
|
|
491
|
+
/** Gets the `Access-Control-Allow-Methods` HTTP header name. */
|
|
492
|
+
const accessControlAllowMethods = "Access-Control-Allow-Methods";
|
|
493
|
+
/** Gets the `Access-Control-Allow-Origin` HTTP header name. */
|
|
494
|
+
const accessControlAllowOrigin = "Access-Control-Allow-Origin";
|
|
495
|
+
/** Gets the `Access-Control-Expose-Headers` HTTP header name. */
|
|
496
|
+
const accessControlExposeHeaders = "Access-Control-Expose-Headers";
|
|
497
|
+
/** Gets the `Access-Control-Max-Age` HTTP header name. */
|
|
498
|
+
const accessControlMaxAge = "Access-Control-Max-Age";
|
|
499
|
+
/** Gets the `Access-Control-Request-Headers` HTTP header name. */
|
|
500
|
+
const accessControlRequestHeaders = "Access-Control-Request-Headers";
|
|
501
|
+
/** Gets the `Access-Control-Request-Method` HTTP header name. */
|
|
502
|
+
const accessControlRequestMethod = "Access-Control-Request-Method";
|
|
503
|
+
/** Gets the `Age` HTTP header name. */
|
|
504
|
+
const age = "Age";
|
|
505
|
+
/** Gets the `Allow` HTTP header name. */
|
|
506
|
+
const allow = "Allow";
|
|
507
|
+
/** Gets the `Alt-Svc` HTTP header name. */
|
|
508
|
+
const altSvc = "Alt-Svc";
|
|
509
|
+
/** Gets the `Authorization` HTTP header name. */
|
|
510
|
+
const authorization = "Authorization";
|
|
511
|
+
/** Gets the `baggage` HTTP header name. */
|
|
512
|
+
const baggage = "baggage";
|
|
513
|
+
/** Gets the `Cache-Control` HTTP header name. */
|
|
514
|
+
const cacheControl = "Cache-Control";
|
|
515
|
+
/** Gets the `Connection` HTTP header name. */
|
|
516
|
+
const connection = "Connection";
|
|
517
|
+
/** Gets the `Content-Disposition` HTTP header name. */
|
|
518
|
+
const contentDisposition = "Content-Disposition";
|
|
519
|
+
/** Gets the `Content-Encoding` HTTP header name. */
|
|
520
|
+
const contentEncoding = "Content-Encoding";
|
|
521
|
+
/** Gets the `Content-Language` HTTP header name. */
|
|
522
|
+
const contentLanguage = "Content-Language";
|
|
523
|
+
/** Gets the `Content-Length` HTTP header name. */
|
|
524
|
+
const contentLength = "Content-Length";
|
|
525
|
+
/** Gets the `Content-Location` HTTP header name. */
|
|
526
|
+
const contentLocation = "Content-Location";
|
|
527
|
+
/** Gets the `Content-MD5` HTTP header name. */
|
|
528
|
+
const contentMD5 = "Content-MD5";
|
|
529
|
+
/** Gets the `Content-Range` HTTP header name. */
|
|
530
|
+
const contentRange = "Content-Range";
|
|
531
|
+
/** Gets the `Content-Security-Policy` HTTP header name. */
|
|
532
|
+
const contentSecurityPolicy = "Content-Security-Policy";
|
|
533
|
+
/** Gets the `Content-Security-Policy-Report-Only` HTTP header name. */
|
|
534
|
+
const contentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only";
|
|
535
|
+
/** Gets the `Content-Type` HTTP header name. */
|
|
536
|
+
const contentType = "Content-Type";
|
|
537
|
+
/** Gets the `Correlation-Context` HTTP header name. */
|
|
538
|
+
const correlationContext = "Correlation-Context";
|
|
539
|
+
/** Gets the `Cookie` HTTP header name. */
|
|
540
|
+
const cookie = "Cookie";
|
|
541
|
+
/** Gets the `Date` HTTP header name. */
|
|
542
|
+
const date = "Date";
|
|
543
|
+
/** Gets the `DNT` HTTP header name. */
|
|
544
|
+
const dnt = "DNT";
|
|
545
|
+
/** Gets the `ETag` HTTP header name. */
|
|
546
|
+
const eTag = "ETag";
|
|
547
|
+
/** Gets the `Expires` HTTP header name. */
|
|
548
|
+
const expires = "Expires";
|
|
549
|
+
/** Gets the `Expect` HTTP header name. */
|
|
550
|
+
const expect = "Expect";
|
|
551
|
+
/** Gets the `From` HTTP header name. */
|
|
552
|
+
const from = "From";
|
|
553
|
+
/** Gets the `Grpc-Accept-Encoding` HTTP header name. */
|
|
554
|
+
const grpcAcceptEncoding = "Grpc-Accept-Encoding";
|
|
555
|
+
/** Gets the `Grpc-Encoding` HTTP header name. */
|
|
556
|
+
const grpcEncoding = "Grpc-Encoding";
|
|
557
|
+
/** Gets the `Grpc-Message` HTTP header name. */
|
|
558
|
+
const grpcMessage = "Grpc-Message";
|
|
559
|
+
/** Gets the `Grpc-Status` HTTP header name. */
|
|
560
|
+
const grpcStatus = "Grpc-Status";
|
|
561
|
+
/** Gets the `Grpc-Timeout` HTTP header name. */
|
|
562
|
+
const grpcTimeout = "Grpc-Timeout";
|
|
563
|
+
/** Gets the `Host` HTTP header name. */
|
|
564
|
+
const host = "Host";
|
|
565
|
+
/** Gets the `Keep-Alive` HTTP header name. */
|
|
566
|
+
const keepAlive = "Keep-Alive";
|
|
567
|
+
/** Gets the `If-Match` HTTP header name. */
|
|
568
|
+
const ifMatch = "If-Match";
|
|
569
|
+
/** Gets the `If-Modified-Since` HTTP header name. */
|
|
570
|
+
const ifModifiedSince = "If-Modified-Since";
|
|
571
|
+
/** Gets the `If-None-Match` HTTP header name. */
|
|
572
|
+
const ifNoneMatch = "If-None-Match";
|
|
573
|
+
/** Gets the `If-Range` HTTP header name. */
|
|
574
|
+
const ifRange = "If-Range";
|
|
575
|
+
/** Gets the `If-Unmodified-Since` HTTP header name. */
|
|
576
|
+
const ifUnmodifiedSince = "If-Unmodified-Since";
|
|
577
|
+
/** Gets the `Last-Modified` HTTP header name. */
|
|
578
|
+
const lastModified = "Last-Modified";
|
|
579
|
+
/** Gets the `Link` HTTP header name. */
|
|
580
|
+
const link = "Link";
|
|
581
|
+
/** Gets the `Location` HTTP header name. */
|
|
582
|
+
const location = "Location";
|
|
583
|
+
/** Gets the `Max-Forwards` HTTP header name. */
|
|
584
|
+
const maxForwards = "Max-Forwards";
|
|
585
|
+
/** Gets the `Origin` HTTP header name. */
|
|
586
|
+
const origin = "Origin";
|
|
587
|
+
/** Gets the `Pragma` HTTP header name. */
|
|
588
|
+
const pragma = "Pragma";
|
|
589
|
+
/** Gets the `Proxy-Authenticate` HTTP header name. */
|
|
590
|
+
const proxyAuthenticate = "Proxy-Authenticate";
|
|
591
|
+
/** Gets the `Proxy-Authorization` HTTP header name. */
|
|
592
|
+
const proxyAuthorization = "Proxy-Authorization";
|
|
593
|
+
/** Gets the `Proxy-Connection` HTTP header name. */
|
|
594
|
+
const proxyConnection = "Proxy-Connection";
|
|
595
|
+
/** Gets the `Range` HTTP header name. */
|
|
596
|
+
const range = "Range";
|
|
597
|
+
/** Gets the `Referer` HTTP header name. */
|
|
598
|
+
const referer = "Referer";
|
|
599
|
+
/** Gets the `Retry-After` HTTP header name. */
|
|
600
|
+
const retryAfter = "Retry-After";
|
|
601
|
+
/** Gets the `Request-Id` HTTP header name. */
|
|
602
|
+
const requestId = "Request-Id";
|
|
603
|
+
/** Gets the `Sec-WebSocket-Accept` HTTP header name. */
|
|
604
|
+
const secWebSocketAccept = "Sec-WebSocket-Accept";
|
|
605
|
+
/** Gets the `Sec-WebSocket-Key` HTTP header name. */
|
|
606
|
+
const secWebSocketKey = "Sec-WebSocket-Key";
|
|
607
|
+
/** Gets the `Sec-WebSocket-Protocol` HTTP header name. */
|
|
608
|
+
const secWebSocketProtocol = "Sec-WebSocket-Protocol";
|
|
609
|
+
/** Gets the `Sec-WebSocket-Version` HTTP header name. */
|
|
610
|
+
const secWebSocketVersion = "Sec-WebSocket-Version";
|
|
611
|
+
/** Gets the `Sec-WebSocket-Extensions` HTTP header name. */
|
|
612
|
+
const secWebSocketExtensions = "Sec-WebSocket-Extensions";
|
|
613
|
+
/** Gets the `Server` HTTP header name. */
|
|
614
|
+
const server = "Server";
|
|
615
|
+
/** Gets the `Set-Cookie` HTTP header name. */
|
|
616
|
+
const setCookie = "Set-Cookie";
|
|
617
|
+
/** Gets the `Strict-Transport-Security` HTTP header name. */
|
|
618
|
+
const strictTransportSecurity = "Strict-Transport-Security";
|
|
619
|
+
/** Gets the `TE` HTTP header name. */
|
|
620
|
+
const te = "TE";
|
|
621
|
+
/** Gets the `Trailer` HTTP header name. */
|
|
622
|
+
const trailer = "Trailer";
|
|
623
|
+
/** Gets the `Transfer-Encoding` HTTP header name. */
|
|
624
|
+
const transferEncoding = "Transfer-Encoding";
|
|
625
|
+
/** Gets the `Translate` HTTP header name. */
|
|
626
|
+
const translate = "Translate";
|
|
627
|
+
/** Gets the `traceparent` HTTP header name. */
|
|
628
|
+
const traceParent = "traceparent";
|
|
629
|
+
/** Gets the `tracestate` HTTP header name. */
|
|
630
|
+
const traceState = "tracestate";
|
|
631
|
+
/** Gets the `Upgrade` HTTP header name. */
|
|
632
|
+
const upgrade = "Upgrade";
|
|
633
|
+
/** Gets the `Upgrade-Insecure-Requests` HTTP header name. */
|
|
634
|
+
const upgradeInsecureRequests = "Upgrade-Insecure-Requests";
|
|
635
|
+
/** Gets the `User-Agent` HTTP header name. */
|
|
636
|
+
const userAgent = "User-Agent";
|
|
637
|
+
/** Gets the `Vary` HTTP header name. */
|
|
638
|
+
const vary = "Vary";
|
|
639
|
+
/** Gets the `Via` HTTP header name. */
|
|
640
|
+
const via = "Via";
|
|
641
|
+
/** Gets the `Warning` HTTP header name. */
|
|
642
|
+
const warning = "Warning";
|
|
643
|
+
/** Gets the `Sec-WebSocket-Protocol` HTTP header name. */
|
|
644
|
+
const webSocketSubProtocols = "Sec-WebSocket-Protocol";
|
|
645
|
+
/** Gets the `WWW-Authenticate` HTTP header name. */
|
|
646
|
+
const wWWAuthenticate = "WWW-Authenticate";
|
|
647
|
+
/** Gets the `X-Content-Type-Options` HTTP header name. */
|
|
648
|
+
const xContentTypeOptions = "X-Content-Type-Options";
|
|
649
|
+
/** Gets the `X-Frame-Options` HTTP header name. */
|
|
650
|
+
const xFrameOptions = "X-Frame-Options";
|
|
651
|
+
/** Gets the `X-Powered-By` HTTP header name. */
|
|
652
|
+
const xPoweredBy = "X-Powered-By";
|
|
653
|
+
/** Gets the `X-Requested-With` HTTP header name. */
|
|
654
|
+
const xRequestedWith = "X-Requested-With";
|
|
655
|
+
/** Gets the `X-UA-Compatible` HTTP header name. */
|
|
656
|
+
const xUACompatible = "X-UA-Compatible";
|
|
657
|
+
/** Gets the `X-XSS-Protection` HTTP header name. */
|
|
658
|
+
const xXSSProtection = "X-XSS-Protection";
|
|
659
|
+
|
|
660
|
+
var headerNames = /*#__PURE__*/Object.freeze({
|
|
661
|
+
__proto__: null,
|
|
662
|
+
accept: accept,
|
|
663
|
+
acceptCharset: acceptCharset,
|
|
664
|
+
acceptEncoding: acceptEncoding,
|
|
665
|
+
acceptLanguage: acceptLanguage,
|
|
666
|
+
acceptRanges: acceptRanges,
|
|
667
|
+
accessControlAllowCredentials: accessControlAllowCredentials,
|
|
668
|
+
accessControlAllowHeaders: accessControlAllowHeaders,
|
|
669
|
+
accessControlAllowMethods: accessControlAllowMethods,
|
|
670
|
+
accessControlAllowOrigin: accessControlAllowOrigin,
|
|
671
|
+
accessControlExposeHeaders: accessControlExposeHeaders,
|
|
672
|
+
accessControlMaxAge: accessControlMaxAge,
|
|
673
|
+
accessControlRequestHeaders: accessControlRequestHeaders,
|
|
674
|
+
accessControlRequestMethod: accessControlRequestMethod,
|
|
675
|
+
age: age,
|
|
676
|
+
allow: allow,
|
|
677
|
+
altSvc: altSvc,
|
|
678
|
+
authorization: authorization,
|
|
679
|
+
baggage: baggage,
|
|
680
|
+
cacheControl: cacheControl,
|
|
681
|
+
connection: connection,
|
|
682
|
+
contentDisposition: contentDisposition,
|
|
683
|
+
contentEncoding: contentEncoding,
|
|
684
|
+
contentLanguage: contentLanguage,
|
|
685
|
+
contentLength: contentLength,
|
|
686
|
+
contentLocation: contentLocation,
|
|
687
|
+
contentMD5: contentMD5,
|
|
688
|
+
contentRange: contentRange,
|
|
689
|
+
contentSecurityPolicy: contentSecurityPolicy,
|
|
690
|
+
contentSecurityPolicyReportOnly: contentSecurityPolicyReportOnly,
|
|
691
|
+
contentType: contentType,
|
|
692
|
+
cookie: cookie,
|
|
693
|
+
correlationContext: correlationContext,
|
|
694
|
+
date: date,
|
|
695
|
+
dnt: dnt,
|
|
696
|
+
eTag: eTag,
|
|
697
|
+
expect: expect,
|
|
698
|
+
expires: expires,
|
|
699
|
+
from: from,
|
|
700
|
+
grpcAcceptEncoding: grpcAcceptEncoding,
|
|
701
|
+
grpcEncoding: grpcEncoding,
|
|
702
|
+
grpcMessage: grpcMessage,
|
|
703
|
+
grpcStatus: grpcStatus,
|
|
704
|
+
grpcTimeout: grpcTimeout,
|
|
705
|
+
host: host,
|
|
706
|
+
ifMatch: ifMatch,
|
|
707
|
+
ifModifiedSince: ifModifiedSince,
|
|
708
|
+
ifNoneMatch: ifNoneMatch,
|
|
709
|
+
ifRange: ifRange,
|
|
710
|
+
ifUnmodifiedSince: ifUnmodifiedSince,
|
|
711
|
+
keepAlive: keepAlive,
|
|
712
|
+
lastModified: lastModified,
|
|
713
|
+
link: link,
|
|
714
|
+
location: location,
|
|
715
|
+
maxForwards: maxForwards,
|
|
716
|
+
origin: origin,
|
|
717
|
+
pragma: pragma,
|
|
718
|
+
proxyAuthenticate: proxyAuthenticate,
|
|
719
|
+
proxyAuthorization: proxyAuthorization,
|
|
720
|
+
proxyConnection: proxyConnection,
|
|
721
|
+
range: range,
|
|
722
|
+
referer: referer,
|
|
723
|
+
requestId: requestId,
|
|
724
|
+
retryAfter: retryAfter,
|
|
725
|
+
secWebSocketAccept: secWebSocketAccept,
|
|
726
|
+
secWebSocketExtensions: secWebSocketExtensions,
|
|
727
|
+
secWebSocketKey: secWebSocketKey,
|
|
728
|
+
secWebSocketProtocol: secWebSocketProtocol,
|
|
729
|
+
secWebSocketVersion: secWebSocketVersion,
|
|
730
|
+
server: server,
|
|
731
|
+
setCookie: setCookie,
|
|
732
|
+
strictTransportSecurity: strictTransportSecurity,
|
|
733
|
+
te: te,
|
|
734
|
+
traceParent: traceParent,
|
|
735
|
+
traceState: traceState,
|
|
736
|
+
trailer: trailer,
|
|
737
|
+
transferEncoding: transferEncoding,
|
|
738
|
+
translate: translate,
|
|
739
|
+
upgrade: upgrade,
|
|
740
|
+
upgradeInsecureRequests: upgradeInsecureRequests,
|
|
741
|
+
userAgent: userAgent,
|
|
742
|
+
vary: vary,
|
|
743
|
+
via: via,
|
|
744
|
+
wWWAuthenticate: wWWAuthenticate,
|
|
745
|
+
warning: warning,
|
|
746
|
+
webSocketSubProtocols: webSocketSubProtocols,
|
|
747
|
+
xContentTypeOptions: xContentTypeOptions,
|
|
748
|
+
xFrameOptions: xFrameOptions,
|
|
749
|
+
xPoweredBy: xPoweredBy,
|
|
750
|
+
xRequestedWith: xRequestedWith,
|
|
751
|
+
xUACompatible: xUACompatible,
|
|
752
|
+
xXSSProtection: xXSSProtection
|
|
528
753
|
});
|
|
529
754
|
|
|
755
|
+
const status100Continue = 100;
|
|
756
|
+
const status101SwitchingProtocols = 101;
|
|
757
|
+
const status102Processing = 102;
|
|
758
|
+
const status200OK = 200;
|
|
759
|
+
const status201Created = 201;
|
|
760
|
+
const status202Accepted = 202;
|
|
761
|
+
const status203NonAuthoritative = 203;
|
|
762
|
+
const status204NoContent = 204;
|
|
763
|
+
const status205ResetContent = 205;
|
|
764
|
+
const status206PartialContent = 206;
|
|
765
|
+
const status207MultiStatus = 207;
|
|
766
|
+
const status208AlreadyReported = 208;
|
|
767
|
+
const status226IMUsed = 226;
|
|
768
|
+
const status300MultipleChoices = 300;
|
|
769
|
+
const status301MovedPermanently = 301;
|
|
770
|
+
const status302Found = 302;
|
|
771
|
+
const status303SeeOther = 303;
|
|
772
|
+
const status304NotModified = 304;
|
|
773
|
+
const status305UseProxy = 305;
|
|
774
|
+
const status306SwitchProxy = 306;
|
|
775
|
+
const status307TemporaryRedirect = 307;
|
|
776
|
+
const status308PermanentRedirect = 308;
|
|
777
|
+
const status400BadRequest = 400;
|
|
778
|
+
const status401Unauthorized = 401;
|
|
779
|
+
const status402PaymentRequired = 402;
|
|
780
|
+
const status403Forbidden = 403;
|
|
781
|
+
const status404NotFound = 404;
|
|
782
|
+
const status405MethodNotAllowed = 405;
|
|
783
|
+
const status406NotAcceptable = 406;
|
|
784
|
+
const status407ProxyAuthenticationRequired = 407;
|
|
785
|
+
const status408RequestTimeout = 408;
|
|
786
|
+
const status409Conflict = 409;
|
|
787
|
+
const status410Gone = 410;
|
|
788
|
+
const status411LengthRequired = 411;
|
|
789
|
+
const status412PreconditionFailed = 412;
|
|
790
|
+
const status413RequestEntityTooLarge = 413;
|
|
791
|
+
const status413PayloadTooLarge = 413;
|
|
792
|
+
const status414RequestUriTooLong = 414;
|
|
793
|
+
const status414UriTooLong = 414;
|
|
794
|
+
const status415UnsupportedMediaType = 415;
|
|
795
|
+
const status416RequestedRangeNotSatisfiable = 416;
|
|
796
|
+
const status416RangeNotSatisfiable = 416;
|
|
797
|
+
const status417ExpectationFailed = 417;
|
|
798
|
+
const status418ImATeapot = 418;
|
|
799
|
+
const status419AuthenticationTimeout = 419;
|
|
800
|
+
const status421MisdirectedRequest = 421;
|
|
801
|
+
const status422UnprocessableEntity = 422;
|
|
802
|
+
const status423Locked = 423;
|
|
803
|
+
const status424FailedDependency = 424;
|
|
804
|
+
const status426UpgradeRequired = 426;
|
|
805
|
+
const status428PreconditionRequired = 428;
|
|
806
|
+
const status429TooManyRequests = 429;
|
|
807
|
+
const status431RequestHeaderFieldsTooLarge = 431;
|
|
808
|
+
const status451UnavailableForLegalReasons = 451;
|
|
809
|
+
const status500InternalServerError = 500;
|
|
810
|
+
const status501NotImplemented = 501;
|
|
811
|
+
const status502BadGateway = 502;
|
|
812
|
+
const status503ServiceUnavailable = 503;
|
|
813
|
+
const status504GatewayTimeout = 504;
|
|
814
|
+
const status505HttpVersionNotsupported = 505;
|
|
815
|
+
const status506VariantAlsoNegotiates = 506;
|
|
816
|
+
const status507InsufficientStorage = 507;
|
|
817
|
+
const status508LoopDetected = 508;
|
|
818
|
+
const status510NotExtended = 510;
|
|
819
|
+
const status511NetworkAuthenticationRequired = 511;
|
|
820
|
+
|
|
821
|
+
var statusCodes = /*#__PURE__*/Object.freeze({
|
|
822
|
+
__proto__: null,
|
|
823
|
+
status100Continue: status100Continue,
|
|
824
|
+
status101SwitchingProtocols: status101SwitchingProtocols,
|
|
825
|
+
status102Processing: status102Processing,
|
|
826
|
+
status200OK: status200OK,
|
|
827
|
+
status201Created: status201Created,
|
|
828
|
+
status202Accepted: status202Accepted,
|
|
829
|
+
status203NonAuthoritative: status203NonAuthoritative,
|
|
830
|
+
status204NoContent: status204NoContent,
|
|
831
|
+
status205ResetContent: status205ResetContent,
|
|
832
|
+
status206PartialContent: status206PartialContent,
|
|
833
|
+
status207MultiStatus: status207MultiStatus,
|
|
834
|
+
status208AlreadyReported: status208AlreadyReported,
|
|
835
|
+
status226IMUsed: status226IMUsed,
|
|
836
|
+
status300MultipleChoices: status300MultipleChoices,
|
|
837
|
+
status301MovedPermanently: status301MovedPermanently,
|
|
838
|
+
status302Found: status302Found,
|
|
839
|
+
status303SeeOther: status303SeeOther,
|
|
840
|
+
status304NotModified: status304NotModified,
|
|
841
|
+
status305UseProxy: status305UseProxy,
|
|
842
|
+
status306SwitchProxy: status306SwitchProxy,
|
|
843
|
+
status307TemporaryRedirect: status307TemporaryRedirect,
|
|
844
|
+
status308PermanentRedirect: status308PermanentRedirect,
|
|
845
|
+
status400BadRequest: status400BadRequest,
|
|
846
|
+
status401Unauthorized: status401Unauthorized,
|
|
847
|
+
status402PaymentRequired: status402PaymentRequired,
|
|
848
|
+
status403Forbidden: status403Forbidden,
|
|
849
|
+
status404NotFound: status404NotFound,
|
|
850
|
+
status405MethodNotAllowed: status405MethodNotAllowed,
|
|
851
|
+
status406NotAcceptable: status406NotAcceptable,
|
|
852
|
+
status407ProxyAuthenticationRequired: status407ProxyAuthenticationRequired,
|
|
853
|
+
status408RequestTimeout: status408RequestTimeout,
|
|
854
|
+
status409Conflict: status409Conflict,
|
|
855
|
+
status410Gone: status410Gone,
|
|
856
|
+
status411LengthRequired: status411LengthRequired,
|
|
857
|
+
status412PreconditionFailed: status412PreconditionFailed,
|
|
858
|
+
status413PayloadTooLarge: status413PayloadTooLarge,
|
|
859
|
+
status413RequestEntityTooLarge: status413RequestEntityTooLarge,
|
|
860
|
+
status414RequestUriTooLong: status414RequestUriTooLong,
|
|
861
|
+
status414UriTooLong: status414UriTooLong,
|
|
862
|
+
status415UnsupportedMediaType: status415UnsupportedMediaType,
|
|
863
|
+
status416RangeNotSatisfiable: status416RangeNotSatisfiable,
|
|
864
|
+
status416RequestedRangeNotSatisfiable: status416RequestedRangeNotSatisfiable,
|
|
865
|
+
status417ExpectationFailed: status417ExpectationFailed,
|
|
866
|
+
status418ImATeapot: status418ImATeapot,
|
|
867
|
+
status419AuthenticationTimeout: status419AuthenticationTimeout,
|
|
868
|
+
status421MisdirectedRequest: status421MisdirectedRequest,
|
|
869
|
+
status422UnprocessableEntity: status422UnprocessableEntity,
|
|
870
|
+
status423Locked: status423Locked,
|
|
871
|
+
status424FailedDependency: status424FailedDependency,
|
|
872
|
+
status426UpgradeRequired: status426UpgradeRequired,
|
|
873
|
+
status428PreconditionRequired: status428PreconditionRequired,
|
|
874
|
+
status429TooManyRequests: status429TooManyRequests,
|
|
875
|
+
status431RequestHeaderFieldsTooLarge: status431RequestHeaderFieldsTooLarge,
|
|
876
|
+
status451UnavailableForLegalReasons: status451UnavailableForLegalReasons,
|
|
877
|
+
status500InternalServerError: status500InternalServerError,
|
|
878
|
+
status501NotImplemented: status501NotImplemented,
|
|
879
|
+
status502BadGateway: status502BadGateway,
|
|
880
|
+
status503ServiceUnavailable: status503ServiceUnavailable,
|
|
881
|
+
status504GatewayTimeout: status504GatewayTimeout,
|
|
882
|
+
status505HttpVersionNotsupported: status505HttpVersionNotsupported,
|
|
883
|
+
status506VariantAlsoNegotiates: status506VariantAlsoNegotiates,
|
|
884
|
+
status507InsufficientStorage: status507InsufficientStorage,
|
|
885
|
+
status508LoopDetected: status508LoopDetected,
|
|
886
|
+
status510NotExtended: status510NotExtended,
|
|
887
|
+
status511NetworkAuthenticationRequired: status511NetworkAuthenticationRequired
|
|
888
|
+
});
|
|
530
889
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
890
|
+
function getNullableMapper(deserialize, typeOrMap) {
|
|
891
|
+
if (!typeOrMap) {
|
|
892
|
+
return (x) => x;
|
|
893
|
+
}
|
|
894
|
+
if (isZeroArgumentFunction(typeOrMap)) {
|
|
895
|
+
// It cannot be a factory function if it takes no arguments,
|
|
896
|
+
// so it must be a (zero argument) type (constructor)
|
|
897
|
+
return (x) => {
|
|
898
|
+
const bound = deserialize(x, typeOrMap);
|
|
899
|
+
// The server cannot produce the undefined result
|
|
900
|
+
if (bound === undefined) {
|
|
901
|
+
throw Error("The model factory created a undefined result");
|
|
902
|
+
}
|
|
903
|
+
return bound;
|
|
904
|
+
};
|
|
905
|
+
}
|
|
545
906
|
return typeOrMap;
|
|
546
907
|
}
|
|
547
|
-
function
|
|
548
|
-
const nullableFactory =
|
|
549
|
-
return (x)=>{
|
|
908
|
+
function getMapper(deserialize, typeOrMap) {
|
|
909
|
+
const nullableFactory = getNullableMapper(deserialize, typeOrMap);
|
|
910
|
+
return (x) => {
|
|
550
911
|
const result = nullableFactory(x);
|
|
551
|
-
if (result === null)
|
|
912
|
+
if (result === null) {
|
|
913
|
+
throw Error("The model factory created a null result");
|
|
914
|
+
}
|
|
552
915
|
return result;
|
|
553
916
|
};
|
|
554
917
|
}
|
|
555
|
-
function
|
|
918
|
+
function isZeroArgumentFunction(typeCtor) {
|
|
556
919
|
return typeCtor.length === 0;
|
|
557
920
|
}
|
|
558
921
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
922
|
+
exports.Http = Http;
|
|
923
|
+
exports.HttpBuilder = HttpBuilder;
|
|
924
|
+
exports.HttpBuilderOfT = HttpBuilderOfT;
|
|
925
|
+
exports.HttpError = HttpError;
|
|
926
|
+
exports.HttpResponse = HttpResponse;
|
|
927
|
+
exports.HttpResponseOfT = HttpResponseOfT;
|
|
928
|
+
exports.QueryString = QueryString;
|
|
929
|
+
exports.TimeoutError = TimeoutError;
|
|
930
|
+
exports.events = events;
|
|
931
|
+
exports.getMapper = getMapper;
|
|
932
|
+
exports.getNullableMapper = getNullableMapper;
|
|
933
|
+
exports.headerNames = headerNames;
|
|
934
|
+
exports.isAbortError = isAbortError;
|
|
935
|
+
exports.isHttpError = isHttpError;
|
|
936
|
+
exports.isTimeoutError = isTimeoutError;
|
|
937
|
+
exports.statusCodes = statusCodes;
|
|
564
938
|
//# sourceMappingURL=index.js.map
|