// ============================================================
// infrastructure/storage/types.ts — 本地存储模块共享类型
// ============================================================

// ---------- 任务记录 ----------

export interface TaskRecordEntry {
  id: string;
  user_id: string;
  model_id: string;
  status: string;
  data_json: string;
  created_at: number;
  updated_at: number;
}

export interface TaskQueryFilter {
  status?: string;
  model_id?: string;
  limit?: number;
  offset?: number;
}

// ---------- 订单记录 ----------

export type OrderType = 'recharge' | 'vip';

export interface OrderRecordEntry {
  id: string;
  user_id: string;
  order_type: OrderType;
  status: string;
  data_json: string;
  created_at: number;
}

export interface OrderQueryFilter {
  order_type?: OrderType;
  status?: string;
  limit?: number;
  offset?: number;
}

// ---------- 参数历史 ----------

export interface ParamHistoryEntry {
  id?: number;
  task_id: string;
  user_id: string;
  model_id: string;
  model_name: string;
  input_params_json: string;
  output_data_json?: string;
  tag?: string;
  created_at: number;
}

// ---------- 媒体缓存 ----------

export interface MediaCacheEntry {
  id?: number;
  user_id: string;
  url_hash: string;
  original_url: string;
  local_path: string;
  mime_type: string;
  file_size: number;
  created_date: string;
  accessed_at: number;
}

// ---------- 同步游标 ----------

export type SyncDataType = 'tasks' | 'recharge_orders' | 'vip_orders';

export interface SyncCursor {
  data_type: SyncDataType;
  last_page: number;
  total_count: number;
  synced_at: number;
}

// ---------- 应用设置 ----------

export interface AppSetting {
  key: string;
  value: string;
  updated_at: number;
}

export const SETTING_KEYS = {
  OUTPUT_PATH: 'output_path',
  TEAM_REPO_PATH: 'team_repo_path',
} as const;
