/**
 * Abstract interface for an Event Store
 */ export abstract class EventStore { /**
     * Performs necessary orchestration to ready the store
     */ public abstract setup ( ) ; /**
     * Tears down all resources created by the store
     */ public abstract teardown ( ) ; /**
     * Commit aggregate events to the store
     */ public abstract commit < TAggregateCommit extends AggregateCommit > ( commitData ) ; /**
     * Query the commits of an [[Aggregate]] instance
     */ public abstract queryAggregateCommits < TAggregateCommit extends AggregateCommit > ( type , key , options ? ) ; /**
     * Retrieve ordered commits for each aggregate instance of [[AggregateType]]
     */ public abstract scanAggregateCommitsGroupedByKey < TAggregateCommit extends AggregateCommit > ( type ) ; /**
     * Get most recent commit for an [[Aggregate]] instance
     */ public abstract getAggregateHeadCommit < TAggregateCommit extends AggregateCommit > ( type , key ) ; /**
     * Scan store commits
     */ public abstract scan < TAggregateCommit extends AggregateCommit > ( options ? ) ; /**
     * Retrieve commits from the store chronologically
     */ public abstract chronologicalQuery < TAggregateCommit extends AggregateCommit > ( params ) ; public abstract chronologicalKey ( data ) ; } export interface AggregateEvent extends Record < string , any > { type : string ; version ? : number ; } export interface AggregateCommit < TEvent extends AggregateEvent = AggregateEvent , TAggregateType extends string = string > { aggregateType : TAggregateType ; aggregateKey : string ; aggregateVersion : number ; timestamp : number ; events : TEvent [ ] ; expiresAt ? : number ; chronologicalPartition ? : string ; chronologicalKey : string ; } export class VersionConflictError extends Error { public readonly commit : AggregateCommit ; constructor ( commit ) { super ( `${ commit . aggregateType }<${ commit . aggregateKey }> already has commit version ${ commit . aggregateVersion }` ) ; Object . setPrototypeOf ( this , new . target . prototype ) ; this . name = 'VersionConflictError' ; this . commit = commit ; } }