@myronsi/messenger-api 2.1.0-alpha.11 → 2.1.0-alpha.12

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,22 @@
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.12
6
+
7
+ - `GET /link-preview?url=` returns the Open Graph preview of a public web page (`title`, `description`,
8
+ `site_name`, `image`), cached for a day. `image.url` points to `GET /link-preview/image`, which streams the
9
+ picture through the server (PNG, JPEG, GIF or WebP up to 5 MB) with a signature, so clients never load
10
+ third-party images directly. Only public `http`/`https` addresses on ports 80 and 443 are fetched.
11
+ - Messages have an optional `system_event` (`kind`, `actor_id`, `actor_name`, `target_id`, `target_name`) on
12
+ `system` messages, whose `content` is then `null`. Groups write them when a group is created and when members
13
+ are added, join, are removed or leave. System messages do not count as unread.
14
+ - `GET /groups/{chat_id}/role-log` lists who changed whose role and when, newest first (members only).
15
+ - `GroupRole` and `UpdateRoleRequest` have `moderator` again: moderators may delete other members' messages.
16
+ - In a direct chat either side may delete any message for everyone (`DELETE /messages/{message_id}?scope=everyone`
17
+ and `POST /chats/{chat_id}/messages/delete`).
18
+ - The last message of a chat (`GET /chats`, `GET /chats/{chat_id}`) skips messages deleted for everyone and is the
19
+ newest message that still has content.
20
+
5
21
  ## 2.1.0-alpha.11
6
22
 
7
23
  - Attachments have `display_url`: a JPEG of at most 1600 px (`GET /attachments/{attachment_id}/content?variant=display`)
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.11. Do not edit. */
2
- export declare const API_VERSION: "2.1.0-alpha.11";
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.12. Do not edit. */
2
+ export declare const API_VERSION: "2.1.0-alpha.12";
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.11";
1
+ export const API_VERSION = "2.1.0-alpha.12";
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.11
4
+ version: 2.1.0-alpha.12
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
@@ -1356,7 +1356,8 @@ paths:
1356
1356
  summary: Delete a message
1357
1357
  description: |
1358
1358
  `scope=me` hides it for the current user only (any message). `scope=everyone` removes
1359
- it for all participants (own messages, and any message for group admins).
1359
+ it for all participants: own messages, any message of a direct chat (either side), and any message
1360
+ for group owners, admins and moderators.
1360
1361
  parameters:
1361
1362
  - name: scope
1362
1363
  in: query
@@ -1829,6 +1830,89 @@ paths:
1829
1830
  "401": { $ref: "#/components/responses/Unauthorized" }
1830
1831
  "404": { $ref: "#/components/responses/NotFound" }
1831
1832
  "409": { $ref: "#/components/responses/Conflict" }
1833
+ /groups/{chat_id}/role-log:
1834
+ parameters:
1835
+ - $ref: "#/components/parameters/ClientVersion"
1836
+ - $ref: "#/components/parameters/ClientApiVersion"
1837
+ - $ref: "#/components/parameters/ChatId"
1838
+ get:
1839
+ tags: [groups]
1840
+ operationId: getGroupRoleLog
1841
+ summary: Role changes of the group's members
1842
+ description: Who made whom an admin or a member, or transferred ownership, and when. Members only.
1843
+ responses:
1844
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1845
+ "400": { $ref: "#/components/responses/BadRequest" }
1846
+ "200":
1847
+ description: Role changes
1848
+ content:
1849
+ application/json:
1850
+ schema: { $ref: "#/components/schemas/GroupRoleLog" }
1851
+ "401": { $ref: "#/components/responses/Unauthorized" }
1852
+ "404": { $ref: "#/components/responses/NotFound" }
1853
+ /link-preview:
1854
+ parameters:
1855
+ - $ref: "#/components/parameters/ClientVersion"
1856
+ - $ref: "#/components/parameters/ClientApiVersion"
1857
+ get:
1858
+ tags: [messages]
1859
+ operationId: getLinkPreview
1860
+ summary: Preview of a web page for a link in a message
1861
+ description: |
1862
+ Reads the page's Open Graph data (`og:title`, `og:description`, `og:site_name`, `og:image`; falling back to
1863
+ `<title>`, `description` and `twitter:image`). Only public `http`/`https` addresses on ports 80 and 443
1864
+ are fetched. Answers are cached for a day (a page without a preview for an hour). `image.url` points to
1865
+ `GET /link-preview/image`, so clients never load third-party images directly. `404` when the page has
1866
+ no preview or cannot be fetched.
1867
+ parameters:
1868
+ - name: url
1869
+ in: query
1870
+ required: true
1871
+ schema: { type: string, minLength: 1, maxLength: 2048 }
1872
+ responses:
1873
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1874
+ "400": { $ref: "#/components/responses/BadRequest" }
1875
+ "200":
1876
+ description: The preview
1877
+ content:
1878
+ application/json:
1879
+ schema: { $ref: "#/components/schemas/LinkPreview" }
1880
+ "401": { $ref: "#/components/responses/Unauthorized" }
1881
+ "404": { $ref: "#/components/responses/NotFound" }
1882
+ "422": { $ref: "#/components/responses/ValidationFailed" }
1883
+ "429": { $ref: "#/components/responses/TooManyRequests" }
1884
+ /link-preview/image:
1885
+ parameters:
1886
+ - $ref: "#/components/parameters/ClientVersion"
1887
+ - $ref: "#/components/parameters/ClientApiVersion"
1888
+ get:
1889
+ tags: [messages]
1890
+ operationId: getLinkPreviewImage
1891
+ summary: The image of a link preview, through the server
1892
+ description: |
1893
+ Use the `image.url` of a link preview as it is; `sig` proves the server made it. PNG, JPEG, GIF and WebP
1894
+ up to 5 MB, sent with `X-Content-Type-Options: nosniff`.
1895
+ parameters:
1896
+ - name: url
1897
+ in: query
1898
+ required: true
1899
+ schema: { type: string, minLength: 1, maxLength: 2048 }
1900
+ - name: sig
1901
+ in: query
1902
+ required: true
1903
+ schema: { type: string, minLength: 1, maxLength: 64 }
1904
+ responses:
1905
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1906
+ "400": { $ref: "#/components/responses/BadRequest" }
1907
+ "200":
1908
+ description: Image content
1909
+ content:
1910
+ image/*:
1911
+ schema: { type: string, format: binary }
1912
+ "401": { $ref: "#/components/responses/Unauthorized" }
1913
+ "403": { $ref: "#/components/responses/Forbidden" }
1914
+ "404": { $ref: "#/components/responses/NotFound" }
1915
+ "429": { $ref: "#/components/responses/TooManyRequests" }
1832
1916
 
1833
1917
  /me/notifications:
1834
1918
  get:
@@ -2833,7 +2917,51 @@ components:
2833
2917
  - $ref: "#/components/schemas/Timestamp"
2834
2918
  - type: "null"
2835
2919
  is_deleted: { type: boolean }
2920
+ system_event:
2921
+ $ref: "#/components/schemas/SystemEvent"
2836
2922
  client_temp_id: { $ref: "#/components/schemas/ClientTempId" }
2923
+ LinkPreview:
2924
+ type: object
2925
+ required: [url, title, description, site_name, image]
2926
+ properties:
2927
+ url:
2928
+ type: string
2929
+ description: The page after redirects
2930
+ title: { type: [string, "null"], maxLength: 300 }
2931
+ description: { type: [string, "null"], maxLength: 500 }
2932
+ site_name: { type: [string, "null"], maxLength: 100 }
2933
+ image:
2934
+ oneOf:
2935
+ - $ref: "#/components/schemas/LinkPreviewImage"
2936
+ - type: "null"
2937
+ LinkPreviewImage:
2938
+ type: object
2939
+ required: [url, width, height]
2940
+ properties:
2941
+ url:
2942
+ type: string
2943
+ description: "`GET /link-preview/image` with the signed address of the page's image"
2944
+ width: { type: [integer, "null"], minimum: 1 }
2945
+ height: { type: [integer, "null"], minimum: 1 }
2946
+ SystemEventKind:
2947
+ type: string
2948
+ enum: [group_created, member_added, member_joined, member_removed, member_left]
2949
+ SystemEvent:
2950
+ type: object
2951
+ description: |
2952
+ What a `system` message records; set on system messages only, whose `content` is then `null`. The names
2953
+ are the display names at the time of the event. `target` fields are set for `member_added` and
2954
+ `member_removed`.
2955
+ required: [kind, actor_id, actor_name]
2956
+ properties:
2957
+ kind: { $ref: "#/components/schemas/SystemEventKind" }
2958
+ actor_id:
2959
+ oneOf:
2960
+ - $ref: "#/components/schemas/Id"
2961
+ - type: "null"
2962
+ actor_name: { type: string }
2963
+ target_id: { $ref: "#/components/schemas/Id" }
2964
+ target_name: { type: string }
2837
2965
  MessagePage:
2838
2966
  type: object
2839
2967
  required: [items, next_cursor, prev_cursor]
@@ -2967,7 +3095,30 @@ components:
2967
3095
  enum: [direct, group]
2968
3096
  GroupRole:
2969
3097
  type: string
2970
- enum: [owner, admin, member]
3098
+ description: A moderator may delete other members' messages; owners and admins also manage the group.
3099
+ enum: [owner, admin, moderator, member]
3100
+ GroupRoleEvent:
3101
+ type: object
3102
+ description: A member got a new role; `owner` means the actor transferred ownership to them.
3103
+ required: [id, actor, target, role, created_at]
3104
+ properties:
3105
+ id: { $ref: "#/components/schemas/Id" }
3106
+ actor:
3107
+ description: "`null` when the account is gone."
3108
+ oneOf:
3109
+ - $ref: "#/components/schemas/User"
3110
+ - type: "null"
3111
+ target: { $ref: "#/components/schemas/User" }
3112
+ role: { $ref: "#/components/schemas/GroupRole" }
3113
+ created_at: { $ref: "#/components/schemas/Timestamp" }
3114
+ GroupRoleLog:
3115
+ type: object
3116
+ required: [items]
3117
+ properties:
3118
+ items:
3119
+ type: array
3120
+ description: Newest first, at most 100
3121
+ items: { $ref: "#/components/schemas/GroupRoleEvent" }
2971
3122
  Chat:
2972
3123
  type: object
2973
3124
  required:
@@ -3069,7 +3220,7 @@ components:
3069
3220
  properties:
3070
3221
  role:
3071
3222
  type: string
3072
- enum: [admin, member]
3223
+ enum: [admin, moderator, member]
3073
3224
  TransferOwnerRequest:
3074
3225
  type: object
3075
3226
  required: [user_id]
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.11. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.12. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -1070,7 +1070,8 @@ export interface paths {
1070
1070
  /**
1071
1071
  * Delete a message
1072
1072
  * @description `scope=me` hides it for the current user only (any message). `scope=everyone` removes
1073
- * it for all participants (own messages, and any message for group admins).
1073
+ * it for all participants: own messages, any message of a direct chat (either side), and any message
1074
+ * for group owners, admins and moderators.
1074
1075
  */
1075
1076
  delete: operations["deleteMessage"];
1076
1077
  options?: never;
@@ -1447,6 +1448,88 @@ export interface paths {
1447
1448
  patch?: never;
1448
1449
  trace?: never;
1449
1450
  };
1451
+ "/groups/{chat_id}/role-log": {
1452
+ parameters: {
1453
+ query?: never;
1454
+ header?: {
1455
+ /** @description Version of the client app, for logs and the per-client metric. */
1456
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
1457
+ /** @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`). */
1458
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
1459
+ };
1460
+ path: {
1461
+ chat_id: components["parameters"]["ChatId"];
1462
+ };
1463
+ cookie?: never;
1464
+ };
1465
+ /**
1466
+ * Role changes of the group's members
1467
+ * @description Who made whom an admin or a member, or transferred ownership, and when. Members only.
1468
+ */
1469
+ get: operations["getGroupRoleLog"];
1470
+ put?: never;
1471
+ post?: never;
1472
+ delete?: never;
1473
+ options?: never;
1474
+ head?: never;
1475
+ patch?: never;
1476
+ trace?: never;
1477
+ };
1478
+ "/link-preview": {
1479
+ parameters: {
1480
+ query?: never;
1481
+ header?: {
1482
+ /** @description Version of the client app, for logs and the per-client metric. */
1483
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
1484
+ /** @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`). */
1485
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
1486
+ };
1487
+ path?: never;
1488
+ cookie?: never;
1489
+ };
1490
+ /**
1491
+ * Preview of a web page for a link in a message
1492
+ * @description Reads the page's Open Graph data (`og:title`, `og:description`, `og:site_name`, `og:image`; falling back to
1493
+ * `<title>`, `description` and `twitter:image`). Only public `http`/`https` addresses on ports 80 and 443
1494
+ * are fetched. Answers are cached for a day (a page without a preview for an hour). `image.url` points to
1495
+ * `GET /link-preview/image`, so clients never load third-party images directly. `404` when the page has
1496
+ * no preview or cannot be fetched.
1497
+ */
1498
+ get: operations["getLinkPreview"];
1499
+ put?: never;
1500
+ post?: never;
1501
+ delete?: never;
1502
+ options?: never;
1503
+ head?: never;
1504
+ patch?: never;
1505
+ trace?: never;
1506
+ };
1507
+ "/link-preview/image": {
1508
+ parameters: {
1509
+ query?: never;
1510
+ header?: {
1511
+ /** @description Version of the client app, for logs and the per-client metric. */
1512
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
1513
+ /** @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`). */
1514
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
1515
+ };
1516
+ path?: never;
1517
+ cookie?: never;
1518
+ };
1519
+ /**
1520
+ * The image of a link preview, through the server
1521
+ * @description Use the `image.url` of a link preview as it is; `sig` proves the server made it. PNG, JPEG, GIF and WebP
1522
+ * up to 5 MB, sent with `X-Content-Type-Options: nosniff`.
1523
+ */
1524
+ get: operations["getLinkPreviewImage"];
1525
+ put?: never;
1526
+ post?: never;
1527
+ delete?: never;
1528
+ options?: never;
1529
+ head?: never;
1530
+ patch?: never;
1531
+ trace?: never;
1532
+ };
1450
1533
  "/me/notifications": {
1451
1534
  parameters: {
1452
1535
  query?: never;
@@ -1964,8 +2047,37 @@ export interface components {
1964
2047
  created_at: components["schemas"]["Timestamp"];
1965
2048
  edited_at: components["schemas"]["Timestamp"] | null;
1966
2049
  is_deleted: boolean;
2050
+ system_event?: components["schemas"]["SystemEvent"];
1967
2051
  client_temp_id?: components["schemas"]["ClientTempId"];
1968
2052
  };
2053
+ LinkPreview: {
2054
+ /** @description The page after redirects */
2055
+ url: string;
2056
+ title: string | null;
2057
+ description: string | null;
2058
+ site_name: string | null;
2059
+ image: components["schemas"]["LinkPreviewImage"] | null;
2060
+ };
2061
+ LinkPreviewImage: {
2062
+ /** @description `GET /link-preview/image` with the signed address of the page's image */
2063
+ url: string;
2064
+ width: number | null;
2065
+ height: number | null;
2066
+ };
2067
+ /** @enum {string} */
2068
+ SystemEventKind: "group_created" | "member_added" | "member_joined" | "member_removed" | "member_left";
2069
+ /**
2070
+ * @description What a `system` message records; set on system messages only, whose `content` is then `null`. The names
2071
+ * are the display names at the time of the event. `target` fields are set for `member_added` and
2072
+ * `member_removed`.
2073
+ */
2074
+ SystemEvent: {
2075
+ kind: components["schemas"]["SystemEventKind"];
2076
+ actor_id: components["schemas"]["Id"] | null;
2077
+ actor_name: string;
2078
+ target_id?: components["schemas"]["Id"];
2079
+ target_name?: string;
2080
+ };
1969
2081
  MessagePage: {
1970
2082
  /** @description Oldest to newest */
1971
2083
  items: components["schemas"]["Message"][];
@@ -2022,8 +2134,24 @@ export interface components {
2022
2134
  };
2023
2135
  /** @enum {string} */
2024
2136
  ChatType: "direct" | "group";
2025
- /** @enum {string} */
2026
- GroupRole: "owner" | "admin" | "member";
2137
+ /**
2138
+ * @description A moderator may delete other members' messages; owners and admins also manage the group.
2139
+ * @enum {string}
2140
+ */
2141
+ GroupRole: "owner" | "admin" | "moderator" | "member";
2142
+ /** @description A member got a new role; `owner` means the actor transferred ownership to them. */
2143
+ GroupRoleEvent: {
2144
+ id: components["schemas"]["Id"];
2145
+ /** @description `null` when the account is gone. */
2146
+ actor: components["schemas"]["User"] | null;
2147
+ target: components["schemas"]["User"];
2148
+ role: components["schemas"]["GroupRole"];
2149
+ created_at: components["schemas"]["Timestamp"];
2150
+ };
2151
+ GroupRoleLog: {
2152
+ /** @description Newest first, at most 100 */
2153
+ items: components["schemas"]["GroupRoleEvent"][];
2154
+ };
2027
2155
  Chat: {
2028
2156
  id: components["schemas"]["Id"];
2029
2157
  type: components["schemas"]["ChatType"];
@@ -2076,7 +2204,7 @@ export interface components {
2076
2204
  };
2077
2205
  UpdateRoleRequest: {
2078
2206
  /** @enum {string} */
2079
- role: "admin" | "member";
2207
+ role: "admin" | "moderator" | "member";
2080
2208
  };
2081
2209
  TransferOwnerRequest: {
2082
2210
  user_id: components["schemas"]["Id"];
@@ -4739,6 +4867,104 @@ export interface operations {
4739
4867
  426: components["responses"]["ClientOutdated"];
4740
4868
  };
4741
4869
  };
4870
+ getGroupRoleLog: {
4871
+ parameters: {
4872
+ query?: never;
4873
+ header?: {
4874
+ /** @description Version of the client app, for logs and the per-client metric. */
4875
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
4876
+ /** @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`). */
4877
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
4878
+ };
4879
+ path: {
4880
+ chat_id: components["parameters"]["ChatId"];
4881
+ };
4882
+ cookie?: never;
4883
+ };
4884
+ requestBody?: never;
4885
+ responses: {
4886
+ /** @description Role changes */
4887
+ 200: {
4888
+ headers: {
4889
+ [name: string]: unknown;
4890
+ };
4891
+ content: {
4892
+ "application/json": components["schemas"]["GroupRoleLog"];
4893
+ };
4894
+ };
4895
+ 400: components["responses"]["BadRequest"];
4896
+ 401: components["responses"]["Unauthorized"];
4897
+ 404: components["responses"]["NotFound"];
4898
+ 426: components["responses"]["ClientOutdated"];
4899
+ };
4900
+ };
4901
+ getLinkPreview: {
4902
+ parameters: {
4903
+ query: {
4904
+ url: string;
4905
+ };
4906
+ header?: {
4907
+ /** @description Version of the client app, for logs and the per-client metric. */
4908
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
4909
+ /** @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`). */
4910
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
4911
+ };
4912
+ path?: never;
4913
+ cookie?: never;
4914
+ };
4915
+ requestBody?: never;
4916
+ responses: {
4917
+ /** @description The preview */
4918
+ 200: {
4919
+ headers: {
4920
+ [name: string]: unknown;
4921
+ };
4922
+ content: {
4923
+ "application/json": components["schemas"]["LinkPreview"];
4924
+ };
4925
+ };
4926
+ 400: components["responses"]["BadRequest"];
4927
+ 401: components["responses"]["Unauthorized"];
4928
+ 404: components["responses"]["NotFound"];
4929
+ 422: components["responses"]["ValidationFailed"];
4930
+ 426: components["responses"]["ClientOutdated"];
4931
+ 429: components["responses"]["TooManyRequests"];
4932
+ };
4933
+ };
4934
+ getLinkPreviewImage: {
4935
+ parameters: {
4936
+ query: {
4937
+ url: string;
4938
+ sig: string;
4939
+ };
4940
+ header?: {
4941
+ /** @description Version of the client app, for logs and the per-client metric. */
4942
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
4943
+ /** @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`). */
4944
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
4945
+ };
4946
+ path?: never;
4947
+ cookie?: never;
4948
+ };
4949
+ requestBody?: never;
4950
+ responses: {
4951
+ /** @description Image content */
4952
+ 200: {
4953
+ headers: {
4954
+ [name: string]: unknown;
4955
+ };
4956
+ content: {
4957
+ "image/*": string;
4958
+ };
4959
+ };
4960
+ 400: components["responses"]["BadRequest"];
4961
+ 401: components["responses"]["Unauthorized"];
4962
+ 403: components["responses"]["Forbidden"];
4963
+ 404: components["responses"]["NotFound"];
4964
+ 426: components["responses"]["ClientOutdated"];
4965
+ 429: components["responses"]["TooManyRequests"];
4966
+ };
4967
+ };
4742
4968
  getNotificationSettings: {
4743
4969
  parameters: {
4744
4970
  query?: never;
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.11. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.12. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -57,7 +57,11 @@ export type Username = string;
57
57
  export type ChatType = "direct" | "group";
58
58
  export type MessageType = "text" | "file" | "voice" | "system";
59
59
  export type AttachmentKind = "image" | "audio" | "voice" | "video" | "file";
60
- export type GroupRole = "owner" | "admin" | "member";
60
+ export type SystemEventKind = "group_created" | "member_added" | "member_joined" | "member_removed" | "member_left";
61
+ /**
62
+ * A moderator may delete other members' messages; owners and admins also manage the group.
63
+ */
64
+ export type GroupRole = "owner" | "admin" | "moderator" | "member";
61
65
  /**
62
66
  * Stable machine-readable error code. New codes can appear in MINOR versions; unknown
63
67
  * codes must be treated like `internal_error`.
@@ -314,6 +318,7 @@ export interface Message {
314
318
  created_at: Timestamp;
315
319
  edited_at: Timestamp | null;
316
320
  is_deleted: boolean;
321
+ system_event?: SystemEvent;
317
322
  client_temp_id?: ClientTempId;
318
323
  }
319
324
  export interface Attachment {
@@ -372,6 +377,19 @@ export interface ReadReceipt {
372
377
  user_id: Id;
373
378
  read_at: Timestamp;
374
379
  }
380
+ /**
381
+ * What a `system` message records; set on system messages only, whose `content` is then `null`. The names
382
+ * are the display names at the time of the event. `target` fields are set for `member_added` and
383
+ * `member_removed`.
384
+ *
385
+ */
386
+ export interface SystemEvent {
387
+ kind: SystemEventKind;
388
+ actor_id: Id | null;
389
+ actor_name: string;
390
+ target_id?: Id;
391
+ target_name?: string;
392
+ }
375
393
  /**
376
394
  * A chat was deleted, or you were removed from it.
377
395
  */
@@ -1442,11 +1442,132 @@
1442
1442
  "is_deleted": {
1443
1443
  "type": "boolean"
1444
1444
  },
1445
+ "system_event": {
1446
+ "$ref": "#/$defs/SystemEvent"
1447
+ },
1445
1448
  "client_temp_id": {
1446
1449
  "$ref": "#/$defs/ClientTempId"
1447
1450
  }
1448
1451
  }
1449
1452
  },
1453
+ "LinkPreview": {
1454
+ "type": "object",
1455
+ "required": [
1456
+ "url",
1457
+ "title",
1458
+ "description",
1459
+ "site_name",
1460
+ "image"
1461
+ ],
1462
+ "properties": {
1463
+ "url": {
1464
+ "type": "string",
1465
+ "description": "The page after redirects"
1466
+ },
1467
+ "title": {
1468
+ "type": [
1469
+ "string",
1470
+ "null"
1471
+ ],
1472
+ "maxLength": 300
1473
+ },
1474
+ "description": {
1475
+ "type": [
1476
+ "string",
1477
+ "null"
1478
+ ],
1479
+ "maxLength": 500
1480
+ },
1481
+ "site_name": {
1482
+ "type": [
1483
+ "string",
1484
+ "null"
1485
+ ],
1486
+ "maxLength": 100
1487
+ },
1488
+ "image": {
1489
+ "oneOf": [
1490
+ {
1491
+ "$ref": "#/$defs/LinkPreviewImage"
1492
+ },
1493
+ {
1494
+ "type": "null"
1495
+ }
1496
+ ]
1497
+ }
1498
+ }
1499
+ },
1500
+ "LinkPreviewImage": {
1501
+ "type": "object",
1502
+ "required": [
1503
+ "url",
1504
+ "width",
1505
+ "height"
1506
+ ],
1507
+ "properties": {
1508
+ "url": {
1509
+ "type": "string",
1510
+ "description": "`GET /link-preview/image` with the signed address of the page's image"
1511
+ },
1512
+ "width": {
1513
+ "type": [
1514
+ "integer",
1515
+ "null"
1516
+ ],
1517
+ "minimum": 1
1518
+ },
1519
+ "height": {
1520
+ "type": [
1521
+ "integer",
1522
+ "null"
1523
+ ],
1524
+ "minimum": 1
1525
+ }
1526
+ }
1527
+ },
1528
+ "SystemEventKind": {
1529
+ "type": "string",
1530
+ "enum": [
1531
+ "group_created",
1532
+ "member_added",
1533
+ "member_joined",
1534
+ "member_removed",
1535
+ "member_left"
1536
+ ]
1537
+ },
1538
+ "SystemEvent": {
1539
+ "type": "object",
1540
+ "description": "What a `system` message records; set on system messages only, whose `content` is then `null`. The names\nare the display names at the time of the event. `target` fields are set for `member_added` and\n`member_removed`.\n",
1541
+ "required": [
1542
+ "kind",
1543
+ "actor_id",
1544
+ "actor_name"
1545
+ ],
1546
+ "properties": {
1547
+ "kind": {
1548
+ "$ref": "#/$defs/SystemEventKind"
1549
+ },
1550
+ "actor_id": {
1551
+ "oneOf": [
1552
+ {
1553
+ "$ref": "#/$defs/Id"
1554
+ },
1555
+ {
1556
+ "type": "null"
1557
+ }
1558
+ ]
1559
+ },
1560
+ "actor_name": {
1561
+ "type": "string"
1562
+ },
1563
+ "target_id": {
1564
+ "$ref": "#/$defs/Id"
1565
+ },
1566
+ "target_name": {
1567
+ "type": "string"
1568
+ }
1569
+ }
1570
+ },
1450
1571
  "MessagePage": {
1451
1572
  "type": "object",
1452
1573
  "required": [
@@ -1708,12 +1829,65 @@
1708
1829
  },
1709
1830
  "GroupRole": {
1710
1831
  "type": "string",
1832
+ "description": "A moderator may delete other members' messages; owners and admins also manage the group.",
1711
1833
  "enum": [
1712
1834
  "owner",
1713
1835
  "admin",
1836
+ "moderator",
1714
1837
  "member"
1715
1838
  ]
1716
1839
  },
1840
+ "GroupRoleEvent": {
1841
+ "type": "object",
1842
+ "description": "A member got a new role; `owner` means the actor transferred ownership to them.",
1843
+ "required": [
1844
+ "id",
1845
+ "actor",
1846
+ "target",
1847
+ "role",
1848
+ "created_at"
1849
+ ],
1850
+ "properties": {
1851
+ "id": {
1852
+ "$ref": "#/$defs/Id"
1853
+ },
1854
+ "actor": {
1855
+ "description": "`null` when the account is gone.",
1856
+ "oneOf": [
1857
+ {
1858
+ "$ref": "#/$defs/User"
1859
+ },
1860
+ {
1861
+ "type": "null"
1862
+ }
1863
+ ]
1864
+ },
1865
+ "target": {
1866
+ "$ref": "#/$defs/User"
1867
+ },
1868
+ "role": {
1869
+ "$ref": "#/$defs/GroupRole"
1870
+ },
1871
+ "created_at": {
1872
+ "$ref": "#/$defs/Timestamp"
1873
+ }
1874
+ }
1875
+ },
1876
+ "GroupRoleLog": {
1877
+ "type": "object",
1878
+ "required": [
1879
+ "items"
1880
+ ],
1881
+ "properties": {
1882
+ "items": {
1883
+ "type": "array",
1884
+ "description": "Newest first, at most 100",
1885
+ "items": {
1886
+ "$ref": "#/$defs/GroupRoleEvent"
1887
+ }
1888
+ }
1889
+ }
1890
+ },
1717
1891
  "Chat": {
1718
1892
  "type": "object",
1719
1893
  "required": [
@@ -1962,6 +2136,7 @@
1962
2136
  "type": "string",
1963
2137
  "enum": [
1964
2138
  "admin",
2139
+ "moderator",
1965
2140
  "member"
1966
2141
  ]
1967
2142
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.1.0-alpha.11",
3
+ "version": "2.1.0-alpha.12",
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": {