@liveblocks/node 2.24.0-sub1 → 2.24.1
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 +88 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -1
- package/dist/index.d.ts +54 -1
- package/dist/index.js +88 -1
- 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.
|
|
6
|
+
var PKG_VERSION = "2.24.1";
|
|
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.
|
|
@@ -1360,6 +1425,28 @@ var Liveblocks = class {
|
|
|
1360
1425
|
async getRoomNotificationSettings(params, options) {
|
|
1361
1426
|
return this.getRoomSubscriptionSettings(params, options);
|
|
1362
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
|
+
}
|
|
1363
1450
|
/**
|
|
1364
1451
|
* Gets the user's room subscription settings.
|
|
1365
1452
|
* @param params.userId The user ID to get the room subscription settings from.
|