cui-server
Version:
Web UI Agent Platform based on Claude Code
49 lines • 1.25 kB
TypeScript
/**
* Simple JSON file manager with race condition protection
* Uses file locking and atomic writes to prevent data corruption
*/
export declare class JsonFileManager<T> {
private defaultData;
private logger;
private filePath;
private lockPath;
private writeQueue;
private isWriting;
constructor(filePath: string, defaultData: T);
/**
* Read data from JSON file
* Returns default data if file doesn't exist
*/
read(): Promise<T>;
/**
* Write data to JSON file atomically
* Uses temporary file and rename to prevent corruption
*/
write(data: T): Promise<void>;
/**
* Update data using a callback function
* Reads current data, applies update, and writes back
*/
update(updateFn: (data: T) => T): Promise<void>;
/**
* Perform atomic write operation
*/
private performWrite;
/**
* Process write queue sequentially
*/
private processWriteQueue;
/**
* Wait for any pending writes to complete
*/
private waitForWrite;
/**
* Acquire file lock
*/
private acquireLock;
/**
* Release file lock
*/
private releaseLock;
}
//# sourceMappingURL=json-file-manager.d.ts.map