/** * Feature Scanner * * Recursively scans Features directory to automatically discover all Features. * Supports Convention over Configuration to automatically infer method/path from folder structure. */ import { Feature } from './feature'; export interface ScanOptions { /** * Features directory path */ directory: string; /** * index file patterns (default: ['index', 'index.ts']) */ indexPatterns?: string[]; /** * Directory patterns to exclude */ excludeDirs?: string[]; /** * Enable debug logging */ debug?: boolean; } export interface ScannedFeature { /** * Feature instance */ feature: Feature; /** * Feature file path */ filePath: string; /** * Relative path (based on features directory) */ relativePath: string; } /** * Feature Scanner class */ export declare class FeatureScanner { private options; private baseDir; constructor(options: ScanOptions); /** * Recursively scan Features directory */ scan(): Promise; /** * Recursively scan directory * * @private */ private scanDirectory; /** * Load Feature file * * @private */ private loadFeature; /** * Check if it's an implicit Feature * * @param dir - Directory path * @param entries - List of files/folders in directory * @returns Whether it's an implicit Feature * * @private */ private isImplicitFeature; /** * Create implicit Feature (without index.js) * * @param dir - Feature directory path * @returns Feature instance * * @private */ private createImplicitFeature; /** * Sort features by route priority * * Priority rules (highest to lowest): * 1. Depth: Deeper routes first (/a/b/c before /a/b) * 2. Specificity: Static segments before dynamic (/blog/search before /blog/:slug) * 3. Alphabetical: For same priority, alphabetical order * * @param features - Features array to sort (in-place) * @private */ private sortFeaturesByPriority; /** * Calculate route priority score * * Higher score = Higher priority (should be registered first) * * Scoring: * - Each segment: +1000 points (depth) * - Each static segment: +100 points (specificity) * * Examples: * - /blog/search/advanced → 3000 + 300 = 3300 * - /blog/search → 2000 + 200 = 2200 * - /blog/:slug → 2000 + 100 = 2100 * - / → 1000 + 100 = 1100 * * @param routePath - Route path * @returns Priority score * @private */ private calculateRoutePriority; /** * Debug log * * @private */ private log; } /** * Recursively scan Features directory and return all Features * * @param directory - Features directory path * @param options - Scan options * @returns Array of ScannedFeature * * @example * ```javascript * const numflow = require('numflow') * * // Scan Features * const features = await numflow.scanFeatures('./features') * * // Register each Feature * features.forEach(({ feature }) => { * app.registerFeature(feature) * }) * ``` * * @example * ```javascript * // Scan with options * const features = await numflow.scanFeatures('./features', { * indexPatterns: ['index', 'feature'], * excludeDirs: ['node_modules', 'test'], * debug: true, * }) * ``` */ export declare function scanFeatures(directory: string, options?: Partial): Promise; //# sourceMappingURL=feature-scanner.d.ts.map