/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { MaybePromise, StorageContext } from "@matter/general"; import { EventNumber } from "@matter/types"; import { EventStore, OccurrenceSummary } from "./EventStore.js"; import { Occurrence } from "./Occurrence.js"; /** * Common base class for standard event stores. * * Owns event numbering for both persistent and ephemeral stores: numbers are reserved in blocks under * {@link BaseEventStore.LAST_RESERVED_NUMBER_KEY}, and a number is handed out only once a reservation covering it is * stored. A restart therefore never reuses a number, whatever the store keeps of its events; only {@link clear} * without `keepNumbering` starts again at 1. * * Also supports data load for both kinds of store so stores can manage conversion when the implementation changes * across restarts. * * @see {@link MatterSpecification.v161.Core} ยง 7.14.1.1 */ export declare abstract class BaseEventStore implements EventStore { #private; /** * @param numberBlockSize how many numbers one reservation write covers; 0 counts as 1. A larger number reduces * writes but must remain small enough to avoid exhausting the full 64-bit event numbering space. */ constructor(storage: StorageContext, numberBlockSize?: number); abstract load(): MaybePromise; abstract add(occurrence: Occurrence): MaybePromise; abstract get(number: EventNumber): MaybePromise; abstract delete(number: EventNumber): MaybePromise; clear(options?: EventStore.ClearOptions): MaybePromise; /** * Settles the pending reservation write. A store that overrides this settles its own writes and then calls it. */ close(): MaybePromise; protected loadInitialState(): Promise<{ reservationEnd: bigint | undefined; eventIds: bigint[]; }>; protected get nextNumber(): bigint; /** * Stores the current numbering as the number to continue from after a restart, before a store discards the events * it would otherwise continue from. */ protected reserveCurrentNumbering(): MaybePromise; /** * The next event number, available once a stored reservation covers it. Synchronous while no reservation write is * pending. */ protected allocateNumber(): MaybePromise; protected get storage(): StorageContext; protected get eventStorage(): StorageContext; protected logLoad(type: string): void; /** * If present in the store, this sub-context contains persisted events. */ static EVENTS_KEY: string; /** * If present in the store, this value designates the next event value to use on startup. Every number handed out * is below it. * * This should really be "lastReservedNumber" but keeping old name for backwards compatibility. */ static LAST_RESERVED_NUMBER_KEY: string; } //# sourceMappingURL=BaseEventStore.d.ts.map