/** * FileTransaction — 文件操作事务 * * 提供原子性的多文件操作:写入、删除、移动。 * 操作前自动备份原始内容,失败时回滚到备份。 * * 使用方式: * const tx = new FileTransaction(); * tx.write('path/to/file.md', 'new content') * .write('path/to/other.md', 'updated') * .delete('path/to/temp.md'); * await tx.commit(); */ /** 操作类型 */ type OpType = 'write' | 'delete' | 'move'; export declare class FileTransaction { private operations; private committed; /** * 写入文件。自动备份原内容。 */ write(path: string, content: string): this; /** * 删除文件。自动备份原内容以便回滚。 */ delete(path: string): this; /** * 移动/重命名文件。 */ move(srcPath: string, destPath: string): this; /** * 执行所有操作。任何一步失败则自动回滚。 */ commit(): Promise; /** * 回滚已执行的操作。 */ private rollback; /** * 获取操作数量。 */ getOperations(): ReadonlyArray<{ type: OpType; path: string; }>; /** * 获取操作数量。 */ get length(): number; } export {}; //# sourceMappingURL=transaction.d.ts.map