FileStorage
Defined in: src/session/file-storage.ts:25
File-based implementation of SnapshotStorage. Persists session snapshots to the local filesystem under a configurable base directory.
Directory layout:
<baseDir>/<sessionId>/scopes/<scope>/<scopeId>/snapshots/ snapshot_latest.json immutable_history/ snapshot_<uuid7>.jsonImplements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FileStorage(baseDir): FileStorage;Defined in: src/session/file-storage.ts:32
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
baseDir | string | Absolute path to the root directory for storing session snapshots. |
Returns
Section titled “Returns”FileStorage
Methods
Section titled “Methods”saveSnapshot()
Section titled “saveSnapshot()”saveSnapshot(params): Promise<void>;Defined in: src/session/file-storage.ts:62
Persists a snapshot to disk.
If isLatest is true, writes to snapshot_latest.json (overwriting any previous).
Otherwise, writes to immutable_history/snapshot_<snapshotId>.json.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { location: SnapshotLocation; snapshotId: string; isLatest: boolean; snapshot: Snapshot; } |
params.location | SnapshotLocation |
params.snapshotId | string |
params.isLatest | boolean |
params.snapshot | Snapshot |
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”loadSnapshot()
Section titled “loadSnapshot()”loadSnapshot(params): Promise<Snapshot>;Defined in: src/session/file-storage.ts:79
Loads a snapshot from disk.
If snapshotId is omitted, loads snapshot_latest.json.
Returns null if the file does not exist.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { location: SnapshotLocation; snapshotId?: string; } |
params.location | SnapshotLocation |
params.snapshotId? | string |
Returns
Section titled “Returns”Promise<Snapshot>
Implementation of
Section titled “Implementation of”listSnapshotIds()
Section titled “listSnapshotIds()”listSnapshotIds(params): Promise<string[]>;Defined in: src/session/file-storage.ts:94
Lists immutable snapshot IDs for a scope, sorted chronologically.
Since IDs are UUID v7, lexicographic sort equals chronological order.
startAfter filters to IDs after the given UUID v7 (exclusive cursor).
limit caps the number of returned IDs.
Returns an empty array if no snapshots exist yet.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { location: SnapshotLocation; limit?: number; startAfter?: string; } |
params.location | SnapshotLocation |
params.limit? | number |
params.startAfter? | string |
Returns
Section titled “Returns”Promise<string[]>
Implementation of
Section titled “Implementation of”SnapshotStorage.listSnapshotIds
deleteSession()
Section titled “deleteSession()”deleteSession(params): Promise<void>;Defined in: src/session/file-storage.ts:126
Deletes all data for a session by removing its root directory (<baseDir>/<sessionId>/) recursively.
No-ops if the session directory does not exist.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { sessionId: string; } |
params.sessionId | string |
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”loadManifest()
Section titled “loadManifest()”loadManifest(params): Promise<SnapshotManifest>;Defined in: src/session/file-storage.ts:140
Loads the snapshot manifest for a scope. Returns a default manifest with the current timestamp if none exists yet.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { location: SnapshotLocation; } |
params.location | SnapshotLocation |
Returns
Section titled “Returns”Promise<SnapshotManifest>
Implementation of
Section titled “Implementation of”saveManifest()
Section titled “saveManifest()”saveManifest(params): Promise<void>;Defined in: src/session/file-storage.ts:155
Persists the snapshot manifest for a scope to disk.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | { location: SnapshotLocation; manifest: SnapshotManifest; } |
params.location | SnapshotLocation |
params.manifest | SnapshotManifest |
Returns
Section titled “Returns”Promise<void>