@myronsi/messenger-api 2.1.0-alpha.22 → 2.1.0-alpha.23

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,15 @@
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.23
6
+
7
+ - `MediaKind` gains `file`: `GET /chats/{chat_id}/media?kind=file` lists messages with file attachments (documents,
8
+ archives and other files that are not images, videos, audio or voice messages), newest first.
9
+ - Rejected sends are kept for the sender: a send refused with `forbidden`, `blocked_by_user`, `rate_limited` or
10
+ `internal_error` is listed by `GET /chats/{chat_id}/unsent` (`UnsentMessage`, oldest first) on all of the sender's
11
+ devices until a send with the same `client_temp_id` succeeds or `DELETE /chats/{chat_id}/unsent/{client_temp_id}`
12
+ discards it.
13
+
5
14
  ## 2.1.0-alpha.22
6
15
 
7
16
  - `Chat` gains the required, nullable `first_unread_message_id` (the oldest message the caller has not read, `null`
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.22. Do not edit. */
2
- export declare const API_VERSION: "2.1.0-alpha.22";
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";
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.22";
1
+ export const API_VERSION = "2.1.0-alpha.23";
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.22
4
+ version: 2.1.0-alpha.23
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
@@ -1219,6 +1219,55 @@ paths:
1219
1219
  "404": { $ref: "#/components/responses/NotFound" }
1220
1220
  "422": { $ref: "#/components/responses/ValidationFailed" }
1221
1221
  "429": { $ref: "#/components/responses/TooManyRequests" }
1222
+ /chats/{chat_id}/unsent:
1223
+ parameters:
1224
+ - $ref: "#/components/parameters/ClientVersion"
1225
+ - $ref: "#/components/parameters/ClientApiVersion"
1226
+ - $ref: "#/components/parameters/ChatId"
1227
+ get:
1228
+ tags: [chats]
1229
+ operationId: listUnsentMessages
1230
+ summary: The caller's rejected sends of a chat
1231
+ description: |
1232
+ Sends the server rejected for a reason that may pass later (`forbidden`, `blocked_by_user`, `rate_limited`,
1233
+ `internal_error`), oldest first. They belong to the caller and are shown on all of the caller's devices.
1234
+ A later send with the same `client_temp_id` that succeeds removes the entry; at most 500 are kept per user.
1235
+ responses:
1236
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1237
+ "400": { $ref: "#/components/responses/BadRequest" }
1238
+ "200":
1239
+ description: Kept sends
1240
+ content:
1241
+ application/json:
1242
+ schema:
1243
+ type: object
1244
+ required: [items]
1245
+ properties:
1246
+ items:
1247
+ type: array
1248
+ items: { $ref: "#/components/schemas/UnsentMessage" }
1249
+ "401": { $ref: "#/components/responses/Unauthorized" }
1250
+ "404": { $ref: "#/components/responses/NotFound" }
1251
+ /chats/{chat_id}/unsent/{client_temp_id}:
1252
+ parameters:
1253
+ - $ref: "#/components/parameters/ClientVersion"
1254
+ - $ref: "#/components/parameters/ClientApiVersion"
1255
+ - $ref: "#/components/parameters/ChatId"
1256
+ - name: client_temp_id
1257
+ in: path
1258
+ required: true
1259
+ schema: { $ref: "#/components/schemas/ClientTempId" }
1260
+ delete:
1261
+ tags: [chats]
1262
+ operationId: deleteUnsentMessage
1263
+ summary: Discard a rejected send
1264
+ responses:
1265
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1266
+ "400": { $ref: "#/components/responses/BadRequest" }
1267
+ "204":
1268
+ description: Discarded
1269
+ "401": { $ref: "#/components/responses/Unauthorized" }
1270
+ "404": { $ref: "#/components/responses/NotFound" }
1222
1271
  /chats/{chat_id}/messages/search:
1223
1272
  parameters:
1224
1273
  - $ref: "#/components/parameters/ClientVersion"
@@ -1255,7 +1304,7 @@ paths:
1255
1304
  get:
1256
1305
  tags: [chats]
1257
1306
  operationId: listChatMedia
1258
- summary: Photos, videos or audio of a chat
1307
+ summary: Photos, videos, audio or files of a chat
1259
1308
  description: Replaces `GET /messages/photos/{chat_id}` and `GET /messages/audios/{chat_id}`.
1260
1309
  parameters:
1261
1310
  - name: kind
@@ -4923,7 +4972,8 @@ components:
4923
4972
  drawing: { $ref: "#/components/schemas/Drawing" }
4924
4973
  MediaKind:
4925
4974
  type: string
4926
- enum: [image, audio, visual]
4975
+ description: "`image` photos, `visual` photos and videos, `audio` audio files and voice messages, `file` other files (documents, archives)."
4976
+ enum: [image, audio, visual, file]
4927
4977
 
4928
4978
  # -------------------------------------------------------- messages
4929
4979
  MessageType:
@@ -5228,6 +5278,28 @@ components:
5228
5278
  wrapped in U+E000 (start) and U+E001 (end), characters of the Unicode private use area,
5229
5279
  so a client can mark them without parsing markup. `null` when the message matched without
5230
5280
  an excerpt.
5281
+ UnsentMessage:
5282
+ type: object
5283
+ description: A send the server rejected for a reason that may pass later. Resend it with the same `client_temp_id`.
5284
+ required: [chat_id, client_temp_id, type, content, reply_to, attachments, error_code, created_at]
5285
+ properties:
5286
+ chat_id: { $ref: "#/components/schemas/Id" }
5287
+ client_temp_id: { $ref: "#/components/schemas/ClientTempId" }
5288
+ type:
5289
+ type: string
5290
+ enum: [text, file, voice, sticker]
5291
+ content: { type: [string, "null"] }
5292
+ reply_to:
5293
+ oneOf:
5294
+ - { $ref: "#/components/schemas/Id" }
5295
+ - { type: "null" }
5296
+ attachments:
5297
+ type: array
5298
+ description: Uploaded files of the send that still exist, in the order they were sent.
5299
+ items: { $ref: "#/components/schemas/Attachment" }
5300
+ sticker: { $ref: "#/components/schemas/Sticker" }
5301
+ error_code: { $ref: "#/components/schemas/ErrorCode" }
5302
+ created_at: { $ref: "#/components/schemas/Timestamp" }
5231
5303
  MessageSearchPage:
5232
5304
  type: object
5233
5305
  required: [items, next_cursor]
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.22. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.23. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -952,6 +952,60 @@ export interface paths {
952
952
  patch?: never;
953
953
  trace?: never;
954
954
  };
955
+ "/chats/{chat_id}/unsent": {
956
+ parameters: {
957
+ query?: never;
958
+ header?: {
959
+ /** @description Version of the client app, for logs and the per-client metric. */
960
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
961
+ /** @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`). */
962
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
963
+ };
964
+ path: {
965
+ chat_id: components["parameters"]["ChatId"];
966
+ };
967
+ cookie?: never;
968
+ };
969
+ /**
970
+ * The caller's rejected sends of a chat
971
+ * @description Sends the server rejected for a reason that may pass later (`forbidden`, `blocked_by_user`, `rate_limited`,
972
+ * `internal_error`), oldest first. They belong to the caller and are shown on all of the caller's devices.
973
+ * A later send with the same `client_temp_id` that succeeds removes the entry; at most 500 are kept per user.
974
+ */
975
+ get: operations["listUnsentMessages"];
976
+ put?: never;
977
+ post?: never;
978
+ delete?: never;
979
+ options?: never;
980
+ head?: never;
981
+ patch?: never;
982
+ trace?: never;
983
+ };
984
+ "/chats/{chat_id}/unsent/{client_temp_id}": {
985
+ parameters: {
986
+ query?: never;
987
+ header?: {
988
+ /** @description Version of the client app, for logs and the per-client metric. */
989
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
990
+ /** @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`). */
991
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
992
+ };
993
+ path: {
994
+ chat_id: components["parameters"]["ChatId"];
995
+ client_temp_id: components["schemas"]["ClientTempId"];
996
+ };
997
+ cookie?: never;
998
+ };
999
+ get?: never;
1000
+ put?: never;
1001
+ post?: never;
1002
+ /** Discard a rejected send */
1003
+ delete: operations["deleteUnsentMessage"];
1004
+ options?: never;
1005
+ head?: never;
1006
+ patch?: never;
1007
+ trace?: never;
1008
+ };
955
1009
  "/chats/{chat_id}/messages/search": {
956
1010
  parameters: {
957
1011
  query?: never;
@@ -991,7 +1045,7 @@ export interface paths {
991
1045
  cookie?: never;
992
1046
  };
993
1047
  /**
994
- * Photos, videos or audio of a chat
1048
+ * Photos, videos, audio or files of a chat
995
1049
  * @description Replaces `GET /messages/photos/{chat_id}` and `GET /messages/audios/{chat_id}`.
996
1050
  */
997
1051
  get: operations["listChatMedia"];
@@ -3204,8 +3258,11 @@ export interface components {
3204
3258
  attachment_id: components["schemas"]["AttachmentRef"];
3205
3259
  drawing: components["schemas"]["Drawing"];
3206
3260
  };
3207
- /** @enum {string} */
3208
- MediaKind: "image" | "audio" | "visual";
3261
+ /**
3262
+ * @description `image` photos, `visual` photos and videos, `audio` audio files and voice messages, `file` other files (documents, archives).
3263
+ * @enum {string}
3264
+ */
3265
+ MediaKind: "image" | "audio" | "visual" | "file";
3209
3266
  /** @enum {string} */
3210
3267
  MessageType: "text" | "file" | "voice" | "system" | "sticker";
3211
3268
  /**
@@ -3374,6 +3431,20 @@ export interface components {
3374
3431
  */
3375
3432
  highlight?: string | null;
3376
3433
  };
3434
+ /** @description A send the server rejected for a reason that may pass later. Resend it with the same `client_temp_id`. */
3435
+ UnsentMessage: {
3436
+ chat_id: components["schemas"]["Id"];
3437
+ client_temp_id: components["schemas"]["ClientTempId"];
3438
+ /** @enum {string} */
3439
+ type: "text" | "file" | "voice" | "sticker";
3440
+ content: string | null;
3441
+ reply_to: components["schemas"]["Id"] | null;
3442
+ /** @description Uploaded files of the send that still exist, in the order they were sent. */
3443
+ attachments: components["schemas"]["Attachment"][];
3444
+ sticker?: components["schemas"]["Sticker"];
3445
+ error_code: components["schemas"]["ErrorCode"];
3446
+ created_at: components["schemas"]["Timestamp"];
3447
+ };
3377
3448
  MessageSearchPage: {
3378
3449
  items: components["schemas"]["SearchHit"][];
3379
3450
  next_cursor: components["schemas"]["Cursor"];
@@ -5633,6 +5704,69 @@ export interface operations {
5633
5704
  429: components["responses"]["TooManyRequests"];
5634
5705
  };
5635
5706
  };
5707
+ listUnsentMessages: {
5708
+ parameters: {
5709
+ query?: never;
5710
+ header?: {
5711
+ /** @description Version of the client app, for logs and the per-client metric. */
5712
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
5713
+ /** @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`). */
5714
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
5715
+ };
5716
+ path: {
5717
+ chat_id: components["parameters"]["ChatId"];
5718
+ };
5719
+ cookie?: never;
5720
+ };
5721
+ requestBody?: never;
5722
+ responses: {
5723
+ /** @description Kept sends */
5724
+ 200: {
5725
+ headers: {
5726
+ [name: string]: unknown;
5727
+ };
5728
+ content: {
5729
+ "application/json": {
5730
+ items: components["schemas"]["UnsentMessage"][];
5731
+ };
5732
+ };
5733
+ };
5734
+ 400: components["responses"]["BadRequest"];
5735
+ 401: components["responses"]["Unauthorized"];
5736
+ 404: components["responses"]["NotFound"];
5737
+ 426: components["responses"]["ClientOutdated"];
5738
+ };
5739
+ };
5740
+ deleteUnsentMessage: {
5741
+ parameters: {
5742
+ query?: never;
5743
+ header?: {
5744
+ /** @description Version of the client app, for logs and the per-client metric. */
5745
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
5746
+ /** @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`). */
5747
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
5748
+ };
5749
+ path: {
5750
+ chat_id: components["parameters"]["ChatId"];
5751
+ client_temp_id: components["schemas"]["ClientTempId"];
5752
+ };
5753
+ cookie?: never;
5754
+ };
5755
+ requestBody?: never;
5756
+ responses: {
5757
+ /** @description Discarded */
5758
+ 204: {
5759
+ headers: {
5760
+ [name: string]: unknown;
5761
+ };
5762
+ content?: never;
5763
+ };
5764
+ 400: components["responses"]["BadRequest"];
5765
+ 401: components["responses"]["Unauthorized"];
5766
+ 404: components["responses"]["NotFound"];
5767
+ 426: components["responses"]["ClientOutdated"];
5768
+ };
5769
+ };
5636
5770
  searchMessages: {
5637
5771
  parameters: {
5638
5772
  query: {
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.22. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.23. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -1425,10 +1425,12 @@
1425
1425
  },
1426
1426
  "MediaKind": {
1427
1427
  "type": "string",
1428
+ "description": "`image` photos, `visual` photos and videos, `audio` audio files and voice messages, `file` other files (documents, archives).",
1428
1429
  "enum": [
1429
1430
  "image",
1430
1431
  "audio",
1431
- "visual"
1432
+ "visual",
1433
+ "file"
1432
1434
  ]
1433
1435
  },
1434
1436
  "MessageType": {
@@ -2085,6 +2087,69 @@
2085
2087
  }
2086
2088
  }
2087
2089
  },
2090
+ "UnsentMessage": {
2091
+ "type": "object",
2092
+ "description": "A send the server rejected for a reason that may pass later. Resend it with the same `client_temp_id`.",
2093
+ "required": [
2094
+ "chat_id",
2095
+ "client_temp_id",
2096
+ "type",
2097
+ "content",
2098
+ "reply_to",
2099
+ "attachments",
2100
+ "error_code",
2101
+ "created_at"
2102
+ ],
2103
+ "properties": {
2104
+ "chat_id": {
2105
+ "$ref": "#/$defs/Id"
2106
+ },
2107
+ "client_temp_id": {
2108
+ "$ref": "#/$defs/ClientTempId"
2109
+ },
2110
+ "type": {
2111
+ "type": "string",
2112
+ "enum": [
2113
+ "text",
2114
+ "file",
2115
+ "voice",
2116
+ "sticker"
2117
+ ]
2118
+ },
2119
+ "content": {
2120
+ "type": [
2121
+ "string",
2122
+ "null"
2123
+ ]
2124
+ },
2125
+ "reply_to": {
2126
+ "oneOf": [
2127
+ {
2128
+ "$ref": "#/$defs/Id"
2129
+ },
2130
+ {
2131
+ "type": "null"
2132
+ }
2133
+ ]
2134
+ },
2135
+ "attachments": {
2136
+ "type": "array",
2137
+ "description": "Uploaded files of the send that still exist, in the order they were sent.",
2138
+ "items": {
2139
+ "$ref": "#/$defs/Attachment"
2140
+ }
2141
+ },
2142
+ "sticker": {
2143
+ "$ref": "#/$defs/Sticker"
2144
+ },
2145
+ "error_code": {
2146
+ "$ref": "#/$defs/ErrorCode"
2147
+ },
2148
+ "created_at": {
2149
+ "$ref": "#/$defs/Timestamp"
2150
+ }
2151
+ }
2152
+ },
2088
2153
  "MessageSearchPage": {
2089
2154
  "type": "object",
2090
2155
  "required": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.1.0-alpha.22",
3
+ "version": "2.1.0-alpha.23",
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": {