import type { Effect, MaybePromise, PosixDate, UnexpectedError, UUID, VariantFromTag, VariantTag, } from "@fabric/core"; import type { StoreQueryError } from "../errors/query-error.ts"; import type { DomainEvent } from "./event.ts"; import type { StoredEvent } from "./stored-event.ts"; export interface EventStore { /** * Store a new event in the event store. */ append( event: T, ): Effect, StoreQueryError | UnexpectedError>; getEventsFromStream( streamId: UUID, ): Effect[], 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; }