import type { System } from "@/api/systems";

export type TaskStatus = "todo" | "in_progress" | "done" | "cancelled";
export type TaskPriority = "none" | "low" | "medium" | "high";
/**
 * What KIND of work a task is, not how it is going.
 *   work  — ships a change (default)
 *   issue — corrective; something was broken
 *   spike — time-boxed, output is knowledge; it succeeds by producing an
 *           answer and nothing ships at the end of it
 *   plan  — retired (plans are milestones); kept so historical plan-tasks
 *           still render their kind
 */
export type TaskKind = "work" | "plan" | "issue" | "spike";
export type NoteType = "note" | "process" | "snippet";

export interface Note {
  id: number;
  title: string;
  body: string;
  description: string | null;
  tags: string[];
  parent_id: number | null;
  parent_title?: string | null;
  project_id: number | null;
  milestone_id: number | null;
  status: TaskStatus | null;
  priority: TaskPriority | null;
  due_date: string | null;
  started_at: string | null;
  completed_at: string | null;
  recurrence_rule: Record<string, unknown> | null;
  recurrence_next_spawn_at: string | null;
  is_task: boolean;
  note_type: NoteType;
  task_kind?: TaskKind;
  // The note's own check (milestone 317). Empty on almost every note — that
  // is the normal case: a note with no `verify_with` is a DECISION, and there
  // is nothing to go and check. Only a note asserting a fact about something
  // outside the operator's control carries one. `verified_at` null while
  // `verify_with` is set means NOBODY HAS EVER CONFIRMED IT, which is the
  // state the sweep ranks first.
  verify_with?: string;
  expires_when?: string;
  verified_at?: string | null;
  systems?: System[];
  arose_from_id?: number | null;
  created_at: string;
  updated_at: string;
}

export interface NoteListResponse {
  notes: Note[];
  total: number;
}
