/** * File Editor for Safe In-Place Editing (T017 - Simplified) * * Provides atomic file operations with backup support * SECURITY FIX (BF011): Added file locking to prevent race conditions */ import type { EncodeOptions } from '../types.js'; export interface FileEditorOptions { /** * Create backup before saving */ backup?: boolean; /** * Backup file suffix */ backupSuffix?: string; /** * Encoding options for TONL output */ encoding?: EncodeOptions; } /** * FileEditor provides safe in-place editing of TONL files * * Features: * - Atomic saves (write to temp + rename) * - Optional backup before modification * - Transaction-like semantics * * @example * ```typescript * const editor = await FileEditor.open('data.tonl', { backup: true }); * editor.data.users.push({ name: 'New User' }); * await editor.save(); // Atomic save with backup * ``` */ export declare class FileEditor { private filePath; private options; data: any; private originalContent; private constructor(); /** * Open a TONL file for editing (async) * SECURITY FIX: Added path validation to prevent path traversal attacks */ static open(filePath: string, options?: FileEditorOptions): Promise; /** * Open a TONL file for editing (sync) * SECURITY FIX: Added path validation to prevent path traversal attacks */ static openSync(filePath: string, options?: FileEditorOptions): FileEditor; /** * Save changes atomically * * Process: * 1. Create backup (if enabled) * 2. Write to temporary file * 3. Rename temp file to original (atomic on most systems) */ save(): Promise; /** * Save changes synchronously (atomic) */ saveSync(): void; /** * Check if file has been modified */ isModified(): boolean; /** * Discard changes and reload from file */ reload(): Promise; /** * Discard changes and reload from file (sync) */ reloadSync(): void; /** * Restore from backup */ restoreBackup(): Promise; /** * Restore from backup (sync) */ restoreBackupSync(): void; /** * Get file path */ getFilePath(): string; } //# sourceMappingURL=file-editor.d.ts.map