import type { _InternalHttpMethods, HttpMethods } from '../types.ts'; /** * Validation function type for PropertyStore. * * @template T - The property type */ export type PropertyValidateFn = (value: T, method?: _InternalHttpMethods) => void; /** * Method-specific overrides type for PropertyStore. * * @template T - The property type */ export type MethodOverrides = Partial>>; /** * PropertyStore constructor options. * * @template T - The property type */ export interface PropertyStoreOptions { /** Default values applied to all requests */ defaults?: T | undefined; /** Method-specific overrides (e.g., POST has different headers than GET) */ methodOverrides?: Partial> | undefined; /** Validation function called when values are set */ validate?: PropertyValidateFn | undefined; } /** * Generic store for request properties (headers, params). * * Handles CRUD operations, method-specific overrides, and merging * for requests. This class is used internally by FetchEngine * to manage both headers and params with a unified API. * * Properties are resolved in order: * 1. Instance defaults * 2. Method-specific overrides * 3. Request-level overrides * * @template T - The property type (e.g., Record) * * @example * ```typescript * const headers = new PropertyStore({ * defaults: { 'Content-Type': 'application/json' }, * methodOverrides: { * POST: { 'X-Custom': 'post-only' } * } * }); * * // Add header globally * headers.set('Authorization', 'Bearer token'); * * // Add header for specific method * headers.set('X-Request-ID', 'abc', 'POST'); * * // Resolve headers for a request * const resolved = headers.resolve('POST', { 'X-Override': 'value' }); * ``` */ export declare class PropertyStore> { constructor(options?: PropertyStoreOptions); /** * Set a property value globally or for a specific method. * * @param key - Property key * @param value - Property value * @param method - Optional HTTP method for method-specific override * * @example * headers.set('Authorization', 'Bearer token'); * headers.set('X-Custom', 'value', 'POST'); */ set(key: string, value: unknown, method?: HttpMethods): void; /** * Set multiple property values globally or for a specific method. * * @param values - Object with key-value pairs to set * @param method - Optional HTTP method for method-specific overrides * * @example * headers.set({ 'Authorization': 'Bearer token', 'X-API-Key': 'abc' }); * headers.set({ 'X-Custom': 'value' }, 'POST'); */ set(values: Partial, method?: HttpMethods): void; /** * Remove a property globally or for a specific method. * * @param key - Property key to remove * @param method - Optional HTTP method for method-specific removal * * @example * headers.remove('Authorization'); * headers.remove('X-Custom', 'POST'); */ remove(key: string, method?: HttpMethods): void; /** * Remove multiple properties globally or for a specific method. * * @param keys - Array of property keys to remove * @param method - Optional HTTP method for method-specific removal * * @example * headers.remove(['Authorization', 'X-API-Key']); * headers.remove(['X-Custom', 'X-Other'], 'POST'); */ remove(keys: string[], method?: HttpMethods): void; /** * Check if a property exists globally or for a specific method. * * @param key - Property key to check * @param method - Optional HTTP method to check method-specific value * @returns True if the property exists * * @example * if (headers.has('Authorization')) { * console.log('Auth header is set'); * } */ has(key: string, method?: HttpMethods): boolean; /** * Get the default values (without method overrides). * * @returns Clone of the default values * * @example * const defaultHeaders = headers.defaults; */ get defaults(): T; /** * Get all values including method overrides. * * Returns an object with 'default' key for defaults and * method names as keys for method-specific overrides. * * @returns Object with all property values * * @example * const all = headers.all; * // { default: { Authorization: '...' }, POST: { 'X-Custom': '...' } } */ get all(): { default: T; } & Record>; /** * Get method-specific overrides only (not merged with defaults). * * @param method - HTTP method * @returns Method-specific overrides or empty object * * @example * const postHeaders = headers.forMethod('POST'); */ forMethod(method: HttpMethods): Partial; /** * Resolve the final property values for a specific method. * * Merges in order: defaults → method overrides → request overrides. * * @param method - HTTP method * @param requestOverrides - Request-level overrides (highest priority) * @returns Merged property values * * @example * const headers = this.headers.resolve('POST', { 'X-Request-ID': '123' }); */ resolve(method: HttpMethods, requestOverrides?: Partial): T; }