@amityco/ts-sdk 7.11.1-78c2ad3f.0 → 7.11.1-7dbda1f3.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.
Files changed (125) hide show
  1. package/dist/@types/core/events.d.ts +4 -3
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +2 -2
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +20 -4
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/domains/community.d.ts +10 -7
  8. package/dist/@types/domains/community.d.ts.map +1 -1
  9. package/dist/@types/domains/event.d.ts +20 -8
  10. package/dist/@types/domains/event.d.ts.map +1 -1
  11. package/dist/@types/domains/room.d.ts +11 -0
  12. package/dist/@types/domains/room.d.ts.map +1 -1
  13. package/dist/client/api/getPresenceSetting.d.ts +2 -0
  14. package/dist/client/api/getPresenceSetting.d.ts.map +1 -0
  15. package/dist/client/api/resumeSession.d.ts.map +1 -1
  16. package/dist/client/events/onUserDeleted.d.ts +17 -0
  17. package/dist/client/events/onUserDeleted.d.ts.map +1 -0
  18. package/dist/client/services/ObjectResolver/objectResolverEngine.d.ts.map +1 -0
  19. package/dist/client/services/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +1 -0
  20. package/dist/client/services/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +1 -0
  21. package/dist/client/services/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +1 -0
  22. package/dist/client/services/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -0
  23. package/dist/client/services/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts.map +1 -0
  24. package/dist/core/events.d.ts +3 -3
  25. package/dist/core/events.d.ts.map +1 -1
  26. package/dist/core/model/idResolvers.d.ts.map +1 -1
  27. package/dist/core/model/index.d.ts.map +1 -1
  28. package/dist/eventRepository/observers/index.d.ts +0 -1
  29. package/dist/eventRepository/observers/index.d.ts.map +1 -1
  30. package/dist/index.cjs.js +457 -282
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.esm.js +443 -269
  34. package/dist/index.umd.js +3 -3
  35. package/dist/invitationRepository/api/index.d.ts +0 -1
  36. package/dist/invitationRepository/api/index.d.ts.map +1 -1
  37. package/dist/invitationRepository/internalObservers/getInvitations/InvitationsLiveCollectionController.d.ts.map +1 -0
  38. package/dist/invitationRepository/internalObservers/getInvitations/InvitationsPaginationController.d.ts.map +1 -0
  39. package/dist/invitationRepository/internalObservers/getInvitations/InvitationsQueryStreamController.d.ts.map +1 -0
  40. package/dist/invitationRepository/internalObservers/getInvitations/enums.d.ts.map +1 -0
  41. package/dist/invitationRepository/internalObservers/getInvitations.d.ts +12 -0
  42. package/dist/invitationRepository/internalObservers/getInvitations.d.ts.map +1 -0
  43. package/dist/invitationRepository/observers/getInvitations.d.ts +28 -6
  44. package/dist/invitationRepository/observers/getInvitations.d.ts.map +1 -1
  45. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts +1 -1
  46. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts.map +1 -1
  47. package/dist/invitationRepository/observers/index.d.ts +1 -1
  48. package/dist/invitationRepository/observers/index.d.ts.map +1 -1
  49. package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts +2 -2
  50. package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts.map +1 -1
  51. package/dist/roomPresenceRepository/api/getRoomOnlineUsers.d.ts +18 -0
  52. package/dist/roomPresenceRepository/api/getRoomOnlineUsers.d.ts.map +1 -0
  53. package/dist/roomPresenceRepository/api/getRoomUserCount.d.ts +17 -0
  54. package/dist/roomPresenceRepository/api/getRoomUserCount.d.ts.map +1 -0
  55. package/dist/roomPresenceRepository/api/index.d.ts +5 -0
  56. package/dist/roomPresenceRepository/api/index.d.ts.map +1 -0
  57. package/dist/roomPresenceRepository/api/startHeartbeat.d.ts +15 -0
  58. package/dist/roomPresenceRepository/api/startHeartbeat.d.ts.map +1 -0
  59. package/dist/roomPresenceRepository/api/stopHeartbeat.d.ts +15 -0
  60. package/dist/roomPresenceRepository/api/stopHeartbeat.d.ts.map +1 -0
  61. package/dist/roomPresenceRepository/index.d.ts +2 -0
  62. package/dist/roomPresenceRepository/index.d.ts.map +1 -0
  63. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/RoomPresenceSyncEngine.d.ts +38 -0
  64. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/RoomPresenceSyncEngine.d.ts.map +1 -0
  65. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/index.d.ts +2 -0
  66. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/index.d.ts.map +1 -0
  67. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/roomPresenceSyncEngineFactory.d.ts +32 -0
  68. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/roomPresenceSyncEngineFactory.d.ts.map +1 -0
  69. package/dist/roomPresenceRepository/services/index.d.ts +2 -0
  70. package/dist/roomPresenceRepository/services/index.d.ts.map +1 -0
  71. package/dist/roomRepository/api/removeParticipant.d.ts.map +1 -1
  72. package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts +1 -1
  73. package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts.map +1 -1
  74. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +1 -1
  75. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +1 -1
  76. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +1 -1
  77. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +1 -1
  78. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +1 -1
  79. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +1 -1
  80. package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts +17 -0
  81. package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts.map +1 -0
  82. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +1 -1
  83. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +1 -1
  84. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +1 -1
  85. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +1 -1
  86. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +1 -1
  87. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +1 -1
  88. package/dist/roomRepository/observers/getRoom.d.ts.map +1 -1
  89. package/dist/roomRepository/observers/utils.d.ts +1 -1
  90. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -1
  91. package/package.json +1 -1
  92. package/dist/client/utils/ObjectResolver/objectResolverEngine.d.ts.map +0 -1
  93. package/dist/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +0 -1
  94. package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +0 -1
  95. package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
  96. package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +0 -1
  97. package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
  98. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts +0 -13
  99. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +0 -1
  100. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +0 -5
  101. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +0 -1
  102. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +0 -15
  103. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +0 -1
  104. package/dist/eventRepository/observers/getMyEvents.d.ts +0 -12
  105. package/dist/eventRepository/observers/getMyEvents.d.ts.map +0 -1
  106. package/dist/invitationRepository/api/acceptInvitation.d.ts +0 -16
  107. package/dist/invitationRepository/api/acceptInvitation.d.ts.map +0 -1
  108. package/dist/invitationRepository/api/getMyInvitation.d.ts +0 -16
  109. package/dist/invitationRepository/api/getMyInvitation.d.ts.map +0 -1
  110. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +0 -1
  111. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +0 -1
  112. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +0 -1
  113. package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +0 -1
  114. package/dist/invitationRepository/observers/observeInvitations.d.ts +0 -34
  115. package/dist/invitationRepository/observers/observeInvitations.d.ts.map +0 -1
  116. /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngine.d.ts +0 -0
  117. /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts +0 -0
  118. /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts +0 -0
  119. /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts +0 -0
  120. /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngine.d.ts +0 -0
  121. /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts +0 -0
  122. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsLiveCollectionController.d.ts +0 -0
  123. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsPaginationController.d.ts +0 -0
  124. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsQueryStreamController.d.ts +0 -0
  125. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/enums.d.ts +0 -0
package/dist/index.cjs.js CHANGED
@@ -88,6 +88,11 @@ const CommunityPostSettingMaps = Object.freeze({
88
88
  },
89
89
  });
90
90
  const DefaultCommunityPostSetting = 'ONLY_ADMIN_CAN_POST';
91
+ exports.AmityCommunityType = void 0;
92
+ (function (AmityCommunityType) {
93
+ AmityCommunityType["Default"] = "default";
94
+ AmityCommunityType["Event"] = "event";
95
+ })(exports.AmityCommunityType || (exports.AmityCommunityType = {}));
91
96
 
92
97
  const ContentFeedType = Object.freeze({
93
98
  STORY: 'story',
@@ -222,6 +227,16 @@ exports.AmityEventResponseStatus = void 0;
222
227
  AmityEventResponseStatus["Interested"] = "interested";
223
228
  AmityEventResponseStatus["NotGoing"] = "not_going";
224
229
  })(exports.AmityEventResponseStatus || (exports.AmityEventResponseStatus = {}));
230
+ exports.AmityEventSortOption = void 0;
231
+ (function (AmityEventSortOption) {
232
+ AmityEventSortOption["StartTime"] = "startTime";
233
+ AmityEventSortOption["CreatedAt"] = "createdAt";
234
+ })(exports.AmityEventSortOption || (exports.AmityEventSortOption = {}));
235
+ exports.AmityEventOrderOption = void 0;
236
+ (function (AmityEventOrderOption) {
237
+ AmityEventOrderOption["Ascending"] = "asc";
238
+ AmityEventOrderOption["Descending"] = "desc";
239
+ })(exports.AmityEventOrderOption || (exports.AmityEventOrderOption = {}));
225
240
 
226
241
  function getVersion() {
227
242
  try {
@@ -673,7 +688,6 @@ const idResolvers = {
673
688
  joinRequest: ({ joinRequestId }) => joinRequestId,
674
689
  room: ({ roomId }) => roomId,
675
690
  event: ({ eventId }) => eventId,
676
- discussionCommunity: ({ communityId }) => communityId,
677
691
  };
678
692
  /**
679
693
  * Retrieve the id resolver matching a domain name
@@ -731,7 +745,7 @@ const PAYLOAD2MODEL = {
731
745
  joinRequests: 'joinRequest',
732
746
  rooms: 'room',
733
747
  events: 'event',
734
- discussionCommunities: 'discussionCommunity',
748
+ viewers: 'viewer',
735
749
  };
736
750
  /** hidden */
737
751
  const isOutdated = (prevData, nextData) => {
@@ -1462,14 +1476,12 @@ const createEventEmitter = () => {
1462
1476
  const proxyMqttEvents = (mqttClient, emitter) => {
1463
1477
  MQTT_EVENTS.forEach(event => {
1464
1478
  mqttClient === null || mqttClient === void 0 ? void 0 : mqttClient.on(event, (...params) => {
1465
- console.log('global event received => ', event);
1466
1479
  emitter.emit(event, params.length === 1 ? params[0] : params);
1467
1480
  });
1468
1481
  });
1469
1482
  // @ts-ignore
1470
1483
  mqttClient.on('message', (topic, payload) => {
1471
1484
  const message = JSON.parse(payload.toString());
1472
- console.log('message event received => ', message.eventType, message.data);
1473
1485
  emitter.emit(message.eventType, message.data);
1474
1486
  });
1475
1487
  };
@@ -8511,11 +8523,11 @@ var objectResolverEngineOnLoginHandler = () => {
8511
8523
  * @category Live Reaction API
8512
8524
  * @async
8513
8525
  */
8514
- const createLiveReaction = async ({ reactions, roomId, }) => {
8526
+ const createLiveReaction = async ({ reactions, liveStreamId, }) => {
8515
8527
  const client = getActiveClient();
8516
8528
  client.log('live_reaction/addReaction', reactions);
8517
8529
  const { data } = await client.http.post(`/api/v1/reactions/live`, {
8518
- roomId,
8530
+ liveStreamId,
8519
8531
  reactions,
8520
8532
  });
8521
8533
  return data;
@@ -8585,7 +8597,7 @@ class LiveReactionSyncEngine {
8585
8597
  // Call server api `POST /api/v1/reactions/live` to sync live reactions
8586
8598
  Object.entries(payloads).forEach(([roomId, reactions]) => {
8587
8599
  createLiveReaction({
8588
- roomId,
8600
+ liveStreamId: roomId,
8589
8601
  reactions,
8590
8602
  });
8591
8603
  });
@@ -10507,7 +10519,7 @@ const getUserUnread = (callback) => {
10507
10519
  };
10508
10520
  };
10509
10521
 
10510
- var index$q = /*#__PURE__*/Object.freeze({
10522
+ var index$r = /*#__PURE__*/Object.freeze({
10511
10523
  __proto__: null,
10512
10524
  getActiveClient: getActiveClient,
10513
10525
  getActiveUser: getActiveUser,
@@ -11726,7 +11738,7 @@ const getMyFollowInfo = (callback) => {
11726
11738
  };
11727
11739
  /* end_public_function */
11728
11740
 
11729
- var index$p = /*#__PURE__*/Object.freeze({
11741
+ var index$q = /*#__PURE__*/Object.freeze({
11730
11742
  __proto__: null,
11731
11743
  blockUser: blockUser,
11732
11744
  unBlockUser: unBlockUser,
@@ -12371,7 +12383,7 @@ const createInvitations = async (bundle) => {
12371
12383
  * @category Invitation API
12372
12384
  * @async
12373
12385
  */
12374
- const acceptInvitation$1 = async (invitationId) => {
12386
+ const acceptInvitation = async (invitationId) => {
12375
12387
  var _a;
12376
12388
  const client = getActiveClient();
12377
12389
  client.log('invitation/acceptInvitation', invitationId);
@@ -12457,7 +12469,7 @@ const invitationLinkedObject = (invitation) => {
12457
12469
  }
12458
12470
  return undefined;
12459
12471
  }, accept: async () => {
12460
- await acceptInvitation$1(invitation._id);
12472
+ await acceptInvitation(invitation._id);
12461
12473
  }, reject: async () => {
12462
12474
  await rejectInvitation(invitation._id);
12463
12475
  } });
@@ -12708,7 +12720,7 @@ class InvitationsLiveCollectionController extends LiveCollectionController {
12708
12720
  * @category Invitation Live Collection
12709
12721
  *
12710
12722
  */
12711
- const getInvitations = (params, callback, config) => {
12723
+ const getInvitations$1 = (params, callback, config) => {
12712
12724
  const { log, cache } = getActiveClient();
12713
12725
  if (!cache) {
12714
12726
  console.log(ENABLE_CACHE_MESSAGE);
@@ -12807,7 +12819,7 @@ const roomLinkedObject = (room) => {
12807
12819
  targetType: 'room',
12808
12820
  targetId: room.roomId,
12809
12821
  userIds: [userId],
12810
- }), getInvitations: (params, callback) => getInvitations(Object.assign(Object.assign({}, params), { targetId: room.roomId, targetType: 'room', type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */ }), callback), getMyInvitation: async () => {
12822
+ }), getInvitations: (params, callback) => getInvitations$1(Object.assign(Object.assign({}, params), { targetId: room.roomId, targetType: 'room', type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */ }), callback), getMyInvitation: async () => {
12811
12823
  const { data } = await getInvitation({
12812
12824
  targetId: room.roomId,
12813
12825
  targetType: 'room',
@@ -13806,7 +13818,7 @@ const communityLinkedObject = (community) => {
13806
13818
  userIds,
13807
13819
  });
13808
13820
  }, getMemberInvitations: (params, callback) => {
13809
- return getInvitations(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
13821
+ return getInvitations$1(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
13810
13822
  }, getInvitation: async () => {
13811
13823
  const { data } = await getInvitation({
13812
13824
  targetType: 'community',
@@ -13828,18 +13840,6 @@ const eventLinkedObject = (event) => {
13828
13840
  return;
13829
13841
  return userLinkedObject(cacheData.data);
13830
13842
  },
13831
- get discussionCommunity() {
13832
- if (!event.discussionCommunityId)
13833
- return;
13834
- const cacheData = pullFromCache([
13835
- 'discussionCommunity',
13836
- 'get',
13837
- event.discussionCommunityId,
13838
- ]);
13839
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
13840
- return;
13841
- return communityLinkedObject(cacheData.data);
13842
- },
13843
13843
  get targetCommunity() {
13844
13844
  if (!event.originId)
13845
13845
  return;
@@ -13856,13 +13856,22 @@ const eventLinkedObject = (event) => {
13856
13856
  return;
13857
13857
  return cacheData.data;
13858
13858
  },
13859
- get liveStream() {
13860
- if (!event.livestreamId)
13859
+ get post() {
13860
+ if (!event.postId)
13861
13861
  return;
13862
- const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
13862
+ const cacheData = pullFromCache(['post', 'get', event.postId]);
13863
13863
  if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
13864
13864
  return;
13865
- return cacheData.data;
13865
+ return postLinkedObject(cacheData.data);
13866
+ },
13867
+ get room() {
13868
+ var _a;
13869
+ if (!event.postId)
13870
+ return;
13871
+ const cacheData = (_a = queryCache(['room', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(room => room.data.referenceId === event.postId);
13872
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.length) || !cacheData[0].data)
13873
+ return;
13874
+ return roomLinkedObject(cacheData[0].data);
13866
13875
  } });
13867
13876
  };
13868
13877
 
@@ -14876,9 +14885,9 @@ var AmityUserSearchMatchType;
14876
14885
  AmityUserSearchMatchType["PARTIAL"] = "partial";
14877
14886
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
14878
14887
 
14879
- var index$o = /*#__PURE__*/Object.freeze({
14888
+ var index$p = /*#__PURE__*/Object.freeze({
14880
14889
  __proto__: null,
14881
- Relationship: index$p,
14890
+ Relationship: index$q,
14882
14891
  getUserByIds: getUserByIds,
14883
14892
  updateUser: updateUser,
14884
14893
  flagUser: flagUser,
@@ -15281,7 +15290,7 @@ const uploadAudio = async (formData, onProgress) => {
15281
15290
  };
15282
15291
  /* end_public_function */
15283
15292
 
15284
- var index$n = /*#__PURE__*/Object.freeze({
15293
+ var index$o = /*#__PURE__*/Object.freeze({
15285
15294
  __proto__: null,
15286
15295
  getFile: getFile,
15287
15296
  uploadFile: uploadFile,
@@ -17093,7 +17102,7 @@ const getReactions$1 = (params, callback, config) => {
17093
17102
  };
17094
17103
  /* end_public_function */
17095
17104
 
17096
- var index$m = /*#__PURE__*/Object.freeze({
17105
+ var index$n = /*#__PURE__*/Object.freeze({
17097
17106
  __proto__: null,
17098
17107
  addReaction: addReaction,
17099
17108
  removeReaction: removeReaction,
@@ -18865,7 +18874,7 @@ const getMessages = (params, callback, config) => {
18865
18874
  };
18866
18875
  /* end_public_function */
18867
18876
 
18868
- var index$l = /*#__PURE__*/Object.freeze({
18877
+ var index$m = /*#__PURE__*/Object.freeze({
18869
18878
  __proto__: null,
18870
18879
  createMessage: createMessage,
18871
18880
  updateMessage: updateMessage,
@@ -19391,7 +19400,7 @@ const stopMessageReceiptSync = (subChannelId) => {
19391
19400
  };
19392
19401
  /* end_public_function */
19393
19402
 
19394
- var index$k = /*#__PURE__*/Object.freeze({
19403
+ var index$l = /*#__PURE__*/Object.freeze({
19395
19404
  __proto__: null,
19396
19405
  getSubChannelByIds: getSubChannels$1,
19397
19406
  createSubChannel: createSubChannel,
@@ -20718,7 +20727,7 @@ const searchMembers$1 = (params, callback, config) => {
20718
20727
  };
20719
20728
  /* end_public_function */
20720
20729
 
20721
- var index$j = /*#__PURE__*/Object.freeze({
20730
+ var index$k = /*#__PURE__*/Object.freeze({
20722
20731
  __proto__: null,
20723
20732
  addMembers: addMembers$1,
20724
20733
  removeMembers: removeMembers$1,
@@ -20921,7 +20930,7 @@ const unmuteMembers = async (channelId, userIds) => {
20921
20930
  };
20922
20931
  /* end_public_function */
20923
20932
 
20924
- var index$i = /*#__PURE__*/Object.freeze({
20933
+ var index$j = /*#__PURE__*/Object.freeze({
20925
20934
  __proto__: null,
20926
20935
  addRole: addRole,
20927
20936
  removeRole: removeRole,
@@ -20931,10 +20940,10 @@ var index$i = /*#__PURE__*/Object.freeze({
20931
20940
  unmuteMembers: unmuteMembers
20932
20941
  });
20933
20942
 
20934
- var index$h = /*#__PURE__*/Object.freeze({
20943
+ var index$i = /*#__PURE__*/Object.freeze({
20935
20944
  __proto__: null,
20936
- Membership: index$j,
20937
- Moderation: index$i,
20945
+ Membership: index$k,
20946
+ Moderation: index$j,
20938
20947
  getChannelByIds: getChannelByIds$1,
20939
20948
  createChannel: createChannel,
20940
20949
  updateChannel: updateChannel,
@@ -22337,7 +22346,7 @@ const searchMembers = (params, callback, config) => {
22337
22346
  };
22338
22347
  /* end_public_function */
22339
22348
 
22340
- var index$g = /*#__PURE__*/Object.freeze({
22349
+ var index$h = /*#__PURE__*/Object.freeze({
22341
22350
  __proto__: null,
22342
22351
  addMembers: addMembers,
22343
22352
  removeMembers: removeMembers,
@@ -23588,7 +23597,7 @@ const unbanMembers = async (communityId, userIds) => {
23588
23597
  };
23589
23598
  /* end_public_function */
23590
23599
 
23591
- var index$f = /*#__PURE__*/Object.freeze({
23600
+ var index$g = /*#__PURE__*/Object.freeze({
23592
23601
  __proto__: null,
23593
23602
  addRoles: addRoles,
23594
23603
  removeRoles: removeRoles,
@@ -23596,10 +23605,10 @@ var index$f = /*#__PURE__*/Object.freeze({
23596
23605
  unbanMembers: unbanMembers
23597
23606
  });
23598
23607
 
23599
- var index$e = /*#__PURE__*/Object.freeze({
23608
+ var index$f = /*#__PURE__*/Object.freeze({
23600
23609
  __proto__: null,
23601
- Moderation: index$f,
23602
- Membership: index$g,
23610
+ Moderation: index$g,
23611
+ Membership: index$h,
23603
23612
  getCommunityByIds: getCommunities$1,
23604
23613
  createCommunity: createCommunity,
23605
23614
  updateCommunity: updateCommunity,
@@ -23833,7 +23842,7 @@ const getCategories = (params, callback, config) => {
23833
23842
  };
23834
23843
  /* end_public_function */
23835
23844
 
23836
- var index$d = /*#__PURE__*/Object.freeze({
23845
+ var index$e = /*#__PURE__*/Object.freeze({
23837
23846
  __proto__: null,
23838
23847
  getCategory: getCategory,
23839
23848
  getCategories: getCategories
@@ -24892,7 +24901,7 @@ const getComments = (params, callback, config) => {
24892
24901
  };
24893
24902
  /* end_public_function */
24894
24903
 
24895
- var index$c = /*#__PURE__*/Object.freeze({
24904
+ var index$d = /*#__PURE__*/Object.freeze({
24896
24905
  __proto__: null,
24897
24906
  getCommentByIds: getCommentByIds,
24898
24907
  createComment: createComment,
@@ -25563,7 +25572,7 @@ const getUserFeed = (params, callback, config) => {
25563
25572
  };
25564
25573
  /* end_public_function */
25565
25574
 
25566
- var index$b = /*#__PURE__*/Object.freeze({
25575
+ var index$c = /*#__PURE__*/Object.freeze({
25567
25576
  __proto__: null,
25568
25577
  queryGlobalFeed: queryGlobalFeed,
25569
25578
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -27244,7 +27253,7 @@ const searchPostsByHashtag = (params, callback, config) => {
27244
27253
  };
27245
27254
  /* end_public_function */
27246
27255
 
27247
- var index$a = /*#__PURE__*/Object.freeze({
27256
+ var index$b = /*#__PURE__*/Object.freeze({
27248
27257
  __proto__: null,
27249
27258
  getPostByIds: getPostByIds,
27250
27259
  createPost: createPost,
@@ -27852,7 +27861,7 @@ const getStreams = (params, callback, config) => {
27852
27861
  };
27853
27862
  };
27854
27863
 
27855
- var index$9 = /*#__PURE__*/Object.freeze({
27864
+ var index$a = /*#__PURE__*/Object.freeze({
27856
27865
  __proto__: null,
27857
27866
  createStream: createStream,
27858
27867
  updateStream: updateStream,
@@ -28067,9 +28076,7 @@ const getRecordedUrl = async (roomId) => {
28067
28076
  const removeParticipant = async (roomId, participantUserId) => {
28068
28077
  const client = getActiveClient();
28069
28078
  client.log('room/removeParticipant', { roomId, participantUserId });
28070
- await client.http.delete(`/api/v1/rooms/${roomId}/participants`, {
28071
- data: { participantUserId },
28072
- });
28079
+ await client.http.delete(`/api/v1/rooms/${roomId}/participants/${participantUserId}`);
28073
28080
  fireEvent('local.room.participantRemoved', {
28074
28081
  rooms: [{ _id: roomId }],
28075
28082
  users: [{ _id: participantUserId }],
@@ -28225,6 +28232,46 @@ const onRoomCoHostInvited = (callback) => {
28225
28232
  return createEventSubscriber(client, 'room/onRoomCoHostInvited', 'room.didCohostInvite', filter);
28226
28233
  };
28227
28234
 
28235
+ const getRoomById = async (roomId) => {
28236
+ const client = getActiveClient();
28237
+ client.log('room/getRoomById', roomId);
28238
+ // Check if room is in tombstone
28239
+ isInTombstone('room', roomId);
28240
+ let data;
28241
+ try {
28242
+ const response = await client.http.get(`/api/v1/rooms/${roomId}`);
28243
+ data = response.data;
28244
+ }
28245
+ catch (error) {
28246
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
28247
+ pushToTombstone('room', roomId);
28248
+ }
28249
+ throw error;
28250
+ }
28251
+ const cachedAt = client.cache && Date.now();
28252
+ if (client.cache) {
28253
+ ingestInCache(data, { cachedAt });
28254
+ }
28255
+ return {
28256
+ data: data.rooms[0],
28257
+ cachedAt,
28258
+ };
28259
+ };
28260
+ getRoomById.locally = (roomId) => {
28261
+ const client = getActiveClient();
28262
+ client.log('room/getRoomById.locally', roomId);
28263
+ // Check if room is in tombstone
28264
+ isInTombstone('room', roomId);
28265
+ const cachedAt = client.cache && Date.now();
28266
+ const roomCache = pullFromCache(['room', 'get', roomId]);
28267
+ if (!roomCache)
28268
+ return;
28269
+ return {
28270
+ data: roomCache.data,
28271
+ cachedAt,
28272
+ };
28273
+ };
28274
+
28228
28275
  /**
28229
28276
  * ```js
28230
28277
  * import { onRoomCoHostInviteAccepted } from '@amityco/ts-sdk'
@@ -28242,12 +28289,14 @@ const onRoomCoHostInvited = (callback) => {
28242
28289
  */
28243
28290
  const onRoomCoHostInviteAccepted = (callback) => {
28244
28291
  const client = getActiveClient();
28245
- const filter = (payload) => {
28292
+ const filter = async (payload) => {
28293
+ var _a;
28246
28294
  const data = prepareMyInvitationsPayload(payload);
28295
+ await getRoomById((_a = data.invitations) === null || _a === void 0 ? void 0 : _a[0].targetId);
28247
28296
  ingestInCache(data);
28248
- callback(data.invitations);
28297
+ callback(data.invitations[0]);
28249
28298
  };
28250
- return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCoHostInviteAccept', filter);
28299
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCohostInviteAccept', filter);
28251
28300
  };
28252
28301
 
28253
28302
  /**
@@ -28272,7 +28321,7 @@ const onRoomCoHostInviteRejected = (callback) => {
28272
28321
  ingestInCache(data);
28273
28322
  callback(data.invitations);
28274
28323
  };
28275
- return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCoHostInviteReject', filter);
28324
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCohostInviteReject', filter);
28276
28325
  };
28277
28326
 
28278
28327
  /**
@@ -28297,7 +28346,7 @@ const onRoomCoHostInviteCanceled = (callback) => {
28297
28346
  ingestInCache(data);
28298
28347
  callback(data.invitations);
28299
28348
  };
28300
- return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCoHostInviteCancel', filter);
28349
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCohostInviteCancel', filter);
28301
28350
  };
28302
28351
 
28303
28352
  /**
@@ -28465,7 +28514,7 @@ const onRoomParticipantRemoved = (callback) => {
28465
28514
  ingestInCache(payload);
28466
28515
  callback(payload.rooms[0]);
28467
28516
  };
28468
- return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
28517
+ return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'room.participantRemoved', filter);
28469
28518
  };
28470
28519
 
28471
28520
  /**
@@ -28492,44 +28541,28 @@ const onRoomLeft = (callback) => {
28492
28541
  return createEventSubscriber(client, 'room/onRoomLeft', 'local.room.left', filter);
28493
28542
  };
28494
28543
 
28495
- const getRoomById = async (roomId) => {
28496
- const client = getActiveClient();
28497
- client.log('room/getRoomById', roomId);
28498
- // Check if room is in tombstone
28499
- isInTombstone('room', roomId);
28500
- let data;
28501
- try {
28502
- const response = await client.http.get(`/api/v1/rooms/${roomId}`);
28503
- data = response.data;
28504
- }
28505
- catch (error) {
28506
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
28507
- pushToTombstone('room', roomId);
28508
- }
28509
- throw error;
28510
- }
28511
- const cachedAt = client.cache && Date.now();
28512
- if (client.cache) {
28513
- ingestInCache(data, { cachedAt });
28514
- }
28515
- return {
28516
- data: data.rooms[0],
28517
- cachedAt,
28518
- };
28519
- };
28520
- getRoomById.locally = (roomId) => {
28544
+ /**
28545
+ * ```js
28546
+ * import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
28547
+ * const dispose = onRoomParticipantRemoved(room => {
28548
+ * // ...
28549
+ * })
28550
+ * ```
28551
+ *
28552
+ * Fired when a participant has been removed from a {@link Amity.Room} locally
28553
+ *
28554
+ * @param callback The function to call when the event was fired
28555
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
28556
+ *
28557
+ * @category Room Events
28558
+ */
28559
+ const onRoomParticipantRemovedLocal = (callback) => {
28521
28560
  const client = getActiveClient();
28522
- client.log('room/getRoomById.locally', roomId);
28523
- // Check if room is in tombstone
28524
- isInTombstone('room', roomId);
28525
- const cachedAt = client.cache && Date.now();
28526
- const roomCache = pullFromCache(['room', 'get', roomId]);
28527
- if (!roomCache)
28528
- return;
28529
- return {
28530
- data: roomCache.data,
28531
- cachedAt,
28561
+ const filter = (payload) => {
28562
+ ingestInCache(payload);
28563
+ callback(payload.rooms[0]);
28532
28564
  };
28565
+ return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
28533
28566
  };
28534
28567
 
28535
28568
  const getRoom = (roomId, callback) => {
@@ -28539,6 +28572,11 @@ const getRoom = (roomId, callback) => {
28539
28572
  onRoomStartBroadcasting,
28540
28573
  onRoomWaitingReconnect,
28541
28574
  onRoomRecordedAvailable,
28575
+ onRoomParticipantJoined,
28576
+ onRoomParticipantLeft,
28577
+ onRoomParticipantRemoved,
28578
+ onRoomParticipantRemovedLocal,
28579
+ convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
28542
28580
  ], {
28543
28581
  callbackDataSelector: (data) => {
28544
28582
  if (!data)
@@ -28758,7 +28796,7 @@ const getRooms = (params, callback, config) => {
28758
28796
  };
28759
28797
  /* end_public_function */
28760
28798
 
28761
- var index$8 = /*#__PURE__*/Object.freeze({
28799
+ var index$9 = /*#__PURE__*/Object.freeze({
28762
28800
  __proto__: null,
28763
28801
  createRoom: createRoom,
28764
28802
  updateRoom: updateRoom,
@@ -28788,6 +28826,300 @@ var index$8 = /*#__PURE__*/Object.freeze({
28788
28826
  getRooms: getRooms
28789
28827
  });
28790
28828
 
28829
+ /* begin_public_function
28830
+ id: roomPresence.getRoomOnlineUsers
28831
+ */
28832
+ /**
28833
+ * ```js
28834
+ * import { getRoomOnlineUsers } from '@amityco/ts-sdk'
28835
+ * const result = await getRoomOnlineUsers('roomId')
28836
+ * ```
28837
+ *
28838
+ * Retrieves the list of users currently online in a specific room.
28839
+ * This function fetches all users who are actively watching or present in the room,
28840
+ * handling pagination automatically for large numbers of users.
28841
+ *
28842
+ * @param roomId The ID of the room to get online users for
28843
+ * @returns Promise that resolves with a cached list of online users
28844
+ *
28845
+ * @category Room Presence API
28846
+ * @async
28847
+ */
28848
+ const getRoomOnlineUsers = async (roomId) => {
28849
+ var _a, _b, _c;
28850
+ const client = getActiveClient();
28851
+ client.log('room/getWatchingUsers', { roomId });
28852
+ const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users`);
28853
+ const viewerIds = (_a = data === null || data === void 0 ? void 0 : data.viewers.map(viewer => viewer.userId)) !== null && _a !== void 0 ? _a : [];
28854
+ // getUserByIds has a maximum limit of 100 users per call
28855
+ // Split into chunks of 100 if we have more than 100 users
28856
+ const BATCH_SIZE = 100;
28857
+ const batches = [];
28858
+ for (let i = 0; i < viewerIds.length; i += BATCH_SIZE) {
28859
+ batches.push(viewerIds.slice(i, i + BATCH_SIZE));
28860
+ }
28861
+ // Fetch all batches in parallel
28862
+ const batchResults = await Promise.all(batches.map(batch => getUserByIds(batch)));
28863
+ // Merge all results
28864
+ const allViewers = [];
28865
+ batchResults.forEach(result => {
28866
+ if (result.data) {
28867
+ allViewers.push(...result.data);
28868
+ }
28869
+ });
28870
+ // Return in the same format as getUserByIds
28871
+ return {
28872
+ data: allViewers,
28873
+ cachedAt: (_c = (_b = batchResults[0]) === null || _b === void 0 ? void 0 : _b.cachedAt) !== null && _c !== void 0 ? _c : Date.now(),
28874
+ };
28875
+ };
28876
+ /* end_public_function */
28877
+
28878
+ /* begin_public_function
28879
+ id: roomPresence.getRoomUserCount
28880
+ */
28881
+ /**
28882
+ * ```js
28883
+ * import { getRoomUserCount } from '@amityco/ts-sdk'
28884
+ * const count = await getRoomUserCount('roomId')
28885
+ * ```
28886
+ *
28887
+ * Retrieves the count of users currently watching or present in a specific room.
28888
+ * This function returns the total number of online users without fetching their full user data.
28889
+ *
28890
+ * @param roomId The ID of the room to get the user count for
28891
+ * @returns Promise that resolves with the room watching count data
28892
+ *
28893
+ * @category Room Presence API
28894
+ * @async
28895
+ */
28896
+ const getRoomUserCount = async (roomId) => {
28897
+ const client = getActiveClient();
28898
+ client.log('roomPresence/getRoomUserCount', { roomId });
28899
+ const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users/count`);
28900
+ pushToCache(['get', 'watchingCount', roomId], data);
28901
+ fireEvent('local.room.watchingCountUpdated', data);
28902
+ return data;
28903
+ };
28904
+ /* end_public_function */
28905
+
28906
+ const getPresenceSetting = async () => {
28907
+ const client = getActiveClient();
28908
+ client.log('presence/getPresenceSetting');
28909
+ const { data } = await client.http.get('/api/v1/presence/settings');
28910
+ pushToCache(['get', 'presenceSetting'], data);
28911
+ return data;
28912
+ };
28913
+
28914
+ class RoomPresenceSyncEngine {
28915
+ constructor(roomId) {
28916
+ this.isEnabled = false;
28917
+ this.config = {
28918
+ heartbeatInterval: 30 * SECOND$1,
28919
+ };
28920
+ this.roomId = roomId;
28921
+ // Initialize config asynchronously - don't await in constructor
28922
+ this.initializeConfig().catch(error => {
28923
+ console.error('Failed to initialize RoomPresenceSyncEngine config in constructor:', error);
28924
+ });
28925
+ }
28926
+ async initializeConfig() {
28927
+ try {
28928
+ // Get presence settings from API with retry logic
28929
+ const presenceSettings = await RoomPresenceSyncEngine.getPresenceSettingWithRetry();
28930
+ if (presenceSettings) {
28931
+ // Set intervals from network settings (convert from minutes to milliseconds)
28932
+ this.config = {
28933
+ heartbeatInterval: (presenceSettings.network.heartbeatInterval || 5) * 60 * 1000,
28934
+ };
28935
+ }
28936
+ else {
28937
+ // Use default intervals if all retries failed
28938
+ this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
28939
+ }
28940
+ }
28941
+ catch (error) {
28942
+ console.error('Failed to initialize RoomPresenceSyncEngine config:', error);
28943
+ // Use default intervals if settings fetch fails
28944
+ this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
28945
+ }
28946
+ }
28947
+ static async getPresenceSettingWithRetry(maxRetries = 5) {
28948
+ for (let attempt = 0; attempt < maxRetries; attempt += 1) {
28949
+ try {
28950
+ // eslint-disable-next-line no-await-in-loop
28951
+ const presenceSettings = await getPresenceSetting();
28952
+ return presenceSettings;
28953
+ }
28954
+ catch (error) {
28955
+ if (attempt >= maxRetries - 1) {
28956
+ console.error(`Failed to get presence setting after ${maxRetries} attempts:`, error);
28957
+ return null;
28958
+ }
28959
+ // Calculate delay: 20 seconds + random jitter (0-5 seconds)
28960
+ const jitter = Math.random() * 5000; // 0-5 seconds in milliseconds
28961
+ const delay = 20000 + jitter; // 20 seconds + jitter
28962
+ console.warn(`Failed to get presence setting (attempt ${attempt + 1}/${maxRetries}), retrying in ${Math.round(delay / 1000)}s:`, error);
28963
+ // Wait before retry
28964
+ // eslint-disable-next-line no-await-in-loop
28965
+ await new Promise(resolve => {
28966
+ setTimeout(resolve, delay);
28967
+ });
28968
+ }
28969
+ }
28970
+ return null;
28971
+ }
28972
+ /**
28973
+ * Start heartbeat for the room
28974
+ */
28975
+ start() {
28976
+ if (this.isEnabled)
28977
+ return;
28978
+ this.isEnabled = true;
28979
+ // Send immediate heartbeat
28980
+ this.sendHeartbeat();
28981
+ // Start heartbeat timer
28982
+ this.heartbeatTimer = setInterval(() => {
28983
+ this.sendHeartbeat();
28984
+ }, this.config.heartbeatInterval);
28985
+ }
28986
+ /**
28987
+ * Stop heartbeat for the room
28988
+ */
28989
+ stop() {
28990
+ this.isEnabled = false;
28991
+ // Stop heartbeat timer
28992
+ if (this.heartbeatTimer) {
28993
+ clearInterval(this.heartbeatTimer);
28994
+ this.heartbeatTimer = undefined;
28995
+ }
28996
+ }
28997
+ /**
28998
+ * Send heartbeat to the room
28999
+ */
29000
+ async sendHeartbeat() {
29001
+ try {
29002
+ const client = getActiveClient();
29003
+ await client.http.post(`/api/v1/presence/rooms/${this.roomId}/heartbeat`);
29004
+ }
29005
+ catch (error) {
29006
+ console.error(`Heartbeat failed for room ${this.roomId}:`, error);
29007
+ }
29008
+ }
29009
+ /**
29010
+ * Get the room ID
29011
+ */
29012
+ getRoomId() {
29013
+ return this.roomId;
29014
+ }
29015
+ /**
29016
+ * Check if the engine is enabled
29017
+ */
29018
+ isActive() {
29019
+ return this.isEnabled;
29020
+ }
29021
+ /**
29022
+ * Cleanup method to stop all timers and release resources
29023
+ * Call this when the engine instance is no longer needed
29024
+ */
29025
+ destroy() {
29026
+ // Stop the engine
29027
+ this.stop();
29028
+ }
29029
+ // Session Management
29030
+ onSessionDestroyed() {
29031
+ // Stop all timers when session is destroyed and cleanup
29032
+ this.destroy();
29033
+ }
29034
+ onTokenExpired() {
29035
+ // Stop engine when token expires
29036
+ this.stop();
29037
+ }
29038
+ }
29039
+
29040
+ // Map to store engine instances per roomId
29041
+ const engineInstances = new Map();
29042
+ /**
29043
+ * Get or create a RoomPresenceSyncEngine instance for a specific room
29044
+ *
29045
+ * @param roomId The room ID to get/create engine for
29046
+ * @returns RoomPresenceSyncEngine instance for the room
29047
+ */
29048
+ const getRoomPresenceSyncEngine = (roomId) => {
29049
+ let engine = engineInstances.get(roomId);
29050
+ if (!engine) {
29051
+ engine = new RoomPresenceSyncEngine(roomId);
29052
+ engineInstances.set(roomId, engine);
29053
+ }
29054
+ return engine;
29055
+ };
29056
+ /**
29057
+ * Destroy the engine instance for a specific room
29058
+ *
29059
+ * @param roomId The room ID to destroy engine for
29060
+ */
29061
+ const destroyRoomPresenceSyncEngine = (roomId) => {
29062
+ const engine = engineInstances.get(roomId);
29063
+ if (engine) {
29064
+ engine.destroy();
29065
+ engineInstances.delete(roomId);
29066
+ }
29067
+ };
29068
+
29069
+ /* begin_public_function
29070
+ id: roomPresence.startHeartbeat
29071
+ */
29072
+ /**
29073
+ * ```js
29074
+ * import { startHeartbeat } from '@amityco/ts-sdk'
29075
+ * startHeartbeat('roomId')
29076
+ * ```
29077
+ *
29078
+ * Starts sending heartbeat signals for a specific room to maintain presence status.
29079
+ * This enables the room presence tracking and notifies the server that the user is actively viewing the room.
29080
+ *
29081
+ * @param roomId The ID of the room to start heartbeat for
29082
+ *
29083
+ * @category Room Presence API
29084
+ */
29085
+ const startHeartbeat = (roomId) => {
29086
+ const engine = getRoomPresenceSyncEngine(roomId);
29087
+ engine.start();
29088
+ };
29089
+ /* end_public_function */
29090
+
29091
+ /* begin_public_function
29092
+ id: roomPresence.stopHeartbeat
29093
+ */
29094
+ /**
29095
+ * ```js
29096
+ * import { stopHeartbeat } from '@amityco/ts-sdk'
29097
+ * stopHeartbeat('roomId')
29098
+ * ```
29099
+ *
29100
+ * Stops sending heartbeat signals for a specific room.
29101
+ * This disables the room presence tracking for the specified room and stops notifying the server of the user's presence.
29102
+ *
29103
+ * @param roomId The ID of the room to stop heartbeat for
29104
+ *
29105
+ * @category Room Presence API
29106
+ */
29107
+ const stopHeartbeat = (roomId) => {
29108
+ const engine = getRoomPresenceSyncEngine(roomId);
29109
+ engine.stop();
29110
+ // Clean up the engine instance
29111
+ destroyRoomPresenceSyncEngine(roomId);
29112
+ };
29113
+ /* end_public_function */
29114
+
29115
+ var index$8 = /*#__PURE__*/Object.freeze({
29116
+ __proto__: null,
29117
+ getRoomOnlineUsers: getRoomOnlineUsers,
29118
+ getRoomUserCount: getRoomUserCount,
29119
+ startHeartbeat: startHeartbeat,
29120
+ stopHeartbeat: stopHeartbeat
29121
+ });
29122
+
28791
29123
  /* begin_public_function
28792
29124
  id: poll.create
28793
29125
  */
@@ -31115,28 +31447,6 @@ const cancelInvitation = async (invitationId) => {
31115
31447
  };
31116
31448
  /* end_public_function */
31117
31449
 
31118
- /* begin_public_function
31119
- id: invitation.accept
31120
- */
31121
- /**
31122
- * ```js
31123
- * import { acceptInvitation } from '@amityco/ts-sdk'
31124
- * const isAccepted = await acceptInvitation(invitationId)
31125
- * ```
31126
- *
31127
- * Accepts a {@link Amity.Invitation} object
31128
- *
31129
- * @param invitationId the {@link Amity.Invitation} to accept
31130
- * @returns A success boolean if the {@link Amity.Invitation} was accepted
31131
- *
31132
- * @category Invitation API
31133
- * @async
31134
- */
31135
- const acceptInvitation = async (invitationId) => {
31136
- return acceptInvitation$1(invitationId);
31137
- };
31138
- /* end_public_function */
31139
-
31140
31450
  class MyInvitationsPaginationController extends PaginationController {
31141
31451
  async getRequest(queryParams, token) {
31142
31452
  const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
@@ -31197,7 +31507,7 @@ class MyInvitationsQueryStreamController extends QueryStreamController {
31197
31507
  ]),
31198
31508
  ];
31199
31509
  }
31200
- if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
31510
+ if (action === InvitationActionsEnum.OnLocalInvitationCanceled) {
31201
31511
  collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
31202
31512
  }
31203
31513
  pushToCache(this.cacheKey, collection);
@@ -31329,13 +31639,16 @@ const getMyCommunityInvitations = (params, callback, config) => {
31329
31639
  };
31330
31640
  };
31331
31641
 
31642
+ /* begin_public_function
31643
+ id: invitation.get_invitations
31644
+ */
31332
31645
  /**
31333
31646
  *
31334
31647
  * ```js
31335
- * import { observeInvitations } from '@amityco/ts-sdk';
31648
+ * import { InvitationRepository } from '@amityco/ts-sdk';
31336
31649
  *
31337
31650
  * // For room invitations
31338
- * const unsubscribe = observeInvitations(
31651
+ * const unsubscribe = InvitationRepository.getInvitations(
31339
31652
  * { targetId: 'room123', targetType: 'room' },
31340
31653
  * response => {
31341
31654
  * console.log('Room invitation event:', response.room, response.users, response.eventType)
@@ -31359,7 +31672,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
31359
31672
  *
31360
31673
  * @category Invitation Observable
31361
31674
  */
31362
- const observeInvitations = (params, callback) => {
31675
+ const getInvitations = (params, callback) => {
31363
31676
  const { _id: userId } = getCurrentUser();
31364
31677
  if (!userId)
31365
31678
  throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
@@ -31372,7 +31685,7 @@ const observeInvitations = (params, callback) => {
31372
31685
  callback(data.map(LinkedObject.invitation));
31373
31686
  };
31374
31687
  const realtimeRouter = (data) => {
31375
- const invitations = data.filter(({ targetId, targetType }) => targetId === params.targetId && targetType === params.targetType);
31688
+ const invitations = (Array.isArray(data) ? data : [data]).filter(({ targetId, targetType }) => targetId === params.targetId && targetType === params.targetType);
31376
31689
  dispatcher(invitations);
31377
31690
  };
31378
31691
  // Only subscribe to room co-host events for now (since that's what we have implemented)
@@ -31384,7 +31697,7 @@ const observeInvitations = (params, callback) => {
31384
31697
  disposers.push(onRoomCoHostInviteCanceled(realtimeRouter));
31385
31698
  }
31386
31699
  return () => {
31387
- log(`observeInvitations(tmpid: ${timestamp}) > dispose for ${targetType}: ${targetId}`);
31700
+ log(`getInvitations(tmpid: ${timestamp}) > dispose for ${targetType}: ${targetId}`);
31388
31701
  disposers.forEach(fn => fn());
31389
31702
  };
31390
31703
  };
@@ -31392,12 +31705,11 @@ const observeInvitations = (params, callback) => {
31392
31705
  var index$2 = /*#__PURE__*/Object.freeze({
31393
31706
  __proto__: null,
31394
31707
  cancelInvitation: cancelInvitation,
31395
- acceptInvitation: acceptInvitation,
31396
31708
  onLocalInvitationCreated: onLocalInvitationCreated,
31397
31709
  onLocalInvitationUpdated: onLocalInvitationUpdated,
31398
31710
  onLocalInvitationCanceled: onLocalInvitationCanceled,
31399
31711
  getMyCommunityInvitations: getMyCommunityInvitations,
31400
- observeInvitations: observeInvitations
31712
+ getInvitations: getInvitations
31401
31713
  });
31402
31714
 
31403
31715
  // TODO: confirm id
@@ -31716,9 +32028,9 @@ const deleteEvent = async (eventId) => {
31716
32028
  users: [],
31717
32029
  files: [],
31718
32030
  communities: [],
31719
- videoStreamings: [],
32031
+ posts: [],
32032
+ rooms: [],
31720
32033
  events: [deletedEvent],
31721
- discussionCommunities: [],
31722
32034
  });
31723
32035
  };
31724
32036
  /* end_public_function */
@@ -31995,143 +32307,6 @@ const getEvents = (params, callback, config) => {
31995
32307
  };
31996
32308
  };
31997
32309
 
31998
- class MyEventPaginationController extends PaginationController {
31999
- async getRequest(queryParams, token) {
32000
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
32001
- const options = token ? { token } : { limit };
32002
- const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
32003
- return response;
32004
- }
32005
- }
32006
-
32007
- class MyEventQueryStreamController extends QueryStreamController {
32008
- constructor(query, cacheKey, notifyChange, preparePayload) {
32009
- super(query, cacheKey);
32010
- this.notifyChange = notifyChange;
32011
- this.preparePayload = preparePayload;
32012
- }
32013
- async saveToMainDB(response) {
32014
- const processedPayload = this.preparePayload(response);
32015
- const client = getActiveClient();
32016
- const cachedAt = client.cache && Date.now();
32017
- if (client.cache)
32018
- ingestInCache(processedPayload, { cachedAt });
32019
- }
32020
- appendToQueryStream(response, direction, refresh = false) {
32021
- var _a, _b;
32022
- if (refresh) {
32023
- pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
32024
- }
32025
- else {
32026
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32027
- const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
32028
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
32029
- }
32030
- }
32031
- reactor(action) {
32032
- return (event) => {
32033
- var _a;
32034
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32035
- if (!collection)
32036
- return;
32037
- if (action === EventActionsEnum.OnEventCreated) {
32038
- const client = getActiveClient();
32039
- if (client.userId !== event.userId)
32040
- return;
32041
- collection.data = [...new Set([event.eventId, ...collection.data])];
32042
- }
32043
- if (action === EventActionsEnum.OnEventDeleted) {
32044
- collection.data = collection.data.filter(eventId => eventId !== event.eventId);
32045
- }
32046
- pushToCache(this.cacheKey, collection);
32047
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
32048
- };
32049
- }
32050
- subscribeRTE(createSubscriber) {
32051
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
32052
- }
32053
- }
32054
-
32055
- class MyEventLiveCollectionController extends LiveCollectionController {
32056
- constructor(query, callback) {
32057
- const queryStreamId = hash__default["default"](query);
32058
- const cacheKey = ['event', 'collection', queryStreamId];
32059
- const paginationController = new MyEventPaginationController(query);
32060
- super(paginationController, queryStreamId, cacheKey, callback);
32061
- this.query = query;
32062
- this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
32063
- this.callback = callback.bind(this);
32064
- this.loadPage({ initial: true });
32065
- }
32066
- setup() {
32067
- var _a;
32068
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32069
- if (!collection)
32070
- pushToCache(this.cacheKey, { data: [], params: {} });
32071
- }
32072
- async persistModel(queryPayload) {
32073
- await this.queryStreamController.saveToMainDB(queryPayload);
32074
- }
32075
- persistQueryStream({ response, direction, refresh, }) {
32076
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
32077
- }
32078
- startSubscription() {
32079
- return this.queryStreamController.subscribeRTE([
32080
- { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
32081
- { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
32082
- { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
32083
- { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
32084
- { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
32085
- { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
32086
- ]);
32087
- }
32088
- notifyChange({ origin, loading, error }) {
32089
- var _a, _b;
32090
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32091
- if (!collection)
32092
- return;
32093
- const data = ((_b = collection.data
32094
- .map(eventId => pullFromCache(['event', 'get', eventId]))
32095
- .filter(isNonNullable)
32096
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
32097
- if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
32098
- return;
32099
- this.callback({
32100
- data,
32101
- error,
32102
- loading,
32103
- hasNextPage: !!this.paginationController.getNextToken(),
32104
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
32105
- });
32106
- }
32107
- }
32108
-
32109
- /**
32110
- * Get my events
32111
- *
32112
- * @param params the query parameters
32113
- * @param callback the callback to be called when the events are updated
32114
- * @returns events
32115
- *
32116
- * @category Event Live Collection
32117
- *
32118
- */
32119
- const getMyEvents = (params, callback, config) => {
32120
- const { log, cache } = getActiveClient();
32121
- if (!cache)
32122
- console.log(ENABLE_CACHE_MESSAGE);
32123
- const timestamp = Date.now();
32124
- log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
32125
- const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
32126
- const disposers = myEventLiveCollection.startSubscription();
32127
- const cacheKey = myEventLiveCollection.getCacheKey();
32128
- disposers.push(() => dropFromCache(cacheKey));
32129
- return () => {
32130
- log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
32131
- disposers.forEach(fn => fn());
32132
- };
32133
- };
32134
-
32135
32310
  var index = /*#__PURE__*/Object.freeze({
32136
32311
  __proto__: null,
32137
32312
  createEvent: createEvent,
@@ -32144,41 +32319,41 @@ var index = /*#__PURE__*/Object.freeze({
32144
32319
  onLocalEventUpdated: onLocalEventUpdated,
32145
32320
  onLocalEventDeleted: onLocalEventDeleted,
32146
32321
  getEvent: getEvent,
32147
- getEvents: getEvents,
32148
- getMyEvents: getMyEvents
32322
+ getEvents: getEvents
32149
32323
  });
32150
32324
 
32151
32325
  exports.API_REGIONS = API_REGIONS;
32152
32326
  exports.AdRepository = index$4;
32153
- exports.CategoryRepository = index$d;
32154
- exports.ChannelRepository = index$h;
32155
- exports.Client = index$q;
32156
- exports.CommentRepository = index$c;
32327
+ exports.CategoryRepository = index$e;
32328
+ exports.ChannelRepository = index$i;
32329
+ exports.Client = index$r;
32330
+ exports.CommentRepository = index$d;
32157
32331
  exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
32158
32332
  exports.CommunityPostSettings = CommunityPostSettings;
32159
- exports.CommunityRepository = index$e;
32333
+ exports.CommunityRepository = index$f;
32160
32334
  exports.ContentFeedType = ContentFeedType;
32161
32335
  exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
32162
32336
  exports.EventRepository = index;
32163
- exports.FeedRepository = index$b;
32164
- exports.FileRepository = index$n;
32337
+ exports.FeedRepository = index$c;
32338
+ exports.FileRepository = index$o;
32165
32339
  exports.FileType = FileType;
32166
32340
  exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
32167
32341
  exports.InvitationRepository = index$2;
32168
32342
  exports.LiveReactionRepository = index$1;
32169
32343
  exports.LiveStreamPlayer = index$6;
32170
32344
  exports.MessageContentType = MessageContentType;
32171
- exports.MessageRepository = index$l;
32345
+ exports.MessageRepository = index$m;
32172
32346
  exports.PollRepository = index$7;
32173
32347
  exports.PostContentType = PostContentType;
32174
- exports.PostRepository = index$a;
32348
+ exports.PostRepository = index$b;
32175
32349
  exports.PostStructureType = PostStructureType;
32176
- exports.ReactionRepository = index$m;
32177
- exports.RoomRepository = index$8;
32350
+ exports.ReactionRepository = index$n;
32351
+ exports.RoomPresenceRepository = index$8;
32352
+ exports.RoomRepository = index$9;
32178
32353
  exports.StoryRepository = index$5;
32179
- exports.StreamRepository = index$9;
32180
- exports.SubChannelRepository = index$k;
32181
- exports.UserRepository = index$o;
32354
+ exports.StreamRepository = index$a;
32355
+ exports.SubChannelRepository = index$l;
32356
+ exports.UserRepository = index$p;
32182
32357
  exports.VERSION = VERSION;
32183
32358
  exports.VideoResolution = VideoResolution;
32184
32359
  exports.VideoSize = VideoSize;