/** * Route Configuration Manager * Manages route configurations, validation, and parameter operations * * @module client/managers/RouteConfigManager */ import type { RouteConfig, WebhookDefaults } from '../../types/route.types.js'; import type { ILogger, LoggerOptions, ILoggerAware } from '../../types/logger.types.js'; /** * Configuration options for RouteConfigManager */ export interface RouteConfigManagerOptions extends LoggerOptions { /** Initial routes configuration */ routes?: RouteConfig | RouteConfig[] | Map; /** Default route ID */ defaultRouteId?: string; /** Default webhook configuration values */ webhookDefaults?: WebhookDefaults; } /** * Route Configuration Manager * Manages route configurations storage, validation, and updates * * Responsibilities: * - Store and retrieve route configurations * - Validate route configurations * - Manage default route * - Provide webhook defaults * - Support dot notation for parameter updates */ export declare class RouteConfigManager implements ILoggerAware { private routes; private defaultRouteId?; private webhookDefaults?; private static validator; private static validatorInitPromise; /** Logger instance - mutable to support LoggerBinder.bind() */ logger?: ILogger; /** * Create a new RouteConfigManager instance * @param options - Configuration options */ constructor(options?: RouteConfigManagerOptions); /** * Initialize DataValidator for schema validation * Called automatically on first validation */ private static initValidator; /** * Load routes from various formats * Supports: single config, array, or Map * * @param routes - Routes in any supported format */ private loadRoutes; /** * Set or update a route configuration * Applies webhook defaults if configured * * @param id - Route identifier * @param config - Route configuration */ setRoute(id: string, config: RouteConfig): void; /** * Get route configuration * * @param id - Route identifier (uses default if not specified) * @returns Route configuration or undefined */ getRoute(id?: string): RouteConfig | undefined; /** * Update route configuration (partial update) * * @param id - Route identifier * @param updates - Partial route configuration */ updateRoute(id: string, updates: Partial): void; /** * Remove a route * * @param id - Route identifier */ removeRoute(id: string): void; /** * Check if route exists * * @param id - Route identifier * @returns True if route exists */ hasRoute(id: string): boolean; /** * Get all route IDs * * @returns Array of route IDs */ getRouteIds(): string[]; /** * Get default route ID * * @returns Default route ID or undefined */ getDefaultRouteId(): string | undefined; /** * Set default route * * @param id - Route identifier to set as default */ setDefaultRoute(id: string): void; /** * Get webhook defaults * * @returns Webhook defaults or undefined */ getWebhookDefaults(): WebhookDefaults | undefined; /** * Set webhook defaults * * @param defaults - Webhook defaults */ setWebhookDefaults(defaults: WebhookDefaults): void; /** * Set route parameter using dot notation * Supports nested paths like "webhook.url" or "longPolling.timeout" * * @param routeId - Route identifier * @param path - Parameter path (dot notation) * @param value - Value to set * * @example * ```typescript * manager.setParam('support', 'webhook.url', 'https://new-url.com'); * manager.setParam('support', 'longPolling.timeout', 60); * ``` */ setParam(routeId: string, path: string, value: unknown): void; /** * Get route parameter using dot notation * * @param routeId - Route identifier * @param path - Parameter path (dot notation) * @returns Parameter value or undefined * * @example * ```typescript * const url = manager.getParam('support', 'webhook.url'); * const timeout = manager.getParam('support', 'longPolling.timeout'); * ``` */ getParam(routeId: string, path: string): unknown; /** * Replace all routes * Clears existing routes and loads new configuration * * @param routes - New routes configuration */ replaceAll(routes: RouteConfig | RouteConfig[] | Map): void; /** * Validate route configuration using DataValidator and JSON Schema * Async method that initializes validator on first call * * @param config - Route configuration to validate * @throws {Error} If validation fails with detailed error message * * @example * ```typescript * try { * await manager.validateRouteAsync(config); * console.log('Config is valid'); * } catch (error) { * console.error('Validation failed:', error.message); * } * ``` */ validateRouteAsync(config: RouteConfig): Promise; /** * Validate route configuration (synchronous basic validation) * For full JSON Schema validation, use validateRouteAsync() * Returns array of validation errors (empty if valid) * * @param config - Route configuration to validate * @returns Array of error messages * * @deprecated Use validateRouteAsync() for full JSON Schema validation */ validateRoute(config: RouteConfig): string[]; }