@amityco/ts-sdk 7.11.1-9f733521.0 → 7.11.1-bd338235.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 (154) hide show
  1. package/dist/@types/core/events.d.ts +13 -32
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +3 -2
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +4 -15
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/core/transport.d.ts +0 -3
  8. package/dist/@types/core/transport.d.ts.map +1 -1
  9. package/dist/@types/domains/community.d.ts +1 -8
  10. package/dist/@types/domains/community.d.ts.map +1 -1
  11. package/dist/@types/domains/content.d.ts +4 -1
  12. package/dist/@types/domains/content.d.ts.map +1 -1
  13. package/dist/@types/domains/feed.d.ts +2 -1
  14. package/dist/@types/domains/feed.d.ts.map +1 -1
  15. package/dist/@types/domains/partials.d.ts +2 -2
  16. package/dist/@types/domains/partials.d.ts.map +1 -1
  17. package/dist/@types/domains/post.d.ts +2 -0
  18. package/dist/@types/domains/post.d.ts.map +1 -1
  19. package/dist/@types/domains/room.d.ts +74 -0
  20. package/dist/@types/domains/room.d.ts.map +1 -0
  21. package/dist/@types/index.d.ts +2 -1
  22. package/dist/@types/index.d.ts.map +1 -1
  23. package/dist/core/events.d.ts +3 -3
  24. package/dist/core/events.d.ts.map +1 -1
  25. package/dist/core/model/index.d.ts.map +1 -1
  26. package/dist/index.cjs.js +2675 -2541
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.esm.js +747 -613
  30. package/dist/index.umd.js +3 -3
  31. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
  32. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  33. package/dist/roomRepository/api/createRoom.d.ts +24 -0
  34. package/dist/roomRepository/api/createRoom.d.ts.map +1 -0
  35. package/dist/roomRepository/api/deleteRoom.d.ts +16 -0
  36. package/dist/roomRepository/api/deleteRoom.d.ts.map +1 -0
  37. package/dist/roomRepository/api/getRecordedUrl.d.ts +19 -0
  38. package/dist/roomRepository/api/getRecordedUrl.d.ts.map +1 -0
  39. package/dist/roomRepository/api/getRoomToken.d.ts +16 -0
  40. package/dist/roomRepository/api/getRoomToken.d.ts.map +1 -0
  41. package/dist/roomRepository/api/index.d.ts +7 -0
  42. package/dist/roomRepository/api/index.d.ts.map +1 -0
  43. package/dist/roomRepository/api/stopRoom.d.ts +16 -0
  44. package/dist/roomRepository/api/stopRoom.d.ts.map +1 -0
  45. package/dist/roomRepository/api/updateRoom.d.ts +24 -0
  46. package/dist/roomRepository/api/updateRoom.d.ts.map +1 -0
  47. package/dist/roomRepository/events/index.d.ts +12 -0
  48. package/dist/roomRepository/events/index.d.ts.map +1 -0
  49. package/dist/roomRepository/events/onRoomCreated.d.ts +17 -0
  50. package/dist/roomRepository/events/onRoomCreated.d.ts.map +1 -0
  51. package/dist/roomRepository/events/onRoomDeleted.d.ts +17 -0
  52. package/dist/roomRepository/events/onRoomDeleted.d.ts.map +1 -0
  53. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +17 -0
  54. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +1 -0
  55. package/dist/roomRepository/events/onRoomParticipantInviting.d.ts +17 -0
  56. package/dist/roomRepository/events/onRoomParticipantInviting.d.ts.map +1 -0
  57. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +17 -0
  58. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +1 -0
  59. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +17 -0
  60. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +1 -0
  61. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +17 -0
  62. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +1 -0
  63. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +17 -0
  64. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +1 -0
  65. package/dist/roomRepository/events/onRoomStopped.d.ts +17 -0
  66. package/dist/roomRepository/events/onRoomStopped.d.ts.map +1 -0
  67. package/dist/roomRepository/events/onRoomUpdated.d.ts +17 -0
  68. package/dist/roomRepository/events/onRoomUpdated.d.ts.map +1 -0
  69. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +17 -0
  70. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +1 -0
  71. package/dist/roomRepository/index.d.ts.map +1 -0
  72. package/dist/roomRepository/internalApi/getRoomById.d.ts +5 -0
  73. package/dist/roomRepository/internalApi/getRoomById.d.ts.map +1 -0
  74. package/dist/roomRepository/internalApi/index.d.ts +2 -0
  75. package/dist/roomRepository/internalApi/index.d.ts.map +1 -0
  76. package/dist/roomRepository/observers/enums.d.ts +10 -0
  77. package/dist/roomRepository/observers/enums.d.ts.map +1 -0
  78. package/dist/roomRepository/observers/getRoom.d.ts +2 -0
  79. package/dist/roomRepository/observers/getRoom.d.ts.map +1 -0
  80. package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts +14 -0
  81. package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts.map +1 -0
  82. package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts +5 -0
  83. package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts.map +1 -0
  84. package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts +15 -0
  85. package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts.map +1 -0
  86. package/dist/roomRepository/observers/getRooms.d.ts +29 -0
  87. package/dist/roomRepository/observers/getRooms.d.ts.map +1 -0
  88. package/dist/roomRepository/observers/index.d.ts +3 -0
  89. package/dist/roomRepository/observers/index.d.ts.map +1 -0
  90. package/dist/roomRepository/observers/utils.d.ts +6 -0
  91. package/dist/roomRepository/observers/utils.d.ts.map +1 -0
  92. package/dist/utils/linkedObject/index.d.ts +0 -1
  93. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  94. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  95. package/dist/utils/linkedObject/roomLinkedObject.d.ts +4 -0
  96. package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +1 -0
  97. package/dist/utils/postTypePredicate.d.ts +1 -0
  98. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  99. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  100. package/package.json +1 -1
  101. package/dist/@types/domains/event.d.ts +0 -77
  102. package/dist/@types/domains/event.d.ts.map +0 -1
  103. package/dist/eventRepository/api/createEvent.d.ts +0 -16
  104. package/dist/eventRepository/api/createEvent.d.ts.map +0 -1
  105. package/dist/eventRepository/api/deleteEvent.d.ts +0 -15
  106. package/dist/eventRepository/api/deleteEvent.d.ts.map +0 -1
  107. package/dist/eventRepository/api/index.d.ts +0 -4
  108. package/dist/eventRepository/api/index.d.ts.map +0 -1
  109. package/dist/eventRepository/api/updateEvent.d.ts +0 -17
  110. package/dist/eventRepository/api/updateEvent.d.ts.map +0 -1
  111. package/dist/eventRepository/events/enums.d.ts +0 -6
  112. package/dist/eventRepository/events/enums.d.ts.map +0 -1
  113. package/dist/eventRepository/events/index.d.ts +0 -4
  114. package/dist/eventRepository/events/index.d.ts.map +0 -1
  115. package/dist/eventRepository/events/onEventCreated.d.ts +0 -17
  116. package/dist/eventRepository/events/onEventCreated.d.ts.map +0 -1
  117. package/dist/eventRepository/events/onEventDeleted.d.ts +0 -17
  118. package/dist/eventRepository/events/onEventDeleted.d.ts.map +0 -1
  119. package/dist/eventRepository/events/onEventUpdated.d.ts +0 -17
  120. package/dist/eventRepository/events/onEventUpdated.d.ts.map +0 -1
  121. package/dist/eventRepository/index.d.ts.map +0 -1
  122. package/dist/eventRepository/internalApi/getEvent.d.ts +0 -32
  123. package/dist/eventRepository/internalApi/getEvent.d.ts.map +0 -1
  124. package/dist/eventRepository/internalApi/index.d.ts +0 -2
  125. package/dist/eventRepository/internalApi/index.d.ts.map +0 -1
  126. package/dist/eventRepository/observers/getEvent.d.ts +0 -21
  127. package/dist/eventRepository/observers/getEvent.d.ts.map +0 -1
  128. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts +0 -13
  129. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +0 -1
  130. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts +0 -5
  131. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts.map +0 -1
  132. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts +0 -15
  133. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts.map +0 -1
  134. package/dist/eventRepository/observers/getEvents.d.ts +0 -12
  135. package/dist/eventRepository/observers/getEvents.d.ts.map +0 -1
  136. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts +0 -13
  137. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +0 -1
  138. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +0 -5
  139. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +0 -1
  140. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +0 -15
  141. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +0 -1
  142. package/dist/eventRepository/observers/getMyEvents.d.ts +0 -12
  143. package/dist/eventRepository/observers/getMyEvents.d.ts.map +0 -1
  144. package/dist/eventRepository/observers/index.d.ts +0 -4
  145. package/dist/eventRepository/observers/index.d.ts.map +0 -1
  146. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +0 -2
  147. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +0 -1
  148. package/dist/eventRepository/utils/index.d.ts +0 -3
  149. package/dist/eventRepository/utils/index.d.ts.map +0 -1
  150. package/dist/eventRepository/utils/prepareEventPayload.d.ts +0 -2
  151. package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +0 -1
  152. package/dist/utils/linkedObject/eventLinkObject.d.ts +0 -2
  153. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +0 -1
  154. /package/dist/{eventRepository → roomRepository}/index.d.ts +0 -0
package/dist/index.esm.js CHANGED
@@ -112,6 +112,7 @@ const PostContentType = Object.freeze({
112
112
  POLL: 'poll',
113
113
  CLIP: 'clip',
114
114
  AUDIO: 'audio',
115
+ ROOM: 'room',
115
116
  });
116
117
  const PostStructureType = Object.freeze({
117
118
  TEXT: 'text',
@@ -163,6 +164,7 @@ var FeedDataTypeEnum;
163
164
  FeedDataTypeEnum["LiveStream"] = "liveStream";
164
165
  FeedDataTypeEnum["Clip"] = "clip";
165
166
  FeedDataTypeEnum["Poll"] = "poll";
167
+ FeedDataTypeEnum["Room"] = "room";
166
168
  })(FeedDataTypeEnum || (FeedDataTypeEnum = {}));
167
169
  var FeedSortByEnum;
168
170
  (function (FeedSortByEnum) {
@@ -177,30 +179,6 @@ var FeedSourceEnum;
177
179
  FeedSourceEnum["User"] = "user";
178
180
  })(FeedSourceEnum || (FeedSourceEnum = {}));
179
181
 
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["Interested"] = "interested";
201
- AmityEventResponseStatus["NotGoing"] = "not_going";
202
- })(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
203
-
204
182
  function getVersion() {
205
183
  try {
206
184
  // the string ''v7.11.0-esm'' should be replaced by actual value by @rollup/plugin-replace
@@ -649,7 +627,7 @@ const idResolvers = {
649
627
  notificationTraySeen: ({ userId }) => userId,
650
628
  invitation: ({ _id }) => _id,
651
629
  joinRequest: ({ joinRequestId }) => joinRequestId,
652
- event: ({ eventId }) => eventId,
630
+ room: ({ roomId }) => roomId,
653
631
  };
654
632
  /**
655
633
  * Retrieve the id resolver matching a domain name
@@ -705,8 +683,7 @@ const PAYLOAD2MODEL = {
705
683
  notificationTrayItems: 'notificationTrayItem',
706
684
  invitations: 'invitation',
707
685
  joinRequests: 'joinRequest',
708
- events: 'event',
709
- discussionCommunities: 'community',
686
+ rooms: 'room',
710
687
  };
711
688
  /** hidden */
712
689
  const isOutdated = (prevData, nextData) => {
@@ -28326,6 +28303,12 @@ function isAmityAudioPost(post) {
28326
28303
  'fileId' in post.data &&
28327
28304
  post.dataType === 'audio');
28328
28305
  }
28306
+ function isAmityRoomPost(post) {
28307
+ return !!(post.data &&
28308
+ typeof post.data !== 'string' &&
28309
+ 'roomId' in post.data &&
28310
+ post.dataType === 'room');
28311
+ }
28329
28312
 
28330
28313
  const postLinkedObject = (post) => {
28331
28314
  return shallowClone(post, {
@@ -28420,6 +28403,12 @@ const postLinkedObject = (post) => {
28420
28403
  ? (_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
28421
28404
  : undefined;
28422
28405
  },
28406
+ getRoomInfo() {
28407
+ var _a, _b;
28408
+ if (!isAmityRoomPost(post))
28409
+ return;
28410
+ 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;
28411
+ },
28423
28412
  });
28424
28413
  };
28425
28414
 
@@ -29777,35 +29766,6 @@ const communityLinkedObject = (community) => {
29777
29766
  } });
29778
29767
  };
29779
29768
 
29780
- const eventLinkedObject = (event) => {
29781
- return Object.assign(Object.assign({}, event), { get creator() {
29782
- const cacheData = pullFromCache(['user', 'get', event.userId]);
29783
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29784
- return;
29785
- return userLinkedObject(cacheData.data);
29786
- },
29787
- get discussionCommunity() {
29788
- if (!event.discussionCommunityId)
29789
- return;
29790
- const cacheData = pullFromCache([
29791
- 'community',
29792
- 'get',
29793
- event.discussionCommunityId,
29794
- ]);
29795
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29796
- return;
29797
- return communityLinkedObject(cacheData.data);
29798
- },
29799
- get liveStream() {
29800
- if (!event.livestreamId)
29801
- return;
29802
- const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
29803
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29804
- return;
29805
- return cacheData.data;
29806
- } });
29807
- };
29808
-
29809
29769
  const LinkedObject = {
29810
29770
  ad: adLinkedObject,
29811
29771
  comment: commentLinkedObject,
@@ -29824,7 +29784,6 @@ const LinkedObject = {
29824
29784
  invitation: invitationLinkedObject,
29825
29785
  joinRequest: joinRequestLinkedObject,
29826
29786
  channelMember: channelMemberLinkedObject,
29827
- event: eventLinkedObject,
29828
29787
  };
29829
29788
 
29830
29789
  /* begin_public_function
@@ -43809,6 +43768,729 @@ var index$8 = /*#__PURE__*/Object.freeze({
43809
43768
  getStreams: getStreams
43810
43769
  });
43811
43770
 
43771
+ /* begin_public_function
43772
+ id: room.create
43773
+ */
43774
+ /**
43775
+ * ```js
43776
+ * import { createRoom } from '@amityco/ts-sdk'
43777
+ * const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
43778
+ * ```
43779
+ *
43780
+ * Creates an {@link Amity.Room}
43781
+ *
43782
+ * @param bundle The data necessary to create a new {@link Amity.Room}
43783
+ * @returns The newly created {@link Amity.Room}
43784
+ *
43785
+ * @category Room API
43786
+ * @async
43787
+ */
43788
+ const createRoom = async (bundle) => {
43789
+ const client = getActiveClient();
43790
+ client.log('room/createRoom', bundle);
43791
+ const { data } = await client.http.post('/api/v1/rooms', bundle);
43792
+ fireEvent('local.room.created', data);
43793
+ const cachedAt = client.cache && Date.now();
43794
+ // TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
43795
+ if (client.cache)
43796
+ ingestInCache(data, { cachedAt });
43797
+ const { rooms } = data;
43798
+ return {
43799
+ data: rooms[0],
43800
+ cachedAt,
43801
+ };
43802
+ };
43803
+ /* end_public_function */
43804
+
43805
+ /* begin_public_function
43806
+ id: room.update
43807
+ */
43808
+ /**
43809
+ * ```js
43810
+ * import { updateRoom } from '@amityco/ts-sdk'
43811
+ * const updated = await updateRoom('roomId', { title: 'updated title' })
43812
+ * ```
43813
+ *
43814
+ * Updates an {@link Amity.InternalRoom}
43815
+ *
43816
+ * @param roomId The ID of the room to update
43817
+ * @param bundle The data to update the room with
43818
+ * @returns The updated {@link Amity.InternalRoom}
43819
+ *
43820
+ * @category Room API
43821
+ * @async
43822
+ */
43823
+ const updateRoom = async (roomId, bundle) => {
43824
+ const client = getActiveClient();
43825
+ client.log('room/updateRoom', { roomId, bundle });
43826
+ const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
43827
+ fireEvent('local.room.updated', data);
43828
+ const cachedAt = client.cache && Date.now();
43829
+ if (client.cache)
43830
+ ingestInCache(data, { cachedAt });
43831
+ const { rooms } = data;
43832
+ return {
43833
+ data: rooms[0],
43834
+ cachedAt,
43835
+ };
43836
+ };
43837
+ /* end_public_function */
43838
+
43839
+ /* begin_public_function
43840
+ id: room.delete
43841
+ */
43842
+ /**
43843
+ * ```js
43844
+ * import { deleteRoom } from '@amityco/ts-sdk'
43845
+ * const result = await deleteRoom('roomId')
43846
+ * ```
43847
+ *
43848
+ * Deletes an {@link Amity.Room}
43849
+ *
43850
+ * @param roomId The ID of the room to delete
43851
+ * @returns Promise that resolves when the room is deleted
43852
+ *
43853
+ * @category Room API
43854
+ * @async
43855
+ */
43856
+ const deleteRoom = async (roomId) => {
43857
+ const client = getActiveClient();
43858
+ client.log('room/deleteRoom', { roomId });
43859
+ await client.http.delete(`/api/v1/rooms/${roomId}`);
43860
+ fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
43861
+ };
43862
+ /* end_public_function */
43863
+
43864
+ /* begin_public_function
43865
+ id: room.stop
43866
+ */
43867
+ /**
43868
+ * ```js
43869
+ * import { stopRoom } from '@amityco/ts-sdk'
43870
+ * const result = await stopRoom('roomId')
43871
+ * ```
43872
+ *
43873
+ * Stops a room's broadcasting
43874
+ *
43875
+ * @param roomId The ID of the room to stop
43876
+ * @returns The updated room data
43877
+ *
43878
+ * @category Room API
43879
+ * @async
43880
+ */
43881
+ const stopRoom = async (roomId) => {
43882
+ const client = getActiveClient();
43883
+ client.log('room/stopRoom', { roomId });
43884
+ const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
43885
+ fireEvent('local.room.stopped', data);
43886
+ const cachedAt = client.cache && Date.now();
43887
+ if (client.cache)
43888
+ ingestInCache(data, { cachedAt });
43889
+ const { rooms } = data;
43890
+ return {
43891
+ data: rooms[0],
43892
+ cachedAt,
43893
+ };
43894
+ };
43895
+ /* end_public_function */
43896
+
43897
+ /* begin_public_function
43898
+ id: room.getBroadcasterData
43899
+ */
43900
+ /**
43901
+ * ```js
43902
+ * import { getBroadcasterData } from '@amityco/ts-sdk'
43903
+ * const token = await getBroadcasterData('roomId')
43904
+ * ```
43905
+ *
43906
+ * Gets an access token for a room
43907
+ *
43908
+ * @param roomId The ID of the room to get token for
43909
+ * @returns The room access token
43910
+ *
43911
+ * @category Room API
43912
+ * @async
43913
+ */
43914
+ const getBroadcasterData = async (roomId) => {
43915
+ const client = getActiveClient();
43916
+ client.log('room/getBroadcasterData', { roomId });
43917
+ const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
43918
+ return data;
43919
+ };
43920
+ /* end_public_function */
43921
+
43922
+ /* begin_public_function
43923
+ id: room.getRecordedUrl
43924
+ */
43925
+ /**
43926
+ * ```js
43927
+ * import { getRecordedUrl } from '@amityco/ts-sdk'
43928
+ * const recordedUrl = await getRecordedUrl('roomId')
43929
+ * ```
43930
+ *
43931
+ * Gets the recorded URL for a room
43932
+ *
43933
+ * @param roomId The ID of the room to get recorded URL for
43934
+ * @returns The recorded URL information
43935
+ *
43936
+ * @category Room API
43937
+ * @async
43938
+ */
43939
+ const getRecordedUrl = async (roomId) => {
43940
+ const client = getActiveClient();
43941
+ client.log('room/getRecordedUrl', { roomId });
43942
+ const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
43943
+ return data;
43944
+ };
43945
+ /* end_public_function */
43946
+
43947
+ /**
43948
+ * ```js
43949
+ * import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
43950
+ * const dispose = onRoomStartBroadcasting(room => {
43951
+ * // ...
43952
+ * })
43953
+ * ```
43954
+ *
43955
+ * Fired when a {@link Amity.Room} has started broadcasting
43956
+ *
43957
+ * @param callback The function to call when the event was fired
43958
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
43959
+ *
43960
+ * @category Room Events
43961
+ */
43962
+ const onRoomStartBroadcasting = (callback) => {
43963
+ const client = getActiveClient();
43964
+ const filter = (payload) => {
43965
+ ingestInCache(payload);
43966
+ callback(payload.rooms[0]);
43967
+ };
43968
+ return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
43969
+ };
43970
+
43971
+ /**
43972
+ * ```js
43973
+ * import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
43974
+ * const dispose = onRoomWaitingReconnect(room => {
43975
+ * // ...
43976
+ * })
43977
+ * ```
43978
+ *
43979
+ * Fired when a {@link Amity.Room} is waiting for reconnection
43980
+ *
43981
+ * @param callback The function to call when the event was fired
43982
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
43983
+ *
43984
+ * @category Room Events
43985
+ */
43986
+ const onRoomWaitingReconnect = (callback) => {
43987
+ const client = getActiveClient();
43988
+ const filter = (payload) => {
43989
+ ingestInCache(payload);
43990
+ callback(payload.rooms[0]);
43991
+ };
43992
+ return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
43993
+ };
43994
+
43995
+ /**
43996
+ * ```js
43997
+ * import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
43998
+ * const dispose = onRoomEndBroadcasting(room => {
43999
+ * // ...
44000
+ * })
44001
+ * ```
44002
+ *
44003
+ * Fired when a {@link Amity.Room} has ended broadcasting
44004
+ *
44005
+ * @param callback The function to call when the event was fired
44006
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44007
+ *
44008
+ * @category Room Events
44009
+ */
44010
+ const onRoomEndBroadcasting = (callback) => {
44011
+ const client = getActiveClient();
44012
+ const filter = (payload) => {
44013
+ ingestInCache(payload);
44014
+ callback(payload.rooms[0]);
44015
+ };
44016
+ return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
44017
+ };
44018
+
44019
+ /**
44020
+ * ```js
44021
+ * import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
44022
+ * const dispose = onRoomRecordedAvailable(room => {
44023
+ * // ...
44024
+ * })
44025
+ * ```
44026
+ *
44027
+ * Fired when a {@link Amity.Room} recorded content becomes available
44028
+ *
44029
+ * @param callback The function to call when the event was fired
44030
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44031
+ *
44032
+ * @category Room Events
44033
+ */
44034
+ const onRoomRecordedAvailable = (callback) => {
44035
+ const client = getActiveClient();
44036
+ const filter = (payload) => {
44037
+ ingestInCache(payload);
44038
+ callback(payload.rooms[0]);
44039
+ };
44040
+ return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
44041
+ };
44042
+
44043
+ /**
44044
+ * ```js
44045
+ * import { onRoomParticipantInviting } from '@amityco/ts-sdk'
44046
+ * const dispose = onRoomParticipantInviting(room => {
44047
+ * // ...
44048
+ * })
44049
+ * ```
44050
+ *
44051
+ * Fired when a participant is being invited to a {@link Amity.Room}
44052
+ *
44053
+ * @param callback The function to call when the event was fired
44054
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44055
+ *
44056
+ * @category Room Events
44057
+ */
44058
+ const onRoomParticipantInviting = (callback) => {
44059
+ const client = getActiveClient();
44060
+ const filter = (payload) => {
44061
+ ingestInCache(payload);
44062
+ callback(payload.rooms[0]);
44063
+ };
44064
+ return createEventSubscriber(client, 'room/onRoomParticipantInviting', 'room.participantInviting', filter);
44065
+ };
44066
+
44067
+ /**
44068
+ * ```js
44069
+ * import { onRoomParticipantJoined } from '@amityco/ts-sdk'
44070
+ * const dispose = onRoomParticipantJoined(room => {
44071
+ * // ...
44072
+ * })
44073
+ * ```
44074
+ *
44075
+ * Fired when a participant has joined a {@link Amity.Room}
44076
+ *
44077
+ * @param callback The function to call when the event was fired
44078
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44079
+ *
44080
+ * @category Room Events
44081
+ */
44082
+ const onRoomParticipantJoined = (callback) => {
44083
+ const client = getActiveClient();
44084
+ const filter = (payload) => {
44085
+ ingestInCache(payload);
44086
+ callback(payload.rooms[0]);
44087
+ };
44088
+ return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
44089
+ };
44090
+
44091
+ /**
44092
+ * ```js
44093
+ * import { onRoomParticipantLeft } from '@amityco/ts-sdk'
44094
+ * const dispose = onRoomParticipantLeft(room => {
44095
+ * // ...
44096
+ * })
44097
+ * ```
44098
+ *
44099
+ * Fired when a participant has left a {@link Amity.Room}
44100
+ *
44101
+ * @param callback The function to call when the event was fired
44102
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44103
+ *
44104
+ * @category Room Events
44105
+ */
44106
+ const onRoomParticipantLeft = (callback) => {
44107
+ const client = getActiveClient();
44108
+ const filter = (payload) => {
44109
+ ingestInCache(payload);
44110
+ callback(payload.rooms[0]);
44111
+ };
44112
+ return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
44113
+ };
44114
+
44115
+ /**
44116
+ * ```js
44117
+ * import { onRoomCreated } from '@amityco/ts-sdk'
44118
+ * const dispose = onRoomCreated(room => {
44119
+ * // ...
44120
+ * })
44121
+ * ```
44122
+ *
44123
+ * Fired when a {@link Amity.Room} has been created locally
44124
+ *
44125
+ * @param callback The function to call when the event was fired
44126
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44127
+ *
44128
+ * @category Room Events
44129
+ */
44130
+ const onRoomCreated = (callback) => {
44131
+ const client = getActiveClient();
44132
+ const filter = (payload) => {
44133
+ ingestInCache(payload);
44134
+ callback(payload.rooms[0]);
44135
+ };
44136
+ return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
44137
+ };
44138
+
44139
+ /**
44140
+ * ```js
44141
+ * import { onRoomUpdated } from '@amityco/ts-sdk'
44142
+ * const dispose = onRoomUpdated(room => {
44143
+ * // ...
44144
+ * })
44145
+ * ```
44146
+ *
44147
+ * Fired when a {@link Amity.Room} has been updated locally
44148
+ *
44149
+ * @param callback The function to call when the event was fired
44150
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44151
+ *
44152
+ * @category Room Events
44153
+ */
44154
+ const onRoomUpdated = (callback) => {
44155
+ const client = getActiveClient();
44156
+ const filter = (payload) => {
44157
+ ingestInCache(payload);
44158
+ callback(payload.rooms[0]);
44159
+ };
44160
+ return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
44161
+ };
44162
+
44163
+ /**
44164
+ * ```js
44165
+ * import { onRoomDeleted } from '@amityco/ts-sdk'
44166
+ * const dispose = onRoomDeleted(room => {
44167
+ * // ...
44168
+ * })
44169
+ * ```
44170
+ *
44171
+ * Fired when a {@link Amity.Room} has been deleted locally
44172
+ *
44173
+ * @param callback The function to call when the event was fired
44174
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44175
+ *
44176
+ * @category Room Events
44177
+ */
44178
+ const onRoomDeleted = (callback) => {
44179
+ const client = getActiveClient();
44180
+ const filter = (payload) => {
44181
+ ingestInCache(payload);
44182
+ callback(payload.rooms[0]);
44183
+ };
44184
+ return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
44185
+ };
44186
+
44187
+ /**
44188
+ * ```js
44189
+ * import { onRoomStopped } from '@amityco/ts-sdk'
44190
+ * const dispose = onRoomStopped(room => {
44191
+ * // ...
44192
+ * })
44193
+ * ```
44194
+ *
44195
+ * Fired when a {@link Amity.Room} has been stopped locally
44196
+ *
44197
+ * @param callback The function to call when the event was fired
44198
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44199
+ *
44200
+ * @category Room Events
44201
+ */
44202
+ const onRoomStopped = (callback) => {
44203
+ const client = getActiveClient();
44204
+ const filter = (payload) => {
44205
+ ingestInCache(payload);
44206
+ callback(payload.rooms[0]);
44207
+ };
44208
+ return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
44209
+ };
44210
+
44211
+ const getRoomById = async (roomId) => {
44212
+ const client = getActiveClient();
44213
+ client.log('room/getRoomById', roomId);
44214
+ // Check if room is in tombstone
44215
+ isInTombstone('room', roomId);
44216
+ let data;
44217
+ try {
44218
+ const response = await client.http.get(`/api/v1/rooms/${roomId}`);
44219
+ data = response.data;
44220
+ }
44221
+ catch (error) {
44222
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
44223
+ pushToTombstone('room', roomId);
44224
+ }
44225
+ throw error;
44226
+ }
44227
+ const cachedAt = client.cache && Date.now();
44228
+ if (client.cache) {
44229
+ ingestInCache(data, { cachedAt });
44230
+ }
44231
+ return {
44232
+ data: data.rooms[0],
44233
+ cachedAt,
44234
+ };
44235
+ };
44236
+ getRoomById.locally = (roomId) => {
44237
+ const client = getActiveClient();
44238
+ client.log('room/getRoomById.locally', roomId);
44239
+ // Check if room is in tombstone
44240
+ isInTombstone('room', roomId);
44241
+ const cachedAt = client.cache && Date.now();
44242
+ const roomCache = pullFromCache(['room', 'get', roomId]);
44243
+ if (!roomCache)
44244
+ return;
44245
+ return {
44246
+ data: roomCache.data,
44247
+ cachedAt,
44248
+ };
44249
+ };
44250
+
44251
+ const getRoom = (roomId, callback) => {
44252
+ // TODO: add callbackDataSelector if there are linked object fields
44253
+ return liveObject(roomId, callback, '_id', getRoomById, [
44254
+ onRoomEndBroadcasting,
44255
+ onRoomStartBroadcasting,
44256
+ onRoomWaitingReconnect,
44257
+ onRoomRecordedAvailable,
44258
+ ]);
44259
+ };
44260
+
44261
+ class RoomPaginationController extends PaginationController {
44262
+ async getRequest(queryParams, token) {
44263
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
44264
+ const baseOptions = {
44265
+ type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
44266
+ };
44267
+ const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
44268
+ const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
44269
+ params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
44270
+ });
44271
+ return queryResponse;
44272
+ }
44273
+ }
44274
+
44275
+ var EnumRoomActions;
44276
+ (function (EnumRoomActions) {
44277
+ EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
44278
+ EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
44279
+ EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
44280
+ EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
44281
+ EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
44282
+ EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
44283
+ EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
44284
+ })(EnumRoomActions || (EnumRoomActions = {}));
44285
+
44286
+ class RoomQueryStreamController extends QueryStreamController {
44287
+ constructor(query, cacheKey, notifyChange, preparePayload) {
44288
+ super(query, cacheKey);
44289
+ this.notifyChange = notifyChange;
44290
+ this.preparePayload = preparePayload;
44291
+ }
44292
+ async saveToMainDB(response) {
44293
+ const processedPayload = await this.preparePayload(response);
44294
+ const client = getActiveClient();
44295
+ const cachedAt = client.cache && Date.now();
44296
+ if (client.cache) {
44297
+ ingestInCache(processedPayload, { cachedAt });
44298
+ }
44299
+ }
44300
+ appendToQueryStream(response, direction, refresh = false) {
44301
+ var _a, _b;
44302
+ if (refresh) {
44303
+ pushToCache(this.cacheKey, {
44304
+ data: response.rooms.map(getResolver('room')),
44305
+ });
44306
+ }
44307
+ else {
44308
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44309
+ const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
44310
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
44311
+ }
44312
+ }
44313
+ reactor(action) {
44314
+ return (room) => {
44315
+ var _a;
44316
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44317
+ if (!collection)
44318
+ return;
44319
+ if (action === EnumRoomActions.OnRoomDeleted) {
44320
+ collection.data = collection.data.filter(roomId => roomId !== room._id);
44321
+ }
44322
+ if (action === EnumRoomActions.OnRoomCreated) {
44323
+ collection.data = [...new Set([room._id, ...collection.data])];
44324
+ }
44325
+ pushToCache(this.cacheKey, collection);
44326
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
44327
+ };
44328
+ }
44329
+ subscribeRTE(createSubscriber) {
44330
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
44331
+ }
44332
+ }
44333
+
44334
+ // TODO: confirm related events
44335
+ const getRoomSubscription = () => [
44336
+ {
44337
+ fn: onRoomStartBroadcasting,
44338
+ action: EnumRoomActions.OnRoomStartBroadcasting,
44339
+ },
44340
+ {
44341
+ fn: onRoomEndBroadcasting,
44342
+ action: EnumRoomActions.OnRoomEndBroadcasting,
44343
+ },
44344
+ {
44345
+ fn: onRoomRecordedAvailable,
44346
+ action: EnumRoomActions.OnRoomUpdated,
44347
+ },
44348
+ ];
44349
+
44350
+ class RoomLiveCollectionController extends LiveCollectionController {
44351
+ constructor(query, callback) {
44352
+ const queryStreamId = hash(query);
44353
+ const cacheKey = ['rooms', 'collection', queryStreamId];
44354
+ const paginationController = new RoomPaginationController(query);
44355
+ super(paginationController, queryStreamId, cacheKey, callback);
44356
+ this.query = query;
44357
+ this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
44358
+ this.callback = callback.bind(this);
44359
+ this.loadPage({ initial: true });
44360
+ }
44361
+ setup() {
44362
+ var _a;
44363
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44364
+ if (!collection) {
44365
+ pushToCache(this.cacheKey, {
44366
+ data: [],
44367
+ params: {},
44368
+ });
44369
+ }
44370
+ }
44371
+ async persistModel(queryPayload) {
44372
+ await this.queryStreamController.saveToMainDB(queryPayload);
44373
+ }
44374
+ persistQueryStream({ response, direction, refresh, }) {
44375
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
44376
+ }
44377
+ startSubscription() {
44378
+ return this.queryStreamController.subscribeRTE(getRoomSubscription());
44379
+ }
44380
+ notifyChange({ origin, loading, error }) {
44381
+ var _a, _b;
44382
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44383
+ if (!collection)
44384
+ return;
44385
+ const data = this.applyFilter((_b = collection.data
44386
+ .map(id => pullFromCache(['room', 'get', id]))
44387
+ .filter(isNonNullable)
44388
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
44389
+ if (!this.shouldNotify(data) && origin === 'event')
44390
+ return;
44391
+ this.callback({
44392
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
44393
+ data,
44394
+ hasNextPage: !!this.paginationController.getNextToken(),
44395
+ loading,
44396
+ error,
44397
+ });
44398
+ }
44399
+ applyFilter(data) {
44400
+ let rooms = data;
44401
+ if (!this.query.includeDeleted) {
44402
+ rooms = filterByPropEquality(rooms, 'isDeleted', false);
44403
+ }
44404
+ if (this.query.statuses && this.query.statuses.length > 0) {
44405
+ rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
44406
+ }
44407
+ if (this.query.type) {
44408
+ rooms = filterByPropEquality(rooms, 'type', this.query.type);
44409
+ }
44410
+ switch (this.query.sortBy) {
44411
+ case 'firstCreated':
44412
+ rooms = rooms.sort(sortByFirstCreated);
44413
+ break;
44414
+ case 'lastCreated':
44415
+ default:
44416
+ rooms = rooms.sort(sortByLastCreated);
44417
+ break;
44418
+ }
44419
+ return rooms;
44420
+ }
44421
+ }
44422
+
44423
+ /* begin_public_function
44424
+ id: room.get_rooms
44425
+ */
44426
+ /**
44427
+ * ```js
44428
+ * import { RoomRepository } from '@amityco/ts-sdk'
44429
+ *
44430
+ * let rooms = []
44431
+ * const unsub = RoomRepository.getRooms({
44432
+ * type: 'direct_streaming',
44433
+ * statuses: ['live', 'idle'],
44434
+ * sortBy: 'lastCreated',
44435
+ * limit: 20,
44436
+ * includeDeleted: false
44437
+ * }, response => merge(rooms, response.data))
44438
+ * ```
44439
+ *
44440
+ * Observe all mutations on a list of {@link Amity.Room} for a given query
44441
+ *
44442
+ * @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
44443
+ * @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
44444
+ * @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
44445
+ * @param params.limit maximum number of rooms to retrieve per page
44446
+ * @param params.includeDeleted whether to include deleted rooms in the results
44447
+ * @param callback the function to call when new data are available
44448
+ * @param config optional configuration for the live collection
44449
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
44450
+ *
44451
+ * @category Rooms Live Collection
44452
+ */
44453
+ const getRooms = (params, callback, config) => {
44454
+ const { log, cache } = getActiveClient();
44455
+ if (!cache) {
44456
+ console.log(ENABLE_CACHE_MESSAGE);
44457
+ }
44458
+ const timestamp = Date.now();
44459
+ log(`getRooms(tmpid: ${timestamp}) > listen`);
44460
+ const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
44461
+ const disposers = roomsLiveCollection.startSubscription();
44462
+ const cacheKey = roomsLiveCollection.getCacheKey();
44463
+ disposers.push(() => dropFromCache(cacheKey));
44464
+ return () => {
44465
+ log(`getRooms(tmpid: ${timestamp}) > dispose`);
44466
+ disposers.forEach(fn => fn());
44467
+ };
44468
+ };
44469
+ /* end_public_function */
44470
+
44471
+ var index$7 = /*#__PURE__*/Object.freeze({
44472
+ __proto__: null,
44473
+ createRoom: createRoom,
44474
+ updateRoom: updateRoom,
44475
+ deleteRoom: deleteRoom,
44476
+ stopRoom: stopRoom,
44477
+ getBroadcasterData: getBroadcasterData,
44478
+ getRecordedUrl: getRecordedUrl,
44479
+ onRoomStartBroadcasting: onRoomStartBroadcasting,
44480
+ onRoomWaitingReconnect: onRoomWaitingReconnect,
44481
+ onRoomEndBroadcasting: onRoomEndBroadcasting,
44482
+ onRoomRecordedAvailable: onRoomRecordedAvailable,
44483
+ onRoomParticipantInviting: onRoomParticipantInviting,
44484
+ onRoomParticipantJoined: onRoomParticipantJoined,
44485
+ onRoomParticipantLeft: onRoomParticipantLeft,
44486
+ onRoomCreated: onRoomCreated,
44487
+ onRoomUpdated: onRoomUpdated,
44488
+ onRoomDeleted: onRoomDeleted,
44489
+ onRoomStopped: onRoomStopped,
44490
+ getRoom: getRoom,
44491
+ getRooms: getRooms
44492
+ });
44493
+
43812
44494
  /* begin_public_function
43813
44495
  id: poll.create
43814
44496
  */
@@ -44109,7 +44791,7 @@ const getPoll = (pollId, callback) => {
44109
44791
  };
44110
44792
  /* end_public_function */
44111
44793
 
44112
- var index$7 = /*#__PURE__*/Object.freeze({
44794
+ var index$6 = /*#__PURE__*/Object.freeze({
44113
44795
  __proto__: null,
44114
44796
  createPoll: createPoll,
44115
44797
  closePoll: closePoll,
@@ -44492,7 +45174,7 @@ const getPlayer = async (parameters) => {
44492
45174
  return video;
44493
45175
  };
44494
45176
 
44495
- var index$6 = /*#__PURE__*/Object.freeze({
45177
+ var index$5 = /*#__PURE__*/Object.freeze({
44496
45178
  __proto__: null,
44497
45179
  getPlayer: getPlayer
44498
45180
  });
@@ -45665,7 +46347,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
45665
46347
  };
45666
46348
  };
45667
46349
 
45668
- var index$5 = /*#__PURE__*/Object.freeze({
46350
+ var index$4 = /*#__PURE__*/Object.freeze({
45669
46351
  __proto__: null,
45670
46352
  createImageStory: createImageStory,
45671
46353
  createVideoStory: createVideoStory,
@@ -45702,7 +46384,7 @@ const getNetworkAds = async () => {
45702
46384
  };
45703
46385
  };
45704
46386
 
45705
- var index$4 = /*#__PURE__*/Object.freeze({
46387
+ var index$3 = /*#__PURE__*/Object.freeze({
45706
46388
  __proto__: null,
45707
46389
  getNetworkAds: getNetworkAds
45708
46390
  });
@@ -46093,7 +46775,7 @@ const markTraySeen = async (lastSeenAt) => {
46093
46775
  };
46094
46776
  /* end_public_function */
46095
46777
 
46096
- var index$3 = /*#__PURE__*/Object.freeze({
46778
+ var index$2 = /*#__PURE__*/Object.freeze({
46097
46779
  __proto__: null,
46098
46780
  getNotificationTraySeen: getNotificationTraySeen,
46099
46781
  getNotificationTrayItems: getNotificationTrayItems,
@@ -46294,7 +46976,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
46294
46976
  };
46295
46977
  };
46296
46978
 
46297
- var index$2 = /*#__PURE__*/Object.freeze({
46979
+ var index$1 = /*#__PURE__*/Object.freeze({
46298
46980
  __proto__: null,
46299
46981
  onLocalInvitationCreated: onLocalInvitationCreated,
46300
46982
  onLocalInvitationUpdated: onLocalInvitationUpdated,
@@ -46435,559 +47117,11 @@ const getReactions = (postId, callback) => {
46435
47117
  };
46436
47118
  };
46437
47119
 
46438
- var index$1 = /*#__PURE__*/Object.freeze({
47120
+ var index = /*#__PURE__*/Object.freeze({
46439
47121
  __proto__: null,
46440
47122
  createReaction: createReaction,
46441
47123
  onLiveReactionCreated: onLiveReactionCreated,
46442
47124
  getReactions: getReactions
46443
47125
  });
46444
47126
 
46445
- const prepareEventPayload = (rawPayload) => {
46446
- return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
46447
- };
46448
-
46449
- const createEventEventSubscriber = (event, callback) => {
46450
- const client = getActiveClient();
46451
- const filter = (payload) => {
46452
- const unpackedPayload = prepareEventPayload(payload);
46453
- if (!client.cache) {
46454
- callback(unpackedPayload.events[0]);
46455
- }
46456
- else {
46457
- ingestInCache(unpackedPayload);
46458
- const event = pullFromCache([
46459
- 'event',
46460
- 'get',
46461
- unpackedPayload.events[0].eventId,
46462
- ]);
46463
- callback(event.data);
46464
- }
46465
- };
46466
- return createEventSubscriber(client, event, event, filter);
46467
- };
46468
-
46469
- /* begin_public_function
46470
- id: event.create
46471
- */
46472
- /**
46473
- * ```js
46474
- * import { EventRepository } from '@amityco/ts-sdk'
46475
- * const response = await EventRepository.createEvent(bundle)
46476
- * ```
46477
- *
46478
- * Creates an {@link Amity.Event}
46479
- *
46480
- * @param bundle The data necessary to create a new {@link Amity.Event}
46481
- * @returns The newly created {@link Amity.Event}
46482
- *
46483
- * @category Event API
46484
- * @async
46485
- */
46486
- const createEvent = async (bundle) => {
46487
- const client = getActiveClient();
46488
- client.log('event/createEvent', bundle);
46489
- const { data: payload } = await client.http.post('/api/v1/events', bundle);
46490
- fireEvent('event.created', payload);
46491
- const preparedPayload = prepareEventPayload(payload);
46492
- const cachedAt = client.cache && Date.now();
46493
- if (client.cache)
46494
- ingestInCache(preparedPayload, { cachedAt });
46495
- return {
46496
- data: eventLinkedObject(preparedPayload.events[0]),
46497
- cachedAt,
46498
- };
46499
- };
46500
- /* end_public_function */
46501
-
46502
- /* begin_public_function
46503
- id: event.update
46504
- */
46505
- /**
46506
- * ```js
46507
- * import { EventRepository } from '@amityco/ts-sdk'
46508
- * const response = await EventRepository.updateEvent(eventId, bundle)
46509
- * ```
46510
- *
46511
- * Updates an {@link Amity.Event}
46512
- *
46513
- * @param eventId The ID of the {@link Amity.Event} to edit
46514
- * @param bundle The data necessary to update an existing {@link Amity.Event}
46515
- * @returns the updated {@link Amity.Event}
46516
- *
46517
- * @category Event API
46518
- * @async
46519
- */
46520
- const updateEvent = async (eventId, bundle) => {
46521
- const client = getActiveClient();
46522
- client.log('event/updateEvent', eventId, bundle);
46523
- const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
46524
- fireEvent('event.updated', payload);
46525
- const preparedPayload = prepareEventPayload(payload);
46526
- const cachedAt = client.cache && Date.now();
46527
- if (client.cache)
46528
- ingestInCache(preparedPayload, { cachedAt });
46529
- return {
46530
- data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
46531
- cachedAt,
46532
- };
46533
- };
46534
- /* end_public_function */
46535
-
46536
- /* begin_public_function
46537
- id: event.get
46538
- */
46539
- /**
46540
- * ```js
46541
- * import { EventRepository } from '@amityco/ts-sdk'
46542
- * const event = await EventRepository.getEvent(eventId)
46543
- * ```
46544
- *
46545
- * Fetches a {@link Amity.Event} object
46546
- *
46547
- * @param eventId the ID of the {@link Amity.Event} to fetch
46548
- * @returns the associated {@link Amity.Event} object
46549
- *
46550
- * @category Event API
46551
- * @async
46552
- */
46553
- const getEvent$1 = async (eventId) => {
46554
- const client = getActiveClient();
46555
- client.log('event/getEvent', eventId);
46556
- const { data: payload } = await client.http.get(`/api/v3/events/${eventId}`);
46557
- const data = prepareEventPayload(payload);
46558
- const cachedAt = client.cache && Date.now();
46559
- if (client.cache)
46560
- ingestInCache(data, { cachedAt });
46561
- return {
46562
- data: data.events.find(event => event.eventId === eventId),
46563
- cachedAt,
46564
- };
46565
- };
46566
- /* end_public_function */
46567
- /**
46568
- * ```js
46569
- * import { EventRepository } from '@amityco/ts-sdk'
46570
- * const event = EventRepository.getEvent.locally(eventId)
46571
- * ```
46572
- *
46573
- * Fetches a {@link Amity.Event} object in cache
46574
- *
46575
- * @param eventId the ID of the {@link Amity.Event} to fetch
46576
- * @returns the associated {@link Amity.Event} object
46577
- *
46578
- * @category Event API
46579
- */
46580
- getEvent$1.locally = (eventId) => {
46581
- const client = getActiveClient();
46582
- client.log('event/getEvent.locally', eventId);
46583
- if (!client.cache)
46584
- return;
46585
- const cache = pullFromCache(['event', 'get', eventId]);
46586
- if (!cache)
46587
- return;
46588
- return {
46589
- data: cache.data,
46590
- cachedAt: cache.cachedAt,
46591
- };
46592
- };
46593
-
46594
- /* begin_public_function
46595
- id: event.delete
46596
- */
46597
- /**
46598
- * ```js
46599
- * import { EventRepository } from '@amityco/ts-sdk'
46600
- * const { success } = await EventRepository.deleteEvent(eventId)
46601
- * ```
46602
- *
46603
- * Deletes a {@link Amity.Event}
46604
- *
46605
- * @param eventId The {@link Amity.Event} ID to delete
46606
- *
46607
- * @category Event API
46608
- * @async
46609
- */
46610
- const deleteEvent = async (eventId) => {
46611
- const client = getActiveClient();
46612
- client.log('event/deleteEvent', eventId);
46613
- const event = await getEvent$1(eventId);
46614
- await client.http.delete(`/api/v3/events/${eventId}`);
46615
- const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
46616
- upsertInCache(['event', 'get', eventId], deletedEvent);
46617
- fireEvent('event.deleted', {
46618
- users: [],
46619
- files: [],
46620
- communities: [],
46621
- videoStreamings: [],
46622
- events: [deletedEvent],
46623
- discussionCommunities: [],
46624
- });
46625
- };
46626
- /* end_public_function */
46627
-
46628
- /**
46629
- * ```js
46630
- * import { EventRepository } from '@amityco/ts-sdk'
46631
- * const dispose = EventRepository.onEventCreated(event => {
46632
- * // ...
46633
- * })
46634
- * ```
46635
- *
46636
- * Fired when a {@link Amity.Event} has been created
46637
- *
46638
- * @param callback The function to call when the event was fired
46639
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46640
- *
46641
- * @category Event Events
46642
- */
46643
- const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
46644
-
46645
- /**
46646
- * ```js
46647
- * import { EventRepository } from '@amityco/ts-sdk'
46648
- * const dispose = EventRepository.onEventUpdated(event => {
46649
- * // ...
46650
- * })
46651
- * ```
46652
- *
46653
- * Fired when a {@link Amity.Event} has been updated
46654
- *
46655
- * @param callback The function to call when the event was fired
46656
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46657
- *
46658
- * @category Event Events
46659
- */
46660
- const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
46661
-
46662
- /**
46663
- * ```js
46664
- * import { EventRepository } from '@amityco/ts-sdk'
46665
- * const dispose = EventRepository.onEventDeleted(event => {
46666
- * // ...
46667
- * })
46668
- * ```
46669
- *
46670
- * Fired when a {@link Amity.Event} has been deleted
46671
- *
46672
- * @param callback The function to call when the event was fired
46673
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46674
- *
46675
- * @category Event Events
46676
- */
46677
- const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
46678
-
46679
- /* begin_public_function
46680
- id: event.get
46681
- */
46682
- /**
46683
- * ```js
46684
- * import { EventRepository } from '@amityco/ts-sdk';
46685
- *
46686
- * let event;
46687
- *
46688
- * const unsubscribe = EventRepository.getEvent(eventId, response => {
46689
- * event = response.data;
46690
- * });
46691
- * ```
46692
- *
46693
- * Observe all mutation on a given {@link Amity.Event}
46694
- *
46695
- * @param eventId the ID of the event to observe
46696
- * @param callback the function to call when new snapshot of event are available
46697
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
46698
- *
46699
- * @category Event Live Object
46700
- */
46701
- const getEvent = (eventId, callback) => {
46702
- return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventCreated, onEventUpdated, onEventDeleted], {
46703
- callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
46704
- });
46705
- };
46706
- /* end_public_function */
46707
-
46708
- var EventActionsEnum;
46709
- (function (EventActionsEnum) {
46710
- EventActionsEnum["OnEventCreated"] = "onEventCreated";
46711
- EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
46712
- EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
46713
- })(EventActionsEnum || (EventActionsEnum = {}));
46714
-
46715
- class EventPaginationController extends PaginationController {
46716
- async getRequest(queryParams, token) {
46717
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
46718
- const options = token ? { token } : { limit };
46719
- const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
46720
- return response;
46721
- }
46722
- }
46723
-
46724
- class EventQueryStreamController extends QueryStreamController {
46725
- constructor(query, cacheKey, notifyChange, preparePayload) {
46726
- super(query, cacheKey);
46727
- this.notifyChange = notifyChange;
46728
- this.preparePayload = preparePayload;
46729
- }
46730
- async saveToMainDB(response) {
46731
- const processedPayload = this.preparePayload(response);
46732
- const client = getActiveClient();
46733
- const cachedAt = client.cache && Date.now();
46734
- if (client.cache)
46735
- ingestInCache(processedPayload, { cachedAt });
46736
- }
46737
- appendToQueryStream(response, direction, refresh = false) {
46738
- var _a, _b;
46739
- if (refresh) {
46740
- pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
46741
- }
46742
- else {
46743
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46744
- const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
46745
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
46746
- }
46747
- }
46748
- reactor(action) {
46749
- return (event) => {
46750
- var _a;
46751
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46752
- if (!collection)
46753
- return;
46754
- if (action === EventActionsEnum.OnEventCreated) {
46755
- collection.data = [...new Set([event.eventId, ...collection.data])];
46756
- }
46757
- if (action === EventActionsEnum.OnEventDeleted) {
46758
- collection.data = collection.data.filter(eventId => eventId !== event.eventId);
46759
- }
46760
- pushToCache(this.cacheKey, collection);
46761
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
46762
- };
46763
- }
46764
- subscribeRTE(createSubscriber) {
46765
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
46766
- }
46767
- }
46768
-
46769
- class EventLiveCollectionController extends LiveCollectionController {
46770
- constructor(query, callback) {
46771
- const queryStreamId = hash(query);
46772
- const cacheKey = ['event', 'collection', queryStreamId];
46773
- const paginationController = new EventPaginationController(query);
46774
- super(paginationController, queryStreamId, cacheKey, callback);
46775
- this.query = query;
46776
- this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
46777
- this.callback = callback.bind(this);
46778
- this.loadPage({ initial: true });
46779
- }
46780
- setup() {
46781
- var _a;
46782
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46783
- if (!collection)
46784
- pushToCache(this.cacheKey, { data: [], params: {} });
46785
- }
46786
- async persistModel(queryPayload) {
46787
- await this.queryStreamController.saveToMainDB(queryPayload);
46788
- }
46789
- persistQueryStream({ response, direction, refresh, }) {
46790
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
46791
- }
46792
- startSubscription() {
46793
- return this.queryStreamController.subscribeRTE([
46794
- { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
46795
- { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
46796
- { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
46797
- ]);
46798
- }
46799
- notifyChange({ origin, loading, error }) {
46800
- var _a, _b;
46801
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46802
- if (!collection)
46803
- return;
46804
- const data = ((_b = collection.data
46805
- .map(eventId => pullFromCache(['event', 'get', eventId]))
46806
- .filter(isNonNullable)
46807
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
46808
- if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
46809
- return;
46810
- this.callback({
46811
- data,
46812
- error,
46813
- loading,
46814
- hasNextPage: !!this.paginationController.getNextToken(),
46815
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
46816
- });
46817
- }
46818
- }
46819
-
46820
- /**
46821
- * Get events
46822
- *
46823
- * @param params the query parameters
46824
- * @param callback the callback to be called when the events are updated
46825
- * @returns events
46826
- *
46827
- * @category Event Live Collection
46828
- *
46829
- */
46830
- const getEvents = (params, callback, config) => {
46831
- const { log, cache } = getActiveClient();
46832
- if (!cache)
46833
- console.log(ENABLE_CACHE_MESSAGE);
46834
- const timestamp = Date.now();
46835
- log(`getEvents: (tmpid: ${timestamp}) > listen`);
46836
- const eventLiveCollection = new EventLiveCollectionController(params, callback);
46837
- const disposers = eventLiveCollection.startSubscription();
46838
- const cacheKey = eventLiveCollection.getCacheKey();
46839
- disposers.push(() => dropFromCache(cacheKey));
46840
- return () => {
46841
- log(`getEvents (tmpid: ${timestamp}) > dispose`);
46842
- disposers.forEach(fn => fn());
46843
- };
46844
- };
46845
-
46846
- class MyEventPaginationController extends PaginationController {
46847
- async getRequest(queryParams, token) {
46848
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
46849
- const options = token ? { token } : { limit };
46850
- const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
46851
- return response;
46852
- }
46853
- }
46854
-
46855
- class MyEventQueryStreamController extends QueryStreamController {
46856
- constructor(query, cacheKey, notifyChange, preparePayload) {
46857
- super(query, cacheKey);
46858
- this.notifyChange = notifyChange;
46859
- this.preparePayload = preparePayload;
46860
- }
46861
- async saveToMainDB(response) {
46862
- const processedPayload = this.preparePayload(response);
46863
- const client = getActiveClient();
46864
- const cachedAt = client.cache && Date.now();
46865
- if (client.cache)
46866
- ingestInCache(processedPayload, { cachedAt });
46867
- }
46868
- appendToQueryStream(response, direction, refresh = false) {
46869
- var _a, _b;
46870
- if (refresh) {
46871
- pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
46872
- }
46873
- else {
46874
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46875
- const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
46876
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
46877
- }
46878
- }
46879
- reactor(action) {
46880
- return (event) => {
46881
- var _a;
46882
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46883
- if (!collection)
46884
- return;
46885
- if (action === EventActionsEnum.OnEventCreated) {
46886
- const client = getActiveClient();
46887
- if (client.userId !== event.userId)
46888
- return;
46889
- collection.data = [...new Set([event.eventId, ...collection.data])];
46890
- }
46891
- if (action === EventActionsEnum.OnEventDeleted) {
46892
- collection.data = collection.data.filter(eventId => eventId !== event.eventId);
46893
- }
46894
- pushToCache(this.cacheKey, collection);
46895
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
46896
- };
46897
- }
46898
- subscribeRTE(createSubscriber) {
46899
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
46900
- }
46901
- }
46902
-
46903
- class MyEventLiveCollectionController extends LiveCollectionController {
46904
- constructor(query, callback) {
46905
- const queryStreamId = hash(query);
46906
- const cacheKey = ['event', 'collection', queryStreamId];
46907
- const paginationController = new MyEventPaginationController(query);
46908
- super(paginationController, queryStreamId, cacheKey, callback);
46909
- this.query = query;
46910
- this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
46911
- this.callback = callback.bind(this);
46912
- this.loadPage({ initial: true });
46913
- }
46914
- setup() {
46915
- var _a;
46916
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46917
- if (!collection)
46918
- pushToCache(this.cacheKey, { data: [], params: {} });
46919
- }
46920
- async persistModel(queryPayload) {
46921
- await this.queryStreamController.saveToMainDB(queryPayload);
46922
- }
46923
- persistQueryStream({ response, direction, refresh, }) {
46924
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
46925
- }
46926
- startSubscription() {
46927
- return this.queryStreamController.subscribeRTE([
46928
- { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
46929
- { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
46930
- { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
46931
- ]);
46932
- }
46933
- notifyChange({ origin, loading, error }) {
46934
- var _a, _b;
46935
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46936
- if (!collection)
46937
- return;
46938
- const data = ((_b = collection.data
46939
- .map(eventId => pullFromCache(['event', 'get', eventId]))
46940
- .filter(isNonNullable)
46941
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
46942
- if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
46943
- return;
46944
- this.callback({
46945
- data,
46946
- error,
46947
- loading,
46948
- hasNextPage: !!this.paginationController.getNextToken(),
46949
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
46950
- });
46951
- }
46952
- }
46953
-
46954
- /**
46955
- * Get my events
46956
- *
46957
- * @param params the query parameters
46958
- * @param callback the callback to be called when the events are updated
46959
- * @returns events
46960
- *
46961
- * @category Event Live Collection
46962
- *
46963
- */
46964
- const getMyEvents = (params, callback, config) => {
46965
- const { log, cache } = getActiveClient();
46966
- if (!cache)
46967
- console.log(ENABLE_CACHE_MESSAGE);
46968
- const timestamp = Date.now();
46969
- log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
46970
- const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
46971
- const disposers = myEventLiveCollection.startSubscription();
46972
- const cacheKey = myEventLiveCollection.getCacheKey();
46973
- disposers.push(() => dropFromCache(cacheKey));
46974
- return () => {
46975
- log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
46976
- disposers.forEach(fn => fn());
46977
- };
46978
- };
46979
-
46980
- var index = /*#__PURE__*/Object.freeze({
46981
- __proto__: null,
46982
- createEvent: createEvent,
46983
- updateEvent: updateEvent,
46984
- deleteEvent: deleteEvent,
46985
- onEventCreated: onEventCreated,
46986
- onEventUpdated: onEventUpdated,
46987
- onEventDeleted: onEventDeleted,
46988
- getEvent: getEvent,
46989
- getEvents: getEvents,
46990
- getMyEvents: getMyEvents
46991
- });
46992
-
46993
- 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 };
47127
+ 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 };