import { DataContainer, RawItem } from '@dcupl/common'; /** * Change tracking state machine states * - clean: No changes tracked * - tracking: Actively tracking incremental changes * - full-reset: A full reset occurred, all subsequent changes are part of the reset */ type ChangeTrackerState = 'clean' | 'tracking' | 'full-reset'; /** * ChangeTracker detects and records which attributes and items have changed during data updates. * * This enables partial updates by tracking: * - Which model attributes have changed * - Which specific items were added/modified/deleted * - Whether a full model reset occurred (type='set') * * State Machine: * - clean → tracking (first update/upsert/remove) * - clean → full-reset (first set) * - tracking → full-reset (set occurs) * - full-reset → full-reset (stays in full-reset until clear()) * - any → clean (clear() called) */ export declare class ChangeTracker { private changedAttributes; private changedItems; private deletedItems; private changedRows; private deletedRows; private modelFullReset; private state; constructor(); /** * Records changes from a data container using state machine logic * @param container - The data container with changes */ recordDataChange(container: DataContainer): void; /** * Records a specific attribute change * @param modelKey - The model key * @param attributeKey - The attribute key that changed */ recordAttributeChange(modelKey: string, attributeKey: string): void; /** * Records changed data items and determines which attributes changed * @param modelKey - The model key * @param data - The changed data items */ private recordChangedData; /** * Records deleted items * @param modelKey - The model key * @param data - The deleted data items */ private recordDeletedItems; private addRows; /** * Re-reads the changed and deleted item keys from the recorded rows. A row * keyed by a custom `keyProperty` or by `autoGenerateKey` gets its `key` * only when the parser applies the keys (`handleAlternativeKey`), after the * row was recorded: without this its item was missing from * getChangedItems() / getDeletedItems() (#368). Call it once the keys are * applied. */ refreshItemKeys(): void; /** * Gets all changed attributes grouped by model * @returns Map of modelKey → Set of changed attributeKeys */ getChangedAttributes(): Map>; /** * Gets changed attributes for a specific model * @param modelKey - The model key * @returns Set of changed attribute keys, or undefined if model has no changes */ getChangedAttributesForModel(modelKey: string): Set | undefined; /** * Gets changed items for a specific model * @param modelKey - The model key * @returns Set of changed item keys, or empty set if no changes */ getChangedItems(modelKey: string): Set; /** * Gets deleted items for a specific model * @param modelKey - The model key * @returns Set of deleted item keys, or empty set if no deletions */ getDeletedItems(modelKey: string): Set; /** * Gets all models that have changes (not full resets) * @returns Array of model keys with changes */ getModelsWithChanges(): string[]; /** * Every model the pending update effectively touches: attribute changes, * item changes, deletions AND full resets (#245). `getModelsWithChanges()` * deliberately excludes full resets and a deletion records its attribute * changes only later, inside the parser — so callers that need "which * models did this update change" must not reconstruct the union from the * per-kind accessors. Returns a fresh Set that survives `clear()`. */ getEffectivelyChangedModels(): Set; /** * Gets all models that had a full reset (type='set') * @returns Set of model keys that need full reset */ getModelsWithFullReset(): Set; /** * Checks if a model had a full reset * @param modelKey - The model key * @returns true if model had type='set', false otherwise */ hasFullReset(modelKey: string): boolean; /** * Checks if there are any changes tracked * @returns true if any changes are tracked, false otherwise */ hasChanges(): boolean; /** * Gets the total number of changed items across all models * @returns Total count of changed items */ getTotalChangedItemCount(): number; /** * Gets the ratio of models with changes to total models * @param totalModelCount - Total number of models in the system * @returns Ratio between 0 and 1 */ getAffectedModelRatio(totalModelCount: number): number; /** * Gets the ratio of changed items to total items for a model * @param modelKey - The model key * @param totalItemCount - Total number of items in the model * @returns Ratio between 0 and 1 */ getAffectedItemRatio(modelKey: string, totalItemCount: number): number; /** * Clears all tracked changes and resets state to clean */ clear(): void; /** * Checks if the tracker is in full-reset state * @returns true if in full-reset state, false otherwise */ requiresFullReset(): boolean; /** * Gets the current state of the change tracker * @returns The current state */ getState(): ChangeTrackerState; /** * Gets statistics about tracked changes * @returns Statistics object */ getStats(): { modelsWithChanges: number; modelsWithFullReset: number; totalChangedItems: number; totalDeletedItems: number; totalChangedAttributes: number; }; } export {};