UNPKG

datapilot-cli

Version:

Enterprise-grade streaming multi-format data analysis with comprehensive statistical insights and intelligent relationship detection - supports CSV, JSON, Excel, TSV, Parquet - memory-efficient, cross-platform

121 lines 3.34 kB
/** * Universal Data Parser Interface * Enables multi-format support while maintaining streaming capability */ export interface ParsedRow { index: number; data: string[]; raw?: string; metadata?: Record<string, any>; } export interface ParseOptions { maxRows?: number; encoding?: BufferEncoding; chunkSize?: number; format?: string; delimiter?: string; quote?: string; hasHeader?: boolean; jsonPath?: string; arrayMode?: 'records' | 'values'; flattenObjects?: boolean; sheetName?: string; sheetIndex?: number; columns?: string[]; rowStart?: number; rowEnd?: number; streaming?: boolean; memoryLimit?: string; } export interface FormatDetectionResult { format: string; confidence: number; metadata: Record<string, any>; encoding?: BufferEncoding; estimatedRows?: number; estimatedColumns?: number; suggestedOptions?: ParseOptions; } export interface ValidationResult { valid: boolean; errors: string[]; warnings: string[]; canProceed: boolean; suggestedFixes?: string[]; } export interface ParserStats { bytesProcessed: number; rowsProcessed: number; errors: { row: number; column?: number; message: string; code: string; }[]; startTime: number; endTime?: number; peakMemoryUsage?: number; format?: string; } /** * Universal data parser interface * All format-specific parsers must implement this interface */ export interface DataParser { /** * Parse file and return async iterator of rows * Maintains streaming capability for large files */ parse(filePath: string, options?: ParseOptions): AsyncIterableIterator<ParsedRow>; /** * Detect if this parser can handle the file format */ detect(filePath: string): Promise<FormatDetectionResult>; /** * Get parsing statistics */ getStats(): ParserStats; /** * Abort parsing operation */ abort(): void; /** * Validate file can be parsed */ validate(filePath: string): Promise<ValidationResult>; /** * Get supported file extensions */ getSupportedExtensions(): string[]; /** * Get format name */ getFormatName(): string; } /** * Format detector interface */ export interface FormatDetector { detect(filePath: string): Promise<FormatDetectionResult>; getSupportedExtensions(): string[]; getFormatName(): string; } /** * Base parser class with common functionality */ export declare abstract class BaseParser implements DataParser { protected stats: ParserStats; protected aborted: boolean; protected options: ParseOptions; constructor(options?: ParseOptions); abstract parse(filePath: string, options?: ParseOptions): AsyncIterableIterator<ParsedRow>; abstract detect(filePath: string): Promise<FormatDetectionResult>; abstract getSupportedExtensions(): string[]; abstract getFormatName(): string; getStats(): ParserStats; abort(): void; validate(filePath: string): Promise<ValidationResult>; protected addError(row: number, message: string, code: string, column?: number): void; protected updateStats(bytesProcessed: number, rowsProcessed: number): void; } //# sourceMappingURL=data-parser.d.ts.map