@zthun/webigail-http 4.0.2 → 4.0.4

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/index.js CHANGED
@@ -1,43 +1,136 @@
1
- import { ZMimeTypeApplication } from "@zthun/webigail-url";
2
- import fetch from "cross-fetch";
3
- var ZHttpMethod = /* @__PURE__ */ ((ZHttpMethod2) => {
4
- ZHttpMethod2["Get"] = "GET";
5
- ZHttpMethod2["Put"] = "PUT";
6
- ZHttpMethod2["Post"] = "POST";
7
- ZHttpMethod2["Delete"] = "DELETE";
8
- ZHttpMethod2["Patch"] = "PATCH";
9
- ZHttpMethod2["Options"] = "OPTIONS";
10
- ZHttpMethod2["Head"] = "HEAD";
11
- return ZHttpMethod2;
12
- })(ZHttpMethod || {});
13
- class ZHttpRequestBuilder {
14
- /**
15
- * Initializes a new instance of this object.
16
- */
17
- constructor() {
18
- this.json = this.content.bind(this, ZMimeTypeApplication.JSON);
19
- this._request = {
20
- method: "GET",
21
- url: ""
22
- };
23
- }
24
- /**
25
- * Duplicates a request, keeping it's structure intact.
1
+ import { ZMimeTypeApplication } from '@zthun/webigail-url';
2
+ import fetch from 'cross-fetch';
3
+
4
+ function _class_call_check$3(instance, Constructor) {
5
+ if (!(instance instanceof Constructor)) {
6
+ throw new TypeError("Cannot call a class as a function");
7
+ }
8
+ }
9
+ function _defineProperties$3(target, props) {
10
+ for(var i = 0; i < props.length; i++){
11
+ var descriptor = props[i];
12
+ descriptor.enumerable = descriptor.enumerable || false;
13
+ descriptor.configurable = true;
14
+ if ("value" in descriptor) descriptor.writable = true;
15
+ Object.defineProperty(target, descriptor.key, descriptor);
16
+ }
17
+ }
18
+ function _create_class$3(Constructor, protoProps, staticProps) {
19
+ if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
20
+ if (staticProps) _defineProperties$3(Constructor, staticProps);
21
+ return Constructor;
22
+ }
23
+ function _define_property$7(obj, key, value) {
24
+ if (key in obj) {
25
+ Object.defineProperty(obj, key, {
26
+ value: value,
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true
30
+ });
31
+ } else {
32
+ obj[key] = value;
33
+ }
34
+ return obj;
35
+ }
36
+ function _object_spread$1(target) {
37
+ for(var i = 1; i < arguments.length; i++){
38
+ var source = arguments[i] != null ? arguments[i] : {};
39
+ var ownKeys = Object.keys(source);
40
+ if (typeof Object.getOwnPropertySymbols === "function") {
41
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
42
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
43
+ }));
44
+ }
45
+ ownKeys.forEach(function(key) {
46
+ _define_property$7(target, key, source[key]);
47
+ });
48
+ }
49
+ return target;
50
+ }
51
+ function ownKeys(object, enumerableOnly) {
52
+ var keys = Object.keys(object);
53
+ if (Object.getOwnPropertySymbols) {
54
+ var symbols = Object.getOwnPropertySymbols(object);
55
+ keys.push.apply(keys, symbols);
56
+ }
57
+ return keys;
58
+ }
59
+ function _object_spread_props(target, source) {
60
+ source = source != null ? source : {};
61
+ if (Object.getOwnPropertyDescriptors) {
62
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
63
+ } else {
64
+ ownKeys(Object(source)).forEach(function(key) {
65
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
66
+ });
67
+ }
68
+ return target;
69
+ }
70
+ /**
71
+ * Represents an available method for an http invocation.
72
+ */ var ZHttpMethod = /*#__PURE__*/ function(ZHttpMethod) {
73
+ /**
74
+ * GET
26
75
  *
27
- * The underlying headers will be duplicated, but everything
28
- * else will be a shallow copy to preserve the body in the
29
- * case that it is a blob or other binary structure.
76
+ * Used for reads
77
+ */ ZHttpMethod["Get"] = "GET";
78
+ /**
79
+ * PUT
30
80
  *
31
- * @param other -
32
- * The request to duplicate.
81
+ * Used for updates and can combine creates.
82
+ */ ZHttpMethod["Put"] = "PUT";
83
+ /**
84
+ * POST
85
+ *
86
+ * Use for create.
87
+ */ ZHttpMethod["Post"] = "POST";
88
+ /**
89
+ * DELETE.
90
+ *
91
+ * Used for....delete..duh.
92
+ */ ZHttpMethod["Delete"] = "DELETE";
93
+ /**
94
+ * PATCH.
95
+ *
96
+ * Used for updates but only
97
+ * partials of objects.
98
+ */ ZHttpMethod["Patch"] = "PATCH";
99
+ /**
100
+ * OPTIONS
101
+ *
102
+ * Used to retrieve the available methods and
103
+ * accessors for a single api. Normally used
104
+ * by the browser.
105
+ */ ZHttpMethod["Options"] = "OPTIONS";
106
+ /**
107
+ * HEAD
108
+ *
109
+ * Used for metadata.
110
+ */ ZHttpMethod["Head"] = "HEAD";
111
+ return ZHttpMethod;
112
+ }({});
113
+ /**
114
+ * Represents a builder for an http request.
115
+ */ var ZHttpRequestBuilder = /*#__PURE__*/ function() {
116
+ function ZHttpRequestBuilder() {
117
+ _class_call_check$3(this, ZHttpRequestBuilder);
118
+ _define_property$7(this, "_request", void 0);
119
+ /**
120
+ * Sets the content type to json.
33
121
  *
34
122
  * @returns
35
- * The duplicated object.
36
- */
37
- static duplicate(other) {
38
- return { ...other, headers: structuredClone(other.headers) };
39
- }
40
- /**
123
+ * This object.
124
+ */ _define_property$7(this, "json", this.content.bind(this, ZMimeTypeApplication.JSON));
125
+ this._request = {
126
+ method: "GET",
127
+ url: ""
128
+ };
129
+ }
130
+ _create_class$3(ZHttpRequestBuilder, [
131
+ {
132
+ key: "_method",
133
+ value: /**
41
134
  * Sets the method.
42
135
  *
43
136
  * @param method -
@@ -47,91 +140,95 @@ class ZHttpRequestBuilder {
47
140
  *
48
141
  * @returns
49
142
  * This object.
50
- */
51
- _method(method, body) {
52
- this._request.method = method;
53
- this._request.body = body;
54
- if (this._request.body === void 0) {
55
- delete this._request.body;
56
- }
57
- return this;
58
- }
59
- /**
143
+ */ function _method(method, body) {
144
+ this._request.method = method;
145
+ this._request.body = body;
146
+ if (this._request.body === undefined) {
147
+ delete this._request.body;
148
+ }
149
+ return this;
150
+ }
151
+ },
152
+ {
153
+ key: "get",
154
+ value: /**
60
155
  * Constructs a get request.
61
156
  *
62
157
  * @returns
63
158
  * This object.
64
- */
65
- get() {
66
- return this._method(
67
- "GET"
68
- /* Get */
69
- );
70
- }
71
- /**
159
+ */ function get() {
160
+ return this._method("GET");
161
+ }
162
+ },
163
+ {
164
+ key: "post",
165
+ value: /**
72
166
  * Constructs a post request.
73
167
  *
74
168
  * @returns
75
169
  * This object.
76
- */
77
- post(body) {
78
- return this._method("POST", body).json();
79
- }
80
- /**
170
+ */ function post(body) {
171
+ return this._method("POST", body).json();
172
+ }
173
+ },
174
+ {
175
+ key: "put",
176
+ value: /**
81
177
  * Constructs a put request.
82
178
  *
83
179
  * @returns
84
180
  * This object.
85
- */
86
- put(body) {
87
- return this._method("PUT", body).json();
88
- }
89
- /**
181
+ */ function put(body) {
182
+ return this._method("PUT", body).json();
183
+ }
184
+ },
185
+ {
186
+ key: "delete",
187
+ value: /**
90
188
  * Constructs a delete request.
91
189
  *
92
190
  * @returns
93
191
  * This object.
94
- */
95
- delete() {
96
- return this._method(
97
- "DELETE"
98
- /* Delete */
99
- );
100
- }
101
- /**
192
+ */ function _delete() {
193
+ return this._method("DELETE");
194
+ }
195
+ },
196
+ {
197
+ key: "patch",
198
+ value: /**
102
199
  * Constructs a patch request.
103
200
  *
104
201
  * @returns
105
202
  * This object.
106
- */
107
- patch(body) {
108
- return this._method("PATCH", body).json();
109
- }
110
- /**
203
+ */ function patch(body) {
204
+ return this._method("PATCH", body).json();
205
+ }
206
+ },
207
+ {
208
+ key: "options",
209
+ value: /**
111
210
  * Constructs a options request.
112
211
  *
113
212
  * @returns
114
213
  * This object.
115
- */
116
- options() {
117
- return this._method(
118
- "OPTIONS"
119
- /* Options */
120
- );
121
- }
122
- /**
214
+ */ function options() {
215
+ return this._method("OPTIONS");
216
+ }
217
+ },
218
+ {
219
+ key: "head",
220
+ value: /**
123
221
  * Constructs a head request.
124
222
  *
125
223
  * @returns
126
224
  * This object.
127
- */
128
- head() {
129
- return this._method(
130
- "HEAD"
131
- /* Head */
132
- );
133
- }
134
- /**
225
+ */ function head() {
226
+ return this._method("HEAD");
227
+ }
228
+ },
229
+ {
230
+ key: "url",
231
+ value: /**
135
232
  * Sets the url to make the request from.
136
233
  *
137
234
  * @param url -
@@ -139,12 +236,14 @@ class ZHttpRequestBuilder {
139
236
  *
140
237
  * @returns
141
238
  * This object.
142
- */
143
- url(url) {
144
- this._request.url = url;
145
- return this;
146
- }
147
- /**
239
+ */ function url(url) {
240
+ this._request.url = url;
241
+ return this;
242
+ }
243
+ },
244
+ {
245
+ key: "timeout",
246
+ value: /**
148
247
  * Sets the timeout for the url.
149
248
  *
150
249
  * @param ms -
@@ -152,12 +251,14 @@ class ZHttpRequestBuilder {
152
251
  *
153
252
  * @returns
154
253
  * The object.
155
- */
156
- timeout(ms) {
157
- this._request.timeout = ms;
158
- return this;
159
- }
160
- /**
254
+ */ function timeout(ms) {
255
+ this._request.timeout = ms;
256
+ return this;
257
+ }
258
+ },
259
+ {
260
+ key: "headers",
261
+ value: /**
161
262
  * Sets the headers.
162
263
  *
163
264
  * @param headers -
@@ -165,12 +266,14 @@ class ZHttpRequestBuilder {
165
266
  *
166
267
  * @returns
167
268
  * This object.
168
- */
169
- headers(headers) {
170
- this._request.headers = headers;
171
- return this;
172
- }
173
- /**
269
+ */ function headers(headers) {
270
+ this._request.headers = headers;
271
+ return this;
272
+ }
273
+ },
274
+ {
275
+ key: "header",
276
+ value: /**
174
277
  * Sets an individual header.
175
278
  *
176
279
  * @param key -
@@ -180,17 +283,19 @@ class ZHttpRequestBuilder {
180
283
  *
181
284
  * @returns
182
285
  * This object.
183
- */
184
- header(key, value) {
185
- this._request.headers = this._request.headers || {};
186
- if (value == null) {
187
- delete this._request.headers[key];
188
- } else {
189
- this._request.headers[key] = `${value}`;
190
- }
191
- return this;
192
- }
193
- /**
286
+ */ function header(key, value) {
287
+ this._request.headers = this._request.headers || {};
288
+ if (value == null) {
289
+ delete this._request.headers[key];
290
+ } else {
291
+ this._request.headers[key] = "".concat(value);
292
+ }
293
+ return this;
294
+ }
295
+ },
296
+ {
297
+ key: "content",
298
+ value: /**
194
299
  * Sets the content type header.
195
300
  *
196
301
  * @param type -
@@ -198,11 +303,13 @@ class ZHttpRequestBuilder {
198
303
  *
199
304
  * @returns
200
305
  * This object.
201
- */
202
- content(type) {
203
- return this.header("Content-Type", type);
204
- }
205
- /**
306
+ */ function content(type) {
307
+ return this.header("Content-Type", type);
308
+ }
309
+ },
310
+ {
311
+ key: "copy",
312
+ value: /**
206
313
  * Copies other to this object.
207
314
  *
208
315
  * @param other -
@@ -210,677 +317,676 @@ class ZHttpRequestBuilder {
210
317
  *
211
318
  * @returns
212
319
  * This object.
213
- */
214
- copy(other) {
215
- this._request = ZHttpRequestBuilder.duplicate(other);
216
- return this;
217
- }
218
- /**
320
+ */ function copy(other) {
321
+ this._request = ZHttpRequestBuilder.duplicate(other);
322
+ return this;
323
+ }
324
+ },
325
+ {
326
+ key: "build",
327
+ value: /**
219
328
  * Returns the constructed request.
220
329
  *
221
330
  * @returns
222
331
  * The constructed request.
223
- */
224
- build() {
225
- return ZHttpRequestBuilder.duplicate(this._request);
226
- }
332
+ */ function build() {
333
+ return ZHttpRequestBuilder.duplicate(this._request);
334
+ }
335
+ }
336
+ ], [
337
+ {
338
+ key: "duplicate",
339
+ value: /**
340
+ * Duplicates a request, keeping it's structure intact.
341
+ *
342
+ * The underlying headers will be duplicated, but everything
343
+ * else will be a shallow copy to preserve the body in the
344
+ * case that it is a blob or other binary structure.
345
+ *
346
+ * @param other -
347
+ * The request to duplicate.
348
+ *
349
+ * @returns
350
+ * The duplicated object.
351
+ */ function duplicate(other) {
352
+ return _object_spread_props(_object_spread$1({}, other), {
353
+ headers: structuredClone(other.headers)
354
+ });
355
+ }
356
+ }
357
+ ]);
358
+ return ZHttpRequestBuilder;
359
+ }();
360
+
361
+ /**
362
+ * This class of status code is intended for situations in which the error seems to have been caused by the client.
363
+ *
364
+ * Except when responding to a HEAD request, the server should include an entity containing an explanation
365
+ * of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable
366
+ * to any request method. User agents should display any included entity to the user.
367
+ */ function _define_property$6(obj, key, value) {
368
+ if (key in obj) {
369
+ Object.defineProperty(obj, key, {
370
+ value: value,
371
+ enumerable: true,
372
+ configurable: true,
373
+ writable: true
374
+ });
375
+ } else {
376
+ obj[key] = value;
377
+ }
378
+ return obj;
227
379
  }
228
- var ZHttpCodeClient = /* @__PURE__ */ ((ZHttpCodeClient2) => {
229
- ZHttpCodeClient2[ZHttpCodeClient2["BadRequest"] = 400] = "BadRequest";
230
- ZHttpCodeClient2[ZHttpCodeClient2["Unauthorized"] = 401] = "Unauthorized";
231
- ZHttpCodeClient2[ZHttpCodeClient2["PaymentRequired"] = 402] = "PaymentRequired";
232
- ZHttpCodeClient2[ZHttpCodeClient2["Forbidden"] = 403] = "Forbidden";
233
- ZHttpCodeClient2[ZHttpCodeClient2["NotFound"] = 404] = "NotFound";
234
- ZHttpCodeClient2[ZHttpCodeClient2["MethodNotAllowed"] = 405] = "MethodNotAllowed";
235
- ZHttpCodeClient2[ZHttpCodeClient2["NotAcceptable"] = 406] = "NotAcceptable";
236
- ZHttpCodeClient2[ZHttpCodeClient2["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
237
- ZHttpCodeClient2[ZHttpCodeClient2["RequestTimeout"] = 408] = "RequestTimeout";
238
- ZHttpCodeClient2[ZHttpCodeClient2["Conflict"] = 409] = "Conflict";
239
- ZHttpCodeClient2[ZHttpCodeClient2["Gone"] = 410] = "Gone";
240
- ZHttpCodeClient2[ZHttpCodeClient2["LengthRequired"] = 411] = "LengthRequired";
241
- ZHttpCodeClient2[ZHttpCodeClient2["PreconditionFailed"] = 412] = "PreconditionFailed";
242
- ZHttpCodeClient2[ZHttpCodeClient2["PayloadTooLarge"] = 413] = "PayloadTooLarge";
243
- ZHttpCodeClient2[ZHttpCodeClient2["URITooLong"] = 414] = "URITooLong";
244
- ZHttpCodeClient2[ZHttpCodeClient2["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
245
- ZHttpCodeClient2[ZHttpCodeClient2["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
246
- ZHttpCodeClient2[ZHttpCodeClient2["ExpectationFailed"] = 417] = "ExpectationFailed";
247
- ZHttpCodeClient2[ZHttpCodeClient2["ImATeapot"] = 418] = "ImATeapot";
248
- ZHttpCodeClient2[ZHttpCodeClient2["MisdirectedRequest"] = 421] = "MisdirectedRequest";
249
- ZHttpCodeClient2[ZHttpCodeClient2["UnProcessableEntity"] = 422] = "UnProcessableEntity";
250
- ZHttpCodeClient2[ZHttpCodeClient2["Locked"] = 423] = "Locked";
251
- ZHttpCodeClient2[ZHttpCodeClient2["FailedDependency"] = 424] = "FailedDependency";
252
- ZHttpCodeClient2[ZHttpCodeClient2["UpgradeRequired"] = 426] = "UpgradeRequired";
253
- ZHttpCodeClient2[ZHttpCodeClient2["PreconditionRequired"] = 428] = "PreconditionRequired";
254
- ZHttpCodeClient2[ZHttpCodeClient2["TooManyRequests"] = 429] = "TooManyRequests";
255
- ZHttpCodeClient2[ZHttpCodeClient2["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
256
- ZHttpCodeClient2[ZHttpCodeClient2["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
257
- return ZHttpCodeClient2;
258
- })(ZHttpCodeClient || {});
259
- const ZHttpCodeClientNames = {
260
- [
261
- 400
262
- /* BadRequest */
263
- ]: "Bad Request",
264
- [
265
- 401
266
- /* Unauthorized */
267
- ]: "Unauthorized",
268
- [
269
- 402
270
- /* PaymentRequired */
271
- ]: "Payment Required",
272
- [
273
- 403
274
- /* Forbidden */
275
- ]: "Forbidden",
276
- [
277
- 404
278
- /* NotFound */
279
- ]: "Not Found",
280
- [
281
- 405
282
- /* MethodNotAllowed */
283
- ]: "Method not Allowed",
284
- [
285
- 406
286
- /* NotAcceptable */
287
- ]: "Not Acceptable",
288
- [
289
- 407
290
- /* ProxyAuthenticationRequired */
291
- ]: "Proxy Authentication Required",
292
- [
293
- 408
294
- /* RequestTimeout */
295
- ]: "Request Timeout",
296
- [
297
- 409
298
- /* Conflict */
299
- ]: "Conflict",
300
- [
301
- 410
302
- /* Gone */
303
- ]: "Gone",
304
- [
305
- 411
306
- /* LengthRequired */
307
- ]: "Length Required",
308
- [
309
- 412
310
- /* PreconditionFailed */
311
- ]: "Precondition Failed",
312
- [
313
- 413
314
- /* PayloadTooLarge */
315
- ]: "Payload Too Large",
316
- [
317
- 414
318
- /* URITooLong */
319
- ]: "URI Too Long",
320
- [
321
- 415
322
- /* UnsupportedMediaType */
323
- ]: "Unsupported Media Type",
324
- [
325
- 416
326
- /* RangeNotSatisfiable */
327
- ]: "Range Not Satisfiable",
328
- [
329
- 417
330
- /* ExpectationFailed */
331
- ]: "Expectation Failed",
332
- [
333
- 418
334
- /* ImATeapot */
335
- ]: "I am a Teapot",
336
- [
337
- 421
338
- /* MisdirectedRequest */
339
- ]: "Misdirected Requested",
340
- [
341
- 422
342
- /* UnProcessableEntity */
343
- ]: "Entity Not Processable",
344
- [
345
- 423
346
- /* Locked */
347
- ]: "Locked",
348
- [
349
- 424
350
- /* FailedDependency */
351
- ]: "Failed Dependency",
352
- [
353
- 426
354
- /* UpgradeRequired */
355
- ]: "Upgrade Required",
356
- [
357
- 428
358
- /* PreconditionRequired */
359
- ]: "Precondition Required",
360
- [
361
- 429
362
- /* TooManyRequests */
363
- ]: "Too Many Requests",
364
- [
365
- 431
366
- /* RequestHeaderFieldsTooLarge */
367
- ]: "Request Header Fields Too Large",
368
- [
369
- 451
370
- /* UnavailableForLegalReasons */
371
- ]: "Unavailable for Legal Reasons"
372
- };
373
- const ZHttpCodeClientDescriptions = {
374
- [
375
- 400
376
- /* BadRequest */
377
- ]: "A bad request was sent.",
378
- [
379
- 401
380
- /* Unauthorized */
381
- ]: "You are not authenticated and cannot view this content.",
382
- [
383
- 402
384
- /* PaymentRequired */
385
- ]: "Payment is required",
386
- [
387
- 403
388
- /* Forbidden */
389
- ]: "You are not authorized to view this content.",
390
- [
391
- 404
392
- /* NotFound */
393
- ]: "The resource you are looking for could not be found.",
394
- [
395
- 405
396
- /* MethodNotAllowed */
397
- ]: "The requested operation was not allowed.",
398
- [
399
- 406
400
- /* NotAcceptable */
401
- ]: "The requested resource is not capable of generating the content for you.",
402
- [
403
- 407
404
- /* ProxyAuthenticationRequired */
405
- ]: "You must first authenticate your self with the proxy.",
406
- [
407
- 408
408
- /* RequestTimeout */
409
- ]: "The server timed out waiting for a request. Please try again.",
410
- [
411
- 409
412
- /* Conflict */
413
- ]: "There was a conflict with request. Try something else.",
414
- [
415
- 410
416
- /* Gone */
417
- ]: "The resource you requested is no longer available.",
418
- [
419
- 411
420
- /* LengthRequired */
421
- ]: "Your request did not specify the length of its content, which is required by the requested resource.",
422
- [
423
- 412
424
- /* PreconditionFailed */
425
- ]: "The server did not meet the requirements that was required to meet the request.",
426
- [
427
- 413
428
- /* PayloadTooLarge */
429
- ]: "The request is too large and the server cannot handle it.",
430
- [
431
- 414
432
- /* URITooLong */
433
- ]: "The URI provided was too long for the server to process.",
434
- [
435
- 415
436
- /* UnsupportedMediaType */
437
- ]: "The media type requested is not supported by the server.",
438
- [
439
- 416
440
- /* RangeNotSatisfiable */
441
- ]: "A portion of the file was requested by the server cannot supply said portion.",
442
- [
443
- 417
444
- /* ExpectationFailed */
445
- ]: "The server cannot meet the requirements of the expectation made of it.",
446
- [
447
- 418
448
- /* ImATeapot */
449
- ]: "Short and stout. Here is my handle, here is my spout. When I get all steamed up, hear me shout. Tip me over and pour me out!",
450
- [
451
- 421
452
- /* MisdirectedRequest */
453
- ]: "The request was directed at the server, but the server cannot produce a response.",
454
- [
455
- 422
456
- /* UnProcessableEntity */
457
- ]: "The request was well-formed but was unable to be followed due to semantic errors.",
458
- [
459
- 423
460
- /* Locked */
461
- ]: "The resource that is being accessed is locked.",
462
- [
463
- 424
464
- /* FailedDependency */
465
- ]: "The request failed because it depended on another request and that request failed.",
466
- [
467
- 426
468
- /* UpgradeRequired */
469
- ]: "The client needs to switch to a different protocol.",
470
- [
471
- 428
472
- /* PreconditionRequired */
473
- ]: "The origin server requires the request to be conditional.",
474
- [
475
- 429
476
- /* TooManyRequests */
477
- ]: "The user has sent too many requests in a given amount of time.",
478
- [
479
- 431
480
- /* RequestHeaderFieldsTooLarge */
481
- ]: "The request cannot be processed because the collective header fields are too large.",
482
- [
483
- 451
484
- /* UnavailableForLegalReasons */
485
- ]: "Call your lawyer!"
486
- };
487
- var ZHttpCodeInformationalResponse = /* @__PURE__ */ ((ZHttpCodeInformationalResponse2) => {
488
- ZHttpCodeInformationalResponse2[ZHttpCodeInformationalResponse2["Continue"] = 100] = "Continue";
489
- ZHttpCodeInformationalResponse2[ZHttpCodeInformationalResponse2["SwitchingProtocols"] = 101] = "SwitchingProtocols";
490
- ZHttpCodeInformationalResponse2[ZHttpCodeInformationalResponse2["Processing"] = 102] = "Processing";
491
- ZHttpCodeInformationalResponse2[ZHttpCodeInformationalResponse2["EarlyHints"] = 103] = "EarlyHints";
492
- return ZHttpCodeInformationalResponse2;
493
- })(ZHttpCodeInformationalResponse || {});
494
- const ZHttpCodeInformationalResponseNames = {
495
- [
496
- 100
497
- /* Continue */
498
- ]: "Continue",
499
- [
500
- 101
501
- /* SwitchingProtocols */
502
- ]: "Switching Protocols",
503
- [
504
- 102
505
- /* Processing */
506
- ]: "Processing",
507
- [
508
- 103
509
- /* EarlyHints */
510
- ]: "Early Hints"
511
- };
512
- const ZHttpCodeInformationalResponseDescriptions = {
513
- [
514
- 100
515
- /* Continue */
516
- ]: "The client should continue to send the request body.",
517
- [
518
- 101
519
- /* SwitchingProtocols */
520
- ]: "The requestor has asked the server to switch protocols and the server has agreed to do so.",
521
- [
522
- 102
523
- /* Processing */
524
- ]: "The server has received and is processing the request, but a response is not available yet.",
525
- [
526
- 103
527
- /* EarlyHints */
528
- ]: "There are some early response headers available for you before the final message."
529
- };
530
- var ZHttpCodeRedirection = /* @__PURE__ */ ((ZHttpCodeRedirection2) => {
531
- ZHttpCodeRedirection2[ZHttpCodeRedirection2["MultipleChoices"] = 300] = "MultipleChoices";
532
- ZHttpCodeRedirection2[ZHttpCodeRedirection2["MovedPermanently"] = 301] = "MovedPermanently";
533
- ZHttpCodeRedirection2[ZHttpCodeRedirection2["Found"] = 302] = "Found";
534
- ZHttpCodeRedirection2[ZHttpCodeRedirection2["SeeOther"] = 303] = "SeeOther";
535
- ZHttpCodeRedirection2[ZHttpCodeRedirection2["NotModified"] = 304] = "NotModified";
536
- ZHttpCodeRedirection2[ZHttpCodeRedirection2["UseProxy"] = 305] = "UseProxy";
537
- ZHttpCodeRedirection2[ZHttpCodeRedirection2["SwitchProxy"] = 306] = "SwitchProxy";
538
- ZHttpCodeRedirection2[ZHttpCodeRedirection2["TemporaryRedirect"] = 307] = "TemporaryRedirect";
539
- ZHttpCodeRedirection2[ZHttpCodeRedirection2["PermanentRedirect"] = 308] = "PermanentRedirect";
540
- return ZHttpCodeRedirection2;
541
- })(ZHttpCodeRedirection || {});
542
- const ZHttpCodeRedirectionNames = {
543
- [
544
- 300
545
- /* MultipleChoices */
546
- ]: "Multiple Choices",
547
- [
548
- 301
549
- /* MovedPermanently */
550
- ]: "Moved Permanently",
551
- [
552
- 302
553
- /* Found */
554
- ]: "Found",
555
- [
556
- 303
557
- /* SeeOther */
558
- ]: "See Other",
559
- [
560
- 304
561
- /* NotModified */
562
- ]: "Not Modified",
563
- [
564
- 305
565
- /* UseProxy */
566
- ]: "Use Proxy",
567
- [
568
- 306
569
- /* SwitchProxy */
570
- ]: "Switch Proxy",
571
- [
572
- 307
573
- /* TemporaryRedirect */
574
- ]: "Temporary Redirect",
575
- [
576
- 308
577
- /* PermanentRedirect */
578
- ]: "Permanent Redirect"
579
- };
580
- const ZHttpCodeRedirectionDescriptions = {
581
- [
582
- 300
583
- /* MultipleChoices */
584
- ]: "Indicates multiple options for the resource from which the client may choose.",
585
- [
586
- 301
587
- /* MovedPermanently */
588
- ]: "This and all future requests should be directed to the given URI.",
589
- [
590
- 302
591
- /* Found */
592
- ]: "Tells the client to look at another url",
593
- [
594
- 303
595
- /* SeeOther */
596
- ]: "The response to the request can be found under another URI using the GET method.",
597
- [
598
- 304
599
- /* NotModified */
600
- ]: "Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.",
601
- [
602
- 305
603
- /* UseProxy */
604
- ]: "The requested resource is available only through a proxy, the address for which is provided in the response.",
605
- [
606
- 306
607
- /* SwitchProxy */
608
- ]: 'No longer used. Originally meant "Subsequent requests should use the specified proxy.',
609
- [
610
- 307
611
- /* TemporaryRedirect */
612
- ]: "In this case, the request should be repeated with another URI; however, future requests should still use the original URI.",
613
- [
614
- 308
615
- /* PermanentRedirect */
616
- ]: "The request and all future requests should be repeated using another URI."
617
- };
618
- var ZHttpCodeServer = /* @__PURE__ */ ((ZHttpCodeServer2) => {
619
- ZHttpCodeServer2[ZHttpCodeServer2["InternalServerError"] = 500] = "InternalServerError";
620
- ZHttpCodeServer2[ZHttpCodeServer2["NotImplemented"] = 501] = "NotImplemented";
621
- ZHttpCodeServer2[ZHttpCodeServer2["BadGateway"] = 502] = "BadGateway";
622
- ZHttpCodeServer2[ZHttpCodeServer2["ServiceUnavailable"] = 503] = "ServiceUnavailable";
623
- ZHttpCodeServer2[ZHttpCodeServer2["GatewayTimeout"] = 504] = "GatewayTimeout";
624
- ZHttpCodeServer2[ZHttpCodeServer2["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
625
- ZHttpCodeServer2[ZHttpCodeServer2["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
626
- ZHttpCodeServer2[ZHttpCodeServer2["InsufficientStorage"] = 507] = "InsufficientStorage";
627
- ZHttpCodeServer2[ZHttpCodeServer2["LoopDetected"] = 508] = "LoopDetected";
628
- ZHttpCodeServer2[ZHttpCodeServer2["NotExtended"] = 510] = "NotExtended";
629
- ZHttpCodeServer2[ZHttpCodeServer2["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
630
- return ZHttpCodeServer2;
631
- })(ZHttpCodeServer || {});
632
- const ZHttpCodeServerNames = {
633
- [
634
- 500
635
- /* InternalServerError */
636
- ]: "Internal Server Error",
637
- [
638
- 501
639
- /* NotImplemented */
640
- ]: "Not Implemented",
641
- [
642
- 502
643
- /* BadGateway */
644
- ]: "Bad Gateway",
645
- [
646
- 503
647
- /* ServiceUnavailable */
648
- ]: "Service Unavailable",
649
- [
650
- 504
651
- /* GatewayTimeout */
652
- ]: "Gateway Timeout",
653
- [
654
- 505
655
- /* HttpVersionNotSupported */
656
- ]: "HTTP Version Not Supported",
657
- [
658
- 506
659
- /* VariantAlsoNegotiates */
660
- ]: "Variant Also Negotiates",
661
- [
662
- 507
663
- /* InsufficientStorage */
664
- ]: "Insufficient Storage",
665
- [
666
- 508
667
- /* LoopDetected */
668
- ]: "Loop Detected",
669
- [
670
- 510
671
- /* NotExtended */
672
- ]: "Not Extended",
673
- [
674
- 511
675
- /* NetworkAuthenticationRequired */
676
- ]: "Network Authentication Required"
677
- };
678
- const ZHttpCodeServerDescriptions = {
679
- [
680
- 500
681
- /* InternalServerError */
682
- ]: "An unexpected condition was encountered on the server.",
683
- [
684
- 501
685
- /* NotImplemented */
686
- ]: "The server either does not recognize the request method, or it lacks the ability to fulfil the request. Usually this implies future availability (e.g., a new feature of a web-service API).",
687
- [
688
- 502
689
- /* BadGateway */
690
- ]: " The server was acting as a gateway or proxy and received an invalid response from the upstream server.",
691
- [
692
- 503
693
- /* ServiceUnavailable */
694
- ]: "The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.",
695
- [
696
- 504
697
- /* GatewayTimeout */
698
- ]: "The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.",
699
- [
700
- 505
701
- /* HttpVersionNotSupported */
702
- ]: "The server does not support the HTTP protocol version used in the request.",
703
- [
704
- 506
705
- /* VariantAlsoNegotiates */
706
- ]: " Transparent content negotiation for the request results in a circular reference.",
707
- [
708
- 507
709
- /* InsufficientStorage */
710
- ]: "The server is unable to store the representation needed to complete the request.",
711
- [
712
- 508
713
- /* LoopDetected */
714
- ]: "The server detected an infinite loop while processing the request.",
715
- [
716
- 510
717
- /* NotExtended */
718
- ]: "Further extensions to the request are required for the server to fulfil it.",
719
- [
720
- 511
721
- /* NetworkAuthenticationRequired */
722
- ]: "The client needs to authenticate to gain network access."
723
- };
724
- var ZHttpCodeSuccess = /* @__PURE__ */ ((ZHttpCodeSuccess2) => {
725
- ZHttpCodeSuccess2[ZHttpCodeSuccess2["OK"] = 200] = "OK";
726
- ZHttpCodeSuccess2[ZHttpCodeSuccess2["Created"] = 201] = "Created";
727
- ZHttpCodeSuccess2[ZHttpCodeSuccess2["Accepted"] = 202] = "Accepted";
728
- ZHttpCodeSuccess2[ZHttpCodeSuccess2["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
729
- ZHttpCodeSuccess2[ZHttpCodeSuccess2["NoContent"] = 204] = "NoContent";
730
- ZHttpCodeSuccess2[ZHttpCodeSuccess2["ResetContent"] = 205] = "ResetContent";
731
- ZHttpCodeSuccess2[ZHttpCodeSuccess2["PartialContent"] = 206] = "PartialContent";
732
- ZHttpCodeSuccess2[ZHttpCodeSuccess2["MultiStatus"] = 207] = "MultiStatus";
733
- ZHttpCodeSuccess2[ZHttpCodeSuccess2["AlreadyReported"] = 208] = "AlreadyReported";
734
- ZHttpCodeSuccess2[ZHttpCodeSuccess2["IMUsed"] = 226] = "IMUsed";
735
- return ZHttpCodeSuccess2;
736
- })(ZHttpCodeSuccess || {});
737
- const ZHttpCodeSuccessNames = {
738
- [
739
- 200
740
- /* OK */
741
- ]: "OK",
742
- [
743
- 201
744
- /* Created */
745
- ]: "Created",
746
- [
747
- 202
748
- /* Accepted */
749
- ]: "Accepted",
750
- [
751
- 203
752
- /* NonAuthoritativeInformation */
753
- ]: "Non-Authoritative Information",
754
- [
755
- 204
756
- /* NoContent */
757
- ]: "No Content",
758
- [
759
- 205
760
- /* ResetContent */
761
- ]: "Reset Content",
762
- [
763
- 206
764
- /* PartialContent */
765
- ]: "Partial Content",
766
- [
767
- 207
768
- /* MultiStatus */
769
- ]: "Multi Status",
770
- [
771
- 208
772
- /* AlreadyReported */
773
- ]: "Already Reported",
774
- [
775
- 226
776
- /* IMUsed */
777
- ]: "IM Used"
778
- };
779
- const ZHttpCodeSuccessDescriptions = {
780
- [
781
- 200
782
- /* OK */
783
- ]: "The request was successful.",
784
- [
785
- 201
786
- /* Created */
787
- ]: "The request has been fulfilled, resulting in the creation of a new resource.",
788
- [
789
- 202
790
- /* Accepted */
791
- ]: "The request has been accepted for processing, but the processing has not been completed.",
792
- [
793
- 203
794
- /* NonAuthoritativeInformation */
795
- ]: "The server is a transforming proxy that received an OK from its origin,but is returning a modified version of the response.",
796
- [
797
- 204
798
- /* NoContent */
799
- ]: "The server successfully processed the request and is not returning any content.",
800
- [
801
- 205
802
- /* ResetContent */
803
- ]: "The server successfully processed the request, but is not returning any content. The document view must be refreshed.",
804
- [
805
- 206
806
- /* PartialContent */
807
- ]: "he server is delivering only part of the resource due to a range header sent by the client.",
808
- [
809
- 207
810
- /* MultiStatus */
811
- ]: "The message body that follows is by default an XML message and can contain a number of separate response codes, depending on how many sub-requests were made.",
812
- [
813
- 208
814
- /* AlreadyReported */
815
- ]: "The members of a DAV binding have already been enumerated in a preceding part of the response, and are not being included again.",
816
- [
817
- 226
818
- /* IMUsed */
819
- ]: "The server has fulfilled a request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance."
820
- };
821
- var ZHttpCodeCategory = /* @__PURE__ */ ((ZHttpCodeCategory2) => {
822
- ZHttpCodeCategory2["InformationalResponse"] = "Informational Response";
823
- ZHttpCodeCategory2["Success"] = "Success";
824
- ZHttpCodeCategory2["Redirection"] = "Redirection";
825
- ZHttpCodeCategory2["Client"] = "Client Error";
826
- ZHttpCodeCategory2["Server"] = "Server Error";
827
- return ZHttpCodeCategory2;
828
- })(ZHttpCodeCategory || {});
829
- var ZHttpCodeSeverity = /* @__PURE__ */ ((ZHttpCodeSeverity2) => {
830
- ZHttpCodeSeverity2["Info"] = "info";
831
- ZHttpCodeSeverity2["Success"] = "success";
832
- ZHttpCodeSeverity2["Warning"] = "warning";
833
- ZHttpCodeSeverity2["Error"] = "error";
834
- return ZHttpCodeSeverity2;
835
- })(ZHttpCodeSeverity || {});
836
- function getHttpCodeName(code) {
837
- return ZHttpCodeInformationalResponseNames[code] || ZHttpCodeSuccessNames[code] || ZHttpCodeRedirectionNames[code] || ZHttpCodeClientNames[code] || ZHttpCodeServerNames[code];
380
+ var ZHttpCodeClient = /*#__PURE__*/ function(ZHttpCodeClient) {
381
+ /**
382
+ * The server cannot or will not process the request due to an apparent client error
383
+ * (e.g., malformed request syntax, size too large, invalid request message framing,
384
+ * or deceptive request routing).
385
+ */ ZHttpCodeClient[ZHttpCodeClient["BadRequest"] = 400] = "BadRequest";
386
+ /**
387
+ * Similar to 403 Forbidden, but specifically for use when authentication is required and has failed
388
+ * or has not yet been provided.
389
+ *
390
+ * The response must include a WWW-Authenticate header field containing a challenge applicable to the
391
+ * requested resource. See Basic access authentication and Digest access authentication. 401
392
+ * semantically means "unauthenticated",[35] i.e. the user does not have the necessary credentials.
393
+ *
394
+ * Note: Some sites issue HTTP 401 when an IP address is banned from the website (usually the website domain)
395
+ * and that specific address is refused permission to access a website.
396
+ */ ZHttpCodeClient[ZHttpCodeClient["Unauthorized"] = 401] = "Unauthorized";
397
+ /**
398
+ * Reserved for future use.
399
+ *
400
+ * The original intention was that this code might be used as part of some form of digital cash or
401
+ * micro-payment scheme, as proposed for example by GNU Taler, but that has not yet happened, and
402
+ * this code is not usually used. Google Developers API uses this status if a particular developer
403
+ * has exceeded the daily limit on requests
404
+ */ ZHttpCodeClient[ZHttpCodeClient["PaymentRequired"] = 402] = "PaymentRequired";
405
+ /**
406
+ * The request was valid, but the server is refusing action.
407
+ *
408
+ * The user might not have the necessary permissions for a resource, or may need an account of some sort.
409
+ */ ZHttpCodeClient[ZHttpCodeClient["Forbidden"] = 403] = "Forbidden";
410
+ /**
411
+ * The requested resource could not be found but may be available in the future.
412
+ *
413
+ * Subsequent requests by the client are permissible.
414
+ */ ZHttpCodeClient[ZHttpCodeClient["NotFound"] = 404] = "NotFound";
415
+ /**
416
+ * A request method is not supported for the requested resource; for example, a GET
417
+ * request on a form that requires data to be presented via POST, or a PUT request on
418
+ * a read-only resource.
419
+ */ ZHttpCodeClient[ZHttpCodeClient["MethodNotAllowed"] = 405] = "MethodNotAllowed";
420
+ /**
421
+ * The requested resource is capable of generating only content not acceptable according
422
+ * to the Accept headers sent in the request.
423
+ */ ZHttpCodeClient[ZHttpCodeClient["NotAcceptable"] = 406] = "NotAcceptable";
424
+ /**
425
+ * The client must first authenticate itself with the proxy.
426
+ */ ZHttpCodeClient[ZHttpCodeClient["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
427
+ /**
428
+ * The server timed out waiting for the request.
429
+ *
430
+ * According to HTTP specifications: "The client did not produce a request within the
431
+ * time that the server was prepared to wait. The client MAY repeat the request without
432
+ * modifications at any later time.
433
+ */ ZHttpCodeClient[ZHttpCodeClient["RequestTimeout"] = 408] = "RequestTimeout";
434
+ /**
435
+ * Indicates that the request could not be processed because of conflict in the request, such
436
+ * as an edit conflict between multiple simultaneous updates.
437
+ */ ZHttpCodeClient[ZHttpCodeClient["Conflict"] = 409] = "Conflict";
438
+ /**
439
+ * Indicates that the resource requested is no longer available and will not be available again.
440
+ *
441
+ * This should be used when a resource has been intentionally removed and the resource should be
442
+ * purged. Upon receiving a 410 status code, the client should not request the resource in the
443
+ * future. Clients such as search engines should remove the resource from their indices. Most use
444
+ * cases do not require clients and search engines to purge the resource, and a "404 Not Found" may
445
+ * be used instead.
446
+ */ ZHttpCodeClient[ZHttpCodeClient["Gone"] = 410] = "Gone";
447
+ /**
448
+ * The request did not specify the length of its content, which is required by the requested resource.
449
+ */ ZHttpCodeClient[ZHttpCodeClient["LengthRequired"] = 411] = "LengthRequired";
450
+ /**
451
+ * The server does not meet one of the preconditions that the requester put on the request.
452
+ */ ZHttpCodeClient[ZHttpCodeClient["PreconditionFailed"] = 412] = "PreconditionFailed";
453
+ /**
454
+ * The request is larger than the server is willing or able to process. Previously called
455
+ * "Request Entity Too Large".
456
+ */ ZHttpCodeClient[ZHttpCodeClient["PayloadTooLarge"] = 413] = "PayloadTooLarge";
457
+ /**
458
+ * The URI provided was too long for the server to process.
459
+ *
460
+ * Often the result of too much data being encoded as a query-string of
461
+ * a GET request, in which case it should be converted to a POST request.
462
+ * Called "Request-URI Too Long" previously.
463
+ */ ZHttpCodeClient[ZHttpCodeClient["URITooLong"] = 414] = "URITooLong";
464
+ /**
465
+ * The request entity has a media type which the server or resource does not support.
466
+ *
467
+ * For example, the client uploads an image as image/svg+xml, but the server requires that
468
+ * images use a different format.
469
+ */ ZHttpCodeClient[ZHttpCodeClient["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
470
+ /**
471
+ * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.
472
+ *
473
+ * For example, if the client asked for a part of the file that lies beyond the end of the file.
474
+ * Called "Requested Range Not Satisfiable" previously.
475
+ */ ZHttpCodeClient[ZHttpCodeClient["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
476
+ /**
477
+ * The server cannot meet the requirements of the Expect request-header field.
478
+ */ ZHttpCodeClient[ZHttpCodeClient["ExpectationFailed"] = 417] = "ExpectationFailed";
479
+ /**
480
+ * This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper
481
+ * Text Coffee Pot Control Protocol, and is not expected to be implemented by actual HTTP servers.
482
+ *
483
+ * The RFC specifies this code should be returned by teapots requested to brew coffee. This HTTP
484
+ * status is used as an Easter egg in some websites, including Google.com.
485
+ */ ZHttpCodeClient[ZHttpCodeClient["ImATeapot"] = 418] = "ImATeapot";
486
+ /**
487
+ * The request was directed at a server that is not able to produce a response[53] (for example because of connection reuse).
488
+ */ ZHttpCodeClient[ZHttpCodeClient["MisdirectedRequest"] = 421] = "MisdirectedRequest";
489
+ /**
490
+ * The request was well-formed but was unable to be followed due to semantic errors.
491
+ */ ZHttpCodeClient[ZHttpCodeClient["UnProcessableEntity"] = 422] = "UnProcessableEntity";
492
+ /**
493
+ * The resource that is being accessed is locked.
494
+ */ ZHttpCodeClient[ZHttpCodeClient["Locked"] = 423] = "Locked";
495
+ /**
496
+ * The request failed because it depended on another request and that request failed.
497
+ */ ZHttpCodeClient[ZHttpCodeClient["FailedDependency"] = 424] = "FailedDependency";
498
+ /**
499
+ * The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.
500
+ */ ZHttpCodeClient[ZHttpCodeClient["UpgradeRequired"] = 426] = "UpgradeRequired";
501
+ /**
502
+ * The origin server requires the request to be conditional.
503
+ *
504
+ * Intended to prevent the 'lost update' problem, where a client GETs a resource's state, modifies it,
505
+ * and PUTs it back to the server, when meanwhile a third party has modified the state on the server,
506
+ * leading to a conflict.
507
+ */ ZHttpCodeClient[ZHttpCodeClient["PreconditionRequired"] = 428] = "PreconditionRequired";
508
+ /**
509
+ * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.
510
+ */ ZHttpCodeClient[ZHttpCodeClient["TooManyRequests"] = 429] = "TooManyRequests";
511
+ /**
512
+ * The server is unwilling to process the request because either an individual header field, or all the
513
+ * header fields collectively, are too large.[
514
+ */ ZHttpCodeClient[ZHttpCodeClient["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
515
+ /**
516
+ * A server operator has received a legal demand to deny access to a resource or to a set of resources that includes the
517
+ * requested resource.
518
+ *
519
+ * The code 451 was chosen as a reference to the novel Fahrenheit 451.
520
+ */ ZHttpCodeClient[ZHttpCodeClient["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
521
+ return ZHttpCodeClient;
522
+ }({});
523
+ var _obj$4;
524
+ /**
525
+ * English friendly names of the codes.
526
+ */ var ZHttpCodeClientNames = (_obj$4 = {}, _define_property$6(_obj$4, 400, "Bad Request"), _define_property$6(_obj$4, 401, "Unauthorized"), _define_property$6(_obj$4, 402, "Payment Required"), _define_property$6(_obj$4, 403, "Forbidden"), _define_property$6(_obj$4, 404, "Not Found"), _define_property$6(_obj$4, 405, "Method not Allowed"), _define_property$6(_obj$4, 406, "Not Acceptable"), _define_property$6(_obj$4, 407, "Proxy Authentication Required"), _define_property$6(_obj$4, 408, "Request Timeout"), _define_property$6(_obj$4, 409, "Conflict"), _define_property$6(_obj$4, 410, "Gone"), _define_property$6(_obj$4, 411, "Length Required"), _define_property$6(_obj$4, 412, "Precondition Failed"), _define_property$6(_obj$4, 413, "Payload Too Large"), _define_property$6(_obj$4, 414, "URI Too Long"), _define_property$6(_obj$4, 415, "Unsupported Media Type"), _define_property$6(_obj$4, 416, "Range Not Satisfiable"), _define_property$6(_obj$4, 417, "Expectation Failed"), _define_property$6(_obj$4, 418, "I am a Teapot"), _define_property$6(_obj$4, 421, "Misdirected Requested"), _define_property$6(_obj$4, 422, "Entity Not Processable"), _define_property$6(_obj$4, 423, "Locked"), _define_property$6(_obj$4, 424, "Failed Dependency"), _define_property$6(_obj$4, 426, "Upgrade Required"), _define_property$6(_obj$4, 428, "Precondition Required"), _define_property$6(_obj$4, 429, "Too Many Requests"), _define_property$6(_obj$4, 431, "Request Header Fields Too Large"), _define_property$6(_obj$4, 451, "Unavailable for Legal Reasons"), _obj$4);
527
+ var _obj1$4;
528
+ /**
529
+ * English friendly descriptions of HttpClientCodes
530
+ */ var ZHttpCodeClientDescriptions = (_obj1$4 = {}, _define_property$6(_obj1$4, 400, "A bad request was sent."), _define_property$6(_obj1$4, 401, "You are not authenticated and cannot view this content."), _define_property$6(_obj1$4, 402, "Payment is required"), _define_property$6(_obj1$4, 403, "You are not authorized to view this content."), _define_property$6(_obj1$4, 404, "The resource you are looking for could not be found."), _define_property$6(_obj1$4, 405, "The requested operation was not allowed."), _define_property$6(_obj1$4, 406, "The requested resource is not capable of generating the content for you."), _define_property$6(_obj1$4, 407, "You must first authenticate your self with the proxy."), _define_property$6(_obj1$4, 408, "The server timed out waiting for a request. Please try again."), _define_property$6(_obj1$4, 409, "There was a conflict with request. Try something else."), _define_property$6(_obj1$4, 410, "The resource you requested is no longer available."), _define_property$6(_obj1$4, 411, "Your request did not specify the length of its content, which is required by the requested resource."), _define_property$6(_obj1$4, 412, "The server did not meet the requirements that was required to meet the request."), _define_property$6(_obj1$4, 413, "The request is too large and the server cannot handle it."), _define_property$6(_obj1$4, 414, "The URI provided was too long for the server to process."), _define_property$6(_obj1$4, 415, "The media type requested is not supported by the server."), _define_property$6(_obj1$4, 416, "A portion of the file was requested by the server cannot supply said portion."), _define_property$6(_obj1$4, 417, "The server cannot meet the requirements of the expectation made of it."), _define_property$6(_obj1$4, 418, "Short and stout. Here is my handle, here is my spout. When I get all steamed up, hear me shout. Tip me over and pour me out!"), _define_property$6(_obj1$4, 421, "The request was directed at the server, but the server cannot produce a response."), _define_property$6(_obj1$4, 422, "The request was well-formed but was unable to be followed due to semantic errors."), _define_property$6(_obj1$4, 423, "The resource that is being accessed is locked."), _define_property$6(_obj1$4, 424, "The request failed because it depended on another request and that request failed."), _define_property$6(_obj1$4, 426, "The client needs to switch to a different protocol."), _define_property$6(_obj1$4, 428, "The origin server requires the request to be conditional."), _define_property$6(_obj1$4, 429, "The user has sent too many requests in a given amount of time."), _define_property$6(_obj1$4, 431, "The request cannot be processed because the collective header fields are too large."), _define_property$6(_obj1$4, 451, "Call your lawyer!"), _obj1$4);
531
+
532
+ /**
533
+ * An informational response indicates that the request was received and understood.
534
+ *
535
+ * It is issued on a provisional basis while request processing continues. It alerts the
536
+ * client to wait for a final response. The message consists only of the status line and
537
+ * optional header fields, and is terminated by an empty line. As the HTTP/1.0 standard
538
+ * did not define any 1xx status codes, servers must not[note 1] send a 1xx response to
539
+ * an HTTP/1.0 compliant client except under experimental conditions.[4]
540
+ */ function _define_property$5(obj, key, value) {
541
+ if (key in obj) {
542
+ Object.defineProperty(obj, key, {
543
+ value: value,
544
+ enumerable: true,
545
+ configurable: true,
546
+ writable: true
547
+ });
548
+ } else {
549
+ obj[key] = value;
550
+ }
551
+ return obj;
838
552
  }
839
- function getHttpCodeDescription(code) {
840
- return ZHttpCodeInformationalResponseDescriptions[code] || ZHttpCodeSuccessDescriptions[code] || ZHttpCodeRedirectionDescriptions[code] || ZHttpCodeClientDescriptions[code] || ZHttpCodeServerDescriptions[code];
553
+ var ZHttpCodeInformationalResponse = /*#__PURE__*/ function(ZHttpCodeInformationalResponse) {
554
+ /**
555
+ * The server has received the request headers and the client should proceed to send the
556
+ * request body (in the case of a request for which a body needs to be sent; for example, a
557
+ * POST request).
558
+ *
559
+ * Sending a large request body to a server after a request has been rejected
560
+ * for inappropriate headers would be inefficient. To have a server check the request's headers,
561
+ * a client must send Expect: 100-continue as a header in its initial request and receive a 100 Continue status
562
+ * code in response before sending the body. If the client receives an error code such as 403 (Forbidden) or 405
563
+ * (Method Not Allowed) then it shouldn't send the request's body. The response 417 Expectation Failed indicates
564
+ * that the request should be repeated without the Expect header as it indicates that the server doesn't support
565
+ * expectations (this is the case, for example, of HTTP/1.0 servers).
566
+ */ ZHttpCodeInformationalResponse[ZHttpCodeInformationalResponse["Continue"] = 100] = "Continue";
567
+ /**
568
+ * The requester has asked the server to switch protocols and the server has agreed to do so.
569
+ */ ZHttpCodeInformationalResponse[ZHttpCodeInformationalResponse["SwitchingProtocols"] = 101] = "SwitchingProtocols";
570
+ /**
571
+ * A WebDAV request may contain many sub-requests involving file operations, requiring a long time to
572
+ * complete the request. This code indicates that the server has received and is processing the request,
573
+ * but no response is available yet. This prevents the client from timing out and assuming the request was lost.
574
+ */ ZHttpCodeInformationalResponse[ZHttpCodeInformationalResponse["Processing"] = 102] = "Processing";
575
+ /**
576
+ * Used to return some response headers before final HTTP message.
577
+ */ ZHttpCodeInformationalResponse[ZHttpCodeInformationalResponse["EarlyHints"] = 103] = "EarlyHints";
578
+ return ZHttpCodeInformationalResponse;
579
+ }({});
580
+ var _obj$3;
581
+ /**
582
+ * English friendly names of the codes.
583
+ */ var ZHttpCodeInformationalResponseNames = (_obj$3 = {}, _define_property$5(_obj$3, 100, "Continue"), _define_property$5(_obj$3, 101, "Switching Protocols"), _define_property$5(_obj$3, 102, "Processing"), _define_property$5(_obj$3, 103, "Early Hints"), _obj$3);
584
+ var _obj1$3;
585
+ /**
586
+ * English friendly descriptions of the codes.
587
+ */ var ZHttpCodeInformationalResponseDescriptions = (_obj1$3 = {}, _define_property$5(_obj1$3, 100, "The client should continue to send the request body."), _define_property$5(_obj1$3, 101, "The requestor has asked the server to switch protocols and the server has agreed to do so."), _define_property$5(_obj1$3, 102, "The server has received and is processing the request, but a response is not available yet."), _define_property$5(_obj1$3, 103, "There are some early response headers available for you before the final message."), _obj1$3);
588
+
589
+ /**
590
+ * This class of status code indicates the client must take additional action to complete the request.
591
+ *
592
+ * Many of these status codes are used in URL redirection. A user agent may carry out the additional
593
+ * action with no user interaction only if the method used in the second request is GET or HEAD.
594
+ * A user agent may automatically redirect a request. A user agent should detect and intervene
595
+ * to prevent cyclical redirects.
596
+ */ function _define_property$4(obj, key, value) {
597
+ if (key in obj) {
598
+ Object.defineProperty(obj, key, {
599
+ value: value,
600
+ enumerable: true,
601
+ configurable: true,
602
+ writable: true
603
+ });
604
+ } else {
605
+ obj[key] = value;
606
+ }
607
+ return obj;
841
608
  }
842
- function getHttpCodeSeverity(code) {
843
- if (code >= 200 && code < 300) {
844
- return "success";
845
- }
846
- if (code >= 400 && code < 500) {
847
- return "warning";
848
- }
849
- if (code >= 500) {
850
- return "error";
851
- }
852
- return "info";
609
+ var ZHttpCodeRedirection = /*#__PURE__*/ function(ZHttpCodeRedirection) {
610
+ /**
611
+ * Indicates multiple options for the resource from which the client may choose
612
+ * (via agent-driven content negotiation).
613
+ *
614
+ * For example, this code could be used to present multiple video format options, to
615
+ * list files with different filename extensions, or to suggest word-sense disambiguation.
616
+ */ ZHttpCodeRedirection[ZHttpCodeRedirection["MultipleChoices"] = 300] = "MultipleChoices";
617
+ /**
618
+ * This and all future requests should be directed to the given URI.
619
+ */ ZHttpCodeRedirection[ZHttpCodeRedirection["MovedPermanently"] = 301] = "MovedPermanently";
620
+ /**
621
+ * Tells the client to look at (browse to) another url. 302 has been superseded by 303 and 307.
622
+ * This is an example of industry practice contradicting the standard. The HTTP/1.0 specification (RFC 1945)
623
+ * required the client to perform a temporary redirect (the original describing phrase was "Moved Temporarily"),
624
+ * [22] but popular browsers implemented 302 with the functionality of a 303 See Other. Therefore, HTTP/1.1
625
+ * added status codes 303 and 307 to distinguish between the two behaviors.[23] However, some Web applications
626
+ * and frameworks use the 302 status code as if it were the 303.
627
+ */ ZHttpCodeRedirection[ZHttpCodeRedirection["Found"] = 302] = "Found";
628
+ /**
629
+ * The response to the request can be found under another URI using the GET method.
630
+ *
631
+ * When received in response to a POST (or PUT/DELETE), the client should presume
632
+ * that the server has received the data and should issue a new GET request to
633
+ * the given URI.
634
+ */ ZHttpCodeRedirection[ZHttpCodeRedirection["SeeOther"] = 303] = "SeeOther";
635
+ /**
636
+ * Indicates that the resource has not been modified since the version specified by the request headers
637
+ * If-Modified-Since or If-None-Match. In such case, there is no need to retransmit the resource since
638
+ * the client still has a previously-downloaded copy.
639
+ */ ZHttpCodeRedirection[ZHttpCodeRedirection["NotModified"] = 304] = "NotModified";
640
+ /**
641
+ * The requested resource is available only through a proxy, the address for which is provided in the response.
642
+ *
643
+ * Many HTTP clients (such as Mozilla[27] and Internet Explorer) do not correctly handle responses with
644
+ * this status code, primarily for security reasons.
645
+ */ ZHttpCodeRedirection[ZHttpCodeRedirection["UseProxy"] = 305] = "UseProxy";
646
+ /**
647
+ * No longer used. Originally meant "Subsequent requests should use the specified proxy.
648
+ */ ZHttpCodeRedirection[ZHttpCodeRedirection["SwitchProxy"] = 306] = "SwitchProxy";
649
+ /**
650
+ * In this case, the request should be repeated with another URI; however, future requests
651
+ * should still use the original URI.
652
+ *
653
+ * In contrast to how 302 was historically implemented, the request method is not allowed to be
654
+ * changed when reissuing the original request. For example, a POST request should be repeated using
655
+ * another POST request.
656
+ */ ZHttpCodeRedirection[ZHttpCodeRedirection["TemporaryRedirect"] = 307] = "TemporaryRedirect";
657
+ /**
658
+ * The request and all future requests should be repeated using another URI.
659
+ *
660
+ * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.
661
+ * So, for example, submitting a form to a permanently redirected resource may continue smoothly.
662
+ */ ZHttpCodeRedirection[ZHttpCodeRedirection["PermanentRedirect"] = 308] = "PermanentRedirect";
663
+ return ZHttpCodeRedirection;
664
+ }({});
665
+ var _obj$2;
666
+ /**
667
+ * English friendly names of the redirection codes.
668
+ */ var ZHttpCodeRedirectionNames = (_obj$2 = {}, _define_property$4(_obj$2, 300, "Multiple Choices"), _define_property$4(_obj$2, 301, "Moved Permanently"), _define_property$4(_obj$2, 302, "Found"), _define_property$4(_obj$2, 303, "See Other"), _define_property$4(_obj$2, 304, "Not Modified"), _define_property$4(_obj$2, 305, "Use Proxy"), _define_property$4(_obj$2, 306, "Switch Proxy"), _define_property$4(_obj$2, 307, "Temporary Redirect"), _define_property$4(_obj$2, 308, "Permanent Redirect"), _obj$2);
669
+ var _obj1$2;
670
+ /**
671
+ * English friendly descriptions of the redirection codes.
672
+ */ var ZHttpCodeRedirectionDescriptions = (_obj1$2 = {}, _define_property$4(_obj1$2, 300, "Indicates multiple options for the resource from which the client may choose."), _define_property$4(_obj1$2, 301, "This and all future requests should be directed to the given URI."), _define_property$4(_obj1$2, 302, "Tells the client to look at another url"), _define_property$4(_obj1$2, 303, "The response to the request can be found under another URI using the GET method."), _define_property$4(_obj1$2, 304, "Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match."), _define_property$4(_obj1$2, 305, "The requested resource is available only through a proxy, the address for which is provided in the response."), _define_property$4(_obj1$2, 306, 'No longer used. Originally meant "Subsequent requests should use the specified proxy.'), _define_property$4(_obj1$2, 307, "In this case, the request should be repeated with another URI; however, future requests should still use the original URI."), _define_property$4(_obj1$2, 308, "The request and all future requests should be repeated using another URI."), _obj1$2);
673
+
674
+ /**
675
+ * The server failed to fulfil a request.
676
+ *
677
+ * Response status codes beginning with the digit "5" indicate
678
+ * cases in which the server is aware that it has encountered an
679
+ * error or is otherwise incapable of performing the request. Except
680
+ * when responding to a HEAD request, the server should include an entity
681
+ * containing an explanation of the error situation, and indicate whether it
682
+ * is a temporary or permanent condition. Likewise, user agents should
683
+ * display any included entity to the user. These response codes are applicable
684
+ * to any request method.
685
+ */ function _define_property$3(obj, key, value) {
686
+ if (key in obj) {
687
+ Object.defineProperty(obj, key, {
688
+ value: value,
689
+ enumerable: true,
690
+ configurable: true,
691
+ writable: true
692
+ });
693
+ } else {
694
+ obj[key] = value;
695
+ }
696
+ return obj;
853
697
  }
854
- function getHttpCodeCategory(code) {
855
- if (code >= 100 && code < 200) {
856
- return "Informational Response";
857
- }
858
- if (code >= 200 && code < 300) {
859
- return "Success";
860
- }
861
- if (code >= 300 && code < 400) {
862
- return "Redirection";
863
- }
864
- if (code >= 400 && code < 500) {
865
- return "Client Error";
866
- }
867
- return "Server Error";
698
+ var ZHttpCodeServer = /*#__PURE__*/ function(ZHttpCodeServer) {
699
+ /**
700
+ * A generic error message, given when an unexpected condition was encountered
701
+ * and no more specific message is suitable.
702
+ */ ZHttpCodeServer[ZHttpCodeServer["InternalServerError"] = 500] = "InternalServerError";
703
+ /**
704
+ * The server either does not recognize the request method, or it lacks the ability to
705
+ * fulfil the request. Usually this implies future availability (e.g., a new feature of
706
+ * a web-service API).
707
+ */ ZHttpCodeServer[ZHttpCodeServer["NotImplemented"] = 501] = "NotImplemented";
708
+ /**
709
+ * The server was acting as a gateway or proxy and received an invalid response
710
+ * from the upstream server.
711
+ */ ZHttpCodeServer[ZHttpCodeServer["BadGateway"] = 502] = "BadGateway";
712
+ /**
713
+ * The server is currently unavailable (because it is overloaded or down for maintenance).
714
+ * Generally, this is a temporary state.
715
+ */ ZHttpCodeServer[ZHttpCodeServer["ServiceUnavailable"] = 503] = "ServiceUnavailable";
716
+ /**
717
+ * The server was acting as a gateway or proxy and did not receive a timely response from
718
+ * the upstream server.
719
+ */ ZHttpCodeServer[ZHttpCodeServer["GatewayTimeout"] = 504] = "GatewayTimeout";
720
+ /**
721
+ * The server does not support the HTTP protocol version used in the request.
722
+ */ ZHttpCodeServer[ZHttpCodeServer["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
723
+ /**
724
+ * Transparent content negotiation for the request results in a circular reference.
725
+ */ ZHttpCodeServer[ZHttpCodeServer["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
726
+ /**
727
+ * The server is unable to store the representation needed to complete the request.
728
+ */ ZHttpCodeServer[ZHttpCodeServer["InsufficientStorage"] = 507] = "InsufficientStorage";
729
+ /**
730
+ * The server detected an infinite loop while processing the request.
731
+ */ ZHttpCodeServer[ZHttpCodeServer["LoopDetected"] = 508] = "LoopDetected";
732
+ /**
733
+ * Further extensions to the request are required for the server to fulfil it.
734
+ */ ZHttpCodeServer[ZHttpCodeServer["NotExtended"] = 510] = "NotExtended";
735
+ /**
736
+ * The client needs to authenticate to gain network access. Intended for use by
737
+ * intercepting proxies used to control access to the network.
738
+ */ ZHttpCodeServer[ZHttpCodeServer["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
739
+ return ZHttpCodeServer;
740
+ }({});
741
+ var _obj$1;
742
+ /**
743
+ * English friendly names of the server codes.
744
+ */ var ZHttpCodeServerNames = (_obj$1 = {}, _define_property$3(_obj$1, 500, "Internal Server Error"), _define_property$3(_obj$1, 501, "Not Implemented"), _define_property$3(_obj$1, 502, "Bad Gateway"), _define_property$3(_obj$1, 503, "Service Unavailable"), _define_property$3(_obj$1, 504, "Gateway Timeout"), _define_property$3(_obj$1, 505, "HTTP Version Not Supported"), _define_property$3(_obj$1, 506, "Variant Also Negotiates"), _define_property$3(_obj$1, 507, "Insufficient Storage"), _define_property$3(_obj$1, 508, "Loop Detected"), _define_property$3(_obj$1, 510, "Not Extended"), _define_property$3(_obj$1, 511, "Network Authentication Required"), _obj$1);
745
+ var _obj1$1;
746
+ /**
747
+ * English friendly names of the server codes.
748
+ */ var ZHttpCodeServerDescriptions = (_obj1$1 = {}, _define_property$3(_obj1$1, 500, "An unexpected condition was encountered on the server."), _define_property$3(_obj1$1, 501, "The server either does not recognize the request method, or it lacks the ability to fulfil the request. Usually this implies future availability (e.g., a new feature of a web-service API)."), _define_property$3(_obj1$1, 502, " The server was acting as a gateway or proxy and received an invalid response from the upstream server."), _define_property$3(_obj1$1, 503, "The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state."), _define_property$3(_obj1$1, 504, "The server was acting as a gateway or proxy and did not receive a timely response from the upstream server."), _define_property$3(_obj1$1, 505, "The server does not support the HTTP protocol version used in the request."), _define_property$3(_obj1$1, 506, " Transparent content negotiation for the request results in a circular reference."), _define_property$3(_obj1$1, 507, "The server is unable to store the representation needed to complete the request."), _define_property$3(_obj1$1, 508, "The server detected an infinite loop while processing the request."), _define_property$3(_obj1$1, 510, "Further extensions to the request are required for the server to fulfil it."), _define_property$3(_obj1$1, 511, "The client needs to authenticate to gain network access."), _obj1$1);
749
+
750
+ /**
751
+ * This class of status codes indicates the action requested by
752
+ * the client was received, understood and accepted.
753
+ */ function _define_property$2(obj, key, value) {
754
+ if (key in obj) {
755
+ Object.defineProperty(obj, key, {
756
+ value: value,
757
+ enumerable: true,
758
+ configurable: true,
759
+ writable: true
760
+ });
761
+ } else {
762
+ obj[key] = value;
763
+ }
764
+ return obj;
868
765
  }
869
- class ZHttpResultBuilder {
870
- /**
871
- * Initializes a new instance of this object.
766
+ var ZHttpCodeSuccess = /*#__PURE__*/ function(ZHttpCodeSuccess) {
767
+ /**
768
+ * Standard response for successful HTTP requests.
872
769
  *
873
- * @param data -
874
- * The data result.
875
- */
876
- constructor(data) {
877
- this._result = {
878
- status: ZHttpCodeSuccess.OK,
879
- headers: {},
880
- data
881
- };
882
- }
883
- /**
770
+ * The actual response will depend on the request method used. In a GET
771
+ * request, the response will contain an entity corresponding to the
772
+ * requested resource. In a POST request, the response will contain an
773
+ * entity describing or containing the result of the action.
774
+ */ ZHttpCodeSuccess[ZHttpCodeSuccess["OK"] = 200] = "OK";
775
+ /**
776
+ * The request has been fulfilled, resulting in the creation of a new resource.
777
+ */ ZHttpCodeSuccess[ZHttpCodeSuccess["Created"] = 201] = "Created";
778
+ /**
779
+ * The request has been accepted for processing, but the processing has not been completed.
780
+ *
781
+ * The request might or might not be eventually acted upon, and may be disallowed when processing occurs.
782
+ */ ZHttpCodeSuccess[ZHttpCodeSuccess["Accepted"] = 202] = "Accepted";
783
+ /**
784
+ * The server is a transforming proxy (e.g. a Web accelerator) that received a 200 OK from its origin,
785
+ * but is returning a modified version of the origin's response.
786
+ */ ZHttpCodeSuccess[ZHttpCodeSuccess["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
787
+ /**
788
+ * The server successfully processed the request and is not returning any content.
789
+ */ ZHttpCodeSuccess[ZHttpCodeSuccess["NoContent"] = 204] = "NoContent";
790
+ /**
791
+ * The server successfully processed the request, but is not returning any content.
792
+ *
793
+ * Unlike a 204 response, this response requires that the requester reset the document view.
794
+ */ ZHttpCodeSuccess[ZHttpCodeSuccess["ResetContent"] = 205] = "ResetContent";
795
+ /**
796
+ * The server is delivering only part of the resource (byte serving) due to a range header
797
+ * sent by the client.
798
+ *
799
+ * The range header is used by HTTP clients to enable resuming of interrupted downloads, or
800
+ * split a download into multiple simultaneous streams.
801
+ */ ZHttpCodeSuccess[ZHttpCodeSuccess["PartialContent"] = 206] = "PartialContent";
802
+ /**
803
+ * The message body that follows is by default an XML message and can contain a number of separate
804
+ * response codes, depending on how many sub-requests were made.
805
+ */ ZHttpCodeSuccess[ZHttpCodeSuccess["MultiStatus"] = 207] = "MultiStatus";
806
+ /**
807
+ * The members of a DAV binding have already been enumerated in a preceding part of the
808
+ * response, and are not being included again.
809
+ */ ZHttpCodeSuccess[ZHttpCodeSuccess["AlreadyReported"] = 208] = "AlreadyReported";
810
+ /**
811
+ * The server has fulfilled a request for the resource, and the response is a representation of the result
812
+ * of one or more instance-manipulations applied to the current instance.
813
+ */ ZHttpCodeSuccess[ZHttpCodeSuccess["IMUsed"] = 226] = "IMUsed";
814
+ return ZHttpCodeSuccess;
815
+ }({});
816
+ var _obj;
817
+ /**
818
+ * Friendly english names of success codes.
819
+ */ var ZHttpCodeSuccessNames = (_obj = {}, _define_property$2(_obj, 200, "OK"), _define_property$2(_obj, 201, "Created"), _define_property$2(_obj, 202, "Accepted"), _define_property$2(_obj, 203, "Non-Authoritative Information"), _define_property$2(_obj, 204, "No Content"), _define_property$2(_obj, 205, "Reset Content"), _define_property$2(_obj, 206, "Partial Content"), _define_property$2(_obj, 207, "Multi Status"), _define_property$2(_obj, 208, "Already Reported"), _define_property$2(_obj, 226, "IM Used"), _obj);
820
+ var _obj1;
821
+ /**
822
+ * Friendly english descriptions of success codes.
823
+ */ var ZHttpCodeSuccessDescriptions = (_obj1 = {}, _define_property$2(_obj1, 200, "The request was successful."), _define_property$2(_obj1, 201, "The request has been fulfilled, resulting in the creation of a new resource."), _define_property$2(_obj1, 202, "The request has been accepted for processing, but the processing has not been completed."), _define_property$2(_obj1, 203, "The server is a transforming proxy that received an OK from its origin,but is returning a modified version of the response."), _define_property$2(_obj1, 204, "The server successfully processed the request and is not returning any content."), _define_property$2(_obj1, 205, "The server successfully processed the request, but is not returning any content. The document view must be refreshed."), _define_property$2(_obj1, 206, "he server is delivering only part of the resource due to a range header sent by the client."), _define_property$2(_obj1, 207, "The message body that follows is by default an XML message and can contain a number of separate response codes, depending on how many sub-requests were made."), _define_property$2(_obj1, 208, "The members of a DAV binding have already been enumerated in a preceding part of the response, and are not being included again."), _define_property$2(_obj1, 226, "The server has fulfilled a request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance."), _obj1);
824
+
825
+ /**
826
+ * Represents the category name for an http code.
827
+ */ var ZHttpCodeCategory = /*#__PURE__*/ function(ZHttpCodeCategory) {
828
+ /**
829
+ * Error codes 100-199.
830
+ */ ZHttpCodeCategory["InformationalResponse"] = "Informational Response";
831
+ /**
832
+ * Error codes 200-299.
833
+ */ ZHttpCodeCategory["Success"] = "Success";
834
+ /**
835
+ * Error codes 300-399.
836
+ */ ZHttpCodeCategory["Redirection"] = "Redirection";
837
+ /**
838
+ * Error codes 400-499.
839
+ */ ZHttpCodeCategory["Client"] = "Client Error";
840
+ /**
841
+ * Error codes 500-599.
842
+ */ ZHttpCodeCategory["Server"] = "Server Error";
843
+ return ZHttpCodeCategory;
844
+ }({});
845
+ /**
846
+ * Represents a classification of severity for a code.
847
+ */ var ZHttpCodeSeverity = /*#__PURE__*/ function(ZHttpCodeSeverity) {
848
+ /**
849
+ * Covers information response (100-199) and redirection codes (300-399).
850
+ */ ZHttpCodeSeverity["Info"] = "info";
851
+ /**
852
+ * Covers the success codes (200-299)
853
+ */ ZHttpCodeSeverity["Success"] = "success";
854
+ /**
855
+ * Covers client errors (400-499).
856
+ */ ZHttpCodeSeverity["Warning"] = "warning";
857
+ /**
858
+ * Covers server errors (500-599).
859
+ */ ZHttpCodeSeverity["Error"] = "error";
860
+ return ZHttpCodeSeverity;
861
+ }({});
862
+ /**
863
+ * Gets the english friendly name of a code.
864
+ *
865
+ * @param code -
866
+ * The code to retrieve the name for.
867
+ *
868
+ * @returns
869
+ * The english friendly name of a code.
870
+ */ function getHttpCodeName(code) {
871
+ return ZHttpCodeInformationalResponseNames[code] || ZHttpCodeSuccessNames[code] || ZHttpCodeRedirectionNames[code] || ZHttpCodeClientNames[code] || ZHttpCodeServerNames[code];
872
+ }
873
+ /**
874
+ * Gets the english friendly description of a code.
875
+ *
876
+ * @param code -
877
+ * The code to retrieve the description for.
878
+ *
879
+ * @returns
880
+ * The english friendly description of a code.
881
+ */ function getHttpCodeDescription(code) {
882
+ return ZHttpCodeInformationalResponseDescriptions[code] || ZHttpCodeSuccessDescriptions[code] || ZHttpCodeRedirectionDescriptions[code] || ZHttpCodeClientDescriptions[code] || ZHttpCodeServerDescriptions[code];
883
+ }
884
+ /**
885
+ * Gets the severity of a code.
886
+ *
887
+ * @param code -
888
+ * The severity of a code.
889
+ *
890
+ * @returns
891
+ * The severity of a code.
892
+ */ function getHttpCodeSeverity(code) {
893
+ if (code >= 200 && code < 300) {
894
+ return "success";
895
+ }
896
+ if (code >= 400 && code < 500) {
897
+ return "warning";
898
+ }
899
+ if (code >= 500) {
900
+ return "error";
901
+ }
902
+ return "info";
903
+ }
904
+ /**
905
+ * Gets the category of a code.
906
+ *
907
+ * @param code -
908
+ * The category of a code.
909
+ *
910
+ * @returns
911
+ * The code category.
912
+ */ function getHttpCodeCategory(code) {
913
+ if (code >= 100 && code < 200) {
914
+ return "Informational Response";
915
+ }
916
+ if (code >= 200 && code < 300) {
917
+ return "Success";
918
+ }
919
+ if (code >= 300 && code < 400) {
920
+ return "Redirection";
921
+ }
922
+ if (code >= 400 && code < 500) {
923
+ return "Client Error";
924
+ }
925
+ return "Server Error";
926
+ }
927
+
928
+ function _class_call_check$2(instance, Constructor) {
929
+ if (!(instance instanceof Constructor)) {
930
+ throw new TypeError("Cannot call a class as a function");
931
+ }
932
+ }
933
+ function _defineProperties$2(target, props) {
934
+ for(var i = 0; i < props.length; i++){
935
+ var descriptor = props[i];
936
+ descriptor.enumerable = descriptor.enumerable || false;
937
+ descriptor.configurable = true;
938
+ if ("value" in descriptor) descriptor.writable = true;
939
+ Object.defineProperty(target, descriptor.key, descriptor);
940
+ }
941
+ }
942
+ function _create_class$2(Constructor, protoProps, staticProps) {
943
+ if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
944
+ return Constructor;
945
+ }
946
+ function _define_property$1(obj, key, value) {
947
+ if (key in obj) {
948
+ Object.defineProperty(obj, key, {
949
+ value: value,
950
+ enumerable: true,
951
+ configurable: true,
952
+ writable: true
953
+ });
954
+ } else {
955
+ obj[key] = value;
956
+ }
957
+ return obj;
958
+ }
959
+ function _object_spread(target) {
960
+ for(var i = 1; i < arguments.length; i++){
961
+ var source = arguments[i] != null ? arguments[i] : {};
962
+ var ownKeys = Object.keys(source);
963
+ if (typeof Object.getOwnPropertySymbols === "function") {
964
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
965
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
966
+ }));
967
+ }
968
+ ownKeys.forEach(function(key) {
969
+ _define_property$1(target, key, source[key]);
970
+ });
971
+ }
972
+ return target;
973
+ }
974
+ /**
975
+ * Represents a builder for an IZHttpResult class.
976
+ */ var ZHttpResultBuilder = /*#__PURE__*/ function() {
977
+ function ZHttpResultBuilder(data) {
978
+ _class_call_check$2(this, ZHttpResultBuilder);
979
+ _define_property$1(this, "_result", void 0);
980
+ this._result = {
981
+ status: ZHttpCodeSuccess.OK,
982
+ headers: {},
983
+ data: data
984
+ };
985
+ }
986
+ _create_class$2(ZHttpResultBuilder, [
987
+ {
988
+ key: "data",
989
+ value: /**
884
990
  * Sets the data.
885
991
  *
886
992
  * @param data -
@@ -888,12 +994,14 @@ class ZHttpResultBuilder {
888
994
  *
889
995
  * @returns
890
996
  * This object.
891
- */
892
- data(data) {
893
- this._result.data = data;
894
- return this;
895
- }
896
- /**
997
+ */ function data(data) {
998
+ this._result.data = data;
999
+ return this;
1000
+ }
1001
+ },
1002
+ {
1003
+ key: "status",
1004
+ value: /**
897
1005
  * Sets the status code and the english description.
898
1006
  *
899
1007
  * @param code -
@@ -901,12 +1009,14 @@ class ZHttpResultBuilder {
901
1009
  *
902
1010
  * @returns
903
1011
  * This object.
904
- */
905
- status(code) {
906
- this._result.status = code;
907
- return this;
908
- }
909
- /**
1012
+ */ function status(code) {
1013
+ this._result.status = code;
1014
+ return this;
1015
+ }
1016
+ },
1017
+ {
1018
+ key: "headers",
1019
+ value: /**
910
1020
  * Sets the return headers.
911
1021
  *
912
1022
  * @param headers -
@@ -914,26 +1024,190 @@ class ZHttpResultBuilder {
914
1024
  *
915
1025
  * @returns
916
1026
  * This object.
917
- */
918
- headers(headers = {}) {
919
- this._result.headers = headers;
920
- return this;
921
- }
922
- /**
1027
+ */ function headers() {
1028
+ var headers = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1029
+ this._result.headers = headers;
1030
+ return this;
1031
+ }
1032
+ },
1033
+ {
1034
+ key: "build",
1035
+ value: /**
923
1036
  * Returns the built up result.
924
1037
  *
925
1038
  * @returns
926
1039
  * A shallow copy of the built up result.
927
- */
928
- build() {
929
- return { ...this._result };
930
- }
1040
+ */ function build() {
1041
+ return _object_spread({}, this._result);
1042
+ }
1043
+ }
1044
+ ]);
1045
+ return ZHttpResultBuilder;
1046
+ }();
1047
+
1048
+ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
1049
+ try {
1050
+ var info = gen[key](arg);
1051
+ var value = info.value;
1052
+ } catch (error) {
1053
+ reject(error);
1054
+ return;
1055
+ }
1056
+ if (info.done) {
1057
+ resolve(value);
1058
+ } else {
1059
+ Promise.resolve(value).then(_next, _throw);
1060
+ }
1061
+ }
1062
+ function _async_to_generator$1(fn) {
1063
+ return function() {
1064
+ var self = this, args = arguments;
1065
+ return new Promise(function(resolve, reject) {
1066
+ var gen = fn.apply(self, args);
1067
+ function _next(value) {
1068
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1069
+ }
1070
+ function _throw(err) {
1071
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
1072
+ }
1073
+ _next(undefined);
1074
+ });
1075
+ };
931
1076
  }
932
- class ZHttpServiceMock {
933
- constructor() {
934
- this._mapping = {};
935
- }
936
- /**
1077
+ function _class_call_check$1(instance, Constructor) {
1078
+ if (!(instance instanceof Constructor)) {
1079
+ throw new TypeError("Cannot call a class as a function");
1080
+ }
1081
+ }
1082
+ function _defineProperties$1(target, props) {
1083
+ for(var i = 0; i < props.length; i++){
1084
+ var descriptor = props[i];
1085
+ descriptor.enumerable = descriptor.enumerable || false;
1086
+ descriptor.configurable = true;
1087
+ if ("value" in descriptor) descriptor.writable = true;
1088
+ Object.defineProperty(target, descriptor.key, descriptor);
1089
+ }
1090
+ }
1091
+ function _create_class$1(Constructor, protoProps, staticProps) {
1092
+ if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
1093
+ return Constructor;
1094
+ }
1095
+ function _define_property(obj, key, value) {
1096
+ if (key in obj) {
1097
+ Object.defineProperty(obj, key, {
1098
+ value: value,
1099
+ enumerable: true,
1100
+ configurable: true,
1101
+ writable: true
1102
+ });
1103
+ } else {
1104
+ obj[key] = value;
1105
+ }
1106
+ return obj;
1107
+ }
1108
+ function _ts_generator$1(thisArg, body) {
1109
+ var f, y, t, _ = {
1110
+ label: 0,
1111
+ sent: function() {
1112
+ if (t[0] & 1) throw t[1];
1113
+ return t[1];
1114
+ },
1115
+ trys: [],
1116
+ ops: []
1117
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
1118
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
1119
+ return this;
1120
+ }), g;
1121
+ function verb(n) {
1122
+ return function(v) {
1123
+ return step([
1124
+ n,
1125
+ v
1126
+ ]);
1127
+ };
1128
+ }
1129
+ function step(op) {
1130
+ if (f) throw new TypeError("Generator is already executing.");
1131
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
1132
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1133
+ if (y = 0, t) op = [
1134
+ op[0] & 2,
1135
+ t.value
1136
+ ];
1137
+ switch(op[0]){
1138
+ case 0:
1139
+ case 1:
1140
+ t = op;
1141
+ break;
1142
+ case 4:
1143
+ _.label++;
1144
+ return {
1145
+ value: op[1],
1146
+ done: false
1147
+ };
1148
+ case 5:
1149
+ _.label++;
1150
+ y = op[1];
1151
+ op = [
1152
+ 0
1153
+ ];
1154
+ continue;
1155
+ case 7:
1156
+ op = _.ops.pop();
1157
+ _.trys.pop();
1158
+ continue;
1159
+ default:
1160
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1161
+ _ = 0;
1162
+ continue;
1163
+ }
1164
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1165
+ _.label = op[1];
1166
+ break;
1167
+ }
1168
+ if (op[0] === 6 && _.label < t[1]) {
1169
+ _.label = t[1];
1170
+ t = op;
1171
+ break;
1172
+ }
1173
+ if (t && _.label < t[2]) {
1174
+ _.label = t[2];
1175
+ _.ops.push(op);
1176
+ break;
1177
+ }
1178
+ if (t[2]) _.ops.pop();
1179
+ _.trys.pop();
1180
+ continue;
1181
+ }
1182
+ op = body.call(thisArg, _);
1183
+ } catch (e) {
1184
+ op = [
1185
+ 6,
1186
+ e
1187
+ ];
1188
+ y = 0;
1189
+ } finally{
1190
+ f = t = 0;
1191
+ }
1192
+ if (op[0] & 5) throw op[1];
1193
+ return {
1194
+ value: op[0] ? op[1] : void 0,
1195
+ done: true
1196
+ };
1197
+ }
1198
+ }
1199
+ /**
1200
+ * Represents a mock http service that can be useful for demos,
1201
+ * testing, and pre-api implementations.
1202
+ */ var ZHttpServiceMock = /*#__PURE__*/ function() {
1203
+ function ZHttpServiceMock() {
1204
+ _class_call_check$1(this, ZHttpServiceMock);
1205
+ _define_property(this, "_mapping", {});
1206
+ }
1207
+ _create_class$1(ZHttpServiceMock, [
1208
+ {
1209
+ key: "set",
1210
+ value: /**
937
1211
  * Sets the result of a given endpoint.
938
1212
  *
939
1213
  * @param endpoint -
@@ -942,12 +1216,16 @@ class ZHttpServiceMock {
942
1216
  * The endpoint verb to respond to.
943
1217
  * @param invoke -
944
1218
  * The result method. If this is falsy, then the endpoint is removed.
945
- */
946
- set(endpoint, verb, invoke) {
947
- this._mapping[endpoint] = this._mapping[endpoint] || {};
948
- this._mapping[endpoint][verb] = typeof invoke === "function" ? invoke : () => invoke;
949
- }
950
- /**
1219
+ */ function set(endpoint, verb, invoke) {
1220
+ this._mapping[endpoint] = this._mapping[endpoint] || {};
1221
+ this._mapping[endpoint][verb] = typeof invoke === "function" ? invoke : function() {
1222
+ return invoke;
1223
+ };
1224
+ }
1225
+ },
1226
+ {
1227
+ key: "request",
1228
+ value: /**
951
1229
  * Invokes the request given the allowed api implementations.
952
1230
  *
953
1231
  * @param req -
@@ -956,94 +1234,307 @@ class ZHttpServiceMock {
956
1234
  * @returns
957
1235
  * A promise that resolves with the given result if the status code is less than 400.
958
1236
  * Any status code above 400 will result in a rejected promise.
959
- */
960
- async request(req) {
961
- const endpointConfig = this._mapping[req.url];
962
- const result = endpointConfig == null ? void 0 : endpointConfig[req.method];
963
- if (result == null) {
964
- const notFound = new ZHttpResultBuilder(null).status(ZHttpCodeClient.NotFound).build();
965
- return Promise.reject(notFound);
1237
+ */ function request(req) {
1238
+ return _async_to_generator$1(function() {
1239
+ var endpointConfig, result, notFound, errorThreshold, intermediate;
1240
+ return _ts_generator$1(this, function(_state) {
1241
+ switch(_state.label){
1242
+ case 0:
1243
+ endpointConfig = this._mapping[req.url];
1244
+ result = endpointConfig === null || endpointConfig === void 0 ? void 0 : endpointConfig[req.method];
1245
+ if (result == null) {
1246
+ notFound = new ZHttpResultBuilder(null).status(ZHttpCodeClient.NotFound).build();
1247
+ return [
1248
+ 2,
1249
+ Promise.reject(notFound)
1250
+ ];
1251
+ }
1252
+ errorThreshold = 400;
1253
+ return [
1254
+ 4,
1255
+ result(req)
1256
+ ];
1257
+ case 1:
1258
+ intermediate = _state.sent();
1259
+ return [
1260
+ 2,
1261
+ +intermediate.status < errorThreshold ? Promise.resolve(intermediate) : Promise.reject(intermediate)
1262
+ ];
1263
+ }
1264
+ });
1265
+ }).call(this);
1266
+ }
1267
+ }
1268
+ ]);
1269
+ return ZHttpServiceMock;
1270
+ }();
1271
+
1272
+ /**
1273
+ * A method that determines if an object conforms to a Request BodyInit shape.
1274
+ *
1275
+ * See the BodyInit interface for more information about the possible
1276
+ * shapes.
1277
+ *
1278
+ * @param obj -
1279
+ * The object to test.
1280
+ *
1281
+ * @returns
1282
+ * True if obj is a BodyInit shape, false otherwise.
1283
+ */ function _instanceof(left, right) {
1284
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
1285
+ return !!right[Symbol.hasInstance](left);
1286
+ } else {
1287
+ return left instanceof right;
966
1288
  }
967
- const errorThreshold = 400;
968
- const intermediate = await result(req);
969
- return +intermediate.status < errorThreshold ? Promise.resolve(intermediate) : Promise.reject(intermediate);
970
- }
971
1289
  }
972
1290
  function isBodyInit(obj) {
973
- return obj == null || typeof obj === "string" || obj instanceof Blob || obj instanceof ArrayBuffer || ArrayBuffer.isView(obj) || obj instanceof FormData || obj instanceof URLSearchParams || obj instanceof ReadableStream;
1291
+ return obj == null || typeof obj === "string" || _instanceof(obj, Blob) || _instanceof(obj, ArrayBuffer) || ArrayBuffer.isView(obj) || _instanceof(obj, FormData) || _instanceof(obj, URLSearchParams) || _instanceof(obj, ReadableStream);
974
1292
  }
975
- function toBodyInit(obj) {
976
- return isBodyInit(obj) ? obj : JSON.stringify(obj);
1293
+ /**
1294
+ * A helper method that converts an object to a BodyInit.
1295
+ *
1296
+ * If obj is not a BodyInit supported object, then it will
1297
+ * simply be converted to JSON.
1298
+ *
1299
+ * @param obj -
1300
+ * The object to convert.
1301
+ *
1302
+ * @returns
1303
+ * Obj as a body init serialization. If obj is not
1304
+ * compatible with a BodyInit shape, then it is converted
1305
+ * to JSON.
1306
+ */ function toBodyInit(obj) {
1307
+ return isBodyInit(obj) ? obj : JSON.stringify(obj);
977
1308
  }
978
- function fromContentType(res) {
979
- const contentType = res.headers.get("content-type");
980
- if ((contentType == null ? void 0 : contentType.startsWith("application/json")) || (contentType == null ? void 0 : contentType.endsWith("+json"))) {
981
- return res.json();
982
- }
983
- if (contentType == null ? void 0 : contentType.startsWith("multipart/form-data")) {
984
- return res.formData();
985
- }
986
- if ((contentType == null ? void 0 : contentType.startsWith("text")) || (contentType == null ? void 0 : contentType.endsWith("+xml"))) {
987
- return res.text();
988
- }
989
- return res.blob();
1309
+
1310
+ /**
1311
+ * A helper method that takes an HTTP Fetch Response and converts the body data based on its
1312
+ * content type.
1313
+ *
1314
+ * This will favor a blob as the default type.
1315
+ */ function fromContentType(res) {
1316
+ var contentType = res.headers.get("content-type");
1317
+ if ((contentType === null || contentType === void 0 ? void 0 : contentType.startsWith("application/json")) || (contentType === null || contentType === void 0 ? void 0 : contentType.endsWith("+json"))) {
1318
+ return res.json();
1319
+ }
1320
+ if (contentType === null || contentType === void 0 ? void 0 : contentType.startsWith("multipart/form-data")) {
1321
+ return res.formData();
1322
+ }
1323
+ if ((contentType === null || contentType === void 0 ? void 0 : contentType.startsWith("text")) || (contentType === null || contentType === void 0 ? void 0 : contentType.endsWith("+xml"))) {
1324
+ return res.text();
1325
+ }
1326
+ return res.blob();
990
1327
  }
991
- class ZHttpService {
992
- /**
1328
+
1329
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1330
+ try {
1331
+ var info = gen[key](arg);
1332
+ var value = info.value;
1333
+ } catch (error) {
1334
+ reject(error);
1335
+ return;
1336
+ }
1337
+ if (info.done) {
1338
+ resolve(value);
1339
+ } else {
1340
+ Promise.resolve(value).then(_next, _throw);
1341
+ }
1342
+ }
1343
+ function _async_to_generator(fn) {
1344
+ return function() {
1345
+ var self = this, args = arguments;
1346
+ return new Promise(function(resolve, reject) {
1347
+ var gen = fn.apply(self, args);
1348
+ function _next(value) {
1349
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1350
+ }
1351
+ function _throw(err) {
1352
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1353
+ }
1354
+ _next(undefined);
1355
+ });
1356
+ };
1357
+ }
1358
+ function _class_call_check(instance, Constructor) {
1359
+ if (!(instance instanceof Constructor)) {
1360
+ throw new TypeError("Cannot call a class as a function");
1361
+ }
1362
+ }
1363
+ function _defineProperties(target, props) {
1364
+ for(var i = 0; i < props.length; i++){
1365
+ var descriptor = props[i];
1366
+ descriptor.enumerable = descriptor.enumerable || false;
1367
+ descriptor.configurable = true;
1368
+ if ("value" in descriptor) descriptor.writable = true;
1369
+ Object.defineProperty(target, descriptor.key, descriptor);
1370
+ }
1371
+ }
1372
+ function _create_class(Constructor, protoProps, staticProps) {
1373
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
1374
+ return Constructor;
1375
+ }
1376
+ function _ts_generator(thisArg, body) {
1377
+ var f, y, t, _ = {
1378
+ label: 0,
1379
+ sent: function() {
1380
+ if (t[0] & 1) throw t[1];
1381
+ return t[1];
1382
+ },
1383
+ trys: [],
1384
+ ops: []
1385
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
1386
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
1387
+ return this;
1388
+ }), g;
1389
+ function verb(n) {
1390
+ return function(v) {
1391
+ return step([
1392
+ n,
1393
+ v
1394
+ ]);
1395
+ };
1396
+ }
1397
+ function step(op) {
1398
+ if (f) throw new TypeError("Generator is already executing.");
1399
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
1400
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1401
+ if (y = 0, t) op = [
1402
+ op[0] & 2,
1403
+ t.value
1404
+ ];
1405
+ switch(op[0]){
1406
+ case 0:
1407
+ case 1:
1408
+ t = op;
1409
+ break;
1410
+ case 4:
1411
+ _.label++;
1412
+ return {
1413
+ value: op[1],
1414
+ done: false
1415
+ };
1416
+ case 5:
1417
+ _.label++;
1418
+ y = op[1];
1419
+ op = [
1420
+ 0
1421
+ ];
1422
+ continue;
1423
+ case 7:
1424
+ op = _.ops.pop();
1425
+ _.trys.pop();
1426
+ continue;
1427
+ default:
1428
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1429
+ _ = 0;
1430
+ continue;
1431
+ }
1432
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1433
+ _.label = op[1];
1434
+ break;
1435
+ }
1436
+ if (op[0] === 6 && _.label < t[1]) {
1437
+ _.label = t[1];
1438
+ t = op;
1439
+ break;
1440
+ }
1441
+ if (t && _.label < t[2]) {
1442
+ _.label = t[2];
1443
+ _.ops.push(op);
1444
+ break;
1445
+ }
1446
+ if (t[2]) _.ops.pop();
1447
+ _.trys.pop();
1448
+ continue;
1449
+ }
1450
+ op = body.call(thisArg, _);
1451
+ } catch (e) {
1452
+ op = [
1453
+ 6,
1454
+ e
1455
+ ];
1456
+ y = 0;
1457
+ } finally{
1458
+ f = t = 0;
1459
+ }
1460
+ if (op[0] & 5) throw op[1];
1461
+ return {
1462
+ value: op[0] ? op[1] : void 0,
1463
+ done: true
1464
+ };
1465
+ }
1466
+ }
1467
+ /**
1468
+ * Represents an axios based implementation of the http service.
1469
+ */ var ZHttpService = /*#__PURE__*/ function() {
1470
+ function ZHttpService() {
1471
+ _class_call_check(this, ZHttpService);
1472
+ }
1473
+ _create_class(ZHttpService, [
1474
+ {
1475
+ key: "request",
1476
+ value: /**
993
1477
  * Invokes the request with a real http service.
994
1478
  *
995
1479
  * @param req -
996
1480
  * The request information to make.
997
- */
998
- async request(req) {
999
- try {
1000
- const res = await fetch(req.url, {
1001
- method: req.method,
1002
- body: isBodyInit(req.body) ? req.body : JSON.stringify(req.body),
1003
- headers: req.headers,
1004
- redirect: "follow"
1005
- });
1006
- const data = await fromContentType(res);
1007
- const result = new ZHttpResultBuilder(data).headers(res.headers).status(res.status).build();
1008
- return res.ok ? Promise.resolve(result) : Promise.reject(result);
1009
- } catch (e) {
1010
- let result = new ZHttpResultBuilder(e.message).headers().status(ZHttpCodeServer.InternalServerError);
1011
- if (e.code === "ENOTFOUND") {
1012
- result = result.status(ZHttpCodeClient.NotFound);
1013
- }
1014
- return Promise.reject(result.build());
1015
- }
1016
- }
1017
- }
1018
- export {
1019
- ZHttpCodeCategory,
1020
- ZHttpCodeClient,
1021
- ZHttpCodeClientDescriptions,
1022
- ZHttpCodeClientNames,
1023
- ZHttpCodeInformationalResponse,
1024
- ZHttpCodeInformationalResponseDescriptions,
1025
- ZHttpCodeInformationalResponseNames,
1026
- ZHttpCodeRedirection,
1027
- ZHttpCodeRedirectionDescriptions,
1028
- ZHttpCodeRedirectionNames,
1029
- ZHttpCodeServer,
1030
- ZHttpCodeServerDescriptions,
1031
- ZHttpCodeServerNames,
1032
- ZHttpCodeSeverity,
1033
- ZHttpCodeSuccess,
1034
- ZHttpCodeSuccessDescriptions,
1035
- ZHttpCodeSuccessNames,
1036
- ZHttpMethod,
1037
- ZHttpRequestBuilder,
1038
- ZHttpResultBuilder,
1039
- ZHttpService,
1040
- ZHttpServiceMock,
1041
- fromContentType,
1042
- getHttpCodeCategory,
1043
- getHttpCodeDescription,
1044
- getHttpCodeName,
1045
- getHttpCodeSeverity,
1046
- isBodyInit,
1047
- toBodyInit
1048
- };
1481
+ */ function request(req) {
1482
+ return _async_to_generator(function() {
1483
+ var res, data, result, e, result1;
1484
+ return _ts_generator(this, function(_state) {
1485
+ switch(_state.label){
1486
+ case 0:
1487
+ _state.trys.push([
1488
+ 0,
1489
+ 3,
1490
+ ,
1491
+ 4
1492
+ ]);
1493
+ return [
1494
+ 4,
1495
+ fetch(req.url, {
1496
+ method: req.method,
1497
+ body: isBodyInit(req.body) ? req.body : JSON.stringify(req.body),
1498
+ headers: req.headers,
1499
+ redirect: "follow"
1500
+ })
1501
+ ];
1502
+ case 1:
1503
+ res = _state.sent();
1504
+ return [
1505
+ 4,
1506
+ fromContentType(res)
1507
+ ];
1508
+ case 2:
1509
+ data = _state.sent();
1510
+ result = new ZHttpResultBuilder(data).headers(res.headers).status(res.status).build();
1511
+ return [
1512
+ 2,
1513
+ res.ok ? Promise.resolve(result) : Promise.reject(result)
1514
+ ];
1515
+ case 3:
1516
+ e = _state.sent();
1517
+ result1 = new ZHttpResultBuilder(e.message).headers().status(ZHttpCodeServer.InternalServerError);
1518
+ if (e.code === "ENOTFOUND") {
1519
+ // The request was made, but some DNS lookup failed.
1520
+ result1 = result1.status(ZHttpCodeClient.NotFound);
1521
+ }
1522
+ return [
1523
+ 2,
1524
+ Promise.reject(result1.build())
1525
+ ];
1526
+ case 4:
1527
+ return [
1528
+ 2
1529
+ ];
1530
+ }
1531
+ });
1532
+ })();
1533
+ }
1534
+ }
1535
+ ]);
1536
+ return ZHttpService;
1537
+ }();
1538
+
1539
+ export { ZHttpCodeCategory, ZHttpCodeClient, ZHttpCodeClientDescriptions, ZHttpCodeClientNames, ZHttpCodeInformationalResponse, ZHttpCodeInformationalResponseDescriptions, ZHttpCodeInformationalResponseNames, ZHttpCodeRedirection, ZHttpCodeRedirectionDescriptions, ZHttpCodeRedirectionNames, ZHttpCodeServer, ZHttpCodeServerDescriptions, ZHttpCodeServerNames, ZHttpCodeSeverity, ZHttpCodeSuccess, ZHttpCodeSuccessDescriptions, ZHttpCodeSuccessNames, ZHttpMethod, ZHttpRequestBuilder, ZHttpResultBuilder, ZHttpService, ZHttpServiceMock, fromContentType, getHttpCodeCategory, getHttpCodeDescription, getHttpCodeName, getHttpCodeSeverity, isBodyInit, toBodyInit };
1049
1540
  //# sourceMappingURL=index.js.map