{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hantamonitor.com/schemas/changes.schema.json",
  "title": "Hanta Monitor Changes Artifact",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "schema_version",
    "generated_at",
    "artifact_version",
    "generator",
    "status",
    "summary",
    "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 },
    "source_status": { "type": "object" },
    "input_artifacts": { "type": "object" },
    "summary": {
      "type": "object",
      "required": ["item_count", "added_count", "removed_count", "updated_count", "scope_note"],
      "properties": {
        "item_count": { "type": "number" },
        "added_count": { "type": "number" },
        "removed_count": { "type": "number" },
        "updated_count": { "type": "number" },
        "current_item_count": { "type": "number" },
        "previous_item_count": { "type": "number" },
        "compared_at": { "type": "string", "format": "date-time" },
        "scope_note": { "type": "string" }
      }
    },
    "sources": { "type": "array" },
    "items": {
      "type": "array",
      "items": { "$ref": "#/$defs/changeItem" }
    }
  },
  "$defs": {
    "changeItem": {
      "type": "object",
      "additionalProperties": true,
      "required": ["id", "change_type", "item_key", "title", "changed_fields"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "change_type": { "enum": ["added", "removed", "updated"] },
        "item_key": { "type": "string", "minLength": 1 },
        "feed_item_id": { "type": ["string", "null"] },
        "title": { "type": "string", "minLength": 1 },
        "source": { "type": "string" },
        "source_id": { "type": ["string", "null"] },
        "source_rank": { "type": ["string", "null"] },
        "url": { "type": ["string", "null"], "format": "uri" },
        "published_at": { "type": ["string", "null"], "format": "date-time" },
        "fetched_at": { "type": ["string", "null"], "format": "date-time" },
        "classification": { "type": ["string", "null"] },
        "location": { "type": ["string", "null"] },
        "changed_fields": {
          "type": "array",
          "items": { "type": "string" }
        },
        "previous": { "type": ["object", "null"] },
        "current": { "type": ["object", "null"] }
      }
    }
  }
}
