version: "1.0"
info:
  title: "EU Customer Records (GDPR Protected)"
  version: "1.0.0"
  description: "Ingestion of EU customer data with GDPR consent and PII controls."
  owner: "Data Protection Officer"

source:
  type: landing
  path: "data/eu_customers.csv"
  format: csv

model:
  fields:
    - name: id
      type: integer
    - name: full_name
      type: string
      pii: true
      classification: person_name
    - name: email
      type: string
      pii: true
      classification: email
    - name: phone
      type: string
      pii: true
      classification: phone_number
    - name: country_code
      type: string
      description: "ISO 3166-1 alpha-2 country code (e.g. DE, FR, GB)"
    - name: consent_given
      type: boolean
      description: "Explicit opt-in consent under GDPR Art. 7"
    - name: lawful_basis
      type: string
      description: "Legal basis for processing: consent, contract, legal_obligation, vital_interest, public_task, legitimate_interest"
    - name: retention_expires_at
      type: date
      description: "Date when this record must be reviewed or deleted (GDPR Art. 5(1)(e))"
    - name: created_at
      type: timestamp

quality:
  row_rules:
    - name: valid_email
      sql: "email LIKE '%@%.%'"
      description: "Email must contain @ and domain"
    - name: consent_explicit
      sql: "consent_given IS NOT NULL"
      description: "GDPR Art. 7 - consent must be explicitly recorded"
    - name: lawful_basis_present
      sql: "lawful_basis IN ('consent', 'contract', 'legal_obligation', 'vital_interest', 'public_task', 'legitimate_interest')"
      description: "GDPR Art. 6 - lawful basis must be one of the six defined types"
    - name: retention_set
      sql: "retention_expires_at IS NOT NULL"
      description: "GDPR Art. 5(1)(e) - storage limitation requires a retention date"
    - name: valid_country
      sql: "LENGTH(country_code) = 2"
      description: "Country code must be ISO 3166-1 alpha-2"
    - name: phone_not_empty
      sql: "phone IS NOT NULL AND phone != ''"
      description: "Phone number should be present for contact purposes"

external_logic:
  type: python
  path: "../../../../lakelogic/tools/hooks/pii_masking.py"
  entrypoint: "mask_pii"
  args:
    entities: ["PERSON", "EMAIL_ADDRESS", "PHONE_NUMBER"]
    mask_with: "[GDPR_REDACTED]"
    columns: ["full_name", "email", "phone"]

quarantine:
  enabled: true
  target: "data/quarantine_gdpr.csv"
