@myronsi/messenger-api 2.0.0-alpha.1.next.1
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 +11 -0
- package/README.md +58 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -0
- package/dist/openapi.yaml +2334 -0
- package/dist/schema.d.ts +3889 -0
- package/dist/ws-docs.json +428 -0
- package/dist/ws-events.d.ts +526 -0
- package/dist/ws-events.schema.json +2739 -0
- package/package.json +54 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
/* Generated from api/openapi.yaml 2.0.0-alpha.1. Do not edit. */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Any WebSocket event, in either direction.
|
|
5
|
+
*/
|
|
6
|
+
export type WebSocketEvent = ClientEvent | ServerEvent;
|
|
7
|
+
/**
|
|
8
|
+
* Every event a client may send.
|
|
9
|
+
*/
|
|
10
|
+
export type ClientEvent =
|
|
11
|
+
| ClientDeleteEvent
|
|
12
|
+
| ClientEditEvent
|
|
13
|
+
| ClientMessageEvent
|
|
14
|
+
| ClientReactionAddEvent
|
|
15
|
+
| ClientReactionRemoveEvent
|
|
16
|
+
| ClientReadEvent
|
|
17
|
+
| ClientResendEvent
|
|
18
|
+
| ClientTypingEvent;
|
|
19
|
+
/**
|
|
20
|
+
* Client-generated ID that makes sending idempotent and ties acks and errors to the send.
|
|
21
|
+
*/
|
|
22
|
+
export type ClientTempId = string;
|
|
23
|
+
/**
|
|
24
|
+
* Decimal ID as a string (Snowflake IDs exceed 2^53).
|
|
25
|
+
*/
|
|
26
|
+
export type Id = string;
|
|
27
|
+
/**
|
|
28
|
+
* Every event the server may send.
|
|
29
|
+
*/
|
|
30
|
+
export type ServerEvent =
|
|
31
|
+
| ServerAckEvent
|
|
32
|
+
| ServerApprovalRequestCreatedEvent
|
|
33
|
+
| ServerChatCreatedEvent
|
|
34
|
+
| ServerChatDeletedEvent
|
|
35
|
+
| ServerChatListUpdateEvent
|
|
36
|
+
| ServerDeleteEvent
|
|
37
|
+
| ServerEditEvent
|
|
38
|
+
| ServerErrorEvent
|
|
39
|
+
| ServerGroupCreatedEvent
|
|
40
|
+
| ServerGroupUpdatedEvent
|
|
41
|
+
| ServerHelloEvent
|
|
42
|
+
| ServerMessageEvent
|
|
43
|
+
| ServerPresenceEvent
|
|
44
|
+
| ServerReactionAddEvent
|
|
45
|
+
| ServerReactionRemoveEvent
|
|
46
|
+
| ServerReadEvent
|
|
47
|
+
| ServerTypingEvent;
|
|
48
|
+
export type Timestamp = string;
|
|
49
|
+
export type ApprovalRequestType = "direct_message" | "group_invite";
|
|
50
|
+
export type ApprovalRequestStatus = "pending" | "approved" | "rejected";
|
|
51
|
+
export type Username = string;
|
|
52
|
+
export type ChatType = "direct" | "group";
|
|
53
|
+
export type MessageType = "text" | "file" | "voice" | "system";
|
|
54
|
+
export type AttachmentKind = "image" | "audio" | "voice" | "video" | "file";
|
|
55
|
+
export type GroupRole = "owner" | "admin" | "member";
|
|
56
|
+
/**
|
|
57
|
+
* Stable machine-readable error code. New codes can appear in MINOR versions; unknown
|
|
58
|
+
* codes must be treated like `internal_error`.
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
export type ErrorCode =
|
|
62
|
+
| "invalid_request"
|
|
63
|
+
| "validation_failed"
|
|
64
|
+
| "unauthenticated"
|
|
65
|
+
| "invalid_credentials"
|
|
66
|
+
| "two_factor_required"
|
|
67
|
+
| "invalid_two_factor_code"
|
|
68
|
+
| "token_expired"
|
|
69
|
+
| "forbidden"
|
|
70
|
+
| "not_found"
|
|
71
|
+
| "conflict"
|
|
72
|
+
| "already_exists"
|
|
73
|
+
| "payload_too_large"
|
|
74
|
+
| "unsupported_media_type"
|
|
75
|
+
| "rate_limited"
|
|
76
|
+
| "client_outdated"
|
|
77
|
+
| "invalid_client_version"
|
|
78
|
+
| "blocked_by_user"
|
|
79
|
+
| "approval_required"
|
|
80
|
+
| "internal_error";
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Delete a message for yourself or for everyone.
|
|
84
|
+
*/
|
|
85
|
+
export interface ClientDeleteEvent {
|
|
86
|
+
type: "delete";
|
|
87
|
+
client_temp_id: ClientTempId;
|
|
88
|
+
chat_id: Id;
|
|
89
|
+
data: {
|
|
90
|
+
message_id: Id;
|
|
91
|
+
scope: "me" | "everyone";
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Edit your own text message.
|
|
96
|
+
*/
|
|
97
|
+
export interface ClientEditEvent {
|
|
98
|
+
type: "edit";
|
|
99
|
+
client_temp_id: ClientTempId;
|
|
100
|
+
chat_id: Id;
|
|
101
|
+
data: {
|
|
102
|
+
message_id: Id;
|
|
103
|
+
content: string;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Send a message. Idempotent per `client_temp_id`; answered with `ack` or `error`.
|
|
108
|
+
*/
|
|
109
|
+
export interface ClientMessageEvent {
|
|
110
|
+
type: "message";
|
|
111
|
+
client_temp_id: ClientTempId;
|
|
112
|
+
chat_id: Id;
|
|
113
|
+
data: TextMessageData | AttachmentMessageData;
|
|
114
|
+
}
|
|
115
|
+
export interface TextMessageData {
|
|
116
|
+
type: "text";
|
|
117
|
+
content: string;
|
|
118
|
+
reply_to?: Id | null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* `file` and `voice` messages reference an uploaded attachment by ID, never by URL.
|
|
122
|
+
*/
|
|
123
|
+
export interface AttachmentMessageData {
|
|
124
|
+
type: "file" | "voice";
|
|
125
|
+
/**
|
|
126
|
+
* Optional caption
|
|
127
|
+
*/
|
|
128
|
+
content?: string | null;
|
|
129
|
+
attachment_id: Id;
|
|
130
|
+
reply_to?: Id | null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Add a reaction.
|
|
134
|
+
*/
|
|
135
|
+
export interface ClientReactionAddEvent {
|
|
136
|
+
type: "reaction_add";
|
|
137
|
+
client_temp_id: ClientTempId;
|
|
138
|
+
chat_id: Id;
|
|
139
|
+
data: {
|
|
140
|
+
message_id: Id;
|
|
141
|
+
emoji: string;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Remove your reaction.
|
|
146
|
+
*/
|
|
147
|
+
export interface ClientReactionRemoveEvent {
|
|
148
|
+
type: "reaction_remove";
|
|
149
|
+
client_temp_id: ClientTempId;
|
|
150
|
+
chat_id: Id;
|
|
151
|
+
data: {
|
|
152
|
+
message_id: Id;
|
|
153
|
+
emoji: string;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Mark messages as read up to and including `message_id`.
|
|
158
|
+
*/
|
|
159
|
+
export interface ClientReadEvent {
|
|
160
|
+
type: "read";
|
|
161
|
+
client_temp_id: ClientTempId;
|
|
162
|
+
chat_id: Id;
|
|
163
|
+
data: {
|
|
164
|
+
message_id: Id;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Ask the server to deliver a message again that was saved but not delivered.
|
|
169
|
+
*/
|
|
170
|
+
export interface ClientResendEvent {
|
|
171
|
+
type: "resend";
|
|
172
|
+
client_temp_id: ClientTempId;
|
|
173
|
+
chat_id: Id;
|
|
174
|
+
data: {
|
|
175
|
+
message_id: Id;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Tell the chat that you are (not) typing. Not acknowledged, so it carries no `client_temp_id`.
|
|
180
|
+
*/
|
|
181
|
+
export interface ClientTypingEvent {
|
|
182
|
+
type: "typing";
|
|
183
|
+
chat_id: Id;
|
|
184
|
+
data: {
|
|
185
|
+
is_typing: boolean;
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The server accepted the client event with this `client_temp_id`.
|
|
190
|
+
*/
|
|
191
|
+
export interface ServerAckEvent {
|
|
192
|
+
type: "ack";
|
|
193
|
+
event_id: Id;
|
|
194
|
+
chat_id: Id | null;
|
|
195
|
+
/**
|
|
196
|
+
* Result of the client event. A `message` is answered with the stored `message_id` and `created_at`; every other event with an empty object.
|
|
197
|
+
*/
|
|
198
|
+
data: MessageAckData | EmptyAckData;
|
|
199
|
+
client_temp_id: ClientTempId;
|
|
200
|
+
}
|
|
201
|
+
export interface MessageAckData {
|
|
202
|
+
message_id: Id;
|
|
203
|
+
created_at: Timestamp;
|
|
204
|
+
}
|
|
205
|
+
export interface EmptyAckData {
|
|
206
|
+
message_id?: {
|
|
207
|
+
[k: string]: unknown | undefined;
|
|
208
|
+
};
|
|
209
|
+
created_at?: {
|
|
210
|
+
[k: string]: unknown | undefined;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* A new request waits in your inbox.
|
|
215
|
+
*/
|
|
216
|
+
export interface ServerApprovalRequestCreatedEvent {
|
|
217
|
+
type: "approval_request_created";
|
|
218
|
+
event_id: Id;
|
|
219
|
+
chat_id: null;
|
|
220
|
+
data: {
|
|
221
|
+
request: ApprovalRequest;
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export interface ApprovalRequest {
|
|
225
|
+
id: Id;
|
|
226
|
+
type: ApprovalRequestType;
|
|
227
|
+
status: ApprovalRequestStatus;
|
|
228
|
+
requester: User;
|
|
229
|
+
/**
|
|
230
|
+
* Only for `group_invite`
|
|
231
|
+
*/
|
|
232
|
+
group_name?: string | null;
|
|
233
|
+
/**
|
|
234
|
+
* First message of a direct-message request
|
|
235
|
+
*/
|
|
236
|
+
preview?: string | null;
|
|
237
|
+
created_at: Timestamp;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* A user as visible to the requesting user; hidden fields are `null`.
|
|
241
|
+
*/
|
|
242
|
+
export interface User {
|
|
243
|
+
id: Id;
|
|
244
|
+
username: Username;
|
|
245
|
+
display_name: string;
|
|
246
|
+
/**
|
|
247
|
+
* The requesting user's own name for this user, if set.
|
|
248
|
+
*/
|
|
249
|
+
contact_name?: string | null;
|
|
250
|
+
/**
|
|
251
|
+
* Path of the avatar, always same-origin (`/api/v2/users/{id}/avatar`).
|
|
252
|
+
*/
|
|
253
|
+
avatar_url: string | null;
|
|
254
|
+
bio: string | null;
|
|
255
|
+
is_online: boolean;
|
|
256
|
+
last_seen: Timestamp | null;
|
|
257
|
+
is_deleted: boolean;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* A chat was created with you.
|
|
261
|
+
*/
|
|
262
|
+
export interface ServerChatCreatedEvent {
|
|
263
|
+
type: "chat_created";
|
|
264
|
+
event_id: Id;
|
|
265
|
+
chat_id: Id;
|
|
266
|
+
data: {
|
|
267
|
+
chat: Chat;
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
export interface Chat {
|
|
271
|
+
id: Id;
|
|
272
|
+
type: ChatType;
|
|
273
|
+
/**
|
|
274
|
+
* Display name of the peer or the group
|
|
275
|
+
*/
|
|
276
|
+
name: string;
|
|
277
|
+
avatar_url: string | null;
|
|
278
|
+
/**
|
|
279
|
+
* The other user of a direct chat; `null` for groups.
|
|
280
|
+
*/
|
|
281
|
+
peer: User | null;
|
|
282
|
+
is_pinned: boolean;
|
|
283
|
+
unread_count: number;
|
|
284
|
+
last_message: Message | null;
|
|
285
|
+
/**
|
|
286
|
+
* Only for groups.
|
|
287
|
+
*/
|
|
288
|
+
my_role?: GroupRole | null;
|
|
289
|
+
created_at: Timestamp;
|
|
290
|
+
}
|
|
291
|
+
export interface Message {
|
|
292
|
+
id: Id;
|
|
293
|
+
chat_id: Id;
|
|
294
|
+
type: MessageType;
|
|
295
|
+
/**
|
|
296
|
+
* `null` for system messages.
|
|
297
|
+
*/
|
|
298
|
+
sender: User | null;
|
|
299
|
+
/**
|
|
300
|
+
* Text, or the caption of a file; `null` when deleted.
|
|
301
|
+
*/
|
|
302
|
+
content: string | null;
|
|
303
|
+
attachment: Attachment | null;
|
|
304
|
+
reply_to: Id | null;
|
|
305
|
+
forwarded_from: ForwardedFrom | null;
|
|
306
|
+
reactions: Reaction[];
|
|
307
|
+
read_by: ReadReceipt[];
|
|
308
|
+
created_at: Timestamp;
|
|
309
|
+
edited_at: Timestamp | null;
|
|
310
|
+
is_deleted: boolean;
|
|
311
|
+
client_temp_id?: ClientTempId;
|
|
312
|
+
}
|
|
313
|
+
export interface Attachment {
|
|
314
|
+
id: Id;
|
|
315
|
+
kind: AttachmentKind;
|
|
316
|
+
filename: string;
|
|
317
|
+
/**
|
|
318
|
+
* Detected by the server
|
|
319
|
+
*/
|
|
320
|
+
content_type: string;
|
|
321
|
+
/**
|
|
322
|
+
* Bytes
|
|
323
|
+
*/
|
|
324
|
+
size: number;
|
|
325
|
+
/**
|
|
326
|
+
* Same-origin path (`/api/v2/attachments/{id}/content`) set by the server.
|
|
327
|
+
*/
|
|
328
|
+
url: string;
|
|
329
|
+
width?: number | null;
|
|
330
|
+
height?: number | null;
|
|
331
|
+
thumbnail_url?: string | null;
|
|
332
|
+
duration_ms?: number | null;
|
|
333
|
+
waveform?: number[] | null;
|
|
334
|
+
}
|
|
335
|
+
export interface ForwardedFrom {
|
|
336
|
+
message_id: Id;
|
|
337
|
+
sender_id: Id | null;
|
|
338
|
+
sender_name: string;
|
|
339
|
+
}
|
|
340
|
+
export interface Reaction {
|
|
341
|
+
emoji: string;
|
|
342
|
+
user_id: Id;
|
|
343
|
+
}
|
|
344
|
+
export interface ReadReceipt {
|
|
345
|
+
user_id: Id;
|
|
346
|
+
read_at: Timestamp;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* A chat was deleted, or you were removed from it.
|
|
350
|
+
*/
|
|
351
|
+
export interface ServerChatDeletedEvent {
|
|
352
|
+
type: "chat_deleted";
|
|
353
|
+
event_id: Id;
|
|
354
|
+
chat_id: Id;
|
|
355
|
+
data: {};
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* The chat-list entry changed (last message, unread count, pin).
|
|
359
|
+
*/
|
|
360
|
+
export interface ServerChatListUpdateEvent {
|
|
361
|
+
type: "chat_list_update";
|
|
362
|
+
event_id: Id;
|
|
363
|
+
chat_id: Id;
|
|
364
|
+
data: {
|
|
365
|
+
chat: Chat;
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* A message was deleted for everyone (deleting for yourself is only sent to your other devices).
|
|
370
|
+
*/
|
|
371
|
+
export interface ServerDeleteEvent {
|
|
372
|
+
type: "delete";
|
|
373
|
+
event_id: Id;
|
|
374
|
+
chat_id: Id;
|
|
375
|
+
data: {
|
|
376
|
+
message_id: Id;
|
|
377
|
+
scope: "me" | "everyone";
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* A message was edited.
|
|
382
|
+
*/
|
|
383
|
+
export interface ServerEditEvent {
|
|
384
|
+
type: "edit";
|
|
385
|
+
event_id: Id;
|
|
386
|
+
chat_id: Id;
|
|
387
|
+
data: {
|
|
388
|
+
message: Message;
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* The server rejected the client event with this `client_temp_id`, or a connection-level error occurred.
|
|
393
|
+
*/
|
|
394
|
+
export interface ServerErrorEvent {
|
|
395
|
+
type: "error";
|
|
396
|
+
event_id: Id;
|
|
397
|
+
chat_id: Id | null;
|
|
398
|
+
data: {
|
|
399
|
+
code: ErrorCode;
|
|
400
|
+
message?: string;
|
|
401
|
+
};
|
|
402
|
+
client_temp_id?: ClientTempId;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* You were added to a new group.
|
|
406
|
+
*/
|
|
407
|
+
export interface ServerGroupCreatedEvent {
|
|
408
|
+
type: "group_created";
|
|
409
|
+
event_id: Id;
|
|
410
|
+
chat_id: Id;
|
|
411
|
+
data: {
|
|
412
|
+
group: Group;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
export interface Group {
|
|
416
|
+
id: Id;
|
|
417
|
+
name: string;
|
|
418
|
+
description: string | null;
|
|
419
|
+
avatar_url: string | null;
|
|
420
|
+
owner_id: Id;
|
|
421
|
+
my_role: GroupRole;
|
|
422
|
+
members: GroupMember[];
|
|
423
|
+
created_at: Timestamp;
|
|
424
|
+
}
|
|
425
|
+
export interface GroupMember {
|
|
426
|
+
user: User;
|
|
427
|
+
role: GroupRole;
|
|
428
|
+
joined_at: Timestamp;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Name, description, avatar, members or roles of a group changed.
|
|
432
|
+
*/
|
|
433
|
+
export interface ServerGroupUpdatedEvent {
|
|
434
|
+
type: "group_updated";
|
|
435
|
+
event_id: Id;
|
|
436
|
+
chat_id: Id;
|
|
437
|
+
data: {
|
|
438
|
+
group: Group;
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* First event after connecting, so clients that reconnect after a deploy learn the current contract.
|
|
443
|
+
*/
|
|
444
|
+
export interface ServerHelloEvent {
|
|
445
|
+
type: "hello";
|
|
446
|
+
event_id: Id;
|
|
447
|
+
chat_id: null;
|
|
448
|
+
data: {
|
|
449
|
+
api_version: string;
|
|
450
|
+
min_client_api_version: string;
|
|
451
|
+
user_id: Id;
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* A new message in a chat.
|
|
456
|
+
*/
|
|
457
|
+
export interface ServerMessageEvent {
|
|
458
|
+
type: "message";
|
|
459
|
+
event_id: Id;
|
|
460
|
+
chat_id: Id;
|
|
461
|
+
data: {
|
|
462
|
+
message: Message;
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* A user came online or went offline, as far as their privacy settings allow.
|
|
467
|
+
*/
|
|
468
|
+
export interface ServerPresenceEvent {
|
|
469
|
+
type: "presence";
|
|
470
|
+
event_id: Id;
|
|
471
|
+
chat_id: null;
|
|
472
|
+
data: {
|
|
473
|
+
user_id: Id;
|
|
474
|
+
is_online: boolean;
|
|
475
|
+
last_seen: Timestamp | null;
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* A reaction was added.
|
|
480
|
+
*/
|
|
481
|
+
export interface ServerReactionAddEvent {
|
|
482
|
+
type: "reaction_add";
|
|
483
|
+
event_id: Id;
|
|
484
|
+
chat_id: Id;
|
|
485
|
+
data: {
|
|
486
|
+
message_id: Id;
|
|
487
|
+
reaction: Reaction;
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* A reaction was removed.
|
|
492
|
+
*/
|
|
493
|
+
export interface ServerReactionRemoveEvent {
|
|
494
|
+
type: "reaction_remove";
|
|
495
|
+
event_id: Id;
|
|
496
|
+
chat_id: Id;
|
|
497
|
+
data: {
|
|
498
|
+
message_id: Id;
|
|
499
|
+
reaction: Reaction;
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* A user read messages up to and including `message_id` (not sent when the reader turned read receipts off).
|
|
504
|
+
*/
|
|
505
|
+
export interface ServerReadEvent {
|
|
506
|
+
type: "read";
|
|
507
|
+
event_id: Id;
|
|
508
|
+
chat_id: Id;
|
|
509
|
+
data: {
|
|
510
|
+
message_id: Id;
|
|
511
|
+
user_id: Id;
|
|
512
|
+
read_at: Timestamp;
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* A user started or stopped typing.
|
|
517
|
+
*/
|
|
518
|
+
export interface ServerTypingEvent {
|
|
519
|
+
type: "typing";
|
|
520
|
+
event_id: Id;
|
|
521
|
+
chat_id: Id;
|
|
522
|
+
data: {
|
|
523
|
+
user_id: Id;
|
|
524
|
+
is_typing: boolean;
|
|
525
|
+
};
|
|
526
|
+
}
|