@amityco/ts-sdk 7.11.1-3b65d6ed.0 → 7.11.1-4318edb0.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 (254) hide show
  1. package/dist/@types/core/events.d.ts +53 -10
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +5 -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/channel.d.ts +1 -0
  12. package/dist/@types/domains/channel.d.ts.map +1 -1
  13. package/dist/@types/domains/community.d.ts +14 -1
  14. package/dist/@types/domains/community.d.ts.map +1 -1
  15. package/dist/@types/domains/event.d.ts +122 -0
  16. package/dist/@types/domains/event.d.ts.map +1 -0
  17. package/dist/@types/domains/invitation.d.ts +7 -2
  18. package/dist/@types/domains/invitation.d.ts.map +1 -1
  19. package/dist/@types/domains/notification.d.ts +6 -2
  20. package/dist/@types/domains/notification.d.ts.map +1 -1
  21. package/dist/@types/domains/partials.d.ts +2 -2
  22. package/dist/@types/domains/partials.d.ts.map +1 -1
  23. package/dist/@types/domains/room.d.ts +22 -4
  24. package/dist/@types/domains/room.d.ts.map +1 -1
  25. package/dist/@types/index.d.ts +1 -0
  26. package/dist/@types/index.d.ts.map +1 -1
  27. package/dist/client/api/getPresenceSetting.d.ts +2 -0
  28. package/dist/client/api/getPresenceSetting.d.ts.map +1 -0
  29. package/dist/client/api/resumeSession.d.ts.map +1 -1
  30. package/dist/client/events/onUserDeleted.d.ts +17 -0
  31. package/dist/client/events/onUserDeleted.d.ts.map +1 -0
  32. package/dist/client/services/ObjectResolver/objectResolverEngine.d.ts.map +1 -0
  33. package/dist/client/services/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +1 -0
  34. package/dist/client/services/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +1 -0
  35. package/dist/client/services/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +1 -0
  36. package/dist/client/services/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -0
  37. package/dist/client/services/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts.map +1 -0
  38. package/dist/core/events.d.ts +3 -3
  39. package/dist/core/events.d.ts.map +1 -1
  40. package/dist/core/model/idResolvers.d.ts.map +1 -1
  41. package/dist/core/model/index.d.ts.map +1 -1
  42. package/dist/core/subscription.d.ts +2 -0
  43. package/dist/core/subscription.d.ts.map +1 -1
  44. package/dist/eventRepository/api/createEvent.d.ts +16 -0
  45. package/dist/eventRepository/api/createEvent.d.ts.map +1 -0
  46. package/dist/eventRepository/api/deleteEvent.d.ts +15 -0
  47. package/dist/eventRepository/api/deleteEvent.d.ts.map +1 -0
  48. package/dist/eventRepository/api/index.d.ts +4 -0
  49. package/dist/eventRepository/api/index.d.ts.map +1 -0
  50. package/dist/eventRepository/api/updateEvent.d.ts +17 -0
  51. package/dist/eventRepository/api/updateEvent.d.ts.map +1 -0
  52. package/dist/eventRepository/events/enums.d.ts +8 -0
  53. package/dist/eventRepository/events/enums.d.ts.map +1 -0
  54. package/dist/eventRepository/events/index.d.ts +11 -0
  55. package/dist/eventRepository/events/index.d.ts.map +1 -0
  56. package/dist/eventRepository/events/onEventCreated.d.ts +17 -0
  57. package/dist/eventRepository/events/onEventCreated.d.ts.map +1 -0
  58. package/dist/eventRepository/events/onEventDeleted.d.ts +17 -0
  59. package/dist/eventRepository/events/onEventDeleted.d.ts.map +1 -0
  60. package/dist/eventRepository/events/onEventUpdated.d.ts +17 -0
  61. package/dist/eventRepository/events/onEventUpdated.d.ts.map +1 -0
  62. package/dist/eventRepository/events/onLocalEventCreated.d.ts +17 -0
  63. package/dist/eventRepository/events/onLocalEventCreated.d.ts.map +1 -0
  64. package/dist/eventRepository/events/onLocalEventDeleted.d.ts +17 -0
  65. package/dist/eventRepository/events/onLocalEventDeleted.d.ts.map +1 -0
  66. package/dist/eventRepository/events/onLocalEventUpdated.d.ts +17 -0
  67. package/dist/eventRepository/events/onLocalEventUpdated.d.ts.map +1 -0
  68. package/dist/eventRepository/events/onLocalRSVPCreated.d.ts +17 -0
  69. package/dist/eventRepository/events/onLocalRSVPCreated.d.ts.map +1 -0
  70. package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts +17 -0
  71. package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts.map +1 -0
  72. package/dist/eventRepository/events/onRSVPCreated.d.ts +17 -0
  73. package/dist/eventRepository/events/onRSVPCreated.d.ts.map +1 -0
  74. package/dist/eventRepository/events/onRSVPUpdated.d.ts +17 -0
  75. package/dist/eventRepository/events/onRSVPUpdated.d.ts.map +1 -0
  76. package/dist/eventRepository/index.d.ts +4 -0
  77. package/dist/eventRepository/index.d.ts.map +1 -0
  78. package/dist/eventRepository/internalApi/createRSVP.d.ts +17 -0
  79. package/dist/eventRepository/internalApi/createRSVP.d.ts.map +1 -0
  80. package/dist/eventRepository/internalApi/getEvent.d.ts +32 -0
  81. package/dist/eventRepository/internalApi/getEvent.d.ts.map +1 -0
  82. package/dist/eventRepository/internalApi/getMyRSVP.d.ts +32 -0
  83. package/dist/eventRepository/internalApi/getMyRSVP.d.ts.map +1 -0
  84. package/dist/eventRepository/internalApi/index.d.ts +5 -0
  85. package/dist/eventRepository/internalApi/index.d.ts.map +1 -0
  86. package/dist/eventRepository/internalApi/updateRSVP.d.ts +17 -0
  87. package/dist/eventRepository/internalApi/updateRSVP.d.ts.map +1 -0
  88. package/dist/eventRepository/observers/getEvent.d.ts +21 -0
  89. package/dist/eventRepository/observers/getEvent.d.ts.map +1 -0
  90. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts +13 -0
  91. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +1 -0
  92. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts +5 -0
  93. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts.map +1 -0
  94. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts +15 -0
  95. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts.map +1 -0
  96. package/dist/eventRepository/observers/getEvents.d.ts +12 -0
  97. package/dist/eventRepository/observers/getEvents.d.ts.map +1 -0
  98. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts +13 -0
  99. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +1 -0
  100. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +5 -0
  101. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +1 -0
  102. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +15 -0
  103. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +1 -0
  104. package/dist/eventRepository/observers/getMyEvents.d.ts +12 -0
  105. package/dist/eventRepository/observers/getMyEvents.d.ts.map +1 -0
  106. package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts +13 -0
  107. package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts.map +1 -0
  108. package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts +5 -0
  109. package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts.map +1 -0
  110. package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts +15 -0
  111. package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts.map +1 -0
  112. package/dist/eventRepository/observers/getRSVPs.d.ts +12 -0
  113. package/dist/eventRepository/observers/getRSVPs.d.ts.map +1 -0
  114. package/dist/eventRepository/observers/index.d.ts +5 -0
  115. package/dist/eventRepository/observers/index.d.ts.map +1 -0
  116. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +2 -0
  117. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +1 -0
  118. package/dist/eventRepository/utils/createEventResponseSubscriber.d.ts +2 -0
  119. package/dist/eventRepository/utils/createEventResponseSubscriber.d.ts.map +1 -0
  120. package/dist/eventRepository/utils/index.d.ts +5 -0
  121. package/dist/eventRepository/utils/index.d.ts.map +1 -0
  122. package/dist/eventRepository/utils/prepareEventPayload.d.ts +2 -0
  123. package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +1 -0
  124. package/dist/eventRepository/utils/prepareEventResponsePayload.d.ts +2 -0
  125. package/dist/eventRepository/utils/prepareEventResponsePayload.d.ts.map +1 -0
  126. package/dist/index.cjs.js +4248 -2489
  127. package/dist/index.d.ts +2 -0
  128. package/dist/index.d.ts.map +1 -1
  129. package/dist/index.esm.js +2335 -580
  130. package/dist/index.umd.js +3 -3
  131. package/dist/invitationRepository/api/cancelInvitation.d.ts +16 -0
  132. package/dist/invitationRepository/api/cancelInvitation.d.ts.map +1 -0
  133. package/dist/invitationRepository/api/index.d.ts +2 -0
  134. package/dist/invitationRepository/api/index.d.ts.map +1 -0
  135. package/dist/invitationRepository/events/index.d.ts +1 -1
  136. package/dist/invitationRepository/events/index.d.ts.map +1 -1
  137. package/dist/invitationRepository/events/onLocalInvitationCanceled.d.ts +17 -0
  138. package/dist/invitationRepository/events/onLocalInvitationCanceled.d.ts.map +1 -0
  139. package/dist/invitationRepository/index.d.ts +1 -0
  140. package/dist/invitationRepository/index.d.ts.map +1 -1
  141. package/dist/invitationRepository/internalApi/getInvitation.d.ts +1 -1
  142. package/dist/invitationRepository/internalApi/getInvitation.d.ts.map +1 -1
  143. package/dist/invitationRepository/internalObservers/getInvitations/InvitationsLiveCollectionController.d.ts.map +1 -0
  144. package/dist/invitationRepository/internalObservers/getInvitations/InvitationsPaginationController.d.ts.map +1 -0
  145. package/dist/invitationRepository/internalObservers/getInvitations/InvitationsQueryStreamController.d.ts.map +1 -0
  146. package/dist/invitationRepository/{observers → internalObservers}/getInvitations/enums.d.ts +1 -1
  147. package/dist/invitationRepository/internalObservers/getInvitations/enums.d.ts.map +1 -0
  148. package/dist/invitationRepository/internalObservers/getInvitations.d.ts +12 -0
  149. package/dist/invitationRepository/internalObservers/getInvitations.d.ts.map +1 -0
  150. package/dist/invitationRepository/observers/getInvitations.d.ts +28 -6
  151. package/dist/invitationRepository/observers/getInvitations.d.ts.map +1 -1
  152. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts +1 -1
  153. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts.map +1 -1
  154. package/dist/invitationRepository/observers/index.d.ts +1 -0
  155. package/dist/invitationRepository/observers/index.d.ts.map +1 -1
  156. package/dist/liveReactionRepository/api/createReaction.d.ts +2 -2
  157. package/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -1
  158. package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts +1 -1
  159. package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts.map +1 -1
  160. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +2 -1
  161. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
  162. package/dist/roomPresenceRepository/api/getRoomOnlineUsers.d.ts +18 -0
  163. package/dist/roomPresenceRepository/api/getRoomOnlineUsers.d.ts.map +1 -0
  164. package/dist/roomPresenceRepository/api/getRoomUserCount.d.ts +17 -0
  165. package/dist/roomPresenceRepository/api/getRoomUserCount.d.ts.map +1 -0
  166. package/dist/roomPresenceRepository/api/index.d.ts +5 -0
  167. package/dist/roomPresenceRepository/api/index.d.ts.map +1 -0
  168. package/dist/roomPresenceRepository/api/startHeartbeat.d.ts +15 -0
  169. package/dist/roomPresenceRepository/api/startHeartbeat.d.ts.map +1 -0
  170. package/dist/roomPresenceRepository/api/stopHeartbeat.d.ts +15 -0
  171. package/dist/roomPresenceRepository/api/stopHeartbeat.d.ts.map +1 -0
  172. package/dist/roomPresenceRepository/index.d.ts +2 -0
  173. package/dist/roomPresenceRepository/index.d.ts.map +1 -0
  174. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/RoomPresenceSyncEngine.d.ts +38 -0
  175. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/RoomPresenceSyncEngine.d.ts.map +1 -0
  176. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/index.d.ts +2 -0
  177. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/index.d.ts.map +1 -0
  178. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/roomPresenceSyncEngineFactory.d.ts +32 -0
  179. package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/roomPresenceSyncEngineFactory.d.ts.map +1 -0
  180. package/dist/roomPresenceRepository/services/index.d.ts +2 -0
  181. package/dist/roomPresenceRepository/services/index.d.ts.map +1 -0
  182. package/dist/roomRepository/api/{getRoomToken.d.ts → getBroadcasterData.d.ts} +3 -3
  183. package/dist/roomRepository/api/getBroadcasterData.d.ts.map +1 -0
  184. package/dist/roomRepository/api/index.d.ts +3 -1
  185. package/dist/roomRepository/api/index.d.ts.map +1 -1
  186. package/dist/roomRepository/api/leaveRoom.d.ts +16 -0
  187. package/dist/roomRepository/api/leaveRoom.d.ts.map +1 -0
  188. package/dist/roomRepository/api/removeParticipant.d.ts +17 -0
  189. package/dist/roomRepository/api/removeParticipant.d.ts.map +1 -0
  190. package/dist/roomRepository/api/updateRoom.d.ts +1 -1
  191. package/dist/roomRepository/api/updateRoom.d.ts.map +1 -1
  192. package/dist/roomRepository/events/index.d.ts +6 -1
  193. package/dist/roomRepository/events/index.d.ts.map +1 -1
  194. package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts +17 -0
  195. package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts.map +1 -0
  196. package/dist/roomRepository/events/onRoomCoHostInviteCanceled.d.ts +17 -0
  197. package/dist/roomRepository/events/onRoomCoHostInviteCanceled.d.ts.map +1 -0
  198. package/dist/roomRepository/events/onRoomCoHostInviteRejected.d.ts +17 -0
  199. package/dist/roomRepository/events/onRoomCoHostInviteRejected.d.ts.map +1 -0
  200. package/dist/roomRepository/events/{onRoomParticipantInviting.d.ts → onRoomCoHostInvited.d.ts} +2 -2
  201. package/dist/roomRepository/events/onRoomCoHostInvited.d.ts.map +1 -0
  202. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +1 -1
  203. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +1 -1
  204. package/dist/roomRepository/events/onRoomLeft.d.ts +17 -0
  205. package/dist/roomRepository/events/onRoomLeft.d.ts.map +1 -0
  206. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +1 -1
  207. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +1 -1
  208. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +1 -1
  209. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +1 -1
  210. package/dist/roomRepository/events/onRoomParticipantRemoved.d.ts +17 -0
  211. package/dist/roomRepository/events/onRoomParticipantRemoved.d.ts.map +1 -0
  212. package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts +17 -0
  213. package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts.map +1 -0
  214. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +1 -1
  215. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +1 -1
  216. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +1 -1
  217. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +1 -1
  218. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +1 -1
  219. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +1 -1
  220. package/dist/roomRepository/observers/getRoom.d.ts.map +1 -1
  221. package/dist/roomRepository/observers/utils.d.ts +1 -1
  222. package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -1
  223. package/dist/utils/linkedObject/eventLinkObject.d.ts +2 -0
  224. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -0
  225. package/dist/utils/linkedObject/eventResponseLinkObject.d.ts +2 -0
  226. package/dist/utils/linkedObject/eventResponseLinkObject.d.ts.map +1 -0
  227. package/dist/utils/linkedObject/index.d.ts +3 -0
  228. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  229. package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts.map +1 -1
  230. package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +1 -1
  231. package/package.json +1 -1
  232. package/dist/client/utils/ObjectResolver/objectResolverEngine.d.ts.map +0 -1
  233. package/dist/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +0 -1
  234. package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +0 -1
  235. package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
  236. package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +0 -1
  237. package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
  238. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +0 -17
  239. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +0 -1
  240. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +0 -1
  241. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +0 -1
  242. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +0 -1
  243. package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +0 -1
  244. package/dist/roomRepository/api/getRoomToken.d.ts.map +0 -1
  245. package/dist/roomRepository/events/onRoomParticipantInviting.d.ts.map +0 -1
  246. /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngine.d.ts +0 -0
  247. /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts +0 -0
  248. /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts +0 -0
  249. /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts +0 -0
  250. /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngine.d.ts +0 -0
  251. /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts +0 -0
  252. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsLiveCollectionController.d.ts +0 -0
  253. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsPaginationController.d.ts +0 -0
  254. /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsQueryStreamController.d.ts +0 -0
package/dist/index.esm.js CHANGED
@@ -73,6 +73,11 @@ const CommunityPostSettingMaps = Object.freeze({
73
73
  },
74
74
  });
75
75
  const DefaultCommunityPostSetting = 'ONLY_ADMIN_CAN_POST';
76
+ var AmityCommunityType;
77
+ (function (AmityCommunityType) {
78
+ AmityCommunityType["Default"] = "default";
79
+ AmityCommunityType["Event"] = "event";
80
+ })(AmityCommunityType || (AmityCommunityType = {}));
76
81
 
77
82
  const ContentFeedType = Object.freeze({
78
83
  STORY: 'story',
@@ -126,7 +131,7 @@ const PostStructureType = Object.freeze({
126
131
  var InvitationTypeEnum;
127
132
  (function (InvitationTypeEnum) {
128
133
  InvitationTypeEnum["CommunityMemberInvite"] = "communityMemberInvite";
129
- InvitationTypeEnum["LivestreamInvite"] = "livestreamInvite";
134
+ InvitationTypeEnum["LivestreamCohostInvite"] = "livestreamCohostInvite";
130
135
  })(InvitationTypeEnum || (InvitationTypeEnum = {}));
131
136
  var InvitationStatusEnum;
132
137
  (function (InvitationStatusEnum) {
@@ -140,6 +145,11 @@ var InvitationSortByEnum;
140
145
  InvitationSortByEnum["FirstCreated"] = "firstCreated";
141
146
  InvitationSortByEnum["LastCreated"] = "lastCreated";
142
147
  })(InvitationSortByEnum || (InvitationSortByEnum = {}));
148
+ var InvitationTargetTypeEnum;
149
+ (function (InvitationTargetTypeEnum) {
150
+ InvitationTargetTypeEnum["Community"] = "community";
151
+ InvitationTargetTypeEnum["Room"] = "room";
152
+ })(InvitationTargetTypeEnum || (InvitationTargetTypeEnum = {}));
143
153
 
144
154
  var JoinRequestStatusEnum;
145
155
  (function (JoinRequestStatusEnum) {
@@ -179,6 +189,39 @@ var FeedSourceEnum;
179
189
  FeedSourceEnum["User"] = "user";
180
190
  })(FeedSourceEnum || (FeedSourceEnum = {}));
181
191
 
192
+ var AmityEventType;
193
+ (function (AmityEventType) {
194
+ AmityEventType["Virtual"] = "virtual";
195
+ AmityEventType["InPerson"] = "in_person";
196
+ })(AmityEventType || (AmityEventType = {}));
197
+ var AmityEventOriginType;
198
+ (function (AmityEventOriginType) {
199
+ AmityEventOriginType["Community"] = "community";
200
+ AmityEventOriginType["User"] = "user";
201
+ })(AmityEventOriginType || (AmityEventOriginType = {}));
202
+ var AmityEventStatus;
203
+ (function (AmityEventStatus) {
204
+ AmityEventStatus["Scheduled"] = "scheduled";
205
+ AmityEventStatus["Live"] = "live";
206
+ AmityEventStatus["Ended"] = "ended";
207
+ AmityEventStatus["Cancelled"] = "cancelled";
208
+ })(AmityEventStatus || (AmityEventStatus = {}));
209
+ var AmityEventResponseStatus;
210
+ (function (AmityEventResponseStatus) {
211
+ AmityEventResponseStatus["Going"] = "going";
212
+ AmityEventResponseStatus["NotGoing"] = "not_going";
213
+ })(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
214
+ var AmityEventSortOption;
215
+ (function (AmityEventSortOption) {
216
+ AmityEventSortOption["StartTime"] = "startTime";
217
+ AmityEventSortOption["CreatedAt"] = "createdAt";
218
+ })(AmityEventSortOption || (AmityEventSortOption = {}));
219
+ var AmityEventOrderOption;
220
+ (function (AmityEventOrderOption) {
221
+ AmityEventOrderOption["Ascending"] = "asc";
222
+ AmityEventOrderOption["Descending"] = "desc";
223
+ })(AmityEventOrderOption || (AmityEventOrderOption = {}));
224
+
182
225
  function getVersion() {
183
226
  try {
184
227
  // the string ''v7.11.0-esm'' should be replaced by actual value by @rollup/plugin-replace
@@ -628,6 +671,10 @@ const idResolvers = {
628
671
  invitation: ({ _id }) => _id,
629
672
  joinRequest: ({ joinRequestId }) => joinRequestId,
630
673
  room: ({ roomId }) => roomId,
674
+ viewer: ({ userId }) => userId,
675
+ event: ({ eventId }) => eventId,
676
+ eventResponse: ({ eventId }) => eventId,
677
+ discussionCommunity: ({ communityId }) => communityId,
631
678
  };
632
679
  /**
633
680
  * Retrieve the id resolver matching a domain name
@@ -684,6 +731,9 @@ const PAYLOAD2MODEL = {
684
731
  invitations: 'invitation',
685
732
  joinRequests: 'joinRequest',
686
733
  rooms: 'room',
734
+ events: 'event',
735
+ viewers: 'viewer',
736
+ eventResponses: 'eventResponse',
687
737
  };
688
738
  /** hidden */
689
739
  const isOutdated = (prevData, nextData) => {
@@ -1483,6 +1533,37 @@ async function modifyMqttConnection() {
1483
1533
  }
1484
1534
  }
1485
1535
 
1536
+ const userLinkedObject = (user) => {
1537
+ return Object.assign(Object.assign({}, user), { get avatar() {
1538
+ var _a;
1539
+ if (!user.avatarFileId)
1540
+ return undefined;
1541
+ const avatar = (_a = pullFromCache([
1542
+ 'file',
1543
+ 'get',
1544
+ `${user.avatarFileId}`,
1545
+ ])) === null || _a === void 0 ? void 0 : _a.data;
1546
+ return avatar;
1547
+ } });
1548
+ };
1549
+
1550
+ /* begin_public_function
1551
+ id: client.get_current_user
1552
+ */
1553
+ const getCurrentUser = () => {
1554
+ var _a;
1555
+ const client = getActiveClient();
1556
+ if (!client) {
1557
+ throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
1558
+ }
1559
+ const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
1560
+ if (!cache) {
1561
+ throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
1562
+ }
1563
+ return userLinkedObject(cache);
1564
+ };
1565
+ /* end_public_function */
1566
+
1486
1567
  var SubscriptionLevels;
1487
1568
  (function (SubscriptionLevels) {
1488
1569
  SubscriptionLevels["COMMUNITY"] = "community";
@@ -1588,6 +1669,14 @@ const getLiveStreamTopic = () => {
1588
1669
  const getLiveReactionTopic = (post) => {
1589
1670
  return `${post.path}/liveReaction`;
1590
1671
  };
1672
+ const getRoomWatcherTopic = (room) => {
1673
+ const user = getCurrentUser();
1674
+ return `${getNetworkId(user)}/room/${room._id}`;
1675
+ };
1676
+ const getRoomStreamerTopic = (room) => {
1677
+ const user = getCurrentUser();
1678
+ return `${getNetworkId(user)}/room/${room.roomId}/streamer`;
1679
+ };
1591
1680
  function subscribeTopic(topic, callback) {
1592
1681
  const { mqtt } = getActiveClient();
1593
1682
  if (!mqtt)
@@ -21014,20 +21103,6 @@ const getChannelMessagePreview = (channelId) => {
21014
21103
  return ((_b = (_a = pullFromCache(['messagePreviewChannel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : null);
21015
21104
  };
21016
21105
 
21017
- const userLinkedObject = (user) => {
21018
- return Object.assign(Object.assign({}, user), { get avatar() {
21019
- var _a;
21020
- if (!user.avatarFileId)
21021
- return undefined;
21022
- const avatar = (_a = pullFromCache([
21023
- 'file',
21024
- 'get',
21025
- `${user.avatarFileId}`,
21026
- ])) === null || _a === void 0 ? void 0 : _a.data;
21027
- return avatar;
21028
- } });
21029
- };
21030
-
21031
21106
  const getChannelMessagePreviewWithUser = (channel) => {
21032
21107
  var _a;
21033
21108
  const messagePreview = channel.messagePreviewId
@@ -24605,19 +24680,19 @@ class LiveReactionSyncEngine {
24605
24680
  // Clear buffer
24606
24681
  this.clearBuffer();
24607
24682
  const payloads = reactions.reduce((prev, curr) => {
24608
- const { streamId } = curr, rest = __rest(curr, ["streamId"]);
24609
- if (!prev[streamId]) {
24683
+ const { roomId } = curr, rest = __rest(curr, ["roomId"]);
24684
+ if (!prev[roomId]) {
24610
24685
  // eslint-disable-next-line no-param-reassign
24611
- prev[streamId] = [rest];
24686
+ prev[roomId] = [rest];
24612
24687
  }
24613
24688
  else
24614
- prev[streamId].push(rest);
24689
+ prev[roomId].push(rest);
24615
24690
  return prev;
24616
24691
  }, {});
24617
24692
  // Call server api `POST /api/v1/reactions/live` to sync live reactions
24618
- Object.entries(payloads).forEach(([streamId, reactions]) => {
24693
+ Object.entries(payloads).forEach(([roomId, reactions]) => {
24619
24694
  createLiveReaction({
24620
- liveStreamId: streamId,
24695
+ liveStreamId: roomId,
24621
24696
  reactions,
24622
24697
  });
24623
24698
  });
@@ -25110,23 +25185,6 @@ const loginAsVisitor = async (params) => {
25110
25185
  };
25111
25186
  /* end_public_function */
25112
25187
 
25113
- /* begin_public_function
25114
- id: client.get_current_user
25115
- */
25116
- const getCurrentUser = () => {
25117
- var _a;
25118
- const client = getActiveClient();
25119
- if (!client) {
25120
- throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
25121
- }
25122
- const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
25123
- if (!cache) {
25124
- throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
25125
- }
25126
- return userLinkedObject(cache);
25127
- };
25128
- /* end_public_function */
25129
-
25130
25188
  /* begin_public_function
25131
25189
  id: client.renew_access_token
25132
25190
  */
@@ -26556,7 +26614,7 @@ const getUserUnread = (callback) => {
26556
26614
  };
26557
26615
  };
26558
26616
 
26559
- var index$p = /*#__PURE__*/Object.freeze({
26617
+ var index$r = /*#__PURE__*/Object.freeze({
26560
26618
  __proto__: null,
26561
26619
  getActiveClient: getActiveClient,
26562
26620
  getActiveUser: getActiveUser,
@@ -27775,7 +27833,7 @@ const getMyFollowInfo = (callback) => {
27775
27833
  };
27776
27834
  /* end_public_function */
27777
27835
 
27778
- var index$o = /*#__PURE__*/Object.freeze({
27836
+ var index$q = /*#__PURE__*/Object.freeze({
27779
27837
  __proto__: null,
27780
27838
  blockUser: blockUser,
27781
27839
  unBlockUser: unBlockUser,
@@ -28357,6 +28415,462 @@ const getLiveChat = async (room) => {
28357
28415
  return undefined;
28358
28416
  };
28359
28417
 
28418
+ const convertRawInvitationToInternalInvitation = (rawInvitation) => {
28419
+ return Object.assign(Object.assign({}, rawInvitation), { createdById: rawInvitation.createdBy });
28420
+ };
28421
+
28422
+ const prepareInvitationPayload = (rawPayload) => {
28423
+ return Object.assign(Object.assign({}, rawPayload), { invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation), users: rawPayload.users.map(convertRawUserToInternalUser) });
28424
+ };
28425
+
28426
+ /* begin_public_function
28427
+ id: invitation.createInvitations
28428
+ */
28429
+ /**
28430
+ * ```js
28431
+ * import { createInvitations } from '@amityco/ts-sdk'
28432
+ * const created = await createInvitations({
28433
+ * type: string,
28434
+ * targetType: string,
28435
+ * targetId: string,
28436
+ * userIds: string[]
28437
+ * }))
28438
+ * ```
28439
+ *
28440
+ * Creates an {@link Amity.Invitation}
28441
+ *
28442
+ * @param bundle The data necessary to create a new {@link Amity.Invitation}
28443
+ * @returns The newly created {@link Amity.Invitation}
28444
+ *
28445
+ * @category Invitation API
28446
+ * @async
28447
+ */
28448
+ const createInvitations = async (bundle) => {
28449
+ const client = getActiveClient();
28450
+ client.log('invitation/createInvitations', bundle);
28451
+ const { data: payload } = await client.http.post('/api/v1/invitations', bundle);
28452
+ const data = prepareInvitationPayload(payload);
28453
+ const cachedAt = client.cache && Date.now();
28454
+ if (client.cache)
28455
+ ingestInCache(data, { cachedAt });
28456
+ fireEvent('local.invitation.created', data.invitations);
28457
+ return {
28458
+ data: data.invitations,
28459
+ cachedAt,
28460
+ };
28461
+ };
28462
+ /* end_public_function */
28463
+
28464
+ /* begin_public_function
28465
+ id: invitation.accept
28466
+ */
28467
+ /**
28468
+ * ```js
28469
+ * import { acceptInvitation } from '@amityco/ts-sdk'
28470
+ * const isAccepted = await acceptInvitation(invitationId)
28471
+ * ```
28472
+ *
28473
+ * Accepts a {@link Amity.Invitation} object
28474
+ *
28475
+ * @param invitationId the {@link Amity.Invitation} to accept
28476
+ * @returns A success boolean if the {@link Amity.Invitation} was accepted
28477
+ *
28478
+ * @category Invitation API
28479
+ * @async
28480
+ */
28481
+ const acceptInvitation = async (invitationId) => {
28482
+ var _a;
28483
+ const client = getActiveClient();
28484
+ client.log('invitation/acceptInvitation', invitationId);
28485
+ const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/accept`);
28486
+ const invitation = (_a = pullFromCache([
28487
+ 'invitation',
28488
+ 'get',
28489
+ invitationId,
28490
+ ])) === null || _a === void 0 ? void 0 : _a.data;
28491
+ if (invitation) {
28492
+ upsertInCache(['invitation', 'get', invitationId], { status: "approved" /* InvitationStatusEnum.Approved */ });
28493
+ fireEvent('local.invitation.updated', [invitation]);
28494
+ }
28495
+ return data.success;
28496
+ };
28497
+ /* end_public_function */
28498
+
28499
+ /* begin_public_function
28500
+ id: invitation.reject
28501
+ */
28502
+ /**
28503
+ * ```js
28504
+ * import { rejectInvitation } from '@amityco/ts-sdk'
28505
+ * const isRejected = await rejectInvitation(invitationId)
28506
+ * ```
28507
+ *
28508
+ * Rejects a {@link Amity.Invitation} object
28509
+ *
28510
+ * @param invitationId the {@link Amity.Invitation} to reject
28511
+ * @returns A success boolean if the {@link Amity.Invitation} was rejected
28512
+ *
28513
+ * @category Invitation API
28514
+ * @async
28515
+ */
28516
+ const rejectInvitation = async (invitationId) => {
28517
+ var _a;
28518
+ const client = getActiveClient();
28519
+ client.log('invitation/rejectInvitation', invitationId);
28520
+ const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/reject`);
28521
+ const invitation = (_a = pullFromCache([
28522
+ 'invitation',
28523
+ 'get',
28524
+ invitationId,
28525
+ ])) === null || _a === void 0 ? void 0 : _a.data;
28526
+ if (invitation) {
28527
+ upsertInCache(['invitation', 'get', invitationId], { status: "rejected" /* InvitationStatusEnum.Rejected */ });
28528
+ fireEvent('local.invitation.updated', [invitation]);
28529
+ }
28530
+ return data.success;
28531
+ };
28532
+ /* end_public_function */
28533
+
28534
+ var InvitationActionsEnum;
28535
+ (function (InvitationActionsEnum) {
28536
+ InvitationActionsEnum["OnLocalInvitationCreated"] = "onLocalInvitationCreated";
28537
+ InvitationActionsEnum["OnLocalInvitationUpdated"] = "onLocalInvitationUpdated";
28538
+ InvitationActionsEnum["OnLocalInvitationCanceled"] = "onLocalInvitationCanceled";
28539
+ })(InvitationActionsEnum || (InvitationActionsEnum = {}));
28540
+
28541
+ const invitationLinkedObject = (invitation) => {
28542
+ return Object.assign(Object.assign({}, invitation), { get user() {
28543
+ const cacheData = pullFromCache(['user', 'get', invitation.invitedUserPublicId]);
28544
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
28545
+ return userLinkedObject(cacheData.data);
28546
+ return undefined;
28547
+ },
28548
+ get createdBy() {
28549
+ const cacheData = pullFromCache(['user', 'get', invitation.inviterUserPublicId]);
28550
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
28551
+ return userLinkedObject(cacheData.data);
28552
+ return undefined;
28553
+ },
28554
+ get target() {
28555
+ if (invitation.targetType === 'community') {
28556
+ const cacheData = pullFromCache([
28557
+ 'community',
28558
+ 'get',
28559
+ invitation.targetId,
28560
+ ]);
28561
+ if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
28562
+ return cacheData.data;
28563
+ return undefined;
28564
+ }
28565
+ return undefined;
28566
+ }, accept: async () => {
28567
+ await acceptInvitation(invitation._id);
28568
+ }, reject: async () => {
28569
+ await rejectInvitation(invitation._id);
28570
+ } });
28571
+ };
28572
+
28573
+ class InvitationsPaginationController extends PaginationController {
28574
+ async getRequest(queryParams, token) {
28575
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
28576
+ const options = token ? { token } : { limit };
28577
+ const { data } = await this.http.get('/api/v1/invitations', { params: Object.assign(Object.assign({}, params), { options }) });
28578
+ return data;
28579
+ }
28580
+ }
28581
+
28582
+ class InvitationsQueryStreamController extends QueryStreamController {
28583
+ constructor(query, cacheKey, notifyChange, preparePayload) {
28584
+ super(query, cacheKey);
28585
+ this.notifyChange = notifyChange;
28586
+ this.preparePayload = preparePayload;
28587
+ }
28588
+ async saveToMainDB(response) {
28589
+ const processedPayload = await this.preparePayload(response);
28590
+ const client = getActiveClient();
28591
+ const cachedAt = client.cache && Date.now();
28592
+ if (client.cache) {
28593
+ ingestInCache(processedPayload, { cachedAt });
28594
+ }
28595
+ }
28596
+ appendToQueryStream(response, direction, refresh = false) {
28597
+ var _a, _b;
28598
+ if (refresh) {
28599
+ pushToCache(this.cacheKey, {
28600
+ data: response.invitations.map(getResolver('invitation')),
28601
+ });
28602
+ }
28603
+ else {
28604
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
28605
+ const invitations = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
28606
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
28607
+ ...new Set([...invitations, ...response.invitations.map(getResolver('invitation'))]),
28608
+ ] }));
28609
+ }
28610
+ }
28611
+ reactor(action) {
28612
+ return (invitations) => {
28613
+ var _a;
28614
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
28615
+ if (!collection)
28616
+ return;
28617
+ if (action === InvitationActionsEnum.OnLocalInvitationUpdated) {
28618
+ const isExist = collection.data.find(id => id === invitations[0].invitationId);
28619
+ if (!isExist)
28620
+ return;
28621
+ }
28622
+ if (action === InvitationActionsEnum.OnLocalInvitationCreated) {
28623
+ collection.data = [
28624
+ ...new Set([
28625
+ ...invitations.map(invitation => invitation.invitationId),
28626
+ ...collection.data,
28627
+ ]),
28628
+ ];
28629
+ }
28630
+ if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
28631
+ collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
28632
+ }
28633
+ pushToCache(this.cacheKey, collection);
28634
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
28635
+ };
28636
+ }
28637
+ subscribeRTE(createSubscriber) {
28638
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
28639
+ }
28640
+ }
28641
+
28642
+ /**
28643
+ * ```js
28644
+ * import { onLocalInvitationCreated } from '@amityco/ts-sdk'
28645
+ * const dispose = onLocalInvitationCreated(data => {
28646
+ * // ...
28647
+ * })
28648
+ * ```
28649
+ *
28650
+ * Fired when an {@link Amity.InvitationPayload} has been created
28651
+ *
28652
+ * @param callback The function to call when the event was fired
28653
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
28654
+ *
28655
+ * @category Invitation Events
28656
+ */
28657
+ const onLocalInvitationCreated = (callback) => {
28658
+ const client = getActiveClient();
28659
+ const disposers = [
28660
+ createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload => callback(payload)),
28661
+ ];
28662
+ return () => {
28663
+ disposers.forEach(fn => fn());
28664
+ };
28665
+ };
28666
+
28667
+ /**
28668
+ * ```js
28669
+ * import { onLocalInvitationUpdated } from '@amityco/ts-sdk'
28670
+ * const dispose = onLocalInvitationUpdated(data => {
28671
+ * // ...
28672
+ * })
28673
+ * ```
28674
+ *
28675
+ * Fired when an {@link Amity.InvitationPayload} has been updated
28676
+ *
28677
+ * @param callback The function to call when the event was fired
28678
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
28679
+ *
28680
+ * @category Invitation Events
28681
+ */
28682
+ const onLocalInvitationUpdated = (callback) => {
28683
+ const client = getActiveClient();
28684
+ const disposers = [
28685
+ createEventSubscriber(client, 'onLocalInvitationUpdated', 'local.invitation.updated', payload => callback(payload)),
28686
+ ];
28687
+ return () => {
28688
+ disposers.forEach(fn => fn());
28689
+ };
28690
+ };
28691
+
28692
+ /**
28693
+ * ```js
28694
+ * import { onLocalInvitationCanceled } from '@amityco/ts-sdk'
28695
+ * const dispose = onLocalInvitationCanceled(data => {
28696
+ * // ...
28697
+ * })
28698
+ * ```
28699
+ *
28700
+ * Fired when an {@link Amity.InvitationPayload} has been deleted
28701
+ *
28702
+ * @param callback The function to call when the event was fired
28703
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
28704
+ *
28705
+ * @category Invitation Events
28706
+ */
28707
+ const onLocalInvitationCanceled = (callback) => {
28708
+ const client = getActiveClient();
28709
+ const disposers = [
28710
+ createEventSubscriber(client, 'onLocalInvitationCanceled', 'local.invitation.canceled', payload => callback(payload)),
28711
+ ];
28712
+ return () => {
28713
+ disposers.forEach(fn => fn());
28714
+ };
28715
+ };
28716
+
28717
+ class InvitationsLiveCollectionController extends LiveCollectionController {
28718
+ constructor(query, callback) {
28719
+ const queryStreamId = hash(query);
28720
+ const cacheKey = ['invitation', 'collection', queryStreamId];
28721
+ const paginationController = new InvitationsPaginationController(query);
28722
+ super(paginationController, queryStreamId, cacheKey, callback);
28723
+ this.query = query;
28724
+ this.queryStreamController = new InvitationsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareInvitationPayload);
28725
+ this.callback = callback.bind(this);
28726
+ this.loadPage({ initial: true });
28727
+ }
28728
+ setup() {
28729
+ var _a;
28730
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
28731
+ if (!collection) {
28732
+ pushToCache(this.cacheKey, {
28733
+ data: [],
28734
+ params: this.query,
28735
+ });
28736
+ }
28737
+ }
28738
+ async persistModel(queryPayload) {
28739
+ await this.queryStreamController.saveToMainDB(queryPayload);
28740
+ }
28741
+ persistQueryStream({ response, direction, refresh, }) {
28742
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
28743
+ }
28744
+ startSubscription() {
28745
+ return this.queryStreamController.subscribeRTE([
28746
+ {
28747
+ fn: onLocalInvitationCreated,
28748
+ action: InvitationActionsEnum.OnLocalInvitationCreated,
28749
+ },
28750
+ {
28751
+ fn: onLocalInvitationUpdated,
28752
+ action: InvitationActionsEnum.OnLocalInvitationUpdated,
28753
+ },
28754
+ {
28755
+ fn: onLocalInvitationCanceled,
28756
+ action: InvitationActionsEnum.OnLocalInvitationCanceled,
28757
+ },
28758
+ ]);
28759
+ }
28760
+ notifyChange({ origin, loading, error }) {
28761
+ var _a, _b;
28762
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
28763
+ if (!collection)
28764
+ return;
28765
+ const data = this.applyFilter((_b = collection.data
28766
+ .map(id => pullFromCache(['invitation', 'get', id]))
28767
+ .filter(isNonNullable)
28768
+ .map(({ data }) => invitationLinkedObject(data))) !== null && _b !== void 0 ? _b : []);
28769
+ if (!this.shouldNotify(data) && origin === 'event')
28770
+ return;
28771
+ this.callback({
28772
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
28773
+ data,
28774
+ hasNextPage: !!this.paginationController.getNextToken(),
28775
+ loading,
28776
+ error,
28777
+ });
28778
+ }
28779
+ applyFilter(data) {
28780
+ let invitations = data;
28781
+ if (this.query.targetId) {
28782
+ invitations = invitations.filter(invitation => invitation.targetId === this.query.targetId);
28783
+ }
28784
+ if (this.query.statuses) {
28785
+ invitations = invitations.filter(invitation => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(invitation.status); });
28786
+ }
28787
+ if (this.query.targetType) {
28788
+ invitations = invitations.filter(invitation => invitation.targetType === this.query.targetType);
28789
+ }
28790
+ if (this.query.type) {
28791
+ invitations = invitations.filter(invitation => invitation.type === this.query.type);
28792
+ }
28793
+ const sortFn = (() => {
28794
+ switch (this.query.sortBy) {
28795
+ case 'firstCreated':
28796
+ return sortByFirstCreated;
28797
+ case 'lastCreated':
28798
+ return sortByLastCreated;
28799
+ default:
28800
+ return sortByLastCreated;
28801
+ }
28802
+ })();
28803
+ invitations = invitations.sort(sortFn);
28804
+ return invitations;
28805
+ }
28806
+ }
28807
+
28808
+ /**
28809
+ * Get invitations
28810
+ *
28811
+ * @param params the query parameters
28812
+ * @param callback the callback to be called when the invitations are updated
28813
+ * @returns invitations
28814
+ *
28815
+ * @category Invitation Live Collection
28816
+ *
28817
+ */
28818
+ const getInvitations$1 = (params, callback, config) => {
28819
+ const { log, cache } = getActiveClient();
28820
+ if (!cache) {
28821
+ console.log(ENABLE_CACHE_MESSAGE);
28822
+ }
28823
+ const timestamp = Date.now();
28824
+ log(`getInvitations: (tmpid: ${timestamp}) > listen`);
28825
+ const invitationsLiveCollection = new InvitationsLiveCollectionController(params, callback);
28826
+ const disposers = invitationsLiveCollection.startSubscription();
28827
+ const cacheKey = invitationsLiveCollection.getCacheKey();
28828
+ disposers.push(() => {
28829
+ dropFromCache(cacheKey);
28830
+ });
28831
+ return () => {
28832
+ log(`getInvitations (tmpid: ${timestamp}) > dispose`);
28833
+ disposers.forEach(fn => fn());
28834
+ };
28835
+ };
28836
+
28837
+ const prepareMyInvitationsPayload = (rawPayload) => {
28838
+ return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser), invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation) });
28839
+ };
28840
+
28841
+ /* begin_public_function
28842
+ id: invitation.get
28843
+ */
28844
+ /**
28845
+ * ```js
28846
+ * import { getInvitation } from '@amityco/ts-sdk'
28847
+ * const { invitation } = await getInvitation(targetType, targetId)
28848
+ * ```
28849
+ *
28850
+ * Get a {@link Amity.Invitation} object
28851
+ *
28852
+ * @param targetType The type of the target of the {@link Amity.Invitation}
28853
+ * @param targetId The ID of the target of the {@link Amity.Invitation}
28854
+ * @returns A {@link Amity.Invitation} object
28855
+ *
28856
+ * @category Invitation API
28857
+ * @async
28858
+ */
28859
+ const getInvitation = async (params) => {
28860
+ const client = getActiveClient();
28861
+ client.log('invitation/getInvitation', params.targetType, params.targetId, params.type);
28862
+ const { data: payload } = await client.http.get(`/api/v1/invitations/me`, { params });
28863
+ const data = prepareMyInvitationsPayload(payload);
28864
+ const cachedAt = client.cache && Date.now();
28865
+ if (client.cache)
28866
+ ingestInCache(data, { cachedAt });
28867
+ return {
28868
+ data: data.invitations[0] ? invitationLinkedObject(data.invitations[0]) : undefined,
28869
+ cachedAt,
28870
+ };
28871
+ };
28872
+ /* end_public_function */
28873
+
28360
28874
  const roomLinkedObject = (room) => {
28361
28875
  return Object.assign(Object.assign({}, room), { get moderation() {
28362
28876
  var _a;
@@ -28376,7 +28890,8 @@ const roomLinkedObject = (room) => {
28376
28890
  },
28377
28891
  get user() {
28378
28892
  var _a;
28379
- return (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
28893
+ const user = (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
28894
+ return user ? userLinkedObject(user) : user;
28380
28895
  },
28381
28896
  get childRooms() {
28382
28897
  if (!room.childRoomIds || room.childRoomIds.length === 0)
@@ -28390,7 +28905,23 @@ const roomLinkedObject = (room) => {
28390
28905
  return roomLinkedObject(roomCache);
28391
28906
  })
28392
28907
  .filter(isNonNullable);
28393
- }, getLiveChat: () => getLiveChat(room) });
28908
+ }, participants: room.participants.map(participant => (Object.assign(Object.assign({}, participant), { get user() {
28909
+ var _a;
28910
+ const user = (_a = pullFromCache(['user', 'get', participant.userId])) === null || _a === void 0 ? void 0 : _a.data;
28911
+ return user ? userLinkedObject(user) : user;
28912
+ } }))), getLiveChat: () => getLiveChat(room), createInvitation: (userId) => createInvitations({
28913
+ type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */,
28914
+ targetType: 'room',
28915
+ targetId: room.roomId,
28916
+ userIds: [userId],
28917
+ }), getInvitations: (params, callback) => getInvitations$1(Object.assign(Object.assign({}, params), { targetId: room.roomId, targetType: 'room', type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */ }), callback), getMyInvitation: async () => {
28918
+ const { data } = await getInvitation({
28919
+ targetId: room.roomId,
28920
+ targetType: 'room',
28921
+ type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */,
28922
+ });
28923
+ return data;
28924
+ } });
28394
28925
  };
28395
28926
 
28396
28927
  const postLinkedObject = (post) => {
@@ -28795,7 +29326,12 @@ const notificationTrayLinkedObject = (noti) => {
28795
29326
  .map(({ publicId }) => pullFromCache(['user', 'get', publicId]))
28796
29327
  .filter(isNonNullable)
28797
29328
  .map(({ data }) => data)
28798
- .map(user => userLinkedObject(user)) });
29329
+ .map(user => userLinkedObject(user)), get event() {
29330
+ const cacheData = pullFromCache(['event', 'get', noti.actionReferenceId]);
29331
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29332
+ return;
29333
+ return cacheData.data;
29334
+ } });
28799
29335
  };
28800
29336
 
28801
29337
  /*
@@ -29363,462 +29899,6 @@ const getJoinRequests = (params, callback, config) => {
29363
29899
  };
29364
29900
  };
29365
29901
 
29366
- const convertRawInvitationToInternalInvitation = (rawInvitation) => {
29367
- return Object.assign(Object.assign({}, rawInvitation), { createdById: rawInvitation.createdBy });
29368
- };
29369
-
29370
- const prepareInvitationPayload = (rawPayload) => {
29371
- return Object.assign(Object.assign({}, rawPayload), { invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation), users: rawPayload.users.map(convertRawUserToInternalUser) });
29372
- };
29373
-
29374
- /* begin_public_function
29375
- id: invitation.createInvitations
29376
- */
29377
- /**
29378
- * ```js
29379
- * import { createInvitations } from '@amityco/ts-sdk'
29380
- * const created = await createInvitations({
29381
- * type: string,
29382
- * targetType: string,
29383
- * targetId: string,
29384
- * userIds: string[]
29385
- * }))
29386
- * ```
29387
- *
29388
- * Creates an {@link Amity.Invitation}
29389
- *
29390
- * @param bundle The data necessary to create a new {@link Amity.Invitation}
29391
- * @returns The newly created {@link Amity.Invitation}
29392
- *
29393
- * @category Invitation API
29394
- * @async
29395
- */
29396
- const createInvitations = async (bundle) => {
29397
- const client = getActiveClient();
29398
- client.log('invitation/createInvitations', bundle);
29399
- const { data: payload } = await client.http.post('/api/v1/invitations', bundle);
29400
- const data = prepareInvitationPayload(payload);
29401
- const cachedAt = client.cache && Date.now();
29402
- if (client.cache)
29403
- ingestInCache(data, { cachedAt });
29404
- fireEvent('local.invitation.created', data.invitations);
29405
- return {
29406
- data: data.invitations,
29407
- cachedAt,
29408
- };
29409
- };
29410
- /* end_public_function */
29411
-
29412
- /* begin_public_function
29413
- id: invitation.accept
29414
- */
29415
- /**
29416
- * ```js
29417
- * import { acceptInvitation } from '@amityco/ts-sdk'
29418
- * const isAccepted = await acceptInvitation(invitationId)
29419
- * ```
29420
- *
29421
- * Accepts a {@link Amity.Invitation} object
29422
- *
29423
- * @param invitationId the {@link Amity.Invitation} to accept
29424
- * @returns A success boolean if the {@link Amity.Invitation} was accepted
29425
- *
29426
- * @category Invitation API
29427
- * @async
29428
- */
29429
- const acceptInvitation = async (invitationId) => {
29430
- var _a;
29431
- const client = getActiveClient();
29432
- client.log('invitation/acceptInvitation', invitationId);
29433
- const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/accept`);
29434
- const invitation = (_a = pullFromCache([
29435
- 'invitation',
29436
- 'get',
29437
- invitationId,
29438
- ])) === null || _a === void 0 ? void 0 : _a.data;
29439
- if (invitation) {
29440
- upsertInCache(['invitation', 'get', invitationId], { status: "approved" /* InvitationStatusEnum.Approved */ });
29441
- fireEvent('local.invitation.updated', [invitation]);
29442
- }
29443
- return data.success;
29444
- };
29445
- /* end_public_function */
29446
-
29447
- /* begin_public_function
29448
- id: invitation.reject
29449
- */
29450
- /**
29451
- * ```js
29452
- * import { rejectInvitation } from '@amityco/ts-sdk'
29453
- * const isRejected = await rejectInvitation(invitationId)
29454
- * ```
29455
- *
29456
- * Rejects a {@link Amity.Invitation} object
29457
- *
29458
- * @param invitationId the {@link Amity.Invitation} to reject
29459
- * @returns A success boolean if the {@link Amity.Invitation} was rejected
29460
- *
29461
- * @category Invitation API
29462
- * @async
29463
- */
29464
- const rejectInvitation = async (invitationId) => {
29465
- var _a;
29466
- const client = getActiveClient();
29467
- client.log('invitation/rejectInvitation', invitationId);
29468
- const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/reject`);
29469
- const invitation = (_a = pullFromCache([
29470
- 'invitation',
29471
- 'get',
29472
- invitationId,
29473
- ])) === null || _a === void 0 ? void 0 : _a.data;
29474
- if (invitation) {
29475
- upsertInCache(['invitation', 'get', invitationId], { status: "rejected" /* InvitationStatusEnum.Rejected */ });
29476
- fireEvent('local.invitation.updated', [invitation]);
29477
- }
29478
- return data.success;
29479
- };
29480
- /* end_public_function */
29481
-
29482
- const prepareMyInvitationsPayload = (rawPayload) => {
29483
- return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser), invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation) });
29484
- };
29485
-
29486
- const invitationLinkedObject = (invitation) => {
29487
- return Object.assign(Object.assign({}, invitation), { get user() {
29488
- const cacheData = pullFromCache(['user', 'get', invitation.invitedUserPublicId]);
29489
- if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
29490
- return userLinkedObject(cacheData.data);
29491
- return undefined;
29492
- },
29493
- get createdBy() {
29494
- const cacheData = pullFromCache(['user', 'get', invitation.inviterUserPublicId]);
29495
- if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
29496
- return userLinkedObject(cacheData.data);
29497
- return undefined;
29498
- },
29499
- get target() {
29500
- if (invitation.targetType === 'community') {
29501
- const cacheData = pullFromCache([
29502
- 'community',
29503
- 'get',
29504
- invitation.targetId,
29505
- ]);
29506
- if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
29507
- return cacheData.data;
29508
- return undefined;
29509
- }
29510
- return undefined;
29511
- }, accept: async () => {
29512
- await acceptInvitation(invitation._id);
29513
- }, reject: async () => {
29514
- await rejectInvitation(invitation._id);
29515
- } });
29516
- };
29517
-
29518
- /* begin_public_function
29519
- id: invitation.get
29520
- */
29521
- /**
29522
- * ```js
29523
- * import { getInvitation } from '@amityco/ts-sdk'
29524
- * const { invitation } = await getInvitation(targetType, targetId)
29525
- * ```
29526
- *
29527
- * Get a {@link Amity.Invitation} object
29528
- *
29529
- * @param targetType The type of the target of the {@link Amity.Invitation}
29530
- * @param targetId The ID of the target of the {@link Amity.Invitation}
29531
- * @returns A {@link Amity.Invitation} object
29532
- *
29533
- * @category Invitation API
29534
- * @async
29535
- */
29536
- const getInvitation = async (targetType, targetId) => {
29537
- const client = getActiveClient();
29538
- client.log('invitation/getInvitation', targetType, targetId);
29539
- const { data: payload } = await client.http.get(`/api/v1/invitations/me`, { params: { targetType, targetId } });
29540
- const data = prepareMyInvitationsPayload(payload);
29541
- const cachedAt = client.cache && Date.now();
29542
- if (client.cache)
29543
- ingestInCache(data, { cachedAt });
29544
- return {
29545
- data: data.invitations[0] ? invitationLinkedObject(data.invitations[0]) : undefined,
29546
- cachedAt,
29547
- };
29548
- };
29549
- /* end_public_function */
29550
-
29551
- var InvitationActionsEnum;
29552
- (function (InvitationActionsEnum) {
29553
- InvitationActionsEnum["OnLocalInvitationCreated"] = "onLocalInvitationCreated";
29554
- InvitationActionsEnum["OnLocalInvitationUpdated"] = "onLocalInvitationUpdated";
29555
- InvitationActionsEnum["OnLocalInvitationDeleted"] = "onLocalInvitationDeleted";
29556
- })(InvitationActionsEnum || (InvitationActionsEnum = {}));
29557
-
29558
- class InvitationsPaginationController extends PaginationController {
29559
- async getRequest(queryParams, token) {
29560
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
29561
- const options = token ? { token } : { limit };
29562
- const { data } = await this.http.get('/api/v1/invitations', { params: Object.assign(Object.assign({}, params), { options }) });
29563
- return data;
29564
- }
29565
- }
29566
-
29567
- class InvitationsQueryStreamController extends QueryStreamController {
29568
- constructor(query, cacheKey, notifyChange, preparePayload) {
29569
- super(query, cacheKey);
29570
- this.notifyChange = notifyChange;
29571
- this.preparePayload = preparePayload;
29572
- }
29573
- async saveToMainDB(response) {
29574
- const processedPayload = await this.preparePayload(response);
29575
- const client = getActiveClient();
29576
- const cachedAt = client.cache && Date.now();
29577
- if (client.cache) {
29578
- ingestInCache(processedPayload, { cachedAt });
29579
- }
29580
- }
29581
- appendToQueryStream(response, direction, refresh = false) {
29582
- var _a, _b;
29583
- if (refresh) {
29584
- pushToCache(this.cacheKey, {
29585
- data: response.invitations.map(getResolver('invitation')),
29586
- });
29587
- }
29588
- else {
29589
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
29590
- const invitations = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
29591
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
29592
- ...new Set([...invitations, ...response.invitations.map(getResolver('invitation'))]),
29593
- ] }));
29594
- }
29595
- }
29596
- reactor(action) {
29597
- return (invitations) => {
29598
- var _a;
29599
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
29600
- if (!collection)
29601
- return;
29602
- if (action === InvitationActionsEnum.OnLocalInvitationUpdated) {
29603
- const isExist = collection.data.find(id => id === invitations[0].invitationId);
29604
- if (!isExist)
29605
- return;
29606
- }
29607
- if (action === InvitationActionsEnum.OnLocalInvitationCreated) {
29608
- collection.data = [
29609
- ...new Set([
29610
- ...invitations.map(invitation => invitation.invitationId),
29611
- ...collection.data,
29612
- ]),
29613
- ];
29614
- }
29615
- if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
29616
- collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
29617
- }
29618
- pushToCache(this.cacheKey, collection);
29619
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
29620
- };
29621
- }
29622
- subscribeRTE(createSubscriber) {
29623
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
29624
- }
29625
- }
29626
-
29627
- /**
29628
- * ```js
29629
- * import { onLocalInvitationCreated } from '@amityco/ts-sdk'
29630
- * const dispose = onLocalInvitationCreated(data => {
29631
- * // ...
29632
- * })
29633
- * ```
29634
- *
29635
- * Fired when an {@link Amity.InvitationPayload} has been created
29636
- *
29637
- * @param callback The function to call when the event was fired
29638
- * @returns an {@link Amity.Unsubscriber} function to stop listening
29639
- *
29640
- * @category Invitation Events
29641
- */
29642
- const onLocalInvitationCreated = (callback) => {
29643
- const client = getActiveClient();
29644
- const disposers = [
29645
- createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload => callback(payload)),
29646
- ];
29647
- return () => {
29648
- disposers.forEach(fn => fn());
29649
- };
29650
- };
29651
-
29652
- /**
29653
- * ```js
29654
- * import { onLocalInvitationUpdated } from '@amityco/ts-sdk'
29655
- * const dispose = onLocalInvitationUpdated(data => {
29656
- * // ...
29657
- * })
29658
- * ```
29659
- *
29660
- * Fired when an {@link Amity.InvitationPayload} has been updated
29661
- *
29662
- * @param callback The function to call when the event was fired
29663
- * @returns an {@link Amity.Unsubscriber} function to stop listening
29664
- *
29665
- * @category Invitation Events
29666
- */
29667
- const onLocalInvitationUpdated = (callback) => {
29668
- const client = getActiveClient();
29669
- const disposers = [
29670
- createEventSubscriber(client, 'onLocalInvitationUpdated', 'local.invitation.updated', payload => callback(payload)),
29671
- ];
29672
- return () => {
29673
- disposers.forEach(fn => fn());
29674
- };
29675
- };
29676
-
29677
- /**
29678
- * ```js
29679
- * import { onLocalInvitationDeleted } from '@amityco/ts-sdk'
29680
- * const dispose = onLocalInvitationDeleted(data => {
29681
- * // ...
29682
- * })
29683
- * ```
29684
- *
29685
- * Fired when an {@link Amity.InvitationPayload} has been deleted
29686
- *
29687
- * @param callback The function to call when the event was fired
29688
- * @returns an {@link Amity.Unsubscriber} function to stop listening
29689
- *
29690
- * @category Invitation Events
29691
- */
29692
- const onLocalInvitationDeleted = (callback) => {
29693
- const client = getActiveClient();
29694
- const disposers = [
29695
- createEventSubscriber(client, 'onLocalInvitationDeleted', 'local.invitation.deleted', payload => callback(payload)),
29696
- ];
29697
- return () => {
29698
- disposers.forEach(fn => fn());
29699
- };
29700
- };
29701
-
29702
- class InvitationsLiveCollectionController extends LiveCollectionController {
29703
- constructor(query, callback) {
29704
- const queryStreamId = hash(query);
29705
- const cacheKey = ['invitation', 'collection', queryStreamId];
29706
- const paginationController = new InvitationsPaginationController(query);
29707
- super(paginationController, queryStreamId, cacheKey, callback);
29708
- this.query = query;
29709
- this.queryStreamController = new InvitationsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareInvitationPayload);
29710
- this.callback = callback.bind(this);
29711
- this.loadPage({ initial: true });
29712
- }
29713
- setup() {
29714
- var _a;
29715
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
29716
- if (!collection) {
29717
- pushToCache(this.cacheKey, {
29718
- data: [],
29719
- params: this.query,
29720
- });
29721
- }
29722
- }
29723
- async persistModel(queryPayload) {
29724
- await this.queryStreamController.saveToMainDB(queryPayload);
29725
- }
29726
- persistQueryStream({ response, direction, refresh, }) {
29727
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
29728
- }
29729
- startSubscription() {
29730
- return this.queryStreamController.subscribeRTE([
29731
- {
29732
- fn: onLocalInvitationCreated,
29733
- action: InvitationActionsEnum.OnLocalInvitationCreated,
29734
- },
29735
- {
29736
- fn: onLocalInvitationUpdated,
29737
- action: InvitationActionsEnum.OnLocalInvitationUpdated,
29738
- },
29739
- {
29740
- fn: onLocalInvitationDeleted,
29741
- action: InvitationActionsEnum.OnLocalInvitationDeleted,
29742
- },
29743
- ]);
29744
- }
29745
- notifyChange({ origin, loading, error }) {
29746
- var _a, _b;
29747
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
29748
- if (!collection)
29749
- return;
29750
- const data = this.applyFilter((_b = collection.data
29751
- .map(id => pullFromCache(['invitation', 'get', id]))
29752
- .filter(isNonNullable)
29753
- .map(({ data }) => invitationLinkedObject(data))) !== null && _b !== void 0 ? _b : []);
29754
- if (!this.shouldNotify(data) && origin === 'event')
29755
- return;
29756
- this.callback({
29757
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
29758
- data,
29759
- hasNextPage: !!this.paginationController.getNextToken(),
29760
- loading,
29761
- error,
29762
- });
29763
- }
29764
- applyFilter(data) {
29765
- let invitations = data;
29766
- if (this.query.targetId) {
29767
- invitations = invitations.filter(invitation => invitation.targetId === this.query.targetId);
29768
- }
29769
- if (this.query.statuses) {
29770
- invitations = invitations.filter(invitation => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(invitation.status); });
29771
- }
29772
- if (this.query.targetType) {
29773
- invitations = invitations.filter(invitation => invitation.targetType === this.query.targetType);
29774
- }
29775
- if (this.query.type) {
29776
- invitations = invitations.filter(invitation => invitation.type === this.query.type);
29777
- }
29778
- const sortFn = (() => {
29779
- switch (this.query.sortBy) {
29780
- case 'firstCreated':
29781
- return sortByFirstCreated;
29782
- case 'lastCreated':
29783
- return sortByLastCreated;
29784
- default:
29785
- return sortByLastCreated;
29786
- }
29787
- })();
29788
- invitations = invitations.sort(sortFn);
29789
- return invitations;
29790
- }
29791
- }
29792
-
29793
- /**
29794
- * Get invitations
29795
- *
29796
- * @param params the query parameters
29797
- * @param callback the callback to be called when the invitations are updated
29798
- * @returns invitations
29799
- *
29800
- * @category Invitation Live Collection
29801
- *
29802
- */
29803
- const getInvitations = (params, callback, config) => {
29804
- const { log, cache } = getActiveClient();
29805
- if (!cache) {
29806
- console.log(ENABLE_CACHE_MESSAGE);
29807
- }
29808
- const timestamp = Date.now();
29809
- log(`getInvitations: (tmpid: ${timestamp}) > listen`);
29810
- const invitationsLiveCollection = new InvitationsLiveCollectionController(params, callback);
29811
- const disposers = invitationsLiveCollection.startSubscription();
29812
- const cacheKey = invitationsLiveCollection.getCacheKey();
29813
- disposers.push(() => {
29814
- dropFromCache(cacheKey);
29815
- });
29816
- return () => {
29817
- log(`getInvitations (tmpid: ${timestamp}) > dispose`);
29818
- disposers.forEach(fn => fn());
29819
- };
29820
- };
29821
-
29822
29902
  const communityLinkedObject = (community) => {
29823
29903
  return Object.assign(Object.assign({}, community), { get categories() {
29824
29904
  var _a;
@@ -29838,9 +29918,12 @@ const communityLinkedObject = (community) => {
29838
29918
  userIds,
29839
29919
  });
29840
29920
  }, getMemberInvitations: (params, callback) => {
29841
- return getInvitations(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
29921
+ return getInvitations$1(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
29842
29922
  }, getInvitation: async () => {
29843
- const { data } = await getInvitation('community', community.communityId);
29923
+ const { data } = await getInvitation({
29924
+ targetType: 'community',
29925
+ targetId: community.communityId,
29926
+ });
29844
29927
  return data;
29845
29928
  }, join: async () => joinRequest(community.communityId), getJoinRequests: (params, callback) => {
29846
29929
  return getJoinRequests(Object.assign(Object.assign({}, params), { communityId: community.communityId }), callback);
@@ -29850,6 +29933,578 @@ const communityLinkedObject = (community) => {
29850
29933
  } });
29851
29934
  };
29852
29935
 
29936
+ const prepareEventResponsePayload = (rawPayload) => {
29937
+ return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
29938
+ };
29939
+
29940
+ const eventResponseLinkedObject = (event) => {
29941
+ return Object.assign(Object.assign({}, event), { get status() {
29942
+ return event.status;
29943
+ },
29944
+ get userId() {
29945
+ return event.userId;
29946
+ },
29947
+ get eventId() {
29948
+ return event.eventId;
29949
+ },
29950
+ get respondedAt() {
29951
+ return event.respondedAt;
29952
+ },
29953
+ get event() {
29954
+ const cacheData = pullFromCache(['event', 'get', event.eventId]);
29955
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29956
+ return;
29957
+ return cacheData.data;
29958
+ },
29959
+ get user() {
29960
+ const cacheData = pullFromCache(['user', 'get', event.userId]);
29961
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29962
+ return;
29963
+ return userLinkedObject(cacheData.data);
29964
+ } });
29965
+ };
29966
+
29967
+ /* begin_public_function
29968
+ id: event.rsvp.create
29969
+ */
29970
+ /**
29971
+ * ```js
29972
+ * import { event } from '@amityco/ts-sdk'
29973
+ * const response = await event.createRSVP(eventId, status)
29974
+ * ```
29975
+ *
29976
+ * Creates an {@link Amity.EventResponse} for the active user for a specific event.
29977
+ *
29978
+ * @param eventId The ID of the {@link Amity.EventResponse} to create an RSVP for
29979
+ * @param status The RSVP status to set for the event
29980
+ * @returns The {@link Amity.EventResponse} with updated RSVP information
29981
+ *
29982
+ * @category Event API
29983
+ * @async
29984
+ */
29985
+ const createRSVP = async (eventId, status) => {
29986
+ const client = getActiveClient();
29987
+ client.log('event/createRSVP', eventId, status);
29988
+ const { data: payload } = await client.http.post(`/api/v1/events/${eventId}/rsvp`, { status });
29989
+ fireEvent('local.rsvp.created', payload);
29990
+ const data = prepareEventResponsePayload(payload);
29991
+ const cachedAt = client.cache && Date.now();
29992
+ if (client.cache)
29993
+ ingestInCache(data, { cachedAt });
29994
+ return {
29995
+ data: eventResponseLinkedObject(data.eventResponses[0]),
29996
+ cachedAt,
29997
+ };
29998
+ };
29999
+ /* end_public_function */
30000
+
30001
+ /* begin_public_function
30002
+ id: event.update
30003
+ */
30004
+ /**
30005
+ * ```js
30006
+ * import { event } from '@amityco/ts-sdk'
30007
+ * const response = await event.updateRSVP(eventId, status)
30008
+ * ```
30009
+ *
30010
+ * Updates an {@link Amity.EventResponse}
30011
+ *
30012
+ * @param eventId The ID of the {@link Amity.EventResponse} to edit
30013
+ * @param bundle The data necessary to update an existing {@link Amity.EventResponse}
30014
+ * @returns the updated {@link Amity.EventResponse}
30015
+ *
30016
+ * @category Event API
30017
+ * @async
30018
+ */
30019
+ const updateRSVP = async (eventId, status) => {
30020
+ const client = getActiveClient();
30021
+ client.log('event/updateRSVP', eventId, status);
30022
+ const { data: payload } = await client.http.put(`/api/v1/events/${eventId}/rsvp`, { status });
30023
+ fireEvent('local.rsvp.updated', payload);
30024
+ const data = prepareEventResponsePayload(payload);
30025
+ const cachedAt = client.cache && Date.now();
30026
+ if (client.cache)
30027
+ ingestInCache(data, { cachedAt });
30028
+ return {
30029
+ data: eventResponseLinkedObject(data.eventResponses[0]),
30030
+ cachedAt,
30031
+ };
30032
+ };
30033
+ /* end_public_function */
30034
+
30035
+ const prepareEventPayload = (rawPayload) => {
30036
+ return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
30037
+ };
30038
+
30039
+ const createEventEventSubscriber = (event, callback) => {
30040
+ const client = getActiveClient();
30041
+ const filter = (payload) => {
30042
+ const unpackedPayload = prepareEventPayload(payload);
30043
+ if (!client.cache) {
30044
+ callback(unpackedPayload.events[0]);
30045
+ }
30046
+ else {
30047
+ ingestInCache(unpackedPayload);
30048
+ const event = pullFromCache([
30049
+ 'event',
30050
+ 'get',
30051
+ unpackedPayload.events[0].eventId,
30052
+ ]);
30053
+ callback(event.data);
30054
+ }
30055
+ };
30056
+ return createEventSubscriber(client, event, event, filter);
30057
+ };
30058
+
30059
+ const createEventResponseSubscriber = (event, callback) => {
30060
+ const client = getActiveClient();
30061
+ const filter = (payload) => {
30062
+ const unpackedPayload = prepareEventResponsePayload(payload);
30063
+ if (!client.cache) {
30064
+ callback(unpackedPayload);
30065
+ }
30066
+ else {
30067
+ ingestInCache(unpackedPayload.event[0]);
30068
+ const eventResponse = pullFromCache([
30069
+ 'eventResponse',
30070
+ 'get',
30071
+ payload.eventResponses[0].eventId,
30072
+ ]);
30073
+ callback(eventResponse.data);
30074
+ }
30075
+ };
30076
+ return createEventSubscriber(client, event, event, filter);
30077
+ };
30078
+
30079
+ /* begin_public_function
30080
+ id: event.rsvp.me
30081
+ */
30082
+ /**
30083
+ * ```js
30084
+ * import { event } from '@amityco/ts-sdk'
30085
+ * const myRSVP = await event.getMyRSVP()
30086
+ * ```
30087
+ *
30088
+ * Joins a {@link Amity.EventResponse} object
30089
+ *
30090
+ * @param eventId the {@link Amity.EventResponse} to get RSVP for
30091
+ * @returns A success boolean if the {@link Amity.EventResponse} RSVP was retrieved
30092
+ *
30093
+ * @category Event API
30094
+ * @async
30095
+ */
30096
+ const getMyRSVP = async (eventId) => {
30097
+ const client = getActiveClient();
30098
+ client.log('event/getMyRSVP', eventId);
30099
+ const { data: payload } = await client.http.get(`/api/v1/events/${eventId}/me/rsvp`);
30100
+ const data = prepareEventResponsePayload(payload);
30101
+ const cachedAt = client.cache && Date.now();
30102
+ if (client.cache)
30103
+ ingestInCache(data, { cachedAt });
30104
+ return {
30105
+ data: eventResponseLinkedObject(data.eventResponses[0]),
30106
+ cachedAt,
30107
+ };
30108
+ };
30109
+ /* end_public_function */
30110
+ /**
30111
+ * ```js
30112
+ * import { event } from '@amityco/ts-sdk'
30113
+ * const event = event.getMyRSVP.locally(eventId)
30114
+ * ```
30115
+ *
30116
+ * Fetches a {@link Amity.EventResponse} object in cache
30117
+ *
30118
+ * @param eventId the ID of the {@link Amity.EventResponse} to fetch
30119
+ * @returns the associated {@link Amity.EventResponse} object
30120
+ *
30121
+ * @category Event API
30122
+ */
30123
+ getMyRSVP.locally = (eventId) => {
30124
+ const client = getActiveClient();
30125
+ client.log('event/getMyRSVP.locally', eventId);
30126
+ if (!client.cache)
30127
+ return;
30128
+ const cache = pullFromCache(['event', 'getMyRSVP', eventId]);
30129
+ if (!cache)
30130
+ return;
30131
+ return {
30132
+ data: cache.data,
30133
+ cachedAt: cache.cachedAt,
30134
+ };
30135
+ };
30136
+
30137
+ var EventActionsEnum;
30138
+ (function (EventActionsEnum) {
30139
+ EventActionsEnum["OnEventCreated"] = "onEventCreated";
30140
+ EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
30141
+ EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
30142
+ EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
30143
+ EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
30144
+ })(EventActionsEnum || (EventActionsEnum = {}));
30145
+
30146
+ class RSVPPaginationController extends PaginationController {
30147
+ async getRequest(queryParams, token) {
30148
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, eventId } = queryParams, params = __rest(queryParams, ["limit", "eventId"]);
30149
+ const options = token ? { token } : { limit };
30150
+ const { data: response } = await this.http.get(`/api/v1/events/${eventId}/rsvp`, { params: Object.assign(Object.assign({}, params), { options }) });
30151
+ return response;
30152
+ }
30153
+ }
30154
+
30155
+ class RSVPQueryStreamController extends QueryStreamController {
30156
+ constructor(query, cacheKey, notifyChange, preparePayload) {
30157
+ super(query, cacheKey);
30158
+ this.notifyChange = notifyChange;
30159
+ this.preparePayload = preparePayload;
30160
+ }
30161
+ async saveToMainDB(response) {
30162
+ const processedPayload = this.preparePayload(response);
30163
+ const client = getActiveClient();
30164
+ const cachedAt = client.cache && Date.now();
30165
+ if (client.cache)
30166
+ ingestInCache({ eventResponses: [processedPayload] }, { cachedAt });
30167
+ }
30168
+ appendToQueryStream(response, direction, refresh = false) {
30169
+ var _a, _b;
30170
+ if (refresh) {
30171
+ pushToCache(this.cacheKey, {
30172
+ data: response.eventResponses.map(getResolver('eventResponse')),
30173
+ });
30174
+ }
30175
+ else {
30176
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30177
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
30178
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
30179
+ ...new Set([...events, ...response.eventResponses.map(getResolver('eventResponse'))]),
30180
+ ] }));
30181
+ }
30182
+ }
30183
+ reactor(action) {
30184
+ return (event) => {
30185
+ var _a;
30186
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30187
+ if (!collection)
30188
+ return;
30189
+ if (action === EventActionsEnum.OnRSVPCreated) {
30190
+ const client = getActiveClient();
30191
+ if (client.userId !== event.userId)
30192
+ return;
30193
+ collection.data = [...new Set([event.eventId, ...collection.data])];
30194
+ }
30195
+ if (action === EventActionsEnum.OnEventDeleted) {
30196
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
30197
+ }
30198
+ pushToCache(this.cacheKey, collection);
30199
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
30200
+ };
30201
+ }
30202
+ subscribeRTE(createSubscriber) {
30203
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
30204
+ }
30205
+ }
30206
+
30207
+ /**
30208
+ * ```js
30209
+ * import { EventRepository } from '@amityco/ts-sdk'
30210
+ * const dispose = EventRepository.onEventCreated(event => {
30211
+ * // ...
30212
+ * })
30213
+ * ```
30214
+ *
30215
+ * Fired when an RSVP response for a {@link Amity.Event} has been created
30216
+ *
30217
+ * @param callback The function to call when the event was fired
30218
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30219
+ *
30220
+ * @category Event Events
30221
+ */
30222
+ const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
30223
+
30224
+ /**
30225
+ * ```js
30226
+ * import { EventRepository } from '@amityco/ts-sdk'
30227
+ * const dispose = EventRepository.onEventUpdated(event => {
30228
+ * // ...
30229
+ * })
30230
+ * ```
30231
+ *
30232
+ * Fired when a {@link Amity.Event} has been updated
30233
+ *
30234
+ * @param callback The function to call when the event was fired
30235
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30236
+ *
30237
+ * @category Event Events
30238
+ */
30239
+ const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
30240
+
30241
+ /**
30242
+ * ```js
30243
+ * import { EventRepository } from '@amityco/ts-sdk'
30244
+ * const dispose = EventRepository.onEventDeleted(event => {
30245
+ * // ...
30246
+ * })
30247
+ * ```
30248
+ *
30249
+ * Fired when a {@link Amity.Event} has been deleted
30250
+ *
30251
+ * @param callback The function to call when the event was fired
30252
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30253
+ *
30254
+ * @category Event Events
30255
+ */
30256
+ const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
30257
+
30258
+ /**
30259
+ * ```js
30260
+ * import { EventRepository } from '@amityco/ts-sdk'
30261
+ * const dispose = EventRepository.onLocalEventCreated(event => {
30262
+ * // ...
30263
+ * })
30264
+ * ```
30265
+ *
30266
+ * Fired when a {@link Amity.Event} has been created
30267
+ *
30268
+ * @param callback The function to call when the event was fired
30269
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30270
+ *
30271
+ * @category Event Events
30272
+ */
30273
+ const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
30274
+
30275
+ /**
30276
+ * ```js
30277
+ * import { EventRepository } from '@amityco/ts-sdk'
30278
+ * const dispose = EventRepository.onLocalEventUpdated(event => {
30279
+ * // ...
30280
+ * })
30281
+ * ```
30282
+ *
30283
+ * Fired when a {@link Amity.Event} has been updated
30284
+ *
30285
+ * @param callback The function to call when the event was fired
30286
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30287
+ *
30288
+ * @category Event Events
30289
+ */
30290
+ const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
30291
+
30292
+ /**
30293
+ * ```js
30294
+ * import { EventRepository } from '@amityco/ts-sdk'
30295
+ * const dispose = EventRepository.onLocalEventDeleted(event => {
30296
+ * // ...
30297
+ * })
30298
+ * ```
30299
+ *
30300
+ * Fired when a {@link Amity.Event} has been deleted
30301
+ *
30302
+ * @param callback The function to call when the event was fired
30303
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30304
+ *
30305
+ * @category Event Events
30306
+ */
30307
+ const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
30308
+
30309
+ /**
30310
+ * ```js
30311
+ * import { EventRepository } from '@amityco/ts-sdk'
30312
+ * const dispose = EventRepository.onRSVPCreated(event => {
30313
+ * // ...
30314
+ * })
30315
+ * ```
30316
+ *
30317
+ * Fired when a {@link Amity.Event} has been created
30318
+ *
30319
+ * @param callback The function to call when the event was fired
30320
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30321
+ *
30322
+ * @category Event Events
30323
+ */
30324
+ const onRSVPCreated = (callback) => createEventResponseSubscriber('event.rsvp.created', callback);
30325
+
30326
+ /**
30327
+ * ```js
30328
+ * import { EventRepository } from '@amityco/ts-sdk'
30329
+ * const dispose = EventRepository.onRSVPUpdated(event => {
30330
+ * // ...
30331
+ * })
30332
+ * ```
30333
+ *
30334
+ * Fired when a {@link Amity.InternalEventResponse} has been updated
30335
+ *
30336
+ * @param callback The function to call when the event was fired
30337
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30338
+ *
30339
+ * @category Event Events
30340
+ */
30341
+ const onRSVPUpdated = (callback) => createEventResponseSubscriber('event.rsvp.updated', callback);
30342
+
30343
+ /**
30344
+ * ```js
30345
+ * import { EventRepository } from '@amityco/ts-sdk'
30346
+ * const dispose = EventRepository.onLocalRSVPCreated(event => {
30347
+ * // ...
30348
+ * })
30349
+ * ```
30350
+ *
30351
+ * Fired when an RSVP response for a {@link Amity.EventResponse} has been created
30352
+ *
30353
+ * @param callback The function to call when the event was fired
30354
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30355
+ *
30356
+ * @category Event Events
30357
+ */
30358
+ const onLocalRSVPCreated = (callback) => createEventResponseSubscriber('local.rsvp.created', callback);
30359
+
30360
+ /**
30361
+ * ```js
30362
+ * import { EventRepository } from '@amityco/ts-sdk'
30363
+ * const dispose = EventRepository.onLocalEventUpdated(event => {
30364
+ * // ...
30365
+ * })
30366
+ * ```
30367
+ *
30368
+ * Fired when an RSVP response for a {@link Amity.EventResponse} has been updated
30369
+ *
30370
+ * @param callback The function to call when the event was fired
30371
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30372
+ *
30373
+ * @category Event Events
30374
+ */
30375
+ const onLocalRSVPUpdated = (callback) => createEventResponseSubscriber('local.rsvp.updated', callback);
30376
+
30377
+ class RSVPLiveCollectionController extends LiveCollectionController {
30378
+ constructor(query, callback) {
30379
+ const queryStreamId = hash(query);
30380
+ const cacheKey = ['eventResponse', 'collection', queryStreamId];
30381
+ const paginationController = new RSVPPaginationController(query);
30382
+ super(paginationController, queryStreamId, cacheKey, callback);
30383
+ this.query = query;
30384
+ this.queryStreamController = new RSVPQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventResponsePayload);
30385
+ this.callback = callback.bind(this);
30386
+ this.loadPage({ initial: true });
30387
+ }
30388
+ setup() {
30389
+ var _a;
30390
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30391
+ if (!collection)
30392
+ pushToCache(this.cacheKey, { data: [], params: this.query });
30393
+ }
30394
+ async persistModel(queryPayload) {
30395
+ await this.queryStreamController.saveToMainDB(queryPayload);
30396
+ }
30397
+ persistQueryStream({ response, direction, refresh, }) {
30398
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
30399
+ }
30400
+ startSubscription() {
30401
+ return this.queryStreamController.subscribeRTE([
30402
+ { fn: onRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
30403
+ { fn: onRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
30404
+ { fn: onLocalRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
30405
+ { fn: onLocalRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
30406
+ ]);
30407
+ }
30408
+ notifyChange({ origin, loading, error }) {
30409
+ var _a, _b;
30410
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30411
+ if (!collection)
30412
+ return;
30413
+ const data = (_b = collection.data
30414
+ .map(eventId => pullFromCache(['eventResponse', 'get', eventId]))
30415
+ .filter(isNonNullable)
30416
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : [].map(eventResponseLinkedObject);
30417
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
30418
+ return;
30419
+ this.callback({
30420
+ data,
30421
+ error,
30422
+ loading,
30423
+ hasNextPage: !!this.paginationController.getNextToken(),
30424
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
30425
+ });
30426
+ }
30427
+ }
30428
+
30429
+ /**
30430
+ * Get events
30431
+ *
30432
+ * @param params the query parameters
30433
+ * @param callback the callback to be called when the events are updated
30434
+ * @returns events
30435
+ *
30436
+ * @category RSVP Live Collection
30437
+ *
30438
+ */
30439
+ const getRSVPs = (params, callback, config) => {
30440
+ const { log, cache } = getActiveClient();
30441
+ if (!cache)
30442
+ console.log(ENABLE_CACHE_MESSAGE);
30443
+ const timestamp = Date.now();
30444
+ log(`getRSVPs: (tmpid: ${timestamp}) > listen`);
30445
+ const rsvpLiveCollection = new RSVPLiveCollectionController(params, callback);
30446
+ const disposers = rsvpLiveCollection.startSubscription();
30447
+ const cacheKey = rsvpLiveCollection.getCacheKey();
30448
+ disposers.push(() => dropFromCache(cacheKey));
30449
+ return () => {
30450
+ log(`getRSVPs (tmpid: ${timestamp}) > dispose`);
30451
+ disposers.forEach(fn => fn());
30452
+ };
30453
+ };
30454
+
30455
+ const eventLinkedObject = (event) => {
30456
+ return Object.assign(Object.assign({}, event), { get creator() {
30457
+ const cacheData = pullFromCache(['user', 'get', event.userId]);
30458
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
30459
+ return;
30460
+ return userLinkedObject(cacheData.data);
30461
+ },
30462
+ get targetCommunity() {
30463
+ if (!event.originId)
30464
+ return;
30465
+ const cacheData = pullFromCache(['community', 'get', event.originId]);
30466
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
30467
+ return;
30468
+ return communityLinkedObject(cacheData.data);
30469
+ },
30470
+ get coverImage() {
30471
+ if (!event.coverImageFileId)
30472
+ return;
30473
+ const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
30474
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
30475
+ return;
30476
+ return cacheData.data;
30477
+ },
30478
+ get post() {
30479
+ if (!event.postId)
30480
+ return;
30481
+ const cacheData = pullFromCache(['post', 'get', event.postId]);
30482
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
30483
+ return;
30484
+ return postLinkedObject(cacheData.data);
30485
+ },
30486
+ get room() {
30487
+ var _a;
30488
+ if (!event.postId)
30489
+ return;
30490
+ const cacheData = (_a = queryCache(['room', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(room => room.data.referenceId === event.postId);
30491
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.length) || !cacheData[0].data)
30492
+ return;
30493
+ return roomLinkedObject(cacheData[0].data);
30494
+ }, createRSVP: async (status) => {
30495
+ const { data } = await createRSVP(event.eventId, status);
30496
+ return data;
30497
+ }, updateRSVP: async (status) => {
30498
+ const { data } = await updateRSVP(event.eventId, status);
30499
+ return data;
30500
+ }, getMyRSVP: async () => {
30501
+ const { data } = await getMyRSVP(event.eventId);
30502
+ return data;
30503
+ }, getRSVPs: (params, callback) => {
30504
+ return getRSVPs(Object.assign({ eventId: event.eventId }, params), callback);
30505
+ } });
30506
+ };
30507
+
29853
30508
  const LinkedObject = {
29854
30509
  ad: adLinkedObject,
29855
30510
  comment: commentLinkedObject,
@@ -29868,6 +30523,9 @@ const LinkedObject = {
29868
30523
  invitation: invitationLinkedObject,
29869
30524
  joinRequest: joinRequestLinkedObject,
29870
30525
  channelMember: channelMemberLinkedObject,
30526
+ room: roomLinkedObject,
30527
+ event: eventLinkedObject,
30528
+ eventResponse: eventResponseLinkedObject,
29871
30529
  };
29872
30530
 
29873
30531
  /* begin_public_function
@@ -30858,9 +31516,9 @@ var AmityUserSearchMatchType;
30858
31516
  AmityUserSearchMatchType["PARTIAL"] = "partial";
30859
31517
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
30860
31518
 
30861
- var index$n = /*#__PURE__*/Object.freeze({
31519
+ var index$p = /*#__PURE__*/Object.freeze({
30862
31520
  __proto__: null,
30863
- Relationship: index$o,
31521
+ Relationship: index$q,
30864
31522
  getUserByIds: getUserByIds,
30865
31523
  updateUser: updateUser,
30866
31524
  flagUser: flagUser,
@@ -31263,7 +31921,7 @@ const uploadAudio = async (formData, onProgress) => {
31263
31921
  };
31264
31922
  /* end_public_function */
31265
31923
 
31266
- var index$m = /*#__PURE__*/Object.freeze({
31924
+ var index$o = /*#__PURE__*/Object.freeze({
31267
31925
  __proto__: null,
31268
31926
  getFile: getFile,
31269
31927
  uploadFile: uploadFile,
@@ -33075,7 +33733,7 @@ const getReactions$1 = (params, callback, config) => {
33075
33733
  };
33076
33734
  /* end_public_function */
33077
33735
 
33078
- var index$l = /*#__PURE__*/Object.freeze({
33736
+ var index$n = /*#__PURE__*/Object.freeze({
33079
33737
  __proto__: null,
33080
33738
  addReaction: addReaction,
33081
33739
  removeReaction: removeReaction,
@@ -34847,7 +35505,7 @@ const getMessages = (params, callback, config) => {
34847
35505
  };
34848
35506
  /* end_public_function */
34849
35507
 
34850
- var index$k = /*#__PURE__*/Object.freeze({
35508
+ var index$m = /*#__PURE__*/Object.freeze({
34851
35509
  __proto__: null,
34852
35510
  createMessage: createMessage,
34853
35511
  updateMessage: updateMessage,
@@ -35373,7 +36031,7 @@ const stopMessageReceiptSync = (subChannelId) => {
35373
36031
  };
35374
36032
  /* end_public_function */
35375
36033
 
35376
- var index$j = /*#__PURE__*/Object.freeze({
36034
+ var index$l = /*#__PURE__*/Object.freeze({
35377
36035
  __proto__: null,
35378
36036
  getSubChannelByIds: getSubChannels$1,
35379
36037
  createSubChannel: createSubChannel,
@@ -36700,7 +37358,7 @@ const searchMembers$1 = (params, callback, config) => {
36700
37358
  };
36701
37359
  /* end_public_function */
36702
37360
 
36703
- var index$i = /*#__PURE__*/Object.freeze({
37361
+ var index$k = /*#__PURE__*/Object.freeze({
36704
37362
  __proto__: null,
36705
37363
  addMembers: addMembers$1,
36706
37364
  removeMembers: removeMembers$1,
@@ -36903,7 +37561,7 @@ const unmuteMembers = async (channelId, userIds) => {
36903
37561
  };
36904
37562
  /* end_public_function */
36905
37563
 
36906
- var index$h = /*#__PURE__*/Object.freeze({
37564
+ var index$j = /*#__PURE__*/Object.freeze({
36907
37565
  __proto__: null,
36908
37566
  addRole: addRole,
36909
37567
  removeRole: removeRole,
@@ -36913,10 +37571,10 @@ var index$h = /*#__PURE__*/Object.freeze({
36913
37571
  unmuteMembers: unmuteMembers
36914
37572
  });
36915
37573
 
36916
- var index$g = /*#__PURE__*/Object.freeze({
37574
+ var index$i = /*#__PURE__*/Object.freeze({
36917
37575
  __proto__: null,
36918
- Membership: index$i,
36919
- Moderation: index$h,
37576
+ Membership: index$k,
37577
+ Moderation: index$j,
36920
37578
  getChannelByIds: getChannelByIds$1,
36921
37579
  createChannel: createChannel,
36922
37580
  updateChannel: updateChannel,
@@ -38319,7 +38977,7 @@ const searchMembers = (params, callback, config) => {
38319
38977
  };
38320
38978
  /* end_public_function */
38321
38979
 
38322
- var index$f = /*#__PURE__*/Object.freeze({
38980
+ var index$h = /*#__PURE__*/Object.freeze({
38323
38981
  __proto__: null,
38324
38982
  addMembers: addMembers,
38325
38983
  removeMembers: removeMembers,
@@ -39570,7 +40228,7 @@ const unbanMembers = async (communityId, userIds) => {
39570
40228
  };
39571
40229
  /* end_public_function */
39572
40230
 
39573
- var index$e = /*#__PURE__*/Object.freeze({
40231
+ var index$g = /*#__PURE__*/Object.freeze({
39574
40232
  __proto__: null,
39575
40233
  addRoles: addRoles,
39576
40234
  removeRoles: removeRoles,
@@ -39578,10 +40236,10 @@ var index$e = /*#__PURE__*/Object.freeze({
39578
40236
  unbanMembers: unbanMembers
39579
40237
  });
39580
40238
 
39581
- var index$d = /*#__PURE__*/Object.freeze({
40239
+ var index$f = /*#__PURE__*/Object.freeze({
39582
40240
  __proto__: null,
39583
- Moderation: index$e,
39584
- Membership: index$f,
40241
+ Moderation: index$g,
40242
+ Membership: index$h,
39585
40243
  getCommunityByIds: getCommunities$1,
39586
40244
  createCommunity: createCommunity,
39587
40245
  updateCommunity: updateCommunity,
@@ -39815,7 +40473,7 @@ const getCategories = (params, callback, config) => {
39815
40473
  };
39816
40474
  /* end_public_function */
39817
40475
 
39818
- var index$c = /*#__PURE__*/Object.freeze({
40476
+ var index$e = /*#__PURE__*/Object.freeze({
39819
40477
  __proto__: null,
39820
40478
  getCategory: getCategory,
39821
40479
  getCategories: getCategories
@@ -40874,7 +41532,7 @@ const getComments = (params, callback, config) => {
40874
41532
  };
40875
41533
  /* end_public_function */
40876
41534
 
40877
- var index$b = /*#__PURE__*/Object.freeze({
41535
+ var index$d = /*#__PURE__*/Object.freeze({
40878
41536
  __proto__: null,
40879
41537
  getCommentByIds: getCommentByIds,
40880
41538
  createComment: createComment,
@@ -41545,7 +42203,7 @@ const getUserFeed = (params, callback, config) => {
41545
42203
  };
41546
42204
  /* end_public_function */
41547
42205
 
41548
- var index$a = /*#__PURE__*/Object.freeze({
42206
+ var index$c = /*#__PURE__*/Object.freeze({
41549
42207
  __proto__: null,
41550
42208
  queryGlobalFeed: queryGlobalFeed,
41551
42209
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -43226,7 +43884,7 @@ const searchPostsByHashtag = (params, callback, config) => {
43226
43884
  };
43227
43885
  /* end_public_function */
43228
43886
 
43229
- var index$9 = /*#__PURE__*/Object.freeze({
43887
+ var index$b = /*#__PURE__*/Object.freeze({
43230
43888
  __proto__: null,
43231
43889
  getPostByIds: getPostByIds,
43232
43890
  createPost: createPost,
@@ -43834,7 +44492,7 @@ const getStreams = (params, callback, config) => {
43834
44492
  };
43835
44493
  };
43836
44494
 
43837
- var index$8 = /*#__PURE__*/Object.freeze({
44495
+ var index$a = /*#__PURE__*/Object.freeze({
43838
44496
  __proto__: null,
43839
44497
  createStream: createStream,
43840
44498
  updateStream: updateStream,
@@ -43914,7 +44572,7 @@ const updateRoom = async (roomId, bundle) => {
43914
44572
  ingestInCache(data, { cachedAt });
43915
44573
  const { rooms } = data;
43916
44574
  return {
43917
- data: rooms[0],
44575
+ data: roomLinkedObject(rooms[0]),
43918
44576
  cachedAt,
43919
44577
  };
43920
44578
  };
@@ -43987,10 +44645,10 @@ const stopRoom = async (roomId) => {
43987
44645
  * const token = await getBroadcasterData('roomId')
43988
44646
  * ```
43989
44647
  *
43990
- * Gets an access token for a room
44648
+ * Gets broadcaster data for a room
43991
44649
  *
43992
44650
  * @param roomId The ID of the room to get token for
43993
- * @returns The room access token
44651
+ * @returns The broadcaster data of the room including coHostToken, coHostUrl and direactStreamUrl
43994
44652
  *
43995
44653
  * @category Room API
43996
44654
  * @async
@@ -44028,6 +44686,62 @@ const getRecordedUrl = async (roomId) => {
44028
44686
  };
44029
44687
  /* end_public_function */
44030
44688
 
44689
+ /* begin_public_function
44690
+ id: room.removeParticipant
44691
+ */
44692
+ /**
44693
+ * ```js
44694
+ * import { removeParticipant } from '@amityco/ts-sdk'
44695
+ * const result = await removeParticipant('roomId', 'participantUserId')
44696
+ * ```
44697
+ *
44698
+ * Removes a participant from an {@link Amity.Room}
44699
+ *
44700
+ * @param roomId The ID of the room to remove participant from
44701
+ * @param participantUserId The ID of the user to remove as participant
44702
+ * @returns Promise that resolves when the participant is removed
44703
+ *
44704
+ * @category Room API
44705
+ * @async
44706
+ */
44707
+ const removeParticipant = async (roomId, participantUserId) => {
44708
+ const client = getActiveClient();
44709
+ client.log('room/removeParticipant', { roomId, participantUserId });
44710
+ await client.http.delete(`/api/v1/rooms/${roomId}/participants/${participantUserId}`);
44711
+ fireEvent('local.room.participantRemoved', {
44712
+ rooms: [{ _id: roomId }],
44713
+ users: [{ _id: participantUserId }],
44714
+ });
44715
+ };
44716
+ /* end_public_function */
44717
+
44718
+ /* begin_public_function
44719
+ id: room.leave
44720
+ */
44721
+ /**
44722
+ * ```js
44723
+ * import { leaveRoom } from '@amityco/ts-sdk'
44724
+ * const result = await leaveRoom('roomId')
44725
+ * ```
44726
+ *
44727
+ * Leaves an {@link Amity.Room}
44728
+ *
44729
+ * @param roomId The ID of the room to leave
44730
+ * @returns Promise that resolves when the user has left the room
44731
+ *
44732
+ * @category Room API
44733
+ * @async
44734
+ */
44735
+ const leaveRoom = async (roomId) => {
44736
+ const client = getActiveClient();
44737
+ client.log('room/leaveRoom', { roomId });
44738
+ await client.http.post(`/api/v1/rooms/${roomId}/leave`);
44739
+ fireEvent('local.room.left', {
44740
+ rooms: [{ _id: roomId }],
44741
+ });
44742
+ };
44743
+ /* end_public_function */
44744
+
44031
44745
  /**
44032
44746
  * ```js
44033
44747
  * import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
@@ -44139,13 +44853,131 @@ const onRoomRecordedAvailable = (callback) => {
44139
44853
  *
44140
44854
  * @category Room Events
44141
44855
  */
44142
- const onRoomParticipantInviting = (callback) => {
44856
+ const onRoomCoHostInvited = (callback) => {
44143
44857
  const client = getActiveClient();
44144
44858
  const filter = (payload) => {
44145
- ingestInCache(payload);
44146
- callback(payload.rooms[0]);
44859
+ const data = prepareMyInvitationsPayload(payload);
44860
+ ingestInCache(data);
44861
+ callback(data.invitations);
44862
+ };
44863
+ return createEventSubscriber(client, 'room/onRoomCoHostInvited', 'room.didCohostInvite', filter);
44864
+ };
44865
+
44866
+ const getRoomById = async (roomId) => {
44867
+ const client = getActiveClient();
44868
+ client.log('room/getRoomById', roomId);
44869
+ // Check if room is in tombstone
44870
+ isInTombstone('room', roomId);
44871
+ let data;
44872
+ try {
44873
+ const response = await client.http.get(`/api/v1/rooms/${roomId}`);
44874
+ data = response.data;
44875
+ }
44876
+ catch (error) {
44877
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
44878
+ pushToTombstone('room', roomId);
44879
+ }
44880
+ throw error;
44881
+ }
44882
+ const cachedAt = client.cache && Date.now();
44883
+ if (client.cache) {
44884
+ ingestInCache(data, { cachedAt });
44885
+ }
44886
+ return {
44887
+ data: data.rooms[0],
44888
+ cachedAt,
44889
+ };
44890
+ };
44891
+ getRoomById.locally = (roomId) => {
44892
+ const client = getActiveClient();
44893
+ client.log('room/getRoomById.locally', roomId);
44894
+ // Check if room is in tombstone
44895
+ isInTombstone('room', roomId);
44896
+ const cachedAt = client.cache && Date.now();
44897
+ const roomCache = pullFromCache(['room', 'get', roomId]);
44898
+ if (!roomCache)
44899
+ return;
44900
+ return {
44901
+ data: roomCache.data,
44902
+ cachedAt,
44903
+ };
44904
+ };
44905
+
44906
+ /**
44907
+ * ```js
44908
+ * import { onRoomCoHostInviteAccepted } from '@amityco/ts-sdk'
44909
+ * const dispose = onRoomCoHostInviteAccepted(room => {
44910
+ * // ...
44911
+ * })
44912
+ * ```
44913
+ *
44914
+ * Fired when a co-host invitation is accepted for a {@link Amity.Room}
44915
+ *
44916
+ * @param callback The function to call when the event was fired
44917
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44918
+ *
44919
+ * @category Room Events
44920
+ */
44921
+ const onRoomCoHostInviteAccepted = (callback) => {
44922
+ const client = getActiveClient();
44923
+ const filter = async (payload) => {
44924
+ var _a;
44925
+ const data = prepareMyInvitationsPayload(payload);
44926
+ await getRoomById((_a = data.invitations) === null || _a === void 0 ? void 0 : _a[0].targetId);
44927
+ ingestInCache(data);
44928
+ callback(data.invitations[0]);
44929
+ };
44930
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCohostInviteAccept', filter);
44931
+ };
44932
+
44933
+ /**
44934
+ * ```js
44935
+ * import { onRoomCoHostInviteRejected } from '@amityco/ts-sdk'
44936
+ * const dispose = onRoomCoHostInviteRejected(room => {
44937
+ * // ...
44938
+ * })
44939
+ * ```
44940
+ *
44941
+ * Fired when a co-host invitation is rejected for a {@link Amity.Room}
44942
+ *
44943
+ * @param callback The function to call when the event was fired
44944
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44945
+ *
44946
+ * @category Room Events
44947
+ */
44948
+ const onRoomCoHostInviteRejected = (callback) => {
44949
+ const client = getActiveClient();
44950
+ const filter = (payload) => {
44951
+ const data = prepareMyInvitationsPayload(payload);
44952
+ ingestInCache(data);
44953
+ callback(data.invitations);
44954
+ };
44955
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCohostInviteReject', filter);
44956
+ };
44957
+
44958
+ /**
44959
+ * ```js
44960
+ * import { onRoomCoHostInviteCanceled } from '@amityco/ts-sdk'
44961
+ * const dispose = onRoomCoHostInviteCanceled(room => {
44962
+ * // ...
44963
+ * })
44964
+ * ```
44965
+ *
44966
+ * Fired when a co-host invitation is canceled for a {@link Amity.Room}
44967
+ *
44968
+ * @param callback The function to call when the event was fired
44969
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44970
+ *
44971
+ * @category Room Events
44972
+ */
44973
+ const onRoomCoHostInviteCanceled = (callback) => {
44974
+ const client = getActiveClient();
44975
+ const filter = (payload) => {
44976
+ const data = prepareMyInvitationsPayload(payload);
44977
+ ingestInCache(data);
44978
+ callback(data.invitations);
44147
44979
  };
44148
- return createEventSubscriber(client, 'room/onRoomParticipantInviting', 'room.participantInviting', filter);
44980
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCohostInviteCancel', filter);
44149
44981
  };
44150
44982
 
44151
44983
  /**
@@ -44292,44 +45124,76 @@ const onRoomStopped = (callback) => {
44292
45124
  return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
44293
45125
  };
44294
45126
 
44295
- const getRoomById = async (roomId) => {
45127
+ /**
45128
+ * ```js
45129
+ * import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
45130
+ * const dispose = onRoomParticipantRemoved(room => {
45131
+ * // ...
45132
+ * })
45133
+ * ```
45134
+ *
45135
+ * Fired when a participant has been removed from a {@link Amity.Room} locally
45136
+ *
45137
+ * @param callback The function to call when the event was fired
45138
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
45139
+ *
45140
+ * @category Room Events
45141
+ */
45142
+ const onRoomParticipantRemoved = (callback) => {
44296
45143
  const client = getActiveClient();
44297
- client.log('room/getRoomById', roomId);
44298
- // Check if room is in tombstone
44299
- isInTombstone('room', roomId);
44300
- let data;
44301
- try {
44302
- const response = await client.http.get(`/api/v1/rooms/${roomId}`);
44303
- data = response.data;
44304
- }
44305
- catch (error) {
44306
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
44307
- pushToTombstone('room', roomId);
44308
- }
44309
- throw error;
44310
- }
44311
- const cachedAt = client.cache && Date.now();
44312
- if (client.cache) {
44313
- ingestInCache(data, { cachedAt });
44314
- }
44315
- return {
44316
- data: data.rooms[0],
44317
- cachedAt,
45144
+ const filter = (payload) => {
45145
+ ingestInCache(payload);
45146
+ callback(payload.rooms[0]);
44318
45147
  };
45148
+ return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'room.participantRemoved', filter);
44319
45149
  };
44320
- getRoomById.locally = (roomId) => {
45150
+
45151
+ /**
45152
+ * ```js
45153
+ * import { onRoomLeft } from '@amityco/ts-sdk'
45154
+ * const dispose = onRoomLeft(room => {
45155
+ * // ...
45156
+ * })
45157
+ * ```
45158
+ *
45159
+ * Fired when a user has left a {@link Amity.Room} locally
45160
+ *
45161
+ * @param callback The function to call when the event was fired
45162
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
45163
+ *
45164
+ * @category Room Events
45165
+ */
45166
+ const onRoomLeft = (callback) => {
44321
45167
  const client = getActiveClient();
44322
- client.log('room/getRoomById.locally', roomId);
44323
- // Check if room is in tombstone
44324
- isInTombstone('room', roomId);
44325
- const cachedAt = client.cache && Date.now();
44326
- const roomCache = pullFromCache(['room', 'get', roomId]);
44327
- if (!roomCache)
44328
- return;
44329
- return {
44330
- data: roomCache.data,
44331
- cachedAt,
45168
+ const filter = (payload) => {
45169
+ ingestInCache(payload);
45170
+ callback(payload.rooms[0]);
45171
+ };
45172
+ return createEventSubscriber(client, 'room/onRoomLeft', 'local.room.left', filter);
45173
+ };
45174
+
45175
+ /**
45176
+ * ```js
45177
+ * import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
45178
+ * const dispose = onRoomParticipantRemoved(room => {
45179
+ * // ...
45180
+ * })
45181
+ * ```
45182
+ *
45183
+ * Fired when a participant has been removed from a {@link Amity.Room} locally
45184
+ *
45185
+ * @param callback The function to call when the event was fired
45186
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
45187
+ *
45188
+ * @category Room Events
45189
+ */
45190
+ const onRoomParticipantRemovedLocal = (callback) => {
45191
+ const client = getActiveClient();
45192
+ const filter = (payload) => {
45193
+ ingestInCache(payload);
45194
+ callback(payload.rooms[0]);
44332
45195
  };
45196
+ return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
44333
45197
  };
44334
45198
 
44335
45199
  const getRoom = (roomId, callback) => {
@@ -44339,7 +45203,18 @@ const getRoom = (roomId, callback) => {
44339
45203
  onRoomStartBroadcasting,
44340
45204
  onRoomWaitingReconnect,
44341
45205
  onRoomRecordedAvailable,
44342
- ]);
45206
+ onRoomParticipantJoined,
45207
+ onRoomParticipantLeft,
45208
+ onRoomParticipantRemoved,
45209
+ onRoomParticipantRemovedLocal,
45210
+ convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
45211
+ ], {
45212
+ callbackDataSelector: (data) => {
45213
+ if (!data)
45214
+ return data;
45215
+ return LinkedObject.room(data);
45216
+ },
45217
+ });
44343
45218
  };
44344
45219
 
44345
45220
  class RoomPaginationController extends PaginationController {
@@ -44552,7 +45427,7 @@ const getRooms = (params, callback, config) => {
44552
45427
  };
44553
45428
  /* end_public_function */
44554
45429
 
44555
- var index$7 = /*#__PURE__*/Object.freeze({
45430
+ var index$9 = /*#__PURE__*/Object.freeze({
44556
45431
  __proto__: null,
44557
45432
  createRoom: createRoom,
44558
45433
  updateRoom: updateRoom,
@@ -44560,21 +45435,322 @@ var index$7 = /*#__PURE__*/Object.freeze({
44560
45435
  stopRoom: stopRoom,
44561
45436
  getBroadcasterData: getBroadcasterData,
44562
45437
  getRecordedUrl: getRecordedUrl,
45438
+ removeParticipant: removeParticipant,
45439
+ leaveRoom: leaveRoom,
44563
45440
  onRoomStartBroadcasting: onRoomStartBroadcasting,
44564
45441
  onRoomWaitingReconnect: onRoomWaitingReconnect,
44565
45442
  onRoomEndBroadcasting: onRoomEndBroadcasting,
44566
45443
  onRoomRecordedAvailable: onRoomRecordedAvailable,
44567
- onRoomParticipantInviting: onRoomParticipantInviting,
45444
+ onRoomCoHostInvited: onRoomCoHostInvited,
45445
+ onRoomCoHostInviteAccepted: onRoomCoHostInviteAccepted,
45446
+ onRoomCoHostInviteRejected: onRoomCoHostInviteRejected,
45447
+ onRoomCoHostInviteCanceled: onRoomCoHostInviteCanceled,
44568
45448
  onRoomParticipantJoined: onRoomParticipantJoined,
44569
45449
  onRoomParticipantLeft: onRoomParticipantLeft,
44570
45450
  onRoomCreated: onRoomCreated,
44571
45451
  onRoomUpdated: onRoomUpdated,
44572
45452
  onRoomDeleted: onRoomDeleted,
44573
45453
  onRoomStopped: onRoomStopped,
45454
+ onRoomParticipantRemoved: onRoomParticipantRemoved,
45455
+ onRoomLeft: onRoomLeft,
44574
45456
  getRoom: getRoom,
44575
45457
  getRooms: getRooms
44576
45458
  });
44577
45459
 
45460
+ /* begin_public_function
45461
+ id: roomPresence.getRoomOnlineUsers
45462
+ */
45463
+ /**
45464
+ * ```js
45465
+ * import { getRoomOnlineUsers } from '@amityco/ts-sdk'
45466
+ * const result = await getRoomOnlineUsers('roomId')
45467
+ * ```
45468
+ *
45469
+ * Retrieves the list of users currently online in a specific room.
45470
+ * This function fetches all users who are actively watching or present in the room,
45471
+ * handling pagination automatically for large numbers of users.
45472
+ *
45473
+ * @param roomId The ID of the room to get online users for
45474
+ * @returns Promise that resolves with a cached list of online users
45475
+ *
45476
+ * @category Room Presence API
45477
+ * @async
45478
+ */
45479
+ const getRoomOnlineUsers = async (roomId) => {
45480
+ var _a, _b, _c;
45481
+ const client = getActiveClient();
45482
+ client.log('room/getWatchingUsers', { roomId });
45483
+ const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users`);
45484
+ const viewerIds = (_a = data === null || data === void 0 ? void 0 : data.viewers.map(viewer => viewer.userId)) !== null && _a !== void 0 ? _a : [];
45485
+ // getUserByIds has a maximum limit of 100 users per call
45486
+ // Split into chunks of 100 if we have more than 100 users
45487
+ const BATCH_SIZE = 100;
45488
+ const batches = [];
45489
+ for (let i = 0; i < viewerIds.length; i += BATCH_SIZE) {
45490
+ batches.push(viewerIds.slice(i, i + BATCH_SIZE));
45491
+ }
45492
+ // Fetch all batches in parallel
45493
+ const batchResults = await Promise.all(batches.map(batch => getUserByIds(batch)));
45494
+ // Merge all results
45495
+ const allViewers = [];
45496
+ batchResults.forEach(result => {
45497
+ if (result.data) {
45498
+ allViewers.push(...result.data);
45499
+ }
45500
+ });
45501
+ // Return in the same format as getUserByIds
45502
+ return {
45503
+ data: allViewers,
45504
+ cachedAt: (_c = (_b = batchResults[0]) === null || _b === void 0 ? void 0 : _b.cachedAt) !== null && _c !== void 0 ? _c : Date.now(),
45505
+ };
45506
+ };
45507
+ /* end_public_function */
45508
+
45509
+ /* begin_public_function
45510
+ id: roomPresence.getRoomUserCount
45511
+ */
45512
+ /**
45513
+ * ```js
45514
+ * import { getRoomUserCount } from '@amityco/ts-sdk'
45515
+ * const count = await getRoomUserCount('roomId')
45516
+ * ```
45517
+ *
45518
+ * Retrieves the count of users currently watching or present in a specific room.
45519
+ * This function returns the total number of online users without fetching their full user data.
45520
+ *
45521
+ * @param roomId The ID of the room to get the user count for
45522
+ * @returns Promise that resolves with the room watching count data
45523
+ *
45524
+ * @category Room Presence API
45525
+ * @async
45526
+ */
45527
+ const getRoomUserCount = async (roomId) => {
45528
+ const client = getActiveClient();
45529
+ client.log('roomPresence/getRoomUserCount', { roomId });
45530
+ const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users/count`);
45531
+ pushToCache(['get', 'watchingCount', roomId], data);
45532
+ fireEvent('local.room.watchingCountUpdated', data);
45533
+ return data;
45534
+ };
45535
+ /* end_public_function */
45536
+
45537
+ const getPresenceSetting = async () => {
45538
+ const client = getActiveClient();
45539
+ client.log('presence/getPresenceSetting');
45540
+ const { data } = await client.http.get('/api/v1/presence/settings');
45541
+ pushToCache(['get', 'presenceSetting'], data);
45542
+ return data;
45543
+ };
45544
+
45545
+ class RoomPresenceSyncEngine {
45546
+ constructor(roomId) {
45547
+ this.isEnabled = false;
45548
+ this.config = {
45549
+ heartbeatInterval: 30 * SECOND$1,
45550
+ };
45551
+ this.roomId = roomId;
45552
+ // Initialize config asynchronously - don't await in constructor
45553
+ this.initializeConfig().catch(error => {
45554
+ console.error('Failed to initialize RoomPresenceSyncEngine config in constructor:', error);
45555
+ });
45556
+ }
45557
+ async initializeConfig() {
45558
+ try {
45559
+ // Get presence settings from API with retry logic
45560
+ const presenceSettings = await RoomPresenceSyncEngine.getPresenceSettingWithRetry();
45561
+ if (presenceSettings) {
45562
+ // Set intervals from network settings (convert from minutes to milliseconds)
45563
+ this.config = {
45564
+ heartbeatInterval: (presenceSettings.network.heartbeatInterval || 5) * 60 * 1000,
45565
+ };
45566
+ }
45567
+ else {
45568
+ // Use default intervals if all retries failed
45569
+ this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
45570
+ }
45571
+ }
45572
+ catch (error) {
45573
+ console.error('Failed to initialize RoomPresenceSyncEngine config:', error);
45574
+ // Use default intervals if settings fetch fails
45575
+ this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
45576
+ }
45577
+ }
45578
+ static async getPresenceSettingWithRetry(maxRetries = 5) {
45579
+ for (let attempt = 0; attempt < maxRetries; attempt += 1) {
45580
+ try {
45581
+ // eslint-disable-next-line no-await-in-loop
45582
+ const presenceSettings = await getPresenceSetting();
45583
+ return presenceSettings;
45584
+ }
45585
+ catch (error) {
45586
+ if (attempt >= maxRetries - 1) {
45587
+ console.error(`Failed to get presence setting after ${maxRetries} attempts:`, error);
45588
+ return null;
45589
+ }
45590
+ // Calculate delay: 20 seconds + random jitter (0-5 seconds)
45591
+ const jitter = Math.random() * 5000; // 0-5 seconds in milliseconds
45592
+ const delay = 20000 + jitter; // 20 seconds + jitter
45593
+ console.warn(`Failed to get presence setting (attempt ${attempt + 1}/${maxRetries}), retrying in ${Math.round(delay / 1000)}s:`, error);
45594
+ // Wait before retry
45595
+ // eslint-disable-next-line no-await-in-loop
45596
+ await new Promise(resolve => {
45597
+ setTimeout(resolve, delay);
45598
+ });
45599
+ }
45600
+ }
45601
+ return null;
45602
+ }
45603
+ /**
45604
+ * Start heartbeat for the room
45605
+ */
45606
+ start() {
45607
+ if (this.isEnabled)
45608
+ return;
45609
+ this.isEnabled = true;
45610
+ // Send immediate heartbeat
45611
+ this.sendHeartbeat();
45612
+ // Start heartbeat timer
45613
+ this.heartbeatTimer = setInterval(() => {
45614
+ this.sendHeartbeat();
45615
+ }, this.config.heartbeatInterval);
45616
+ }
45617
+ /**
45618
+ * Stop heartbeat for the room
45619
+ */
45620
+ stop() {
45621
+ this.isEnabled = false;
45622
+ // Stop heartbeat timer
45623
+ if (this.heartbeatTimer) {
45624
+ clearInterval(this.heartbeatTimer);
45625
+ this.heartbeatTimer = undefined;
45626
+ }
45627
+ }
45628
+ /**
45629
+ * Send heartbeat to the room
45630
+ */
45631
+ async sendHeartbeat() {
45632
+ try {
45633
+ const client = getActiveClient();
45634
+ await client.http.post(`/api/v1/presence/rooms/${this.roomId}/heartbeat`);
45635
+ }
45636
+ catch (error) {
45637
+ console.error(`Heartbeat failed for room ${this.roomId}:`, error);
45638
+ }
45639
+ }
45640
+ /**
45641
+ * Get the room ID
45642
+ */
45643
+ getRoomId() {
45644
+ return this.roomId;
45645
+ }
45646
+ /**
45647
+ * Check if the engine is enabled
45648
+ */
45649
+ isActive() {
45650
+ return this.isEnabled;
45651
+ }
45652
+ /**
45653
+ * Cleanup method to stop all timers and release resources
45654
+ * Call this when the engine instance is no longer needed
45655
+ */
45656
+ destroy() {
45657
+ // Stop the engine
45658
+ this.stop();
45659
+ }
45660
+ // Session Management
45661
+ onSessionDestroyed() {
45662
+ // Stop all timers when session is destroyed and cleanup
45663
+ this.destroy();
45664
+ }
45665
+ onTokenExpired() {
45666
+ // Stop engine when token expires
45667
+ this.stop();
45668
+ }
45669
+ }
45670
+
45671
+ // Map to store engine instances per roomId
45672
+ const engineInstances = new Map();
45673
+ /**
45674
+ * Get or create a RoomPresenceSyncEngine instance for a specific room
45675
+ *
45676
+ * @param roomId The room ID to get/create engine for
45677
+ * @returns RoomPresenceSyncEngine instance for the room
45678
+ */
45679
+ const getRoomPresenceSyncEngine = (roomId) => {
45680
+ let engine = engineInstances.get(roomId);
45681
+ if (!engine) {
45682
+ engine = new RoomPresenceSyncEngine(roomId);
45683
+ engineInstances.set(roomId, engine);
45684
+ }
45685
+ return engine;
45686
+ };
45687
+ /**
45688
+ * Destroy the engine instance for a specific room
45689
+ *
45690
+ * @param roomId The room ID to destroy engine for
45691
+ */
45692
+ const destroyRoomPresenceSyncEngine = (roomId) => {
45693
+ const engine = engineInstances.get(roomId);
45694
+ if (engine) {
45695
+ engine.destroy();
45696
+ engineInstances.delete(roomId);
45697
+ }
45698
+ };
45699
+
45700
+ /* begin_public_function
45701
+ id: roomPresence.startHeartbeat
45702
+ */
45703
+ /**
45704
+ * ```js
45705
+ * import { startHeartbeat } from '@amityco/ts-sdk'
45706
+ * startHeartbeat('roomId')
45707
+ * ```
45708
+ *
45709
+ * Starts sending heartbeat signals for a specific room to maintain presence status.
45710
+ * This enables the room presence tracking and notifies the server that the user is actively viewing the room.
45711
+ *
45712
+ * @param roomId The ID of the room to start heartbeat for
45713
+ *
45714
+ * @category Room Presence API
45715
+ */
45716
+ const startHeartbeat = (roomId) => {
45717
+ const engine = getRoomPresenceSyncEngine(roomId);
45718
+ engine.start();
45719
+ };
45720
+ /* end_public_function */
45721
+
45722
+ /* begin_public_function
45723
+ id: roomPresence.stopHeartbeat
45724
+ */
45725
+ /**
45726
+ * ```js
45727
+ * import { stopHeartbeat } from '@amityco/ts-sdk'
45728
+ * stopHeartbeat('roomId')
45729
+ * ```
45730
+ *
45731
+ * Stops sending heartbeat signals for a specific room.
45732
+ * This disables the room presence tracking for the specified room and stops notifying the server of the user's presence.
45733
+ *
45734
+ * @param roomId The ID of the room to stop heartbeat for
45735
+ *
45736
+ * @category Room Presence API
45737
+ */
45738
+ const stopHeartbeat = (roomId) => {
45739
+ const engine = getRoomPresenceSyncEngine(roomId);
45740
+ engine.stop();
45741
+ // Clean up the engine instance
45742
+ destroyRoomPresenceSyncEngine(roomId);
45743
+ };
45744
+ /* end_public_function */
45745
+
45746
+ var index$8 = /*#__PURE__*/Object.freeze({
45747
+ __proto__: null,
45748
+ getRoomOnlineUsers: getRoomOnlineUsers,
45749
+ getRoomUserCount: getRoomUserCount,
45750
+ startHeartbeat: startHeartbeat,
45751
+ stopHeartbeat: stopHeartbeat
45752
+ });
45753
+
44578
45754
  /* begin_public_function
44579
45755
  id: poll.create
44580
45756
  */
@@ -44875,7 +46051,7 @@ const getPoll = (pollId, callback) => {
44875
46051
  };
44876
46052
  /* end_public_function */
44877
46053
 
44878
- var index$6 = /*#__PURE__*/Object.freeze({
46054
+ var index$7 = /*#__PURE__*/Object.freeze({
44879
46055
  __proto__: null,
44880
46056
  createPoll: createPoll,
44881
46057
  closePoll: closePoll,
@@ -45258,7 +46434,7 @@ const getPlayer = async (parameters) => {
45258
46434
  return video;
45259
46435
  };
45260
46436
 
45261
- var index$5 = /*#__PURE__*/Object.freeze({
46437
+ var index$6 = /*#__PURE__*/Object.freeze({
45262
46438
  __proto__: null,
45263
46439
  getPlayer: getPlayer
45264
46440
  });
@@ -46431,7 +47607,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
46431
47607
  };
46432
47608
  };
46433
47609
 
46434
- var index$4 = /*#__PURE__*/Object.freeze({
47610
+ var index$5 = /*#__PURE__*/Object.freeze({
46435
47611
  __proto__: null,
46436
47612
  createImageStory: createImageStory,
46437
47613
  createVideoStory: createVideoStory,
@@ -46468,7 +47644,7 @@ const getNetworkAds = async () => {
46468
47644
  };
46469
47645
  };
46470
47646
 
46471
- var index$3 = /*#__PURE__*/Object.freeze({
47647
+ var index$4 = /*#__PURE__*/Object.freeze({
46472
47648
  __proto__: null,
46473
47649
  getNetworkAds: getNetworkAds
46474
47650
  });
@@ -46859,7 +48035,7 @@ const markTraySeen = async (lastSeenAt) => {
46859
48035
  };
46860
48036
  /* end_public_function */
46861
48037
 
46862
- var index$2 = /*#__PURE__*/Object.freeze({
48038
+ var index$3 = /*#__PURE__*/Object.freeze({
46863
48039
  __proto__: null,
46864
48040
  getNotificationTraySeen: getNotificationTraySeen,
46865
48041
  getNotificationTrayItems: getNotificationTrayItems,
@@ -46868,6 +48044,40 @@ var index$2 = /*#__PURE__*/Object.freeze({
46868
48044
  onNotificationTraySeenUpdated: onNotificationTraySeenUpdated
46869
48045
  });
46870
48046
 
48047
+ /* begin_public_function
48048
+ id: invitation.reject
48049
+ */
48050
+ /**
48051
+ * ```js
48052
+ * import { rejectInvitation } from '@amityco/ts-sdk'
48053
+ * const isRejected = await rejectInvitation(invitationId)
48054
+ * ```
48055
+ *
48056
+ * Rejects a {@link Amity.Invitation} object
48057
+ *
48058
+ * @param invitationId the {@link Amity.Invitation} to reject
48059
+ * @returns A success boolean if the {@link Amity.Invitation} was rejected
48060
+ *
48061
+ * @category Invitation API
48062
+ * @async
48063
+ */
48064
+ const cancelInvitation = async (invitationId) => {
48065
+ var _a;
48066
+ const client = getActiveClient();
48067
+ client.log('invitation/cancelInvitation', invitationId);
48068
+ const { data } = await client.http.delete(`/api/v1/invitations/${invitationId}`);
48069
+ const invitation = (_a = pullFromCache([
48070
+ 'invitation',
48071
+ 'get',
48072
+ invitationId,
48073
+ ])) === null || _a === void 0 ? void 0 : _a.data;
48074
+ pushToTombstone('invitation', invitationId);
48075
+ if (invitation)
48076
+ fireEvent('local.invitation.canceled', [invitation]);
48077
+ return data.success;
48078
+ };
48079
+ /* end_public_function */
48080
+
46871
48081
  class MyInvitationsPaginationController extends PaginationController {
46872
48082
  async getRequest(queryParams, token) {
46873
48083
  const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
@@ -46928,7 +48138,7 @@ class MyInvitationsQueryStreamController extends QueryStreamController {
46928
48138
  ]),
46929
48139
  ];
46930
48140
  }
46931
- if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
48141
+ if (action === InvitationActionsEnum.OnLocalInvitationCanceled) {
46932
48142
  collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
46933
48143
  }
46934
48144
  pushToCache(this.cacheKey, collection);
@@ -46978,8 +48188,8 @@ class MyInvitationsLiveCollectionController extends LiveCollectionController {
46978
48188
  action: InvitationActionsEnum.OnLocalInvitationUpdated,
46979
48189
  },
46980
48190
  {
46981
- fn: onLocalInvitationDeleted,
46982
- action: InvitationActionsEnum.OnLocalInvitationDeleted,
48191
+ fn: onLocalInvitationCanceled,
48192
+ action: InvitationActionsEnum.OnLocalInvitationCanceled,
46983
48193
  },
46984
48194
  ]);
46985
48195
  }
@@ -47060,12 +48270,77 @@ const getMyCommunityInvitations = (params, callback, config) => {
47060
48270
  };
47061
48271
  };
47062
48272
 
47063
- var index$1 = /*#__PURE__*/Object.freeze({
48273
+ /* begin_public_function
48274
+ id: invitation.get_invitations
48275
+ */
48276
+ /**
48277
+ *
48278
+ * ```js
48279
+ * import { InvitationRepository } from '@amityco/ts-sdk';
48280
+ *
48281
+ * // For room invitations
48282
+ * const unsubscribe = InvitationRepository.getInvitations(
48283
+ * { targetId: 'room123', targetType: 'room' },
48284
+ * response => {
48285
+ * console.log('Room invitation event:', response.room, response.users, response.eventType)
48286
+ * }
48287
+ * );
48288
+ *
48289
+ * // For community invitations (when implemented)
48290
+ * const unsubscribe2 = observeInvitations(
48291
+ * { targetId: 'community456', targetType: 'community' },
48292
+ * response => {
48293
+ * console.log('Community invitation event:', response.community, response.users, response.eventType)
48294
+ * }
48295
+ * );
48296
+ * ```
48297
+ *
48298
+ * Observe invitations events including invited, accepted, rejected, and canceled
48299
+ *
48300
+ * @param params The target ID and type to observe invitations for
48301
+ * @param callback The function to call when new invitation events are available
48302
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the events
48303
+ *
48304
+ * @category Invitation Observable
48305
+ */
48306
+ const getInvitations = (params, callback) => {
48307
+ const { _id: userId } = getCurrentUser();
48308
+ if (!userId)
48309
+ throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
48310
+ const { log } = getActiveClient();
48311
+ const { targetId, targetType } = params;
48312
+ const timestamp = Date.now();
48313
+ log(`observeInvitations(tmpid: ${timestamp}) > listen for ${targetType}: ${targetId}`);
48314
+ const disposers = [];
48315
+ const dispatcher = (data) => {
48316
+ callback(data.map(LinkedObject.invitation));
48317
+ };
48318
+ const realtimeRouter = (data) => {
48319
+ const invitations = (Array.isArray(data) ? data : [data]).filter(({ targetId, targetType }) => targetId === params.targetId && targetType === params.targetType);
48320
+ dispatcher(invitations);
48321
+ };
48322
+ // Only subscribe to room co-host events for now (since that's what we have implemented)
48323
+ if (targetType === 'room') {
48324
+ // Create custom event subscribers that receive the full payload
48325
+ disposers.push(onRoomCoHostInvited(realtimeRouter));
48326
+ disposers.push(onRoomCoHostInviteAccepted(realtimeRouter));
48327
+ disposers.push(onRoomCoHostInviteRejected(realtimeRouter));
48328
+ disposers.push(onRoomCoHostInviteCanceled(realtimeRouter));
48329
+ }
48330
+ return () => {
48331
+ log(`getInvitations(tmpid: ${timestamp}) > dispose for ${targetType}: ${targetId}`);
48332
+ disposers.forEach(fn => fn());
48333
+ };
48334
+ };
48335
+
48336
+ var index$2 = /*#__PURE__*/Object.freeze({
47064
48337
  __proto__: null,
48338
+ cancelInvitation: cancelInvitation,
47065
48339
  onLocalInvitationCreated: onLocalInvitationCreated,
47066
48340
  onLocalInvitationUpdated: onLocalInvitationUpdated,
47067
- onLocalInvitationDeleted: onLocalInvitationDeleted,
47068
- getMyCommunityInvitations: getMyCommunityInvitations
48341
+ onLocalInvitationCanceled: onLocalInvitationCanceled,
48342
+ getMyCommunityInvitations: getMyCommunityInvitations,
48343
+ getInvitations: getInvitations
47069
48344
  });
47070
48345
 
47071
48346
  // TODO: confirm id
@@ -47093,7 +48368,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
47093
48368
  * @category Live Reaction API
47094
48369
  * @async
47095
48370
  */
47096
- const createReaction = async ({ referenceId, referenceType, reactionName, streamId, }) => {
48371
+ const createReaction = async ({ referenceId, referenceType, reactionName, roomId, }) => {
47097
48372
  const client = getActiveClient();
47098
48373
  client.log('live_reaction/createReaction', {
47099
48374
  referenceId,
@@ -47105,7 +48380,7 @@ const createReaction = async ({ referenceId, referenceType, reactionName, stream
47105
48380
  reactionName,
47106
48381
  referencePublicId: referenceId,
47107
48382
  referenceType,
47108
- streamId,
48383
+ roomId,
47109
48384
  occurredAt: new Date().toISOString(),
47110
48385
  };
47111
48386
  reactionSynceEngine.createLiveReaction(reaction);
@@ -47201,11 +48476,491 @@ const getReactions = (postId, callback) => {
47201
48476
  };
47202
48477
  };
47203
48478
 
47204
- var index = /*#__PURE__*/Object.freeze({
48479
+ var index$1 = /*#__PURE__*/Object.freeze({
47205
48480
  __proto__: null,
47206
48481
  createReaction: createReaction,
47207
48482
  onLiveReactionCreated: onLiveReactionCreated,
47208
48483
  getReactions: getReactions
47209
48484
  });
47210
48485
 
47211
- export { API_REGIONS, index$3 as AdRepository, index$c as CategoryRepository, index$g as ChannelRepository, index$p as Client, index$b as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$d as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, FeedDataTypeEnum, index$a as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$m as FileRepository, FileType, GET_WATCHER_URLS, index$1 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index as LiveReactionRepository, index$5 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$k as MessageRepository, index$6 as PollRepository, PostContentType, index$9 as PostRepository, PostStructureType, index$l as ReactionRepository, index$7 as RoomRepository, index$4 as StoryRepository, index$8 as StreamRepository, index$j as SubChannelRepository, SubscriptionLevels, index$n as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$2 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
48486
+ /* begin_public_function
48487
+ id: event.create
48488
+ */
48489
+ /**
48490
+ * ```js
48491
+ * import { EventRepository } from '@amityco/ts-sdk'
48492
+ * const response = await EventRepository.createEvent(bundle)
48493
+ * ```
48494
+ *
48495
+ * Creates an {@link Amity.Event}
48496
+ *
48497
+ * @param bundle The data necessary to create a new {@link Amity.Event}
48498
+ * @returns The newly created {@link Amity.Event}
48499
+ *
48500
+ * @category Event API
48501
+ * @async
48502
+ */
48503
+ const createEvent = async (bundle) => {
48504
+ const client = getActiveClient();
48505
+ client.log('event/createEvent', bundle);
48506
+ const { data: payload } = await client.http.post('/api/v1/events', bundle);
48507
+ fireEvent('local.event.created', payload);
48508
+ const preparedPayload = prepareEventPayload(payload);
48509
+ const cachedAt = client.cache && Date.now();
48510
+ if (client.cache)
48511
+ ingestInCache(preparedPayload, { cachedAt });
48512
+ return {
48513
+ data: eventLinkedObject(preparedPayload.events[0]),
48514
+ cachedAt,
48515
+ };
48516
+ };
48517
+ /* end_public_function */
48518
+
48519
+ /* begin_public_function
48520
+ id: event.update
48521
+ */
48522
+ /**
48523
+ * ```js
48524
+ * import { EventRepository } from '@amityco/ts-sdk'
48525
+ * const response = await EventRepository.updateEvent(eventId, bundle)
48526
+ * ```
48527
+ *
48528
+ * Updates an {@link Amity.Event}
48529
+ *
48530
+ * @param eventId The ID of the {@link Amity.Event} to edit
48531
+ * @param bundle The data necessary to update an existing {@link Amity.Event}
48532
+ * @returns the updated {@link Amity.Event}
48533
+ *
48534
+ * @category Event API
48535
+ * @async
48536
+ */
48537
+ const updateEvent = async (eventId, bundle) => {
48538
+ const client = getActiveClient();
48539
+ client.log('event/updateEvent', eventId, bundle);
48540
+ const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
48541
+ fireEvent('local.event.updated', payload);
48542
+ const preparedPayload = prepareEventPayload(payload);
48543
+ const cachedAt = client.cache && Date.now();
48544
+ if (client.cache)
48545
+ ingestInCache(preparedPayload, { cachedAt });
48546
+ return {
48547
+ data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
48548
+ cachedAt,
48549
+ };
48550
+ };
48551
+ /* end_public_function */
48552
+
48553
+ /* begin_public_function
48554
+ id: event.get
48555
+ */
48556
+ /**
48557
+ * ```js
48558
+ * import { EventRepository } from '@amityco/ts-sdk'
48559
+ * const event = await EventRepository.getEvent(eventId)
48560
+ * ```
48561
+ *
48562
+ * Fetches a {@link Amity.Event} object
48563
+ *
48564
+ * @param eventId the ID of the {@link Amity.Event} to fetch
48565
+ * @returns the associated {@link Amity.Event} object
48566
+ *
48567
+ * @category Event API
48568
+ * @async
48569
+ */
48570
+ const getEvent$1 = async (eventId) => {
48571
+ const client = getActiveClient();
48572
+ client.log('event/getEvent', eventId);
48573
+ const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
48574
+ const data = prepareEventPayload(payload);
48575
+ const cachedAt = client.cache && Date.now();
48576
+ if (client.cache)
48577
+ ingestInCache(data, { cachedAt });
48578
+ return {
48579
+ data: data.events.find(event => event.eventId === eventId),
48580
+ cachedAt,
48581
+ };
48582
+ };
48583
+ /* end_public_function */
48584
+ /**
48585
+ * ```js
48586
+ * import { EventRepository } from '@amityco/ts-sdk'
48587
+ * const event = EventRepository.getEvent.locally(eventId)
48588
+ * ```
48589
+ *
48590
+ * Fetches a {@link Amity.Event} object in cache
48591
+ *
48592
+ * @param eventId the ID of the {@link Amity.Event} to fetch
48593
+ * @returns the associated {@link Amity.Event} object
48594
+ *
48595
+ * @category Event API
48596
+ */
48597
+ getEvent$1.locally = (eventId) => {
48598
+ const client = getActiveClient();
48599
+ client.log('event/getEvent.locally', eventId);
48600
+ if (!client.cache)
48601
+ return;
48602
+ const cache = pullFromCache(['event', 'get', eventId]);
48603
+ if (!cache)
48604
+ return;
48605
+ return {
48606
+ data: cache.data,
48607
+ cachedAt: cache.cachedAt,
48608
+ };
48609
+ };
48610
+
48611
+ /* begin_public_function
48612
+ id: event.delete
48613
+ */
48614
+ /**
48615
+ * ```js
48616
+ * import { EventRepository } from '@amityco/ts-sdk'
48617
+ * const { success } = await EventRepository.deleteEvent(eventId)
48618
+ * ```
48619
+ *
48620
+ * Deletes a {@link Amity.Event}
48621
+ *
48622
+ * @param eventId The {@link Amity.Event} ID to delete
48623
+ *
48624
+ * @category Event API
48625
+ * @async
48626
+ */
48627
+ const deleteEvent = async (eventId) => {
48628
+ const client = getActiveClient();
48629
+ client.log('event/deleteEvent', eventId);
48630
+ const event = await getEvent$1(eventId);
48631
+ await client.http.delete(`/api/v1/events/${eventId}`);
48632
+ const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
48633
+ upsertInCache(['event', 'get', eventId], deletedEvent);
48634
+ fireEvent('local.event.deleted', {
48635
+ users: [],
48636
+ files: [],
48637
+ communities: [],
48638
+ posts: [],
48639
+ rooms: [],
48640
+ events: [deletedEvent],
48641
+ });
48642
+ };
48643
+ /* end_public_function */
48644
+
48645
+ /* begin_public_function
48646
+ id: event.get
48647
+ */
48648
+ /**
48649
+ * ```js
48650
+ * import { EventRepository } from '@amityco/ts-sdk';
48651
+ *
48652
+ * let event;
48653
+ *
48654
+ * const unsubscribe = EventRepository.getEvent(eventId, response => {
48655
+ * event = response.data;
48656
+ * });
48657
+ * ```
48658
+ *
48659
+ * Observe all mutation on a given {@link Amity.Event}
48660
+ *
48661
+ * @param eventId the ID of the event to observe
48662
+ * @param callback the function to call when new snapshot of event are available
48663
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
48664
+ *
48665
+ * @category Event Live Object
48666
+ */
48667
+ const getEvent = (eventId, callback) => {
48668
+ return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
48669
+ callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
48670
+ });
48671
+ };
48672
+ /* end_public_function */
48673
+
48674
+ class EventPaginationController extends PaginationController {
48675
+ async getRequest(queryParams, token) {
48676
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
48677
+ const options = token ? { token } : { limit };
48678
+ const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
48679
+ return response;
48680
+ }
48681
+ }
48682
+
48683
+ class EventQueryStreamController extends QueryStreamController {
48684
+ constructor(query, cacheKey, notifyChange, preparePayload) {
48685
+ super(query, cacheKey);
48686
+ this.notifyChange = notifyChange;
48687
+ this.preparePayload = preparePayload;
48688
+ }
48689
+ async saveToMainDB(response) {
48690
+ const processedPayload = this.preparePayload(response);
48691
+ const client = getActiveClient();
48692
+ const cachedAt = client.cache && Date.now();
48693
+ if (client.cache)
48694
+ ingestInCache(processedPayload, { cachedAt });
48695
+ }
48696
+ appendToQueryStream(response, direction, refresh = false) {
48697
+ var _a, _b;
48698
+ if (refresh) {
48699
+ pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
48700
+ }
48701
+ else {
48702
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48703
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
48704
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
48705
+ }
48706
+ }
48707
+ reactor(action) {
48708
+ return (event) => {
48709
+ var _a;
48710
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48711
+ if (!collection)
48712
+ return;
48713
+ if (action === EventActionsEnum.OnEventCreated) {
48714
+ collection.data = [...new Set([event.eventId, ...collection.data])];
48715
+ }
48716
+ if (action === EventActionsEnum.OnEventDeleted) {
48717
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
48718
+ }
48719
+ pushToCache(this.cacheKey, collection);
48720
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
48721
+ };
48722
+ }
48723
+ subscribeRTE(createSubscriber) {
48724
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
48725
+ }
48726
+ }
48727
+
48728
+ class EventLiveCollectionController extends LiveCollectionController {
48729
+ constructor(query, callback) {
48730
+ const queryStreamId = hash(query);
48731
+ const cacheKey = ['event', 'collection', queryStreamId];
48732
+ const paginationController = new EventPaginationController(query);
48733
+ super(paginationController, queryStreamId, cacheKey, callback);
48734
+ this.query = query;
48735
+ this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
48736
+ this.callback = callback.bind(this);
48737
+ this.loadPage({ initial: true });
48738
+ }
48739
+ setup() {
48740
+ var _a;
48741
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48742
+ if (!collection)
48743
+ pushToCache(this.cacheKey, { data: [], params: {} });
48744
+ }
48745
+ async persistModel(queryPayload) {
48746
+ await this.queryStreamController.saveToMainDB(queryPayload);
48747
+ }
48748
+ persistQueryStream({ response, direction, refresh, }) {
48749
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
48750
+ }
48751
+ startSubscription() {
48752
+ return this.queryStreamController.subscribeRTE([
48753
+ { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
48754
+ { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
48755
+ { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
48756
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
48757
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
48758
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
48759
+ ]);
48760
+ }
48761
+ notifyChange({ origin, loading, error }) {
48762
+ var _a, _b;
48763
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48764
+ if (!collection)
48765
+ return;
48766
+ const data = ((_b = collection.data
48767
+ .map(eventId => pullFromCache(['event', 'get', eventId]))
48768
+ .filter(isNonNullable)
48769
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
48770
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
48771
+ return;
48772
+ this.callback({
48773
+ data,
48774
+ error,
48775
+ loading,
48776
+ hasNextPage: !!this.paginationController.getNextToken(),
48777
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
48778
+ });
48779
+ }
48780
+ }
48781
+
48782
+ /**
48783
+ * Get events
48784
+ *
48785
+ * @param params the query parameters
48786
+ * @param callback the callback to be called when the events are updated
48787
+ * @returns events
48788
+ *
48789
+ * @category Event Live Collection
48790
+ *
48791
+ */
48792
+ const getEvents = (params, callback, config) => {
48793
+ const { log, cache } = getActiveClient();
48794
+ if (!cache)
48795
+ console.log(ENABLE_CACHE_MESSAGE);
48796
+ const timestamp = Date.now();
48797
+ log(`getEvents: (tmpid: ${timestamp}) > listen`);
48798
+ const eventLiveCollection = new EventLiveCollectionController(params, callback);
48799
+ const disposers = eventLiveCollection.startSubscription();
48800
+ const cacheKey = eventLiveCollection.getCacheKey();
48801
+ disposers.push(() => dropFromCache(cacheKey));
48802
+ return () => {
48803
+ log(`getEvents (tmpid: ${timestamp}) > dispose`);
48804
+ disposers.forEach(fn => fn());
48805
+ };
48806
+ };
48807
+
48808
+ class MyEventPaginationController extends PaginationController {
48809
+ async getRequest(queryParams, token) {
48810
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
48811
+ const options = token ? { token } : { limit };
48812
+ const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
48813
+ return response;
48814
+ }
48815
+ }
48816
+
48817
+ class MyEventQueryStreamController extends QueryStreamController {
48818
+ constructor(query, cacheKey, notifyChange, preparePayload) {
48819
+ super(query, cacheKey);
48820
+ this.notifyChange = notifyChange;
48821
+ this.preparePayload = preparePayload;
48822
+ }
48823
+ async saveToMainDB(response) {
48824
+ const processedPayload = this.preparePayload(response);
48825
+ const client = getActiveClient();
48826
+ const cachedAt = client.cache && Date.now();
48827
+ if (client.cache)
48828
+ ingestInCache(processedPayload, { cachedAt });
48829
+ }
48830
+ appendToQueryStream(response, direction, refresh = false) {
48831
+ var _a, _b;
48832
+ if (refresh) {
48833
+ pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
48834
+ }
48835
+ else {
48836
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48837
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
48838
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
48839
+ }
48840
+ }
48841
+ reactor(action) {
48842
+ return (event) => {
48843
+ var _a;
48844
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48845
+ if (!collection)
48846
+ return;
48847
+ if (action === EventActionsEnum.OnEventCreated) {
48848
+ const client = getActiveClient();
48849
+ if (client.userId !== event.userId)
48850
+ return;
48851
+ collection.data = [...new Set([event.eventId, ...collection.data])];
48852
+ }
48853
+ if (action === EventActionsEnum.OnEventDeleted) {
48854
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
48855
+ }
48856
+ pushToCache(this.cacheKey, collection);
48857
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
48858
+ };
48859
+ }
48860
+ subscribeRTE(createSubscriber) {
48861
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
48862
+ }
48863
+ }
48864
+
48865
+ class MyEventLiveCollectionController extends LiveCollectionController {
48866
+ constructor(query, callback) {
48867
+ const queryStreamId = hash(query);
48868
+ const cacheKey = ['event', 'collection', queryStreamId];
48869
+ const paginationController = new MyEventPaginationController(query);
48870
+ super(paginationController, queryStreamId, cacheKey, callback);
48871
+ this.query = query;
48872
+ this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
48873
+ this.callback = callback.bind(this);
48874
+ this.loadPage({ initial: true });
48875
+ }
48876
+ setup() {
48877
+ var _a;
48878
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48879
+ if (!collection)
48880
+ pushToCache(this.cacheKey, { data: [], params: {} });
48881
+ }
48882
+ async persistModel(queryPayload) {
48883
+ await this.queryStreamController.saveToMainDB(queryPayload);
48884
+ }
48885
+ persistQueryStream({ response, direction, refresh, }) {
48886
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
48887
+ }
48888
+ startSubscription() {
48889
+ return this.queryStreamController.subscribeRTE([
48890
+ { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
48891
+ { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
48892
+ { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
48893
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
48894
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
48895
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
48896
+ ]);
48897
+ }
48898
+ notifyChange({ origin, loading, error }) {
48899
+ var _a, _b;
48900
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48901
+ if (!collection)
48902
+ return;
48903
+ const data = ((_b = collection.data
48904
+ .map(eventId => pullFromCache(['event', 'get', eventId]))
48905
+ .filter(isNonNullable)
48906
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
48907
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
48908
+ return;
48909
+ this.callback({
48910
+ data,
48911
+ error,
48912
+ loading,
48913
+ hasNextPage: !!this.paginationController.getNextToken(),
48914
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
48915
+ });
48916
+ }
48917
+ }
48918
+
48919
+ /**
48920
+ * Get my events
48921
+ *
48922
+ * @param params the query parameters
48923
+ * @param callback the callback to be called when the events are updated
48924
+ * @returns events
48925
+ *
48926
+ * @category Event Live Collection
48927
+ *
48928
+ */
48929
+ const getMyEvents = (params, callback, config) => {
48930
+ const { log, cache } = getActiveClient();
48931
+ if (!cache)
48932
+ console.log(ENABLE_CACHE_MESSAGE);
48933
+ const timestamp = Date.now();
48934
+ log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
48935
+ const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
48936
+ const disposers = myEventLiveCollection.startSubscription();
48937
+ const cacheKey = myEventLiveCollection.getCacheKey();
48938
+ disposers.push(() => dropFromCache(cacheKey));
48939
+ return () => {
48940
+ log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
48941
+ disposers.forEach(fn => fn());
48942
+ };
48943
+ };
48944
+
48945
+ var index = /*#__PURE__*/Object.freeze({
48946
+ __proto__: null,
48947
+ createEvent: createEvent,
48948
+ updateEvent: updateEvent,
48949
+ deleteEvent: deleteEvent,
48950
+ onEventCreated: onEventCreated,
48951
+ onEventUpdated: onEventUpdated,
48952
+ onEventDeleted: onEventDeleted,
48953
+ onLocalEventCreated: onLocalEventCreated,
48954
+ onLocalEventUpdated: onLocalEventUpdated,
48955
+ onLocalEventDeleted: onLocalEventDeleted,
48956
+ onRSVPCreated: onRSVPCreated,
48957
+ onRSVPUpdated: onRSVPUpdated,
48958
+ onLocalRSVPCreated: onLocalRSVPCreated,
48959
+ onLocalRSVPUpdated: onLocalRSVPUpdated,
48960
+ getEvent: getEvent,
48961
+ getEvents: getEvents,
48962
+ getMyEvents: getMyEvents,
48963
+ getRSVPs: getRSVPs
48964
+ });
48965
+
48966
+ export { API_REGIONS, index$4 as AdRepository, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, index$e as CategoryRepository, index$i as ChannelRepository, index$r as Client, index$d as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$f as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$c as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$o as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$m as MessageRepository, index$7 as PollRepository, PostContentType, index$b as PostRepository, PostStructureType, index$n as ReactionRepository, index$8 as RoomPresenceRepository, index$9 as RoomRepository, index$5 as StoryRepository, index$a as StreamRepository, index$l as SubChannelRepository, SubscriptionLevels, index$p as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$3 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };