import { ChangeEntry, ChangeLogOptions, ChangeType, PruneMode } from "./types.js"; /** * Calculates a fast approximation of the memory/JSON byte footprint of a JavaScript object/value. * * @param obj - The value or object to estimate. * @returns Estimated size in bytes. */ export declare function estimateObjectSizeBytes(obj: unknown): number; export declare class ServerChangeTracker { readonly className: string; private currentRevision; private lowestRetainedRevision; private entries; private totalEstimatedBytes; maxAgeMs?: number; maxSizeBytes?: number; maxEntries?: number; pruneMode: PruneMode; /** * Initializes a new ServerChangeTracker instance. * * @param className - Managed entity class name. * @param options - Pruning options such as maxAgeMs, maxSizeBytes, maxEntries, and pruneMode. */ constructor(className: string, options?: ChangeLogOptions); /** * Dynamically updates limits (MB size, TTL age, entries, pruneMode) mid-run and triggers pruning. * * @param options - Partial set of options to overwrite. */ updateOptions(options: Partial): void; /** * Retrieves the current monotonic revision number. * * @returns Latest revision counter. */ getCurrentRevision(): number; /** * Retrieves the lowest revision number retained in the mutation log. * * @returns Oldest retained revision number. */ getLowestRetainedRevision(): number; /** * Retrieves the estimated total memory usage of all retained entries in bytes. * * @returns Total bytes consumed by retained entries. */ getEstimatedSizeBytes(): number; /** * Retrieves the total count of currently retained change entries. * * @returns Number of retained mutation entries. */ getEntryCount(): number; /** * Records a mutation and assigns a new monotonic revision number. * * @param type - Mutation type ('create', 'update', or 'delete'). * @param id - String identifier of mutated entity. * @param data - Optional mutated property payload. * @returns Assigned monotonic revision number. */ recordChange(type: ChangeType, id: string, data?: Partial): number; /** * Records a mutation with an explicit timestamp (useful for testing or replay). * * @param type - Mutation type ('create', 'update', or 'delete'). * @param id - String identifier of mutated entity. * @param data - Optional mutated property payload. * @param timestamp - Explicit Unix timestamp in milliseconds. * @returns Assigned monotonic revision number. */ recordChangeWithTimestamp(type: ChangeType, id: string, data: Partial | undefined, timestamp: number): number; /** * Retrieves all mutations occurring strictly after `clientRevision`. * If `clientRevision` is older than the lowest retained revision in history, * returns `isExpired: true` indicating a full sync is necessary. * * @param clientRevision - The last revision known by the client. * @param allowedIds - Optional Set of allowed IDs for permission filtering. * @returns Object containing isExpired flag and array of change entries. */ getChangesSince(clientRevision: number, allowedIds?: Set): { isExpired: boolean; changes: ChangeEntry[]; }; /** * Prunes entries based on configured maxAgeMs, maxSizeBytes, maxEntries, and pruneMode. */ prune(): void; /** * Clears all recorded entries and resets tracking state. */ clear(): void; }