@zthun/webigail-http 4.0.8 → 5.0.0

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
@@ -5,26 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
  const webigailUrl = require('@zthun/webigail-url');
6
6
  const fetch = require('cross-fetch');
7
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) {
8
+ function _define_property$2(obj, key, value) {
28
9
  if (key in obj) {
29
10
  Object.defineProperty(obj, key, {
30
11
  value: value,
@@ -37,40 +18,6 @@ function _define_property$7(obj, key, value) {
37
18
  }
38
19
  return obj;
39
20
  }
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
21
  /**
75
22
  * Represents an available method for an http invocation.
76
23
  */ var ZHttpMethod = /*#__PURE__*/ function(ZHttpMethod) {
@@ -116,25 +63,26 @@ function _object_spread_props(target, source) {
116
63
  }({});
117
64
  /**
118
65
  * 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.
66
+ */ class ZHttpRequestBuilder {
67
+ /**
68
+ * Duplicates a request, keeping it's structure intact.
69
+ *
70
+ * The underlying headers will be duplicated, but everything
71
+ * else will be a shallow copy to preserve the body in the
72
+ * case that it is a blob or other binary structure.
73
+ *
74
+ * @param other -
75
+ * The request to duplicate.
125
76
  *
126
77
  * @returns
127
- * This object.
128
- */ _define_property$7(this, "json", this.content.bind(this, webigailUrl.ZMimeTypeApplication.JSON));
129
- this._request = {
130
- method: "GET",
131
- url: ""
78
+ * The duplicated object.
79
+ */ static duplicate(other) {
80
+ return {
81
+ ...other,
82
+ headers: structuredClone(other.headers)
132
83
  };
133
84
  }
134
- _create_class$3(ZHttpRequestBuilder, [
135
- {
136
- key: "_method",
137
- value: /**
85
+ /**
138
86
  * Sets the method.
139
87
  *
140
88
  * @param method -
@@ -144,95 +92,71 @@ function _object_spread_props(target, source) {
144
92
  *
145
93
  * @returns
146
94
  * This object.
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: /**
95
+ */ _method(method, body) {
96
+ this._request.method = method;
97
+ this._request.body = body;
98
+ if (this._request.body === undefined) {
99
+ delete this._request.body;
100
+ }
101
+ return this;
102
+ }
103
+ /**
159
104
  * Constructs a get request.
160
105
  *
161
106
  * @returns
162
107
  * This object.
163
- */ function get() {
164
- return this._method("GET");
165
- }
166
- },
167
- {
168
- key: "post",
169
- value: /**
108
+ */ get() {
109
+ return this._method("GET");
110
+ }
111
+ /**
170
112
  * Constructs a post request.
171
113
  *
172
114
  * @returns
173
115
  * This object.
174
- */ function post(body) {
175
- return this._method("POST", body).json();
176
- }
177
- },
178
- {
179
- key: "put",
180
- value: /**
116
+ */ post(body) {
117
+ return this._method("POST", body).json();
118
+ }
119
+ /**
181
120
  * Constructs a put request.
182
121
  *
183
122
  * @returns
184
123
  * This object.
185
- */ function put(body) {
186
- return this._method("PUT", body).json();
187
- }
188
- },
189
- {
190
- key: "delete",
191
- value: /**
124
+ */ put(body) {
125
+ return this._method("PUT", body).json();
126
+ }
127
+ /**
192
128
  * Constructs a delete request.
193
129
  *
194
130
  * @returns
195
131
  * This object.
196
- */ function _delete() {
197
- return this._method("DELETE");
198
- }
199
- },
200
- {
201
- key: "patch",
202
- value: /**
132
+ */ delete() {
133
+ return this._method("DELETE");
134
+ }
135
+ /**
203
136
  * Constructs a patch request.
204
137
  *
205
138
  * @returns
206
139
  * This object.
207
- */ function patch(body) {
208
- return this._method("PATCH", body).json();
209
- }
210
- },
211
- {
212
- key: "options",
213
- value: /**
140
+ */ patch(body) {
141
+ return this._method("PATCH", body).json();
142
+ }
143
+ /**
214
144
  * Constructs a options request.
215
145
  *
216
146
  * @returns
217
147
  * This object.
218
- */ function options() {
219
- return this._method("OPTIONS");
220
- }
221
- },
222
- {
223
- key: "head",
224
- value: /**
148
+ */ options() {
149
+ return this._method("OPTIONS");
150
+ }
151
+ /**
225
152
  * Constructs a head request.
226
153
  *
227
154
  * @returns
228
155
  * This object.
229
- */ function head() {
230
- return this._method("HEAD");
231
- }
232
- },
233
- {
234
- key: "url",
235
- value: /**
156
+ */ head() {
157
+ return this._method("HEAD");
158
+ }
159
+ /**
236
160
  * Sets the url to make the request from.
237
161
  *
238
162
  * @param url -
@@ -240,14 +164,11 @@ function _object_spread_props(target, source) {
240
164
  *
241
165
  * @returns
242
166
  * This object.
243
- */ function url(url) {
244
- this._request.url = url;
245
- return this;
246
- }
247
- },
248
- {
249
- key: "timeout",
250
- value: /**
167
+ */ url(url) {
168
+ this._request.url = url;
169
+ return this;
170
+ }
171
+ /**
251
172
  * Sets the timeout for the url.
252
173
  *
253
174
  * @param ms -
@@ -255,14 +176,11 @@ function _object_spread_props(target, source) {
255
176
  *
256
177
  * @returns
257
178
  * The object.
258
- */ function timeout(ms) {
259
- this._request.timeout = ms;
260
- return this;
261
- }
262
- },
263
- {
264
- key: "headers",
265
- value: /**
179
+ */ timeout(ms) {
180
+ this._request.timeout = ms;
181
+ return this;
182
+ }
183
+ /**
266
184
  * Sets the headers.
267
185
  *
268
186
  * @param headers -
@@ -270,14 +188,11 @@ function _object_spread_props(target, source) {
270
188
  *
271
189
  * @returns
272
190
  * This object.
273
- */ function headers(headers) {
274
- this._request.headers = headers;
275
- return this;
276
- }
277
- },
278
- {
279
- key: "header",
280
- value: /**
191
+ */ headers(headers) {
192
+ this._request.headers = headers;
193
+ return this;
194
+ }
195
+ /**
281
196
  * Sets an individual header.
282
197
  *
283
198
  * @param key -
@@ -287,19 +202,16 @@ function _object_spread_props(target, source) {
287
202
  *
288
203
  * @returns
289
204
  * This object.
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: /**
205
+ */ header(key, value) {
206
+ this._request.headers = this._request.headers || {};
207
+ if (value == null) {
208
+ delete this._request.headers[key];
209
+ } else {
210
+ this._request.headers[key] = `${value}`;
211
+ }
212
+ return this;
213
+ }
214
+ /**
303
215
  * Sets the content type header.
304
216
  *
305
217
  * @param type -
@@ -307,13 +219,10 @@ function _object_spread_props(target, source) {
307
219
  *
308
220
  * @returns
309
221
  * This object.
310
- */ function content(type) {
311
- return this.header("Content-Type", type);
312
- }
313
- },
314
- {
315
- key: "copy",
316
- value: /**
222
+ */ content(type) {
223
+ return this.header("Content-Type", type);
224
+ }
225
+ /**
317
226
  * Copies other to this object.
318
227
  *
319
228
  * @param other -
@@ -321,46 +230,34 @@ function _object_spread_props(target, source) {
321
230
  *
322
231
  * @returns
323
232
  * This object.
324
- */ function copy(other) {
325
- this._request = ZHttpRequestBuilder.duplicate(other);
326
- return this;
327
- }
328
- },
329
- {
330
- key: "build",
331
- value: /**
233
+ */ copy(other) {
234
+ this._request = ZHttpRequestBuilder.duplicate(other);
235
+ return this;
236
+ }
237
+ /**
332
238
  * Returns the constructed request.
333
239
  *
334
240
  * @returns
335
241
  * The constructed request.
336
- */ function build() {
337
- return ZHttpRequestBuilder.duplicate(this._request);
338
- }
339
- }
340
- ], [
341
- {
342
- key: "duplicate",
343
- value: /**
344
- * Duplicates a request, keeping it's structure intact.
345
- *
346
- * The underlying headers will be duplicated, but everything
347
- * else will be a shallow copy to preserve the body in the
348
- * case that it is a blob or other binary structure.
349
- *
350
- * @param other -
351
- * The request to duplicate.
242
+ */ build() {
243
+ return ZHttpRequestBuilder.duplicate(this._request);
244
+ }
245
+ /**
246
+ * Initializes a new instance of this object.
247
+ */ constructor(){
248
+ _define_property$2(this, "_request", void 0);
249
+ /**
250
+ * Sets the content type to json.
352
251
  *
353
252
  * @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
- }();
253
+ * This object.
254
+ */ _define_property$2(this, "json", this.content.bind(this, webigailUrl.ZMimeTypeApplication.JSON));
255
+ this._request = {
256
+ method: "GET",
257
+ url: ""
258
+ };
259
+ }
260
+ }
364
261
 
365
262
  /**
366
263
  * This class of status code is intended for situations in which the error seems to have been caused by the client.
@@ -368,20 +265,7 @@ function _object_spread_props(target, source) {
368
265
  * Except when responding to a HEAD request, the server should include an entity containing an explanation
369
266
  * of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable
370
267
  * 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) {
268
+ */ var ZHttpCodeClient = /*#__PURE__*/ function(ZHttpCodeClient) {
385
269
  /**
386
270
  * The server cannot or will not process the request due to an apparent client error
387
271
  * (e.g., malformed request syntax, size too large, invalid request message framing,
@@ -524,14 +408,70 @@ var ZHttpCodeClient = /*#__PURE__*/ function(ZHttpCodeClient) {
524
408
  */ ZHttpCodeClient[ZHttpCodeClient["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
525
409
  return ZHttpCodeClient;
526
410
  }({});
527
- var _obj$4;
528
411
  /**
529
412
  * 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;
413
+ */ const ZHttpCodeClientNames = {
414
+ [400]: "Bad Request",
415
+ [401]: "Unauthorized",
416
+ [402]: "Payment Required",
417
+ [403]: "Forbidden",
418
+ [404]: "Not Found",
419
+ [405]: "Method not Allowed",
420
+ [406]: "Not Acceptable",
421
+ [407]: "Proxy Authentication Required",
422
+ [408]: "Request Timeout",
423
+ [409]: "Conflict",
424
+ [410]: "Gone",
425
+ [411]: "Length Required",
426
+ [412]: "Precondition Failed",
427
+ [413]: "Payload Too Large",
428
+ [414]: "URI Too Long",
429
+ [415]: "Unsupported Media Type",
430
+ [416]: "Range Not Satisfiable",
431
+ [417]: "Expectation Failed",
432
+ [418]: "I am a Teapot",
433
+ [421]: "Misdirected Requested",
434
+ [422]: "Entity Not Processable",
435
+ [423]: "Locked",
436
+ [424]: "Failed Dependency",
437
+ [426]: "Upgrade Required",
438
+ [428]: "Precondition Required",
439
+ [429]: "Too Many Requests",
440
+ [431]: "Request Header Fields Too Large",
441
+ [451]: "Unavailable for Legal Reasons"
442
+ };
532
443
  /**
533
444
  * 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);
445
+ */ const ZHttpCodeClientDescriptions = {
446
+ [400]: "A bad request was sent.",
447
+ [401]: "You are not authenticated and cannot view this content.",
448
+ [402]: "Payment is required",
449
+ [403]: "You are not authorized to view this content.",
450
+ [404]: "The resource you are looking for could not be found.",
451
+ [405]: "The requested operation was not allowed.",
452
+ [406]: "The requested resource is not capable of generating the content for you.",
453
+ [407]: "You must first authenticate your self with the proxy.",
454
+ [408]: "The server timed out waiting for a request. Please try again.",
455
+ [409]: "There was a conflict with request. Try something else.",
456
+ [410]: "The resource you requested is no longer available.",
457
+ [411]: "Your request did not specify the length of its content, which is required by the requested resource.",
458
+ [412]: "The server did not meet the requirements that was required to meet the request.",
459
+ [413]: "The request is too large and the server cannot handle it.",
460
+ [414]: "The URI provided was too long for the server to process.",
461
+ [415]: "The media type requested is not supported by the server.",
462
+ [416]: "A portion of the file was requested by the server cannot supply said portion.",
463
+ [417]: "The server cannot meet the requirements of the expectation made of it.",
464
+ [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!",
465
+ [421]: "The request was directed at the server, but the server cannot produce a response.",
466
+ [422]: "The request was well-formed but was unable to be followed due to semantic errors.",
467
+ [423]: "The resource that is being accessed is locked.",
468
+ [424]: "The request failed because it depended on another request and that request failed.",
469
+ [426]: "The client needs to switch to a different protocol.",
470
+ [428]: "The origin server requires the request to be conditional.",
471
+ [429]: "The user has sent too many requests in a given amount of time.",
472
+ [431]: "The request cannot be processed because the collective header fields are too large.",
473
+ [451]: "Call your lawyer!"
474
+ };
535
475
 
536
476
  /**
537
477
  * An informational response indicates that the request was received and understood.
@@ -541,20 +481,7 @@ var _obj1$4;
541
481
  * optional header fields, and is terminated by an empty line. As the HTTP/1.0 standard
542
482
  * did not define any 1xx status codes, servers must not[note 1] send a 1xx response to
543
483
  * 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) {
484
+ */ var ZHttpCodeInformationalResponse = /*#__PURE__*/ function(ZHttpCodeInformationalResponse) {
558
485
  /**
559
486
  * The server has received the request headers and the client should proceed to send the
560
487
  * request body (in the case of a request for which a body needs to be sent; for example, a
@@ -581,14 +508,22 @@ var ZHttpCodeInformationalResponse = /*#__PURE__*/ function(ZHttpCodeInformation
581
508
  */ ZHttpCodeInformationalResponse[ZHttpCodeInformationalResponse["EarlyHints"] = 103] = "EarlyHints";
582
509
  return ZHttpCodeInformationalResponse;
583
510
  }({});
584
- var _obj$3;
585
511
  /**
586
512
  * 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;
513
+ */ const ZHttpCodeInformationalResponseNames = {
514
+ [100]: "Continue",
515
+ [101]: "Switching Protocols",
516
+ [102]: "Processing",
517
+ [103]: "Early Hints"
518
+ };
589
519
  /**
590
520
  * 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);
521
+ */ const ZHttpCodeInformationalResponseDescriptions = {
522
+ [100]: "The client should continue to send the request body.",
523
+ [101]: "The requestor has asked the server to switch protocols and the server has agreed to do so.",
524
+ [102]: "The server has received and is processing the request, but a response is not available yet.",
525
+ [103]: "There are some early response headers available for you before the final message."
526
+ };
592
527
 
593
528
  /**
594
529
  * This class of status code indicates the client must take additional action to complete the request.
@@ -597,20 +532,7 @@ var _obj1$3;
597
532
  * action with no user interaction only if the method used in the second request is GET or HEAD.
598
533
  * A user agent may automatically redirect a request. A user agent should detect and intervene
599
534
  * 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) {
535
+ */ var ZHttpCodeRedirection = /*#__PURE__*/ function(ZHttpCodeRedirection) {
614
536
  /**
615
537
  * Indicates multiple options for the resource from which the client may choose
616
538
  * (via agent-driven content negotiation).
@@ -666,14 +588,32 @@ var ZHttpCodeRedirection = /*#__PURE__*/ function(ZHttpCodeRedirection) {
666
588
  */ ZHttpCodeRedirection[ZHttpCodeRedirection["PermanentRedirect"] = 308] = "PermanentRedirect";
667
589
  return ZHttpCodeRedirection;
668
590
  }({});
669
- var _obj$2;
670
591
  /**
671
592
  * 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;
593
+ */ const ZHttpCodeRedirectionNames = {
594
+ [300]: "Multiple Choices",
595
+ [301]: "Moved Permanently",
596
+ [302]: "Found",
597
+ [303]: "See Other",
598
+ [304]: "Not Modified",
599
+ [305]: "Use Proxy",
600
+ [306]: "Switch Proxy",
601
+ [307]: "Temporary Redirect",
602
+ [308]: "Permanent Redirect"
603
+ };
674
604
  /**
675
605
  * 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);
606
+ */ const ZHttpCodeRedirectionDescriptions = {
607
+ [300]: "Indicates multiple options for the resource from which the client may choose.",
608
+ [301]: "This and all future requests should be directed to the given URI.",
609
+ [302]: "Tells the client to look at another url",
610
+ [303]: "The response to the request can be found under another URI using the GET method.",
611
+ [304]: "Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.",
612
+ [305]: "The requested resource is available only through a proxy, the address for which is provided in the response.",
613
+ [306]: 'No longer used. Originally meant "Subsequent requests should use the specified proxy.',
614
+ [307]: "In this case, the request should be repeated with another URI; however, future requests should still use the original URI.",
615
+ [308]: "The request and all future requests should be repeated using another URI."
616
+ };
677
617
 
678
618
  /**
679
619
  * The server failed to fulfil a request.
@@ -686,20 +626,7 @@ var _obj1$2;
686
626
  * is a temporary or permanent condition. Likewise, user agents should
687
627
  * display any included entity to the user. These response codes are applicable
688
628
  * 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) {
629
+ */ var ZHttpCodeServer = /*#__PURE__*/ function(ZHttpCodeServer) {
703
630
  /**
704
631
  * A generic error message, given when an unexpected condition was encountered
705
632
  * and no more specific message is suitable.
@@ -742,32 +669,41 @@ var ZHttpCodeServer = /*#__PURE__*/ function(ZHttpCodeServer) {
742
669
  */ ZHttpCodeServer[ZHttpCodeServer["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
743
670
  return ZHttpCodeServer;
744
671
  }({});
745
- var _obj$1;
746
672
  /**
747
673
  * 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;
674
+ */ const ZHttpCodeServerNames = {
675
+ [500]: "Internal Server Error",
676
+ [501]: "Not Implemented",
677
+ [502]: "Bad Gateway",
678
+ [503]: "Service Unavailable",
679
+ [504]: "Gateway Timeout",
680
+ [505]: "HTTP Version Not Supported",
681
+ [506]: "Variant Also Negotiates",
682
+ [507]: "Insufficient Storage",
683
+ [508]: "Loop Detected",
684
+ [510]: "Not Extended",
685
+ [511]: "Network Authentication Required"
686
+ };
750
687
  /**
751
688
  * 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);
689
+ */ const ZHttpCodeServerDescriptions = {
690
+ [500]: "An unexpected condition was encountered on the server.",
691
+ [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).",
692
+ [502]: " The server was acting as a gateway or proxy and received an invalid response from the upstream server.",
693
+ [503]: "The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.",
694
+ [504]: "The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.",
695
+ [505]: "The server does not support the HTTP protocol version used in the request.",
696
+ [506]: " Transparent content negotiation for the request results in a circular reference.",
697
+ [507]: "The server is unable to store the representation needed to complete the request.",
698
+ [508]: "The server detected an infinite loop while processing the request.",
699
+ [510]: "Further extensions to the request are required for the server to fulfil it.",
700
+ [511]: "The client needs to authenticate to gain network access."
701
+ };
753
702
 
754
703
  /**
755
704
  * This class of status codes indicates the action requested by
756
705
  * 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) {
706
+ */ var ZHttpCodeSuccess = /*#__PURE__*/ function(ZHttpCodeSuccess) {
771
707
  /**
772
708
  * Standard response for successful HTTP requests.
773
709
  *
@@ -817,14 +753,34 @@ var ZHttpCodeSuccess = /*#__PURE__*/ function(ZHttpCodeSuccess) {
817
753
  */ ZHttpCodeSuccess[ZHttpCodeSuccess["IMUsed"] = 226] = "IMUsed";
818
754
  return ZHttpCodeSuccess;
819
755
  }({});
820
- var _obj;
821
756
  /**
822
757
  * 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;
758
+ */ const ZHttpCodeSuccessNames = {
759
+ [200]: "OK",
760
+ [201]: "Created",
761
+ [202]: "Accepted",
762
+ [203]: "Non-Authoritative Information",
763
+ [204]: "No Content",
764
+ [205]: "Reset Content",
765
+ [206]: "Partial Content",
766
+ [207]: "Multi Status",
767
+ [208]: "Already Reported",
768
+ [226]: "IM Used"
769
+ };
825
770
  /**
826
771
  * 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);
772
+ */ const ZHttpCodeSuccessDescriptions = {
773
+ [200]: "The request was successful.",
774
+ [201]: "The request has been fulfilled, resulting in the creation of a new resource.",
775
+ [202]: "The request has been accepted for processing, but the processing has not been completed.",
776
+ [203]: "The server is a transforming proxy that received an OK from its origin,but is returning a modified version of the response.",
777
+ [204]: "The server successfully processed the request and is not returning any content.",
778
+ [205]: "The server successfully processed the request, but is not returning any content. The document view must be refreshed.",
779
+ [206]: "he server is delivering only part of the resource due to a range header sent by the client.",
780
+ [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.",
781
+ [208]: "The members of a DAV binding have already been enumerated in a preceding part of the response, and are not being included again.",
782
+ [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."
783
+ };
828
784
 
829
785
  /**
830
786
  * Represents the category name for an http code.
@@ -929,24 +885,6 @@ var _obj1;
929
885
  return "Server Error";
930
886
  }
931
887
 
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
888
  function _define_property$1(obj, key, value) {
951
889
  if (key in obj) {
952
890
  Object.defineProperty(obj, key, {
@@ -960,37 +898,10 @@ function _define_property$1(obj, key, value) {
960
898
  }
961
899
  return obj;
962
900
  }
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
901
  /**
979
902
  * 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: /**
903
+ */ class ZHttpResultBuilder {
904
+ /**
994
905
  * Sets the data.
995
906
  *
996
907
  * @param data -
@@ -998,14 +909,11 @@ function _object_spread(target) {
998
909
  *
999
910
  * @returns
1000
911
  * This object.
1001
- */ function data(data) {
1002
- this._result.data = data;
1003
- return this;
1004
- }
1005
- },
1006
- {
1007
- key: "status",
1008
- value: /**
912
+ */ data(data) {
913
+ this._result.data = data;
914
+ return this;
915
+ }
916
+ /**
1009
917
  * Sets the status code and the english description.
1010
918
  *
1011
919
  * @param code -
@@ -1013,14 +921,11 @@ function _object_spread(target) {
1013
921
  *
1014
922
  * @returns
1015
923
  * This object.
1016
- */ function status(code) {
1017
- this._result.status = code;
1018
- return this;
1019
- }
1020
- },
1021
- {
1022
- key: "headers",
1023
- value: /**
924
+ */ status(code) {
925
+ this._result.status = code;
926
+ return this;
927
+ }
928
+ /**
1024
929
  * Sets the return headers.
1025
930
  *
1026
931
  * @param headers -
@@ -1028,74 +933,35 @@ function _object_spread(target) {
1028
933
  *
1029
934
  * @returns
1030
935
  * This object.
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: /**
936
+ */ headers(headers = {}) {
937
+ this._result.headers = headers;
938
+ return this;
939
+ }
940
+ /**
1040
941
  * Returns the built up result.
1041
942
  *
1042
943
  * @returns
1043
944
  * A shallow copy of the built up result.
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");
945
+ */ build() {
946
+ return {
947
+ ...this._result
948
+ };
1084
949
  }
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);
950
+ /**
951
+ * Initializes a new instance of this object.
952
+ *
953
+ * @param data -
954
+ * The data result.
955
+ */ constructor(data){
956
+ _define_property$1(this, "_result", void 0);
957
+ this._result = {
958
+ status: ZHttpCodeSuccess.OK,
959
+ headers: {},
960
+ data
961
+ };
1093
962
  }
1094
963
  }
1095
- function _create_class$1(Constructor, protoProps, staticProps) {
1096
- if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
1097
- return Constructor;
1098
- }
964
+
1099
965
  function _define_property(obj, key, value) {
1100
966
  if (key in obj) {
1101
967
  Object.defineProperty(obj, key, {
@@ -1109,109 +975,11 @@ function _define_property(obj, key, value) {
1109
975
  }
1110
976
  return obj;
1111
977
  }
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
978
  /**
1204
979
  * Represents a mock http service that can be useful for demos,
1205
980
  * 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: /**
981
+ */ class ZHttpServiceMock {
982
+ /**
1215
983
  * Sets the result of a given endpoint.
1216
984
  *
1217
985
  * @param endpoint -
@@ -1220,16 +988,11 @@ function _ts_generator$1(thisArg, body) {
1220
988
  * The endpoint verb to respond to.
1221
989
  * @param invoke -
1222
990
  * The result method. If this is falsy, then the endpoint is removed.
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: /**
991
+ */ set(endpoint, verb, invoke) {
992
+ this._mapping[endpoint] = this._mapping[endpoint] || {};
993
+ this._mapping[endpoint][verb] = typeof invoke === "function" ? invoke : ()=>invoke;
994
+ }
995
+ /**
1233
996
  * Invokes the request given the allowed api implementations.
1234
997
  *
1235
998
  * @param req -
@@ -1238,40 +1001,21 @@ function _ts_generator$1(thisArg, body) {
1238
1001
  * @returns
1239
1002
  * A promise that resolves with the given result if the status code is less than 400.
1240
1003
  * Any status code above 400 will result in a rejected promise.
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
- }
1004
+ */ async request(req) {
1005
+ const endpointConfig = this._mapping[req.url];
1006
+ const result = endpointConfig?.[req.method];
1007
+ if (result == null) {
1008
+ const notFound = new ZHttpResultBuilder(null).status(ZHttpCodeClient.NotFound).build();
1009
+ return Promise.reject(notFound);
1271
1010
  }
1272
- ]);
1273
- return ZHttpServiceMock;
1274
- }();
1011
+ const errorThreshold = 400;
1012
+ const intermediate = await result(req);
1013
+ return +intermediate.status < errorThreshold ? Promise.resolve(intermediate) : Promise.reject(intermediate);
1014
+ }
1015
+ constructor(){
1016
+ _define_property(this, "_mapping", {});
1017
+ }
1018
+ }
1275
1019
 
1276
1020
  /**
1277
1021
  * A method that determines if an object conforms to a Request BodyInit shape.
@@ -1284,15 +1028,8 @@ function _ts_generator$1(thisArg, body) {
1284
1028
  *
1285
1029
  * @returns
1286
1030
  * 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
- }
1293
- }
1294
- function isBodyInit(obj) {
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);
1031
+ */ function isBodyInit(obj) {
1032
+ return obj == null || typeof obj === "string" || obj instanceof Blob || obj instanceof ArrayBuffer || ArrayBuffer.isView(obj) || obj instanceof FormData || obj instanceof URLSearchParams || obj instanceof ReadableStream;
1296
1033
  }
1297
1034
  /**
1298
1035
  * A helper method that converts an object to a BodyInit.
@@ -1317,228 +1054,48 @@ function isBodyInit(obj) {
1317
1054
  *
1318
1055
  * This will favor a blob as the default type.
1319
1056
  */ 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"))) {
1057
+ const contentType = res.headers.get("content-type");
1058
+ if (contentType?.startsWith("application/json") || contentType?.endsWith("+json")) {
1322
1059
  return res.json();
1323
1060
  }
1324
- if (contentType === null || contentType === void 0 ? void 0 : contentType.startsWith("multipart/form-data")) {
1061
+ if (contentType?.startsWith("multipart/form-data")) {
1325
1062
  return res.formData();
1326
1063
  }
1327
- if ((contentType === null || contentType === void 0 ? void 0 : contentType.startsWith("text")) || (contentType === null || contentType === void 0 ? void 0 : contentType.endsWith("+xml"))) {
1064
+ if (contentType?.startsWith("text") || contentType?.endsWith("+xml")) {
1328
1065
  return res.text();
1329
1066
  }
1330
1067
  return res.blob();
1331
1068
  }
1332
1069
 
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
1070
  /**
1472
1071
  * 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: /**
1072
+ */ class ZHttpService {
1073
+ /**
1481
1074
  * Invokes the request with a real http service.
1482
1075
  *
1483
1076
  * @param req -
1484
1077
  * The request information to make.
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
- })();
1078
+ */ async request(req) {
1079
+ try {
1080
+ const res = await fetch(req.url, {
1081
+ method: req.method,
1082
+ body: isBodyInit(req.body) ? req.body : JSON.stringify(req.body),
1083
+ headers: req.headers,
1084
+ redirect: "follow"
1085
+ });
1086
+ const data = await fromContentType(res);
1087
+ const result = new ZHttpResultBuilder(data).headers(res.headers).status(res.status).build();
1088
+ return res.ok ? Promise.resolve(result) : Promise.reject(result);
1089
+ } catch (e) {
1090
+ let result = new ZHttpResultBuilder(e.message).headers().status(ZHttpCodeServer.InternalServerError);
1091
+ if (e.code === "ENOTFOUND") {
1092
+ // The request was made, but some DNS lookup failed.
1093
+ result = result.status(ZHttpCodeClient.NotFound);
1537
1094
  }
1095
+ return Promise.reject(result.build());
1538
1096
  }
1539
- ]);
1540
- return ZHttpService;
1541
- }();
1097
+ }
1098
+ }
1542
1099
 
1543
1100
  exports.ZHttpCodeCategory = ZHttpCodeCategory;
1544
1101
  exports.ZHttpCodeClient = ZHttpCodeClient;