{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hantamonitor.com/schemas/feed.schema.json",
  "title": "Hanta Monitor Feed Artifact",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "schema_version",
    "generated_at",
    "artifact_version",
    "generator",
    "status",
    "sources",
    "items"
  ],
  "properties": {
    "schema_version": { "const": 1 },
    "generated_at": { "type": "string", "format": "date-time" },
    "artifact_version": { "type": "string", "minLength": 1 },
    "generator": { "type": "string", "minLength": 1 },
    "status": { "type": "string", "minLength": 1 },
    "refresh": { "type": "object" },
    "source_status": { "type": "object" },
    "source_health_summary": { "type": "object" },
    "summary": { "type": "object" },
    "sources": {
      "type": "array",
      "items": { "$ref": "#/$defs/feedSource" }
    },
    "items": {
      "type": "array",
      "items": { "$ref": "#/$defs/feedItem" }
    }
  },
  "$defs": {
    "languageCode": {
      "type": "string",
      "pattern": "^[a-z]{2}$"
    },
    "languageCodeOrNull": {
      "anyOf": [
        { "$ref": "#/$defs/languageCode" },
        { "type": "null" }
      ]
    },
    "sourceLanguages": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/languageCode" }
    },
    "feedSource": {
      "type": "object",
      "additionalProperties": true,
      "required": ["id", "name", "rank", "url", "language", "source_languages"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "name": { "type": "string", "minLength": 1 },
        "rank": { "type": "string", "minLength": 1 },
        "url": { "type": "string", "format": "uri" },
        "trust_lane": { "type": "string" },
        "coverage_label": { "type": "string" },
        "coverage_note": { "type": "string" },
        "language": { "$ref": "#/$defs/languageCodeOrNull" },
        "source_languages": { "$ref": "#/$defs/sourceLanguages" },
        "health": { "$ref": "#/$defs/sourceHealth" }
      }
    },
    "sourceHealth": {
      "type": "object",
      "additionalProperties": true,
      "required": ["status"],
      "properties": {
        "status": { "type": "string", "minLength": 1 },
        "label": { "type": "string" },
        "lifecycle": { "type": "string" },
        "lifecycle_label": { "type": "string" },
        "explanation": { "type": "string" },
        "next_step": { "type": "string" },
        "blocked": { "type": "boolean" },
        "deprioritized": { "type": "boolean" },
        "cadence": {
          "anyOf": [
            { "type": "string" },
            { "type": "null" }
          ]
        },
        "checked_at": {
          "anyOf": [
            { "type": "string", "format": "date-time" },
            { "type": "null" }
          ]
        },
        "item_count": { "type": "number" },
        "trust_lane": { "type": "string" },
        "coverage_label": { "type": "string" },
        "coverage_note": { "type": "string" },
        "detail": { "type": "string" }
      }
    },
    "feedItem": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "id",
        "title",
        "source",
        "source_id",
        "source_rank",
        "url",
        "fetched_at",
        "classification",
        "summary",
        "language",
        "source_languages"
      ],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "title": { "type": "string", "minLength": 1 },
        "source": { "type": "string", "minLength": 1 },
        "source_id": { "type": "string", "minLength": 1 },
        "source_rank": { "type": "string", "minLength": 1 },
        "url": { "type": "string", "format": "uri" },
        "published_at": {
          "anyOf": [
            { "type": "string", "format": "date-time" },
            { "type": "null" }
          ]
        },
        "fetched_at": { "type": "string", "format": "date-time" },
        "classification": { "type": "string", "minLength": 1 },
        "category": { "type": "string" },
        "location": { "type": "string" },
        "summary": { "type": "string", "minLength": 1 },
        "confidence": { "type": "string" },
        "language": { "$ref": "#/$defs/languageCodeOrNull" },
        "source_languages": { "$ref": "#/$defs/sourceLanguages" },
        "data": {
          "type": "object",
          "additionalProperties": true,
          "properties": {
            "source_event_url": { "type": "string", "format": "uri" },
            "source_date": { "type": "string", "format": "date-time" },
            "source_date_label": { "type": "string" },
            "bulletin_number": { "type": "number" },
            "epidemiological_week": { "type": "number" },
            "body_evidence_status": { "type": "string" },
            "body_match_terms": {
              "type": "array",
              "items": { "type": "string" }
            },
            "body_case_count": { "type": "number" },
            "body_death_count": { "type": "number" }
          }
        }
      }
    }
  }
}
