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
251 lines • 8.25 kB
TypeScript
/**
* CLI-specific type definitions with enhanced dependency injection and progress callback support
*/
import type { Section1Result } from '../analyzers/overview/types';
import type { Section2Result } from '../analyzers/quality/types';
import type { Section3Result } from '../analyzers/eda/types';
import type { Section4Result } from '../analyzers/visualization/types';
import type { Section5Result } from '../analyzers/engineering/types';
import type { Section6Result } from '../analyzers/modeling/types';
import type { LogContext } from '../utils/logger';
import type { DataPilotError } from '../core/types';
export interface CLIOptions {
output?: 'txt' | 'markdown' | 'json' | 'yaml';
outputFile?: string;
verbose?: boolean;
quiet?: boolean;
maxRows?: number;
enableHashing?: boolean;
includeEnvironment?: boolean;
privacyMode?: 'full' | 'redacted' | 'minimal';
maxMemory?: number;
parallel?: boolean;
chunkSize?: number;
memoryLimit?: number;
autoConfig?: boolean;
preset?: string;
threads?: number;
enableCaching?: boolean;
cacheSize?: number;
streamingOptimizations?: boolean;
progressiveReporting?: boolean;
sections?: string[];
accessibility?: 'excellent' | 'good' | 'adequate';
complexity?: 'simple' | 'moderate' | 'complex';
maxRecommendations?: number;
includeCode?: boolean;
database?: string;
framework?: string;
focus?: string[];
interpretability?: 'low' | 'medium' | 'high';
format?: string;
encoding?: string;
delimiter?: string;
quote?: string;
hasHeader?: boolean;
jsonPath?: string;
arrayMode?: 'records' | 'values';
flattenObjects?: boolean;
sheetName?: string;
sheetIndex?: number;
columns?: string[];
rowStart?: number;
rowEnd?: number;
force?: boolean;
dryRun?: boolean;
showProgress?: boolean;
forceSequential?: boolean;
forceIndividual?: boolean;
fallbackOnError?: boolean;
continueOnError?: boolean;
autoSample?: boolean;
samplePercentage?: number;
sampleRows?: number;
sampleSizeBytes?: number;
sampleMethod?: 'random' | 'stratified' | 'systematic' | 'head';
stratifyBy?: string;
seed?: number;
confidence?: number;
command?: string;
[key: string]: unknown;
}
export interface CLIContext {
command: string;
args: string[];
options: CLIOptions;
startTime: number;
workingDirectory: string;
file?: string;
}
export interface CLIResult {
success: boolean;
exitCode: number;
message?: string;
error?: string;
data?: any;
format?: string;
metadata?: any;
suggestions?: string[];
outputFiles?: string[];
output?: string;
stats?: {
processingTime: number;
rowsProcessed: number;
warnings: number;
errors: number;
};
}
export interface ProgressState {
phase: string;
progress: number;
message: string;
timeElapsed: number;
estimatedTimeRemaining?: number;
}
export type ProgressCallback = (state: ProgressState) => void;
export interface ProgressCallbacks {
onPhaseStart?: (phase: string, message: string) => void;
onProgress?: ProgressCallback;
onPhaseComplete?: (message: string, timeElapsed: number) => void;
onError?: (message: string) => void;
onWarning?: (message: string) => void;
}
export type SectionResult = Section1Result | Section2Result | Section3Result | Section4Result | Section5Result | Section6Result;
export type SectionResultMap = {
section1: Section1Result;
section2: Section2Result;
section3: Section3Result;
section4: Section4Result;
section5: Section5Result;
section6: Section6Result;
};
export interface AnalyzerDependency<TResult extends SectionResult = SectionResult> {
name: string;
result: TResult;
timestamp: Date;
cached: boolean;
}
export interface DependencyResolver {
resolve<K extends keyof SectionResultMap>(sectionName: K): Promise<SectionResultMap[K]>;
cache<K extends keyof SectionResultMap>(sectionName: K, result: SectionResultMap[K]): void;
clear(): void;
has(sectionName: string): boolean;
}
export interface AnalyzerFactory<TOptions extends Record<string, unknown> = CLIOptions, TDeps extends SectionResult[] = SectionResult[], TResult extends SectionResult = SectionResult> {
(filePath: string, options: TOptions, dependencies?: TDeps): Promise<TResult>;
}
export interface SectionAnalysisConfig<TResult extends SectionResult = SectionResult, TDeps extends SectionResult[] = SectionResult[]> {
sectionName: string;
phase: string;
message: string;
dependencies?: Array<keyof SectionResultMap>;
analyzerFactory: AnalyzerFactory<CLIOptions, TDeps, TResult>;
formatterMethod?: (result: TResult) => string;
outputMethod: OutputMethodFactory<TResult>;
progressWeighting?: number;
retryable?: boolean;
required?: boolean;
}
export interface OutputMethodFactory<TResult extends SectionResult> {
(outputManager: unknown, report: string | null, result: TResult, fileName?: string): string[];
}
export interface DependencyChain {
sections: Array<{
name: keyof SectionResultMap;
dependencies: Array<keyof SectionResultMap>;
optional?: boolean;
}>;
validateChain(): {
isValid: boolean;
errors: string[];
};
getExecutionOrder(): Array<keyof SectionResultMap>;
}
export interface CLIErrorContext extends LogContext {
command?: string;
phase?: string;
dependencies?: string[];
retryAttempt?: number;
}
export interface CLIErrorHandler {
handleSectionError(error: DataPilotError, sectionName: string, context: CLIErrorContext): Promise<boolean>;
recordSectionFailure(sectionName: string, error: DataPilotError): void;
getSectionErrors(sectionName: string): DataPilotError[];
getTotalErrors(): number;
canContinue(sectionName: string): boolean;
}
export interface ConfigurationMode {
mode: 'development' | 'production' | 'ci' | 'test';
presets?: string[];
overrides?: Partial<CLIOptions>;
}
export interface CLIConfigurationLoader {
loadConfiguration(mode?: ConfigurationMode): Promise<CLIOptions>;
validateConfiguration(config: CLIOptions): {
isValid: boolean;
errors: string[];
};
applyPresets(config: CLIOptions, presets: string[]): CLIOptions;
}
export interface SectionExecutionResult<T extends SectionResult = SectionResult> {
sectionName: string;
success: boolean;
result?: T;
error?: DataPilotError;
processingTime: number;
warnings: string[];
outputFiles: string[];
dependencies: string[];
}
export interface AnalysisPipelineResult {
overallSuccess: boolean;
executedSections: SectionExecutionResult[];
totalProcessingTime: number;
totalWarnings: number;
totalErrors: number;
outputFiles: string[];
metadata: {
command: string;
filePath: string;
startTime: Date;
endTime: Date;
options: CLIOptions;
};
}
export interface AnalysisPipeline {
addSection<T extends SectionResult>(config: SectionAnalysisConfig<T>): void;
execute(filePath: string, options: CLIOptions): Promise<AnalysisPipelineResult>;
validatePipeline(): {
isValid: boolean;
errors: string[];
};
getExecutionPlan(): string[];
}
export interface ResourceMetrics {
memoryUsage: number;
processingTime: number;
rowsProcessed: number;
sectionsCompleted: number;
}
export interface ResourceMonitor {
startMonitoring(context: LogContext): void;
updateMetrics(metrics: Partial<ResourceMetrics>): void;
checkThresholds(): {
exceeded: boolean;
warnings: string[];
};
stopMonitoring(): ResourceMetrics;
}
export declare class CLIError extends Error {
exitCode: number;
showHelp: boolean;
constructor(message: string, exitCode?: number, showHelp?: boolean);
}
export declare class ValidationError extends CLIError {
constructor(message: string);
}
export declare class FileError extends CLIError {
filePath: string;
constructor(message: string, filePath: string);
}
//# sourceMappingURL=types.d.ts.map