@myronsi/messenger-api 2.0.0-alpha.3.next.42 → 2.0.0-alpha.4.next.44

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,14 @@
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.4
6
+
7
+ Media, found while implementing uploads:
8
+
9
+ - 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.
10
+ - `GET /attachments/{attachment_id}/content` takes `variant=thumbnail`, may answer `302` to a signed URL, and documents its `Content-Disposition` rules.
11
+ - `GET /users/{user_id}/avatar` takes `version` (an `AvatarVersion.id`), which `AvatarVersion.url` points to.
12
+
5
13
  ## 2.0.0-alpha.3
6
14
 
7
15
  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.4. Do not edit. */
2
+ export declare const API_VERSION: "2.0.0-alpha.4";
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.4";
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.4
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
@@ -727,7 +727,14 @@ paths:
727
727
  tags: [users]
728
728
  operationId: getUserAvatar
729
729
  summary: Current avatar image
730
- description: Respects the avatar visibility of the user; falls back to the default avatar.
730
+ description: |
731
+ Respects the avatar visibility of the user; falls back to the default avatar. With `version`, an
732
+ earlier avatar of the history (`AvatarVersion.url`).
733
+ parameters:
734
+ - name: version
735
+ in: query
736
+ description: "`id` of an `AvatarVersion` of this user."
737
+ schema: { $ref: "#/components/schemas/Id" }
731
738
  responses:
732
739
  "426": { $ref: "#/components/responses/ClientOutdated" }
733
740
  "400": { $ref: "#/components/responses/BadRequest" }
@@ -843,7 +850,19 @@ paths:
843
850
  tags: [attachments]
844
851
  operationId: getAttachmentContent
845
852
  summary: Download an attachment
846
- description: Only participants of the chat the attachment was sent to (and its uploader) can download it.
853
+ description: |
854
+ Only the uploader and members of a chat in which a message using the attachment is visible to them can
855
+ download it. The answer is the file, or a `302` redirect to a short-lived signed URL of the object
856
+ storage. Images, audio and video are sent `inline`; everything else as a download
857
+ (`Content-Disposition: attachment`, `application/octet-stream`), always with
858
+ `X-Content-Type-Options: nosniff`.
859
+ parameters:
860
+ - name: variant
861
+ in: query
862
+ description: "`thumbnail`: a JPEG of at most 320 px (images only; `thumbnail_url` of the attachment)."
863
+ schema:
864
+ type: string
865
+ enum: [thumbnail]
847
866
  responses:
848
867
  "426": { $ref: "#/components/responses/ClientOutdated" }
849
868
  "400": { $ref: "#/components/responses/BadRequest" }
@@ -1558,7 +1577,7 @@ components:
1558
1577
  name: attachment_id
1559
1578
  in: path
1560
1579
  required: true
1561
- schema: { $ref: "#/components/schemas/Id" }
1580
+ schema: { $ref: "#/components/schemas/AttachmentRef" }
1562
1581
  SessionId:
1563
1582
  name: session_id
1564
1583
  in: path
@@ -1641,6 +1660,11 @@ components:
1641
1660
  pattern: "^[0-9]{1,19}$"
1642
1661
  description: Decimal ID as a string (Snowflake IDs exceed 2^53).
1643
1662
  examples: ["7217400317439950848"]
1663
+ AttachmentRef:
1664
+ type: string
1665
+ format: uuid
1666
+ description: ID of an uploaded attachment (a UUID, unlike the decimal IDs of messages, users and chats).
1667
+ examples: ["5f0c8a64-2f2b-4c7e-9d0e-6b1f3a2c4d5e"]
1644
1668
  Cursor:
1645
1669
  type: [string, "null"]
1646
1670
  maxLength: 256
@@ -1824,7 +1848,7 @@ components:
1824
1848
  type: object
1825
1849
  required: [attachment_id]
1826
1850
  properties:
1827
- attachment_id: { $ref: "#/components/schemas/Id" }
1851
+ attachment_id: { $ref: "#/components/schemas/AttachmentRef" }
1828
1852
  SecuritySettings:
1829
1853
  type: object
1830
1854
  required: [session_duration_days, two_factor_enabled]
@@ -2021,7 +2045,7 @@ components:
2021
2045
  type: object
2022
2046
  required: [id, kind, filename, content_type, size, url]
2023
2047
  properties:
2024
- id: { $ref: "#/components/schemas/Id" }
2048
+ id: { $ref: "#/components/schemas/AttachmentRef" }
2025
2049
  kind: { $ref: "#/components/schemas/AttachmentKind" }
2026
2050
  filename: { type: string }
2027
2051
  content_type:
@@ -2176,7 +2200,7 @@ components:
2176
2200
  attachment_id:
2177
2201
  description: Required and not null for `file` and `voice`; never a URL.
2178
2202
  oneOf:
2179
- - $ref: "#/components/schemas/Id"
2203
+ - $ref: "#/components/schemas/AttachmentRef"
2180
2204
  - type: "null"
2181
2205
  reply_to:
2182
2206
  oneOf:
@@ -2188,7 +2212,7 @@ components:
2188
2212
  then:
2189
2213
  required: [attachment_id]
2190
2214
  properties:
2191
- attachment_id: { $ref: "#/components/schemas/Id" }
2215
+ attachment_id: { $ref: "#/components/schemas/AttachmentRef" }
2192
2216
  else:
2193
2217
  required: [content]
2194
2218
  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.4. 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;
@@ -1232,6 +1237,12 @@ export interface components {
1232
1237
  * @example 7217400317439950848
1233
1238
  */
1234
1239
  Id: string;
1240
+ /**
1241
+ * Format: uuid
1242
+ * @description ID of an uploaded attachment (a UUID, unlike the decimal IDs of messages, users and chats).
1243
+ * @example 5f0c8a64-2f2b-4c7e-9d0e-6b1f3a2c4d5e
1244
+ */
1245
+ AttachmentRef: string;
1235
1246
  /** @description Opaque cursor; `null` when there are no more results. */
1236
1247
  Cursor: string | null;
1237
1248
  /** Format: date-time */
@@ -1341,7 +1352,7 @@ export interface components {
1341
1352
  bio?: string | null;
1342
1353
  };
1343
1354
  SetAvatarRequest: {
1344
- attachment_id: components["schemas"]["Id"];
1355
+ attachment_id: components["schemas"]["AttachmentRef"];
1345
1356
  };
1346
1357
  SecuritySettings: {
1347
1358
  session_duration_days: number;
@@ -1460,7 +1471,7 @@ export interface components {
1460
1471
  waveform?: number[];
1461
1472
  };
1462
1473
  Attachment: {
1463
- id: components["schemas"]["Id"];
1474
+ id: components["schemas"]["AttachmentRef"];
1464
1475
  kind: components["schemas"]["AttachmentKind"];
1465
1476
  filename: string;
1466
1477
  /** @description Detected by the server */
@@ -1536,7 +1547,7 @@ export interface components {
1536
1547
  type: "text" | "file" | "voice";
1537
1548
  content?: string | null;
1538
1549
  /** @description Required and not null for `file` and `voice`; never a URL. */
1539
- attachment_id?: components["schemas"]["Id"] | null;
1550
+ attachment_id?: components["schemas"]["AttachmentRef"] | null;
1540
1551
  reply_to?: components["schemas"]["Id"] | null;
1541
1552
  };
1542
1553
  EditMessageRequest: {
@@ -1729,7 +1740,7 @@ export interface components {
1729
1740
  MessageId: components["schemas"]["Id"];
1730
1741
  UserId: components["schemas"]["Id"];
1731
1742
  RequestId: components["schemas"]["Id"];
1732
- AttachmentId: components["schemas"]["Id"];
1743
+ AttachmentId: components["schemas"]["AttachmentRef"];
1733
1744
  SessionId: string;
1734
1745
  /** @description Version of the client app, for logs and the per-client metric. */
1735
1746
  ClientVersion: string;
@@ -2715,7 +2726,10 @@ export interface operations {
2715
2726
  };
2716
2727
  getUserAvatar: {
2717
2728
  parameters: {
2718
- query?: never;
2729
+ query?: {
2730
+ /** @description `id` of an `AvatarVersion` of this user. */
2731
+ version?: components["schemas"]["Id"];
2732
+ };
2719
2733
  header?: {
2720
2734
  /** @description Version of the client app, for logs and the per-client metric. */
2721
2735
  "X-Client-Version"?: components["parameters"]["ClientVersion"];
@@ -2885,7 +2899,10 @@ export interface operations {
2885
2899
  };
2886
2900
  getAttachmentContent: {
2887
2901
  parameters: {
2888
- query?: never;
2902
+ query?: {
2903
+ /** @description `thumbnail`: a JPEG of at most 320 px (images only; `thumbnail_url` of the attachment). */
2904
+ variant?: "thumbnail";
2905
+ };
2889
2906
  header?: {
2890
2907
  /** @description Version of the client app, for logs and the per-client metric. */
2891
2908
  "X-Client-Version"?: components["parameters"]["ClientVersion"];
@@ -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.4. 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.4.next.44",
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": {