import type { FetchEngineCore } from '../engine/types.ts'; import type { HttpMethods, DictAndT } from '../types.ts'; import { PropertyStore } from './store.ts'; /** * Manages HTTP headers for FetchEngine with event emission. * * Wraps PropertyStore with FetchEngine-specific event emission. * Pulls initial headers and validation from engine options. * * @template H - Headers type * * @example * ```typescript * // Access via engine.headers * engine.headers.set('Authorization', 'Bearer token'); * engine.headers.set({ 'X-API-Key': 'abc', 'X-Request-ID': '123' }); * * // Method-specific headers * engine.headers.set('Content-Type', 'application/json', 'POST'); * * // Remove headers * engine.headers.remove('Authorization'); * engine.headers.remove(['X-API-Key', 'X-Request-ID']); * * // Check if header exists * if (engine.headers.has('Authorization')) { ... } * * // Get resolved headers for a request * const headers = engine.headers.resolve('POST', { 'X-Override': 'value' }); * ``` */ export declare class HeadersManager { constructor(engine: FetchEngineCore); /** * Set a header value globally or for a specific method. * * @example * ```typescript * engine.headers.set('Authorization', 'Bearer token'); * engine.headers.set('Content-Type', 'application/json', 'POST'); * ``` */ set(key: string, value: string, method?: HttpMethods): void; /** * Set multiple header values globally or for a specific method. * * @example * ```typescript * engine.headers.set({ Authorization: 'Bearer token', 'X-API-Key': 'abc' }); * engine.headers.set({ 'Content-Type': 'application/json' }, 'POST'); * ``` */ set(headers: Partial>, method?: HttpMethods): void; /** * Remove a header globally or for a specific method. * * @example * ```typescript * engine.headers.remove('Authorization'); * engine.headers.remove('Content-Type', 'POST'); * ``` */ remove(key: string, method?: HttpMethods): void; /** * Remove multiple headers globally or for a specific method. * * @example * ```typescript * engine.headers.remove(['Authorization', 'X-API-Key']); * engine.headers.remove(['Content-Type'], 'POST'); * ``` */ remove(keys: string[], method?: HttpMethods): void; /** * Check if a header exists globally or for a specific method. * * @example * ```typescript * if (engine.headers.has('Authorization')) { * console.log('Auth header is set'); * } * ``` */ has(key: string, method?: HttpMethods): boolean; /** * Resolve the final headers for a specific method. * * Merges in order: defaults → method overrides → request overrides. * * @example * ```typescript * const headers = engine.headers.resolve('POST', { 'X-Request-ID': '123' }); * ``` */ resolve(method: HttpMethods, requestOverrides?: Partial>): DictAndT; /** * Get the default headers (without method overrides). */ get defaults(): DictAndT; /** * Get all headers including method overrides. * * @example * ```typescript * const all = engine.headers.all; * // { default: { Authorization: '...' }, post: { 'Content-Type': '...' } } * ``` */ get all(): { default: DictAndT; } & Record>>; /** * Get method-specific headers only (not merged with defaults). */ forMethod(method: HttpMethods): Partial>; /** * Get the underlying PropertyStore for internal use. * * Exposed for FetchEngineCore compliance. Internal components * (executor, policies) access the store directly for resolution. * * @internal */ get $store(): PropertyStore>; }