// ==========================================
// INTERFACES - VVT / PROCESSING ACTIVITIES
// ==========================================

import type { LocalizedText, ResponsibleParty, Contact } from './common'
import type {
  LegalBasisType,
  RecipientCategoryType,
  TransferMechanismType,
  DataSourceType,
  PersonalDataCategory,
  DataSubjectCategory,
  ProtectionLevel,
  ProcessingActivityStatus,
} from './enums'

export interface LegalBasis {
  type: LegalBasisType
  description?: string
  reference?: string // z.B. "§ 26 BDSG"
}

export interface RecipientCategory {
  type: RecipientCategoryType
  name: string
  description?: string
  isThirdCountry?: boolean
  country?: string
}

export interface ThirdCountryTransfer {
  country: string // ISO 3166-1 alpha-2
  recipient: string
  transferMechanism: TransferMechanismType
  sccVersion?: string
  tiaCompleted?: boolean
  tiaDate?: Date
  additionalMeasures?: string[]
}

export interface RetentionPeriod {
  duration?: number // in Monaten
  durationUnit?: 'DAYS' | 'MONTHS' | 'YEARS'
  description: LocalizedText
  legalBasis?: string // z.B. "HGB § 257", "AO § 147"
  deletionProcedure?: string
}

export interface DataSource {
  type: DataSourceType
  description?: string
}

export interface SystemReference {
  systemId: string
  name: string
  description?: string
  type?: string // CRM, ERP, etc.
}

export interface DataFlow {
  sourceSystem?: string
  targetSystem?: string
  description: string
  dataCategories: PersonalDataCategory[]
}

export interface ProcessingActivity {
  id: string
  tenantId: string

  // Pflichtfelder Art. 30(1) DSGVO
  vvtId: string // Eindeutige VVT-Nummer (z.B. VVT-2024-001)
  name: LocalizedText
  responsible: ResponsibleParty
  dpoContact?: Contact
  purposes: LocalizedText[]
  dataSubjectCategories: DataSubjectCategory[]
  personalDataCategories: PersonalDataCategory[]
  recipientCategories: RecipientCategory[]
  thirdCountryTransfers: ThirdCountryTransfer[]
  retentionPeriod: RetentionPeriod
  technicalMeasures: string[] // TOM-Referenzen

  // Empfohlene Zusatzfelder
  legalBasis: LegalBasis[]
  dataSources: DataSource[]
  systems: SystemReference[]
  dataFlows: DataFlow[]
  protectionLevel: ProtectionLevel
  dpiaRequired: boolean
  dpiaJustification?: string
  subProcessors: string[] // Vendor-IDs
  legalRetentionBasis?: string

  // Workflow
  status: ProcessingActivityStatus
  owner: string
  lastReviewDate?: Date
  nextReviewDate?: Date

  createdAt: Date
  updatedAt: Date
}
