export interface AdminScheduledJobCloudtentaclesAccount {
  sourceKey: string
  label: string
  enabled: boolean
  assetThreshold: number
}

export interface AdminScheduledJobItem {
  id: string
  type: string
  enabled: boolean
  intervalSeconds: number
  cooldownSeconds: number
  config: {
    assetThreshold?: number
    accounts?: AdminScheduledJobCloudtentaclesAccount[]
    scanLimit?: number
    [key: string]: unknown
  }
}

export interface AdminScheduledJobsConfig {
  enabled: boolean
  jobs: AdminScheduledJobItem[]
}

export interface AdminScheduledJobRuntimeState {
  id: string
  enabled: boolean
  running: boolean
  lastRunAt: string
  lastFinishedAt: string
  nextRunAt: string
  lastStatus: string
  lastMessage: string
  lastAsset: number | null
  lastThreshold: number | null
  lastAccounts: AdminScheduledJobAccountRuntime[]
  lastAccountCount: number
  lastCheckedCount: number
  lastOkCount: number
  lastLowAssetCount: number
  lastFailedCount: number
  lastManual: boolean
}

export interface AdminScheduledJobAccountRuntime {
  sourceKey: string
  label: string
  enabled: boolean
  hasToken: boolean
  ok: boolean
  skipped: boolean
  status: string
  message: string
  asset: number | null
  threshold: number
  checkedAt: string
}

export interface AdminCloudtentaclesMonitorAccount {
  sourceKey: string
  label: string
  enabled: boolean
  username: string
  phoneMasked: string
  hasToken: boolean
  loggedInAt: string
}

export interface AdminScheduledJobsResponse {
  filePath: string
  source: AdminScheduledJobsConfig
  runtime: AdminScheduledJobRuntimeState[]
  cloudtentaclesAccounts: AdminCloudtentaclesMonitorAccount[]
}
