{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:transit-delivery-atlas:watchlist-schema:0.1.0",
  "title": "Transit Delivery Atlas context watchlist",
  "type": "object",
  "required": [
    "schemaVersion",
    "scope",
    "lastUpdatedOn",
    "boundaryNote",
    "items"
  ],
  "properties": {
    "schemaVersion": {
      "const": "0.1.0"
    },
    "scope": {
      "const": "selective-context"
    },
    "lastUpdatedOn": {
      "$ref": "#/$defs/date"
    },
    "boundaryNote": {
      "type": "string",
      "minLength": 100
    },
    "items": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/watchlistItem"
      }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "date": {
      "type": "string",
      "format": "date",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "identifier": {
      "type": "string",
      "pattern": "^[a-z0-9-]+$"
    },
    "httpsUri": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://"
    },
    "relatedUrl": {
      "type": "object",
      "required": [
        "label",
        "url"
      ],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 3
        },
        "url": {
          "$ref": "#/$defs/httpsUri"
        }
      },
      "additionalProperties": false
    },
    "sourceDate": {
      "type": "object",
      "required": [
        "value",
        "kind",
        "origin"
      ],
      "properties": {
        "value": {
          "$ref": "#/$defs/date"
        },
        "kind": {
          "enum": [
            "scheduled-event",
            "published",
            "updated"
          ]
        },
        "origin": {
          "enum": [
            "artifact-header",
            "page-header",
            "page-content",
            "publisher-metadata"
          ]
        }
      },
      "additionalProperties": false
    },
    "evidenceBoundary": {
      "type": "object",
      "required": [
        "reason",
        "checkedOn",
        "explicitOrderCitation",
        "note"
      ],
      "properties": {
        "reason": {
          "enum": [
            "no-explicit-order-citation",
            "expected-artifact-not-published"
          ]
        },
        "checkedOn": {
          "$ref": "#/$defs/date"
        },
        "explicitOrderCitation": {
          "const": false
        },
        "note": {
          "type": "string",
          "minLength": 40
        }
      },
      "additionalProperties": false
    },
    "directiveLink": {
      "type": "object",
      "required": [
        "directiveId",
        "relationship",
        "rationale"
      ],
      "properties": {
        "directiveId": {
          "$ref": "#/$defs/identifier"
        },
        "relationship": {
          "enum": [
            "topic-alignment",
            "process-adjacency",
            "publication-watch"
          ]
        },
        "rationale": {
          "type": "string",
          "minLength": 30
        }
      },
      "additionalProperties": false
    },
    "watchlistItem": {
      "type": "object",
      "required": [
        "id",
        "kind",
        "title",
        "titleOrigin",
        "publisher",
        "url",
        "mediaType",
        "relatedUrls",
        "retrievedOn",
        "lastReviewedOn",
        "editorialSummary",
        "whyTracked",
        "evidenceBoundary",
        "directiveLinks",
        "nextReviewOn",
        "watchFor",
        "limitations"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/identifier"
        },
        "kind": {
          "enum": [
            "context-source",
            "publication-checkpoint"
          ]
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "titleOrigin": {
          "enum": [
            "publisher",
            "editorial"
          ]
        },
        "publisher": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "$ref": "#/$defs/httpsUri"
        },
        "mediaType": {
          "enum": [
            "text/html",
            "application/pdf"
          ]
        },
        "relatedUrls": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/relatedUrl"
          }
        },
        "sourceDate": {
          "$ref": "#/$defs/sourceDate"
        },
        "retrievedOn": {
          "$ref": "#/$defs/date"
        },
        "lastReviewedOn": {
          "$ref": "#/$defs/date"
        },
        "editorialSummary": {
          "type": "string",
          "minLength": 40
        },
        "whyTracked": {
          "type": "string",
          "minLength": 40
        },
        "evidenceBoundary": {
          "$ref": "#/$defs/evidenceBoundary"
        },
        "directiveLinks": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/directiveLink"
          }
        },
        "nextReviewOn": {
          "$ref": "#/$defs/date"
        },
        "watchFor": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 30
          }
        },
        "limitations": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 30
          }
        }
      },
      "additionalProperties": false
    }
  }
}
