@liveblocks/node 3.14.0-pre5 → 3.14.0-pre6
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 +123 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -13
- package/dist/index.d.ts +50 -13
- package/dist/index.js +107 -57
- 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.14.0-
|
|
6
|
+
var PKG_VERSION = "3.14.0-pre6";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
8
8
|
|
|
9
9
|
// src/client.ts
|
|
@@ -171,16 +171,16 @@ var Session = (_class = class {
|
|
|
171
171
|
#postFn;
|
|
172
172
|
#userId;
|
|
173
173
|
#userInfo;
|
|
174
|
-
#
|
|
174
|
+
#organizationId;
|
|
175
175
|
#sealed = false;
|
|
176
176
|
#permissions = /* @__PURE__ */ new Map();
|
|
177
177
|
/** @internal */
|
|
178
|
-
constructor(postFn, userId, userInfo,
|
|
178
|
+
constructor(postFn, userId, userInfo, organizationId) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
179
179
|
assertNonEmpty(userId, "userId");
|
|
180
180
|
this.#postFn = postFn;
|
|
181
181
|
this.#userId = userId;
|
|
182
182
|
this.#userInfo = userInfo;
|
|
183
|
-
this.#
|
|
183
|
+
this.#organizationId = organizationId;
|
|
184
184
|
}
|
|
185
185
|
#getOrCreate(roomId) {
|
|
186
186
|
if (this.#sealed) {
|
|
@@ -254,14 +254,17 @@ var Session = (_class = class {
|
|
|
254
254
|
);
|
|
255
255
|
}
|
|
256
256
|
try {
|
|
257
|
-
const
|
|
257
|
+
const body = {
|
|
258
258
|
// Required
|
|
259
259
|
userId: this.#userId,
|
|
260
260
|
permissions: this.serializePermissions(),
|
|
261
261
|
// Optional metadata
|
|
262
|
-
userInfo: this.#userInfo
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
userInfo: this.#userInfo
|
|
263
|
+
};
|
|
264
|
+
if (this.#organizationId !== void 0) {
|
|
265
|
+
body.organizationId = this.#organizationId;
|
|
266
|
+
}
|
|
267
|
+
const resp = await this.#postFn(_core.url`/v2/authorize-user`, body);
|
|
265
268
|
return {
|
|
266
269
|
status: normalizeStatusCode(resp.status),
|
|
267
270
|
body: await resp.text()
|
|
@@ -391,7 +394,7 @@ var Liveblocks = class {
|
|
|
391
394
|
* uniquely identify the user account in your system. The uniqueness of this
|
|
392
395
|
* value will determine how many MAUs will be counted/billed.
|
|
393
396
|
*
|
|
394
|
-
* @param
|
|
397
|
+
* @param options.organizationId (optional) The organization ID to authorize the user for.
|
|
395
398
|
*
|
|
396
399
|
* @param options.userInfo Custom metadata to attach to this user. Data you
|
|
397
400
|
* add here will be visible to all other clients in the room, through the
|
|
@@ -404,7 +407,7 @@ var Liveblocks = class {
|
|
|
404
407
|
this.#post.bind(this),
|
|
405
408
|
userId,
|
|
406
409
|
_optionalChain([options, 'optionalAccess', _5 => _5.userInfo]),
|
|
407
|
-
_optionalChain([options, 'optionalAccess', _6 => _6.tenantId])
|
|
410
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _6 => _6.organizationId]), () => ( _optionalChain([options, 'optionalAccess', _7 => _7.tenantId])))
|
|
408
411
|
);
|
|
409
412
|
}
|
|
410
413
|
/**
|
|
@@ -443,14 +446,23 @@ var Liveblocks = class {
|
|
|
443
446
|
async identifyUser(identity, ...rest) {
|
|
444
447
|
const options = rest[0];
|
|
445
448
|
const path = _core.url`/v2/identify-user`;
|
|
446
|
-
const { userId, groupIds, tenantId } = typeof identity === "string" ? {
|
|
449
|
+
const { userId, groupIds, tenantId, organizationId } = typeof identity === "string" ? {
|
|
450
|
+
userId: identity,
|
|
451
|
+
groupIds: void 0,
|
|
452
|
+
tenantId: void 0,
|
|
453
|
+
organizationId: void 0
|
|
454
|
+
} : identity;
|
|
447
455
|
assertNonEmpty(userId, "userId");
|
|
448
456
|
const body = {
|
|
449
457
|
userId,
|
|
450
458
|
groupIds,
|
|
451
|
-
|
|
452
|
-
userInfo: _optionalChain([options, 'optionalAccess', _7 => _7.userInfo])
|
|
459
|
+
userInfo: _optionalChain([options, 'optionalAccess', _8 => _8.userInfo])
|
|
453
460
|
};
|
|
461
|
+
if (organizationId !== void 0) {
|
|
462
|
+
body.organizationId = organizationId;
|
|
463
|
+
} else if (tenantId !== void 0) {
|
|
464
|
+
body.organizationId = tenantId;
|
|
465
|
+
}
|
|
454
466
|
try {
|
|
455
467
|
const resp = await this.#post(path, body);
|
|
456
468
|
return {
|
|
@@ -478,7 +490,7 @@ var Liveblocks = class {
|
|
|
478
490
|
* @param params.userId (optional) A filter on users accesses.
|
|
479
491
|
* @param params.metadata (optional) A filter on metadata. Multiple metadata keys can be used to filter rooms.
|
|
480
492
|
* @param params.groupIds (optional) A filter on groups accesses. Multiple groups can be used.
|
|
481
|
-
* @param params.
|
|
493
|
+
* @param params.organizationId (optional) A filter on organization ID.
|
|
482
494
|
* @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.
|
|
483
495
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
484
496
|
* @returns A list of rooms.
|
|
@@ -495,10 +507,14 @@ var Liveblocks = class {
|
|
|
495
507
|
limit: params.limit,
|
|
496
508
|
startingAfter: params.startingAfter,
|
|
497
509
|
userId: params.userId,
|
|
498
|
-
tenantId: params.tenantId,
|
|
499
510
|
groupIds: params.groupIds ? params.groupIds.join(",") : void 0,
|
|
500
511
|
query
|
|
501
512
|
};
|
|
513
|
+
if (params.organizationId !== void 0) {
|
|
514
|
+
queryParams.organizationId = params.organizationId;
|
|
515
|
+
} else if (params.tenantId !== void 0) {
|
|
516
|
+
queryParams.organizationId = params.tenantId;
|
|
517
|
+
}
|
|
502
518
|
const res = await this.#get(path, queryParams, options);
|
|
503
519
|
if (!res.ok) {
|
|
504
520
|
throw await LiveblocksError.from(res);
|
|
@@ -526,7 +542,7 @@ var Liveblocks = class {
|
|
|
526
542
|
*/
|
|
527
543
|
async *iterRooms(criteria, options) {
|
|
528
544
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
529
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
545
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.pageSize]), () => ( 40)), 20);
|
|
530
546
|
let cursor = void 0;
|
|
531
547
|
while (true) {
|
|
532
548
|
const { nextCursor, data } = await this.getRooms(
|
|
@@ -549,7 +565,7 @@ var Liveblocks = class {
|
|
|
549
565
|
* @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.
|
|
550
566
|
* @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.
|
|
551
567
|
* @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.
|
|
552
|
-
* @param params.
|
|
568
|
+
* @param params.organizationId (optional) The organization ID to create the room for.
|
|
553
569
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
554
570
|
* @returns The created room.
|
|
555
571
|
*/
|
|
@@ -560,19 +576,25 @@ var Liveblocks = class {
|
|
|
560
576
|
usersAccesses,
|
|
561
577
|
metadata,
|
|
562
578
|
tenantId,
|
|
579
|
+
organizationId,
|
|
563
580
|
engine
|
|
564
581
|
} = params;
|
|
582
|
+
const body = {
|
|
583
|
+
id: roomId,
|
|
584
|
+
defaultAccesses,
|
|
585
|
+
groupsAccesses,
|
|
586
|
+
usersAccesses,
|
|
587
|
+
metadata,
|
|
588
|
+
engine
|
|
589
|
+
};
|
|
590
|
+
if (organizationId !== void 0) {
|
|
591
|
+
body.organizationId = organizationId;
|
|
592
|
+
} else if (tenantId !== void 0) {
|
|
593
|
+
body.organizationId = tenantId;
|
|
594
|
+
}
|
|
565
595
|
const res = await this.#post(
|
|
566
|
-
_optionalChain([options, 'optionalAccess',
|
|
567
|
-
|
|
568
|
-
id: roomId,
|
|
569
|
-
defaultAccesses,
|
|
570
|
-
groupsAccesses,
|
|
571
|
-
usersAccesses,
|
|
572
|
-
tenantId,
|
|
573
|
-
metadata,
|
|
574
|
-
engine
|
|
575
|
-
},
|
|
596
|
+
_optionalChain([options, 'optionalAccess', _10 => _10.idempotent]) ? _core.url`/v2/rooms?idempotent` : _core.url`/v2/rooms`,
|
|
597
|
+
body,
|
|
576
598
|
options
|
|
577
599
|
);
|
|
578
600
|
if (!res.ok) {
|
|
@@ -590,7 +612,7 @@ var Liveblocks = class {
|
|
|
590
612
|
* @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.
|
|
591
613
|
* @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.
|
|
592
614
|
* @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.
|
|
593
|
-
* @param params.
|
|
615
|
+
* @param params.organizationId (optional) The organization ID to create the room for.
|
|
594
616
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
595
617
|
* @returns The room.
|
|
596
618
|
*/
|
|
@@ -1000,7 +1022,7 @@ var Liveblocks = class {
|
|
|
1000
1022
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments`,
|
|
1001
1023
|
{
|
|
1002
1024
|
...data,
|
|
1003
|
-
createdAt: _optionalChain([data, 'access',
|
|
1025
|
+
createdAt: _optionalChain([data, 'access', _11 => _11.createdAt, 'optionalAccess', _12 => _12.toISOString, 'call', _13 => _13()])
|
|
1004
1026
|
},
|
|
1005
1027
|
options
|
|
1006
1028
|
);
|
|
@@ -1026,7 +1048,7 @@ var Liveblocks = class {
|
|
|
1026
1048
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}`,
|
|
1027
1049
|
{
|
|
1028
1050
|
body: data.body,
|
|
1029
|
-
editedAt: _optionalChain([data, 'access',
|
|
1051
|
+
editedAt: _optionalChain([data, 'access', _14 => _14.editedAt, 'optionalAccess', _15 => _15.toISOString, 'call', _16 => _16()]),
|
|
1030
1052
|
metadata: data.metadata
|
|
1031
1053
|
},
|
|
1032
1054
|
options
|
|
@@ -1074,7 +1096,7 @@ var Liveblocks = class {
|
|
|
1074
1096
|
...data,
|
|
1075
1097
|
comment: {
|
|
1076
1098
|
...data.comment,
|
|
1077
|
-
createdAt: _optionalChain([data, 'access',
|
|
1099
|
+
createdAt: _optionalChain([data, 'access', _17 => _17.comment, 'access', _18 => _18.createdAt, 'optionalAccess', _19 => _19.toISOString, 'call', _20 => _20()])
|
|
1078
1100
|
}
|
|
1079
1101
|
},
|
|
1080
1102
|
options
|
|
@@ -1197,7 +1219,7 @@ var Liveblocks = class {
|
|
|
1197
1219
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/metadata`,
|
|
1198
1220
|
{
|
|
1199
1221
|
...data,
|
|
1200
|
-
updatedAt: _optionalChain([data, 'access',
|
|
1222
|
+
updatedAt: _optionalChain([data, 'access', _21 => _21.updatedAt, 'optionalAccess', _22 => _22.toISOString, 'call', _23 => _23()])
|
|
1201
1223
|
},
|
|
1202
1224
|
options
|
|
1203
1225
|
);
|
|
@@ -1223,7 +1245,7 @@ var Liveblocks = class {
|
|
|
1223
1245
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/metadata`,
|
|
1224
1246
|
{
|
|
1225
1247
|
...data,
|
|
1226
|
-
updatedAt: _optionalChain([data, 'access',
|
|
1248
|
+
updatedAt: _optionalChain([data, 'access', _24 => _24.updatedAt, 'optionalAccess', _25 => _25.toISOString, 'call', _26 => _26()])
|
|
1227
1249
|
},
|
|
1228
1250
|
options
|
|
1229
1251
|
);
|
|
@@ -1249,7 +1271,7 @@ var Liveblocks = class {
|
|
|
1249
1271
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/add-reaction`,
|
|
1250
1272
|
{
|
|
1251
1273
|
...data,
|
|
1252
|
-
createdAt: _optionalChain([data, 'access',
|
|
1274
|
+
createdAt: _optionalChain([data, 'access', _27 => _27.createdAt, 'optionalAccess', _28 => _28.toISOString, 'call', _29 => _29()])
|
|
1253
1275
|
},
|
|
1254
1276
|
options
|
|
1255
1277
|
);
|
|
@@ -1275,7 +1297,7 @@ var Liveblocks = class {
|
|
|
1275
1297
|
_core.url`/v2/rooms/${roomId}/threads/${threadId}/comments/${params.commentId}/remove-reaction`,
|
|
1276
1298
|
{
|
|
1277
1299
|
...data,
|
|
1278
|
-
removedAt: _optionalChain([data, 'access',
|
|
1300
|
+
removedAt: _optionalChain([data, 'access', _30 => _30.removedAt, 'optionalAccess', _31 => _31.toISOString, 'call', _32 => _32()])
|
|
1279
1301
|
},
|
|
1280
1302
|
options
|
|
1281
1303
|
);
|
|
@@ -1307,25 +1329,30 @@ var Liveblocks = class {
|
|
|
1307
1329
|
* Returns the inbox notifications for a user.
|
|
1308
1330
|
* @param params.userId The user ID to get the inbox notifications from.
|
|
1309
1331
|
* @param params.query The query to filter inbox notifications by. It is based on our query language and can filter by unread.
|
|
1310
|
-
* @param params.
|
|
1332
|
+
* @param params.organizationId (optional) The organization ID to get the inbox notifications for.
|
|
1311
1333
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1312
1334
|
*/
|
|
1313
1335
|
async getInboxNotifications(params, options) {
|
|
1314
|
-
const { userId, tenantId, limit, startingAfter } = params;
|
|
1336
|
+
const { userId, tenantId, organizationId, limit, startingAfter } = params;
|
|
1315
1337
|
let query;
|
|
1316
1338
|
if (typeof params.query === "string") {
|
|
1317
1339
|
query = params.query;
|
|
1318
1340
|
} else if (typeof params.query === "object") {
|
|
1319
1341
|
query = _core.objectToQuery.call(void 0, params.query);
|
|
1320
1342
|
}
|
|
1343
|
+
const queryParams = {
|
|
1344
|
+
query,
|
|
1345
|
+
limit,
|
|
1346
|
+
startingAfter
|
|
1347
|
+
};
|
|
1348
|
+
if (organizationId !== void 0) {
|
|
1349
|
+
queryParams.organizationId = organizationId;
|
|
1350
|
+
} else if (tenantId !== void 0) {
|
|
1351
|
+
queryParams.organizationId = tenantId;
|
|
1352
|
+
}
|
|
1321
1353
|
const res = await this.#get(
|
|
1322
1354
|
_core.url`/v2/users/${userId}/inbox-notifications`,
|
|
1323
|
-
|
|
1324
|
-
query,
|
|
1325
|
-
limit,
|
|
1326
|
-
startingAfter,
|
|
1327
|
-
tenantId
|
|
1328
|
-
},
|
|
1355
|
+
queryParams,
|
|
1329
1356
|
options
|
|
1330
1357
|
);
|
|
1331
1358
|
if (!res.ok) {
|
|
@@ -1345,13 +1372,13 @@ var Liveblocks = class {
|
|
|
1345
1372
|
*
|
|
1346
1373
|
* @param criteria.userId The user ID to get the inbox notifications from.
|
|
1347
1374
|
* @param criteria.query The query to filter inbox notifications by. It is based on our query language and can filter by unread.
|
|
1348
|
-
* @param criteria.
|
|
1375
|
+
* @param criteria.organizationId (optional) The organization ID to get the inbox notifications for.
|
|
1349
1376
|
* @param options.pageSize (optional) The page size to use for each request.
|
|
1350
1377
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1351
1378
|
*/
|
|
1352
1379
|
async *iterInboxNotifications(criteria, options) {
|
|
1353
1380
|
const { signal } = _nullishCoalesce(options, () => ( {}));
|
|
1354
|
-
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1381
|
+
const pageSize = _core.checkBounds.call(void 0, "pageSize", _nullishCoalesce(_optionalChain([options, 'optionalAccess', _33 => _33.pageSize]), () => ( 50)), 10);
|
|
1355
1382
|
let cursor = void 0;
|
|
1356
1383
|
while (true) {
|
|
1357
1384
|
const { nextCursor, data } = await this.getInboxNotifications(
|
|
@@ -1370,20 +1397,25 @@ var Liveblocks = class {
|
|
|
1370
1397
|
/**
|
|
1371
1398
|
* Returns all room subscription settings for a user.
|
|
1372
1399
|
* @param params.userId The user ID to get the room subscription settings from.
|
|
1373
|
-
* @param params.
|
|
1400
|
+
* @param params.organizationId (optional) The organization ID to get the room subscription settings for.
|
|
1374
1401
|
* @param params.startingAfter (optional) The cursor to start the pagination from.
|
|
1375
1402
|
* @param params.limit (optional) The number of items to return.
|
|
1376
1403
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1377
1404
|
*/
|
|
1378
1405
|
async getUserRoomSubscriptionSettings(params, options) {
|
|
1379
|
-
const { userId, tenantId, startingAfter, limit } = params;
|
|
1406
|
+
const { userId, tenantId, organizationId, startingAfter, limit } = params;
|
|
1407
|
+
const queryParams = {
|
|
1408
|
+
startingAfter,
|
|
1409
|
+
limit
|
|
1410
|
+
};
|
|
1411
|
+
if (organizationId !== void 0) {
|
|
1412
|
+
queryParams.organizationId = organizationId;
|
|
1413
|
+
} else if (tenantId !== void 0) {
|
|
1414
|
+
queryParams.organizationId = tenantId;
|
|
1415
|
+
}
|
|
1380
1416
|
const res = await this.#get(
|
|
1381
1417
|
_core.url`/v2/users/${userId}/room-subscription-settings`,
|
|
1382
|
-
|
|
1383
|
-
tenantId,
|
|
1384
|
-
startingAfter,
|
|
1385
|
-
limit
|
|
1386
|
-
},
|
|
1418
|
+
queryParams,
|
|
1387
1419
|
options
|
|
1388
1420
|
);
|
|
1389
1421
|
if (!res.ok) {
|
|
@@ -1471,13 +1503,22 @@ var Liveblocks = class {
|
|
|
1471
1503
|
* @param params.subjectId The subject ID of the triggered inbox notification.
|
|
1472
1504
|
* @param params.activityData The activity data of the triggered inbox notification.
|
|
1473
1505
|
* @param params.roomId (optional) The room ID to trigger the inbox notification for.
|
|
1474
|
-
* @param params.
|
|
1506
|
+
* @param params.organizationId (optional) The organization ID to trigger the inbox notification for.
|
|
1475
1507
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1476
1508
|
*/
|
|
1477
1509
|
async triggerInboxNotification(params, options) {
|
|
1510
|
+
const { tenantId, organizationId, ...restParams } = params;
|
|
1511
|
+
const body = {
|
|
1512
|
+
...restParams
|
|
1513
|
+
};
|
|
1514
|
+
if (organizationId !== void 0) {
|
|
1515
|
+
body.organizationId = organizationId;
|
|
1516
|
+
} else if (tenantId !== void 0) {
|
|
1517
|
+
body.organizationId = tenantId;
|
|
1518
|
+
}
|
|
1478
1519
|
const res = await this.#post(
|
|
1479
1520
|
_core.url`/v2/inbox-notifications/trigger`,
|
|
1480
|
-
|
|
1521
|
+
body,
|
|
1481
1522
|
options
|
|
1482
1523
|
);
|
|
1483
1524
|
if (!res.ok) {
|
|
@@ -1504,14 +1545,20 @@ var Liveblocks = class {
|
|
|
1504
1545
|
/**
|
|
1505
1546
|
* Deletes all inbox notifications for a user.
|
|
1506
1547
|
* @param params.userId The user ID for which to delete all the inbox notifications.
|
|
1507
|
-
* @param params.
|
|
1548
|
+
* @param params.organizationId (optional) The organization ID to delete the inbox notifications for.
|
|
1508
1549
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1509
1550
|
*/
|
|
1510
1551
|
async deleteAllInboxNotifications(params, options) {
|
|
1511
|
-
const { userId, tenantId } = params;
|
|
1552
|
+
const { userId, tenantId, organizationId } = params;
|
|
1553
|
+
const queryParams = {};
|
|
1554
|
+
if (organizationId !== void 0) {
|
|
1555
|
+
queryParams.organizationId = organizationId;
|
|
1556
|
+
} else if (tenantId !== void 0) {
|
|
1557
|
+
queryParams.organizationId = tenantId;
|
|
1558
|
+
}
|
|
1512
1559
|
const res = await this.#delete(
|
|
1513
1560
|
_core.url`/v2/users/${userId}/inbox-notifications`,
|
|
1514
|
-
|
|
1561
|
+
queryParams,
|
|
1515
1562
|
options
|
|
1516
1563
|
);
|
|
1517
1564
|
if (!res.ok) {
|
|
@@ -1577,21 +1624,24 @@ var Liveblocks = class {
|
|
|
1577
1624
|
* Create a group
|
|
1578
1625
|
* @param params.groupId The ID of the group to create.
|
|
1579
1626
|
* @param params.memberIds The IDs of the members to add to the group.
|
|
1580
|
-
* @param params.
|
|
1627
|
+
* @param params.organizationId (optional) The organization ID to create the group for.
|
|
1581
1628
|
* @param params.scopes (optional) The scopes to grant to the group. The default is `{ mention: true }`.
|
|
1582
1629
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1583
1630
|
*/
|
|
1584
1631
|
async createGroup(params, options) {
|
|
1585
|
-
const
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
)
|
|
1632
|
+
const { tenantId, organizationId, ...restParams } = params;
|
|
1633
|
+
const body = {
|
|
1634
|
+
...restParams,
|
|
1635
|
+
// The REST API uses `id` since a group is a resource,
|
|
1636
|
+
// but we use `groupId` here for consistency with the other methods.
|
|
1637
|
+
id: params.groupId
|
|
1638
|
+
};
|
|
1639
|
+
if (organizationId !== void 0) {
|
|
1640
|
+
body.organizationId = organizationId;
|
|
1641
|
+
} else if (tenantId !== void 0) {
|
|
1642
|
+
body.organizationId = tenantId;
|
|
1643
|
+
}
|
|
1644
|
+
const res = await this.#post(_core.url`/v2/groups`, body, options);
|
|
1595
1645
|
if (!res.ok) {
|
|
1596
1646
|
throw await LiveblocksError.from(res);
|
|
1597
1647
|
}
|
|
@@ -1675,7 +1725,7 @@ var Liveblocks = class {
|
|
|
1675
1725
|
async getGroups(params, options) {
|
|
1676
1726
|
const res = await this.#get(
|
|
1677
1727
|
_core.url`/v2/groups`,
|
|
1678
|
-
{ startingAfter: _optionalChain([params, 'optionalAccess',
|
|
1728
|
+
{ startingAfter: _optionalChain([params, 'optionalAccess', _34 => _34.startingAfter]), limit: _optionalChain([params, 'optionalAccess', _35 => _35.limit]) },
|
|
1679
1729
|
options
|
|
1680
1730
|
);
|
|
1681
1731
|
if (!res.ok) {
|
|
@@ -1737,7 +1787,7 @@ var Liveblocks = class {
|
|
|
1737
1787
|
async massMutateStorage(criteria, callback, massOptions) {
|
|
1738
1788
|
const concurrency = _core.checkBounds.call(void 0,
|
|
1739
1789
|
"concurrency",
|
|
1740
|
-
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess',
|
|
1790
|
+
_nullishCoalesce(_optionalChain([massOptions, 'optionalAccess', _36 => _36.concurrency]), () => ( 8)),
|
|
1741
1791
|
1,
|
|
1742
1792
|
20
|
|
1743
1793
|
);
|
|
@@ -1753,7 +1803,7 @@ var Liveblocks = class {
|
|
|
1753
1803
|
}
|
|
1754
1804
|
async #_mutateOneRoom(roomId, room, callback, options) {
|
|
1755
1805
|
const debounceInterval = 200;
|
|
1756
|
-
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess',
|
|
1806
|
+
const { signal, abort } = _core.makeAbortController.call(void 0, _optionalChain([options, 'optionalAccess', _37 => _37.signal]));
|
|
1757
1807
|
let opsBuffer = [];
|
|
1758
1808
|
let outstandingFlush$ = void 0;
|
|
1759
1809
|
let lastFlush = performance.now();
|
|
@@ -1819,7 +1869,7 @@ var Liveblocks = class {
|
|
|
1819
1869
|
const res = await this.#post(
|
|
1820
1870
|
_core.url`/v2/rooms/${roomId}/send-message`,
|
|
1821
1871
|
{ messages },
|
|
1822
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
1872
|
+
{ signal: _optionalChain([options, 'optionalAccess', _38 => _38.signal]) }
|
|
1823
1873
|
);
|
|
1824
1874
|
if (!res.ok) {
|
|
1825
1875
|
throw await LiveblocksError.from(res);
|
|
@@ -1956,7 +2006,7 @@ var Liveblocks = class {
|
|
|
1956
2006
|
"Content-Type": params.file.type,
|
|
1957
2007
|
"Content-Length": String(params.file.size)
|
|
1958
2008
|
},
|
|
1959
|
-
signal: _optionalChain([options, 'optionalAccess',
|
|
2009
|
+
signal: _optionalChain([options, 'optionalAccess', _39 => _39.signal])
|
|
1960
2010
|
}
|
|
1961
2011
|
);
|
|
1962
2012
|
if (!res.ok) {
|