import { IApiRepository } from './IApiRepository'; import { IAuditEntry } from '../types/AuditTypes'; import { EntityType } from '../types/CalendarTypes'; /** * MockAuditRepository - Mock API repository for audit entries * * In production, this would send audit entries to the backend. * For development/testing, it just logs the operations. */ export class MockAuditRepository implements IApiRepository { readonly entityType: EntityType = 'Audit'; async sendCreate(entity: IAuditEntry): Promise { // Simulate API call delay await new Promise(resolve => setTimeout(resolve, 100)); console.log('MockAuditRepository: Audit entry synced to backend:', { id: entity.id, entityType: entity.entityType, entityId: entity.entityId, operation: entity.operation, timestamp: new Date(entity.timestamp).toISOString() }); return entity; } async sendUpdate(_id: string, _entity: IAuditEntry): Promise { // Audit entries are immutable - updates should not happen throw new Error('Audit entries cannot be updated'); } async sendDelete(_id: string): Promise { // Audit entries should never be deleted throw new Error('Audit entries cannot be deleted'); } async fetchAll(): Promise { // For now, return empty array - audit entries are local-first // In production, this could fetch audit history from backend return []; } async fetchById(_id: string): Promise { // For now, return null - audit entries are local-first return null; } }