@myronsi/messenger-api 2.1.0-alpha.23.next.104 → 2.1.0-alpha.25.next.107

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,27 @@
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.25
6
+
7
+ - Archive: `PUT` and `DELETE /chats/{chat_id}/archive` archive a chat for the caller and move it back. `Chat` gains
8
+ the required `is_archived`; `GET /chats?archived=true|false` lists only archived or only other chats (without the
9
+ parameter, every chat as before). Archiving unpins; an archived chat stays archived when new messages arrive;
10
+ pinning a chat unarchives it.
11
+ - Pin order: `Chat` gains the required, nullable `pin_position` (lowest first) and pinned chats are listed in that
12
+ order. A newly pinned chat goes to the top. `PUT /chats/pins/order` (`PinOrderRequest`) sets the order of all
13
+ pinned chats at once.
14
+ - Saved Messages: `POST /chats` accepts the caller's own `user_id` and opens a direct chat whose only member and
15
+ `peer` is the caller.
16
+
17
+ ## 2.1.0-alpha.24
18
+
19
+ - `PrivacySettings` gains the required `last_seen_visibility`, also accepted by `PATCH /me/privacy` and as a
20
+ `setting_key` of `PUT /me/privacy/exceptions/{setting_key}/{effect}`. It decides who sees `User.last_seen` and the
21
+ `last_seen` of `presence` events; `presence_visibility` now decides only `User.is_online` and online `presence`
22
+ events. Existing users start with both settings and their exceptions equal to their old `presence_visibility`.
23
+ - The `action` of the client and server `typing` events gains `choosing_sticker`, `uploading_photo`,
24
+ `uploading_video` and `uploading_file`.
25
+
5
26
  ## 2.1.0-alpha.23
6
27
 
7
28
  - `MediaKind` gains `file`: `GET /chats/{chat_id}/media?kind=file` lists messages with file attachments (documents,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.23. Do not edit. */
2
- export declare const API_VERSION: "2.1.0-alpha.23";
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.25. Do not edit. */
2
+ export declare const API_VERSION: "2.1.0-alpha.25";
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.23";
1
+ export const API_VERSION = "2.1.0-alpha.25";
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.23
4
+ version: 2.1.0-alpha.25
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
@@ -651,7 +651,7 @@ paths:
651
651
  required: true
652
652
  schema:
653
653
  type: string
654
- enum: [avatar_visibility, profile_visibility, presence_visibility, group_invites, direct_messages, search_visibility]
654
+ enum: [avatar_visibility, profile_visibility, presence_visibility, last_seen_visibility, group_invites, direct_messages, search_visibility]
655
655
  - name: effect
656
656
  in: path
657
657
  required: true
@@ -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 (most recently pinned first), then the others by their last
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:
@@ -1102,7 +1109,9 @@ paths:
1102
1109
  tags: [chats]
1103
1110
  operationId: pinChat
1104
1111
  summary: Pin a chat
1105
- description: At most 10 chats can be pinned (`409` beyond that). Pinning a pinned chat changes nothing.
1112
+ description: |
1113
+ At most 10 chats can be pinned (`409` beyond that). A newly pinned chat goes to the top of the pinned
1114
+ chats and leaves the archive. Pinning a pinned chat changes nothing.
1106
1115
  responses:
1107
1116
  "426": { $ref: "#/components/responses/ClientOutdated" }
1108
1117
  "400": { $ref: "#/components/responses/BadRequest" }
@@ -1122,6 +1131,60 @@ paths:
1122
1131
  description: Unpinned
1123
1132
  "401": { $ref: "#/components/responses/Unauthorized" }
1124
1133
  "404": { $ref: "#/components/responses/NotFound" }
1134
+ /chats/{chat_id}/archive:
1135
+ parameters:
1136
+ - $ref: "#/components/parameters/ClientVersion"
1137
+ - $ref: "#/components/parameters/ClientApiVersion"
1138
+ - $ref: "#/components/parameters/ChatId"
1139
+ put:
1140
+ tags: [chats]
1141
+ operationId: archiveChat
1142
+ summary: Archive a chat
1143
+ description: |
1144
+ Only for the caller. The chat leaves the pinned chats and stays archived when new messages arrive,
1145
+ until `DELETE` unarchives it. Archiving an archived chat changes nothing. The caller's devices get
1146
+ `chat_list_update`.
1147
+ responses:
1148
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1149
+ "400": { $ref: "#/components/responses/BadRequest" }
1150
+ "204":
1151
+ description: Archived
1152
+ "401": { $ref: "#/components/responses/Unauthorized" }
1153
+ "404": { $ref: "#/components/responses/NotFound" }
1154
+ delete:
1155
+ tags: [chats]
1156
+ operationId: unarchiveChat
1157
+ summary: Move a chat out of the archive
1158
+ responses:
1159
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1160
+ "400": { $ref: "#/components/responses/BadRequest" }
1161
+ "204":
1162
+ description: Not archived
1163
+ "401": { $ref: "#/components/responses/Unauthorized" }
1164
+ "404": { $ref: "#/components/responses/NotFound" }
1165
+ /chats/pins/order:
1166
+ parameters:
1167
+ - $ref: "#/components/parameters/ClientVersion"
1168
+ - $ref: "#/components/parameters/ClientApiVersion"
1169
+ put:
1170
+ tags: [chats]
1171
+ operationId: reorderPinnedChats
1172
+ summary: Order the pinned chats
1173
+ description: |
1174
+ `chat_ids` must name every pinned chat of the caller exactly once (`422` otherwise), in the new order,
1175
+ top first. The caller's devices get `chat_list_update` for each pinned chat.
1176
+ requestBody:
1177
+ required: true
1178
+ content:
1179
+ application/json:
1180
+ schema: { $ref: "#/components/schemas/PinOrderRequest" }
1181
+ responses:
1182
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1183
+ "400": { $ref: "#/components/responses/BadRequest" }
1184
+ "204":
1185
+ description: Reordered
1186
+ "401": { $ref: "#/components/responses/Unauthorized" }
1187
+ "422": { $ref: "#/components/responses/ValidationFailed" }
1125
1188
  /chats/{chat_id}/read:
1126
1189
  parameters:
1127
1190
  - $ref: "#/components/parameters/ClientVersion"
@@ -4736,6 +4799,7 @@ components:
4736
4799
  - avatar_visibility
4737
4800
  - profile_visibility
4738
4801
  - presence_visibility
4802
+ - last_seen_visibility
4739
4803
  - read_receipts_enabled
4740
4804
  - direct_messages
4741
4805
  - group_invites
@@ -4746,7 +4810,12 @@ components:
4746
4810
  properties:
4747
4811
  avatar_visibility: { $ref: "#/components/schemas/Visibility" }
4748
4812
  profile_visibility: { $ref: "#/components/schemas/Visibility" }
4749
- presence_visibility: { $ref: "#/components/schemas/Visibility" }
4813
+ presence_visibility:
4814
+ description: Who sees that the user is online now (`User.is_online`, `presence` events).
4815
+ allOf: [{ $ref: "#/components/schemas/Visibility" }]
4816
+ last_seen_visibility:
4817
+ description: Who sees when the user was last online (`User.last_seen`, `presence` events).
4818
+ allOf: [{ $ref: "#/components/schemas/Visibility" }]
4750
4819
  read_receipts_enabled: { type: boolean }
4751
4820
  direct_messages: { $ref: "#/components/schemas/DirectMessagePolicy" }
4752
4821
  group_invites: { $ref: "#/components/schemas/GroupInvitePolicy" }
@@ -4765,6 +4834,7 @@ components:
4765
4834
  avatar_visibility: { $ref: "#/components/schemas/Visibility" }
4766
4835
  profile_visibility: { $ref: "#/components/schemas/Visibility" }
4767
4836
  presence_visibility: { $ref: "#/components/schemas/Visibility" }
4837
+ last_seen_visibility: { $ref: "#/components/schemas/Visibility" }
4768
4838
  read_receipts_enabled: { type: boolean }
4769
4839
  direct_messages: { $ref: "#/components/schemas/DirectMessagePolicy" }
4770
4840
  group_invites: { $ref: "#/components/schemas/GroupInvitePolicy" }
@@ -5479,6 +5549,8 @@ components:
5479
5549
  - avatar_url
5480
5550
  - peer
5481
5551
  - is_pinned
5552
+ - pin_position
5553
+ - is_archived
5482
5554
  - unread_count
5483
5555
  - first_unread_message_id
5484
5556
  - last_read_message_id
@@ -5492,11 +5564,17 @@ components:
5492
5564
  description: Display name of the peer or the group
5493
5565
  avatar_url: { type: [string, "null"] }
5494
5566
  peer:
5495
- description: The other user of a direct chat; `null` for groups.
5567
+ description: The other user of a direct chat (the caller in their "Saved Messages" chat); `null` for groups.
5496
5568
  oneOf:
5497
5569
  - $ref: "#/components/schemas/User"
5498
5570
  - type: "null"
5499
5571
  is_pinned: { type: boolean }
5572
+ pin_position:
5573
+ description: Order of a pinned chat among the caller's pinned chats, lowest first; `null` when not pinned.
5574
+ type: [integer, "null"]
5575
+ is_archived:
5576
+ type: boolean
5577
+ description: Whether the caller archived the chat (only for the caller).
5500
5578
  unread_count: { type: integer, minimum: 0 }
5501
5579
  first_unread_message_id:
5502
5580
  description: |
@@ -5529,6 +5607,15 @@ components:
5529
5607
  type: array
5530
5608
  items: { $ref: "#/components/schemas/Chat" }
5531
5609
  next_cursor: { $ref: "#/components/schemas/Cursor" }
5610
+ PinOrderRequest:
5611
+ type: object
5612
+ required: [chat_ids]
5613
+ properties:
5614
+ chat_ids:
5615
+ type: array
5616
+ maxItems: 10
5617
+ uniqueItems: true
5618
+ items: { $ref: "#/components/schemas/Id" }
5532
5619
  CreateChatRequest:
5533
5620
  type: object
5534
5621
  required: [user_id]
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.23. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.25. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -514,7 +514,7 @@ export interface paths {
514
514
  "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
515
515
  };
516
516
  path: {
517
- setting_key: "avatar_visibility" | "profile_visibility" | "presence_visibility" | "group_invites" | "direct_messages" | "search_visibility";
517
+ setting_key: "avatar_visibility" | "profile_visibility" | "presence_visibility" | "last_seen_visibility" | "group_invites" | "direct_messages" | "search_visibility";
518
518
  effect: "allow" | "deny";
519
519
  };
520
520
  cookie?: never;
@@ -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 (most recently pinned first), then the others by their last
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;
@@ -880,7 +882,8 @@ export interface paths {
880
882
  get?: never;
881
883
  /**
882
884
  * Pin a chat
883
- * @description At most 10 chats can be pinned (`409` beyond that). Pinning a pinned chat changes nothing.
885
+ * @description At most 10 chats can be pinned (`409` beyond that). A newly pinned chat goes to the top of the pinned
886
+ * chats and leaves the archive. Pinning a pinned chat changes nothing.
884
887
  */
885
888
  put: operations["pinChat"];
886
889
  post?: never;
@@ -891,6 +894,62 @@ export interface paths {
891
894
  patch?: never;
892
895
  trace?: never;
893
896
  };
897
+ "/chats/{chat_id}/archive": {
898
+ parameters: {
899
+ query?: never;
900
+ header?: {
901
+ /** @description Version of the client app, for logs and the per-client metric. */
902
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
903
+ /** @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`). */
904
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
905
+ };
906
+ path: {
907
+ chat_id: components["parameters"]["ChatId"];
908
+ };
909
+ cookie?: never;
910
+ };
911
+ get?: never;
912
+ /**
913
+ * Archive a chat
914
+ * @description Only for the caller. The chat leaves the pinned chats and stays archived when new messages arrive,
915
+ * until `DELETE` unarchives it. Archiving an archived chat changes nothing. The caller's devices get
916
+ * `chat_list_update`.
917
+ */
918
+ put: operations["archiveChat"];
919
+ post?: never;
920
+ /** Move a chat out of the archive */
921
+ delete: operations["unarchiveChat"];
922
+ options?: never;
923
+ head?: never;
924
+ patch?: never;
925
+ trace?: never;
926
+ };
927
+ "/chats/pins/order": {
928
+ parameters: {
929
+ query?: never;
930
+ header?: {
931
+ /** @description Version of the client app, for logs and the per-client metric. */
932
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
933
+ /** @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`). */
934
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
935
+ };
936
+ path?: never;
937
+ cookie?: never;
938
+ };
939
+ get?: never;
940
+ /**
941
+ * Order the pinned chats
942
+ * @description `chat_ids` must name every pinned chat of the caller exactly once (`422` otherwise), in the new order,
943
+ * top first. The caller's devices get `chat_list_update` for each pinned chat.
944
+ */
945
+ put: operations["reorderPinnedChats"];
946
+ post?: never;
947
+ delete?: never;
948
+ options?: never;
949
+ head?: never;
950
+ patch?: never;
951
+ trace?: never;
952
+ };
894
953
  "/chats/{chat_id}/read": {
895
954
  parameters: {
896
955
  query?: never;
@@ -3118,7 +3177,10 @@ export interface components {
3118
3177
  PrivacySettings: {
3119
3178
  avatar_visibility: components["schemas"]["Visibility"];
3120
3179
  profile_visibility: components["schemas"]["Visibility"];
3180
+ /** @description Who sees that the user is online now (`User.is_online`, `presence` events). */
3121
3181
  presence_visibility: components["schemas"]["Visibility"];
3182
+ /** @description Who sees when the user was last online (`User.last_seen`, `presence` events). */
3183
+ last_seen_visibility: components["schemas"]["Visibility"];
3122
3184
  read_receipts_enabled: boolean;
3123
3185
  direct_messages: components["schemas"]["DirectMessagePolicy"];
3124
3186
  group_invites: components["schemas"]["GroupInvitePolicy"];
@@ -3133,6 +3195,7 @@ export interface components {
3133
3195
  avatar_visibility?: components["schemas"]["Visibility"];
3134
3196
  profile_visibility?: components["schemas"]["Visibility"];
3135
3197
  presence_visibility?: components["schemas"]["Visibility"];
3198
+ last_seen_visibility?: components["schemas"]["Visibility"];
3136
3199
  read_receipts_enabled?: boolean;
3137
3200
  direct_messages?: components["schemas"]["DirectMessagePolicy"];
3138
3201
  group_invites?: components["schemas"]["GroupInvitePolicy"];
@@ -3518,9 +3581,13 @@ export interface components {
3518
3581
  /** @description Display name of the peer or the group */
3519
3582
  name: string;
3520
3583
  avatar_url: string | null;
3521
- /** @description The other user of a direct chat; `null` for groups. */
3584
+ /** @description The other user of a direct chat (the caller in their "Saved Messages" chat); `null` for groups. */
3522
3585
  peer: components["schemas"]["User"] | null;
3523
3586
  is_pinned: boolean;
3587
+ /** @description Order of a pinned chat among the caller's pinned chats, lowest first; `null` when not pinned. */
3588
+ pin_position: number | null;
3589
+ /** @description Whether the caller archived the chat (only for the caller). */
3590
+ is_archived: boolean;
3524
3591
  unread_count: number;
3525
3592
  /**
3526
3593
  * @description The oldest message the caller has not read (the same messages `unread_count` counts: not their own,
@@ -3539,6 +3606,9 @@ export interface components {
3539
3606
  items: components["schemas"]["Chat"][];
3540
3607
  next_cursor: components["schemas"]["Cursor"];
3541
3608
  };
3609
+ PinOrderRequest: {
3610
+ chat_ids: components["schemas"]["Id"][];
3611
+ };
3542
3612
  CreateChatRequest: {
3543
3613
  user_id: components["schemas"]["Id"];
3544
3614
  initial_message?: string | null;
@@ -4887,7 +4957,7 @@ export interface operations {
4887
4957
  "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
4888
4958
  };
4889
4959
  path: {
4890
- setting_key: "avatar_visibility" | "profile_visibility" | "presence_visibility" | "group_invites" | "direct_messages" | "search_visibility";
4960
+ setting_key: "avatar_visibility" | "profile_visibility" | "presence_visibility" | "last_seen_visibility" | "group_invites" | "direct_messages" | "search_visibility";
4891
4961
  effect: "allow" | "deny";
4892
4962
  };
4893
4963
  cookie?: never;
@@ -5379,6 +5449,8 @@ export interface operations {
5379
5449
  limit?: components["parameters"]["Limit"];
5380
5450
  /** @description Opaque `next_cursor` of the previous page */
5381
5451
  after?: components["parameters"]["After"];
5452
+ /** @description `true`: only archived chats, `false`: only chats that are not archived. Without it, every chat. */
5453
+ archived?: boolean;
5382
5454
  };
5383
5455
  header?: {
5384
5456
  /** @description Version of the client app, for logs and the per-client metric. */
@@ -5579,6 +5651,95 @@ export interface operations {
5579
5651
  426: components["responses"]["ClientOutdated"];
5580
5652
  };
5581
5653
  };
5654
+ archiveChat: {
5655
+ parameters: {
5656
+ query?: never;
5657
+ header?: {
5658
+ /** @description Version of the client app, for logs and the per-client metric. */
5659
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
5660
+ /** @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`). */
5661
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
5662
+ };
5663
+ path: {
5664
+ chat_id: components["parameters"]["ChatId"];
5665
+ };
5666
+ cookie?: never;
5667
+ };
5668
+ requestBody?: never;
5669
+ responses: {
5670
+ /** @description Archived */
5671
+ 204: {
5672
+ headers: {
5673
+ [name: string]: unknown;
5674
+ };
5675
+ content?: never;
5676
+ };
5677
+ 400: components["responses"]["BadRequest"];
5678
+ 401: components["responses"]["Unauthorized"];
5679
+ 404: components["responses"]["NotFound"];
5680
+ 426: components["responses"]["ClientOutdated"];
5681
+ };
5682
+ };
5683
+ unarchiveChat: {
5684
+ parameters: {
5685
+ query?: never;
5686
+ header?: {
5687
+ /** @description Version of the client app, for logs and the per-client metric. */
5688
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
5689
+ /** @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`). */
5690
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
5691
+ };
5692
+ path: {
5693
+ chat_id: components["parameters"]["ChatId"];
5694
+ };
5695
+ cookie?: never;
5696
+ };
5697
+ requestBody?: never;
5698
+ responses: {
5699
+ /** @description Not archived */
5700
+ 204: {
5701
+ headers: {
5702
+ [name: string]: unknown;
5703
+ };
5704
+ content?: never;
5705
+ };
5706
+ 400: components["responses"]["BadRequest"];
5707
+ 401: components["responses"]["Unauthorized"];
5708
+ 404: components["responses"]["NotFound"];
5709
+ 426: components["responses"]["ClientOutdated"];
5710
+ };
5711
+ };
5712
+ reorderPinnedChats: {
5713
+ parameters: {
5714
+ query?: never;
5715
+ header?: {
5716
+ /** @description Version of the client app, for logs and the per-client metric. */
5717
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
5718
+ /** @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`). */
5719
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
5720
+ };
5721
+ path?: never;
5722
+ cookie?: never;
5723
+ };
5724
+ requestBody: {
5725
+ content: {
5726
+ "application/json": components["schemas"]["PinOrderRequest"];
5727
+ };
5728
+ };
5729
+ responses: {
5730
+ /** @description Reordered */
5731
+ 204: {
5732
+ headers: {
5733
+ [name: string]: unknown;
5734
+ };
5735
+ content?: never;
5736
+ };
5737
+ 400: components["responses"]["BadRequest"];
5738
+ 401: components["responses"]["Unauthorized"];
5739
+ 422: components["responses"]["ValidationFailed"];
5740
+ 426: components["responses"]["ClientOutdated"];
5741
+ };
5742
+ };
5582
5743
  markChatRead: {
5583
5744
  parameters: {
5584
5745
  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 or recording a voice message (`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 or recording a voice message (`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 |\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,
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.23. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.25. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -221,7 +221,7 @@ export interface ClientResendEvent {
221
221
  };
222
222
  }
223
223
  /**
224
- * Tell the chat that you are (not) typing or recording a voice message. Not acknowledged, so it carries no `client_temp_id`. Send `is_typing: true` again every few seconds while it lasts and `false` when it ends; receivers hide it when it is not repeated. Dropped when your `typing_indicators_enabled` privacy setting is off.
224
+ * Tell the chat that you are (not) typing, recording a voice message, choosing a sticker or sending a photo, video or file. Not acknowledged, so it carries no `client_temp_id`. Send `is_typing: true` again every few seconds while it lasts and `false` when it ends; receivers hide it when it is not repeated. Dropped when your `typing_indicators_enabled` privacy setting is off.
225
225
  */
226
226
  export interface ClientTypingEvent {
227
227
  type: "typing";
@@ -231,7 +231,8 @@ export interface ClientTypingEvent {
231
231
  /**
232
232
  * What you are doing. Without it, `typing`.
233
233
  */
234
- action?: "typing" | "recording_voice";
234
+ action?:
235
+ "typing" | "recording_voice" | "choosing_sticker" | "uploading_photo" | "uploading_video" | "uploading_file";
235
236
  };
236
237
  }
237
238
  /**
@@ -414,10 +415,18 @@ export interface Chat {
414
415
  name: string;
415
416
  avatar_url: string | null;
416
417
  /**
417
- * The other user of a direct chat; `null` for groups.
418
+ * The other user of a direct chat (the caller in their "Saved Messages" chat); `null` for groups.
418
419
  */
419
420
  peer: User | null;
420
421
  is_pinned: boolean;
422
+ /**
423
+ * Order of a pinned chat among the caller's pinned chats, lowest first; `null` when not pinned.
424
+ */
425
+ pin_position: number | null;
426
+ /**
427
+ * Whether the caller archived the chat (only for the caller).
428
+ */
429
+ is_archived: boolean;
421
430
  unread_count: number;
422
431
  /**
423
432
  * The oldest message the caller has not read (the same messages `unread_count` counts: not their own,
@@ -881,7 +890,7 @@ export interface ServerSecurityNoticeEvent {
881
890
  };
882
891
  }
883
892
  /**
884
- * A user started or stopped typing or recording a voice message. Hide it after about 6 seconds without a repeat: the sender may disconnect before it sends `false`.
893
+ * A user started or stopped typing, recording a voice message, choosing a sticker or sending a photo, video or file. Hide it after about 6 seconds without a repeat: the sender may disconnect before it sends `false`.
885
894
  */
886
895
  export interface ServerTypingEvent {
887
896
  type: "typing";
@@ -893,6 +902,7 @@ export interface ServerTypingEvent {
893
902
  /**
894
903
  * What the user is doing. New values may be added: show an unknown one like `typing`.
895
904
  */
896
- action: "typing" | "recording_voice";
905
+ action:
906
+ "typing" | "recording_voice" | "choosing_sticker" | "uploading_photo" | "uploading_video" | "uploading_file";
897
907
  };
898
908
  }
@@ -892,6 +892,7 @@
892
892
  "avatar_visibility",
893
893
  "profile_visibility",
894
894
  "presence_visibility",
895
+ "last_seen_visibility",
895
896
  "read_receipts_enabled",
896
897
  "direct_messages",
897
898
  "group_invites",
@@ -908,7 +909,20 @@
908
909
  "$ref": "#/$defs/Visibility"
909
910
  },
910
911
  "presence_visibility": {
911
- "$ref": "#/$defs/Visibility"
912
+ "description": "Who sees that the user is online now (`User.is_online`, `presence` events).",
913
+ "allOf": [
914
+ {
915
+ "$ref": "#/$defs/Visibility"
916
+ }
917
+ ]
918
+ },
919
+ "last_seen_visibility": {
920
+ "description": "Who sees when the user was last online (`User.last_seen`, `presence` events).",
921
+ "allOf": [
922
+ {
923
+ "$ref": "#/$defs/Visibility"
924
+ }
925
+ ]
912
926
  },
913
927
  "read_receipts_enabled": {
914
928
  "type": "boolean"
@@ -948,6 +962,9 @@
948
962
  "presence_visibility": {
949
963
  "$ref": "#/$defs/Visibility"
950
964
  },
965
+ "last_seen_visibility": {
966
+ "$ref": "#/$defs/Visibility"
967
+ },
951
968
  "read_receipts_enabled": {
952
969
  "type": "boolean"
953
970
  },
@@ -2513,6 +2530,8 @@
2513
2530
  "avatar_url",
2514
2531
  "peer",
2515
2532
  "is_pinned",
2533
+ "pin_position",
2534
+ "is_archived",
2516
2535
  "unread_count",
2517
2536
  "first_unread_message_id",
2518
2537
  "last_read_message_id",
@@ -2537,7 +2556,7 @@
2537
2556
  ]
2538
2557
  },
2539
2558
  "peer": {
2540
- "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.",
2541
2560
  "oneOf": [
2542
2561
  {
2543
2562
  "$ref": "#/$defs/User"
@@ -2550,6 +2569,17 @@
2550
2569
  "is_pinned": {
2551
2570
  "type": "boolean"
2552
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
+ },
2553
2583
  "unread_count": {
2554
2584
  "type": "integer",
2555
2585
  "minimum": 0
@@ -2620,6 +2650,22 @@
2620
2650
  }
2621
2651
  }
2622
2652
  },
2653
+ "PinOrderRequest": {
2654
+ "type": "object",
2655
+ "required": [
2656
+ "chat_ids"
2657
+ ],
2658
+ "properties": {
2659
+ "chat_ids": {
2660
+ "type": "array",
2661
+ "maxItems": 10,
2662
+ "uniqueItems": true,
2663
+ "items": {
2664
+ "$ref": "#/$defs/Id"
2665
+ }
2666
+ }
2667
+ }
2668
+ },
2623
2669
  "CreateChatRequest": {
2624
2670
  "type": "object",
2625
2671
  "required": [
@@ -4193,7 +4239,7 @@
4193
4239
  },
4194
4240
  "ClientTypingEvent": {
4195
4241
  "title": "ClientTypingEvent",
4196
- "description": "Tell the chat that you are (not) typing or recording a voice message. Not acknowledged, so it carries no `client_temp_id`. Send `is_typing: true` again every few seconds while it lasts and `false` when it ends; receivers hide it when it is not repeated. Dropped when your `typing_indicators_enabled` privacy setting is off.",
4242
+ "description": "Tell the chat that you are (not) typing, recording a voice message, choosing a sticker or sending a photo, video or file. Not acknowledged, so it carries no `client_temp_id`. Send `is_typing: true` again every few seconds while it lasts and `false` when it ends; receivers hide it when it is not repeated. Dropped when your `typing_indicators_enabled` privacy setting is off.",
4197
4243
  "type": "object",
4198
4244
  "properties": {
4199
4245
  "type": {
@@ -4213,7 +4259,11 @@
4213
4259
  "type": "string",
4214
4260
  "enum": [
4215
4261
  "typing",
4216
- "recording_voice"
4262
+ "recording_voice",
4263
+ "choosing_sticker",
4264
+ "uploading_photo",
4265
+ "uploading_video",
4266
+ "uploading_file"
4217
4267
  ],
4218
4268
  "default": "typing"
4219
4269
  }
@@ -5068,7 +5118,7 @@
5068
5118
  },
5069
5119
  "ServerTypingEvent": {
5070
5120
  "title": "ServerTypingEvent",
5071
- "description": "A user started or stopped typing or recording a voice message. Hide it after about 6 seconds without a repeat: the sender may disconnect before it sends `false`.",
5121
+ "description": "A user started or stopped typing, recording a voice message, choosing a sticker or sending a photo, video or file. Hide it after about 6 seconds without a repeat: the sender may disconnect before it sends `false`.",
5072
5122
  "type": "object",
5073
5123
  "properties": {
5074
5124
  "type": {
@@ -5094,7 +5144,11 @@
5094
5144
  "type": "string",
5095
5145
  "enum": [
5096
5146
  "typing",
5097
- "recording_voice"
5147
+ "recording_voice",
5148
+ "choosing_sticker",
5149
+ "uploading_photo",
5150
+ "uploading_video",
5151
+ "uploading_file"
5098
5152
  ]
5099
5153
  }
5100
5154
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.1.0-alpha.23.next.104",
3
+ "version": "2.1.0-alpha.25.next.107",
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": {