@myronsi/messenger-api 2.1.0-alpha.1 → 2.1.0-alpha.2

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,11 @@
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.2
6
+
7
+ - Adds notification preferences, session-bound push device registration and per-tab activity leases.
8
+ - Adds chat notification mutes for one hour, eight hours, indefinitely, or until unmuted.
9
+
5
10
  ## 2.1.0-alpha.1
6
11
 
7
12
  - Registration returns a one-time recovery_key. GET /me adds recovery_setup_required.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.1. Do not edit. */
2
- export declare const API_VERSION: "2.1.0-alpha.1";
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.2. Do not edit. */
2
+ export declare const API_VERSION: "2.1.0-alpha.2";
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.1";
1
+ export const API_VERSION = "2.1.0-alpha.2";
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.1
4
+ version: 2.1.0-alpha.2
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
@@ -1715,6 +1715,160 @@ paths:
1715
1715
  "404": { $ref: "#/components/responses/NotFound" }
1716
1716
  "409": { $ref: "#/components/responses/Conflict" }
1717
1717
 
1718
+ /me/notifications:
1719
+ get:
1720
+ tags:
1721
+ - me
1722
+ operationId: getNotificationSettings
1723
+ summary: Notification preferences and supported push platforms
1724
+ responses:
1725
+ "200":
1726
+ description: Notification settings or registered device
1727
+ content:
1728
+ application/json:
1729
+ schema:
1730
+ $ref: "#/components/schemas/NotificationSettings"
1731
+ "400":
1732
+ $ref: "#/components/responses/BadRequest"
1733
+ "401":
1734
+ $ref: "#/components/responses/Unauthorized"
1735
+ "404":
1736
+ $ref: "#/components/responses/NotFound"
1737
+ "409":
1738
+ $ref: "#/components/responses/Conflict"
1739
+ put:
1740
+ tags:
1741
+ - me
1742
+ operationId: updateNotificationSettings
1743
+ summary: Replace notification preferences
1744
+ requestBody:
1745
+ required: true
1746
+ content:
1747
+ application/json:
1748
+ schema:
1749
+ $ref: "#/components/schemas/NotificationPreferences"
1750
+ responses:
1751
+ "204":
1752
+ description: Saved
1753
+ "400":
1754
+ $ref: "#/components/responses/BadRequest"
1755
+ "401":
1756
+ $ref: "#/components/responses/Unauthorized"
1757
+ "404":
1758
+ $ref: "#/components/responses/NotFound"
1759
+ "409":
1760
+ $ref: "#/components/responses/Conflict"
1761
+ /me/notification-devices:
1762
+ post:
1763
+ tags:
1764
+ - me
1765
+ operationId: registerNotificationDevice
1766
+ summary: Register a push destination for the current session
1767
+ requestBody:
1768
+ required: true
1769
+ content:
1770
+ application/json:
1771
+ schema:
1772
+ $ref: "#/components/schemas/NotificationDeviceRequest"
1773
+ responses:
1774
+ "200":
1775
+ description: Notification settings or registered device
1776
+ content:
1777
+ application/json:
1778
+ schema:
1779
+ $ref: "#/components/schemas/NotificationDeviceRegistered"
1780
+ "400":
1781
+ $ref: "#/components/responses/BadRequest"
1782
+ "401":
1783
+ $ref: "#/components/responses/Unauthorized"
1784
+ "404":
1785
+ $ref: "#/components/responses/NotFound"
1786
+ "409":
1787
+ $ref: "#/components/responses/Conflict"
1788
+ /me/notification-devices/{id}:
1789
+ parameters:
1790
+ - name: id
1791
+ in: path
1792
+ required: true
1793
+ schema:
1794
+ type: string
1795
+ format: uuid
1796
+ delete:
1797
+ tags:
1798
+ - me
1799
+ operationId: deleteNotificationDevice
1800
+ summary: Unregister a push destination for the current session
1801
+ responses:
1802
+ "204":
1803
+ description: Saved
1804
+ "400":
1805
+ $ref: "#/components/responses/BadRequest"
1806
+ "401":
1807
+ $ref: "#/components/responses/Unauthorized"
1808
+ "404":
1809
+ $ref: "#/components/responses/NotFound"
1810
+ "409":
1811
+ $ref: "#/components/responses/Conflict"
1812
+ /chats/{chatId}/notification-mute:
1813
+ parameters:
1814
+ - name: chatId
1815
+ in: path
1816
+ required: true
1817
+ schema:
1818
+ $ref: "#/components/schemas/Id"
1819
+ put:
1820
+ tags:
1821
+ - me
1822
+ operationId: setNotificationMute
1823
+ summary: Mute or unmute a chat
1824
+ requestBody:
1825
+ required: true
1826
+ content:
1827
+ application/json:
1828
+ schema:
1829
+ $ref: "#/components/schemas/NotificationMuteRequest"
1830
+ responses:
1831
+ "204":
1832
+ description: Saved
1833
+ "400":
1834
+ $ref: "#/components/responses/BadRequest"
1835
+ "401":
1836
+ $ref: "#/components/responses/Unauthorized"
1837
+ "404":
1838
+ $ref: "#/components/responses/NotFound"
1839
+ "409":
1840
+ $ref: "#/components/responses/Conflict"
1841
+ /me/notification-devices/{id}/activity:
1842
+ parameters:
1843
+ - name: id
1844
+ in: path
1845
+ required: true
1846
+ schema:
1847
+ type: string
1848
+ format: uuid
1849
+ put:
1850
+ tags:
1851
+ - me
1852
+ operationId: updateNotificationActivity
1853
+ summary: Report a visible client with a healthy live connection
1854
+ requestBody:
1855
+ required: true
1856
+ content:
1857
+ application/json:
1858
+ schema:
1859
+ $ref: "#/components/schemas/NotificationActivity"
1860
+ responses:
1861
+ "204":
1862
+ description: Saved
1863
+ "400":
1864
+ $ref: "#/components/responses/BadRequest"
1865
+ "401":
1866
+ $ref: "#/components/responses/Unauthorized"
1867
+ "404":
1868
+ $ref: "#/components/responses/NotFound"
1869
+ "409":
1870
+ $ref: "#/components/responses/Conflict"
1871
+
1718
1872
  components:
1719
1873
  securitySchemes:
1720
1874
  bearerAuth:
@@ -1845,6 +1999,106 @@ components:
1845
1999
  schema: { $ref: "#/components/schemas/Problem" }
1846
2000
 
1847
2001
  schemas:
2002
+ NotificationPreferences:
2003
+ type: object
2004
+ required:
2005
+ - enabled
2006
+ - sound
2007
+ - previews
2008
+ properties:
2009
+ enabled:
2010
+ type: boolean
2011
+ sound:
2012
+ type: boolean
2013
+ previews:
2014
+ type: boolean
2015
+ NotificationSettings:
2016
+ type: object
2017
+ required:
2018
+ - preferences
2019
+ - mutes
2020
+ - web_push
2021
+ - android_push
2022
+ - ios_push
2023
+ - vapid_public_key
2024
+ properties:
2025
+ preferences:
2026
+ $ref: "#/components/schemas/NotificationPreferences"
2027
+ mutes:
2028
+ type: array
2029
+ items:
2030
+ type: object
2031
+ required:
2032
+ - chat_id
2033
+ - until
2034
+ properties:
2035
+ chat_id:
2036
+ $ref: "#/components/schemas/Id"
2037
+ until:
2038
+ type: string
2039
+ format: date-time
2040
+ web_push:
2041
+ type: boolean
2042
+ android_push:
2043
+ type: boolean
2044
+ ios_push:
2045
+ type: boolean
2046
+ vapid_public_key:
2047
+ type: string
2048
+ NotificationDeviceRequest:
2049
+ type: object
2050
+ required:
2051
+ - platform
2052
+ - destination
2053
+ properties:
2054
+ platform:
2055
+ type: string
2056
+ enum:
2057
+ - web
2058
+ - android
2059
+ - ios
2060
+ destination:
2061
+ type: string
2062
+ minLength: 1
2063
+ maxLength: 4096
2064
+ p256dh:
2065
+ type: string
2066
+ maxLength: 128
2067
+ auth:
2068
+ type: string
2069
+ maxLength: 64
2070
+ NotificationDeviceRegistered:
2071
+ type: object
2072
+ required:
2073
+ - id
2074
+ properties:
2075
+ id:
2076
+ type: string
2077
+ format: uuid
2078
+ NotificationMuteRequest:
2079
+ type: object
2080
+ required:
2081
+ - duration
2082
+ properties:
2083
+ duration:
2084
+ type: string
2085
+ enum:
2086
+ - off
2087
+ - 1h
2088
+ - 8h
2089
+ - forever
2090
+ NotificationActivity:
2091
+ type: object
2092
+ required:
2093
+ - active
2094
+ - client_id
2095
+ properties:
2096
+ active:
2097
+ type: boolean
2098
+ client_id:
2099
+ type: string
2100
+ format: uuid
2101
+
1848
2102
  # ---------------------------------------------------------- basics
1849
2103
  Id:
1850
2104
  type: string
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.1. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.2. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -1340,10 +1340,139 @@ export interface paths {
1340
1340
  patch?: never;
1341
1341
  trace?: never;
1342
1342
  };
1343
+ "/me/notifications": {
1344
+ parameters: {
1345
+ query?: never;
1346
+ header?: never;
1347
+ path?: never;
1348
+ cookie?: never;
1349
+ };
1350
+ /** Notification preferences and supported push platforms */
1351
+ get: operations["getNotificationSettings"];
1352
+ /** Replace notification preferences */
1353
+ put: operations["updateNotificationSettings"];
1354
+ post?: never;
1355
+ delete?: never;
1356
+ options?: never;
1357
+ head?: never;
1358
+ patch?: never;
1359
+ trace?: never;
1360
+ };
1361
+ "/me/notification-devices": {
1362
+ parameters: {
1363
+ query?: never;
1364
+ header?: never;
1365
+ path?: never;
1366
+ cookie?: never;
1367
+ };
1368
+ get?: never;
1369
+ put?: never;
1370
+ /** Register a push destination for the current session */
1371
+ post: operations["registerNotificationDevice"];
1372
+ delete?: never;
1373
+ options?: never;
1374
+ head?: never;
1375
+ patch?: never;
1376
+ trace?: never;
1377
+ };
1378
+ "/me/notification-devices/{id}": {
1379
+ parameters: {
1380
+ query?: never;
1381
+ header?: never;
1382
+ path: {
1383
+ id: string;
1384
+ };
1385
+ cookie?: never;
1386
+ };
1387
+ get?: never;
1388
+ put?: never;
1389
+ post?: never;
1390
+ /** Unregister a push destination for the current session */
1391
+ delete: operations["deleteNotificationDevice"];
1392
+ options?: never;
1393
+ head?: never;
1394
+ patch?: never;
1395
+ trace?: never;
1396
+ };
1397
+ "/chats/{chatId}/notification-mute": {
1398
+ parameters: {
1399
+ query?: never;
1400
+ header?: never;
1401
+ path: {
1402
+ chatId: components["schemas"]["Id"];
1403
+ };
1404
+ cookie?: never;
1405
+ };
1406
+ get?: never;
1407
+ /** Mute or unmute a chat */
1408
+ put: operations["setNotificationMute"];
1409
+ post?: never;
1410
+ delete?: never;
1411
+ options?: never;
1412
+ head?: never;
1413
+ patch?: never;
1414
+ trace?: never;
1415
+ };
1416
+ "/me/notification-devices/{id}/activity": {
1417
+ parameters: {
1418
+ query?: never;
1419
+ header?: never;
1420
+ path: {
1421
+ id: string;
1422
+ };
1423
+ cookie?: never;
1424
+ };
1425
+ get?: never;
1426
+ /** Report a visible client with a healthy live connection */
1427
+ put: operations["updateNotificationActivity"];
1428
+ post?: never;
1429
+ delete?: never;
1430
+ options?: never;
1431
+ head?: never;
1432
+ patch?: never;
1433
+ trace?: never;
1434
+ };
1343
1435
  }
1344
1436
  export type webhooks = Record<string, never>;
1345
1437
  export interface components {
1346
1438
  schemas: {
1439
+ NotificationPreferences: {
1440
+ enabled: boolean;
1441
+ sound: boolean;
1442
+ previews: boolean;
1443
+ };
1444
+ NotificationSettings: {
1445
+ preferences: components["schemas"]["NotificationPreferences"];
1446
+ mutes: {
1447
+ chat_id: components["schemas"]["Id"];
1448
+ /** Format: date-time */
1449
+ until: string;
1450
+ }[];
1451
+ web_push: boolean;
1452
+ android_push: boolean;
1453
+ ios_push: boolean;
1454
+ vapid_public_key: string;
1455
+ };
1456
+ NotificationDeviceRequest: {
1457
+ /** @enum {string} */
1458
+ platform: "web" | "android" | "ios";
1459
+ destination: string;
1460
+ p256dh?: string;
1461
+ auth?: string;
1462
+ };
1463
+ NotificationDeviceRegistered: {
1464
+ /** Format: uuid */
1465
+ id: string;
1466
+ };
1467
+ NotificationMuteRequest: {
1468
+ /** @enum {string} */
1469
+ duration: "off" | "1h" | "8h" | "forever";
1470
+ };
1471
+ NotificationActivity: {
1472
+ active: boolean;
1473
+ /** Format: uuid */
1474
+ client_id: string;
1475
+ };
1347
1476
  /**
1348
1477
  * @description Decimal ID as a string (Snowflake IDs exceed 2^53).
1349
1478
  * @example 7217400317439950848
@@ -4311,4 +4440,162 @@ export interface operations {
4311
4440
  426: components["responses"]["ClientOutdated"];
4312
4441
  };
4313
4442
  };
4443
+ getNotificationSettings: {
4444
+ parameters: {
4445
+ query?: never;
4446
+ header?: never;
4447
+ path?: never;
4448
+ cookie?: never;
4449
+ };
4450
+ requestBody?: never;
4451
+ responses: {
4452
+ /** @description Notification settings or registered device */
4453
+ 200: {
4454
+ headers: {
4455
+ [name: string]: unknown;
4456
+ };
4457
+ content: {
4458
+ "application/json": components["schemas"]["NotificationSettings"];
4459
+ };
4460
+ };
4461
+ 400: components["responses"]["BadRequest"];
4462
+ 401: components["responses"]["Unauthorized"];
4463
+ 404: components["responses"]["NotFound"];
4464
+ 409: components["responses"]["Conflict"];
4465
+ };
4466
+ };
4467
+ updateNotificationSettings: {
4468
+ parameters: {
4469
+ query?: never;
4470
+ header?: never;
4471
+ path?: never;
4472
+ cookie?: never;
4473
+ };
4474
+ requestBody: {
4475
+ content: {
4476
+ "application/json": components["schemas"]["NotificationPreferences"];
4477
+ };
4478
+ };
4479
+ responses: {
4480
+ /** @description Saved */
4481
+ 204: {
4482
+ headers: {
4483
+ [name: string]: unknown;
4484
+ };
4485
+ content?: never;
4486
+ };
4487
+ 400: components["responses"]["BadRequest"];
4488
+ 401: components["responses"]["Unauthorized"];
4489
+ 404: components["responses"]["NotFound"];
4490
+ 409: components["responses"]["Conflict"];
4491
+ };
4492
+ };
4493
+ registerNotificationDevice: {
4494
+ parameters: {
4495
+ query?: never;
4496
+ header?: never;
4497
+ path?: never;
4498
+ cookie?: never;
4499
+ };
4500
+ requestBody: {
4501
+ content: {
4502
+ "application/json": components["schemas"]["NotificationDeviceRequest"];
4503
+ };
4504
+ };
4505
+ responses: {
4506
+ /** @description Notification settings or registered device */
4507
+ 200: {
4508
+ headers: {
4509
+ [name: string]: unknown;
4510
+ };
4511
+ content: {
4512
+ "application/json": components["schemas"]["NotificationDeviceRegistered"];
4513
+ };
4514
+ };
4515
+ 400: components["responses"]["BadRequest"];
4516
+ 401: components["responses"]["Unauthorized"];
4517
+ 404: components["responses"]["NotFound"];
4518
+ 409: components["responses"]["Conflict"];
4519
+ };
4520
+ };
4521
+ deleteNotificationDevice: {
4522
+ parameters: {
4523
+ query?: never;
4524
+ header?: never;
4525
+ path: {
4526
+ id: string;
4527
+ };
4528
+ cookie?: never;
4529
+ };
4530
+ requestBody?: never;
4531
+ responses: {
4532
+ /** @description Saved */
4533
+ 204: {
4534
+ headers: {
4535
+ [name: string]: unknown;
4536
+ };
4537
+ content?: never;
4538
+ };
4539
+ 400: components["responses"]["BadRequest"];
4540
+ 401: components["responses"]["Unauthorized"];
4541
+ 404: components["responses"]["NotFound"];
4542
+ 409: components["responses"]["Conflict"];
4543
+ };
4544
+ };
4545
+ setNotificationMute: {
4546
+ parameters: {
4547
+ query?: never;
4548
+ header?: never;
4549
+ path: {
4550
+ chatId: components["schemas"]["Id"];
4551
+ };
4552
+ cookie?: never;
4553
+ };
4554
+ requestBody: {
4555
+ content: {
4556
+ "application/json": components["schemas"]["NotificationMuteRequest"];
4557
+ };
4558
+ };
4559
+ responses: {
4560
+ /** @description Saved */
4561
+ 204: {
4562
+ headers: {
4563
+ [name: string]: unknown;
4564
+ };
4565
+ content?: never;
4566
+ };
4567
+ 400: components["responses"]["BadRequest"];
4568
+ 401: components["responses"]["Unauthorized"];
4569
+ 404: components["responses"]["NotFound"];
4570
+ 409: components["responses"]["Conflict"];
4571
+ };
4572
+ };
4573
+ updateNotificationActivity: {
4574
+ parameters: {
4575
+ query?: never;
4576
+ header?: never;
4577
+ path: {
4578
+ id: string;
4579
+ };
4580
+ cookie?: never;
4581
+ };
4582
+ requestBody: {
4583
+ content: {
4584
+ "application/json": components["schemas"]["NotificationActivity"];
4585
+ };
4586
+ };
4587
+ responses: {
4588
+ /** @description Saved */
4589
+ 204: {
4590
+ headers: {
4591
+ [name: string]: unknown;
4592
+ };
4593
+ content?: never;
4594
+ };
4595
+ 400: components["responses"]["BadRequest"];
4596
+ 401: components["responses"]["Unauthorized"];
4597
+ 404: components["responses"]["NotFound"];
4598
+ 409: components["responses"]["Conflict"];
4599
+ };
4600
+ };
4314
4601
  }
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.1. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.2. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -1,6 +1,147 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$defs": {
4
+ "NotificationPreferences": {
5
+ "type": "object",
6
+ "required": [
7
+ "enabled",
8
+ "sound",
9
+ "previews"
10
+ ],
11
+ "properties": {
12
+ "enabled": {
13
+ "type": "boolean"
14
+ },
15
+ "sound": {
16
+ "type": "boolean"
17
+ },
18
+ "previews": {
19
+ "type": "boolean"
20
+ }
21
+ }
22
+ },
23
+ "NotificationSettings": {
24
+ "type": "object",
25
+ "required": [
26
+ "preferences",
27
+ "mutes",
28
+ "web_push",
29
+ "android_push",
30
+ "ios_push",
31
+ "vapid_public_key"
32
+ ],
33
+ "properties": {
34
+ "preferences": {
35
+ "$ref": "#/$defs/NotificationPreferences"
36
+ },
37
+ "mutes": {
38
+ "type": "array",
39
+ "items": {
40
+ "type": "object",
41
+ "required": [
42
+ "chat_id",
43
+ "until"
44
+ ],
45
+ "properties": {
46
+ "chat_id": {
47
+ "$ref": "#/$defs/Id"
48
+ },
49
+ "until": {
50
+ "type": "string",
51
+ "format": "date-time"
52
+ }
53
+ }
54
+ }
55
+ },
56
+ "web_push": {
57
+ "type": "boolean"
58
+ },
59
+ "android_push": {
60
+ "type": "boolean"
61
+ },
62
+ "ios_push": {
63
+ "type": "boolean"
64
+ },
65
+ "vapid_public_key": {
66
+ "type": "string"
67
+ }
68
+ }
69
+ },
70
+ "NotificationDeviceRequest": {
71
+ "type": "object",
72
+ "required": [
73
+ "platform",
74
+ "destination"
75
+ ],
76
+ "properties": {
77
+ "platform": {
78
+ "type": "string",
79
+ "enum": [
80
+ "web",
81
+ "android",
82
+ "ios"
83
+ ]
84
+ },
85
+ "destination": {
86
+ "type": "string",
87
+ "minLength": 1,
88
+ "maxLength": 4096
89
+ },
90
+ "p256dh": {
91
+ "type": "string",
92
+ "maxLength": 128
93
+ },
94
+ "auth": {
95
+ "type": "string",
96
+ "maxLength": 64
97
+ }
98
+ }
99
+ },
100
+ "NotificationDeviceRegistered": {
101
+ "type": "object",
102
+ "required": [
103
+ "id"
104
+ ],
105
+ "properties": {
106
+ "id": {
107
+ "type": "string",
108
+ "format": "uuid"
109
+ }
110
+ }
111
+ },
112
+ "NotificationMuteRequest": {
113
+ "type": "object",
114
+ "required": [
115
+ "duration"
116
+ ],
117
+ "properties": {
118
+ "duration": {
119
+ "type": "string",
120
+ "enum": [
121
+ "off",
122
+ "1h",
123
+ "8h",
124
+ "forever"
125
+ ]
126
+ }
127
+ }
128
+ },
129
+ "NotificationActivity": {
130
+ "type": "object",
131
+ "required": [
132
+ "active",
133
+ "client_id"
134
+ ],
135
+ "properties": {
136
+ "active": {
137
+ "type": "boolean"
138
+ },
139
+ "client_id": {
140
+ "type": "string",
141
+ "format": "uuid"
142
+ }
143
+ }
144
+ },
4
145
  "Id": {
5
146
  "type": "string",
6
147
  "pattern": "^[0-9]{1,19}$",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.1.0-alpha.1",
3
+ "version": "2.1.0-alpha.2",
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": {