@liveblocks/node 3.6.1-preview1 → 3.7.0-preview1
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 +230 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -3
- package/dist/index.d.ts +100 -3
- package/dist/index.js +216 -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 = "3.
|
|
6
|
+
var PKG_VERSION = "3.7.0-preview1";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
8
8
|
|
|
9
9
|
// src/client.ts
|
|
@@ -26,6 +26,7 @@ var PKG_FORMAT = "cjs";
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
|
|
29
30
|
|
|
30
31
|
// src/lib/itertools.ts
|
|
31
32
|
async function asyncConsume(iterable) {
|
|
@@ -170,14 +171,16 @@ var Session = (_class = class {
|
|
|
170
171
|
#postFn;
|
|
171
172
|
#userId;
|
|
172
173
|
#userInfo;
|
|
174
|
+
#tenantId;
|
|
173
175
|
#sealed = false;
|
|
174
176
|
#permissions = /* @__PURE__ */ new Map();
|
|
175
177
|
/** @internal */
|
|
176
|
-
constructor(postFn, userId, userInfo) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
178
|
+
constructor(postFn, userId, userInfo, tenantId) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
177
179
|
assertNonEmpty(userId, "userId");
|
|
178
180
|
this.#postFn = postFn;
|
|
179
181
|
this.#userId = userId;
|
|
180
182
|
this.#userInfo = userInfo;
|
|
183
|
+
this.#tenantId = tenantId;
|
|
181
184
|
}
|
|
182
185
|
#getOrCreate(roomId) {
|
|
183
186
|
if (this.#sealed) {
|
|
@@ -256,7 +259,8 @@ var Session = (_class = class {
|
|
|
256
259
|
userId: this.#userId,
|
|
257
260
|
permissions: this.serializePermissions(),
|
|
258
261
|
// Optional metadata
|
|
259
|
-
userInfo: this.#userInfo
|
|
262
|
+
userInfo: this.#userInfo,
|
|
263
|
+
tenantId: this.#tenantId
|
|
260
264
|
});
|
|
261
265
|
return {
|
|
262
266
|
status: normalizeStatusCode(resp.status),
|
|
@@ -361,8 +365,8 @@ var Liveblocks = class {
|
|
|
361
365
|
signal: _optionalChain([options, 'optionalAccess', _3 => _3.signal])
|
|
362
366
|
});
|
|
363
367
|
}
|
|
364
|
-
async #delete(path, options) {
|
|
365
|
-
const url3 = _core.urljoin.call(void 0, this.#baseUrl, path);
|
|
368
|
+
async #delete(path, params, options) {
|
|
369
|
+
const url3 = _core.urljoin.call(void 0, this.#baseUrl, path, params);
|
|
366
370
|
const headers = {
|
|
367
371
|
Authorization: `Bearer ${this.#secret}`
|
|
368
372
|
};
|
|
@@ -401,6 +405,8 @@ var Liveblocks = class {
|
|
|
401
405
|
* uniquely identify the user account in your system. The uniqueness of this
|
|
402
406
|
* value will determine how many MAUs will be counted/billed.
|
|
403
407
|
*
|
|
408
|
+
* @param tenantId (optional) The tenant ID to authorize the user for.
|
|
409
|
+
*
|
|
404
410
|
* @param options.userInfo Custom metadata to attach to this user. Data you
|
|
405
411
|
* add here will be visible to all other clients in the room, through the
|
|
406
412
|
* `other.info` property.
|
|
@@ -408,7 +414,12 @@ var Liveblocks = class {
|
|
|
408
414
|
*/
|
|
409
415
|
prepareSession(userId, ...rest) {
|
|
410
416
|
const options = rest[0];
|
|
411
|
-
return new Session(
|
|
417
|
+
return new Session(
|
|
418
|
+
this.#post.bind(this),
|
|
419
|
+
userId,
|
|
420
|
+
_optionalChain([options, 'optionalAccess', _6 => _6.userInfo]),
|
|
421
|
+
_optionalChain([options, 'optionalAccess', _7 => _7.tenantId])
|
|
422
|
+
);
|
|
412
423
|
}
|
|
413
424
|
/**
|
|
414
425
|
* Call this to authenticate the user as an actor you want to allow to use
|
|
@@ -452,7 +463,7 @@ var Liveblocks = class {
|
|
|
452
463
|
userId,
|
|
453
464
|
groupIds,
|
|
454
465
|
tenantId,
|
|
455
|
-
userInfo: _optionalChain([options, 'optionalAccess',
|
|
466
|
+
userInfo: _optionalChain([options, 'optionalAccess', _8 => _8.userInfo])
|
|
456
467
|
};
|
|
457
468
|
try {
|
|
458
469
|
const resp = await this.#post(path, body);
|
|
@@ -481,6 +492,7 @@ var Liveblocks = class {
|
|
|
481
492
|
* @param params.userId (optional) A filter on users accesses.
|
|
482
493
|
* @param params.metadata (optional) A filter on metadata. Multiple metadata keys can be used to filter rooms.
|
|
483
494
|
* @param params.groupIds (optional) A filter on groups accesses. Multiple groups can be used.
|
|
495
|
+
* @param params.tenantId (optional) A filter on tenant ID.
|
|
484
496
|
* @param params.query (optional) A query to filter rooms by. It is based on our query language. You can filter by metadata and room ID.
|
|
485
497
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
486
498
|
* @returns A list of rooms.
|
|
@@ -527,7 +539,7 @@ var Liveblocks = class {
|
|
|
527
539
|
*/
|
|
528
540
|
async *iterRooms(criteria, options) {
|
|
529
541
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
530
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
542
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.pageSize]), () => ( 40)), 20);
|
|
531
543
|
let cursor = void 0;
|
|
532
544
|
while (true) {
|
|
533
545
|
const { nextCursor, data } = await this.getRooms(
|
|
@@ -550,13 +562,14 @@ var Liveblocks = class {
|
|
|
550
562
|
* @param params.groupsAccesses (optional) The group accesses for the room. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
551
563
|
* @param params.usersAccesses (optional) The user accesses for the room. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
552
564
|
* @param params.metadata (optional) The metadata for the room. Supports upto a maximum of 50 entries. Key length has a limit of 40 characters. Value length has a limit of 256 characters.
|
|
565
|
+
* @param params.tenantId (optional) The tenant ID to create the room for.
|
|
553
566
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
554
567
|
* @returns The created room.
|
|
555
568
|
*/
|
|
556
569
|
async createRoom(roomId, params, options) {
|
|
557
570
|
const { defaultAccesses, groupsAccesses, usersAccesses, metadata } = params;
|
|
558
571
|
const res = await this.#post(
|
|
559
|
-
_optionalChain([options, 'optionalAccess',
|
|
572
|
+
_optionalChain([options, 'optionalAccess', _10 => _10.idempotent]) ? _core.url`/v2/rooms?idempotent` : _core.url`/v2/rooms`,
|
|
560
573
|
{
|
|
561
574
|
id: roomId,
|
|
562
575
|
defaultAccesses,
|
|
@@ -581,6 +594,7 @@ var Liveblocks = class {
|
|
|
581
594
|
* @param params.groupsAccesses (optional) The group accesses for the room if the room will be created. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
582
595
|
* @param params.usersAccesses (optional) The user accesses for the room if the room will be created. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
583
596
|
* @param params.metadata (optional) The metadata for the room if the room will be created. Supports upto a maximum of 50 entries. Key length has a limit of 40 characters. Value length has a limit of 256 characters.
|
|
597
|
+
* @param params.tenantId (optional) The tenant ID to create the room for.
|
|
584
598
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
585
599
|
* @returns The room.
|
|
586
600
|
*/
|
|
@@ -660,7 +674,11 @@ var Liveblocks = class {
|
|
|
660
674
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
661
675
|
*/
|
|
662
676
|
async deleteRoom(roomId, options) {
|
|
663
|
-
const res = await this.#delete(
|
|
677
|
+
const res = await this.#delete(
|
|
678
|
+
_core.url`/v2/rooms/${roomId}`,
|
|
679
|
+
void 0,
|
|
680
|
+
options
|
|
681
|
+
);
|
|
664
682
|
if (!res.ok) {
|
|
665
683
|
throw await LiveblocksError.from(res);
|
|
666
684
|
}
|
|
@@ -759,7 +777,11 @@ var Liveblocks = class {
|
|
|
759
777
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
760
778
|
*/
|
|
761
779
|
async deleteStorageDocument(roomId, options) {
|
|
762
|
-
const res = await this.#delete(
|
|
780
|
+
const res = await this.#delete(
|
|
781
|
+
_core.url`/v2/rooms/${roomId}/storage`,
|
|
782
|
+
void 0,
|
|
783
|
+
options
|
|
784
|
+
);
|
|
763
785
|
if (!res.ok) {
|
|
764
786
|
throw await LiveblocksError.from(res);
|
|
765
787
|
}
|
|
@@ -905,7 +927,11 @@ var Liveblocks = class {
|
|
|
905
927
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
906
928
|
*/
|
|
907
929
|
async deleteSchema(schemaId, options) {
|
|
908
|
-
const res = await this.#delete(
|
|
930
|
+
const res = await this.#delete(
|
|
931
|
+
_core.url`/v2/schemas/${schemaId}`,
|
|
932
|
+
void 0,
|
|
933
|
+
options
|
|
934
|
+
);
|
|
909
935
|
if (!res.ok) {
|
|
910
936
|
throw await LiveblocksError.from(res);
|
|
911
937
|
}
|
|
@@ -959,7 +985,11 @@ var Liveblocks = class {
|
|
|
959
985
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
960
986
|
*/
|
|
961
987
|
async detachSchemaFromRoom(roomId, options) {
|
|
962
|
-
const res = await this.#delete(
|
|
988
|
+
const res = await this.#delete(
|
|
989
|
+
_core.url`/v2/rooms/${roomId}/schema`,
|
|
990
|
+
void 0,
|
|
991
|
+
options
|
|
992
|
+
);
|
|
963
993
|
if (!res.ok) {
|
|
964
994
|
throw await LiveblocksError.from(res);
|
|
965
995
|
}
|
|
@@ -1017,10 +1047,14 @@ var Liveblocks = class {
|
|
|
1017
1047
|
return _core.convertToThreadData.call(void 0, await res.json());
|
|
1018
1048
|
}
|
|
1019
1049
|
/**
|
|
1050
|
+
* @deprecated Prefer using `getMentionsFromCommentBody` to extract mentions
|
|
1051
|
+
* from comments and threads, or `Liveblocks.getThreadSubscriptions` to get
|
|
1052
|
+
* the list of users who are subscribed to a thread.
|
|
1053
|
+
*
|
|
1020
1054
|
* Gets a thread's participants.
|
|
1021
1055
|
*
|
|
1022
1056
|
* Participants are users who have commented on the thread
|
|
1023
|
-
* or users
|
|
1057
|
+
* or users that have been mentioned in a comment.
|
|
1024
1058
|
*
|
|
1025
1059
|
* @param params.roomId The room ID to get the thread participants from.
|
|
1026
1060
|
* @param params.threadId The thread ID to get the participants from.
|
|
@@ -1100,7 +1134,7 @@ var Liveblocks = class {
|
|
|
1100
1134
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments`,
|
|
1101
1135
|
{
|
|
1102
1136
|
...data,
|
|
1103
|
-
createdAt: _optionalChain([data, 'access',
|
|
1137
|
+
createdAt: _optionalChain([data, 'access', _11 => _11.createdAt, 'optionalAccess', _12 => _12.toISOString, 'call', _13 => _13()])
|
|
1104
1138
|
},
|
|
1105
1139
|
options
|
|
1106
1140
|
);
|
|
@@ -1123,7 +1157,7 @@ var Liveblocks = class {
|
|
|
1123
1157
|
const { roomId, threadId, commentId, data } = params;
|
|
1124
1158
|
const res = await this.#post(
|
|
1125
1159
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}`,
|
|
1126
|
-
{ ...data, editedAt: _optionalChain([data, 'access',
|
|
1160
|
+
{ ...data, editedAt: _optionalChain([data, 'access', _14 => _14.editedAt, 'optionalAccess', _15 => _15.toISOString, 'call', _16 => _16()]) },
|
|
1127
1161
|
options
|
|
1128
1162
|
);
|
|
1129
1163
|
if (!res.ok) {
|
|
@@ -1142,6 +1176,7 @@ var Liveblocks = class {
|
|
|
1142
1176
|
const { roomId, threadId, commentId } = params;
|
|
1143
1177
|
const res = await this.#delete(
|
|
1144
1178
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}`,
|
|
1179
|
+
void 0,
|
|
1145
1180
|
options
|
|
1146
1181
|
);
|
|
1147
1182
|
if (!res.ok) {
|
|
@@ -1167,7 +1202,7 @@ var Liveblocks = class {
|
|
|
1167
1202
|
...data,
|
|
1168
1203
|
comment: {
|
|
1169
1204
|
...data.comment,
|
|
1170
|
-
createdAt: _optionalChain([data, 'access',
|
|
1205
|
+
createdAt: _optionalChain([data, 'access', _17 => _17.comment, 'access', _18 => _18.createdAt, 'optionalAccess', _19 => _19.toISOString, 'call', _20 => _20()])
|
|
1171
1206
|
}
|
|
1172
1207
|
},
|
|
1173
1208
|
options
|
|
@@ -1187,6 +1222,7 @@ var Liveblocks = class {
|
|
|
1187
1222
|
const { roomId, threadId } = params;
|
|
1188
1223
|
const res = await this.#delete(
|
|
1189
1224
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}`,
|
|
1225
|
+
void 0,
|
|
1190
1226
|
options
|
|
1191
1227
|
);
|
|
1192
1228
|
if (!res.ok) {
|
|
@@ -1289,7 +1325,7 @@ var Liveblocks = class {
|
|
|
1289
1325
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/metadata`,
|
|
1290
1326
|
{
|
|
1291
1327
|
...data,
|
|
1292
|
-
updatedAt: _optionalChain([data, 'access',
|
|
1328
|
+
updatedAt: _optionalChain([data, 'access', _21 => _21.updatedAt, 'optionalAccess', _22 => _22.toISOString, 'call', _23 => _23()])
|
|
1293
1329
|
},
|
|
1294
1330
|
options
|
|
1295
1331
|
);
|
|
@@ -1315,7 +1351,7 @@ var Liveblocks = class {
|
|
|
1315
1351
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/add-reaction`,
|
|
1316
1352
|
{
|
|
1317
1353
|
...data,
|
|
1318
|
-
createdAt: _optionalChain([data, 'access',
|
|
1354
|
+
createdAt: _optionalChain([data, 'access', _24 => _24.createdAt, 'optionalAccess', _25 => _25.toISOString, 'call', _26 => _26()])
|
|
1319
1355
|
},
|
|
1320
1356
|
options
|
|
1321
1357
|
);
|
|
@@ -1341,7 +1377,7 @@ var Liveblocks = class {
|
|
|
1341
1377
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${params.commentId}/remove-reaction`,
|
|
1342
1378
|
{
|
|
1343
1379
|
...data,
|
|
1344
|
-
removedAt: _optionalChain([data, 'access',
|
|
1380
|
+
removedAt: _optionalChain([data, 'access', _27 => _27.removedAt, 'optionalAccess', _28 => _28.toISOString, 'call', _29 => _29()])
|
|
1345
1381
|
},
|
|
1346
1382
|
options
|
|
1347
1383
|
);
|
|
@@ -1373,10 +1409,11 @@ var Liveblocks = class {
|
|
|
1373
1409
|
* Returns the inbox notifications for a user.
|
|
1374
1410
|
* @param params.userId The user ID to get the inbox notifications from.
|
|
1375
1411
|
* @param params.query The query to filter inbox notifications by. It is based on our query language and can filter by unread.
|
|
1412
|
+
* @param params.tenantId (optional) The tenant ID to get the inbox notifications for.
|
|
1376
1413
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1377
1414
|
*/
|
|
1378
1415
|
async getInboxNotifications(params, options) {
|
|
1379
|
-
const { userId } = params;
|
|
1416
|
+
const { userId, tenantId, limit, startingAfter } = params;
|
|
1380
1417
|
let query;
|
|
1381
1418
|
if (typeof params.query === "string") {
|
|
1382
1419
|
query = params.query;
|
|
@@ -1387,8 +1424,9 @@ var Liveblocks = class {
|
|
|
1387
1424
|
_core.url`/v2/users/${userId}/inbox-notifications`,
|
|
1388
1425
|
{
|
|
1389
1426
|
query,
|
|
1390
|
-
limit
|
|
1391
|
-
startingAfter
|
|
1427
|
+
limit,
|
|
1428
|
+
startingAfter,
|
|
1429
|
+
tenantId
|
|
1392
1430
|
},
|
|
1393
1431
|
options
|
|
1394
1432
|
);
|
|
@@ -1409,12 +1447,13 @@ var Liveblocks = class {
|
|
|
1409
1447
|
*
|
|
1410
1448
|
* @param criteria.userId The user ID to get the inbox notifications from.
|
|
1411
1449
|
* @param criteria.query The query to filter inbox notifications by. It is based on our query language and can filter by unread.
|
|
1450
|
+
* @param criteria.tenantId (optional) The tenant ID to get the inbox notifications for.
|
|
1412
1451
|
* @param options.pageSize (optional) The page size to use for each request.
|
|
1413
1452
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1414
1453
|
*/
|
|
1415
1454
|
async *iterInboxNotifications(criteria, options) {
|
|
1416
1455
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
1417
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1456
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _30 => _30.pageSize]), () => ( 50)), 10);
|
|
1418
1457
|
let cursor = void 0;
|
|
1419
1458
|
while (true) {
|
|
1420
1459
|
const { nextCursor, data } = await this.getInboxNotifications(
|
|
@@ -1433,15 +1472,17 @@ var Liveblocks = class {
|
|
|
1433
1472
|
/**
|
|
1434
1473
|
* Returns all room subscription settings for a user.
|
|
1435
1474
|
* @param params.userId The user ID to get the room subscription settings from.
|
|
1475
|
+
* @param params.tenantId (optional) The tenant ID to get the room subscription settings for.
|
|
1436
1476
|
* @param params.startingAfter (optional) The cursor to start the pagination from.
|
|
1437
1477
|
* @param params.limit (optional) The number of items to return.
|
|
1438
1478
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1439
1479
|
*/
|
|
1440
1480
|
async getUserRoomSubscriptionSettings(params, options) {
|
|
1441
|
-
const { userId, startingAfter, limit } = params;
|
|
1481
|
+
const { userId, tenantId, startingAfter, limit } = params;
|
|
1442
1482
|
const res = await this.#get(
|
|
1443
1483
|
_core.url`/v2/users/${userId}/room-subscription-settings`,
|
|
1444
1484
|
{
|
|
1485
|
+
tenantId,
|
|
1445
1486
|
startingAfter,
|
|
1446
1487
|
limit
|
|
1447
1488
|
},
|
|
@@ -1499,6 +1540,7 @@ var Liveblocks = class {
|
|
|
1499
1540
|
const { userId, roomId } = params;
|
|
1500
1541
|
const res = await this.#delete(
|
|
1501
1542
|
_core.url`/v2/rooms/${roomId}/users/${userId}/subscription-settings`,
|
|
1543
|
+
void 0,
|
|
1502
1544
|
options
|
|
1503
1545
|
);
|
|
1504
1546
|
if (!res.ok) {
|
|
@@ -1524,6 +1566,16 @@ var Liveblocks = class {
|
|
|
1524
1566
|
const data = await res.json();
|
|
1525
1567
|
return inflateRoomData(data);
|
|
1526
1568
|
}
|
|
1569
|
+
/**
|
|
1570
|
+
* Triggers an inbox notification for a user.
|
|
1571
|
+
* @param params.userId The user ID to trigger the inbox notification for.
|
|
1572
|
+
* @param params.kind The kind of inbox notification to trigger.
|
|
1573
|
+
* @param params.subjectId The subject ID of the triggered inbox notification.
|
|
1574
|
+
* @param params.activityData The activity data of the triggered inbox notification.
|
|
1575
|
+
* @param params.roomId (optional) The room ID to trigger the inbox notification for.
|
|
1576
|
+
* @param params.tenantId (optional) The tenant ID to trigger the inbox notification for.
|
|
1577
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1578
|
+
*/
|
|
1527
1579
|
async triggerInboxNotification(params, options) {
|
|
1528
1580
|
const res = await this.#post(
|
|
1529
1581
|
_core.url`/v2/inbox-notifications/trigger`,
|
|
@@ -1544,6 +1596,7 @@ var Liveblocks = class {
|
|
|
1544
1596
|
const { userId, inboxNotificationId } = params;
|
|
1545
1597
|
const res = await this.#delete(
|
|
1546
1598
|
_core.url`/v2/users/${userId}/inbox-notifications/${inboxNotificationId}`,
|
|
1599
|
+
void 0,
|
|
1547
1600
|
options
|
|
1548
1601
|
);
|
|
1549
1602
|
if (!res.ok) {
|
|
@@ -1553,12 +1606,14 @@ var Liveblocks = class {
|
|
|
1553
1606
|
/**
|
|
1554
1607
|
* Deletes all inbox notifications for a user.
|
|
1555
1608
|
* @param params.userId The user ID for which to delete all the inbox notifications.
|
|
1609
|
+
* @param params.tenantId (optional) The tenant ID to delete the inbox notifications for.
|
|
1556
1610
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1557
1611
|
*/
|
|
1558
1612
|
async deleteAllInboxNotifications(params, options) {
|
|
1559
|
-
const { userId } = params;
|
|
1613
|
+
const { userId, tenantId } = params;
|
|
1560
1614
|
const res = await this.#delete(
|
|
1561
1615
|
_core.url`/v2/users/${userId}/inbox-notifications`,
|
|
1616
|
+
{ tenantId },
|
|
1562
1617
|
options
|
|
1563
1618
|
);
|
|
1564
1619
|
if (!res.ok) {
|
|
@@ -1613,11 +1668,149 @@ var Liveblocks = class {
|
|
|
1613
1668
|
const { userId } = params;
|
|
1614
1669
|
const res = await this.#delete(
|
|
1615
1670
|
_core.url`/v2/users/${userId}/notification-settings`,
|
|
1671
|
+
void 0,
|
|
1672
|
+
options
|
|
1673
|
+
);
|
|
1674
|
+
if (!res.ok) {
|
|
1675
|
+
throw await LiveblocksError.from(res);
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Create a group
|
|
1680
|
+
* @param params.groupId The ID of the group to create.
|
|
1681
|
+
* @param params.memberIds The IDs of the members to add to the group.
|
|
1682
|
+
* @param params.tenantId (optional) The tenant ID to create the group for.
|
|
1683
|
+
* @param params.scopes (optional) The scopes to grant to the group. The default is `{ mention: true }`.
|
|
1684
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1685
|
+
*/
|
|
1686
|
+
async createGroup(params, options) {
|
|
1687
|
+
const res = await this.#post(
|
|
1688
|
+
_core.url`/v2/groups`,
|
|
1689
|
+
{
|
|
1690
|
+
...params,
|
|
1691
|
+
// The REST API uses `id` since a group is a resource,
|
|
1692
|
+
// but we use `groupId` here for consistency with the other methods.
|
|
1693
|
+
id: params.groupId
|
|
1694
|
+
},
|
|
1695
|
+
options
|
|
1696
|
+
);
|
|
1697
|
+
if (!res.ok) {
|
|
1698
|
+
throw await LiveblocksError.from(res);
|
|
1699
|
+
}
|
|
1700
|
+
const group = await res.json();
|
|
1701
|
+
return _core.convertToGroupData.call(void 0, group);
|
|
1702
|
+
}
|
|
1703
|
+
/**
|
|
1704
|
+
* Get a group
|
|
1705
|
+
* @param params.groupId The ID of the group to get.
|
|
1706
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1707
|
+
*/
|
|
1708
|
+
async getGroup(params, options) {
|
|
1709
|
+
const res = await this.#get(
|
|
1710
|
+
_core.url`/v2/groups/${params.groupId}`,
|
|
1711
|
+
void 0,
|
|
1712
|
+
options
|
|
1713
|
+
);
|
|
1714
|
+
if (!res.ok) {
|
|
1715
|
+
throw await LiveblocksError.from(res);
|
|
1716
|
+
}
|
|
1717
|
+
const group = await res.json();
|
|
1718
|
+
return _core.convertToGroupData.call(void 0, group);
|
|
1719
|
+
}
|
|
1720
|
+
/**
|
|
1721
|
+
* Add members to a group
|
|
1722
|
+
* @param params.groupId The ID of the group to add members to.
|
|
1723
|
+
* @param params.memberIds The IDs of the members to add to the group.
|
|
1724
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1725
|
+
*/
|
|
1726
|
+
async addGroupMembers(params, options) {
|
|
1727
|
+
const res = await this.#post(
|
|
1728
|
+
_core.url`/v2/groups/${params.groupId}/add-members`,
|
|
1729
|
+
{ memberIds: params.memberIds },
|
|
1730
|
+
options
|
|
1731
|
+
);
|
|
1732
|
+
if (!res.ok) {
|
|
1733
|
+
throw await LiveblocksError.from(res);
|
|
1734
|
+
}
|
|
1735
|
+
const group = await res.json();
|
|
1736
|
+
return _core.convertToGroupData.call(void 0, group);
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Remove members from a group
|
|
1740
|
+
* @param params.groupId The ID of the group to remove members from.
|
|
1741
|
+
* @param params.memberIds The IDs of the members to remove from the group.
|
|
1742
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1743
|
+
*/
|
|
1744
|
+
async removeGroupMembers(params, options) {
|
|
1745
|
+
const res = await this.#post(
|
|
1746
|
+
_core.url`/v2/groups/${params.groupId}/remove-members`,
|
|
1747
|
+
{ memberIds: params.memberIds },
|
|
1748
|
+
options
|
|
1749
|
+
);
|
|
1750
|
+
if (!res.ok) {
|
|
1751
|
+
throw await LiveblocksError.from(res);
|
|
1752
|
+
}
|
|
1753
|
+
const group = await res.json();
|
|
1754
|
+
return _core.convertToGroupData.call(void 0, group);
|
|
1755
|
+
}
|
|
1756
|
+
/**
|
|
1757
|
+
* Delete a group
|
|
1758
|
+
* @param params.groupId The ID of the group to delete.
|
|
1759
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1760
|
+
*/
|
|
1761
|
+
async deleteGroup(params, options) {
|
|
1762
|
+
const res = await this.#delete(
|
|
1763
|
+
_core.url`/v2/groups/${params.groupId}`,
|
|
1764
|
+
void 0,
|
|
1765
|
+
options
|
|
1766
|
+
);
|
|
1767
|
+
if (!res.ok) {
|
|
1768
|
+
throw await LiveblocksError.from(res);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* Get all groups
|
|
1773
|
+
* @param params.limit (optional) The number of groups to return.
|
|
1774
|
+
* @param params.startingAfter (optional) The cursor to start the pagination from.
|
|
1775
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1776
|
+
*/
|
|
1777
|
+
async getGroups(params, options) {
|
|
1778
|
+
const res = await this.#get(
|
|
1779
|
+
_core.url`/v2/groups`,
|
|
1780
|
+
{ startingAfter: _optionalChain([params, 'optionalAccess', _31 => _31.startingAfter]), limit: _optionalChain([params, 'optionalAccess', _32 => _32.limit]) },
|
|
1616
1781
|
options
|
|
1617
1782
|
);
|
|
1618
1783
|
if (!res.ok) {
|
|
1619
1784
|
throw await LiveblocksError.from(res);
|
|
1620
1785
|
}
|
|
1786
|
+
const page = await res.json();
|
|
1787
|
+
return {
|
|
1788
|
+
...page,
|
|
1789
|
+
data: page.data.map(_core.convertToGroupData)
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Returns all groups a user is a member of.
|
|
1794
|
+
* @param params.userId The user ID to get the groups for.
|
|
1795
|
+
* @param params.startingAfter (optional) The cursor to start the pagination from.
|
|
1796
|
+
* @param params.limit (optional) The number of items to return.
|
|
1797
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1798
|
+
*/
|
|
1799
|
+
async getUserGroups(params, options) {
|
|
1800
|
+
const { userId, startingAfter, limit } = params;
|
|
1801
|
+
const res = await this.#get(
|
|
1802
|
+
_core.url`/v2/users/${userId}/groups`,
|
|
1803
|
+
{ startingAfter, limit },
|
|
1804
|
+
options
|
|
1805
|
+
);
|
|
1806
|
+
if (!res.ok) {
|
|
1807
|
+
throw await LiveblocksError.from(res);
|
|
1808
|
+
}
|
|
1809
|
+
const page = await res.json();
|
|
1810
|
+
return {
|
|
1811
|
+
...page,
|
|
1812
|
+
data: page.data.map(_core.convertToGroupData)
|
|
1813
|
+
};
|
|
1621
1814
|
}
|
|
1622
1815
|
/**
|
|
1623
1816
|
* Retrieves the current Storage contents for the given room ID and calls the
|
|
@@ -1646,7 +1839,7 @@ var Liveblocks = class {
|
|
|
1646
1839
|
async massMutateStorage(criteria, callback, massOptions) {
|
|
1647
1840
|
const concurrency = _core.checkBounds.call(void 0,
|
|
1648
1841
|
"concurrency",
|
|
1649
|
-
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess',
|
|
1842
|
+
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess', _33 => _33.concurrency]), () => ( 8)),
|
|
1650
1843
|
1,
|
|
1651
1844
|
20
|
|
1652
1845
|
);
|
|
@@ -1662,7 +1855,7 @@ var Liveblocks = class {
|
|
|
1662
1855
|
}
|
|
1663
1856
|
async #_mutateOneRoom(roomId, room, callback, options) {
|
|
1664
1857
|
const debounceInterval = 200;
|
|
1665
|
-
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess',
|
|
1858
|
+
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess', _34 => _34.signal]));
|
|
1666
1859
|
let opsBuffer = [];
|
|
1667
1860
|
let outstandingFlush$ = void 0;
|
|
1668
1861
|
let lastFlush = performance.now();
|
|
@@ -1728,7 +1921,7 @@ var Liveblocks = class {
|
|
|
1728
1921
|
const res = await this.#post(
|
|
1729
1922
|
_core.url`/v2/rooms/${roomId}/send-message`,
|
|
1730
1923
|
{ messages },
|
|
1731
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
1924
|
+
{ signal: _optionalChain([options, 'optionalAccess', _35 => _35.signal]) }
|
|
1732
1925
|
);
|
|
1733
1926
|
if (!res.ok) {
|
|
1734
1927
|
throw await LiveblocksError.from(res);
|
|
@@ -1814,7 +2007,11 @@ var Liveblocks = class {
|
|
|
1814
2007
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1815
2008
|
*/
|
|
1816
2009
|
async deleteAiCopilot(copilotId, options) {
|
|
1817
|
-
const res = await this.#delete(
|
|
2010
|
+
const res = await this.#delete(
|
|
2011
|
+
_core.url`/v2/ai/copilots/${copilotId}`,
|
|
2012
|
+
void 0,
|
|
2013
|
+
options
|
|
2014
|
+
);
|
|
1818
2015
|
if (!res.ok) {
|
|
1819
2016
|
throw await LiveblocksError.from(res);
|
|
1820
2017
|
}
|
|
@@ -1861,7 +2058,7 @@ var Liveblocks = class {
|
|
|
1861
2058
|
"Content-Type": params.file.type,
|
|
1862
2059
|
"Content-Length": String(params.file.size)
|
|
1863
2060
|
},
|
|
1864
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
2061
|
+
signal: _optionalChain([options, 'optionalAccess', _36 => _36.signal])
|
|
1865
2062
|
}
|
|
1866
2063
|
);
|
|
1867
2064
|
if (!res.ok) {
|
|
@@ -1879,6 +2076,7 @@ var Liveblocks = class {
|
|
|
1879
2076
|
async deleteFileKnowledgeSource(params, options) {
|
|
1880
2077
|
const res = await this.#delete(
|
|
1881
2078
|
_core.url`/v2/ai/copilots/${params.copilotId}/knowledge/file/${params.knowledgeSourceId}`,
|
|
2079
|
+
void 0,
|
|
1882
2080
|
options
|
|
1883
2081
|
);
|
|
1884
2082
|
if (!res.ok) {
|
|
@@ -1894,6 +2092,7 @@ var Liveblocks = class {
|
|
|
1894
2092
|
async deleteWebKnowledgeSource(params, options) {
|
|
1895
2093
|
const res = await this.#delete(
|
|
1896
2094
|
_core.url`/v2/ai/copilots/${params.copilotId}/knowledge/web/${params.knowledgeSourceId}`,
|
|
2095
|
+
void 0,
|
|
1897
2096
|
options
|
|
1898
2097
|
);
|
|
1899
2098
|
if (!res.ok) {
|