UNPKG

legal-markdown-js

Version:

Node.js implementation of LegalMarkdown for processing legal documents with markdown and YAML - Complete feature parity with Ruby version

105 lines 3.65 kB
/** * Archive Manager Utility * * This module handles moving processed source files to archive directories * with conflict resolution, error handling, and directory management. * It provides a clean API for organizing files after successful processing. */ /** * Configuration options for archiving operations */ export interface ArchiveOptions { /** Target directory for archiving files */ archiveDir: string; /** Whether to create the archive directory if it doesn't exist */ createDirectory?: boolean; /** Strategy for handling filename conflicts */ conflictResolution?: 'overwrite' | 'rename' | 'skip'; } /** * Configuration options for smart archiving with content comparison */ export interface SmartArchiveOptions extends ArchiveOptions { /** Original file content */ originalContent: string; /** Processed file content */ processedContent: string; } /** * Result of an archive operation */ export interface ArchiveResult { /** Whether the operation was successful */ success: boolean; /** Original file path */ originalPath: string; /** Final archived file path (if successful) */ archivedPath?: string; /** Error message (if unsuccessful) */ error?: string; } /** * Result of a smart archive operation */ export interface SmartArchiveResult extends ArchiveResult { /** Whether contents were identical */ contentsIdentical: boolean; /** Path to archived original file (if different from processed) */ archivedOriginalPath?: string; /** Path to archived processed file (if different from original) */ archivedProcessedPath?: string; } /** * Archive Manager class for handling file archiving operations */ export declare class ArchiveManager { /** * Archive a file to the specified directory * * @param sourcePath Path to the source file to archive * @param options Archive configuration options * @returns Promise resolving to the archive result */ archiveFile(sourcePath: string, options: ArchiveOptions): Promise<ArchiveResult>; /** * Generate a unique filename by adding a numeric suffix * * @param targetPath The original target path * @returns A unique file path that doesn't conflict with existing files */ private generateUniqueFilename; /** * Ensure a directory exists, creating it recursively if necessary * * @param dirPath Path to the directory to create * @throws Error if directory creation fails */ private ensureDirectoryExists; /** * Smart archive that compares original and processed content * * If contents are identical, archives only the original file. * If contents are different, archives both with .ORIGINAL and .PROCESSED suffixes. * * @param sourcePath Path to the source file * @param options Smart archive configuration options * @returns Promise resolving to the smart archive result */ smartArchiveFile(sourcePath: string, options: SmartArchiveOptions): Promise<SmartArchiveResult>; /** * Handle filename conflicts using the specified strategy * * @param targetPath The proposed target file path * @param strategy The conflict resolution strategy * @returns The resolved file path, or null if skipping */ private handleConflicts; /** * Check if a path can be used as an archive directory * * @param dirPath Path to check * @returns True if the path is valid for archiving */ static isValidArchiveDirectory(dirPath: string): boolean; } //# sourceMappingURL=archive-manager.d.ts.map