@amityco/ts-sdk 7.11.1-7526ae66.0 → 7.11.1-7696451.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 (187) hide show
  1. package/dist/@types/core/events.d.ts +36 -13
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +6 -3
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +30 -4
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/core/permissions.d.ts +5 -1
  8. package/dist/@types/core/permissions.d.ts.map +1 -1
  9. package/dist/@types/core/transport.d.ts +3 -0
  10. package/dist/@types/core/transport.d.ts.map +1 -1
  11. package/dist/@types/domains/community.d.ts +11 -1
  12. package/dist/@types/domains/community.d.ts.map +1 -1
  13. package/dist/@types/domains/content.d.ts +1 -4
  14. package/dist/@types/domains/content.d.ts.map +1 -1
  15. package/dist/@types/domains/event.d.ts +109 -0
  16. package/dist/@types/domains/event.d.ts.map +1 -0
  17. package/dist/@types/domains/notification.d.ts +3 -1
  18. package/dist/@types/domains/notification.d.ts.map +1 -1
  19. package/dist/@types/domains/partials.d.ts +2 -2
  20. package/dist/@types/domains/partials.d.ts.map +1 -1
  21. package/dist/@types/domains/post.d.ts +0 -2
  22. package/dist/@types/domains/post.d.ts.map +1 -1
  23. package/dist/@types/index.d.ts +1 -2
  24. package/dist/@types/index.d.ts.map +1 -1
  25. package/dist/core/events.d.ts +3 -3
  26. package/dist/core/events.d.ts.map +1 -1
  27. package/dist/core/model/idResolvers.d.ts.map +1 -1
  28. package/dist/core/model/index.d.ts.map +1 -1
  29. package/dist/eventRepository/api/createEvent.d.ts +16 -0
  30. package/dist/eventRepository/api/createEvent.d.ts.map +1 -0
  31. package/dist/eventRepository/api/deleteEvent.d.ts +15 -0
  32. package/dist/eventRepository/api/deleteEvent.d.ts.map +1 -0
  33. package/dist/eventRepository/api/index.d.ts +4 -0
  34. package/dist/eventRepository/api/index.d.ts.map +1 -0
  35. package/dist/eventRepository/api/updateEvent.d.ts +17 -0
  36. package/dist/eventRepository/api/updateEvent.d.ts.map +1 -0
  37. package/dist/eventRepository/events/enums.d.ts +8 -0
  38. package/dist/eventRepository/events/enums.d.ts.map +1 -0
  39. package/dist/eventRepository/events/index.d.ts +11 -0
  40. package/dist/eventRepository/events/index.d.ts.map +1 -0
  41. package/dist/eventRepository/events/onEventCreated.d.ts +17 -0
  42. package/dist/eventRepository/events/onEventCreated.d.ts.map +1 -0
  43. package/dist/eventRepository/events/onEventDeleted.d.ts +17 -0
  44. package/dist/eventRepository/events/onEventDeleted.d.ts.map +1 -0
  45. package/dist/eventRepository/events/onEventUpdated.d.ts +17 -0
  46. package/dist/eventRepository/events/onEventUpdated.d.ts.map +1 -0
  47. package/dist/eventRepository/events/onLocalEventCreated.d.ts +17 -0
  48. package/dist/eventRepository/events/onLocalEventCreated.d.ts.map +1 -0
  49. package/dist/eventRepository/events/onLocalEventDeleted.d.ts +17 -0
  50. package/dist/eventRepository/events/onLocalEventDeleted.d.ts.map +1 -0
  51. package/dist/eventRepository/events/onLocalEventUpdated.d.ts +17 -0
  52. package/dist/eventRepository/events/onLocalEventUpdated.d.ts.map +1 -0
  53. package/dist/eventRepository/events/onLocalRSVPCreated.d.ts +17 -0
  54. package/dist/eventRepository/events/onLocalRSVPCreated.d.ts.map +1 -0
  55. package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts +17 -0
  56. package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts.map +1 -0
  57. package/dist/eventRepository/events/onRSVPCreated.d.ts +17 -0
  58. package/dist/eventRepository/events/onRSVPCreated.d.ts.map +1 -0
  59. package/dist/eventRepository/events/onRSVPUpdated.d.ts +17 -0
  60. package/dist/eventRepository/events/onRSVPUpdated.d.ts.map +1 -0
  61. package/dist/eventRepository/index.d.ts.map +1 -0
  62. package/dist/eventRepository/internalApi/createRSVP.d.ts +16 -0
  63. package/dist/eventRepository/internalApi/createRSVP.d.ts.map +1 -0
  64. package/dist/eventRepository/internalApi/getEvent.d.ts +32 -0
  65. package/dist/eventRepository/internalApi/getEvent.d.ts.map +1 -0
  66. package/dist/eventRepository/internalApi/getMyRSVP.d.ts +32 -0
  67. package/dist/eventRepository/internalApi/getMyRSVP.d.ts.map +1 -0
  68. package/dist/eventRepository/internalApi/index.d.ts +5 -0
  69. package/dist/eventRepository/internalApi/index.d.ts.map +1 -0
  70. package/dist/eventRepository/internalApi/updateRSVP.d.ts +17 -0
  71. package/dist/eventRepository/internalApi/updateRSVP.d.ts.map +1 -0
  72. package/dist/eventRepository/observers/getEvent.d.ts +21 -0
  73. package/dist/eventRepository/observers/getEvent.d.ts.map +1 -0
  74. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts +13 -0
  75. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +1 -0
  76. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts +5 -0
  77. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts.map +1 -0
  78. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts +15 -0
  79. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts.map +1 -0
  80. package/dist/eventRepository/observers/getEvents.d.ts +12 -0
  81. package/dist/eventRepository/observers/getEvents.d.ts.map +1 -0
  82. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts +13 -0
  83. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +1 -0
  84. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +5 -0
  85. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +1 -0
  86. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +15 -0
  87. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +1 -0
  88. package/dist/eventRepository/observers/getMyEvents.d.ts +12 -0
  89. package/dist/eventRepository/observers/getMyEvents.d.ts.map +1 -0
  90. package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts +13 -0
  91. package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts.map +1 -0
  92. package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts +5 -0
  93. package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts.map +1 -0
  94. package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts +15 -0
  95. package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts.map +1 -0
  96. package/dist/eventRepository/observers/getRSVPs.d.ts +12 -0
  97. package/dist/eventRepository/observers/getRSVPs.d.ts.map +1 -0
  98. package/dist/eventRepository/observers/index.d.ts +5 -0
  99. package/dist/eventRepository/observers/index.d.ts.map +1 -0
  100. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +2 -0
  101. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +1 -0
  102. package/dist/eventRepository/utils/createEventResponseSubscriber.d.ts +2 -0
  103. package/dist/eventRepository/utils/createEventResponseSubscriber.d.ts.map +1 -0
  104. package/dist/eventRepository/utils/index.d.ts +5 -0
  105. package/dist/eventRepository/utils/index.d.ts.map +1 -0
  106. package/dist/eventRepository/utils/prepareEventPayload.d.ts +2 -0
  107. package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +1 -0
  108. package/dist/eventRepository/utils/prepareEventResponsePayload.d.ts +2 -0
  109. package/dist/eventRepository/utils/prepareEventResponsePayload.d.ts.map +1 -0
  110. package/dist/index.cjs.js +13043 -12717
  111. package/dist/index.d.ts +1 -1
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.esm.js +1072 -746
  114. package/dist/index.umd.js +3 -3
  115. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
  116. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  117. package/dist/utils/linkedObject/eventLinkObject.d.ts +2 -0
  118. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -0
  119. package/dist/utils/linkedObject/index.d.ts +1 -0
  120. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  121. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  122. package/dist/utils/postTypePredicate.d.ts +0 -1
  123. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  124. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  125. package/package.json +1 -1
  126. package/dist/@types/domains/room.d.ts +0 -76
  127. package/dist/@types/domains/room.d.ts.map +0 -1
  128. package/dist/roomRepository/api/createRoom.d.ts +0 -24
  129. package/dist/roomRepository/api/createRoom.d.ts.map +0 -1
  130. package/dist/roomRepository/api/deleteRoom.d.ts +0 -16
  131. package/dist/roomRepository/api/deleteRoom.d.ts.map +0 -1
  132. package/dist/roomRepository/api/getRecordedUrl.d.ts +0 -19
  133. package/dist/roomRepository/api/getRecordedUrl.d.ts.map +0 -1
  134. package/dist/roomRepository/api/getRoomToken.d.ts +0 -16
  135. package/dist/roomRepository/api/getRoomToken.d.ts.map +0 -1
  136. package/dist/roomRepository/api/index.d.ts +0 -7
  137. package/dist/roomRepository/api/index.d.ts.map +0 -1
  138. package/dist/roomRepository/api/stopRoom.d.ts +0 -16
  139. package/dist/roomRepository/api/stopRoom.d.ts.map +0 -1
  140. package/dist/roomRepository/api/updateRoom.d.ts +0 -24
  141. package/dist/roomRepository/api/updateRoom.d.ts.map +0 -1
  142. package/dist/roomRepository/events/index.d.ts +0 -12
  143. package/dist/roomRepository/events/index.d.ts.map +0 -1
  144. package/dist/roomRepository/events/onRoomCreated.d.ts +0 -17
  145. package/dist/roomRepository/events/onRoomCreated.d.ts.map +0 -1
  146. package/dist/roomRepository/events/onRoomDeleted.d.ts +0 -17
  147. package/dist/roomRepository/events/onRoomDeleted.d.ts.map +0 -1
  148. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +0 -17
  149. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +0 -1
  150. package/dist/roomRepository/events/onRoomParticipantInviting.d.ts +0 -17
  151. package/dist/roomRepository/events/onRoomParticipantInviting.d.ts.map +0 -1
  152. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +0 -17
  153. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +0 -1
  154. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +0 -17
  155. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +0 -1
  156. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +0 -17
  157. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +0 -1
  158. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +0 -17
  159. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +0 -1
  160. package/dist/roomRepository/events/onRoomStopped.d.ts +0 -17
  161. package/dist/roomRepository/events/onRoomStopped.d.ts.map +0 -1
  162. package/dist/roomRepository/events/onRoomUpdated.d.ts +0 -17
  163. package/dist/roomRepository/events/onRoomUpdated.d.ts.map +0 -1
  164. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +0 -17
  165. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +0 -1
  166. package/dist/roomRepository/index.d.ts.map +0 -1
  167. package/dist/roomRepository/internalApi/getRoomById.d.ts +0 -5
  168. package/dist/roomRepository/internalApi/getRoomById.d.ts.map +0 -1
  169. package/dist/roomRepository/internalApi/index.d.ts +0 -2
  170. package/dist/roomRepository/internalApi/index.d.ts.map +0 -1
  171. package/dist/roomRepository/observers/enums.d.ts +0 -10
  172. package/dist/roomRepository/observers/enums.d.ts.map +0 -1
  173. package/dist/roomRepository/observers/getRoom.d.ts +0 -2
  174. package/dist/roomRepository/observers/getRoom.d.ts.map +0 -1
  175. package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts +0 -14
  176. package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts.map +0 -1
  177. package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts +0 -5
  178. package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts.map +0 -1
  179. package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts +0 -15
  180. package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts.map +0 -1
  181. package/dist/roomRepository/observers/getRooms.d.ts +0 -29
  182. package/dist/roomRepository/observers/getRooms.d.ts.map +0 -1
  183. package/dist/roomRepository/observers/index.d.ts +0 -3
  184. package/dist/roomRepository/observers/index.d.ts.map +0 -1
  185. package/dist/roomRepository/observers/utils.d.ts +0 -6
  186. package/dist/roomRepository/observers/utils.d.ts.map +0 -1
  187. /package/dist/{roomRepository → eventRepository}/index.d.ts +0 -0
package/dist/index.esm.js CHANGED
@@ -112,7 +112,6 @@ const PostContentType = Object.freeze({
112
112
  POLL: 'poll',
113
113
  CLIP: 'clip',
114
114
  AUDIO: 'audio',
115
- ROOM: 'room',
116
115
  });
117
116
  const PostStructureType = Object.freeze({
118
117
  TEXT: 'text',
@@ -178,6 +177,29 @@ var FeedSourceEnum;
178
177
  FeedSourceEnum["User"] = "user";
179
178
  })(FeedSourceEnum || (FeedSourceEnum = {}));
180
179
 
180
+ var AmityEventType;
181
+ (function (AmityEventType) {
182
+ AmityEventType["Virtual"] = "virtual";
183
+ AmityEventType["InPerson"] = "in_person";
184
+ })(AmityEventType || (AmityEventType = {}));
185
+ var AmityEventOriginType;
186
+ (function (AmityEventOriginType) {
187
+ AmityEventOriginType["Community"] = "community";
188
+ AmityEventOriginType["User"] = "user";
189
+ })(AmityEventOriginType || (AmityEventOriginType = {}));
190
+ var AmityEventStatus;
191
+ (function (AmityEventStatus) {
192
+ AmityEventStatus["Scheduled"] = "scheduled";
193
+ AmityEventStatus["Live"] = "live";
194
+ AmityEventStatus["Ended"] = "ended";
195
+ AmityEventStatus["Cancelled"] = "cancelled";
196
+ })(AmityEventStatus || (AmityEventStatus = {}));
197
+ var AmityEventResponseStatus;
198
+ (function (AmityEventResponseStatus) {
199
+ AmityEventResponseStatus["Going"] = "going";
200
+ AmityEventResponseStatus["NotGoing"] = "not_going";
201
+ })(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
202
+
181
203
  function getVersion() {
182
204
  try {
183
205
  // the string ''v7.11.0-esm'' should be replaced by actual value by @rollup/plugin-replace
@@ -626,7 +648,9 @@ const idResolvers = {
626
648
  notificationTraySeen: ({ userId }) => userId,
627
649
  invitation: ({ _id }) => _id,
628
650
  joinRequest: ({ joinRequestId }) => joinRequestId,
629
- room: ({ roomId }) => roomId,
651
+ event: ({ eventId }) => eventId,
652
+ eventResponse: ({ eventId }) => eventId,
653
+ discussionCommunity: ({ communityId }) => communityId,
630
654
  };
631
655
  /**
632
656
  * Retrieve the id resolver matching a domain name
@@ -682,7 +706,9 @@ const PAYLOAD2MODEL = {
682
706
  notificationTrayItems: 'notificationTrayItem',
683
707
  invitations: 'invitation',
684
708
  joinRequests: 'joinRequest',
685
- rooms: 'room',
709
+ events: 'event',
710
+ eventResponses: 'eventResponse',
711
+ discussionCommunities: 'discussionCommunity',
686
712
  };
687
713
  /** hidden */
688
714
  const isOutdated = (prevData, nextData) => {
@@ -28302,12 +28328,6 @@ function isAmityAudioPost(post) {
28302
28328
  'fileId' in post.data &&
28303
28329
  post.dataType === 'audio');
28304
28330
  }
28305
- function isAmityRoomPost(post) {
28306
- return !!(post.data &&
28307
- typeof post.data !== 'string' &&
28308
- 'roomId' in post.data &&
28309
- post.dataType === 'room');
28310
- }
28311
28331
 
28312
28332
  const postLinkedObject = (post) => {
28313
28333
  return shallowClone(post, {
@@ -28402,12 +28422,6 @@ const postLinkedObject = (post) => {
28402
28422
  ? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
28403
28423
  : undefined;
28404
28424
  },
28405
- getRoomInfo() {
28406
- var _a, _b;
28407
- if (!isAmityRoomPost(post))
28408
- return;
28409
- return (_b = pullFromCache(['room', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.roomId])) === null || _b === void 0 ? void 0 : _b.data;
28410
- },
28411
28425
  });
28412
28426
  };
28413
28427
 
@@ -29765,6 +29779,560 @@ const communityLinkedObject = (community) => {
29765
29779
  } });
29766
29780
  };
29767
29781
 
29782
+ const prepareEventResponsePayload = (rawPayload) => {
29783
+ return {
29784
+ respondedAt: rawPayload.eventResponses[0].respondedAt,
29785
+ status: rawPayload.eventResponses[0].status,
29786
+ eventId: rawPayload.eventResponses[0].eventId,
29787
+ event: rawPayload.events,
29788
+ userId: rawPayload.eventResponses[0].userId,
29789
+ user: rawPayload.users.map(convertRawUserToInternalUser),
29790
+ };
29791
+ };
29792
+
29793
+ /* begin_public_function
29794
+ id: event.rsvp.create
29795
+ */
29796
+ /**
29797
+ * ```js
29798
+ * import { event } from '@amityco/ts-sdk'
29799
+ * const response = await event.createRSVP(eventId, status)
29800
+ * ```
29801
+ *
29802
+ * Creates an {@link Amity.InternalEvent}
29803
+ *
29804
+ * @param bundle The data necessary to create a new {@link Amity.InternalEvent}
29805
+ * @returns The newly created {@link Amity.InternalEvent}
29806
+ *
29807
+ * @category Event API
29808
+ * @async
29809
+ */
29810
+ const createRSVP = async (eventId, status) => {
29811
+ const client = getActiveClient();
29812
+ client.log('event/createRSVP', eventId, status);
29813
+ const { data: payload } = await client.http.post(`/api/v1/events/${eventId}/rsvp`, { status });
29814
+ fireEvent('local.rsvp.created', payload);
29815
+ const data = prepareEventResponsePayload(payload);
29816
+ const cachedAt = client.cache && Date.now();
29817
+ if (client.cache)
29818
+ ingestInCache({ eventResponses: [data] }, { cachedAt });
29819
+ return {
29820
+ data,
29821
+ cachedAt,
29822
+ };
29823
+ };
29824
+ /* end_public_function */
29825
+
29826
+ /* begin_public_function
29827
+ id: event.update
29828
+ */
29829
+ /**
29830
+ * ```js
29831
+ * import { event } from '@amityco/ts-sdk'
29832
+ * const response = await event.updateRSVP(eventId, status)
29833
+ * ```
29834
+ *
29835
+ * Updates an {@link Amity.EventResponse}
29836
+ *
29837
+ * @param eventId The ID of the {@link Amity.EventResponse} to edit
29838
+ * @param bundle The data necessary to update an existing {@link Amity.EventResponse}
29839
+ * @returns the updated {@link Amity.EventResponse}
29840
+ *
29841
+ * @category Event API
29842
+ * @async
29843
+ */
29844
+ const updateRSVP = async (eventId, status) => {
29845
+ const client = getActiveClient();
29846
+ client.log('event/updateRSVP', eventId, status);
29847
+ const { data: payload } = await client.http.put(`/api/v1/events/${eventId}/rsvp`, { status });
29848
+ fireEvent('local.rsvp.updated', payload);
29849
+ const data = prepareEventResponsePayload(payload);
29850
+ const cachedAt = client.cache && Date.now();
29851
+ if (client.cache)
29852
+ ingestInCache({ eventResponses: [data] }, { cachedAt });
29853
+ return {
29854
+ data,
29855
+ cachedAt,
29856
+ };
29857
+ };
29858
+ /* end_public_function */
29859
+
29860
+ const prepareEventPayload = (rawPayload) => {
29861
+ return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
29862
+ };
29863
+
29864
+ const createEventEventSubscriber = (event, callback) => {
29865
+ const client = getActiveClient();
29866
+ const filter = (payload) => {
29867
+ const unpackedPayload = prepareEventPayload(payload);
29868
+ if (!client.cache) {
29869
+ callback(unpackedPayload.events[0]);
29870
+ }
29871
+ else {
29872
+ ingestInCache(unpackedPayload);
29873
+ const event = pullFromCache([
29874
+ 'event',
29875
+ 'get',
29876
+ unpackedPayload.events[0].eventId,
29877
+ ]);
29878
+ callback(event.data);
29879
+ }
29880
+ };
29881
+ return createEventSubscriber(client, event, event, filter);
29882
+ };
29883
+
29884
+ const createEventResponseSubscriber = (event, callback) => {
29885
+ const client = getActiveClient();
29886
+ const filter = (payload) => {
29887
+ const unpackedPayload = prepareEventResponsePayload(payload);
29888
+ if (!client.cache) {
29889
+ callback(unpackedPayload);
29890
+ }
29891
+ else {
29892
+ ingestInCache(unpackedPayload.event[0]);
29893
+ const eventResponse = pullFromCache([
29894
+ 'eventResponse',
29895
+ 'get',
29896
+ payload.eventResponses[0].eventId,
29897
+ ]);
29898
+ callback(eventResponse.data);
29899
+ }
29900
+ };
29901
+ return createEventSubscriber(client, event, event, filter);
29902
+ };
29903
+
29904
+ /* begin_public_function
29905
+ id: event.rsvp.me
29906
+ */
29907
+ /**
29908
+ * ```js
29909
+ * import { event } from '@amityco/ts-sdk'
29910
+ * const myRSVP = await event.getMyRSVP()
29911
+ * ```
29912
+ *
29913
+ * Joins a {@link Amity.EventResponse} object
29914
+ *
29915
+ * @param eventId the {@link Amity.EventResponse} to get RSVP for
29916
+ * @returns A success boolean if the {@link Amity.EventResponse} RSVP was retrieved
29917
+ *
29918
+ * @category Event API
29919
+ * @async
29920
+ */
29921
+ const getMyRSVP = async (eventId) => {
29922
+ const client = getActiveClient();
29923
+ client.log('event/getMyRSVP', eventId);
29924
+ const { data: payload } = await client.http.get(`/api/v1/events/${eventId}/me/rsvp`);
29925
+ const data = prepareEventResponsePayload(payload);
29926
+ const cachedAt = client.cache && Date.now();
29927
+ if (client.cache)
29928
+ ingestInCache({ eventResponses: [data] }, { cachedAt });
29929
+ return {
29930
+ data,
29931
+ cachedAt,
29932
+ };
29933
+ };
29934
+ /* end_public_function */
29935
+ /**
29936
+ * ```js
29937
+ * import { event } from '@amityco/ts-sdk'
29938
+ * const event = event.getMyRSVP.locally(eventId)
29939
+ * ```
29940
+ *
29941
+ * Fetches a {@link Amity.EventResponse} object in cache
29942
+ *
29943
+ * @param eventId the ID of the {@link Amity.EventResponse} to fetch
29944
+ * @returns the associated {@link Amity.EventResponse} object
29945
+ *
29946
+ * @category Event API
29947
+ */
29948
+ getMyRSVP.locally = (eventId) => {
29949
+ const client = getActiveClient();
29950
+ client.log('event/getMyRSVP.locally', eventId);
29951
+ if (!client.cache)
29952
+ return;
29953
+ const cache = pullFromCache(['event', 'getMyRSVP', eventId]);
29954
+ if (!cache)
29955
+ return;
29956
+ return {
29957
+ data: cache.data,
29958
+ cachedAt: cache.cachedAt,
29959
+ };
29960
+ };
29961
+
29962
+ var EventActionsEnum;
29963
+ (function (EventActionsEnum) {
29964
+ EventActionsEnum["OnEventCreated"] = "onEventCreated";
29965
+ EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
29966
+ EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
29967
+ EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
29968
+ EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
29969
+ })(EventActionsEnum || (EventActionsEnum = {}));
29970
+
29971
+ class RSVPPaginationController extends PaginationController {
29972
+ async getRequest(queryParams, token) {
29973
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, eventId } = queryParams, params = __rest(queryParams, ["limit", "eventId"]);
29974
+ const options = token ? { token } : { limit };
29975
+ const { data: response } = await this.http.get(`/api/v1/events/${eventId}/rsvp`, { params: Object.assign(Object.assign({}, params), { options }) });
29976
+ return response;
29977
+ }
29978
+ }
29979
+
29980
+ class RSVPQueryStreamController extends QueryStreamController {
29981
+ constructor(query, cacheKey, notifyChange, preparePayload) {
29982
+ super(query, cacheKey);
29983
+ this.notifyChange = notifyChange;
29984
+ this.preparePayload = preparePayload;
29985
+ }
29986
+ async saveToMainDB(response) {
29987
+ const processedPayload = this.preparePayload(response);
29988
+ const client = getActiveClient();
29989
+ const cachedAt = client.cache && Date.now();
29990
+ if (client.cache)
29991
+ ingestInCache({ eventResponses: [processedPayload] }, { cachedAt });
29992
+ }
29993
+ appendToQueryStream(response, direction, refresh = false) {
29994
+ var _a, _b;
29995
+ if (refresh) {
29996
+ pushToCache(this.cacheKey, {
29997
+ data: response.eventResponses.map(getResolver('eventResponse')),
29998
+ });
29999
+ }
30000
+ else {
30001
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30002
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
30003
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
30004
+ ...new Set([...events, ...response.eventResponses.map(getResolver('eventResponse'))]),
30005
+ ] }));
30006
+ }
30007
+ }
30008
+ reactor(action) {
30009
+ return (event) => {
30010
+ var _a;
30011
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30012
+ if (!collection)
30013
+ return;
30014
+ if (action === EventActionsEnum.OnRSVPCreated) {
30015
+ const client = getActiveClient();
30016
+ if (client.userId !== event.userId)
30017
+ return;
30018
+ collection.data = [...new Set([event.eventId, ...collection.data])];
30019
+ }
30020
+ if (action === EventActionsEnum.OnEventDeleted) {
30021
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
30022
+ }
30023
+ pushToCache(this.cacheKey, collection);
30024
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
30025
+ };
30026
+ }
30027
+ subscribeRTE(createSubscriber) {
30028
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
30029
+ }
30030
+ }
30031
+
30032
+ /**
30033
+ * ```js
30034
+ * import { EventRepository } from '@amityco/ts-sdk'
30035
+ * const dispose = EventRepository.onEventCreated(event => {
30036
+ * // ...
30037
+ * })
30038
+ * ```
30039
+ *
30040
+ * Fired when a {@link Amity.Event} has been created
30041
+ *
30042
+ * @param callback The function to call when the event was fired
30043
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30044
+ *
30045
+ * @category Event Events
30046
+ */
30047
+ const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
30048
+
30049
+ /**
30050
+ * ```js
30051
+ * import { EventRepository } from '@amityco/ts-sdk'
30052
+ * const dispose = EventRepository.onEventUpdated(event => {
30053
+ * // ...
30054
+ * })
30055
+ * ```
30056
+ *
30057
+ * Fired when a {@link Amity.Event} has been updated
30058
+ *
30059
+ * @param callback The function to call when the event was fired
30060
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30061
+ *
30062
+ * @category Event Events
30063
+ */
30064
+ const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
30065
+
30066
+ /**
30067
+ * ```js
30068
+ * import { EventRepository } from '@amityco/ts-sdk'
30069
+ * const dispose = EventRepository.onEventDeleted(event => {
30070
+ * // ...
30071
+ * })
30072
+ * ```
30073
+ *
30074
+ * Fired when a {@link Amity.Event} has been deleted
30075
+ *
30076
+ * @param callback The function to call when the event was fired
30077
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30078
+ *
30079
+ * @category Event Events
30080
+ */
30081
+ const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
30082
+
30083
+ /**
30084
+ * ```js
30085
+ * import { EventRepository } from '@amityco/ts-sdk'
30086
+ * const dispose = EventRepository.onLocalEventCreated(event => {
30087
+ * // ...
30088
+ * })
30089
+ * ```
30090
+ *
30091
+ * Fired when a {@link Amity.Event} has been created
30092
+ *
30093
+ * @param callback The function to call when the event was fired
30094
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30095
+ *
30096
+ * @category Event Events
30097
+ */
30098
+ const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
30099
+
30100
+ /**
30101
+ * ```js
30102
+ * import { EventRepository } from '@amityco/ts-sdk'
30103
+ * const dispose = EventRepository.onLocalEventUpdated(event => {
30104
+ * // ...
30105
+ * })
30106
+ * ```
30107
+ *
30108
+ * Fired when a {@link Amity.Event} has been updated
30109
+ *
30110
+ * @param callback The function to call when the event was fired
30111
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30112
+ *
30113
+ * @category Event Events
30114
+ */
30115
+ const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
30116
+
30117
+ /**
30118
+ * ```js
30119
+ * import { EventRepository } from '@amityco/ts-sdk'
30120
+ * const dispose = EventRepository.onLocalEventDeleted(event => {
30121
+ * // ...
30122
+ * })
30123
+ * ```
30124
+ *
30125
+ * Fired when a {@link Amity.Event} has been deleted
30126
+ *
30127
+ * @param callback The function to call when the event was fired
30128
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30129
+ *
30130
+ * @category Event Events
30131
+ */
30132
+ const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
30133
+
30134
+ /**
30135
+ * ```js
30136
+ * import { EventRepository } from '@amityco/ts-sdk'
30137
+ * const dispose = EventRepository.onRSVPCreated(event => {
30138
+ * // ...
30139
+ * })
30140
+ * ```
30141
+ *
30142
+ * Fired when a {@link Amity.Event} has been created
30143
+ *
30144
+ * @param callback The function to call when the event was fired
30145
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30146
+ *
30147
+ * @category Event Events
30148
+ */
30149
+ const onRSVPCreated = (callback) => createEventResponseSubscriber('event.rsvp.created', callback);
30150
+
30151
+ /**
30152
+ * ```js
30153
+ * import { EventRepository } from '@amityco/ts-sdk'
30154
+ * const dispose = EventRepository.onRSVPUpdated(event => {
30155
+ * // ...
30156
+ * })
30157
+ * ```
30158
+ *
30159
+ * Fired when a {@link Amity.InternalEventResponse} has been updated
30160
+ *
30161
+ * @param callback The function to call when the event was fired
30162
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30163
+ *
30164
+ * @category Event Events
30165
+ */
30166
+ const onRSVPUpdated = (callback) => createEventResponseSubscriber('event.rsvp.updated', callback);
30167
+
30168
+ /**
30169
+ * ```js
30170
+ * import { EventRepository } from '@amityco/ts-sdk'
30171
+ * const dispose = EventRepository.onLocalRSVPCreated(event => {
30172
+ * // ...
30173
+ * })
30174
+ * ```
30175
+ *
30176
+ * Fired when a {@link Amity.Event} has been created
30177
+ *
30178
+ * @param callback The function to call when the event was fired
30179
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30180
+ *
30181
+ * @category Event Events
30182
+ */
30183
+ const onLocalRSVPCreated = (callback) => createEventResponseSubscriber('local.rsvp.created', callback);
30184
+
30185
+ /**
30186
+ * ```js
30187
+ * import { EventRepository } from '@amityco/ts-sdk'
30188
+ * const dispose = EventRepository.onLocalEventUpdated(event => {
30189
+ * // ...
30190
+ * })
30191
+ * ```
30192
+ *
30193
+ * Fired when a {@link Amity.Event} has been updated
30194
+ *
30195
+ * @param callback The function to call when the event was fired
30196
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30197
+ *
30198
+ * @category Event Events
30199
+ */
30200
+ const onLocalRSVPUpdated = (callback) => createEventResponseSubscriber('local.rsvp.updated', callback);
30201
+
30202
+ class RSVPLiveCollectionController extends LiveCollectionController {
30203
+ constructor(query, callback) {
30204
+ const queryStreamId = hash(query);
30205
+ const cacheKey = ['eventResponse', 'collection', queryStreamId];
30206
+ const paginationController = new RSVPPaginationController(query);
30207
+ super(paginationController, queryStreamId, cacheKey, callback);
30208
+ this.query = query;
30209
+ this.queryStreamController = new RSVPQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventResponsePayload);
30210
+ this.callback = callback.bind(this);
30211
+ this.loadPage({ initial: true });
30212
+ }
30213
+ setup() {
30214
+ var _a;
30215
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30216
+ if (!collection)
30217
+ pushToCache(this.cacheKey, { data: [], params: this.query });
30218
+ }
30219
+ async persistModel(queryPayload) {
30220
+ await this.queryStreamController.saveToMainDB(queryPayload);
30221
+ }
30222
+ persistQueryStream({ response, direction, refresh, }) {
30223
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
30224
+ }
30225
+ startSubscription() {
30226
+ return this.queryStreamController.subscribeRTE([
30227
+ { fn: onRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
30228
+ { fn: onRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
30229
+ { fn: onLocalRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
30230
+ { fn: onLocalRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
30231
+ ]);
30232
+ }
30233
+ notifyChange({ origin, loading, error }) {
30234
+ var _a, _b;
30235
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30236
+ if (!collection)
30237
+ return;
30238
+ const data = (_b = collection.data
30239
+ .map(eventId => pullFromCache(['eventResponse', 'get', eventId]))
30240
+ .filter(isNonNullable)
30241
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
30242
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
30243
+ return;
30244
+ this.callback({
30245
+ data,
30246
+ error,
30247
+ loading,
30248
+ hasNextPage: !!this.paginationController.getNextToken(),
30249
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
30250
+ });
30251
+ }
30252
+ }
30253
+
30254
+ /**
30255
+ * Get events
30256
+ *
30257
+ * @param params the query parameters
30258
+ * @param callback the callback to be called when the events are updated
30259
+ * @returns events
30260
+ *
30261
+ * @category RSVP Live Collection
30262
+ *
30263
+ */
30264
+ const getRSVPs = (params, callback, config) => {
30265
+ const { log, cache } = getActiveClient();
30266
+ if (!cache)
30267
+ console.log(ENABLE_CACHE_MESSAGE);
30268
+ const timestamp = Date.now();
30269
+ log(`getRSVPs: (tmpid: ${timestamp}) > listen`);
30270
+ const rsvpLiveCollection = new RSVPLiveCollectionController(params, callback);
30271
+ const disposers = rsvpLiveCollection.startSubscription();
30272
+ const cacheKey = rsvpLiveCollection.getCacheKey();
30273
+ disposers.push(() => dropFromCache(cacheKey));
30274
+ return () => {
30275
+ log(`getRSVPs (tmpid: ${timestamp}) > dispose`);
30276
+ disposers.forEach(fn => fn());
30277
+ };
30278
+ };
30279
+
30280
+ const eventLinkedObject = (event) => {
30281
+ return Object.assign(Object.assign({}, event), { get creator() {
30282
+ const cacheData = pullFromCache(['user', 'get', event.userId]);
30283
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
30284
+ return;
30285
+ return userLinkedObject(cacheData.data);
30286
+ },
30287
+ get discussionCommunity() {
30288
+ if (!event.discussionCommunityId)
30289
+ return;
30290
+ const cacheData = pullFromCache([
30291
+ 'discussionCommunity',
30292
+ 'get',
30293
+ event.discussionCommunityId,
30294
+ ]);
30295
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
30296
+ return;
30297
+ return communityLinkedObject(cacheData.data);
30298
+ },
30299
+ get targetCommunity() {
30300
+ if (!event.originId)
30301
+ return;
30302
+ const cacheData = pullFromCache(['community', 'get', event.originId]);
30303
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
30304
+ return;
30305
+ return communityLinkedObject(cacheData.data);
30306
+ },
30307
+ get coverImage() {
30308
+ if (!event.coverImageFileId)
30309
+ return;
30310
+ const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
30311
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
30312
+ return;
30313
+ return cacheData.data;
30314
+ },
30315
+ get liveStream() {
30316
+ if (!event.livestreamId)
30317
+ return;
30318
+ const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
30319
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
30320
+ return;
30321
+ return cacheData.data;
30322
+ }, createRSVP: async (status) => {
30323
+ const { data } = await createRSVP(event.eventId, status);
30324
+ return data;
30325
+ }, updateRSVP: async (status) => {
30326
+ const { data } = await updateRSVP(event.eventId, status);
30327
+ return data;
30328
+ }, getMyRSVP: async () => {
30329
+ const { data } = await getMyRSVP(event.eventId);
30330
+ return data;
30331
+ }, getRSVPs: (params, callback) => {
30332
+ return getRSVPs(Object.assign({ eventId: event.eventId }, params), callback);
30333
+ } });
30334
+ };
30335
+
29768
30336
  const LinkedObject = {
29769
30337
  ad: adLinkedObject,
29770
30338
  comment: commentLinkedObject,
@@ -29783,6 +30351,7 @@ const LinkedObject = {
29783
30351
  invitation: invitationLinkedObject,
29784
30352
  joinRequest: joinRequestLinkedObject,
29785
30353
  channelMember: channelMemberLinkedObject,
30354
+ event: eventLinkedObject,
29786
30355
  };
29787
30356
 
29788
30357
  /* begin_public_function
@@ -43767,729 +44336,6 @@ var index$8 = /*#__PURE__*/Object.freeze({
43767
44336
  getStreams: getStreams
43768
44337
  });
43769
44338
 
43770
- /* begin_public_function
43771
- id: room.create
43772
- */
43773
- /**
43774
- * ```js
43775
- * import { createRoom } from '@amityco/ts-sdk'
43776
- * const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
43777
- * ```
43778
- *
43779
- * Creates an {@link Amity.Room}
43780
- *
43781
- * @param bundle The data necessary to create a new {@link Amity.Room}
43782
- * @returns The newly created {@link Amity.Room}
43783
- *
43784
- * @category Room API
43785
- * @async
43786
- */
43787
- const createRoom = async (bundle) => {
43788
- const client = getActiveClient();
43789
- client.log('room/createRoom', bundle);
43790
- const { data } = await client.http.post('/api/v1/rooms', bundle);
43791
- fireEvent('local.room.created', data);
43792
- const cachedAt = client.cache && Date.now();
43793
- // TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
43794
- if (client.cache)
43795
- ingestInCache(data, { cachedAt });
43796
- const { rooms } = data;
43797
- return {
43798
- data: rooms[0],
43799
- cachedAt,
43800
- };
43801
- };
43802
- /* end_public_function */
43803
-
43804
- /* begin_public_function
43805
- id: room.update
43806
- */
43807
- /**
43808
- * ```js
43809
- * import { updateRoom } from '@amityco/ts-sdk'
43810
- * const updated = await updateRoom('roomId', { title: 'updated title' })
43811
- * ```
43812
- *
43813
- * Updates an {@link Amity.InternalRoom}
43814
- *
43815
- * @param roomId The ID of the room to update
43816
- * @param bundle The data to update the room with
43817
- * @returns The updated {@link Amity.InternalRoom}
43818
- *
43819
- * @category Room API
43820
- * @async
43821
- */
43822
- const updateRoom = async (roomId, bundle) => {
43823
- const client = getActiveClient();
43824
- client.log('room/updateRoom', { roomId, bundle });
43825
- const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
43826
- fireEvent('local.room.updated', data);
43827
- const cachedAt = client.cache && Date.now();
43828
- if (client.cache)
43829
- ingestInCache(data, { cachedAt });
43830
- const { rooms } = data;
43831
- return {
43832
- data: rooms[0],
43833
- cachedAt,
43834
- };
43835
- };
43836
- /* end_public_function */
43837
-
43838
- /* begin_public_function
43839
- id: room.delete
43840
- */
43841
- /**
43842
- * ```js
43843
- * import { deleteRoom } from '@amityco/ts-sdk'
43844
- * const result = await deleteRoom('roomId')
43845
- * ```
43846
- *
43847
- * Deletes an {@link Amity.Room}
43848
- *
43849
- * @param roomId The ID of the room to delete
43850
- * @returns Promise that resolves when the room is deleted
43851
- *
43852
- * @category Room API
43853
- * @async
43854
- */
43855
- const deleteRoom = async (roomId) => {
43856
- const client = getActiveClient();
43857
- client.log('room/deleteRoom', { roomId });
43858
- await client.http.delete(`/api/v1/rooms/${roomId}`);
43859
- fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
43860
- };
43861
- /* end_public_function */
43862
-
43863
- /* begin_public_function
43864
- id: room.stop
43865
- */
43866
- /**
43867
- * ```js
43868
- * import { stopRoom } from '@amityco/ts-sdk'
43869
- * const result = await stopRoom('roomId')
43870
- * ```
43871
- *
43872
- * Stops a room's broadcasting
43873
- *
43874
- * @param roomId The ID of the room to stop
43875
- * @returns The updated room data
43876
- *
43877
- * @category Room API
43878
- * @async
43879
- */
43880
- const stopRoom = async (roomId) => {
43881
- const client = getActiveClient();
43882
- client.log('room/stopRoom', { roomId });
43883
- const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
43884
- fireEvent('local.room.stopped', data);
43885
- const cachedAt = client.cache && Date.now();
43886
- if (client.cache)
43887
- ingestInCache(data, { cachedAt });
43888
- const { rooms } = data;
43889
- return {
43890
- data: rooms[0],
43891
- cachedAt,
43892
- };
43893
- };
43894
- /* end_public_function */
43895
-
43896
- /* begin_public_function
43897
- id: room.getToken
43898
- */
43899
- /**
43900
- * ```js
43901
- * import { getRoomToken } from '@amityco/ts-sdk'
43902
- * const token = await getRoomToken('roomId')
43903
- * ```
43904
- *
43905
- * Gets an access token for a room
43906
- *
43907
- * @param roomId The ID of the room to get token for
43908
- * @returns The room access token
43909
- *
43910
- * @category Room API
43911
- * @async
43912
- */
43913
- const getRoomToken = async (roomId) => {
43914
- const client = getActiveClient();
43915
- client.log('room/getRoomToken', { roomId });
43916
- const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
43917
- return data;
43918
- };
43919
- /* end_public_function */
43920
-
43921
- /* begin_public_function
43922
- id: room.getRecordedUrl
43923
- */
43924
- /**
43925
- * ```js
43926
- * import { getRecordedUrl } from '@amityco/ts-sdk'
43927
- * const recordedUrl = await getRecordedUrl('roomId')
43928
- * ```
43929
- *
43930
- * Gets the recorded URL for a room
43931
- *
43932
- * @param roomId The ID of the room to get recorded URL for
43933
- * @returns The recorded URL information
43934
- *
43935
- * @category Room API
43936
- * @async
43937
- */
43938
- const getRecordedUrl = async (roomId) => {
43939
- const client = getActiveClient();
43940
- client.log('room/getRecordedUrl', { roomId });
43941
- const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
43942
- return data;
43943
- };
43944
- /* end_public_function */
43945
-
43946
- /**
43947
- * ```js
43948
- * import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
43949
- * const dispose = onRoomStartBroadcasting(room => {
43950
- * // ...
43951
- * })
43952
- * ```
43953
- *
43954
- * Fired when a {@link Amity.Room} has started broadcasting
43955
- *
43956
- * @param callback The function to call when the event was fired
43957
- * @returns an {@link Amity.Unsubscriber} function to stop listening
43958
- *
43959
- * @category Room Events
43960
- */
43961
- const onRoomStartBroadcasting = (callback) => {
43962
- const client = getActiveClient();
43963
- const filter = (payload) => {
43964
- ingestInCache(payload);
43965
- callback(payload.rooms[0]);
43966
- };
43967
- return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
43968
- };
43969
-
43970
- /**
43971
- * ```js
43972
- * import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
43973
- * const dispose = onRoomWaitingReconnect(room => {
43974
- * // ...
43975
- * })
43976
- * ```
43977
- *
43978
- * Fired when a {@link Amity.Room} is waiting for reconnection
43979
- *
43980
- * @param callback The function to call when the event was fired
43981
- * @returns an {@link Amity.Unsubscriber} function to stop listening
43982
- *
43983
- * @category Room Events
43984
- */
43985
- const onRoomWaitingReconnect = (callback) => {
43986
- const client = getActiveClient();
43987
- const filter = (payload) => {
43988
- ingestInCache(payload);
43989
- callback(payload.rooms[0]);
43990
- };
43991
- return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
43992
- };
43993
-
43994
- /**
43995
- * ```js
43996
- * import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
43997
- * const dispose = onRoomEndBroadcasting(room => {
43998
- * // ...
43999
- * })
44000
- * ```
44001
- *
44002
- * Fired when a {@link Amity.Room} has ended broadcasting
44003
- *
44004
- * @param callback The function to call when the event was fired
44005
- * @returns an {@link Amity.Unsubscriber} function to stop listening
44006
- *
44007
- * @category Room Events
44008
- */
44009
- const onRoomEndBroadcasting = (callback) => {
44010
- const client = getActiveClient();
44011
- const filter = (payload) => {
44012
- ingestInCache(payload);
44013
- callback(payload.rooms[0]);
44014
- };
44015
- return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
44016
- };
44017
-
44018
- /**
44019
- * ```js
44020
- * import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
44021
- * const dispose = onRoomRecordedAvailable(room => {
44022
- * // ...
44023
- * })
44024
- * ```
44025
- *
44026
- * Fired when a {@link Amity.Room} recorded content becomes available
44027
- *
44028
- * @param callback The function to call when the event was fired
44029
- * @returns an {@link Amity.Unsubscriber} function to stop listening
44030
- *
44031
- * @category Room Events
44032
- */
44033
- const onRoomRecordedAvailable = (callback) => {
44034
- const client = getActiveClient();
44035
- const filter = (payload) => {
44036
- ingestInCache(payload);
44037
- callback(payload.rooms[0]);
44038
- };
44039
- return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
44040
- };
44041
-
44042
- /**
44043
- * ```js
44044
- * import { onRoomParticipantInviting } from '@amityco/ts-sdk'
44045
- * const dispose = onRoomParticipantInviting(room => {
44046
- * // ...
44047
- * })
44048
- * ```
44049
- *
44050
- * Fired when a participant is being invited to a {@link Amity.Room}
44051
- *
44052
- * @param callback The function to call when the event was fired
44053
- * @returns an {@link Amity.Unsubscriber} function to stop listening
44054
- *
44055
- * @category Room Events
44056
- */
44057
- const onRoomParticipantInviting = (callback) => {
44058
- const client = getActiveClient();
44059
- const filter = (payload) => {
44060
- ingestInCache(payload);
44061
- callback(payload.rooms[0]);
44062
- };
44063
- return createEventSubscriber(client, 'room/onRoomParticipantInviting', 'room.participantInviting', filter);
44064
- };
44065
-
44066
- /**
44067
- * ```js
44068
- * import { onRoomParticipantJoined } from '@amityco/ts-sdk'
44069
- * const dispose = onRoomParticipantJoined(room => {
44070
- * // ...
44071
- * })
44072
- * ```
44073
- *
44074
- * Fired when a participant has joined a {@link Amity.Room}
44075
- *
44076
- * @param callback The function to call when the event was fired
44077
- * @returns an {@link Amity.Unsubscriber} function to stop listening
44078
- *
44079
- * @category Room Events
44080
- */
44081
- const onRoomParticipantJoined = (callback) => {
44082
- const client = getActiveClient();
44083
- const filter = (payload) => {
44084
- ingestInCache(payload);
44085
- callback(payload.rooms[0]);
44086
- };
44087
- return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
44088
- };
44089
-
44090
- /**
44091
- * ```js
44092
- * import { onRoomParticipantLeft } from '@amityco/ts-sdk'
44093
- * const dispose = onRoomParticipantLeft(room => {
44094
- * // ...
44095
- * })
44096
- * ```
44097
- *
44098
- * Fired when a participant has left a {@link Amity.Room}
44099
- *
44100
- * @param callback The function to call when the event was fired
44101
- * @returns an {@link Amity.Unsubscriber} function to stop listening
44102
- *
44103
- * @category Room Events
44104
- */
44105
- const onRoomParticipantLeft = (callback) => {
44106
- const client = getActiveClient();
44107
- const filter = (payload) => {
44108
- ingestInCache(payload);
44109
- callback(payload.rooms[0]);
44110
- };
44111
- return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
44112
- };
44113
-
44114
- /**
44115
- * ```js
44116
- * import { onRoomCreated } from '@amityco/ts-sdk'
44117
- * const dispose = onRoomCreated(room => {
44118
- * // ...
44119
- * })
44120
- * ```
44121
- *
44122
- * Fired when a {@link Amity.Room} has been created locally
44123
- *
44124
- * @param callback The function to call when the event was fired
44125
- * @returns an {@link Amity.Unsubscriber} function to stop listening
44126
- *
44127
- * @category Room Events
44128
- */
44129
- const onRoomCreated = (callback) => {
44130
- const client = getActiveClient();
44131
- const filter = (payload) => {
44132
- ingestInCache(payload);
44133
- callback(payload.rooms[0]);
44134
- };
44135
- return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
44136
- };
44137
-
44138
- /**
44139
- * ```js
44140
- * import { onRoomUpdated } from '@amityco/ts-sdk'
44141
- * const dispose = onRoomUpdated(room => {
44142
- * // ...
44143
- * })
44144
- * ```
44145
- *
44146
- * Fired when a {@link Amity.Room} has been updated locally
44147
- *
44148
- * @param callback The function to call when the event was fired
44149
- * @returns an {@link Amity.Unsubscriber} function to stop listening
44150
- *
44151
- * @category Room Events
44152
- */
44153
- const onRoomUpdated = (callback) => {
44154
- const client = getActiveClient();
44155
- const filter = (payload) => {
44156
- ingestInCache(payload);
44157
- callback(payload.rooms[0]);
44158
- };
44159
- return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
44160
- };
44161
-
44162
- /**
44163
- * ```js
44164
- * import { onRoomDeleted } from '@amityco/ts-sdk'
44165
- * const dispose = onRoomDeleted(room => {
44166
- * // ...
44167
- * })
44168
- * ```
44169
- *
44170
- * Fired when a {@link Amity.Room} has been deleted locally
44171
- *
44172
- * @param callback The function to call when the event was fired
44173
- * @returns an {@link Amity.Unsubscriber} function to stop listening
44174
- *
44175
- * @category Room Events
44176
- */
44177
- const onRoomDeleted = (callback) => {
44178
- const client = getActiveClient();
44179
- const filter = (payload) => {
44180
- ingestInCache(payload);
44181
- callback(payload.rooms[0]);
44182
- };
44183
- return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
44184
- };
44185
-
44186
- /**
44187
- * ```js
44188
- * import { onRoomStopped } from '@amityco/ts-sdk'
44189
- * const dispose = onRoomStopped(room => {
44190
- * // ...
44191
- * })
44192
- * ```
44193
- *
44194
- * Fired when a {@link Amity.Room} has been stopped locally
44195
- *
44196
- * @param callback The function to call when the event was fired
44197
- * @returns an {@link Amity.Unsubscriber} function to stop listening
44198
- *
44199
- * @category Room Events
44200
- */
44201
- const onRoomStopped = (callback) => {
44202
- const client = getActiveClient();
44203
- const filter = (payload) => {
44204
- ingestInCache(payload);
44205
- callback(payload.rooms[0]);
44206
- };
44207
- return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
44208
- };
44209
-
44210
- const getRoomById = async (roomId) => {
44211
- const client = getActiveClient();
44212
- client.log('room/getRoomById', roomId);
44213
- // Check if room is in tombstone
44214
- isInTombstone('room', roomId);
44215
- let data;
44216
- try {
44217
- const response = await client.http.get(`/api/v1/rooms/${roomId}`);
44218
- data = response.data;
44219
- }
44220
- catch (error) {
44221
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
44222
- pushToTombstone('room', roomId);
44223
- }
44224
- throw error;
44225
- }
44226
- const cachedAt = client.cache && Date.now();
44227
- if (client.cache) {
44228
- ingestInCache(data, { cachedAt });
44229
- }
44230
- return {
44231
- data: data.rooms[0],
44232
- cachedAt,
44233
- };
44234
- };
44235
- getRoomById.locally = (roomId) => {
44236
- const client = getActiveClient();
44237
- client.log('room/getRoomById.locally', roomId);
44238
- // Check if room is in tombstone
44239
- isInTombstone('room', roomId);
44240
- const cachedAt = client.cache && Date.now();
44241
- const roomCache = pullFromCache(['room', 'get', roomId]);
44242
- if (!roomCache)
44243
- return;
44244
- return {
44245
- data: roomCache.data,
44246
- cachedAt,
44247
- };
44248
- };
44249
-
44250
- const getRoom = (roomId, callback) => {
44251
- // TODO: add callbackDataSelector if there are linked object fields
44252
- return liveObject(roomId, callback, '_id', getRoomById, [
44253
- onRoomEndBroadcasting,
44254
- onRoomStartBroadcasting,
44255
- onRoomWaitingReconnect,
44256
- onRoomRecordedAvailable,
44257
- ]);
44258
- };
44259
-
44260
- class RoomPaginationController extends PaginationController {
44261
- async getRequest(queryParams, token) {
44262
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
44263
- const baseOptions = {
44264
- type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
44265
- };
44266
- const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
44267
- const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
44268
- params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
44269
- });
44270
- return queryResponse;
44271
- }
44272
- }
44273
-
44274
- var EnumRoomActions;
44275
- (function (EnumRoomActions) {
44276
- EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
44277
- EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
44278
- EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
44279
- EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
44280
- EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
44281
- EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
44282
- EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
44283
- })(EnumRoomActions || (EnumRoomActions = {}));
44284
-
44285
- class RoomQueryStreamController extends QueryStreamController {
44286
- constructor(query, cacheKey, notifyChange, preparePayload) {
44287
- super(query, cacheKey);
44288
- this.notifyChange = notifyChange;
44289
- this.preparePayload = preparePayload;
44290
- }
44291
- async saveToMainDB(response) {
44292
- const processedPayload = await this.preparePayload(response);
44293
- const client = getActiveClient();
44294
- const cachedAt = client.cache && Date.now();
44295
- if (client.cache) {
44296
- ingestInCache(processedPayload, { cachedAt });
44297
- }
44298
- }
44299
- appendToQueryStream(response, direction, refresh = false) {
44300
- var _a, _b;
44301
- if (refresh) {
44302
- pushToCache(this.cacheKey, {
44303
- data: response.rooms.map(getResolver('room')),
44304
- });
44305
- }
44306
- else {
44307
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44308
- const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
44309
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
44310
- }
44311
- }
44312
- reactor(action) {
44313
- return (room) => {
44314
- var _a;
44315
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44316
- if (!collection)
44317
- return;
44318
- if (action === EnumRoomActions.OnRoomDeleted) {
44319
- collection.data = collection.data.filter(roomId => roomId !== room._id);
44320
- }
44321
- if (action === EnumRoomActions.OnRoomCreated) {
44322
- collection.data = [...new Set([room._id, ...collection.data])];
44323
- }
44324
- pushToCache(this.cacheKey, collection);
44325
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
44326
- };
44327
- }
44328
- subscribeRTE(createSubscriber) {
44329
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
44330
- }
44331
- }
44332
-
44333
- // TODO: confirm related events
44334
- const getRoomSubscription = () => [
44335
- {
44336
- fn: onRoomStartBroadcasting,
44337
- action: EnumRoomActions.OnRoomStartBroadcasting,
44338
- },
44339
- {
44340
- fn: onRoomEndBroadcasting,
44341
- action: EnumRoomActions.OnRoomEndBroadcasting,
44342
- },
44343
- {
44344
- fn: onRoomRecordedAvailable,
44345
- action: EnumRoomActions.OnRoomUpdated,
44346
- },
44347
- ];
44348
-
44349
- class RoomLiveCollectionController extends LiveCollectionController {
44350
- constructor(query, callback) {
44351
- const queryStreamId = hash(query);
44352
- const cacheKey = ['rooms', 'collection', queryStreamId];
44353
- const paginationController = new RoomPaginationController(query);
44354
- super(paginationController, queryStreamId, cacheKey, callback);
44355
- this.query = query;
44356
- this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
44357
- this.callback = callback.bind(this);
44358
- this.loadPage({ initial: true });
44359
- }
44360
- setup() {
44361
- var _a;
44362
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44363
- if (!collection) {
44364
- pushToCache(this.cacheKey, {
44365
- data: [],
44366
- params: {},
44367
- });
44368
- }
44369
- }
44370
- async persistModel(queryPayload) {
44371
- await this.queryStreamController.saveToMainDB(queryPayload);
44372
- }
44373
- persistQueryStream({ response, direction, refresh, }) {
44374
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
44375
- }
44376
- startSubscription() {
44377
- return this.queryStreamController.subscribeRTE(getRoomSubscription());
44378
- }
44379
- notifyChange({ origin, loading, error }) {
44380
- var _a, _b;
44381
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44382
- if (!collection)
44383
- return;
44384
- const data = this.applyFilter((_b = collection.data
44385
- .map(id => pullFromCache(['room', 'get', id]))
44386
- .filter(isNonNullable)
44387
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
44388
- if (!this.shouldNotify(data) && origin === 'event')
44389
- return;
44390
- this.callback({
44391
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
44392
- data,
44393
- hasNextPage: !!this.paginationController.getNextToken(),
44394
- loading,
44395
- error,
44396
- });
44397
- }
44398
- applyFilter(data) {
44399
- let rooms = data;
44400
- if (!this.query.includeDeleted) {
44401
- rooms = filterByPropEquality(rooms, 'isDeleted', false);
44402
- }
44403
- if (this.query.statuses && this.query.statuses.length > 0) {
44404
- rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
44405
- }
44406
- if (this.query.type) {
44407
- rooms = filterByPropEquality(rooms, 'type', this.query.type);
44408
- }
44409
- switch (this.query.sortBy) {
44410
- case 'firstCreated':
44411
- rooms = rooms.sort(sortByFirstCreated);
44412
- break;
44413
- case 'lastCreated':
44414
- default:
44415
- rooms = rooms.sort(sortByLastCreated);
44416
- break;
44417
- }
44418
- return rooms;
44419
- }
44420
- }
44421
-
44422
- /* begin_public_function
44423
- id: room.get_rooms
44424
- */
44425
- /**
44426
- * ```js
44427
- * import { RoomRepository } from '@amityco/ts-sdk'
44428
- *
44429
- * let rooms = []
44430
- * const unsub = RoomRepository.getRooms({
44431
- * type: 'direct_streaming',
44432
- * statuses: ['live', 'idle'],
44433
- * sortBy: 'lastCreated',
44434
- * limit: 20,
44435
- * includeDeleted: false
44436
- * }, response => merge(rooms, response.data))
44437
- * ```
44438
- *
44439
- * Observe all mutations on a list of {@link Amity.Room} for a given query
44440
- *
44441
- * @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
44442
- * @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
44443
- * @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
44444
- * @param params.limit maximum number of rooms to retrieve per page
44445
- * @param params.includeDeleted whether to include deleted rooms in the results
44446
- * @param callback the function to call when new data are available
44447
- * @param config optional configuration for the live collection
44448
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
44449
- *
44450
- * @category Rooms Live Collection
44451
- */
44452
- const getRooms = (params, callback, config) => {
44453
- const { log, cache } = getActiveClient();
44454
- if (!cache) {
44455
- console.log(ENABLE_CACHE_MESSAGE);
44456
- }
44457
- const timestamp = Date.now();
44458
- log(`getRooms(tmpid: ${timestamp}) > listen`);
44459
- const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
44460
- const disposers = roomsLiveCollection.startSubscription();
44461
- const cacheKey = roomsLiveCollection.getCacheKey();
44462
- disposers.push(() => dropFromCache(cacheKey));
44463
- return () => {
44464
- log(`getRooms(tmpid: ${timestamp}) > dispose`);
44465
- disposers.forEach(fn => fn());
44466
- };
44467
- };
44468
- /* end_public_function */
44469
-
44470
- var index$7 = /*#__PURE__*/Object.freeze({
44471
- __proto__: null,
44472
- createRoom: createRoom,
44473
- updateRoom: updateRoom,
44474
- deleteRoom: deleteRoom,
44475
- stopRoom: stopRoom,
44476
- getRoomToken: getRoomToken,
44477
- getRecordedUrl: getRecordedUrl,
44478
- onRoomStartBroadcasting: onRoomStartBroadcasting,
44479
- onRoomWaitingReconnect: onRoomWaitingReconnect,
44480
- onRoomEndBroadcasting: onRoomEndBroadcasting,
44481
- onRoomRecordedAvailable: onRoomRecordedAvailable,
44482
- onRoomParticipantInviting: onRoomParticipantInviting,
44483
- onRoomParticipantJoined: onRoomParticipantJoined,
44484
- onRoomParticipantLeft: onRoomParticipantLeft,
44485
- onRoomCreated: onRoomCreated,
44486
- onRoomUpdated: onRoomUpdated,
44487
- onRoomDeleted: onRoomDeleted,
44488
- onRoomStopped: onRoomStopped,
44489
- getRoom: getRoom,
44490
- getRooms: getRooms
44491
- });
44492
-
44493
44339
  /* begin_public_function
44494
44340
  id: poll.create
44495
44341
  */
@@ -44790,7 +44636,7 @@ const getPoll = (pollId, callback) => {
44790
44636
  };
44791
44637
  /* end_public_function */
44792
44638
 
44793
- var index$6 = /*#__PURE__*/Object.freeze({
44639
+ var index$7 = /*#__PURE__*/Object.freeze({
44794
44640
  __proto__: null,
44795
44641
  createPoll: createPoll,
44796
44642
  closePoll: closePoll,
@@ -45173,7 +45019,7 @@ const getPlayer = async (parameters) => {
45173
45019
  return video;
45174
45020
  };
45175
45021
 
45176
- var index$5 = /*#__PURE__*/Object.freeze({
45022
+ var index$6 = /*#__PURE__*/Object.freeze({
45177
45023
  __proto__: null,
45178
45024
  getPlayer: getPlayer
45179
45025
  });
@@ -46346,7 +46192,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
46346
46192
  };
46347
46193
  };
46348
46194
 
46349
- var index$4 = /*#__PURE__*/Object.freeze({
46195
+ var index$5 = /*#__PURE__*/Object.freeze({
46350
46196
  __proto__: null,
46351
46197
  createImageStory: createImageStory,
46352
46198
  createVideoStory: createVideoStory,
@@ -46383,7 +46229,7 @@ const getNetworkAds = async () => {
46383
46229
  };
46384
46230
  };
46385
46231
 
46386
- var index$3 = /*#__PURE__*/Object.freeze({
46232
+ var index$4 = /*#__PURE__*/Object.freeze({
46387
46233
  __proto__: null,
46388
46234
  getNetworkAds: getNetworkAds
46389
46235
  });
@@ -46774,7 +46620,7 @@ const markTraySeen = async (lastSeenAt) => {
46774
46620
  };
46775
46621
  /* end_public_function */
46776
46622
 
46777
- var index$2 = /*#__PURE__*/Object.freeze({
46623
+ var index$3 = /*#__PURE__*/Object.freeze({
46778
46624
  __proto__: null,
46779
46625
  getNotificationTraySeen: getNotificationTraySeen,
46780
46626
  getNotificationTrayItems: getNotificationTrayItems,
@@ -46975,7 +46821,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
46975
46821
  };
46976
46822
  };
46977
46823
 
46978
- var index$1 = /*#__PURE__*/Object.freeze({
46824
+ var index$2 = /*#__PURE__*/Object.freeze({
46979
46825
  __proto__: null,
46980
46826
  onLocalInvitationCreated: onLocalInvitationCreated,
46981
46827
  onLocalInvitationUpdated: onLocalInvitationUpdated,
@@ -47116,11 +46962,491 @@ const getReactions = (postId, callback) => {
47116
46962
  };
47117
46963
  };
47118
46964
 
47119
- var index = /*#__PURE__*/Object.freeze({
46965
+ var index$1 = /*#__PURE__*/Object.freeze({
47120
46966
  __proto__: null,
47121
46967
  createReaction: createReaction,
47122
46968
  onLiveReactionCreated: onLiveReactionCreated,
47123
46969
  getReactions: getReactions
47124
46970
  });
47125
46971
 
47126
- 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 };
46972
+ /* begin_public_function
46973
+ id: event.create
46974
+ */
46975
+ /**
46976
+ * ```js
46977
+ * import { EventRepository } from '@amityco/ts-sdk'
46978
+ * const response = await EventRepository.createEvent(bundle)
46979
+ * ```
46980
+ *
46981
+ * Creates an {@link Amity.Event}
46982
+ *
46983
+ * @param bundle The data necessary to create a new {@link Amity.Event}
46984
+ * @returns The newly created {@link Amity.Event}
46985
+ *
46986
+ * @category Event API
46987
+ * @async
46988
+ */
46989
+ const createEvent = async (bundle) => {
46990
+ const client = getActiveClient();
46991
+ client.log('event/createEvent', bundle);
46992
+ const { data: payload } = await client.http.post('/api/v1/events', bundle);
46993
+ fireEvent('local.event.created', payload);
46994
+ const preparedPayload = prepareEventPayload(payload);
46995
+ const cachedAt = client.cache && Date.now();
46996
+ if (client.cache)
46997
+ ingestInCache(preparedPayload, { cachedAt });
46998
+ return {
46999
+ data: eventLinkedObject(preparedPayload.events[0]),
47000
+ cachedAt,
47001
+ };
47002
+ };
47003
+ /* end_public_function */
47004
+
47005
+ /* begin_public_function
47006
+ id: event.update
47007
+ */
47008
+ /**
47009
+ * ```js
47010
+ * import { EventRepository } from '@amityco/ts-sdk'
47011
+ * const response = await EventRepository.updateEvent(eventId, bundle)
47012
+ * ```
47013
+ *
47014
+ * Updates an {@link Amity.Event}
47015
+ *
47016
+ * @param eventId The ID of the {@link Amity.Event} to edit
47017
+ * @param bundle The data necessary to update an existing {@link Amity.Event}
47018
+ * @returns the updated {@link Amity.Event}
47019
+ *
47020
+ * @category Event API
47021
+ * @async
47022
+ */
47023
+ const updateEvent = async (eventId, bundle) => {
47024
+ const client = getActiveClient();
47025
+ client.log('event/updateEvent', eventId, bundle);
47026
+ const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
47027
+ fireEvent('local.event.updated', payload);
47028
+ const preparedPayload = prepareEventPayload(payload);
47029
+ const cachedAt = client.cache && Date.now();
47030
+ if (client.cache)
47031
+ ingestInCache(preparedPayload, { cachedAt });
47032
+ return {
47033
+ data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
47034
+ cachedAt,
47035
+ };
47036
+ };
47037
+ /* end_public_function */
47038
+
47039
+ /* begin_public_function
47040
+ id: event.get
47041
+ */
47042
+ /**
47043
+ * ```js
47044
+ * import { EventRepository } from '@amityco/ts-sdk'
47045
+ * const event = await EventRepository.getEvent(eventId)
47046
+ * ```
47047
+ *
47048
+ * Fetches a {@link Amity.Event} object
47049
+ *
47050
+ * @param eventId the ID of the {@link Amity.Event} to fetch
47051
+ * @returns the associated {@link Amity.Event} object
47052
+ *
47053
+ * @category Event API
47054
+ * @async
47055
+ */
47056
+ const getEvent$1 = async (eventId) => {
47057
+ const client = getActiveClient();
47058
+ client.log('event/getEvent', eventId);
47059
+ const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
47060
+ const data = prepareEventPayload(payload);
47061
+ const cachedAt = client.cache && Date.now();
47062
+ if (client.cache)
47063
+ ingestInCache(data, { cachedAt });
47064
+ return {
47065
+ data: data.events.find(event => event.eventId === eventId),
47066
+ cachedAt,
47067
+ };
47068
+ };
47069
+ /* end_public_function */
47070
+ /**
47071
+ * ```js
47072
+ * import { EventRepository } from '@amityco/ts-sdk'
47073
+ * const event = EventRepository.getEvent.locally(eventId)
47074
+ * ```
47075
+ *
47076
+ * Fetches a {@link Amity.Event} object in cache
47077
+ *
47078
+ * @param eventId the ID of the {@link Amity.Event} to fetch
47079
+ * @returns the associated {@link Amity.Event} object
47080
+ *
47081
+ * @category Event API
47082
+ */
47083
+ getEvent$1.locally = (eventId) => {
47084
+ const client = getActiveClient();
47085
+ client.log('event/getEvent.locally', eventId);
47086
+ if (!client.cache)
47087
+ return;
47088
+ const cache = pullFromCache(['event', 'get', eventId]);
47089
+ if (!cache)
47090
+ return;
47091
+ return {
47092
+ data: cache.data,
47093
+ cachedAt: cache.cachedAt,
47094
+ };
47095
+ };
47096
+
47097
+ /* begin_public_function
47098
+ id: event.delete
47099
+ */
47100
+ /**
47101
+ * ```js
47102
+ * import { EventRepository } from '@amityco/ts-sdk'
47103
+ * const { success } = await EventRepository.deleteEvent(eventId)
47104
+ * ```
47105
+ *
47106
+ * Deletes a {@link Amity.Event}
47107
+ *
47108
+ * @param eventId The {@link Amity.Event} ID to delete
47109
+ *
47110
+ * @category Event API
47111
+ * @async
47112
+ */
47113
+ const deleteEvent = async (eventId) => {
47114
+ const client = getActiveClient();
47115
+ client.log('event/deleteEvent', eventId);
47116
+ const event = await getEvent$1(eventId);
47117
+ await client.http.delete(`/api/v1/events/${eventId}`);
47118
+ const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
47119
+ upsertInCache(['event', 'get', eventId], deletedEvent);
47120
+ fireEvent('local.event.deleted', {
47121
+ users: [],
47122
+ files: [],
47123
+ communities: [],
47124
+ videoStreamings: [],
47125
+ events: [deletedEvent],
47126
+ discussionCommunities: [],
47127
+ });
47128
+ };
47129
+ /* end_public_function */
47130
+
47131
+ /* begin_public_function
47132
+ id: event.get
47133
+ */
47134
+ /**
47135
+ * ```js
47136
+ * import { EventRepository } from '@amityco/ts-sdk';
47137
+ *
47138
+ * let event;
47139
+ *
47140
+ * const unsubscribe = EventRepository.getEvent(eventId, response => {
47141
+ * event = response.data;
47142
+ * });
47143
+ * ```
47144
+ *
47145
+ * Observe all mutation on a given {@link Amity.Event}
47146
+ *
47147
+ * @param eventId the ID of the event to observe
47148
+ * @param callback the function to call when new snapshot of event are available
47149
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
47150
+ *
47151
+ * @category Event Live Object
47152
+ */
47153
+ const getEvent = (eventId, callback) => {
47154
+ return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
47155
+ callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
47156
+ });
47157
+ };
47158
+ /* end_public_function */
47159
+
47160
+ class EventPaginationController extends PaginationController {
47161
+ async getRequest(queryParams, token) {
47162
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
47163
+ const options = token ? { token } : { limit };
47164
+ const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
47165
+ return response;
47166
+ }
47167
+ }
47168
+
47169
+ class EventQueryStreamController extends QueryStreamController {
47170
+ constructor(query, cacheKey, notifyChange, preparePayload) {
47171
+ super(query, cacheKey);
47172
+ this.notifyChange = notifyChange;
47173
+ this.preparePayload = preparePayload;
47174
+ }
47175
+ async saveToMainDB(response) {
47176
+ const processedPayload = this.preparePayload(response);
47177
+ const client = getActiveClient();
47178
+ const cachedAt = client.cache && Date.now();
47179
+ if (client.cache)
47180
+ ingestInCache(processedPayload, { cachedAt });
47181
+ }
47182
+ appendToQueryStream(response, direction, refresh = false) {
47183
+ var _a, _b;
47184
+ if (refresh) {
47185
+ pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
47186
+ }
47187
+ else {
47188
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47189
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
47190
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
47191
+ }
47192
+ }
47193
+ reactor(action) {
47194
+ return (event) => {
47195
+ var _a;
47196
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47197
+ if (!collection)
47198
+ return;
47199
+ if (action === EventActionsEnum.OnEventCreated) {
47200
+ collection.data = [...new Set([event.eventId, ...collection.data])];
47201
+ }
47202
+ if (action === EventActionsEnum.OnEventDeleted) {
47203
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
47204
+ }
47205
+ pushToCache(this.cacheKey, collection);
47206
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
47207
+ };
47208
+ }
47209
+ subscribeRTE(createSubscriber) {
47210
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
47211
+ }
47212
+ }
47213
+
47214
+ class EventLiveCollectionController extends LiveCollectionController {
47215
+ constructor(query, callback) {
47216
+ const queryStreamId = hash(query);
47217
+ const cacheKey = ['event', 'collection', queryStreamId];
47218
+ const paginationController = new EventPaginationController(query);
47219
+ super(paginationController, queryStreamId, cacheKey, callback);
47220
+ this.query = query;
47221
+ this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
47222
+ this.callback = callback.bind(this);
47223
+ this.loadPage({ initial: true });
47224
+ }
47225
+ setup() {
47226
+ var _a;
47227
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47228
+ if (!collection)
47229
+ pushToCache(this.cacheKey, { data: [], params: {} });
47230
+ }
47231
+ async persistModel(queryPayload) {
47232
+ await this.queryStreamController.saveToMainDB(queryPayload);
47233
+ }
47234
+ persistQueryStream({ response, direction, refresh, }) {
47235
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
47236
+ }
47237
+ startSubscription() {
47238
+ return this.queryStreamController.subscribeRTE([
47239
+ { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
47240
+ { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
47241
+ { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
47242
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
47243
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
47244
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
47245
+ ]);
47246
+ }
47247
+ notifyChange({ origin, loading, error }) {
47248
+ var _a, _b;
47249
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47250
+ if (!collection)
47251
+ return;
47252
+ const data = ((_b = collection.data
47253
+ .map(eventId => pullFromCache(['event', 'get', eventId]))
47254
+ .filter(isNonNullable)
47255
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
47256
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
47257
+ return;
47258
+ this.callback({
47259
+ data,
47260
+ error,
47261
+ loading,
47262
+ hasNextPage: !!this.paginationController.getNextToken(),
47263
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
47264
+ });
47265
+ }
47266
+ }
47267
+
47268
+ /**
47269
+ * Get events
47270
+ *
47271
+ * @param params the query parameters
47272
+ * @param callback the callback to be called when the events are updated
47273
+ * @returns events
47274
+ *
47275
+ * @category Event Live Collection
47276
+ *
47277
+ */
47278
+ const getEvents = (params, callback, config) => {
47279
+ const { log, cache } = getActiveClient();
47280
+ if (!cache)
47281
+ console.log(ENABLE_CACHE_MESSAGE);
47282
+ const timestamp = Date.now();
47283
+ log(`getEvents: (tmpid: ${timestamp}) > listen`);
47284
+ const eventLiveCollection = new EventLiveCollectionController(params, callback);
47285
+ const disposers = eventLiveCollection.startSubscription();
47286
+ const cacheKey = eventLiveCollection.getCacheKey();
47287
+ disposers.push(() => dropFromCache(cacheKey));
47288
+ return () => {
47289
+ log(`getEvents (tmpid: ${timestamp}) > dispose`);
47290
+ disposers.forEach(fn => fn());
47291
+ };
47292
+ };
47293
+
47294
+ class MyEventPaginationController extends PaginationController {
47295
+ async getRequest(queryParams, token) {
47296
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
47297
+ const options = token ? { token } : { limit };
47298
+ const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
47299
+ return response;
47300
+ }
47301
+ }
47302
+
47303
+ class MyEventQueryStreamController extends QueryStreamController {
47304
+ constructor(query, cacheKey, notifyChange, preparePayload) {
47305
+ super(query, cacheKey);
47306
+ this.notifyChange = notifyChange;
47307
+ this.preparePayload = preparePayload;
47308
+ }
47309
+ async saveToMainDB(response) {
47310
+ const processedPayload = this.preparePayload(response);
47311
+ const client = getActiveClient();
47312
+ const cachedAt = client.cache && Date.now();
47313
+ if (client.cache)
47314
+ ingestInCache(processedPayload, { cachedAt });
47315
+ }
47316
+ appendToQueryStream(response, direction, refresh = false) {
47317
+ var _a, _b;
47318
+ if (refresh) {
47319
+ pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
47320
+ }
47321
+ else {
47322
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47323
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
47324
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
47325
+ }
47326
+ }
47327
+ reactor(action) {
47328
+ return (event) => {
47329
+ var _a;
47330
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47331
+ if (!collection)
47332
+ return;
47333
+ if (action === EventActionsEnum.OnEventCreated) {
47334
+ const client = getActiveClient();
47335
+ if (client.userId !== event.userId)
47336
+ return;
47337
+ collection.data = [...new Set([event.eventId, ...collection.data])];
47338
+ }
47339
+ if (action === EventActionsEnum.OnEventDeleted) {
47340
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
47341
+ }
47342
+ pushToCache(this.cacheKey, collection);
47343
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
47344
+ };
47345
+ }
47346
+ subscribeRTE(createSubscriber) {
47347
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
47348
+ }
47349
+ }
47350
+
47351
+ class MyEventLiveCollectionController extends LiveCollectionController {
47352
+ constructor(query, callback) {
47353
+ const queryStreamId = hash(query);
47354
+ const cacheKey = ['event', 'collection', queryStreamId];
47355
+ const paginationController = new MyEventPaginationController(query);
47356
+ super(paginationController, queryStreamId, cacheKey, callback);
47357
+ this.query = query;
47358
+ this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
47359
+ this.callback = callback.bind(this);
47360
+ this.loadPage({ initial: true });
47361
+ }
47362
+ setup() {
47363
+ var _a;
47364
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47365
+ if (!collection)
47366
+ pushToCache(this.cacheKey, { data: [], params: {} });
47367
+ }
47368
+ async persistModel(queryPayload) {
47369
+ await this.queryStreamController.saveToMainDB(queryPayload);
47370
+ }
47371
+ persistQueryStream({ response, direction, refresh, }) {
47372
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
47373
+ }
47374
+ startSubscription() {
47375
+ return this.queryStreamController.subscribeRTE([
47376
+ { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
47377
+ { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
47378
+ { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
47379
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
47380
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
47381
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
47382
+ ]);
47383
+ }
47384
+ notifyChange({ origin, loading, error }) {
47385
+ var _a, _b;
47386
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47387
+ if (!collection)
47388
+ return;
47389
+ const data = ((_b = collection.data
47390
+ .map(eventId => pullFromCache(['event', 'get', eventId]))
47391
+ .filter(isNonNullable)
47392
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
47393
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
47394
+ return;
47395
+ this.callback({
47396
+ data,
47397
+ error,
47398
+ loading,
47399
+ hasNextPage: !!this.paginationController.getNextToken(),
47400
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
47401
+ });
47402
+ }
47403
+ }
47404
+
47405
+ /**
47406
+ * Get my events
47407
+ *
47408
+ * @param params the query parameters
47409
+ * @param callback the callback to be called when the events are updated
47410
+ * @returns events
47411
+ *
47412
+ * @category Event Live Collection
47413
+ *
47414
+ */
47415
+ const getMyEvents = (params, callback, config) => {
47416
+ const { log, cache } = getActiveClient();
47417
+ if (!cache)
47418
+ console.log(ENABLE_CACHE_MESSAGE);
47419
+ const timestamp = Date.now();
47420
+ log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
47421
+ const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
47422
+ const disposers = myEventLiveCollection.startSubscription();
47423
+ const cacheKey = myEventLiveCollection.getCacheKey();
47424
+ disposers.push(() => dropFromCache(cacheKey));
47425
+ return () => {
47426
+ log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
47427
+ disposers.forEach(fn => fn());
47428
+ };
47429
+ };
47430
+
47431
+ var index = /*#__PURE__*/Object.freeze({
47432
+ __proto__: null,
47433
+ createEvent: createEvent,
47434
+ updateEvent: updateEvent,
47435
+ deleteEvent: deleteEvent,
47436
+ onEventCreated: onEventCreated,
47437
+ onEventUpdated: onEventUpdated,
47438
+ onEventDeleted: onEventDeleted,
47439
+ onLocalEventCreated: onLocalEventCreated,
47440
+ onLocalEventUpdated: onLocalEventUpdated,
47441
+ onLocalEventDeleted: onLocalEventDeleted,
47442
+ onRSVPCreated: onRSVPCreated,
47443
+ onRSVPUpdated: onRSVPUpdated,
47444
+ onLocalRSVPCreated: onLocalRSVPCreated,
47445
+ onLocalRSVPUpdated: onLocalRSVPUpdated,
47446
+ getEvent: getEvent,
47447
+ getEvents: getEvents,
47448
+ getMyEvents: getMyEvents,
47449
+ getRSVPs: getRSVPs
47450
+ });
47451
+
47452
+ export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType, AmityEventResponseStatus, AmityEventStatus, AmityEventType, 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, index as EventRepository, FeedDataTypeEnum, index$a as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$m as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$k as MessageRepository, index$7 as PollRepository, PostContentType, index$9 as PostRepository, PostStructureType, index$l as ReactionRepository, index$5 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$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 };