@myronsi/messenger-api 2.0.0-alpha.3.next.42 → 2.0.0-alpha.5.next.46

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.0.0-alpha.5
6
+
7
+ Chats, found while implementing the chat list:
8
+
9
+ - `DELETE /chats/{chat_id}` deletes a direct chat for both users (as v1 did), not "for yourself"; a group is `422`.
10
+ - `POST /chats` can answer `422` (a chat with yourself, a too long `initial_message`).
11
+ - `PUT /chats/{chat_id}/pin`: at most 10 pinned chats (`409`).
12
+ - `GET /chats` documents its order, what `last_message` and its `read_by` hold, and that `unread_count` stops at 999.
13
+ - `DELETE /me` can answer `429` (repeated wrong passwords).
14
+
15
+ ## 2.0.0-alpha.4
16
+
17
+ Media, found while implementing uploads:
18
+
19
+ - Attachment IDs are UUIDs (`AttachmentRef`, `format: uuid`) instead of decimal IDs: `Attachment.id`, the `attachment_id` path parameter, `attachment_id` of `SendMessageRequest`, `SetAvatarRequest` and the WebSocket `message` event.
20
+ - `GET /attachments/{attachment_id}/content` takes `variant=thumbnail`, may answer `302` to a signed URL, and documents its `Content-Disposition` rules.
21
+ - `GET /users/{user_id}/avatar` takes `version` (an `AvatarVersion.id`), which `AvatarVersion.url` points to.
22
+
5
23
  ## 2.0.0-alpha.3
6
24
 
7
25
  WebSocket details found while implementing the gateway (documentation of `websocket.md` only):
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.0.0-alpha.3. Do not edit. */
2
- export declare const API_VERSION: "2.0.0-alpha.3";
1
+ /* Generated from api/openapi.yaml 2.0.0-alpha.5. Do not edit. */
2
+ export declare const API_VERSION: "2.0.0-alpha.5";
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.0.0-alpha.3";
1
+ export const API_VERSION = "2.0.0-alpha.5";
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.0.0-alpha.3
4
+ version: 2.0.0-alpha.5
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
@@ -324,6 +324,7 @@ paths:
324
324
  description: Account deleted
325
325
  "401": { $ref: "#/components/responses/Unauthorized" }
326
326
  "403": { $ref: "#/components/responses/Forbidden" }
327
+ "429": { $ref: "#/components/responses/TooManyRequests" }
327
328
  /me/avatar:
328
329
  parameters:
329
330
  - $ref: "#/components/parameters/ClientVersion"
@@ -727,7 +728,14 @@ paths:
727
728
  tags: [users]
728
729
  operationId: getUserAvatar
729
730
  summary: Current avatar image
730
- description: Respects the avatar visibility of the user; falls back to the default avatar.
731
+ description: |
732
+ Respects the avatar visibility of the user; falls back to the default avatar. With `version`, an
733
+ earlier avatar of the history (`AvatarVersion.url`).
734
+ parameters:
735
+ - name: version
736
+ in: query
737
+ description: "`id` of an `AvatarVersion` of this user."
738
+ schema: { $ref: "#/components/schemas/Id" }
731
739
  responses:
732
740
  "426": { $ref: "#/components/responses/ClientOutdated" }
733
741
  "400": { $ref: "#/components/responses/BadRequest" }
@@ -843,7 +851,19 @@ paths:
843
851
  tags: [attachments]
844
852
  operationId: getAttachmentContent
845
853
  summary: Download an attachment
846
- description: Only participants of the chat the attachment was sent to (and its uploader) can download it.
854
+ description: |
855
+ Only the uploader and members of a chat in which a message using the attachment is visible to them can
856
+ download it. The answer is the file, or a `302` redirect to a short-lived signed URL of the object
857
+ storage. Images, audio and video are sent `inline`; everything else as a download
858
+ (`Content-Disposition: attachment`, `application/octet-stream`), always with
859
+ `X-Content-Type-Options: nosniff`.
860
+ parameters:
861
+ - name: variant
862
+ in: query
863
+ description: "`thumbnail`: a JPEG of at most 320 px (images only; `thumbnail_url` of the attachment)."
864
+ schema:
865
+ type: string
866
+ enum: [thumbnail]
847
867
  responses:
848
868
  "426": { $ref: "#/components/responses/ClientOutdated" }
849
869
  "400": { $ref: "#/components/responses/BadRequest" }
@@ -865,7 +885,12 @@ paths:
865
885
  tags: [chats]
866
886
  operationId: listChats
867
887
  summary: My chats with last message and unread count
868
- description: One request replaces `GET /chats/list/{username}` and `GET /groups/list/{username}`; pinned chats come first.
888
+ description: |
889
+ One request replaces `GET /chats/list/{username}` and `GET /groups/list/{username}`.
890
+ Pinned chats come first (most recently pinned first), then the others by their last
891
+ message (newest first). `last_message` is the newest message the caller can see; in
892
+ direct chats its `read_by` holds the other user once they read it (with read receipts
893
+ on), in groups it is empty. `unread_count` stops at 999.
869
894
  parameters:
870
895
  - $ref: "#/components/parameters/Limit"
871
896
  - $ref: "#/components/parameters/After"
@@ -912,6 +937,7 @@ paths:
912
937
  "401": { $ref: "#/components/responses/Unauthorized" }
913
938
  "403": { $ref: "#/components/responses/Forbidden" }
914
939
  "404": { $ref: "#/components/responses/NotFound" }
940
+ "422": { $ref: "#/components/responses/ValidationFailed" }
915
941
  "429": { $ref: "#/components/responses/TooManyRequests" }
916
942
  /chats/{chat_id}:
917
943
  parameters:
@@ -935,8 +961,11 @@ paths:
935
961
  delete:
936
962
  tags: [chats]
937
963
  operationId: deleteChat
938
- summary: Delete a direct chat for yourself
939
- description: For groups use `DELETE /groups/{chat_id}` (owner) or `POST /groups/{chat_id}/leave`.
964
+ summary: Delete a direct chat
965
+ description: |
966
+ Deletes the chat and its messages for both users (as v1 did); both get `chat_deleted`.
967
+ For groups use `DELETE /groups/{chat_id}` (owner) or `POST /groups/{chat_id}/leave`;
968
+ a group here is `422`.
940
969
  responses:
941
970
  "426": { $ref: "#/components/responses/ClientOutdated" }
942
971
  "400": { $ref: "#/components/responses/BadRequest" }
@@ -944,6 +973,7 @@ paths:
944
973
  description: Deleted
945
974
  "401": { $ref: "#/components/responses/Unauthorized" }
946
975
  "404": { $ref: "#/components/responses/NotFound" }
976
+ "422": { $ref: "#/components/responses/ValidationFailed" }
947
977
  /chats/{chat_id}/pin:
948
978
  parameters:
949
979
  - $ref: "#/components/parameters/ClientVersion"
@@ -953,6 +983,7 @@ paths:
953
983
  tags: [chats]
954
984
  operationId: pinChat
955
985
  summary: Pin a chat
986
+ description: At most 10 chats can be pinned (`409` beyond that). Pinning a pinned chat changes nothing.
956
987
  responses:
957
988
  "426": { $ref: "#/components/responses/ClientOutdated" }
958
989
  "400": { $ref: "#/components/responses/BadRequest" }
@@ -1558,7 +1589,7 @@ components:
1558
1589
  name: attachment_id
1559
1590
  in: path
1560
1591
  required: true
1561
- schema: { $ref: "#/components/schemas/Id" }
1592
+ schema: { $ref: "#/components/schemas/AttachmentRef" }
1562
1593
  SessionId:
1563
1594
  name: session_id
1564
1595
  in: path
@@ -1641,6 +1672,11 @@ components:
1641
1672
  pattern: "^[0-9]{1,19}$"
1642
1673
  description: Decimal ID as a string (Snowflake IDs exceed 2^53).
1643
1674
  examples: ["7217400317439950848"]
1675
+ AttachmentRef:
1676
+ type: string
1677
+ format: uuid
1678
+ description: ID of an uploaded attachment (a UUID, unlike the decimal IDs of messages, users and chats).
1679
+ examples: ["5f0c8a64-2f2b-4c7e-9d0e-6b1f3a2c4d5e"]
1644
1680
  Cursor:
1645
1681
  type: [string, "null"]
1646
1682
  maxLength: 256
@@ -1824,7 +1860,7 @@ components:
1824
1860
  type: object
1825
1861
  required: [attachment_id]
1826
1862
  properties:
1827
- attachment_id: { $ref: "#/components/schemas/Id" }
1863
+ attachment_id: { $ref: "#/components/schemas/AttachmentRef" }
1828
1864
  SecuritySettings:
1829
1865
  type: object
1830
1866
  required: [session_duration_days, two_factor_enabled]
@@ -2021,7 +2057,7 @@ components:
2021
2057
  type: object
2022
2058
  required: [id, kind, filename, content_type, size, url]
2023
2059
  properties:
2024
- id: { $ref: "#/components/schemas/Id" }
2060
+ id: { $ref: "#/components/schemas/AttachmentRef" }
2025
2061
  kind: { $ref: "#/components/schemas/AttachmentKind" }
2026
2062
  filename: { type: string }
2027
2063
  content_type:
@@ -2176,7 +2212,7 @@ components:
2176
2212
  attachment_id:
2177
2213
  description: Required and not null for `file` and `voice`; never a URL.
2178
2214
  oneOf:
2179
- - $ref: "#/components/schemas/Id"
2215
+ - $ref: "#/components/schemas/AttachmentRef"
2180
2216
  - type: "null"
2181
2217
  reply_to:
2182
2218
  oneOf:
@@ -2188,7 +2224,7 @@ components:
2188
2224
  then:
2189
2225
  required: [attachment_id]
2190
2226
  properties:
2191
- attachment_id: { $ref: "#/components/schemas/Id" }
2227
+ attachment_id: { $ref: "#/components/schemas/AttachmentRef" }
2192
2228
  else:
2193
2229
  required: [content]
2194
2230
  properties:
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.0.0-alpha.3. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.0.0-alpha.5. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -613,7 +613,8 @@ export interface paths {
613
613
  };
614
614
  /**
615
615
  * Current avatar image
616
- * @description Respects the avatar visibility of the user; falls back to the default avatar.
616
+ * @description Respects the avatar visibility of the user; falls back to the default avatar. With `version`, an
617
+ * earlier avatar of the history (`AvatarVersion.url`).
617
618
  */
618
619
  get: operations["getUserAvatar"];
619
620
  put?: never;
@@ -716,7 +717,11 @@ export interface paths {
716
717
  };
717
718
  /**
718
719
  * Download an attachment
719
- * @description Only participants of the chat the attachment was sent to (and its uploader) can download it.
720
+ * @description Only the uploader and members of a chat in which a message using the attachment is visible to them can
721
+ * download it. The answer is the file, or a `302` redirect to a short-lived signed URL of the object
722
+ * storage. Images, audio and video are sent `inline`; everything else as a download
723
+ * (`Content-Disposition: attachment`, `application/octet-stream`), always with
724
+ * `X-Content-Type-Options: nosniff`.
720
725
  */
721
726
  get: operations["getAttachmentContent"];
722
727
  put?: never;
@@ -741,7 +746,11 @@ export interface paths {
741
746
  };
742
747
  /**
743
748
  * My chats with last message and unread count
744
- * @description One request replaces `GET /chats/list/{username}` and `GET /groups/list/{username}`; pinned chats come first.
749
+ * @description One request replaces `GET /chats/list/{username}` and `GET /groups/list/{username}`.
750
+ * Pinned chats come first (most recently pinned first), then the others by their last
751
+ * message (newest first). `last_message` is the newest message the caller can see; in
752
+ * direct chats its `read_by` holds the other user once they read it (with read receipts
753
+ * on), in groups it is empty. `unread_count` stops at 999.
745
754
  */
746
755
  get: operations["listChats"];
747
756
  put?: never;
@@ -777,8 +786,10 @@ export interface paths {
777
786
  put?: never;
778
787
  post?: never;
779
788
  /**
780
- * Delete a direct chat for yourself
781
- * @description For groups use `DELETE /groups/{chat_id}` (owner) or `POST /groups/{chat_id}/leave`.
789
+ * Delete a direct chat
790
+ * @description Deletes the chat and its messages for both users (as v1 did); both get `chat_deleted`.
791
+ * For groups use `DELETE /groups/{chat_id}` (owner) or `POST /groups/{chat_id}/leave`;
792
+ * a group here is `422`.
782
793
  */
783
794
  delete: operations["deleteChat"];
784
795
  options?: never;
@@ -801,7 +812,10 @@ export interface paths {
801
812
  cookie?: never;
802
813
  };
803
814
  get?: never;
804
- /** Pin a chat */
815
+ /**
816
+ * Pin a chat
817
+ * @description At most 10 chats can be pinned (`409` beyond that). Pinning a pinned chat changes nothing.
818
+ */
805
819
  put: operations["pinChat"];
806
820
  post?: never;
807
821
  /** Unpin a chat */
@@ -1232,6 +1246,12 @@ export interface components {
1232
1246
  * @example 7217400317439950848
1233
1247
  */
1234
1248
  Id: string;
1249
+ /**
1250
+ * Format: uuid
1251
+ * @description ID of an uploaded attachment (a UUID, unlike the decimal IDs of messages, users and chats).
1252
+ * @example 5f0c8a64-2f2b-4c7e-9d0e-6b1f3a2c4d5e
1253
+ */
1254
+ AttachmentRef: string;
1235
1255
  /** @description Opaque cursor; `null` when there are no more results. */
1236
1256
  Cursor: string | null;
1237
1257
  /** Format: date-time */
@@ -1341,7 +1361,7 @@ export interface components {
1341
1361
  bio?: string | null;
1342
1362
  };
1343
1363
  SetAvatarRequest: {
1344
- attachment_id: components["schemas"]["Id"];
1364
+ attachment_id: components["schemas"]["AttachmentRef"];
1345
1365
  };
1346
1366
  SecuritySettings: {
1347
1367
  session_duration_days: number;
@@ -1460,7 +1480,7 @@ export interface components {
1460
1480
  waveform?: number[];
1461
1481
  };
1462
1482
  Attachment: {
1463
- id: components["schemas"]["Id"];
1483
+ id: components["schemas"]["AttachmentRef"];
1464
1484
  kind: components["schemas"]["AttachmentKind"];
1465
1485
  filename: string;
1466
1486
  /** @description Detected by the server */
@@ -1536,7 +1556,7 @@ export interface components {
1536
1556
  type: "text" | "file" | "voice";
1537
1557
  content?: string | null;
1538
1558
  /** @description Required and not null for `file` and `voice`; never a URL. */
1539
- attachment_id?: components["schemas"]["Id"] | null;
1559
+ attachment_id?: components["schemas"]["AttachmentRef"] | null;
1540
1560
  reply_to?: components["schemas"]["Id"] | null;
1541
1561
  };
1542
1562
  EditMessageRequest: {
@@ -1729,7 +1749,7 @@ export interface components {
1729
1749
  MessageId: components["schemas"]["Id"];
1730
1750
  UserId: components["schemas"]["Id"];
1731
1751
  RequestId: components["schemas"]["Id"];
1732
- AttachmentId: components["schemas"]["Id"];
1752
+ AttachmentId: components["schemas"]["AttachmentRef"];
1733
1753
  SessionId: string;
1734
1754
  /** @description Version of the client app, for logs and the per-client metric. */
1735
1755
  ClientVersion: string;
@@ -2079,6 +2099,7 @@ export interface operations {
2079
2099
  401: components["responses"]["Unauthorized"];
2080
2100
  403: components["responses"]["Forbidden"];
2081
2101
  426: components["responses"]["ClientOutdated"];
2102
+ 429: components["responses"]["TooManyRequests"];
2082
2103
  };
2083
2104
  };
2084
2105
  updateMe: {
@@ -2715,7 +2736,10 @@ export interface operations {
2715
2736
  };
2716
2737
  getUserAvatar: {
2717
2738
  parameters: {
2718
- query?: never;
2739
+ query?: {
2740
+ /** @description `id` of an `AvatarVersion` of this user. */
2741
+ version?: components["schemas"]["Id"];
2742
+ };
2719
2743
  header?: {
2720
2744
  /** @description Version of the client app, for logs and the per-client metric. */
2721
2745
  "X-Client-Version"?: components["parameters"]["ClientVersion"];
@@ -2885,7 +2909,10 @@ export interface operations {
2885
2909
  };
2886
2910
  getAttachmentContent: {
2887
2911
  parameters: {
2888
- query?: never;
2912
+ query?: {
2913
+ /** @description `thumbnail`: a JPEG of at most 320 px (images only; `thumbnail_url` of the attachment). */
2914
+ variant?: "thumbnail";
2915
+ };
2889
2916
  header?: {
2890
2917
  /** @description Version of the client app, for logs and the per-client metric. */
2891
2918
  "X-Client-Version"?: components["parameters"]["ClientVersion"];
@@ -2997,6 +3024,7 @@ export interface operations {
2997
3024
  401: components["responses"]["Unauthorized"];
2998
3025
  403: components["responses"]["Forbidden"];
2999
3026
  404: components["responses"]["NotFound"];
3027
+ 422: components["responses"]["ValidationFailed"];
3000
3028
  426: components["responses"]["ClientOutdated"];
3001
3029
  429: components["responses"]["TooManyRequests"];
3002
3030
  };
@@ -3058,6 +3086,7 @@ export interface operations {
3058
3086
  400: components["responses"]["BadRequest"];
3059
3087
  401: components["responses"]["Unauthorized"];
3060
3088
  404: components["responses"]["NotFound"];
3089
+ 422: components["responses"]["ValidationFailed"];
3061
3090
  426: components["responses"]["ClientOutdated"];
3062
3091
  };
3063
3092
  };
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.0.0-alpha.3. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.0.0-alpha.5. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -24,6 +24,10 @@ export type ClientTempId = string;
24
24
  * Decimal ID as a string (Snowflake IDs exceed 2^53).
25
25
  */
26
26
  export type Id = string;
27
+ /**
28
+ * ID of an uploaded attachment (a UUID, unlike the decimal IDs of messages, users and chats).
29
+ */
30
+ export type AttachmentRef = string;
27
31
  /**
28
32
  * Every event the server may send.
29
33
  */
@@ -126,7 +130,7 @@ export interface AttachmentMessageData {
126
130
  * Optional caption
127
131
  */
128
132
  content?: string | null;
129
- attachment_id: Id;
133
+ attachment_id: AttachmentRef;
130
134
  reply_to?: Id | null;
131
135
  }
132
136
  /**
@@ -311,7 +315,7 @@ export interface Message {
311
315
  client_temp_id?: ClientTempId;
312
316
  }
313
317
  export interface Attachment {
314
- id: Id;
318
+ id: AttachmentRef;
315
319
  kind: AttachmentKind;
316
320
  filename: string;
317
321
  /**
@@ -9,6 +9,14 @@
9
9
  "7217400317439950848"
10
10
  ]
11
11
  },
12
+ "AttachmentRef": {
13
+ "type": "string",
14
+ "format": "uuid",
15
+ "description": "ID of an uploaded attachment (a UUID, unlike the decimal IDs of messages, users and chats).",
16
+ "examples": [
17
+ "5f0c8a64-2f2b-4c7e-9d0e-6b1f3a2c4d5e"
18
+ ]
19
+ },
12
20
  "Cursor": {
13
21
  "type": [
14
22
  "string",
@@ -407,7 +415,7 @@
407
415
  ],
408
416
  "properties": {
409
417
  "attachment_id": {
410
- "$ref": "#/$defs/Id"
418
+ "$ref": "#/$defs/AttachmentRef"
411
419
  }
412
420
  }
413
421
  },
@@ -871,7 +879,7 @@
871
879
  ],
872
880
  "properties": {
873
881
  "id": {
874
- "$ref": "#/$defs/Id"
882
+ "$ref": "#/$defs/AttachmentRef"
875
883
  },
876
884
  "kind": {
877
885
  "$ref": "#/$defs/AttachmentKind"
@@ -1221,7 +1229,7 @@
1221
1229
  "description": "Required and not null for `file` and `voice`; never a URL.",
1222
1230
  "oneOf": [
1223
1231
  {
1224
- "$ref": "#/$defs/Id"
1232
+ "$ref": "#/$defs/AttachmentRef"
1225
1233
  },
1226
1234
  {
1227
1235
  "type": "null"
@@ -1255,7 +1263,7 @@
1255
1263
  ],
1256
1264
  "properties": {
1257
1265
  "attachment_id": {
1258
- "$ref": "#/$defs/Id"
1266
+ "$ref": "#/$defs/AttachmentRef"
1259
1267
  }
1260
1268
  }
1261
1269
  },
@@ -1801,7 +1809,7 @@
1801
1809
  "description": "Optional caption"
1802
1810
  },
1803
1811
  "attachment_id": {
1804
- "$ref": "#/$defs/Id"
1812
+ "$ref": "#/$defs/AttachmentRef"
1805
1813
  },
1806
1814
  "reply_to": {
1807
1815
  "oneOf": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.0.0-alpha.3.next.42",
3
+ "version": "2.0.0-alpha.5.next.46",
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": {