/**
 * Project Repository Port Interface
 *
 * Port for Project aggregate operations and initiative-project junction.
 * Implementations (Drizzle, etc.) are adapters.
 */

import type { Project, NewProject } from '../schema.js';

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

/**
 * Data for updating a project.
 * Name is immutable (used as directory name for worktrees).
 */
export type UpdateProjectData = Omit<Partial<CreateProjectData>, 'name'>;

/**
 * Project Repository Port
 */
export interface ProjectRepository {
  create(data: CreateProjectData): Promise<Project>;
  findById(id: string): Promise<Project | null>;
  findByName(name: string): Promise<Project | null>;
  findAll(): Promise<Project[]>;
  update(id: string, data: UpdateProjectData): Promise<Project>;
  delete(id: string): Promise<void>;

  // Junction ops
  addProjectToInitiative(initiativeId: string, projectId: string): Promise<void>;
  removeProjectFromInitiative(initiativeId: string, projectId: string): Promise<void>;
  findProjectsByInitiativeId(initiativeId: string): Promise<Project[]>;
  setInitiativeProjects(initiativeId: string, projectIds: string[]): Promise<void>;
}
