Adds audit logging and sync management infrastructure

Introduces comprehensive audit trail system with:
- AuditService to track entity changes
- SyncManager for background sync of audit entries
- New CoreEvents for entity and audit tracking
- Simplified sync architecture with event-driven approach

Prepares system for enhanced compliance and change tracking
This commit is contained in:
Janus C. H. Knudsen 2025-11-21 23:23:04 +01:00
parent dcd76836bd
commit 9ea98e3a04
18 changed files with 469 additions and 414 deletions

38
src/types/AuditTypes.ts Normal file
View file

@ -0,0 +1,38 @@
import { ISync, EntityType } from './CalendarTypes';
/**
* IAuditEntry - Audit log entry for tracking all entity changes
*
* Used for:
* - Compliance and audit trail
* - Sync tracking with backend
* - Change history
*/
export interface IAuditEntry extends ISync {
/** Unique audit entry ID */
id: string;
/** Type of entity that was changed */
entityType: EntityType;
/** ID of the entity that was changed */
entityId: string;
/** Type of operation performed */
operation: 'create' | 'update' | 'delete';
/** User who made the change */
userId: string;
/** Timestamp when change was made */
timestamp: number;
/** Changes made (full entity for create, diff for update, { id } for delete) */
changes: any;
/** Whether this audit entry has been synced to backend */
synced: boolean;
/** Sync status inherited from ISync */
syncStatus: 'synced' | 'pending' | 'error';
}

View file

@ -12,7 +12,7 @@ export type SyncStatus = 'synced' | 'pending' | 'error';
/**
* EntityType - Discriminator for all syncable entities
*/
export type EntityType = 'Event' | 'Booking' | 'Customer' | 'Resource';
export type EntityType = 'Event' | 'Booking' | 'Customer' | 'Resource' | 'Audit';
/**
* ISync - Interface composition for sync status tracking