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