/** * Temporal Entity Snapshots & Multi-Entity Joins * * Maintains point-in-time entity states and enables cross-entity * queries for compliance evaluation (Enhancement #16). */ import type { ArkaEntity } from '@arka-protocol/types'; /** * Entity snapshot at a point in time */ export interface EntitySnapshot { /** Snapshot identifier */ id: string; /** Entity ID */ entityId: string; /** Entity type */ entityType: string; /** Snapshot timestamp */ timestamp: string; /** Entity data at this point */ data: Record; /** Previous snapshot ID (for chaining) */ previousSnapshotId?: string; /** Change reason */ changeReason?: string; /** Actor who made the change */ changedBy?: string; /** Hash of the data for integrity */ dataHash: string; } /** * Entity relationship */ export interface EntityRelationship { /** Source entity ID */ sourceEntityId: string; /** Target entity ID */ targetEntityId: string; /** Relationship type */ type: string; /** Relationship properties */ properties?: Record; /** When relationship was established */ establishedAt: string; /** When relationship ended (if applicable) */ endedAt?: string; } /** * Join query specification */ export interface EntityJoinQuery { /** Primary entity type */ primaryEntityType: string; /** Primary entity filter */ primaryFilter?: Record; /** Joins to other entities */ joins: Array<{ /** Entity type to join */ entityType: string; /** Relationship type to follow */ relationshipType: string; /** Alias for joined entity */ alias: string; /** Filter on joined entity */ filter?: Record; }>; /** Point in time for the query */ asOf?: string; } /** * Join result */ export interface EntityJoinResult { /** Primary entity */ primary: EntitySnapshot; /** Joined entities by alias */ joined: Record; /** Relationships used */ relationships: EntityRelationship[]; } /** * Temporal storage interface */ export interface TemporalStorage { /** Store a snapshot */ storeSnapshot(snapshot: EntitySnapshot): Promise; /** Get snapshot by ID */ getSnapshot(snapshotId: string): Promise; /** Get latest snapshot for entity */ getLatestSnapshot(entityId: string): Promise; /** Get snapshot at specific time */ getSnapshotAtTime(entityId: string, timestamp: string): Promise; /** Get all snapshots for entity */ getSnapshotHistory(entityId: string, limit?: number): Promise; /** Store relationship */ storeRelationship(relationship: EntityRelationship): Promise; /** Get relationships for entity */ getRelationships(entityId: string, type?: string, asOf?: string): Promise; /** Find entities matching criteria */ findEntities(entityType: string, filter: Record, asOf?: string): Promise; } /** * In-memory temporal storage implementation */ export declare class InMemoryTemporalStorage implements TemporalStorage { private snapshots; private entityIndex; private relationships; storeSnapshot(snapshot: EntitySnapshot): Promise; getSnapshot(snapshotId: string): Promise; getLatestSnapshot(entityId: string): Promise; getSnapshotAtTime(entityId: string, timestamp: string): Promise; getSnapshotHistory(entityId: string, limit?: number): Promise; storeRelationship(relationship: EntityRelationship): Promise; getRelationships(entityId: string, type?: string, asOf?: string): Promise; findEntities(entityType: string, filter: Record, asOf?: string): Promise; } /** * Temporal Entity Manager */ export declare class TemporalEntityManager { private storage; constructor(storage?: TemporalStorage); /** * Create a snapshot from an entity */ createSnapshot(entity: ArkaEntity, changeReason?: string, changedBy?: string): Promise; /** * Get entity state at a specific time */ getEntityAtTime(entityId: string, timestamp: string): Promise; /** * Get current entity state */ getCurrentEntity(entityId: string): Promise; /** * Get entity history */ getEntityHistory(entityId: string, limit?: number): Promise; /** * Compare two points in time for an entity */ compareEntityAtTimes(entityId: string, time1: string, time2: string): Promise<{ snapshot1: EntitySnapshot | null; snapshot2: EntitySnapshot | null; changes: Array<{ field: string; oldValue: unknown; newValue: unknown; }>; }>; /** * Create a relationship between entities */ createRelationship(sourceEntityId: string, targetEntityId: string, type: string, properties?: Record): Promise; /** * Execute a join query */ executeJoinQuery(query: EntityJoinQuery): Promise; private hashData; } /** * Create temporal entity manager */ export declare function createTemporalEntityManager(storage?: TemporalStorage): TemporalEntityManager; //# sourceMappingURL=entitySnapshots.d.ts.map