import apiClient from './client'; export interface IngestionSourceResult { status: 'ok' | 'error' | 'skipped' | 'warning'; message?: string | null; records?: number; classification?: string; confidence?: number; } export interface FetchDataResult { symbol: string; sources: Record; } /** Provider sources that cost an API call/quota. */ export type FetchSource = 'ohlcv' | 'sentiment'; /** Source selector: omit → fetch all; array → those providers; 'recompute' → derived only (free). */ export type FetchSelector = FetchSource[] | 'recompute'; export function fetchData(symbol: string, sources?: FetchSelector) { let sourcesParam: string | undefined; if (sources === 'recompute') sourcesParam = 'recompute'; else if (sources && sources.length) sourcesParam = sources.join(','); const params = sourcesParam ? { sources: sourcesParam } : undefined; return apiClient .post(`ingestion/fetch/${symbol}`, null, { params }) .then((r) => r.data); }