'use client';

import type {
  AiInvocationDetail,
  AiInvocationListQuery,
  AiInvocationStats,
  ListAiInvocationsResponse,
} from '@pac/types';
import { api } from '@/lib/api-client';

const BASE = '/pac/v1/admin/ai-invocations';

export const aiInvocationsApi = {
  list: (q: Partial<AiInvocationListQuery>) =>
    api.get<ListAiInvocationsResponse>(BASE, {
      query: {
        callKey: q.callKey,
        promptVersion: q.promptVersion,
        modelName: q.modelName,
        status: q.status,
        evalMode: q.evalMode,
        linkedPlanId: q.linkedPlanId,
        linkedPatientId: q.linkedPatientId,
        page: q.page ?? 1,
        pageSize: q.pageSize ?? 20,
      },
    }),
  detail: (id: string) => api.get<AiInvocationDetail>(`${BASE}/${encodeURIComponent(id)}`),
  stats: () => api.get<AiInvocationStats>(`${BASE}/stats`),
};
