47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import { ICalendarEvent } from '../types/CalendarTypes';
|
|
import { IEventRepository, UpdateSource } from './IEventRepository';
|
|
import { IndexedDBService } from '../storage/IndexedDBService';
|
|
import { OperationQueue } from '../storage/OperationQueue';
|
|
/**
|
|
* IndexedDBEventRepository
|
|
* Offline-first repository using IndexedDB as single source of truth
|
|
*
|
|
* All CRUD operations:
|
|
* - Save to IndexedDB immediately (always succeeds)
|
|
* - Add to sync queue if source is 'local'
|
|
* - Background SyncManager processes queue to sync with API
|
|
*/
|
|
export declare class IndexedDBEventRepository implements IEventRepository {
|
|
private indexedDB;
|
|
private queue;
|
|
constructor(indexedDB: IndexedDBService, queue: OperationQueue);
|
|
/**
|
|
* Load all events from IndexedDB
|
|
* Ensures IndexedDB is initialized and seeded on first call
|
|
*/
|
|
loadEvents(): Promise<ICalendarEvent[]>;
|
|
/**
|
|
* Create a new event
|
|
* - Generates ID
|
|
* - Saves to IndexedDB
|
|
* - Adds to queue if local (needs sync)
|
|
*/
|
|
createEvent(event: Omit<ICalendarEvent, 'id'>, source?: UpdateSource): Promise<ICalendarEvent>;
|
|
/**
|
|
* Update an existing event
|
|
* - Updates in IndexedDB
|
|
* - Adds to queue if local (needs sync)
|
|
*/
|
|
updateEvent(id: string, updates: Partial<ICalendarEvent>, source?: UpdateSource): Promise<ICalendarEvent>;
|
|
/**
|
|
* Delete an event
|
|
* - Removes from IndexedDB
|
|
* - Adds to queue if local (needs sync)
|
|
*/
|
|
deleteEvent(id: string, source?: UpdateSource): Promise<void>;
|
|
/**
|
|
* Generate unique event ID
|
|
* Format: {timestamp}-{random}
|
|
*/
|
|
private generateEventId;
|
|
}
|