import { ApiClient } from '@/lib/apiClient';

export async function fetchLineage(
  apiClient: ApiClient,
  clipId: string,
  onlyDescendants: boolean = false
) {
  const result = await apiClient.GET('/api/clips/children', {
    params: {
      query: {
        clip_id: clipId,
        descend_from_roots: onlyDescendants ? false : true,
        follow_concat_paths: true,
      },
    },
  });
  if (!result.data) {
    throw new Error(result.error);
  }
  return result.data;
}
