import api from './client'

export interface PartEntry {
  part_key: string
  source_name: string
  prim_path: string | null
  effective_material: string | null
  assignment_provenance: 'manual' | 'auto' | 'source' | 'default'
  is_unassigned: boolean
}

export interface SceneManifest {
  cad_file_id: string
  parts: PartEntry[]
  unmatched_source_rows: string[]
  unassigned_parts: string[]
}

export async function fetchSceneManifest(cadFileId: string): Promise<SceneManifest> {
  const res = await api.get<SceneManifest>(`/cad/${cadFileId}/scene-manifest`)
  return res.data
}

export async function triggerUsdMasterGeneration(cadFileId: string): Promise<{ status: string; task_id: string; cad_file_id: string }> {
  const res = await api.post(`/cad/${cadFileId}/generate-usd-master`)
  return res.data
}
