@amityco/ts-sdk 7.11.1-31db2c1f.0 → 7.11.1-352154bf.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 (223) hide show
  1. package/dist/@types/core/events.d.ts +41 -5
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +6 -1
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +46 -0
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/core/permissions.d.ts +5 -1
  8. package/dist/@types/core/permissions.d.ts.map +1 -1
  9. package/dist/@types/core/transport.d.ts +3 -0
  10. package/dist/@types/core/transport.d.ts.map +1 -1
  11. package/dist/@types/domains/community.d.ts +14 -1
  12. package/dist/@types/domains/community.d.ts.map +1 -1
  13. package/dist/@types/domains/event.d.ts +122 -0
  14. package/dist/@types/domains/event.d.ts.map +1 -0
  15. package/dist/@types/domains/notification.d.ts +6 -2
  16. package/dist/@types/domains/notification.d.ts.map +1 -1
  17. package/dist/@types/domains/partials.d.ts +2 -2
  18. package/dist/@types/domains/partials.d.ts.map +1 -1
  19. package/dist/@types/domains/room.d.ts +18 -3
  20. package/dist/@types/domains/room.d.ts.map +1 -1
  21. package/dist/@types/index.d.ts +1 -0
  22. package/dist/@types/index.d.ts.map +1 -1
  23. package/dist/client/api/getPresenceSetting.d.ts +2 -0
  24. package/dist/client/api/getPresenceSetting.d.ts.map +1 -0
  25. package/dist/client/api/resumeSession.d.ts.map +1 -1
  26. package/dist/client/events/onUserDeleted.d.ts +17 -0
  27. package/dist/client/events/onUserDeleted.d.ts.map +1 -0
  28. package/dist/client/services/ObjectResolver/objectResolverEngine.d.ts.map +1 -0
  29. package/dist/client/services/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +1 -0
  30. package/dist/client/services/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +1 -0
  31. package/dist/client/services/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +1 -0
  32. package/dist/client/services/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -0
  33. package/dist/client/services/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts.map +1 -0
  34. package/dist/core/events.d.ts +3 -3
  35. package/dist/core/events.d.ts.map +1 -1
  36. package/dist/core/model/idResolvers.d.ts.map +1 -1
  37. package/dist/core/model/index.d.ts.map +1 -1
  38. package/dist/eventRepository/api/createEvent.d.ts +16 -0
  39. package/dist/eventRepository/api/createEvent.d.ts.map +1 -0
  40. package/dist/eventRepository/api/deleteEvent.d.ts +15 -0
  41. package/dist/eventRepository/api/deleteEvent.d.ts.map +1 -0
  42. package/dist/eventRepository/api/index.d.ts +4 -0
  43. package/dist/eventRepository/api/index.d.ts.map +1 -0
  44. package/dist/eventRepository/api/updateEvent.d.ts +17 -0
  45. package/dist/eventRepository/api/updateEvent.d.ts.map +1 -0
  46. package/dist/eventRepository/events/enums.d.ts +8 -0
  47. package/dist/eventRepository/events/enums.d.ts.map +1 -0
  48. package/dist/eventRepository/events/index.d.ts +11 -0
  49. package/dist/eventRepository/events/index.d.ts.map +1 -0
  50. package/dist/eventRepository/events/onEventCreated.d.ts +17 -0
  51. package/dist/eventRepository/events/onEventCreated.d.ts.map +1 -0
  52. package/dist/eventRepository/events/onEventDeleted.d.ts +17 -0
  53. package/dist/eventRepository/events/onEventDeleted.d.ts.map +1 -0
  54. package/dist/eventRepository/events/onEventUpdated.d.ts +17 -0
  55. package/dist/eventRepository/events/onEventUpdated.d.ts.map +1 -0
  56. package/dist/eventRepository/events/onLocalEventCreated.d.ts +17 -0
  57. package/dist/eventRepository/events/onLocalEventCreated.d.ts.map +1 -0
  58. package/dist/eventRepository/events/onLocalEventDeleted.d.ts +17 -0
  59. package/dist/eventRepository/events/onLocalEventDeleted.d.ts.map +1 -0
  60. package/dist/eventRepository/events/onLocalEventUpdated.d.ts +17 -0
  61. package/dist/eventRepository/events/onLocalEventUpdated.d.ts.map +1 -0
  62. package/dist/eventRepository/events/onLocalRSVPCreated.d.ts +17 -0
  63. package/dist/eventRepository/events/onLocalRSVPCreated.d.ts.map +1 -0
  64. package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts +17 -0
  65. package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts.map +1 -0
  66. package/dist/eventRepository/events/onRSVPCreated.d.ts +17 -0
  67. package/dist/eventRepository/events/onRSVPCreated.d.ts.map +1 -0
  68. package/dist/eventRepository/events/onRSVPUpdated.d.ts +17 -0
  69. package/dist/eventRepository/events/onRSVPUpdated.d.ts.map +1 -0
  70. package/dist/eventRepository/index.d.ts +4 -0
  71. package/dist/eventRepository/index.d.ts.map +1 -0
  72. package/dist/eventRepository/internalApi/createRSVP.d.ts +17 -0
  73. package/dist/eventRepository/internalApi/createRSVP.d.ts.map +1 -0
  74. package/dist/eventRepository/internalApi/getEvent.d.ts +32 -0
  75. package/dist/eventRepository/internalApi/getEvent.d.ts.map +1 -0
  76. package/dist/eventRepository/internalApi/getMyRSVP.d.ts +32 -0
  77. package/dist/eventRepository/internalApi/getMyRSVP.d.ts.map +1 -0
  78. package/dist/eventRepository/internalApi/index.d.ts +5 -0
  79. package/dist/eventRepository/internalApi/index.d.ts.map +1 -0
  80. package/dist/eventRepository/internalApi/updateRSVP.d.ts +17 -0
  81. package/dist/eventRepository/internalApi/updateRSVP.d.ts.map +1 -0
  82. package/dist/eventRepository/observers/getEvent.d.ts +21 -0
  83. package/dist/eventRepository/observers/getEvent.d.ts.map +1 -0
  84. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts +13 -0
  85. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +1 -0
  86. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts +5 -0
  87. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts.map +1 -0
  88. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts +15 -0
  89. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts.map +1 -0
  90. package/dist/eventRepository/observers/getEvents.d.ts +12 -0
  91. package/dist/eventRepository/observers/getEvents.d.ts.map +1 -0
  92. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts +13 -0
  93. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +1 -0
  94. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +5 -0
  95. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +1 -0
  96. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +15 -0
  97. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +1 -0
  98. package/dist/eventRepository/observers/getMyEvents.d.ts +12 -0
  99. package/dist/eventRepository/observers/getMyEvents.d.ts.map +1 -0
  100. package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts +13 -0
  101. package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts.map +1 -0
  102. package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts +5 -0
  103. package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts.map +1 -0
  104. package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts +15 -0
  105. package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts.map +1 -0
  106. package/dist/eventRepository/observers/getRSVPs.d.ts +12 -0
  107. package/dist/eventRepository/observers/getRSVPs.d.ts.map +1 -0
  108. package/dist/eventRepository/observers/index.d.ts +5 -0
  109. package/dist/eventRepository/observers/index.d.ts.map +1 -0
  110. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +2 -0
  111. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +1 -0
  112. package/dist/eventRepository/utils/createEventResponseSubscriber.d.ts +2 -0
  113. package/dist/eventRepository/utils/createEventResponseSubscriber.d.ts.map +1 -0
  114. package/dist/eventRepository/utils/index.d.ts +5 -0
  115. package/dist/eventRepository/utils/index.d.ts.map +1 -0
  116. package/dist/eventRepository/utils/prepareEventPayload.d.ts +2 -0
  117. package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +1 -0
  118. package/dist/eventRepository/utils/prepareEventResponsePayload.d.ts +2 -0
  119. package/dist/eventRepository/utils/prepareEventResponsePayload.d.ts.map +1 -0
  120. package/dist/index.cjs.js +2063 -600
  121. package/dist/index.d.ts +2 -0
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.esm.js +1579 -118
  124. package/dist/index.umd.js +3 -3
  125. package/dist/invitationRepository/api/index.d.ts +0 -1
  126. package/dist/invitationRepository/api/index.d.ts.map +1 -1
  127. package/dist/invitationRepository/internalObservers/getInvitations/InvitationsLiveCollectionController.d.ts.map +1 -0
  128. package/dist/invitationRepository/internalObservers/getInvitations/InvitationsPaginationController.d.ts.map +1 -0
  129. package/dist/invitationRepository/internalObservers/getInvitations/InvitationsQueryStreamController.d.ts.map +1 -0
  130. package/dist/invitationRepository/internalObservers/getInvitations/enums.d.ts.map +1 -0
  131. package/dist/invitationRepository/internalObservers/getInvitations.d.ts +12 -0
  132. package/dist/invitationRepository/internalObservers/getInvitations.d.ts.map +1 -0
  133. package/dist/invitationRepository/observers/getInvitations.d.ts +28 -6
  134. package/dist/invitationRepository/observers/getInvitations.d.ts.map +1 -1
  135. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts +1 -1
  136. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts.map +1 -1
  137. package/dist/invitationRepository/observers/index.d.ts +1 -1
  138. package/dist/invitationRepository/observers/index.d.ts.map +1 -1
  139. package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts +2 -2
  140. package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts.map +1 -1
  141. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
  142. package/dist/roomPresenceRepository/api/getRoomOnlineUsers.d.ts +18 -0
  143. package/dist/roomPresenceRepository/api/getRoomOnlineUsers.d.ts.map +1 -0
  144. package/dist/roomPresenceRepository/api/getRoomUserCount.d.ts +17 -0
  145. package/dist/roomPresenceRepository/api/getRoomUserCount.d.ts.map +1 -0
  146. package/dist/roomPresenceRepository/api/index.d.ts +5 -0
  147. package/dist/roomPresenceRepository/api/index.d.ts.map +1 -0
  148. package/dist/roomPresenceRepository/api/startHeartbeat.d.ts +15 -0
  149. package/dist/roomPresenceRepository/api/startHeartbeat.d.ts.map +1 -0
  150. package/dist/roomPresenceRepository/api/stopHeartbeat.d.ts +15 -0
  151. package/dist/roomPresenceRepository/api/stopHeartbeat.d.ts.map +1 -0
  152. package/dist/roomPresenceRepository/index.d.ts +2 -0
  153. package/dist/roomPresenceRepository/index.d.ts.map +1 -0
  154. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/RoomPresenceSyncEngine.d.ts +38 -0
  155. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/RoomPresenceSyncEngine.d.ts.map +1 -0
  156. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/index.d.ts +2 -0
  157. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/index.d.ts.map +1 -0
  158. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/roomPresenceSyncEngineFactory.d.ts +32 -0
  159. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/roomPresenceSyncEngineFactory.d.ts.map +1 -0
  160. package/dist/roomPresenceRepository/services/index.d.ts +2 -0
  161. package/dist/roomPresenceRepository/services/index.d.ts.map +1 -0
  162. package/dist/roomRepository/api/index.d.ts +1 -0
  163. package/dist/roomRepository/api/index.d.ts.map +1 -1
  164. package/dist/roomRepository/api/leaveRoom.d.ts +16 -0
  165. package/dist/roomRepository/api/leaveRoom.d.ts.map +1 -0
  166. package/dist/roomRepository/api/removeParticipant.d.ts.map +1 -1
  167. package/dist/roomRepository/events/index.d.ts +1 -0
  168. package/dist/roomRepository/events/index.d.ts.map +1 -1
  169. package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts +1 -1
  170. package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts.map +1 -1
  171. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +1 -1
  172. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +1 -1
  173. package/dist/roomRepository/events/onRoomLeft.d.ts +17 -0
  174. package/dist/roomRepository/events/onRoomLeft.d.ts.map +1 -0
  175. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +1 -1
  176. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +1 -1
  177. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +1 -1
  178. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +1 -1
  179. package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts +17 -0
  180. package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts.map +1 -0
  181. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +1 -1
  182. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +1 -1
  183. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +1 -1
  184. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +1 -1
  185. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +1 -1
  186. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +1 -1
  187. package/dist/roomRepository/observers/getRoom.d.ts.map +1 -1
  188. package/dist/roomRepository/observers/utils.d.ts +1 -1
  189. package/dist/utils/linkedObject/eventLinkObject.d.ts +2 -0
  190. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -0
  191. package/dist/utils/linkedObject/eventResponseLinkObject.d.ts +2 -0
  192. package/dist/utils/linkedObject/eventResponseLinkObject.d.ts.map +1 -0
  193. package/dist/utils/linkedObject/index.d.ts +2 -0
  194. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  195. package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts.map +1 -1
  196. package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +1 -1
  197. package/package.json +1 -1
  198. package/dist/client/utils/ObjectResolver/objectResolverEngine.d.ts.map +0 -1
  199. package/dist/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +0 -1
  200. package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +0 -1
  201. package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
  202. package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +0 -1
  203. package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
  204. package/dist/invitationRepository/api/acceptInvitation.d.ts +0 -16
  205. package/dist/invitationRepository/api/acceptInvitation.d.ts.map +0 -1
  206. package/dist/invitationRepository/api/getMyInvitation.d.ts +0 -16
  207. package/dist/invitationRepository/api/getMyInvitation.d.ts.map +0 -1
  208. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +0 -1
  209. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +0 -1
  210. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +0 -1
  211. package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +0 -1
  212. package/dist/invitationRepository/observers/observeInvitations.d.ts +0 -34
  213. package/dist/invitationRepository/observers/observeInvitations.d.ts.map +0 -1
  214. /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngine.d.ts +0 -0
  215. /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts +0 -0
  216. /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts +0 -0
  217. /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts +0 -0
  218. /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngine.d.ts +0 -0
  219. /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts +0 -0
  220. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsLiveCollectionController.d.ts +0 -0
  221. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsPaginationController.d.ts +0 -0
  222. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsQueryStreamController.d.ts +0 -0
  223. /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',
@@ -199,6 +204,39 @@ exports.FeedSourceEnum = void 0;
199
204
  FeedSourceEnum["User"] = "user";
200
205
  })(exports.FeedSourceEnum || (exports.FeedSourceEnum = {}));
201
206
 
207
+ exports.AmityEventType = void 0;
208
+ (function (AmityEventType) {
209
+ AmityEventType["Virtual"] = "virtual";
210
+ AmityEventType["InPerson"] = "in_person";
211
+ })(exports.AmityEventType || (exports.AmityEventType = {}));
212
+ exports.AmityEventOriginType = void 0;
213
+ (function (AmityEventOriginType) {
214
+ AmityEventOriginType["Community"] = "community";
215
+ AmityEventOriginType["User"] = "user";
216
+ })(exports.AmityEventOriginType || (exports.AmityEventOriginType = {}));
217
+ exports.AmityEventStatus = void 0;
218
+ (function (AmityEventStatus) {
219
+ AmityEventStatus["Scheduled"] = "scheduled";
220
+ AmityEventStatus["Live"] = "live";
221
+ AmityEventStatus["Ended"] = "ended";
222
+ AmityEventStatus["Cancelled"] = "cancelled";
223
+ })(exports.AmityEventStatus || (exports.AmityEventStatus = {}));
224
+ exports.AmityEventResponseStatus = void 0;
225
+ (function (AmityEventResponseStatus) {
226
+ AmityEventResponseStatus["Going"] = "going";
227
+ AmityEventResponseStatus["NotGoing"] = "not_going";
228
+ })(exports.AmityEventResponseStatus || (exports.AmityEventResponseStatus = {}));
229
+ exports.AmityEventSortOption = void 0;
230
+ (function (AmityEventSortOption) {
231
+ AmityEventSortOption["StartTime"] = "startTime";
232
+ AmityEventSortOption["CreatedAt"] = "createdAt";
233
+ })(exports.AmityEventSortOption || (exports.AmityEventSortOption = {}));
234
+ exports.AmityEventOrderOption = void 0;
235
+ (function (AmityEventOrderOption) {
236
+ AmityEventOrderOption["Ascending"] = "asc";
237
+ AmityEventOrderOption["Descending"] = "desc";
238
+ })(exports.AmityEventOrderOption || (exports.AmityEventOrderOption = {}));
239
+
202
240
  function getVersion() {
203
241
  try {
204
242
  // the string ''v7.11.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
@@ -648,6 +686,9 @@ const idResolvers = {
648
686
  invitation: ({ _id }) => _id,
649
687
  joinRequest: ({ joinRequestId }) => joinRequestId,
650
688
  room: ({ roomId }) => roomId,
689
+ viewer: ({ userId }) => userId,
690
+ event: ({ eventId }) => eventId,
691
+ eventResponse: ({ eventId }) => eventId,
651
692
  };
652
693
  /**
653
694
  * Retrieve the id resolver matching a domain name
@@ -704,6 +745,9 @@ const PAYLOAD2MODEL = {
704
745
  invitations: 'invitation',
705
746
  joinRequests: 'joinRequest',
706
747
  rooms: 'room',
748
+ events: 'event',
749
+ viewers: 'viewer',
750
+ eventResponses: 'eventResponse',
707
751
  };
708
752
  /** hidden */
709
753
  const isOutdated = (prevData, nextData) => {
@@ -1434,14 +1478,12 @@ const createEventEmitter = () => {
1434
1478
  const proxyMqttEvents = (mqttClient, emitter) => {
1435
1479
  MQTT_EVENTS.forEach(event => {
1436
1480
  mqttClient === null || mqttClient === void 0 ? void 0 : mqttClient.on(event, (...params) => {
1437
- console.log('global event received => ', event);
1438
1481
  emitter.emit(event, params.length === 1 ? params[0] : params);
1439
1482
  });
1440
1483
  });
1441
1484
  // @ts-ignore
1442
1485
  mqttClient.on('message', (topic, payload) => {
1443
1486
  const message = JSON.parse(payload.toString());
1444
- console.log('message event received => ', message.eventType, message.data);
1445
1487
  emitter.emit(message.eventType, message.data);
1446
1488
  });
1447
1489
  };
@@ -8483,11 +8525,11 @@ var objectResolverEngineOnLoginHandler = () => {
8483
8525
  * @category Live Reaction API
8484
8526
  * @async
8485
8527
  */
8486
- const createLiveReaction = async ({ reactions, roomId, }) => {
8528
+ const createLiveReaction = async ({ reactions, liveStreamId, }) => {
8487
8529
  const client = getActiveClient();
8488
8530
  client.log('live_reaction/addReaction', reactions);
8489
8531
  const { data } = await client.http.post(`/api/v1/reactions/live`, {
8490
- roomId,
8532
+ liveStreamId,
8491
8533
  reactions,
8492
8534
  });
8493
8535
  return data;
@@ -8557,7 +8599,7 @@ class LiveReactionSyncEngine {
8557
8599
  // Call server api `POST /api/v1/reactions/live` to sync live reactions
8558
8600
  Object.entries(payloads).forEach(([roomId, reactions]) => {
8559
8601
  createLiveReaction({
8560
- roomId,
8602
+ liveStreamId: roomId,
8561
8603
  reactions,
8562
8604
  });
8563
8605
  });
@@ -10479,7 +10521,7 @@ const getUserUnread = (callback) => {
10479
10521
  };
10480
10522
  };
10481
10523
 
10482
- var index$p = /*#__PURE__*/Object.freeze({
10524
+ var index$r = /*#__PURE__*/Object.freeze({
10483
10525
  __proto__: null,
10484
10526
  getActiveClient: getActiveClient,
10485
10527
  getActiveUser: getActiveUser,
@@ -11698,7 +11740,7 @@ const getMyFollowInfo = (callback) => {
11698
11740
  };
11699
11741
  /* end_public_function */
11700
11742
 
11701
- var index$o = /*#__PURE__*/Object.freeze({
11743
+ var index$q = /*#__PURE__*/Object.freeze({
11702
11744
  __proto__: null,
11703
11745
  blockUser: blockUser,
11704
11746
  unBlockUser: unBlockUser,
@@ -12343,7 +12385,7 @@ const createInvitations = async (bundle) => {
12343
12385
  * @category Invitation API
12344
12386
  * @async
12345
12387
  */
12346
- const acceptInvitation$1 = async (invitationId) => {
12388
+ const acceptInvitation = async (invitationId) => {
12347
12389
  var _a;
12348
12390
  const client = getActiveClient();
12349
12391
  client.log('invitation/acceptInvitation', invitationId);
@@ -12429,7 +12471,7 @@ const invitationLinkedObject = (invitation) => {
12429
12471
  }
12430
12472
  return undefined;
12431
12473
  }, accept: async () => {
12432
- await acceptInvitation$1(invitation._id);
12474
+ await acceptInvitation(invitation._id);
12433
12475
  }, reject: async () => {
12434
12476
  await rejectInvitation(invitation._id);
12435
12477
  } });
@@ -12680,7 +12722,7 @@ class InvitationsLiveCollectionController extends LiveCollectionController {
12680
12722
  * @category Invitation Live Collection
12681
12723
  *
12682
12724
  */
12683
- const getInvitations = (params, callback, config) => {
12725
+ const getInvitations$1 = (params, callback, config) => {
12684
12726
  const { log, cache } = getActiveClient();
12685
12727
  if (!cache) {
12686
12728
  console.log(ENABLE_CACHE_MESSAGE);
@@ -12755,7 +12797,8 @@ const roomLinkedObject = (room) => {
12755
12797
  },
12756
12798
  get user() {
12757
12799
  var _a;
12758
- return (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
12800
+ const user = (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
12801
+ return user ? userLinkedObject(user) : user;
12759
12802
  },
12760
12803
  get childRooms() {
12761
12804
  if (!room.childRoomIds || room.childRoomIds.length === 0)
@@ -12769,12 +12812,16 @@ const roomLinkedObject = (room) => {
12769
12812
  return roomLinkedObject(roomCache);
12770
12813
  })
12771
12814
  .filter(isNonNullable);
12772
- }, getLiveChat: () => getLiveChat(room), createInvitation: (userId) => createInvitations({
12815
+ }, participants: room.participants.map(participant => (Object.assign(Object.assign({}, participant), { get user() {
12816
+ var _a;
12817
+ const user = (_a = pullFromCache(['user', 'get', participant.userId])) === null || _a === void 0 ? void 0 : _a.data;
12818
+ return user ? userLinkedObject(user) : user;
12819
+ } }))), getLiveChat: () => getLiveChat(room), createInvitation: (userId) => createInvitations({
12773
12820
  type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */,
12774
12821
  targetType: 'room',
12775
12822
  targetId: room.roomId,
12776
12823
  userIds: [userId],
12777
- }), getInvitations: (params, callback) => getInvitations(Object.assign(Object.assign({}, params), { targetId: room.roomId, targetType: 'room', type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */ }), callback), getMyInvitation: async () => {
12824
+ }), getInvitations: (params, callback) => getInvitations$1(Object.assign(Object.assign({}, params), { targetId: room.roomId, targetType: 'room', type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */ }), callback), getMyInvitation: async () => {
12778
12825
  const { data } = await getInvitation({
12779
12826
  targetId: room.roomId,
12780
12827
  targetType: 'room',
@@ -13186,7 +13233,12 @@ const notificationTrayLinkedObject = (noti) => {
13186
13233
  .map(({ publicId }) => pullFromCache(['user', 'get', publicId]))
13187
13234
  .filter(isNonNullable)
13188
13235
  .map(({ data }) => data)
13189
- .map(user => userLinkedObject(user)) });
13236
+ .map(user => userLinkedObject(user)), get event() {
13237
+ const cacheData = pullFromCache(['event', 'get', noti.actionReferenceId]);
13238
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
13239
+ return;
13240
+ return cacheData.data;
13241
+ } });
13190
13242
  };
13191
13243
 
13192
13244
  /*
@@ -13773,7 +13825,7 @@ const communityLinkedObject = (community) => {
13773
13825
  userIds,
13774
13826
  });
13775
13827
  }, getMemberInvitations: (params, callback) => {
13776
- return getInvitations(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
13828
+ return getInvitations$1(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
13777
13829
  }, getInvitation: async () => {
13778
13830
  const { data } = await getInvitation({
13779
13831
  targetType: 'community',
@@ -13788,480 +13840,463 @@ const communityLinkedObject = (community) => {
13788
13840
  } });
13789
13841
  };
13790
13842
 
13791
- const LinkedObject = {
13792
- ad: adLinkedObject,
13793
- comment: commentLinkedObject,
13794
- post: postLinkedObject,
13795
- user: userLinkedObject,
13796
- category: categoryLinkedObject,
13797
- stream: streamLinkedObject,
13798
- story: storyLinkedObject,
13799
- storyTarget: storyTargetLinkedObject,
13800
- message: messageLinkedObject,
13801
- reactor: reactorLinkedObject,
13802
- channel: channelLinkedObject,
13803
- pinnedPost: pinnedPostLinkedObject,
13804
- notificationTray: notificationTrayLinkedObject,
13805
- community: communityLinkedObject,
13806
- invitation: invitationLinkedObject,
13807
- joinRequest: joinRequestLinkedObject,
13808
- channelMember: channelMemberLinkedObject,
13809
- room: roomLinkedObject,
13843
+ const prepareEventResponsePayload = (rawPayload) => {
13844
+ return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
13845
+ };
13846
+
13847
+ const eventResponseLinkedObject = (event) => {
13848
+ return Object.assign(Object.assign({}, event), { get status() {
13849
+ return event.status;
13850
+ },
13851
+ get userId() {
13852
+ return event.userId;
13853
+ },
13854
+ get eventId() {
13855
+ return event.eventId;
13856
+ },
13857
+ get respondedAt() {
13858
+ return event.respondedAt;
13859
+ },
13860
+ get event() {
13861
+ const cacheData = pullFromCache(['event', 'get', event.eventId]);
13862
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
13863
+ return;
13864
+ return cacheData.data;
13865
+ },
13866
+ get user() {
13867
+ const cacheData = pullFromCache(['user', 'get', event.userId]);
13868
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
13869
+ return;
13870
+ return userLinkedObject(cacheData.data);
13871
+ } });
13810
13872
  };
13811
13873
 
13812
13874
  /* begin_public_function
13813
- id: user.get_by_ids
13875
+ id: event.rsvp.create
13814
13876
  */
13815
13877
  /**
13816
13878
  * ```js
13817
- * import { getUsers } from '@amityco/ts-sdk'
13818
- * const { data: users } = await getUsers(['foo', 'bar'])
13879
+ * import { event } from '@amityco/ts-sdk'
13880
+ * const response = await event.createRSVP(eventId, status)
13819
13881
  * ```
13820
13882
  *
13821
- * Fetches a collection of {@link Amity.User} objects
13883
+ * Creates an {@link Amity.EventResponse} for the active user for a specific event.
13822
13884
  *
13823
- * @param userIds the IDs of the {@link Amity.User} to fetch
13824
- * @returns the associated collection of {@link Amity.User} objects
13885
+ * @param eventId The ID of the {@link Amity.EventResponse} to create an RSVP for
13886
+ * @param status The RSVP status to set for the event
13887
+ * @returns The {@link Amity.EventResponse} with updated RSVP information
13825
13888
  *
13826
- * @category User API
13889
+ * @category Event API
13827
13890
  * @async
13828
13891
  */
13829
- const getUserByIds = async (userIds) => {
13892
+ const createRSVP = async (eventId, status) => {
13830
13893
  const client = getActiveClient();
13831
- client.log('user/getUsers', userIds);
13832
- const encodedUserIds = userIds.map(userId => encodeURIComponent(userId));
13833
- // API-FIX: endpoint should not be /list, parameters should be querystring.
13834
- const { data } = await client.http.get(`/api/v3/users/list`, {
13835
- params: { userIds: encodedUserIds },
13836
- });
13837
- const payload = prepareUserPayload(data);
13894
+ client.log('event/createRSVP', eventId, status);
13895
+ const { data: payload } = await client.http.post(`/api/v1/events/${eventId}/rsvp`, { status });
13896
+ fireEvent('local.rsvp.created', payload);
13897
+ const data = prepareEventResponsePayload(payload);
13838
13898
  const cachedAt = client.cache && Date.now();
13839
13899
  if (client.cache)
13840
- ingestInCache(payload, { cachedAt });
13841
- fireEvent('user.fetched', data);
13900
+ ingestInCache(data, { cachedAt });
13842
13901
  return {
13843
- data: payload.users.map(user => LinkedObject.user(user)),
13902
+ data: eventResponseLinkedObject(data.eventResponses[0]),
13844
13903
  cachedAt,
13845
13904
  };
13846
13905
  };
13847
13906
  /* end_public_function */
13848
- /**
13849
- * ```js
13850
- * import { getUsers } from '@amityco/ts-sdk'
13851
- * const { data: users } = getUsers.locally!(['foo', 'bar'])
13852
- * ```
13853
- *
13854
- * Fetches a collection of {@link Amity.User} objects from cache
13855
- *
13856
- * @param userIds the IDs of the {@link Amity.User} to fetch
13857
- * @returns the associated collection of {@link Amity.User} objects
13858
- *
13859
- * @category User API
13860
- */
13861
- getUserByIds.locally = (userIds) => {
13862
- var _a;
13863
- const client = getActiveClient();
13864
- client.log('user/getUsers.locally', userIds);
13865
- if (!client.cache)
13866
- return;
13867
- const cached = userIds
13868
- .map(userId => pullFromCache(['user', 'get', userId]))
13869
- .filter(Boolean);
13870
- const users = cached.map(({ data }) => LinkedObject.user(data));
13871
- const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
13872
- if ((cached === null || cached === void 0 ? void 0 : cached.length) < userIds.length)
13873
- return;
13874
- return {
13875
- data: users,
13876
- cachedAt: oldest.cachedAt,
13877
- };
13878
- };
13879
13907
 
13880
13908
  /* begin_public_function
13881
- id: client.update_user
13909
+ id: event.update
13882
13910
  */
13883
13911
  /**
13884
13912
  * ```js
13885
- * import { updateUser } from '@amityco/ts-sdk'
13886
- * const updated = await updateUser(userId, { displayName: 'foobar' })
13913
+ * import { event } from '@amityco/ts-sdk'
13914
+ * const response = await event.updateRSVP(eventId, status)
13887
13915
  * ```
13888
13916
  *
13889
- * Updates an {@link Amity.User}
13917
+ * Updates an {@link Amity.EventResponse}
13890
13918
  *
13891
- * @param userId The ID of the {@link Amity.User} to update
13892
- * @param patch The patch data to apply
13893
- * @returns the updated {@link Amity.User} object
13919
+ * @param eventId The ID of the {@link Amity.EventResponse} to edit
13920
+ * @param bundle The data necessary to update an existing {@link Amity.EventResponse}
13921
+ * @returns the updated {@link Amity.EventResponse}
13894
13922
  *
13895
- * @category User API
13923
+ * @category Event API
13896
13924
  * @async
13897
13925
  */
13898
- const updateUser = async (userId, patch) => {
13926
+ const updateRSVP = async (eventId, status) => {
13899
13927
  const client = getActiveClient();
13900
- client.log('user/updateUser', userId, patch);
13901
- const { data } = await client.http.put(`/api/v3/users/`, Object.assign(Object.assign({ userId }, patch), { createNewUserWhenNotFound: false }));
13902
- const payload = prepareUserPayload(data);
13928
+ client.log('event/updateRSVP', eventId, status);
13929
+ const { data: payload } = await client.http.put(`/api/v1/events/${eventId}/rsvp`, { status });
13930
+ fireEvent('local.rsvp.updated', payload);
13931
+ const data = prepareEventResponsePayload(payload);
13903
13932
  const cachedAt = client.cache && Date.now();
13904
13933
  if (client.cache)
13905
- ingestInCache(payload, { cachedAt });
13906
- fireEvent('user.updated', data);
13934
+ ingestInCache(data, { cachedAt });
13907
13935
  return {
13908
- data: payload.users.find(user => user.userId === userId),
13936
+ data: eventResponseLinkedObject(data.eventResponses[0]),
13909
13937
  cachedAt,
13910
13938
  };
13911
13939
  };
13912
13940
  /* end_public_function */
13913
13941
 
13914
- /* begin_public_function
13915
- id: user.flag
13916
- */
13917
- /**
13918
- * ```js
13919
- * import { UserRepository } from '@amityco/ts-sdk'
13920
- * const flagged = await UserRepository.flagUser('userId')
13921
- * ```
13922
- *
13923
- * @param userId The ID of the user to add a be flagged
13924
- * @returns the created report result
13925
- *
13926
- * @category User API
13927
- * @async
13928
- * */
13929
- const flagUser = async (userId) => {
13942
+ const prepareEventPayload = (rawPayload) => {
13943
+ return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
13944
+ };
13945
+
13946
+ const createEventEventSubscriber = (event, callback) => {
13930
13947
  const client = getActiveClient();
13931
- client.log('user/flagUser', userId);
13932
- const { data } = await client.http.post(`api/v4/me/flags/${encodeURIComponent(userId)}`);
13933
- const payload = prepareUserPayload(data);
13934
- if (client.cache) {
13935
- ingestInCache(payload);
13936
- }
13937
- fireEvent('user.flagged', data);
13938
- return !!payload;
13948
+ const filter = (payload) => {
13949
+ const unpackedPayload = prepareEventPayload(payload);
13950
+ if (!client.cache) {
13951
+ callback(unpackedPayload.events[0]);
13952
+ }
13953
+ else {
13954
+ ingestInCache(unpackedPayload);
13955
+ const event = pullFromCache([
13956
+ 'event',
13957
+ 'get',
13958
+ unpackedPayload.events[0].eventId,
13959
+ ]);
13960
+ callback(event.data);
13961
+ }
13962
+ };
13963
+ return createEventSubscriber(client, event, event, filter);
13964
+ };
13965
+
13966
+ const createEventResponseSubscriber = (event, callback) => {
13967
+ const client = getActiveClient();
13968
+ const filter = (payload) => {
13969
+ const unpackedPayload = prepareEventResponsePayload(payload);
13970
+ if (!client.cache) {
13971
+ callback(unpackedPayload);
13972
+ }
13973
+ else {
13974
+ ingestInCache(unpackedPayload.event[0]);
13975
+ const eventResponse = pullFromCache([
13976
+ 'eventResponse',
13977
+ 'get',
13978
+ payload.eventResponses[0].eventId,
13979
+ ]);
13980
+ callback(eventResponse.data);
13981
+ }
13982
+ };
13983
+ return createEventSubscriber(client, event, event, filter);
13939
13984
  };
13940
- /* end_public_function */
13941
13985
 
13942
13986
  /* begin_public_function
13943
- id: user.unflag
13987
+ id: event.rsvp.me
13944
13988
  */
13945
13989
  /**
13946
13990
  * ```js
13947
- * import { UserRepository } from '@amityco/ts-sdk'
13948
- * const unflagged = await UserRepository.unflagUser('post', postId)
13991
+ * import { event } from '@amityco/ts-sdk'
13992
+ * const myRSVP = await event.getMyRSVP()
13949
13993
  * ```
13950
13994
  *
13951
- * @param userId The ID of the user to unflag
13952
- * @returns the deleted report result
13995
+ * Joins a {@link Amity.EventResponse} object
13953
13996
  *
13954
- * @category User API
13997
+ * @param eventId the {@link Amity.EventResponse} to get RSVP for
13998
+ * @returns A success boolean if the {@link Amity.EventResponse} RSVP was retrieved
13999
+ *
14000
+ * @category Event API
13955
14001
  * @async
13956
- * */
13957
- const unflagUser = async (userId) => {
14002
+ */
14003
+ const getMyRSVP = async (eventId) => {
13958
14004
  const client = getActiveClient();
13959
- client.log('user/unflag', userId);
13960
- const { data } = await client.http.delete(`/api/v4/me/flags/${encodeURIComponent(userId)}`);
13961
- const payload = prepareUserPayload(data);
13962
- if (client.cache) {
13963
- ingestInCache(payload);
13964
- }
13965
- fireEvent('user.unflagged', data);
13966
- return !!payload;
14005
+ client.log('event/getMyRSVP', eventId);
14006
+ const { data: payload } = await client.http.get(`/api/v1/events/${eventId}/me/rsvp`);
14007
+ const data = prepareEventResponsePayload(payload);
14008
+ const cachedAt = client.cache && Date.now();
14009
+ if (client.cache)
14010
+ ingestInCache(data, { cachedAt });
14011
+ return {
14012
+ data: eventResponseLinkedObject(data.eventResponses[0]),
14013
+ cachedAt,
14014
+ };
13967
14015
  };
13968
14016
  /* end_public_function */
13969
-
13970
- /* begin_public_function
13971
- id: user.check_flag_by_me
13972
- */
13973
14017
  /**
13974
14018
  * ```js
13975
- * import { UserRepository } from '@amityco/ts-sdk'
13976
- * const isFlagged = await UserRepository.isUserFlaggedByMe(postId)
14019
+ * import { event } from '@amityco/ts-sdk'
14020
+ * const event = event.getMyRSVP.locally(eventId)
13977
14021
  * ```
13978
14022
  *
13979
- * @param userId The ID of the thing to check a report to.
13980
- * @returns `true` if the report is created by me, `false` if doesn't.
14023
+ * Fetches a {@link Amity.EventResponse} object in cache
13981
14024
  *
13982
- * @category Report API
13983
- * @async
13984
- * */
13985
- const isUserFlaggedByMe = async (userId) => {
14025
+ * @param eventId the ID of the {@link Amity.EventResponse} to fetch
14026
+ * @returns the associated {@link Amity.EventResponse} object
14027
+ *
14028
+ * @category Event API
14029
+ */
14030
+ getMyRSVP.locally = (eventId) => {
13986
14031
  const client = getActiveClient();
13987
- client.log('user/isUserFlaggedByMe', userId);
13988
- const { data: { isFlagByMe }, } = await client.http.get(`/api/v3/users/${userId}/isFlagByMe`);
13989
- return isFlagByMe;
14032
+ client.log('event/getMyRSVP.locally', eventId);
14033
+ if (!client.cache)
14034
+ return;
14035
+ const cache = pullFromCache(['event', 'getMyRSVP', eventId]);
14036
+ if (!cache)
14037
+ return;
14038
+ return {
14039
+ data: cache.data,
14040
+ cachedAt: cache.cachedAt,
14041
+ };
13990
14042
  };
13991
- /* end_public_function */
14043
+
14044
+ var EventActionsEnum;
14045
+ (function (EventActionsEnum) {
14046
+ EventActionsEnum["OnEventCreated"] = "onEventCreated";
14047
+ EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
14048
+ EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
14049
+ EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
14050
+ EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
14051
+ })(EventActionsEnum || (EventActionsEnum = {}));
14052
+
14053
+ class RSVPPaginationController extends PaginationController {
14054
+ async getRequest(queryParams, token) {
14055
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, eventId } = queryParams, params = __rest(queryParams, ["limit", "eventId"]);
14056
+ const options = token ? { token } : { limit };
14057
+ const { data: response } = await this.http.get(`/api/v1/events/${eventId}/rsvp`, { params: Object.assign(Object.assign({}, params), { options }) });
14058
+ return response;
14059
+ }
14060
+ }
14061
+
14062
+ class RSVPQueryStreamController extends QueryStreamController {
14063
+ constructor(query, cacheKey, notifyChange, preparePayload) {
14064
+ super(query, cacheKey);
14065
+ this.notifyChange = notifyChange;
14066
+ this.preparePayload = preparePayload;
14067
+ }
14068
+ async saveToMainDB(response) {
14069
+ const processedPayload = this.preparePayload(response);
14070
+ const client = getActiveClient();
14071
+ const cachedAt = client.cache && Date.now();
14072
+ if (client.cache)
14073
+ ingestInCache({ eventResponses: [processedPayload] }, { cachedAt });
14074
+ }
14075
+ appendToQueryStream(response, direction, refresh = false) {
14076
+ var _a, _b;
14077
+ if (refresh) {
14078
+ pushToCache(this.cacheKey, {
14079
+ data: response.eventResponses.map(getResolver('eventResponse')),
14080
+ });
14081
+ }
14082
+ else {
14083
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
14084
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
14085
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
14086
+ ...new Set([...events, ...response.eventResponses.map(getResolver('eventResponse'))]),
14087
+ ] }));
14088
+ }
14089
+ }
14090
+ reactor(action) {
14091
+ return (event) => {
14092
+ var _a;
14093
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
14094
+ if (!collection)
14095
+ return;
14096
+ if (action === EventActionsEnum.OnRSVPCreated) {
14097
+ const client = getActiveClient();
14098
+ if (client.userId !== event.userId)
14099
+ return;
14100
+ collection.data = [...new Set([event.eventId, ...collection.data])];
14101
+ }
14102
+ if (action === EventActionsEnum.OnEventDeleted) {
14103
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
14104
+ }
14105
+ pushToCache(this.cacheKey, collection);
14106
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
14107
+ };
14108
+ }
14109
+ subscribeRTE(createSubscriber) {
14110
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
14111
+ }
14112
+ }
13992
14113
 
13993
14114
  /**
13994
14115
  * ```js
13995
- * import { onUserUpdated } from '@amityco/ts-sdk'
13996
- * const dispose = onUserUpdated(user => {
14116
+ * import { EventRepository } from '@amityco/ts-sdk'
14117
+ * const dispose = EventRepository.onEventCreated(event => {
13997
14118
  * // ...
13998
14119
  * })
13999
14120
  * ```
14000
14121
  *
14001
- * Fired when a {@link Amity.InternalUser} has been updated
14122
+ * Fired when an RSVP response for a {@link Amity.Event} has been created
14002
14123
  *
14003
14124
  * @param callback The function to call when the event was fired
14004
14125
  * @returns an {@link Amity.Unsubscriber} function to stop listening
14005
14126
  *
14006
- * @category User Events
14127
+ * @category Event Events
14007
14128
  */
14008
- const onUserUpdated = (callback) => createUserEventSubscriber('user.updated', callback);
14129
+ const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
14009
14130
 
14010
14131
  /**
14011
14132
  * ```js
14012
- * import { onUserFlagged } from '@amityco/ts-sdk'
14013
- * const dispose = onUserFlagged(user => {
14133
+ * import { EventRepository } from '@amityco/ts-sdk'
14134
+ * const dispose = EventRepository.onEventUpdated(event => {
14014
14135
  * // ...
14015
14136
  * })
14016
14137
  * ```
14017
14138
  *
14018
- * Fired when a {@link Amity.InternalUser} has been flagged
14139
+ * Fired when a {@link Amity.Event} has been updated
14019
14140
  *
14020
14141
  * @param callback The function to call when the event was fired
14021
14142
  * @returns an {@link Amity.Unsubscriber} function to stop listening
14022
14143
  *
14023
- * @category User Events
14144
+ * @category Event Events
14024
14145
  */
14025
- const onUserFlagged = (callback) => createUserEventSubscriber('user.flagged', callback);
14146
+ const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
14026
14147
 
14027
14148
  /**
14028
14149
  * ```js
14029
- * import { onUserUnflagged } from '@amityco/ts-sdk'
14030
- * const dispose = onUserUnflagged(user => {
14150
+ * import { EventRepository } from '@amityco/ts-sdk'
14151
+ * const dispose = EventRepository.onEventDeleted(event => {
14031
14152
  * // ...
14032
14153
  * })
14033
14154
  * ```
14034
14155
  *
14035
- * Fired when a flag has been removed from a {@link Amity.InternalUser}
14156
+ * Fired when a {@link Amity.Event} has been deleted
14036
14157
  *
14037
14158
  * @param callback The function to call when the event was fired
14038
14159
  * @returns an {@link Amity.Unsubscriber} function to stop listening
14039
14160
  *
14040
- * @category User Events
14161
+ * @category Event Events
14041
14162
  */
14042
- const onUserUnflagged = (callback) => createUserEventSubscriber('user.unflagged', callback);
14163
+ const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
14043
14164
 
14044
14165
  /**
14045
14166
  * ```js
14046
- * import { onUserFlagCleared } from '@amityco/ts-sdk'
14047
- * const dispose = onUserFlagCleared(user => {
14167
+ * import { EventRepository } from '@amityco/ts-sdk'
14168
+ * const dispose = EventRepository.onLocalEventCreated(event => {
14048
14169
  * // ...
14049
14170
  * })
14050
14171
  * ```
14051
14172
  *
14052
- * Fired when flags have been cleared for a {@link Amity.InternalUser}
14173
+ * Fired when a {@link Amity.Event} has been created
14053
14174
  *
14054
14175
  * @param callback The function to call when the event was fired
14055
14176
  * @returns an {@link Amity.Unsubscriber} function to stop listening
14056
14177
  *
14057
- * @category User Events
14178
+ * @category Event Events
14058
14179
  */
14059
- const onUserFlagCleared = (callback) => createUserEventSubscriber('user.flagCleared', callback);
14180
+ const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
14060
14181
 
14061
14182
  /**
14062
14183
  * ```js
14063
- * import { onUserFetched } from '@amityco/ts-sdk'
14064
- * const dispose = onUserFetched(user => {
14184
+ * import { EventRepository } from '@amityco/ts-sdk'
14185
+ * const dispose = EventRepository.onLocalEventUpdated(event => {
14065
14186
  * // ...
14066
14187
  * })
14067
14188
  * ```
14068
14189
  *
14069
- * Fired when a {@link Amity.InternalUser} has been fetched
14190
+ * Fired when a {@link Amity.Event} has been updated
14070
14191
  *
14071
14192
  * @param callback The function to call when the event was fired
14072
14193
  * @returns an {@link Amity.Unsubscriber} function to stop listening
14073
14194
  *
14074
- * @category User Events
14195
+ * @category Event Events
14075
14196
  */
14076
- const onUserFetched = (callback) => createUserEventSubscriber('user.fetched', callback);
14197
+ const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
14077
14198
 
14078
14199
  /**
14079
14200
  * ```js
14080
- * import { getUser } from '~/user/api'
14081
- * const { data: user } = await getUser('foobar')
14201
+ * import { EventRepository } from '@amityco/ts-sdk'
14202
+ * const dispose = EventRepository.onLocalEventDeleted(event => {
14203
+ * // ...
14204
+ * })
14082
14205
  * ```
14083
14206
  *
14084
- * Fetches a {@link Amity.User} object
14207
+ * Fired when a {@link Amity.Event} has been deleted
14085
14208
  *
14086
- * @param userId the ID of the {@link Amity.User} to fetch
14087
- * @returns the associated {@link Amity.User} object
14209
+ * @param callback The function to call when the event was fired
14210
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
14088
14211
  *
14089
- * @category Private
14090
- * @async
14212
+ * @category Event Events
14091
14213
  */
14092
- const getUser$1 = async (userId) => {
14093
- const client = getActiveClient();
14094
- client.log('user/getUser', userId);
14095
- isInTombstone('user', userId);
14096
- try {
14097
- const { data } = await client.http.get(`/api/v3/users/${encodeURIComponent(userId)}`);
14098
- const cachedAt = client.cache && Date.now();
14099
- const payload = prepareUserPayload(data);
14100
- if (client.cache)
14101
- ingestInCache(payload, { cachedAt });
14102
- fireEvent('user.fetched', data);
14103
- return {
14104
- data: payload.users.find(user => user.userId === userId),
14105
- cachedAt,
14106
- };
14107
- }
14108
- catch (error) {
14109
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
14110
- pushToTombstone('user', userId);
14111
- }
14112
- throw error;
14113
- }
14114
- };
14214
+ const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
14215
+
14115
14216
  /**
14116
14217
  * ```js
14117
- * import { getUser } from '@amityco/ts-sdk'
14118
- * const { data: user } = getUser.locally('foobar')
14218
+ * import { EventRepository } from '@amityco/ts-sdk'
14219
+ * const dispose = EventRepository.onRSVPCreated(event => {
14220
+ * // ...
14221
+ * })
14119
14222
  * ```
14120
14223
  *
14121
- * Fetches a {@link Amity.User} object from cache
14224
+ * Fired when a {@link Amity.Event} has been created
14122
14225
  *
14123
- * @param userId the ID of the {@link Amity.User} to fetch
14124
- * @returns the associated {@link Amity.User} object
14226
+ * @param callback The function to call when the event was fired
14227
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
14125
14228
  *
14126
- * @category User API
14229
+ * @category Event Events
14127
14230
  */
14128
- getUser$1.locally = (userId) => {
14129
- const client = getActiveClient();
14130
- client.log('user/getUser.locally', userId);
14131
- if (!client.cache)
14132
- return;
14133
- const cached = pullFromCache(['user', 'get', userId]);
14134
- if (!cached)
14135
- return;
14136
- return {
14137
- data: cached.data,
14138
- cachedAt: cached.cachedAt,
14139
- };
14140
- };
14231
+ const onRSVPCreated = (callback) => createEventResponseSubscriber('event.rsvp.created', callback);
14141
14232
 
14142
- /* begin_public_function
14143
- id: user.get
14144
- */
14145
14233
  /**
14146
14234
  * ```js
14147
- * import { liveUser } from '@amityco/ts-sdk';
14235
+ * import { EventRepository } from '@amityco/ts-sdk'
14236
+ * const dispose = EventRepository.onRSVPUpdated(event => {
14237
+ * // ...
14238
+ * })
14239
+ * ```
14148
14240
  *
14149
- * let user;
14241
+ * Fired when a {@link Amity.InternalEventResponse} has been updated
14150
14242
  *
14151
- * const unsubscribe = liveUser(userId, response => {
14152
- * user = response.data;
14153
- * });
14243
+ * @param callback The function to call when the event was fired
14244
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
14245
+ *
14246
+ * @category Event Events
14247
+ */
14248
+ const onRSVPUpdated = (callback) => createEventResponseSubscriber('event.rsvp.updated', callback);
14249
+
14250
+ /**
14251
+ * ```js
14252
+ * import { EventRepository } from '@amityco/ts-sdk'
14253
+ * const dispose = EventRepository.onLocalRSVPCreated(event => {
14254
+ * // ...
14255
+ * })
14154
14256
  * ```
14155
14257
  *
14156
- * Observe all mutation on a given {@link Amity.User}
14258
+ * Fired when an RSVP response for a {@link Amity.EventResponse} has been created
14157
14259
  *
14158
- * @param userId the ID of the user to observe
14159
- * @param callback the function to call when new data are available
14160
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the user
14260
+ * @param callback The function to call when the event was fired
14261
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
14161
14262
  *
14162
- * @category Message Live Object
14263
+ * @category Event Events
14163
14264
  */
14164
- const getUser = (userId, callback) => {
14165
- const reactor = (response) => {
14166
- return callback(Object.assign(Object.assign({}, response), { data: response.data ? LinkedObject.user(response.data) : response.data }));
14167
- };
14168
- return liveObject(userId, reactor, 'userId', getUser$1, [
14169
- onUserFetched,
14170
- onUserUpdated,
14171
- onUserDeleted$2,
14172
- onUserFlagged,
14173
- onUserUnflagged,
14174
- onUserFlagCleared,
14175
- ]);
14176
- };
14177
- /* end_public_function */
14178
-
14179
- class UserPaginationController extends PaginationController {
14180
- async getRequest(queryParams, token) {
14181
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
14182
- const options = token ? { token } : { limit };
14183
- const { data: queryResponse } = await this.http.get(`/api/v3/users`, {
14184
- params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
14185
- });
14186
- return queryResponse;
14187
- }
14188
- }
14189
-
14190
- class UserQueryStreamController extends QueryStreamController {
14191
- constructor(query, cacheKey, notifyChange, preparePayload) {
14192
- super(query, cacheKey);
14193
- this.notifyChange = notifyChange;
14194
- this.preparePayload = preparePayload;
14195
- }
14196
- async saveToMainDB(response) {
14197
- const processedPayload = await this.preparePayload(response);
14198
- const client = getActiveClient();
14199
- const cachedAt = client.cache && Date.now();
14200
- if (client.cache) {
14201
- ingestInCache(processedPayload, { cachedAt });
14202
- }
14203
- }
14204
- appendToQueryStream(response, direction, refresh = false) {
14205
- var _a, _b;
14206
- if (refresh) {
14207
- pushToCache(this.cacheKey, {
14208
- data: response.users.map(getResolver('user')),
14209
- });
14210
- }
14211
- else {
14212
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
14213
- const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
14214
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...users, ...response.users.map(getResolver('user'))])] }));
14215
- }
14216
- }
14217
- reactor(action) {
14218
- return (user) => {
14219
- var _a;
14220
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
14221
- if (!collection)
14222
- return;
14223
- /*
14224
- * Simply update a collection and let responder decide what to do with data
14225
- */
14226
- collection.data = [...new Set([user.userId, ...collection.data])];
14227
- pushToCache(this.cacheKey, collection);
14228
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
14229
- };
14230
- }
14231
- subscribeRTE(createSubscriber) {
14232
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
14233
- }
14234
- }
14265
+ const onLocalRSVPCreated = (callback) => createEventResponseSubscriber('local.rsvp.created', callback);
14235
14266
 
14236
- var EnumUserActions;
14237
- (function (EnumUserActions) {
14238
- EnumUserActions["OnUserDeleted"] = "onUserDeleted";
14239
- EnumUserActions["OnUserUpdated"] = "onUserUpdated";
14240
- EnumUserActions["OnUserFlagged"] = "onUserFlagged";
14241
- EnumUserActions["OnUserUnflagged"] = "onUserUnflagged";
14242
- EnumUserActions["OnUserFlagCleared"] = "onUserFlagCleared";
14243
- })(EnumUserActions || (EnumUserActions = {}));
14267
+ /**
14268
+ * ```js
14269
+ * import { EventRepository } from '@amityco/ts-sdk'
14270
+ * const dispose = EventRepository.onLocalEventUpdated(event => {
14271
+ * // ...
14272
+ * })
14273
+ * ```
14274
+ *
14275
+ * Fired when an RSVP response for a {@link Amity.EventResponse} has been updated
14276
+ *
14277
+ * @param callback The function to call when the event was fired
14278
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
14279
+ *
14280
+ * @category Event Events
14281
+ */
14282
+ const onLocalRSVPUpdated = (callback) => createEventResponseSubscriber('local.rsvp.updated', callback);
14244
14283
 
14245
- class UserLiveCollectionController extends LiveCollectionController {
14284
+ class RSVPLiveCollectionController extends LiveCollectionController {
14246
14285
  constructor(query, callback) {
14247
14286
  const queryStreamId = hash__default["default"](query);
14248
- const cacheKey = ['user', 'collection', queryStreamId];
14249
- const paginationController = new UserPaginationController(query);
14287
+ const cacheKey = ['eventResponse', 'collection', queryStreamId];
14288
+ const paginationController = new RSVPPaginationController(query);
14250
14289
  super(paginationController, queryStreamId, cacheKey, callback);
14251
14290
  this.query = query;
14252
- this.queryStreamController = new UserQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareUserPayload);
14291
+ this.queryStreamController = new RSVPQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventResponsePayload);
14253
14292
  this.callback = callback.bind(this);
14254
14293
  this.loadPage({ initial: true });
14255
14294
  }
14256
14295
  setup() {
14257
14296
  var _a;
14258
14297
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
14259
- if (!collection) {
14260
- pushToCache(this.cacheKey, {
14261
- data: [],
14262
- params: {},
14263
- });
14264
- }
14298
+ if (!collection)
14299
+ pushToCache(this.cacheKey, { data: [], params: this.query });
14265
14300
  }
14266
14301
  async persistModel(queryPayload) {
14267
14302
  await this.queryStreamController.saveToMainDB(queryPayload);
@@ -14271,11 +14306,10 @@ class UserLiveCollectionController extends LiveCollectionController {
14271
14306
  }
14272
14307
  startSubscription() {
14273
14308
  return this.queryStreamController.subscribeRTE([
14274
- { fn: onUserDeleted$2, action: EnumUserActions.OnUserDeleted },
14275
- { fn: onUserUpdated, action: EnumUserActions.OnUserUpdated },
14276
- { fn: onUserFlagged, action: EnumUserActions.OnUserFlagged },
14277
- { fn: onUserUnflagged, action: EnumUserActions.OnUserUnflagged },
14278
- { fn: onUserFlagCleared, action: EnumUserActions.OnUserFlagCleared },
14309
+ { fn: onRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
14310
+ { fn: onRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
14311
+ { fn: onLocalRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
14312
+ { fn: onLocalRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
14279
14313
  ]);
14280
14314
  }
14281
14315
  notifyChange({ origin, loading, error }) {
@@ -14283,57 +14317,649 @@ class UserLiveCollectionController extends LiveCollectionController {
14283
14317
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
14284
14318
  if (!collection)
14285
14319
  return;
14286
- const data = this.applyFilter((_b = collection.data
14287
- .map(id => pullFromCache(['user', 'get', id]))
14320
+ const data = (_b = collection.data
14321
+ .map(eventId => pullFromCache(['eventResponse', 'get', eventId]))
14288
14322
  .filter(isNonNullable)
14289
- .map(({ data }) => data)
14290
- .map(LinkedObject.user)) !== null && _b !== void 0 ? _b : []);
14291
- if (!this.shouldNotify(data) && origin === 'event')
14323
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : [].map(eventResponseLinkedObject);
14324
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
14292
14325
  return;
14293
14326
  this.callback({
14294
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
14295
14327
  data,
14296
- hasNextPage: !!this.paginationController.getNextToken(),
14297
- loading,
14298
14328
  error,
14329
+ loading,
14330
+ hasNextPage: !!this.paginationController.getNextToken(),
14331
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
14299
14332
  });
14300
14333
  }
14301
- applyFilter(data) {
14302
- let users = data;
14303
- const sortFn = (() => {
14304
- switch (this.query.sortBy) {
14305
- case 'firstCreated':
14306
- return sortByFirstCreated;
14307
- case 'lastCreated':
14308
- return sortByLastCreated;
14309
- default:
14310
- return sortByLastCreated;
14311
- }
14312
- })();
14313
- users = users.sort(sortFn);
14314
- if (this.query.filter === 'flagged') {
14315
- users = users.filter(user => !!user.hashFlag);
14316
- }
14317
- users = users.filter(user => user.isDeleted == null || user.isDeleted === false);
14318
- return users;
14319
- }
14320
14334
  }
14321
14335
 
14322
- /* begin_public_function
14323
- id: user.query
14324
- */
14325
14336
  /**
14326
- * ```js
14327
- * import { liveUsers } from '@amityco/ts-sdk'
14337
+ * Get events
14328
14338
  *
14329
- * let users = []
14330
- * const unsub = liveUsers({}, response => merge(users, response.data))
14331
- * ```
14339
+ * @param params the query parameters
14340
+ * @param callback the callback to be called when the events are updated
14341
+ * @returns events
14332
14342
  *
14333
- * Observe all mutations on a list of {@link Amity.User}s
14343
+ * @category RSVP Live Collection
14334
14344
  *
14335
- * @param params for querying users
14336
- * @param callback the function to call when new data are available
14345
+ */
14346
+ const getRSVPs = (params, callback, config) => {
14347
+ const { log, cache } = getActiveClient();
14348
+ if (!cache)
14349
+ console.log(ENABLE_CACHE_MESSAGE);
14350
+ const timestamp = Date.now();
14351
+ log(`getRSVPs: (tmpid: ${timestamp}) > listen`);
14352
+ const rsvpLiveCollection = new RSVPLiveCollectionController(params, callback);
14353
+ const disposers = rsvpLiveCollection.startSubscription();
14354
+ const cacheKey = rsvpLiveCollection.getCacheKey();
14355
+ disposers.push(() => dropFromCache(cacheKey));
14356
+ return () => {
14357
+ log(`getRSVPs (tmpid: ${timestamp}) > dispose`);
14358
+ disposers.forEach(fn => fn());
14359
+ };
14360
+ };
14361
+
14362
+ const eventLinkedObject = (event) => {
14363
+ return Object.assign(Object.assign({}, event), { get creator() {
14364
+ const cacheData = pullFromCache(['user', 'get', event.userId]);
14365
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
14366
+ return;
14367
+ return userLinkedObject(cacheData.data);
14368
+ },
14369
+ get targetCommunity() {
14370
+ if (!event.originId)
14371
+ return;
14372
+ const cacheData = pullFromCache(['community', 'get', event.originId]);
14373
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
14374
+ return;
14375
+ return communityLinkedObject(cacheData.data);
14376
+ },
14377
+ get coverImage() {
14378
+ if (!event.coverImageFileId)
14379
+ return;
14380
+ const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
14381
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
14382
+ return;
14383
+ return cacheData.data;
14384
+ },
14385
+ get post() {
14386
+ if (!event.postId)
14387
+ return;
14388
+ const cacheData = pullFromCache(['post', 'get', event.postId]);
14389
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
14390
+ return;
14391
+ return postLinkedObject(cacheData.data);
14392
+ },
14393
+ get room() {
14394
+ var _a;
14395
+ if (!event.postId)
14396
+ return;
14397
+ const cacheData = (_a = queryCache(['room', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(room => room.data.referenceId === event.postId);
14398
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.length) || !cacheData[0].data)
14399
+ return;
14400
+ return roomLinkedObject(cacheData[0].data);
14401
+ }, createRSVP: async (status) => {
14402
+ const { data } = await createRSVP(event.eventId, status);
14403
+ return data;
14404
+ }, updateRSVP: async (status) => {
14405
+ const { data } = await updateRSVP(event.eventId, status);
14406
+ return data;
14407
+ }, getMyRSVP: async () => {
14408
+ const { data } = await getMyRSVP(event.eventId);
14409
+ return data;
14410
+ }, getRSVPs: (params, callback) => {
14411
+ return getRSVPs(Object.assign({ eventId: event.eventId }, params), callback);
14412
+ } });
14413
+ };
14414
+
14415
+ const LinkedObject = {
14416
+ ad: adLinkedObject,
14417
+ comment: commentLinkedObject,
14418
+ post: postLinkedObject,
14419
+ user: userLinkedObject,
14420
+ category: categoryLinkedObject,
14421
+ stream: streamLinkedObject,
14422
+ story: storyLinkedObject,
14423
+ storyTarget: storyTargetLinkedObject,
14424
+ message: messageLinkedObject,
14425
+ reactor: reactorLinkedObject,
14426
+ channel: channelLinkedObject,
14427
+ pinnedPost: pinnedPostLinkedObject,
14428
+ notificationTray: notificationTrayLinkedObject,
14429
+ community: communityLinkedObject,
14430
+ invitation: invitationLinkedObject,
14431
+ joinRequest: joinRequestLinkedObject,
14432
+ channelMember: channelMemberLinkedObject,
14433
+ room: roomLinkedObject,
14434
+ event: eventLinkedObject,
14435
+ eventResponse: eventResponseLinkedObject,
14436
+ };
14437
+
14438
+ /* begin_public_function
14439
+ id: user.get_by_ids
14440
+ */
14441
+ /**
14442
+ * ```js
14443
+ * import { getUsers } from '@amityco/ts-sdk'
14444
+ * const { data: users } = await getUsers(['foo', 'bar'])
14445
+ * ```
14446
+ *
14447
+ * Fetches a collection of {@link Amity.User} objects
14448
+ *
14449
+ * @param userIds the IDs of the {@link Amity.User} to fetch
14450
+ * @returns the associated collection of {@link Amity.User} objects
14451
+ *
14452
+ * @category User API
14453
+ * @async
14454
+ */
14455
+ const getUserByIds = async (userIds) => {
14456
+ const client = getActiveClient();
14457
+ client.log('user/getUsers', userIds);
14458
+ const encodedUserIds = userIds.map(userId => encodeURIComponent(userId));
14459
+ // API-FIX: endpoint should not be /list, parameters should be querystring.
14460
+ const { data } = await client.http.get(`/api/v3/users/list`, {
14461
+ params: { userIds: encodedUserIds },
14462
+ });
14463
+ const payload = prepareUserPayload(data);
14464
+ const cachedAt = client.cache && Date.now();
14465
+ if (client.cache)
14466
+ ingestInCache(payload, { cachedAt });
14467
+ fireEvent('user.fetched', data);
14468
+ return {
14469
+ data: payload.users.map(user => LinkedObject.user(user)),
14470
+ cachedAt,
14471
+ };
14472
+ };
14473
+ /* end_public_function */
14474
+ /**
14475
+ * ```js
14476
+ * import { getUsers } from '@amityco/ts-sdk'
14477
+ * const { data: users } = getUsers.locally!(['foo', 'bar'])
14478
+ * ```
14479
+ *
14480
+ * Fetches a collection of {@link Amity.User} objects from cache
14481
+ *
14482
+ * @param userIds the IDs of the {@link Amity.User} to fetch
14483
+ * @returns the associated collection of {@link Amity.User} objects
14484
+ *
14485
+ * @category User API
14486
+ */
14487
+ getUserByIds.locally = (userIds) => {
14488
+ var _a;
14489
+ const client = getActiveClient();
14490
+ client.log('user/getUsers.locally', userIds);
14491
+ if (!client.cache)
14492
+ return;
14493
+ const cached = userIds
14494
+ .map(userId => pullFromCache(['user', 'get', userId]))
14495
+ .filter(Boolean);
14496
+ const users = cached.map(({ data }) => LinkedObject.user(data));
14497
+ const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
14498
+ if ((cached === null || cached === void 0 ? void 0 : cached.length) < userIds.length)
14499
+ return;
14500
+ return {
14501
+ data: users,
14502
+ cachedAt: oldest.cachedAt,
14503
+ };
14504
+ };
14505
+
14506
+ /* begin_public_function
14507
+ id: client.update_user
14508
+ */
14509
+ /**
14510
+ * ```js
14511
+ * import { updateUser } from '@amityco/ts-sdk'
14512
+ * const updated = await updateUser(userId, { displayName: 'foobar' })
14513
+ * ```
14514
+ *
14515
+ * Updates an {@link Amity.User}
14516
+ *
14517
+ * @param userId The ID of the {@link Amity.User} to update
14518
+ * @param patch The patch data to apply
14519
+ * @returns the updated {@link Amity.User} object
14520
+ *
14521
+ * @category User API
14522
+ * @async
14523
+ */
14524
+ const updateUser = async (userId, patch) => {
14525
+ const client = getActiveClient();
14526
+ client.log('user/updateUser', userId, patch);
14527
+ const { data } = await client.http.put(`/api/v3/users/`, Object.assign(Object.assign({ userId }, patch), { createNewUserWhenNotFound: false }));
14528
+ const payload = prepareUserPayload(data);
14529
+ const cachedAt = client.cache && Date.now();
14530
+ if (client.cache)
14531
+ ingestInCache(payload, { cachedAt });
14532
+ fireEvent('user.updated', data);
14533
+ return {
14534
+ data: payload.users.find(user => user.userId === userId),
14535
+ cachedAt,
14536
+ };
14537
+ };
14538
+ /* end_public_function */
14539
+
14540
+ /* begin_public_function
14541
+ id: user.flag
14542
+ */
14543
+ /**
14544
+ * ```js
14545
+ * import { UserRepository } from '@amityco/ts-sdk'
14546
+ * const flagged = await UserRepository.flagUser('userId')
14547
+ * ```
14548
+ *
14549
+ * @param userId The ID of the user to add a be flagged
14550
+ * @returns the created report result
14551
+ *
14552
+ * @category User API
14553
+ * @async
14554
+ * */
14555
+ const flagUser = async (userId) => {
14556
+ const client = getActiveClient();
14557
+ client.log('user/flagUser', userId);
14558
+ const { data } = await client.http.post(`api/v4/me/flags/${encodeURIComponent(userId)}`);
14559
+ const payload = prepareUserPayload(data);
14560
+ if (client.cache) {
14561
+ ingestInCache(payload);
14562
+ }
14563
+ fireEvent('user.flagged', data);
14564
+ return !!payload;
14565
+ };
14566
+ /* end_public_function */
14567
+
14568
+ /* begin_public_function
14569
+ id: user.unflag
14570
+ */
14571
+ /**
14572
+ * ```js
14573
+ * import { UserRepository } from '@amityco/ts-sdk'
14574
+ * const unflagged = await UserRepository.unflagUser('post', postId)
14575
+ * ```
14576
+ *
14577
+ * @param userId The ID of the user to unflag
14578
+ * @returns the deleted report result
14579
+ *
14580
+ * @category User API
14581
+ * @async
14582
+ * */
14583
+ const unflagUser = async (userId) => {
14584
+ const client = getActiveClient();
14585
+ client.log('user/unflag', userId);
14586
+ const { data } = await client.http.delete(`/api/v4/me/flags/${encodeURIComponent(userId)}`);
14587
+ const payload = prepareUserPayload(data);
14588
+ if (client.cache) {
14589
+ ingestInCache(payload);
14590
+ }
14591
+ fireEvent('user.unflagged', data);
14592
+ return !!payload;
14593
+ };
14594
+ /* end_public_function */
14595
+
14596
+ /* begin_public_function
14597
+ id: user.check_flag_by_me
14598
+ */
14599
+ /**
14600
+ * ```js
14601
+ * import { UserRepository } from '@amityco/ts-sdk'
14602
+ * const isFlagged = await UserRepository.isUserFlaggedByMe(postId)
14603
+ * ```
14604
+ *
14605
+ * @param userId The ID of the thing to check a report to.
14606
+ * @returns `true` if the report is created by me, `false` if doesn't.
14607
+ *
14608
+ * @category Report API
14609
+ * @async
14610
+ * */
14611
+ const isUserFlaggedByMe = async (userId) => {
14612
+ const client = getActiveClient();
14613
+ client.log('user/isUserFlaggedByMe', userId);
14614
+ const { data: { isFlagByMe }, } = await client.http.get(`/api/v3/users/${userId}/isFlagByMe`);
14615
+ return isFlagByMe;
14616
+ };
14617
+ /* end_public_function */
14618
+
14619
+ /**
14620
+ * ```js
14621
+ * import { onUserUpdated } from '@amityco/ts-sdk'
14622
+ * const dispose = onUserUpdated(user => {
14623
+ * // ...
14624
+ * })
14625
+ * ```
14626
+ *
14627
+ * Fired when a {@link Amity.InternalUser} has been updated
14628
+ *
14629
+ * @param callback The function to call when the event was fired
14630
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
14631
+ *
14632
+ * @category User Events
14633
+ */
14634
+ const onUserUpdated = (callback) => createUserEventSubscriber('user.updated', callback);
14635
+
14636
+ /**
14637
+ * ```js
14638
+ * import { onUserFlagged } from '@amityco/ts-sdk'
14639
+ * const dispose = onUserFlagged(user => {
14640
+ * // ...
14641
+ * })
14642
+ * ```
14643
+ *
14644
+ * Fired when a {@link Amity.InternalUser} has been flagged
14645
+ *
14646
+ * @param callback The function to call when the event was fired
14647
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
14648
+ *
14649
+ * @category User Events
14650
+ */
14651
+ const onUserFlagged = (callback) => createUserEventSubscriber('user.flagged', callback);
14652
+
14653
+ /**
14654
+ * ```js
14655
+ * import { onUserUnflagged } from '@amityco/ts-sdk'
14656
+ * const dispose = onUserUnflagged(user => {
14657
+ * // ...
14658
+ * })
14659
+ * ```
14660
+ *
14661
+ * Fired when a flag has been removed from a {@link Amity.InternalUser}
14662
+ *
14663
+ * @param callback The function to call when the event was fired
14664
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
14665
+ *
14666
+ * @category User Events
14667
+ */
14668
+ const onUserUnflagged = (callback) => createUserEventSubscriber('user.unflagged', callback);
14669
+
14670
+ /**
14671
+ * ```js
14672
+ * import { onUserFlagCleared } from '@amityco/ts-sdk'
14673
+ * const dispose = onUserFlagCleared(user => {
14674
+ * // ...
14675
+ * })
14676
+ * ```
14677
+ *
14678
+ * Fired when flags have been cleared for a {@link Amity.InternalUser}
14679
+ *
14680
+ * @param callback The function to call when the event was fired
14681
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
14682
+ *
14683
+ * @category User Events
14684
+ */
14685
+ const onUserFlagCleared = (callback) => createUserEventSubscriber('user.flagCleared', callback);
14686
+
14687
+ /**
14688
+ * ```js
14689
+ * import { onUserFetched } from '@amityco/ts-sdk'
14690
+ * const dispose = onUserFetched(user => {
14691
+ * // ...
14692
+ * })
14693
+ * ```
14694
+ *
14695
+ * Fired when a {@link Amity.InternalUser} has been fetched
14696
+ *
14697
+ * @param callback The function to call when the event was fired
14698
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
14699
+ *
14700
+ * @category User Events
14701
+ */
14702
+ const onUserFetched = (callback) => createUserEventSubscriber('user.fetched', callback);
14703
+
14704
+ /**
14705
+ * ```js
14706
+ * import { getUser } from '~/user/api'
14707
+ * const { data: user } = await getUser('foobar')
14708
+ * ```
14709
+ *
14710
+ * Fetches a {@link Amity.User} object
14711
+ *
14712
+ * @param userId the ID of the {@link Amity.User} to fetch
14713
+ * @returns the associated {@link Amity.User} object
14714
+ *
14715
+ * @category Private
14716
+ * @async
14717
+ */
14718
+ const getUser$1 = async (userId) => {
14719
+ const client = getActiveClient();
14720
+ client.log('user/getUser', userId);
14721
+ isInTombstone('user', userId);
14722
+ try {
14723
+ const { data } = await client.http.get(`/api/v3/users/${encodeURIComponent(userId)}`);
14724
+ const cachedAt = client.cache && Date.now();
14725
+ const payload = prepareUserPayload(data);
14726
+ if (client.cache)
14727
+ ingestInCache(payload, { cachedAt });
14728
+ fireEvent('user.fetched', data);
14729
+ return {
14730
+ data: payload.users.find(user => user.userId === userId),
14731
+ cachedAt,
14732
+ };
14733
+ }
14734
+ catch (error) {
14735
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
14736
+ pushToTombstone('user', userId);
14737
+ }
14738
+ throw error;
14739
+ }
14740
+ };
14741
+ /**
14742
+ * ```js
14743
+ * import { getUser } from '@amityco/ts-sdk'
14744
+ * const { data: user } = getUser.locally('foobar')
14745
+ * ```
14746
+ *
14747
+ * Fetches a {@link Amity.User} object from cache
14748
+ *
14749
+ * @param userId the ID of the {@link Amity.User} to fetch
14750
+ * @returns the associated {@link Amity.User} object
14751
+ *
14752
+ * @category User API
14753
+ */
14754
+ getUser$1.locally = (userId) => {
14755
+ const client = getActiveClient();
14756
+ client.log('user/getUser.locally', userId);
14757
+ if (!client.cache)
14758
+ return;
14759
+ const cached = pullFromCache(['user', 'get', userId]);
14760
+ if (!cached)
14761
+ return;
14762
+ return {
14763
+ data: cached.data,
14764
+ cachedAt: cached.cachedAt,
14765
+ };
14766
+ };
14767
+
14768
+ /* begin_public_function
14769
+ id: user.get
14770
+ */
14771
+ /**
14772
+ * ```js
14773
+ * import { liveUser } from '@amityco/ts-sdk';
14774
+ *
14775
+ * let user;
14776
+ *
14777
+ * const unsubscribe = liveUser(userId, response => {
14778
+ * user = response.data;
14779
+ * });
14780
+ * ```
14781
+ *
14782
+ * Observe all mutation on a given {@link Amity.User}
14783
+ *
14784
+ * @param userId the ID of the user to observe
14785
+ * @param callback the function to call when new data are available
14786
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the user
14787
+ *
14788
+ * @category Message Live Object
14789
+ */
14790
+ const getUser = (userId, callback) => {
14791
+ const reactor = (response) => {
14792
+ return callback(Object.assign(Object.assign({}, response), { data: response.data ? LinkedObject.user(response.data) : response.data }));
14793
+ };
14794
+ return liveObject(userId, reactor, 'userId', getUser$1, [
14795
+ onUserFetched,
14796
+ onUserUpdated,
14797
+ onUserDeleted$2,
14798
+ onUserFlagged,
14799
+ onUserUnflagged,
14800
+ onUserFlagCleared,
14801
+ ]);
14802
+ };
14803
+ /* end_public_function */
14804
+
14805
+ class UserPaginationController extends PaginationController {
14806
+ async getRequest(queryParams, token) {
14807
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
14808
+ const options = token ? { token } : { limit };
14809
+ const { data: queryResponse } = await this.http.get(`/api/v3/users`, {
14810
+ params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
14811
+ });
14812
+ return queryResponse;
14813
+ }
14814
+ }
14815
+
14816
+ class UserQueryStreamController extends QueryStreamController {
14817
+ constructor(query, cacheKey, notifyChange, preparePayload) {
14818
+ super(query, cacheKey);
14819
+ this.notifyChange = notifyChange;
14820
+ this.preparePayload = preparePayload;
14821
+ }
14822
+ async saveToMainDB(response) {
14823
+ const processedPayload = await this.preparePayload(response);
14824
+ const client = getActiveClient();
14825
+ const cachedAt = client.cache && Date.now();
14826
+ if (client.cache) {
14827
+ ingestInCache(processedPayload, { cachedAt });
14828
+ }
14829
+ }
14830
+ appendToQueryStream(response, direction, refresh = false) {
14831
+ var _a, _b;
14832
+ if (refresh) {
14833
+ pushToCache(this.cacheKey, {
14834
+ data: response.users.map(getResolver('user')),
14835
+ });
14836
+ }
14837
+ else {
14838
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
14839
+ const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
14840
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...users, ...response.users.map(getResolver('user'))])] }));
14841
+ }
14842
+ }
14843
+ reactor(action) {
14844
+ return (user) => {
14845
+ var _a;
14846
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
14847
+ if (!collection)
14848
+ return;
14849
+ /*
14850
+ * Simply update a collection and let responder decide what to do with data
14851
+ */
14852
+ collection.data = [...new Set([user.userId, ...collection.data])];
14853
+ pushToCache(this.cacheKey, collection);
14854
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
14855
+ };
14856
+ }
14857
+ subscribeRTE(createSubscriber) {
14858
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
14859
+ }
14860
+ }
14861
+
14862
+ var EnumUserActions;
14863
+ (function (EnumUserActions) {
14864
+ EnumUserActions["OnUserDeleted"] = "onUserDeleted";
14865
+ EnumUserActions["OnUserUpdated"] = "onUserUpdated";
14866
+ EnumUserActions["OnUserFlagged"] = "onUserFlagged";
14867
+ EnumUserActions["OnUserUnflagged"] = "onUserUnflagged";
14868
+ EnumUserActions["OnUserFlagCleared"] = "onUserFlagCleared";
14869
+ })(EnumUserActions || (EnumUserActions = {}));
14870
+
14871
+ class UserLiveCollectionController extends LiveCollectionController {
14872
+ constructor(query, callback) {
14873
+ const queryStreamId = hash__default["default"](query);
14874
+ const cacheKey = ['user', 'collection', queryStreamId];
14875
+ const paginationController = new UserPaginationController(query);
14876
+ super(paginationController, queryStreamId, cacheKey, callback);
14877
+ this.query = query;
14878
+ this.queryStreamController = new UserQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareUserPayload);
14879
+ this.callback = callback.bind(this);
14880
+ this.loadPage({ initial: true });
14881
+ }
14882
+ setup() {
14883
+ var _a;
14884
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
14885
+ if (!collection) {
14886
+ pushToCache(this.cacheKey, {
14887
+ data: [],
14888
+ params: {},
14889
+ });
14890
+ }
14891
+ }
14892
+ async persistModel(queryPayload) {
14893
+ await this.queryStreamController.saveToMainDB(queryPayload);
14894
+ }
14895
+ persistQueryStream({ response, direction, refresh, }) {
14896
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
14897
+ }
14898
+ startSubscription() {
14899
+ return this.queryStreamController.subscribeRTE([
14900
+ { fn: onUserDeleted$2, action: EnumUserActions.OnUserDeleted },
14901
+ { fn: onUserUpdated, action: EnumUserActions.OnUserUpdated },
14902
+ { fn: onUserFlagged, action: EnumUserActions.OnUserFlagged },
14903
+ { fn: onUserUnflagged, action: EnumUserActions.OnUserUnflagged },
14904
+ { fn: onUserFlagCleared, action: EnumUserActions.OnUserFlagCleared },
14905
+ ]);
14906
+ }
14907
+ notifyChange({ origin, loading, error }) {
14908
+ var _a, _b;
14909
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
14910
+ if (!collection)
14911
+ return;
14912
+ const data = this.applyFilter((_b = collection.data
14913
+ .map(id => pullFromCache(['user', 'get', id]))
14914
+ .filter(isNonNullable)
14915
+ .map(({ data }) => data)
14916
+ .map(LinkedObject.user)) !== null && _b !== void 0 ? _b : []);
14917
+ if (!this.shouldNotify(data) && origin === 'event')
14918
+ return;
14919
+ this.callback({
14920
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
14921
+ data,
14922
+ hasNextPage: !!this.paginationController.getNextToken(),
14923
+ loading,
14924
+ error,
14925
+ });
14926
+ }
14927
+ applyFilter(data) {
14928
+ let users = data;
14929
+ const sortFn = (() => {
14930
+ switch (this.query.sortBy) {
14931
+ case 'firstCreated':
14932
+ return sortByFirstCreated;
14933
+ case 'lastCreated':
14934
+ return sortByLastCreated;
14935
+ default:
14936
+ return sortByLastCreated;
14937
+ }
14938
+ })();
14939
+ users = users.sort(sortFn);
14940
+ if (this.query.filter === 'flagged') {
14941
+ users = users.filter(user => !!user.hashFlag);
14942
+ }
14943
+ users = users.filter(user => user.isDeleted == null || user.isDeleted === false);
14944
+ return users;
14945
+ }
14946
+ }
14947
+
14948
+ /* begin_public_function
14949
+ id: user.query
14950
+ */
14951
+ /**
14952
+ * ```js
14953
+ * import { liveUsers } from '@amityco/ts-sdk'
14954
+ *
14955
+ * let users = []
14956
+ * const unsub = liveUsers({}, response => merge(users, response.data))
14957
+ * ```
14958
+ *
14959
+ * Observe all mutations on a list of {@link Amity.User}s
14960
+ *
14961
+ * @param params for querying users
14962
+ * @param callback the function to call when new data are available
14337
14963
  * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the users
14338
14964
  *
14339
14965
  * @category Category Live Collection
@@ -14797,9 +15423,9 @@ var AmityUserSearchMatchType;
14797
15423
  AmityUserSearchMatchType["PARTIAL"] = "partial";
14798
15424
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
14799
15425
 
14800
- var index$n = /*#__PURE__*/Object.freeze({
15426
+ var index$p = /*#__PURE__*/Object.freeze({
14801
15427
  __proto__: null,
14802
- Relationship: index$o,
15428
+ Relationship: index$q,
14803
15429
  getUserByIds: getUserByIds,
14804
15430
  updateUser: updateUser,
14805
15431
  flagUser: flagUser,
@@ -15202,7 +15828,7 @@ const uploadAudio = async (formData, onProgress) => {
15202
15828
  };
15203
15829
  /* end_public_function */
15204
15830
 
15205
- var index$m = /*#__PURE__*/Object.freeze({
15831
+ var index$o = /*#__PURE__*/Object.freeze({
15206
15832
  __proto__: null,
15207
15833
  getFile: getFile,
15208
15834
  uploadFile: uploadFile,
@@ -17014,7 +17640,7 @@ const getReactions$1 = (params, callback, config) => {
17014
17640
  };
17015
17641
  /* end_public_function */
17016
17642
 
17017
- var index$l = /*#__PURE__*/Object.freeze({
17643
+ var index$n = /*#__PURE__*/Object.freeze({
17018
17644
  __proto__: null,
17019
17645
  addReaction: addReaction,
17020
17646
  removeReaction: removeReaction,
@@ -18786,7 +19412,7 @@ const getMessages = (params, callback, config) => {
18786
19412
  };
18787
19413
  /* end_public_function */
18788
19414
 
18789
- var index$k = /*#__PURE__*/Object.freeze({
19415
+ var index$m = /*#__PURE__*/Object.freeze({
18790
19416
  __proto__: null,
18791
19417
  createMessage: createMessage,
18792
19418
  updateMessage: updateMessage,
@@ -19312,7 +19938,7 @@ const stopMessageReceiptSync = (subChannelId) => {
19312
19938
  };
19313
19939
  /* end_public_function */
19314
19940
 
19315
- var index$j = /*#__PURE__*/Object.freeze({
19941
+ var index$l = /*#__PURE__*/Object.freeze({
19316
19942
  __proto__: null,
19317
19943
  getSubChannelByIds: getSubChannels$1,
19318
19944
  createSubChannel: createSubChannel,
@@ -20639,7 +21265,7 @@ const searchMembers$1 = (params, callback, config) => {
20639
21265
  };
20640
21266
  /* end_public_function */
20641
21267
 
20642
- var index$i = /*#__PURE__*/Object.freeze({
21268
+ var index$k = /*#__PURE__*/Object.freeze({
20643
21269
  __proto__: null,
20644
21270
  addMembers: addMembers$1,
20645
21271
  removeMembers: removeMembers$1,
@@ -20842,7 +21468,7 @@ const unmuteMembers = async (channelId, userIds) => {
20842
21468
  };
20843
21469
  /* end_public_function */
20844
21470
 
20845
- var index$h = /*#__PURE__*/Object.freeze({
21471
+ var index$j = /*#__PURE__*/Object.freeze({
20846
21472
  __proto__: null,
20847
21473
  addRole: addRole,
20848
21474
  removeRole: removeRole,
@@ -20852,10 +21478,10 @@ var index$h = /*#__PURE__*/Object.freeze({
20852
21478
  unmuteMembers: unmuteMembers
20853
21479
  });
20854
21480
 
20855
- var index$g = /*#__PURE__*/Object.freeze({
21481
+ var index$i = /*#__PURE__*/Object.freeze({
20856
21482
  __proto__: null,
20857
- Membership: index$i,
20858
- Moderation: index$h,
21483
+ Membership: index$k,
21484
+ Moderation: index$j,
20859
21485
  getChannelByIds: getChannelByIds$1,
20860
21486
  createChannel: createChannel,
20861
21487
  updateChannel: updateChannel,
@@ -22258,7 +22884,7 @@ const searchMembers = (params, callback, config) => {
22258
22884
  };
22259
22885
  /* end_public_function */
22260
22886
 
22261
- var index$f = /*#__PURE__*/Object.freeze({
22887
+ var index$h = /*#__PURE__*/Object.freeze({
22262
22888
  __proto__: null,
22263
22889
  addMembers: addMembers,
22264
22890
  removeMembers: removeMembers,
@@ -23509,7 +24135,7 @@ const unbanMembers = async (communityId, userIds) => {
23509
24135
  };
23510
24136
  /* end_public_function */
23511
24137
 
23512
- var index$e = /*#__PURE__*/Object.freeze({
24138
+ var index$g = /*#__PURE__*/Object.freeze({
23513
24139
  __proto__: null,
23514
24140
  addRoles: addRoles,
23515
24141
  removeRoles: removeRoles,
@@ -23517,10 +24143,10 @@ var index$e = /*#__PURE__*/Object.freeze({
23517
24143
  unbanMembers: unbanMembers
23518
24144
  });
23519
24145
 
23520
- var index$d = /*#__PURE__*/Object.freeze({
24146
+ var index$f = /*#__PURE__*/Object.freeze({
23521
24147
  __proto__: null,
23522
- Moderation: index$e,
23523
- Membership: index$f,
24148
+ Moderation: index$g,
24149
+ Membership: index$h,
23524
24150
  getCommunityByIds: getCommunities$1,
23525
24151
  createCommunity: createCommunity,
23526
24152
  updateCommunity: updateCommunity,
@@ -23754,7 +24380,7 @@ const getCategories = (params, callback, config) => {
23754
24380
  };
23755
24381
  /* end_public_function */
23756
24382
 
23757
- var index$c = /*#__PURE__*/Object.freeze({
24383
+ var index$e = /*#__PURE__*/Object.freeze({
23758
24384
  __proto__: null,
23759
24385
  getCategory: getCategory,
23760
24386
  getCategories: getCategories
@@ -24813,7 +25439,7 @@ const getComments = (params, callback, config) => {
24813
25439
  };
24814
25440
  /* end_public_function */
24815
25441
 
24816
- var index$b = /*#__PURE__*/Object.freeze({
25442
+ var index$d = /*#__PURE__*/Object.freeze({
24817
25443
  __proto__: null,
24818
25444
  getCommentByIds: getCommentByIds,
24819
25445
  createComment: createComment,
@@ -25484,7 +26110,7 @@ const getUserFeed = (params, callback, config) => {
25484
26110
  };
25485
26111
  /* end_public_function */
25486
26112
 
25487
- var index$a = /*#__PURE__*/Object.freeze({
26113
+ var index$c = /*#__PURE__*/Object.freeze({
25488
26114
  __proto__: null,
25489
26115
  queryGlobalFeed: queryGlobalFeed,
25490
26116
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -27165,7 +27791,7 @@ const searchPostsByHashtag = (params, callback, config) => {
27165
27791
  };
27166
27792
  /* end_public_function */
27167
27793
 
27168
- var index$9 = /*#__PURE__*/Object.freeze({
27794
+ var index$b = /*#__PURE__*/Object.freeze({
27169
27795
  __proto__: null,
27170
27796
  getPostByIds: getPostByIds,
27171
27797
  createPost: createPost,
@@ -27773,7 +28399,7 @@ const getStreams = (params, callback, config) => {
27773
28399
  };
27774
28400
  };
27775
28401
 
27776
- var index$8 = /*#__PURE__*/Object.freeze({
28402
+ var index$a = /*#__PURE__*/Object.freeze({
27777
28403
  __proto__: null,
27778
28404
  createStream: createStream,
27779
28405
  updateStream: updateStream,
@@ -27988,9 +28614,7 @@ const getRecordedUrl = async (roomId) => {
27988
28614
  const removeParticipant = async (roomId, participantUserId) => {
27989
28615
  const client = getActiveClient();
27990
28616
  client.log('room/removeParticipant', { roomId, participantUserId });
27991
- await client.http.delete(`/api/v1/rooms/${roomId}/participants`, {
27992
- data: { participantUserId },
27993
- });
28617
+ await client.http.delete(`/api/v1/rooms/${roomId}/participants/${participantUserId}`);
27994
28618
  fireEvent('local.room.participantRemoved', {
27995
28619
  rooms: [{ _id: roomId }],
27996
28620
  users: [{ _id: participantUserId }],
@@ -27998,6 +28622,33 @@ const removeParticipant = async (roomId, participantUserId) => {
27998
28622
  };
27999
28623
  /* end_public_function */
28000
28624
 
28625
+ /* begin_public_function
28626
+ id: room.leave
28627
+ */
28628
+ /**
28629
+ * ```js
28630
+ * import { leaveRoom } from '@amityco/ts-sdk'
28631
+ * const result = await leaveRoom('roomId')
28632
+ * ```
28633
+ *
28634
+ * Leaves an {@link Amity.Room}
28635
+ *
28636
+ * @param roomId The ID of the room to leave
28637
+ * @returns Promise that resolves when the user has left the room
28638
+ *
28639
+ * @category Room API
28640
+ * @async
28641
+ */
28642
+ const leaveRoom = async (roomId) => {
28643
+ const client = getActiveClient();
28644
+ client.log('room/leaveRoom', { roomId });
28645
+ await client.http.post(`/api/v1/rooms/${roomId}/leave`);
28646
+ fireEvent('local.room.left', {
28647
+ rooms: [{ _id: roomId }],
28648
+ });
28649
+ };
28650
+ /* end_public_function */
28651
+
28001
28652
  /**
28002
28653
  * ```js
28003
28654
  * import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
@@ -28116,7 +28767,47 @@ const onRoomCoHostInvited = (callback) => {
28116
28767
  ingestInCache(data);
28117
28768
  callback(data.invitations);
28118
28769
  };
28119
- return createEventSubscriber(client, 'room/onRoomCoHostInvited', 'room.didCohostInvite', filter);
28770
+ return createEventSubscriber(client, 'room/onRoomCoHostInvited', 'room.didCohostInvite', filter);
28771
+ };
28772
+
28773
+ const getRoomById = async (roomId) => {
28774
+ const client = getActiveClient();
28775
+ client.log('room/getRoomById', roomId);
28776
+ // Check if room is in tombstone
28777
+ isInTombstone('room', roomId);
28778
+ let data;
28779
+ try {
28780
+ const response = await client.http.get(`/api/v1/rooms/${roomId}`);
28781
+ data = response.data;
28782
+ }
28783
+ catch (error) {
28784
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
28785
+ pushToTombstone('room', roomId);
28786
+ }
28787
+ throw error;
28788
+ }
28789
+ const cachedAt = client.cache && Date.now();
28790
+ if (client.cache) {
28791
+ ingestInCache(data, { cachedAt });
28792
+ }
28793
+ return {
28794
+ data: data.rooms[0],
28795
+ cachedAt,
28796
+ };
28797
+ };
28798
+ getRoomById.locally = (roomId) => {
28799
+ const client = getActiveClient();
28800
+ client.log('room/getRoomById.locally', roomId);
28801
+ // Check if room is in tombstone
28802
+ isInTombstone('room', roomId);
28803
+ const cachedAt = client.cache && Date.now();
28804
+ const roomCache = pullFromCache(['room', 'get', roomId]);
28805
+ if (!roomCache)
28806
+ return;
28807
+ return {
28808
+ data: roomCache.data,
28809
+ cachedAt,
28810
+ };
28120
28811
  };
28121
28812
 
28122
28813
  /**
@@ -28136,12 +28827,14 @@ const onRoomCoHostInvited = (callback) => {
28136
28827
  */
28137
28828
  const onRoomCoHostInviteAccepted = (callback) => {
28138
28829
  const client = getActiveClient();
28139
- const filter = (payload) => {
28830
+ const filter = async (payload) => {
28831
+ var _a;
28140
28832
  const data = prepareMyInvitationsPayload(payload);
28833
+ await getRoomById((_a = data.invitations) === null || _a === void 0 ? void 0 : _a[0].targetId);
28141
28834
  ingestInCache(data);
28142
- callback(data.invitations);
28835
+ callback(data.invitations[0]);
28143
28836
  };
28144
- return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCoHostInviteAccept', filter);
28837
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCohostInviteAccept', filter);
28145
28838
  };
28146
28839
 
28147
28840
  /**
@@ -28166,7 +28859,7 @@ const onRoomCoHostInviteRejected = (callback) => {
28166
28859
  ingestInCache(data);
28167
28860
  callback(data.invitations);
28168
28861
  };
28169
- return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCoHostInviteReject', filter);
28862
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCohostInviteReject', filter);
28170
28863
  };
28171
28864
 
28172
28865
  /**
@@ -28191,7 +28884,7 @@ const onRoomCoHostInviteCanceled = (callback) => {
28191
28884
  ingestInCache(data);
28192
28885
  callback(data.invitations);
28193
28886
  };
28194
- return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCoHostInviteCancel', filter);
28887
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCohostInviteCancel', filter);
28195
28888
  };
28196
28889
 
28197
28890
  /**
@@ -28359,47 +29052,55 @@ const onRoomParticipantRemoved = (callback) => {
28359
29052
  ingestInCache(payload);
28360
29053
  callback(payload.rooms[0]);
28361
29054
  };
28362
- return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
29055
+ return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'room.participantRemoved', filter);
28363
29056
  };
28364
29057
 
28365
- const getRoomById = async (roomId) => {
29058
+ /**
29059
+ * ```js
29060
+ * import { onRoomLeft } from '@amityco/ts-sdk'
29061
+ * const dispose = onRoomLeft(room => {
29062
+ * // ...
29063
+ * })
29064
+ * ```
29065
+ *
29066
+ * Fired when a user has left a {@link Amity.Room} locally
29067
+ *
29068
+ * @param callback The function to call when the event was fired
29069
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
29070
+ *
29071
+ * @category Room Events
29072
+ */
29073
+ const onRoomLeft = (callback) => {
28366
29074
  const client = getActiveClient();
28367
- client.log('room/getRoomById', roomId);
28368
- // Check if room is in tombstone
28369
- isInTombstone('room', roomId);
28370
- let data;
28371
- try {
28372
- const response = await client.http.get(`/api/v1/rooms/${roomId}`);
28373
- data = response.data;
28374
- }
28375
- catch (error) {
28376
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
28377
- pushToTombstone('room', roomId);
28378
- }
28379
- throw error;
28380
- }
28381
- const cachedAt = client.cache && Date.now();
28382
- if (client.cache) {
28383
- ingestInCache(data, { cachedAt });
28384
- }
28385
- return {
28386
- data: data.rooms[0],
28387
- cachedAt,
29075
+ const filter = (payload) => {
29076
+ ingestInCache(payload);
29077
+ callback(payload.rooms[0]);
28388
29078
  };
29079
+ return createEventSubscriber(client, 'room/onRoomLeft', 'local.room.left', filter);
28389
29080
  };
28390
- getRoomById.locally = (roomId) => {
29081
+
29082
+ /**
29083
+ * ```js
29084
+ * import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
29085
+ * const dispose = onRoomParticipantRemoved(room => {
29086
+ * // ...
29087
+ * })
29088
+ * ```
29089
+ *
29090
+ * Fired when a participant has been removed from a {@link Amity.Room} locally
29091
+ *
29092
+ * @param callback The function to call when the event was fired
29093
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
29094
+ *
29095
+ * @category Room Events
29096
+ */
29097
+ const onRoomParticipantRemovedLocal = (callback) => {
28391
29098
  const client = getActiveClient();
28392
- client.log('room/getRoomById.locally', roomId);
28393
- // Check if room is in tombstone
28394
- isInTombstone('room', roomId);
28395
- const cachedAt = client.cache && Date.now();
28396
- const roomCache = pullFromCache(['room', 'get', roomId]);
28397
- if (!roomCache)
28398
- return;
28399
- return {
28400
- data: roomCache.data,
28401
- cachedAt,
29099
+ const filter = (payload) => {
29100
+ ingestInCache(payload);
29101
+ callback(payload.rooms[0]);
28402
29102
  };
29103
+ return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
28403
29104
  };
28404
29105
 
28405
29106
  const getRoom = (roomId, callback) => {
@@ -28409,7 +29110,11 @@ const getRoom = (roomId, callback) => {
28409
29110
  onRoomStartBroadcasting,
28410
29111
  onRoomWaitingReconnect,
28411
29112
  onRoomRecordedAvailable,
28412
- onRoomCoHostInvited,
29113
+ onRoomParticipantJoined,
29114
+ onRoomParticipantLeft,
29115
+ onRoomParticipantRemoved,
29116
+ onRoomParticipantRemovedLocal,
29117
+ convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
28413
29118
  ], {
28414
29119
  callbackDataSelector: (data) => {
28415
29120
  if (!data)
@@ -28598,63 +29303,359 @@ class RoomLiveCollectionController extends LiveCollectionController {
28598
29303
  * }, response => merge(rooms, response.data))
28599
29304
  * ```
28600
29305
  *
28601
- * Observe all mutations on a list of {@link Amity.Room} for a given query
29306
+ * Observe all mutations on a list of {@link Amity.Room} for a given query
29307
+ *
29308
+ * @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
29309
+ * @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
29310
+ * @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
29311
+ * @param params.limit maximum number of rooms to retrieve per page
29312
+ * @param params.includeDeleted whether to include deleted rooms in the results
29313
+ * @param callback the function to call when new data are available
29314
+ * @param config optional configuration for the live collection
29315
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
29316
+ *
29317
+ * @category Rooms Live Collection
29318
+ */
29319
+ const getRooms = (params, callback, config) => {
29320
+ const { log, cache } = getActiveClient();
29321
+ if (!cache) {
29322
+ console.log(ENABLE_CACHE_MESSAGE);
29323
+ }
29324
+ const timestamp = Date.now();
29325
+ log(`getRooms(tmpid: ${timestamp}) > listen`);
29326
+ const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
29327
+ const disposers = roomsLiveCollection.startSubscription();
29328
+ const cacheKey = roomsLiveCollection.getCacheKey();
29329
+ disposers.push(() => dropFromCache(cacheKey));
29330
+ return () => {
29331
+ log(`getRooms(tmpid: ${timestamp}) > dispose`);
29332
+ disposers.forEach(fn => fn());
29333
+ };
29334
+ };
29335
+ /* end_public_function */
29336
+
29337
+ var index$9 = /*#__PURE__*/Object.freeze({
29338
+ __proto__: null,
29339
+ createRoom: createRoom,
29340
+ updateRoom: updateRoom,
29341
+ deleteRoom: deleteRoom,
29342
+ stopRoom: stopRoom,
29343
+ getBroadcasterData: getBroadcasterData,
29344
+ getRecordedUrl: getRecordedUrl,
29345
+ removeParticipant: removeParticipant,
29346
+ leaveRoom: leaveRoom,
29347
+ onRoomStartBroadcasting: onRoomStartBroadcasting,
29348
+ onRoomWaitingReconnect: onRoomWaitingReconnect,
29349
+ onRoomEndBroadcasting: onRoomEndBroadcasting,
29350
+ onRoomRecordedAvailable: onRoomRecordedAvailable,
29351
+ onRoomCoHostInvited: onRoomCoHostInvited,
29352
+ onRoomCoHostInviteAccepted: onRoomCoHostInviteAccepted,
29353
+ onRoomCoHostInviteRejected: onRoomCoHostInviteRejected,
29354
+ onRoomCoHostInviteCanceled: onRoomCoHostInviteCanceled,
29355
+ onRoomParticipantJoined: onRoomParticipantJoined,
29356
+ onRoomParticipantLeft: onRoomParticipantLeft,
29357
+ onRoomCreated: onRoomCreated,
29358
+ onRoomUpdated: onRoomUpdated,
29359
+ onRoomDeleted: onRoomDeleted,
29360
+ onRoomStopped: onRoomStopped,
29361
+ onRoomParticipantRemoved: onRoomParticipantRemoved,
29362
+ onRoomLeft: onRoomLeft,
29363
+ getRoom: getRoom,
29364
+ getRooms: getRooms
29365
+ });
29366
+
29367
+ /* begin_public_function
29368
+ id: roomPresence.getRoomOnlineUsers
29369
+ */
29370
+ /**
29371
+ * ```js
29372
+ * import { getRoomOnlineUsers } from '@amityco/ts-sdk'
29373
+ * const result = await getRoomOnlineUsers('roomId')
29374
+ * ```
29375
+ *
29376
+ * Retrieves the list of users currently online in a specific room.
29377
+ * This function fetches all users who are actively watching or present in the room,
29378
+ * handling pagination automatically for large numbers of users.
29379
+ *
29380
+ * @param roomId The ID of the room to get online users for
29381
+ * @returns Promise that resolves with a cached list of online users
29382
+ *
29383
+ * @category Room Presence API
29384
+ * @async
29385
+ */
29386
+ const getRoomOnlineUsers = async (roomId) => {
29387
+ var _a, _b, _c;
29388
+ const client = getActiveClient();
29389
+ client.log('room/getWatchingUsers', { roomId });
29390
+ const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users`);
29391
+ const viewerIds = (_a = data === null || data === void 0 ? void 0 : data.viewers.map(viewer => viewer.userId)) !== null && _a !== void 0 ? _a : [];
29392
+ // getUserByIds has a maximum limit of 100 users per call
29393
+ // Split into chunks of 100 if we have more than 100 users
29394
+ const BATCH_SIZE = 100;
29395
+ const batches = [];
29396
+ for (let i = 0; i < viewerIds.length; i += BATCH_SIZE) {
29397
+ batches.push(viewerIds.slice(i, i + BATCH_SIZE));
29398
+ }
29399
+ // Fetch all batches in parallel
29400
+ const batchResults = await Promise.all(batches.map(batch => getUserByIds(batch)));
29401
+ // Merge all results
29402
+ const allViewers = [];
29403
+ batchResults.forEach(result => {
29404
+ if (result.data) {
29405
+ allViewers.push(...result.data);
29406
+ }
29407
+ });
29408
+ // Return in the same format as getUserByIds
29409
+ return {
29410
+ data: allViewers,
29411
+ cachedAt: (_c = (_b = batchResults[0]) === null || _b === void 0 ? void 0 : _b.cachedAt) !== null && _c !== void 0 ? _c : Date.now(),
29412
+ };
29413
+ };
29414
+ /* end_public_function */
29415
+
29416
+ /* begin_public_function
29417
+ id: roomPresence.getRoomUserCount
29418
+ */
29419
+ /**
29420
+ * ```js
29421
+ * import { getRoomUserCount } from '@amityco/ts-sdk'
29422
+ * const count = await getRoomUserCount('roomId')
29423
+ * ```
29424
+ *
29425
+ * Retrieves the count of users currently watching or present in a specific room.
29426
+ * This function returns the total number of online users without fetching their full user data.
29427
+ *
29428
+ * @param roomId The ID of the room to get the user count for
29429
+ * @returns Promise that resolves with the room watching count data
29430
+ *
29431
+ * @category Room Presence API
29432
+ * @async
29433
+ */
29434
+ const getRoomUserCount = async (roomId) => {
29435
+ const client = getActiveClient();
29436
+ client.log('roomPresence/getRoomUserCount', { roomId });
29437
+ const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users/count`);
29438
+ pushToCache(['get', 'watchingCount', roomId], data);
29439
+ fireEvent('local.room.watchingCountUpdated', data);
29440
+ return data;
29441
+ };
29442
+ /* end_public_function */
29443
+
29444
+ const getPresenceSetting = async () => {
29445
+ const client = getActiveClient();
29446
+ client.log('presence/getPresenceSetting');
29447
+ const { data } = await client.http.get('/api/v1/presence/settings');
29448
+ pushToCache(['get', 'presenceSetting'], data);
29449
+ return data;
29450
+ };
29451
+
29452
+ class RoomPresenceSyncEngine {
29453
+ constructor(roomId) {
29454
+ this.isEnabled = false;
29455
+ this.config = {
29456
+ heartbeatInterval: 30 * SECOND$1,
29457
+ };
29458
+ this.roomId = roomId;
29459
+ // Initialize config asynchronously - don't await in constructor
29460
+ this.initializeConfig().catch(error => {
29461
+ console.error('Failed to initialize RoomPresenceSyncEngine config in constructor:', error);
29462
+ });
29463
+ }
29464
+ async initializeConfig() {
29465
+ try {
29466
+ // Get presence settings from API with retry logic
29467
+ const presenceSettings = await RoomPresenceSyncEngine.getPresenceSettingWithRetry();
29468
+ if (presenceSettings) {
29469
+ // Set intervals from network settings (convert from minutes to milliseconds)
29470
+ this.config = {
29471
+ heartbeatInterval: (presenceSettings.network.heartbeatInterval || 5) * 60 * 1000,
29472
+ };
29473
+ }
29474
+ else {
29475
+ // Use default intervals if all retries failed
29476
+ this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
29477
+ }
29478
+ }
29479
+ catch (error) {
29480
+ console.error('Failed to initialize RoomPresenceSyncEngine config:', error);
29481
+ // Use default intervals if settings fetch fails
29482
+ this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
29483
+ }
29484
+ }
29485
+ static async getPresenceSettingWithRetry(maxRetries = 5) {
29486
+ for (let attempt = 0; attempt < maxRetries; attempt += 1) {
29487
+ try {
29488
+ // eslint-disable-next-line no-await-in-loop
29489
+ const presenceSettings = await getPresenceSetting();
29490
+ return presenceSettings;
29491
+ }
29492
+ catch (error) {
29493
+ if (attempt >= maxRetries - 1) {
29494
+ console.error(`Failed to get presence setting after ${maxRetries} attempts:`, error);
29495
+ return null;
29496
+ }
29497
+ // Calculate delay: 20 seconds + random jitter (0-5 seconds)
29498
+ const jitter = Math.random() * 5000; // 0-5 seconds in milliseconds
29499
+ const delay = 20000 + jitter; // 20 seconds + jitter
29500
+ console.warn(`Failed to get presence setting (attempt ${attempt + 1}/${maxRetries}), retrying in ${Math.round(delay / 1000)}s:`, error);
29501
+ // Wait before retry
29502
+ // eslint-disable-next-line no-await-in-loop
29503
+ await new Promise(resolve => {
29504
+ setTimeout(resolve, delay);
29505
+ });
29506
+ }
29507
+ }
29508
+ return null;
29509
+ }
29510
+ /**
29511
+ * Start heartbeat for the room
29512
+ */
29513
+ start() {
29514
+ if (this.isEnabled)
29515
+ return;
29516
+ this.isEnabled = true;
29517
+ // Send immediate heartbeat
29518
+ this.sendHeartbeat();
29519
+ // Start heartbeat timer
29520
+ this.heartbeatTimer = setInterval(() => {
29521
+ this.sendHeartbeat();
29522
+ }, this.config.heartbeatInterval);
29523
+ }
29524
+ /**
29525
+ * Stop heartbeat for the room
29526
+ */
29527
+ stop() {
29528
+ this.isEnabled = false;
29529
+ // Stop heartbeat timer
29530
+ if (this.heartbeatTimer) {
29531
+ clearInterval(this.heartbeatTimer);
29532
+ this.heartbeatTimer = undefined;
29533
+ }
29534
+ }
29535
+ /**
29536
+ * Send heartbeat to the room
29537
+ */
29538
+ async sendHeartbeat() {
29539
+ try {
29540
+ const client = getActiveClient();
29541
+ await client.http.post(`/api/v1/presence/rooms/${this.roomId}/heartbeat`);
29542
+ }
29543
+ catch (error) {
29544
+ console.error(`Heartbeat failed for room ${this.roomId}:`, error);
29545
+ }
29546
+ }
29547
+ /**
29548
+ * Get the room ID
29549
+ */
29550
+ getRoomId() {
29551
+ return this.roomId;
29552
+ }
29553
+ /**
29554
+ * Check if the engine is enabled
29555
+ */
29556
+ isActive() {
29557
+ return this.isEnabled;
29558
+ }
29559
+ /**
29560
+ * Cleanup method to stop all timers and release resources
29561
+ * Call this when the engine instance is no longer needed
29562
+ */
29563
+ destroy() {
29564
+ // Stop the engine
29565
+ this.stop();
29566
+ }
29567
+ // Session Management
29568
+ onSessionDestroyed() {
29569
+ // Stop all timers when session is destroyed and cleanup
29570
+ this.destroy();
29571
+ }
29572
+ onTokenExpired() {
29573
+ // Stop engine when token expires
29574
+ this.stop();
29575
+ }
29576
+ }
29577
+
29578
+ // Map to store engine instances per roomId
29579
+ const engineInstances = new Map();
29580
+ /**
29581
+ * Get or create a RoomPresenceSyncEngine instance for a specific room
29582
+ *
29583
+ * @param roomId The room ID to get/create engine for
29584
+ * @returns RoomPresenceSyncEngine instance for the room
29585
+ */
29586
+ const getRoomPresenceSyncEngine = (roomId) => {
29587
+ let engine = engineInstances.get(roomId);
29588
+ if (!engine) {
29589
+ engine = new RoomPresenceSyncEngine(roomId);
29590
+ engineInstances.set(roomId, engine);
29591
+ }
29592
+ return engine;
29593
+ };
29594
+ /**
29595
+ * Destroy the engine instance for a specific room
29596
+ *
29597
+ * @param roomId The room ID to destroy engine for
29598
+ */
29599
+ const destroyRoomPresenceSyncEngine = (roomId) => {
29600
+ const engine = engineInstances.get(roomId);
29601
+ if (engine) {
29602
+ engine.destroy();
29603
+ engineInstances.delete(roomId);
29604
+ }
29605
+ };
29606
+
29607
+ /* begin_public_function
29608
+ id: roomPresence.startHeartbeat
29609
+ */
29610
+ /**
29611
+ * ```js
29612
+ * import { startHeartbeat } from '@amityco/ts-sdk'
29613
+ * startHeartbeat('roomId')
29614
+ * ```
29615
+ *
29616
+ * Starts sending heartbeat signals for a specific room to maintain presence status.
29617
+ * This enables the room presence tracking and notifies the server that the user is actively viewing the room.
29618
+ *
29619
+ * @param roomId The ID of the room to start heartbeat for
29620
+ *
29621
+ * @category Room Presence API
29622
+ */
29623
+ const startHeartbeat = (roomId) => {
29624
+ const engine = getRoomPresenceSyncEngine(roomId);
29625
+ engine.start();
29626
+ };
29627
+ /* end_public_function */
29628
+
29629
+ /* begin_public_function
29630
+ id: roomPresence.stopHeartbeat
29631
+ */
29632
+ /**
29633
+ * ```js
29634
+ * import { stopHeartbeat } from '@amityco/ts-sdk'
29635
+ * stopHeartbeat('roomId')
29636
+ * ```
29637
+ *
29638
+ * Stops sending heartbeat signals for a specific room.
29639
+ * This disables the room presence tracking for the specified room and stops notifying the server of the user's presence.
28602
29640
  *
28603
- * @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
28604
- * @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
28605
- * @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
28606
- * @param params.limit maximum number of rooms to retrieve per page
28607
- * @param params.includeDeleted whether to include deleted rooms in the results
28608
- * @param callback the function to call when new data are available
28609
- * @param config optional configuration for the live collection
28610
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
29641
+ * @param roomId The ID of the room to stop heartbeat for
28611
29642
  *
28612
- * @category Rooms Live Collection
29643
+ * @category Room Presence API
28613
29644
  */
28614
- const getRooms = (params, callback, config) => {
28615
- const { log, cache } = getActiveClient();
28616
- if (!cache) {
28617
- console.log(ENABLE_CACHE_MESSAGE);
28618
- }
28619
- const timestamp = Date.now();
28620
- log(`getRooms(tmpid: ${timestamp}) > listen`);
28621
- const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
28622
- const disposers = roomsLiveCollection.startSubscription();
28623
- const cacheKey = roomsLiveCollection.getCacheKey();
28624
- disposers.push(() => dropFromCache(cacheKey));
28625
- return () => {
28626
- log(`getRooms(tmpid: ${timestamp}) > dispose`);
28627
- disposers.forEach(fn => fn());
28628
- };
29645
+ const stopHeartbeat = (roomId) => {
29646
+ const engine = getRoomPresenceSyncEngine(roomId);
29647
+ engine.stop();
29648
+ // Clean up the engine instance
29649
+ destroyRoomPresenceSyncEngine(roomId);
28629
29650
  };
28630
29651
  /* end_public_function */
28631
29652
 
28632
- var index$7 = /*#__PURE__*/Object.freeze({
29653
+ var index$8 = /*#__PURE__*/Object.freeze({
28633
29654
  __proto__: null,
28634
- createRoom: createRoom,
28635
- updateRoom: updateRoom,
28636
- deleteRoom: deleteRoom,
28637
- stopRoom: stopRoom,
28638
- getBroadcasterData: getBroadcasterData,
28639
- getRecordedUrl: getRecordedUrl,
28640
- removeParticipant: removeParticipant,
28641
- onRoomStartBroadcasting: onRoomStartBroadcasting,
28642
- onRoomWaitingReconnect: onRoomWaitingReconnect,
28643
- onRoomEndBroadcasting: onRoomEndBroadcasting,
28644
- onRoomRecordedAvailable: onRoomRecordedAvailable,
28645
- onRoomCoHostInvited: onRoomCoHostInvited,
28646
- onRoomCoHostInviteAccepted: onRoomCoHostInviteAccepted,
28647
- onRoomCoHostInviteRejected: onRoomCoHostInviteRejected,
28648
- onRoomCoHostInviteCanceled: onRoomCoHostInviteCanceled,
28649
- onRoomParticipantJoined: onRoomParticipantJoined,
28650
- onRoomParticipantLeft: onRoomParticipantLeft,
28651
- onRoomCreated: onRoomCreated,
28652
- onRoomUpdated: onRoomUpdated,
28653
- onRoomDeleted: onRoomDeleted,
28654
- onRoomStopped: onRoomStopped,
28655
- onRoomParticipantRemoved: onRoomParticipantRemoved,
28656
- getRoom: getRoom,
28657
- getRooms: getRooms
29655
+ getRoomOnlineUsers: getRoomOnlineUsers,
29656
+ getRoomUserCount: getRoomUserCount,
29657
+ startHeartbeat: startHeartbeat,
29658
+ stopHeartbeat: stopHeartbeat
28658
29659
  });
28659
29660
 
28660
29661
  /* begin_public_function
@@ -28957,7 +29958,7 @@ const getPoll = (pollId, callback) => {
28957
29958
  };
28958
29959
  /* end_public_function */
28959
29960
 
28960
- var index$6 = /*#__PURE__*/Object.freeze({
29961
+ var index$7 = /*#__PURE__*/Object.freeze({
28961
29962
  __proto__: null,
28962
29963
  createPoll: createPoll,
28963
29964
  closePoll: closePoll,
@@ -29340,7 +30341,7 @@ const getPlayer = async (parameters) => {
29340
30341
  return video;
29341
30342
  };
29342
30343
 
29343
- var index$5 = /*#__PURE__*/Object.freeze({
30344
+ var index$6 = /*#__PURE__*/Object.freeze({
29344
30345
  __proto__: null,
29345
30346
  getPlayer: getPlayer
29346
30347
  });
@@ -30513,7 +31514,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
30513
31514
  };
30514
31515
  };
30515
31516
 
30516
- var index$4 = /*#__PURE__*/Object.freeze({
31517
+ var index$5 = /*#__PURE__*/Object.freeze({
30517
31518
  __proto__: null,
30518
31519
  createImageStory: createImageStory,
30519
31520
  createVideoStory: createVideoStory,
@@ -30550,7 +31551,7 @@ const getNetworkAds = async () => {
30550
31551
  };
30551
31552
  };
30552
31553
 
30553
- var index$3 = /*#__PURE__*/Object.freeze({
31554
+ var index$4 = /*#__PURE__*/Object.freeze({
30554
31555
  __proto__: null,
30555
31556
  getNetworkAds: getNetworkAds
30556
31557
  });
@@ -30941,7 +31942,7 @@ const markTraySeen = async (lastSeenAt) => {
30941
31942
  };
30942
31943
  /* end_public_function */
30943
31944
 
30944
- var index$2 = /*#__PURE__*/Object.freeze({
31945
+ var index$3 = /*#__PURE__*/Object.freeze({
30945
31946
  __proto__: null,
30946
31947
  getNotificationTraySeen: getNotificationTraySeen,
30947
31948
  getNotificationTrayItems: getNotificationTrayItems,
@@ -30984,28 +31985,6 @@ const cancelInvitation = async (invitationId) => {
30984
31985
  };
30985
31986
  /* end_public_function */
30986
31987
 
30987
- /* begin_public_function
30988
- id: invitation.accept
30989
- */
30990
- /**
30991
- * ```js
30992
- * import { acceptInvitation } from '@amityco/ts-sdk'
30993
- * const isAccepted = await acceptInvitation(invitationId)
30994
- * ```
30995
- *
30996
- * Accepts a {@link Amity.Invitation} object
30997
- *
30998
- * @param invitationId the {@link Amity.Invitation} to accept
30999
- * @returns A success boolean if the {@link Amity.Invitation} was accepted
31000
- *
31001
- * @category Invitation API
31002
- * @async
31003
- */
31004
- const acceptInvitation = async (invitationId) => {
31005
- return acceptInvitation$1(invitationId);
31006
- };
31007
- /* end_public_function */
31008
-
31009
31988
  class MyInvitationsPaginationController extends PaginationController {
31010
31989
  async getRequest(queryParams, token) {
31011
31990
  const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
@@ -31066,7 +32045,7 @@ class MyInvitationsQueryStreamController extends QueryStreamController {
31066
32045
  ]),
31067
32046
  ];
31068
32047
  }
31069
- if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
32048
+ if (action === InvitationActionsEnum.OnLocalInvitationCanceled) {
31070
32049
  collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
31071
32050
  }
31072
32051
  pushToCache(this.cacheKey, collection);
@@ -31198,13 +32177,16 @@ const getMyCommunityInvitations = (params, callback, config) => {
31198
32177
  };
31199
32178
  };
31200
32179
 
32180
+ /* begin_public_function
32181
+ id: invitation.get_invitations
32182
+ */
31201
32183
  /**
31202
32184
  *
31203
32185
  * ```js
31204
- * import { observeInvitations } from '@amityco/ts-sdk';
32186
+ * import { InvitationRepository } from '@amityco/ts-sdk';
31205
32187
  *
31206
32188
  * // For room invitations
31207
- * const unsubscribe = observeInvitations(
32189
+ * const unsubscribe = InvitationRepository.getInvitations(
31208
32190
  * { targetId: 'room123', targetType: 'room' },
31209
32191
  * response => {
31210
32192
  * console.log('Room invitation event:', response.room, response.users, response.eventType)
@@ -31228,7 +32210,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
31228
32210
  *
31229
32211
  * @category Invitation Observable
31230
32212
  */
31231
- const observeInvitations = (params, callback) => {
32213
+ const getInvitations = (params, callback) => {
31232
32214
  const { _id: userId } = getCurrentUser();
31233
32215
  if (!userId)
31234
32216
  throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
@@ -31241,7 +32223,7 @@ const observeInvitations = (params, callback) => {
31241
32223
  callback(data.map(LinkedObject.invitation));
31242
32224
  };
31243
32225
  const realtimeRouter = (data) => {
31244
- const invitations = data.filter(({ targetId, targetType }) => targetId === params.targetId && targetType === params.targetType);
32226
+ const invitations = (Array.isArray(data) ? data : [data]).filter(({ targetId, targetType }) => targetId === params.targetId && targetType === params.targetType);
31245
32227
  dispatcher(invitations);
31246
32228
  };
31247
32229
  // Only subscribe to room co-host events for now (since that's what we have implemented)
@@ -31253,20 +32235,19 @@ const observeInvitations = (params, callback) => {
31253
32235
  disposers.push(onRoomCoHostInviteCanceled(realtimeRouter));
31254
32236
  }
31255
32237
  return () => {
31256
- log(`observeInvitations(tmpid: ${timestamp}) > dispose for ${targetType}: ${targetId}`);
32238
+ log(`getInvitations(tmpid: ${timestamp}) > dispose for ${targetType}: ${targetId}`);
31257
32239
  disposers.forEach(fn => fn());
31258
32240
  };
31259
32241
  };
31260
32242
 
31261
- var index$1 = /*#__PURE__*/Object.freeze({
32243
+ var index$2 = /*#__PURE__*/Object.freeze({
31262
32244
  __proto__: null,
31263
32245
  cancelInvitation: cancelInvitation,
31264
- acceptInvitation: acceptInvitation,
31265
32246
  onLocalInvitationCreated: onLocalInvitationCreated,
31266
32247
  onLocalInvitationUpdated: onLocalInvitationUpdated,
31267
32248
  onLocalInvitationCanceled: onLocalInvitationCanceled,
31268
32249
  getMyCommunityInvitations: getMyCommunityInvitations,
31269
- observeInvitations: observeInvitations
32250
+ getInvitations: getInvitations
31270
32251
  });
31271
32252
 
31272
32253
  // TODO: confirm id
@@ -31323,122 +32304,604 @@ const createReaction = async ({ referenceId, referenceType, reactionName, roomId
31323
32304
  * })
31324
32305
  * ```
31325
32306
  *
31326
- * Fired when a batch of {@link Amity.LiveReaction} has been created
32307
+ * Fired when a batch of {@link Amity.LiveReaction} has been created
32308
+ *
32309
+ * @param callback The function to call when the event was fired
32310
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
32311
+ *
32312
+ * @category Live Reaction Events
32313
+ */
32314
+ const onLiveReactionCreated = (callback) => {
32315
+ const client = getActiveClient();
32316
+ const filter = (rawPayload) => {
32317
+ if (rawPayload.reactions.length > 0) {
32318
+ // TODO: check with BE if user id is internal or pulbic id
32319
+ const filteredPayload = rawPayload.reactions.filter(({ userId }) => userId !== client.userId);
32320
+ callback(filteredPayload);
32321
+ }
32322
+ };
32323
+ return createEventSubscriber(client, 'live_reaction/onLiveReactionCreated', 'liveReaction.created', filter);
32324
+ };
32325
+
32326
+ /**
32327
+ * ```js
32328
+ * import { onLiveReactionCreatedLocal } from '@amityco/ts-sdk'
32329
+ * const dispose = onLiveReactionCreatedLocal(reactions => {
32330
+ * // ...
32331
+ * })
32332
+ * ```
32333
+ *
32334
+ * Fired when a batch of {@link Amity.LiveReaction} has been created
32335
+ *
32336
+ * @param callback The function to call when the event was fired
32337
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
32338
+ *
32339
+ * @category Live Reaction Events
32340
+ */
32341
+ const onLiveReactionCreatedLocal = (callback) => {
32342
+ const client = getActiveClient();
32343
+ return createEventSubscriber(client, 'live_reaction/onLiveReactionCreated', 'local.liveReaction.created', callback);
32344
+ };
32345
+
32346
+ /**
32347
+ *
32348
+ * ```js
32349
+ * import { getReactions } from '@amityco/ts-sdk';
32350
+ *
32351
+ * const unsubscribe = getReactions(response => {
32352
+ * reactions = response.data
32353
+ * });
32354
+ * ```
32355
+ *
32356
+ * Observe live reactions {@link_Amity.LiveReaction} that have been created in a post linked with a stream
32357
+ *
32358
+ * @param callback the function to call when new data are available
32359
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the events
32360
+ *
32361
+ * @category Live Reaction Observable
32362
+ */
32363
+ // TODO: confirm return type for this observable property
32364
+ const getReactions = (postId, callback) => {
32365
+ const { _id: userId } = getActiveUser();
32366
+ if (!userId)
32367
+ throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
32368
+ const { log } = getActiveClient();
32369
+ const timestamp = Date.now();
32370
+ log(`getReactions(tmpid: ${timestamp}) > listen`);
32371
+ const disposers = [];
32372
+ const dispatcher = (data) => {
32373
+ callback(data);
32374
+ };
32375
+ const realtimeRouter = (data) => {
32376
+ const relevantReactions = data.filter(({ referenceId }) => referenceId === postId);
32377
+ dispatcher(relevantReactions);
32378
+ };
32379
+ disposers.push(onLiveReactionCreated(realtimeRouter));
32380
+ disposers.push(onLiveReactionCreatedLocal(realtimeRouter));
32381
+ return () => {
32382
+ disposers.forEach(fn => fn());
32383
+ };
32384
+ };
32385
+
32386
+ var index$1 = /*#__PURE__*/Object.freeze({
32387
+ __proto__: null,
32388
+ createReaction: createReaction,
32389
+ onLiveReactionCreated: onLiveReactionCreated,
32390
+ getReactions: getReactions
32391
+ });
32392
+
32393
+ /* begin_public_function
32394
+ id: event.create
32395
+ */
32396
+ /**
32397
+ * ```js
32398
+ * import { EventRepository } from '@amityco/ts-sdk'
32399
+ * const response = await EventRepository.createEvent(bundle)
32400
+ * ```
32401
+ *
32402
+ * Creates an {@link Amity.Event}
32403
+ *
32404
+ * @param bundle The data necessary to create a new {@link Amity.Event}
32405
+ * @returns The newly created {@link Amity.Event}
32406
+ *
32407
+ * @category Event API
32408
+ * @async
32409
+ */
32410
+ const createEvent = async (bundle) => {
32411
+ const client = getActiveClient();
32412
+ client.log('event/createEvent', bundle);
32413
+ const { data: payload } = await client.http.post('/api/v1/events', bundle);
32414
+ fireEvent('local.event.created', payload);
32415
+ const preparedPayload = prepareEventPayload(payload);
32416
+ const cachedAt = client.cache && Date.now();
32417
+ if (client.cache)
32418
+ ingestInCache(preparedPayload, { cachedAt });
32419
+ return {
32420
+ data: eventLinkedObject(preparedPayload.events[0]),
32421
+ cachedAt,
32422
+ };
32423
+ };
32424
+ /* end_public_function */
32425
+
32426
+ /* begin_public_function
32427
+ id: event.update
32428
+ */
32429
+ /**
32430
+ * ```js
32431
+ * import { EventRepository } from '@amityco/ts-sdk'
32432
+ * const response = await EventRepository.updateEvent(eventId, bundle)
32433
+ * ```
32434
+ *
32435
+ * Updates an {@link Amity.Event}
32436
+ *
32437
+ * @param eventId The ID of the {@link Amity.Event} to edit
32438
+ * @param bundle The data necessary to update an existing {@link Amity.Event}
32439
+ * @returns the updated {@link Amity.Event}
32440
+ *
32441
+ * @category Event API
32442
+ * @async
32443
+ */
32444
+ const updateEvent = async (eventId, bundle) => {
32445
+ const client = getActiveClient();
32446
+ client.log('event/updateEvent', eventId, bundle);
32447
+ const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
32448
+ fireEvent('local.event.updated', payload);
32449
+ const preparedPayload = prepareEventPayload(payload);
32450
+ const cachedAt = client.cache && Date.now();
32451
+ if (client.cache)
32452
+ ingestInCache(preparedPayload, { cachedAt });
32453
+ return {
32454
+ data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
32455
+ cachedAt,
32456
+ };
32457
+ };
32458
+ /* end_public_function */
32459
+
32460
+ /* begin_public_function
32461
+ id: event.get
32462
+ */
32463
+ /**
32464
+ * ```js
32465
+ * import { EventRepository } from '@amityco/ts-sdk'
32466
+ * const event = await EventRepository.getEvent(eventId)
32467
+ * ```
32468
+ *
32469
+ * Fetches a {@link Amity.Event} object
32470
+ *
32471
+ * @param eventId the ID of the {@link Amity.Event} to fetch
32472
+ * @returns the associated {@link Amity.Event} object
32473
+ *
32474
+ * @category Event API
32475
+ * @async
32476
+ */
32477
+ const getEvent$1 = async (eventId) => {
32478
+ const client = getActiveClient();
32479
+ client.log('event/getEvent', eventId);
32480
+ const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
32481
+ const data = prepareEventPayload(payload);
32482
+ const cachedAt = client.cache && Date.now();
32483
+ if (client.cache)
32484
+ ingestInCache(data, { cachedAt });
32485
+ return {
32486
+ data: data.events.find(event => event.eventId === eventId),
32487
+ cachedAt,
32488
+ };
32489
+ };
32490
+ /* end_public_function */
32491
+ /**
32492
+ * ```js
32493
+ * import { EventRepository } from '@amityco/ts-sdk'
32494
+ * const event = EventRepository.getEvent.locally(eventId)
32495
+ * ```
32496
+ *
32497
+ * Fetches a {@link Amity.Event} object in cache
32498
+ *
32499
+ * @param eventId the ID of the {@link Amity.Event} to fetch
32500
+ * @returns the associated {@link Amity.Event} object
32501
+ *
32502
+ * @category Event API
32503
+ */
32504
+ getEvent$1.locally = (eventId) => {
32505
+ const client = getActiveClient();
32506
+ client.log('event/getEvent.locally', eventId);
32507
+ if (!client.cache)
32508
+ return;
32509
+ const cache = pullFromCache(['event', 'get', eventId]);
32510
+ if (!cache)
32511
+ return;
32512
+ return {
32513
+ data: cache.data,
32514
+ cachedAt: cache.cachedAt,
32515
+ };
32516
+ };
32517
+
32518
+ /* begin_public_function
32519
+ id: event.delete
32520
+ */
32521
+ /**
32522
+ * ```js
32523
+ * import { EventRepository } from '@amityco/ts-sdk'
32524
+ * const { success } = await EventRepository.deleteEvent(eventId)
32525
+ * ```
32526
+ *
32527
+ * Deletes a {@link Amity.Event}
31327
32528
  *
31328
- * @param callback The function to call when the event was fired
31329
- * @returns an {@link Amity.Unsubscriber} function to stop listening
32529
+ * @param eventId The {@link Amity.Event} ID to delete
31330
32530
  *
31331
- * @category Live Reaction Events
32531
+ * @category Event API
32532
+ * @async
31332
32533
  */
31333
- const onLiveReactionCreated = (callback) => {
32534
+ const deleteEvent = async (eventId) => {
31334
32535
  const client = getActiveClient();
31335
- const filter = (rawPayload) => {
31336
- if (rawPayload.reactions.length > 0) {
31337
- // TODO: check with BE if user id is internal or pulbic id
31338
- const filteredPayload = rawPayload.reactions.filter(({ userId }) => userId !== client.userId);
31339
- callback(filteredPayload);
31340
- }
31341
- };
31342
- return createEventSubscriber(client, 'live_reaction/onLiveReactionCreated', 'liveReaction.created', filter);
32536
+ client.log('event/deleteEvent', eventId);
32537
+ const event = await getEvent$1(eventId);
32538
+ await client.http.delete(`/api/v1/events/${eventId}`);
32539
+ const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
32540
+ upsertInCache(['event', 'get', eventId], deletedEvent);
32541
+ fireEvent('local.event.deleted', {
32542
+ users: [],
32543
+ files: [],
32544
+ communities: [],
32545
+ posts: [],
32546
+ rooms: [],
32547
+ events: [deletedEvent],
32548
+ });
31343
32549
  };
32550
+ /* end_public_function */
31344
32551
 
32552
+ /* begin_public_function
32553
+ id: event.get
32554
+ */
31345
32555
  /**
31346
32556
  * ```js
31347
- * import { onLiveReactionCreatedLocal } from '@amityco/ts-sdk'
31348
- * const dispose = onLiveReactionCreatedLocal(reactions => {
31349
- * // ...
31350
- * })
32557
+ * import { EventRepository } from '@amityco/ts-sdk';
32558
+ *
32559
+ * let event;
32560
+ *
32561
+ * const unsubscribe = EventRepository.getEvent(eventId, response => {
32562
+ * event = response.data;
32563
+ * });
31351
32564
  * ```
31352
32565
  *
31353
- * Fired when a batch of {@link Amity.LiveReaction} has been created
32566
+ * Observe all mutation on a given {@link Amity.Event}
31354
32567
  *
31355
- * @param callback The function to call when the event was fired
31356
- * @returns an {@link Amity.Unsubscriber} function to stop listening
32568
+ * @param eventId the ID of the event to observe
32569
+ * @param callback the function to call when new snapshot of event are available
32570
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
31357
32571
  *
31358
- * @category Live Reaction Events
32572
+ * @category Event Live Object
31359
32573
  */
31360
- const onLiveReactionCreatedLocal = (callback) => {
31361
- const client = getActiveClient();
31362
- return createEventSubscriber(client, 'live_reaction/onLiveReactionCreated', 'local.liveReaction.created', callback);
32574
+ const getEvent = (eventId, callback) => {
32575
+ return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
32576
+ callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
32577
+ });
31363
32578
  };
32579
+ /* end_public_function */
32580
+
32581
+ class EventPaginationController extends PaginationController {
32582
+ async getRequest(queryParams, token) {
32583
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
32584
+ const options = token ? { token } : { limit };
32585
+ const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
32586
+ return response;
32587
+ }
32588
+ }
32589
+
32590
+ class EventQueryStreamController extends QueryStreamController {
32591
+ constructor(query, cacheKey, notifyChange, preparePayload) {
32592
+ super(query, cacheKey);
32593
+ this.notifyChange = notifyChange;
32594
+ this.preparePayload = preparePayload;
32595
+ }
32596
+ async saveToMainDB(response) {
32597
+ const processedPayload = this.preparePayload(response);
32598
+ const client = getActiveClient();
32599
+ const cachedAt = client.cache && Date.now();
32600
+ if (client.cache)
32601
+ ingestInCache(processedPayload, { cachedAt });
32602
+ }
32603
+ appendToQueryStream(response, direction, refresh = false) {
32604
+ var _a, _b;
32605
+ if (refresh) {
32606
+ pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
32607
+ }
32608
+ else {
32609
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32610
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
32611
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
32612
+ }
32613
+ }
32614
+ reactor(action) {
32615
+ return (event) => {
32616
+ var _a;
32617
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32618
+ if (!collection)
32619
+ return;
32620
+ if (action === EventActionsEnum.OnEventCreated) {
32621
+ collection.data = [...new Set([event.eventId, ...collection.data])];
32622
+ }
32623
+ if (action === EventActionsEnum.OnEventDeleted) {
32624
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
32625
+ }
32626
+ pushToCache(this.cacheKey, collection);
32627
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
32628
+ };
32629
+ }
32630
+ subscribeRTE(createSubscriber) {
32631
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
32632
+ }
32633
+ }
32634
+
32635
+ class EventLiveCollectionController extends LiveCollectionController {
32636
+ constructor(query, callback) {
32637
+ const queryStreamId = hash__default["default"](query);
32638
+ const cacheKey = ['event', 'collection', queryStreamId];
32639
+ const paginationController = new EventPaginationController(query);
32640
+ super(paginationController, queryStreamId, cacheKey, callback);
32641
+ this.query = query;
32642
+ this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
32643
+ this.callback = callback.bind(this);
32644
+ this.loadPage({ initial: true });
32645
+ }
32646
+ setup() {
32647
+ var _a;
32648
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32649
+ if (!collection)
32650
+ pushToCache(this.cacheKey, { data: [], params: {} });
32651
+ }
32652
+ async persistModel(queryPayload) {
32653
+ await this.queryStreamController.saveToMainDB(queryPayload);
32654
+ }
32655
+ persistQueryStream({ response, direction, refresh, }) {
32656
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
32657
+ }
32658
+ startSubscription() {
32659
+ return this.queryStreamController.subscribeRTE([
32660
+ { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
32661
+ { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
32662
+ { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
32663
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
32664
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
32665
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
32666
+ ]);
32667
+ }
32668
+ notifyChange({ origin, loading, error }) {
32669
+ var _a, _b;
32670
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32671
+ if (!collection)
32672
+ return;
32673
+ const data = ((_b = collection.data
32674
+ .map(eventId => pullFromCache(['event', 'get', eventId]))
32675
+ .filter(isNonNullable)
32676
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
32677
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
32678
+ return;
32679
+ this.callback({
32680
+ data,
32681
+ error,
32682
+ loading,
32683
+ hasNextPage: !!this.paginationController.getNextToken(),
32684
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
32685
+ });
32686
+ }
32687
+ }
31364
32688
 
31365
32689
  /**
32690
+ * Get events
31366
32691
  *
31367
- * ```js
31368
- * import { getReactions } from '@amityco/ts-sdk';
32692
+ * @param params the query parameters
32693
+ * @param callback the callback to be called when the events are updated
32694
+ * @returns events
31369
32695
  *
31370
- * const unsubscribe = getReactions(response => {
31371
- * reactions = response.data
31372
- * });
31373
- * ```
32696
+ * @category Event Live Collection
31374
32697
  *
31375
- * Observe live reactions {@link_Amity.LiveReaction} that have been created in a post linked with a stream
32698
+ */
32699
+ const getEvents = (params, callback, config) => {
32700
+ const { log, cache } = getActiveClient();
32701
+ if (!cache)
32702
+ console.log(ENABLE_CACHE_MESSAGE);
32703
+ const timestamp = Date.now();
32704
+ log(`getEvents: (tmpid: ${timestamp}) > listen`);
32705
+ const eventLiveCollection = new EventLiveCollectionController(params, callback);
32706
+ const disposers = eventLiveCollection.startSubscription();
32707
+ const cacheKey = eventLiveCollection.getCacheKey();
32708
+ disposers.push(() => dropFromCache(cacheKey));
32709
+ return () => {
32710
+ log(`getEvents (tmpid: ${timestamp}) > dispose`);
32711
+ disposers.forEach(fn => fn());
32712
+ };
32713
+ };
32714
+
32715
+ class MyEventPaginationController extends PaginationController {
32716
+ async getRequest(queryParams, token) {
32717
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
32718
+ const options = token ? { token } : { limit };
32719
+ const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
32720
+ return response;
32721
+ }
32722
+ }
32723
+
32724
+ class MyEventQueryStreamController extends QueryStreamController {
32725
+ constructor(query, cacheKey, notifyChange, preparePayload) {
32726
+ super(query, cacheKey);
32727
+ this.notifyChange = notifyChange;
32728
+ this.preparePayload = preparePayload;
32729
+ }
32730
+ async saveToMainDB(response) {
32731
+ const processedPayload = this.preparePayload(response);
32732
+ const client = getActiveClient();
32733
+ const cachedAt = client.cache && Date.now();
32734
+ if (client.cache)
32735
+ ingestInCache(processedPayload, { cachedAt });
32736
+ }
32737
+ appendToQueryStream(response, direction, refresh = false) {
32738
+ var _a, _b;
32739
+ if (refresh) {
32740
+ pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
32741
+ }
32742
+ else {
32743
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32744
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
32745
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
32746
+ }
32747
+ }
32748
+ reactor(action) {
32749
+ return (event) => {
32750
+ var _a;
32751
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32752
+ if (!collection)
32753
+ return;
32754
+ if (action === EventActionsEnum.OnEventCreated) {
32755
+ const client = getActiveClient();
32756
+ if (client.userId !== event.userId)
32757
+ return;
32758
+ collection.data = [...new Set([event.eventId, ...collection.data])];
32759
+ }
32760
+ if (action === EventActionsEnum.OnEventDeleted) {
32761
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
32762
+ }
32763
+ pushToCache(this.cacheKey, collection);
32764
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
32765
+ };
32766
+ }
32767
+ subscribeRTE(createSubscriber) {
32768
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
32769
+ }
32770
+ }
32771
+
32772
+ class MyEventLiveCollectionController extends LiveCollectionController {
32773
+ constructor(query, callback) {
32774
+ const queryStreamId = hash__default["default"](query);
32775
+ const cacheKey = ['event', 'collection', queryStreamId];
32776
+ const paginationController = new MyEventPaginationController(query);
32777
+ super(paginationController, queryStreamId, cacheKey, callback);
32778
+ this.query = query;
32779
+ this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
32780
+ this.callback = callback.bind(this);
32781
+ this.loadPage({ initial: true });
32782
+ }
32783
+ setup() {
32784
+ var _a;
32785
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32786
+ if (!collection)
32787
+ pushToCache(this.cacheKey, { data: [], params: {} });
32788
+ }
32789
+ async persistModel(queryPayload) {
32790
+ await this.queryStreamController.saveToMainDB(queryPayload);
32791
+ }
32792
+ persistQueryStream({ response, direction, refresh, }) {
32793
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
32794
+ }
32795
+ startSubscription() {
32796
+ return this.queryStreamController.subscribeRTE([
32797
+ { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
32798
+ { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
32799
+ { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
32800
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
32801
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
32802
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
32803
+ ]);
32804
+ }
32805
+ notifyChange({ origin, loading, error }) {
32806
+ var _a, _b;
32807
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
32808
+ if (!collection)
32809
+ return;
32810
+ const data = ((_b = collection.data
32811
+ .map(eventId => pullFromCache(['event', 'get', eventId]))
32812
+ .filter(isNonNullable)
32813
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
32814
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
32815
+ return;
32816
+ this.callback({
32817
+ data,
32818
+ error,
32819
+ loading,
32820
+ hasNextPage: !!this.paginationController.getNextToken(),
32821
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
32822
+ });
32823
+ }
32824
+ }
32825
+
32826
+ /**
32827
+ * Get my events
31376
32828
  *
31377
- * @param callback the function to call when new data are available
31378
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the events
32829
+ * @param params the query parameters
32830
+ * @param callback the callback to be called when the events are updated
32831
+ * @returns events
32832
+ *
32833
+ * @category Event Live Collection
31379
32834
  *
31380
- * @category Live Reaction Observable
31381
32835
  */
31382
- // TODO: confirm return type for this observable property
31383
- const getReactions = (postId, callback) => {
31384
- const { _id: userId } = getActiveUser();
31385
- if (!userId)
31386
- throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
31387
- const { log } = getActiveClient();
32836
+ const getMyEvents = (params, callback, config) => {
32837
+ const { log, cache } = getActiveClient();
32838
+ if (!cache)
32839
+ console.log(ENABLE_CACHE_MESSAGE);
31388
32840
  const timestamp = Date.now();
31389
- log(`getReactions(tmpid: ${timestamp}) > listen`);
31390
- const disposers = [];
31391
- const dispatcher = (data) => {
31392
- callback(data);
31393
- };
31394
- const realtimeRouter = (data) => {
31395
- const relevantReactions = data.filter(({ referenceId }) => referenceId === postId);
31396
- dispatcher(relevantReactions);
31397
- };
31398
- disposers.push(onLiveReactionCreated(realtimeRouter));
31399
- disposers.push(onLiveReactionCreatedLocal(realtimeRouter));
32841
+ log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
32842
+ const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
32843
+ const disposers = myEventLiveCollection.startSubscription();
32844
+ const cacheKey = myEventLiveCollection.getCacheKey();
32845
+ disposers.push(() => dropFromCache(cacheKey));
31400
32846
  return () => {
32847
+ log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
31401
32848
  disposers.forEach(fn => fn());
31402
32849
  };
31403
32850
  };
31404
32851
 
31405
32852
  var index = /*#__PURE__*/Object.freeze({
31406
32853
  __proto__: null,
31407
- createReaction: createReaction,
31408
- onLiveReactionCreated: onLiveReactionCreated,
31409
- getReactions: getReactions
32854
+ createEvent: createEvent,
32855
+ updateEvent: updateEvent,
32856
+ deleteEvent: deleteEvent,
32857
+ onEventCreated: onEventCreated,
32858
+ onEventUpdated: onEventUpdated,
32859
+ onEventDeleted: onEventDeleted,
32860
+ onLocalEventCreated: onLocalEventCreated,
32861
+ onLocalEventUpdated: onLocalEventUpdated,
32862
+ onLocalEventDeleted: onLocalEventDeleted,
32863
+ onRSVPCreated: onRSVPCreated,
32864
+ onRSVPUpdated: onRSVPUpdated,
32865
+ onLocalRSVPCreated: onLocalRSVPCreated,
32866
+ onLocalRSVPUpdated: onLocalRSVPUpdated,
32867
+ getEvent: getEvent,
32868
+ getEvents: getEvents,
32869
+ getMyEvents: getMyEvents,
32870
+ getRSVPs: getRSVPs
31410
32871
  });
31411
32872
 
31412
32873
  exports.API_REGIONS = API_REGIONS;
31413
- exports.AdRepository = index$3;
31414
- exports.CategoryRepository = index$c;
31415
- exports.ChannelRepository = index$g;
31416
- exports.Client = index$p;
31417
- exports.CommentRepository = index$b;
32874
+ exports.AdRepository = index$4;
32875
+ exports.CategoryRepository = index$e;
32876
+ exports.ChannelRepository = index$i;
32877
+ exports.Client = index$r;
32878
+ exports.CommentRepository = index$d;
31418
32879
  exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
31419
32880
  exports.CommunityPostSettings = CommunityPostSettings;
31420
- exports.CommunityRepository = index$d;
32881
+ exports.CommunityRepository = index$f;
31421
32882
  exports.ContentFeedType = ContentFeedType;
31422
32883
  exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
31423
- exports.FeedRepository = index$a;
31424
- exports.FileRepository = index$m;
32884
+ exports.EventRepository = index;
32885
+ exports.FeedRepository = index$c;
32886
+ exports.FileRepository = index$o;
31425
32887
  exports.FileType = FileType;
31426
32888
  exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
31427
- exports.InvitationRepository = index$1;
31428
- exports.LiveReactionRepository = index;
31429
- exports.LiveStreamPlayer = index$5;
32889
+ exports.InvitationRepository = index$2;
32890
+ exports.LiveReactionRepository = index$1;
32891
+ exports.LiveStreamPlayer = index$6;
31430
32892
  exports.MessageContentType = MessageContentType;
31431
- exports.MessageRepository = index$k;
31432
- exports.PollRepository = index$6;
32893
+ exports.MessageRepository = index$m;
32894
+ exports.PollRepository = index$7;
31433
32895
  exports.PostContentType = PostContentType;
31434
- exports.PostRepository = index$9;
32896
+ exports.PostRepository = index$b;
31435
32897
  exports.PostStructureType = PostStructureType;
31436
- exports.ReactionRepository = index$l;
31437
- exports.RoomRepository = index$7;
31438
- exports.StoryRepository = index$4;
31439
- exports.StreamRepository = index$8;
31440
- exports.SubChannelRepository = index$j;
31441
- exports.UserRepository = index$n;
32898
+ exports.ReactionRepository = index$n;
32899
+ exports.RoomPresenceRepository = index$8;
32900
+ exports.RoomRepository = index$9;
32901
+ exports.StoryRepository = index$5;
32902
+ exports.StreamRepository = index$a;
32903
+ exports.SubChannelRepository = index$l;
32904
+ exports.UserRepository = index$p;
31442
32905
  exports.VERSION = VERSION;
31443
32906
  exports.VideoResolution = VideoResolution;
31444
32907
  exports.VideoSize = VideoSize;
@@ -31494,7 +32957,7 @@ exports.isPaged = isPaged;
31494
32957
  exports.isReportedByMe = isReportedByMe;
31495
32958
  exports.isSkip = isSkip;
31496
32959
  exports.mergeInCache = mergeInCache;
31497
- exports.notificationTray = index$2;
32960
+ exports.notificationTray = index$3;
31498
32961
  exports.onChannelMarkerFetched = onChannelMarkerFetched;
31499
32962
  exports.onFeedMarkerFetched = onFeedMarkerFetched;
31500
32963
  exports.onFeedMarkerUpdated = onFeedMarkerUpdated;