/** * Event Namespace Constants * Centralized constants for all event namespaces */ /** * Main event namespaces for the API package */ export declare const EVENT_NAMESPACES: { readonly HEADERS: "headers"; readonly NETWORK: "network"; readonly ERRORS: "errors"; readonly DEBUG: "debug"; readonly CONFIG: "config"; readonly PERFORMANCE: "performance"; readonly CLIENT: "client"; readonly CACHE: "cache"; readonly POLLING: "polling"; readonly REQUEST: "request"; readonly REVALIDATION: "revalidation"; readonly EVENT_MANAGER: "eventManager"; }; /** * Header-specific event keys */ export declare const HEADER_EVENTS: { readonly CHANGED: "headers:changed"; readonly ENRICHED: "headers:enriched"; readonly CONFLICT: "headers:conflict"; readonly OVERRIDE: "headers:override"; readonly TRACKED: "headers:tracked"; readonly MERGED: "headers:merged"; readonly FILTERED: "headers:filtered"; readonly VALIDATED: "headers:validated"; readonly CACHED: "headers:cached"; readonly CACHE_HIT: "headers:cache:hit"; readonly CACHE_MISS: "headers:cache:miss"; readonly ANY: "headers:*"; }; /** * Network-specific event keys */ export declare const NETWORK_EVENTS: { readonly QUALITY_CHANGE: "network:quality:changed"; readonly INFO_UPDATE: "network:info-update"; readonly CONFIG_OVERRIDE: "network:config:override"; readonly CONFIG_RESTORED: "network:config:restored"; readonly OVERRIDE_CHANGE: "network:override-change"; readonly PRESET_APPLIED: "network:preset-applied"; readonly PRESET_CHANGED: "network:preset:changed"; readonly HINTS_UPDATED: "network:hints:updated"; readonly AUTO_DETECTION: "network:auto:detection"; readonly MANUAL_UPDATE: "network:manual:update"; readonly ANY: "network:*"; }; /** * Error-specific event keys */ export declare const ERROR_EVENTS: { readonly NETWORK_ERROR: "errors:network"; readonly VALIDATION_ERROR: "errors:validation"; readonly AUTHENTICATION_ERROR: "errors:authentication"; readonly AUTHORIZATION_ERROR: "errors:authorization"; readonly RATE_LIMIT_ERROR: "errors:rate-limit"; readonly SERVER_ERROR: "errors:server"; readonly CLIENT_ERROR: "errors:client"; readonly TIMEOUT_ERROR: "errors:timeout"; readonly CONFLICT_ERROR: "errors:conflict"; readonly CACHE_ERROR: "errors:cache"; readonly HEADERS_ERROR: "errors:headers"; readonly RETRY_ERROR: "errors:retry"; readonly STRATEGY_ERROR: "errors:strategy"; readonly REGIONAL_ERROR: "errors:regional"; readonly NOT_FOUND_ERROR: "errors:not-found"; readonly EXTERNAL_SERVICE_ERROR: "errors:external-service"; readonly UNKNOWN_ERROR: "errors:unknown"; readonly GENERIC_ERROR: "errors:generic"; readonly ANY: "errors:*"; }; /** * Handler scopes for different levels of event handlers * These prefixes are used for registering handlers at different priority levels * Can be used for any type of handler (error, request, response, debug, etc.) * * Priority order (lowest to highest): * 1. GLOBAL - Set via setGlobalErrorHandlers(), persists across all instances * 2. CONFIG - Set via setGlobalConfig({ errorHandlers }), global configuration * 3. CLIENT - Set via createApiClient({ errorHandlers }), instance-specific * 4. REQUEST/TEMPORARY - Set per-request or via updateConfig(), highest priority * * Usage: * - GLOBAL: For app-wide handlers that should always run (e.g., logging) * - CONFIG: For environment-specific handlers (e.g., dev vs prod) * - CLIENT: For instance-specific handlers (e.g., per-service client) * - REQUEST/TEMPORARY: For request-specific or runtime updates * * Note: REQUEST and TEMPORARY are aliases - both use 'request' scope * * Examples of namespaced handlers: * - Error handlers: 'global:error', 'config:error', 'client:error' * - Debug handlers: 'global:debug', 'config:debug', 'client:debug' * - Request handlers: 'global:request', 'config:request', 'client:request' */ export declare const HANDLER_SCOPES: { readonly GLOBAL: "global"; readonly CONFIG: "config"; readonly CLIENT: "client"; readonly TEMPORARY: "request"; readonly REQUEST: "request"; }; /** * Core event scopes (excluding aliases) * These are the actual scope values used by the event system */ export declare const EVENT_SCOPES: readonly ["global", "config", "client", "request"]; /** * All event scopes including 'temporary' alias * Used in APIs where 'temporary' provides semantic clarity */ export declare const EVENT_SCOPES_WITH_TEMPORARY: readonly ["global", "config", "client", "request", "temporary"]; /** * Type for core event scopes */ export type EventScope = (typeof EVENT_SCOPES)[number]; /** * Type for event scopes including 'temporary' */ export type EventScopeWithTemporary = (typeof EVENT_SCOPES)[number] | 'temporary'; /** * Create handler namespace for a specific event type and scope * Example: createHandlerNamespace('error', 'GLOBAL') => 'global:error' * Example: createHandlerNamespace('debug', 'CLIENT') => 'client:debug' * * @param eventType - The type of event (error, debug, request, response, etc.) * @param scope - The scope level (GLOBAL, CONFIG, CLIENT, REQUEST, TEMPORARY) * @returns The namespaced string for handler registration */ export declare function createHandlerNamespace(eventType: string, scope: keyof typeof HANDLER_SCOPES): string; /** * Debug-specific event keys */ export declare const DEBUG_EVENTS: { readonly CONFIG_CONFLICT: "debug:config-conflict"; readonly CONFIG_CHANGE: "debug:config-change"; readonly HEADERS_TRACKED: "debug:headers-tracked"; readonly NETWORK_OVERRIDE: "debug:network-override"; readonly NETWORK_STATE_CHANGED: "debug:network-state-changed"; readonly NETWORK_DATA_CLEARED: "debug:network-data-cleared"; readonly DEBUG_INFO: "debug:info"; readonly PERFORMANCE_IMPACT: "debug:performance-impact"; readonly MONITORING_ALERT: "debug:monitoring-alert"; readonly CONFIG_TRACKED: "debug:config-tracked"; readonly CONFLICTS_BATCH: "debug:conflicts-batch"; readonly EVENT_OPERATION: "debug:event-operation"; readonly ANY: "debug:*"; }; /** * Configuration sources - where config updates originate from */ export declare const EVENTS_CONFIG_SOURCES: { readonly GLOBAL: "global"; readonly CREATE_API_CLIENT: "createApiClient"; readonly UPDATE_CONFIG: "updateConfig"; readonly MANUAL: "manual"; readonly ENVIRONMENT: "environment"; readonly PRESET: "preset"; readonly NETWORK_AWARE: "networkAware"; readonly ADAPTIVE: "adaptive"; }; export type EventsConfigSource = (typeof EVENTS_CONFIG_SOURCES)[keyof typeof EVENTS_CONFIG_SOURCES]; /** * Configuration-specific event keys */ export declare const CONFIG_EVENTS: { readonly GLOBAL_UPDATED: "config:global-updated"; readonly GLOBAL_RESET: "config:global-reset"; readonly ENVIRONMENT_CONFIGURED: "config:environment-configured"; readonly PRESET_APPLIED: "config:preset-applied"; readonly ANY: "config:*"; }; /** * Performance-specific event keys */ export declare const PERFORMANCE_EVENTS: { readonly REQUEST_START: "performance:request-start"; readonly REQUEST_COMPLETE: "performance:request-complete"; readonly RETRY: "performance:retry"; readonly THRESHOLD_EXCEEDED: "performance:threshold-exceeded"; readonly OPTIMIZATION_APPLIED: "performance:optimization-applied"; readonly METRIC_RECORDED: "performance:metric-recorded"; readonly ANY: "performance:*"; }; /** * Client-specific event keys */ export declare const CLIENT_EVENTS: { readonly CONFLICT: "client:conflict"; readonly DEBUG: "client:debug"; readonly CREATED: "client:created"; readonly ANY: "client:*"; }; /** * Cache-specific event keys */ export declare const CACHE_EVENTS: { readonly HIT: "cache:hit"; readonly MISS: "cache:miss"; readonly INVALIDATE: "cache:invalidate"; readonly ANY: "cache:*"; }; /** * All event keys combined for easy access */ export declare const ALL_EVENTS: { readonly HIT: "cache:hit"; readonly MISS: "cache:miss"; readonly INVALIDATE: "cache:invalidate"; readonly ANY: "cache:*"; readonly CONFLICT: "client:conflict"; readonly DEBUG: "client:debug"; readonly CREATED: "client:created"; readonly REQUEST_START: "performance:request-start"; readonly REQUEST_COMPLETE: "performance:request-complete"; readonly RETRY: "performance:retry"; readonly THRESHOLD_EXCEEDED: "performance:threshold-exceeded"; readonly OPTIMIZATION_APPLIED: "performance:optimization-applied"; readonly METRIC_RECORDED: "performance:metric-recorded"; readonly GLOBAL_UPDATED: "config:global-updated"; readonly GLOBAL_RESET: "config:global-reset"; readonly ENVIRONMENT_CONFIGURED: "config:environment-configured"; readonly PRESET_APPLIED: "config:preset-applied"; readonly CONFIG_CONFLICT: "debug:config-conflict"; readonly CONFIG_CHANGE: "debug:config-change"; readonly HEADERS_TRACKED: "debug:headers-tracked"; readonly NETWORK_OVERRIDE: "debug:network-override"; readonly NETWORK_STATE_CHANGED: "debug:network-state-changed"; readonly NETWORK_DATA_CLEARED: "debug:network-data-cleared"; readonly DEBUG_INFO: "debug:info"; readonly PERFORMANCE_IMPACT: "debug:performance-impact"; readonly MONITORING_ALERT: "debug:monitoring-alert"; readonly CONFIG_TRACKED: "debug:config-tracked"; readonly CONFLICTS_BATCH: "debug:conflicts-batch"; readonly EVENT_OPERATION: "debug:event-operation"; readonly NETWORK_ERROR: "errors:network"; readonly VALIDATION_ERROR: "errors:validation"; readonly AUTHENTICATION_ERROR: "errors:authentication"; readonly AUTHORIZATION_ERROR: "errors:authorization"; readonly RATE_LIMIT_ERROR: "errors:rate-limit"; readonly SERVER_ERROR: "errors:server"; readonly CLIENT_ERROR: "errors:client"; readonly TIMEOUT_ERROR: "errors:timeout"; readonly CONFLICT_ERROR: "errors:conflict"; readonly CACHE_ERROR: "errors:cache"; readonly HEADERS_ERROR: "errors:headers"; readonly RETRY_ERROR: "errors:retry"; readonly STRATEGY_ERROR: "errors:strategy"; readonly REGIONAL_ERROR: "errors:regional"; readonly NOT_FOUND_ERROR: "errors:not-found"; readonly EXTERNAL_SERVICE_ERROR: "errors:external-service"; readonly UNKNOWN_ERROR: "errors:unknown"; readonly GENERIC_ERROR: "errors:generic"; readonly QUALITY_CHANGE: "network:quality:changed"; readonly INFO_UPDATE: "network:info-update"; readonly CONFIG_OVERRIDE: "network:config:override"; readonly CONFIG_RESTORED: "network:config:restored"; readonly OVERRIDE_CHANGE: "network:override-change"; readonly PRESET_CHANGED: "network:preset:changed"; readonly HINTS_UPDATED: "network:hints:updated"; readonly AUTO_DETECTION: "network:auto:detection"; readonly MANUAL_UPDATE: "network:manual:update"; readonly CHANGED: "headers:changed"; readonly ENRICHED: "headers:enriched"; readonly OVERRIDE: "headers:override"; readonly TRACKED: "headers:tracked"; readonly MERGED: "headers:merged"; readonly FILTERED: "headers:filtered"; readonly VALIDATED: "headers:validated"; readonly CACHED: "headers:cached"; readonly CACHE_HIT: "headers:cache:hit"; readonly CACHE_MISS: "headers:cache:miss"; }; /** * Helper function to create namespaced event key */ export declare function createEventKey(namespace: keyof typeof EVENT_NAMESPACES, event: string): string; /** * Alias for ERROR_EVENTS for backwards compatibility */ export declare const ERROR_EVENT_TYPES: { readonly NETWORK_ERROR: "errors:network"; readonly VALIDATION_ERROR: "errors:validation"; readonly AUTHENTICATION_ERROR: "errors:authentication"; readonly AUTHORIZATION_ERROR: "errors:authorization"; readonly RATE_LIMIT_ERROR: "errors:rate-limit"; readonly SERVER_ERROR: "errors:server"; readonly CLIENT_ERROR: "errors:client"; readonly TIMEOUT_ERROR: "errors:timeout"; readonly CONFLICT_ERROR: "errors:conflict"; readonly CACHE_ERROR: "errors:cache"; readonly HEADERS_ERROR: "errors:headers"; readonly RETRY_ERROR: "errors:retry"; readonly STRATEGY_ERROR: "errors:strategy"; readonly REGIONAL_ERROR: "errors:regional"; readonly NOT_FOUND_ERROR: "errors:not-found"; readonly EXTERNAL_SERVICE_ERROR: "errors:external-service"; readonly UNKNOWN_ERROR: "errors:unknown"; readonly GENERIC_ERROR: "errors:generic"; readonly ANY: "errors:*"; }; /** * Handler namespace creators for common event types * These provide convenient functions to create properly namespaced handlers * * @example * ```typescript * // For error handlers at different scopes: * const globalErrorNS = createErrorHandlerNamespace('GLOBAL'); // 'global:error' * const clientErrorNS = createErrorHandlerNamespace('CLIENT'); // 'client:error' * * // For debug handlers at different scopes: * const globalDebugNS = createDebugHandlerNamespace('GLOBAL'); // 'global:debug' * const clientDebugNS = createDebugHandlerNamespace('CLIENT'); // 'client:debug' * ``` */ export declare const createErrorHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createDebugHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createRequestHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createResponseHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createRetryHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createHeadersHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createNetworkHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createCacheHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createConfigHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createPerformanceHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createClientHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createPollingHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; export declare const createRevalidationHandlerNamespace: (scope: keyof typeof HANDLER_SCOPES) => string; /** * Pre-created handler namespaces for all event types and scopes * These provide ready-to-use namespaces for handler registration */ /** * Configuration update strategy - controls WHERE configuration is applied * - 'merge': Merges with existing config at CLIENT scope * - 'replace': Replaces existing config at CLIENT scope * - 'temporary': Applies at REQUEST/TEMPORARY scope (highest priority) */ export type ConfigUpdateStrategy = 'merge' | 'replace' | 'temporary'; /** * Handler strategy - controls how handlers are registered and merged * - 'merge': Merge handlers with existing ones (chain them) * - 'replace': Replace existing handlers entirely * - 'prepend': Add new handlers before existing ones * - 'append': Add new handlers after existing ones * - 'temporary': Apply as temporary handlers (highest priority, can be reverted) */ export type HandlerStrategy = 'merge' | 'replace' | 'append' | 'prepend' | 'temporary'; export declare const HANDLER_NAMESPACES: { readonly ERROR: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly DEBUG: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly HEADERS: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly NETWORK: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly CACHE: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly CONFIG: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly PERFORMANCE: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly CLIENT: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly REQUEST: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly RESPONSE: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly RETRY: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly POLLING: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; readonly REVALIDATION: { readonly GLOBAL: string; readonly CONFIG: string; readonly CLIENT: string; readonly REQUEST: string; readonly TEMPORARY: string; }; }; /** * Type-safe mapping of event type strings to HANDLER_NAMESPACES keys * This ensures TypeScript will error if a new namespace is added without updating the map * * Used for mapping event types (like 'errors', 'headers') to their corresponding * namespace keys in HANDLER_NAMESPACES (like 'ERROR', 'HEADERS') */ export declare const EVENT_TYPE_TO_NAMESPACE_MAP: Record; export type ValidateAllNamespacesAreMapped = typeof EVENT_TYPE_TO_NAMESPACE_MAP extends Record ? T extends keyof typeof HANDLER_NAMESPACES ? keyof typeof HANDLER_NAMESPACES extends T ? true : 'Error: Not all HANDLER_NAMESPACES keys are mapped in EVENT_TYPE_TO_NAMESPACE_MAP' : never : never; /** * Get handler namespace for an event type and scope * Helper function for consistent namespace resolution */ export declare function getHandlerNamespaceForEvent(eventType: string, scope: keyof typeof HANDLER_SCOPES): string; //# sourceMappingURL=namespaces.d.ts.map