/** * Copyright 2026 - present Nazmul Hassan * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { nr as LooseLiteral } from "./index-Dx3yeNwR.mjs"; import { n as HTTP_STATUS_DATA } from "./constants-DNIXgBkz.mjs"; //#region src/types/http-status.d.ts /** Mapped type of HTTP status entries */ type $HttpStatusMap = (typeof HTTP_STATUS_DATA)[number]; /** HTTP status name variants: `name` or `readableName` */ type $StatusNameVar = 'name' | 'readableName'; /** * Categories of HTTP status codes: `"informational"`, `"success"`, `"redirection"`, `"clientError`" or `"serverError"` */ type StatusCategory = $HttpStatusMap['category']; /** - Extracts standard HTTP status codes by the given `Category` name. Defaults to all {@link StatusCategory categories}. */ type HttpStatusCode = $HttpStatusMap extends (infer Target) ? Target extends $HttpStatusMap ? Target['category'] extends Category ? Target['code'] : never : never : never; /** Standard HTTP Status Code, e.g. `404`, `500` etc. + any number */ type StatusCode = LooseLiteral; /** * - Extracts standard HTTP status names filtered by {@link $StatusNameVar variant} and {@link StatusCategory category}. * - Defaults to all `variants` and `categories`. * * @remarks * - `Name` selects either the `name` (CONSTANT_CASE) or `readableName` (Title Case). * - `Category` restricts results to the chosen HTTP status {@link StatusCategory category}. * - Produces a union of all matching literal status name values. */ type HttpStatusName = $HttpStatusMap extends (infer Target) ? Target extends $HttpStatusMap ? Target['category'] extends Category ? Target[Name] : never : never : never; /** Standard HTTP status name in `CONSTANT_CASE`, e.g. `"INTERNAL_SERVER_ERROR"` + any string */ type StatusName = LooseLiteral; /** HTTP status name (`CONSTANT_CASE`) in {@link StatusEntry} interface */ type EntryStatusName = LooseLiteral>; /** HTTP status name (`Title Case`) in {@link StatusEntry} interface */ type EntryReadableName = LooseLiteral>; /** * Shape of an HTTP status entry. */ interface StatusEntry { /** HTTP Status Code, e.g. `404`, `500` etc. */ code: StatusCode; /** HTTP status name in `CONSTANT_CASE`, e.g. `"NOT_FOUND"`, `"INTERNAL_SERVER_ERROR"` */ name: EntryStatusName; /** HTTP status name in `Title Case` form, e.g. `"Not Found"`, `"Internal Server Error"` */ readableName: EntryReadableName; /** Link to full `MDN` Docs if available */ link?: string; /** Short message, Can override using `httpStatus.setMessage` method */ message: string; /** A brief description of the status code */ description: string; /** The type of HTTP Status: `"informational"`, `"success"`, `"redirection"`, `"clientError`" or `"serverError"` */ category: StatusCategory; } //#endregion export { HttpStatusCode as a, StatusCode as c, EntryStatusName as i, StatusEntry as l, $StatusNameVar as n, HttpStatusName as o, EntryReadableName as r, StatusCategory as s, $HttpStatusMap as t, StatusName as u };