{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/ringsaturn/xue/blob/main/docs/schemas/alerts-archive-catalog.schema.json",
  "title": "AlertsArchiveCatalog",
  "description": "alerts/archive/catalog.json (docs/alerts.md section 12.3): every month of the archive. That months are sorted and unique, and that each path names its own month, are the readers' own checks.",
  "type": "object",
  "required": ["archiveSchemaVersion", "product", "months"],
  "properties": {
    "archiveSchemaVersion": {"description": "A reader rejects a version above the one it implements.", "type": "integer", "const": 1},
    "product": {"const": "alerts"},
    "months": {"type": "array", "items": {"$ref": "#/$defs/CatalogMonth"}}
  },
  "$defs": {
    "ByteLength": {"description": "A file's length in bytes.", "type": "integer", "minimum": 0},
    "Crc32": {"description": "A file's CRC32, 8 lowercase hex characters: what it is requested by (?v=).", "type": "string", "pattern": "^[0-9a-f]{8}$"},
    "Month": {"description": "A UTC month, YYYY-MM.", "type": "string", "pattern": "^\\d{4}-(0[1-9]|1[0-2])$"},
    "Round": {
      "description": "A round's issued time (docs/alerts.md section 5): a UTC minute that is a multiple of five.",
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d[05]:00Z$",
      "format": "date-time"
    },
    "Network": {"description": "A network id (docs/alerts.md section 10).", "type": "string", "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$"},
    "EndedReason": {"description": "Why an alert left the snapshot (docs/alerts.md section 7).", "enum": ["expired", "replaced", "cancelled", "gone"]},
    "CatalogMonth": {
      "description": "One month's index.",
      "type": "object",
      "required": ["month", "path", "byteLength", "crc32", "alerts"],
      "properties": {
        "month": {"$ref": "#/$defs/Month"},
        "path": {"description": "<YYYY>/<MM>/index.json, relative to the catalog.", "type": "string", "pattern": "^\\d{4}/\\d{2}/index\\.json$"},
        "byteLength": {"$ref": "#/$defs/ByteLength"},
        "crc32": {"$ref": "#/$defs/Crc32"},
        "alerts": {"description": "Records in the month: its index's rows.", "type": "integer", "minimum": 0}
      }
    }
  }
}
