/** * @fileoverview Project index filtering utilities * * Provides efficient filtering of existing ProjectIndex instances based on * include/exclude patterns without requiring file system access. Reuses * existing pattern matching infrastructure for consistency and performance. * * @example * // Filter to only TypeScript files * const filtered = filterProjectIndex(index, { * include: ['src/**'] * }); * * // Exclude test files * const prodIndex = filterProjectIndex(index, { * exclude: ['test/**'] * }); */ import type { ProjectIndex, FilterOptions } from '../types/index.js'; /** * Filter an existing ProjectIndex based on include/exclude patterns * * This function operates entirely in memory and is designed to be 10-1000x faster * than re-scanning the file system. It filters all data structures within the index: * - nodes array (file paths) * - files object (detailed file info) * - edges array (dependencies - keeps only if both source and target are included) * - tree structure (rebuilt from filtered files) * - metadata (updated to reflect filtered counts) * * @param index - The ProjectIndex to filter * @param options - Filter options with include/exclude patterns * @param options.include - Array of glob patterns to include files (OR logic) * @param options.exclude - Array of glob patterns to exclude files (OR logic) * @returns New filtered ProjectIndex with updated metadata * * @example Basic filtering * const index = await indexer.processProject(); * * // Filter to only source files * const srcIndex = filterProjectIndex(index, { * include: ['src/**'] * }); * * // Exclude test files * const prodIndex = filterProjectIndex(index, { * exclude: ['test/**'] * }); * * @example Complex filtering * // Filter to specific components excluding tests * const componentIndex = filterProjectIndex(index, { * include: ['src/components/**', 'src/ui/**'], * exclude: ['test/**', 'stories/**'] * }); * * console.log('Filtered files from', index.metadata.totalFiles, 'to', componentIndex.metadata.totalFiles); * * @throws {PatternValidationError} When glob patterns are malformed * @throws {SecurityViolationError} When patterns contain dangerous sequences */ export declare function filterProjectIndex(index: ProjectIndex, options?: FilterOptions): ProjectIndex; /** * Get filtering statistics for analysis * * Provides detailed information about how filtering affected the project index, * useful for understanding the impact of different filter patterns. * * @param originalIndex - Original ProjectIndex before filtering * @param filteredIndex - Filtered ProjectIndex after filtering * @param options - Filter options that were applied * @returns Statistics about the filtering operation * * @example * ```typescript * const original = await indexer.processProject(); * const filtered = filterProjectIndex(original, { include: ['src/**'] }); * const stats = getFilteringStats(original, filtered, { include: ['src/**'] }); * * console.log(`Reduced files from ${stats.originalFileCount} to ${stats.filteredFileCount}`); * console.log(`Reduction: ${stats.reductionPercentage.toFixed(1)}%`); * console.log(`Removed ${stats.removedEdgeCount} dependency edges`); * ``` */ export declare function getFilteringStats(originalIndex: ProjectIndex, filteredIndex: ProjectIndex, options: FilterOptions): { originalFileCount: number; filteredFileCount: number; reductionPercentage: number; removedFileCount: number; originalEdgeCount: number; filteredEdgeCount: number; removedEdgeCount: number; edgeReductionPercentage: number; filterOptions: FilterOptions; }; //# sourceMappingURL=project-index-filter.d.ts.map