{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Threecard v1 design contract (APPROVED_DESIGN / NOT_RUN)",
  "$defs": {
    "Id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{1,128}(?![\\s\\S])"
    },
    "Seq": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)(?![\\s\\S])",
      "description": "Exact nonnegative integer; arbitrary precision, never a JSON number."
    },
    "PositiveSeq": {
      "type": "string",
      "pattern": "^[1-9][0-9]*(?![\\s\\S])"
    },
    "Timestamp": {
      "type": "string",
      "format": "date-time",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z(?![\\s\\S])",
      "description": "UTC RFC3339 with milliseconds."
    },
    "Millis": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "InputAmount": {
      "type": "string",
      "pattern": "^[1-9][0-9]{0,17}(?![\\s\\S])",
      "description": "Positive whole Play Chips; checked x10 <= signed int64; no sign, leading zero, spaces or exponent."
    },
    "ConfigAmount": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]{0,8}|1000000000)(?![\\s\\S])",
      "description": "Whole Play Chips; <= 1000000000."
    },
    "Amount": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]{0,17})(\\.[1-9])?(?![\\s\\S])",
      "description": "Canonical nonnegative Play Chips, <=922337203685477580.7; whole amounts omit .0."
    },
    "SignedAmount": {
      "type": "string",
      "pattern": "^(?!-0(?![\\s\\S]))-?(0|[1-9][0-9]{0,17})(\\.[1-9])?(?![\\s\\S])",
      "description": "Signed ledger/net value; -0 forbidden; checked signed-int64 storage range."
    },
    "Rules": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "ante": {
          "$ref": "#/$defs/InputAmount"
        },
        "minimum_buy_in": {
          "$ref": "#/$defs/InputAmount"
        },
        "bet_limit": {
          "$ref": "#/$defs/InputAmount"
        },
        "category_order": {
          "type": "string",
          "enum": [
            "flush_over_straight",
            "straight_over_flush"
          ]
        },
        "blind_compare_enabled": {
          "type": "boolean"
        }
      },
      "required": [
        "ante",
        "minimum_buy_in",
        "bet_limit",
        "category_order",
        "blind_compare_enabled"
      ]
    },
    "Session": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "session_id": {
          "$ref": "#/$defs/Id"
        },
        "session_generation": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "expires_at": {
          "$ref": "#/$defs/Timestamp"
        },
        "absolute_expires_at": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "session_id",
        "session_generation",
        "expires_at",
        "absolute_expires_at"
      ]
    },
    "Tokens": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "token_type": {
          "const": "Bearer"
        },
        "access_token": {
          "type": "string",
          "minLength": 1,
          "writeOnly": false
        },
        "access_token_expires_at": {
          "$ref": "#/$defs/Timestamp"
        },
        "refresh_token": {
          "type": "string",
          "minLength": 43
        },
        "refresh_token_expires_at": {
          "$ref": "#/$defs/Timestamp"
        },
        "session": {
          "$ref": "#/$defs/Session"
        }
      },
      "required": [
        "token_type",
        "access_token",
        "access_token_expires_at",
        "refresh_token",
        "refresh_token_expires_at",
        "session"
      ]
    },
    "User": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "player_id": {
          "$ref": "#/$defs/Id"
        },
        "display_name": {
          "type": "string",
          "maxLength": 128
        },
        "status": {
          "type": "string",
          "enum": [
            "ACTIVE",
            "RESTRICTED",
            "CLOSED"
          ]
        }
      },
      "required": [
        "player_id",
        "display_name",
        "status"
      ]
    },
    "Admin": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "admin_id": {
          "$ref": "#/$defs/Id"
        },
        "roles": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "uniqueItems": true
        },
        "permissions": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "uniqueItems": true
        }
      },
      "required": [
        "admin_id",
        "roles",
        "permissions"
      ]
    },
    "Wallet": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "available": {
          "$ref": "#/$defs/Amount"
        },
        "reserved_capacity": {
          "$ref": "#/$defs/Amount"
        },
        "account_version": {
          "$ref": "#/$defs/Seq"
        }
      },
      "required": [
        "available",
        "reserved_capacity",
        "account_version"
      ]
    },
    "Registration": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "created": {
          "type": "boolean"
        },
        "bonus_amount": {
          "$ref": "#/$defs/Amount"
        },
        "bonus_config_version": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "bonus_ledger_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/Id"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "created",
        "bonus_amount",
        "bonus_config_version",
        "bonus_ledger_id"
      ]
    },
    "TelegramRequest": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "init_data": {
          "type": "string",
          "minLength": 1,
          "maxLength": 16384
        }
      },
      "required": [
        "init_data"
      ]
    },
    "RefreshRequest": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "refresh_token": {
          "type": "string",
          "minLength": 43,
          "maxLength": 1024
        }
      },
      "required": [
        "refresh_token"
      ]
    },
    "LogoutRequest": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "all_sessions": {
          "type": "boolean",
          "default": false
        }
      },
      "required": []
    },
    "DevLoginRequest": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "player_id": {
              "$ref": "#/$defs/Id"
            }
          },
          "required": [
            "player_id"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "telegram_id": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,19}(?![\\s\\S])"
            }
          },
          "required": [
            "telegram_id"
          ]
        }
      ]
    },
    "AdminLoginRequest": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "username": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "password": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024,
          "writeOnly": true
        }
      },
      "required": [
        "username",
        "password"
      ]
    },
    "Login": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "user": {
          "$ref": "#/$defs/User"
        },
        "registration": {
          "$ref": "#/$defs/Registration"
        },
        "tokens": {
          "$ref": "#/$defs/Tokens"
        }
      },
      "required": [
        "user",
        "registration",
        "tokens"
      ]
    },
    "AdminLogin": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "admin": {
          "$ref": "#/$defs/Admin"
        },
        "tokens": {
          "$ref": "#/$defs/Tokens"
        }
      },
      "required": [
        "admin",
        "tokens"
      ]
    },
    "ErrorCode": {
      "type": "string",
      "enum": [
        "INVALID_REQUEST",
        "UNSUPPORTED_PROTOCOL",
        "INVALID_AMOUNT",
        "AMOUNT_OVERFLOW",
        "UNAUTHENTICATED",
        "TOKEN_EXPIRED",
        "TOKEN_INVALID",
        "INVALID_REFRESH_TOKEN",
        "SESSION_REPLACED",
        "SESSION_REVOKED",
        "SESSION_EXPIRED",
        "INVALID_TELEGRAM_INIT_DATA",
        "TELEGRAM_AUTH_EXPIRED",
        "INVALID_CREDENTIALS",
        "FORBIDDEN",
        "ROOM_NOT_AVAILABLE",
        "ROOM_FULL",
        "ALREADY_IN_ACTIVE_ROOM",
        "RULE_VERSION_CHANGED",
        "STATE_VERSION_CONFLICT",
        "NOT_YOUR_TURN",
        "INVALID_ACTION",
        "INVALID_COMPARE_TARGET",
        "INSUFFICIENT_POINTS",
        "DUPLICATE_ACTION_PAYLOAD_MISMATCH",
        "INTENT_CONFLICT",
        "INTENT_REVISION_CONFLICT",
        "INTENT_REQUIRES_REVISION",
        "DEADLINE_EXPIRED",
        "RATE_LIMITED",
        "QUEUE_FULL",
        "COMMAND_IN_PROGRESS",
        "RECOVERY_IN_PROGRESS",
        "SETTLEMENT_PENDING",
        "DEPENDENCY_UNAVAILABLE",
        "CONFIG_UNAVAILABLE",
        "CONFIG_VERSION_CONFLICT",
        "INVALID_CURSOR",
        "SNAPSHOT_REQUIRED",
        "USER_NOT_FOUND"
      ]
    },
    "Error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "$ref": "#/$defs/ErrorCode"
        },
        "message": {
          "type": "string",
          "maxLength": 256
        },
        "retry": {
          "type": "string",
          "enum": [
            "NONE",
            "SAME_KEY",
            "QUERY_ONLY",
            "SYNC_NEW_KEY",
            "REAUTH",
            "RESNAPSHOT"
          ]
        },
        "retry_after_ms": {
          "anyOf": [
            {
              "$ref": "#/$defs/Millis"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "code",
        "message",
        "retry",
        "retry_after_ms"
      ]
    },
    "ErrorResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "error": {
          "$ref": "#/$defs/Error"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "error"
      ]
    },
    "Command_create_room": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "player"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "type": "null"
        },
        "hand_id": {
          "type": "null"
        },
        "turn_id": {
          "type": "null"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "create_room"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "rules": {
              "$ref": "#/$defs/Rules"
            },
            "buy_in_amount": {
              "$ref": "#/$defs/InputAmount"
            }
          },
          "required": [
            "rules",
            "buy_in_amount"
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_join_room": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "player"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "type": "null"
        },
        "hand_id": {
          "type": "null"
        },
        "turn_id": {
          "type": "null"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "join_room"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "invite_code": {
              "type": "string",
              "pattern": "^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{16}(?![\\s\\S])"
            },
            "buy_in_amount": {
              "$ref": "#/$defs/InputAmount"
            },
            "seat": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "maximum": 5
            }
          },
          "required": [
            "invite_code",
            "buy_in_amount"
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_ready": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "type": "null"
        },
        "turn_id": {
          "type": "null"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "ready"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "ready": {
              "type": "boolean"
            },
            "rule_version": {
              "$ref": "#/$defs/PositiveSeq"
            }
          },
          "required": [
            "ready",
            "rule_version"
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_set_rules": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "type": "null"
        },
        "turn_id": {
          "type": "null"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "set_rules"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "rules": {
              "$ref": "#/$defs/Rules"
            }
          },
          "required": [
            "rules"
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_start_hand": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "type": "null"
        },
        "turn_id": {
          "type": "null"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "start_hand"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "rule_version": {
              "$ref": "#/$defs/PositiveSeq"
            }
          },
          "required": [
            "rule_version"
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_rotate_invite": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "type": "null"
        },
        "turn_id": {
          "type": "null"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "rotate_invite"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {},
          "required": []
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_transfer_host": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "type": "null"
        },
        "turn_id": {
          "type": "null"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "transfer_host"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "target_player_id": {
              "$ref": "#/$defs/Id"
            }
          },
          "required": [
            "target_player_id"
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_kick_member": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "type": "null"
        },
        "turn_id": {
          "type": "null"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "kick_member"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "target_player_id": {
              "$ref": "#/$defs/Id"
            },
            "reason": {
              "type": "string",
              "minLength": 8,
              "maxLength": 500
            }
          },
          "required": [
            "target_player_id"
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_close_room": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "type": "null"
        },
        "turn_id": {
          "type": "null"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "close_room"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {},
          "required": []
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_leave_room": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "type": "null"
        },
        "turn_id": {
          "type": "null"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "leave_room"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {},
          "required": []
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_look": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "$ref": "#/$defs/Id"
        },
        "turn_id": {
          "$ref": "#/$defs/Id"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "look"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {},
          "required": []
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_bet": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "$ref": "#/$defs/Id"
        },
        "turn_id": {
          "$ref": "#/$defs/Id"
        },
        "intent_revision": {
          "anyOf": [
            {
              "$ref": "#/$defs/PositiveSeq"
            },
            {
              "type": "null"
            }
          ]
        },
        "command": {
          "const": "bet"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "amount": {
              "$ref": "#/$defs/InputAmount"
            }
          },
          "required": [
            "amount"
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_call": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "$ref": "#/$defs/Id"
        },
        "turn_id": {
          "$ref": "#/$defs/Id"
        },
        "intent_revision": {
          "anyOf": [
            {
              "$ref": "#/$defs/PositiveSeq"
            },
            {
              "type": "null"
            }
          ]
        },
        "command": {
          "const": "call"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {},
          "required": []
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_raise": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "$ref": "#/$defs/Id"
        },
        "turn_id": {
          "$ref": "#/$defs/Id"
        },
        "intent_revision": {
          "anyOf": [
            {
              "$ref": "#/$defs/PositiveSeq"
            },
            {
              "type": "null"
            }
          ]
        },
        "command": {
          "const": "raise"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "amount": {
              "$ref": "#/$defs/InputAmount"
            }
          },
          "required": [
            "amount"
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_compare": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "$ref": "#/$defs/Id"
        },
        "turn_id": {
          "$ref": "#/$defs/Id"
        },
        "intent_revision": {
          "anyOf": [
            {
              "$ref": "#/$defs/PositiveSeq"
            },
            {
              "type": "null"
            }
          ]
        },
        "command": {
          "const": "compare"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "target_player_id": {
              "$ref": "#/$defs/Id"
            }
          },
          "required": [
            "target_player_id"
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_fold": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "$ref": "#/$defs/Id"
        },
        "turn_id": {
          "$ref": "#/$defs/Id"
        },
        "intent_revision": {
          "type": "null"
        },
        "command": {
          "const": "fold"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {},
          "required": []
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_request_topup": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "$ref": "#/$defs/Id"
        },
        "turn_id": {
          "$ref": "#/$defs/Id"
        },
        "intent_revision": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "command": {
          "const": "request_topup"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {},
          "required": []
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_topup": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "$ref": "#/$defs/Id"
        },
        "turn_id": {
          "$ref": "#/$defs/Id"
        },
        "intent_revision": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "command": {
          "const": "topup"
        },
        "payload": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "amount": {
              "$ref": "#/$defs/InputAmount"
            }
          },
          "required": [
            "amount"
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command_revise_intent": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "protocol_version": {
          "const": "threecard.v1"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "const": "room"
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "expected_version": {
          "$ref": "#/$defs/Seq"
        },
        "hand_id": {
          "$ref": "#/$defs/Id"
        },
        "turn_id": {
          "$ref": "#/$defs/Id"
        },
        "intent_revision": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "command": {
          "const": "revise_intent"
        },
        "payload": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "amount": {
                  "$ref": "#/$defs/InputAmount"
                }
              },
              "required": [
                "amount"
              ]
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "target_player_id": {
                  "$ref": "#/$defs/Id"
                }
              },
              "required": [
                "target_player_id"
              ]
            }
          ]
        }
      },
      "required": [
        "protocol_version",
        "action_id",
        "scope_kind",
        "scope_id",
        "expected_version",
        "hand_id",
        "turn_id",
        "intent_revision",
        "command",
        "payload"
      ]
    },
    "Command": {
      "oneOf": [
        {
          "$ref": "#/$defs/Command_create_room"
        },
        {
          "$ref": "#/$defs/Command_join_room"
        },
        {
          "$ref": "#/$defs/Command_ready"
        },
        {
          "$ref": "#/$defs/Command_set_rules"
        },
        {
          "$ref": "#/$defs/Command_start_hand"
        },
        {
          "$ref": "#/$defs/Command_rotate_invite"
        },
        {
          "$ref": "#/$defs/Command_transfer_host"
        },
        {
          "$ref": "#/$defs/Command_kick_member"
        },
        {
          "$ref": "#/$defs/Command_close_room"
        },
        {
          "$ref": "#/$defs/Command_leave_room"
        },
        {
          "$ref": "#/$defs/Command_look"
        },
        {
          "$ref": "#/$defs/Command_bet"
        },
        {
          "$ref": "#/$defs/Command_call"
        },
        {
          "$ref": "#/$defs/Command_raise"
        },
        {
          "$ref": "#/$defs/Command_compare"
        },
        {
          "$ref": "#/$defs/Command_fold"
        },
        {
          "$ref": "#/$defs/Command_request_topup"
        },
        {
          "$ref": "#/$defs/Command_topup"
        },
        {
          "$ref": "#/$defs/Command_revise_intent"
        }
      ]
    },
    "Receipt": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "action_id": {
              "$ref": "#/$defs/Id"
            },
            "scope_kind": {
              "type": "string",
              "enum": [
                "player",
                "room",
                "auth",
                "admin"
              ]
            },
            "scope_id": {
              "$ref": "#/$defs/Id"
            },
            "state_version": {
              "anyOf": [
                {
                  "$ref": "#/$defs/Seq"
                },
                {
                  "type": "null"
                }
              ]
            },
            "references": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "room_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "hand_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "ledger_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "room_id",
                "hand_id",
                "ledger_id"
              ]
            },
            "status": {
              "const": "COMMITTED"
            },
            "outcome": {
              "const": "APPLIED"
            },
            "error": {
              "type": "null"
            }
          },
          "required": [
            "action_id",
            "scope_kind",
            "scope_id",
            "state_version",
            "references",
            "status",
            "outcome",
            "error"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "action_id": {
              "$ref": "#/$defs/Id"
            },
            "scope_kind": {
              "type": "string",
              "enum": [
                "player",
                "room",
                "auth",
                "admin"
              ]
            },
            "scope_id": {
              "$ref": "#/$defs/Id"
            },
            "state_version": {
              "anyOf": [
                {
                  "$ref": "#/$defs/Seq"
                },
                {
                  "type": "null"
                }
              ]
            },
            "references": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "room_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "hand_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "ledger_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "room_id",
                "hand_id",
                "ledger_id"
              ]
            },
            "status": {
              "const": "COMMITTED"
            },
            "outcome": {
              "const": "REJECTED"
            },
            "error": {
              "$ref": "#/$defs/Error"
            }
          },
          "required": [
            "action_id",
            "scope_kind",
            "scope_id",
            "state_version",
            "references",
            "status",
            "outcome",
            "error"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "action_id": {
              "$ref": "#/$defs/Id"
            },
            "scope_kind": {
              "type": "string",
              "enum": [
                "player",
                "room",
                "auth",
                "admin"
              ]
            },
            "scope_id": {
              "$ref": "#/$defs/Id"
            },
            "state_version": {
              "anyOf": [
                {
                  "$ref": "#/$defs/Seq"
                },
                {
                  "type": "null"
                }
              ]
            },
            "references": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "room_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "hand_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "ledger_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "room_id",
                "hand_id",
                "ledger_id"
              ]
            },
            "status": {
              "const": "KNOWN_ROLLED_BACK"
            },
            "outcome": {
              "type": "null"
            },
            "error": {
              "$ref": "#/$defs/Error"
            }
          },
          "required": [
            "action_id",
            "scope_kind",
            "scope_id",
            "state_version",
            "references",
            "status",
            "outcome",
            "error"
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "action_id": {
              "$ref": "#/$defs/Id"
            },
            "scope_kind": {
              "type": "string",
              "enum": [
                "player",
                "room",
                "auth",
                "admin"
              ]
            },
            "scope_id": {
              "$ref": "#/$defs/Id"
            },
            "state_version": {
              "anyOf": [
                {
                  "$ref": "#/$defs/Seq"
                },
                {
                  "type": "null"
                }
              ]
            },
            "references": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "room_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "hand_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "ledger_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "room_id",
                "hand_id",
                "ledger_id"
              ]
            },
            "status": {
              "const": "UNKNOWN"
            },
            "outcome": {
              "type": "null"
            },
            "error": {
              "$ref": "#/$defs/Error"
            }
          },
          "required": [
            "action_id",
            "scope_kind",
            "scope_id",
            "state_version",
            "references",
            "status",
            "outcome",
            "error"
          ]
        }
      ]
    },
    "Member": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "player_id": {
          "$ref": "#/$defs/Id"
        },
        "display_name": {
          "type": "string",
          "maxLength": 128
        },
        "seat": {
          "type": "integer",
          "minimum": 0,
          "maximum": 5
        },
        "ready": {
          "type": "boolean"
        },
        "online": {
          "type": "boolean"
        },
        "hand_status": {
          "type": "string",
          "enum": [
            "NOT_PLAYING",
            "BLIND",
            "SEEN",
            "FOLDED",
            "ELIMINATED"
          ]
        },
        "escrow": {
          "anyOf": [
            {
              "$ref": "#/$defs/Amount"
            },
            {
              "type": "null"
            }
          ]
        },
        "contribution": {
          "$ref": "#/$defs/Amount"
        }
      },
      "required": [
        "player_id",
        "display_name",
        "seat",
        "ready",
        "online",
        "hand_status",
        "escrow",
        "contribution"
      ]
    },
    "Turn": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "turn_id": {
          "$ref": "#/$defs/Id"
        },
        "player_id": {
          "$ref": "#/$defs/Id"
        },
        "turn_epoch": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "deadline": {
          "anyOf": [
            {
              "$ref": "#/$defs/Timestamp"
            },
            {
              "type": "null"
            }
          ]
        },
        "saved_remaining_ms": {
          "anyOf": [
            {
              "$ref": "#/$defs/Millis"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "turn_id",
        "player_id",
        "turn_epoch",
        "deadline",
        "saved_remaining_ms"
      ]
    },
    "Pause": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "pause_id": {
          "$ref": "#/$defs/Id"
        },
        "pause_epoch": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "requester_player_id": {
          "$ref": "#/$defs/Id"
        },
        "started_at": {
          "$ref": "#/$defs/Timestamp"
        },
        "deadline": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "pause_id",
        "pause_epoch",
        "requester_player_id",
        "started_at",
        "deadline"
      ],
      "description": "Public pause timing only. Cumulative personal budget is projected exclusively via Snapshot.self_topup_budget."
    },
    "Intent": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "intent_revision": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "command": {
          "type": "string",
          "enum": [
            "bet",
            "call",
            "raise",
            "compare"
          ]
        },
        "amount": {
          "anyOf": [
            {
              "$ref": "#/$defs/InputAmount"
            },
            {
              "type": "null"
            }
          ]
        },
        "target_player_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/Id"
            },
            {
              "type": "null"
            }
          ]
        },
        "required_amount": {
          "anyOf": [
            {
              "$ref": "#/$defs/Amount"
            },
            {
              "type": "null"
            }
          ]
        },
        "valid": {
          "type": "boolean"
        },
        "invalid_reason": {
          "anyOf": [
            {
              "$ref": "#/$defs/ErrorCode"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "intent_revision",
        "command",
        "amount",
        "target_player_id",
        "required_amount",
        "valid",
        "invalid_reason"
      ]
    },
    "Outcome": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "SETTLED",
            "CANCELLED_REFUNDED"
          ]
        },
        "winner_player_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/Id"
            },
            {
              "type": "null"
            }
          ]
        },
        "pot_transferred": {
          "$ref": "#/$defs/Amount"
        },
        "reason_code": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "GAME_STATE_UNRECOVERABLE",
                "DEAL_UNRECOVERABLE"
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "kind",
        "winner_player_id",
        "pot_transferred",
        "reason_code"
      ]
    },
    "HandPublic": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "hand_id": {
          "$ref": "#/$defs/Id"
        },
        "phase": {
          "type": "string",
          "enum": [
            "ACTIVE",
            "TOPUP_PAUSED",
            "SETTLED",
            "CANCELLED_REFUNDED"
          ]
        },
        "rule_version": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "rules": {
          "$ref": "#/$defs/Rules"
        },
        "round_id": {
          "$ref": "#/$defs/Id"
        },
        "round_no": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "base_amount": {
          "anyOf": [
            {
              "$ref": "#/$defs/Amount"
            },
            {
              "type": "null"
            }
          ]
        },
        "pot": {
          "$ref": "#/$defs/Amount"
        },
        "turn": {
          "anyOf": [
            {
              "$ref": "#/$defs/Turn"
            },
            {
              "type": "null"
            }
          ]
        },
        "pause": {
          "anyOf": [
            {
              "$ref": "#/$defs/Pause"
            },
            {
              "type": "null"
            }
          ]
        },
        "outcome": {
          "anyOf": [
            {
              "$ref": "#/$defs/Outcome"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "hand_id",
        "phase",
        "rule_version",
        "rules",
        "round_id",
        "round_no",
        "base_amount",
        "pot",
        "turn",
        "pause",
        "outcome"
      ]
    },
    "VisibleHand": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "subject_player_id": {
          "$ref": "#/$defs/Id"
        },
        "cards": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^(2|3|4|5|6|7|8|9|T|J|Q|K|A)[CDHS](?![\\s\\S])"
          },
          "minItems": 3,
          "maxItems": 3,
          "uniqueItems": true
        },
        "reason": {
          "type": "string",
          "enum": [
            "LOOK",
            "COMPARE",
            "WINNER_PUBLIC"
          ]
        },
        "source_seq": {
          "$ref": "#/$defs/Seq"
        }
      },
      "required": [
        "subject_player_id",
        "cards",
        "reason",
        "source_seq"
      ]
    },
    "QuoteAction": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "command": {
          "type": "string",
          "enum": [
            "bet",
            "call",
            "raise",
            "compare",
            "look",
            "fold",
            "leave_room",
            "request_topup",
            "topup",
            "revise_intent"
          ]
        },
        "allowed": {
          "type": "boolean"
        },
        "reason": {
          "anyOf": [
            {
              "$ref": "#/$defs/ErrorCode"
            },
            {
              "type": "null"
            }
          ]
        },
        "automatic_amount": {
          "anyOf": [
            {
              "$ref": "#/$defs/Amount"
            },
            {
              "type": "null"
            }
          ]
        },
        "minimum_input": {
          "anyOf": [
            {
              "$ref": "#/$defs/InputAmount"
            },
            {
              "type": "null"
            }
          ]
        },
        "maximum_input": {
          "anyOf": [
            {
              "$ref": "#/$defs/InputAmount"
            },
            {
              "type": "null"
            }
          ]
        },
        "target_player_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Id"
          },
          "maxItems": 5,
          "uniqueItems": true
        }
      },
      "required": [
        "command",
        "allowed",
        "reason",
        "automatic_amount",
        "minimum_input",
        "maximum_input",
        "target_player_ids"
      ]
    },
    "Quote": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "room_id": {
          "$ref": "#/$defs/Id"
        },
        "hand_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/Id"
            },
            {
              "type": "null"
            }
          ]
        },
        "state_version": {
          "$ref": "#/$defs/Seq"
        },
        "rule_version": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "turn_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/Id"
            },
            {
              "type": "null"
            }
          ]
        },
        "intent": {
          "anyOf": [
            {
              "$ref": "#/$defs/Intent"
            },
            {
              "type": "null"
            }
          ]
        },
        "actions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/QuoteAction"
          },
          "maxItems": 11
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "room_id",
        "hand_id",
        "state_version",
        "rule_version",
        "turn_id",
        "intent",
        "actions",
        "server_time"
      ]
    },
    "TopupBudget": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "budget_ms": {
          "$ref": "#/$defs/Millis"
        },
        "used_ms": {
          "$ref": "#/$defs/Millis",
          "description": "Closed pause segments of this viewer only. Remaining subtracts the open segment only when this viewer is its requester at snapshot.server_time; never charge another player or subtract twice."
        },
        "remaining_ms_at_server_time": {
          "$ref": "#/$defs/Millis"
        },
        "config_version": {
          "$ref": "#/$defs/PositiveSeq"
        }
      },
      "required": [
        "budget_ms",
        "used_ms",
        "remaining_ms_at_server_time",
        "config_version"
      ]
    },
    "Snapshot": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "room_id": {
          "$ref": "#/$defs/Id"
        },
        "state_version": {
          "$ref": "#/$defs/Seq"
        },
        "event_seq": {
          "$ref": "#/$defs/Seq"
        },
        "delivery_generation": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "availability": {
          "type": "string",
          "enum": [
            "SERVING",
            "RECOVERING",
            "RECOVERY_BLOCKED",
            "VOID_PENDING"
          ]
        },
        "host_player_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/Id"
            },
            {
              "type": "null"
            }
          ]
        },
        "rule_version": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "rules": {
          "$ref": "#/$defs/Rules"
        },
        "members": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Member"
          },
          "maxItems": 6
        },
        "hand": {
          "anyOf": [
            {
              "$ref": "#/$defs/HandPublic"
            },
            {
              "type": "null"
            }
          ]
        },
        "self_invite": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "invite_code": {
                  "type": "string",
                  "pattern": "^[0-9A-HJKMNP-TV-Z]{16}(?![\\s\\S])"
                },
                "invite_version": {
                  "$ref": "#/$defs/PositiveSeq"
                },
                "expires_at": {
                  "$ref": "#/$defs/Timestamp"
                }
              },
              "required": [
                "invite_code",
                "invite_version",
                "expires_at"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "self_intent": {
          "anyOf": [
            {
              "$ref": "#/$defs/Intent"
            },
            {
              "type": "null"
            }
          ]
        },
        "self_topup_budget": {
          "anyOf": [
            {
              "$ref": "#/$defs/TopupBudget"
            },
            {
              "type": "null"
            }
          ]
        },
        "visible_hands": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/VisibleHand"
          },
          "maxItems": 6
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "room_id",
        "state_version",
        "event_seq",
        "delivery_generation",
        "availability",
        "host_player_id",
        "rule_version",
        "rules",
        "members",
        "hand",
        "self_invite",
        "self_intent",
        "self_topup_budget",
        "visible_hands",
        "server_time"
      ]
    },
    "HistoryEntry": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "history_seq": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "hand_id": {
          "$ref": "#/$defs/Id"
        },
        "room_id": {
          "$ref": "#/$defs/Id"
        },
        "terminal_at": {
          "$ref": "#/$defs/Timestamp"
        },
        "terminal_event_seq": {
          "$ref": "#/$defs/Seq"
        },
        "rule_version": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "outcome": {
          "$ref": "#/$defs/Outcome"
        },
        "self_contribution": {
          "$ref": "#/$defs/Amount"
        },
        "self_net": {
          "$ref": "#/$defs/SignedAmount"
        },
        "visible_hands": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/VisibleHand"
          },
          "maxItems": 6
        }
      },
      "required": [
        "history_seq",
        "hand_id",
        "room_id",
        "terminal_at",
        "terminal_event_seq",
        "rule_version",
        "outcome",
        "self_contribution",
        "self_net",
        "visible_hands"
      ]
    },
    "HistoryPage": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/HistoryEntry"
          },
          "maxItems": 100
        },
        "start": {
          "$ref": "#/$defs/Timestamp"
        },
        "end": {
          "$ref": "#/$defs/Timestamp"
        },
        "high_watermark": {
          "$ref": "#/$defs/Seq"
        },
        "page_size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        },
        "next_cursor": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "items",
        "start",
        "end",
        "high_watermark",
        "page_size",
        "next_cursor"
      ]
    },
    "LedgerEntry": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "ledger_seq": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "ledger_id": {
          "$ref": "#/$defs/Id"
        },
        "account_kind": {
          "type": "string",
          "enum": [
            "WALLET",
            "ROOM_ESCROW"
          ]
        },
        "created_at": {
          "$ref": "#/$defs/Timestamp"
        },
        "kind": {
          "type": "string",
          "enum": [
            "PROMO_CREDIT",
            "ADMIN_CREDIT",
            "ADMIN_DEBIT",
            "CORRECTION",
            "BUY_IN",
            "TOPUP",
            "ANTE",
            "BET",
            "COMPARE",
            "SETTLE",
            "LEAVE_RETURN",
            "REFUND"
          ]
        },
        "delta": {
          "$ref": "#/$defs/SignedAmount"
        },
        "balance_after": {
          "$ref": "#/$defs/Amount"
        },
        "hand_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/Id"
            },
            {
              "type": "null"
            }
          ]
        },
        "room_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/Id"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "ledger_seq",
        "ledger_id",
        "account_kind",
        "created_at",
        "kind",
        "delta",
        "balance_after",
        "hand_id",
        "room_id"
      ]
    },
    "LedgerPage": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/LedgerEntry"
          },
          "maxItems": 100
        },
        "high_watermark": {
          "$ref": "#/$defs/Seq"
        },
        "page_size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        },
        "next_cursor": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "items",
        "high_watermark",
        "page_size",
        "next_cursor"
      ]
    },
    "BonusConfig": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "amount": {
          "$ref": "#/$defs/ConfigAmount"
        },
        "config_version": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "effective_at": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "amount",
        "config_version",
        "effective_at"
      ]
    },
    "BonusUpdate": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "amount": {
          "$ref": "#/$defs/ConfigAmount"
        },
        "expected_config_version": {
          "$ref": "#/$defs/PositiveSeq"
        }
      },
      "required": [
        "amount",
        "expected_config_version"
      ]
    },
    "AdjustmentRequest": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "player_id": {
          "$ref": "#/$defs/Id"
        },
        "operation": {
          "type": "string",
          "enum": [
            "credit",
            "debit",
            "promo",
            "correction"
          ]
        },
        "direction": {
          "type": "string",
          "enum": [
            "credit",
            "debit"
          ]
        },
        "amount": {
          "$ref": "#/$defs/InputAmount"
        },
        "reason": {
          "type": "string",
          "minLength": 8,
          "maxLength": 500
        }
      },
      "required": [
        "player_id",
        "operation",
        "direction",
        "amount"
      ]
    },
    "Adjustment": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "adjustment_id": {
          "$ref": "#/$defs/Id"
        },
        "ledger_id": {
          "$ref": "#/$defs/Id"
        },
        "player_id": {
          "$ref": "#/$defs/Id"
        },
        "operation": {
          "type": "string",
          "enum": [
            "credit",
            "debit",
            "promo",
            "correction"
          ]
        },
        "direction": {
          "type": "string",
          "enum": [
            "credit",
            "debit"
          ]
        },
        "amount": {
          "$ref": "#/$defs/Amount"
        },
        "wallet_after": {
          "$ref": "#/$defs/Amount"
        },
        "created_at": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "adjustment_id",
        "ledger_id",
        "player_id",
        "operation",
        "direction",
        "amount",
        "wallet_after",
        "created_at"
      ]
    },
    "Empty": {
      "type": "object",
      "additionalProperties": false,
      "properties": {},
      "required": []
    },
    "Health": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "ok",
            "not_ready"
          ]
        }
      },
      "required": [
        "status"
      ]
    },
    "SessionResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/Session"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "UserResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/User"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "AdminResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/Admin"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "WalletResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/Wallet"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "LoginResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/Login"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "AdminLoginResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/AdminLogin"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "TokensResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/Tokens"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "ReceiptResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/Receipt"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "SnapshotResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/Snapshot"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "QuoteResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/Quote"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "HistoryPageResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/HistoryPage"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "HistoryEntryResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/HistoryEntry"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "LedgerPageResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/LedgerPage"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "BonusConfigResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/BonusConfig"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "AdjustmentResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/Adjustment"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "EmptyResponse": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        },
        "data": {
          "$ref": "#/$defs/Empty"
        }
      },
      "required": [
        "request_id",
        "server_time",
        "data"
      ]
    },
    "Authenticate": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "authenticate"
        },
        "protocol_version": {
          "const": "threecard.v1"
        },
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "access_token": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "type",
        "protocol_version",
        "request_id",
        "access_token"
      ]
    },
    "Authenticated": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "authenticated"
        },
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "session_generation": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "type",
        "request_id",
        "session_generation",
        "server_time"
      ]
    },
    "Subscribe": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "subscribe"
        },
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "room_id": {
          "$ref": "#/$defs/Id"
        },
        "after_seq": {
          "anyOf": [
            {
              "$ref": "#/$defs/Seq"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "type",
        "request_id",
        "room_id",
        "after_seq"
      ]
    },
    "Unsubscribe": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "unsubscribe"
        },
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "subscription_id": {
          "$ref": "#/$defs/Id"
        }
      },
      "required": [
        "type",
        "request_id",
        "subscription_id"
      ]
    },
    "Subscribed": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "subscribed"
        },
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "subscription_id": {
          "$ref": "#/$defs/Id"
        },
        "room_id": {
          "$ref": "#/$defs/Id"
        },
        "delivery_generation": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "mode": {
          "type": "string",
          "enum": [
            "REPLAY",
            "SNAPSHOT"
          ]
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "type",
        "request_id",
        "subscription_id",
        "room_id",
        "delivery_generation",
        "mode",
        "server_time"
      ]
    },
    "Unsubscribed": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "unsubscribed"
        },
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "subscription_id": {
          "$ref": "#/$defs/Id"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "type",
        "request_id",
        "subscription_id",
        "server_time"
      ]
    },
    "WsCommand": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "command"
        },
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "body": {
          "$ref": "#/$defs/Command"
        }
      },
      "required": [
        "type",
        "request_id",
        "body"
      ]
    },
    "WsQuery": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "query_result"
        },
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "scope_kind": {
          "type": "string",
          "enum": [
            "player",
            "room"
          ]
        },
        "scope_id": {
          "$ref": "#/$defs/Id"
        },
        "action_id": {
          "$ref": "#/$defs/Id"
        }
      },
      "required": [
        "type",
        "request_id",
        "scope_kind",
        "scope_id",
        "action_id"
      ]
    },
    "Ack": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "ack"
        },
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "receipt": {
          "$ref": "#/$defs/Receipt"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "type",
        "request_id",
        "receipt",
        "server_time"
      ]
    },
    "SnapshotMessage": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "snapshot"
        },
        "request_id": {
          "$ref": "#/$defs/Id"
        },
        "subscription_id": {
          "$ref": "#/$defs/Id"
        },
        "snapshot": {
          "$ref": "#/$defs/Snapshot"
        }
      },
      "required": [
        "type",
        "request_id",
        "subscription_id",
        "snapshot"
      ]
    },
    "Event": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "event"
        },
        "subscription_id": {
          "$ref": "#/$defs/Id"
        },
        "room_id": {
          "$ref": "#/$defs/Id"
        },
        "hand_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/Id"
            },
            {
              "type": "null"
            }
          ]
        },
        "event_id": {
          "$ref": "#/$defs/Id"
        },
        "event_seq": {
          "$ref": "#/$defs/PositiveSeq"
        },
        "state_version": {
          "$ref": "#/$defs/Seq"
        },
        "effect": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "kind": {
                  "const": "room_updated"
                },
                "host_player_id": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Id"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "rule_version": {
                  "$ref": "#/$defs/PositiveSeq"
                },
                "rules": {
                  "$ref": "#/$defs/Rules"
                },
                "members": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/Member"
                  },
                  "maxItems": 6
                }
              },
              "required": [
                "kind",
                "host_player_id",
                "rule_version",
                "rules",
                "members"
              ]
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "kind": {
                  "const": "hand_updated"
                },
                "hand": {
                  "$ref": "#/$defs/HandPublic"
                },
                "members": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/Member"
                  },
                  "maxItems": 6
                }
              },
              "required": [
                "kind",
                "hand",
                "members"
              ]
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "kind": {
                  "const": "compare_resolved"
                },
                "initiator_player_id": {
                  "$ref": "#/$defs/Id"
                },
                "target_player_id": {
                  "$ref": "#/$defs/Id"
                },
                "winner_player_id": {
                  "$ref": "#/$defs/Id"
                },
                "loser_player_id": {
                  "$ref": "#/$defs/Id"
                },
                "charged_amount": {
                  "$ref": "#/$defs/Amount"
                }
              },
              "required": [
                "kind",
                "initiator_player_id",
                "target_player_id",
                "winner_player_id",
                "loser_player_id",
                "charged_amount"
              ]
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "kind": {
                  "const": "hand_finished"
                },
                "outcome": {
                  "$ref": "#/$defs/Outcome"
                }
              },
              "required": [
                "kind",
                "outcome"
              ]
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "kind": {
                  "const": "cards_disclosed"
                },
                "visible_hands": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/VisibleHand"
                  },
                  "minItems": 1,
                  "maxItems": 6
                }
              },
              "required": [
                "kind",
                "visible_hands"
              ]
            }
          ]
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "type",
        "subscription_id",
        "room_id",
        "hand_id",
        "event_id",
        "event_seq",
        "state_version",
        "effect",
        "server_time"
      ]
    },
    "Progress": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "progress"
        },
        "subscription_id": {
          "$ref": "#/$defs/Id"
        },
        "room_id": {
          "$ref": "#/$defs/Id"
        },
        "covered_through_seq": {
          "$ref": "#/$defs/Seq"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "type",
        "subscription_id",
        "room_id",
        "covered_through_seq",
        "server_time"
      ]
    },
    "WsError": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "error"
        },
        "request_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/Id"
            },
            {
              "type": "null"
            }
          ]
        },
        "error": {
          "$ref": "#/$defs/Error"
        },
        "server_time": {
          "$ref": "#/$defs/Timestamp"
        }
      },
      "required": [
        "type",
        "request_id",
        "error",
        "server_time"
      ]
    },
    "ClientMessage": {
      "oneOf": [
        {
          "$ref": "#/$defs/Authenticate"
        },
        {
          "$ref": "#/$defs/Subscribe"
        },
        {
          "$ref": "#/$defs/Unsubscribe"
        },
        {
          "$ref": "#/$defs/WsCommand"
        },
        {
          "$ref": "#/$defs/WsQuery"
        }
      ]
    },
    "ServerMessage": {
      "oneOf": [
        {
          "$ref": "#/$defs/Authenticated"
        },
        {
          "$ref": "#/$defs/Subscribed"
        },
        {
          "$ref": "#/$defs/Unsubscribed"
        },
        {
          "$ref": "#/$defs/Ack"
        },
        {
          "$ref": "#/$defs/SnapshotMessage"
        },
        {
          "$ref": "#/$defs/Event"
        },
        {
          "$ref": "#/$defs/Progress"
        },
        {
          "$ref": "#/$defs/WsError"
        }
      ]
    }
  },
  "oneOf": [
    {
      "$ref": "#/$defs/ClientMessage"
    },
    {
      "$ref": "#/$defs/ServerMessage"
    }
  ]
}
