{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://trackbtc.bot/schemas/feed-v2.json",
  "title": "TrackBTC current public intelligence feed",
  "type": "object",
  "properties": {
    "contract": {
      "const": "trackbtc_public_intelligence_v2"
    },
    "as_of": {
      "type": "string",
      "format": "date-time",
      "pattern": "Z$",
      "description": "Publication preparation frontier, not first publication of each alert."
    },
    "daily": {
      "type": "object",
      "properties": {
        "status": {
          "enum": [
            "empty",
            "available"
          ]
        },
        "scope": {
          "type": "string"
        },
        "coverage_end": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "Z$"
            },
            {
              "type": "null"
            }
          ]
        },
        "cards": {
          "type": "array",
          "items": {
            "allOf": [
              {
                "$ref": "https://trackbtc.bot/schemas/alert-v1.json#/$defs/card"
              },
              {
                "properties": {
                  "type": {
                    "const": "daily"
                  }
                }
              }
            ]
          },
          "maxItems": 1024
        }
      },
      "required": [
        "status",
        "scope",
        "coverage_end",
        "cards"
      ],
      "additionalProperties": false
    },
    "weekly": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "status": {
              "const": "awaiting_release"
            },
            "cards": {
              "type": "array",
              "items": {
                "$ref": "https://trackbtc.bot/schemas/alert-v1.json#/$defs/card"
              },
              "maxItems": 0
            }
          },
          "required": [
            "status",
            "cards"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "status": {
              "const": "available"
            },
            "period": {
              "type": "string"
            },
            "release_at": {
              "type": "string",
              "format": "date-time",
              "pattern": "Z$"
            },
            "cards": {
              "type": "array",
              "items": {
                "allOf": [
                  {
                    "$ref": "https://trackbtc.bot/schemas/alert-v1.json#/$defs/card"
                  },
                  {
                    "properties": {
                      "type": {
                        "const": "weekly"
                      }
                    }
                  }
                ]
              },
              "maxItems": 64
            }
          },
          "required": [
            "status",
            "period",
            "release_at",
            "cards"
          ],
          "additionalProperties": false
        }
      ]
    },
    "activity_lanes": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "title",
          "description"
        ],
        "additionalProperties": false
      },
      "minItems": 5,
      "maxItems": 5
    },
    "reading_order": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^tb-[0-9A-Za-z]+-[dw][0-9A-Za-z]+$"
      },
      "uniqueItems": true
    },
    "highlights": {
      "type": "object",
      "description": "Backend-selected references to findings in this published feed, with factual selection reasons.",
      "properties": {
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^\\S(?:[^\\r\\n]*\\S)?$"
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 400,
          "pattern": "^\\S(?:[^\\r\\n]*\\S)?$"
        },
        "items": {
          "type": "array",
          "maxItems": 9,
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^tb-[0-9A-Za-z]+-[dw][0-9A-Za-z]+$"
              },
              "reason": {
                "type": "string",
                "minLength": 1,
                "maxLength": 400,
                "pattern": "^\\S(?:[^\\r\\n]*\\S)?$"
              }
            },
            "required": [
              "id",
              "reason"
            ],
            "additionalProperties": false
          },
          "uniqueItems": true
        }
      },
      "required": [
        "title",
        "description",
        "items"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "contract",
    "as_of",
    "daily",
    "weekly",
    "activity_lanes",
    "reading_order",
    "highlights"
  ],
  "additionalProperties": false
}
