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:
37
schema/s2c/dm.json
Normal file
37
schema/s2c/dm.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/dm.json",
|
||||
"title": "S2C Direct Message",
|
||||
"description": "A direct message delivered via the unified message stream.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"description": "Server-assigned message ID."
|
||||
},
|
||||
"type": {
|
||||
"const": "dm"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"from": {
|
||||
"type": "string",
|
||||
"description": "Sender nick."
|
||||
},
|
||||
"to": {
|
||||
"type": "string",
|
||||
"description": "Recipient nick."
|
||||
},
|
||||
"content": {
|
||||
"type": "string",
|
||||
"description": "Message body."
|
||||
},
|
||||
"meta": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts", "from", "to", "content"]
|
||||
}
|
||||
33
schema/s2c/error.json
Normal file
33
schema/s2c/error.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/error.json",
|
||||
"title": "S2C Error",
|
||||
"description": "Error message delivered via the message stream.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"const": "error"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"code": {
|
||||
"type": "string",
|
||||
"description": "Machine-readable error code.",
|
||||
"examples": ["nick_in_use", "no_such_channel", "not_on_channel", "permission_denied"]
|
||||
},
|
||||
"content": {
|
||||
"type": "string",
|
||||
"description": "Human-readable error message."
|
||||
},
|
||||
"channel": {
|
||||
"type": "string",
|
||||
"description": "Related channel, if applicable."
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts", "code", "content"]
|
||||
}
|
||||
29
schema/s2c/join.json
Normal file
29
schema/s2c/join.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/join.json",
|
||||
"title": "S2C Join",
|
||||
"description": "A user joined a channel.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"const": "join"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"nick": {
|
||||
"type": "string",
|
||||
"description": "The nick that joined."
|
||||
},
|
||||
"channel": {
|
||||
"type": "string",
|
||||
"description": "The channel joined.",
|
||||
"pattern": "^#[a-zA-Z0-9_-]+$"
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts", "nick", "channel"]
|
||||
}
|
||||
40
schema/s2c/message.json
Normal file
40
schema/s2c/message.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/message.json",
|
||||
"title": "S2C Message",
|
||||
"description": "A channel message delivered via the unified message stream.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"description": "Server-assigned message ID, monotonically increasing."
|
||||
},
|
||||
"type": {
|
||||
"const": "message"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "Server-assigned timestamp (ISO 8601)."
|
||||
},
|
||||
"from": {
|
||||
"type": "string",
|
||||
"description": "Sender nick."
|
||||
},
|
||||
"channel": {
|
||||
"type": "string",
|
||||
"description": "Channel the message was sent to.",
|
||||
"pattern": "^#[a-zA-Z0-9_-]+$"
|
||||
},
|
||||
"content": {
|
||||
"type": "string",
|
||||
"description": "Message body."
|
||||
},
|
||||
"meta": {
|
||||
"type": "object",
|
||||
"description": "Extensible metadata (signatures, rich content, etc.).",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts", "from", "channel", "content"]
|
||||
}
|
||||
37
schema/s2c/mode.json
Normal file
37
schema/s2c/mode.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/mode.json",
|
||||
"title": "S2C Mode",
|
||||
"description": "A channel or user mode was changed.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"const": "mode"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"nick": {
|
||||
"type": "string",
|
||||
"description": "The nick that set the mode."
|
||||
},
|
||||
"channel": {
|
||||
"type": "string",
|
||||
"pattern": "^#[a-zA-Z0-9_-]+$"
|
||||
},
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"description": "Mode string applied (e.g. +o, -m).",
|
||||
"pattern": "^[+-][a-zA-Z]+$"
|
||||
},
|
||||
"target": {
|
||||
"type": "string",
|
||||
"description": "Target nick for user modes. Absent for channel modes."
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts", "nick", "channel", "mode"]
|
||||
}
|
||||
28
schema/s2c/nick.json
Normal file
28
schema/s2c/nick.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/nick.json",
|
||||
"title": "S2C Nick",
|
||||
"description": "A user changed their nickname.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"const": "nick"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"oldNick": {
|
||||
"type": "string",
|
||||
"description": "Previous nickname."
|
||||
},
|
||||
"newNick": {
|
||||
"type": "string",
|
||||
"description": "New nickname."
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts", "oldNick", "newNick"]
|
||||
}
|
||||
32
schema/s2c/notice.json
Normal file
32
schema/s2c/notice.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/notice.json",
|
||||
"title": "S2C Notice",
|
||||
"description": "A server notice. May be targeted to a channel or user, or global.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"const": "notice"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"from": {
|
||||
"type": "string",
|
||||
"description": "Origin (server name or nick)."
|
||||
},
|
||||
"channel": {
|
||||
"type": "string",
|
||||
"description": "Target channel, if channel-scoped."
|
||||
},
|
||||
"content": {
|
||||
"type": "string",
|
||||
"description": "Notice text."
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts", "content"]
|
||||
}
|
||||
32
schema/s2c/part.json
Normal file
32
schema/s2c/part.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/part.json",
|
||||
"title": "S2C Part",
|
||||
"description": "A user left a channel.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"const": "part"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"nick": {
|
||||
"type": "string",
|
||||
"description": "The nick that left."
|
||||
},
|
||||
"channel": {
|
||||
"type": "string",
|
||||
"pattern": "^#[a-zA-Z0-9_-]+$"
|
||||
},
|
||||
"reason": {
|
||||
"type": "string",
|
||||
"description": "Optional part reason."
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts", "nick", "channel"]
|
||||
}
|
||||
24
schema/s2c/pong.json
Normal file
24
schema/s2c/pong.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/pong.json",
|
||||
"title": "S2C Pong",
|
||||
"description": "Keepalive response to a client ping.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"const": "pong"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"token": {
|
||||
"type": "string",
|
||||
"description": "Echoed token from the client's ping, if provided."
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts"]
|
||||
}
|
||||
28
schema/s2c/quit.json
Normal file
28
schema/s2c/quit.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/quit.json",
|
||||
"title": "S2C Quit",
|
||||
"description": "A user disconnected from the server.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"const": "quit"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"nick": {
|
||||
"type": "string",
|
||||
"description": "The nick that quit."
|
||||
},
|
||||
"reason": {
|
||||
"type": "string",
|
||||
"description": "Optional quit reason."
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts", "nick"]
|
||||
}
|
||||
29
schema/s2c/system.json
Normal file
29
schema/s2c/system.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/system.json",
|
||||
"title": "S2C System",
|
||||
"description": "Server system message (MOTD, maintenance notices, etc.).",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"const": "system"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"content": {
|
||||
"type": "string",
|
||||
"description": "System message text."
|
||||
},
|
||||
"code": {
|
||||
"type": "string",
|
||||
"description": "Optional machine-readable system message code.",
|
||||
"examples": ["motd", "maintenance", "server_restart"]
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts", "content"]
|
||||
}
|
||||
32
schema/s2c/topic.json
Normal file
32
schema/s2c/topic.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/s2c/topic.json",
|
||||
"title": "S2C Topic",
|
||||
"description": "A channel topic was changed.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"const": "topic"
|
||||
},
|
||||
"ts": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"nick": {
|
||||
"type": "string",
|
||||
"description": "The nick that changed the topic."
|
||||
},
|
||||
"channel": {
|
||||
"type": "string",
|
||||
"pattern": "^#[a-zA-Z0-9_-]+$"
|
||||
},
|
||||
"topic": {
|
||||
"type": "string",
|
||||
"description": "New topic text."
|
||||
}
|
||||
},
|
||||
"required": ["id", "type", "ts", "nick", "channel", "topic"]
|
||||
}
|
||||
Reference in New Issue
Block a user