{
  "$comment": "JSON Schema for State of Watch data files",
  "meta": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "version": {
        "type": "string",
        "pattern": "^\\d+\\.\\d+$"
      },
      "compiled": {
        "type": "string",
        "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
      },
      "title": {
        "type": "string"
      },
      "description": {
        "type": "string"
      },
      "legend": {
        "type": "object",
        "propertyNames": {
          "type": "string",
          "enum": [
            "verified",
            "partial",
            "retracted"
          ]
        },
        "additionalProperties": {
          "type": "string"
        },
        "required": [
          "verified",
          "partial",
          "retracted"
        ]
      },
      "sections": {
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {
          "type": "string"
        }
      }
    },
    "required": [
      "version",
      "compiled",
      "title",
      "description",
      "legend",
      "sections"
    ],
    "additionalProperties": false
  },
  "claim": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9.-]*$"
      },
      "section": {
        "type": "integer",
        "minimum": 1,
        "maximum": 8
      },
      "title": {
        "type": "string",
        "minLength": 1
      },
      "date": {
        "type": [
          "string",
          "null"
        ]
      },
      "sort": {
        "anyOf": [
          {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          {
            "type": "null"
          }
        ]
      },
      "status": {
        "type": "string",
        "enum": [
          "verified",
          "partial",
          "retracted"
        ]
      },
      "checked": {
        "anyOf": [
          {
            "type": "string",
            "pattern": "^\\d+\\.\\d+$"
          },
          {
            "type": "null"
          }
        ]
      },
      "note": {
        "type": "string",
        "minLength": 1
      },
      "category": {
        "type": "string",
        "enum": [
          "court",
          "contract",
          "data",
          "face",
          "misuse",
          "backlash",
          "protest",
          "policy",
          "funding"
        ]
      },
      "case": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9.-]*$"
      },
      "scope": {
        "type": "string"
      },
      "summary": {
        "type": "string",
        "minLength": 1
      },
      "body": {
        "type": "string",
        "minLength": 1
      },
      "quotes": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "text": {
              "type": "string",
              "minLength": 1
            },
            "from": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "text",
            "from"
          ],
          "additionalProperties": false
        }
      },
      "sources": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "label": {
              "type": "string",
              "minLength": 1
            },
            "primary": {
              "type": "boolean"
            },
            "docket": {
              "type": "string"
            },
            "url": {
              "type": "string",
              "format": "uri"
            },
            "doc": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9.-]*$"
            }
          },
          "required": [
            "label"
          ],
          "additionalProperties": false
        }
      },
      "places": {
        "type": "array",
        "items": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]*$"
        }
      },
      "related": {
        "type": "array",
        "items": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]*$"
        }
      }
    },
    "required": [
      "id",
      "section",
      "title",
      "date",
      "sort",
      "status",
      "checked",
      "note",
      "category",
      "body",
      "quotes",
      "sources",
      "places"
    ],
    "additionalProperties": false
  },
  "place": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9.-]*$"
      },
      "name": {
        "type": "string"
      },
      "state": {
        "type": "string",
        "minLength": 2,
        "maxLength": 2
      },
      "lat": {
        "type": "number"
      },
      "lng": {
        "type": "number"
      }
    },
    "required": [
      "id",
      "name",
      "state",
      "lat",
      "lng"
    ],
    "additionalProperties": false
  },
  "case": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9.-]*$"
      },
      "caption": {
        "type": "string"
      },
      "short": {
        "type": "string"
      },
      "subject": {
        "type": "string"
      },
      "court": {
        "type": "string"
      },
      "docket": {
        "type": [
          "string",
          "null"
        ]
      },
      "dockets": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "judge": {
        "type": [
          "string",
          "null"
        ]
      },
      "live": {
        "type": "boolean"
      },
      "stage": {
        "type": "string"
      },
      "next": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "date": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "label": {
                "type": "string"
              },
              "firm": {
                "type": "boolean"
              },
              "note": {
                "type": "string"
              }
            },
            "required": [
              "date",
              "label",
              "firm",
              "note"
            ],
            "additionalProperties": false
          },
          {
            "type": "null"
          }
        ]
      },
      "sealed": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "pending": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "asOf": {
        "type": "string",
        "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
      },
      "timeline": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "date": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            "text": {
              "type": "string"
            }
          },
          "required": [
            "date",
            "text"
          ],
          "additionalProperties": false
        }
      },
      "claims": {
        "type": "array",
        "items": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]*$"
        }
      }
    },
    "required": [
      "id",
      "caption",
      "short",
      "subject",
      "court",
      "docket",
      "dockets",
      "judge",
      "live",
      "stage",
      "next",
      "sealed",
      "pending",
      "asOf",
      "timeline",
      "claims"
    ],
    "additionalProperties": false
  },
  "correction": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9.-]*$"
      },
      "version": {
        "anyOf": [
          {
            "type": "string",
            "pattern": "^\\d+\\.\\d+$"
          },
          {
            "type": "null"
          }
        ]
      },
      "kind": {
        "type": "string",
        "enum": [
          "correction",
          "retraction",
          "confirmed"
        ]
      },
      "title": {
        "type": "string"
      },
      "was": {
        "type": "string"
      },
      "now": {
        "type": "string"
      },
      "why": {
        "type": "string"
      },
      "claims": {
        "type": "array",
        "items": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]*$"
        }
      }
    },
    "required": [
      "id",
      "version",
      "kind",
      "title",
      "was",
      "now",
      "why",
      "claims"
    ],
    "additionalProperties": false
  },
  "open": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9.-]*$"
      },
      "text": {
        "type": "string"
      },
      "claims": {
        "type": "array",
        "items": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]*$"
        }
      },
      "case": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9.-]*$"
      }
    },
    "required": [
      "id",
      "text",
      "claims"
    ],
    "additionalProperties": false
  },
  "cut": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "n": {
        "type": "integer",
        "minimum": -9007199254740991,
        "maximum": 9007199254740991
      },
      "text": {
        "type": "string"
      },
      "status": {
        "type": "string"
      },
      "claim": {
        "anyOf": [
          {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9.-]*$"
          },
          {
            "type": "null"
          }
        ]
      }
    },
    "required": [
      "n",
      "text",
      "status",
      "claim"
    ],
    "additionalProperties": false
  },
  "document": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9.-]*$"
      },
      "title": {
        "type": "string",
        "minLength": 1
      },
      "kind": {
        "type": "string",
        "minLength": 1
      },
      "court": {
        "type": [
          "string",
          "null"
        ]
      },
      "docket": {
        "type": [
          "string",
          "null"
        ]
      },
      "filed": {
        "anyOf": [
          {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          {
            "type": "null"
          }
        ]
      },
      "url": {
        "anyOf": [
          {
            "type": "string",
            "format": "uri"
          },
          {
            "type": "null"
          }
        ]
      },
      "sha256": {
        "type": "string",
        "pattern": "^[0-9a-f]{64}$"
      },
      "file": {
        "type": "string",
        "pattern": "^\\/docs\\/files\\/[0-9a-f]{64}\\.(pdf|zip|csv|json|txt|html|docx|xlsx|png|jpg|mp4|webm)$"
      },
      "format": {
        "type": "string",
        "enum": [
          "pdf",
          "zip",
          "csv",
          "json",
          "txt",
          "html",
          "docx",
          "xlsx",
          "png",
          "jpg",
          "mp4",
          "webm"
        ]
      },
      "bytes": {
        "type": "integer",
        "exclusiveMinimum": 0,
        "maximum": 9007199254740991
      },
      "pages": {
        "anyOf": [
          {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          {
            "type": "null"
          }
        ]
      },
      "entries": {
        "anyOf": [
          {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          {
            "type": "null"
          }
        ]
      },
      "changes": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "claims": {
        "type": "array",
        "items": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]*$"
        }
      },
      "cases": {
        "type": "array",
        "items": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]*$"
        }
      }
    },
    "required": [
      "id",
      "title",
      "kind",
      "court",
      "docket",
      "filed",
      "url",
      "sha256",
      "file",
      "format",
      "bytes",
      "pages",
      "entries",
      "changes",
      "claims",
      "cases"
    ],
    "additionalProperties": false
  }
}
