@myronsi/messenger-api 2.0.0-alpha.5.next.46 → 2.0.0-alpha.7.next.49

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,23 @@
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.7
6
+
7
+ Search:
8
+
9
+ - New `GET /search/messages`: full-text search across all chats of the caller, with filters (`chat_id`, `sender_id`,
10
+ `type`, `from`, `to`) and `search_after` paging.
11
+ - `SearchHit.highlight` wraps the matched words in U+E000 and U+E001.
12
+ - `GET /chats/{chat_id}/messages/search` can answer `429` (searches are rate limited).
13
+
14
+ ## 2.0.0-alpha.6
15
+
16
+ Groups, found while implementing them:
17
+
18
+ - `POST /groups` can answer `403`: a member who does not allow invitations from the caller fails the request.
19
+ - `PUT /groups/{chat_id}/avatar` (`422`: not an image the caller uploaded as an avatar) and
20
+ `POST /groups/{chat_id}/transfer-owner` (`422`: to yourself) document their validation errors.
21
+
5
22
  ## 2.0.0-alpha.5
6
23
 
7
24
  Chats, found while implementing the chat list:
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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";
1
+ /* Generated from api/openapi.yaml 2.0.0-alpha.7. Do not edit. */
2
+ export declare const API_VERSION: "2.0.0-alpha.7";
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.5";
1
+ export const API_VERSION = "2.0.0-alpha.7";
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.5
4
+ version: 2.0.0-alpha.7
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
@@ -1127,6 +1127,7 @@ paths:
1127
1127
  "401": { $ref: "#/components/responses/Unauthorized" }
1128
1128
  "404": { $ref: "#/components/responses/NotFound" }
1129
1129
  "422": { $ref: "#/components/responses/ValidationFailed" }
1130
+ "429": { $ref: "#/components/responses/TooManyRequests" }
1130
1131
  /chats/{chat_id}/media:
1131
1132
  parameters:
1132
1133
  - $ref: "#/components/parameters/ClientVersion"
@@ -1240,6 +1241,62 @@ paths:
1240
1241
  "422": { $ref: "#/components/responses/ValidationFailed" }
1241
1242
  "429": { $ref: "#/components/responses/TooManyRequests" }
1242
1243
 
1244
+ # -------------------------------------------------------------- search
1245
+ /search/messages:
1246
+ parameters:
1247
+ - $ref: "#/components/parameters/ClientVersion"
1248
+ - $ref: "#/components/parameters/ClientApiVersion"
1249
+ get:
1250
+ tags: [messages]
1251
+ operationId: searchAllMessages
1252
+ summary: Search messages in all my chats
1253
+ description: |
1254
+ Full-text search across every chat the caller is in, newest first. Only chats the caller
1255
+ is a member of are searched, messages they deleted for themselves are left out, and every
1256
+ hit is checked against the message store before it is returned (a deleted message never
1257
+ shows, even when the index lags behind). Edits and deletions reach the results within a
1258
+ few seconds.
1259
+ parameters:
1260
+ - name: q
1261
+ in: query
1262
+ required: true
1263
+ schema: { type: string, minLength: 2, maxLength: 128 }
1264
+ - name: chat_id
1265
+ in: query
1266
+ description: Only this chat
1267
+ schema: { $ref: "#/components/schemas/Id" }
1268
+ - name: sender_id
1269
+ in: query
1270
+ description: Only messages of this user
1271
+ schema: { $ref: "#/components/schemas/Id" }
1272
+ - name: type
1273
+ in: query
1274
+ schema:
1275
+ type: string
1276
+ enum: [text, file, voice]
1277
+ - name: from
1278
+ in: query
1279
+ description: Messages created at or after this time
1280
+ schema: { $ref: "#/components/schemas/Timestamp" }
1281
+ - name: to
1282
+ in: query
1283
+ description: Messages created before this time
1284
+ schema: { $ref: "#/components/schemas/Timestamp" }
1285
+ - $ref: "#/components/parameters/Limit"
1286
+ - $ref: "#/components/parameters/After"
1287
+ responses:
1288
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1289
+ "400": { $ref: "#/components/responses/BadRequest" }
1290
+ "200":
1291
+ description: Matches, newest first
1292
+ content:
1293
+ application/json:
1294
+ schema: { $ref: "#/components/schemas/MessageSearchPage" }
1295
+ "401": { $ref: "#/components/responses/Unauthorized" }
1296
+ "404": { $ref: "#/components/responses/NotFound" }
1297
+ "422": { $ref: "#/components/responses/ValidationFailed" }
1298
+ "429": { $ref: "#/components/responses/TooManyRequests" }
1299
+
1243
1300
  # ------------------------------------------------------------ requests
1244
1301
  /requests:
1245
1302
  parameters:
@@ -1333,7 +1390,9 @@ paths:
1333
1390
  tags: [groups]
1334
1391
  operationId: createGroup
1335
1392
  summary: Create a group
1336
- description: Members whose `group_invites` setting requires approval get an approval request instead of being added.
1393
+ description: |
1394
+ Members whose `group_invites` setting requires approval get an approval request instead of being added.
1395
+ If any of them does not allow invitations from the caller at all, nothing is created (`403`).
1337
1396
  requestBody:
1338
1397
  required: true
1339
1398
  content:
@@ -1348,6 +1407,7 @@ paths:
1348
1407
  schema: { $ref: "#/components/schemas/Group" }
1349
1408
  "400": { $ref: "#/components/responses/BadRequest" }
1350
1409
  "401": { $ref: "#/components/responses/Unauthorized" }
1410
+ "403": { $ref: "#/components/responses/Forbidden" }
1351
1411
  "422": { $ref: "#/components/responses/ValidationFailed" }
1352
1412
  "429": { $ref: "#/components/responses/TooManyRequests" }
1353
1413
  /groups/{chat_id}:
@@ -1411,6 +1471,7 @@ paths:
1411
1471
  tags: [groups]
1412
1472
  operationId: setGroupAvatar
1413
1473
  summary: Set the group avatar from an uploaded attachment
1474
+ description: The attachment must be an image the caller uploaded with purpose `avatar` (`422` otherwise).
1414
1475
  requestBody:
1415
1476
  required: true
1416
1477
  content:
@@ -1427,6 +1488,7 @@ paths:
1427
1488
  "401": { $ref: "#/components/responses/Unauthorized" }
1428
1489
  "403": { $ref: "#/components/responses/Forbidden" }
1429
1490
  "404": { $ref: "#/components/responses/NotFound" }
1491
+ "422": { $ref: "#/components/responses/ValidationFailed" }
1430
1492
  /groups/{chat_id}/participants:
1431
1493
  parameters:
1432
1494
  - $ref: "#/components/parameters/ClientVersion"
@@ -1501,6 +1563,7 @@ paths:
1501
1563
  tags: [groups]
1502
1564
  operationId: transferGroupOwnership
1503
1565
  summary: Make another member the owner
1566
+ description: The previous owner becomes an admin. Transferring to yourself is `422`.
1504
1567
  requestBody:
1505
1568
  required: true
1506
1569
  content:
@@ -1517,6 +1580,7 @@ paths:
1517
1580
  "401": { $ref: "#/components/responses/Unauthorized" }
1518
1581
  "403": { $ref: "#/components/responses/Forbidden" }
1519
1582
  "404": { $ref: "#/components/responses/NotFound" }
1583
+ "422": { $ref: "#/components/responses/ValidationFailed" }
1520
1584
  /groups/{chat_id}/leave:
1521
1585
  parameters:
1522
1586
  - $ref: "#/components/parameters/ClientVersion"
@@ -2189,7 +2253,11 @@ components:
2189
2253
  message: { $ref: "#/components/schemas/Message" }
2190
2254
  highlight:
2191
2255
  type: [string, "null"]
2192
- description: Plain-text excerpt; never HTML.
2256
+ description: |
2257
+ Plain-text excerpt of the matching text or file name; never HTML. The matched words are
2258
+ wrapped in U+E000 (start) and U+E001 (end), characters of the Unicode private use area,
2259
+ so a client can mark them without parsing markup. `null` when the message matched without
2260
+ an excerpt.
2193
2261
  MessageSearchPage:
2194
2262
  type: object
2195
2263
  required: [items, next_cursor]
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.0.0-alpha.5. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.0.0-alpha.7. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -990,6 +990,35 @@ export interface paths {
990
990
  patch?: never;
991
991
  trace?: never;
992
992
  };
993
+ "/search/messages": {
994
+ parameters: {
995
+ query?: never;
996
+ header?: {
997
+ /** @description Version of the client app, for logs and the per-client metric. */
998
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
999
+ /** @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`). */
1000
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
1001
+ };
1002
+ path?: never;
1003
+ cookie?: never;
1004
+ };
1005
+ /**
1006
+ * Search messages in all my chats
1007
+ * @description Full-text search across every chat the caller is in, newest first. Only chats the caller
1008
+ * is a member of are searched, messages they deleted for themselves are left out, and every
1009
+ * hit is checked against the message store before it is returned (a deleted message never
1010
+ * shows, even when the index lags behind). Edits and deletions reach the results within a
1011
+ * few seconds.
1012
+ */
1013
+ get: operations["searchAllMessages"];
1014
+ put?: never;
1015
+ post?: never;
1016
+ delete?: never;
1017
+ options?: never;
1018
+ head?: never;
1019
+ patch?: never;
1020
+ trace?: never;
1021
+ };
993
1022
  "/requests": {
994
1023
  parameters: {
995
1024
  query?: never;
@@ -1078,6 +1107,7 @@ export interface paths {
1078
1107
  /**
1079
1108
  * Create a group
1080
1109
  * @description Members whose `group_invites` setting requires approval get an approval request instead of being added.
1110
+ * If any of them does not allow invitations from the caller at all, nothing is created (`403`).
1081
1111
  */
1082
1112
  post: operations["createGroup"];
1083
1113
  delete?: never;
@@ -1127,7 +1157,10 @@ export interface paths {
1127
1157
  cookie?: never;
1128
1158
  };
1129
1159
  get?: never;
1130
- /** Set the group avatar from an uploaded attachment */
1160
+ /**
1161
+ * Set the group avatar from an uploaded attachment
1162
+ * @description The attachment must be an image the caller uploaded with purpose `avatar` (`422` otherwise).
1163
+ */
1131
1164
  put: operations["setGroupAvatar"];
1132
1165
  post?: never;
1133
1166
  delete?: never;
@@ -1202,7 +1235,10 @@ export interface paths {
1202
1235
  };
1203
1236
  get?: never;
1204
1237
  put?: never;
1205
- /** Make another member the owner */
1238
+ /**
1239
+ * Make another member the owner
1240
+ * @description The previous owner becomes an admin. Transferring to yourself is `422`.
1241
+ */
1206
1242
  post: operations["transferGroupOwnership"];
1207
1243
  delete?: never;
1208
1244
  options?: never;
@@ -1543,7 +1579,12 @@ export interface components {
1543
1579
  };
1544
1580
  SearchHit: {
1545
1581
  message: components["schemas"]["Message"];
1546
- /** @description Plain-text excerpt; never HTML. */
1582
+ /**
1583
+ * @description Plain-text excerpt of the matching text or file name; never HTML. The matched words are
1584
+ * wrapped in U+E000 (start) and U+E001 (end), characters of the Unicode private use area,
1585
+ * so a client can mark them without parsing markup. `null` when the message matched without
1586
+ * an excerpt.
1587
+ */
1547
1588
  highlight?: string | null;
1548
1589
  };
1549
1590
  MessageSearchPage: {
@@ -3310,6 +3351,7 @@ export interface operations {
3310
3351
  404: components["responses"]["NotFound"];
3311
3352
  422: components["responses"]["ValidationFailed"];
3312
3353
  426: components["responses"]["ClientOutdated"];
3354
+ 429: components["responses"]["TooManyRequests"];
3313
3355
  };
3314
3356
  };
3315
3357
  listChatMedia: {
@@ -3460,6 +3502,52 @@ export interface operations {
3460
3502
  429: components["responses"]["TooManyRequests"];
3461
3503
  };
3462
3504
  };
3505
+ searchAllMessages: {
3506
+ parameters: {
3507
+ query: {
3508
+ q: string;
3509
+ /** @description Only this chat */
3510
+ chat_id?: components["schemas"]["Id"];
3511
+ /** @description Only messages of this user */
3512
+ sender_id?: components["schemas"]["Id"];
3513
+ type?: "text" | "file" | "voice";
3514
+ /** @description Messages created at or after this time */
3515
+ from?: components["schemas"]["Timestamp"];
3516
+ /** @description Messages created before this time */
3517
+ to?: components["schemas"]["Timestamp"];
3518
+ /** @description Page size */
3519
+ limit?: components["parameters"]["Limit"];
3520
+ /** @description Opaque `next_cursor` of the previous page */
3521
+ after?: components["parameters"]["After"];
3522
+ };
3523
+ header?: {
3524
+ /** @description Version of the client app, for logs and the per-client metric. */
3525
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
3526
+ /** @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`). */
3527
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
3528
+ };
3529
+ path?: never;
3530
+ cookie?: never;
3531
+ };
3532
+ requestBody?: never;
3533
+ responses: {
3534
+ /** @description Matches, newest first */
3535
+ 200: {
3536
+ headers: {
3537
+ [name: string]: unknown;
3538
+ };
3539
+ content: {
3540
+ "application/json": components["schemas"]["MessageSearchPage"];
3541
+ };
3542
+ };
3543
+ 400: components["responses"]["BadRequest"];
3544
+ 401: components["responses"]["Unauthorized"];
3545
+ 404: components["responses"]["NotFound"];
3546
+ 422: components["responses"]["ValidationFailed"];
3547
+ 426: components["responses"]["ClientOutdated"];
3548
+ 429: components["responses"]["TooManyRequests"];
3549
+ };
3550
+ };
3463
3551
  listApprovalRequests: {
3464
3552
  parameters: {
3465
3553
  query?: {
@@ -3622,6 +3710,7 @@ export interface operations {
3622
3710
  };
3623
3711
  400: components["responses"]["BadRequest"];
3624
3712
  401: components["responses"]["Unauthorized"];
3713
+ 403: components["responses"]["Forbidden"];
3625
3714
  422: components["responses"]["ValidationFailed"];
3626
3715
  426: components["responses"]["ClientOutdated"];
3627
3716
  429: components["responses"]["TooManyRequests"];
@@ -3758,6 +3847,7 @@ export interface operations {
3758
3847
  401: components["responses"]["Unauthorized"];
3759
3848
  403: components["responses"]["Forbidden"];
3760
3849
  404: components["responses"]["NotFound"];
3850
+ 422: components["responses"]["ValidationFailed"];
3761
3851
  426: components["responses"]["ClientOutdated"];
3762
3852
  };
3763
3853
  };
@@ -3900,6 +3990,7 @@ export interface operations {
3900
3990
  401: components["responses"]["Unauthorized"];
3901
3991
  403: components["responses"]["Forbidden"];
3902
3992
  404: components["responses"]["NotFound"];
3993
+ 422: components["responses"]["ValidationFailed"];
3903
3994
  426: components["responses"]["ClientOutdated"];
3904
3995
  };
3905
3996
  };
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.0.0-alpha.5. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.0.0-alpha.7. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -1178,7 +1178,7 @@
1178
1178
  "string",
1179
1179
  "null"
1180
1180
  ],
1181
- "description": "Plain-text excerpt; never HTML."
1181
+ "description": "Plain-text excerpt of the matching text or file name; never HTML. The matched words are\nwrapped in U+E000 (start) and U+E001 (end), characters of the Unicode private use area,\nso a client can mark them without parsing markup. `null` when the message matched without\nan excerpt.\n"
1182
1182
  }
1183
1183
  }
1184
1184
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.0.0-alpha.5.next.46",
3
+ "version": "2.0.0-alpha.7.next.49",
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": {