UNPKG

advanced-patch-generator

Version:

Advanced patch manager using Xdelta for efficient patch creation and application with progress support, events, and error handling

176 lines 5.66 kB
import { EventEmitter } from 'events'; export type ProgressData = { percentage: number; message: string; current?: number; total?: number; speed?: string; eta?: string; }; export type ErrorData = { message: string; code?: string; details?: unknown; }; export type FileInfo = { exists: boolean; size: number; sizeFormatted: string; modified: Date; path: string; isDirectory: boolean; }; export type PatchResult = { success: boolean; error?: string; patchFile: FileInfo; metrics: { duration: number; durationFormatted: string; compressionRatio: number; originalSize: number; patchSize: number; isLargeFile: boolean; }; }; export type ApplyPatchResult = { success: boolean; error?: string; newFile: FileInfo; metrics: { duration: number; durationFormatted: string; }; }; export type VerifyPatchResult = { isValid: boolean; error?: string; metrics: { duration: number; durationFormatted: string; }; }; export type BatchResult = { file: string; status: 'success' | 'error' | 'skipped'; error?: string; metrics?: { duration: number; durationFormatted: string; }; }; export type AdvancedPatchGeneratorOptions = { xdeltaPath?: string; compression?: number; verify?: boolean; showProgress?: boolean; largeFileThreshold?: number; timeout?: number; memoryLimit?: number; enableChunkProcessing?: boolean; onProgress?: (progress: ProgressData) => void; onError?: (error: ErrorData) => void; onComplete?: (result: PatchResult | ApplyPatchResult | VerifyPatchResult) => void; }; export type CreatePatchOptions = { compression?: number; verify?: boolean; showProgress?: boolean; timeout?: number; onProgress?: (progress: ProgressData) => void; onError?: (error: ErrorData) => void; onComplete?: (result: PatchResult) => void; }; export type ApplyPatchOptions = { showProgress?: boolean; timeout?: number; onProgress?: (progress: ProgressData) => void; onError?: (error: ErrorData) => void; onComplete?: (result: ApplyPatchResult) => void; }; export type BatchOptions = { showProgress?: boolean; timeout?: number; onProgress?: (progress: ProgressData) => void; onError?: (error: ErrorData) => void; onComplete?: (result: BatchResult[]) => void; }; export type CommandResult = { success: boolean; stdout: string; stderr: string; duration: number; }; export type ChunkInfo = { start: number; end: number; size: number; index: number; }; export type LargeFileOptions = { chunkSize?: number; overlap?: number; compression?: number; onProgress?: (progress: ProgressData) => void; }; export type PatchAnalysisResult = { success: boolean; error?: string; patchInfo: { size: number; sizeFormatted: string; compressionRatio?: number; estimatedOriginalSize?: number; estimatedNewSize?: number; }; metadata?: Record<string, unknown>; }; export type PatchComparisonResult = { success: boolean; error?: string; comparison: { sizeDifference: number; sizeDifferenceFormatted: string; compressionRatioDifference: number; similarity: number; }; }; export type PatchInfoResult = { success: boolean; error?: string; info: { size: number; sizeFormatted: string; format: string; version?: string; flags?: string[]; metadata?: Record<string, unknown>; }; }; export type IAdvancedPatchGenerator = EventEmitter & { xdeltaPath: string; defaultOptions: AdvancedPatchGeneratorOptions; checkXdelta(): Promise<boolean>; getFileInfo(filePath: string): Promise<FileInfo>; createPatch(oldFile: string, newFile: string, patchFile: string, options?: CreatePatchOptions): Promise<PatchResult>; applyPatch(oldFile: string, patchFile: string, newFile: string, options?: ApplyPatchOptions): Promise<ApplyPatchResult>; verifyPatch(oldFile: string, patchFile: string, expectedFile: string): Promise<VerifyPatchResult>; createPatchWithChunks(oldFile: string, newFile: string, patchFile: string, options?: LargeFileOptions): Promise<PatchResult>; combinePatchChunks(patchChunks: string[], outputPath: string): Promise<void>; createBatchPatches(oldDir: string, newDir: string, patchesDir: string, options?: BatchOptions): Promise<BatchResult[]>; applyBatchPatches(oldDir: string, patchesDir: string, outputDir: string, options?: BatchOptions): Promise<BatchResult[]>; on(event: 'progress', listener: (data: ProgressData) => void): IAdvancedPatchGenerator; on(event: 'error', listener: (error: ErrorData) => void): IAdvancedPatchGenerator; on(event: 'complete', listener: (result: PatchResult | ApplyPatchResult | VerifyPatchResult) => void): IAdvancedPatchGenerator; on(event: string, listener: (...args: unknown[]) => void): IAdvancedPatchGenerator; emit(event: 'progress', data: ProgressData): boolean; emit(event: 'error', error: ErrorData): boolean; emit(event: 'complete', result: PatchResult | ApplyPatchResult | VerifyPatchResult): boolean; emit(event: string, ...args: unknown[]): boolean; }; export type IPatchAnalyzer = { analyzePatch(patchFile: string): Promise<PatchAnalysisResult>; comparePatches(patch1: string, patch2: string): Promise<PatchComparisonResult>; getPatchInfo(patchFile: string): Promise<PatchInfoResult>; }; //# sourceMappingURL=index.d.ts.map