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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  Contract changes only. The backend changelog is `CHANGELOG.md` in the repository root. Rules: `docs/api-compatibility.md`.
4
4
 
5
+ ## 2.1.0-alpha.26
6
+
7
+ - `DELETE /chats/{chat_id}` takes `scope=me|everyone` (default `everyone`, as before). `me` deletes the direct chat
8
+ only for the caller: it leaves their list, its history so far stays hidden for them, and it comes back with only
9
+ newer messages when one arrives.
10
+ - `POST /chats/{chat_id}/clear` (`ClearHistoryRequest`, `scope: me|everyone`) clears the history up to the newest
11
+ message: for the caller only, or for every member (direct chats: either user; groups: owner and admins, else
12
+ `403`).
13
+ - New server WebSocket event `history_cleared` (`before_message_id`, `scope`, `actor_id`).
14
+
5
15
  ## 2.1.0-alpha.25
6
16
 
7
17
  - Archive: `PUT` and `DELETE /chats/{chat_id}/archive` archive a chat for the caller and move it back. `Chat` gains
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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";
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.26. Do not edit. */
2
+ export declare const API_VERSION: "2.1.0-alpha.26";
3
3
  export type { paths, components, operations } from "./schema.js";
4
4
  export * from "./ws-events.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export const API_VERSION = "2.1.0-alpha.25";
1
+ export const API_VERSION = "2.1.0-alpha.26";
package/dist/openapi.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
3
  title: Messenger API
4
- version: 2.1.0-alpha.25
4
+ version: 2.1.0-alpha.26
5
5
  summary: REST contract of the Messenger backend (v2).
6
6
  description: |
7
7
  Contract for the Go backend. The WebSocket protocol is described in `websocket/` and
@@ -1089,9 +1089,20 @@ paths:
1089
1089
  operationId: deleteChat
1090
1090
  summary: Delete a direct chat
1091
1091
  description: |
1092
- Deletes the chat and its messages for both users (as v1 did); both get `chat_deleted`.
1092
+ `scope=everyone` (the default) deletes the chat and its messages for both users (as v1 did); both get
1093
+ `chat_deleted`. `scope=me` deletes it only for the caller: the chat leaves their list and its history up to
1094
+ now is hidden for them (as `POST /chats/{chat_id}/clear` with `scope: me`); only the caller's devices get
1095
+ `chat_deleted`. When a newer message arrives the chat comes back for the caller with only the newer messages.
1093
1096
  For groups use `DELETE /groups/{chat_id}` (owner) or `POST /groups/{chat_id}/leave`;
1094
1097
  a group here is `422`.
1098
+ parameters:
1099
+ - name: scope
1100
+ in: query
1101
+ required: false
1102
+ schema:
1103
+ type: string
1104
+ enum: [me, everyone]
1105
+ default: everyone
1095
1106
  responses:
1096
1107
  "426": { $ref: "#/components/responses/ClientOutdated" }
1097
1108
  "400": { $ref: "#/components/responses/BadRequest" }
@@ -1131,6 +1142,35 @@ paths:
1131
1142
  description: Unpinned
1132
1143
  "401": { $ref: "#/components/responses/Unauthorized" }
1133
1144
  "404": { $ref: "#/components/responses/NotFound" }
1145
+ /chats/{chat_id}/clear:
1146
+ parameters:
1147
+ - $ref: "#/components/parameters/ClientVersion"
1148
+ - $ref: "#/components/parameters/ClientApiVersion"
1149
+ - $ref: "#/components/parameters/ChatId"
1150
+ post:
1151
+ tags: [chats]
1152
+ operationId: clearChatHistory
1153
+ summary: Clear the history of a chat
1154
+ description: |
1155
+ Clears every message up to the newest one now. `scope: me` hides them only for the caller (any member).
1156
+ `scope: everyone` removes them for every member: in a direct chat either user may do it, in a group the
1157
+ owner and admins (`403` for others). The chat itself stays. The caller's devices (`me`) or every member's
1158
+ (`everyone`) get `history_cleared`; messages up to `before_message_id` are no longer listed, counted as
1159
+ unread, found by search or shown as media.
1160
+ requestBody:
1161
+ required: true
1162
+ content:
1163
+ application/json:
1164
+ schema: { $ref: "#/components/schemas/ClearHistoryRequest" }
1165
+ responses:
1166
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1167
+ "400": { $ref: "#/components/responses/BadRequest" }
1168
+ "204":
1169
+ description: Cleared
1170
+ "401": { $ref: "#/components/responses/Unauthorized" }
1171
+ "403": { $ref: "#/components/responses/Forbidden" }
1172
+ "404": { $ref: "#/components/responses/NotFound" }
1173
+ "422": { $ref: "#/components/responses/ValidationFailed" }
1134
1174
  /chats/{chat_id}/archive:
1135
1175
  parameters:
1136
1176
  - $ref: "#/components/parameters/ClientVersion"
@@ -5607,6 +5647,13 @@ components:
5607
5647
  type: array
5608
5648
  items: { $ref: "#/components/schemas/Chat" }
5609
5649
  next_cursor: { $ref: "#/components/schemas/Cursor" }
5650
+ ClearHistoryRequest:
5651
+ type: object
5652
+ required: [scope]
5653
+ properties:
5654
+ scope:
5655
+ type: string
5656
+ enum: [me, everyone]
5610
5657
  PinOrderRequest:
5611
5658
  type: object
5612
5659
  required: [chat_ids]
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.25. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.26. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -855,7 +855,10 @@ export interface paths {
855
855
  post?: never;
856
856
  /**
857
857
  * Delete a direct chat
858
- * @description Deletes the chat and its messages for both users (as v1 did); both get `chat_deleted`.
858
+ * @description `scope=everyone` (the default) deletes the chat and its messages for both users (as v1 did); both get
859
+ * `chat_deleted`. `scope=me` deletes it only for the caller: the chat leaves their list and its history up to
860
+ * now is hidden for them (as `POST /chats/{chat_id}/clear` with `scope: me`); only the caller's devices get
861
+ * `chat_deleted`. When a newer message arrives the chat comes back for the caller with only the newer messages.
859
862
  * For groups use `DELETE /groups/{chat_id}` (owner) or `POST /groups/{chat_id}/leave`;
860
863
  * a group here is `422`.
861
864
  */
@@ -894,6 +897,37 @@ export interface paths {
894
897
  patch?: never;
895
898
  trace?: never;
896
899
  };
900
+ "/chats/{chat_id}/clear": {
901
+ parameters: {
902
+ query?: never;
903
+ header?: {
904
+ /** @description Version of the client app, for logs and the per-client metric. */
905
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
906
+ /** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
907
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
908
+ };
909
+ path: {
910
+ chat_id: components["parameters"]["ChatId"];
911
+ };
912
+ cookie?: never;
913
+ };
914
+ get?: never;
915
+ put?: never;
916
+ /**
917
+ * Clear the history of a chat
918
+ * @description Clears every message up to the newest one now. `scope: me` hides them only for the caller (any member).
919
+ * `scope: everyone` removes them for every member: in a direct chat either user may do it, in a group the
920
+ * owner and admins (`403` for others). The chat itself stays. The caller's devices (`me`) or every member's
921
+ * (`everyone`) get `history_cleared`; messages up to `before_message_id` are no longer listed, counted as
922
+ * unread, found by search or shown as media.
923
+ */
924
+ post: operations["clearChatHistory"];
925
+ delete?: never;
926
+ options?: never;
927
+ head?: never;
928
+ patch?: never;
929
+ trace?: never;
930
+ };
897
931
  "/chats/{chat_id}/archive": {
898
932
  parameters: {
899
933
  query?: never;
@@ -3606,6 +3640,10 @@ export interface components {
3606
3640
  items: components["schemas"]["Chat"][];
3607
3641
  next_cursor: components["schemas"]["Cursor"];
3608
3642
  };
3643
+ ClearHistoryRequest: {
3644
+ /** @enum {string} */
3645
+ scope: "me" | "everyone";
3646
+ };
3609
3647
  PinOrderRequest: {
3610
3648
  chat_ids: components["schemas"]["Id"][];
3611
3649
  };
@@ -5564,7 +5602,9 @@ export interface operations {
5564
5602
  };
5565
5603
  deleteChat: {
5566
5604
  parameters: {
5567
- query?: never;
5605
+ query?: {
5606
+ scope?: "me" | "everyone";
5607
+ };
5568
5608
  header?: {
5569
5609
  /** @description Version of the client app, for logs and the per-client metric. */
5570
5610
  "X-Client-Version"?: components["parameters"]["ClientVersion"];
@@ -5651,6 +5691,41 @@ export interface operations {
5651
5691
  426: components["responses"]["ClientOutdated"];
5652
5692
  };
5653
5693
  };
5694
+ clearChatHistory: {
5695
+ parameters: {
5696
+ query?: never;
5697
+ header?: {
5698
+ /** @description Version of the client app, for logs and the per-client metric. */
5699
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
5700
+ /** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
5701
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
5702
+ };
5703
+ path: {
5704
+ chat_id: components["parameters"]["ChatId"];
5705
+ };
5706
+ cookie?: never;
5707
+ };
5708
+ requestBody: {
5709
+ content: {
5710
+ "application/json": components["schemas"]["ClearHistoryRequest"];
5711
+ };
5712
+ };
5713
+ responses: {
5714
+ /** @description Cleared */
5715
+ 204: {
5716
+ headers: {
5717
+ [name: string]: unknown;
5718
+ };
5719
+ content?: never;
5720
+ };
5721
+ 400: components["responses"]["BadRequest"];
5722
+ 401: components["responses"]["Unauthorized"];
5723
+ 403: components["responses"]["Forbidden"];
5724
+ 404: components["responses"]["NotFound"];
5725
+ 422: components["responses"]["ValidationFailed"];
5726
+ 426: components["responses"]["ClientOutdated"];
5727
+ };
5728
+ };
5654
5729
  archiveChat: {
5655
5730
  parameters: {
5656
5731
  query?: never;
package/dist/ws-docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "markdown": "# WebSocket protocol (API contract v2)\r\n\r\nThe JSON Schemas in `websocket/client/` (client → server) and `websocket/server/` (server → client) are the source of truth. Every event has an example in `websocket/examples/`, validated against its schema by `npm run check`. TypeScript types are generated into `dist/ws-events.d.ts` (`ClientEvent`, `ServerEvent`).\r\n\r\n## Connecting\r\n\r\n1. `POST /api/v2/ws/ticket` (authenticated) returns `{ \"ticket\": \"…\", \"expires_in\": 30 }`. The ticket is single-use and short-lived, so no access token ends up in a URL or a log.\r\n2. Open **one connection per browser tab**: `wss://<host>/api/v2/ws?ticket=<ticket>&api_version=<contract version>`. The connection carries the events of all chats of the user. `api_version` is optional and takes the place of the `X-Client-Api-Version` header, which browsers cannot send on a WebSocket.\r\n3. The first server event is `hello` with `api_version` and `min_client_api_version`. A client that reconnects after a deploy compares them with the contract version it was built for and shows an upgrade notice instead of failing at random.\r\n4. When the ticket is invalid or expired the server closes the connection with code `4401`. A client whose `api_version` is no longer served is closed with `4426` after `hello`.\r\n\r\n## Close codes\r\n\r\n| Code | Meaning | Client |\r\n| --- | --- | --- |\r\n| `1012` | `reconnect`: the server is restarting, or it lost its pub/sub connection and events may be missing | reconnect with backoff, then load what was missed (`after` cursor) |\r\n| `1013` | the client did not keep up with its events, or sent more than 64 events that are not handled yet | reconnect, then catch up |\r\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\r\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\r\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\r\n\r\n## Envelope\r\n\r\nServer → client:\r\n\r\n```json\r\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\r\n```\r\n\r\nClient → server:\r\n\r\n```json\r\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\r\n```\r\n\r\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\r\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\r\n- `chat_id` is always `null` in `hello`, `presence` and `approval_request_created`, which do not belong to a chat. `ack` and `error` repeat the `chat_id` of the client event they answer, and it is `null` for connection-level errors.\r\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\r\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\r\n\r\n## Acknowledgements\r\n\r\nEvery client event except `typing` (which is not acknowledged and carries no `client_temp_id`) has a `client_temp_id` (1–64 characters, unique per client). The server answers with exactly one of:\r\n\r\n- `ack` — `client_temp_id`, and for `message` the stored `message_id` and `created_at`. Sending the same `client_temp_id` again returns the same `ack` (idempotent), which makes retries after a reconnect safe.\r\n- `error` — `client_temp_id` and `data.code`/`data.message`. `code` is one of the stable codes of `ErrorCode` in `openapi.yaml` (the same codes as the REST `application/problem+json` errors).\r\n\r\nThe sender also receives the broadcast `message` event with the stored message (its `client_temp_id` is included, so the client can replace its pending copy).\r\n\r\n## Client → server events\r\n\r\n| Type | Purpose |\r\n| --- | --- |\r\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\r\n| `resend` | Deliver a stored but undelivered message again |\r\n| `edit` | Edit your own text message |\r\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\r\n| `read` | Mark messages as read up to `message_id` |\r\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\r\n| `typing` | Typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`, not acknowledged). Repeat `is_typing: true` every 3 s while it lasts, send `false` when it ends |\r\n\r\n## Server → client events\r\n\r\n| Type | Meaning |\r\n| --- | --- |\r\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\r\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\r\n| `message`, `edit`, `delete` | Message created, edited or deleted |\r\n| `reaction_add`, `reaction_remove` | Reactions changed |\r\n| `read` | A user read up to `message_id` |\r\n| `typing` | A user is typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`); hide it after 6 s without a repeat |\r\n| `chat_created`, `chat_deleted`, `chat_list_update` | Chat list changes |\r\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\r\n| `approval_request_created` | New request in the inbox |\r\n| `presence` | A user came online or went offline |\n| `call_updated` | A call of the chat changed (state, participants, epoch); carries the whole call, keep the highest `version` |\n| `call_keys` | Sealed call sender keys for this session only (`docs/calls-e2ee.md`) |\r\n\r\n## Compatibility\r\n\r\nAdding an event type or an optional field is a MINOR change; removing or renaming an event or field, or making a field required, is MAJOR (see `docs/api-compatibility.md`). Clients must ignore unknown events and unknown fields.\r\n",
2
+ "markdown": "# WebSocket protocol (API contract v2)\r\n\r\nThe JSON Schemas in `websocket/client/` (client → server) and `websocket/server/` (server → client) are the source of truth. Every event has an example in `websocket/examples/`, validated against its schema by `npm run check`. TypeScript types are generated into `dist/ws-events.d.ts` (`ClientEvent`, `ServerEvent`).\r\n\r\n## Connecting\r\n\r\n1. `POST /api/v2/ws/ticket` (authenticated) returns `{ \"ticket\": \"…\", \"expires_in\": 30 }`. The ticket is single-use and short-lived, so no access token ends up in a URL or a log.\r\n2. Open **one connection per browser tab**: `wss://<host>/api/v2/ws?ticket=<ticket>&api_version=<contract version>`. The connection carries the events of all chats of the user. `api_version` is optional and takes the place of the `X-Client-Api-Version` header, which browsers cannot send on a WebSocket.\r\n3. The first server event is `hello` with `api_version` and `min_client_api_version`. A client that reconnects after a deploy compares them with the contract version it was built for and shows an upgrade notice instead of failing at random.\r\n4. When the ticket is invalid or expired the server closes the connection with code `4401`. A client whose `api_version` is no longer served is closed with `4426` after `hello`.\r\n\r\n## Close codes\r\n\r\n| Code | Meaning | Client |\r\n| --- | --- | --- |\r\n| `1012` | `reconnect`: the server is restarting, or it lost its pub/sub connection and events may be missing | reconnect with backoff, then load what was missed (`after` cursor) |\r\n| `1013` | the client did not keep up with its events, or sent more than 64 events that are not handled yet | reconnect, then catch up |\r\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\r\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\r\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\r\n\r\n## Envelope\r\n\r\nServer → client:\r\n\r\n```json\r\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\r\n```\r\n\r\nClient → server:\r\n\r\n```json\r\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\r\n```\r\n\r\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\r\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\r\n- `chat_id` is always `null` in `hello`, `presence` and `approval_request_created`, which do not belong to a chat. `ack` and `error` repeat the `chat_id` of the client event they answer, and it is `null` for connection-level errors.\r\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\r\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\r\n\r\n## Acknowledgements\r\n\r\nEvery client event except `typing` (which is not acknowledged and carries no `client_temp_id`) has a `client_temp_id` (1–64 characters, unique per client). The server answers with exactly one of:\r\n\r\n- `ack` — `client_temp_id`, and for `message` the stored `message_id` and `created_at`. Sending the same `client_temp_id` again returns the same `ack` (idempotent), which makes retries after a reconnect safe.\r\n- `error` — `client_temp_id` and `data.code`/`data.message`. `code` is one of the stable codes of `ErrorCode` in `openapi.yaml` (the same codes as the REST `application/problem+json` errors).\r\n\r\nThe sender also receives the broadcast `message` event with the stored message (its `client_temp_id` is included, so the client can replace its pending copy).\r\n\r\n## Client → server events\r\n\r\n| Type | Purpose |\r\n| --- | --- |\r\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\r\n| `resend` | Deliver a stored but undelivered message again |\r\n| `edit` | Edit your own text message |\r\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\r\n| `read` | Mark messages as read up to `message_id` |\r\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\r\n| `typing` | Typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`, not acknowledged). Repeat `is_typing: true` every 3 s while it lasts, send `false` when it ends |\r\n\r\n## Server → client events\r\n\r\n| Type | Meaning |\r\n| --- | --- |\r\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\r\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\r\n| `message`, `edit`, `delete` | Message created, edited or deleted |\r\n| `reaction_add`, `reaction_remove` | Reactions changed |\r\n| `read` | A user read up to `message_id` |\r\n| `typing` | A user is typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`); hide it after 6 s without a repeat |\r\n| `chat_created`, `chat_deleted`, `chat_list_update` | Chat list changes |\n| `history_cleared` | Messages up to `before_message_id` were cleared for you (`scope: me`) or everyone |\r\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\r\n| `approval_request_created` | New request in the inbox |\r\n| `presence` | A user came online or went offline |\n| `call_updated` | A call of the chat changed (state, participants, epoch); carries the whole call, keep the highest `version` |\n| `call_keys` | Sealed call sender keys for this session only (`docs/calls-e2ee.md`) |\r\n\r\n## Compatibility\r\n\r\nAdding an event type or an optional field is a MINOR change; removing or renaming an event or field, or making a field required, is MAJOR (see `docs/api-compatibility.md`). Clients must ignore unknown events and unknown fields.\r\n",
3
3
  "examples": {
4
4
  "client/delete.json": {
5
5
  "type": "delete",
@@ -412,6 +412,16 @@
412
412
  "user_id": "1001"
413
413
  }
414
414
  },
415
+ "server/history_cleared.json": {
416
+ "type": "history_cleared",
417
+ "event_id": "7217400317439950011",
418
+ "chat_id": "42",
419
+ "data": {
420
+ "before_message_id": "7217400317439950002",
421
+ "scope": "everyone",
422
+ "actor_id": "7"
423
+ }
424
+ },
415
425
  "server/message.json": {
416
426
  "type": "message",
417
427
  "event_id": "7217400317439950009",
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.25. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.26. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -45,6 +45,7 @@ export type ServerEvent =
45
45
  | ServerGroupCreatedEvent
46
46
  | ServerGroupUpdatedEvent
47
47
  | ServerHelloEvent
48
+ | ServerHistoryClearedEvent
48
49
  | ServerMessageEvent
49
50
  | ServerPresenceEvent
50
51
  | ServerReactionAddEvent
@@ -754,6 +755,19 @@ export interface ServerHelloEvent {
754
755
  user_id: Id;
755
756
  };
756
757
  }
758
+ /**
759
+ * Messages of the chat up to before_message_id were cleared, for you (scope me) or for every member (scope everyone). Drop them from what you show.
760
+ */
761
+ export interface ServerHistoryClearedEvent {
762
+ type: "history_cleared";
763
+ event_id: Id;
764
+ chat_id: Id;
765
+ data: {
766
+ before_message_id: Id;
767
+ scope: "me" | "everyone";
768
+ actor_id: Id;
769
+ };
770
+ }
757
771
  /**
758
772
  * A new message in a chat.
759
773
  */
@@ -2650,6 +2650,21 @@
2650
2650
  }
2651
2651
  }
2652
2652
  },
2653
+ "ClearHistoryRequest": {
2654
+ "type": "object",
2655
+ "required": [
2656
+ "scope"
2657
+ ],
2658
+ "properties": {
2659
+ "scope": {
2660
+ "type": "string",
2661
+ "enum": [
2662
+ "me",
2663
+ "everyone"
2664
+ ]
2665
+ }
2666
+ }
2667
+ },
2653
2668
  "PinOrderRequest": {
2654
2669
  "type": "object",
2655
2670
  "required": [
@@ -4758,6 +4773,51 @@
4758
4773
  "data"
4759
4774
  ]
4760
4775
  },
4776
+ "ServerHistoryClearedEvent": {
4777
+ "title": "ServerHistoryClearedEvent",
4778
+ "description": "Messages of the chat up to before_message_id were cleared, for you (scope me) or for every member (scope everyone). Drop them from what you show.",
4779
+ "type": "object",
4780
+ "properties": {
4781
+ "type": {
4782
+ "const": "history_cleared"
4783
+ },
4784
+ "event_id": {
4785
+ "$ref": "#/$defs/Id"
4786
+ },
4787
+ "chat_id": {
4788
+ "$ref": "#/$defs/Id"
4789
+ },
4790
+ "data": {
4791
+ "type": "object",
4792
+ "properties": {
4793
+ "before_message_id": {
4794
+ "$ref": "#/$defs/Id"
4795
+ },
4796
+ "scope": {
4797
+ "type": "string",
4798
+ "enum": [
4799
+ "me",
4800
+ "everyone"
4801
+ ]
4802
+ },
4803
+ "actor_id": {
4804
+ "$ref": "#/$defs/Id"
4805
+ }
4806
+ },
4807
+ "required": [
4808
+ "before_message_id",
4809
+ "scope",
4810
+ "actor_id"
4811
+ ]
4812
+ }
4813
+ },
4814
+ "required": [
4815
+ "type",
4816
+ "event_id",
4817
+ "chat_id",
4818
+ "data"
4819
+ ]
4820
+ },
4761
4821
  "ServerMessageEvent": {
4762
4822
  "title": "ServerMessageEvent",
4763
4823
  "description": "A new message in a chat.",
@@ -5239,6 +5299,9 @@
5239
5299
  {
5240
5300
  "$ref": "#/$defs/ServerHelloEvent"
5241
5301
  },
5302
+ {
5303
+ "$ref": "#/$defs/ServerHistoryClearedEvent"
5304
+ },
5242
5305
  {
5243
5306
  "$ref": "#/$defs/ServerMessageEvent"
5244
5307
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.1.0-alpha.25.next.107",
3
+ "version": "2.1.0-alpha.26.next.108",
4
4
  "description": "API contract of the Messenger backend: OpenAPI document, WebSocket event schemas and generated TypeScript types",
5
5
  "license": "MIT",
6
6
  "repository": {