@zthun/webigail-http 4.0.1 → 4.0.3

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