docs: add JSON Schema definitions for all message types (draft 2020-12)

C2S (7): send, join, part, nick, topic, mode, ping
S2C (12): message, dm, notice, join, part, quit, nick, topic, mode, system, error, pong
S2S (6): relay, link, unlink, sync, ping, pong

Each message type has its own schema file under schema/{c2s,s2c,s2s}/.
schema/README.md provides an index of all types with descriptions.
This commit is contained in:
user
2026-02-10 10:25:42 -08:00
parent 6483670dc7
commit 065b243def
26 changed files with 848 additions and 0 deletions

80
schema/README.md Normal file
View File

@@ -0,0 +1,80 @@
# Message Schema Index
JSON Schema (draft 2020-12) definitions for the IRC-style message protocol.
All messages share a common envelope defined in [`message.schema.json`](message.schema.json).
## Base Envelope
| Field | Type | Required | Description |
|-----------|-----------------|----------|-------------|
| `command` | string | ✓ | IRC command name or numeric reply code |
| `from` | string | | Sender nick or server name |
| `to` | string | | Destination channel or nick |
| `params` | array\<string\> | | Additional IRC-style parameters |
| `body` | array \| object | varies | Message body (never a raw string) |
| `meta` | object | | Extensible metadata (signatures, etc.) |
| `id` | string (uuid) | | Server-assigned message ID |
| `ts` | string (date-time) | | Server-assigned timestamp |
## Client-to-Server (C2S)
| Command | Schema | Description |
|----------|--------|-------------|
| PRIVMSG | [`c2s/privmsg.schema.json`](c2s/privmsg.schema.json) | Send message to channel or user |
| NOTICE | [`c2s/notice.schema.json`](c2s/notice.schema.json) | Send a notice |
| JOIN | [`c2s/join.schema.json`](c2s/join.schema.json) | Join a channel |
| PART | [`c2s/part.schema.json`](c2s/part.schema.json) | Leave a channel |
| QUIT | [`c2s/quit.schema.json`](c2s/quit.schema.json) | Disconnect |
| NICK | [`c2s/nick.schema.json`](c2s/nick.schema.json) | Change nick |
| MODE | [`c2s/mode.schema.json`](c2s/mode.schema.json) | Set/query modes |
| TOPIC | [`c2s/topic.schema.json`](c2s/topic.schema.json) | Set/query topic |
| KICK | [`c2s/kick.schema.json`](c2s/kick.schema.json) | Kick user |
| PING | [`c2s/ping.schema.json`](c2s/ping.schema.json) | Client ping |
| PUBKEY | [`c2s/pubkey.schema.json`](c2s/pubkey.schema.json) | Announce public key |
## Server-to-Client (S2C)
### Named Commands
| Command | Schema | Description |
|----------|--------|-------------|
| PRIVMSG | [`s2c/privmsg.schema.json`](s2c/privmsg.schema.json) | Relayed message |
| NOTICE | [`s2c/notice.schema.json`](s2c/notice.schema.json) | Server or user notice |
| JOIN | [`s2c/join.schema.json`](s2c/join.schema.json) | User joined channel |
| PART | [`s2c/part.schema.json`](s2c/part.schema.json) | User left channel |
| QUIT | [`s2c/quit.schema.json`](s2c/quit.schema.json) | User disconnected |
| NICK | [`s2c/nick.schema.json`](s2c/nick.schema.json) | Nick change |
| MODE | [`s2c/mode.schema.json`](s2c/mode.schema.json) | Mode change |
| TOPIC | [`s2c/topic.schema.json`](s2c/topic.schema.json) | Topic change |
| KICK | [`s2c/kick.schema.json`](s2c/kick.schema.json) | User kicked |
| PONG | [`s2c/pong.schema.json`](s2c/pong.schema.json) | Server pong |
| PUBKEY | [`s2c/pubkey.schema.json`](s2c/pubkey.schema.json) | Relayed public key |
| ERROR | [`s2c/error.schema.json`](s2c/error.schema.json) | Server error |
### Numeric Replies
| Code | Name | Schema | Description |
|------|--------------------|--------|-------------|
| 001 | RPL_WELCOME | [`s2c/001.schema.json`](s2c/001.schema.json) | Welcome after registration |
| 002 | RPL_YOURHOST | [`s2c/002.schema.json`](s2c/002.schema.json) | Server host info |
| 322 | RPL_LIST | [`s2c/322.schema.json`](s2c/322.schema.json) | Channel list entry |
| 353 | RPL_NAMREPLY | [`s2c/353.schema.json`](s2c/353.schema.json) | Names list |
| 366 | RPL_ENDOFNAMES | [`s2c/366.schema.json`](s2c/366.schema.json) | End of names list |
| 372 | RPL_MOTD | [`s2c/372.schema.json`](s2c/372.schema.json) | MOTD line |
| 375 | RPL_MOTDSTART | [`s2c/375.schema.json`](s2c/375.schema.json) | Start of MOTD |
| 376 | RPL_ENDOFMOTD | [`s2c/376.schema.json`](s2c/376.schema.json) | End of MOTD |
| 401 | ERR_NOSUCHNICK | [`s2c/401.schema.json`](s2c/401.schema.json) | No such nick/channel |
| 403 | ERR_NOSUCHCHANNEL | [`s2c/403.schema.json`](s2c/403.schema.json) | No such channel |
| 433 | ERR_NICKNAMEINUSE | [`s2c/433.schema.json`](s2c/433.schema.json) | Nick in use |
## Server-to-Server (S2S)
| Command | Schema | Description |
|---------|--------|-------------|
| RELAY | [`s2s/relay.schema.json`](s2s/relay.schema.json) | Relay message to linked server |
| LINK | [`s2s/link.schema.json`](s2s/link.schema.json) | Establish server link |
| UNLINK | [`s2s/unlink.schema.json`](s2s/unlink.schema.json) | Tear down link |
| SYNC | [`s2s/sync.schema.json`](s2s/sync.schema.json) | Synchronize state |
| PING | [`s2s/ping.schema.json`](s2s/ping.schema.json) | Server ping |
| PONG | [`s2s/pong.schema.json`](s2s/pong.schema.json) | Server pong |