import { HistoryEntry } from "../types/index.js"; import { AggregateChanges } from "./aggregate-changes.js"; /** * Callback for validation on property change. * Return false to reject the change, or throw an error. */ export type OnChangeValidator = (path: string, newValue: any) => boolean | void; /** * Tracks changes in Aggregates using Proxy. * * Features: * - Tracks changes in primitive properties * - Tracks changes in nested entities (1:1) * - Tracks changes in collections (1:N) * - Calculates depth automatically * - Generates AggregateChanges for persistence * - Supports validation on change via onChangeValidator */ export declare class ChangeTracker { private target; private rootEntityName; private path; private depth; private parentId?; private parentEntity?; private rootTracker?; private history; private originalValues; private trackedArrays; private trackedEntities; private onChangeValidator?; constructor(target: any, rootEntityName: string, path?: string, depth?: number, parentId?: string | undefined, parentEntity?: string | undefined, rootTracker?: ChangeTracker | undefined); /** * Sets a validator callback that will be called on every property change. * The validator can: * - Return false to reject the change (value will be reverted) * - Throw an error to reject the change with an error * - Return true/undefined to accept the change */ setOnChangeValidator(validator: OnChangeValidator): void; private captureInitialState; private captureEntityState; private captureArrayState; createProxy(): any; private createArrayProxy; /** * Returns all detected changes as AggregateChanges. */ getChanges>(): AggregateChanges; /** * Collects all root-level changes: primitive properties and primitive arrays. */ private collectRootChanges; /** * Compares two arrays for equality (shallow comparison for primitives). */ private arraysEqual; private analyzeCollectionChanges; /** * Recursively marks all nested items as created when a parent is created. */ private markNestedItemsAsCreated; /** * Recursively marks all nested items as deleted when a parent is deleted. * Uses the original captured state to find nested items. */ private markNestedItemsAsDeleted; /** * Recursively marks nested items as deleted from a JSON object. * This is used when processing cloned (JSON) state. */ private markNestedJsonItemAsDeleted; /** * Extracts identity key from a JSON object by looking at the original Entity instances. */ private extractIdentityKeyFromJson; private collectNestedArrays; private analyzeEntityChanges; private detectEntityChangeState; private isAbsent; private detectArrayChanges; private detectChangedFields; private handleArrayAssignment; private handleEntityChange; private getRootTracker; private isSelfReference; private buildPath; private shouldSkipProperty; private getValueAtPath; private extractRelationField; private getItemKey; private getEntityId; private getEntityName; /** * Checks if a value is a primitive (string, number, boolean, null, undefined, symbol, bigint). */ private isPrimitiveValue; /** * Checks if an array contains only primitive values. * Empty arrays are not treated as primitive at capture time since their * element type is not yet known. */ private isPrimitiveArray; /** * Determines whether an array should be tracked as a primitive property * during change analysis. Uses current contents when available, otherwise * falls back to the originally captured clone. */ private shouldTreatArrayAsPrimitive; private isEqual; private deepEqual; private hasChanged; private toCanonicalString; private throwCircularReferenceError; private cloneArray; private deepClone; getHistory(): HistoryEntry[]; clearHistory(): void; markAsClean(): void; getTarget(): any; } //# sourceMappingURL=change-tracker.d.ts.map