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