UNPKG

@pulzar/core

Version:

Next-generation Node.js framework for ultra-fast web applications with zero-reflection DI, GraphQL, WebSockets, events, and edge runtime support

128 lines 3.31 kB
import { Token } from "./tokens"; export interface ScannedProvider { token: Token; class: new (...args: any[]) => any; dependencies: Token[]; singleton: boolean; scope?: "singleton" | "transient" | "request"; filePath: string; } export interface ScannedModule { name: string; providers: ScannedProvider[]; imports: string[]; exports: Token[]; filePath: string; namespace?: string; } export declare class DependencyScanner { private providers; private modules; private project; private scannedFiles; constructor(tsConfigPath?: string); /** * Scan a single TypeScript file for DI metadata */ scanFile(filePath: string): ScannedProvider[]; /** * Scan a directory recursively for TypeScript files */ scanDirectory(dirPath: string): ScannedProvider[]; /** * Get all TypeScript files in a directory recursively */ private getTypeScriptFiles; /** * Scan a source file for providers and modules */ private scanSourceFile; /** * Extract provider information from a class declaration */ private extractProviderFromClass; /** * Extract module information from a class declaration */ private extractModuleFromClass; /** * Find a decorator by name on a class declaration */ private findDecorator; /** * Parse decorator arguments using AST */ private parseDecoratorArguments; /** * Parse object literal using AST */ private parseObjectLiteralAST; /** * Parse token value from AST node */ private parseTokenValue; /** * Parse boolean value from AST node */ private parseBooleanValue; /** * Parse string value from AST node */ private parseStringValue; /** * Parse array value from AST node */ private parseArrayValue; /** * Parse literal value from AST node */ private parseLiteralValue; /** * Extract constructor dependencies from a class */ private extractDependencies; /** * Extract token from @Inject decorator */ private extractInjectToken; /** * Get relative import path for a file */ private getRelativeImportPath; addProvider(provider: ScannedProvider): void; addModule(module: ScannedModule): void; getProviders(): ScannedProvider[]; getModules(): ScannedModule[]; getProvider(token: Token): ScannedProvider | undefined; getModule(name: string): ScannedModule | undefined; generateGraph(): any; private buildDependencyMap; validate(): { valid: boolean; errors: string[]; }; private hasCircularDependency; /** * Clear all scanned data */ clear(): void; /** * Get scanning statistics */ getStats(): { totalProviders: number; totalModules: number; scannedFiles: number; providersByScope: { singleton: number; transient: number; request: number; }; }; /** * Get providers grouped by scope */ private getProvidersByScope; } export declare function createDependencyScanner(tsConfigPath?: string): DependencyScanner; //# sourceMappingURL=scanner.d.ts.map