chore: Новый черновик DRAFT, удалить старые docs-v

This commit is contained in:
2026-07-30 09:19:59 +03:00
parent 6f6e4896af
commit 590fb63ca7
122 changed files with 29145 additions and 3253 deletions

View File

@@ -0,0 +1,79 @@
# Socket.IO chat contract
## Connection
Connect to the Complex API namespace:
```text
http://localhost:3002/chat
```
The browser must already have a valid `demo_session` cookie and use credentials. Both `websocket` and `polling` transports are enabled.
```ts
import { io } from "socket.io-client";
const socket = io("http://localhost:3002/chat", {
withCredentials: true,
});
```
An invalid session receives `chat:error` and is disconnected.
## Client events
### `chat:join`
```json
{
"organizationId": "org-acme",
"conversationId": "conversation-support"
}
```
Response event: `chat:joined`.
### `chat:leave`
Uses the same payload. Response event: `chat:left`.
### `message:send`
```json
{
"organizationId": "org-acme",
"conversationId": "conversation-support",
"text": "Can you check this order?",
"clientMessageId": "frontend-generated-uuid"
}
```
Response event: `message:ack`. Room broadcast: `message:created`.
Sending the same `clientMessageId` again returns the existing message. Frontends should also deduplicate incoming `message:created` by server message `id`.
### `typing:start` and `typing:stop`
Use the `chat:join` payload. Other room members receive `typing:started` or `typing:stopped`:
```json
{
"conversationId": "conversation-support",
"userId": "complex-user-support"
}
```
## Error event
`chat:error` always contains a stable shape:
```json
{
"code": "CHAT_OPERATION_FAILED",
"message": "Conversation not found."
}
```
## Reconnect expectations
After reconnect, the frontend should join active conversations again and reload messages after its last known cursor. A session expired by `POST /api/v1/testing/session/expire` rejects the next Socket.IO connection.