/**
 * Task dependencies types — task-dependencies.
 * Shared between API handlers and React components.
 */
import type { TaskObject } from './tasks'

// ── Direction literals ────────────────────────────────────────────────────────

export type DependencyDirection = 'blocks' | 'blocked_by'

// ── Domain objects ────────────────────────────────────────────────────────────

export interface TaskDependency {
  id: string
  blocking_task_id: string
  blocked_task_id: string
  created_by: string
  created_at: string // ISO 8601
}

/** A task + the dependency edge id that links it, for removal support. */
export interface DependencyEntry {
  dependency_id: string
  task: TaskObject
}

export interface DependenciesResponse {
  blocking: DependencyEntry[]    // tasks that THIS task blocks (downstream)
  blocked_by: DependencyEntry[]  // tasks that block THIS task (upstream)
}

export interface CriticalPathResult {
  critical_task_ids: string[]
  critical_dependency_ids: string[]
}

// ── API error shapes ──────────────────────────────────────────────────────────

export interface TaskBlockedError {
  error: 'task_blocked'
  blockers: TaskObject[]
}

export interface TaskPatchMeta {
  overridden?: boolean
  overridden_blockers?: string[]
}
