import { EndpointChangeListener, EndpointDefinition, EndpointHealth, HttpMethod, IEndpointRegistry, Milliseconds, Unsubscribe } from '../types'; /** * Centralized registry for REST API endpoints. * * Provides comprehensive endpoint management including: * - Registration and lookup * - Health tracking * - Dynamic URL building * - Change subscriptions * * @example * ```typescript * const registry = EndpointRegistry.getInstance(); * * // Register an endpoint * registry.register({ * name: 'users.list', * path: '/users', * method: 'GET', * auth: true, * cache: { strategy: 'cache-first', ttl: 300000 }, * }); * * // Build URL with params * const url = registry.buildUrl('users.detail', { id: '123' }); * // Result: '/users/123' * * // Track health * registry.markHealthy('users.list', 150); // 150ms response time * registry.markUnhealthy('users.list', 'Connection timeout'); * ``` */ export declare class EndpointRegistry implements IEndpointRegistry { private static instance; private endpoints; private health; private successCounts; private responseTimes; private listeners; private baseUrl; private constructor(); /** * Get the singleton instance. */ static getInstance(): EndpointRegistry; /** * Reset the singleton instance (for testing). */ static resetInstance(): void; /** * Set the base URL for all endpoints. */ setBaseUrl(url: string): void; /** * Get the current base URL. */ getBaseUrl(): string; /** * Register a new endpoint. */ register(definition: EndpointDefinition): void; /** * Register multiple endpoints at once. */ registerBatch(definitions: readonly EndpointDefinition[]): void; /** * Register endpoints from an object (for easy migration from existing patterns). */ registerFromObject(obj: Record string)>, options?: { method?: HttpMethod; auth?: boolean; prefix?: string; tags?: string[]; }): void; /** * Get an endpoint by name. */ get(name: string): EndpointDefinition | undefined; /** * Get all endpoints matching a tag. */ getByTag(tag: string): readonly EndpointDefinition[]; /** * Get all endpoints matching a path pattern. */ getByPath(pathPattern: string): readonly EndpointDefinition[]; /** * Get all registered endpoints. */ getAll(): readonly EndpointDefinition[]; /** * Check if an endpoint exists. */ has(name: string): boolean; /** * Update an existing endpoint. */ update(name: string, updates: Partial): void; /** * Remove an endpoint. */ remove(name: string): void; /** * Clear all endpoints. */ clear(): void; /** * Mark an endpoint as healthy after a successful request. */ markHealthy(name: string, responseTime?: Milliseconds): void; /** * Mark an endpoint as unhealthy after a failed request. */ markUnhealthy(name: string, reason: string): void; /** * Get health status for an endpoint. */ getHealth(name: string): EndpointHealth | undefined; /** * Get all unhealthy endpoints. */ getUnhealthyEndpoints(): readonly string[]; /** * Get all degraded endpoints. */ getDegradedEndpoints(): readonly string[]; /** * Get all healthy endpoints. */ getHealthyEndpoints(): readonly string[]; /** * Build a full URL for an endpoint. */ buildUrl(name: string, params?: Record): string; /** * Build a URL with query parameters. */ buildUrlWithQuery(name: string, params?: Record, query?: Record): string; /** * Subscribe to endpoint changes. */ subscribe(listener: EndpointChangeListener): Unsubscribe; /** * Export all endpoints as JSON. */ toJSON(): string; /** * Import endpoints from JSON with schema validation. * * Validates the imported JSON against a strict Zod schema before processing * to prevent injection of malformed or malicious data. * * @param json - JSON string to import * @throws {z.ZodError} If validation fails * @throws {SyntaxError} If JSON parsing fails */ fromJSON(json: string): void; /** * Get registry statistics. */ getStats(): { totalEndpoints: number; healthy: number; degraded: number; unhealthy: number; unknown: number; avgResponseTime: Milliseconds | undefined; }; /** * Calculate average response time for an endpoint. */ private calculateAvgResponseTime; private emitEvent; } /** * Get the EndpointRegistry singleton instance. */ export declare function getEndpointRegistry(): EndpointRegistry; /** * Register an endpoint. */ export declare function registerEndpoint(definition: EndpointDefinition): void; /** * Get an endpoint by name. */ export declare function getEndpoint(name: string): EndpointDefinition | undefined; /** * Build a URL for an endpoint. */ export declare function buildEndpointUrl(name: string, params?: Record, query?: Record): string; /** * Check endpoint health. */ export declare function isEndpointHealthy(name: string): boolean;