import { api } from '@/api/client'
import type { Trace } from '@/types/trace'

export const tracesService = {
  reload: () =>
    api.post('api/traces/reload').json<{ data: { message: string }; status: string }>(),
  listAll: () => api.get('api/traces').json<{ data: Trace[]; status: string }>(),
  getOne: (id: string) =>
    api.get(`api/traces/${id}`).json<{ data: Trace; status: string }>(),
  process: (payload: { traceJson: string; name?: string }) =>
    api.post('api/traces', { json: payload }).json<{ data: Trace; status: string }>(),
  deletePasted: (id: string) =>
    api.delete(`api/traces/${id}`).json<{ data: { message: string }; status: string }>(),
  deleteAllPasted: () =>
    api.delete('api/traces?source=pasted').json<{ data: { message: string }; status: string }>(),
}
