{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://daarion.city/schemas/brand/BrandSnapshot.schema.json",
  "title": "BrandSnapshot",
  "type": "object",
  "required": ["id", "created_at", "brand_id", "source_id", "quality", "extracted"],
  "properties": {
    "id": { "type": "string", "description": "ULID/UUID" },
    "created_at": { "type": "string", "format": "date-time" },
    "brand_id": { "type": "string" },
    "source_id": { "type": "string" },
    "quality": {
      "type": "object",
      "required": ["confidence", "warnings"],
      "properties": {
        "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
        "warnings": { "type": "array", "items": { "type": "string" } },
        "needs_review": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "extracted": {
      "type": "object",
      "properties": {
        "palette": {
          "type": "object",
          "properties": {
            "primary": { "type": "string", "pattern": "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$" },
            "secondary": { "type": "string", "pattern": "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$" },
            "accent": { "type": "string", "pattern": "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$" },
            "background": { "type": "string" },
            "text": { "type": "string" },
            "extra": { "type": "array", "items": { "type": "string" } }
          },
          "additionalProperties": false
        },
        "typography": {
          "type": "object",
          "properties": {
            "font_family_primary": { "type": "string" },
            "font_family_secondary": { "type": "string" },
            "weights": { "type": "array", "items": { "type": "integer" } },
            "sources": { "type": "array", "items": { "type": "string" } }
          },
          "additionalProperties": false
        },
        "logos": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["role", "ref"],
            "properties": {
              "role": { "type": "string", "enum": ["primary", "alt", "icon", "wordmark"] },
              "variant": { "type": "string", "enum": ["light", "dark", "mono"], "default": "light" },
              "ref": { "type": "string", "description": "S3 key" },
              "mime_type": { "type": "string" }
            }
          }
        },
        "web_tokens": {
          "type": "object",
          "properties": {
            "css_colors": { "type": "array", "items": { "type": "string" } },
            "css_fonts": { "type": "array", "items": { "type": "string" } },
            "screenshots": { "type": "array", "items": { "type": "string" } }
          },
          "additionalProperties": false
        },
        "documents": {
          "type": "object",
          "properties": {
            "brandbook_pages": { "type": "array", "items": { "type": "string" } },
            "extracted_terms": { "type": "array", "items": { "type": "string" } }
          },
          "additionalProperties": false
        },
        "licensing": {
          "type": "object",
          "properties": {
            "notes": { "type": "string" },
            "unknown_risks": { "type": "array", "items": { "type": "string" } }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "theme_draft_ref": { "type": "string", "description": "S3 key на згенерований theme.json draft" }
  },
  "additionalProperties": false
}
