# forge-chart WebSocket messages v1

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "forge-chart WebSocket messages v1",
  "oneOf": [
    {
      "$ref": "#/$defs/auth"
    },
    {
      "$ref": "#/$defs/ready"
    },
    {
      "$ref": "#/$defs/subscribe"
    },
    {
      "$ref": "#/$defs/snapshot"
    },
    {
      "$ref": "#/$defs/bar"
    },
    {
      "$ref": "#/$defs/series"
    },
    {
      "$ref": "#/$defs/status"
    },
    {
      "$ref": "#/$defs/unsubscribe"
    },
    {
      "$ref": "#/$defs/ping"
    },
    {
      "$ref": "#/$defs/pong"
    },
    {
      "$ref": "#/$defs/error"
    }
  ],
  "$defs": {
    "id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "id"
      ],
      "properties": {
        "kind": {
          "enum": [
            "upload",
            "broker"
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "auth": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "token"
      ],
      "properties": {
        "type": {
          "const": "auth"
        },
        "token": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "ready": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "user_id",
        "limits"
      ],
      "properties": {
        "type": {
          "const": "ready"
        },
        "user_id": {
          "type": "string"
        },
        "limits": {
          "type": "object",
          "required": [
            "max_subscriptions"
          ],
          "properties": {
            "max_subscriptions": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      }
    },
    "subscribe": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id",
        "spec",
        "source",
        "series"
      ],
      "properties": {
        "type": {
          "const": "subscribe"
        },
        "id": {
          "$ref": "#/$defs/id"
        },
        "spec": {
          "$ref": "bar-spec.schema.json"
        },
        "source": {
          "$ref": "#/$defs/source"
        },
        "series": {
          "type": "array",
          "maxItems": 20,
          "items": {
            "type": "object"
          }
        }
      }
    },
    "snapshot": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id",
        "page",
        "series"
      ],
      "properties": {
        "type": {
          "const": "snapshot"
        },
        "id": {
          "$ref": "#/$defs/id"
        },
        "page": {
          "$ref": "bar-page.schema.json"
        },
        "series": {
          "type": "array",
          "items": {
            "$ref": "series-page.schema.json"
          }
        }
      }
    },
    "bar": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id",
        "i",
        "row",
        "state"
      ],
      "properties": {
        "type": {
          "const": "bar"
        },
        "id": {
          "$ref": "#/$defs/id"
        },
        "i": {
          "type": "integer",
          "minimum": 0
        },
        "row": {
          "type": "object",
          "required": [
            "t_open",
            "t_close",
            "o",
            "h",
            "l",
            "c",
            "flags",
            "dir"
          ]
        },
        "state": {
          "enum": [
            "forming",
            "closed"
          ]
        }
      }
    },
    "series": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id",
        "name",
        "i",
        "values",
        "state"
      ],
      "properties": {
        "type": {
          "const": "series"
        },
        "id": {
          "$ref": "#/$defs/id"
        },
        "name": {
          "type": "string"
        },
        "i": {
          "type": "integer",
          "minimum": 0
        },
        "values": {
          "type": "object"
        },
        "state": {
          "enum": [
            "forming",
            "closed"
          ]
        }
      }
    },
    "status": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id",
        "source",
        "stale"
      ],
      "properties": {
        "type": {
          "const": "status"
        },
        "id": {
          "$ref": "#/$defs/id"
        },
        "source": {
          "$ref": "#/$defs/source"
        },
        "stale": {
          "type": "boolean"
        },
        "reason": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "unsubscribe": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id"
      ],
      "properties": {
        "type": {
          "const": "unsubscribe"
        },
        "id": {
          "$ref": "#/$defs/id"
        }
      }
    },
    "ping": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "const": "ping"
        }
      }
    },
    "pong": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "const": "pong"
        }
      }
    },
    "error": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id",
        "code",
        "message"
      ],
      "properties": {
        "type": {
          "const": "error"
        },
        "id": {
          "type": [
            "string",
            "null"
          ]
        },
        "code": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$"
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}
```
