/**
 * 触发器统一视图 API 调用。
 */

import { apiClient } from './client';

/** 统一触发器条目 */
export interface UnifiedTriggerItem {
  id: number;
  name: string;
  source: 'biz' | 'ai' | 'etl';
  trigger_condition: string;
  status: string;
  last_run_at: string | null;
  next_run_at: string | null;
  last_error: string | null;
}

/** 获取所有触发器统一视图 */
export async function fetchUnifiedTriggers(): Promise<UnifiedTriggerItem[]> {
  const { data } = await apiClient.get<UnifiedTriggerItem[]>('/admin/triggers/unified');
  return data;
}
