{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://wickfeed.com/schema/heartbeat.v1.json",
  "title": "The heartbeat of a Wickfeed feed in one country, version 1",
  "description": "Which sources stand behind one feed in one country and when each last answered: the payload of wickfeed.<feed>.heartbeat. Registered in the catalogue of every feed's channel; Wickfeed sends one at the top of every hour for each feed and country with at least one source it is set to check on a schedule.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "feed",
    "country",
    "sources",
    "emitted_at"
  ],
  "properties": {
    "feed": {
      "enum": [
        "calendar",
        "stack",
        "rules",
        "delivery",
        "attention",
        "trust",
        "platform",
        "money",
        "local",
        "company",
        "launches",
        "markets"
      ]
    },
    "country": {
      "type": "string",
      "pattern": "^(global|[a-z]{2})$"
    },
    "sources": {
      "description": "One row for each source Wickfeed is set to check on a schedule for this feed and this country, including any it has stopped checking; state says which.",
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source_id",
          "last_seen",
          "state"
        ],
        "properties": {
          "source_id": {
            "type": "string",
            "minLength": 1
          },
          "last_seen": {
            "description": "When the source last answered Wickfeed's check, or null when it never has.",
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{3})?Z$"
          },
          "state": {
            "description": "Whether the source is still on Wickfeed's schedule: active, it is, though a check can fail or be held back, as when the source's own site asks Wickfeed to hold off, and last_seen then stands still; parked, it is not, and Wickfeed has stopped checking it until the source is set up again.",
            "enum": [
              "active",
              "parked"
            ]
          }
        }
      }
    },
    "emitted_at": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$"
    }
  }
}
