@myronsi/messenger-api 2.1.0-alpha.24.next.106 → 2.1.0-alpha.26.next.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/openapi.yaml +133 -6
- package/dist/schema.d.ts +239 -7
- package/dist/ws-docs.json +15 -1
- package/dist/ws-events.d.ts +24 -2
- package/dist/ws-events.schema.json +93 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
Contract changes only. The backend changelog is `CHANGELOG.md` in the repository root. Rules: `docs/api-compatibility.md`.
|
|
4
4
|
|
|
5
|
+
## 2.1.0-alpha.26
|
|
6
|
+
|
|
7
|
+
- `DELETE /chats/{chat_id}` takes `scope=me|everyone` (default `everyone`, as before). `me` deletes the direct chat
|
|
8
|
+
only for the caller: it leaves their list, its history so far stays hidden for them, and it comes back with only
|
|
9
|
+
newer messages when one arrives.
|
|
10
|
+
- `POST /chats/{chat_id}/clear` (`ClearHistoryRequest`, `scope: me|everyone`) clears the history up to the newest
|
|
11
|
+
message: for the caller only, or for every member (direct chats: either user; groups: owner and admins, else
|
|
12
|
+
`403`).
|
|
13
|
+
- New server WebSocket event `history_cleared` (`before_message_id`, `scope`, `actor_id`).
|
|
14
|
+
|
|
15
|
+
## 2.1.0-alpha.25
|
|
16
|
+
|
|
17
|
+
- Archive: `PUT` and `DELETE /chats/{chat_id}/archive` archive a chat for the caller and move it back. `Chat` gains
|
|
18
|
+
the required `is_archived`; `GET /chats?archived=true|false` lists only archived or only other chats (without the
|
|
19
|
+
parameter, every chat as before). Archiving unpins; an archived chat stays archived when new messages arrive;
|
|
20
|
+
pinning a chat unarchives it.
|
|
21
|
+
- Pin order: `Chat` gains the required, nullable `pin_position` (lowest first) and pinned chats are listed in that
|
|
22
|
+
order. A newly pinned chat goes to the top. `PUT /chats/pins/order` (`PinOrderRequest`) sets the order of all
|
|
23
|
+
pinned chats at once.
|
|
24
|
+
- Saved Messages: `POST /chats` accepts the caller's own `user_id` and opens a direct chat whose only member and
|
|
25
|
+
`peer` is the caller.
|
|
26
|
+
|
|
5
27
|
## 2.1.0-alpha.24
|
|
6
28
|
|
|
7
29
|
- `PrivacySettings` gains the required `last_seen_visibility`, also accepted by `PATCH /me/privacy` and as a
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated from api/openapi.yaml 2.1.0-alpha.
|
|
2
|
-
export declare const API_VERSION: "2.1.0-alpha.
|
|
1
|
+
/* Generated from api/openapi.yaml 2.1.0-alpha.26. Do not edit. */
|
|
2
|
+
export declare const API_VERSION: "2.1.0-alpha.26";
|
|
3
3
|
export type { paths, components, operations } from "./schema.js";
|
|
4
4
|
export * from "./ws-events.js";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const API_VERSION = "2.1.0-alpha.
|
|
1
|
+
export const API_VERSION = "2.1.0-alpha.26";
|
package/dist/openapi.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
openapi: 3.1.0
|
|
2
2
|
info:
|
|
3
3
|
title: Messenger API
|
|
4
|
-
version: 2.1.0-alpha.
|
|
4
|
+
version: 2.1.0-alpha.26
|
|
5
5
|
summary: REST contract of the Messenger backend (v2).
|
|
6
6
|
description: |
|
|
7
7
|
Contract for the Go backend. The WebSocket protocol is described in `websocket/` and
|
|
@@ -1006,13 +1006,18 @@ paths:
|
|
|
1006
1006
|
summary: My chats with last message and unread count
|
|
1007
1007
|
description: |
|
|
1008
1008
|
One request replaces `GET /chats/list/{username}` and `GET /groups/list/{username}`.
|
|
1009
|
-
Pinned chats come first (
|
|
1009
|
+
Pinned chats come first (by `pin_position`), then the others by their last
|
|
1010
1010
|
message (newest first). `last_message` is the newest message the caller can see; in
|
|
1011
1011
|
direct chats its `read_by` holds the other user once they read it (with read receipts
|
|
1012
1012
|
on), in groups it is empty. `unread_count` stops at 999.
|
|
1013
1013
|
parameters:
|
|
1014
1014
|
- $ref: "#/components/parameters/Limit"
|
|
1015
1015
|
- $ref: "#/components/parameters/After"
|
|
1016
|
+
- name: archived
|
|
1017
|
+
in: query
|
|
1018
|
+
required: false
|
|
1019
|
+
description: "`true`: only archived chats, `false`: only chats that are not archived. Without it, every chat."
|
|
1020
|
+
schema: { type: boolean }
|
|
1016
1021
|
responses:
|
|
1017
1022
|
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1018
1023
|
"400": { $ref: "#/components/responses/BadRequest" }
|
|
@@ -1029,7 +1034,9 @@ paths:
|
|
|
1029
1034
|
description: |
|
|
1030
1035
|
Respects the other user's `direct_messages` privacy setting. When approval is needed
|
|
1031
1036
|
the answer is `202` with the pending request instead of a chat. Returns the existing
|
|
1032
|
-
chat (`200`) if there already is one.
|
|
1037
|
+
chat (`200`) if there already is one. `user_id` may be the caller's own id: that opens
|
|
1038
|
+
their "Saved Messages" chat, a direct chat with the caller as its only member and as
|
|
1039
|
+
its `peer`.
|
|
1033
1040
|
requestBody:
|
|
1034
1041
|
required: true
|
|
1035
1042
|
content:
|
|
@@ -1082,9 +1089,20 @@ paths:
|
|
|
1082
1089
|
operationId: deleteChat
|
|
1083
1090
|
summary: Delete a direct chat
|
|
1084
1091
|
description: |
|
|
1085
|
-
|
|
1092
|
+
`scope=everyone` (the default) deletes the chat and its messages for both users (as v1 did); both get
|
|
1093
|
+
`chat_deleted`. `scope=me` deletes it only for the caller: the chat leaves their list and its history up to
|
|
1094
|
+
now is hidden for them (as `POST /chats/{chat_id}/clear` with `scope: me`); only the caller's devices get
|
|
1095
|
+
`chat_deleted`. When a newer message arrives the chat comes back for the caller with only the newer messages.
|
|
1086
1096
|
For groups use `DELETE /groups/{chat_id}` (owner) or `POST /groups/{chat_id}/leave`;
|
|
1087
1097
|
a group here is `422`.
|
|
1098
|
+
parameters:
|
|
1099
|
+
- name: scope
|
|
1100
|
+
in: query
|
|
1101
|
+
required: false
|
|
1102
|
+
schema:
|
|
1103
|
+
type: string
|
|
1104
|
+
enum: [me, everyone]
|
|
1105
|
+
default: everyone
|
|
1088
1106
|
responses:
|
|
1089
1107
|
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1090
1108
|
"400": { $ref: "#/components/responses/BadRequest" }
|
|
@@ -1102,7 +1120,9 @@ paths:
|
|
|
1102
1120
|
tags: [chats]
|
|
1103
1121
|
operationId: pinChat
|
|
1104
1122
|
summary: Pin a chat
|
|
1105
|
-
description:
|
|
1123
|
+
description: |
|
|
1124
|
+
At most 10 chats can be pinned (`409` beyond that). A newly pinned chat goes to the top of the pinned
|
|
1125
|
+
chats and leaves the archive. Pinning a pinned chat changes nothing.
|
|
1106
1126
|
responses:
|
|
1107
1127
|
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1108
1128
|
"400": { $ref: "#/components/responses/BadRequest" }
|
|
@@ -1122,6 +1142,89 @@ paths:
|
|
|
1122
1142
|
description: Unpinned
|
|
1123
1143
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1124
1144
|
"404": { $ref: "#/components/responses/NotFound" }
|
|
1145
|
+
/chats/{chat_id}/clear:
|
|
1146
|
+
parameters:
|
|
1147
|
+
- $ref: "#/components/parameters/ClientVersion"
|
|
1148
|
+
- $ref: "#/components/parameters/ClientApiVersion"
|
|
1149
|
+
- $ref: "#/components/parameters/ChatId"
|
|
1150
|
+
post:
|
|
1151
|
+
tags: [chats]
|
|
1152
|
+
operationId: clearChatHistory
|
|
1153
|
+
summary: Clear the history of a chat
|
|
1154
|
+
description: |
|
|
1155
|
+
Clears every message up to the newest one now. `scope: me` hides them only for the caller (any member).
|
|
1156
|
+
`scope: everyone` removes them for every member: in a direct chat either user may do it, in a group the
|
|
1157
|
+
owner and admins (`403` for others). The chat itself stays. The caller's devices (`me`) or every member's
|
|
1158
|
+
(`everyone`) get `history_cleared`; messages up to `before_message_id` are no longer listed, counted as
|
|
1159
|
+
unread, found by search or shown as media.
|
|
1160
|
+
requestBody:
|
|
1161
|
+
required: true
|
|
1162
|
+
content:
|
|
1163
|
+
application/json:
|
|
1164
|
+
schema: { $ref: "#/components/schemas/ClearHistoryRequest" }
|
|
1165
|
+
responses:
|
|
1166
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1167
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
1168
|
+
"204":
|
|
1169
|
+
description: Cleared
|
|
1170
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1171
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
1172
|
+
"404": { $ref: "#/components/responses/NotFound" }
|
|
1173
|
+
"422": { $ref: "#/components/responses/ValidationFailed" }
|
|
1174
|
+
/chats/{chat_id}/archive:
|
|
1175
|
+
parameters:
|
|
1176
|
+
- $ref: "#/components/parameters/ClientVersion"
|
|
1177
|
+
- $ref: "#/components/parameters/ClientApiVersion"
|
|
1178
|
+
- $ref: "#/components/parameters/ChatId"
|
|
1179
|
+
put:
|
|
1180
|
+
tags: [chats]
|
|
1181
|
+
operationId: archiveChat
|
|
1182
|
+
summary: Archive a chat
|
|
1183
|
+
description: |
|
|
1184
|
+
Only for the caller. The chat leaves the pinned chats and stays archived when new messages arrive,
|
|
1185
|
+
until `DELETE` unarchives it. Archiving an archived chat changes nothing. The caller's devices get
|
|
1186
|
+
`chat_list_update`.
|
|
1187
|
+
responses:
|
|
1188
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1189
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
1190
|
+
"204":
|
|
1191
|
+
description: Archived
|
|
1192
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1193
|
+
"404": { $ref: "#/components/responses/NotFound" }
|
|
1194
|
+
delete:
|
|
1195
|
+
tags: [chats]
|
|
1196
|
+
operationId: unarchiveChat
|
|
1197
|
+
summary: Move a chat out of the archive
|
|
1198
|
+
responses:
|
|
1199
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1200
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
1201
|
+
"204":
|
|
1202
|
+
description: Not archived
|
|
1203
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1204
|
+
"404": { $ref: "#/components/responses/NotFound" }
|
|
1205
|
+
/chats/pins/order:
|
|
1206
|
+
parameters:
|
|
1207
|
+
- $ref: "#/components/parameters/ClientVersion"
|
|
1208
|
+
- $ref: "#/components/parameters/ClientApiVersion"
|
|
1209
|
+
put:
|
|
1210
|
+
tags: [chats]
|
|
1211
|
+
operationId: reorderPinnedChats
|
|
1212
|
+
summary: Order the pinned chats
|
|
1213
|
+
description: |
|
|
1214
|
+
`chat_ids` must name every pinned chat of the caller exactly once (`422` otherwise), in the new order,
|
|
1215
|
+
top first. The caller's devices get `chat_list_update` for each pinned chat.
|
|
1216
|
+
requestBody:
|
|
1217
|
+
required: true
|
|
1218
|
+
content:
|
|
1219
|
+
application/json:
|
|
1220
|
+
schema: { $ref: "#/components/schemas/PinOrderRequest" }
|
|
1221
|
+
responses:
|
|
1222
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1223
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
1224
|
+
"204":
|
|
1225
|
+
description: Reordered
|
|
1226
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1227
|
+
"422": { $ref: "#/components/responses/ValidationFailed" }
|
|
1125
1228
|
/chats/{chat_id}/read:
|
|
1126
1229
|
parameters:
|
|
1127
1230
|
- $ref: "#/components/parameters/ClientVersion"
|
|
@@ -5486,6 +5589,8 @@ components:
|
|
|
5486
5589
|
- avatar_url
|
|
5487
5590
|
- peer
|
|
5488
5591
|
- is_pinned
|
|
5592
|
+
- pin_position
|
|
5593
|
+
- is_archived
|
|
5489
5594
|
- unread_count
|
|
5490
5595
|
- first_unread_message_id
|
|
5491
5596
|
- last_read_message_id
|
|
@@ -5499,11 +5604,17 @@ components:
|
|
|
5499
5604
|
description: Display name of the peer or the group
|
|
5500
5605
|
avatar_url: { type: [string, "null"] }
|
|
5501
5606
|
peer:
|
|
5502
|
-
description: The other user of a direct chat; `null` for groups.
|
|
5607
|
+
description: The other user of a direct chat (the caller in their "Saved Messages" chat); `null` for groups.
|
|
5503
5608
|
oneOf:
|
|
5504
5609
|
- $ref: "#/components/schemas/User"
|
|
5505
5610
|
- type: "null"
|
|
5506
5611
|
is_pinned: { type: boolean }
|
|
5612
|
+
pin_position:
|
|
5613
|
+
description: Order of a pinned chat among the caller's pinned chats, lowest first; `null` when not pinned.
|
|
5614
|
+
type: [integer, "null"]
|
|
5615
|
+
is_archived:
|
|
5616
|
+
type: boolean
|
|
5617
|
+
description: Whether the caller archived the chat (only for the caller).
|
|
5507
5618
|
unread_count: { type: integer, minimum: 0 }
|
|
5508
5619
|
first_unread_message_id:
|
|
5509
5620
|
description: |
|
|
@@ -5536,6 +5647,22 @@ components:
|
|
|
5536
5647
|
type: array
|
|
5537
5648
|
items: { $ref: "#/components/schemas/Chat" }
|
|
5538
5649
|
next_cursor: { $ref: "#/components/schemas/Cursor" }
|
|
5650
|
+
ClearHistoryRequest:
|
|
5651
|
+
type: object
|
|
5652
|
+
required: [scope]
|
|
5653
|
+
properties:
|
|
5654
|
+
scope:
|
|
5655
|
+
type: string
|
|
5656
|
+
enum: [me, everyone]
|
|
5657
|
+
PinOrderRequest:
|
|
5658
|
+
type: object
|
|
5659
|
+
required: [chat_ids]
|
|
5660
|
+
properties:
|
|
5661
|
+
chat_ids:
|
|
5662
|
+
type: array
|
|
5663
|
+
maxItems: 10
|
|
5664
|
+
uniqueItems: true
|
|
5665
|
+
items: { $ref: "#/components/schemas/Id" }
|
|
5539
5666
|
CreateChatRequest:
|
|
5540
5667
|
type: object
|
|
5541
5668
|
required: [user_id]
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated from api/openapi.yaml 2.1.0-alpha.
|
|
1
|
+
/* Generated from api/openapi.yaml 2.1.0-alpha.26. Do not edit. */
|
|
2
2
|
export interface paths {
|
|
3
3
|
"/meta": {
|
|
4
4
|
parameters: {
|
|
@@ -813,7 +813,7 @@ export interface paths {
|
|
|
813
813
|
/**
|
|
814
814
|
* My chats with last message and unread count
|
|
815
815
|
* @description One request replaces `GET /chats/list/{username}` and `GET /groups/list/{username}`.
|
|
816
|
-
* Pinned chats come first (
|
|
816
|
+
* Pinned chats come first (by `pin_position`), then the others by their last
|
|
817
817
|
* message (newest first). `last_message` is the newest message the caller can see; in
|
|
818
818
|
* direct chats its `read_by` holds the other user once they read it (with read receipts
|
|
819
819
|
* on), in groups it is empty. `unread_count` stops at 999.
|
|
@@ -824,7 +824,9 @@ export interface paths {
|
|
|
824
824
|
* Start a direct chat
|
|
825
825
|
* @description Respects the other user's `direct_messages` privacy setting. When approval is needed
|
|
826
826
|
* the answer is `202` with the pending request instead of a chat. Returns the existing
|
|
827
|
-
* chat (`200`) if there already is one.
|
|
827
|
+
* chat (`200`) if there already is one. `user_id` may be the caller's own id: that opens
|
|
828
|
+
* their "Saved Messages" chat, a direct chat with the caller as its only member and as
|
|
829
|
+
* its `peer`.
|
|
828
830
|
*/
|
|
829
831
|
post: operations["createChat"];
|
|
830
832
|
delete?: never;
|
|
@@ -853,7 +855,10 @@ export interface paths {
|
|
|
853
855
|
post?: never;
|
|
854
856
|
/**
|
|
855
857
|
* Delete a direct chat
|
|
856
|
-
* @description
|
|
858
|
+
* @description `scope=everyone` (the default) deletes the chat and its messages for both users (as v1 did); both get
|
|
859
|
+
* `chat_deleted`. `scope=me` deletes it only for the caller: the chat leaves their list and its history up to
|
|
860
|
+
* now is hidden for them (as `POST /chats/{chat_id}/clear` with `scope: me`); only the caller's devices get
|
|
861
|
+
* `chat_deleted`. When a newer message arrives the chat comes back for the caller with only the newer messages.
|
|
857
862
|
* For groups use `DELETE /groups/{chat_id}` (owner) or `POST /groups/{chat_id}/leave`;
|
|
858
863
|
* a group here is `422`.
|
|
859
864
|
*/
|
|
@@ -880,7 +885,8 @@ export interface paths {
|
|
|
880
885
|
get?: never;
|
|
881
886
|
/**
|
|
882
887
|
* Pin a chat
|
|
883
|
-
* @description At most 10 chats can be pinned (`409` beyond that).
|
|
888
|
+
* @description At most 10 chats can be pinned (`409` beyond that). A newly pinned chat goes to the top of the pinned
|
|
889
|
+
* chats and leaves the archive. Pinning a pinned chat changes nothing.
|
|
884
890
|
*/
|
|
885
891
|
put: operations["pinChat"];
|
|
886
892
|
post?: never;
|
|
@@ -891,6 +897,93 @@ export interface paths {
|
|
|
891
897
|
patch?: never;
|
|
892
898
|
trace?: never;
|
|
893
899
|
};
|
|
900
|
+
"/chats/{chat_id}/clear": {
|
|
901
|
+
parameters: {
|
|
902
|
+
query?: never;
|
|
903
|
+
header?: {
|
|
904
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
905
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
906
|
+
/** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
|
|
907
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
908
|
+
};
|
|
909
|
+
path: {
|
|
910
|
+
chat_id: components["parameters"]["ChatId"];
|
|
911
|
+
};
|
|
912
|
+
cookie?: never;
|
|
913
|
+
};
|
|
914
|
+
get?: never;
|
|
915
|
+
put?: never;
|
|
916
|
+
/**
|
|
917
|
+
* Clear the history of a chat
|
|
918
|
+
* @description Clears every message up to the newest one now. `scope: me` hides them only for the caller (any member).
|
|
919
|
+
* `scope: everyone` removes them for every member: in a direct chat either user may do it, in a group the
|
|
920
|
+
* owner and admins (`403` for others). The chat itself stays. The caller's devices (`me`) or every member's
|
|
921
|
+
* (`everyone`) get `history_cleared`; messages up to `before_message_id` are no longer listed, counted as
|
|
922
|
+
* unread, found by search or shown as media.
|
|
923
|
+
*/
|
|
924
|
+
post: operations["clearChatHistory"];
|
|
925
|
+
delete?: never;
|
|
926
|
+
options?: never;
|
|
927
|
+
head?: never;
|
|
928
|
+
patch?: never;
|
|
929
|
+
trace?: never;
|
|
930
|
+
};
|
|
931
|
+
"/chats/{chat_id}/archive": {
|
|
932
|
+
parameters: {
|
|
933
|
+
query?: never;
|
|
934
|
+
header?: {
|
|
935
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
936
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
937
|
+
/** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
|
|
938
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
939
|
+
};
|
|
940
|
+
path: {
|
|
941
|
+
chat_id: components["parameters"]["ChatId"];
|
|
942
|
+
};
|
|
943
|
+
cookie?: never;
|
|
944
|
+
};
|
|
945
|
+
get?: never;
|
|
946
|
+
/**
|
|
947
|
+
* Archive a chat
|
|
948
|
+
* @description Only for the caller. The chat leaves the pinned chats and stays archived when new messages arrive,
|
|
949
|
+
* until `DELETE` unarchives it. Archiving an archived chat changes nothing. The caller's devices get
|
|
950
|
+
* `chat_list_update`.
|
|
951
|
+
*/
|
|
952
|
+
put: operations["archiveChat"];
|
|
953
|
+
post?: never;
|
|
954
|
+
/** Move a chat out of the archive */
|
|
955
|
+
delete: operations["unarchiveChat"];
|
|
956
|
+
options?: never;
|
|
957
|
+
head?: never;
|
|
958
|
+
patch?: never;
|
|
959
|
+
trace?: never;
|
|
960
|
+
};
|
|
961
|
+
"/chats/pins/order": {
|
|
962
|
+
parameters: {
|
|
963
|
+
query?: never;
|
|
964
|
+
header?: {
|
|
965
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
966
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
967
|
+
/** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
|
|
968
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
969
|
+
};
|
|
970
|
+
path?: never;
|
|
971
|
+
cookie?: never;
|
|
972
|
+
};
|
|
973
|
+
get?: never;
|
|
974
|
+
/**
|
|
975
|
+
* Order the pinned chats
|
|
976
|
+
* @description `chat_ids` must name every pinned chat of the caller exactly once (`422` otherwise), in the new order,
|
|
977
|
+
* top first. The caller's devices get `chat_list_update` for each pinned chat.
|
|
978
|
+
*/
|
|
979
|
+
put: operations["reorderPinnedChats"];
|
|
980
|
+
post?: never;
|
|
981
|
+
delete?: never;
|
|
982
|
+
options?: never;
|
|
983
|
+
head?: never;
|
|
984
|
+
patch?: never;
|
|
985
|
+
trace?: never;
|
|
986
|
+
};
|
|
894
987
|
"/chats/{chat_id}/read": {
|
|
895
988
|
parameters: {
|
|
896
989
|
query?: never;
|
|
@@ -3522,9 +3615,13 @@ export interface components {
|
|
|
3522
3615
|
/** @description Display name of the peer or the group */
|
|
3523
3616
|
name: string;
|
|
3524
3617
|
avatar_url: string | null;
|
|
3525
|
-
/** @description The other user of a direct chat; `null` for groups. */
|
|
3618
|
+
/** @description The other user of a direct chat (the caller in their "Saved Messages" chat); `null` for groups. */
|
|
3526
3619
|
peer: components["schemas"]["User"] | null;
|
|
3527
3620
|
is_pinned: boolean;
|
|
3621
|
+
/** @description Order of a pinned chat among the caller's pinned chats, lowest first; `null` when not pinned. */
|
|
3622
|
+
pin_position: number | null;
|
|
3623
|
+
/** @description Whether the caller archived the chat (only for the caller). */
|
|
3624
|
+
is_archived: boolean;
|
|
3528
3625
|
unread_count: number;
|
|
3529
3626
|
/**
|
|
3530
3627
|
* @description The oldest message the caller has not read (the same messages `unread_count` counts: not their own,
|
|
@@ -3543,6 +3640,13 @@ export interface components {
|
|
|
3543
3640
|
items: components["schemas"]["Chat"][];
|
|
3544
3641
|
next_cursor: components["schemas"]["Cursor"];
|
|
3545
3642
|
};
|
|
3643
|
+
ClearHistoryRequest: {
|
|
3644
|
+
/** @enum {string} */
|
|
3645
|
+
scope: "me" | "everyone";
|
|
3646
|
+
};
|
|
3647
|
+
PinOrderRequest: {
|
|
3648
|
+
chat_ids: components["schemas"]["Id"][];
|
|
3649
|
+
};
|
|
3546
3650
|
CreateChatRequest: {
|
|
3547
3651
|
user_id: components["schemas"]["Id"];
|
|
3548
3652
|
initial_message?: string | null;
|
|
@@ -5383,6 +5487,8 @@ export interface operations {
|
|
|
5383
5487
|
limit?: components["parameters"]["Limit"];
|
|
5384
5488
|
/** @description Opaque `next_cursor` of the previous page */
|
|
5385
5489
|
after?: components["parameters"]["After"];
|
|
5490
|
+
/** @description `true`: only archived chats, `false`: only chats that are not archived. Without it, every chat. */
|
|
5491
|
+
archived?: boolean;
|
|
5386
5492
|
};
|
|
5387
5493
|
header?: {
|
|
5388
5494
|
/** @description Version of the client app, for logs and the per-client metric. */
|
|
@@ -5496,7 +5602,9 @@ export interface operations {
|
|
|
5496
5602
|
};
|
|
5497
5603
|
deleteChat: {
|
|
5498
5604
|
parameters: {
|
|
5499
|
-
query?:
|
|
5605
|
+
query?: {
|
|
5606
|
+
scope?: "me" | "everyone";
|
|
5607
|
+
};
|
|
5500
5608
|
header?: {
|
|
5501
5609
|
/** @description Version of the client app, for logs and the per-client metric. */
|
|
5502
5610
|
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
@@ -5583,6 +5691,130 @@ export interface operations {
|
|
|
5583
5691
|
426: components["responses"]["ClientOutdated"];
|
|
5584
5692
|
};
|
|
5585
5693
|
};
|
|
5694
|
+
clearChatHistory: {
|
|
5695
|
+
parameters: {
|
|
5696
|
+
query?: never;
|
|
5697
|
+
header?: {
|
|
5698
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
5699
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
5700
|
+
/** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
|
|
5701
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
5702
|
+
};
|
|
5703
|
+
path: {
|
|
5704
|
+
chat_id: components["parameters"]["ChatId"];
|
|
5705
|
+
};
|
|
5706
|
+
cookie?: never;
|
|
5707
|
+
};
|
|
5708
|
+
requestBody: {
|
|
5709
|
+
content: {
|
|
5710
|
+
"application/json": components["schemas"]["ClearHistoryRequest"];
|
|
5711
|
+
};
|
|
5712
|
+
};
|
|
5713
|
+
responses: {
|
|
5714
|
+
/** @description Cleared */
|
|
5715
|
+
204: {
|
|
5716
|
+
headers: {
|
|
5717
|
+
[name: string]: unknown;
|
|
5718
|
+
};
|
|
5719
|
+
content?: never;
|
|
5720
|
+
};
|
|
5721
|
+
400: components["responses"]["BadRequest"];
|
|
5722
|
+
401: components["responses"]["Unauthorized"];
|
|
5723
|
+
403: components["responses"]["Forbidden"];
|
|
5724
|
+
404: components["responses"]["NotFound"];
|
|
5725
|
+
422: components["responses"]["ValidationFailed"];
|
|
5726
|
+
426: components["responses"]["ClientOutdated"];
|
|
5727
|
+
};
|
|
5728
|
+
};
|
|
5729
|
+
archiveChat: {
|
|
5730
|
+
parameters: {
|
|
5731
|
+
query?: never;
|
|
5732
|
+
header?: {
|
|
5733
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
5734
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
5735
|
+
/** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
|
|
5736
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
5737
|
+
};
|
|
5738
|
+
path: {
|
|
5739
|
+
chat_id: components["parameters"]["ChatId"];
|
|
5740
|
+
};
|
|
5741
|
+
cookie?: never;
|
|
5742
|
+
};
|
|
5743
|
+
requestBody?: never;
|
|
5744
|
+
responses: {
|
|
5745
|
+
/** @description Archived */
|
|
5746
|
+
204: {
|
|
5747
|
+
headers: {
|
|
5748
|
+
[name: string]: unknown;
|
|
5749
|
+
};
|
|
5750
|
+
content?: never;
|
|
5751
|
+
};
|
|
5752
|
+
400: components["responses"]["BadRequest"];
|
|
5753
|
+
401: components["responses"]["Unauthorized"];
|
|
5754
|
+
404: components["responses"]["NotFound"];
|
|
5755
|
+
426: components["responses"]["ClientOutdated"];
|
|
5756
|
+
};
|
|
5757
|
+
};
|
|
5758
|
+
unarchiveChat: {
|
|
5759
|
+
parameters: {
|
|
5760
|
+
query?: never;
|
|
5761
|
+
header?: {
|
|
5762
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
5763
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
5764
|
+
/** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
|
|
5765
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
5766
|
+
};
|
|
5767
|
+
path: {
|
|
5768
|
+
chat_id: components["parameters"]["ChatId"];
|
|
5769
|
+
};
|
|
5770
|
+
cookie?: never;
|
|
5771
|
+
};
|
|
5772
|
+
requestBody?: never;
|
|
5773
|
+
responses: {
|
|
5774
|
+
/** @description Not archived */
|
|
5775
|
+
204: {
|
|
5776
|
+
headers: {
|
|
5777
|
+
[name: string]: unknown;
|
|
5778
|
+
};
|
|
5779
|
+
content?: never;
|
|
5780
|
+
};
|
|
5781
|
+
400: components["responses"]["BadRequest"];
|
|
5782
|
+
401: components["responses"]["Unauthorized"];
|
|
5783
|
+
404: components["responses"]["NotFound"];
|
|
5784
|
+
426: components["responses"]["ClientOutdated"];
|
|
5785
|
+
};
|
|
5786
|
+
};
|
|
5787
|
+
reorderPinnedChats: {
|
|
5788
|
+
parameters: {
|
|
5789
|
+
query?: never;
|
|
5790
|
+
header?: {
|
|
5791
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
5792
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
5793
|
+
/** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
|
|
5794
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
5795
|
+
};
|
|
5796
|
+
path?: never;
|
|
5797
|
+
cookie?: never;
|
|
5798
|
+
};
|
|
5799
|
+
requestBody: {
|
|
5800
|
+
content: {
|
|
5801
|
+
"application/json": components["schemas"]["PinOrderRequest"];
|
|
5802
|
+
};
|
|
5803
|
+
};
|
|
5804
|
+
responses: {
|
|
5805
|
+
/** @description Reordered */
|
|
5806
|
+
204: {
|
|
5807
|
+
headers: {
|
|
5808
|
+
[name: string]: unknown;
|
|
5809
|
+
};
|
|
5810
|
+
content?: never;
|
|
5811
|
+
};
|
|
5812
|
+
400: components["responses"]["BadRequest"];
|
|
5813
|
+
401: components["responses"]["Unauthorized"];
|
|
5814
|
+
422: components["responses"]["ValidationFailed"];
|
|
5815
|
+
426: components["responses"]["ClientOutdated"];
|
|
5816
|
+
};
|
|
5817
|
+
};
|
|
5586
5818
|
markChatRead: {
|
|
5587
5819
|
parameters: {
|
|
5588
5820
|
query?: never;
|
package/dist/ws-docs.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"markdown": "# WebSocket protocol (API contract v2)\r\n\r\nThe JSON Schemas in `websocket/client/` (client → server) and `websocket/server/` (server → client) are the source of truth. Every event has an example in `websocket/examples/`, validated against its schema by `npm run check`. TypeScript types are generated into `dist/ws-events.d.ts` (`ClientEvent`, `ServerEvent`).\r\n\r\n## Connecting\r\n\r\n1. `POST /api/v2/ws/ticket` (authenticated) returns `{ \"ticket\": \"…\", \"expires_in\": 30 }`. The ticket is single-use and short-lived, so no access token ends up in a URL or a log.\r\n2. Open **one connection per browser tab**: `wss://<host>/api/v2/ws?ticket=<ticket>&api_version=<contract version>`. The connection carries the events of all chats of the user. `api_version` is optional and takes the place of the `X-Client-Api-Version` header, which browsers cannot send on a WebSocket.\r\n3. The first server event is `hello` with `api_version` and `min_client_api_version`. A client that reconnects after a deploy compares them with the contract version it was built for and shows an upgrade notice instead of failing at random.\r\n4. When the ticket is invalid or expired the server closes the connection with code `4401`. A client whose `api_version` is no longer served is closed with `4426` after `hello`.\r\n\r\n## Close codes\r\n\r\n| Code | Meaning | Client |\r\n| --- | --- | --- |\r\n| `1012` | `reconnect`: the server is restarting, or it lost its pub/sub connection and events may be missing | reconnect with backoff, then load what was missed (`after` cursor) |\r\n| `1013` | the client did not keep up with its events, or sent more than 64 events that are not handled yet | reconnect, then catch up |\r\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\r\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\r\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\r\n\r\n## Envelope\r\n\r\nServer → client:\r\n\r\n```json\r\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\r\n```\r\n\r\nClient → server:\r\n\r\n```json\r\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\r\n```\r\n\r\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\r\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\r\n- `chat_id` is always `null` in `hello`, `presence` and `approval_request_created`, which do not belong to a chat. `ack` and `error` repeat the `chat_id` of the client event they answer, and it is `null` for connection-level errors.\r\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\r\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\r\n\r\n## Acknowledgements\r\n\r\nEvery client event except `typing` (which is not acknowledged and carries no `client_temp_id`) has a `client_temp_id` (1–64 characters, unique per client). The server answers with exactly one of:\r\n\r\n- `ack` — `client_temp_id`, and for `message` the stored `message_id` and `created_at`. Sending the same `client_temp_id` again returns the same `ack` (idempotent), which makes retries after a reconnect safe.\r\n- `error` — `client_temp_id` and `data.code`/`data.message`. `code` is one of the stable codes of `ErrorCode` in `openapi.yaml` (the same codes as the REST `application/problem+json` errors).\r\n\r\nThe sender also receives the broadcast `message` event with the stored message (its `client_temp_id` is included, so the client can replace its pending copy).\r\n\r\n## Client → server events\r\n\r\n| Type | Purpose |\r\n| --- | --- |\r\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\r\n| `resend` | Deliver a stored but undelivered message again |\r\n| `edit` | Edit your own text message |\r\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\r\n| `read` | Mark messages as read up to `message_id` |\r\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\r\n| `typing` | Typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`, not acknowledged). Repeat `is_typing: true` every 3 s while it lasts, send `false` when it ends |\r\n\r\n## Server → client events\r\n\r\n| Type | Meaning |\r\n| --- | --- |\r\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\r\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\r\n| `message`, `edit`, `delete` | Message created, edited or deleted |\r\n| `reaction_add`, `reaction_remove` | Reactions changed |\r\n| `read` | A user read up to `message_id` |\r\n| `typing` | A user is typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`); hide it after 6 s without a repeat |\r\n| `chat_created`, `chat_deleted`, `chat_list_update` | Chat list changes |\r\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\r\n| `approval_request_created` | New request in the inbox |\r\n| `presence` | A user came online or went offline |\n| `call_updated` | A call of the chat changed (state, participants, epoch); carries the whole call, keep the highest `version` |\n| `call_keys` | Sealed call sender keys for this session only (`docs/calls-e2ee.md`) |\r\n\r\n## Compatibility\r\n\r\nAdding an event type or an optional field is a MINOR change; removing or renaming an event or field, or making a field required, is MAJOR (see `docs/api-compatibility.md`). Clients must ignore unknown events and unknown fields.\r\n",
|
|
2
|
+
"markdown": "# WebSocket protocol (API contract v2)\r\n\r\nThe JSON Schemas in `websocket/client/` (client → server) and `websocket/server/` (server → client) are the source of truth. Every event has an example in `websocket/examples/`, validated against its schema by `npm run check`. TypeScript types are generated into `dist/ws-events.d.ts` (`ClientEvent`, `ServerEvent`).\r\n\r\n## Connecting\r\n\r\n1. `POST /api/v2/ws/ticket` (authenticated) returns `{ \"ticket\": \"…\", \"expires_in\": 30 }`. The ticket is single-use and short-lived, so no access token ends up in a URL or a log.\r\n2. Open **one connection per browser tab**: `wss://<host>/api/v2/ws?ticket=<ticket>&api_version=<contract version>`. The connection carries the events of all chats of the user. `api_version` is optional and takes the place of the `X-Client-Api-Version` header, which browsers cannot send on a WebSocket.\r\n3. The first server event is `hello` with `api_version` and `min_client_api_version`. A client that reconnects after a deploy compares them with the contract version it was built for and shows an upgrade notice instead of failing at random.\r\n4. When the ticket is invalid or expired the server closes the connection with code `4401`. A client whose `api_version` is no longer served is closed with `4426` after `hello`.\r\n\r\n## Close codes\r\n\r\n| Code | Meaning | Client |\r\n| --- | --- | --- |\r\n| `1012` | `reconnect`: the server is restarting, or it lost its pub/sub connection and events may be missing | reconnect with backoff, then load what was missed (`after` cursor) |\r\n| `1013` | the client did not keep up with its events, or sent more than 64 events that are not handled yet | reconnect, then catch up |\r\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\r\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\r\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\r\n\r\n## Envelope\r\n\r\nServer → client:\r\n\r\n```json\r\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\r\n```\r\n\r\nClient → server:\r\n\r\n```json\r\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\r\n```\r\n\r\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\r\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\r\n- `chat_id` is always `null` in `hello`, `presence` and `approval_request_created`, which do not belong to a chat. `ack` and `error` repeat the `chat_id` of the client event they answer, and it is `null` for connection-level errors.\r\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\r\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\r\n\r\n## Acknowledgements\r\n\r\nEvery client event except `typing` (which is not acknowledged and carries no `client_temp_id`) has a `client_temp_id` (1–64 characters, unique per client). The server answers with exactly one of:\r\n\r\n- `ack` — `client_temp_id`, and for `message` the stored `message_id` and `created_at`. Sending the same `client_temp_id` again returns the same `ack` (idempotent), which makes retries after a reconnect safe.\r\n- `error` — `client_temp_id` and `data.code`/`data.message`. `code` is one of the stable codes of `ErrorCode` in `openapi.yaml` (the same codes as the REST `application/problem+json` errors).\r\n\r\nThe sender also receives the broadcast `message` event with the stored message (its `client_temp_id` is included, so the client can replace its pending copy).\r\n\r\n## Client → server events\r\n\r\n| Type | Purpose |\r\n| --- | --- |\r\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\r\n| `resend` | Deliver a stored but undelivered message again |\r\n| `edit` | Edit your own text message |\r\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\r\n| `read` | Mark messages as read up to `message_id` |\r\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\r\n| `typing` | Typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`, not acknowledged). Repeat `is_typing: true` every 3 s while it lasts, send `false` when it ends |\r\n\r\n## Server → client events\r\n\r\n| Type | Meaning |\r\n| --- | --- |\r\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\r\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\r\n| `message`, `edit`, `delete` | Message created, edited or deleted |\r\n| `reaction_add`, `reaction_remove` | Reactions changed |\r\n| `read` | A user read up to `message_id` |\r\n| `typing` | A user is typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`); hide it after 6 s without a repeat |\r\n| `chat_created`, `chat_deleted`, `chat_list_update` | Chat list changes |\n| `history_cleared` | Messages up to `before_message_id` were cleared for you (`scope: me`) or everyone |\r\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\r\n| `approval_request_created` | New request in the inbox |\r\n| `presence` | A user came online or went offline |\n| `call_updated` | A call of the chat changed (state, participants, epoch); carries the whole call, keep the highest `version` |\n| `call_keys` | Sealed call sender keys for this session only (`docs/calls-e2ee.md`) |\r\n\r\n## Compatibility\r\n\r\nAdding an event type or an optional field is a MINOR change; removing or renaming an event or field, or making a field required, is MAJOR (see `docs/api-compatibility.md`). Clients must ignore unknown events and unknown fields.\r\n",
|
|
3
3
|
"examples": {
|
|
4
4
|
"client/delete.json": {
|
|
5
5
|
"type": "delete",
|
|
@@ -190,6 +190,8 @@
|
|
|
190
190
|
"is_deleted": false
|
|
191
191
|
},
|
|
192
192
|
"is_pinned": false,
|
|
193
|
+
"pin_position": null,
|
|
194
|
+
"is_archived": false,
|
|
193
195
|
"unread_count": 1,
|
|
194
196
|
"first_unread_message_id": "7217400317439950001",
|
|
195
197
|
"last_read_message_id": null,
|
|
@@ -250,6 +252,8 @@
|
|
|
250
252
|
"is_deleted": false
|
|
251
253
|
},
|
|
252
254
|
"is_pinned": false,
|
|
255
|
+
"pin_position": null,
|
|
256
|
+
"is_archived": false,
|
|
253
257
|
"unread_count": 1,
|
|
254
258
|
"first_unread_message_id": "7217400317439950001",
|
|
255
259
|
"last_read_message_id": null,
|
|
@@ -408,6 +412,16 @@
|
|
|
408
412
|
"user_id": "1001"
|
|
409
413
|
}
|
|
410
414
|
},
|
|
415
|
+
"server/history_cleared.json": {
|
|
416
|
+
"type": "history_cleared",
|
|
417
|
+
"event_id": "7217400317439950011",
|
|
418
|
+
"chat_id": "42",
|
|
419
|
+
"data": {
|
|
420
|
+
"before_message_id": "7217400317439950002",
|
|
421
|
+
"scope": "everyone",
|
|
422
|
+
"actor_id": "7"
|
|
423
|
+
}
|
|
424
|
+
},
|
|
411
425
|
"server/message.json": {
|
|
412
426
|
"type": "message",
|
|
413
427
|
"event_id": "7217400317439950009",
|
package/dist/ws-events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated from api/openapi.yaml 2.1.0-alpha.
|
|
1
|
+
/* Generated from api/openapi.yaml 2.1.0-alpha.26. Do not edit. */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Any WebSocket event, in either direction.
|
|
@@ -45,6 +45,7 @@ export type ServerEvent =
|
|
|
45
45
|
| ServerGroupCreatedEvent
|
|
46
46
|
| ServerGroupUpdatedEvent
|
|
47
47
|
| ServerHelloEvent
|
|
48
|
+
| ServerHistoryClearedEvent
|
|
48
49
|
| ServerMessageEvent
|
|
49
50
|
| ServerPresenceEvent
|
|
50
51
|
| ServerReactionAddEvent
|
|
@@ -415,10 +416,18 @@ export interface Chat {
|
|
|
415
416
|
name: string;
|
|
416
417
|
avatar_url: string | null;
|
|
417
418
|
/**
|
|
418
|
-
* The other user of a direct chat; `null` for groups.
|
|
419
|
+
* The other user of a direct chat (the caller in their "Saved Messages" chat); `null` for groups.
|
|
419
420
|
*/
|
|
420
421
|
peer: User | null;
|
|
421
422
|
is_pinned: boolean;
|
|
423
|
+
/**
|
|
424
|
+
* Order of a pinned chat among the caller's pinned chats, lowest first; `null` when not pinned.
|
|
425
|
+
*/
|
|
426
|
+
pin_position: number | null;
|
|
427
|
+
/**
|
|
428
|
+
* Whether the caller archived the chat (only for the caller).
|
|
429
|
+
*/
|
|
430
|
+
is_archived: boolean;
|
|
422
431
|
unread_count: number;
|
|
423
432
|
/**
|
|
424
433
|
* The oldest message the caller has not read (the same messages `unread_count` counts: not their own,
|
|
@@ -746,6 +755,19 @@ export interface ServerHelloEvent {
|
|
|
746
755
|
user_id: Id;
|
|
747
756
|
};
|
|
748
757
|
}
|
|
758
|
+
/**
|
|
759
|
+
* Messages of the chat up to before_message_id were cleared, for you (scope me) or for every member (scope everyone). Drop them from what you show.
|
|
760
|
+
*/
|
|
761
|
+
export interface ServerHistoryClearedEvent {
|
|
762
|
+
type: "history_cleared";
|
|
763
|
+
event_id: Id;
|
|
764
|
+
chat_id: Id;
|
|
765
|
+
data: {
|
|
766
|
+
before_message_id: Id;
|
|
767
|
+
scope: "me" | "everyone";
|
|
768
|
+
actor_id: Id;
|
|
769
|
+
};
|
|
770
|
+
}
|
|
749
771
|
/**
|
|
750
772
|
* A new message in a chat.
|
|
751
773
|
*/
|
|
@@ -2530,6 +2530,8 @@
|
|
|
2530
2530
|
"avatar_url",
|
|
2531
2531
|
"peer",
|
|
2532
2532
|
"is_pinned",
|
|
2533
|
+
"pin_position",
|
|
2534
|
+
"is_archived",
|
|
2533
2535
|
"unread_count",
|
|
2534
2536
|
"first_unread_message_id",
|
|
2535
2537
|
"last_read_message_id",
|
|
@@ -2554,7 +2556,7 @@
|
|
|
2554
2556
|
]
|
|
2555
2557
|
},
|
|
2556
2558
|
"peer": {
|
|
2557
|
-
"description": "The other user of a direct chat; `null` for groups.",
|
|
2559
|
+
"description": "The other user of a direct chat (the caller in their \"Saved Messages\" chat); `null` for groups.",
|
|
2558
2560
|
"oneOf": [
|
|
2559
2561
|
{
|
|
2560
2562
|
"$ref": "#/$defs/User"
|
|
@@ -2567,6 +2569,17 @@
|
|
|
2567
2569
|
"is_pinned": {
|
|
2568
2570
|
"type": "boolean"
|
|
2569
2571
|
},
|
|
2572
|
+
"pin_position": {
|
|
2573
|
+
"description": "Order of a pinned chat among the caller's pinned chats, lowest first; `null` when not pinned.",
|
|
2574
|
+
"type": [
|
|
2575
|
+
"integer",
|
|
2576
|
+
"null"
|
|
2577
|
+
]
|
|
2578
|
+
},
|
|
2579
|
+
"is_archived": {
|
|
2580
|
+
"type": "boolean",
|
|
2581
|
+
"description": "Whether the caller archived the chat (only for the caller)."
|
|
2582
|
+
},
|
|
2570
2583
|
"unread_count": {
|
|
2571
2584
|
"type": "integer",
|
|
2572
2585
|
"minimum": 0
|
|
@@ -2637,6 +2650,37 @@
|
|
|
2637
2650
|
}
|
|
2638
2651
|
}
|
|
2639
2652
|
},
|
|
2653
|
+
"ClearHistoryRequest": {
|
|
2654
|
+
"type": "object",
|
|
2655
|
+
"required": [
|
|
2656
|
+
"scope"
|
|
2657
|
+
],
|
|
2658
|
+
"properties": {
|
|
2659
|
+
"scope": {
|
|
2660
|
+
"type": "string",
|
|
2661
|
+
"enum": [
|
|
2662
|
+
"me",
|
|
2663
|
+
"everyone"
|
|
2664
|
+
]
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
},
|
|
2668
|
+
"PinOrderRequest": {
|
|
2669
|
+
"type": "object",
|
|
2670
|
+
"required": [
|
|
2671
|
+
"chat_ids"
|
|
2672
|
+
],
|
|
2673
|
+
"properties": {
|
|
2674
|
+
"chat_ids": {
|
|
2675
|
+
"type": "array",
|
|
2676
|
+
"maxItems": 10,
|
|
2677
|
+
"uniqueItems": true,
|
|
2678
|
+
"items": {
|
|
2679
|
+
"$ref": "#/$defs/Id"
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
},
|
|
2640
2684
|
"CreateChatRequest": {
|
|
2641
2685
|
"type": "object",
|
|
2642
2686
|
"required": [
|
|
@@ -4729,6 +4773,51 @@
|
|
|
4729
4773
|
"data"
|
|
4730
4774
|
]
|
|
4731
4775
|
},
|
|
4776
|
+
"ServerHistoryClearedEvent": {
|
|
4777
|
+
"title": "ServerHistoryClearedEvent",
|
|
4778
|
+
"description": "Messages of the chat up to before_message_id were cleared, for you (scope me) or for every member (scope everyone). Drop them from what you show.",
|
|
4779
|
+
"type": "object",
|
|
4780
|
+
"properties": {
|
|
4781
|
+
"type": {
|
|
4782
|
+
"const": "history_cleared"
|
|
4783
|
+
},
|
|
4784
|
+
"event_id": {
|
|
4785
|
+
"$ref": "#/$defs/Id"
|
|
4786
|
+
},
|
|
4787
|
+
"chat_id": {
|
|
4788
|
+
"$ref": "#/$defs/Id"
|
|
4789
|
+
},
|
|
4790
|
+
"data": {
|
|
4791
|
+
"type": "object",
|
|
4792
|
+
"properties": {
|
|
4793
|
+
"before_message_id": {
|
|
4794
|
+
"$ref": "#/$defs/Id"
|
|
4795
|
+
},
|
|
4796
|
+
"scope": {
|
|
4797
|
+
"type": "string",
|
|
4798
|
+
"enum": [
|
|
4799
|
+
"me",
|
|
4800
|
+
"everyone"
|
|
4801
|
+
]
|
|
4802
|
+
},
|
|
4803
|
+
"actor_id": {
|
|
4804
|
+
"$ref": "#/$defs/Id"
|
|
4805
|
+
}
|
|
4806
|
+
},
|
|
4807
|
+
"required": [
|
|
4808
|
+
"before_message_id",
|
|
4809
|
+
"scope",
|
|
4810
|
+
"actor_id"
|
|
4811
|
+
]
|
|
4812
|
+
}
|
|
4813
|
+
},
|
|
4814
|
+
"required": [
|
|
4815
|
+
"type",
|
|
4816
|
+
"event_id",
|
|
4817
|
+
"chat_id",
|
|
4818
|
+
"data"
|
|
4819
|
+
]
|
|
4820
|
+
},
|
|
4732
4821
|
"ServerMessageEvent": {
|
|
4733
4822
|
"title": "ServerMessageEvent",
|
|
4734
4823
|
"description": "A new message in a chat.",
|
|
@@ -5210,6 +5299,9 @@
|
|
|
5210
5299
|
{
|
|
5211
5300
|
"$ref": "#/$defs/ServerHelloEvent"
|
|
5212
5301
|
},
|
|
5302
|
+
{
|
|
5303
|
+
"$ref": "#/$defs/ServerHistoryClearedEvent"
|
|
5304
|
+
},
|
|
5213
5305
|
{
|
|
5214
5306
|
"$ref": "#/$defs/ServerMessageEvent"
|
|
5215
5307
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myronsi/messenger-api",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.26.next.108",
|
|
4
4
|
"description": "API contract of the Messenger backend: OpenAPI document, WebSocket event schemas and generated TypeScript types",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|