UNPKG

nestjs-event-sourcing-lib

Version:

A comprehensive Event Sourcing and CQRS library for NestJS applications

56 lines 1.51 kB
import { Event } from './event'; /** * Base class for projections (read models) in CQRS system */ export declare abstract class Projection { /** * Unique projection identifier */ protected id: string; /** * Last processed event version */ protected lastEventVersion: number; /** * Last update timestamp */ protected lastUpdated: Date; constructor(id: string); getId(): string; getLastEventVersion(): number; getLastUpdated(): Date; /** * Abstract method for event handling * Must be implemented in each projection */ abstract onEvent(event: Event): Promise<void>; /** * Updates metadata after event processing */ protected updateMetadata(eventVersion?: number): void; /** * Checks if projection supports given event type */ protected supportsEvent(event: Event): boolean; /** * Serializes projection to JSON */ toJSON(): Record<string, any>; /** * Gets projection data for serialization */ protected getProjectionData(): Record<string, any>; /** * Restores projection from JSON */ static fromJSON<T extends Projection>(this: new (...args: any[]) => T, json: Record<string, any>): T; /** * Resets projection to initial state */ reset(): void; /** * Resets projection data (should be overridden in projection) */ protected resetProjectionData(): void; } //# sourceMappingURL=projection.d.ts.map