/**
 * Errand Repository Port Interface
 *
 * Port for Errand aggregate operations.
 * Implementations (Drizzle, etc.) are adapters.
 */

import type { Errand, NewErrand, ErrandStatus } from '../schema.js';

/**
 * Data for creating a new errand.
 * Omits system-managed fields (id, createdAt, updatedAt).
 */
export type CreateErrandData = Omit<NewErrand, 'id' | 'createdAt' | 'updatedAt'>;

/**
 * Data for updating an errand.
 */
export type UpdateErrandData = Partial<Omit<NewErrand, 'id' | 'createdAt'>>;

/**
 * Errand with the agent alias joined in.
 */
export interface ErrandWithAlias extends Errand {
  agentAlias: string | null;
}

/**
 * Filter options for listing errands.
 */
export interface FindAllErrandOptions {
  projectId?: string;
  status?: ErrandStatus;
}

/**
 * Errand Repository Port
 */
export interface ErrandRepository {
  create(data: CreateErrandData): Promise<Errand>;
  findById(id: string): Promise<ErrandWithAlias | null>;
  findAll(options?: FindAllErrandOptions): Promise<ErrandWithAlias[]>;
  update(id: string, data: UpdateErrandData): Promise<Errand | null>;
  delete(id: string): Promise<void>;
}
