import type { Database } from '../../supabase/database.types'

export type ActivityRow = Database['public']['Tables']['activities']['Row']
export type ActivityInsert = Database['public']['Tables']['activities']['Insert']

export type ActivityType =
  | 'workflow_execution'
  | 'agent_run'
  | 'hitl_action'
  | 'webhook_received'
  | 'webhook_executed'
  | 'webhook_failed'
  | 'credential_change'
  | 'credential_read'
  | 'api_key_change'
  | 'deployment_change'
  | 'membership_change'

export type ActivityStatus = 'success' | 'failure' | 'pending' | 'approved' | 'rejected' | 'completed'

export interface Activity {
  id: string
  organizationId: string
  activityType: ActivityType
  status: ActivityStatus
  title: string
  description: string | null
  entityType: string
  entityId: string
  entityName: string | null
  metadata: Record<string, unknown> | null
  actorId: string | null
  actorType: string | null
  occurredAt: Date
  createdAt: Date
}

export interface CreateActivityParams {
  organizationId: string
  activityType: ActivityType
  status: ActivityStatus
  title: string
  description?: string
  entityType: string
  entityId: string
  entityName?: string
  metadata?: Record<string, unknown>
  actorId?: string
  actorType?: string
  occurredAt?: Date
}

export interface ListActivitiesParams {
  organizationId: string
  limit?: number
  offset?: number
  activityType?: ActivityType
  entityType?: string
  entityId?: string
  startDate?: string
  endDate?: string
  status?: string
  search?: string
}
