{
  "$defs": {
    "IsoCountry": {
      "description": "ISO 3166-1 alpha-2 country code.",
      "pattern": "^[A-Z]{2}$",
      "type": "string"
    },
    "IsoCurrency": {
      "description": "ISO 4217 currency code.",
      "pattern": "^[A-Z]{3}$",
      "type": "string"
    },
    "IsoDate": {
      "description": "ISO 8601 date (YYYY-MM-DD).",
      "format": "date",
      "type": "string"
    },
    "Lei": {
      "description": "ISO 17442 Legal Entity Identifier (20-character alphanumeric).",
      "pattern": "^[A-Z0-9]{18}[0-9]{2}$",
      "type": "string"
    },
    "PathRef": {
      "description": "Path-based cross-reference relative to .corpospec/ root.\nPattern: `^[a-z0-9_-]+(/[a-z0-9_.-]+)+$`",
      "pattern": "^[a-z0-9_-]+(/[a-z0-9_.-]+)+$",
      "type": "string"
    },
    "PostalAddress": {
      "description": "Physical address aligned with schema.org PostalAddress.",
      "properties": {
        "city": {
          "type": [
            "string",
            "null"
          ]
        },
        "country": {
          "$ref": "#/$defs/IsoCountry"
        },
        "postal_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "state": {
          "type": [
            "string",
            "null"
          ]
        },
        "street": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "country"
      ],
      "type": "object"
    },
    "VendorCategory": {
      "description": "Vendor category.",
      "oneOf": [
        {
          "enum": [
            "other"
          ],
          "type": "string"
        },
        {
          "const": "technology",
          "description": "SaaS / cloud / IT.",
          "type": "string"
        },
        {
          "const": "legal",
          "description": "External legal counsel.",
          "type": "string"
        },
        {
          "const": "financial",
          "description": "Accountants / tax advisors.",
          "type": "string"
        },
        {
          "const": "recruiting",
          "description": "Recruitment / staffing.",
          "type": "string"
        },
        {
          "const": "marketing",
          "description": "Marketing / agencies.",
          "type": "string"
        },
        {
          "const": "facilities",
          "description": "Office / facilities.",
          "type": "string"
        },
        {
          "const": "logistics",
          "description": "Logistics / shipping.",
          "type": "string"
        },
        {
          "const": "insurance",
          "description": "Insurance.",
          "type": "string"
        },
        {
          "const": "banking",
          "description": "Banking / payments.",
          "type": "string"
        },
        {
          "const": "ai_model",
          "description": "AI / ML model vendor.",
          "type": "string"
        },
        {
          "const": "contractor",
          "description": "Independent contractor / freelancer.",
          "type": "string"
        },
        {
          "const": "materials",
          "description": "Goods supplier.",
          "type": "string"
        },
        {
          "const": "government",
          "description": "Government / authority (statutory).",
          "type": "string"
        }
      ]
    },
    "VendorContact": {
      "description": "Primary contact.",
      "properties": {
        "email_pseudonym": {
          "description": "Pseudonymised email reference (hash) — actual address held in a\nseparate PII-class document.",
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "type": "string"
        },
        "role": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "role"
      ],
      "type": "object"
    },
    "VendorRelationship": {
      "description": "Relationship category.",
      "oneOf": [
        {
          "const": "customer_only",
          "description": "Buys from us only.",
          "type": "string"
        },
        {
          "const": "vendor_only",
          "description": "Sells to us only.",
          "type": "string"
        },
        {
          "const": "mutual",
          "description": "Both.",
          "type": "string"
        },
        {
          "const": "strategic_partner",
          "description": "Strategic partnership (co-marketing, integration, etc.).",
          "type": "string"
        },
        {
          "const": "investor",
          "description": "Investor / financier.",
          "type": "string"
        }
      ]
    },
    "VendorStatus": {
      "description": "Lifecycle.",
      "oneOf": [
        {
          "enum": [
            "onboarding",
            "active",
            "probation",
            "suspended",
            "terminated"
          ],
          "type": "string"
        },
        {
          "const": "blacklisted",
          "description": "Banned (do not engage).",
          "type": "string"
        }
      ]
    },
    "WikidataQid": {
      "description": "Wikidata Q-identifier (`Q123`, `Q92779`). Optional global-discoverability\nhook on Entity / Person / Party / Brand records. See BDR 0080 §4.",
      "pattern": "^Q[1-9][0-9]*$",
      "type": "string"
    }
  },
  "$id": "https://corpospec.com/schemas/v0.16.0/vendor.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Vendor master record.",
  "properties": {
    "category": {
      "$ref": "#/$defs/VendorCategory"
    },
    "display_name": {
      "type": "string"
    },
    "dpa_ref": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef to active DPA (Art. 28)."
    },
    "gdpr_role": {
      "description": "GDPR role assigned to this vendor.",
      "type": [
        "string",
        "null"
      ]
    },
    "id": {
      "$ref": "#/$defs/PathRef"
    },
    "internal_owner": {
      "$ref": "#/$defs/PathRef",
      "description": "PathRef to the internal owner (sponsor / KAM)."
    },
    "jurisdiction": {
      "$ref": "#/$defs/IsoCountry"
    },
    "last_risk_assessment": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "Last risk-assessment record (vendor_risk_assessment)."
    },
    "legal_name": {
      "type": "string"
    },
    "lei": {
      "anyOf": [
        {
          "$ref": "#/$defs/Lei"
        },
        {
          "type": "null"
        }
      ],
      "description": "LEI per ISO 17442."
    },
    "master_agreement": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef to active master service / framework agreement."
    },
    "onboarded_at": {
      "$ref": "#/$defs/IsoDate"
    },
    "parent_vendor": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "Parent vendor (LEI Level-2 relationship)."
    },
    "primary_contact": {
      "anyOf": [
        {
          "$ref": "#/$defs/VendorContact"
        },
        {
          "type": "null"
        }
      ],
      "description": "Primary contact (often KAM / partner-success manager)."
    },
    "processing_record_refs": {
      "description": "Processing records this vendor participates in.",
      "items": {
        "$ref": "#/$defs/PathRef"
      },
      "type": "array"
    },
    "registered_address": {
      "$ref": "#/$defs/PostalAddress",
      "description": "Registered address."
    },
    "relationship": {
      "$ref": "#/$defs/VendorRelationship"
    },
    "spend_currency": {
      "$ref": "#/$defs/IsoCurrency",
      "description": "Annual spend currency + amount (latest closed FY)."
    },
    "spend_per_year": {
      "format": "double",
      "type": "number"
    },
    "status": {
      "$ref": "#/$defs/VendorStatus"
    },
    "tax_id": {
      "description": "Tax identification number.",
      "type": [
        "string",
        "null"
      ]
    },
    "terminated_at": {
      "anyOf": [
        {
          "$ref": "#/$defs/IsoDate"
        },
        {
          "type": "null"
        }
      ]
    },
    "wikidata_qid": {
      "anyOf": [
        {
          "$ref": "#/$defs/WikidataQid"
        },
        {
          "type": "null"
        }
      ],
      "description": "Wikidata QID for public identification."
    }
  },
  "required": [
    "id",
    "legal_name",
    "display_name",
    "jurisdiction",
    "category",
    "relationship",
    "status",
    "registered_address",
    "spend_currency",
    "spend_per_year",
    "internal_owner",
    "onboarded_at"
  ],
  "title": "Vendor",
  "type": "object",
  "x-corpospec-pillar": "operations"
}