{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://getkontax.com/schemas/kontax-archive.v1.schema.json",
  "title": "Kontax Contact Export Archive Manifest (getkontax.com:Archive), format major 1",
  "description": "See docs/contact-export-format-spec.md §7 for the normative prose. This schema validates manifest.json — the envelope + integrity root of a .zip archive whose contacts/ entries each validate against kontax-contact.v1.schema.json.",
  "type": "object",
  "required": ["@type", "getkontax.com:formatVersion", "getkontax.com:exportedAt", "integrity"],
  "properties": {
    "@type": { "const": "getkontax.com:Archive" },
    "getkontax.com:formatVersion": { "type": "string", "pattern": "^1\\.[0-9]+$" },
    "getkontax.com:exportedAt": { "type": "string", "format": "date-time" },
    "exporter": { "type": "string" },
    "counts": {
      "type": "object",
      "properties": {
        "contacts": { "type": "integer", "minimum": 0 },
        "photos": { "type": "integer", "minimum": 0 }
      }
    },
    "getkontax.com:labels": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "required": ["name", "color"],
        "properties": {
          "name": { "type": "string" },
          "color": { "type": "string" },
          "position": { "type": "integer" }
        }
      }
    },
    "getkontax.com:books": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": { "type": "string" },
          "description": { "type": ["string", "null"] }
        }
      }
    },
    "integrity": {
      "type": "object",
      "required": ["algorithm", "entries"],
      "properties": {
        "algorithm": { "const": "sha256" },
        "entries": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["path", "sha256", "bytes"],
            "properties": {
              "path": { "type": "string", "pattern": "^(contacts/|media/|vcards/)" },
              "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
              "bytes": { "type": "integer", "minimum": 0 }
            }
          }
        }
      }
    }
  }
}
