import { ISync, EntityType, SyncStatus } from '../types/CalendarTypes';

/**
 * IEntityService<T> - Generic interface for entity services with sync capabilities
 *
 * All entity services implement this interface to enable polymorphic operations.
 */
export interface IEntityService<T extends ISync> {
  /**
   * Entity type discriminator for runtime routing
   */
  readonly entityType: EntityType;

  /**
   * Get all entities from IndexedDB
   */
  getAll(): Promise<T[]>;

  /**
   * Save an entity (create or update) to IndexedDB
   * @param entity - Entity to save
   * @param silent - If true, skip event emission (used for seeding)
   */
  save(entity: T, silent?: boolean): Promise<void>;

  /**
   * Mark entity as successfully synced
   */
  markAsSynced(id: string): Promise<void>;

  /**
   * Mark entity as sync error
   */
  markAsError(id: string): Promise<void>;

  /**
   * Get current sync status for an entity
   */
  getSyncStatus(id: string): Promise<SyncStatus | null>;
}
