import { EventClient } from "./eventDbHelpers"; import { GenericEventBase, GenericEventInput } from "./schemaHelpers"; import { EventFromType, StreamOptionsForEvents } from "./utils"; export declare class MultiStreamProjectionBase, Client extends EventClient, V extends Record, ET extends EventType = EventType, E extends EventFromType = EventFromType> { protected eventsClient: Client; private loadExistingProjection; /** The type of this projection, used to look up the projection in the database */ protected get projectionType(): string; protected _events?: Promise<(E | GenericEventInput)[]>; protected _stagedEvents: (E | GenericEventInput)[]; private _savedProjection?; constructor(eventsClient: Client, loadExistingProjection?: boolean); protected get savedProjection(): Promise<{ data: V; latestEventId: string; } | undefined>; private getEventsAfterIdentifiers; private get events(); protected projectionEvents(): Promise<(E | GenericEventInput)[]>; /** Stage events without saving them to the database */ apply(events: GenericEventInput[]): this; /** Replace internal events array without affecting database */ fromHistory(events: E[]): this; /** Clear cached events and projection to force fresh data on next access */ refresh(): this; /** Reduce events with a custom reducer function */ protected reduceEvents(reducer: (acc: T, event: E | GenericEventInput) => T, initialValue: T): Promise; /** Check if there are events to save */ isDirty(): Promise; /** Save the projection only if it has events to save, returns true if saved */ saveIfDirty(overwrite?: boolean): Promise; /** Save the projection to the database */ saveProjection(overwrite?: boolean): Promise<{ id: string; data: unknown; type: string; latestEventId: string; status: "created" | "updated" | "skipped"; }>; /** Get a value from the saved projection or return the fallback */ protected fromProjectionOrDefault(key: keyof V, fallback: T): Promise; get id(): string; protected getStreamOptions(): Promise[]> | StreamOptionsForEvents[]; asJson(): Promise; }