import { AuthorizationKey, DocumentBaseline, ObjectIdentifier, Operation } from '@verdant-web/common'; import { Context } from '../context/context.js'; import { EntityChange } from './types.js'; export type EntityMetadataView = { view: any; fromOlderVersion: boolean; deleted: boolean; empty: boolean; updatedAt: number; latestTimestamp: string | null; authz?: AuthorizationKey; }; export declare class EntityMetadata { private ctx; private baseline; private confirmedOperations; private ephemeralOperations?; private pendingOperations; readonly oid: string; constructor({ oid, ctx, confirmedOperations, pendingOperations, baseline, }: { oid: ObjectIdentifier; ctx: Context; confirmedOperations?: Operation[]; pendingOperations?: Operation[]; baseline?: DocumentBaseline; }); /** * Compute the current view of the entity. */ computeView: (omitPending?: boolean) => EntityMetadataView; addBaseline: (baseline: DocumentBaseline) => void; /** * @returns total number of new operations added */ addConfirmedOperations: (operations: Operation[]) => number; addPendingOperation: (operation: Operation) => void; addEphemeralOperation: (operation: Operation) => void; clearEphemeralOperations: () => Operation[] | undefined; discardPendingOperation: (operation: Operation) => void; private applyOperations; } /** * Represents the metadata for a group of entities underneath a Document. * Metadata is separated out this way so that these classes can be * garbage collected when the root Document goes out of scope. */ export declare class EntityFamilyMetadata { private ctx; private entities; private onPendingOperations; private rootOid; constructor({ ctx, onPendingOperations, rootOid, }: { ctx: Context; onPendingOperations: (ops: Operation[]) => void; rootOid: ObjectIdentifier; }); get: (oid: ObjectIdentifier) => EntityMetadata; getAllOids: () => string[]; addConfirmedData: ({ baselines, operations, isLocal, }: { baselines?: DocumentBaseline[]; operations?: Record; isLocal?: boolean; }) => EntityChange[]; /** * Adds local, unconfirmed operations to the system. * The API is different here to streamline for the way * local changes are usually handled, as a list. */ addPendingData: (operations: Operation[]) => EntityChange[]; private ephemeralMemo; private flushAllEphemeral; addEphemeralData: (operations: Operation[]) => EntityChange[]; replaceAllData: ({ operations, baselines, }: { operations?: Record; baselines?: DocumentBaseline[]; }) => EntityChange[]; discardPendingOperation: (operation: Operation) => void; }