/**
 * DSFA API Types - Request/response types and UCCA integration
 *
 * All types used for API communication with the DSFA backend.
 */

import type { DSFAStatus, DSFARiskLevel } from './types-core'
import type { DSFA } from './types-assessment'

// =============================================================================
// API REQUEST/RESPONSE TYPES
// =============================================================================

export interface DSFAListResponse {
  dsfas: DSFA[]
}

export interface DSFAStatsResponse {
  status_stats: Record<DSFAStatus | 'total', number>
  risk_stats: Record<DSFARiskLevel, number>
  total: number
}

export interface CreateDSFARequest {
  name: string
  description?: string
  processing_description?: string
  processing_purpose?: string
  data_categories?: string[]
  legal_basis?: string
}

export interface CreateDSFAFromAssessmentRequest {
  name?: string
  description?: string
}

export interface CreateDSFAFromAssessmentResponse {
  dsfa: DSFA
  prefilled: boolean
  assessment: unknown // UCCA Assessment
  message: string
}

export interface UpdateDSFASectionRequest {
  // Section 1
  processing_description?: string
  processing_purpose?: string
  data_categories?: string[]
  data_subjects?: string[]
  recipients?: string[]
  legal_basis?: string
  legal_basis_details?: string

  // Section 2
  necessity_assessment?: string
  proportionality_assessment?: string
  data_minimization?: string
  alternatives_considered?: string
  retention_justification?: string

  // Section 3
  overall_risk_level?: DSFARiskLevel
  risk_score?: number
  affected_rights?: string[]

  // Section 5
  dpo_consulted?: boolean
  dpo_name?: string
  dpo_opinion?: string
  authority_consulted?: boolean
  authority_reference?: string
  authority_decision?: string
}

export interface SubmitForReviewResponse {
  message: string
  dsfa: DSFA
}

export interface ApproveDSFARequest {
  dpo_opinion: string
  approved: boolean
}

// =============================================================================
// UCCA INTEGRATION TYPES
// =============================================================================

export interface DSFATriggerInfo {
  required: boolean
  reason: string
  triggered_rules: string[]
  assessment_id?: string
  existing_dsfa_id?: string
}

export interface UCCATriggeredRule {
  code: string
  title: string
  description: string
  severity: 'INFO' | 'WARN' | 'BLOCK'
  gdpr_ref?: string
}
