export type DocumentType = "manual" | "service_manual" | "schematic" | "alignment" | "parts_list" | "firmware" | "datasheet" | "service_bulletin" | "other";
export type NoteType = "repair" | "known_fault" | "alignment" | "spare_part" | "general";

export interface KnowledgeManufacturer {
  id: number;
  name: string;
  slug: string;
  website: string;
  notes: string;
  created_at: string;
  updated_at: string;
}

export interface KnowledgeDevice {
  id: number;
  manufacturer_id: number;
  name: string;
  slug: string;
  model_number: string;
  device_type: string;
  frequency_range: string;
  production_year_from: number | null;
  production_year_to: number | null;
  notes: string;
  created_at: string;
  updated_at: string;
  manufacturer: KnowledgeManufacturer;
}

export interface KnowledgeDocument {
  id: number;
  manufacturer_id: number;
  device_id: number | null;
  title: string;
  slug: string;
  document_type: DocumentType;
  language: string;
  file_name: string;
  file_path: string;
  mime_type: string;
  file_size: number;
  checksum_sha256: string;
  external_url: string;
  paperless_document_id: string;
  description: string;
  tags: string[];
  created_at: string;
  updated_at: string;
  manufacturer: KnowledgeManufacturer;
  device: KnowledgeDevice | null;
}

export interface KnowledgeNote {
  id: number;
  manufacturer_id: number | null;
  device_id: number | null;
  title: string;
  content: string;
  note_type: NoteType;
  severity: "" | "low" | "medium" | "high" | "critical";
  tags: string[];
  created_at: string;
  updated_at: string;
  manufacturer: KnowledgeManufacturer | null;
  device: KnowledgeDevice | null;
}

export interface KnowledgeSearchResult {
  entity_type: string;
  id: number;
  title: string;
  subtitle: string;
  href: string;
}

export type ManufacturerPayload = Pick<KnowledgeManufacturer, "name" | "notes"> & { website?: string | null };
export type DevicePayload = Omit<KnowledgeDevice, "id" | "slug" | "created_at" | "updated_at" | "manufacturer">;
export type DocumentPayload = Pick<KnowledgeDocument, "manufacturer_id" | "device_id" | "title" | "document_type" | "language" | "paperless_document_id" | "description" | "tags"> & { external_url?: string | null };
export type NotePayload = Pick<KnowledgeNote, "manufacturer_id" | "device_id" | "title" | "content" | "note_type" | "severity" | "tags">;
