Calendar/src/repositories/MockAuditRepository.ts
Janus C. H. Knudsen 863b433eba Refactors calendar project structure and build configuration
Consolidates V2 codebase into main project directory
Updates build script to support simplified entry points
Removes redundant files and cleans up project organization

Simplifies module imports and entry points for calendar application
2025-12-17 23:54:25 +01:00

49 lines
1.6 KiB
TypeScript

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<IAuditEntry> {
readonly entityType: EntityType = 'Audit';
async sendCreate(entity: IAuditEntry): Promise<IAuditEntry> {
// 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<IAuditEntry> {
// Audit entries are immutable - updates should not happen
throw new Error('Audit entries cannot be updated');
}
async sendDelete(_id: string): Promise<void> {
// Audit entries should never be deleted
throw new Error('Audit entries cannot be deleted');
}
async fetchAll(): Promise<IAuditEntry[]> {
// 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<IAuditEntry | null> {
// For now, return null - audit entries are local-first
return null;
}
}