/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { type SupportedStorageTypes } from "../StringifyTools.js"; export type StoreData = Record>; /** * A single operation within a WAL commit. */ export type WalOp = { op: "upd"; key: string; values: Record; } | { op: "del"; key: string; values?: string[]; }; /** * A commit is a timestamped array of operations serialized as one WAL line. */ export interface WalCommit { /** * Millis since Unix epoch when the commit was written. */ ts: number; /** * The operations in this commit. */ ops: WalOp[]; } /** * 48-bit commit ID: high 32 bits = segment number, low 16 bits = line offset. */ export interface WalCommitId { segment: number; offset: number; } /** Maximum line offset within a single segment (16-bit). */ export declare const MAX_SEGMENT_LINES = 65535; /** * Encode context array to a `/`-delimited key, URL-encoding `%` and `/` in each segment. */ export declare function encodeContextKey(contexts: string[]): string; /** * Decode a `/`-delimited context key back to a context array. */ export declare function decodeContextKey(key: string): string[]; /** * Serialize a commit to a JSON line for the WAL. */ export declare function serializeCommit(commit: WalCommit): string; /** * Deserialize a JSON line back to a commit. * * Handles legacy bare-array format by wrapping as `{ ts: 0, ops }`. * * Throws if the parsed value is not a structurally valid commit so callers * (e.g. {@link WalReader}) can skip the line rather than yielding a commit * that crashes replay downstream. */ export declare function deserializeCommit(line: string): WalCommit; /** * Format a segment number as an 8-digit hex filename with `.jsonl` extension. */ export declare function segmentFilename(segment: number): string; /** * Format a segment number as a compressed segment filename. */ export declare function compressedSegmentFilename(segment: number): string; /** * Returns true if the filename is a gzip-compressed segment file. */ export declare function isCompressedSegmentFile(name: string): boolean; /** * Parse a segment number from a filename. Returns undefined if not a valid segment file. */ export declare function parseSegmentFilename(name: string): number | undefined; /** * Combine a commit ID into a single number (48-bit safe in JS). */ export declare function commitIdToNumber(id: WalCommitId): number; /** * Compare two commit IDs. Returns negative if a < b, 0 if equal, positive if a > b. */ export declare function compareCommitIds(a: WalCommitId, b: WalCommitId): number; //# sourceMappingURL=WalCommit.d.ts.map