@little-nebulae/http 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +531 -38
  2. package/dist/index.js +214 -25
  3. package/package.json +22 -14
package/dist/index.d.ts CHANGED
@@ -1,15 +1,12 @@
1
- import { ValueOf } from "@little-nebulae/type-utils";
2
- //#region src/constants/headers.d.ts
3
- export declare const HTTP_HEADER_RECORD: {
1
+ import { ValueOf } from "type-fest";
2
+ export declare const HTTP_HEADER_ENUM: {
4
3
  readonly AUTHORIZATION: "authorization";
5
4
  readonly CONTENT_TYPE: "content-type";
6
5
  readonly COOKIE: "cookie";
7
6
  readonly RETRY_AFTER: "retry-after";
8
7
  };
9
- export type HttpHeader = ValueOf<typeof HTTP_HEADER_RECORD>;
10
- //#endregion
11
- //#region src/constants/request-methods.d.ts
12
- export declare const HTTP_REQUEST_METHOD_RECORD: {
8
+ export type HttpHeader = ValueOf<typeof HTTP_HEADER_ENUM>;
9
+ export declare const HTTP_REQUEST_METHOD_ENUM: {
13
10
  readonly GET: "GET";
14
11
  readonly POST: "POST";
15
12
  readonly DELETE: "DELETE";
@@ -20,9 +17,7 @@ export declare const HTTP_REQUEST_METHOD_RECORD: {
20
17
  readonly TRACE: "TRACE";
21
18
  readonly CONNECT: "CONNECT";
22
19
  };
23
- export type HttpRequestMethod = ValueOf<typeof HTTP_REQUEST_METHOD_RECORD>;
24
- //#endregion
25
- //#region src/constants/response-statuses/index.d.ts
20
+ export type HttpRequestMethod = ValueOf<typeof HTTP_REQUEST_METHOD_ENUM>;
26
21
  export declare const HTTP_RESPONSE_STATUS_RECORD: {
27
22
  readonly BAD_REQUEST: {
28
23
  readonly code: 400;
@@ -32,6 +27,10 @@ export declare const HTTP_RESPONSE_STATUS_RECORD: {
32
27
  readonly code: 401;
33
28
  readonly text: "Unauthorized";
34
29
  };
30
+ readonly PAYMENT_REQUIRED: {
31
+ readonly code: 402;
32
+ readonly text: "Payment Required";
33
+ };
35
34
  readonly FORBIDDEN: {
36
35
  readonly code: 403;
37
36
  readonly text: "Forbidden";
@@ -40,22 +39,114 @@ export declare const HTTP_RESPONSE_STATUS_RECORD: {
40
39
  readonly code: 404;
41
40
  readonly text: "Not Found";
42
41
  };
42
+ readonly METHOD_NOT_ALLOWED: {
43
+ readonly code: 405;
44
+ readonly text: "Method Not Allowed";
45
+ };
46
+ readonly NOT_ACCEPTABLE: {
47
+ readonly code: 406;
48
+ readonly text: "Not Acceptable";
49
+ };
50
+ readonly PROXY_AUTHENTICATION_REQUIRED: {
51
+ readonly code: 407;
52
+ readonly text: "Proxy Authentication Required";
53
+ };
54
+ readonly REQUEST_TIMEOUT: {
55
+ readonly code: 408;
56
+ readonly text: "Request Timeout";
57
+ };
43
58
  readonly CONFLICT: {
44
59
  readonly code: 409;
45
60
  readonly text: "Conflict";
46
61
  };
62
+ readonly GONE: {
63
+ readonly code: 410;
64
+ readonly text: "Gone";
65
+ };
66
+ readonly LENGTH_REQUIRED: {
67
+ readonly code: 411;
68
+ readonly text: "Length Required";
69
+ };
70
+ readonly PRECONDITION_FAILED: {
71
+ readonly code: 412;
72
+ readonly text: "Precondition Failed";
73
+ };
74
+ readonly CONTENT_TOO_LARGE: {
75
+ readonly code: 413;
76
+ readonly text: "Content Too Large";
77
+ };
78
+ readonly URI_TOO_LONG: {
79
+ readonly code: 414;
80
+ readonly text: "URI Too Long";
81
+ };
82
+ readonly UNSUPPORTED_MEDIA_TYPE: {
83
+ readonly code: 415;
84
+ readonly text: "Unsupported Media Type";
85
+ };
86
+ readonly RANGE_NOT_SATISFIABLE: {
87
+ readonly code: 416;
88
+ readonly text: "Range Not Satisfiable";
89
+ };
90
+ readonly EXPECTATION_FAILED: {
91
+ readonly code: 417;
92
+ readonly text: "Expectation Failed";
93
+ };
94
+ readonly IM_A_TEAPOT: {
95
+ readonly code: 418;
96
+ readonly text: "I'm a teapot";
97
+ };
98
+ readonly MISDIRECTED_REQUEST: {
99
+ readonly code: 421;
100
+ readonly text: "Misdirected Request";
101
+ };
47
102
  readonly UNPROCESSABLE_CONTENT: {
48
103
  readonly code: 422;
49
104
  readonly text: "Unprocessable Content";
50
105
  };
106
+ readonly LOCKED: {
107
+ readonly code: 423;
108
+ readonly text: "Locked";
109
+ };
110
+ readonly FAILED_DEPENDENCY: {
111
+ readonly code: 424;
112
+ readonly text: "Failed Dependency";
113
+ };
114
+ readonly TOO_EARLY: {
115
+ readonly code: 425;
116
+ readonly text: "Too Early";
117
+ };
118
+ readonly UPGRADE_REQUIRED: {
119
+ readonly code: 426;
120
+ readonly text: "Upgrade Required";
121
+ };
122
+ readonly PRECONDITION_REQUIRED: {
123
+ readonly code: 428;
124
+ readonly text: "Precondition Required";
125
+ };
51
126
  readonly TOO_MANY_REQUESTS: {
52
127
  readonly code: 429;
53
128
  readonly text: "Too Many Requests";
54
129
  };
130
+ readonly REQUEST_HEADER_FIELDS_TOO_LARGE: {
131
+ readonly code: 431;
132
+ readonly text: "Request Header Fields Too Large";
133
+ };
134
+ readonly UNAVAILABLE_FOR_LEGAL_REASONS: {
135
+ readonly code: 451;
136
+ readonly text: "Unavailable For Legal Reasons";
137
+ };
55
138
  readonly INTERNAL_SERVER_ERROR: {
56
139
  readonly code: 500;
57
140
  readonly text: "Internal Server Error";
58
141
  };
142
+ readonly NOT_IMPLEMENTED: {
143
+ readonly code: 501;
144
+ readonly text: "Not Implemented";
145
+ };
146
+ readonly BAD_GATEWAY: {
147
+ readonly code: 502;
148
+ readonly text: "Bad Gateway";
149
+ };
59
150
  readonly SERVICE_UNAVAILABLE: {
60
151
  readonly code: 503;
61
152
  readonly text: "Service Unavailable";
@@ -64,6 +155,70 @@ export declare const HTTP_RESPONSE_STATUS_RECORD: {
64
155
  readonly code: 504;
65
156
  readonly text: "Gateway Timeout";
66
157
  };
158
+ readonly HTTP_VERSION_NOT_SUPPORTED: {
159
+ readonly code: 505;
160
+ readonly text: "HTTP Version Not Supported";
161
+ };
162
+ readonly VARIANT_ALSO_NEGOTIATES: {
163
+ readonly code: 506;
164
+ readonly text: "Variant Also Negotiates";
165
+ };
166
+ readonly INSUFFICIENT_STORAGE: {
167
+ readonly code: 507;
168
+ readonly text: "Insufficient Storage";
169
+ };
170
+ readonly LOOP_DETECTED: {
171
+ readonly code: 508;
172
+ readonly text: "Loop Detected";
173
+ };
174
+ readonly NOT_EXTENDED: {
175
+ readonly code: 510;
176
+ readonly text: "Not Extended";
177
+ };
178
+ readonly NETWORK_AUTHENTICATION_REQUIRED: {
179
+ readonly code: 511;
180
+ readonly text: "Network Authentication Required";
181
+ };
182
+ readonly CONTINUE: {
183
+ readonly code: 100;
184
+ readonly text: "Continue";
185
+ };
186
+ readonly SWITCHING_PROTOCOLS: {
187
+ readonly code: 101;
188
+ readonly text: "Switching Protocols";
189
+ };
190
+ readonly EARLY_HINTS: {
191
+ readonly code: 103;
192
+ readonly text: "Early Hints";
193
+ };
194
+ readonly MULTIPLE_CHOICES: {
195
+ readonly code: 300;
196
+ readonly text: "Multiple Choices";
197
+ };
198
+ readonly MOVED_PERMANENTLY: {
199
+ readonly code: 301;
200
+ readonly text: "Moved Permanently";
201
+ };
202
+ readonly FOUND: {
203
+ readonly code: 302;
204
+ readonly text: "Found";
205
+ };
206
+ readonly SEE_OTHER: {
207
+ readonly code: 303;
208
+ readonly text: "See Other";
209
+ };
210
+ readonly NOT_MODIFIED: {
211
+ readonly code: 304;
212
+ readonly text: "Not Modified";
213
+ };
214
+ readonly TEMPORARY_REDIRECT: {
215
+ readonly code: 307;
216
+ readonly text: "Temporary Redirect";
217
+ };
218
+ readonly PERMANENT_REDIRECT: {
219
+ readonly code: 308;
220
+ readonly text: "Permanent Redirect";
221
+ };
67
222
  readonly OK: {
68
223
  readonly code: 200;
69
224
  readonly text: "OK";
@@ -72,17 +227,60 @@ export declare const HTTP_RESPONSE_STATUS_RECORD: {
72
227
  readonly code: 201;
73
228
  readonly text: "Created";
74
229
  };
230
+ readonly ACCEPTED: {
231
+ readonly code: 202;
232
+ readonly text: "Accepted";
233
+ };
234
+ readonly NON_AUTHORITATIVE_INFORMATION: {
235
+ readonly code: 203;
236
+ readonly text: "Non-Authoritative Information";
237
+ };
75
238
  readonly NO_CONTENT: {
76
239
  readonly code: 204;
77
240
  readonly text: "No Content";
78
241
  };
242
+ readonly RESET_CONTENT: {
243
+ readonly code: 205;
244
+ readonly text: "Reset Content";
245
+ };
246
+ readonly PARTIAL_CONTENT: {
247
+ readonly code: 206;
248
+ readonly text: "Partial Content";
249
+ };
250
+ readonly MULTI_STATUS: {
251
+ readonly code: 207;
252
+ readonly text: "Multi-Status";
253
+ };
254
+ readonly ALREADY_REPORTED: {
255
+ readonly code: 208;
256
+ readonly text: "Already Reported";
257
+ };
258
+ readonly IM_USED: {
259
+ readonly code: 226;
260
+ readonly text: "IM Used";
261
+ };
262
+ };
263
+ type HttpResponseStatus = ValueOf<typeof HTTP_RESPONSE_STATUS_RECORD>;
264
+ export type HttpResponseStatusCode = HttpResponseStatus["code"];
265
+ export type HttpResponseStatusText = HttpResponseStatus["text"];
266
+ export declare const HTTP_INFORMATIONAL_RESPONSE_STATUS_ENUM: {
267
+ readonly CONTINUE: {
268
+ readonly code: 100;
269
+ readonly text: "Continue";
270
+ };
271
+ readonly SWITCHING_PROTOCOLS: {
272
+ readonly code: 101;
273
+ readonly text: "Switching Protocols";
274
+ };
275
+ readonly EARLY_HINTS: {
276
+ readonly code: 103;
277
+ readonly text: "Early Hints";
278
+ };
79
279
  };
80
- export type HttpResponseStatusRecord = typeof HTTP_RESPONSE_STATUS_RECORD;
81
- export type HttpResponseStatusCode = ValueOf<HttpResponseStatusRecord>["code"];
82
- export type HttpResponseStatusText = ValueOf<HttpResponseStatusRecord>["text"];
83
- //#endregion
84
- //#region src/constants/response-statuses/success.d.ts
85
- export declare const HTTP_SUCCESSFUL_RESPONSE_STATUS_RECORD: {
280
+ type HttpInformationalResponseStatus = ValueOf<typeof HTTP_INFORMATIONAL_RESPONSE_STATUS_ENUM>;
281
+ export type HttpInformationalResponseStatusCode = HttpInformationalResponseStatus["code"];
282
+ export type HttpInformationalResponseStatusText = HttpInformationalResponseStatus["text"];
283
+ export declare const HTTP_SUCCESSFUL_RESPONSE_STATUS_ENUM: {
86
284
  readonly OK: {
87
285
  readonly code: 200;
88
286
  readonly text: "OK";
@@ -91,17 +289,76 @@ export declare const HTTP_SUCCESSFUL_RESPONSE_STATUS_RECORD: {
91
289
  readonly code: 201;
92
290
  readonly text: "Created";
93
291
  };
292
+ readonly ACCEPTED: {
293
+ readonly code: 202;
294
+ readonly text: "Accepted";
295
+ };
296
+ readonly NON_AUTHORITATIVE_INFORMATION: {
297
+ readonly code: 203;
298
+ readonly text: "Non-Authoritative Information";
299
+ };
94
300
  readonly NO_CONTENT: {
95
301
  readonly code: 204;
96
302
  readonly text: "No Content";
97
303
  };
304
+ readonly RESET_CONTENT: {
305
+ readonly code: 205;
306
+ readonly text: "Reset Content";
307
+ };
308
+ readonly PARTIAL_CONTENT: {
309
+ readonly code: 206;
310
+ readonly text: "Partial Content";
311
+ };
312
+ readonly MULTI_STATUS: {
313
+ readonly code: 207;
314
+ readonly text: "Multi-Status";
315
+ };
316
+ readonly ALREADY_REPORTED: {
317
+ readonly code: 208;
318
+ readonly text: "Already Reported";
319
+ };
320
+ readonly IM_USED: {
321
+ readonly code: 226;
322
+ readonly text: "IM Used";
323
+ };
98
324
  };
99
- export type HttpSuccessfulResponseStatusRecord = typeof HTTP_SUCCESSFUL_RESPONSE_STATUS_RECORD;
100
- export type HttpSuccessfulResponseStatusCode = ValueOf<HttpSuccessfulResponseStatusRecord>["code"];
101
- export type HttpSuccessfulResponseStatusText = ValueOf<HttpSuccessfulResponseStatusRecord>["text"];
102
- //#endregion
103
- //#region src/constants/response-statuses/error/index.d.ts
104
- export declare const HTTP_ERROR_RESPONSE_STATUS_RECORD: {
325
+ type HttpSuccessfulResponseStatus = ValueOf<typeof HTTP_SUCCESSFUL_RESPONSE_STATUS_ENUM>;
326
+ export type HttpSuccessfulResponseStatusCode = HttpSuccessfulResponseStatus["code"];
327
+ export type HttpSuccessfulResponseStatusText = HttpSuccessfulResponseStatus["text"];
328
+ export declare const HTTP_REDIRECTION_RESPONSE_STATUS_ENUM: {
329
+ readonly MULTIPLE_CHOICES: {
330
+ readonly code: 300;
331
+ readonly text: "Multiple Choices";
332
+ };
333
+ readonly MOVED_PERMANENTLY: {
334
+ readonly code: 301;
335
+ readonly text: "Moved Permanently";
336
+ };
337
+ readonly FOUND: {
338
+ readonly code: 302;
339
+ readonly text: "Found";
340
+ };
341
+ readonly SEE_OTHER: {
342
+ readonly code: 303;
343
+ readonly text: "See Other";
344
+ };
345
+ readonly NOT_MODIFIED: {
346
+ readonly code: 304;
347
+ readonly text: "Not Modified";
348
+ };
349
+ readonly TEMPORARY_REDIRECT: {
350
+ readonly code: 307;
351
+ readonly text: "Temporary Redirect";
352
+ };
353
+ readonly PERMANENT_REDIRECT: {
354
+ readonly code: 308;
355
+ readonly text: "Permanent Redirect";
356
+ };
357
+ };
358
+ type HttpRedirectionResponseStatus = ValueOf<typeof HTTP_REDIRECTION_RESPONSE_STATUS_ENUM>;
359
+ export type HttpRedirectionResponseStatusCode = HttpRedirectionResponseStatus["code"];
360
+ export type HttpRedirectionResponseStatusText = HttpRedirectionResponseStatus["text"];
361
+ export declare const HTTP_ERROR_RESPONSE_STATUS_ENUM: {
105
362
  readonly BAD_REQUEST: {
106
363
  readonly code: 400;
107
364
  readonly text: "Bad Request";
@@ -110,6 +367,10 @@ export declare const HTTP_ERROR_RESPONSE_STATUS_RECORD: {
110
367
  readonly code: 401;
111
368
  readonly text: "Unauthorized";
112
369
  };
370
+ readonly PAYMENT_REQUIRED: {
371
+ readonly code: 402;
372
+ readonly text: "Payment Required";
373
+ };
113
374
  readonly FORBIDDEN: {
114
375
  readonly code: 403;
115
376
  readonly text: "Forbidden";
@@ -118,22 +379,114 @@ export declare const HTTP_ERROR_RESPONSE_STATUS_RECORD: {
118
379
  readonly code: 404;
119
380
  readonly text: "Not Found";
120
381
  };
382
+ readonly METHOD_NOT_ALLOWED: {
383
+ readonly code: 405;
384
+ readonly text: "Method Not Allowed";
385
+ };
386
+ readonly NOT_ACCEPTABLE: {
387
+ readonly code: 406;
388
+ readonly text: "Not Acceptable";
389
+ };
390
+ readonly PROXY_AUTHENTICATION_REQUIRED: {
391
+ readonly code: 407;
392
+ readonly text: "Proxy Authentication Required";
393
+ };
394
+ readonly REQUEST_TIMEOUT: {
395
+ readonly code: 408;
396
+ readonly text: "Request Timeout";
397
+ };
121
398
  readonly CONFLICT: {
122
399
  readonly code: 409;
123
400
  readonly text: "Conflict";
124
401
  };
402
+ readonly GONE: {
403
+ readonly code: 410;
404
+ readonly text: "Gone";
405
+ };
406
+ readonly LENGTH_REQUIRED: {
407
+ readonly code: 411;
408
+ readonly text: "Length Required";
409
+ };
410
+ readonly PRECONDITION_FAILED: {
411
+ readonly code: 412;
412
+ readonly text: "Precondition Failed";
413
+ };
414
+ readonly CONTENT_TOO_LARGE: {
415
+ readonly code: 413;
416
+ readonly text: "Content Too Large";
417
+ };
418
+ readonly URI_TOO_LONG: {
419
+ readonly code: 414;
420
+ readonly text: "URI Too Long";
421
+ };
422
+ readonly UNSUPPORTED_MEDIA_TYPE: {
423
+ readonly code: 415;
424
+ readonly text: "Unsupported Media Type";
425
+ };
426
+ readonly RANGE_NOT_SATISFIABLE: {
427
+ readonly code: 416;
428
+ readonly text: "Range Not Satisfiable";
429
+ };
430
+ readonly EXPECTATION_FAILED: {
431
+ readonly code: 417;
432
+ readonly text: "Expectation Failed";
433
+ };
434
+ readonly IM_A_TEAPOT: {
435
+ readonly code: 418;
436
+ readonly text: "I'm a teapot";
437
+ };
438
+ readonly MISDIRECTED_REQUEST: {
439
+ readonly code: 421;
440
+ readonly text: "Misdirected Request";
441
+ };
125
442
  readonly UNPROCESSABLE_CONTENT: {
126
443
  readonly code: 422;
127
444
  readonly text: "Unprocessable Content";
128
445
  };
446
+ readonly LOCKED: {
447
+ readonly code: 423;
448
+ readonly text: "Locked";
449
+ };
450
+ readonly FAILED_DEPENDENCY: {
451
+ readonly code: 424;
452
+ readonly text: "Failed Dependency";
453
+ };
454
+ readonly TOO_EARLY: {
455
+ readonly code: 425;
456
+ readonly text: "Too Early";
457
+ };
458
+ readonly UPGRADE_REQUIRED: {
459
+ readonly code: 426;
460
+ readonly text: "Upgrade Required";
461
+ };
462
+ readonly PRECONDITION_REQUIRED: {
463
+ readonly code: 428;
464
+ readonly text: "Precondition Required";
465
+ };
129
466
  readonly TOO_MANY_REQUESTS: {
130
467
  readonly code: 429;
131
468
  readonly text: "Too Many Requests";
132
469
  };
470
+ readonly REQUEST_HEADER_FIELDS_TOO_LARGE: {
471
+ readonly code: 431;
472
+ readonly text: "Request Header Fields Too Large";
473
+ };
474
+ readonly UNAVAILABLE_FOR_LEGAL_REASONS: {
475
+ readonly code: 451;
476
+ readonly text: "Unavailable For Legal Reasons";
477
+ };
133
478
  readonly INTERNAL_SERVER_ERROR: {
134
479
  readonly code: 500;
135
480
  readonly text: "Internal Server Error";
136
481
  };
482
+ readonly NOT_IMPLEMENTED: {
483
+ readonly code: 501;
484
+ readonly text: "Not Implemented";
485
+ };
486
+ readonly BAD_GATEWAY: {
487
+ readonly code: 502;
488
+ readonly text: "Bad Gateway";
489
+ };
137
490
  readonly SERVICE_UNAVAILABLE: {
138
491
  readonly code: 503;
139
492
  readonly text: "Service Unavailable";
@@ -142,13 +495,35 @@ export declare const HTTP_ERROR_RESPONSE_STATUS_RECORD: {
142
495
  readonly code: 504;
143
496
  readonly text: "Gateway Timeout";
144
497
  };
498
+ readonly HTTP_VERSION_NOT_SUPPORTED: {
499
+ readonly code: 505;
500
+ readonly text: "HTTP Version Not Supported";
501
+ };
502
+ readonly VARIANT_ALSO_NEGOTIATES: {
503
+ readonly code: 506;
504
+ readonly text: "Variant Also Negotiates";
505
+ };
506
+ readonly INSUFFICIENT_STORAGE: {
507
+ readonly code: 507;
508
+ readonly text: "Insufficient Storage";
509
+ };
510
+ readonly LOOP_DETECTED: {
511
+ readonly code: 508;
512
+ readonly text: "Loop Detected";
513
+ };
514
+ readonly NOT_EXTENDED: {
515
+ readonly code: 510;
516
+ readonly text: "Not Extended";
517
+ };
518
+ readonly NETWORK_AUTHENTICATION_REQUIRED: {
519
+ readonly code: 511;
520
+ readonly text: "Network Authentication Required";
521
+ };
145
522
  };
146
- export type HttpErrorResponseStatusRecord = typeof HTTP_ERROR_RESPONSE_STATUS_RECORD;
147
- export type HttpErrorResponseStatusCode = ValueOf<HttpErrorResponseStatusRecord>["code"];
148
- export type HttpErrorResponseStatusText = ValueOf<HttpErrorResponseStatusRecord>["text"];
149
- //#endregion
150
- //#region src/constants/response-statuses/error/client.d.ts
151
- export declare const HTTP_CLIENT_ERROR_RESPONSE_STATUS_RECORD: {
523
+ type HttpErrorResponseStatus = ValueOf<typeof HTTP_ERROR_RESPONSE_STATUS_ENUM>;
524
+ export type HttpErrorResponseStatusCode = HttpErrorResponseStatus["code"];
525
+ export type HttpErrorResponseStatusText = HttpErrorResponseStatus["text"];
526
+ export declare const HTTP_CLIENT_ERROR_RESPONSE_STATUS_ENUM: {
152
527
  readonly BAD_REQUEST: {
153
528
  readonly code: 400;
154
529
  readonly text: "Bad Request";
@@ -157,6 +532,10 @@ export declare const HTTP_CLIENT_ERROR_RESPONSE_STATUS_RECORD: {
157
532
  readonly code: 401;
158
533
  readonly text: "Unauthorized";
159
534
  };
535
+ readonly PAYMENT_REQUIRED: {
536
+ readonly code: 402;
537
+ readonly text: "Payment Required";
538
+ };
160
539
  readonly FORBIDDEN: {
161
540
  readonly code: 403;
162
541
  readonly text: "Forbidden";
@@ -165,29 +544,119 @@ export declare const HTTP_CLIENT_ERROR_RESPONSE_STATUS_RECORD: {
165
544
  readonly code: 404;
166
545
  readonly text: "Not Found";
167
546
  };
547
+ readonly METHOD_NOT_ALLOWED: {
548
+ readonly code: 405;
549
+ readonly text: "Method Not Allowed";
550
+ };
551
+ readonly NOT_ACCEPTABLE: {
552
+ readonly code: 406;
553
+ readonly text: "Not Acceptable";
554
+ };
555
+ readonly PROXY_AUTHENTICATION_REQUIRED: {
556
+ readonly code: 407;
557
+ readonly text: "Proxy Authentication Required";
558
+ };
559
+ readonly REQUEST_TIMEOUT: {
560
+ readonly code: 408;
561
+ readonly text: "Request Timeout";
562
+ };
168
563
  readonly CONFLICT: {
169
564
  readonly code: 409;
170
565
  readonly text: "Conflict";
171
566
  };
567
+ readonly GONE: {
568
+ readonly code: 410;
569
+ readonly text: "Gone";
570
+ };
571
+ readonly LENGTH_REQUIRED: {
572
+ readonly code: 411;
573
+ readonly text: "Length Required";
574
+ };
575
+ readonly PRECONDITION_FAILED: {
576
+ readonly code: 412;
577
+ readonly text: "Precondition Failed";
578
+ };
579
+ readonly CONTENT_TOO_LARGE: {
580
+ readonly code: 413;
581
+ readonly text: "Content Too Large";
582
+ };
583
+ readonly URI_TOO_LONG: {
584
+ readonly code: 414;
585
+ readonly text: "URI Too Long";
586
+ };
587
+ readonly UNSUPPORTED_MEDIA_TYPE: {
588
+ readonly code: 415;
589
+ readonly text: "Unsupported Media Type";
590
+ };
591
+ readonly RANGE_NOT_SATISFIABLE: {
592
+ readonly code: 416;
593
+ readonly text: "Range Not Satisfiable";
594
+ };
595
+ readonly EXPECTATION_FAILED: {
596
+ readonly code: 417;
597
+ readonly text: "Expectation Failed";
598
+ };
599
+ readonly IM_A_TEAPOT: {
600
+ readonly code: 418;
601
+ readonly text: "I'm a teapot";
602
+ };
603
+ readonly MISDIRECTED_REQUEST: {
604
+ readonly code: 421;
605
+ readonly text: "Misdirected Request";
606
+ };
172
607
  readonly UNPROCESSABLE_CONTENT: {
173
608
  readonly code: 422;
174
609
  readonly text: "Unprocessable Content";
175
610
  };
611
+ readonly LOCKED: {
612
+ readonly code: 423;
613
+ readonly text: "Locked";
614
+ };
615
+ readonly FAILED_DEPENDENCY: {
616
+ readonly code: 424;
617
+ readonly text: "Failed Dependency";
618
+ };
619
+ readonly TOO_EARLY: {
620
+ readonly code: 425;
621
+ readonly text: "Too Early";
622
+ };
623
+ readonly UPGRADE_REQUIRED: {
624
+ readonly code: 426;
625
+ readonly text: "Upgrade Required";
626
+ };
627
+ readonly PRECONDITION_REQUIRED: {
628
+ readonly code: 428;
629
+ readonly text: "Precondition Required";
630
+ };
176
631
  readonly TOO_MANY_REQUESTS: {
177
632
  readonly code: 429;
178
633
  readonly text: "Too Many Requests";
179
634
  };
635
+ readonly REQUEST_HEADER_FIELDS_TOO_LARGE: {
636
+ readonly code: 431;
637
+ readonly text: "Request Header Fields Too Large";
638
+ };
639
+ readonly UNAVAILABLE_FOR_LEGAL_REASONS: {
640
+ readonly code: 451;
641
+ readonly text: "Unavailable For Legal Reasons";
642
+ };
180
643
  };
181
- export type HttpClientErrorResponseStatusRecord = typeof HTTP_CLIENT_ERROR_RESPONSE_STATUS_RECORD;
182
- export type HttpClientErrorResponseStatusCode = ValueOf<HttpClientErrorResponseStatusRecord>["code"];
183
- export type HttpClientErrorResponseStatusText = ValueOf<HttpClientErrorResponseStatusRecord>["text"];
184
- //#endregion
185
- //#region src/constants/response-statuses/error/server.d.ts
186
- export declare const HTTP_SERVER_ERROR_RESPONSE_STATUS_RECORD: {
644
+ type HttpClientErrorResponseStatus = ValueOf<typeof HTTP_CLIENT_ERROR_RESPONSE_STATUS_ENUM>;
645
+ export type HttpClientErrorResponseStatusCode = HttpClientErrorResponseStatus["code"];
646
+ export type HttpClientErrorResponseStatusText = HttpClientErrorResponseStatus["text"];
647
+ export declare const HTTP_SERVER_ERROR_RESPONSE_STATUS_ENUM: {
187
648
  readonly INTERNAL_SERVER_ERROR: {
188
649
  readonly code: 500;
189
650
  readonly text: "Internal Server Error";
190
651
  };
652
+ readonly NOT_IMPLEMENTED: {
653
+ readonly code: 501;
654
+ readonly text: "Not Implemented";
655
+ };
656
+ readonly BAD_GATEWAY: {
657
+ readonly code: 502;
658
+ readonly text: "Bad Gateway";
659
+ };
191
660
  readonly SERVICE_UNAVAILABLE: {
192
661
  readonly code: 503;
193
662
  readonly text: "Service Unavailable";
@@ -196,8 +665,32 @@ export declare const HTTP_SERVER_ERROR_RESPONSE_STATUS_RECORD: {
196
665
  readonly code: 504;
197
666
  readonly text: "Gateway Timeout";
198
667
  };
668
+ readonly HTTP_VERSION_NOT_SUPPORTED: {
669
+ readonly code: 505;
670
+ readonly text: "HTTP Version Not Supported";
671
+ };
672
+ readonly VARIANT_ALSO_NEGOTIATES: {
673
+ readonly code: 506;
674
+ readonly text: "Variant Also Negotiates";
675
+ };
676
+ readonly INSUFFICIENT_STORAGE: {
677
+ readonly code: 507;
678
+ readonly text: "Insufficient Storage";
679
+ };
680
+ readonly LOOP_DETECTED: {
681
+ readonly code: 508;
682
+ readonly text: "Loop Detected";
683
+ };
684
+ readonly NOT_EXTENDED: {
685
+ readonly code: 510;
686
+ readonly text: "Not Extended";
687
+ };
688
+ readonly NETWORK_AUTHENTICATION_REQUIRED: {
689
+ readonly code: 511;
690
+ readonly text: "Network Authentication Required";
691
+ };
199
692
  };
200
- export type HttpServerErrorResponseStatusRecord = typeof HTTP_SERVER_ERROR_RESPONSE_STATUS_RECORD;
201
- export type HttpServerErrorResponseStatusCode = ValueOf<HttpServerErrorResponseStatusRecord>["code"];
202
- export type HttpServerErrorResponseStatusText = ValueOf<HttpServerErrorResponseStatusRecord>["text"];
203
- //#endregion
693
+ type HttpServerErrorResponseStatus = ValueOf<typeof HTTP_SERVER_ERROR_RESPONSE_STATUS_ENUM>;
694
+ export type HttpServerErrorResponseStatusCode = HttpServerErrorResponseStatus["code"];
695
+ export type HttpServerErrorResponseStatusText = HttpServerErrorResponseStatus["text"];
696
+ export {};
package/dist/index.js CHANGED
@@ -1,13 +1,12 @@
1
- //#region src/constants/headers.ts
2
- const HTTP_HEADER_RECORD = {
1
+ // src/constants/headers.ts
2
+ const HTTP_HEADER_ENUM = {
3
3
  AUTHORIZATION: "authorization",
4
4
  CONTENT_TYPE: "content-type",
5
5
  COOKIE: "cookie",
6
6
  RETRY_AFTER: "retry-after"
7
7
  };
8
- //#endregion
9
- //#region src/constants/request-methods.ts
10
- const HTTP_REQUEST_METHOD_RECORD = {
8
+ // src/constants/request-methods.ts
9
+ const HTTP_REQUEST_METHOD_ENUM = {
11
10
  GET: "GET",
12
11
  POST: "POST",
13
12
  DELETE: "DELETE",
@@ -18,9 +17,8 @@ const HTTP_REQUEST_METHOD_RECORD = {
18
17
  TRACE: "TRACE",
19
18
  CONNECT: "CONNECT"
20
19
  };
21
- //#endregion
22
- //#region src/constants/response-statuses/error/client.ts
23
- const HTTP_CLIENT_ERROR_RESPONSE_STATUS_RECORD = {
20
+ // src/constants/response-statuses/error/client.ts
21
+ const HTTP_CLIENT_ERROR_RESPONSE_STATUS_ENUM = {
24
22
  BAD_REQUEST: {
25
23
  code: 400,
26
24
  text: "Bad Request"
@@ -29,6 +27,10 @@ const HTTP_CLIENT_ERROR_RESPONSE_STATUS_RECORD = {
29
27
  code: 401,
30
28
  text: "Unauthorized"
31
29
  },
30
+ PAYMENT_REQUIRED: {
31
+ code: 402,
32
+ text: "Payment Required"
33
+ },
32
34
  FORBIDDEN: {
33
35
  code: 403,
34
36
  text: "Forbidden"
@@ -37,26 +39,117 @@ const HTTP_CLIENT_ERROR_RESPONSE_STATUS_RECORD = {
37
39
  code: 404,
38
40
  text: "Not Found"
39
41
  },
42
+ METHOD_NOT_ALLOWED: {
43
+ code: 405,
44
+ text: "Method Not Allowed"
45
+ },
46
+ NOT_ACCEPTABLE: {
47
+ code: 406,
48
+ text: "Not Acceptable"
49
+ },
50
+ PROXY_AUTHENTICATION_REQUIRED: {
51
+ code: 407,
52
+ text: "Proxy Authentication Required"
53
+ },
54
+ REQUEST_TIMEOUT: {
55
+ code: 408,
56
+ text: "Request Timeout"
57
+ },
40
58
  CONFLICT: {
41
59
  code: 409,
42
60
  text: "Conflict"
43
61
  },
62
+ GONE: {
63
+ code: 410,
64
+ text: "Gone"
65
+ },
66
+ LENGTH_REQUIRED: {
67
+ code: 411,
68
+ text: "Length Required"
69
+ },
70
+ PRECONDITION_FAILED: {
71
+ code: 412,
72
+ text: "Precondition Failed"
73
+ },
74
+ CONTENT_TOO_LARGE: {
75
+ code: 413,
76
+ text: "Content Too Large"
77
+ },
78
+ URI_TOO_LONG: {
79
+ code: 414,
80
+ text: "URI Too Long"
81
+ },
82
+ UNSUPPORTED_MEDIA_TYPE: {
83
+ code: 415,
84
+ text: "Unsupported Media Type"
85
+ },
86
+ RANGE_NOT_SATISFIABLE: {
87
+ code: 416,
88
+ text: "Range Not Satisfiable"
89
+ },
90
+ EXPECTATION_FAILED: {
91
+ code: 417,
92
+ text: "Expectation Failed"
93
+ },
94
+ IM_A_TEAPOT: {
95
+ code: 418,
96
+ text: "I'm a teapot"
97
+ },
98
+ MISDIRECTED_REQUEST: {
99
+ code: 421,
100
+ text: "Misdirected Request"
101
+ },
44
102
  UNPROCESSABLE_CONTENT: {
45
103
  code: 422,
46
104
  text: "Unprocessable Content"
47
105
  },
106
+ LOCKED: {
107
+ code: 423,
108
+ text: "Locked"
109
+ },
110
+ FAILED_DEPENDENCY: {
111
+ code: 424,
112
+ text: "Failed Dependency"
113
+ },
114
+ TOO_EARLY: {
115
+ code: 425,
116
+ text: "Too Early"
117
+ },
118
+ UPGRADE_REQUIRED: {
119
+ code: 426,
120
+ text: "Upgrade Required"
121
+ },
122
+ PRECONDITION_REQUIRED: {
123
+ code: 428,
124
+ text: "Precondition Required"
125
+ },
48
126
  TOO_MANY_REQUESTS: {
49
127
  code: 429,
50
128
  text: "Too Many Requests"
129
+ },
130
+ REQUEST_HEADER_FIELDS_TOO_LARGE: {
131
+ code: 431,
132
+ text: "Request Header Fields Too Large"
133
+ },
134
+ UNAVAILABLE_FOR_LEGAL_REASONS: {
135
+ code: 451,
136
+ text: "Unavailable For Legal Reasons"
51
137
  }
52
138
  };
53
- //#endregion
54
- //#region src/constants/response-statuses/error/server.ts
55
- const HTTP_SERVER_ERROR_RESPONSE_STATUS_RECORD = {
139
+ // src/constants/response-statuses/error/server.ts
140
+ const HTTP_SERVER_ERROR_RESPONSE_STATUS_ENUM = {
56
141
  INTERNAL_SERVER_ERROR: {
57
142
  code: 500,
58
143
  text: "Internal Server Error"
59
144
  },
145
+ NOT_IMPLEMENTED: {
146
+ code: 501,
147
+ text: "Not Implemented"
148
+ },
149
+ BAD_GATEWAY: {
150
+ code: 502,
151
+ text: "Bad Gateway"
152
+ },
60
153
  SERVICE_UNAVAILABLE: {
61
154
  code: 503,
62
155
  text: "Service Unavailable"
@@ -64,17 +157,85 @@ const HTTP_SERVER_ERROR_RESPONSE_STATUS_RECORD = {
64
157
  GATEWAY_TIMEOUT: {
65
158
  code: 504,
66
159
  text: "Gateway Timeout"
160
+ },
161
+ HTTP_VERSION_NOT_SUPPORTED: {
162
+ code: 505,
163
+ text: "HTTP Version Not Supported"
164
+ },
165
+ VARIANT_ALSO_NEGOTIATES: {
166
+ code: 506,
167
+ text: "Variant Also Negotiates"
168
+ },
169
+ INSUFFICIENT_STORAGE: {
170
+ code: 507,
171
+ text: "Insufficient Storage"
172
+ },
173
+ LOOP_DETECTED: {
174
+ code: 508,
175
+ text: "Loop Detected"
176
+ },
177
+ NOT_EXTENDED: {
178
+ code: 510,
179
+ text: "Not Extended"
180
+ },
181
+ NETWORK_AUTHENTICATION_REQUIRED: {
182
+ code: 511,
183
+ text: "Network Authentication Required"
184
+ }
185
+ };
186
+ // src/constants/response-statuses/error/index.ts
187
+ const HTTP_ERROR_RESPONSE_STATUS_ENUM = {
188
+ ...HTTP_CLIENT_ERROR_RESPONSE_STATUS_ENUM,
189
+ ...HTTP_SERVER_ERROR_RESPONSE_STATUS_ENUM
190
+ };
191
+ // src/constants/response-statuses/information.ts
192
+ const HTTP_INFORMATIONAL_RESPONSE_STATUS_ENUM = {
193
+ CONTINUE: {
194
+ code: 100,
195
+ text: "Continue"
196
+ },
197
+ SWITCHING_PROTOCOLS: {
198
+ code: 101,
199
+ text: "Switching Protocols"
200
+ },
201
+ EARLY_HINTS: {
202
+ code: 103,
203
+ text: "Early Hints"
67
204
  }
68
205
  };
69
- //#endregion
70
- //#region src/constants/response-statuses/error/index.ts
71
- const HTTP_ERROR_RESPONSE_STATUS_RECORD = {
72
- ...HTTP_CLIENT_ERROR_RESPONSE_STATUS_RECORD,
73
- ...HTTP_SERVER_ERROR_RESPONSE_STATUS_RECORD
206
+ // src/constants/response-statuses/redirection.ts
207
+ const HTTP_REDIRECTION_RESPONSE_STATUS_ENUM = {
208
+ MULTIPLE_CHOICES: {
209
+ code: 300,
210
+ text: "Multiple Choices"
211
+ },
212
+ MOVED_PERMANENTLY: {
213
+ code: 301,
214
+ text: "Moved Permanently"
215
+ },
216
+ FOUND: {
217
+ code: 302,
218
+ text: "Found"
219
+ },
220
+ SEE_OTHER: {
221
+ code: 303,
222
+ text: "See Other"
223
+ },
224
+ NOT_MODIFIED: {
225
+ code: 304,
226
+ text: "Not Modified"
227
+ },
228
+ TEMPORARY_REDIRECT: {
229
+ code: 307,
230
+ text: "Temporary Redirect"
231
+ },
232
+ PERMANENT_REDIRECT: {
233
+ code: 308,
234
+ text: "Permanent Redirect"
235
+ }
74
236
  };
75
- //#endregion
76
- //#region src/constants/response-statuses/success.ts
77
- const HTTP_SUCCESSFUL_RESPONSE_STATUS_RECORD = {
237
+ // src/constants/response-statuses/success.ts
238
+ const HTTP_SUCCESSFUL_RESPONSE_STATUS_ENUM = {
78
239
  OK: {
79
240
  code: 200,
80
241
  text: "OK"
@@ -83,16 +244,44 @@ const HTTP_SUCCESSFUL_RESPONSE_STATUS_RECORD = {
83
244
  code: 201,
84
245
  text: "Created"
85
246
  },
247
+ ACCEPTED: {
248
+ code: 202,
249
+ text: "Accepted"
250
+ },
251
+ NON_AUTHORITATIVE_INFORMATION: {
252
+ code: 203,
253
+ text: "Non-Authoritative Information"
254
+ },
86
255
  NO_CONTENT: {
87
256
  code: 204,
88
257
  text: "No Content"
258
+ },
259
+ RESET_CONTENT: {
260
+ code: 205,
261
+ text: "Reset Content"
262
+ },
263
+ PARTIAL_CONTENT: {
264
+ code: 206,
265
+ text: "Partial Content"
266
+ },
267
+ MULTI_STATUS: {
268
+ code: 207,
269
+ text: "Multi-Status"
270
+ },
271
+ ALREADY_REPORTED: {
272
+ code: 208,
273
+ text: "Already Reported"
274
+ },
275
+ IM_USED: {
276
+ code: 226,
277
+ text: "IM Used"
89
278
  }
90
279
  };
91
- //#endregion
92
- //#region src/constants/response-statuses/index.ts
280
+ // src/constants/response-statuses/index.ts
93
281
  const HTTP_RESPONSE_STATUS_RECORD = {
94
- ...HTTP_SUCCESSFUL_RESPONSE_STATUS_RECORD,
95
- ...HTTP_ERROR_RESPONSE_STATUS_RECORD
282
+ ...HTTP_INFORMATIONAL_RESPONSE_STATUS_ENUM,
283
+ ...HTTP_SUCCESSFUL_RESPONSE_STATUS_ENUM,
284
+ ...HTTP_REDIRECTION_RESPONSE_STATUS_ENUM,
285
+ ...HTTP_ERROR_RESPONSE_STATUS_ENUM
96
286
  };
97
- //#endregion
98
- export { HTTP_CLIENT_ERROR_RESPONSE_STATUS_RECORD, HTTP_ERROR_RESPONSE_STATUS_RECORD, HTTP_HEADER_RECORD, HTTP_REQUEST_METHOD_RECORD, HTTP_RESPONSE_STATUS_RECORD, HTTP_SERVER_ERROR_RESPONSE_STATUS_RECORD, HTTP_SUCCESSFUL_RESPONSE_STATUS_RECORD };
287
+ export { HTTP_CLIENT_ERROR_RESPONSE_STATUS_ENUM, HTTP_ERROR_RESPONSE_STATUS_ENUM, HTTP_HEADER_ENUM, HTTP_INFORMATIONAL_RESPONSE_STATUS_ENUM, HTTP_REDIRECTION_RESPONSE_STATUS_ENUM, HTTP_REQUEST_METHOD_ENUM, HTTP_RESPONSE_STATUS_RECORD, HTTP_SERVER_ERROR_RESPONSE_STATUS_ENUM, HTTP_SUCCESSFUL_RESPONSE_STATUS_ENUM };
package/package.json CHANGED
@@ -1,41 +1,49 @@
1
1
  {
2
2
  "name": "@little-nebulae/http",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
8
  "type": "module",
9
+ "sideEffects": false,
9
10
  "exports": {
10
11
  ".": "./dist/index.js",
11
12
  "./package.json": "./package.json"
12
13
  },
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "tag": "latest"
17
+ },
13
18
  "devDependencies": {
14
19
  "@arethetypeswrong/core": "0.18.5",
15
- "@little-nebulae/type-utils": "1.1.0",
16
- "@types/node": "26.6.2",
17
- "oxfmt": "0.68.0",
18
- "oxlint": "1.83.0",
19
- "oxlint-tsgolint": "7.0.2002",
20
- "publint": "0.3.24",
21
- "tsdown": "0.23.0",
22
- "tsx": "4.23.13",
23
- "typescript": "7.0.2",
24
- "vitest": "5.0.1"
20
+ "@types/node": "26.6.6",
21
+ "oxfmt": "0.78.0",
22
+ "oxlint": "1.93.0",
23
+ "oxlint-tsgolint": "7.0.2006",
24
+ "publint": "0.3.25",
25
+ "tsdown": "0.23.7",
26
+ "type-fest": "5.10.0",
27
+ "typescript": "7.1.0-beta",
28
+ "vitest": "5.1.0"
25
29
  },
26
30
  "peerDependencies": {
27
- "@little-nebulae/type-utils": "^1.0.0"
31
+ "type-fest": "^5.0.0"
28
32
  },
29
33
  "devEngines": {
30
34
  "packageManager": {
31
35
  "name": "pnpm",
32
- "version": "12.5.1",
36
+ "version": "^12.0.0",
37
+ "onFail": "warn"
38
+ },
39
+ "runtime": {
40
+ "name": "node",
41
+ "version": "^26.0.0",
33
42
  "onFail": "warn"
34
43
  }
35
44
  },
36
45
  "scripts": {
37
46
  "build": "tsdown",
38
- "try": "tsx ./src/try.ts",
39
47
  "fmt": "oxfmt --disable-nested-config",
40
48
  "fmt:check": "oxfmt --check --disable-nested-config",
41
49
  "lint": "oxlint --disable-nested-config",