@amityco/ts-sdk 7.11.1-ec3d3468.0 → 7.11.1-f05493be.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 (126) 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 +18 -3
  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 +464 -285
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.esm.js +450 -272
  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/dist/utils/linkedObject/roomLinkedObject.d.ts.map +1 -1
  92. package/package.json +1 -1
  93. package/dist/client/utils/ObjectResolver/objectResolverEngine.d.ts.map +0 -1
  94. package/dist/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +0 -1
  95. package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +0 -1
  96. package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
  97. package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +0 -1
  98. package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
  99. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts +0 -13
  100. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +0 -1
  101. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +0 -5
  102. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +0 -1
  103. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +0 -15
  104. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +0 -1
  105. package/dist/eventRepository/observers/getMyEvents.d.ts +0 -12
  106. package/dist/eventRepository/observers/getMyEvents.d.ts.map +0 -1
  107. package/dist/invitationRepository/api/acceptInvitation.d.ts +0 -16
  108. package/dist/invitationRepository/api/acceptInvitation.d.ts.map +0 -1
  109. package/dist/invitationRepository/api/getMyInvitation.d.ts +0 -16
  110. package/dist/invitationRepository/api/getMyInvitation.d.ts.map +0 -1
  111. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +0 -1
  112. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +0 -1
  113. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +0 -1
  114. package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +0 -1
  115. package/dist/invitationRepository/observers/observeInvitations.d.ts +0 -34
  116. package/dist/invitationRepository/observers/observeInvitations.d.ts.map +0 -1
  117. /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngine.d.ts +0 -0
  118. /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts +0 -0
  119. /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts +0 -0
  120. /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts +0 -0
  121. /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngine.d.ts +0 -0
  122. /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts +0 -0
  123. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsLiveCollectionController.d.ts +0 -0
  124. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsPaginationController.d.ts +0 -0
  125. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsQueryStreamController.d.ts +0 -0
  126. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/enums.d.ts +0 -0
package/dist/index.esm.js CHANGED
@@ -73,6 +73,11 @@ const CommunityPostSettingMaps = Object.freeze({
73
73
  },
74
74
  });
75
75
  const DefaultCommunityPostSetting = 'ONLY_ADMIN_CAN_POST';
76
+ var AmityCommunityType;
77
+ (function (AmityCommunityType) {
78
+ AmityCommunityType["Default"] = "default";
79
+ AmityCommunityType["Event"] = "event";
80
+ })(AmityCommunityType || (AmityCommunityType = {}));
76
81
 
77
82
  const ContentFeedType = Object.freeze({
78
83
  STORY: 'story',
@@ -207,6 +212,16 @@ var AmityEventResponseStatus;
207
212
  AmityEventResponseStatus["Interested"] = "interested";
208
213
  AmityEventResponseStatus["NotGoing"] = "not_going";
209
214
  })(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
215
+ var AmityEventSortOption;
216
+ (function (AmityEventSortOption) {
217
+ AmityEventSortOption["StartTime"] = "startTime";
218
+ AmityEventSortOption["CreatedAt"] = "createdAt";
219
+ })(AmityEventSortOption || (AmityEventSortOption = {}));
220
+ var AmityEventOrderOption;
221
+ (function (AmityEventOrderOption) {
222
+ AmityEventOrderOption["Ascending"] = "asc";
223
+ AmityEventOrderOption["Descending"] = "desc";
224
+ })(AmityEventOrderOption || (AmityEventOrderOption = {}));
210
225
 
211
226
  function getVersion() {
212
227
  try {
@@ -658,7 +673,6 @@ const idResolvers = {
658
673
  joinRequest: ({ joinRequestId }) => joinRequestId,
659
674
  room: ({ roomId }) => roomId,
660
675
  event: ({ eventId }) => eventId,
661
- discussionCommunity: ({ communityId }) => communityId,
662
676
  };
663
677
  /**
664
678
  * Retrieve the id resolver matching a domain name
@@ -716,7 +730,7 @@ const PAYLOAD2MODEL = {
716
730
  joinRequests: 'joinRequest',
717
731
  rooms: 'room',
718
732
  events: 'event',
719
- discussionCommunities: 'discussionCommunity',
733
+ viewers: 'viewer',
720
734
  };
721
735
  /** hidden */
722
736
  const isOutdated = (prevData, nextData) => {
@@ -1447,14 +1461,12 @@ const createEventEmitter = () => {
1447
1461
  const proxyMqttEvents = (mqttClient, emitter) => {
1448
1462
  MQTT_EVENTS.forEach(event => {
1449
1463
  mqttClient === null || mqttClient === void 0 ? void 0 : mqttClient.on(event, (...params) => {
1450
- console.log('global event received => ', event);
1451
1464
  emitter.emit(event, params.length === 1 ? params[0] : params);
1452
1465
  });
1453
1466
  });
1454
1467
  // @ts-ignore
1455
1468
  mqttClient.on('message', (topic, payload) => {
1456
1469
  const message = JSON.parse(payload.toString());
1457
- console.log('message event received => ', message.eventType, message.data);
1458
1470
  emitter.emit(message.eventType, message.data);
1459
1471
  });
1460
1472
  };
@@ -24603,11 +24615,11 @@ var objectResolverEngineOnLoginHandler = () => {
24603
24615
  * @category Live Reaction API
24604
24616
  * @async
24605
24617
  */
24606
- const createLiveReaction = async ({ reactions, roomId, }) => {
24618
+ const createLiveReaction = async ({ reactions, liveStreamId, }) => {
24607
24619
  const client = getActiveClient();
24608
24620
  client.log('live_reaction/addReaction', reactions);
24609
24621
  const { data } = await client.http.post(`/api/v1/reactions/live`, {
24610
- roomId,
24622
+ liveStreamId,
24611
24623
  reactions,
24612
24624
  });
24613
24625
  return data;
@@ -24677,7 +24689,7 @@ class LiveReactionSyncEngine {
24677
24689
  // Call server api `POST /api/v1/reactions/live` to sync live reactions
24678
24690
  Object.entries(payloads).forEach(([roomId, reactions]) => {
24679
24691
  createLiveReaction({
24680
- roomId,
24692
+ liveStreamId: roomId,
24681
24693
  reactions,
24682
24694
  });
24683
24695
  });
@@ -26599,7 +26611,7 @@ const getUserUnread = (callback) => {
26599
26611
  };
26600
26612
  };
26601
26613
 
26602
- var index$q = /*#__PURE__*/Object.freeze({
26614
+ var index$r = /*#__PURE__*/Object.freeze({
26603
26615
  __proto__: null,
26604
26616
  getActiveClient: getActiveClient,
26605
26617
  getActiveUser: getActiveUser,
@@ -27818,7 +27830,7 @@ const getMyFollowInfo = (callback) => {
27818
27830
  };
27819
27831
  /* end_public_function */
27820
27832
 
27821
- var index$p = /*#__PURE__*/Object.freeze({
27833
+ var index$q = /*#__PURE__*/Object.freeze({
27822
27834
  __proto__: null,
27823
27835
  blockUser: blockUser,
27824
27836
  unBlockUser: unBlockUser,
@@ -28463,7 +28475,7 @@ const createInvitations = async (bundle) => {
28463
28475
  * @category Invitation API
28464
28476
  * @async
28465
28477
  */
28466
- const acceptInvitation$1 = async (invitationId) => {
28478
+ const acceptInvitation = async (invitationId) => {
28467
28479
  var _a;
28468
28480
  const client = getActiveClient();
28469
28481
  client.log('invitation/acceptInvitation', invitationId);
@@ -28549,7 +28561,7 @@ const invitationLinkedObject = (invitation) => {
28549
28561
  }
28550
28562
  return undefined;
28551
28563
  }, accept: async () => {
28552
- await acceptInvitation$1(invitation._id);
28564
+ await acceptInvitation(invitation._id);
28553
28565
  }, reject: async () => {
28554
28566
  await rejectInvitation(invitation._id);
28555
28567
  } });
@@ -28800,7 +28812,7 @@ class InvitationsLiveCollectionController extends LiveCollectionController {
28800
28812
  * @category Invitation Live Collection
28801
28813
  *
28802
28814
  */
28803
- const getInvitations = (params, callback, config) => {
28815
+ const getInvitations$1 = (params, callback, config) => {
28804
28816
  const { log, cache } = getActiveClient();
28805
28817
  if (!cache) {
28806
28818
  console.log(ENABLE_CACHE_MESSAGE);
@@ -28875,7 +28887,8 @@ const roomLinkedObject = (room) => {
28875
28887
  },
28876
28888
  get user() {
28877
28889
  var _a;
28878
- return (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
28890
+ const user = (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
28891
+ return user ? userLinkedObject(user) : user;
28879
28892
  },
28880
28893
  get childRooms() {
28881
28894
  if (!room.childRoomIds || room.childRoomIds.length === 0)
@@ -28889,12 +28902,16 @@ const roomLinkedObject = (room) => {
28889
28902
  return roomLinkedObject(roomCache);
28890
28903
  })
28891
28904
  .filter(isNonNullable);
28892
- }, getLiveChat: () => getLiveChat(room), createInvitation: (userId) => createInvitations({
28905
+ }, participants: room.participants.map(participant => (Object.assign(Object.assign({}, participant), { get user() {
28906
+ var _a;
28907
+ const user = (_a = pullFromCache(['user', 'get', participant.userId])) === null || _a === void 0 ? void 0 : _a.data;
28908
+ return user ? userLinkedObject(user) : user;
28909
+ } }))), getLiveChat: () => getLiveChat(room), createInvitation: (userId) => createInvitations({
28893
28910
  type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */,
28894
28911
  targetType: 'room',
28895
28912
  targetId: room.roomId,
28896
28913
  userIds: [userId],
28897
- }), getInvitations: (params, callback) => getInvitations(Object.assign(Object.assign({}, params), { targetId: room.roomId, targetType: 'room', type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */ }), callback), getMyInvitation: async () => {
28914
+ }), getInvitations: (params, callback) => getInvitations$1(Object.assign(Object.assign({}, params), { targetId: room.roomId, targetType: 'room', type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */ }), callback), getMyInvitation: async () => {
28898
28915
  const { data } = await getInvitation({
28899
28916
  targetId: room.roomId,
28900
28917
  targetType: 'room',
@@ -29893,7 +29910,7 @@ const communityLinkedObject = (community) => {
29893
29910
  userIds,
29894
29911
  });
29895
29912
  }, getMemberInvitations: (params, callback) => {
29896
- return getInvitations(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
29913
+ return getInvitations$1(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
29897
29914
  }, getInvitation: async () => {
29898
29915
  const { data } = await getInvitation({
29899
29916
  targetType: 'community',
@@ -29915,18 +29932,6 @@ const eventLinkedObject = (event) => {
29915
29932
  return;
29916
29933
  return userLinkedObject(cacheData.data);
29917
29934
  },
29918
- get discussionCommunity() {
29919
- if (!event.discussionCommunityId)
29920
- return;
29921
- const cacheData = pullFromCache([
29922
- 'discussionCommunity',
29923
- 'get',
29924
- event.discussionCommunityId,
29925
- ]);
29926
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29927
- return;
29928
- return communityLinkedObject(cacheData.data);
29929
- },
29930
29935
  get targetCommunity() {
29931
29936
  if (!event.originId)
29932
29937
  return;
@@ -29943,13 +29948,22 @@ const eventLinkedObject = (event) => {
29943
29948
  return;
29944
29949
  return cacheData.data;
29945
29950
  },
29946
- get liveStream() {
29947
- if (!event.livestreamId)
29951
+ get post() {
29952
+ if (!event.postId)
29948
29953
  return;
29949
- const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
29954
+ const cacheData = pullFromCache(['post', 'get', event.postId]);
29950
29955
  if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29951
29956
  return;
29952
- return cacheData.data;
29957
+ return postLinkedObject(cacheData.data);
29958
+ },
29959
+ get room() {
29960
+ var _a;
29961
+ if (!event.postId)
29962
+ return;
29963
+ const cacheData = (_a = queryCache(['room', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(room => room.data.referenceId === event.postId);
29964
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.length) || !cacheData[0].data)
29965
+ return;
29966
+ return roomLinkedObject(cacheData[0].data);
29953
29967
  } });
29954
29968
  };
29955
29969
 
@@ -30963,9 +30977,9 @@ var AmityUserSearchMatchType;
30963
30977
  AmityUserSearchMatchType["PARTIAL"] = "partial";
30964
30978
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
30965
30979
 
30966
- var index$o = /*#__PURE__*/Object.freeze({
30980
+ var index$p = /*#__PURE__*/Object.freeze({
30967
30981
  __proto__: null,
30968
- Relationship: index$p,
30982
+ Relationship: index$q,
30969
30983
  getUserByIds: getUserByIds,
30970
30984
  updateUser: updateUser,
30971
30985
  flagUser: flagUser,
@@ -31368,7 +31382,7 @@ const uploadAudio = async (formData, onProgress) => {
31368
31382
  };
31369
31383
  /* end_public_function */
31370
31384
 
31371
- var index$n = /*#__PURE__*/Object.freeze({
31385
+ var index$o = /*#__PURE__*/Object.freeze({
31372
31386
  __proto__: null,
31373
31387
  getFile: getFile,
31374
31388
  uploadFile: uploadFile,
@@ -33180,7 +33194,7 @@ const getReactions$1 = (params, callback, config) => {
33180
33194
  };
33181
33195
  /* end_public_function */
33182
33196
 
33183
- var index$m = /*#__PURE__*/Object.freeze({
33197
+ var index$n = /*#__PURE__*/Object.freeze({
33184
33198
  __proto__: null,
33185
33199
  addReaction: addReaction,
33186
33200
  removeReaction: removeReaction,
@@ -34952,7 +34966,7 @@ const getMessages = (params, callback, config) => {
34952
34966
  };
34953
34967
  /* end_public_function */
34954
34968
 
34955
- var index$l = /*#__PURE__*/Object.freeze({
34969
+ var index$m = /*#__PURE__*/Object.freeze({
34956
34970
  __proto__: null,
34957
34971
  createMessage: createMessage,
34958
34972
  updateMessage: updateMessage,
@@ -35478,7 +35492,7 @@ const stopMessageReceiptSync = (subChannelId) => {
35478
35492
  };
35479
35493
  /* end_public_function */
35480
35494
 
35481
- var index$k = /*#__PURE__*/Object.freeze({
35495
+ var index$l = /*#__PURE__*/Object.freeze({
35482
35496
  __proto__: null,
35483
35497
  getSubChannelByIds: getSubChannels$1,
35484
35498
  createSubChannel: createSubChannel,
@@ -36805,7 +36819,7 @@ const searchMembers$1 = (params, callback, config) => {
36805
36819
  };
36806
36820
  /* end_public_function */
36807
36821
 
36808
- var index$j = /*#__PURE__*/Object.freeze({
36822
+ var index$k = /*#__PURE__*/Object.freeze({
36809
36823
  __proto__: null,
36810
36824
  addMembers: addMembers$1,
36811
36825
  removeMembers: removeMembers$1,
@@ -37008,7 +37022,7 @@ const unmuteMembers = async (channelId, userIds) => {
37008
37022
  };
37009
37023
  /* end_public_function */
37010
37024
 
37011
- var index$i = /*#__PURE__*/Object.freeze({
37025
+ var index$j = /*#__PURE__*/Object.freeze({
37012
37026
  __proto__: null,
37013
37027
  addRole: addRole,
37014
37028
  removeRole: removeRole,
@@ -37018,10 +37032,10 @@ var index$i = /*#__PURE__*/Object.freeze({
37018
37032
  unmuteMembers: unmuteMembers
37019
37033
  });
37020
37034
 
37021
- var index$h = /*#__PURE__*/Object.freeze({
37035
+ var index$i = /*#__PURE__*/Object.freeze({
37022
37036
  __proto__: null,
37023
- Membership: index$j,
37024
- Moderation: index$i,
37037
+ Membership: index$k,
37038
+ Moderation: index$j,
37025
37039
  getChannelByIds: getChannelByIds$1,
37026
37040
  createChannel: createChannel,
37027
37041
  updateChannel: updateChannel,
@@ -38424,7 +38438,7 @@ const searchMembers = (params, callback, config) => {
38424
38438
  };
38425
38439
  /* end_public_function */
38426
38440
 
38427
- var index$g = /*#__PURE__*/Object.freeze({
38441
+ var index$h = /*#__PURE__*/Object.freeze({
38428
38442
  __proto__: null,
38429
38443
  addMembers: addMembers,
38430
38444
  removeMembers: removeMembers,
@@ -39675,7 +39689,7 @@ const unbanMembers = async (communityId, userIds) => {
39675
39689
  };
39676
39690
  /* end_public_function */
39677
39691
 
39678
- var index$f = /*#__PURE__*/Object.freeze({
39692
+ var index$g = /*#__PURE__*/Object.freeze({
39679
39693
  __proto__: null,
39680
39694
  addRoles: addRoles,
39681
39695
  removeRoles: removeRoles,
@@ -39683,10 +39697,10 @@ var index$f = /*#__PURE__*/Object.freeze({
39683
39697
  unbanMembers: unbanMembers
39684
39698
  });
39685
39699
 
39686
- var index$e = /*#__PURE__*/Object.freeze({
39700
+ var index$f = /*#__PURE__*/Object.freeze({
39687
39701
  __proto__: null,
39688
- Moderation: index$f,
39689
- Membership: index$g,
39702
+ Moderation: index$g,
39703
+ Membership: index$h,
39690
39704
  getCommunityByIds: getCommunities$1,
39691
39705
  createCommunity: createCommunity,
39692
39706
  updateCommunity: updateCommunity,
@@ -39920,7 +39934,7 @@ const getCategories = (params, callback, config) => {
39920
39934
  };
39921
39935
  /* end_public_function */
39922
39936
 
39923
- var index$d = /*#__PURE__*/Object.freeze({
39937
+ var index$e = /*#__PURE__*/Object.freeze({
39924
39938
  __proto__: null,
39925
39939
  getCategory: getCategory,
39926
39940
  getCategories: getCategories
@@ -40979,7 +40993,7 @@ const getComments = (params, callback, config) => {
40979
40993
  };
40980
40994
  /* end_public_function */
40981
40995
 
40982
- var index$c = /*#__PURE__*/Object.freeze({
40996
+ var index$d = /*#__PURE__*/Object.freeze({
40983
40997
  __proto__: null,
40984
40998
  getCommentByIds: getCommentByIds,
40985
40999
  createComment: createComment,
@@ -41650,7 +41664,7 @@ const getUserFeed = (params, callback, config) => {
41650
41664
  };
41651
41665
  /* end_public_function */
41652
41666
 
41653
- var index$b = /*#__PURE__*/Object.freeze({
41667
+ var index$c = /*#__PURE__*/Object.freeze({
41654
41668
  __proto__: null,
41655
41669
  queryGlobalFeed: queryGlobalFeed,
41656
41670
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -43331,7 +43345,7 @@ const searchPostsByHashtag = (params, callback, config) => {
43331
43345
  };
43332
43346
  /* end_public_function */
43333
43347
 
43334
- var index$a = /*#__PURE__*/Object.freeze({
43348
+ var index$b = /*#__PURE__*/Object.freeze({
43335
43349
  __proto__: null,
43336
43350
  getPostByIds: getPostByIds,
43337
43351
  createPost: createPost,
@@ -43939,7 +43953,7 @@ const getStreams = (params, callback, config) => {
43939
43953
  };
43940
43954
  };
43941
43955
 
43942
- var index$9 = /*#__PURE__*/Object.freeze({
43956
+ var index$a = /*#__PURE__*/Object.freeze({
43943
43957
  __proto__: null,
43944
43958
  createStream: createStream,
43945
43959
  updateStream: updateStream,
@@ -44154,9 +44168,7 @@ const getRecordedUrl = async (roomId) => {
44154
44168
  const removeParticipant = async (roomId, participantUserId) => {
44155
44169
  const client = getActiveClient();
44156
44170
  client.log('room/removeParticipant', { roomId, participantUserId });
44157
- await client.http.delete(`/api/v1/rooms/${roomId}/participants`, {
44158
- data: { participantUserId },
44159
- });
44171
+ await client.http.delete(`/api/v1/rooms/${roomId}/participants/${participantUserId}`);
44160
44172
  fireEvent('local.room.participantRemoved', {
44161
44173
  rooms: [{ _id: roomId }],
44162
44174
  users: [{ _id: participantUserId }],
@@ -44312,6 +44324,46 @@ const onRoomCoHostInvited = (callback) => {
44312
44324
  return createEventSubscriber(client, 'room/onRoomCoHostInvited', 'room.didCohostInvite', filter);
44313
44325
  };
44314
44326
 
44327
+ const getRoomById = async (roomId) => {
44328
+ const client = getActiveClient();
44329
+ client.log('room/getRoomById', roomId);
44330
+ // Check if room is in tombstone
44331
+ isInTombstone('room', roomId);
44332
+ let data;
44333
+ try {
44334
+ const response = await client.http.get(`/api/v1/rooms/${roomId}`);
44335
+ data = response.data;
44336
+ }
44337
+ catch (error) {
44338
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
44339
+ pushToTombstone('room', roomId);
44340
+ }
44341
+ throw error;
44342
+ }
44343
+ const cachedAt = client.cache && Date.now();
44344
+ if (client.cache) {
44345
+ ingestInCache(data, { cachedAt });
44346
+ }
44347
+ return {
44348
+ data: data.rooms[0],
44349
+ cachedAt,
44350
+ };
44351
+ };
44352
+ getRoomById.locally = (roomId) => {
44353
+ const client = getActiveClient();
44354
+ client.log('room/getRoomById.locally', roomId);
44355
+ // Check if room is in tombstone
44356
+ isInTombstone('room', roomId);
44357
+ const cachedAt = client.cache && Date.now();
44358
+ const roomCache = pullFromCache(['room', 'get', roomId]);
44359
+ if (!roomCache)
44360
+ return;
44361
+ return {
44362
+ data: roomCache.data,
44363
+ cachedAt,
44364
+ };
44365
+ };
44366
+
44315
44367
  /**
44316
44368
  * ```js
44317
44369
  * import { onRoomCoHostInviteAccepted } from '@amityco/ts-sdk'
@@ -44329,12 +44381,14 @@ const onRoomCoHostInvited = (callback) => {
44329
44381
  */
44330
44382
  const onRoomCoHostInviteAccepted = (callback) => {
44331
44383
  const client = getActiveClient();
44332
- const filter = (payload) => {
44384
+ const filter = async (payload) => {
44385
+ var _a;
44333
44386
  const data = prepareMyInvitationsPayload(payload);
44387
+ await getRoomById((_a = data.invitations) === null || _a === void 0 ? void 0 : _a[0].targetId);
44334
44388
  ingestInCache(data);
44335
- callback(data.invitations);
44389
+ callback(data.invitations[0]);
44336
44390
  };
44337
- return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCoHostInviteAccept', filter);
44391
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCohostInviteAccept', filter);
44338
44392
  };
44339
44393
 
44340
44394
  /**
@@ -44359,7 +44413,7 @@ const onRoomCoHostInviteRejected = (callback) => {
44359
44413
  ingestInCache(data);
44360
44414
  callback(data.invitations);
44361
44415
  };
44362
- return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCoHostInviteReject', filter);
44416
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCohostInviteReject', filter);
44363
44417
  };
44364
44418
 
44365
44419
  /**
@@ -44384,7 +44438,7 @@ const onRoomCoHostInviteCanceled = (callback) => {
44384
44438
  ingestInCache(data);
44385
44439
  callback(data.invitations);
44386
44440
  };
44387
- return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCoHostInviteCancel', filter);
44441
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCohostInviteCancel', filter);
44388
44442
  };
44389
44443
 
44390
44444
  /**
@@ -44552,7 +44606,7 @@ const onRoomParticipantRemoved = (callback) => {
44552
44606
  ingestInCache(payload);
44553
44607
  callback(payload.rooms[0]);
44554
44608
  };
44555
- return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
44609
+ return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'room.participantRemoved', filter);
44556
44610
  };
44557
44611
 
44558
44612
  /**
@@ -44579,44 +44633,28 @@ const onRoomLeft = (callback) => {
44579
44633
  return createEventSubscriber(client, 'room/onRoomLeft', 'local.room.left', filter);
44580
44634
  };
44581
44635
 
44582
- const getRoomById = async (roomId) => {
44583
- const client = getActiveClient();
44584
- client.log('room/getRoomById', roomId);
44585
- // Check if room is in tombstone
44586
- isInTombstone('room', roomId);
44587
- let data;
44588
- try {
44589
- const response = await client.http.get(`/api/v1/rooms/${roomId}`);
44590
- data = response.data;
44591
- }
44592
- catch (error) {
44593
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
44594
- pushToTombstone('room', roomId);
44595
- }
44596
- throw error;
44597
- }
44598
- const cachedAt = client.cache && Date.now();
44599
- if (client.cache) {
44600
- ingestInCache(data, { cachedAt });
44601
- }
44602
- return {
44603
- data: data.rooms[0],
44604
- cachedAt,
44605
- };
44606
- };
44607
- getRoomById.locally = (roomId) => {
44636
+ /**
44637
+ * ```js
44638
+ * import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
44639
+ * const dispose = onRoomParticipantRemoved(room => {
44640
+ * // ...
44641
+ * })
44642
+ * ```
44643
+ *
44644
+ * Fired when a participant has been removed from a {@link Amity.Room} locally
44645
+ *
44646
+ * @param callback The function to call when the event was fired
44647
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44648
+ *
44649
+ * @category Room Events
44650
+ */
44651
+ const onRoomParticipantRemovedLocal = (callback) => {
44608
44652
  const client = getActiveClient();
44609
- client.log('room/getRoomById.locally', roomId);
44610
- // Check if room is in tombstone
44611
- isInTombstone('room', roomId);
44612
- const cachedAt = client.cache && Date.now();
44613
- const roomCache = pullFromCache(['room', 'get', roomId]);
44614
- if (!roomCache)
44615
- return;
44616
- return {
44617
- data: roomCache.data,
44618
- cachedAt,
44653
+ const filter = (payload) => {
44654
+ ingestInCache(payload);
44655
+ callback(payload.rooms[0]);
44619
44656
  };
44657
+ return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
44620
44658
  };
44621
44659
 
44622
44660
  const getRoom = (roomId, callback) => {
@@ -44626,7 +44664,11 @@ const getRoom = (roomId, callback) => {
44626
44664
  onRoomStartBroadcasting,
44627
44665
  onRoomWaitingReconnect,
44628
44666
  onRoomRecordedAvailable,
44629
- onRoomCoHostInvited,
44667
+ onRoomParticipantJoined,
44668
+ onRoomParticipantLeft,
44669
+ onRoomParticipantRemoved,
44670
+ onRoomParticipantRemovedLocal,
44671
+ convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
44630
44672
  ], {
44631
44673
  callbackDataSelector: (data) => {
44632
44674
  if (!data)
@@ -44846,7 +44888,7 @@ const getRooms = (params, callback, config) => {
44846
44888
  };
44847
44889
  /* end_public_function */
44848
44890
 
44849
- var index$8 = /*#__PURE__*/Object.freeze({
44891
+ var index$9 = /*#__PURE__*/Object.freeze({
44850
44892
  __proto__: null,
44851
44893
  createRoom: createRoom,
44852
44894
  updateRoom: updateRoom,
@@ -44876,6 +44918,300 @@ var index$8 = /*#__PURE__*/Object.freeze({
44876
44918
  getRooms: getRooms
44877
44919
  });
44878
44920
 
44921
+ /* begin_public_function
44922
+ id: roomPresence.getRoomOnlineUsers
44923
+ */
44924
+ /**
44925
+ * ```js
44926
+ * import { getRoomOnlineUsers } from '@amityco/ts-sdk'
44927
+ * const result = await getRoomOnlineUsers('roomId')
44928
+ * ```
44929
+ *
44930
+ * Retrieves the list of users currently online in a specific room.
44931
+ * This function fetches all users who are actively watching or present in the room,
44932
+ * handling pagination automatically for large numbers of users.
44933
+ *
44934
+ * @param roomId The ID of the room to get online users for
44935
+ * @returns Promise that resolves with a cached list of online users
44936
+ *
44937
+ * @category Room Presence API
44938
+ * @async
44939
+ */
44940
+ const getRoomOnlineUsers = async (roomId) => {
44941
+ var _a, _b, _c;
44942
+ const client = getActiveClient();
44943
+ client.log('room/getWatchingUsers', { roomId });
44944
+ const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users`);
44945
+ const viewerIds = (_a = data === null || data === void 0 ? void 0 : data.viewers.map(viewer => viewer.userId)) !== null && _a !== void 0 ? _a : [];
44946
+ // getUserByIds has a maximum limit of 100 users per call
44947
+ // Split into chunks of 100 if we have more than 100 users
44948
+ const BATCH_SIZE = 100;
44949
+ const batches = [];
44950
+ for (let i = 0; i < viewerIds.length; i += BATCH_SIZE) {
44951
+ batches.push(viewerIds.slice(i, i + BATCH_SIZE));
44952
+ }
44953
+ // Fetch all batches in parallel
44954
+ const batchResults = await Promise.all(batches.map(batch => getUserByIds(batch)));
44955
+ // Merge all results
44956
+ const allViewers = [];
44957
+ batchResults.forEach(result => {
44958
+ if (result.data) {
44959
+ allViewers.push(...result.data);
44960
+ }
44961
+ });
44962
+ // Return in the same format as getUserByIds
44963
+ return {
44964
+ data: allViewers,
44965
+ cachedAt: (_c = (_b = batchResults[0]) === null || _b === void 0 ? void 0 : _b.cachedAt) !== null && _c !== void 0 ? _c : Date.now(),
44966
+ };
44967
+ };
44968
+ /* end_public_function */
44969
+
44970
+ /* begin_public_function
44971
+ id: roomPresence.getRoomUserCount
44972
+ */
44973
+ /**
44974
+ * ```js
44975
+ * import { getRoomUserCount } from '@amityco/ts-sdk'
44976
+ * const count = await getRoomUserCount('roomId')
44977
+ * ```
44978
+ *
44979
+ * Retrieves the count of users currently watching or present in a specific room.
44980
+ * This function returns the total number of online users without fetching their full user data.
44981
+ *
44982
+ * @param roomId The ID of the room to get the user count for
44983
+ * @returns Promise that resolves with the room watching count data
44984
+ *
44985
+ * @category Room Presence API
44986
+ * @async
44987
+ */
44988
+ const getRoomUserCount = async (roomId) => {
44989
+ const client = getActiveClient();
44990
+ client.log('roomPresence/getRoomUserCount', { roomId });
44991
+ const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users/count`);
44992
+ pushToCache(['get', 'watchingCount', roomId], data);
44993
+ fireEvent('local.room.watchingCountUpdated', data);
44994
+ return data;
44995
+ };
44996
+ /* end_public_function */
44997
+
44998
+ const getPresenceSetting = async () => {
44999
+ const client = getActiveClient();
45000
+ client.log('presence/getPresenceSetting');
45001
+ const { data } = await client.http.get('/api/v1/presence/settings');
45002
+ pushToCache(['get', 'presenceSetting'], data);
45003
+ return data;
45004
+ };
45005
+
45006
+ class RoomPresenceSyncEngine {
45007
+ constructor(roomId) {
45008
+ this.isEnabled = false;
45009
+ this.config = {
45010
+ heartbeatInterval: 30 * SECOND$1,
45011
+ };
45012
+ this.roomId = roomId;
45013
+ // Initialize config asynchronously - don't await in constructor
45014
+ this.initializeConfig().catch(error => {
45015
+ console.error('Failed to initialize RoomPresenceSyncEngine config in constructor:', error);
45016
+ });
45017
+ }
45018
+ async initializeConfig() {
45019
+ try {
45020
+ // Get presence settings from API with retry logic
45021
+ const presenceSettings = await RoomPresenceSyncEngine.getPresenceSettingWithRetry();
45022
+ if (presenceSettings) {
45023
+ // Set intervals from network settings (convert from minutes to milliseconds)
45024
+ this.config = {
45025
+ heartbeatInterval: (presenceSettings.network.heartbeatInterval || 5) * 60 * 1000,
45026
+ };
45027
+ }
45028
+ else {
45029
+ // Use default intervals if all retries failed
45030
+ this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
45031
+ }
45032
+ }
45033
+ catch (error) {
45034
+ console.error('Failed to initialize RoomPresenceSyncEngine config:', error);
45035
+ // Use default intervals if settings fetch fails
45036
+ this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
45037
+ }
45038
+ }
45039
+ static async getPresenceSettingWithRetry(maxRetries = 5) {
45040
+ for (let attempt = 0; attempt < maxRetries; attempt += 1) {
45041
+ try {
45042
+ // eslint-disable-next-line no-await-in-loop
45043
+ const presenceSettings = await getPresenceSetting();
45044
+ return presenceSettings;
45045
+ }
45046
+ catch (error) {
45047
+ if (attempt >= maxRetries - 1) {
45048
+ console.error(`Failed to get presence setting after ${maxRetries} attempts:`, error);
45049
+ return null;
45050
+ }
45051
+ // Calculate delay: 20 seconds + random jitter (0-5 seconds)
45052
+ const jitter = Math.random() * 5000; // 0-5 seconds in milliseconds
45053
+ const delay = 20000 + jitter; // 20 seconds + jitter
45054
+ console.warn(`Failed to get presence setting (attempt ${attempt + 1}/${maxRetries}), retrying in ${Math.round(delay / 1000)}s:`, error);
45055
+ // Wait before retry
45056
+ // eslint-disable-next-line no-await-in-loop
45057
+ await new Promise(resolve => {
45058
+ setTimeout(resolve, delay);
45059
+ });
45060
+ }
45061
+ }
45062
+ return null;
45063
+ }
45064
+ /**
45065
+ * Start heartbeat for the room
45066
+ */
45067
+ start() {
45068
+ if (this.isEnabled)
45069
+ return;
45070
+ this.isEnabled = true;
45071
+ // Send immediate heartbeat
45072
+ this.sendHeartbeat();
45073
+ // Start heartbeat timer
45074
+ this.heartbeatTimer = setInterval(() => {
45075
+ this.sendHeartbeat();
45076
+ }, this.config.heartbeatInterval);
45077
+ }
45078
+ /**
45079
+ * Stop heartbeat for the room
45080
+ */
45081
+ stop() {
45082
+ this.isEnabled = false;
45083
+ // Stop heartbeat timer
45084
+ if (this.heartbeatTimer) {
45085
+ clearInterval(this.heartbeatTimer);
45086
+ this.heartbeatTimer = undefined;
45087
+ }
45088
+ }
45089
+ /**
45090
+ * Send heartbeat to the room
45091
+ */
45092
+ async sendHeartbeat() {
45093
+ try {
45094
+ const client = getActiveClient();
45095
+ await client.http.post(`/api/v1/presence/rooms/${this.roomId}/heartbeat`);
45096
+ }
45097
+ catch (error) {
45098
+ console.error(`Heartbeat failed for room ${this.roomId}:`, error);
45099
+ }
45100
+ }
45101
+ /**
45102
+ * Get the room ID
45103
+ */
45104
+ getRoomId() {
45105
+ return this.roomId;
45106
+ }
45107
+ /**
45108
+ * Check if the engine is enabled
45109
+ */
45110
+ isActive() {
45111
+ return this.isEnabled;
45112
+ }
45113
+ /**
45114
+ * Cleanup method to stop all timers and release resources
45115
+ * Call this when the engine instance is no longer needed
45116
+ */
45117
+ destroy() {
45118
+ // Stop the engine
45119
+ this.stop();
45120
+ }
45121
+ // Session Management
45122
+ onSessionDestroyed() {
45123
+ // Stop all timers when session is destroyed and cleanup
45124
+ this.destroy();
45125
+ }
45126
+ onTokenExpired() {
45127
+ // Stop engine when token expires
45128
+ this.stop();
45129
+ }
45130
+ }
45131
+
45132
+ // Map to store engine instances per roomId
45133
+ const engineInstances = new Map();
45134
+ /**
45135
+ * Get or create a RoomPresenceSyncEngine instance for a specific room
45136
+ *
45137
+ * @param roomId The room ID to get/create engine for
45138
+ * @returns RoomPresenceSyncEngine instance for the room
45139
+ */
45140
+ const getRoomPresenceSyncEngine = (roomId) => {
45141
+ let engine = engineInstances.get(roomId);
45142
+ if (!engine) {
45143
+ engine = new RoomPresenceSyncEngine(roomId);
45144
+ engineInstances.set(roomId, engine);
45145
+ }
45146
+ return engine;
45147
+ };
45148
+ /**
45149
+ * Destroy the engine instance for a specific room
45150
+ *
45151
+ * @param roomId The room ID to destroy engine for
45152
+ */
45153
+ const destroyRoomPresenceSyncEngine = (roomId) => {
45154
+ const engine = engineInstances.get(roomId);
45155
+ if (engine) {
45156
+ engine.destroy();
45157
+ engineInstances.delete(roomId);
45158
+ }
45159
+ };
45160
+
45161
+ /* begin_public_function
45162
+ id: roomPresence.startHeartbeat
45163
+ */
45164
+ /**
45165
+ * ```js
45166
+ * import { startHeartbeat } from '@amityco/ts-sdk'
45167
+ * startHeartbeat('roomId')
45168
+ * ```
45169
+ *
45170
+ * Starts sending heartbeat signals for a specific room to maintain presence status.
45171
+ * This enables the room presence tracking and notifies the server that the user is actively viewing the room.
45172
+ *
45173
+ * @param roomId The ID of the room to start heartbeat for
45174
+ *
45175
+ * @category Room Presence API
45176
+ */
45177
+ const startHeartbeat = (roomId) => {
45178
+ const engine = getRoomPresenceSyncEngine(roomId);
45179
+ engine.start();
45180
+ };
45181
+ /* end_public_function */
45182
+
45183
+ /* begin_public_function
45184
+ id: roomPresence.stopHeartbeat
45185
+ */
45186
+ /**
45187
+ * ```js
45188
+ * import { stopHeartbeat } from '@amityco/ts-sdk'
45189
+ * stopHeartbeat('roomId')
45190
+ * ```
45191
+ *
45192
+ * Stops sending heartbeat signals for a specific room.
45193
+ * This disables the room presence tracking for the specified room and stops notifying the server of the user's presence.
45194
+ *
45195
+ * @param roomId The ID of the room to stop heartbeat for
45196
+ *
45197
+ * @category Room Presence API
45198
+ */
45199
+ const stopHeartbeat = (roomId) => {
45200
+ const engine = getRoomPresenceSyncEngine(roomId);
45201
+ engine.stop();
45202
+ // Clean up the engine instance
45203
+ destroyRoomPresenceSyncEngine(roomId);
45204
+ };
45205
+ /* end_public_function */
45206
+
45207
+ var index$8 = /*#__PURE__*/Object.freeze({
45208
+ __proto__: null,
45209
+ getRoomOnlineUsers: getRoomOnlineUsers,
45210
+ getRoomUserCount: getRoomUserCount,
45211
+ startHeartbeat: startHeartbeat,
45212
+ stopHeartbeat: stopHeartbeat
45213
+ });
45214
+
44879
45215
  /* begin_public_function
44880
45216
  id: poll.create
44881
45217
  */
@@ -47203,28 +47539,6 @@ const cancelInvitation = async (invitationId) => {
47203
47539
  };
47204
47540
  /* end_public_function */
47205
47541
 
47206
- /* begin_public_function
47207
- id: invitation.accept
47208
- */
47209
- /**
47210
- * ```js
47211
- * import { acceptInvitation } from '@amityco/ts-sdk'
47212
- * const isAccepted = await acceptInvitation(invitationId)
47213
- * ```
47214
- *
47215
- * Accepts a {@link Amity.Invitation} object
47216
- *
47217
- * @param invitationId the {@link Amity.Invitation} to accept
47218
- * @returns A success boolean if the {@link Amity.Invitation} was accepted
47219
- *
47220
- * @category Invitation API
47221
- * @async
47222
- */
47223
- const acceptInvitation = async (invitationId) => {
47224
- return acceptInvitation$1(invitationId);
47225
- };
47226
- /* end_public_function */
47227
-
47228
47542
  class MyInvitationsPaginationController extends PaginationController {
47229
47543
  async getRequest(queryParams, token) {
47230
47544
  const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
@@ -47285,7 +47599,7 @@ class MyInvitationsQueryStreamController extends QueryStreamController {
47285
47599
  ]),
47286
47600
  ];
47287
47601
  }
47288
- if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
47602
+ if (action === InvitationActionsEnum.OnLocalInvitationCanceled) {
47289
47603
  collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
47290
47604
  }
47291
47605
  pushToCache(this.cacheKey, collection);
@@ -47417,13 +47731,16 @@ const getMyCommunityInvitations = (params, callback, config) => {
47417
47731
  };
47418
47732
  };
47419
47733
 
47734
+ /* begin_public_function
47735
+ id: invitation.get_invitations
47736
+ */
47420
47737
  /**
47421
47738
  *
47422
47739
  * ```js
47423
- * import { observeInvitations } from '@amityco/ts-sdk';
47740
+ * import { InvitationRepository } from '@amityco/ts-sdk';
47424
47741
  *
47425
47742
  * // For room invitations
47426
- * const unsubscribe = observeInvitations(
47743
+ * const unsubscribe = InvitationRepository.getInvitations(
47427
47744
  * { targetId: 'room123', targetType: 'room' },
47428
47745
  * response => {
47429
47746
  * console.log('Room invitation event:', response.room, response.users, response.eventType)
@@ -47447,7 +47764,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
47447
47764
  *
47448
47765
  * @category Invitation Observable
47449
47766
  */
47450
- const observeInvitations = (params, callback) => {
47767
+ const getInvitations = (params, callback) => {
47451
47768
  const { _id: userId } = getCurrentUser();
47452
47769
  if (!userId)
47453
47770
  throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
@@ -47460,7 +47777,7 @@ const observeInvitations = (params, callback) => {
47460
47777
  callback(data.map(LinkedObject.invitation));
47461
47778
  };
47462
47779
  const realtimeRouter = (data) => {
47463
- const invitations = data.filter(({ targetId, targetType }) => targetId === params.targetId && targetType === params.targetType);
47780
+ const invitations = (Array.isArray(data) ? data : [data]).filter(({ targetId, targetType }) => targetId === params.targetId && targetType === params.targetType);
47464
47781
  dispatcher(invitations);
47465
47782
  };
47466
47783
  // Only subscribe to room co-host events for now (since that's what we have implemented)
@@ -47472,7 +47789,7 @@ const observeInvitations = (params, callback) => {
47472
47789
  disposers.push(onRoomCoHostInviteCanceled(realtimeRouter));
47473
47790
  }
47474
47791
  return () => {
47475
- log(`observeInvitations(tmpid: ${timestamp}) > dispose for ${targetType}: ${targetId}`);
47792
+ log(`getInvitations(tmpid: ${timestamp}) > dispose for ${targetType}: ${targetId}`);
47476
47793
  disposers.forEach(fn => fn());
47477
47794
  };
47478
47795
  };
@@ -47480,12 +47797,11 @@ const observeInvitations = (params, callback) => {
47480
47797
  var index$2 = /*#__PURE__*/Object.freeze({
47481
47798
  __proto__: null,
47482
47799
  cancelInvitation: cancelInvitation,
47483
- acceptInvitation: acceptInvitation,
47484
47800
  onLocalInvitationCreated: onLocalInvitationCreated,
47485
47801
  onLocalInvitationUpdated: onLocalInvitationUpdated,
47486
47802
  onLocalInvitationCanceled: onLocalInvitationCanceled,
47487
47803
  getMyCommunityInvitations: getMyCommunityInvitations,
47488
- observeInvitations: observeInvitations
47804
+ getInvitations: getInvitations
47489
47805
  });
47490
47806
 
47491
47807
  // TODO: confirm id
@@ -47804,9 +48120,9 @@ const deleteEvent = async (eventId) => {
47804
48120
  users: [],
47805
48121
  files: [],
47806
48122
  communities: [],
47807
- videoStreamings: [],
48123
+ posts: [],
48124
+ rooms: [],
47808
48125
  events: [deletedEvent],
47809
- discussionCommunities: [],
47810
48126
  });
47811
48127
  };
47812
48128
  /* end_public_function */
@@ -48083,143 +48399,6 @@ const getEvents = (params, callback, config) => {
48083
48399
  };
48084
48400
  };
48085
48401
 
48086
- class MyEventPaginationController extends PaginationController {
48087
- async getRequest(queryParams, token) {
48088
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
48089
- const options = token ? { token } : { limit };
48090
- const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
48091
- return response;
48092
- }
48093
- }
48094
-
48095
- class MyEventQueryStreamController extends QueryStreamController {
48096
- constructor(query, cacheKey, notifyChange, preparePayload) {
48097
- super(query, cacheKey);
48098
- this.notifyChange = notifyChange;
48099
- this.preparePayload = preparePayload;
48100
- }
48101
- async saveToMainDB(response) {
48102
- const processedPayload = this.preparePayload(response);
48103
- const client = getActiveClient();
48104
- const cachedAt = client.cache && Date.now();
48105
- if (client.cache)
48106
- ingestInCache(processedPayload, { cachedAt });
48107
- }
48108
- appendToQueryStream(response, direction, refresh = false) {
48109
- var _a, _b;
48110
- if (refresh) {
48111
- pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
48112
- }
48113
- else {
48114
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48115
- const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
48116
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
48117
- }
48118
- }
48119
- reactor(action) {
48120
- return (event) => {
48121
- var _a;
48122
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48123
- if (!collection)
48124
- return;
48125
- if (action === EventActionsEnum.OnEventCreated) {
48126
- const client = getActiveClient();
48127
- if (client.userId !== event.userId)
48128
- return;
48129
- collection.data = [...new Set([event.eventId, ...collection.data])];
48130
- }
48131
- if (action === EventActionsEnum.OnEventDeleted) {
48132
- collection.data = collection.data.filter(eventId => eventId !== event.eventId);
48133
- }
48134
- pushToCache(this.cacheKey, collection);
48135
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
48136
- };
48137
- }
48138
- subscribeRTE(createSubscriber) {
48139
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
48140
- }
48141
- }
48142
-
48143
- class MyEventLiveCollectionController extends LiveCollectionController {
48144
- constructor(query, callback) {
48145
- const queryStreamId = hash(query);
48146
- const cacheKey = ['event', 'collection', queryStreamId];
48147
- const paginationController = new MyEventPaginationController(query);
48148
- super(paginationController, queryStreamId, cacheKey, callback);
48149
- this.query = query;
48150
- this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
48151
- this.callback = callback.bind(this);
48152
- this.loadPage({ initial: true });
48153
- }
48154
- setup() {
48155
- var _a;
48156
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48157
- if (!collection)
48158
- pushToCache(this.cacheKey, { data: [], params: {} });
48159
- }
48160
- async persistModel(queryPayload) {
48161
- await this.queryStreamController.saveToMainDB(queryPayload);
48162
- }
48163
- persistQueryStream({ response, direction, refresh, }) {
48164
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
48165
- }
48166
- startSubscription() {
48167
- return this.queryStreamController.subscribeRTE([
48168
- { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
48169
- { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
48170
- { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
48171
- { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
48172
- { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
48173
- { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
48174
- ]);
48175
- }
48176
- notifyChange({ origin, loading, error }) {
48177
- var _a, _b;
48178
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48179
- if (!collection)
48180
- return;
48181
- const data = ((_b = collection.data
48182
- .map(eventId => pullFromCache(['event', 'get', eventId]))
48183
- .filter(isNonNullable)
48184
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
48185
- if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
48186
- return;
48187
- this.callback({
48188
- data,
48189
- error,
48190
- loading,
48191
- hasNextPage: !!this.paginationController.getNextToken(),
48192
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
48193
- });
48194
- }
48195
- }
48196
-
48197
- /**
48198
- * Get my events
48199
- *
48200
- * @param params the query parameters
48201
- * @param callback the callback to be called when the events are updated
48202
- * @returns events
48203
- *
48204
- * @category Event Live Collection
48205
- *
48206
- */
48207
- const getMyEvents = (params, callback, config) => {
48208
- const { log, cache } = getActiveClient();
48209
- if (!cache)
48210
- console.log(ENABLE_CACHE_MESSAGE);
48211
- const timestamp = Date.now();
48212
- log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
48213
- const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
48214
- const disposers = myEventLiveCollection.startSubscription();
48215
- const cacheKey = myEventLiveCollection.getCacheKey();
48216
- disposers.push(() => dropFromCache(cacheKey));
48217
- return () => {
48218
- log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
48219
- disposers.forEach(fn => fn());
48220
- };
48221
- };
48222
-
48223
48402
  var index = /*#__PURE__*/Object.freeze({
48224
48403
  __proto__: null,
48225
48404
  createEvent: createEvent,
@@ -48232,8 +48411,7 @@ var index = /*#__PURE__*/Object.freeze({
48232
48411
  onLocalEventUpdated: onLocalEventUpdated,
48233
48412
  onLocalEventDeleted: onLocalEventDeleted,
48234
48413
  getEvent: getEvent,
48235
- getEvents: getEvents,
48236
- getMyEvents: getMyEvents
48414
+ getEvents: getEvents
48237
48415
  });
48238
48416
 
48239
- export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType, AmityEventResponseStatus, AmityEventStatus, AmityEventType, index$d as CategoryRepository, index$h as ChannelRepository, index$q as Client, index$c as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$e as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$b as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$n as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$l as MessageRepository, index$7 as PollRepository, PostContentType, index$a as PostRepository, PostStructureType, index$m as ReactionRepository, index$8 as RoomRepository, index$5 as StoryRepository, index$9 as StreamRepository, index$k as SubChannelRepository, SubscriptionLevels, index$o as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$3 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
48417
+ export { API_REGIONS, index$4 as AdRepository, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, index$e as CategoryRepository, index$i as ChannelRepository, index$r as Client, index$d as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$f as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$c as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$o as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$m as MessageRepository, index$7 as PollRepository, PostContentType, index$b as PostRepository, PostStructureType, index$n as ReactionRepository, index$8 as RoomPresenceRepository, index$9 as RoomRepository, index$5 as StoryRepository, index$a as StreamRepository, index$l as SubChannelRepository, SubscriptionLevels, index$p as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$3 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };