@zthun/webigail-http 5.0.5 → 5.0.6

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