/** * StorageBackend abstraction — pluggable blob storage. * FsBackend ships natively; S3 support via @backloghq/termlog-s3 (separate package). */ /** * Streaming write handle returned by `StorageBackend.createWriteStream`. * Chunks become visible at the target path only after `end()` resolves. * `abort()` discards the in-progress write and leaves nothing at the path. */ export interface BlobWriteStream { write(chunk: Buffer): Promise; /** Atomically commits all written chunks to `path`. */ end(): Promise; /** Discards the in-progress write. */ abort(): Promise; } /** Thrown when a StorageBackend cannot open or complete a streaming write. */ export declare class WriteStreamError extends Error { constructor(message: string); } export interface StorageBackend { readBlob(path: string): Promise; writeBlob(path: string, data: Buffer): Promise; listBlobs(prefix: string): Promise; deleteBlob(path: string): Promise; /** * Open a streaming write handle for `path`. Chunks written via `write()` are * buffered/streamed but not visible until `end()` commits atomically. * On error call `abort()` to clean up. */ createWriteStream(path: string): Promise; /** * Append `data` to the end of `path`, creating it if absent. * Optional — callers fall back to read-modify-writeBlob on backends that omit this. * Implementations must fsync before returning so data survives a crash. */ appendBlob?(path: string, data: Buffer): Promise; /** Hint for concurrency caps — true when backed by the local filesystem. */ isLocalFs?(): boolean; } /** * Local filesystem backend. Atomic writes use a `.tmp` sidecar + rename. * All paths are relative to the root directory supplied at construction. */ export declare class FsBackend implements StorageBackend { private readonly root; constructor(root: string); isLocalFs(): boolean; private abs; readBlob(path: string): Promise; /** Atomic write: write to a unique ..tmp, fsync it, rename over , fsync the directory. */ writeBlob(path: string, data: Buffer): Promise; /** * List all blob paths (relative to root) whose basename starts with `prefix`. * Searches only the root directory (no recursive walk — all termlog files live flat). */ listBlobs(prefix: string): Promise; deleteBlob(path: string): Promise; /** * Append `data` to `path` using O_APPEND (atomic at the kernel level for * writes <= PIPE_BUF on the same filesystem), then fsync for crash durability. */ appendBlob(path: string, data: Buffer): Promise; createWriteStream(path: string): Promise; } //# sourceMappingURL=storage.d.ts.map