@liveblocks/node 2.24.0-deque1 → 2.24.0
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/dist/index.cjs +137 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +108 -17
- package/dist/index.d.ts +108 -17
- package/dist/index.js +138 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@ var _core = require('@liveblocks/core');
|
|
|
3
3
|
|
|
4
4
|
// src/version.ts
|
|
5
5
|
var PKG_NAME = "@liveblocks/node";
|
|
6
|
-
var PKG_VERSION = "2.24.0
|
|
6
|
+
var PKG_VERSION = "2.24.0";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
8
8
|
|
|
9
9
|
// src/client.ts
|
|
@@ -25,6 +25,8 @@ var PKG_FORMAT = "cjs";
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
+
|
|
29
|
+
|
|
28
30
|
// src/lib/itertools.ts
|
|
29
31
|
async function asyncConsume(iterable) {
|
|
30
32
|
const result = [];
|
|
@@ -1021,6 +1023,29 @@ var Liveblocks = class {
|
|
|
1021
1023
|
}
|
|
1022
1024
|
return await res.json();
|
|
1023
1025
|
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Gets a thread's subscriptions.
|
|
1028
|
+
*
|
|
1029
|
+
* @param params.roomId The room ID to get the thread subscriptions from.
|
|
1030
|
+
* @param params.threadId The thread ID to get the subscriptions from.
|
|
1031
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1032
|
+
* @returns An array of subscriptions.
|
|
1033
|
+
*/
|
|
1034
|
+
async getThreadSubscriptions(params, options) {
|
|
1035
|
+
const { roomId, threadId } = params;
|
|
1036
|
+
const res = await this.#get(
|
|
1037
|
+
_core.url`/v2/rooms/${roomId}/threads/${threadId}/subscriptions`,
|
|
1038
|
+
void 0,
|
|
1039
|
+
options
|
|
1040
|
+
);
|
|
1041
|
+
if (!res.ok) {
|
|
1042
|
+
throw await LiveblocksError.from(res);
|
|
1043
|
+
}
|
|
1044
|
+
const { data } = await res.json();
|
|
1045
|
+
return {
|
|
1046
|
+
data: data.map(_core.convertToUserSubscriptionData)
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1024
1049
|
/**
|
|
1025
1050
|
* Gets a thread's comment.
|
|
1026
1051
|
*
|
|
@@ -1192,6 +1217,46 @@ var Liveblocks = class {
|
|
|
1192
1217
|
}
|
|
1193
1218
|
return _core.convertToThreadData.call(void 0, await res.json());
|
|
1194
1219
|
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Subscribes a user to a thread.
|
|
1222
|
+
* @param params.roomId The room ID of the thread.
|
|
1223
|
+
* @param params.threadId The thread ID to subscribe to.
|
|
1224
|
+
* @param params.data.userId The user ID of the user to subscribe to the thread.
|
|
1225
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1226
|
+
* @returns The thread subscription.
|
|
1227
|
+
*/
|
|
1228
|
+
async subscribeToThread(params, options) {
|
|
1229
|
+
const { roomId, threadId } = params;
|
|
1230
|
+
const res = await this.#post(
|
|
1231
|
+
_core.url`/v2/rooms/${roomId}/threads/${threadId}/subscribe`,
|
|
1232
|
+
{ userId: params.data.userId },
|
|
1233
|
+
options
|
|
1234
|
+
);
|
|
1235
|
+
if (!res.ok) {
|
|
1236
|
+
throw await LiveblocksError.from(res);
|
|
1237
|
+
}
|
|
1238
|
+
return _core.convertToSubscriptionData.call(void 0,
|
|
1239
|
+
await res.json()
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Unsubscribes a user from a thread.
|
|
1244
|
+
* @param params.roomId The room ID of the thread.
|
|
1245
|
+
* @param params.threadId The thread ID to unsubscribe from.
|
|
1246
|
+
* @param params.data.userId The user ID of the user to unsubscribe from the thread.
|
|
1247
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1248
|
+
*/
|
|
1249
|
+
async unsubscribeFromThread(params, options) {
|
|
1250
|
+
const { roomId, threadId } = params;
|
|
1251
|
+
const res = await this.#post(
|
|
1252
|
+
_core.url`/v2/rooms/${roomId}/threads/${threadId}/unsubscribe`,
|
|
1253
|
+
{ userId: params.data.userId },
|
|
1254
|
+
options
|
|
1255
|
+
);
|
|
1256
|
+
if (!res.ok) {
|
|
1257
|
+
throw await LiveblocksError.from(res);
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1195
1260
|
/**
|
|
1196
1261
|
* Updates the metadata of the specified thread in a room.
|
|
1197
1262
|
* @param params.roomId The room ID to update the thread in.
|
|
@@ -1350,15 +1415,48 @@ var Liveblocks = class {
|
|
|
1350
1415
|
}
|
|
1351
1416
|
}
|
|
1352
1417
|
/**
|
|
1353
|
-
*
|
|
1354
|
-
*
|
|
1355
|
-
*
|
|
1418
|
+
* @deprecated Renamed to `getRoomSubscriptionSettings`
|
|
1419
|
+
*
|
|
1420
|
+
* Gets the user's room subscription settings.
|
|
1421
|
+
* @param params.userId The user ID to get the room subscription settings from.
|
|
1422
|
+
* @param params.roomId The room ID to get the room subscription settings from.
|
|
1356
1423
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1357
1424
|
*/
|
|
1358
1425
|
async getRoomNotificationSettings(params, options) {
|
|
1426
|
+
return this.getRoomSubscriptionSettings(params, options);
|
|
1427
|
+
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Returns all room subscription settings for a user.
|
|
1430
|
+
* @param params.userId The user ID to get the room subscription settings from.
|
|
1431
|
+
* @param params.startingAfter (optional) The cursor to start the pagination from.
|
|
1432
|
+
* @param params.limit (optional) The number of items to return.
|
|
1433
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1434
|
+
*/
|
|
1435
|
+
async getUserRoomSubscriptionSettings(params, options) {
|
|
1436
|
+
const { userId, startingAfter, limit } = params;
|
|
1437
|
+
const res = await this.#get(
|
|
1438
|
+
_core.url`/v2/users/${userId}/room-subscription-settings`,
|
|
1439
|
+
{
|
|
1440
|
+
startingAfter,
|
|
1441
|
+
limit
|
|
1442
|
+
},
|
|
1443
|
+
options
|
|
1444
|
+
);
|
|
1445
|
+
if (!res.ok) {
|
|
1446
|
+
throw await LiveblocksError.from(res);
|
|
1447
|
+
}
|
|
1448
|
+
return await res.json();
|
|
1449
|
+
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Gets the user's room subscription settings.
|
|
1452
|
+
* @param params.userId The user ID to get the room subscription settings from.
|
|
1453
|
+
* @param params.roomId The room ID to get the room subscription settings from.
|
|
1454
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1455
|
+
*/
|
|
1456
|
+
async getRoomSubscriptionSettings(params, options) {
|
|
1359
1457
|
const { userId, roomId } = params;
|
|
1360
1458
|
const res = await this.#get(
|
|
1361
|
-
_core.url`/v2/rooms/${roomId}/users/${userId}/
|
|
1459
|
+
_core.url`/v2/rooms/${roomId}/users/${userId}/subscription-settings`,
|
|
1362
1460
|
void 0,
|
|
1363
1461
|
options
|
|
1364
1462
|
);
|
|
@@ -1368,16 +1466,28 @@ var Liveblocks = class {
|
|
|
1368
1466
|
return await res.json();
|
|
1369
1467
|
}
|
|
1370
1468
|
/**
|
|
1371
|
-
*
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1374
|
-
* @param params.
|
|
1469
|
+
* @deprecated Renamed to `updateRoomSubscriptionSettings`
|
|
1470
|
+
*
|
|
1471
|
+
* Updates the user's room subscription settings.
|
|
1472
|
+
* @param params.userId The user ID to update the room subscription settings for.
|
|
1473
|
+
* @param params.roomId The room ID to update the room subscription settings for.
|
|
1474
|
+
* @param params.data The new room subscription settings for the user.
|
|
1375
1475
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1376
1476
|
*/
|
|
1377
1477
|
async updateRoomNotificationSettings(params, options) {
|
|
1478
|
+
return this.updateRoomSubscriptionSettings(params, options);
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Updates the user's room subscription settings.
|
|
1482
|
+
* @param params.userId The user ID to update the room subscription settings for.
|
|
1483
|
+
* @param params.roomId The room ID to update the room subscription settings for.
|
|
1484
|
+
* @param params.data The new room subscription settings for the user.
|
|
1485
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1486
|
+
*/
|
|
1487
|
+
async updateRoomSubscriptionSettings(params, options) {
|
|
1378
1488
|
const { userId, roomId, data } = params;
|
|
1379
1489
|
const res = await this.#post(
|
|
1380
|
-
_core.url`/v2/rooms/${roomId}/users/${userId}/
|
|
1490
|
+
_core.url`/v2/rooms/${roomId}/users/${userId}/subscription-settings`,
|
|
1381
1491
|
data,
|
|
1382
1492
|
options
|
|
1383
1493
|
);
|
|
@@ -1387,15 +1497,26 @@ var Liveblocks = class {
|
|
|
1387
1497
|
return await res.json();
|
|
1388
1498
|
}
|
|
1389
1499
|
/**
|
|
1390
|
-
*
|
|
1391
|
-
*
|
|
1392
|
-
*
|
|
1500
|
+
* @deprecated Renamed to `deleteRoomSubscriptionSettings`
|
|
1501
|
+
*
|
|
1502
|
+
* Delete the user's room subscription settings.
|
|
1503
|
+
* @param params.userId The user ID to delete the room subscription settings from.
|
|
1504
|
+
* @param params.roomId The room ID to delete the room subscription settings from.
|
|
1393
1505
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1394
1506
|
*/
|
|
1395
1507
|
async deleteRoomNotificationSettings(params, options) {
|
|
1508
|
+
return this.deleteRoomSubscriptionSettings(params, options);
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Delete the user's room subscription settings.
|
|
1512
|
+
* @param params.userId The user ID to delete the room subscription settings from.
|
|
1513
|
+
* @param params.roomId The room ID to delete the room subscription settings from.
|
|
1514
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1515
|
+
*/
|
|
1516
|
+
async deleteRoomSubscriptionSettings(params, options) {
|
|
1396
1517
|
const { userId, roomId } = params;
|
|
1397
1518
|
const res = await this.#delete(
|
|
1398
|
-
_core.url`/v2/rooms/${roomId}/users/${userId}/
|
|
1519
|
+
_core.url`/v2/rooms/${roomId}/users/${userId}/subscription-settings`,
|
|
1399
1520
|
options
|
|
1400
1521
|
);
|
|
1401
1522
|
if (!res.ok) {
|
|
@@ -1478,7 +1599,7 @@ var Liveblocks = class {
|
|
|
1478
1599
|
throw await LiveblocksError.from(res);
|
|
1479
1600
|
}
|
|
1480
1601
|
const plainSettings = await res.json();
|
|
1481
|
-
const settings = _core.
|
|
1602
|
+
const settings = _core.createNotificationSettings.call(void 0, plainSettings);
|
|
1482
1603
|
return settings;
|
|
1483
1604
|
}
|
|
1484
1605
|
/**
|
|
@@ -1498,7 +1619,7 @@ var Liveblocks = class {
|
|
|
1498
1619
|
throw await LiveblocksError.from(res);
|
|
1499
1620
|
}
|
|
1500
1621
|
const plainSettings = await res.json();
|
|
1501
|
-
const settings = _core.
|
|
1622
|
+
const settings = _core.createNotificationSettings.call(void 0, plainSettings);
|
|
1502
1623
|
return settings;
|
|
1503
1624
|
}
|
|
1504
1625
|
/**
|