//#region src/types/http-well-known.d.ts /** * @file http-well-known.ts * * Well-known HTTP header names and MIME types that power IntelliSense autocomplete * throughout the library — without hardcoding anything unrelated to the Fetch API. * * The `string & {}` intersection is the key technique: it keeps the type open * (any string still compiles) while causing IDEs to display the specific literals * as autocomplete suggestions. * * The {@link HeadersWithSuggestions} type mirrors the three object shapes that the * native `fetch()` function accepts (`RequestInit['headers']`), augmenting only the * plain-object form with known header-name suggestions. */ /** * Well-known HTTP/1.1 and HTTP/2 request header names (RFC 7231, RFC 7235, * and common de-facto standards). * * Uses `string & {}` so the union stays open — any custom header still compiles * and receives no squiggles, while IDEs surface these names as suggestions. */ type KnownRequestHeader = 'Accept' | 'Accept-Charset' | 'Accept-Encoding' | 'Accept-Language' | 'Accept-Ranges' | 'Authorization' | 'Cookie' | 'Origin' | 'Proxy-Authorization' | 'X-Api-Key' | 'X-Auth-Token' | 'X-CSRF-Token' | 'Cache-Control' | 'If-Match' | 'If-Modified-Since' | 'If-None-Match' | 'If-Range' | 'If-Unmodified-Since' | 'Pragma' | 'Connection' | 'Host' | 'Upgrade' | 'Via' | 'Content-Encoding' | 'Content-Language' | 'Content-Length' | 'Content-MD5' | 'Content-Range' | 'Content-Type' | 'Baggage' | 'Traceparent' | 'Tracestate' | 'X-Correlation-ID' | 'X-Forwarded-For' | 'X-Forwarded-Host' | 'X-Forwarded-Proto' | 'X-Request-ID' | 'X-Requested-With' | 'Date' | 'Expect' | 'Max-Forwards' | 'Range' | 'Referer' | 'TE' | 'Trailer' | 'Transfer-Encoding' | 'User-Agent' | (string & {}); /** * A plain-object header map that mirrors `Record` (one of the three * shapes accepted by `fetch()`) but adds autocomplete for well-known header names. * * The `& Record` intersection is what makes this type structurally * compatible with the Fetch API's `HeadersInit` while still surfacing known names * as IntelliSense suggestions. * * @example * const headers: HeadersRecord = { * 'Content-Type': 'application/json', // suggested by IntelliSense * 'X-My-Header': 'custom-value', // still compiles — any key is valid * }; */ type HeadersRecord = { [K in KnownRequestHeader]?: string } & Record; /** * Drop-in replacement for `RequestInit['headers']` / `HeadersInit` that adds * IntelliSense suggestions for common header names on the plain-object form. * * All three shapes the native `fetch()` function accepts are preserved: * - A `Headers` instance * - An array of `[name, value]` tuples * - A plain object (augmented with known-header-name suggestions) * * @example * // Object form — IntelliSense suggests header names as you type * const headers: HeadersWithSuggestions = { * Authorization: 'Bearer eyJhbGc…', * 'Content-Type': 'application/json', * Accept: 'application/json', * }; * * // Still compatible with the Headers constructor and tuple arrays * const h2: HeadersWithSuggestions = new Headers({ Authorization: 'Bearer …' }); * const h3: HeadersWithSuggestions = [['Authorization', 'Bearer …']]; */ type HeadersWithSuggestions = Headers | [string, string][] | HeadersRecord; /** * Common MIME types for `Content-Type` and `Accept` headers. * * Uses `string & {}` so any MIME type string compiles while IDEs show suggestions. * * @example * const contentType: MimeType = 'application/json'; // suggested * const custom: MimeType = 'application/vnd.my-api+json'; // still compiles */ type MimeType = 'application/json' | 'application/ld+json' | 'application/octet-stream' | 'application/pdf' | 'application/x-www-form-urlencoded' | 'application/xml' | 'application/zip' | 'image/avif' | 'image/gif' | 'image/jpeg' | 'image/png' | 'image/svg+xml' | 'image/webp' | 'multipart/form-data' | 'text/css' | 'text/csv' | 'text/html' | 'text/javascript' | 'text/plain' | 'text/xml' | (string & {}); //#endregion export { MimeType as i, HeadersWithSuggestions as n, KnownRequestHeader as r, HeadersRecord as t }; //# sourceMappingURL=http-well-known-BK9MGKQf.d.ts.map