/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import type { Duration } from "#time/Duration.js"; import type { Directory } from "../../fs/Directory.js"; import type { DataNamespace } from "../DataNamespace.js"; import { type CloneableStorage, FilesystemStorageDriver, StorageDriver } from "../StorageDriver.js"; import type { SupportedStorageTypes } from "../StringifyTools.js"; import { type WalCommitId } from "./WalCommit.js"; import { WalSnapshot } from "./WalSnapshot.js"; import { WalTransaction } from "./WalTransaction.js"; /** * Transactional storage backend using a write-ahead log (WAL). * * Data is loaded from the snapshot + WAL on first read and cached. Writes update the cache incrementally so * subsequent reads avoid a full reload. */ export declare class WalStorageDriver extends FilesystemStorageDriver implements CloneableStorage { #private; static readonly id = "wal"; static create(namespace: DataNamespace, descriptor: WalStorageDriver.Descriptor): Promise; constructor(namespace?: DataNamespace, options?: WalStorageDriver.Options); get initialized(): boolean; initialize(): Promise; close(): Promise; clone(): Promise; get(contexts: string[], key: string): Promise; keys(contexts: string[]): Promise; values(contexts: string[]): Promise>; contexts(contexts: string[]): Promise; set(contexts: string[], values: Record): Promise; set(contexts: string[], key: string, value: SupportedStorageTypes): Promise; delete(contexts: string[], key: string): Promise; clearAll(contexts: string[]): Promise; begin(): Promise; /** * Reconstruct a snapshot as of the given timestamp. * * If `asOf` is omitted, returns the full current state. */ snapshotAtTime(asOf?: number): Promise; /** * Reconstruct a snapshot at the given commit ID. * * If `commitId` is omitted, returns the full current state. */ snapshotAtCommit(commitId?: WalCommitId): Promise; } export declare namespace WalStorageDriver { interface Descriptor extends StorageDriver.Descriptor { /** * Maximum WAL segment size in bytes. */ maxSegmentSize?: number; /** * Whether to fsync after each WAL write. */ fsync?: boolean; /** * Whether to gzip-compress snapshots. Defaults to true if the runtime supports gzip. */ compressSnapshot?: boolean; /** * Whether to gzip-compress rotated WAL segments. Defaults to true if the runtime supports gzip. */ compressLog?: boolean; /** * Whether to capture a head snapshot at the truncation boundary when cleaning old WAL segments. */ headSnapshot?: boolean; } interface Options { /** * Override the storage directory. When omitted the directory is derived from the root passed to the * constructor. Used by {@link WalStorageDriver.clone} to point at a temporary copy. */ storageDir?: Directory; /** * Maximum WAL segment size in bytes before the writer rotates to a new file. */ maxSegmentSize?: number; /** * Whether to fsync after each WAL write for durability against unexpected process termination. */ fsync?: boolean; /** * Interval between periodic snapshots that consolidate WAL state into a single file. */ snapshotInterval?: Duration; /** * Interval between periodic WAL cleanup that removes segments already captured in a snapshot. Undefined * disables cleanup. */ cleanInterval?: Duration; /** * Whether to gzip-compress snapshots. Defaults to true if the runtime supports gzip. */ compressSnapshot?: boolean; /** * Whether to gzip-compress rotated WAL segments. Defaults to true if the runtime supports gzip. */ compressLog?: boolean; /** * Whether to capture a head snapshot at the truncation boundary when cleaning old WAL segments. */ headSnapshot?: boolean; } const defaults: { readonly maxSegmentSize: number; readonly fsync: true; readonly snapshotInterval: Duration; readonly cleanInterval: Duration | undefined; readonly compressSnapshot: boolean; readonly compressLog: boolean; readonly headSnapshot: true; }; } //# sourceMappingURL=WalStorageDriver.d.ts.map