{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/kitlangton/cellshot/schemas/recording-entry-v1.schema.json",
  "title": "cellshot recording JSON Lines entry v1",
  "description": "Validates one line of a .cellshot JSON Lines recording. The first line must be a header entry.",
  "oneOf": [
    { "$ref": "#/$defs/header" },
    { "$ref": "#/$defs/output" },
    { "$ref": "#/$defs/input" }
  ],
  "$defs": {
    "dimension": { "type": "integer", "minimum": 0, "maximum": 65535 },
    "byteArray": {
      "type": "array",
      "items": { "type": "integer", "minimum": 0, "maximum": 255 }
    },
    "header": {
      "type": "object",
      "required": ["type", "version", "cols", "rows", "cell_width", "cell_height"],
      "additionalProperties": false,
      "properties": {
        "type": { "const": "header" },
        "version": { "const": 1 },
        "cols": { "$ref": "#/$defs/dimension" },
        "rows": { "$ref": "#/$defs/dimension" },
        "cell_width": { "$ref": "#/$defs/dimension" },
        "cell_height": { "$ref": "#/$defs/dimension" }
      }
    },
    "output": {
      "type": "object",
      "required": ["type", "at_ms", "bytes"],
      "additionalProperties": false,
      "properties": {
        "type": { "const": "output" },
        "at_ms": { "type": "integer", "minimum": 0 },
        "bytes": { "$ref": "#/$defs/byteArray" }
      }
    },
    "input": {
      "type": "object",
      "required": ["type", "at_ms", "origin", "bytes"],
      "additionalProperties": false,
      "properties": {
        "type": { "const": "input" },
        "at_ms": { "type": "integer", "minimum": 0 },
        "origin": { "enum": ["client", "host"] },
        "bytes": { "$ref": "#/$defs/byteArray" }
      }
    }
  }
}
