@liveblocks/node 3.14.0-pre5 → 3.14.0-rc1

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.js CHANGED
@@ -3,7 +3,7 @@ import { detectDupes } from "@liveblocks/core";
3
3
 
4
4
  // src/version.ts
5
5
  var PKG_NAME = "@liveblocks/node";
6
- var PKG_VERSION = "3.14.0-pre5";
6
+ var PKG_VERSION = "3.14.0-rc1";
7
7
  var PKG_FORMAT = "esm";
8
8
 
9
9
  // src/client.ts
@@ -171,16 +171,16 @@ var Session = class {
171
171
  #postFn;
172
172
  #userId;
173
173
  #userInfo;
174
- #tenantId;
174
+ #organizationId;
175
175
  #sealed = false;
176
176
  #permissions = /* @__PURE__ */ new Map();
177
177
  /** @internal */
178
- constructor(postFn, userId, userInfo, tenantId) {
178
+ constructor(postFn, userId, userInfo, organizationId) {
179
179
  assertNonEmpty(userId, "userId");
180
180
  this.#postFn = postFn;
181
181
  this.#userId = userId;
182
182
  this.#userInfo = userInfo;
183
- this.#tenantId = tenantId;
183
+ this.#organizationId = organizationId;
184
184
  }
185
185
  #getOrCreate(roomId) {
186
186
  if (this.#sealed) {
@@ -254,14 +254,17 @@ var Session = class {
254
254
  );
255
255
  }
256
256
  try {
257
- const resp = await this.#postFn(url`/v2/authorize-user`, {
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
- tenantId: this.#tenantId
264
- });
262
+ userInfo: this.#userInfo
263
+ };
264
+ if (this.#organizationId !== void 0) {
265
+ body.organizationId = this.#organizationId;
266
+ }
267
+ const resp = await this.#postFn(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 tenantId (optional) The tenant ID to authorize the user for.
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
  options?.userInfo,
407
- options?.tenantId
410
+ options?.organizationId ?? options?.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 = url2`/v2/identify-user`;
446
- const { userId, groupIds, tenantId } = typeof identity === "string" ? { userId: identity, groupIds: void 0, tenantId: void 0 } : identity;
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
- tenantId,
452
459
  userInfo: options?.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.tenantId (optional) A filter on tenant ID.
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);
@@ -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.tenantId (optional) The tenant ID to create the room for.
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
596
  options?.idempotent ? url2`/v2/rooms?idempotent` : url2`/v2/rooms`,
567
- {
568
- id: roomId,
569
- defaultAccesses,
570
- groupsAccesses,
571
- usersAccesses,
572
- tenantId,
573
- metadata,
574
- engine
575
- },
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.tenantId (optional) The tenant ID to create the room for.
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
  */
@@ -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.tenantId (optional) The tenant ID to get the inbox notifications for.
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 = objectToQuery(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
  url2`/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,7 +1372,7 @@ 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.tenantId (optional) The tenant ID to get the inbox notifications for.
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
  */
@@ -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.tenantId (optional) The tenant ID to get the room subscription settings for.
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
  url2`/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.tenantId (optional) The tenant ID to trigger the inbox notification for.
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
  url2`/v2/inbox-notifications/trigger`,
1480
- params,
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.tenantId (optional) The tenant ID to delete the inbox notifications for.
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
  url2`/v2/users/${userId}/inbox-notifications`,
1514
- { tenantId },
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.tenantId (optional) The tenant ID to create the group for.
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 res = await this.#post(
1586
- url2`/v2/groups`,
1587
- {
1588
- ...params,
1589
- // The REST API uses `id` since a group is a resource,
1590
- // but we use `groupId` here for consistency with the other methods.
1591
- id: params.groupId
1592
- },
1593
- options
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(url2`/v2/groups`, body, options);
1595
1645
  if (!res.ok) {
1596
1646
  throw await LiveblocksError.from(res);
1597
1647
  }