@augment-vir/core 31.4.0 → 31.6.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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ArrayElement } from '../array/array.js';
|
|
2
|
+
import type { ExtractKeysWithMatchingValues } from '../object/object-keys.js';
|
|
2
3
|
/**
|
|
3
4
|
* All standardized HTTP status codes.
|
|
4
5
|
*
|
|
@@ -498,6 +499,120 @@ export declare enum HttpStatusCategory {
|
|
|
498
499
|
ClientError = "clientError",
|
|
499
500
|
ServerError = "serverError"
|
|
500
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* All {@link HttpStatusCategory} entries that indicate a failed response as a runtime value that can
|
|
504
|
+
* be used to check actual response statuses.
|
|
505
|
+
*
|
|
506
|
+
* @category HTTP
|
|
507
|
+
* @category Package : @augment-vir/common
|
|
508
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
509
|
+
*/
|
|
510
|
+
export declare const errorHttpStatusCategories: readonly [HttpStatusCategory.ClientError, HttpStatusCategory.ServerError];
|
|
511
|
+
/**
|
|
512
|
+
* All {@link HttpStatusCategory} entries that indicate a failed response.
|
|
513
|
+
*
|
|
514
|
+
* @category HTTP
|
|
515
|
+
* @category Package : @augment-vir/common
|
|
516
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
517
|
+
*/
|
|
518
|
+
export type ErrorHttpStatusCategories = ArrayElement<typeof errorHttpStatusCategories>;
|
|
519
|
+
/**
|
|
520
|
+
* All {@link HttpStatusCategory} entries that indicate a successful response.
|
|
521
|
+
*
|
|
522
|
+
* @category HTTP
|
|
523
|
+
* @category Package : @augment-vir/common
|
|
524
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
525
|
+
*/
|
|
526
|
+
export type SuccessHttpStatusCategories = Exclude<HttpStatusCategory, ErrorHttpStatusCategories>;
|
|
527
|
+
/**
|
|
528
|
+
* Checks if the given HTTP status is an error status. Type guards the input.
|
|
529
|
+
*
|
|
530
|
+
* @category HTTP
|
|
531
|
+
* @category Package : @augment-vir/common
|
|
532
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
533
|
+
*/
|
|
534
|
+
export declare function isErrorHttpStatus(input: HttpStatus): input is ExtractKeysWithMatchingValues<typeof httpStatusToCategory, ErrorHttpStatusCategories>;
|
|
535
|
+
/**
|
|
536
|
+
* A type that maps the given {@link HttpStatus} type parameter to its respective
|
|
537
|
+
* {@link HttpStatusCategory}.
|
|
538
|
+
*
|
|
539
|
+
* @category HTTP
|
|
540
|
+
* @category Package : @augment-vir/common
|
|
541
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
542
|
+
*/
|
|
543
|
+
export type HttpStatusToCategory<Status extends HttpStatus> = (typeof httpStatusToCategory)[Status];
|
|
544
|
+
/**
|
|
545
|
+
* All standardized HTTP statuses mapped to their respective category.
|
|
546
|
+
*
|
|
547
|
+
* @category HTTP
|
|
548
|
+
* @category Package : @augment-vir/common
|
|
549
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
550
|
+
*/
|
|
551
|
+
export declare const httpStatusToCategory: {
|
|
552
|
+
readonly 100: HttpStatusCategory.Information;
|
|
553
|
+
readonly 101: HttpStatusCategory.Information;
|
|
554
|
+
readonly 102: HttpStatusCategory.Information;
|
|
555
|
+
readonly 103: HttpStatusCategory.Information;
|
|
556
|
+
readonly 200: HttpStatusCategory.Success;
|
|
557
|
+
readonly 201: HttpStatusCategory.Success;
|
|
558
|
+
readonly 202: HttpStatusCategory.Success;
|
|
559
|
+
readonly 203: HttpStatusCategory.Success;
|
|
560
|
+
readonly 204: HttpStatusCategory.Success;
|
|
561
|
+
readonly 205: HttpStatusCategory.Success;
|
|
562
|
+
readonly 206: HttpStatusCategory.Success;
|
|
563
|
+
readonly 207: HttpStatusCategory.Success;
|
|
564
|
+
readonly 208: HttpStatusCategory.Success;
|
|
565
|
+
readonly 226: HttpStatusCategory.Success;
|
|
566
|
+
readonly 300: HttpStatusCategory.Redirect;
|
|
567
|
+
readonly 301: HttpStatusCategory.Redirect;
|
|
568
|
+
readonly 302: HttpStatusCategory.Redirect;
|
|
569
|
+
readonly 303: HttpStatusCategory.Redirect;
|
|
570
|
+
readonly 304: HttpStatusCategory.Redirect;
|
|
571
|
+
readonly 305: HttpStatusCategory.Redirect;
|
|
572
|
+
readonly 306: HttpStatusCategory.Redirect;
|
|
573
|
+
readonly 307: HttpStatusCategory.Redirect;
|
|
574
|
+
readonly 308: HttpStatusCategory.Redirect;
|
|
575
|
+
readonly 400: HttpStatusCategory.ClientError;
|
|
576
|
+
readonly 401: HttpStatusCategory.ClientError;
|
|
577
|
+
readonly 402: HttpStatusCategory.ClientError;
|
|
578
|
+
readonly 403: HttpStatusCategory.ClientError;
|
|
579
|
+
readonly 404: HttpStatusCategory.ClientError;
|
|
580
|
+
readonly 405: HttpStatusCategory.ClientError;
|
|
581
|
+
readonly 406: HttpStatusCategory.ClientError;
|
|
582
|
+
readonly 407: HttpStatusCategory.ClientError;
|
|
583
|
+
readonly 408: HttpStatusCategory.ClientError;
|
|
584
|
+
readonly 409: HttpStatusCategory.ClientError;
|
|
585
|
+
readonly 410: HttpStatusCategory.ClientError;
|
|
586
|
+
readonly 411: HttpStatusCategory.ClientError;
|
|
587
|
+
readonly 412: HttpStatusCategory.ClientError;
|
|
588
|
+
readonly 413: HttpStatusCategory.ClientError;
|
|
589
|
+
readonly 414: HttpStatusCategory.ClientError;
|
|
590
|
+
readonly 415: HttpStatusCategory.ClientError;
|
|
591
|
+
readonly 416: HttpStatusCategory.ClientError;
|
|
592
|
+
readonly 417: HttpStatusCategory.ClientError;
|
|
593
|
+
readonly 418: HttpStatusCategory.ClientError;
|
|
594
|
+
readonly 421: HttpStatusCategory.ClientError;
|
|
595
|
+
readonly 422: HttpStatusCategory.ClientError;
|
|
596
|
+
readonly 423: HttpStatusCategory.ClientError;
|
|
597
|
+
readonly 424: HttpStatusCategory.ClientError;
|
|
598
|
+
readonly 425: HttpStatusCategory.ClientError;
|
|
599
|
+
readonly 426: HttpStatusCategory.ClientError;
|
|
600
|
+
readonly 428: HttpStatusCategory.ClientError;
|
|
601
|
+
readonly 429: HttpStatusCategory.ClientError;
|
|
602
|
+
readonly 431: HttpStatusCategory.ClientError;
|
|
603
|
+
readonly 451: HttpStatusCategory.ClientError;
|
|
604
|
+
readonly 500: HttpStatusCategory.ServerError;
|
|
605
|
+
readonly 501: HttpStatusCategory.ServerError;
|
|
606
|
+
readonly 502: HttpStatusCategory.ServerError;
|
|
607
|
+
readonly 503: HttpStatusCategory.ServerError;
|
|
608
|
+
readonly 504: HttpStatusCategory.ServerError;
|
|
609
|
+
readonly 505: HttpStatusCategory.ServerError;
|
|
610
|
+
readonly 506: HttpStatusCategory.ServerError;
|
|
611
|
+
readonly 507: HttpStatusCategory.ServerError;
|
|
612
|
+
readonly 508: HttpStatusCategory.ServerError;
|
|
613
|
+
readonly 510: HttpStatusCategory.ServerError;
|
|
614
|
+
readonly 511: HttpStatusCategory.ServerError;
|
|
615
|
+
};
|
|
501
616
|
/**
|
|
502
617
|
* All standardized HTTP status codes grouped into their respective categories.
|
|
503
618
|
*
|
|
@@ -506,11 +621,11 @@ export declare enum HttpStatusCategory {
|
|
|
506
621
|
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
507
622
|
*/
|
|
508
623
|
export declare const httpStatusByCategory: {
|
|
509
|
-
readonly information:
|
|
510
|
-
readonly success:
|
|
511
|
-
readonly redirect:
|
|
512
|
-
readonly clientError:
|
|
513
|
-
readonly serverError:
|
|
624
|
+
readonly information: [HttpStatus.Continue, HttpStatus.SwitchingProtocols, HttpStatus.Processing, HttpStatus.EarlyHints];
|
|
625
|
+
readonly success: [HttpStatus.Ok, HttpStatus.Created, HttpStatus.Accepted, HttpStatus.NonAuthoritativeInformation, HttpStatus.NoContent, HttpStatus.ResetContent, HttpStatus.PartialContent, HttpStatus.MultiStatus, HttpStatus.AlreadyReported, HttpStatus.ImUsed];
|
|
626
|
+
readonly redirect: [HttpStatus.MultipleChoices, HttpStatus.MovedPermanently, HttpStatus.Found, HttpStatus.SeeOther, HttpStatus.NotModified, HttpStatus.UseProxy, HttpStatus.Unused, HttpStatus.TemporaryRedirect, HttpStatus.PermanentRedirect];
|
|
627
|
+
readonly clientError: [HttpStatus.BadRequest, HttpStatus.Unauthorized, HttpStatus.PaymentRequired, HttpStatus.Forbidden, HttpStatus.NotFound, HttpStatus.MethodNotAllowed, HttpStatus.NotAcceptable, HttpStatus.ProxyAuthenticationRequired, HttpStatus.RequestTimeout, HttpStatus.Conflict, HttpStatus.Gone, HttpStatus.LengthRequired, HttpStatus.PreconditionFailed, HttpStatus.PayloadTooLarge, HttpStatus.UriTooLong, HttpStatus.UnsupportedMediaType, HttpStatus.RangeNotSatisfiable, HttpStatus.ExpectationFailed, HttpStatus.ImATeapot, HttpStatus.MisdirectedRequest, HttpStatus.UnprocessableContent, HttpStatus.Locked, HttpStatus.FailedDependency, HttpStatus.TooEarly, HttpStatus.UpgradeRequired, HttpStatus.PreconditionRequired, HttpStatus.TooManyRequests, HttpStatus.RequestHeaderFieldsTooLarge, HttpStatus.UnavailableForLegalReasons];
|
|
628
|
+
readonly serverError: [HttpStatus.InternalServerError, HttpStatus.NotImplemented, HttpStatus.BadGateway, HttpStatus.ServiceUnavailable, HttpStatus.GatewayTimeout, HttpStatus.HttpVersionNotSupported, HttpStatus.VariantAlsoNegotiates, HttpStatus.InsufficientStorage, HttpStatus.LoopDetected, HttpStatus.NotExtended, HttpStatus.NetworkAuthenticationRequired];
|
|
514
629
|
};
|
|
515
630
|
/**
|
|
516
631
|
* All possible HTTP status codes for the given {@link HttpStatusCategory}.
|
|
@@ -499,6 +499,100 @@ export var HttpStatusCategory;
|
|
|
499
499
|
HttpStatusCategory["ClientError"] = "clientError";
|
|
500
500
|
HttpStatusCategory["ServerError"] = "serverError";
|
|
501
501
|
})(HttpStatusCategory || (HttpStatusCategory = {}));
|
|
502
|
+
/**
|
|
503
|
+
* All {@link HttpStatusCategory} entries that indicate a failed response as a runtime value that can
|
|
504
|
+
* be used to check actual response statuses.
|
|
505
|
+
*
|
|
506
|
+
* @category HTTP
|
|
507
|
+
* @category Package : @augment-vir/common
|
|
508
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
509
|
+
*/
|
|
510
|
+
export const errorHttpStatusCategories = [
|
|
511
|
+
HttpStatusCategory.ClientError,
|
|
512
|
+
HttpStatusCategory.ServerError,
|
|
513
|
+
];
|
|
514
|
+
/**
|
|
515
|
+
* Checks if the given HTTP status is an error status. Type guards the input.
|
|
516
|
+
*
|
|
517
|
+
* @category HTTP
|
|
518
|
+
* @category Package : @augment-vir/common
|
|
519
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
520
|
+
*/
|
|
521
|
+
export function isErrorHttpStatus(input) {
|
|
522
|
+
return errorHttpStatusCategories.includes(httpStatusToCategory[input]);
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* All standardized HTTP statuses mapped to their respective category.
|
|
526
|
+
*
|
|
527
|
+
* @category HTTP
|
|
528
|
+
* @category Package : @augment-vir/common
|
|
529
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
530
|
+
*/
|
|
531
|
+
export const httpStatusToCategory = {
|
|
532
|
+
[HttpStatus.Continue]: HttpStatusCategory.Information,
|
|
533
|
+
[HttpStatus.SwitchingProtocols]: HttpStatusCategory.Information,
|
|
534
|
+
[HttpStatus.Processing]: HttpStatusCategory.Information,
|
|
535
|
+
[HttpStatus.EarlyHints]: HttpStatusCategory.Information,
|
|
536
|
+
[HttpStatus.Ok]: HttpStatusCategory.Success,
|
|
537
|
+
[HttpStatus.Created]: HttpStatusCategory.Success,
|
|
538
|
+
[HttpStatus.Accepted]: HttpStatusCategory.Success,
|
|
539
|
+
[HttpStatus.NonAuthoritativeInformation]: HttpStatusCategory.Success,
|
|
540
|
+
[HttpStatus.NoContent]: HttpStatusCategory.Success,
|
|
541
|
+
[HttpStatus.ResetContent]: HttpStatusCategory.Success,
|
|
542
|
+
[HttpStatus.PartialContent]: HttpStatusCategory.Success,
|
|
543
|
+
[HttpStatus.MultiStatus]: HttpStatusCategory.Success,
|
|
544
|
+
[HttpStatus.AlreadyReported]: HttpStatusCategory.Success,
|
|
545
|
+
[HttpStatus.ImUsed]: HttpStatusCategory.Success,
|
|
546
|
+
[HttpStatus.MultipleChoices]: HttpStatusCategory.Redirect,
|
|
547
|
+
[HttpStatus.MovedPermanently]: HttpStatusCategory.Redirect,
|
|
548
|
+
[HttpStatus.Found]: HttpStatusCategory.Redirect,
|
|
549
|
+
[HttpStatus.SeeOther]: HttpStatusCategory.Redirect,
|
|
550
|
+
[HttpStatus.NotModified]: HttpStatusCategory.Redirect,
|
|
551
|
+
[HttpStatus.UseProxy]: HttpStatusCategory.Redirect,
|
|
552
|
+
[HttpStatus.Unused]: HttpStatusCategory.Redirect,
|
|
553
|
+
[HttpStatus.TemporaryRedirect]: HttpStatusCategory.Redirect,
|
|
554
|
+
[HttpStatus.PermanentRedirect]: HttpStatusCategory.Redirect,
|
|
555
|
+
[HttpStatus.BadRequest]: HttpStatusCategory.ClientError,
|
|
556
|
+
[HttpStatus.Unauthorized]: HttpStatusCategory.ClientError,
|
|
557
|
+
[HttpStatus.PaymentRequired]: HttpStatusCategory.ClientError,
|
|
558
|
+
[HttpStatus.Forbidden]: HttpStatusCategory.ClientError,
|
|
559
|
+
[HttpStatus.NotFound]: HttpStatusCategory.ClientError,
|
|
560
|
+
[HttpStatus.MethodNotAllowed]: HttpStatusCategory.ClientError,
|
|
561
|
+
[HttpStatus.NotAcceptable]: HttpStatusCategory.ClientError,
|
|
562
|
+
[HttpStatus.ProxyAuthenticationRequired]: HttpStatusCategory.ClientError,
|
|
563
|
+
[HttpStatus.RequestTimeout]: HttpStatusCategory.ClientError,
|
|
564
|
+
[HttpStatus.Conflict]: HttpStatusCategory.ClientError,
|
|
565
|
+
[HttpStatus.Gone]: HttpStatusCategory.ClientError,
|
|
566
|
+
[HttpStatus.LengthRequired]: HttpStatusCategory.ClientError,
|
|
567
|
+
[HttpStatus.PreconditionFailed]: HttpStatusCategory.ClientError,
|
|
568
|
+
[HttpStatus.PayloadTooLarge]: HttpStatusCategory.ClientError,
|
|
569
|
+
[HttpStatus.UriTooLong]: HttpStatusCategory.ClientError,
|
|
570
|
+
[HttpStatus.UnsupportedMediaType]: HttpStatusCategory.ClientError,
|
|
571
|
+
[HttpStatus.RangeNotSatisfiable]: HttpStatusCategory.ClientError,
|
|
572
|
+
[HttpStatus.ExpectationFailed]: HttpStatusCategory.ClientError,
|
|
573
|
+
[HttpStatus.ImATeapot]: HttpStatusCategory.ClientError,
|
|
574
|
+
[HttpStatus.MisdirectedRequest]: HttpStatusCategory.ClientError,
|
|
575
|
+
[HttpStatus.UnprocessableContent]: HttpStatusCategory.ClientError,
|
|
576
|
+
[HttpStatus.Locked]: HttpStatusCategory.ClientError,
|
|
577
|
+
[HttpStatus.FailedDependency]: HttpStatusCategory.ClientError,
|
|
578
|
+
[HttpStatus.TooEarly]: HttpStatusCategory.ClientError,
|
|
579
|
+
[HttpStatus.UpgradeRequired]: HttpStatusCategory.ClientError,
|
|
580
|
+
[HttpStatus.PreconditionRequired]: HttpStatusCategory.ClientError,
|
|
581
|
+
[HttpStatus.TooManyRequests]: HttpStatusCategory.ClientError,
|
|
582
|
+
[HttpStatus.RequestHeaderFieldsTooLarge]: HttpStatusCategory.ClientError,
|
|
583
|
+
[HttpStatus.UnavailableForLegalReasons]: HttpStatusCategory.ClientError,
|
|
584
|
+
[HttpStatus.InternalServerError]: HttpStatusCategory.ServerError,
|
|
585
|
+
[HttpStatus.NotImplemented]: HttpStatusCategory.ServerError,
|
|
586
|
+
[HttpStatus.BadGateway]: HttpStatusCategory.ServerError,
|
|
587
|
+
[HttpStatus.ServiceUnavailable]: HttpStatusCategory.ServerError,
|
|
588
|
+
[HttpStatus.GatewayTimeout]: HttpStatusCategory.ServerError,
|
|
589
|
+
[HttpStatus.HttpVersionNotSupported]: HttpStatusCategory.ServerError,
|
|
590
|
+
[HttpStatus.VariantAlsoNegotiates]: HttpStatusCategory.ServerError,
|
|
591
|
+
[HttpStatus.InsufficientStorage]: HttpStatusCategory.ServerError,
|
|
592
|
+
[HttpStatus.LoopDetected]: HttpStatusCategory.ServerError,
|
|
593
|
+
[HttpStatus.NotExtended]: HttpStatusCategory.ServerError,
|
|
594
|
+
[HttpStatus.NetworkAuthenticationRequired]: HttpStatusCategory.ServerError,
|
|
595
|
+
};
|
|
502
596
|
/**
|
|
503
597
|
* All standardized HTTP status codes grouped into their respective categories.
|
|
504
598
|
*
|