@nestjsvn/swagger-sse
Version:
OpenAPI documentation and interactive Swagger UI for NestJS Server-Sent Events endpoints
80 lines (79 loc) • 2.06 kB
TypeScript
/**
* Swagger UI plugin for Server-Sent Events support
*
* This plugin will be implemented in Phase 4 to provide interactive
* SSE streaming capabilities within the Swagger UI interface.
*/
declare global {
interface Window {
SSEComponents?: {
EventFilterComponent: any;
EventListComponent: any;
ConnectionStatusComponent: any;
};
EventSourceManager?: any;
ThemeManager?: any;
_sseThemeManager?: any;
}
interface HTMLElement {
_sseComponent?: any;
_sseManager?: any;
_unsubscribe?: () => void;
}
}
/**
* SSE connection interface
*/
export interface SseConnection {
eventSource: EventSource | null;
status: 'disconnected' | 'connecting' | 'connected' | 'error';
events: SseEvent[];
}
/**
* SSE event interface
*/
export interface SseEvent {
type: string;
timestamp: Date;
data: any;
}
/**
* SSE connection options
*/
export interface SseConnectionOptions {
url: string;
eventTypes: string[];
headers?: Record<string, string>;
}
/**
* Swagger UI SSE Plugin
*
* This plugin extends Swagger UI to handle SSE endpoints by:
* - Detecting x-sse-endpoint extension in OpenAPI spec
* - Providing connect/disconnect controls
* - Displaying real-time event log
* - Handling EventSource connections
*/
export declare const SwaggerSsePlugin: () => {
name: string;
init(system: any): void;
statePlugins: {
spec: {
wrapActions: {
execute: (ori: any, system: any) => (req: any) => any;
};
};
};
};
/**
* Create EventSource connection for SSE streaming
*
* @param url SSE endpoint URL
* @param options Connection options
* @returns SSE connection object
*/
export declare function createSseConnection(_url: string, _options: SseConnectionOptions): SseConnection;
/**
* Create EventSource connection with event handling
*/
export declare function createEventSourceConnection(url: string, eventTypes: string[]): SseConnection;