/**
 * WebSocket Event System
 * Standardized event patterns for real-time communication
 */
import { Server as SocketIOServer, Socket } from "socket.io";
/**
 * Standard event types
 */
export declare enum EventTypes {
    CONNECT = "connect",
    DISCONNECT = "disconnect",
    ERROR = "error",
    DATA_UPDATE = "data:update",
    DATA_CREATE = "data:create",
    DATA_DELETE = "data:delete",
    DATA_SYNC = "data:sync",
    STATUS_CHANGE = "status:change",
    STATUS_HEALTH = "status:health",
    STATUS_METRICS = "status:metrics",
    CONTROL_START = "control:start",
    CONTROL_STOP = "control:stop",
    CONTROL_RESTART = "control:restart",
    CONTROL_CONFIG = "control:config",
    SUBSCRIBE = "subscribe",
    UNSUBSCRIBE = "unsubscribe",
    SYSTEM_PING = "system:ping",
    SYSTEM_PONG = "system:pong",
    SYSTEM_INFO = "system:info",
    SYSTEM_ALERT = "system:alert"
}
/**
 * Standard event payload structure
 */
export interface EventPayload<T = any> {
    id?: string;
    timestamp: string;
    type: string;
    source?: string;
    target?: string;
    data: T;
    metadata?: Record<string, any>;
}
/**
 * Event response structure
 */
export interface EventResponse<T = any> {
    success: boolean;
    data?: T;
    error?: string;
    timestamp: string;
}
/**
 * WebSocket Event Manager
 */
export declare class WebSocketEventManager {
    private io;
    private subscriptions;
    private eventHandlers;
    constructor(io: SocketIOServer);
    /**
     * Setup default event handlers
     */
    private setupDefaultHandlers;
    /**
     * Subscribe socket to a channel
     */
    subscribe(socket: Socket, channel: string): void;
    /**
     * Unsubscribe socket from a channel
     */
    unsubscribe(socket: Socket, channel: string): void;
    /**
     * Clean up all subscriptions for a socket
     */
    private cleanupSubscriptions;
    /**
     * Emit event to all clients
     */
    broadcast<T>(event: string, payload: EventPayload<T>): void;
    /**
     * Emit event to specific room/channel
     */
    emit<T>(channel: string, event: string, payload: EventPayload<T>): void;
    /**
     * Send event to specific socket
     */
    send<T>(socketId: string, event: string, payload: EventPayload<T>): void;
    /**
     * Register custom event handler
     */
    on(event: string, handler: (socket: Socket, data: any) => void): void;
    /**
     * Get subscription statistics
     */
    getStats(): {
        connections: number;
        channels: number;
        subscriptions: Record<string, number>;
    };
}
/**
 * Typed event emitter for specific domains
 */
export declare class TypedEventEmitter<T extends Record<string, any>> {
    private manager;
    private namespace;
    constructor(manager: WebSocketEventManager, namespace: string);
    /**
     * Emit typed event
     */
    emit<K extends keyof T>(event: K, data: T[K]): void;
    /**
     * Emit to specific channel
     */
    emitTo<K extends keyof T>(channel: string, event: K, data: T[K]): void;
}
/**
 * Create event patterns for common use cases
 */
export declare const EventPatterns: {
    /**
     * CRUD event pattern
     */
    crud: <T>(namespace: string) => {
        created: (data: T) => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: T;
            };
        };
        updated: (data: T) => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: T;
            };
        };
        deleted: (id: string) => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: {
                    id: string;
                };
            };
        };
        list: (data: T[]) => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: T[];
            };
        };
    };
    /**
     * Status event pattern
     */
    status: (namespace: string) => {
        online: () => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: {
                    status: string;
                };
            };
        };
        offline: () => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: {
                    status: string;
                };
            };
        };
        error: (error: string) => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: {
                    error: string;
                };
            };
        };
        health: (health: any) => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: any;
            };
        };
    };
    /**
     * Data stream pattern
     */
    stream: <T>(namespace: string) => {
        start: () => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: {};
            };
        };
        data: (data: T) => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: T;
            };
        };
        end: () => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: {};
            };
        };
        error: (error: string) => {
            event: string;
            payload: {
                timestamp: string;
                type: string;
                data: {
                    error: string;
                };
            };
        };
    };
};
declare const _default: {
    WebSocketEventManager: typeof WebSocketEventManager;
    TypedEventEmitter: typeof TypedEventEmitter;
    EventTypes: typeof EventTypes;
    EventPatterns: {
        /**
         * CRUD event pattern
         */
        crud: <T>(namespace: string) => {
            created: (data: T) => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: T;
                };
            };
            updated: (data: T) => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: T;
                };
            };
            deleted: (id: string) => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: {
                        id: string;
                    };
                };
            };
            list: (data: T[]) => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: T[];
                };
            };
        };
        /**
         * Status event pattern
         */
        status: (namespace: string) => {
            online: () => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: {
                        status: string;
                    };
                };
            };
            offline: () => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: {
                        status: string;
                    };
                };
            };
            error: (error: string) => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: {
                        error: string;
                    };
                };
            };
            health: (health: any) => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: any;
                };
            };
        };
        /**
         * Data stream pattern
         */
        stream: <T>(namespace: string) => {
            start: () => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: {};
                };
            };
            data: (data: T) => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: T;
                };
            };
            end: () => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: {};
                };
            };
            error: (error: string) => {
                event: string;
                payload: {
                    timestamp: string;
                    type: string;
                    data: {
                        error: string;
                    };
                };
            };
        };
    };
};
export default _default;
//# sourceMappingURL=websocketEvents.d.ts.map