@amityco/ts-sdk 7.11.1-4788cb4b.0 → 7.11.1-4c3f6231.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 (176) 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/permissions.d.ts +1 -5
  8. package/dist/@types/core/permissions.d.ts.map +1 -1
  9. package/dist/@types/core/transport.d.ts +0 -3
  10. package/dist/@types/core/transport.d.ts.map +1 -1
  11. package/dist/@types/domains/channel.d.ts +1 -0
  12. package/dist/@types/domains/channel.d.ts.map +1 -1
  13. package/dist/@types/domains/community.d.ts +1 -8
  14. package/dist/@types/domains/community.d.ts.map +1 -1
  15. package/dist/@types/domains/content.d.ts +4 -1
  16. package/dist/@types/domains/content.d.ts.map +1 -1
  17. package/dist/@types/domains/feed.d.ts +2 -1
  18. package/dist/@types/domains/feed.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 +2 -0
  22. package/dist/@types/domains/post.d.ts.map +1 -1
  23. package/dist/@types/domains/room.d.ts +77 -0
  24. package/dist/@types/domains/room.d.ts.map +1 -0
  25. package/dist/@types/index.d.ts +2 -1
  26. package/dist/@types/index.d.ts.map +1 -1
  27. package/dist/channelRepository/api/createChannel.d.ts +1 -0
  28. package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
  29. package/dist/core/events.d.ts +3 -3
  30. package/dist/core/events.d.ts.map +1 -1
  31. package/dist/core/model/index.d.ts.map +1 -1
  32. package/dist/core/subscription.d.ts +2 -0
  33. package/dist/core/subscription.d.ts.map +1 -1
  34. package/dist/index.cjs.js +2822 -2663
  35. package/dist/index.d.ts +1 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.esm.js +889 -732
  38. package/dist/index.umd.js +3 -3
  39. package/dist/liveReactionRepository/api/createReaction.d.ts +2 -2
  40. package/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -1
  41. package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts +2 -2
  42. package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts.map +1 -1
  43. package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts +1 -1
  44. package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts.map +1 -1
  45. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +2 -1
  46. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
  47. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  48. package/dist/roomRepository/api/createRoom.d.ts +24 -0
  49. package/dist/roomRepository/api/createRoom.d.ts.map +1 -0
  50. package/dist/roomRepository/api/deleteRoom.d.ts +16 -0
  51. package/dist/roomRepository/api/deleteRoom.d.ts.map +1 -0
  52. package/dist/roomRepository/api/getBroadcasterData.d.ts +16 -0
  53. package/dist/roomRepository/api/getBroadcasterData.d.ts.map +1 -0
  54. package/dist/roomRepository/api/getRecordedUrl.d.ts +19 -0
  55. package/dist/roomRepository/api/getRecordedUrl.d.ts.map +1 -0
  56. package/dist/roomRepository/api/index.d.ts +7 -0
  57. package/dist/roomRepository/api/index.d.ts.map +1 -0
  58. package/dist/roomRepository/api/stopRoom.d.ts +16 -0
  59. package/dist/roomRepository/api/stopRoom.d.ts.map +1 -0
  60. package/dist/roomRepository/api/updateRoom.d.ts +24 -0
  61. package/dist/roomRepository/api/updateRoom.d.ts.map +1 -0
  62. package/dist/roomRepository/events/index.d.ts +12 -0
  63. package/dist/roomRepository/events/index.d.ts.map +1 -0
  64. package/dist/roomRepository/events/onRoomCreated.d.ts +17 -0
  65. package/dist/roomRepository/events/onRoomCreated.d.ts.map +1 -0
  66. package/dist/roomRepository/events/onRoomDeleted.d.ts +17 -0
  67. package/dist/roomRepository/events/onRoomDeleted.d.ts.map +1 -0
  68. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +17 -0
  69. package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +1 -0
  70. package/dist/roomRepository/events/onRoomParticipantInviting.d.ts +17 -0
  71. package/dist/roomRepository/events/onRoomParticipantInviting.d.ts.map +1 -0
  72. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +17 -0
  73. package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +1 -0
  74. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +17 -0
  75. package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +1 -0
  76. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +17 -0
  77. package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +1 -0
  78. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +17 -0
  79. package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +1 -0
  80. package/dist/roomRepository/events/onRoomStopped.d.ts +17 -0
  81. package/dist/roomRepository/events/onRoomStopped.d.ts.map +1 -0
  82. package/dist/roomRepository/events/onRoomUpdated.d.ts +17 -0
  83. package/dist/roomRepository/events/onRoomUpdated.d.ts.map +1 -0
  84. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +17 -0
  85. package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +1 -0
  86. package/dist/roomRepository/index.d.ts.map +1 -0
  87. package/dist/roomRepository/internalApi/getLiveChat.d.ts +16 -0
  88. package/dist/roomRepository/internalApi/getLiveChat.d.ts.map +1 -0
  89. package/dist/roomRepository/internalApi/getRoomById.d.ts +5 -0
  90. package/dist/roomRepository/internalApi/getRoomById.d.ts.map +1 -0
  91. package/dist/roomRepository/internalApi/index.d.ts +3 -0
  92. package/dist/roomRepository/internalApi/index.d.ts.map +1 -0
  93. package/dist/roomRepository/observers/enums.d.ts +10 -0
  94. package/dist/roomRepository/observers/enums.d.ts.map +1 -0
  95. package/dist/roomRepository/observers/getRoom.d.ts +2 -0
  96. package/dist/roomRepository/observers/getRoom.d.ts.map +1 -0
  97. package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts +14 -0
  98. package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts.map +1 -0
  99. package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts +5 -0
  100. package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts.map +1 -0
  101. package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts +15 -0
  102. package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts.map +1 -0
  103. package/dist/roomRepository/observers/getRooms.d.ts +29 -0
  104. package/dist/roomRepository/observers/getRooms.d.ts.map +1 -0
  105. package/dist/roomRepository/observers/index.d.ts +3 -0
  106. package/dist/roomRepository/observers/index.d.ts.map +1 -0
  107. package/dist/roomRepository/observers/utils.d.ts +6 -0
  108. package/dist/roomRepository/observers/utils.d.ts.map +1 -0
  109. package/dist/utils/linkedObject/index.d.ts +1 -1
  110. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  111. package/dist/utils/linkedObject/roomLinkedObject.d.ts +2 -0
  112. package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +1 -0
  113. package/dist/utils/postTypePredicate.d.ts +1 -0
  114. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  115. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  116. package/package.json +1 -1
  117. package/dist/@types/domains/event.d.ts +0 -81
  118. package/dist/@types/domains/event.d.ts.map +0 -1
  119. package/dist/eventRepository/api/createEvent.d.ts +0 -16
  120. package/dist/eventRepository/api/createEvent.d.ts.map +0 -1
  121. package/dist/eventRepository/api/deleteEvent.d.ts +0 -15
  122. package/dist/eventRepository/api/deleteEvent.d.ts.map +0 -1
  123. package/dist/eventRepository/api/index.d.ts +0 -4
  124. package/dist/eventRepository/api/index.d.ts.map +0 -1
  125. package/dist/eventRepository/api/updateEvent.d.ts +0 -17
  126. package/dist/eventRepository/api/updateEvent.d.ts.map +0 -1
  127. package/dist/eventRepository/events/enums.d.ts +0 -6
  128. package/dist/eventRepository/events/enums.d.ts.map +0 -1
  129. package/dist/eventRepository/events/index.d.ts +0 -7
  130. package/dist/eventRepository/events/index.d.ts.map +0 -1
  131. package/dist/eventRepository/events/onEventCreated.d.ts +0 -17
  132. package/dist/eventRepository/events/onEventCreated.d.ts.map +0 -1
  133. package/dist/eventRepository/events/onEventDeleted.d.ts +0 -17
  134. package/dist/eventRepository/events/onEventDeleted.d.ts.map +0 -1
  135. package/dist/eventRepository/events/onEventUpdated.d.ts +0 -17
  136. package/dist/eventRepository/events/onEventUpdated.d.ts.map +0 -1
  137. package/dist/eventRepository/events/onLocalEventCreated.d.ts +0 -17
  138. package/dist/eventRepository/events/onLocalEventCreated.d.ts.map +0 -1
  139. package/dist/eventRepository/events/onLocalEventDeleted.d.ts +0 -17
  140. package/dist/eventRepository/events/onLocalEventDeleted.d.ts.map +0 -1
  141. package/dist/eventRepository/events/onLocalEventUpdated.d.ts +0 -17
  142. package/dist/eventRepository/events/onLocalEventUpdated.d.ts.map +0 -1
  143. package/dist/eventRepository/index.d.ts.map +0 -1
  144. package/dist/eventRepository/internalApi/getEvent.d.ts +0 -32
  145. package/dist/eventRepository/internalApi/getEvent.d.ts.map +0 -1
  146. package/dist/eventRepository/internalApi/index.d.ts +0 -2
  147. package/dist/eventRepository/internalApi/index.d.ts.map +0 -1
  148. package/dist/eventRepository/observers/getEvent.d.ts +0 -21
  149. package/dist/eventRepository/observers/getEvent.d.ts.map +0 -1
  150. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts +0 -13
  151. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +0 -1
  152. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts +0 -5
  153. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts.map +0 -1
  154. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts +0 -15
  155. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts.map +0 -1
  156. package/dist/eventRepository/observers/getEvents.d.ts +0 -12
  157. package/dist/eventRepository/observers/getEvents.d.ts.map +0 -1
  158. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts +0 -13
  159. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +0 -1
  160. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +0 -5
  161. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +0 -1
  162. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +0 -15
  163. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +0 -1
  164. package/dist/eventRepository/observers/getMyEvents.d.ts +0 -12
  165. package/dist/eventRepository/observers/getMyEvents.d.ts.map +0 -1
  166. package/dist/eventRepository/observers/index.d.ts +0 -4
  167. package/dist/eventRepository/observers/index.d.ts.map +0 -1
  168. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +0 -2
  169. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +0 -1
  170. package/dist/eventRepository/utils/index.d.ts +0 -3
  171. package/dist/eventRepository/utils/index.d.ts.map +0 -1
  172. package/dist/eventRepository/utils/prepareEventPayload.d.ts +0 -2
  173. package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +0 -1
  174. package/dist/utils/linkedObject/eventLinkObject.d.ts +0 -2
  175. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +0 -1
  176. /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) => {
@@ -1506,6 +1483,37 @@ async function modifyMqttConnection() {
1506
1483
  }
1507
1484
  }
1508
1485
 
1486
+ const userLinkedObject = (user) => {
1487
+ return Object.assign(Object.assign({}, user), { get avatar() {
1488
+ var _a;
1489
+ if (!user.avatarFileId)
1490
+ return undefined;
1491
+ const avatar = (_a = pullFromCache([
1492
+ 'file',
1493
+ 'get',
1494
+ `${user.avatarFileId}`,
1495
+ ])) === null || _a === void 0 ? void 0 : _a.data;
1496
+ return avatar;
1497
+ } });
1498
+ };
1499
+
1500
+ /* begin_public_function
1501
+ id: client.get_current_user
1502
+ */
1503
+ const getCurrentUser = () => {
1504
+ var _a;
1505
+ const client = getActiveClient();
1506
+ if (!client) {
1507
+ throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
1508
+ }
1509
+ const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
1510
+ if (!cache) {
1511
+ throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
1512
+ }
1513
+ return userLinkedObject(cache);
1514
+ };
1515
+ /* end_public_function */
1516
+
1509
1517
  var SubscriptionLevels;
1510
1518
  (function (SubscriptionLevels) {
1511
1519
  SubscriptionLevels["COMMUNITY"] = "community";
@@ -1611,6 +1619,14 @@ const getLiveStreamTopic = () => {
1611
1619
  const getLiveReactionTopic = (post) => {
1612
1620
  return `${post.path}/liveReaction`;
1613
1621
  };
1622
+ const getRoomWatcherTopic = (room) => {
1623
+ const user = getCurrentUser();
1624
+ return `${getNetworkId(user)}/room/${room._id}`;
1625
+ };
1626
+ const getRoomStreamerTopic = (room) => {
1627
+ const user = getCurrentUser();
1628
+ return `${getNetworkId(user)}/room/${room.roomId}/streamer`;
1629
+ };
1614
1630
  function subscribeTopic(topic, callback) {
1615
1631
  const { mqtt } = getActiveClient();
1616
1632
  if (!mqtt)
@@ -21037,20 +21053,6 @@ const getChannelMessagePreview = (channelId) => {
21037
21053
  return ((_b = (_a = pullFromCache(['messagePreviewChannel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : null);
21038
21054
  };
21039
21055
 
21040
- const userLinkedObject = (user) => {
21041
- return Object.assign(Object.assign({}, user), { get avatar() {
21042
- var _a;
21043
- if (!user.avatarFileId)
21044
- return undefined;
21045
- const avatar = (_a = pullFromCache([
21046
- 'file',
21047
- 'get',
21048
- `${user.avatarFileId}`,
21049
- ])) === null || _a === void 0 ? void 0 : _a.data;
21050
- return avatar;
21051
- } });
21052
- };
21053
-
21054
21056
  const getChannelMessagePreviewWithUser = (channel) => {
21055
21057
  var _a;
21056
21058
  const messagePreview = channel.messagePreviewId
@@ -24566,11 +24568,11 @@ var objectResolverEngineOnLoginHandler = () => {
24566
24568
  * @category Live Reaction API
24567
24569
  * @async
24568
24570
  */
24569
- const createLiveReaction = async ({ reactions, liveStreamId, }) => {
24571
+ const createLiveReaction = async ({ reactions, roomId, }) => {
24570
24572
  const client = getActiveClient();
24571
24573
  client.log('live_reaction/addReaction', reactions);
24572
24574
  const { data } = await client.http.post(`/api/v1/reactions/live`, {
24573
- liveStreamId,
24575
+ roomId,
24574
24576
  reactions,
24575
24577
  });
24576
24578
  return data;
@@ -24628,19 +24630,19 @@ class LiveReactionSyncEngine {
24628
24630
  // Clear buffer
24629
24631
  this.clearBuffer();
24630
24632
  const payloads = reactions.reduce((prev, curr) => {
24631
- const { streamId } = curr, rest = __rest(curr, ["streamId"]);
24632
- if (!prev[streamId]) {
24633
+ const { roomId } = curr, rest = __rest(curr, ["roomId"]);
24634
+ if (!prev[roomId]) {
24633
24635
  // eslint-disable-next-line no-param-reassign
24634
- prev[streamId] = [rest];
24636
+ prev[roomId] = [rest];
24635
24637
  }
24636
24638
  else
24637
- prev[streamId].push(rest);
24639
+ prev[roomId].push(rest);
24638
24640
  return prev;
24639
24641
  }, {});
24640
24642
  // Call server api `POST /api/v1/reactions/live` to sync live reactions
24641
- Object.entries(payloads).forEach(([streamId, reactions]) => {
24643
+ Object.entries(payloads).forEach(([roomId, reactions]) => {
24642
24644
  createLiveReaction({
24643
- liveStreamId: streamId,
24645
+ roomId,
24644
24646
  reactions,
24645
24647
  });
24646
24648
  });
@@ -25133,23 +25135,6 @@ const loginAsVisitor = async (params) => {
25133
25135
  };
25134
25136
  /* end_public_function */
25135
25137
 
25136
- /* begin_public_function
25137
- id: client.get_current_user
25138
- */
25139
- const getCurrentUser = () => {
25140
- var _a;
25141
- const client = getActiveClient();
25142
- if (!client) {
25143
- throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
25144
- }
25145
- const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
25146
- if (!cache) {
25147
- throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
25148
- }
25149
- return userLinkedObject(cache);
25150
- };
25151
- /* end_public_function */
25152
-
25153
25138
  /* begin_public_function
25154
25139
  id: client.renew_access_token
25155
25140
  */
@@ -28151,7 +28136,7 @@ getChannel$1.locally = (channelId) => {
28151
28136
  * @category Stream API
28152
28137
  * @async
28153
28138
  */
28154
- const getLiveChat = async (stream) => {
28139
+ const getLiveChat$1 = async (stream) => {
28155
28140
  var _a;
28156
28141
  const client = getActiveClient();
28157
28142
  client.log('stream/getLiveChat', stream.streamId);
@@ -28218,7 +28203,7 @@ const streamLinkedObject = (stream) => {
28218
28203
  return streamLinkedObject(streamCache);
28219
28204
  })
28220
28205
  .filter(isNonNullable);
28221
- }, getLiveChat: () => getLiveChat(stream), isBanned: !stream.watcherUrl, watcherUrl: null, get [GET_WATCHER_URLS]() {
28206
+ }, getLiveChat: () => getLiveChat$1(stream), isBanned: !stream.watcherUrl, watcherUrl: null, get [GET_WATCHER_URLS]() {
28222
28207
  return stream.watcherUrl;
28223
28208
  } });
28224
28209
  };
@@ -28326,6 +28311,95 @@ function isAmityAudioPost(post) {
28326
28311
  'fileId' in post.data &&
28327
28312
  post.dataType === 'audio');
28328
28313
  }
28314
+ function isAmityRoomPost(post) {
28315
+ return !!(post.data &&
28316
+ typeof post.data !== 'string' &&
28317
+ 'roomId' in post.data &&
28318
+ post.dataType === 'room');
28319
+ }
28320
+
28321
+ /**
28322
+ * ```js
28323
+ * import { RoomRepository } from '@amityco/ts-sdk'
28324
+ * const stream = await getStream('foobar')
28325
+ * ```
28326
+ *
28327
+ * Fetches a {@link Amity.Channel} object linked with a current stream
28328
+ *
28329
+ * @param stream {@link Amity.Stream} that has linked live channel
28330
+ * @returns the associated {@link Amity.Channel<'live'>} object
28331
+ *
28332
+ * @category Stream API
28333
+ * @async
28334
+ */
28335
+ const getLiveChat = async (room) => {
28336
+ var _a;
28337
+ const client = getActiveClient();
28338
+ client.log('room/getLiveChat', room.roomId);
28339
+ if (room.liveChannelId) {
28340
+ const channel = (_a = pullFromCache([
28341
+ 'channel',
28342
+ 'get',
28343
+ room.liveChannelId,
28344
+ ])) === null || _a === void 0 ? void 0 : _a.data;
28345
+ if (channel)
28346
+ return channelLinkedObject(constructChannelObject(channel));
28347
+ const { data } = await getChannel$1(room.liveChannelId);
28348
+ return channelLinkedObject(constructChannelObject(data));
28349
+ }
28350
+ // No Channel ID
28351
+ // streamer: create a new live channel
28352
+ if (room.createdBy === client.userId) {
28353
+ const { data: channel } = await createChannel({
28354
+ type: 'live',
28355
+ postId: room.referenceId,
28356
+ roomId: room.roomId,
28357
+ });
28358
+ // Update channelId to stream object in cache
28359
+ mergeInCache(['room', 'get', room.roomId], {
28360
+ liveChannelId: channel.channelId,
28361
+ });
28362
+ return channel;
28363
+ }
28364
+ // watcher: return undefined
28365
+ return undefined;
28366
+ };
28367
+
28368
+ const roomLinkedObject = (room) => {
28369
+ return Object.assign(Object.assign({}, room), { get moderation() {
28370
+ var _a;
28371
+ return (_a = pullFromCache(['roomModeration', 'get', room.roomId])) === null || _a === void 0 ? void 0 : _a.data;
28372
+ },
28373
+ get post() {
28374
+ var _a;
28375
+ if (room.referenceType !== 'post')
28376
+ return;
28377
+ return (_a = pullFromCache(['post', 'get', room.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
28378
+ },
28379
+ get community() {
28380
+ var _a;
28381
+ if (room.targetType !== 'community')
28382
+ return;
28383
+ return (_a = pullFromCache(['community', 'get', room.targetId])) === null || _a === void 0 ? void 0 : _a.data;
28384
+ },
28385
+ get user() {
28386
+ var _a;
28387
+ return (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
28388
+ },
28389
+ get childRooms() {
28390
+ if (!room.childRoomIds || room.childRoomIds.length === 0)
28391
+ return [];
28392
+ return room.childRoomIds
28393
+ .map(id => {
28394
+ var _a;
28395
+ const roomCache = (_a = pullFromCache(['room', 'get', id])) === null || _a === void 0 ? void 0 : _a.data;
28396
+ if (!roomCache)
28397
+ return undefined;
28398
+ return roomLinkedObject(roomCache);
28399
+ })
28400
+ .filter(isNonNullable);
28401
+ }, getLiveChat: () => getLiveChat(room) });
28402
+ };
28329
28403
 
28330
28404
  const postLinkedObject = (post) => {
28331
28405
  return shallowClone(post, {
@@ -28420,6 +28494,13 @@ const postLinkedObject = (post) => {
28420
28494
  ? (_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
28495
  : undefined;
28422
28496
  },
28497
+ getRoomInfo() {
28498
+ var _a, _b;
28499
+ if (!isAmityRoomPost(post))
28500
+ return;
28501
+ const room = (_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;
28502
+ return room ? roomLinkedObject(room) : undefined;
28503
+ },
28423
28504
  });
28424
28505
  };
28425
28506
 
@@ -29777,51 +29858,6 @@ const communityLinkedObject = (community) => {
29777
29858
  } });
29778
29859
  };
29779
29860
 
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 targetCommunity() {
29800
- if (!event.originId)
29801
- return;
29802
- const cacheData = pullFromCache(['community', 'get', event.originId]);
29803
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29804
- return;
29805
- return communityLinkedObject(cacheData.data);
29806
- },
29807
- get coverImage() {
29808
- if (!event.coverImageFileId)
29809
- return;
29810
- const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
29811
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29812
- return;
29813
- return cacheData.data;
29814
- },
29815
- get liveStream() {
29816
- if (!event.livestreamId)
29817
- return;
29818
- const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
29819
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29820
- return;
29821
- return cacheData.data;
29822
- } });
29823
- };
29824
-
29825
29861
  const LinkedObject = {
29826
29862
  ad: adLinkedObject,
29827
29863
  comment: commentLinkedObject,
@@ -29840,7 +29876,7 @@ const LinkedObject = {
29840
29876
  invitation: invitationLinkedObject,
29841
29877
  joinRequest: joinRequestLinkedObject,
29842
29878
  channelMember: channelMemberLinkedObject,
29843
- event: eventLinkedObject,
29879
+ room: roomLinkedObject,
29844
29880
  };
29845
29881
 
29846
29882
  /* begin_public_function
@@ -43825,6 +43861,735 @@ var index$8 = /*#__PURE__*/Object.freeze({
43825
43861
  getStreams: getStreams
43826
43862
  });
43827
43863
 
43864
+ /* begin_public_function
43865
+ id: room.create
43866
+ */
43867
+ /**
43868
+ * ```js
43869
+ * import { createRoom } from '@amityco/ts-sdk'
43870
+ * const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
43871
+ * ```
43872
+ *
43873
+ * Creates an {@link Amity.Room}
43874
+ *
43875
+ * @param bundle The data necessary to create a new {@link Amity.Room}
43876
+ * @returns The newly created {@link Amity.Room}
43877
+ *
43878
+ * @category Room API
43879
+ * @async
43880
+ */
43881
+ const createRoom = async (bundle) => {
43882
+ const client = getActiveClient();
43883
+ client.log('room/createRoom', bundle);
43884
+ const { data } = await client.http.post('/api/v1/rooms', bundle);
43885
+ fireEvent('local.room.created', data);
43886
+ const cachedAt = client.cache && Date.now();
43887
+ // TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
43888
+ if (client.cache)
43889
+ ingestInCache(data, { cachedAt });
43890
+ const { rooms } = data;
43891
+ return {
43892
+ data: roomLinkedObject(rooms[0]),
43893
+ cachedAt,
43894
+ };
43895
+ };
43896
+ /* end_public_function */
43897
+
43898
+ /* begin_public_function
43899
+ id: room.update
43900
+ */
43901
+ /**
43902
+ * ```js
43903
+ * import { updateRoom } from '@amityco/ts-sdk'
43904
+ * const updated = await updateRoom('roomId', { title: 'updated title' })
43905
+ * ```
43906
+ *
43907
+ * Updates an {@link Amity.InternalRoom}
43908
+ *
43909
+ * @param roomId The ID of the room to update
43910
+ * @param bundle The data to update the room with
43911
+ * @returns The updated {@link Amity.InternalRoom}
43912
+ *
43913
+ * @category Room API
43914
+ * @async
43915
+ */
43916
+ const updateRoom = async (roomId, bundle) => {
43917
+ const client = getActiveClient();
43918
+ client.log('room/updateRoom', { roomId, bundle });
43919
+ const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
43920
+ fireEvent('local.room.updated', data);
43921
+ const cachedAt = client.cache && Date.now();
43922
+ if (client.cache)
43923
+ ingestInCache(data, { cachedAt });
43924
+ const { rooms } = data;
43925
+ return {
43926
+ data: roomLinkedObject(rooms[0]),
43927
+ cachedAt,
43928
+ };
43929
+ };
43930
+ /* end_public_function */
43931
+
43932
+ /* begin_public_function
43933
+ id: room.delete
43934
+ */
43935
+ /**
43936
+ * ```js
43937
+ * import { deleteRoom } from '@amityco/ts-sdk'
43938
+ * const result = await deleteRoom('roomId')
43939
+ * ```
43940
+ *
43941
+ * Deletes an {@link Amity.Room}
43942
+ *
43943
+ * @param roomId The ID of the room to delete
43944
+ * @returns Promise that resolves when the room is deleted
43945
+ *
43946
+ * @category Room API
43947
+ * @async
43948
+ */
43949
+ const deleteRoom = async (roomId) => {
43950
+ const client = getActiveClient();
43951
+ client.log('room/deleteRoom', { roomId });
43952
+ await client.http.delete(`/api/v1/rooms/${roomId}`);
43953
+ fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
43954
+ };
43955
+ /* end_public_function */
43956
+
43957
+ /* begin_public_function
43958
+ id: room.stop
43959
+ */
43960
+ /**
43961
+ * ```js
43962
+ * import { stopRoom } from '@amityco/ts-sdk'
43963
+ * const result = await stopRoom('roomId')
43964
+ * ```
43965
+ *
43966
+ * Stops a room's broadcasting
43967
+ *
43968
+ * @param roomId The ID of the room to stop
43969
+ * @returns The updated room data
43970
+ *
43971
+ * @category Room API
43972
+ * @async
43973
+ */
43974
+ const stopRoom = async (roomId) => {
43975
+ const client = getActiveClient();
43976
+ client.log('room/stopRoom', { roomId });
43977
+ const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
43978
+ fireEvent('local.room.stopped', data);
43979
+ const cachedAt = client.cache && Date.now();
43980
+ if (client.cache)
43981
+ ingestInCache(data, { cachedAt });
43982
+ const { rooms } = data;
43983
+ return {
43984
+ data: rooms[0],
43985
+ cachedAt,
43986
+ };
43987
+ };
43988
+ /* end_public_function */
43989
+
43990
+ /* begin_public_function
43991
+ id: room.getBroadcasterData
43992
+ */
43993
+ /**
43994
+ * ```js
43995
+ * import { getBroadcasterData } from '@amityco/ts-sdk'
43996
+ * const token = await getBroadcasterData('roomId')
43997
+ * ```
43998
+ *
43999
+ * Gets broadcaster data for a room
44000
+ *
44001
+ * @param roomId The ID of the room to get token for
44002
+ * @returns The broadcaster data of the room including coHostToken, coHostUrl and direactStreamUrl
44003
+ *
44004
+ * @category Room API
44005
+ * @async
44006
+ */
44007
+ const getBroadcasterData = async (roomId) => {
44008
+ const client = getActiveClient();
44009
+ client.log('room/getBroadcasterData', { roomId });
44010
+ const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
44011
+ return data;
44012
+ };
44013
+ /* end_public_function */
44014
+
44015
+ /* begin_public_function
44016
+ id: room.getRecordedUrl
44017
+ */
44018
+ /**
44019
+ * ```js
44020
+ * import { getRecordedUrl } from '@amityco/ts-sdk'
44021
+ * const recordedUrl = await getRecordedUrl('roomId')
44022
+ * ```
44023
+ *
44024
+ * Gets the recorded URL for a room
44025
+ *
44026
+ * @param roomId The ID of the room to get recorded URL for
44027
+ * @returns The recorded URL information
44028
+ *
44029
+ * @category Room API
44030
+ * @async
44031
+ */
44032
+ const getRecordedUrl = async (roomId) => {
44033
+ const client = getActiveClient();
44034
+ client.log('room/getRecordedUrl', { roomId });
44035
+ const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
44036
+ return data;
44037
+ };
44038
+ /* end_public_function */
44039
+
44040
+ /**
44041
+ * ```js
44042
+ * import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
44043
+ * const dispose = onRoomStartBroadcasting(room => {
44044
+ * // ...
44045
+ * })
44046
+ * ```
44047
+ *
44048
+ * Fired when a {@link Amity.Room} has started broadcasting
44049
+ *
44050
+ * @param callback The function to call when the event was fired
44051
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44052
+ *
44053
+ * @category Room Events
44054
+ */
44055
+ const onRoomStartBroadcasting = (callback) => {
44056
+ const client = getActiveClient();
44057
+ const filter = (payload) => {
44058
+ ingestInCache(payload);
44059
+ callback(payload.rooms[0]);
44060
+ };
44061
+ return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
44062
+ };
44063
+
44064
+ /**
44065
+ * ```js
44066
+ * import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
44067
+ * const dispose = onRoomWaitingReconnect(room => {
44068
+ * // ...
44069
+ * })
44070
+ * ```
44071
+ *
44072
+ * Fired when a {@link Amity.Room} is waiting for reconnection
44073
+ *
44074
+ * @param callback The function to call when the event was fired
44075
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44076
+ *
44077
+ * @category Room Events
44078
+ */
44079
+ const onRoomWaitingReconnect = (callback) => {
44080
+ const client = getActiveClient();
44081
+ const filter = (payload) => {
44082
+ ingestInCache(payload);
44083
+ callback(payload.rooms[0]);
44084
+ };
44085
+ return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
44086
+ };
44087
+
44088
+ /**
44089
+ * ```js
44090
+ * import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
44091
+ * const dispose = onRoomEndBroadcasting(room => {
44092
+ * // ...
44093
+ * })
44094
+ * ```
44095
+ *
44096
+ * Fired when a {@link Amity.Room} has ended broadcasting
44097
+ *
44098
+ * @param callback The function to call when the event was fired
44099
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44100
+ *
44101
+ * @category Room Events
44102
+ */
44103
+ const onRoomEndBroadcasting = (callback) => {
44104
+ const client = getActiveClient();
44105
+ const filter = (payload) => {
44106
+ ingestInCache(payload);
44107
+ callback(payload.rooms[0]);
44108
+ };
44109
+ return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
44110
+ };
44111
+
44112
+ /**
44113
+ * ```js
44114
+ * import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
44115
+ * const dispose = onRoomRecordedAvailable(room => {
44116
+ * // ...
44117
+ * })
44118
+ * ```
44119
+ *
44120
+ * Fired when a {@link Amity.Room} recorded content becomes available
44121
+ *
44122
+ * @param callback The function to call when the event was fired
44123
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44124
+ *
44125
+ * @category Room Events
44126
+ */
44127
+ const onRoomRecordedAvailable = (callback) => {
44128
+ const client = getActiveClient();
44129
+ const filter = (payload) => {
44130
+ ingestInCache(payload);
44131
+ callback(payload.rooms[0]);
44132
+ };
44133
+ return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
44134
+ };
44135
+
44136
+ /**
44137
+ * ```js
44138
+ * import { onRoomParticipantInviting } from '@amityco/ts-sdk'
44139
+ * const dispose = onRoomParticipantInviting(room => {
44140
+ * // ...
44141
+ * })
44142
+ * ```
44143
+ *
44144
+ * Fired when a participant is being invited to a {@link Amity.Room}
44145
+ *
44146
+ * @param callback The function to call when the event was fired
44147
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44148
+ *
44149
+ * @category Room Events
44150
+ */
44151
+ const onRoomParticipantInviting = (callback) => {
44152
+ const client = getActiveClient();
44153
+ const filter = (payload) => {
44154
+ ingestInCache(payload);
44155
+ callback(payload.rooms[0]);
44156
+ };
44157
+ return createEventSubscriber(client, 'room/onRoomParticipantInviting', 'room.participantInviting', filter);
44158
+ };
44159
+
44160
+ /**
44161
+ * ```js
44162
+ * import { onRoomParticipantJoined } from '@amityco/ts-sdk'
44163
+ * const dispose = onRoomParticipantJoined(room => {
44164
+ * // ...
44165
+ * })
44166
+ * ```
44167
+ *
44168
+ * Fired when a participant has joined a {@link Amity.Room}
44169
+ *
44170
+ * @param callback The function to call when the event was fired
44171
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44172
+ *
44173
+ * @category Room Events
44174
+ */
44175
+ const onRoomParticipantJoined = (callback) => {
44176
+ const client = getActiveClient();
44177
+ const filter = (payload) => {
44178
+ ingestInCache(payload);
44179
+ callback(payload.rooms[0]);
44180
+ };
44181
+ return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
44182
+ };
44183
+
44184
+ /**
44185
+ * ```js
44186
+ * import { onRoomParticipantLeft } from '@amityco/ts-sdk'
44187
+ * const dispose = onRoomParticipantLeft(room => {
44188
+ * // ...
44189
+ * })
44190
+ * ```
44191
+ *
44192
+ * Fired when a participant has left a {@link Amity.Room}
44193
+ *
44194
+ * @param callback The function to call when the event was fired
44195
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44196
+ *
44197
+ * @category Room Events
44198
+ */
44199
+ const onRoomParticipantLeft = (callback) => {
44200
+ const client = getActiveClient();
44201
+ const filter = (payload) => {
44202
+ ingestInCache(payload);
44203
+ callback(payload.rooms[0]);
44204
+ };
44205
+ return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
44206
+ };
44207
+
44208
+ /**
44209
+ * ```js
44210
+ * import { onRoomCreated } from '@amityco/ts-sdk'
44211
+ * const dispose = onRoomCreated(room => {
44212
+ * // ...
44213
+ * })
44214
+ * ```
44215
+ *
44216
+ * Fired when a {@link Amity.Room} has been created locally
44217
+ *
44218
+ * @param callback The function to call when the event was fired
44219
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44220
+ *
44221
+ * @category Room Events
44222
+ */
44223
+ const onRoomCreated = (callback) => {
44224
+ const client = getActiveClient();
44225
+ const filter = (payload) => {
44226
+ ingestInCache(payload);
44227
+ callback(payload.rooms[0]);
44228
+ };
44229
+ return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
44230
+ };
44231
+
44232
+ /**
44233
+ * ```js
44234
+ * import { onRoomUpdated } from '@amityco/ts-sdk'
44235
+ * const dispose = onRoomUpdated(room => {
44236
+ * // ...
44237
+ * })
44238
+ * ```
44239
+ *
44240
+ * Fired when a {@link Amity.Room} has been updated locally
44241
+ *
44242
+ * @param callback The function to call when the event was fired
44243
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44244
+ *
44245
+ * @category Room Events
44246
+ */
44247
+ const onRoomUpdated = (callback) => {
44248
+ const client = getActiveClient();
44249
+ const filter = (payload) => {
44250
+ ingestInCache(payload);
44251
+ callback(payload.rooms[0]);
44252
+ };
44253
+ return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
44254
+ };
44255
+
44256
+ /**
44257
+ * ```js
44258
+ * import { onRoomDeleted } from '@amityco/ts-sdk'
44259
+ * const dispose = onRoomDeleted(room => {
44260
+ * // ...
44261
+ * })
44262
+ * ```
44263
+ *
44264
+ * Fired when a {@link Amity.Room} has been deleted locally
44265
+ *
44266
+ * @param callback The function to call when the event was fired
44267
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44268
+ *
44269
+ * @category Room Events
44270
+ */
44271
+ const onRoomDeleted = (callback) => {
44272
+ const client = getActiveClient();
44273
+ const filter = (payload) => {
44274
+ ingestInCache(payload);
44275
+ callback(payload.rooms[0]);
44276
+ };
44277
+ return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
44278
+ };
44279
+
44280
+ /**
44281
+ * ```js
44282
+ * import { onRoomStopped } from '@amityco/ts-sdk'
44283
+ * const dispose = onRoomStopped(room => {
44284
+ * // ...
44285
+ * })
44286
+ * ```
44287
+ *
44288
+ * Fired when a {@link Amity.Room} has been stopped locally
44289
+ *
44290
+ * @param callback The function to call when the event was fired
44291
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44292
+ *
44293
+ * @category Room Events
44294
+ */
44295
+ const onRoomStopped = (callback) => {
44296
+ const client = getActiveClient();
44297
+ const filter = (payload) => {
44298
+ ingestInCache(payload);
44299
+ callback(payload.rooms[0]);
44300
+ };
44301
+ return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
44302
+ };
44303
+
44304
+ const getRoomById = async (roomId) => {
44305
+ const client = getActiveClient();
44306
+ client.log('room/getRoomById', roomId);
44307
+ // Check if room is in tombstone
44308
+ isInTombstone('room', roomId);
44309
+ let data;
44310
+ try {
44311
+ const response = await client.http.get(`/api/v1/rooms/${roomId}`);
44312
+ data = response.data;
44313
+ }
44314
+ catch (error) {
44315
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
44316
+ pushToTombstone('room', roomId);
44317
+ }
44318
+ throw error;
44319
+ }
44320
+ const cachedAt = client.cache && Date.now();
44321
+ if (client.cache) {
44322
+ ingestInCache(data, { cachedAt });
44323
+ }
44324
+ return {
44325
+ data: data.rooms[0],
44326
+ cachedAt,
44327
+ };
44328
+ };
44329
+ getRoomById.locally = (roomId) => {
44330
+ const client = getActiveClient();
44331
+ client.log('room/getRoomById.locally', roomId);
44332
+ // Check if room is in tombstone
44333
+ isInTombstone('room', roomId);
44334
+ const cachedAt = client.cache && Date.now();
44335
+ const roomCache = pullFromCache(['room', 'get', roomId]);
44336
+ if (!roomCache)
44337
+ return;
44338
+ return {
44339
+ data: roomCache.data,
44340
+ cachedAt,
44341
+ };
44342
+ };
44343
+
44344
+ const getRoom = (roomId, callback) => {
44345
+ // TODO: add callbackDataSelector if there are linked object fields
44346
+ return liveObject(roomId, callback, '_id', getRoomById, [
44347
+ onRoomEndBroadcasting,
44348
+ onRoomStartBroadcasting,
44349
+ onRoomWaitingReconnect,
44350
+ onRoomRecordedAvailable,
44351
+ ], {
44352
+ callbackDataSelector: (data) => {
44353
+ if (!data)
44354
+ return data;
44355
+ return LinkedObject.room(data);
44356
+ },
44357
+ });
44358
+ };
44359
+
44360
+ class RoomPaginationController extends PaginationController {
44361
+ async getRequest(queryParams, token) {
44362
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
44363
+ const baseOptions = {
44364
+ type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
44365
+ };
44366
+ const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
44367
+ const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
44368
+ params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
44369
+ });
44370
+ return queryResponse;
44371
+ }
44372
+ }
44373
+
44374
+ var EnumRoomActions;
44375
+ (function (EnumRoomActions) {
44376
+ EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
44377
+ EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
44378
+ EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
44379
+ EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
44380
+ EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
44381
+ EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
44382
+ EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
44383
+ })(EnumRoomActions || (EnumRoomActions = {}));
44384
+
44385
+ class RoomQueryStreamController extends QueryStreamController {
44386
+ constructor(query, cacheKey, notifyChange, preparePayload) {
44387
+ super(query, cacheKey);
44388
+ this.notifyChange = notifyChange;
44389
+ this.preparePayload = preparePayload;
44390
+ }
44391
+ async saveToMainDB(response) {
44392
+ const processedPayload = await this.preparePayload(response);
44393
+ const client = getActiveClient();
44394
+ const cachedAt = client.cache && Date.now();
44395
+ if (client.cache) {
44396
+ ingestInCache(processedPayload, { cachedAt });
44397
+ }
44398
+ }
44399
+ appendToQueryStream(response, direction, refresh = false) {
44400
+ var _a, _b;
44401
+ if (refresh) {
44402
+ pushToCache(this.cacheKey, {
44403
+ data: response.rooms.map(getResolver('room')),
44404
+ });
44405
+ }
44406
+ else {
44407
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44408
+ const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
44409
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
44410
+ }
44411
+ }
44412
+ reactor(action) {
44413
+ return (room) => {
44414
+ var _a;
44415
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44416
+ if (!collection)
44417
+ return;
44418
+ if (action === EnumRoomActions.OnRoomDeleted) {
44419
+ collection.data = collection.data.filter(roomId => roomId !== room._id);
44420
+ }
44421
+ if (action === EnumRoomActions.OnRoomCreated) {
44422
+ collection.data = [...new Set([room._id, ...collection.data])];
44423
+ }
44424
+ pushToCache(this.cacheKey, collection);
44425
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
44426
+ };
44427
+ }
44428
+ subscribeRTE(createSubscriber) {
44429
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
44430
+ }
44431
+ }
44432
+
44433
+ // TODO: confirm related events
44434
+ const getRoomSubscription = () => [
44435
+ {
44436
+ fn: onRoomStartBroadcasting,
44437
+ action: EnumRoomActions.OnRoomStartBroadcasting,
44438
+ },
44439
+ {
44440
+ fn: onRoomEndBroadcasting,
44441
+ action: EnumRoomActions.OnRoomEndBroadcasting,
44442
+ },
44443
+ {
44444
+ fn: onRoomRecordedAvailable,
44445
+ action: EnumRoomActions.OnRoomUpdated,
44446
+ },
44447
+ ];
44448
+
44449
+ class RoomLiveCollectionController extends LiveCollectionController {
44450
+ constructor(query, callback) {
44451
+ const queryStreamId = hash(query);
44452
+ const cacheKey = ['rooms', 'collection', queryStreamId];
44453
+ const paginationController = new RoomPaginationController(query);
44454
+ super(paginationController, queryStreamId, cacheKey, callback);
44455
+ this.query = query;
44456
+ this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
44457
+ this.callback = callback.bind(this);
44458
+ this.loadPage({ initial: true });
44459
+ }
44460
+ setup() {
44461
+ var _a;
44462
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44463
+ if (!collection) {
44464
+ pushToCache(this.cacheKey, {
44465
+ data: [],
44466
+ params: {},
44467
+ });
44468
+ }
44469
+ }
44470
+ async persistModel(queryPayload) {
44471
+ await this.queryStreamController.saveToMainDB(queryPayload);
44472
+ }
44473
+ persistQueryStream({ response, direction, refresh, }) {
44474
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
44475
+ }
44476
+ startSubscription() {
44477
+ return this.queryStreamController.subscribeRTE(getRoomSubscription());
44478
+ }
44479
+ notifyChange({ origin, loading, error }) {
44480
+ var _a, _b;
44481
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44482
+ if (!collection)
44483
+ return;
44484
+ const data = this.applyFilter((_b = collection.data
44485
+ .map(id => pullFromCache(['room', 'get', id]))
44486
+ .filter(isNonNullable)
44487
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
44488
+ if (!this.shouldNotify(data) && origin === 'event')
44489
+ return;
44490
+ this.callback({
44491
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
44492
+ data,
44493
+ hasNextPage: !!this.paginationController.getNextToken(),
44494
+ loading,
44495
+ error,
44496
+ });
44497
+ }
44498
+ applyFilter(data) {
44499
+ let rooms = data;
44500
+ if (!this.query.includeDeleted) {
44501
+ rooms = filterByPropEquality(rooms, 'isDeleted', false);
44502
+ }
44503
+ if (this.query.statuses && this.query.statuses.length > 0) {
44504
+ rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
44505
+ }
44506
+ if (this.query.type) {
44507
+ rooms = filterByPropEquality(rooms, 'type', this.query.type);
44508
+ }
44509
+ switch (this.query.sortBy) {
44510
+ case 'firstCreated':
44511
+ rooms = rooms.sort(sortByFirstCreated);
44512
+ break;
44513
+ case 'lastCreated':
44514
+ default:
44515
+ rooms = rooms.sort(sortByLastCreated);
44516
+ break;
44517
+ }
44518
+ return rooms;
44519
+ }
44520
+ }
44521
+
44522
+ /* begin_public_function
44523
+ id: room.get_rooms
44524
+ */
44525
+ /**
44526
+ * ```js
44527
+ * import { RoomRepository } from '@amityco/ts-sdk'
44528
+ *
44529
+ * let rooms = []
44530
+ * const unsub = RoomRepository.getRooms({
44531
+ * type: 'direct_streaming',
44532
+ * statuses: ['live', 'idle'],
44533
+ * sortBy: 'lastCreated',
44534
+ * limit: 20,
44535
+ * includeDeleted: false
44536
+ * }, response => merge(rooms, response.data))
44537
+ * ```
44538
+ *
44539
+ * Observe all mutations on a list of {@link Amity.Room} for a given query
44540
+ *
44541
+ * @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
44542
+ * @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
44543
+ * @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
44544
+ * @param params.limit maximum number of rooms to retrieve per page
44545
+ * @param params.includeDeleted whether to include deleted rooms in the results
44546
+ * @param callback the function to call when new data are available
44547
+ * @param config optional configuration for the live collection
44548
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
44549
+ *
44550
+ * @category Rooms Live Collection
44551
+ */
44552
+ const getRooms = (params, callback, config) => {
44553
+ const { log, cache } = getActiveClient();
44554
+ if (!cache) {
44555
+ console.log(ENABLE_CACHE_MESSAGE);
44556
+ }
44557
+ const timestamp = Date.now();
44558
+ log(`getRooms(tmpid: ${timestamp}) > listen`);
44559
+ const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
44560
+ const disposers = roomsLiveCollection.startSubscription();
44561
+ const cacheKey = roomsLiveCollection.getCacheKey();
44562
+ disposers.push(() => dropFromCache(cacheKey));
44563
+ return () => {
44564
+ log(`getRooms(tmpid: ${timestamp}) > dispose`);
44565
+ disposers.forEach(fn => fn());
44566
+ };
44567
+ };
44568
+ /* end_public_function */
44569
+
44570
+ var index$7 = /*#__PURE__*/Object.freeze({
44571
+ __proto__: null,
44572
+ createRoom: createRoom,
44573
+ updateRoom: updateRoom,
44574
+ deleteRoom: deleteRoom,
44575
+ stopRoom: stopRoom,
44576
+ getBroadcasterData: getBroadcasterData,
44577
+ getRecordedUrl: getRecordedUrl,
44578
+ onRoomStartBroadcasting: onRoomStartBroadcasting,
44579
+ onRoomWaitingReconnect: onRoomWaitingReconnect,
44580
+ onRoomEndBroadcasting: onRoomEndBroadcasting,
44581
+ onRoomRecordedAvailable: onRoomRecordedAvailable,
44582
+ onRoomParticipantInviting: onRoomParticipantInviting,
44583
+ onRoomParticipantJoined: onRoomParticipantJoined,
44584
+ onRoomParticipantLeft: onRoomParticipantLeft,
44585
+ onRoomCreated: onRoomCreated,
44586
+ onRoomUpdated: onRoomUpdated,
44587
+ onRoomDeleted: onRoomDeleted,
44588
+ onRoomStopped: onRoomStopped,
44589
+ getRoom: getRoom,
44590
+ getRooms: getRooms
44591
+ });
44592
+
43828
44593
  /* begin_public_function
43829
44594
  id: poll.create
43830
44595
  */
@@ -44125,7 +44890,7 @@ const getPoll = (pollId, callback) => {
44125
44890
  };
44126
44891
  /* end_public_function */
44127
44892
 
44128
- var index$7 = /*#__PURE__*/Object.freeze({
44893
+ var index$6 = /*#__PURE__*/Object.freeze({
44129
44894
  __proto__: null,
44130
44895
  createPoll: createPoll,
44131
44896
  closePoll: closePoll,
@@ -44508,7 +45273,7 @@ const getPlayer = async (parameters) => {
44508
45273
  return video;
44509
45274
  };
44510
45275
 
44511
- var index$6 = /*#__PURE__*/Object.freeze({
45276
+ var index$5 = /*#__PURE__*/Object.freeze({
44512
45277
  __proto__: null,
44513
45278
  getPlayer: getPlayer
44514
45279
  });
@@ -45681,7 +46446,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
45681
46446
  };
45682
46447
  };
45683
46448
 
45684
- var index$5 = /*#__PURE__*/Object.freeze({
46449
+ var index$4 = /*#__PURE__*/Object.freeze({
45685
46450
  __proto__: null,
45686
46451
  createImageStory: createImageStory,
45687
46452
  createVideoStory: createVideoStory,
@@ -45718,7 +46483,7 @@ const getNetworkAds = async () => {
45718
46483
  };
45719
46484
  };
45720
46485
 
45721
- var index$4 = /*#__PURE__*/Object.freeze({
46486
+ var index$3 = /*#__PURE__*/Object.freeze({
45722
46487
  __proto__: null,
45723
46488
  getNetworkAds: getNetworkAds
45724
46489
  });
@@ -46109,7 +46874,7 @@ const markTraySeen = async (lastSeenAt) => {
46109
46874
  };
46110
46875
  /* end_public_function */
46111
46876
 
46112
- var index$3 = /*#__PURE__*/Object.freeze({
46877
+ var index$2 = /*#__PURE__*/Object.freeze({
46113
46878
  __proto__: null,
46114
46879
  getNotificationTraySeen: getNotificationTraySeen,
46115
46880
  getNotificationTrayItems: getNotificationTrayItems,
@@ -46310,7 +47075,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
46310
47075
  };
46311
47076
  };
46312
47077
 
46313
- var index$2 = /*#__PURE__*/Object.freeze({
47078
+ var index$1 = /*#__PURE__*/Object.freeze({
46314
47079
  __proto__: null,
46315
47080
  onLocalInvitationCreated: onLocalInvitationCreated,
46316
47081
  onLocalInvitationUpdated: onLocalInvitationUpdated,
@@ -46343,7 +47108,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
46343
47108
  * @category Live Reaction API
46344
47109
  * @async
46345
47110
  */
46346
- const createReaction = async ({ referenceId, referenceType, reactionName, streamId, }) => {
47111
+ const createReaction = async ({ referenceId, referenceType, reactionName, roomId, }) => {
46347
47112
  const client = getActiveClient();
46348
47113
  client.log('live_reaction/createReaction', {
46349
47114
  referenceId,
@@ -46355,7 +47120,7 @@ const createReaction = async ({ referenceId, referenceType, reactionName, stream
46355
47120
  reactionName,
46356
47121
  referencePublicId: referenceId,
46357
47122
  referenceType,
46358
- streamId,
47123
+ roomId,
46359
47124
  occurredAt: new Date().toISOString(),
46360
47125
  };
46361
47126
  reactionSynceEngine.createLiveReaction(reaction);
@@ -46451,619 +47216,11 @@ const getReactions = (postId, callback) => {
46451
47216
  };
46452
47217
  };
46453
47218
 
46454
- var index$1 = /*#__PURE__*/Object.freeze({
47219
+ var index = /*#__PURE__*/Object.freeze({
46455
47220
  __proto__: null,
46456
47221
  createReaction: createReaction,
46457
47222
  onLiveReactionCreated: onLiveReactionCreated,
46458
47223
  getReactions: getReactions
46459
47224
  });
46460
47225
 
46461
- const prepareEventPayload = (rawPayload) => {
46462
- return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
46463
- };
46464
-
46465
- const createEventEventSubscriber = (event, callback) => {
46466
- const client = getActiveClient();
46467
- const filter = (payload) => {
46468
- const unpackedPayload = prepareEventPayload(payload);
46469
- if (!client.cache) {
46470
- callback(unpackedPayload.events[0]);
46471
- }
46472
- else {
46473
- ingestInCache(unpackedPayload);
46474
- const event = pullFromCache([
46475
- 'event',
46476
- 'get',
46477
- unpackedPayload.events[0].eventId,
46478
- ]);
46479
- callback(event.data);
46480
- }
46481
- };
46482
- return createEventSubscriber(client, event, event, filter);
46483
- };
46484
-
46485
- /* begin_public_function
46486
- id: event.create
46487
- */
46488
- /**
46489
- * ```js
46490
- * import { EventRepository } from '@amityco/ts-sdk'
46491
- * const response = await EventRepository.createEvent(bundle)
46492
- * ```
46493
- *
46494
- * Creates an {@link Amity.Event}
46495
- *
46496
- * @param bundle The data necessary to create a new {@link Amity.Event}
46497
- * @returns The newly created {@link Amity.Event}
46498
- *
46499
- * @category Event API
46500
- * @async
46501
- */
46502
- const createEvent = async (bundle) => {
46503
- const client = getActiveClient();
46504
- client.log('event/createEvent', bundle);
46505
- const { data: payload } = await client.http.post('/api/v1/events', bundle);
46506
- fireEvent('local.event.created', payload);
46507
- const preparedPayload = prepareEventPayload(payload);
46508
- const cachedAt = client.cache && Date.now();
46509
- if (client.cache)
46510
- ingestInCache(preparedPayload, { cachedAt });
46511
- return {
46512
- data: eventLinkedObject(preparedPayload.events[0]),
46513
- cachedAt,
46514
- };
46515
- };
46516
- /* end_public_function */
46517
-
46518
- /* begin_public_function
46519
- id: event.update
46520
- */
46521
- /**
46522
- * ```js
46523
- * import { EventRepository } from '@amityco/ts-sdk'
46524
- * const response = await EventRepository.updateEvent(eventId, bundle)
46525
- * ```
46526
- *
46527
- * Updates an {@link Amity.Event}
46528
- *
46529
- * @param eventId The ID of the {@link Amity.Event} to edit
46530
- * @param bundle The data necessary to update an existing {@link Amity.Event}
46531
- * @returns the updated {@link Amity.Event}
46532
- *
46533
- * @category Event API
46534
- * @async
46535
- */
46536
- const updateEvent = async (eventId, bundle) => {
46537
- const client = getActiveClient();
46538
- client.log('event/updateEvent', eventId, bundle);
46539
- const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
46540
- fireEvent('local.event.updated', payload);
46541
- const preparedPayload = prepareEventPayload(payload);
46542
- const cachedAt = client.cache && Date.now();
46543
- if (client.cache)
46544
- ingestInCache(preparedPayload, { cachedAt });
46545
- return {
46546
- data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
46547
- cachedAt,
46548
- };
46549
- };
46550
- /* end_public_function */
46551
-
46552
- /* begin_public_function
46553
- id: event.get
46554
- */
46555
- /**
46556
- * ```js
46557
- * import { EventRepository } from '@amityco/ts-sdk'
46558
- * const event = await EventRepository.getEvent(eventId)
46559
- * ```
46560
- *
46561
- * Fetches a {@link Amity.Event} object
46562
- *
46563
- * @param eventId the ID of the {@link Amity.Event} to fetch
46564
- * @returns the associated {@link Amity.Event} object
46565
- *
46566
- * @category Event API
46567
- * @async
46568
- */
46569
- const getEvent$1 = async (eventId) => {
46570
- const client = getActiveClient();
46571
- client.log('event/getEvent', eventId);
46572
- const { data: payload } = await client.http.get(`/api/v3/events/${eventId}`);
46573
- const data = prepareEventPayload(payload);
46574
- const cachedAt = client.cache && Date.now();
46575
- if (client.cache)
46576
- ingestInCache(data, { cachedAt });
46577
- return {
46578
- data: data.events.find(event => event.eventId === eventId),
46579
- cachedAt,
46580
- };
46581
- };
46582
- /* end_public_function */
46583
- /**
46584
- * ```js
46585
- * import { EventRepository } from '@amityco/ts-sdk'
46586
- * const event = EventRepository.getEvent.locally(eventId)
46587
- * ```
46588
- *
46589
- * Fetches a {@link Amity.Event} object in cache
46590
- *
46591
- * @param eventId the ID of the {@link Amity.Event} to fetch
46592
- * @returns the associated {@link Amity.Event} object
46593
- *
46594
- * @category Event API
46595
- */
46596
- getEvent$1.locally = (eventId) => {
46597
- const client = getActiveClient();
46598
- client.log('event/getEvent.locally', eventId);
46599
- if (!client.cache)
46600
- return;
46601
- const cache = pullFromCache(['event', 'get', eventId]);
46602
- if (!cache)
46603
- return;
46604
- return {
46605
- data: cache.data,
46606
- cachedAt: cache.cachedAt,
46607
- };
46608
- };
46609
-
46610
- /* begin_public_function
46611
- id: event.delete
46612
- */
46613
- /**
46614
- * ```js
46615
- * import { EventRepository } from '@amityco/ts-sdk'
46616
- * const { success } = await EventRepository.deleteEvent(eventId)
46617
- * ```
46618
- *
46619
- * Deletes a {@link Amity.Event}
46620
- *
46621
- * @param eventId The {@link Amity.Event} ID to delete
46622
- *
46623
- * @category Event API
46624
- * @async
46625
- */
46626
- const deleteEvent = async (eventId) => {
46627
- const client = getActiveClient();
46628
- client.log('event/deleteEvent', eventId);
46629
- const event = await getEvent$1(eventId);
46630
- await client.http.delete(`/api/v3/events/${eventId}`);
46631
- const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
46632
- upsertInCache(['event', 'get', eventId], deletedEvent);
46633
- fireEvent('local.event.deleted', {
46634
- users: [],
46635
- files: [],
46636
- communities: [],
46637
- videoStreamings: [],
46638
- events: [deletedEvent],
46639
- discussionCommunities: [],
46640
- });
46641
- };
46642
- /* end_public_function */
46643
-
46644
- /**
46645
- * ```js
46646
- * import { EventRepository } from '@amityco/ts-sdk'
46647
- * const dispose = EventRepository.onEventCreated(event => {
46648
- * // ...
46649
- * })
46650
- * ```
46651
- *
46652
- * Fired when a {@link Amity.Event} has been created
46653
- *
46654
- * @param callback The function to call when the event was fired
46655
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46656
- *
46657
- * @category Event Events
46658
- */
46659
- const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
46660
-
46661
- /**
46662
- * ```js
46663
- * import { EventRepository } from '@amityco/ts-sdk'
46664
- * const dispose = EventRepository.onEventUpdated(event => {
46665
- * // ...
46666
- * })
46667
- * ```
46668
- *
46669
- * Fired when a {@link Amity.Event} has been updated
46670
- *
46671
- * @param callback The function to call when the event was fired
46672
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46673
- *
46674
- * @category Event Events
46675
- */
46676
- const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
46677
-
46678
- /**
46679
- * ```js
46680
- * import { EventRepository } from '@amityco/ts-sdk'
46681
- * const dispose = EventRepository.onEventDeleted(event => {
46682
- * // ...
46683
- * })
46684
- * ```
46685
- *
46686
- * Fired when a {@link Amity.Event} has been deleted
46687
- *
46688
- * @param callback The function to call when the event was fired
46689
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46690
- *
46691
- * @category Event Events
46692
- */
46693
- const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
46694
-
46695
- /**
46696
- * ```js
46697
- * import { EventRepository } from '@amityco/ts-sdk'
46698
- * const dispose = EventRepository.onLocalEventCreated(event => {
46699
- * // ...
46700
- * })
46701
- * ```
46702
- *
46703
- * Fired when a {@link Amity.Event} has been created
46704
- *
46705
- * @param callback The function to call when the event was fired
46706
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46707
- *
46708
- * @category Event Events
46709
- */
46710
- const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
46711
-
46712
- /**
46713
- * ```js
46714
- * import { EventRepository } from '@amityco/ts-sdk'
46715
- * const dispose = EventRepository.onLocalEventUpdated(event => {
46716
- * // ...
46717
- * })
46718
- * ```
46719
- *
46720
- * Fired when a {@link Amity.Event} has been updated
46721
- *
46722
- * @param callback The function to call when the event was fired
46723
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46724
- *
46725
- * @category Event Events
46726
- */
46727
- const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
46728
-
46729
- /**
46730
- * ```js
46731
- * import { EventRepository } from '@amityco/ts-sdk'
46732
- * const dispose = EventRepository.onLocalEventDeleted(event => {
46733
- * // ...
46734
- * })
46735
- * ```
46736
- *
46737
- * Fired when a {@link Amity.Event} has been deleted
46738
- *
46739
- * @param callback The function to call when the event was fired
46740
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46741
- *
46742
- * @category Event Events
46743
- */
46744
- const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
46745
-
46746
- /* begin_public_function
46747
- id: event.get
46748
- */
46749
- /**
46750
- * ```js
46751
- * import { EventRepository } from '@amityco/ts-sdk';
46752
- *
46753
- * let event;
46754
- *
46755
- * const unsubscribe = EventRepository.getEvent(eventId, response => {
46756
- * event = response.data;
46757
- * });
46758
- * ```
46759
- *
46760
- * Observe all mutation on a given {@link Amity.Event}
46761
- *
46762
- * @param eventId the ID of the event to observe
46763
- * @param callback the function to call when new snapshot of event are available
46764
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
46765
- *
46766
- * @category Event Live Object
46767
- */
46768
- const getEvent = (eventId, callback) => {
46769
- return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
46770
- callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
46771
- });
46772
- };
46773
- /* end_public_function */
46774
-
46775
- var EventActionsEnum;
46776
- (function (EventActionsEnum) {
46777
- EventActionsEnum["OnEventCreated"] = "onEventCreated";
46778
- EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
46779
- EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
46780
- })(EventActionsEnum || (EventActionsEnum = {}));
46781
-
46782
- class EventPaginationController extends PaginationController {
46783
- async getRequest(queryParams, token) {
46784
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
46785
- const options = token ? { token } : { limit };
46786
- const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
46787
- return response;
46788
- }
46789
- }
46790
-
46791
- class EventQueryStreamController extends QueryStreamController {
46792
- constructor(query, cacheKey, notifyChange, preparePayload) {
46793
- super(query, cacheKey);
46794
- this.notifyChange = notifyChange;
46795
- this.preparePayload = preparePayload;
46796
- }
46797
- async saveToMainDB(response) {
46798
- const processedPayload = this.preparePayload(response);
46799
- const client = getActiveClient();
46800
- const cachedAt = client.cache && Date.now();
46801
- if (client.cache)
46802
- ingestInCache(processedPayload, { cachedAt });
46803
- }
46804
- appendToQueryStream(response, direction, refresh = false) {
46805
- var _a, _b;
46806
- if (refresh) {
46807
- pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
46808
- }
46809
- else {
46810
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46811
- const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
46812
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
46813
- }
46814
- }
46815
- reactor(action) {
46816
- return (event) => {
46817
- var _a;
46818
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46819
- if (!collection)
46820
- return;
46821
- if (action === EventActionsEnum.OnEventCreated) {
46822
- collection.data = [...new Set([event.eventId, ...collection.data])];
46823
- }
46824
- if (action === EventActionsEnum.OnEventDeleted) {
46825
- collection.data = collection.data.filter(eventId => eventId !== event.eventId);
46826
- }
46827
- pushToCache(this.cacheKey, collection);
46828
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
46829
- };
46830
- }
46831
- subscribeRTE(createSubscriber) {
46832
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
46833
- }
46834
- }
46835
-
46836
- class EventLiveCollectionController extends LiveCollectionController {
46837
- constructor(query, callback) {
46838
- const queryStreamId = hash(query);
46839
- const cacheKey = ['event', 'collection', queryStreamId];
46840
- const paginationController = new EventPaginationController(query);
46841
- super(paginationController, queryStreamId, cacheKey, callback);
46842
- this.query = query;
46843
- this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
46844
- this.callback = callback.bind(this);
46845
- this.loadPage({ initial: true });
46846
- }
46847
- setup() {
46848
- var _a;
46849
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46850
- if (!collection)
46851
- pushToCache(this.cacheKey, { data: [], params: {} });
46852
- }
46853
- async persistModel(queryPayload) {
46854
- await this.queryStreamController.saveToMainDB(queryPayload);
46855
- }
46856
- persistQueryStream({ response, direction, refresh, }) {
46857
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
46858
- }
46859
- startSubscription() {
46860
- return this.queryStreamController.subscribeRTE([
46861
- { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
46862
- { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
46863
- { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
46864
- { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
46865
- { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
46866
- { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
46867
- ]);
46868
- }
46869
- notifyChange({ origin, loading, error }) {
46870
- var _a, _b;
46871
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46872
- if (!collection)
46873
- return;
46874
- const data = ((_b = collection.data
46875
- .map(eventId => pullFromCache(['event', 'get', eventId]))
46876
- .filter(isNonNullable)
46877
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
46878
- if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
46879
- return;
46880
- this.callback({
46881
- data,
46882
- error,
46883
- loading,
46884
- hasNextPage: !!this.paginationController.getNextToken(),
46885
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
46886
- });
46887
- }
46888
- }
46889
-
46890
- /**
46891
- * Get events
46892
- *
46893
- * @param params the query parameters
46894
- * @param callback the callback to be called when the events are updated
46895
- * @returns events
46896
- *
46897
- * @category Event Live Collection
46898
- *
46899
- */
46900
- const getEvents = (params, callback, config) => {
46901
- const { log, cache } = getActiveClient();
46902
- if (!cache)
46903
- console.log(ENABLE_CACHE_MESSAGE);
46904
- const timestamp = Date.now();
46905
- log(`getEvents: (tmpid: ${timestamp}) > listen`);
46906
- const eventLiveCollection = new EventLiveCollectionController(params, callback);
46907
- const disposers = eventLiveCollection.startSubscription();
46908
- const cacheKey = eventLiveCollection.getCacheKey();
46909
- disposers.push(() => dropFromCache(cacheKey));
46910
- return () => {
46911
- log(`getEvents (tmpid: ${timestamp}) > dispose`);
46912
- disposers.forEach(fn => fn());
46913
- };
46914
- };
46915
-
46916
- class MyEventPaginationController extends PaginationController {
46917
- async getRequest(queryParams, token) {
46918
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
46919
- const options = token ? { token } : { limit };
46920
- const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
46921
- return response;
46922
- }
46923
- }
46924
-
46925
- class MyEventQueryStreamController extends QueryStreamController {
46926
- constructor(query, cacheKey, notifyChange, preparePayload) {
46927
- super(query, cacheKey);
46928
- this.notifyChange = notifyChange;
46929
- this.preparePayload = preparePayload;
46930
- }
46931
- async saveToMainDB(response) {
46932
- const processedPayload = this.preparePayload(response);
46933
- const client = getActiveClient();
46934
- const cachedAt = client.cache && Date.now();
46935
- if (client.cache)
46936
- ingestInCache(processedPayload, { cachedAt });
46937
- }
46938
- appendToQueryStream(response, direction, refresh = false) {
46939
- var _a, _b;
46940
- if (refresh) {
46941
- pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
46942
- }
46943
- else {
46944
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46945
- const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
46946
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
46947
- }
46948
- }
46949
- reactor(action) {
46950
- return (event) => {
46951
- var _a;
46952
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46953
- if (!collection)
46954
- return;
46955
- if (action === EventActionsEnum.OnEventCreated) {
46956
- const client = getActiveClient();
46957
- if (client.userId !== event.userId)
46958
- return;
46959
- collection.data = [...new Set([event.eventId, ...collection.data])];
46960
- }
46961
- if (action === EventActionsEnum.OnEventDeleted) {
46962
- collection.data = collection.data.filter(eventId => eventId !== event.eventId);
46963
- }
46964
- pushToCache(this.cacheKey, collection);
46965
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
46966
- };
46967
- }
46968
- subscribeRTE(createSubscriber) {
46969
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
46970
- }
46971
- }
46972
-
46973
- class MyEventLiveCollectionController extends LiveCollectionController {
46974
- constructor(query, callback) {
46975
- const queryStreamId = hash(query);
46976
- const cacheKey = ['event', 'collection', queryStreamId];
46977
- const paginationController = new MyEventPaginationController(query);
46978
- super(paginationController, queryStreamId, cacheKey, callback);
46979
- this.query = query;
46980
- this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
46981
- this.callback = callback.bind(this);
46982
- this.loadPage({ initial: true });
46983
- }
46984
- setup() {
46985
- var _a;
46986
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46987
- if (!collection)
46988
- pushToCache(this.cacheKey, { data: [], params: {} });
46989
- }
46990
- async persistModel(queryPayload) {
46991
- await this.queryStreamController.saveToMainDB(queryPayload);
46992
- }
46993
- persistQueryStream({ response, direction, refresh, }) {
46994
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
46995
- }
46996
- startSubscription() {
46997
- return this.queryStreamController.subscribeRTE([
46998
- { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
46999
- { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
47000
- { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
47001
- { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
47002
- { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
47003
- { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
47004
- ]);
47005
- }
47006
- notifyChange({ origin, loading, error }) {
47007
- var _a, _b;
47008
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47009
- if (!collection)
47010
- return;
47011
- const data = ((_b = collection.data
47012
- .map(eventId => pullFromCache(['event', 'get', eventId]))
47013
- .filter(isNonNullable)
47014
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
47015
- if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
47016
- return;
47017
- this.callback({
47018
- data,
47019
- error,
47020
- loading,
47021
- hasNextPage: !!this.paginationController.getNextToken(),
47022
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
47023
- });
47024
- }
47025
- }
47026
-
47027
- /**
47028
- * Get my events
47029
- *
47030
- * @param params the query parameters
47031
- * @param callback the callback to be called when the events are updated
47032
- * @returns events
47033
- *
47034
- * @category Event Live Collection
47035
- *
47036
- */
47037
- const getMyEvents = (params, callback, config) => {
47038
- const { log, cache } = getActiveClient();
47039
- if (!cache)
47040
- console.log(ENABLE_CACHE_MESSAGE);
47041
- const timestamp = Date.now();
47042
- log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
47043
- const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
47044
- const disposers = myEventLiveCollection.startSubscription();
47045
- const cacheKey = myEventLiveCollection.getCacheKey();
47046
- disposers.push(() => dropFromCache(cacheKey));
47047
- return () => {
47048
- log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
47049
- disposers.forEach(fn => fn());
47050
- };
47051
- };
47052
-
47053
- var index = /*#__PURE__*/Object.freeze({
47054
- __proto__: null,
47055
- createEvent: createEvent,
47056
- updateEvent: updateEvent,
47057
- deleteEvent: deleteEvent,
47058
- onEventCreated: onEventCreated,
47059
- onEventUpdated: onEventUpdated,
47060
- onEventDeleted: onEventDeleted,
47061
- onLocalEventCreated: onLocalEventCreated,
47062
- onLocalEventUpdated: onLocalEventUpdated,
47063
- onLocalEventDeleted: onLocalEventDeleted,
47064
- getEvent: getEvent,
47065
- getEvents: getEvents,
47066
- getMyEvents: getMyEvents
47067
- });
47068
-
47069
- 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 };
47226
+ 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, getRoomStreamerTopic, getRoomWatcherTopic, 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 };