import type { AsyncResult, MaybePromise, PosixDate, UUID, VariantFromTag, VariantTag, } from "@fabric/core"; import type { StoreQueryError } from "../errors/query-error.ts"; import type { Event } from "./event.ts"; import type { StoredEvent } from "./stored-event.ts"; export interface EventStore { /** * Store a new event in the event store. */ append( event: T, ): AsyncResult, StoreQueryError>; getEventsFromStream( streamId: UUID, ): AsyncResult[], StoreQueryError>; subscribe( events: TEventKey[], subscriber: EventSubscriber>, ): void; } export type EventSubscriber = ( event: StoredEvent, ) => MaybePromise; export interface EventFilterOptions { fromDate?: PosixDate; toDate?: PosixDate; fromVersion?: bigint; toVersion?: bigint; limit?: number; offset?: number; }