@myronsi/messenger-api 2.1.0-alpha.26.next.108 → 2.1.0-alpha.28

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 CHANGED
@@ -2,6 +2,24 @@
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.28
6
+
7
+ - `MediaKind` gains `voice` (voice messages only) and `link` (messages whose text or caption contains a web link) for
8
+ `GET /chats/{chat_id}/media`.
9
+ - `GET /groups/{chat_id}/participants` (`GroupMemberPage`): members page by page, owner first, then admins, moderators
10
+ and members by display name, with an optional `q` filter and the matching `total`.
11
+ - `GET /users/{user_id}/common-groups` (`CommonGroupPage` of `CommonGroup`): the groups the caller shares with the
12
+ user.
13
+
14
+ ## 2.1.0-alpha.27
15
+
16
+ - `User` gains the required `profile_version` (grows with username, display name, bio or avatar changes, not with
17
+ presence) and `StickerPack` the required `version` (grows with title or sticker changes).
18
+ - `GET /me`, `GET /users/{user_id}`, `GET /groups/{chat_id}`, `GET /stickers/packs` and `GET /stickers/packs/{pack_id}`
19
+ send an `ETag` with `Cache-Control: private, no-cache` and answer `304` to a matching `If-None-Match`.
20
+ - `/attachments/{attachment_id}/content` is cached as immutable (an attachment never changes).
21
+ - New server WebSocket event `user_updated` (`user_id`, `profile_version`) for users who share a chat with the user.
22
+
5
23
  ## 2.1.0-alpha.26
6
24
 
7
25
  - `DELETE /chats/{chat_id}` takes `scope=me|everyone` (default `everyone`, as before). `me` deletes the direct chat
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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";
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.28. Do not edit. */
2
+ export declare const API_VERSION: "2.1.0-alpha.28";
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.26";
1
+ export const API_VERSION = "2.1.0-alpha.28";
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.26
4
+ version: 2.1.0-alpha.28
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
@@ -329,6 +329,8 @@ paths:
329
329
  operationId: getMe
330
330
  summary: Current user
331
331
  responses:
332
+ "304":
333
+ description: Not modified; the response's `ETag` matches `If-None-Match`.
332
334
  "426": { $ref: "#/components/responses/ClientOutdated" }
333
335
  "400": { $ref: "#/components/responses/BadRequest" }
334
336
  "200":
@@ -781,6 +783,32 @@ paths:
781
783
  "401": { $ref: "#/components/responses/Unauthorized" }
782
784
  "404": { $ref: "#/components/responses/NotFound" }
783
785
  "429": { $ref: "#/components/responses/TooManyRequests" }
786
+ /users/{user_id}/common-groups:
787
+ parameters:
788
+ - $ref: "#/components/parameters/ClientVersion"
789
+ - $ref: "#/components/parameters/ClientApiVersion"
790
+ - name: user_id
791
+ in: path
792
+ required: true
793
+ schema: { $ref: "#/components/schemas/Id" }
794
+ get:
795
+ tags: [users]
796
+ operationId: listCommonGroups
797
+ summary: Groups the caller and the user are both in
798
+ description: Newest activity first. Empty for the caller's own id.
799
+ parameters:
800
+ - $ref: "#/components/parameters/Limit"
801
+ - $ref: "#/components/parameters/After"
802
+ responses:
803
+ "426": { $ref: "#/components/responses/ClientOutdated" }
804
+ "400": { $ref: "#/components/responses/BadRequest" }
805
+ "200":
806
+ description: A page of groups
807
+ content:
808
+ application/json:
809
+ schema: { $ref: "#/components/schemas/CommonGroupPage" }
810
+ "401": { $ref: "#/components/responses/Unauthorized" }
811
+ "404": { $ref: "#/components/responses/NotFound" }
784
812
  /users/{user_id}:
785
813
  parameters:
786
814
  - $ref: "#/components/parameters/ClientVersion"
@@ -795,6 +823,8 @@ paths:
795
823
  or a `deny` exception) is `404` unless the two share a chat. Your own profile is always found. Lookups are
796
824
  rate limited per user.
797
825
  responses:
826
+ "304":
827
+ description: Not modified; the response's `ETag` matches `If-None-Match`.
798
828
  "426": { $ref: "#/components/responses/ClientOutdated" }
799
829
  "400": { $ref: "#/components/responses/BadRequest" }
800
830
  "200":
@@ -1407,7 +1437,7 @@ paths:
1407
1437
  get:
1408
1438
  tags: [chats]
1409
1439
  operationId: listChatMedia
1410
- summary: Photos, videos, audio or files of a chat
1440
+ summary: Photos, videos, audio, voice messages, files or links of a chat
1411
1441
  description: Replaces `GET /messages/photos/{chat_id}` and `GET /messages/audios/{chat_id}`.
1412
1442
  parameters:
1413
1443
  - name: kind
@@ -1757,6 +1787,8 @@ paths:
1757
1787
  operationId: getGroup
1758
1788
  summary: Group details and members
1759
1789
  responses:
1790
+ "304":
1791
+ description: Not modified; the response's `ETag` matches `If-None-Match`.
1760
1792
  "426": { $ref: "#/components/responses/ClientOutdated" }
1761
1793
  "400": { $ref: "#/components/responses/BadRequest" }
1762
1794
  "200":
@@ -1831,6 +1863,30 @@ paths:
1831
1863
  - $ref: "#/components/parameters/ClientVersion"
1832
1864
  - $ref: "#/components/parameters/ClientApiVersion"
1833
1865
  - $ref: "#/components/parameters/ChatId"
1866
+ get:
1867
+ tags: [groups]
1868
+ operationId: listGroupMembers
1869
+ summary: Members of a group, page by page
1870
+ description: |
1871
+ Owner first, then admins, moderators and members, each by display name. `q` keeps members whose username starts
1872
+ with it or whose display name contains it (case-insensitive). `total` counts every member that matches.
1873
+ parameters:
1874
+ - name: q
1875
+ in: query
1876
+ required: false
1877
+ schema: { type: string, maxLength: 64 }
1878
+ - $ref: "#/components/parameters/Limit"
1879
+ - $ref: "#/components/parameters/After"
1880
+ responses:
1881
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1882
+ "400": { $ref: "#/components/responses/BadRequest" }
1883
+ "200":
1884
+ description: A page of members
1885
+ content:
1886
+ application/json:
1887
+ schema: { $ref: "#/components/schemas/GroupMemberPage" }
1888
+ "401": { $ref: "#/components/responses/Unauthorized" }
1889
+ "404": { $ref: "#/components/responses/NotFound" }
1834
1890
  post:
1835
1891
  tags: [groups]
1836
1892
  operationId: addGroupParticipant
@@ -1974,6 +2030,8 @@ paths:
1974
2030
  required: false
1975
2031
  schema: { type: boolean, default: false }
1976
2032
  responses:
2033
+ "304":
2034
+ description: Not modified; the response's `ETag` matches `If-None-Match`.
1977
2035
  "426": { $ref: "#/components/responses/ClientOutdated" }
1978
2036
  "400": { $ref: "#/components/responses/BadRequest" }
1979
2037
  "200":
@@ -2020,6 +2078,8 @@ paths:
2020
2078
  `Sticker.pack_slug` with `GET /stickers/links/{slug}` instead. `is_installed` tells whether it is in the
2021
2079
  user's panel. A hidden pack is found only by its owner.
2022
2080
  responses:
2081
+ "304":
2082
+ description: Not modified; the response's `ETag` matches `If-None-Match`.
2023
2083
  "426": { $ref: "#/components/responses/ClientOutdated" }
2024
2084
  "400": { $ref: "#/components/responses/BadRequest" }
2025
2085
  "200":
@@ -4894,9 +4954,13 @@ components:
4894
4954
  User:
4895
4955
  type: object
4896
4956
  description: A user as visible to the requesting user; hidden fields are `null`.
4897
- required: [id, username, display_name, avatar_url, bio, is_online, last_seen, is_deleted]
4957
+ required: [id, username, display_name, avatar_url, bio, is_online, last_seen, is_deleted, profile_version]
4898
4958
  properties:
4899
4959
  id: { $ref: "#/components/schemas/Id" }
4960
+ profile_version:
4961
+ type: integer
4962
+ minimum: 0
4963
+ description: Grows whenever the username, display name, bio or avatar changes (not with presence). Clients keep a stored profile until a higher version arrives.
4900
4964
  username: { $ref: "#/components/schemas/Username" }
4901
4965
  display_name: { type: string }
4902
4966
  contact_name:
@@ -5082,8 +5146,10 @@ components:
5082
5146
  drawing: { $ref: "#/components/schemas/Drawing" }
5083
5147
  MediaKind:
5084
5148
  type: string
5085
- description: "`image` photos, `visual` photos and videos, `audio` audio files and voice messages, `file` other files (documents, archives)."
5086
- enum: [image, audio, visual, file]
5149
+ description: |
5150
+ `image` photos, `visual` photos and videos, `audio` audio files and voice messages, `voice` voice messages only,
5151
+ `file` other files (documents, archives), `link` messages whose text or caption contains a web link.
5152
+ enum: [image, audio, visual, file, voice, link]
5087
5153
 
5088
5154
  # -------------------------------------------------------- messages
5089
5155
  MessageType:
@@ -5115,9 +5181,13 @@ components:
5115
5181
  pattern: "^[A-Za-z0-9]{8,32}$"
5116
5182
  StickerPack:
5117
5183
  type: object
5118
- required: [id, title, is_official, is_installed, is_mine, is_hidden, stickers]
5184
+ required: [id, title, is_official, is_installed, is_mine, is_hidden, stickers, version]
5119
5185
  properties:
5120
5186
  id: { $ref: "#/components/schemas/Id" }
5187
+ version:
5188
+ type: integer
5189
+ minimum: 0
5190
+ description: Grows whenever the title or the stickers of the pack change.
5121
5191
  title: { type: string, minLength: 1, maxLength: 64 }
5122
5192
  is_official:
5123
5193
  type: boolean
@@ -5671,6 +5741,31 @@ components:
5671
5741
  initial_message:
5672
5742
  type: [string, "null"]
5673
5743
  maxLength: 4096
5744
+ GroupMemberPage:
5745
+ type: object
5746
+ required: [items, next_cursor, total]
5747
+ properties:
5748
+ items:
5749
+ type: array
5750
+ items: { $ref: "#/components/schemas/GroupMember" }
5751
+ next_cursor: { $ref: "#/components/schemas/Cursor" }
5752
+ total: { type: integer, minimum: 0 }
5753
+ CommonGroup:
5754
+ type: object
5755
+ required: [id, name, avatar_url, member_count]
5756
+ properties:
5757
+ id: { $ref: "#/components/schemas/Id" }
5758
+ name: { type: string }
5759
+ avatar_url: { type: [string, "null"] }
5760
+ member_count: { type: integer, minimum: 1 }
5761
+ CommonGroupPage:
5762
+ type: object
5763
+ required: [items, next_cursor]
5764
+ properties:
5765
+ items:
5766
+ type: array
5767
+ items: { $ref: "#/components/schemas/CommonGroup" }
5768
+ next_cursor: { $ref: "#/components/schemas/Cursor" }
5674
5769
  GroupMember:
5675
5770
  type: object
5676
5771
  required: [user, role, joined_at]
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.26. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.28. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -628,6 +628,33 @@ export interface paths {
628
628
  patch?: never;
629
629
  trace?: never;
630
630
  };
631
+ "/users/{user_id}/common-groups": {
632
+ parameters: {
633
+ query?: never;
634
+ header?: {
635
+ /** @description Version of the client app, for logs and the per-client metric. */
636
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
637
+ /** @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`). */
638
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
639
+ };
640
+ path: {
641
+ user_id: components["schemas"]["Id"];
642
+ };
643
+ cookie?: never;
644
+ };
645
+ /**
646
+ * Groups the caller and the user are both in
647
+ * @description Newest activity first. Empty for the caller's own id.
648
+ */
649
+ get: operations["listCommonGroups"];
650
+ put?: never;
651
+ post?: never;
652
+ delete?: never;
653
+ options?: never;
654
+ head?: never;
655
+ patch?: never;
656
+ trace?: never;
657
+ };
631
658
  "/users/{user_id}": {
632
659
  parameters: {
633
660
  query?: never;
@@ -1138,7 +1165,7 @@ export interface paths {
1138
1165
  cookie?: never;
1139
1166
  };
1140
1167
  /**
1141
- * Photos, videos, audio or files of a chat
1168
+ * Photos, videos, audio, voice messages, files or links of a chat
1142
1169
  * @description Replaces `GET /messages/photos/{chat_id}` and `GET /messages/audios/{chat_id}`.
1143
1170
  */
1144
1171
  get: operations["listChatMedia"];
@@ -1458,7 +1485,12 @@ export interface paths {
1458
1485
  };
1459
1486
  cookie?: never;
1460
1487
  };
1461
- get?: never;
1488
+ /**
1489
+ * Members of a group, page by page
1490
+ * @description Owner first, then admins, moderators and members, each by display name. `q` keeps members whose username starts
1491
+ * with it or whose display name contains it (case-insensitive). `total` counts every member that matches.
1492
+ */
1493
+ get: operations["listGroupMembers"];
1462
1494
  put?: never;
1463
1495
  /** Add a participant */
1464
1496
  post: operations["addGroupParticipant"];
@@ -3243,6 +3275,8 @@ export interface components {
3243
3275
  /** @description A user as visible to the requesting user; hidden fields are `null`. */
3244
3276
  User: {
3245
3277
  id: components["schemas"]["Id"];
3278
+ /** @description Grows whenever the username, display name, bio or avatar changes (not with presence). Clients keep a stored profile until a higher version arrives. */
3279
+ profile_version: number;
3246
3280
  username: components["schemas"]["Username"];
3247
3281
  display_name: string;
3248
3282
  /** @description The requesting user's own name for this user, if set. */
@@ -3356,10 +3390,11 @@ export interface components {
3356
3390
  drawing: components["schemas"]["Drawing"];
3357
3391
  };
3358
3392
  /**
3359
- * @description `image` photos, `visual` photos and videos, `audio` audio files and voice messages, `file` other files (documents, archives).
3393
+ * @description `image` photos, `visual` photos and videos, `audio` audio files and voice messages, `voice` voice messages only,
3394
+ * `file` other files (documents, archives), `link` messages whose text or caption contains a web link.
3360
3395
  * @enum {string}
3361
3396
  */
3362
- MediaKind: "image" | "audio" | "visual" | "file";
3397
+ MediaKind: "image" | "audio" | "visual" | "file" | "voice" | "link";
3363
3398
  /** @enum {string} */
3364
3399
  MessageType: "text" | "file" | "voice" | "system" | "sticker";
3365
3400
  /**
@@ -3382,6 +3417,8 @@ export interface components {
3382
3417
  StickerPackSlug: string;
3383
3418
  StickerPack: {
3384
3419
  id: components["schemas"]["Id"];
3420
+ /** @description Grows whenever the title or the stickers of the pack change. */
3421
+ version: number;
3385
3422
  title: string;
3386
3423
  /** @description A built-in pack of the messenger, not made by a user. */
3387
3424
  is_official: boolean;
@@ -3651,6 +3688,21 @@ export interface components {
3651
3688
  user_id: components["schemas"]["Id"];
3652
3689
  initial_message?: string | null;
3653
3690
  };
3691
+ GroupMemberPage: {
3692
+ items: components["schemas"]["GroupMember"][];
3693
+ next_cursor: components["schemas"]["Cursor"];
3694
+ total: number;
3695
+ };
3696
+ CommonGroup: {
3697
+ id: components["schemas"]["Id"];
3698
+ name: string;
3699
+ avatar_url: string | null;
3700
+ member_count: number;
3701
+ };
3702
+ CommonGroupPage: {
3703
+ items: components["schemas"]["CommonGroup"][];
3704
+ next_cursor: components["schemas"]["Cursor"];
3705
+ };
3654
3706
  GroupMember: {
3655
3707
  user: components["schemas"]["User"];
3656
3708
  role: components["schemas"]["GroupRole"];
@@ -4509,6 +4561,13 @@ export interface operations {
4509
4561
  "application/json": components["schemas"]["Me"];
4510
4562
  };
4511
4563
  };
4564
+ /** @description Not modified; the response's `ETag` matches `If-None-Match`. */
4565
+ 304: {
4566
+ headers: {
4567
+ [name: string]: unknown;
4568
+ };
4569
+ content?: never;
4570
+ };
4512
4571
  400: components["responses"]["BadRequest"];
4513
4572
  401: components["responses"]["Unauthorized"];
4514
4573
  426: components["responses"]["ClientOutdated"];
@@ -5180,6 +5239,42 @@ export interface operations {
5180
5239
  429: components["responses"]["TooManyRequests"];
5181
5240
  };
5182
5241
  };
5242
+ listCommonGroups: {
5243
+ parameters: {
5244
+ query?: {
5245
+ /** @description Page size */
5246
+ limit?: components["parameters"]["Limit"];
5247
+ /** @description Opaque `next_cursor` of the previous page */
5248
+ after?: components["parameters"]["After"];
5249
+ };
5250
+ header?: {
5251
+ /** @description Version of the client app, for logs and the per-client metric. */
5252
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
5253
+ /** @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`). */
5254
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
5255
+ };
5256
+ path: {
5257
+ user_id: components["schemas"]["Id"];
5258
+ };
5259
+ cookie?: never;
5260
+ };
5261
+ requestBody?: never;
5262
+ responses: {
5263
+ /** @description A page of groups */
5264
+ 200: {
5265
+ headers: {
5266
+ [name: string]: unknown;
5267
+ };
5268
+ content: {
5269
+ "application/json": components["schemas"]["CommonGroupPage"];
5270
+ };
5271
+ };
5272
+ 400: components["responses"]["BadRequest"];
5273
+ 401: components["responses"]["Unauthorized"];
5274
+ 404: components["responses"]["NotFound"];
5275
+ 426: components["responses"]["ClientOutdated"];
5276
+ };
5277
+ };
5183
5278
  getUser: {
5184
5279
  parameters: {
5185
5280
  query?: never;
@@ -5205,6 +5300,13 @@ export interface operations {
5205
5300
  "application/json": components["schemas"]["User"];
5206
5301
  };
5207
5302
  };
5303
+ /** @description Not modified; the response's `ETag` matches `If-None-Match`. */
5304
+ 304: {
5305
+ headers: {
5306
+ [name: string]: unknown;
5307
+ };
5308
+ content?: never;
5309
+ };
5208
5310
  400: components["responses"]["BadRequest"];
5209
5311
  401: components["responses"]["Unauthorized"];
5210
5312
  404: components["responses"]["NotFound"];
@@ -6504,6 +6606,13 @@ export interface operations {
6504
6606
  "application/json": components["schemas"]["Group"];
6505
6607
  };
6506
6608
  };
6609
+ /** @description Not modified; the response's `ETag` matches `If-None-Match`. */
6610
+ 304: {
6611
+ headers: {
6612
+ [name: string]: unknown;
6613
+ };
6614
+ content?: never;
6615
+ };
6507
6616
  400: components["responses"]["BadRequest"];
6508
6617
  401: components["responses"]["Unauthorized"];
6509
6618
  404: components["responses"]["NotFound"];
@@ -6614,6 +6723,43 @@ export interface operations {
6614
6723
  426: components["responses"]["ClientOutdated"];
6615
6724
  };
6616
6725
  };
6726
+ listGroupMembers: {
6727
+ parameters: {
6728
+ query?: {
6729
+ q?: string;
6730
+ /** @description Page size */
6731
+ limit?: components["parameters"]["Limit"];
6732
+ /** @description Opaque `next_cursor` of the previous page */
6733
+ after?: components["parameters"]["After"];
6734
+ };
6735
+ header?: {
6736
+ /** @description Version of the client app, for logs and the per-client metric. */
6737
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
6738
+ /** @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`). */
6739
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
6740
+ };
6741
+ path: {
6742
+ chat_id: components["parameters"]["ChatId"];
6743
+ };
6744
+ cookie?: never;
6745
+ };
6746
+ requestBody?: never;
6747
+ responses: {
6748
+ /** @description A page of members */
6749
+ 200: {
6750
+ headers: {
6751
+ [name: string]: unknown;
6752
+ };
6753
+ content: {
6754
+ "application/json": components["schemas"]["GroupMemberPage"];
6755
+ };
6756
+ };
6757
+ 400: components["responses"]["BadRequest"];
6758
+ 401: components["responses"]["Unauthorized"];
6759
+ 404: components["responses"]["NotFound"];
6760
+ 426: components["responses"]["ClientOutdated"];
6761
+ };
6762
+ };
6617
6763
  addGroupParticipant: {
6618
6764
  parameters: {
6619
6765
  query?: never;
@@ -6843,6 +6989,13 @@ export interface operations {
6843
6989
  "application/json": components["schemas"]["StickerPackList"];
6844
6990
  };
6845
6991
  };
6992
+ /** @description Not modified; the response's `ETag` matches `If-None-Match`. */
6993
+ 304: {
6994
+ headers: {
6995
+ [name: string]: unknown;
6996
+ };
6997
+ content?: never;
6998
+ };
6846
6999
  400: components["responses"]["BadRequest"];
6847
7000
  401: components["responses"]["Unauthorized"];
6848
7001
  426: components["responses"]["ClientOutdated"];
@@ -6907,6 +7060,13 @@ export interface operations {
6907
7060
  "application/json": components["schemas"]["StickerPack"];
6908
7061
  };
6909
7062
  };
7063
+ /** @description Not modified; the response's `ETag` matches `If-None-Match`. */
7064
+ 304: {
7065
+ headers: {
7066
+ [name: string]: unknown;
7067
+ };
7068
+ content?: never;
7069
+ };
6910
7070
  400: components["responses"]["BadRequest"];
6911
7071
  401: components["responses"]["Unauthorized"];
6912
7072
  404: components["responses"]["NotFound"];
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 |\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",
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| `user_updated` | A user you share a chat with changed their profile (`profile_version`) |\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",
@@ -97,7 +97,8 @@
97
97
  "bio": null,
98
98
  "is_online": true,
99
99
  "last_seen": null,
100
- "is_deleted": false
100
+ "is_deleted": false,
101
+ "profile_version": 1
101
102
  },
102
103
  "group_name": null,
103
104
  "preview": "Hi, can we talk?",
@@ -187,7 +188,8 @@
187
188
  "bio": null,
188
189
  "is_online": true,
189
190
  "last_seen": null,
190
- "is_deleted": false
191
+ "is_deleted": false,
192
+ "profile_version": 1
191
193
  },
192
194
  "is_pinned": false,
193
195
  "pin_position": null,
@@ -207,7 +209,8 @@
207
209
  "bio": null,
208
210
  "is_online": true,
209
211
  "last_seen": null,
210
- "is_deleted": false
212
+ "is_deleted": false,
213
+ "profile_version": 1
211
214
  },
212
215
  "content": "Hello!",
213
216
  "attachment": null,
@@ -249,7 +252,8 @@
249
252
  "bio": null,
250
253
  "is_online": true,
251
254
  "last_seen": null,
252
- "is_deleted": false
255
+ "is_deleted": false,
256
+ "profile_version": 1
253
257
  },
254
258
  "is_pinned": false,
255
259
  "pin_position": null,
@@ -269,7 +273,8 @@
269
273
  "bio": null,
270
274
  "is_online": true,
271
275
  "last_seen": null,
272
- "is_deleted": false
276
+ "is_deleted": false,
277
+ "profile_version": 1
273
278
  },
274
279
  "content": "Hello!",
275
280
  "attachment": null,
@@ -313,7 +318,8 @@
313
318
  "bio": null,
314
319
  "is_online": true,
315
320
  "last_seen": null,
316
- "is_deleted": false
321
+ "is_deleted": false,
322
+ "profile_version": 1
317
323
  },
318
324
  "content": "Hello, world!",
319
325
  "attachment": null,
@@ -360,7 +366,8 @@
360
366
  "bio": null,
361
367
  "is_online": true,
362
368
  "last_seen": null,
363
- "is_deleted": false
369
+ "is_deleted": false,
370
+ "profile_version": 1
364
371
  },
365
372
  "role": "owner",
366
373
  "joined_at": "2026-10-04T12:00:00Z"
@@ -392,7 +399,8 @@
392
399
  "bio": null,
393
400
  "is_online": true,
394
401
  "last_seen": null,
395
- "is_deleted": false
402
+ "is_deleted": false,
403
+ "profile_version": 1
396
404
  },
397
405
  "role": "owner",
398
406
  "joined_at": "2026-10-04T12:00:00Z"
@@ -439,7 +447,8 @@
439
447
  "bio": null,
440
448
  "is_online": true,
441
449
  "last_seen": null,
442
- "is_deleted": false
450
+ "is_deleted": false,
451
+ "profile_version": 1
443
452
  },
444
453
  "content": "Hello!",
445
454
  "attachment": null,
@@ -545,6 +554,15 @@
545
554
  "is_typing": true,
546
555
  "action": "recording_voice"
547
556
  }
557
+ },
558
+ "server/user_updated.json": {
559
+ "type": "user_updated",
560
+ "event_id": "7217400317439950012",
561
+ "chat_id": null,
562
+ "data": {
563
+ "user_id": "7",
564
+ "profile_version": 3
565
+ }
548
566
  }
549
567
  }
550
568
  }
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.26. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.28. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -54,7 +54,8 @@ export type ServerEvent =
54
54
  | ServerRecoveryRequestEvent
55
55
  | ServerSecurityAlertEvent
56
56
  | ServerSecurityNoticeEvent
57
- | ServerTypingEvent;
57
+ | ServerTypingEvent
58
+ | ServerUserUpdatedEvent;
58
59
  export type Timestamp = string;
59
60
  export type ApprovalRequestType = "direct_message" | "group_invite";
60
61
  export type ApprovalRequestStatus = "pending" | "approved" | "rejected";
@@ -292,6 +293,10 @@ export interface ApprovalRequest {
292
293
  */
293
294
  export interface User {
294
295
  id: Id;
296
+ /**
297
+ * Grows whenever the username, display name, bio or avatar changes (not with presence). Clients keep a stored profile until a higher version arrives.
298
+ */
299
+ profile_version: number;
295
300
  username: Username;
296
301
  display_name: string;
297
302
  /**
@@ -920,3 +925,15 @@ export interface ServerTypingEvent {
920
925
  "typing" | "recording_voice" | "choosing_sticker" | "uploading_photo" | "uploading_video" | "uploading_file";
921
926
  };
922
927
  }
928
+ /**
929
+ * A user you share a chat with changed their username, display name, bio or avatar. Fetch GET /users/{user_id} again when profile_version is higher than the one you keep.
930
+ */
931
+ export interface ServerUserUpdatedEvent {
932
+ type: "user_updated";
933
+ event_id: Id;
934
+ chat_id: null;
935
+ data: {
936
+ user_id: Id;
937
+ profile_version: number;
938
+ };
939
+ }
@@ -1011,12 +1011,18 @@
1011
1011
  "bio",
1012
1012
  "is_online",
1013
1013
  "last_seen",
1014
- "is_deleted"
1014
+ "is_deleted",
1015
+ "profile_version"
1015
1016
  ],
1016
1017
  "properties": {
1017
1018
  "id": {
1018
1019
  "$ref": "#/$defs/Id"
1019
1020
  },
1021
+ "profile_version": {
1022
+ "type": "integer",
1023
+ "minimum": 0,
1024
+ "description": "Grows whenever the username, display name, bio or avatar changes (not with presence). Clients keep a stored profile until a higher version arrives."
1025
+ },
1020
1026
  "username": {
1021
1027
  "$ref": "#/$defs/Username"
1022
1028
  },
@@ -1442,12 +1448,14 @@
1442
1448
  },
1443
1449
  "MediaKind": {
1444
1450
  "type": "string",
1445
- "description": "`image` photos, `visual` photos and videos, `audio` audio files and voice messages, `file` other files (documents, archives).",
1451
+ "description": "`image` photos, `visual` photos and videos, `audio` audio files and voice messages, `voice` voice messages only,\n`file` other files (documents, archives), `link` messages whose text or caption contains a web link.\n",
1446
1452
  "enum": [
1447
1453
  "image",
1448
1454
  "audio",
1449
1455
  "visual",
1450
- "file"
1456
+ "file",
1457
+ "voice",
1458
+ "link"
1451
1459
  ]
1452
1460
  },
1453
1461
  "MessageType": {
@@ -1512,12 +1520,18 @@
1512
1520
  "is_installed",
1513
1521
  "is_mine",
1514
1522
  "is_hidden",
1515
- "stickers"
1523
+ "stickers",
1524
+ "version"
1516
1525
  ],
1517
1526
  "properties": {
1518
1527
  "id": {
1519
1528
  "$ref": "#/$defs/Id"
1520
1529
  },
1530
+ "version": {
1531
+ "type": "integer",
1532
+ "minimum": 0,
1533
+ "description": "Grows whenever the title or the stickers of the pack change."
1534
+ },
1521
1535
  "title": {
1522
1536
  "type": "string",
1523
1537
  "minLength": 1,
@@ -2699,6 +2713,74 @@
2699
2713
  }
2700
2714
  }
2701
2715
  },
2716
+ "GroupMemberPage": {
2717
+ "type": "object",
2718
+ "required": [
2719
+ "items",
2720
+ "next_cursor",
2721
+ "total"
2722
+ ],
2723
+ "properties": {
2724
+ "items": {
2725
+ "type": "array",
2726
+ "items": {
2727
+ "$ref": "#/$defs/GroupMember"
2728
+ }
2729
+ },
2730
+ "next_cursor": {
2731
+ "$ref": "#/$defs/Cursor"
2732
+ },
2733
+ "total": {
2734
+ "type": "integer",
2735
+ "minimum": 0
2736
+ }
2737
+ }
2738
+ },
2739
+ "CommonGroup": {
2740
+ "type": "object",
2741
+ "required": [
2742
+ "id",
2743
+ "name",
2744
+ "avatar_url",
2745
+ "member_count"
2746
+ ],
2747
+ "properties": {
2748
+ "id": {
2749
+ "$ref": "#/$defs/Id"
2750
+ },
2751
+ "name": {
2752
+ "type": "string"
2753
+ },
2754
+ "avatar_url": {
2755
+ "type": [
2756
+ "string",
2757
+ "null"
2758
+ ]
2759
+ },
2760
+ "member_count": {
2761
+ "type": "integer",
2762
+ "minimum": 1
2763
+ }
2764
+ }
2765
+ },
2766
+ "CommonGroupPage": {
2767
+ "type": "object",
2768
+ "required": [
2769
+ "items",
2770
+ "next_cursor"
2771
+ ],
2772
+ "properties": {
2773
+ "items": {
2774
+ "type": "array",
2775
+ "items": {
2776
+ "$ref": "#/$defs/CommonGroup"
2777
+ }
2778
+ },
2779
+ "next_cursor": {
2780
+ "$ref": "#/$defs/Cursor"
2781
+ }
2782
+ }
2783
+ },
2702
2784
  "GroupMember": {
2703
2785
  "type": "object",
2704
2786
  "required": [
@@ -5226,6 +5308,44 @@
5226
5308
  "data"
5227
5309
  ]
5228
5310
  },
5311
+ "ServerUserUpdatedEvent": {
5312
+ "title": "ServerUserUpdatedEvent",
5313
+ "description": "A user you share a chat with changed their username, display name, bio or avatar. Fetch GET /users/{user_id} again when profile_version is higher than the one you keep.",
5314
+ "type": "object",
5315
+ "properties": {
5316
+ "type": {
5317
+ "const": "user_updated"
5318
+ },
5319
+ "event_id": {
5320
+ "$ref": "#/$defs/Id"
5321
+ },
5322
+ "chat_id": {
5323
+ "type": "null"
5324
+ },
5325
+ "data": {
5326
+ "type": "object",
5327
+ "properties": {
5328
+ "user_id": {
5329
+ "$ref": "#/$defs/Id"
5330
+ },
5331
+ "profile_version": {
5332
+ "type": "integer",
5333
+ "minimum": 0
5334
+ }
5335
+ },
5336
+ "required": [
5337
+ "user_id",
5338
+ "profile_version"
5339
+ ]
5340
+ }
5341
+ },
5342
+ "required": [
5343
+ "type",
5344
+ "event_id",
5345
+ "chat_id",
5346
+ "data"
5347
+ ]
5348
+ },
5229
5349
  "ClientEvent": {
5230
5350
  "title": "ClientEvent",
5231
5351
  "description": "Every event a client may send.",
@@ -5328,6 +5448,9 @@
5328
5448
  },
5329
5449
  {
5330
5450
  "$ref": "#/$defs/ServerTypingEvent"
5451
+ },
5452
+ {
5453
+ "$ref": "#/$defs/ServerUserUpdatedEvent"
5331
5454
  }
5332
5455
  ]
5333
5456
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.1.0-alpha.26.next.108",
3
+ "version": "2.1.0-alpha.28",
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": {