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