@sdxc/http 0.0.0-pre.1

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.
@@ -0,0 +1,620 @@
1
+ /**
2
+ * HTTP status code constants, each pairing a numeric status with its
3
+ * standard status text for use as a `Response` init.
4
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
5
+ * @copyright Sergio Xalambrí 2026
6
+ */
7
+ /**
8
+ * HTTP 100 Continue status.
9
+ * Indicates the initial part of a request has been received and the client
10
+ * should continue with the request or ignore if already complete.
11
+ * @example
12
+ * return new Response(null, Continue);
13
+ * @example
14
+ * return Response.json({ message: "Continue sending" }, Continue);
15
+ */
16
+ export declare const Continue: {
17
+ readonly status: 100;
18
+ readonly statusText: "Continue";
19
+ };
20
+ /**
21
+ * HTTP 101 Switching Protocols status.
22
+ * Indicates the server is switching to a different protocol as requested
23
+ * by the client via the Upgrade header.
24
+ * @example
25
+ * return new Response(null, SwitchingProtocols);
26
+ * @example
27
+ * return new Response(null, { ...SwitchingProtocols, headers: { Upgrade: "websocket" } });
28
+ */
29
+ export declare const SwitchingProtocols: {
30
+ readonly status: 101;
31
+ readonly statusText: "Switching Protocols";
32
+ };
33
+ /**
34
+ * HTTP 200 OK status.
35
+ * Indicates the request succeeded. The meaning varies by HTTP method:
36
+ * GET returns the resource, POST returns the result of the action.
37
+ * @example
38
+ * return new Response(null, Ok);
39
+ * @example
40
+ * return Response.json({ data: result }, Ok);
41
+ */
42
+ export declare const Ok: {
43
+ readonly status: 200;
44
+ readonly statusText: "OK";
45
+ };
46
+ /**
47
+ * HTTP 201 Created status.
48
+ * Indicates the request succeeded and a new resource was created.
49
+ * Typically used after POST or PUT requests.
50
+ * @example
51
+ * return new Response(null, Created);
52
+ * @example
53
+ * return Response.json({ id: newUser.id }, Created);
54
+ */
55
+ export declare const Created: {
56
+ readonly status: 201;
57
+ readonly statusText: "Created";
58
+ };
59
+ /**
60
+ * HTTP 202 Accepted status.
61
+ * Indicates the request has been accepted for processing but processing
62
+ * has not been completed. Used for asynchronous operations.
63
+ * @example
64
+ * return new Response(null, Accepted);
65
+ * @example
66
+ * return Response.json({ jobId: "abc123" }, Accepted);
67
+ */
68
+ export declare const Accepted: {
69
+ readonly status: 202;
70
+ readonly statusText: "Accepted";
71
+ };
72
+ /**
73
+ * HTTP 204 No Content status.
74
+ * Indicates the request succeeded but there is no content to return.
75
+ * Commonly used for DELETE operations or updates that don't return data.
76
+ * @example
77
+ * return new Response(null, NoContent);
78
+ * @example
79
+ * await deleteUser(id); return new Response(null, NoContent);
80
+ */
81
+ export declare const NoContent: {
82
+ readonly status: 204;
83
+ readonly statusText: "No Content";
84
+ };
85
+ /**
86
+ * HTTP 205 Reset Content status.
87
+ * Indicates the request succeeded and the client should reset the document
88
+ * view. Used to clear forms after submission.
89
+ * @example
90
+ * return new Response(null, ResetContent);
91
+ * @example
92
+ * await submitForm(data); return new Response(null, ResetContent);
93
+ */
94
+ export declare const ResetContent: {
95
+ readonly status: 205;
96
+ readonly statusText: "Reset Content";
97
+ };
98
+ /**
99
+ * HTTP 206 Partial Content status.
100
+ * Indicates the server is delivering only part of the resource due to a
101
+ * range header sent by the client. Used for resumable downloads.
102
+ * @example
103
+ * return new Response(chunk, PartialContent);
104
+ * @example
105
+ * return new Response(videoChunk, { ...PartialContent, headers: { "Content-Range": "bytes 0-999/5000" } });
106
+ */
107
+ export declare const PartialContent: {
108
+ readonly status: 206;
109
+ readonly statusText: "Partial Content";
110
+ };
111
+ /**
112
+ * HTTP 300 Multiple Choices status.
113
+ * Indicates multiple options for the resource. The client may choose one
114
+ * or the server may provide a preferred option.
115
+ * @example
116
+ * return new Response(null, MultipleChoices);
117
+ * @example
118
+ * return Response.json({ options: ["/en/page", "/es/page"] }, MultipleChoices);
119
+ */
120
+ export declare const MultipleChoices: {
121
+ readonly status: 300;
122
+ readonly statusText: "Multiple Choices";
123
+ };
124
+ /**
125
+ * HTTP 301 Moved Permanently status.
126
+ * Indicates the resource has been permanently moved to a new URL.
127
+ * Search engines will update their links to the new location.
128
+ * @example
129
+ * return new Response(null, { ...MovedPermanently, headers: { Location: "/new-path" } });
130
+ * @example
131
+ * return Response.redirect("/new-url", MovedPermanently.status);
132
+ */
133
+ export declare const MovedPermanently: {
134
+ readonly status: 301;
135
+ readonly statusText: "Moved Permanently";
136
+ };
137
+ /**
138
+ * HTTP 302 Found status.
139
+ * Indicates the resource temporarily resides at a different URL.
140
+ * The client should continue using the original URL for future requests.
141
+ * @example
142
+ * return new Response(null, { ...Found, headers: { Location: "/temp-path" } });
143
+ * @example
144
+ * return Response.redirect("/temporary-url", Found.status);
145
+ */
146
+ export declare const Found: {
147
+ readonly status: 302;
148
+ readonly statusText: "Found";
149
+ };
150
+ /**
151
+ * HTTP 303 See Other status.
152
+ * Indicates the response can be found at another URL using a GET request.
153
+ * Often used after POST to redirect to a confirmation page.
154
+ * @example
155
+ * return new Response(null, { ...SeeOther, headers: { Location: "/success" } });
156
+ * @example
157
+ * return Response.redirect("/confirmation", SeeOther.status);
158
+ */
159
+ export declare const SeeOther: {
160
+ readonly status: 303;
161
+ readonly statusText: "See Other";
162
+ };
163
+ /**
164
+ * HTTP 304 Not Modified status.
165
+ * Indicates the resource has not been modified since the last request.
166
+ * Used for caching when If-Modified-Since or If-None-Match headers are sent.
167
+ * @example
168
+ * return new Response(null, NotModified);
169
+ * @example
170
+ * if (etag === request.headers.get("If-None-Match")) return new Response(null, NotModified);
171
+ */
172
+ export declare const NotModified: {
173
+ readonly status: 304;
174
+ readonly statusText: "Not Modified";
175
+ };
176
+ /**
177
+ * HTTP 307 Temporary Redirect status.
178
+ * Indicates a temporary redirect that preserves the request method.
179
+ * @example
180
+ * return new Response(null, { ...TemporaryRedirect, headers: { Location: "/temp" } });
181
+ * @example
182
+ * return Response.redirect("/maintenance", TemporaryRedirect.status);
183
+ */
184
+ export declare const TemporaryRedirect: {
185
+ readonly status: 307;
186
+ readonly statusText: "Temporary Redirect";
187
+ };
188
+ /**
189
+ * HTTP 308 Permanent Redirect status.
190
+ * Indicates a permanent redirect that preserves the request method.
191
+ * @example
192
+ * return new Response(null, { ...PermanentRedirect, headers: { Location: "/new" } });
193
+ * @example
194
+ * return Response.redirect("/new-api", PermanentRedirect.status);
195
+ */
196
+ export declare const PermanentRedirect: {
197
+ readonly status: 308;
198
+ readonly statusText: "Permanent Redirect";
199
+ };
200
+ /**
201
+ * HTTP 400 Bad Request status.
202
+ * Indicates the server cannot process the request due to client error,
203
+ * such as malformed syntax or invalid parameters.
204
+ * @example
205
+ * return new Response(null, BadRequest);
206
+ * @example
207
+ * return Response.json({ error: "Invalid JSON" }, BadRequest);
208
+ */
209
+ export declare const BadRequest: {
210
+ readonly status: 400;
211
+ readonly statusText: "Bad Request";
212
+ };
213
+ /**
214
+ * HTTP 401 Unauthorized status.
215
+ * Indicates the request requires authentication. The client must
216
+ * authenticate itself to get the requested response.
217
+ * @example
218
+ * return new Response(null, Unauthorized);
219
+ * @example
220
+ * return Response.json({ error: "Login required" }, Unauthorized);
221
+ */
222
+ export declare const Unauthorized: {
223
+ readonly status: 401;
224
+ readonly statusText: "Unauthorized";
225
+ };
226
+ /**
227
+ * HTTP 402 Payment Required status.
228
+ * Reserved for future use. Originally intended for digital payment systems,
229
+ * sometimes used to indicate a feature requires payment.
230
+ * @example
231
+ * return new Response(null, PaymentRequired);
232
+ * @example
233
+ * return Response.json({ error: "Subscription required" }, PaymentRequired);
234
+ */
235
+ export declare const PaymentRequired: {
236
+ readonly status: 402;
237
+ readonly statusText: "Payment Required";
238
+ };
239
+ /**
240
+ * HTTP 403 Forbidden status.
241
+ * Indicates the server understood the request but refuses to authorize it.
242
+ * Unlike 401, authentication will not help.
243
+ * @example
244
+ * return new Response(null, Forbidden);
245
+ * @example
246
+ * return Response.json({ error: "Access denied" }, Forbidden);
247
+ */
248
+ export declare const Forbidden: {
249
+ readonly status: 403;
250
+ readonly statusText: "Forbidden";
251
+ };
252
+ /**
253
+ * HTTP 404 Not Found status.
254
+ * Indicates the requested resource could not be found on the server.
255
+ * The resource may have been removed or the URL is incorrect.
256
+ * @example
257
+ * return new Response(null, NotFound);
258
+ * @example
259
+ * return Response.json({ error: "User not found" }, NotFound);
260
+ */
261
+ export declare const NotFound: {
262
+ readonly status: 404;
263
+ readonly statusText: "Not Found";
264
+ };
265
+ /**
266
+ * HTTP 405 Method Not Allowed status.
267
+ * Indicates the request method is not supported for the target resource.
268
+ * The response must include an Allow header with valid methods.
269
+ * @example
270
+ * return new Response(null, MethodNotAllowed);
271
+ * @example
272
+ * return new Response(null, { ...MethodNotAllowed, headers: { Allow: "GET, POST" } });
273
+ */
274
+ export declare const MethodNotAllowed: {
275
+ readonly status: 405;
276
+ readonly statusText: "Method Not Allowed";
277
+ };
278
+ /**
279
+ * HTTP 406 Not Acceptable status.
280
+ * Indicates the server cannot produce a response matching the Accept
281
+ * headers sent by the client.
282
+ * @example
283
+ * return new Response(null, NotAcceptable);
284
+ * @example
285
+ * return Response.json({ error: "Cannot produce requested format" }, NotAcceptable);
286
+ */
287
+ export declare const NotAcceptable: {
288
+ readonly status: 406;
289
+ readonly statusText: "Not Acceptable";
290
+ };
291
+ /**
292
+ * HTTP 407 Proxy Authentication Required status.
293
+ * Indicates the client must authenticate with a proxy server before
294
+ * this request can be served.
295
+ * @example
296
+ * return new Response(null, ProxyAuthRequired);
297
+ * @example
298
+ * return new Response(null, { ...ProxyAuthRequired, headers: { "Proxy-Authenticate": "Basic" } });
299
+ */
300
+ export declare const ProxyAuthRequired: {
301
+ readonly status: 407;
302
+ readonly statusText: "Proxy Authentication Required";
303
+ };
304
+ /**
305
+ * HTTP 408 Request Timeout status.
306
+ * Indicates the server timed out waiting for the request. The client
307
+ * may repeat the request without modifications.
308
+ * @example
309
+ * return new Response(null, RequestTimeout);
310
+ * @example
311
+ * return Response.json({ error: "Request took too long" }, RequestTimeout);
312
+ */
313
+ export declare const RequestTimeout: {
314
+ readonly status: 408;
315
+ readonly statusText: "Request Timeout";
316
+ };
317
+ /**
318
+ * HTTP 409 Conflict status.
319
+ * Indicates the request conflicts with the current state of the server.
320
+ * Often used for concurrent modification errors.
321
+ * @example
322
+ * return new Response(null, Conflict);
323
+ * @example
324
+ * return Response.json({ error: "Resource already exists" }, Conflict);
325
+ */
326
+ export declare const Conflict: {
327
+ readonly status: 409;
328
+ readonly statusText: "Conflict";
329
+ };
330
+ /**
331
+ * HTTP 410 Gone status.
332
+ * Indicates the resource is no longer available and will not be available
333
+ * again. Unlike 404, this is permanent.
334
+ * @example
335
+ * return new Response(null, Gone);
336
+ * @example
337
+ * return Response.json({ error: "Resource permanently removed" }, Gone);
338
+ */
339
+ export declare const Gone: {
340
+ readonly status: 410;
341
+ readonly statusText: "Gone";
342
+ };
343
+ /**
344
+ * HTTP 411 Length Required status.
345
+ * Indicates the server requires a Content-Length header in the request.
346
+ * The client should resend with the header included.
347
+ * @example
348
+ * return new Response(null, LengthRequired);
349
+ * @example
350
+ * return Response.json({ error: "Content-Length header required" }, LengthRequired);
351
+ */
352
+ export declare const LengthRequired: {
353
+ readonly status: 411;
354
+ readonly statusText: "Length Required";
355
+ };
356
+ /**
357
+ * HTTP 412 Precondition Failed status.
358
+ * Indicates one or more conditions in the request headers evaluated to
359
+ * false. Used with conditional requests.
360
+ * @example
361
+ * return new Response(null, PreconditionFailed);
362
+ * @example
363
+ * return Response.json({ error: "If-Match condition failed" }, PreconditionFailed);
364
+ */
365
+ export declare const PreconditionFailed: {
366
+ readonly status: 412;
367
+ readonly statusText: "Precondition Failed";
368
+ };
369
+ /**
370
+ * HTTP 413 Payload Too Large status.
371
+ * Indicates the request entity is larger than the server is willing or
372
+ * able to process.
373
+ * @example
374
+ * return new Response(null, PayloadTooLarge);
375
+ * @example
376
+ * return Response.json({ error: "File exceeds 10MB limit" }, PayloadTooLarge);
377
+ */
378
+ export declare const PayloadTooLarge: {
379
+ readonly status: 413;
380
+ readonly statusText: "Payload Too Large";
381
+ };
382
+ /**
383
+ * HTTP 414 URI Too Long status.
384
+ * Indicates the URI requested by the client is longer than the server
385
+ * is willing to interpret.
386
+ * @example
387
+ * return new Response(null, URITooLong);
388
+ * @example
389
+ * return Response.json({ error: "URL exceeds maximum length" }, URITooLong);
390
+ */
391
+ export declare const URITooLong: {
392
+ readonly status: 414;
393
+ readonly statusText: "URI Too Long";
394
+ };
395
+ /**
396
+ * HTTP 415 Unsupported Media Type status.
397
+ * Indicates the media format of the request data is not supported by
398
+ * the server.
399
+ * @example
400
+ * return new Response(null, UnsupportedMediaType);
401
+ * @example
402
+ * return Response.json({ error: "Content-Type must be application/json" }, UnsupportedMediaType);
403
+ */
404
+ export declare const UnsupportedMediaType: {
405
+ readonly status: 415;
406
+ readonly statusText: "Unsupported Media Type";
407
+ };
408
+ /**
409
+ * HTTP 416 Range Not Satisfiable status.
410
+ * Indicates the range specified in the Range header cannot be fulfilled.
411
+ * The range may be outside the target resource's size.
412
+ * @example
413
+ * return new Response(null, RangeNotSatisfiable);
414
+ * @example
415
+ * return new Response(null, { ...RangeNotSatisfiable, headers: { "Content-Range": "bytes 0-0/5000" } });
416
+ */
417
+ export declare const RangeNotSatisfiable: {
418
+ readonly status: 416;
419
+ readonly statusText: "Range Not Satisfiable";
420
+ };
421
+ /**
422
+ * HTTP 417 Expectation Failed status.
423
+ * Indicates the expectation in the Expect request header cannot be met
424
+ * by the server.
425
+ * @example
426
+ * return new Response(null, ExpectationFailed);
427
+ * @example
428
+ * return Response.json({ error: "Cannot meet expectation" }, ExpectationFailed);
429
+ */
430
+ export declare const ExpectationFailed: {
431
+ readonly status: 417;
432
+ readonly statusText: "Expectation Failed";
433
+ };
434
+ /**
435
+ * HTTP 418 I'm a teapot status.
436
+ * A playful response defined in RFC 2324. The server refuses to brew
437
+ * coffee because it is a teapot.
438
+ * @example
439
+ * return new Response(null, ImATeapot);
440
+ * @example
441
+ * return Response.json({ error: "I'm a teapot, not a coffee maker" }, ImATeapot);
442
+ */
443
+ export declare const ImATeapot: {
444
+ readonly status: 418;
445
+ readonly statusText: "I'm a teapot";
446
+ };
447
+ /**
448
+ * HTTP 422 Unprocessable Entity status.
449
+ * Indicates the request was well-formed but contained semantic errors.
450
+ * Commonly used for validation failures.
451
+ * @example
452
+ * return new Response(null, UnprocessableEntity);
453
+ * @example
454
+ * return Response.json({ errors: { email: "Invalid format" } }, UnprocessableEntity);
455
+ */
456
+ export declare const UnprocessableEntity: {
457
+ readonly status: 422;
458
+ readonly statusText: "Unprocessable Entity";
459
+ };
460
+ /**
461
+ * HTTP 425 Too Early status.
462
+ * Indicates the server is unwilling to process a request that might be
463
+ * replayed to avoid potential replay attacks.
464
+ * @example
465
+ * return new Response(null, TooEarly);
466
+ * @example
467
+ * return Response.json({ error: "Request sent too early" }, TooEarly);
468
+ */
469
+ export declare const TooEarly: {
470
+ readonly status: 425;
471
+ readonly statusText: "Too Early";
472
+ };
473
+ /**
474
+ * HTTP 426 Upgrade Required status.
475
+ * Indicates the server refuses to perform the request using the current
476
+ * protocol but might after the client upgrades.
477
+ * @example
478
+ * return new Response(null, UpgradeRequired);
479
+ * @example
480
+ * return new Response(null, { ...UpgradeRequired, headers: { Upgrade: "TLS/1.3" } });
481
+ */
482
+ export declare const UpgradeRequired: {
483
+ readonly status: 426;
484
+ readonly statusText: "Upgrade Required";
485
+ };
486
+ /**
487
+ * HTTP 428 Precondition Required status.
488
+ * Indicates the server requires the request to be conditional to prevent
489
+ * lost update problems.
490
+ * @example
491
+ * return new Response(null, PreconditionRequired);
492
+ * @example
493
+ * return Response.json({ error: "If-Match header required" }, PreconditionRequired);
494
+ */
495
+ export declare const PreconditionRequired: {
496
+ readonly status: 428;
497
+ readonly statusText: "Precondition Required";
498
+ };
499
+ /**
500
+ * HTTP 429 Too Many Requests status.
501
+ * Indicates the user has sent too many requests in a given amount of time.
502
+ * Used for rate limiting.
503
+ * @example
504
+ * return new Response(null, TooManyRequests);
505
+ * @example
506
+ * return new Response(null, { ...TooManyRequests, headers: { "Retry-After": "60" } });
507
+ */
508
+ export declare const TooManyRequests: {
509
+ readonly status: 429;
510
+ readonly statusText: "Too Many Requests";
511
+ };
512
+ /**
513
+ * HTTP 431 Request Header Fields Too Large status.
514
+ * Indicates the server is unwilling to process the request because the
515
+ * header fields are too large.
516
+ * @example
517
+ * return new Response(null, RequestHeaderFieldsTooLarge);
518
+ * @example
519
+ * return Response.json({ error: "Headers exceed size limit" }, RequestHeaderFieldsTooLarge);
520
+ */
521
+ export declare const RequestHeaderFieldsTooLarge: {
522
+ readonly status: 431;
523
+ readonly statusText: "Request Header Fields Too Large";
524
+ };
525
+ /**
526
+ * HTTP 451 Unavailable For Legal Reasons status.
527
+ * Indicates the resource is unavailable due to legal demands such as
528
+ * censorship or government-mandated blocks.
529
+ * @example
530
+ * return new Response(null, UnavailableForLegalReasons);
531
+ * @example
532
+ * return Response.json({ error: "Content blocked in your region" }, UnavailableForLegalReasons);
533
+ */
534
+ export declare const UnavailableForLegalReasons: {
535
+ readonly status: 451;
536
+ readonly statusText: "Unavailable For Legal Reasons";
537
+ };
538
+ /**
539
+ * HTTP 500 Internal Server Error status.
540
+ * Indicates the server encountered an unexpected condition that prevented
541
+ * it from fulfilling the request.
542
+ * @example
543
+ * return new Response(null, InternalServerError);
544
+ * @example
545
+ * return Response.json({ error: "Something went wrong" }, InternalServerError);
546
+ */
547
+ export declare const InternalServerError: {
548
+ readonly status: 500;
549
+ readonly statusText: "Internal Server Error";
550
+ };
551
+ /**
552
+ * HTTP 501 Not Implemented status.
553
+ * Indicates the server does not support the functionality required to
554
+ * fulfill the request.
555
+ * @example
556
+ * return new Response(null, NotImplemented);
557
+ * @example
558
+ * return Response.json({ error: "Feature not implemented" }, NotImplemented);
559
+ */
560
+ export declare const NotImplemented: {
561
+ readonly status: 501;
562
+ readonly statusText: "Not Implemented";
563
+ };
564
+ /**
565
+ * HTTP 502 Bad Gateway status.
566
+ * Indicates the server received an invalid response from an upstream
567
+ * server while acting as a gateway or proxy.
568
+ * @example
569
+ * return new Response(null, BadGateway);
570
+ * @example
571
+ * return Response.json({ error: "Upstream server error" }, BadGateway);
572
+ */
573
+ export declare const BadGateway: {
574
+ readonly status: 502;
575
+ readonly statusText: "Bad Gateway";
576
+ };
577
+ /**
578
+ * HTTP 503 Service Unavailable status.
579
+ * Indicates the server is not ready to handle the request, often due to
580
+ * maintenance or overload.
581
+ * @example
582
+ * return new Response(null, ServiceUnavailable);
583
+ * @example
584
+ * return new Response(null, { ...ServiceUnavailable, headers: { "Retry-After": "3600" } });
585
+ */
586
+ export declare const ServiceUnavailable: {
587
+ readonly status: 503;
588
+ readonly statusText: "Service Unavailable";
589
+ };
590
+ /**
591
+ * HTTP 504 Gateway Timeout status.
592
+ * Indicates the server acting as a gateway did not receive a timely
593
+ * response from the upstream server.
594
+ * @example
595
+ * return new Response(null, GatewayTimeout);
596
+ * @example
597
+ * return Response.json({ error: "Upstream server timed out" }, GatewayTimeout);
598
+ */
599
+ export declare const GatewayTimeout: {
600
+ readonly status: 504;
601
+ readonly statusText: "Gateway Timeout";
602
+ };
603
+ /**
604
+ * HTTP 505 HTTP Version Not Supported status.
605
+ * Indicates the server does not support the HTTP protocol version used
606
+ * in the request.
607
+ * @example
608
+ * return new Response(null, HTTPVersionNotSupported);
609
+ * @example
610
+ * return Response.json({ error: "HTTP version not supported" }, HTTPVersionNotSupported);
611
+ */
612
+ export declare const HTTPVersionNotSupported: {
613
+ readonly status: 505;
614
+ readonly statusText: "HTTP Version Not Supported";
615
+ };
616
+ /** Type representing any HTTP status code constant. */
617
+ export type StatusCode = {
618
+ readonly status: number;
619
+ readonly statusText: string;
620
+ };