import client from "./client"; export interface DataSource { id: string; name: string; display_name: string; type: string; url: string | null; description: string | null; is_enabled: boolean; last_sync_at: string | null; last_sync_status: string | null; last_sync_stats: Record | null; sync_frequency: string | null; config: Record | null; created_at: string | null; } export interface SyncResult { message: string; source: string; stats: Record; } export interface SyncAllResult { message: string; results: Array<{ source: string; status: string; stats?: Record; detail?: string; }>; } export interface DataSourceStats { id: string; name: string; display_name: string; type: string; is_enabled: boolean; last_sync_at: string | null; last_sync_status: string | null; last_sync_stats: Record | null; total_templates: number; total_rules: number; } /** List all data sources. */ export async function getDataSources(): Promise { const { data } = await client.get("/data-sources"); return data; } /** Update a data source (enable/disable, config). */ export async function updateDataSource( id: string, body: Partial<{ is_enabled: boolean; sync_frequency: string; config: Record }> ): Promise<{ message: string; id: string }> { const { data } = await client.patch(`/data-sources/${id}`, body); return data; } /** Trigger sync for a specific data source. */ export async function syncDataSource(id: string): Promise { const { data } = await client.post(`/data-sources/${id}/sync`); return data; } /** Trigger sync for all enabled data sources. */ export async function syncAllDataSources(): Promise { const { data } = await client.post("/data-sources/sync-all"); return data; } /** Get stats for a specific data source. */ export async function getDataSourceStats(id: string): Promise { const { data } = await client.get(`/data-sources/${id}/stats`); return data; }