{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://thewarrecord.com/api/v1/schema/series.json",
 "title": "series",
 "type": "object",
 "description": "An open data series (a price, a transit count, an index) with its source and licence. Proprietary series are never stored; their figures appear only as cited facts.",
 "required": [
  "id",
  "type",
  "name",
  "theme",
  "unit",
  "frequency",
  "source",
  "licence",
  "points",
  "citations",
  "record_state",
  "schema_version"
 ],
 "properties": {
  "record_state": {
   "enum": [
    "active",
    "merged",
    "withdrawn"
   ]
  },
  "merged_into": {
   "type": "string"
  },
  "withdrawn_reason": {
   "type": "string"
  },
  "schema_version": {
   "const": 1
  },
  "created_at": {
   "type": "string",
   "format": "date-time"
  },
  "last_changed": {
   "type": "string",
   "format": "date-time"
  },
  "id": {
   "type": "string",
   "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
  },
  "type": {
   "const": "series"
  },
  "name": {
   "type": "string"
  },
  "description": {
   "type": "string"
  },
  "theme": {
   "enum": [
    "energy",
    "shipping",
    "trade",
    "food",
    "finance",
    "humanitarian",
    "infrastructure"
   ]
  },
  "conflicts": {
   "type": "array",
   "items": {
    "type": "string",
    "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
   }
  },
  "unit": {
   "type": "string"
  },
  "frequency": {
   "enum": [
    "daily",
    "weekly",
    "monthly",
    "quarterly",
    "annual"
   ]
  },
  "source": {
   "type": "string",
   "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
  },
  "licence": {
   "enum": [
    "open",
    "public_domain",
    "cc_by",
    "ask_first_granted"
   ]
  },
  "licence_note": {
   "type": "string"
  },
  "baseline": {
   "type": "object",
   "properties": {
    "label": {
     "type": "string"
    },
    "from": {
     "type": "string",
     "format": "date"
    },
    "to": {
     "type": "string",
     "format": "date"
    },
    "value": {
     "type": "number"
    }
   },
   "additionalProperties": false
  },
  "points": {
   "type": "array",
   "minItems": 1,
   "items": {
    "type": "array",
    "prefixItems": [
     {
      "type": "string",
      "format": "date"
     },
     {
      "type": [
       "number",
       "null"
      ]
     }
    ],
    "minItems": 2,
    "maxItems": 2
   }
  },
  "citations": {
   "type": "array",
   "minItems": 1,
   "items": {
    "type": "object",
    "required": [
     "source",
     "url",
     "origin",
     "role",
     "published_at",
     "accessed_at"
    ],
    "properties": {
     "source": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
     },
     "url": {
      "type": "string",
      "format": "uri"
     },
     "archive_url": {
      "type": "string",
      "format": "uri"
     },
     "origin": {
      "type": "string",
      "minLength": 3,
      "description": "The first-hand material this citation relies on. Independence is counted on distinct origins, not outlets."
     },
     "role": {
      "enum": [
       "evidence",
       "corroboration",
       "contradiction",
       "claim_origin",
       "count",
       "visual",
       "sensor"
      ]
     },
     "supports": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "published_at": {
      "type": "string",
      "format": "date-time"
     },
     "accessed_at": {
      "type": "string",
      "format": "date-time"
     },
     "language": {
      "type": "string"
     },
     "excerpt": {
      "type": "string",
      "maxLength": 200
     }
    },
    "additionalProperties": false
   }
  }
 },
 "additionalProperties": false
}
