@nestjsvn/swagger-sse
Version:
OpenAPI documentation and interactive Swagger UI for NestJS Server-Sent Events endpoints
66 lines (65 loc) • 2.33 kB
TypeScript
import * as ts from 'typescript';
/**
* AST analysis utilities for the SSE transformer
*
* These utilities analyze TypeScript AST nodes and extract SSE-related information
* for automatic documentation generation.
*/
/**
* Check if a method declaration has an @Sse decorator
*
* @param node Method declaration node
* @returns True if the method has @Sse decorator
*/
export declare function hasSseDecorator(node: ts.MethodDeclaration): boolean;
/**
* Check if a decorator has a specific name
*
* @param decorator Decorator node
* @param name Expected decorator name
* @returns True if decorator matches the name
*/
export declare function isDecoratorNamed(decorator: ts.Decorator, name: string): boolean;
/**
* Extract event types from Observable<MessageEvent<T>> return type
*
* @param node Method declaration node
* @returns Array of event type names
*/
export declare function extractEventTypes(node: ts.MethodDeclaration): string[];
/**
* Analyze Observable type to extract MessageEvent type arguments
*
* @param typeNode Type reference node
* @returns Array of event type names
*/
export declare function analyzeObservableType(typeNode: ts.TypeReferenceNode): string[];
/**
* Convert type name to event name using specified convention
*
* @param typeName TypeScript type name
* @param convention Naming convention to use
* @returns Event name string
*/
export declare function typeNameToEventName(typeName: string, convention?: 'kebab-case' | 'camelCase' | 'PascalCase'): string;
/**
* Add @ApiSse decorator to a method declaration
*
* @param node Method declaration node
* @param context Transformation context
* @param eventTypes Array of event type names
* @param options Plugin options
* @returns Modified method declaration
*/
export declare function addApiSseDecorator(node: ts.MethodDeclaration, context: ts.TransformationContext, eventTypes?: string[], options?: {
eventNamingConvention?: 'kebab-case' | 'camelCase' | 'PascalCase';
introspectComments?: boolean;
autoGenerateOperationId?: boolean;
}): ts.MethodDeclaration;
/**
* Check if a method already has @ApiSse decorator
*
* @param node Method declaration node
* @returns True if method already has @ApiSse decorator
*/
export declare function hasApiSseDecorator(node: ts.MethodDeclaration): boolean;