@amityco/ts-sdk 7.11.1-73c76fb.0 → 7.11.1-75f83d1a.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 (74) hide show
  1. package/dist/@types/core/events.d.ts +1 -0
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/linkPreviewMetadata.d.ts +12 -0
  4. package/dist/@types/core/linkPreviewMetadata.d.ts.map +1 -0
  5. package/dist/@types/core/model.d.ts +1 -1
  6. package/dist/@types/core/model.d.ts.map +1 -1
  7. package/dist/@types/core/payload.d.ts +1 -0
  8. package/dist/@types/core/payload.d.ts.map +1 -1
  9. package/dist/@types/domains/client.d.ts +1 -0
  10. package/dist/@types/domains/client.d.ts.map +1 -1
  11. package/dist/@types/domains/community.d.ts +7 -0
  12. package/dist/@types/domains/community.d.ts.map +1 -1
  13. package/dist/@types/domains/event.d.ts +1 -1
  14. package/dist/@types/domains/event.d.ts.map +1 -1
  15. package/dist/@types/domains/notification.d.ts +2 -1
  16. package/dist/@types/domains/notification.d.ts.map +1 -1
  17. package/dist/@types/domains/post.d.ts +22 -0
  18. package/dist/@types/domains/post.d.ts.map +1 -1
  19. package/dist/@types/domains/room.d.ts +8 -3
  20. package/dist/@types/domains/room.d.ts.map +1 -1
  21. package/dist/client/api/fetchLinkPreview.d.ts +3 -0
  22. package/dist/client/api/fetchLinkPreview.d.ts.map +1 -1
  23. package/dist/client/api/getCurrentUser.d.ts +1 -1
  24. package/dist/client/api/getCurrentUser.d.ts.map +1 -1
  25. package/dist/client/api/getLinkPreviewMetadata.d.ts +14 -0
  26. package/dist/client/api/getLinkPreviewMetadata.d.ts.map +1 -0
  27. package/dist/client/api/index.d.ts +1 -0
  28. package/dist/client/api/index.d.ts.map +1 -1
  29. package/dist/client/utils/setBotClientToken.d.ts.map +1 -1
  30. package/dist/client/utils/setClientToken.d.ts.map +1 -1
  31. package/dist/client/utils/setCurrentUser.d.ts.map +1 -1
  32. package/dist/client/utils/setVisitorClientToken.d.ts.map +1 -1
  33. package/dist/core/events.d.ts +3 -3
  34. package/dist/core/events.d.ts.map +1 -1
  35. package/dist/eventRepository/internalApi/updateRSVP.d.ts.map +1 -1
  36. package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts.map +1 -1
  37. package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts.map +1 -1
  38. package/dist/index.cjs.js +2081 -1681
  39. package/dist/index.esm.js +1801 -1401
  40. package/dist/index.umd.js +2 -2
  41. package/dist/postRepository/api/createPost.d.ts +1 -0
  42. package/dist/postRepository/api/createPost.d.ts.map +1 -1
  43. package/dist/postRepository/api/editPost.d.ts +1 -0
  44. package/dist/postRepository/api/editPost.d.ts.map +1 -1
  45. package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostLiveCollectionController.d.ts +14 -0
  46. package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostLiveCollectionController.d.ts.map +1 -0
  47. package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostPaginationController.d.ts +5 -0
  48. package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostPaginationController.d.ts.map +1 -0
  49. package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostQueryStreamController.d.ts +15 -0
  50. package/dist/postRepository/observers/getCommunityLiveRoomPosts/CommunityLiveRoomPostQueryStreamController.d.ts.map +1 -0
  51. package/dist/postRepository/observers/getCommunityLiveRoomPosts.d.ts +22 -0
  52. package/dist/postRepository/observers/getCommunityLiveRoomPosts.d.ts.map +1 -0
  53. package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostLiveCollectionController.d.ts +14 -0
  54. package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostLiveCollectionController.d.ts.map +1 -0
  55. package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostPaginationController.d.ts +5 -0
  56. package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostPaginationController.d.ts.map +1 -0
  57. package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostQueryStreamController.d.ts +15 -0
  58. package/dist/postRepository/observers/getLiveRoomPosts/LiveRoomPostQueryStreamController.d.ts.map +1 -0
  59. package/dist/postRepository/observers/getLiveRoomPosts.d.ts +23 -0
  60. package/dist/postRepository/observers/getLiveRoomPosts.d.ts.map +1 -0
  61. package/dist/postRepository/observers/index.d.ts +2 -0
  62. package/dist/postRepository/observers/index.d.ts.map +1 -1
  63. package/dist/postRepository/observers/utils.d.ts +1 -0
  64. package/dist/postRepository/observers/utils.d.ts.map +1 -1
  65. package/dist/roomPresenceRepository/api/getRoomUserCount.d.ts.map +1 -1
  66. package/dist/roomRepository/events/index.d.ts +1 -0
  67. package/dist/roomRepository/events/index.d.ts.map +1 -1
  68. package/dist/roomRepository/events/onRoomTerminated.d.ts +17 -0
  69. package/dist/roomRepository/events/onRoomTerminated.d.ts.map +1 -0
  70. package/dist/roomRepository/observers/getRoom.d.ts.map +1 -1
  71. package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -1
  72. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  73. package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +1 -1
  74. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -673,7 +673,7 @@ const idResolvers = {
673
673
  room: ({ roomId }) => roomId,
674
674
  viewer: ({ userId }) => userId,
675
675
  event: ({ eventId }) => eventId,
676
- eventResponse: ({ eventId }) => eventId,
676
+ eventResponse: ({ userId }) => userId,
677
677
  };
678
678
  /**
679
679
  * Retrieve the id resolver matching a domain name
@@ -1556,10 +1556,7 @@ const getCurrentUser = () => {
1556
1556
  throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
1557
1557
  }
1558
1558
  const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
1559
- if (!cache) {
1560
- throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
1561
- }
1562
- return userLinkedObject(cache);
1559
+ return cache ? userLinkedObject(cache) : null;
1563
1560
  };
1564
1561
  /* end_public_function */
1565
1562
 
@@ -23407,6 +23404,13 @@ const getToken = async ({ params, options, }) => {
23407
23404
  return data;
23408
23405
  };
23409
23406
 
23407
+ function prepareUserPayload(response) {
23408
+ return {
23409
+ users: response.users.map(convertRawUserToInternalUser),
23410
+ files: response.files,
23411
+ };
23412
+ }
23413
+
23410
23414
  /**
23411
23415
  * A util to set or refresh client token
23412
23416
  *
@@ -23423,7 +23427,7 @@ const setClientToken = async (params) => {
23423
23427
  const client = getActiveClient();
23424
23428
  // begin establishing session
23425
23429
  setSessionState("establishing" /* Amity.SessionStates.ESTABLISHING */);
23426
- const { accessToken, users, expiresAt, issuedAt, userType } = await getToken(params);
23430
+ const { accessToken, users, expiresAt, issuedAt, userType, files } = await getToken(params);
23427
23431
  // manually setup the token for http transport
23428
23432
  client.http.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
23429
23433
  client.http.defaults.metadata = {
@@ -23439,6 +23443,10 @@ const setClientToken = async (params) => {
23439
23443
  };
23440
23444
  client.token = { accessToken, issuedAt, expiresAt };
23441
23445
  setSessionState("established" /* Amity.SessionStates.ESTABLISHED */);
23446
+ ingestInCache(prepareUserPayload({
23447
+ users,
23448
+ files,
23449
+ }));
23442
23450
  return { accessToken, users, userType };
23443
23451
  };
23444
23452
 
@@ -23488,7 +23496,7 @@ const setVisitorClientToken = async (params) => {
23488
23496
  const client = getActiveClient();
23489
23497
  // begin establishing session
23490
23498
  setSessionState("establishing" /* Amity.SessionStates.ESTABLISHING */);
23491
- const { accessToken, users, expiresAt, issuedAt, userType } = await getVisitorToken(params);
23499
+ const { accessToken, users, expiresAt, issuedAt, userType, files } = await getVisitorToken(params);
23492
23500
  // manually setup the token for http transport
23493
23501
  client.http.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
23494
23502
  client.http.defaults.metadata = {
@@ -23498,16 +23506,13 @@ const setVisitorClientToken = async (params) => {
23498
23506
  };
23499
23507
  client.token = { accessToken, issuedAt, expiresAt };
23500
23508
  setSessionState("established" /* Amity.SessionStates.ESTABLISHED */);
23509
+ ingestInCache(prepareUserPayload({
23510
+ users,
23511
+ files,
23512
+ }));
23501
23513
  return { accessToken, users, userType };
23502
23514
  };
23503
23515
 
23504
- function prepareUserPayload(response) {
23505
- return {
23506
- users: response.users.map(convertRawUserToInternalUser),
23507
- files: response.files,
23508
- };
23509
- }
23510
-
23511
23516
  const createUserEventSubscriber = (event, callback) => {
23512
23517
  const client = getActiveClient();
23513
23518
  const filter = (data) => {
@@ -24976,7 +24981,6 @@ const setCurrentUserType = (userType) => {
24976
24981
  const setCurrentUser = ({ user, userType, }) => {
24977
24982
  setActiveUser(user);
24978
24983
  setCurrentUserType(userType);
24979
- pushToCache(['user', 'get', user.userId], user);
24980
24984
  };
24981
24985
 
24982
24986
  /* eslint-disable no-param-reassign */
@@ -26083,6 +26087,9 @@ function setUploadedFileAccessType(accessType) {
26083
26087
  GlobalFileAccessType$1.getInstance().setFileAccessType(accessType);
26084
26088
  }
26085
26089
 
26090
+ /**
26091
+ * @deprecated This function will to be deprecated and use the new getLinkPreviewMetadata
26092
+ */
26086
26093
  /**
26087
26094
  * ```js
26088
26095
  * import { fetchLinkPreview } from '@amityco/ts-sdk'
@@ -26105,6 +26112,24 @@ const fetchLinkPreview = async (url) => {
26105
26112
  return data;
26106
26113
  };
26107
26114
 
26115
+ /**
26116
+ * ```js
26117
+ * import { getLinkPreviewMetadata } from '@amityco/ts-sdk'
26118
+ * const { title, description, imageUrl } = getLinkPreviewMetadata('https://www.example.com/')
26119
+ * ```
26120
+ *
26121
+ *
26122
+ * @param url the url to fetch link preview
26123
+ * @returns A {@link Amity.LinkPreviewMetadata} instance
26124
+ *
26125
+ * @category Client API
26126
+ * */
26127
+ const getLinkPreviewMetadata = async (url) => {
26128
+ const client = getActiveClient();
26129
+ const { data } = await client.http.get(`/api/v1/link-preview?url=${url}`);
26130
+ return data;
26131
+ };
26132
+
26108
26133
  /**
26109
26134
  * ```js
26110
26135
  * import Client from '@amityco/ts-sdk'
@@ -26163,7 +26188,7 @@ const setBotClientToken = async (params) => {
26163
26188
  const client = getActiveClient();
26164
26189
  // begin establishing session
26165
26190
  setSessionState("establishing" /* Amity.SessionStates.ESTABLISHING */);
26166
- const { accessToken, users, expiresAt, issuedAt, userType } = await getBotToken(params);
26191
+ const { accessToken, users, expiresAt, issuedAt, userType, files } = await getBotToken(params);
26167
26192
  // manually setup the token for http transport
26168
26193
  client.http.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
26169
26194
  client.http.defaults.metadata = {
@@ -26173,6 +26198,10 @@ const setBotClientToken = async (params) => {
26173
26198
  };
26174
26199
  client.token = { accessToken, issuedAt, expiresAt };
26175
26200
  setSessionState("established" /* Amity.SessionStates.ESTABLISHED */);
26201
+ ingestInCache(prepareUserPayload({
26202
+ users,
26203
+ files,
26204
+ }));
26176
26205
  return { accessToken, users, userType };
26177
26206
  };
26178
26207
 
@@ -26630,6 +26659,7 @@ var index$r = /*#__PURE__*/Object.freeze({
26630
26659
  enableUnreadCount: enableUnreadCount,
26631
26660
  setUploadedFileAccessType: setUploadedFileAccessType,
26632
26661
  fetchLinkPreview: fetchLinkPreview,
26662
+ getLinkPreviewMetadata: getLinkPreviewMetadata,
26633
26663
  getSocialSettings: getSocialSettings,
26634
26664
  getShareableLinkConfiguration: getShareableLinkConfiguration,
26635
26665
  loginAsVisitor: loginAsVisitor,
@@ -28871,11 +28901,7 @@ const getInvitation = async (params) => {
28871
28901
  /* end_public_function */
28872
28902
 
28873
28903
  const roomLinkedObject = (room) => {
28874
- return Object.assign(Object.assign({}, room), { get moderation() {
28875
- var _a;
28876
- return (_a = pullFromCache(['roomModeration', 'get', room.roomId])) === null || _a === void 0 ? void 0 : _a.data;
28877
- },
28878
- get post() {
28904
+ return Object.assign(Object.assign({}, room), { get post() {
28879
28905
  var _a;
28880
28906
  if (room.referenceType !== 'post')
28881
28907
  return;
@@ -28923,416 +28949,6 @@ const roomLinkedObject = (room) => {
28923
28949
  } });
28924
28950
  };
28925
28951
 
28926
- const postLinkedObject = (post) => {
28927
- return shallowClone(post, {
28928
- childrenPosts: post.children
28929
- .map(childPost => { var _a; return (_a = pullFromCache(['post', 'get', childPost])) === null || _a === void 0 ? void 0 : _a.data; })
28930
- .filter(isNonNullable)
28931
- .map(postLinkedObject),
28932
- analytics: {
28933
- markAsViewed: () => {
28934
- const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
28935
- analyticsEngineInstance.markPostAsViewed(post.postId);
28936
- },
28937
- },
28938
- get latestComments() {
28939
- if (!post.comments)
28940
- return [];
28941
- return (post.comments
28942
- .map(commentId => {
28943
- var _a;
28944
- const commentCached = (_a = pullFromCache([
28945
- 'comment',
28946
- 'get',
28947
- commentId,
28948
- ])) === null || _a === void 0 ? void 0 : _a.data;
28949
- if (!commentCached)
28950
- return null;
28951
- return commentLinkedObject(commentCached);
28952
- })
28953
- .filter(Boolean) || []);
28954
- },
28955
- get creator() {
28956
- const cacheData = pullFromCache(['user', 'get', post.postedUserId]);
28957
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
28958
- return;
28959
- return userLinkedObject(cacheData.data);
28960
- },
28961
- getImageInfo() {
28962
- var _a, _b;
28963
- return isAmityImagePost(post)
28964
- ? (_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
28965
- : undefined;
28966
- },
28967
- getVideoInfo() {
28968
- var _a, _b, _c;
28969
- return isAmityVideoPost(post)
28970
- ? (_c = pullFromCache(['file', 'get', (_b = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original])) === null || _c === void 0 ? void 0 : _c.data
28971
- : undefined;
28972
- },
28973
- getVideoThumbnailInfo() {
28974
- var _a, _b;
28975
- return isAmityVideoPost(post)
28976
- ? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data
28977
- : undefined;
28978
- },
28979
- getFileInfo() {
28980
- var _a, _b;
28981
- return isAmityFilePost(post)
28982
- ? (_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
28983
- : undefined;
28984
- },
28985
- getLivestreamInfo() {
28986
- var _a, _b;
28987
- if (!isAmityLivestreamPost(post))
28988
- return;
28989
- const cache = (_b = pullFromCache([
28990
- 'stream',
28991
- 'get',
28992
- (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.streamId,
28993
- ])) === null || _b === void 0 ? void 0 : _b.data;
28994
- if (!cache)
28995
- return;
28996
- return streamLinkedObject(cache);
28997
- },
28998
- getPollInfo() {
28999
- var _a, _b;
29000
- if (!isAmityPollPost(post))
29001
- return;
29002
- const cache = (_b = pullFromCache(['poll', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.pollId])) === null || _b === void 0 ? void 0 : _b.data;
29003
- if (!cache)
29004
- return;
29005
- return cache;
29006
- },
29007
- getClipInfo() {
29008
- var _a, _b;
29009
- return isAmityClipPost(post)
29010
- ? (_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
29011
- : undefined;
29012
- },
29013
- getAudioInfo() {
29014
- var _a, _b;
29015
- return isAmityAudioPost(post)
29016
- ? (_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
29017
- : undefined;
29018
- },
29019
- getRoomInfo() {
29020
- var _a, _b;
29021
- if (!isAmityRoomPost(post))
29022
- return;
29023
- 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;
29024
- return room ? roomLinkedObject(room) : undefined;
29025
- },
29026
- });
29027
- };
29028
-
29029
- /** @hidden */
29030
- const dispatchReactable = (referenceType, model) => {
29031
- if (referenceType === 'message')
29032
- // @ts-ignore: refactor later
29033
- fireEvent('local.message.updated', { messages: [model] });
29034
- else if (referenceType === 'post')
29035
- // @ts-ignore: refactor later
29036
- fireEvent('post.updated', { posts: [model] });
29037
- else if (referenceType === 'comment')
29038
- // @ts-ignore: refactor later
29039
- fireEvent('comment.updated', { comments: [model] });
29040
- else if (referenceType === 'story')
29041
- // Need to provide all data same StoryPayload from BE
29042
- fireEvent('story.updated', {
29043
- categories: [],
29044
- comments: [],
29045
- communities: [],
29046
- communityUsers: [],
29047
- files: [],
29048
- users: [],
29049
- stories: [model],
29050
- });
29051
- };
29052
-
29053
- const addReaction$1 = async (referenceType, referenceId, reactionName, referenceVersion) => {
29054
- var _a, _b, _c;
29055
- const client = getActiveClient();
29056
- client.log('reaction/createReaction', {
29057
- referenceId,
29058
- referenceType,
29059
- reactionName,
29060
- });
29061
- if (!['post', 'comment', 'story', 'message'].includes(referenceType))
29062
- throw new ASCApiError('The reference type is not valid. It should be one of post, comment, story, or message', 400000 /* Amity.ServerError.BAD_REQUEST */, "error" /* Amity.ErrorLevel.ERROR */);
29063
- const { data } = await client.http.post('/api/v2/reactions', {
29064
- referenceId,
29065
- referenceType,
29066
- reactionName,
29067
- referenceVersion,
29068
- });
29069
- if (client.cache) {
29070
- const model = pullFromCache([
29071
- referenceType,
29072
- 'get',
29073
- referenceId,
29074
- ]);
29075
- if (!model || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
29076
- return true;
29077
- const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }), updatedAt: new Date().toISOString() });
29078
- if (referenceType === 'comment') {
29079
- fireEvent('local.comment.addReaction', {
29080
- comment: updatedModel,
29081
- reactor: {
29082
- userId: client.userId,
29083
- reactionName,
29084
- reactionId: data.addedId,
29085
- },
29086
- });
29087
- return true;
29088
- }
29089
- if (referenceType === 'post') {
29090
- fireEvent('local.post.addReaction', {
29091
- post: updatedModel,
29092
- reactor: {
29093
- userId: client.userId,
29094
- reactionName,
29095
- reactionId: data.addedId,
29096
- },
29097
- });
29098
- return true;
29099
- }
29100
- if (referenceType === 'story') {
29101
- fireEvent('local.story.reactionAdded', {
29102
- story: updatedModel,
29103
- reactor: {
29104
- userId: client.userId,
29105
- reactionName,
29106
- reactionId: data.addedId,
29107
- },
29108
- });
29109
- return true;
29110
- }
29111
- }
29112
- return true;
29113
- };
29114
- addReaction$1.optimistically = (referenceType, referenceId, reactionName) => {
29115
- var _a, _b, _c, _d, _e;
29116
- const client = getActiveClient();
29117
- client.log('reaction/createReaction.optimistically', {
29118
- referenceId,
29119
- referenceType,
29120
- reactionName,
29121
- });
29122
- if (!client.cache)
29123
- return;
29124
- const model = pullFromCache([
29125
- referenceType,
29126
- 'get',
29127
- referenceId,
29128
- ]);
29129
- if (!(model === null || model === void 0 ? void 0 : model.data) || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
29130
- return;
29131
- const reaction = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }) });
29132
- upsertInCache([referenceType, 'get', referenceId], reaction, {
29133
- cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
29134
- });
29135
- dispatchReactable(referenceType, reaction);
29136
- return (_e = (_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName)) !== null && _e !== void 0 ? _e : false;
29137
- };
29138
-
29139
- const removeReaction$1 = async (referenceType, referenceId, reactionName, referenceVersion) => {
29140
- var _a, _b;
29141
- const client = getActiveClient();
29142
- client.log('reaction/removeReaction', {
29143
- referenceId,
29144
- referenceType,
29145
- reactionName,
29146
- });
29147
- if (!['post', 'comment', 'story', 'message'].includes(referenceType))
29148
- throw new ASCApiError('The reference type is not valid. It should be one of post, comment, story, or message', 400000 /* Amity.ServerError.BAD_REQUEST */, "error" /* Amity.ErrorLevel.ERROR */);
29149
- const { data } = await client.http.delete(`/api/v2/reactions`, {
29150
- data: {
29151
- referenceId,
29152
- referenceType,
29153
- reactionName,
29154
- referenceVersion,
29155
- },
29156
- });
29157
- if (client.cache) {
29158
- const model = pullFromCache([
29159
- referenceType,
29160
- 'get',
29161
- referenceId,
29162
- ]);
29163
- if (!model)
29164
- return true;
29165
- const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_a = model.data.myReactions) !== null && _a !== void 0 ? _a : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_b = model.data.reactions[reactionName]) !== null && _b !== void 0 ? _b : 0) - 1) }), updatedAt: new Date().toISOString() });
29166
- if (referenceType === 'comment') {
29167
- fireEvent('local.comment.removeReaction', {
29168
- comment: updatedModel,
29169
- reactor: {
29170
- reactionId: data.removedId,
29171
- reactionName,
29172
- userId: client.userId,
29173
- },
29174
- });
29175
- return true;
29176
- }
29177
- if (referenceType === 'post') {
29178
- fireEvent('local.post.removeReaction', {
29179
- post: updatedModel,
29180
- reactor: {
29181
- reactionId: data.removedId,
29182
- reactionName,
29183
- userId: client.userId,
29184
- },
29185
- });
29186
- return true;
29187
- }
29188
- if (referenceType === 'story') {
29189
- fireEvent('local.story.reactionAdded', {
29190
- story: updatedModel,
29191
- reactor: {
29192
- userId: client.userId,
29193
- reactionName,
29194
- reactionId: data.removedId,
29195
- },
29196
- });
29197
- return true;
29198
- }
29199
- }
29200
- return true;
29201
- };
29202
-
29203
- const addReactionToMessage = (reactionName, message) => {
29204
- const isMessageV3 = message.publicId !== message.messageId;
29205
- return addReaction$1('message', isMessageV3 ? message.publicId : message.messageId, reactionName, isMessageV3 ? 3 : 5);
29206
- };
29207
-
29208
- const getCachedMarker = (message) => {
29209
- var _a, _b;
29210
- const key = {
29211
- creatorId: 'creatorPrivateId' in message ? message.creatorPrivateId : message.creatorId,
29212
- feedId: (_a = message.messageFeedId) !== null && _a !== void 0 ? _a : message.subChannelId,
29213
- contentId: message.messageId,
29214
- };
29215
- return (_b = pullFromCache([
29216
- 'messageMarker',
29217
- 'get',
29218
- getResolver('messageMarker')(key),
29219
- ])) === null || _b === void 0 ? void 0 : _b.data;
29220
- };
29221
- const getMessageReadCount = (message, marker) => {
29222
- var _a;
29223
- // Look in the marker param first
29224
- return (_a = marker !== null && marker !== void 0 ? marker :
29225
- // If the marker param is not set, look in the cache
29226
- getCachedMarker(message)) !== null && _a !== void 0 ? _a : { readCount: 0, deliveredCount: 0 };
29227
- }; // and if not found in cache use default value `0`
29228
-
29229
- const removeReactionToMessage = (reactionName, message) => {
29230
- const isMessageV3 = message.publicId !== message.messageId;
29231
- return removeReaction$1('message', isMessageV3 ? message.publicId : message.messageId, reactionName, isMessageV3 ? 3 : 5);
29232
- };
29233
-
29234
- const messageLinkedObject = (message) => {
29235
- const rest = __rest(message, ["creatorPrivateId"]);
29236
- return Object.assign(Object.assign({}, rest), { get readCount() {
29237
- return getMessageReadCount(message).readCount;
29238
- },
29239
- get deliveredCount() {
29240
- return getMessageReadCount(message).deliveredCount;
29241
- },
29242
- get creator() {
29243
- var _a;
29244
- return (_a = pullFromCache(['user', 'get', message.creatorId])) === null || _a === void 0 ? void 0 : _a.data;
29245
- }, markRead: () => markReadMessage(message), addReaction: (reactionName) => addReactionToMessage(reactionName, message), removeReaction: (reactionName) => removeReactionToMessage(reactionName, message) });
29246
- };
29247
-
29248
- const reactorLinkedObject = (reactor) => {
29249
- return Object.assign(Object.assign({}, reactor), { get user() {
29250
- var _a;
29251
- const user = (_a = pullFromCache(['user', 'get', reactor.userId])) === null || _a === void 0 ? void 0 : _a.data;
29252
- if (!user)
29253
- return undefined;
29254
- return userLinkedObject(user);
29255
- } });
29256
- };
29257
-
29258
- const adLinkedObject = (ad) => {
29259
- const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
29260
- const { image9_16: image916, image1_1: image11 } = ad, restAds = __rest(ad, ["image9_16", "image1_1"]);
29261
- return Object.assign(Object.assign({}, restAds), { analytics: {
29262
- markAsSeen: (placement) => {
29263
- analyticsEngineInstance.markAdAsViewed(ad, placement);
29264
- },
29265
- markLinkAsClicked: (placement) => {
29266
- analyticsEngineInstance.markAdAsClicked(ad, placement);
29267
- },
29268
- }, get advertiser() {
29269
- var _a, _b;
29270
- const advertiserData = (_a = pullFromCache([
29271
- 'advertiser',
29272
- 'get',
29273
- ad.advertiserId,
29274
- ])) === null || _a === void 0 ? void 0 : _a.data;
29275
- if (!advertiserData)
29276
- return;
29277
- const avatarFile = (_b = pullFromCache([
29278
- 'file',
29279
- 'get',
29280
- advertiserData.avatarFileId,
29281
- ])) === null || _b === void 0 ? void 0 : _b.data;
29282
- return Object.assign(Object.assign({}, advertiserData), { avatar: avatarFile });
29283
- },
29284
- get image1_1() {
29285
- const cacheData = pullFromCache(['file', 'get', image11]);
29286
- if (!cacheData)
29287
- return undefined;
29288
- return cacheData.data || undefined;
29289
- },
29290
- get image9_16() {
29291
- const cacheData = pullFromCache(['file', 'get', image916]);
29292
- if (!cacheData)
29293
- return undefined;
29294
- return cacheData.data || undefined;
29295
- } });
29296
- };
29297
-
29298
- const pinnedPostLinkedObject = (pinnedPost) => {
29299
- var _a;
29300
- const postCached = pullFromCache(['post', 'get', pinnedPost.referenceId]);
29301
- const pinnedBy = (_a = queryCache(['user', 'get']).find(cache => {
29302
- var _a;
29303
- return ((_a = cache.data) === null || _a === void 0 ? void 0 : _a.userInternalId) === pinnedPost.pinnedBy;
29304
- })) === null || _a === void 0 ? void 0 : _a.data;
29305
- return Object.assign(Object.assign({}, pinnedPost), { pinnedBy,
29306
- get post() {
29307
- if (!(postCached === null || postCached === void 0 ? void 0 : postCached.data))
29308
- return;
29309
- return postLinkedObject(postCached.data);
29310
- },
29311
- get target() {
29312
- const pinTarget = pullFromCache([
29313
- 'pinTarget',
29314
- 'get',
29315
- postCached === null || postCached === void 0 ? void 0 : postCached.data.targetId,
29316
- ]);
29317
- if (!(pinTarget === null || pinTarget === void 0 ? void 0 : pinTarget.data))
29318
- return;
29319
- return pinTarget === null || pinTarget === void 0 ? void 0 : pinTarget.data;
29320
- } });
29321
- };
29322
-
29323
- const notificationTrayLinkedObject = (noti) => {
29324
- return Object.assign(Object.assign({}, noti), { isSeen: noti.lastSeenAt > noti.lastOccurredAt, isRecent: new Date(noti.lastOccurredAt).getTime() >= Date.now() - WEEK, users: noti.actors
29325
- .map(({ publicId }) => pullFromCache(['user', 'get', publicId]))
29326
- .filter(isNonNullable)
29327
- .map(({ data }) => data)
29328
- .map(user => userLinkedObject(user)), get event() {
29329
- const cacheData = pullFromCache(['event', 'get', noti.actionReferenceId]);
29330
- if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29331
- return;
29332
- return cacheData.data;
29333
- } });
29334
- };
29335
-
29336
28952
  /*
29337
28953
  * verifies membership status
29338
28954
  */
@@ -29909,6 +29525,17 @@ const communityLinkedObject = (community) => {
29909
29525
  return undefined;
29910
29526
  })
29911
29527
  .filter(category => !!category);
29528
+ },
29529
+ get avatar() {
29530
+ var _a;
29531
+ if (!community.avatarFileId)
29532
+ return undefined;
29533
+ const avatar = (_a = pullFromCache([
29534
+ 'file',
29535
+ 'get',
29536
+ community.avatarFileId,
29537
+ ])) === null || _a === void 0 ? void 0 : _a.data;
29538
+ return avatar;
29912
29539
  }, createInvitations: async (userIds) => {
29913
29540
  await createInvitations({
29914
29541
  type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */,
@@ -29932,6 +29559,427 @@ const communityLinkedObject = (community) => {
29932
29559
  } });
29933
29560
  };
29934
29561
 
29562
+ const postLinkedObject = (post) => {
29563
+ return shallowClone(post, {
29564
+ childrenPosts: post.children
29565
+ .map(childPost => { var _a; return (_a = pullFromCache(['post', 'get', childPost])) === null || _a === void 0 ? void 0 : _a.data; })
29566
+ .filter(isNonNullable)
29567
+ .map(postLinkedObject),
29568
+ analytics: {
29569
+ markAsViewed: () => {
29570
+ const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
29571
+ analyticsEngineInstance.markPostAsViewed(post.postId);
29572
+ },
29573
+ },
29574
+ get latestComments() {
29575
+ if (!post.comments)
29576
+ return [];
29577
+ return (post.comments
29578
+ .map(commentId => {
29579
+ var _a;
29580
+ const commentCached = (_a = pullFromCache([
29581
+ 'comment',
29582
+ 'get',
29583
+ commentId,
29584
+ ])) === null || _a === void 0 ? void 0 : _a.data;
29585
+ if (!commentCached)
29586
+ return null;
29587
+ return commentLinkedObject(commentCached);
29588
+ })
29589
+ .filter(Boolean) || []);
29590
+ },
29591
+ get creator() {
29592
+ const cacheData = pullFromCache(['user', 'get', post.postedUserId]);
29593
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29594
+ return;
29595
+ return userLinkedObject(cacheData.data);
29596
+ },
29597
+ get targetCommunity() {
29598
+ var _a;
29599
+ const communityCache = (_a = pullFromCache([
29600
+ 'community',
29601
+ 'get',
29602
+ post.targetId,
29603
+ ])) === null || _a === void 0 ? void 0 : _a.data;
29604
+ if (!communityCache)
29605
+ return;
29606
+ return communityLinkedObject(communityCache);
29607
+ },
29608
+ getImageInfo() {
29609
+ var _a, _b;
29610
+ return isAmityImagePost(post)
29611
+ ? (_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
29612
+ : undefined;
29613
+ },
29614
+ getVideoInfo() {
29615
+ var _a, _b, _c;
29616
+ return isAmityVideoPost(post)
29617
+ ? (_c = pullFromCache(['file', 'get', (_b = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original])) === null || _c === void 0 ? void 0 : _c.data
29618
+ : undefined;
29619
+ },
29620
+ getVideoThumbnailInfo() {
29621
+ var _a, _b;
29622
+ return isAmityVideoPost(post)
29623
+ ? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data
29624
+ : undefined;
29625
+ },
29626
+ getFileInfo() {
29627
+ var _a, _b;
29628
+ return isAmityFilePost(post)
29629
+ ? (_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
29630
+ : undefined;
29631
+ },
29632
+ getLivestreamInfo() {
29633
+ var _a, _b;
29634
+ if (!isAmityLivestreamPost(post))
29635
+ return;
29636
+ const cache = (_b = pullFromCache([
29637
+ 'stream',
29638
+ 'get',
29639
+ (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.streamId,
29640
+ ])) === null || _b === void 0 ? void 0 : _b.data;
29641
+ if (!cache)
29642
+ return;
29643
+ return streamLinkedObject(cache);
29644
+ },
29645
+ getPollInfo() {
29646
+ var _a, _b;
29647
+ if (!isAmityPollPost(post))
29648
+ return;
29649
+ const cache = (_b = pullFromCache(['poll', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.pollId])) === null || _b === void 0 ? void 0 : _b.data;
29650
+ if (!cache)
29651
+ return;
29652
+ return cache;
29653
+ },
29654
+ getClipInfo() {
29655
+ var _a, _b;
29656
+ return isAmityClipPost(post)
29657
+ ? (_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
29658
+ : undefined;
29659
+ },
29660
+ getAudioInfo() {
29661
+ var _a, _b;
29662
+ return isAmityAudioPost(post)
29663
+ ? (_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
29664
+ : undefined;
29665
+ },
29666
+ getRoomInfo() {
29667
+ var _a, _b;
29668
+ if (!isAmityRoomPost(post))
29669
+ return;
29670
+ 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;
29671
+ return room ? roomLinkedObject(room) : undefined;
29672
+ },
29673
+ });
29674
+ };
29675
+
29676
+ /** @hidden */
29677
+ const dispatchReactable = (referenceType, model) => {
29678
+ if (referenceType === 'message')
29679
+ // @ts-ignore: refactor later
29680
+ fireEvent('local.message.updated', { messages: [model] });
29681
+ else if (referenceType === 'post')
29682
+ // @ts-ignore: refactor later
29683
+ fireEvent('post.updated', { posts: [model] });
29684
+ else if (referenceType === 'comment')
29685
+ // @ts-ignore: refactor later
29686
+ fireEvent('comment.updated', { comments: [model] });
29687
+ else if (referenceType === 'story')
29688
+ // Need to provide all data same StoryPayload from BE
29689
+ fireEvent('story.updated', {
29690
+ categories: [],
29691
+ comments: [],
29692
+ communities: [],
29693
+ communityUsers: [],
29694
+ files: [],
29695
+ users: [],
29696
+ stories: [model],
29697
+ });
29698
+ };
29699
+
29700
+ const addReaction$1 = async (referenceType, referenceId, reactionName, referenceVersion) => {
29701
+ var _a, _b, _c;
29702
+ const client = getActiveClient();
29703
+ client.log('reaction/createReaction', {
29704
+ referenceId,
29705
+ referenceType,
29706
+ reactionName,
29707
+ });
29708
+ if (!['post', 'comment', 'story', 'message'].includes(referenceType))
29709
+ throw new ASCApiError('The reference type is not valid. It should be one of post, comment, story, or message', 400000 /* Amity.ServerError.BAD_REQUEST */, "error" /* Amity.ErrorLevel.ERROR */);
29710
+ const { data } = await client.http.post('/api/v2/reactions', {
29711
+ referenceId,
29712
+ referenceType,
29713
+ reactionName,
29714
+ referenceVersion,
29715
+ });
29716
+ if (client.cache) {
29717
+ const model = pullFromCache([
29718
+ referenceType,
29719
+ 'get',
29720
+ referenceId,
29721
+ ]);
29722
+ if (!model || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
29723
+ return true;
29724
+ const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }), updatedAt: new Date().toISOString() });
29725
+ if (referenceType === 'comment') {
29726
+ fireEvent('local.comment.addReaction', {
29727
+ comment: updatedModel,
29728
+ reactor: {
29729
+ userId: client.userId,
29730
+ reactionName,
29731
+ reactionId: data.addedId,
29732
+ },
29733
+ });
29734
+ return true;
29735
+ }
29736
+ if (referenceType === 'post') {
29737
+ fireEvent('local.post.addReaction', {
29738
+ post: updatedModel,
29739
+ reactor: {
29740
+ userId: client.userId,
29741
+ reactionName,
29742
+ reactionId: data.addedId,
29743
+ },
29744
+ });
29745
+ return true;
29746
+ }
29747
+ if (referenceType === 'story') {
29748
+ fireEvent('local.story.reactionAdded', {
29749
+ story: updatedModel,
29750
+ reactor: {
29751
+ userId: client.userId,
29752
+ reactionName,
29753
+ reactionId: data.addedId,
29754
+ },
29755
+ });
29756
+ return true;
29757
+ }
29758
+ }
29759
+ return true;
29760
+ };
29761
+ addReaction$1.optimistically = (referenceType, referenceId, reactionName) => {
29762
+ var _a, _b, _c, _d, _e;
29763
+ const client = getActiveClient();
29764
+ client.log('reaction/createReaction.optimistically', {
29765
+ referenceId,
29766
+ referenceType,
29767
+ reactionName,
29768
+ });
29769
+ if (!client.cache)
29770
+ return;
29771
+ const model = pullFromCache([
29772
+ referenceType,
29773
+ 'get',
29774
+ referenceId,
29775
+ ]);
29776
+ if (!(model === null || model === void 0 ? void 0 : model.data) || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
29777
+ return;
29778
+ const reaction = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }) });
29779
+ upsertInCache([referenceType, 'get', referenceId], reaction, {
29780
+ cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
29781
+ });
29782
+ dispatchReactable(referenceType, reaction);
29783
+ return (_e = (_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName)) !== null && _e !== void 0 ? _e : false;
29784
+ };
29785
+
29786
+ const removeReaction$1 = async (referenceType, referenceId, reactionName, referenceVersion) => {
29787
+ var _a, _b;
29788
+ const client = getActiveClient();
29789
+ client.log('reaction/removeReaction', {
29790
+ referenceId,
29791
+ referenceType,
29792
+ reactionName,
29793
+ });
29794
+ if (!['post', 'comment', 'story', 'message'].includes(referenceType))
29795
+ throw new ASCApiError('The reference type is not valid. It should be one of post, comment, story, or message', 400000 /* Amity.ServerError.BAD_REQUEST */, "error" /* Amity.ErrorLevel.ERROR */);
29796
+ const { data } = await client.http.delete(`/api/v2/reactions`, {
29797
+ data: {
29798
+ referenceId,
29799
+ referenceType,
29800
+ reactionName,
29801
+ referenceVersion,
29802
+ },
29803
+ });
29804
+ if (client.cache) {
29805
+ const model = pullFromCache([
29806
+ referenceType,
29807
+ 'get',
29808
+ referenceId,
29809
+ ]);
29810
+ if (!model)
29811
+ return true;
29812
+ const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_a = model.data.myReactions) !== null && _a !== void 0 ? _a : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_b = model.data.reactions[reactionName]) !== null && _b !== void 0 ? _b : 0) - 1) }), updatedAt: new Date().toISOString() });
29813
+ if (referenceType === 'comment') {
29814
+ fireEvent('local.comment.removeReaction', {
29815
+ comment: updatedModel,
29816
+ reactor: {
29817
+ reactionId: data.removedId,
29818
+ reactionName,
29819
+ userId: client.userId,
29820
+ },
29821
+ });
29822
+ return true;
29823
+ }
29824
+ if (referenceType === 'post') {
29825
+ fireEvent('local.post.removeReaction', {
29826
+ post: updatedModel,
29827
+ reactor: {
29828
+ reactionId: data.removedId,
29829
+ reactionName,
29830
+ userId: client.userId,
29831
+ },
29832
+ });
29833
+ return true;
29834
+ }
29835
+ if (referenceType === 'story') {
29836
+ fireEvent('local.story.reactionAdded', {
29837
+ story: updatedModel,
29838
+ reactor: {
29839
+ userId: client.userId,
29840
+ reactionName,
29841
+ reactionId: data.removedId,
29842
+ },
29843
+ });
29844
+ return true;
29845
+ }
29846
+ }
29847
+ return true;
29848
+ };
29849
+
29850
+ const addReactionToMessage = (reactionName, message) => {
29851
+ const isMessageV3 = message.publicId !== message.messageId;
29852
+ return addReaction$1('message', isMessageV3 ? message.publicId : message.messageId, reactionName, isMessageV3 ? 3 : 5);
29853
+ };
29854
+
29855
+ const getCachedMarker = (message) => {
29856
+ var _a, _b;
29857
+ const key = {
29858
+ creatorId: 'creatorPrivateId' in message ? message.creatorPrivateId : message.creatorId,
29859
+ feedId: (_a = message.messageFeedId) !== null && _a !== void 0 ? _a : message.subChannelId,
29860
+ contentId: message.messageId,
29861
+ };
29862
+ return (_b = pullFromCache([
29863
+ 'messageMarker',
29864
+ 'get',
29865
+ getResolver('messageMarker')(key),
29866
+ ])) === null || _b === void 0 ? void 0 : _b.data;
29867
+ };
29868
+ const getMessageReadCount = (message, marker) => {
29869
+ var _a;
29870
+ // Look in the marker param first
29871
+ return (_a = marker !== null && marker !== void 0 ? marker :
29872
+ // If the marker param is not set, look in the cache
29873
+ getCachedMarker(message)) !== null && _a !== void 0 ? _a : { readCount: 0, deliveredCount: 0 };
29874
+ }; // and if not found in cache use default value `0`
29875
+
29876
+ const removeReactionToMessage = (reactionName, message) => {
29877
+ const isMessageV3 = message.publicId !== message.messageId;
29878
+ return removeReaction$1('message', isMessageV3 ? message.publicId : message.messageId, reactionName, isMessageV3 ? 3 : 5);
29879
+ };
29880
+
29881
+ const messageLinkedObject = (message) => {
29882
+ const rest = __rest(message, ["creatorPrivateId"]);
29883
+ return Object.assign(Object.assign({}, rest), { get readCount() {
29884
+ return getMessageReadCount(message).readCount;
29885
+ },
29886
+ get deliveredCount() {
29887
+ return getMessageReadCount(message).deliveredCount;
29888
+ },
29889
+ get creator() {
29890
+ var _a;
29891
+ return (_a = pullFromCache(['user', 'get', message.creatorId])) === null || _a === void 0 ? void 0 : _a.data;
29892
+ }, markRead: () => markReadMessage(message), addReaction: (reactionName) => addReactionToMessage(reactionName, message), removeReaction: (reactionName) => removeReactionToMessage(reactionName, message) });
29893
+ };
29894
+
29895
+ const reactorLinkedObject = (reactor) => {
29896
+ return Object.assign(Object.assign({}, reactor), { get user() {
29897
+ var _a;
29898
+ const user = (_a = pullFromCache(['user', 'get', reactor.userId])) === null || _a === void 0 ? void 0 : _a.data;
29899
+ if (!user)
29900
+ return undefined;
29901
+ return userLinkedObject(user);
29902
+ } });
29903
+ };
29904
+
29905
+ const adLinkedObject = (ad) => {
29906
+ const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
29907
+ const { image9_16: image916, image1_1: image11 } = ad, restAds = __rest(ad, ["image9_16", "image1_1"]);
29908
+ return Object.assign(Object.assign({}, restAds), { analytics: {
29909
+ markAsSeen: (placement) => {
29910
+ analyticsEngineInstance.markAdAsViewed(ad, placement);
29911
+ },
29912
+ markLinkAsClicked: (placement) => {
29913
+ analyticsEngineInstance.markAdAsClicked(ad, placement);
29914
+ },
29915
+ }, get advertiser() {
29916
+ var _a, _b;
29917
+ const advertiserData = (_a = pullFromCache([
29918
+ 'advertiser',
29919
+ 'get',
29920
+ ad.advertiserId,
29921
+ ])) === null || _a === void 0 ? void 0 : _a.data;
29922
+ if (!advertiserData)
29923
+ return;
29924
+ const avatarFile = (_b = pullFromCache([
29925
+ 'file',
29926
+ 'get',
29927
+ advertiserData.avatarFileId,
29928
+ ])) === null || _b === void 0 ? void 0 : _b.data;
29929
+ return Object.assign(Object.assign({}, advertiserData), { avatar: avatarFile });
29930
+ },
29931
+ get image1_1() {
29932
+ const cacheData = pullFromCache(['file', 'get', image11]);
29933
+ if (!cacheData)
29934
+ return undefined;
29935
+ return cacheData.data || undefined;
29936
+ },
29937
+ get image9_16() {
29938
+ const cacheData = pullFromCache(['file', 'get', image916]);
29939
+ if (!cacheData)
29940
+ return undefined;
29941
+ return cacheData.data || undefined;
29942
+ } });
29943
+ };
29944
+
29945
+ const pinnedPostLinkedObject = (pinnedPost) => {
29946
+ var _a;
29947
+ const postCached = pullFromCache(['post', 'get', pinnedPost.referenceId]);
29948
+ const pinnedBy = (_a = queryCache(['user', 'get']).find(cache => {
29949
+ var _a;
29950
+ return ((_a = cache.data) === null || _a === void 0 ? void 0 : _a.userInternalId) === pinnedPost.pinnedBy;
29951
+ })) === null || _a === void 0 ? void 0 : _a.data;
29952
+ return Object.assign(Object.assign({}, pinnedPost), { pinnedBy,
29953
+ get post() {
29954
+ if (!(postCached === null || postCached === void 0 ? void 0 : postCached.data))
29955
+ return;
29956
+ return postLinkedObject(postCached.data);
29957
+ },
29958
+ get target() {
29959
+ const pinTarget = pullFromCache([
29960
+ 'pinTarget',
29961
+ 'get',
29962
+ postCached === null || postCached === void 0 ? void 0 : postCached.data.targetId,
29963
+ ]);
29964
+ if (!(pinTarget === null || pinTarget === void 0 ? void 0 : pinTarget.data))
29965
+ return;
29966
+ return pinTarget === null || pinTarget === void 0 ? void 0 : pinTarget.data;
29967
+ } });
29968
+ };
29969
+
29970
+ const notificationTrayLinkedObject = (noti) => {
29971
+ return Object.assign(Object.assign({}, noti), { isSeen: noti.lastSeenAt > noti.lastOccurredAt, isRecent: new Date(noti.lastOccurredAt).getTime() >= Date.now() - WEEK, users: noti.actors
29972
+ .map(({ publicId }) => pullFromCache(['user', 'get', publicId]))
29973
+ .filter(isNonNullable)
29974
+ .map(({ data }) => data)
29975
+ .map(user => userLinkedObject(user)), get event() {
29976
+ const cacheData = pullFromCache(['event', 'get', noti.actionReferenceId]);
29977
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29978
+ return;
29979
+ return cacheData.data;
29980
+ } });
29981
+ };
29982
+
29935
29983
  const prepareEventResponsePayload = (rawPayload) => {
29936
29984
  return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
29937
29985
  };
@@ -30162,7 +30210,7 @@ class RSVPQueryStreamController extends QueryStreamController {
30162
30210
  const client = getActiveClient();
30163
30211
  const cachedAt = client.cache && Date.now();
30164
30212
  if (client.cache)
30165
- ingestInCache({ eventResponses: [processedPayload] }, { cachedAt });
30213
+ ingestInCache(processedPayload, { cachedAt });
30166
30214
  }
30167
30215
  appendToQueryStream(response, direction, refresh = false) {
30168
30216
  var _a, _b;
@@ -30186,10 +30234,7 @@ class RSVPQueryStreamController extends QueryStreamController {
30186
30234
  if (!collection)
30187
30235
  return;
30188
30236
  if (action === EventActionsEnum.OnRSVPCreated) {
30189
- const client = getActiveClient();
30190
- if (client.userId !== event.userId)
30191
- return;
30192
- collection.data = [...new Set([event.eventId, ...collection.data])];
30237
+ collection.data = [...new Set([event.userId, ...collection.data])];
30193
30238
  }
30194
30239
  if (action === EventActionsEnum.OnEventDeleted) {
30195
30240
  collection.data = collection.data.filter(eventId => eventId !== event.eventId);
@@ -30405,14 +30450,14 @@ class RSVPLiveCollectionController extends LiveCollectionController {
30405
30450
  ]);
30406
30451
  }
30407
30452
  notifyChange({ origin, loading, error }) {
30408
- var _a, _b;
30453
+ var _a;
30409
30454
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
30410
30455
  if (!collection)
30411
30456
  return;
30412
- const data = (_b = collection.data
30413
- .map(eventId => pullFromCache(['eventResponse', 'get', eventId]))
30457
+ const data = collection.data
30458
+ .map(userId => pullFromCache(['eventResponse', 'get', userId]))
30414
30459
  .filter(isNonNullable)
30415
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : [].map(eventResponseLinkedObject);
30460
+ .map(({ data }) => eventResponseLinkedObject(data));
30416
30461
  if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
30417
30462
  return;
30418
30463
  this.callback({
@@ -42998,6 +43043,15 @@ const getPostSubscription = (cacheKey) => {
42998
43043
  ...generateCommentSubscriptions({ cacheKey }),
42999
43044
  ];
43000
43045
  };
43046
+ const resolvePostIdsFromRooms = (rooms, posts) => {
43047
+ var _a;
43048
+ return ((_a = rooms
43049
+ .map(room => {
43050
+ const post = posts.find(post => post.postId === room.referenceId);
43051
+ return post ? getResolver('post')({ postId: post === null || post === void 0 ? void 0 : post.postId }) : undefined;
43052
+ })
43053
+ .filter(isNonNullable)) !== null && _a !== void 0 ? _a : []);
43054
+ };
43001
43055
 
43002
43056
  class PostLiveCollectionController extends LiveCollectionController {
43003
43057
  constructor(query, callback) {
@@ -43883,1403 +43937,1814 @@ const searchPostsByHashtag = (params, callback, config) => {
43883
43937
  };
43884
43938
  /* end_public_function */
43885
43939
 
43886
- var index$b = /*#__PURE__*/Object.freeze({
43887
- __proto__: null,
43888
- getPostByIds: getPostByIds,
43889
- createPost: createPost,
43890
- editPost: editPost,
43891
- deletePost: deletePost,
43892
- softDeletePost: softDeletePost,
43893
- hardDeletePost: hardDeletePost,
43894
- approvePost: approvePost,
43895
- declinePost: declinePost,
43896
- flagPost: flagPost,
43897
- unflagPost: unflagPost,
43898
- isPostFlaggedByMe: isPostFlaggedByMe,
43899
- createClipPost: createClipPost,
43900
- createAudioPost: createAudioPost,
43901
- createMixedMediaPost: createMixedMediaPost,
43902
- onPostCreated: onPostCreated,
43903
- onPostUpdated: onPostUpdated,
43904
- onPostDeleted: onPostDeleted,
43905
- onPostApproved: onPostApproved,
43906
- onPostDeclined: onPostDeclined,
43907
- onPostFlagged: onPostFlagged,
43908
- onPostUnflagged: onPostUnflagged,
43909
- onPostReactionAdded: onPostReactionAdded,
43910
- onPostReactionRemoved: onPostReactionRemoved,
43911
- getPost: getPost,
43912
- getPosts: getPosts,
43913
- getPinnedPosts: getPinnedPosts,
43914
- getGlobalPinnedPosts: getGlobalPinnedPosts,
43915
- semanticSearchPosts: semanticSearchPosts,
43916
- searchPostsByHashtag: searchPostsByHashtag
43917
- });
43940
+ class LiveRoomPostPaginationController extends PaginationNoPageController {
43941
+ async getRequest(queryParams) {
43942
+ const { limit = 100 } = queryParams;
43943
+ const { data: queryResponse } = await this.http.get(`/api/v1/rooms/lives`, {
43944
+ params: {
43945
+ targetTypes: ['all'],
43946
+ options: {
43947
+ limit,
43948
+ sortBy: 'lastCreated',
43949
+ },
43950
+ },
43951
+ });
43952
+ return queryResponse;
43953
+ }
43954
+ }
43955
+
43956
+ class LiveRoomPostQueryStreamController extends QueryStreamController {
43957
+ constructor(query, cacheKey, notifyChange, preparePayload) {
43958
+ super(query, cacheKey);
43959
+ this.notifyChange = notifyChange;
43960
+ this.preparePayload = preparePayload;
43961
+ }
43962
+ async saveToMainDB(response) {
43963
+ const processedPayload = await this.preparePayload(response);
43964
+ const client = getActiveClient();
43965
+ const cachedAt = client.cache && Date.now();
43966
+ if (client.cache) {
43967
+ ingestInCache(processedPayload, { cachedAt });
43968
+ }
43969
+ }
43970
+ appendToQueryStream(response, direction, refresh = false) {
43971
+ var _a, _b;
43972
+ if (refresh) {
43973
+ pushToCache(this.cacheKey, {
43974
+ data: resolvePostIdsFromRooms(response.rooms, response.posts),
43975
+ });
43976
+ }
43977
+ else {
43978
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
43979
+ const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
43980
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...resolvePostIdsFromRooms(response.rooms, response.posts)])] }));
43981
+ }
43982
+ }
43983
+ reactor(action) {
43984
+ return (room) => {
43985
+ var _a;
43986
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
43987
+ if (!collection)
43988
+ return;
43989
+ if (room.status === 'ended') {
43990
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: collection.data.filter(postId => room.referenceId !== postId) }));
43991
+ }
43992
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
43993
+ };
43994
+ }
43995
+ subscribeRTE(createSubscriber) {
43996
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
43997
+ }
43998
+ }
43918
43999
 
43919
44000
  /* begin_public_function
43920
- id: stream.create
44001
+ id: room.create
43921
44002
  */
43922
44003
  /**
43923
44004
  * ```js
43924
- * import { createStream } from '@amityco/ts-sdk'
43925
- * const created = await createStream({ title: 'my stream', 'thumbnailFileId': fileId })
44005
+ * import { createRoom } from '@amityco/ts-sdk'
44006
+ * const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
43926
44007
  * ```
43927
44008
  *
43928
- * Creates an {@link Amity.InternalStream}
44009
+ * Creates an {@link Amity.Room}
43929
44010
  *
43930
- * @param bundle The data necessary to create a new {@link Amity.InternalStream}
43931
- * @returns The newly created {@link Amity.InternalStream}
44011
+ * @param bundle The data necessary to create a new {@link Amity.Room}
44012
+ * @returns The newly created {@link Amity.Room}
43932
44013
  *
43933
- * @category Stream API
44014
+ * @category Room API
43934
44015
  * @async
43935
44016
  */
43936
- const createStream = async (bundle) => {
44017
+ const createRoom = async (bundle) => {
43937
44018
  const client = getActiveClient();
43938
- client.log('stream/createStream', bundle);
43939
- const { data } = await client.http.post('/api/v3/video-streaming', bundle);
44019
+ client.log('room/createRoom', bundle);
44020
+ const { data } = await client.http.post('/api/v1/rooms', bundle);
44021
+ fireEvent('local.room.created', data);
43940
44022
  const cachedAt = client.cache && Date.now();
44023
+ // TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
43941
44024
  if (client.cache)
43942
44025
  ingestInCache(data, { cachedAt });
43943
- const { videoStreamings } = data;
44026
+ const { rooms } = data;
43944
44027
  return {
43945
- data: LinkedObject.stream(videoStreamings[0]),
44028
+ data: roomLinkedObject(rooms[0]),
43946
44029
  cachedAt,
43947
44030
  };
43948
44031
  };
43949
44032
  /* end_public_function */
43950
44033
 
43951
44034
  /* begin_public_function
43952
- id: stream.update
44035
+ id: room.update
43953
44036
  */
43954
44037
  /**
43955
- * @deprecated this function is deprecated,
43956
- * please use {@link Amity.StreamRepository.editStream} instead.
43957
- *
43958
44038
  * ```js
43959
- * import { updateStream } from '@amityco/ts-sdk'
43960
- * const updated = await updateStream(streamId, { title: 'foobar' })
44039
+ * import { updateRoom } from '@amityco/ts-sdk'
44040
+ * const updated = await updateRoom('roomId', { title: 'updated title' })
43961
44041
  * ```
43962
44042
  *
43963
- * Updates an {@link Amity.Stream}
44043
+ * Updates an {@link Amity.InternalRoom}
43964
44044
  *
43965
- * @param streamId The ID of the {@link Amity.Stream} to edit
43966
- * @param patch The patch data to apply
43967
- * @returns the updated {@link Amity.Stream} object
44045
+ * @param roomId The ID of the room to update
44046
+ * @param bundle The data to update the room with
44047
+ * @returns The updated {@link Amity.InternalRoom}
43968
44048
  *
43969
- * @category Stream API
44049
+ * @category Room API
43970
44050
  * @async
43971
44051
  */
43972
- const updateStream = async (streamId, patch) => {
44052
+ const updateRoom = async (roomId, bundle) => {
43973
44053
  const client = getActiveClient();
43974
- client.log('stream/updateStream', streamId, patch);
43975
- const { data } = await client.http.put(`/api/v3/video-streaming/${streamId}`, patch);
44054
+ client.log('room/updateRoom', { roomId, bundle });
44055
+ const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
44056
+ fireEvent('local.room.updated', data);
43976
44057
  const cachedAt = client.cache && Date.now();
43977
44058
  if (client.cache)
43978
44059
  ingestInCache(data, { cachedAt });
43979
- const { videoStreamings } = data;
44060
+ const { rooms } = data;
43980
44061
  return {
43981
- data: LinkedObject.stream(videoStreamings.find(stream => stream.streamId === streamId)),
44062
+ data: roomLinkedObject(rooms[0]),
43982
44063
  cachedAt,
43983
44064
  };
43984
44065
  };
43985
44066
  /* end_public_function */
43986
44067
 
43987
44068
  /* begin_public_function
43988
- id: stream.get
44069
+ id: room.delete
43989
44070
  */
43990
44071
  /**
43991
44072
  * ```js
43992
- * import { getStream } from '@amityco/ts-sdk'
43993
- * const stream = await getStream('foobar')
44073
+ * import { deleteRoom } from '@amityco/ts-sdk'
44074
+ * const result = await deleteRoom('roomId')
43994
44075
  * ```
43995
44076
  *
43996
- * Fetches a {@link Amity.Stream} object
44077
+ * Deletes an {@link Amity.Room}
43997
44078
  *
43998
- * @param streamId the ID of the {@link Amity.Stream} to fetch
43999
- * @returns the associated {@link Amity.Stream} object
44079
+ * @param roomId The ID of the room to delete
44080
+ * @returns Promise that resolves when the room is deleted
44000
44081
  *
44001
- * @category Stream API
44082
+ * @category Room API
44002
44083
  * @async
44003
44084
  */
44004
- const getStream = async (streamId) => {
44085
+ const deleteRoom = async (roomId) => {
44005
44086
  const client = getActiveClient();
44006
- client.log('stream/getStream', streamId);
44007
- const { data } = await client.http.get(`/api/v3/video-streaming/${streamId}`);
44087
+ client.log('room/deleteRoom', { roomId });
44088
+ await client.http.delete(`/api/v1/rooms/${roomId}`);
44089
+ fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
44090
+ };
44091
+ /* end_public_function */
44092
+
44093
+ /* begin_public_function
44094
+ id: room.stop
44095
+ */
44096
+ /**
44097
+ * ```js
44098
+ * import { stopRoom } from '@amityco/ts-sdk'
44099
+ * const result = await stopRoom('roomId')
44100
+ * ```
44101
+ *
44102
+ * Stops a room's broadcasting
44103
+ *
44104
+ * @param roomId The ID of the room to stop
44105
+ * @returns The updated room data
44106
+ *
44107
+ * @category Room API
44108
+ * @async
44109
+ */
44110
+ const stopRoom = async (roomId) => {
44111
+ const client = getActiveClient();
44112
+ client.log('room/stopRoom', { roomId });
44113
+ const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
44114
+ fireEvent('local.room.stopped', data);
44008
44115
  const cachedAt = client.cache && Date.now();
44009
44116
  if (client.cache)
44010
44117
  ingestInCache(data, { cachedAt });
44011
- const { videoStreamings } = data;
44118
+ const { rooms } = data;
44012
44119
  return {
44013
- data: videoStreamings.find(stream => stream.streamId === streamId),
44120
+ data: rooms[0],
44014
44121
  cachedAt,
44015
44122
  };
44016
44123
  };
44017
44124
  /* end_public_function */
44125
+
44126
+ /* begin_public_function
44127
+ id: room.getBroadcasterData
44128
+ */
44018
44129
  /**
44019
44130
  * ```js
44020
- * import { getStream } from '@amityco/ts-sdk'
44021
- * const stream = getStream.locally('foobar')
44131
+ * import { getBroadcasterData } from '@amityco/ts-sdk'
44132
+ * const token = await getBroadcasterData('roomId')
44022
44133
  * ```
44023
44134
  *
44024
- * Fetches a {@link Amity.Stream} object
44135
+ * Gets broadcaster data for a room
44025
44136
  *
44026
- * @param streamId the ID of the {@link Amity.Stream} to fetch
44027
- * @returns the associated {@link Amity.Stream} object
44137
+ * @param roomId The ID of the room to get token for
44138
+ * @returns The broadcaster data of the room including coHostToken, coHostUrl and direactStreamUrl
44028
44139
  *
44029
- * @category Stream API
44140
+ * @category Room API
44141
+ * @async
44030
44142
  */
44031
- getStream.locally = (streamId) => {
44143
+ const getBroadcasterData = async (roomId) => {
44032
44144
  const client = getActiveClient();
44033
- client.log('stream/getStream', streamId);
44034
- if (!client.cache)
44035
- return;
44036
- const cached = pullFromCache(['stream', 'get', streamId]);
44037
- if (!cached)
44038
- return;
44039
- return {
44040
- data: cached.data,
44041
- cachedAt: cached.cachedAt,
44042
- };
44145
+ client.log('room/getBroadcasterData', { roomId });
44146
+ const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
44147
+ return data;
44043
44148
  };
44149
+ /* end_public_function */
44044
44150
 
44045
- // import { unwrapPayload } from '~/core/transports'
44046
44151
  /* begin_public_function
44047
- id: stream.delete
44152
+ id: room.getRecordedUrl
44048
44153
  */
44049
44154
  /**
44050
44155
  * ```js
44051
- * import { deleteStream } from '@amityco/ts-sdk'
44052
- * const success = await deleteStream(streamId)
44156
+ * import { getRecordedUrl } from '@amityco/ts-sdk'
44157
+ * const recordedUrl = await getRecordedUrl('roomId')
44053
44158
  * ```
44054
44159
  *
44055
- * Deletes a {@link Amity.InternalStream}
44160
+ * Gets the recorded URL for a room
44056
44161
  *
44057
- * @param streamId The {@link Amity.InternalStream} ID to delete
44058
- * @return A success boolean if the {@link Amity.InternalStream} was deleted
44162
+ * @param roomId The ID of the room to get recorded URL for
44163
+ * @returns The recorded URL information
44059
44164
  *
44060
- * @category Stream API
44165
+ * @category Room API
44061
44166
  * @async
44062
44167
  */
44063
- const deleteStream = async (streamId) => {
44168
+ const getRecordedUrl = async (roomId) => {
44064
44169
  const client = getActiveClient();
44065
- client.log('stream/deleteStream', streamId);
44066
- const stream = await getStream(streamId);
44067
- // API-FIX: it returns { success: boolean } but seems it should be Amity.Response<{ success: boolean }
44068
- // API-FIX: swagger docs are wrong!
44069
- const { data } = await client.http.delete(`/api/v3/video-streaming/${streamId}`);
44070
- const { success } = data; // unwrapPayload(data)
44071
- const deleted = Object.assign(Object.assign({}, stream.data), { isDeleted: true });
44072
- upsertInCache(['stream', 'get', streamId], deleted);
44073
- return success;
44170
+ client.log('room/getRecordedUrl', { roomId });
44171
+ const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
44172
+ return data;
44074
44173
  };
44075
44174
  /* end_public_function */
44076
44175
 
44176
+ /* begin_public_function
44177
+ id: room.removeParticipant
44178
+ */
44077
44179
  /**
44078
44180
  * ```js
44079
- * import { disposeStream } from '@amityco/ts-sdk'
44080
- * const stream = await disposeStream(streamId)
44181
+ * import { removeParticipant } from '@amityco/ts-sdk'
44182
+ * const result = await removeParticipant('roomId', 'participantUserId')
44081
44183
  * ```
44082
44184
  *
44083
- * Dispose a {@link Amity.InternalStream}.
44084
- * Streaming status will be updated to "ended" and streaming url will be invalidated
44185
+ * Removes a participant from an {@link Amity.Room}
44085
44186
  *
44086
- * @param streamId The {@link Amity.InternalStream} ID to dispose
44087
- * @returns the associated {@link Amity.InternalStream} object
44187
+ * @param roomId The ID of the room to remove participant from
44188
+ * @param participantUserId The ID of the user to remove as participant
44189
+ * @returns Promise that resolves when the participant is removed
44088
44190
  *
44089
- * @category Stream API
44191
+ * @category Room API
44090
44192
  * @async
44091
44193
  */
44092
- const disposeStream = async (streamId) => {
44194
+ const removeParticipant = async (roomId, participantUserId) => {
44093
44195
  const client = getActiveClient();
44094
- client.log('stream/disposeStream', streamId);
44095
- const { data } = await client.http.delete(`/api/v3/video-streaming/${streamId}/streaming-url`);
44096
- const cachedAt = client.cache && Date.now();
44097
- if (client.cache)
44098
- ingestInCache(data, { cachedAt });
44099
- const { videoStreamings } = data;
44100
- return {
44101
- data: videoStreamings.find(stream => stream.streamId === streamId),
44102
- cachedAt,
44103
- };
44196
+ client.log('room/removeParticipant', { roomId, participantUserId });
44197
+ await client.http.delete(`/api/v1/rooms/${roomId}/participants/${participantUserId}`);
44198
+ fireEvent('local.room.participantRemoved', {
44199
+ rooms: [{ _id: roomId }],
44200
+ users: [{ _id: participantUserId }],
44201
+ });
44104
44202
  };
44105
44203
  /* end_public_function */
44106
44204
 
44107
44205
  /* begin_public_function
44108
- id: stream.update
44206
+ id: room.leave
44109
44207
  */
44110
44208
  /**
44111
- *
44112
44209
  * ```js
44113
- * import { StreamRepository } from '@amityco/ts-sdk'
44114
- * const updated = await StreamRepository.editStream(streamId, { title: 'foobar' })
44210
+ * import { leaveRoom } from '@amityco/ts-sdk'
44211
+ * const result = await leaveRoom('roomId')
44115
44212
  * ```
44116
44213
  *
44117
- * Updates an {@link Amity.Stream}
44214
+ * Leaves an {@link Amity.Room}
44118
44215
  *
44119
- * @param streamId The ID of the {@link Amity.Stream} to edit
44120
- * @param patch The patch data to apply
44121
- * @returns the updated {@link Amity.Stream} object
44216
+ * @param roomId The ID of the room to leave
44217
+ * @returns Promise that resolves when the user has left the room
44122
44218
  *
44123
- * @category Stream API
44219
+ * @category Room API
44124
44220
  * @async
44125
44221
  */
44126
- const editStream = async (streamId, patch) => {
44222
+ const leaveRoom = async (roomId) => {
44127
44223
  const client = getActiveClient();
44128
- client.log('stream/updateStream', streamId, patch);
44129
- const { data } = await client.http.put(`/api/v3/video-streaming/${streamId}`, patch);
44130
- const cachedAt = client.cache && Date.now();
44131
- if (client.cache)
44132
- ingestInCache(data, { cachedAt });
44133
- const { videoStreamings } = data;
44134
- return {
44135
- data: LinkedObject.stream(videoStreamings.find(stream => stream.streamId === streamId)),
44136
- cachedAt,
44137
- };
44224
+ client.log('room/leaveRoom', { roomId });
44225
+ await client.http.post(`/api/v1/rooms/${roomId}/leave`);
44226
+ fireEvent('local.room.left', {
44227
+ rooms: [{ _id: roomId }],
44228
+ });
44138
44229
  };
44139
44230
  /* end_public_function */
44140
44231
 
44141
44232
  /**
44142
44233
  * ```js
44143
- * import { onStreamStarted } from '@amityco/ts-sdk'
44144
- * const dispose = onStreamStarted(stream => {
44234
+ * import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
44235
+ * const dispose = onRoomStartBroadcasting(room => {
44145
44236
  * // ...
44146
44237
  * })
44147
44238
  * ```
44148
44239
  *
44149
- * Fired when a {@link Amity.InternalStream} has started airing
44240
+ * Fired when a {@link Amity.Room} has started broadcasting
44150
44241
  *
44151
44242
  * @param callback The function to call when the event was fired
44152
44243
  * @returns an {@link Amity.Unsubscriber} function to stop listening
44153
44244
  *
44154
- * @category Stream Events
44245
+ * @category Room Events
44155
44246
  */
44156
- const onStreamStarted = (callback) => {
44247
+ const onRoomStartBroadcasting = (callback) => {
44157
44248
  const client = getActiveClient();
44158
44249
  const filter = (payload) => {
44159
44250
  ingestInCache(payload);
44160
- callback(payload.videoStreamings[0]);
44251
+ callback(payload.rooms[0]);
44161
44252
  };
44162
- return createEventSubscriber(client, 'stream/onStreamStarted', 'video-streaming.didStart', filter);
44253
+ return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
44163
44254
  };
44164
44255
 
44165
44256
  /**
44166
44257
  * ```js
44167
- * import { onStreamStopped } from '@amityco/ts-sdk'
44168
- * const dispose = onStreamStopped(stream => {
44258
+ * import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
44259
+ * const dispose = onRoomWaitingReconnect(room => {
44169
44260
  * // ...
44170
44261
  * })
44171
44262
  * ```
44172
44263
  *
44173
- * Fired when a {@link Amity.InternalStream} has stopped airing
44264
+ * Fired when a {@link Amity.Room} is waiting for reconnection
44174
44265
  *
44175
44266
  * @param callback The function to call when the event was fired
44176
44267
  * @returns an {@link Amity.Unsubscriber} function to stop listening
44177
44268
  *
44178
- * @category Stream Events
44269
+ * @category Room Events
44179
44270
  */
44180
- const onStreamStopped = (callback) => {
44271
+ const onRoomWaitingReconnect = (callback) => {
44181
44272
  const client = getActiveClient();
44182
44273
  const filter = (payload) => {
44183
44274
  ingestInCache(payload);
44184
- callback(payload.videoStreamings[0]);
44275
+ callback(payload.rooms[0]);
44185
44276
  };
44186
- return createEventSubscriber(client, 'stream/onStreamStropped', 'video-streaming.didStop', filter);
44277
+ return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
44187
44278
  };
44188
44279
 
44189
44280
  /**
44190
44281
  * ```js
44191
- * import { onStreamRecorded } from '@amityco/ts-sdk'
44192
- * const dispose = onStreamRecorded(stream => {
44282
+ * import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
44283
+ * const dispose = onRoomEndBroadcasting(room => {
44193
44284
  * // ...
44194
44285
  * })
44195
44286
  * ```
44196
44287
  *
44197
- * Fired when the recordings of a {@link Amity.InternalStream} are available
44288
+ * Fired when a {@link Amity.Room} has ended broadcasting
44198
44289
  *
44199
44290
  * @param callback The function to call when the event was fired
44200
44291
  * @returns an {@link Amity.Unsubscriber} function to stop listening
44201
44292
  *
44202
- * @category Stream Events
44293
+ * @category Room Events
44203
44294
  */
44204
- const onStreamRecorded = (callback) => {
44295
+ const onRoomEndBroadcasting = (callback) => {
44205
44296
  const client = getActiveClient();
44206
44297
  const filter = (payload) => {
44207
44298
  ingestInCache(payload);
44208
- callback(payload.videoStreamings[0]);
44299
+ callback(payload.rooms[0]);
44209
44300
  };
44210
- return createEventSubscriber(client, 'stream/onStreamRecorded', 'video-streaming.didRecord', filter);
44301
+ return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
44211
44302
  };
44212
44303
 
44213
44304
  /**
44214
44305
  * ```js
44215
- * import { onStreamFlagged } from '@amityco/ts-sdk'
44216
- * const dispose = onStreamFlagged(stream => {
44306
+ * import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
44307
+ * const dispose = onRoomRecordedAvailable(room => {
44217
44308
  * // ...
44218
44309
  * })
44219
44310
  * ```
44220
44311
  *
44221
- * Fired when a {@link Amity.InternalStream} has started airing
44312
+ * Fired when a {@link Amity.Room} recorded content becomes available
44222
44313
  *
44223
44314
  * @param callback The function to call when the event was fired
44224
44315
  * @returns an {@link Amity.Unsubscriber} function to stop listening
44225
44316
  *
44226
- * @category Stream Events
44317
+ * @category Room Events
44227
44318
  */
44228
- const onStreamFlagged = (callback) => {
44319
+ const onRoomRecordedAvailable = (callback) => {
44229
44320
  const client = getActiveClient();
44230
44321
  const filter = (payload) => {
44231
44322
  ingestInCache(payload);
44232
- callback(payload.videoStreamings[0]);
44323
+ callback(payload.rooms[0]);
44233
44324
  };
44234
- return createEventSubscriber(client, 'stream/onStreamFlagged', 'video-streaming.didFlag', filter);
44325
+ return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
44235
44326
  };
44236
44327
 
44237
44328
  /**
44238
44329
  * ```js
44239
- * import { onStreamTerminated } from '@amityco/ts-sdk'
44240
- * const dispose = onStreamTerminated(stream => {
44330
+ * import { onRoomParticipantInviting } from '@amityco/ts-sdk'
44331
+ * const dispose = onRoomParticipantInviting(room => {
44241
44332
  * // ...
44242
44333
  * })
44243
44334
  * ```
44244
44335
  *
44245
- * Fired when a {@link Amity.InternalStream} has started airing
44336
+ * Fired when a participant is being invited to a {@link Amity.Room}
44246
44337
  *
44247
44338
  * @param callback The function to call when the event was fired
44248
44339
  * @returns an {@link Amity.Unsubscriber} function to stop listening
44249
44340
  *
44250
- * @category Stream Events
44341
+ * @category Room Events
44251
44342
  */
44252
- const onStreamTerminated = (callback) => {
44343
+ const onRoomCoHostInvited = (callback) => {
44253
44344
  const client = getActiveClient();
44254
44345
  const filter = (payload) => {
44255
- ingestInCache(payload);
44256
- callback(payload.videoStreamings[0]);
44346
+ const data = prepareMyInvitationsPayload(payload);
44347
+ ingestInCache(data);
44348
+ callback(data.invitations);
44349
+ };
44350
+ return createEventSubscriber(client, 'room/onRoomCoHostInvited', 'room.didCohostInvite', filter);
44351
+ };
44352
+
44353
+ const getRoomById = async (roomId) => {
44354
+ const client = getActiveClient();
44355
+ client.log('room/getRoomById', roomId);
44356
+ // Check if room is in tombstone
44357
+ isInTombstone('room', roomId);
44358
+ let data;
44359
+ try {
44360
+ const response = await client.http.get(`/api/v1/rooms/${roomId}`);
44361
+ data = response.data;
44362
+ }
44363
+ catch (error) {
44364
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
44365
+ pushToTombstone('room', roomId);
44366
+ }
44367
+ throw error;
44368
+ }
44369
+ const cachedAt = client.cache && Date.now();
44370
+ if (client.cache) {
44371
+ ingestInCache(data, { cachedAt });
44372
+ }
44373
+ return {
44374
+ data: data.rooms[0],
44375
+ cachedAt,
44376
+ };
44377
+ };
44378
+ getRoomById.locally = (roomId) => {
44379
+ const client = getActiveClient();
44380
+ client.log('room/getRoomById.locally', roomId);
44381
+ // Check if room is in tombstone
44382
+ isInTombstone('room', roomId);
44383
+ const cachedAt = client.cache && Date.now();
44384
+ const roomCache = pullFromCache(['room', 'get', roomId]);
44385
+ if (!roomCache)
44386
+ return;
44387
+ return {
44388
+ data: roomCache.data,
44389
+ cachedAt,
44257
44390
  };
44258
- return createEventSubscriber(client, 'stream/onStreamTerminated', 'video-streaming.didTerminate', filter);
44259
44391
  };
44260
44392
 
44261
44393
  /**
44262
44394
  * ```js
44263
- * import { onStreamViewerUnbanned } from '@amityco/ts-sdk'
44264
- * const dispose = onStreamViewerBanned(stream => {
44395
+ * import { onRoomCoHostInviteAccepted } from '@amityco/ts-sdk'
44396
+ * const dispose = onRoomCoHostInviteAccepted(room => {
44265
44397
  * // ...
44266
44398
  * })
44267
44399
  * ```
44268
44400
  *
44269
- * Fired when a user in channel linked to stream has been unbanned
44401
+ * Fired when a co-host invitation is accepted for a {@link Amity.Room}
44270
44402
  *
44271
44403
  * @param callback The function to call when the event was fired
44272
44404
  * @returns an {@link Amity.Unsubscriber} function to stop listening
44273
44405
  *
44274
- * @category Stream Events
44406
+ * @category Room Events
44275
44407
  */
44276
- const onStreamViewerUnbanned = (callback) => {
44408
+ const onRoomCoHostInviteAccepted = (callback) => {
44277
44409
  const client = getActiveClient();
44278
- const filter = async (payloads) => {
44410
+ const filter = async (payload) => {
44279
44411
  var _a;
44280
- // Get new stream object to restore stream watcherUrl in cache
44281
- const { list } = payloads;
44282
- await Promise.all(list.map(({ streamId }) => getStream(streamId)));
44283
- const stream = (_a = pullFromCache(['stream', 'get', list[0].streamId])) === null || _a === void 0 ? void 0 : _a.data;
44284
- if (!stream)
44285
- return;
44286
- callback(stream);
44412
+ const data = prepareMyInvitationsPayload(payload);
44413
+ await getRoomById((_a = data.invitations) === null || _a === void 0 ? void 0 : _a[0].targetId);
44414
+ ingestInCache(data);
44415
+ callback(data.invitations[0]);
44287
44416
  };
44288
- return createEventSubscriber(client, 'stream/onStreamViewerDidUnban', 'video-streaming.viewerDidUnban', filter);
44417
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCohostInviteAccept', filter);
44289
44418
  };
44290
44419
 
44291
- /* eslint-disable no-use-before-define */
44292
- /* begin_public_function
44293
- id: stream.get
44294
- */
44295
44420
  /**
44296
44421
  * ```js
44297
- * import { StreamRepository } from '@amityco/ts-sdk'
44298
- * const unsub = StreamRepository.getStreamById('foobar')
44299
- * unsub()
44422
+ * import { onRoomCoHostInviteRejected } from '@amityco/ts-sdk'
44423
+ * const dispose = onRoomCoHostInviteRejected(room => {
44424
+ * // ...
44425
+ * })
44300
44426
  * ```
44301
44427
  *
44302
- * Fetches a {@link Amity.Stream} object
44428
+ * Fired when a co-host invitation is rejected for a {@link Amity.Room}
44303
44429
  *
44304
- * @param streamId the ID of the {@link Amity.Stream} to get
44305
- * @param callback
44306
- * @returns the associated {@link Amity.Stream} object
44430
+ * @param callback The function to call when the event was fired
44431
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44307
44432
  *
44308
- * @category Stream Live Object
44433
+ * @category Room Events
44309
44434
  */
44310
- const getStreamById = (streamId, callback) => {
44311
- const reactor = (snapshot) => {
44312
- const { data } = snapshot;
44313
- callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.stream(snapshot.data) : data }));
44435
+ const onRoomCoHostInviteRejected = (callback) => {
44436
+ const client = getActiveClient();
44437
+ const filter = (payload) => {
44438
+ const data = prepareMyInvitationsPayload(payload);
44439
+ ingestInCache(data);
44440
+ callback(data.invitations);
44314
44441
  };
44315
- return liveObject(streamId, reactor, 'streamId', getStream, [
44316
- onStreamRecorded,
44317
- onStreamStarted,
44318
- onStreamStopped,
44319
- onStreamFlagged,
44320
- onStreamTerminated,
44321
- onStreamViewerBanned,
44322
- ]);
44442
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCohostInviteReject', filter);
44323
44443
  };
44324
- /* end_public_function */
44444
+
44325
44445
  /**
44326
44446
  * ```js
44327
- * import { StreamRepository } from '@amityco/ts-sdk'
44328
- * const stream = StreamRepository.getStreamById.locally('foobar')
44447
+ * import { onRoomCoHostInviteCanceled } from '@amityco/ts-sdk'
44448
+ * const dispose = onRoomCoHostInviteCanceled(room => {
44449
+ * // ...
44450
+ * })
44329
44451
  * ```
44330
44452
  *
44331
- * Fetches a {@link Amity.Stream} live object
44453
+ * Fired when a co-host invitation is canceled for a {@link Amity.Room}
44332
44454
  *
44333
- * @param streamId the ID of the {@link Amity.Stream} to fetch
44334
- * @returns the associated {@link Amity.Stream} live object
44455
+ * @param callback The function to call when the event was fired
44456
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44335
44457
  *
44336
- * @category Stream API
44458
+ * @category Room Events
44337
44459
  */
44338
- getStreamById.locally = (streamId) => {
44460
+ const onRoomCoHostInviteCanceled = (callback) => {
44339
44461
  const client = getActiveClient();
44340
- client.log('stream/getStreamById', streamId);
44341
- if (!client.cache)
44342
- return;
44343
- const cached = pullFromCache(['stream', 'get', streamId]);
44344
- if (!cached)
44345
- return;
44346
- return {
44347
- data: LinkedObject.stream(cached.data),
44348
- cachedAt: cached.cachedAt,
44349
- };
44350
- };
44351
-
44352
- class GetStreamsPageController extends PaginationController {
44353
- async getRequest(queryParams, token) {
44354
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
44355
- const options = token ? { token } : { limit };
44356
- const { data: queryResponse } = await this.http.get(`/api/v3/video-streaming`, {
44357
- params: Object.assign(Object.assign({}, params), { options }),
44358
- });
44359
- return Object.assign(Object.assign({}, queryResponse.results), { paging: queryResponse.paging });
44360
- }
44361
- }
44362
-
44363
- class GetStreamsQueryStreamController extends QueryStreamController {
44364
- constructor(query, cacheKey, notifyChange, paginationController) {
44365
- super(query, cacheKey);
44366
- this.notifyChange = notifyChange;
44367
- this.paginationController = paginationController;
44368
- }
44369
- // eslint-disable-next-line class-methods-use-this
44370
- saveToMainDB(response) {
44371
- const client = getActiveClient();
44372
- const cachedAt = client.cache && Date.now();
44373
- if (client.cache) {
44374
- ingestInCache(response, { cachedAt });
44375
- }
44376
- }
44377
- appendToQueryStream(response, direction, refresh = false) {
44378
- var _a, _b;
44379
- if (refresh) {
44380
- pushToCache(this.cacheKey, {
44381
- data: response.videoStreamings.map(getResolver('stream')),
44382
- query: this.query,
44383
- });
44384
- }
44385
- else {
44386
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44387
- const messages = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
44388
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === 'next'
44389
- ? [...new Set([...messages, ...response.videoStreamings.map(getResolver('stream'))])]
44390
- : [...new Set([...response.videoStreamings.map(getResolver('stream')), ...messages])] }));
44391
- }
44392
- }
44393
- reactor(action) {
44394
- return (payload) => {
44395
- var _a;
44396
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44397
- if (!collection)
44398
- return;
44399
- collection.data = [...new Set([payload.streamId, ...collection.data])];
44400
- pushToCache(this.cacheKey, collection);
44401
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
44402
- };
44403
- }
44404
- subscribeRTE(createSubscriber) {
44405
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
44406
- }
44407
- }
44408
-
44409
- class GetStreamsLiveCollectionController extends LiveCollectionController {
44410
- constructor(query, callback) {
44411
- const queryStreamId = hash(query);
44412
- const cacheKey = ['streams', 'collection', queryStreamId];
44413
- const paginationController = new GetStreamsPageController(query);
44414
- super(paginationController, queryStreamId, cacheKey, callback);
44415
- this.applyFilter = (data) => {
44416
- let streams = filterByPropEquality(data, 'isDeleted', this.query.isDeleted);
44417
- streams = streams.sort(this.query.sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
44418
- return streams;
44419
- };
44420
- this.query = query;
44421
- this.queryStreamController = new GetStreamsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), paginationController);
44422
- this.paginationController = paginationController;
44423
- this.callback = callback.bind(this);
44424
- this.loadPage({ initial: true });
44425
- }
44426
- notifyChange({ origin, loading, error }) {
44427
- var _a;
44428
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44429
- if (!collection)
44430
- return;
44431
- let data = collection.data
44432
- .map(streamId => pullFromCache(['stream', 'get', streamId]))
44433
- .filter(Boolean)
44434
- .map(stream => LinkedObject.stream(stream.data));
44435
- if (!this.shouldNotify(data) && origin === 'event')
44436
- return;
44437
- data = this.applyFilter(data);
44438
- this.callback({
44439
- onNextPage: () => this.loadPage({ initial: false, direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
44440
- data,
44441
- hasNextPage: !!this.paginationController.getNextToken(),
44442
- loading,
44443
- error,
44444
- });
44445
- }
44446
- startSubscription() {
44447
- return this.queryStreamController.subscribeRTE([
44448
- { fn: onStreamRecorded, action: 'onStreamRecorded' },
44449
- { fn: onStreamStarted, action: 'onStreamStarted' },
44450
- { fn: onStreamStopped, action: 'onStreamStopped' },
44451
- { fn: onStreamFlagged, action: 'onStreamFlagged' },
44452
- { fn: onStreamTerminated, action: 'onStreamTerminated' },
44453
- { fn: onStreamViewerBanned, action: 'onStreamViewerBanned' },
44454
- { fn: onStreamViewerUnbanned, action: 'onStreamViewerUnbanned' },
44455
- ]);
44456
- }
44457
- setup() {
44458
- var _a;
44459
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44460
- if (!collection) {
44461
- pushToCache(this.cacheKey, {
44462
- data: [],
44463
- params: {},
44464
- });
44465
- }
44466
- }
44467
- persistModel(response) {
44468
- this.queryStreamController.saveToMainDB(response);
44469
- }
44470
- persistQueryStream({ response, direction, refresh, }) {
44471
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
44472
- }
44473
- }
44474
-
44475
- const getStreams = (params, callback, config) => {
44476
- const { log, cache, userId } = getActiveClient();
44477
- if (!cache) {
44478
- console.log(ENABLE_CACHE_MESSAGE);
44479
- }
44480
- const timestamp = Date.now();
44481
- log(`getStreams(tmpid: ${timestamp}) > listen`);
44482
- const liveCollection = new GetStreamsLiveCollectionController(params, callback);
44483
- const disposers = liveCollection.startSubscription();
44484
- const cacheKey = liveCollection.getCacheKey();
44485
- disposers.push(() => {
44486
- dropFromCache(cacheKey);
44487
- });
44488
- return () => {
44489
- log(`getStreams(tmpid: ${timestamp}) > dispose`);
44490
- disposers.forEach(fn => fn());
44462
+ const filter = (payload) => {
44463
+ const data = prepareMyInvitationsPayload(payload);
44464
+ ingestInCache(data);
44465
+ callback(data.invitations);
44491
44466
  };
44467
+ return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCohostInviteCancel', filter);
44492
44468
  };
44493
44469
 
44494
- var index$a = /*#__PURE__*/Object.freeze({
44495
- __proto__: null,
44496
- createStream: createStream,
44497
- updateStream: updateStream,
44498
- deleteStream: deleteStream,
44499
- disposeStream: disposeStream,
44500
- editStream: editStream,
44501
- onStreamStarted: onStreamStarted,
44502
- onStreamStopped: onStreamStopped,
44503
- onStreamRecorded: onStreamRecorded,
44504
- onStreamFlagged: onStreamFlagged,
44505
- onStreamTerminated: onStreamTerminated,
44506
- onStreamViewerBanned: onStreamViewerBanned,
44507
- onStreamViewerUnbanned: onStreamViewerUnbanned,
44508
- getStreamById: getStreamById,
44509
- getStreams: getStreams
44510
- });
44511
-
44512
- /* begin_public_function
44513
- id: room.create
44514
- */
44515
44470
  /**
44516
44471
  * ```js
44517
- * import { createRoom } from '@amityco/ts-sdk'
44518
- * const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
44472
+ * import { onRoomParticipantJoined } from '@amityco/ts-sdk'
44473
+ * const dispose = onRoomParticipantJoined(room => {
44474
+ * // ...
44475
+ * })
44519
44476
  * ```
44520
44477
  *
44521
- * Creates an {@link Amity.Room}
44478
+ * Fired when a participant has joined a {@link Amity.Room}
44522
44479
  *
44523
- * @param bundle The data necessary to create a new {@link Amity.Room}
44524
- * @returns The newly created {@link Amity.Room}
44480
+ * @param callback The function to call when the event was fired
44481
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44525
44482
  *
44526
- * @category Room API
44527
- * @async
44483
+ * @category Room Events
44528
44484
  */
44529
- const createRoom = async (bundle) => {
44485
+ const onRoomParticipantJoined = (callback) => {
44530
44486
  const client = getActiveClient();
44531
- client.log('room/createRoom', bundle);
44532
- const { data } = await client.http.post('/api/v1/rooms', bundle);
44533
- fireEvent('local.room.created', data);
44534
- const cachedAt = client.cache && Date.now();
44535
- // TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
44536
- if (client.cache)
44537
- ingestInCache(data, { cachedAt });
44538
- const { rooms } = data;
44539
- return {
44540
- data: roomLinkedObject(rooms[0]),
44541
- cachedAt,
44487
+ const filter = (payload) => {
44488
+ ingestInCache(payload);
44489
+ callback(payload.rooms[0]);
44542
44490
  };
44491
+ return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
44543
44492
  };
44544
- /* end_public_function */
44545
44493
 
44546
- /* begin_public_function
44547
- id: room.update
44548
- */
44549
44494
  /**
44550
44495
  * ```js
44551
- * import { updateRoom } from '@amityco/ts-sdk'
44552
- * const updated = await updateRoom('roomId', { title: 'updated title' })
44496
+ * import { onRoomParticipantLeft } from '@amityco/ts-sdk'
44497
+ * const dispose = onRoomParticipantLeft(room => {
44498
+ * // ...
44499
+ * })
44553
44500
  * ```
44554
44501
  *
44555
- * Updates an {@link Amity.InternalRoom}
44502
+ * Fired when a participant has left a {@link Amity.Room}
44556
44503
  *
44557
- * @param roomId The ID of the room to update
44558
- * @param bundle The data to update the room with
44559
- * @returns The updated {@link Amity.InternalRoom}
44504
+ * @param callback The function to call when the event was fired
44505
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44560
44506
  *
44561
- * @category Room API
44562
- * @async
44507
+ * @category Room Events
44563
44508
  */
44564
- const updateRoom = async (roomId, bundle) => {
44509
+ const onRoomParticipantLeft = (callback) => {
44565
44510
  const client = getActiveClient();
44566
- client.log('room/updateRoom', { roomId, bundle });
44567
- const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
44568
- fireEvent('local.room.updated', data);
44569
- const cachedAt = client.cache && Date.now();
44570
- if (client.cache)
44571
- ingestInCache(data, { cachedAt });
44572
- const { rooms } = data;
44573
- return {
44574
- data: roomLinkedObject(rooms[0]),
44575
- cachedAt,
44511
+ const filter = (payload) => {
44512
+ ingestInCache(payload);
44513
+ callback(payload.rooms[0]);
44576
44514
  };
44515
+ return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
44577
44516
  };
44578
- /* end_public_function */
44579
-
44580
- /* begin_public_function
44581
- id: room.delete
44582
- */
44583
- /**
44584
- * ```js
44585
- * import { deleteRoom } from '@amityco/ts-sdk'
44586
- * const result = await deleteRoom('roomId')
44587
- * ```
44588
- *
44589
- * Deletes an {@link Amity.Room}
44590
- *
44591
- * @param roomId The ID of the room to delete
44592
- * @returns Promise that resolves when the room is deleted
44593
- *
44594
- * @category Room API
44595
- * @async
44596
- */
44597
- const deleteRoom = async (roomId) => {
44598
- const client = getActiveClient();
44599
- client.log('room/deleteRoom', { roomId });
44600
- await client.http.delete(`/api/v1/rooms/${roomId}`);
44601
- fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
44602
- };
44603
- /* end_public_function */
44604
44517
 
44605
- /* begin_public_function
44606
- id: room.stop
44607
- */
44608
44518
  /**
44609
44519
  * ```js
44610
- * import { stopRoom } from '@amityco/ts-sdk'
44611
- * const result = await stopRoom('roomId')
44520
+ * import { onRoomTerminated } from '@amityco/ts-sdk'
44521
+ * const dispose = onRoomTerminated(room => {
44522
+ * // ...
44523
+ * })
44612
44524
  * ```
44613
44525
  *
44614
- * Stops a room's broadcasting
44526
+ * Fired when a {@link Amity.Room} has started broadcasting
44615
44527
  *
44616
- * @param roomId The ID of the room to stop
44617
- * @returns The updated room data
44528
+ * @param callback The function to call when the event was fired
44529
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44618
44530
  *
44619
- * @category Room API
44620
- * @async
44531
+ * @category Room Events
44621
44532
  */
44622
- const stopRoom = async (roomId) => {
44533
+ const onRoomTerminated = (callback) => {
44623
44534
  const client = getActiveClient();
44624
- client.log('room/stopRoom', { roomId });
44625
- const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
44626
- fireEvent('local.room.stopped', data);
44627
- const cachedAt = client.cache && Date.now();
44628
- if (client.cache)
44629
- ingestInCache(data, { cachedAt });
44630
- const { rooms } = data;
44631
- return {
44632
- data: rooms[0],
44633
- cachedAt,
44535
+ const filter = (payload) => {
44536
+ ingestInCache(payload);
44537
+ callback(payload.rooms[0]);
44634
44538
  };
44539
+ return createEventSubscriber(client, 'room/onRoomTerminated', 'room.terminated', filter);
44635
44540
  };
44636
- /* end_public_function */
44637
-
44638
- /* begin_public_function
44639
- id: room.getBroadcasterData
44640
- */
44641
- /**
44642
- * ```js
44643
- * import { getBroadcasterData } from '@amityco/ts-sdk'
44644
- * const token = await getBroadcasterData('roomId')
44645
- * ```
44646
- *
44647
- * Gets broadcaster data for a room
44648
- *
44649
- * @param roomId The ID of the room to get token for
44650
- * @returns The broadcaster data of the room including coHostToken, coHostUrl and direactStreamUrl
44651
- *
44652
- * @category Room API
44653
- * @async
44654
- */
44655
- const getBroadcasterData = async (roomId) => {
44656
- const client = getActiveClient();
44657
- client.log('room/getBroadcasterData', { roomId });
44658
- const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
44659
- return data;
44660
- };
44661
- /* end_public_function */
44662
-
44663
- /* begin_public_function
44664
- id: room.getRecordedUrl
44665
- */
44666
- /**
44667
- * ```js
44668
- * import { getRecordedUrl } from '@amityco/ts-sdk'
44669
- * const recordedUrl = await getRecordedUrl('roomId')
44670
- * ```
44671
- *
44672
- * Gets the recorded URL for a room
44673
- *
44674
- * @param roomId The ID of the room to get recorded URL for
44675
- * @returns The recorded URL information
44676
- *
44677
- * @category Room API
44678
- * @async
44679
- */
44680
- const getRecordedUrl = async (roomId) => {
44681
- const client = getActiveClient();
44682
- client.log('room/getRecordedUrl', { roomId });
44683
- const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
44684
- return data;
44685
- };
44686
- /* end_public_function */
44687
44541
 
44688
- /* begin_public_function
44689
- id: room.removeParticipant
44690
- */
44691
44542
  /**
44692
44543
  * ```js
44693
- * import { removeParticipant } from '@amityco/ts-sdk'
44694
- * const result = await removeParticipant('roomId', 'participantUserId')
44544
+ * import { onRoomCreated } from '@amityco/ts-sdk'
44545
+ * const dispose = onRoomCreated(room => {
44546
+ * // ...
44547
+ * })
44695
44548
  * ```
44696
44549
  *
44697
- * Removes a participant from an {@link Amity.Room}
44550
+ * Fired when a {@link Amity.Room} has been created locally
44698
44551
  *
44699
- * @param roomId The ID of the room to remove participant from
44700
- * @param participantUserId The ID of the user to remove as participant
44701
- * @returns Promise that resolves when the participant is removed
44552
+ * @param callback The function to call when the event was fired
44553
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44702
44554
  *
44703
- * @category Room API
44704
- * @async
44555
+ * @category Room Events
44705
44556
  */
44706
- const removeParticipant = async (roomId, participantUserId) => {
44557
+ const onRoomCreated = (callback) => {
44707
44558
  const client = getActiveClient();
44708
- client.log('room/removeParticipant', { roomId, participantUserId });
44709
- await client.http.delete(`/api/v1/rooms/${roomId}/participants/${participantUserId}`);
44710
- fireEvent('local.room.participantRemoved', {
44711
- rooms: [{ _id: roomId }],
44712
- users: [{ _id: participantUserId }],
44713
- });
44559
+ const filter = (payload) => {
44560
+ ingestInCache(payload);
44561
+ callback(payload.rooms[0]);
44562
+ };
44563
+ return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
44714
44564
  };
44715
- /* end_public_function */
44716
44565
 
44717
- /* begin_public_function
44718
- id: room.leave
44719
- */
44720
44566
  /**
44721
44567
  * ```js
44722
- * import { leaveRoom } from '@amityco/ts-sdk'
44723
- * const result = await leaveRoom('roomId')
44568
+ * import { onRoomUpdated } from '@amityco/ts-sdk'
44569
+ * const dispose = onRoomUpdated(room => {
44570
+ * // ...
44571
+ * })
44724
44572
  * ```
44725
44573
  *
44726
- * Leaves an {@link Amity.Room}
44574
+ * Fired when a {@link Amity.Room} has been updated locally
44727
44575
  *
44728
- * @param roomId The ID of the room to leave
44729
- * @returns Promise that resolves when the user has left the room
44576
+ * @param callback The function to call when the event was fired
44577
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
44730
44578
  *
44731
- * @category Room API
44732
- * @async
44579
+ * @category Room Events
44733
44580
  */
44734
- const leaveRoom = async (roomId) => {
44581
+ const onRoomUpdated = (callback) => {
44735
44582
  const client = getActiveClient();
44736
- client.log('room/leaveRoom', { roomId });
44737
- await client.http.post(`/api/v1/rooms/${roomId}/leave`);
44738
- fireEvent('local.room.left', {
44739
- rooms: [{ _id: roomId }],
44740
- });
44583
+ const filter = (payload) => {
44584
+ ingestInCache(payload);
44585
+ callback(payload.rooms[0]);
44586
+ };
44587
+ return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
44741
44588
  };
44742
- /* end_public_function */
44743
44589
 
44744
44590
  /**
44745
44591
  * ```js
44746
- * import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
44747
- * const dispose = onRoomStartBroadcasting(room => {
44592
+ * import { onRoomDeleted } from '@amityco/ts-sdk'
44593
+ * const dispose = onRoomDeleted(room => {
44748
44594
  * // ...
44749
44595
  * })
44750
44596
  * ```
44751
44597
  *
44752
- * Fired when a {@link Amity.Room} has started broadcasting
44598
+ * Fired when a {@link Amity.Room} has been deleted locally
44753
44599
  *
44754
44600
  * @param callback The function to call when the event was fired
44755
44601
  * @returns an {@link Amity.Unsubscriber} function to stop listening
44756
44602
  *
44757
44603
  * @category Room Events
44758
44604
  */
44759
- const onRoomStartBroadcasting = (callback) => {
44605
+ const onRoomDeleted = (callback) => {
44760
44606
  const client = getActiveClient();
44761
44607
  const filter = (payload) => {
44762
44608
  ingestInCache(payload);
44763
44609
  callback(payload.rooms[0]);
44764
44610
  };
44765
- return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
44611
+ return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
44766
44612
  };
44767
44613
 
44768
44614
  /**
44769
44615
  * ```js
44770
- * import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
44771
- * const dispose = onRoomWaitingReconnect(room => {
44616
+ * import { onRoomStopped } from '@amityco/ts-sdk'
44617
+ * const dispose = onRoomStopped(room => {
44772
44618
  * // ...
44773
44619
  * })
44774
44620
  * ```
44775
44621
  *
44776
- * Fired when a {@link Amity.Room} is waiting for reconnection
44622
+ * Fired when a {@link Amity.Room} has been stopped locally
44777
44623
  *
44778
44624
  * @param callback The function to call when the event was fired
44779
44625
  * @returns an {@link Amity.Unsubscriber} function to stop listening
44780
44626
  *
44781
44627
  * @category Room Events
44782
44628
  */
44783
- const onRoomWaitingReconnect = (callback) => {
44629
+ const onRoomStopped = (callback) => {
44784
44630
  const client = getActiveClient();
44785
44631
  const filter = (payload) => {
44786
44632
  ingestInCache(payload);
44787
44633
  callback(payload.rooms[0]);
44788
44634
  };
44789
- return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
44635
+ return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
44790
44636
  };
44791
44637
 
44792
44638
  /**
44793
44639
  * ```js
44794
- * import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
44795
- * const dispose = onRoomEndBroadcasting(room => {
44640
+ * import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
44641
+ * const dispose = onRoomParticipantRemoved(room => {
44796
44642
  * // ...
44797
44643
  * })
44798
44644
  * ```
44799
44645
  *
44800
- * Fired when a {@link Amity.Room} has ended broadcasting
44646
+ * Fired when a participant has been removed from a {@link Amity.Room} locally
44801
44647
  *
44802
44648
  * @param callback The function to call when the event was fired
44803
44649
  * @returns an {@link Amity.Unsubscriber} function to stop listening
44804
44650
  *
44805
44651
  * @category Room Events
44806
44652
  */
44807
- const onRoomEndBroadcasting = (callback) => {
44653
+ const onRoomParticipantRemoved = (callback) => {
44808
44654
  const client = getActiveClient();
44809
44655
  const filter = (payload) => {
44810
44656
  ingestInCache(payload);
44811
44657
  callback(payload.rooms[0]);
44812
44658
  };
44813
- return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
44659
+ return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'room.participantRemoved', filter);
44814
44660
  };
44815
44661
 
44816
44662
  /**
44817
44663
  * ```js
44818
- * import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
44819
- * const dispose = onRoomRecordedAvailable(room => {
44664
+ * import { onRoomLeft } from '@amityco/ts-sdk'
44665
+ * const dispose = onRoomLeft(room => {
44820
44666
  * // ...
44821
44667
  * })
44822
44668
  * ```
44823
44669
  *
44824
- * Fired when a {@link Amity.Room} recorded content becomes available
44670
+ * Fired when a user has left a {@link Amity.Room} locally
44825
44671
  *
44826
44672
  * @param callback The function to call when the event was fired
44827
44673
  * @returns an {@link Amity.Unsubscriber} function to stop listening
44828
44674
  *
44829
44675
  * @category Room Events
44830
44676
  */
44831
- const onRoomRecordedAvailable = (callback) => {
44677
+ const onRoomLeft = (callback) => {
44832
44678
  const client = getActiveClient();
44833
44679
  const filter = (payload) => {
44834
44680
  ingestInCache(payload);
44835
44681
  callback(payload.rooms[0]);
44836
44682
  };
44837
- return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
44683
+ return createEventSubscriber(client, 'room/onRoomLeft', 'local.room.left', filter);
44838
44684
  };
44839
44685
 
44840
44686
  /**
44841
44687
  * ```js
44842
- * import { onRoomParticipantInviting } from '@amityco/ts-sdk'
44843
- * const dispose = onRoomParticipantInviting(room => {
44688
+ * import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
44689
+ * const dispose = onRoomParticipantRemoved(room => {
44844
44690
  * // ...
44845
44691
  * })
44846
44692
  * ```
44847
44693
  *
44848
- * Fired when a participant is being invited to a {@link Amity.Room}
44694
+ * Fired when a participant has been removed from a {@link Amity.Room} locally
44849
44695
  *
44850
44696
  * @param callback The function to call when the event was fired
44851
44697
  * @returns an {@link Amity.Unsubscriber} function to stop listening
44852
44698
  *
44853
44699
  * @category Room Events
44854
44700
  */
44855
- const onRoomCoHostInvited = (callback) => {
44701
+ const onRoomParticipantRemovedLocal = (callback) => {
44856
44702
  const client = getActiveClient();
44857
44703
  const filter = (payload) => {
44858
- const data = prepareMyInvitationsPayload(payload);
44859
- ingestInCache(data);
44860
- callback(data.invitations);
44861
- };
44862
- return createEventSubscriber(client, 'room/onRoomCoHostInvited', 'room.didCohostInvite', filter);
44863
- };
44864
-
44865
- const getRoomById = async (roomId) => {
44866
- const client = getActiveClient();
44867
- client.log('room/getRoomById', roomId);
44868
- // Check if room is in tombstone
44869
- isInTombstone('room', roomId);
44870
- let data;
44871
- try {
44872
- const response = await client.http.get(`/api/v1/rooms/${roomId}`);
44873
- data = response.data;
44874
- }
44875
- catch (error) {
44876
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
44877
- pushToTombstone('room', roomId);
44878
- }
44879
- throw error;
44880
- }
44881
- const cachedAt = client.cache && Date.now();
44882
- if (client.cache) {
44883
- ingestInCache(data, { cachedAt });
44884
- }
44885
- return {
44886
- data: data.rooms[0],
44887
- cachedAt,
44888
- };
44889
- };
44890
- getRoomById.locally = (roomId) => {
44891
- const client = getActiveClient();
44892
- client.log('room/getRoomById.locally', roomId);
44893
- // Check if room is in tombstone
44894
- isInTombstone('room', roomId);
44895
- const cachedAt = client.cache && Date.now();
44896
- const roomCache = pullFromCache(['room', 'get', roomId]);
44897
- if (!roomCache)
44898
- return;
44899
- return {
44900
- data: roomCache.data,
44901
- cachedAt,
44704
+ ingestInCache(payload);
44705
+ callback(payload.rooms[0]);
44902
44706
  };
44707
+ return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
44903
44708
  };
44904
44709
 
44710
+ const getRoom = (roomId, callback) => {
44711
+ // TODO: add callbackDataSelector if there are linked object fields
44712
+ return liveObject(roomId, callback, '_id', getRoomById, [
44713
+ onRoomEndBroadcasting,
44714
+ onRoomStartBroadcasting,
44715
+ onRoomWaitingReconnect,
44716
+ onRoomTerminated,
44717
+ onRoomRecordedAvailable,
44718
+ onRoomParticipantJoined,
44719
+ onRoomParticipantLeft,
44720
+ onRoomParticipantRemoved,
44721
+ onRoomParticipantRemovedLocal,
44722
+ convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
44723
+ ], {
44724
+ callbackDataSelector: (data) => {
44725
+ if (!data)
44726
+ return data;
44727
+ return LinkedObject.room(data);
44728
+ },
44729
+ });
44730
+ };
44731
+
44732
+ class RoomPaginationController extends PaginationController {
44733
+ async getRequest(queryParams, token) {
44734
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
44735
+ const baseOptions = {
44736
+ type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
44737
+ };
44738
+ const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
44739
+ const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
44740
+ params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
44741
+ });
44742
+ return queryResponse;
44743
+ }
44744
+ }
44745
+
44746
+ var EnumRoomActions;
44747
+ (function (EnumRoomActions) {
44748
+ EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
44749
+ EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
44750
+ EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
44751
+ EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
44752
+ EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
44753
+ EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
44754
+ EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
44755
+ })(EnumRoomActions || (EnumRoomActions = {}));
44756
+
44757
+ class RoomQueryStreamController extends QueryStreamController {
44758
+ constructor(query, cacheKey, notifyChange, preparePayload) {
44759
+ super(query, cacheKey);
44760
+ this.notifyChange = notifyChange;
44761
+ this.preparePayload = preparePayload;
44762
+ }
44763
+ async saveToMainDB(response) {
44764
+ const processedPayload = await this.preparePayload(response);
44765
+ const client = getActiveClient();
44766
+ const cachedAt = client.cache && Date.now();
44767
+ if (client.cache) {
44768
+ ingestInCache(processedPayload, { cachedAt });
44769
+ }
44770
+ }
44771
+ appendToQueryStream(response, direction, refresh = false) {
44772
+ var _a, _b;
44773
+ if (refresh) {
44774
+ pushToCache(this.cacheKey, {
44775
+ data: response.rooms.map(getResolver('room')),
44776
+ });
44777
+ }
44778
+ else {
44779
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44780
+ const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
44781
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
44782
+ }
44783
+ }
44784
+ reactor(action) {
44785
+ return (room) => {
44786
+ var _a;
44787
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44788
+ if (!collection)
44789
+ return;
44790
+ if (action === EnumRoomActions.OnRoomDeleted) {
44791
+ collection.data = collection.data.filter(roomId => roomId !== room._id);
44792
+ }
44793
+ if (action === EnumRoomActions.OnRoomCreated) {
44794
+ collection.data = [...new Set([room._id, ...collection.data])];
44795
+ }
44796
+ pushToCache(this.cacheKey, collection);
44797
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
44798
+ };
44799
+ }
44800
+ subscribeRTE(createSubscriber) {
44801
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
44802
+ }
44803
+ }
44804
+
44805
+ // TODO: confirm related events
44806
+ const getRoomSubscription = () => [
44807
+ {
44808
+ fn: onRoomStartBroadcasting,
44809
+ action: EnumRoomActions.OnRoomStartBroadcasting,
44810
+ },
44811
+ {
44812
+ fn: onRoomEndBroadcasting,
44813
+ action: EnumRoomActions.OnRoomEndBroadcasting,
44814
+ },
44815
+ {
44816
+ fn: onRoomRecordedAvailable,
44817
+ action: EnumRoomActions.OnRoomUpdated,
44818
+ },
44819
+ ];
44820
+
44821
+ class RoomLiveCollectionController extends LiveCollectionController {
44822
+ constructor(query, callback) {
44823
+ const queryStreamId = hash(query);
44824
+ const cacheKey = ['rooms', 'collection', queryStreamId];
44825
+ const paginationController = new RoomPaginationController(query);
44826
+ super(paginationController, queryStreamId, cacheKey, callback);
44827
+ this.query = query;
44828
+ this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
44829
+ this.callback = callback.bind(this);
44830
+ this.loadPage({ initial: true });
44831
+ }
44832
+ setup() {
44833
+ var _a;
44834
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44835
+ if (!collection) {
44836
+ pushToCache(this.cacheKey, {
44837
+ data: [],
44838
+ params: {},
44839
+ });
44840
+ }
44841
+ }
44842
+ async persistModel(queryPayload) {
44843
+ await this.queryStreamController.saveToMainDB(queryPayload);
44844
+ }
44845
+ persistQueryStream({ response, direction, refresh, }) {
44846
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
44847
+ }
44848
+ startSubscription() {
44849
+ return this.queryStreamController.subscribeRTE(getRoomSubscription());
44850
+ }
44851
+ notifyChange({ origin, loading, error }) {
44852
+ var _a, _b;
44853
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44854
+ if (!collection)
44855
+ return;
44856
+ const data = this.applyFilter((_b = collection.data
44857
+ .map(id => pullFromCache(['room', 'get', id]))
44858
+ .filter(isNonNullable)
44859
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
44860
+ if (!this.shouldNotify(data) && origin === 'event')
44861
+ return;
44862
+ this.callback({
44863
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
44864
+ data,
44865
+ hasNextPage: !!this.paginationController.getNextToken(),
44866
+ loading,
44867
+ error,
44868
+ });
44869
+ }
44870
+ applyFilter(data) {
44871
+ let rooms = data;
44872
+ if (!this.query.includeDeleted) {
44873
+ rooms = filterByPropEquality(rooms, 'isDeleted', false);
44874
+ }
44875
+ if (this.query.statuses && this.query.statuses.length > 0) {
44876
+ rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
44877
+ }
44878
+ if (this.query.type) {
44879
+ rooms = filterByPropEquality(rooms, 'type', this.query.type);
44880
+ }
44881
+ switch (this.query.sortBy) {
44882
+ case 'firstCreated':
44883
+ rooms = rooms.sort(sortByFirstCreated);
44884
+ break;
44885
+ case 'lastCreated':
44886
+ default:
44887
+ rooms = rooms.sort(sortByLastCreated);
44888
+ break;
44889
+ }
44890
+ return rooms;
44891
+ }
44892
+ }
44893
+
44894
+ /* begin_public_function
44895
+ id: room.get_rooms
44896
+ */
44905
44897
  /**
44906
44898
  * ```js
44907
- * import { onRoomCoHostInviteAccepted } from '@amityco/ts-sdk'
44908
- * const dispose = onRoomCoHostInviteAccepted(room => {
44909
- * // ...
44910
- * })
44899
+ * import { RoomRepository } from '@amityco/ts-sdk'
44900
+ *
44901
+ * let rooms = []
44902
+ * const unsub = RoomRepository.getRooms({
44903
+ * type: 'direct_streaming',
44904
+ * statuses: ['live', 'idle'],
44905
+ * sortBy: 'lastCreated',
44906
+ * limit: 20,
44907
+ * includeDeleted: false
44908
+ * }, response => merge(rooms, response.data))
44911
44909
  * ```
44912
44910
  *
44913
- * Fired when a co-host invitation is accepted for a {@link Amity.Room}
44911
+ * Observe all mutations on a list of {@link Amity.Room} for a given query
44914
44912
  *
44915
- * @param callback The function to call when the event was fired
44916
- * @returns an {@link Amity.Unsubscriber} function to stop listening
44913
+ * @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
44914
+ * @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
44915
+ * @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
44916
+ * @param params.limit maximum number of rooms to retrieve per page
44917
+ * @param params.includeDeleted whether to include deleted rooms in the results
44918
+ * @param callback the function to call when new data are available
44919
+ * @param config optional configuration for the live collection
44920
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
44917
44921
  *
44918
- * @category Room Events
44922
+ * @category Rooms Live Collection
44919
44923
  */
44920
- const onRoomCoHostInviteAccepted = (callback) => {
44921
- const client = getActiveClient();
44922
- const filter = async (payload) => {
44924
+ const getRooms = (params, callback, config) => {
44925
+ const { log, cache } = getActiveClient();
44926
+ if (!cache) {
44927
+ console.log(ENABLE_CACHE_MESSAGE);
44928
+ }
44929
+ const timestamp = Date.now();
44930
+ log(`getRooms(tmpid: ${timestamp}) > listen`);
44931
+ const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
44932
+ const disposers = roomsLiveCollection.startSubscription();
44933
+ const cacheKey = roomsLiveCollection.getCacheKey();
44934
+ disposers.push(() => dropFromCache(cacheKey));
44935
+ return () => {
44936
+ log(`getRooms(tmpid: ${timestamp}) > dispose`);
44937
+ disposers.forEach(fn => fn());
44938
+ };
44939
+ };
44940
+ /* end_public_function */
44941
+
44942
+ var index$b = /*#__PURE__*/Object.freeze({
44943
+ __proto__: null,
44944
+ createRoom: createRoom,
44945
+ updateRoom: updateRoom,
44946
+ deleteRoom: deleteRoom,
44947
+ stopRoom: stopRoom,
44948
+ getBroadcasterData: getBroadcasterData,
44949
+ getRecordedUrl: getRecordedUrl,
44950
+ removeParticipant: removeParticipant,
44951
+ leaveRoom: leaveRoom,
44952
+ onRoomStartBroadcasting: onRoomStartBroadcasting,
44953
+ onRoomWaitingReconnect: onRoomWaitingReconnect,
44954
+ onRoomEndBroadcasting: onRoomEndBroadcasting,
44955
+ onRoomRecordedAvailable: onRoomRecordedAvailable,
44956
+ onRoomCoHostInvited: onRoomCoHostInvited,
44957
+ onRoomCoHostInviteAccepted: onRoomCoHostInviteAccepted,
44958
+ onRoomCoHostInviteRejected: onRoomCoHostInviteRejected,
44959
+ onRoomCoHostInviteCanceled: onRoomCoHostInviteCanceled,
44960
+ onRoomParticipantJoined: onRoomParticipantJoined,
44961
+ onRoomParticipantLeft: onRoomParticipantLeft,
44962
+ onRoomTerminated: onRoomTerminated,
44963
+ onRoomCreated: onRoomCreated,
44964
+ onRoomUpdated: onRoomUpdated,
44965
+ onRoomDeleted: onRoomDeleted,
44966
+ onRoomStopped: onRoomStopped,
44967
+ onRoomParticipantRemoved: onRoomParticipantRemoved,
44968
+ onRoomLeft: onRoomLeft,
44969
+ getRoom: getRoom,
44970
+ getRooms: getRooms
44971
+ });
44972
+
44973
+ class LiveRoomPostLiveCollectionController extends LiveCollectionController {
44974
+ constructor(callback) {
44975
+ const query = { limit: 100 };
44976
+ const queryStreamId = hash(query);
44977
+ const cacheKey = ['liveRoomPosts', 'collection', queryStreamId];
44978
+ const paginationController = new LiveRoomPostPaginationController(query);
44979
+ super(paginationController, queryStreamId, cacheKey, callback);
44980
+ this.query = query;
44981
+ this.queryStreamController = new LiveRoomPostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
44982
+ this.callback = callback.bind(this);
44983
+ this.loadPage({ initial: true });
44984
+ }
44985
+ setup() {
44923
44986
  var _a;
44924
- const data = prepareMyInvitationsPayload(payload);
44925
- await getRoomById((_a = data.invitations) === null || _a === void 0 ? void 0 : _a[0].targetId);
44926
- ingestInCache(data);
44927
- callback(data.invitations[0]);
44987
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
44988
+ if (!collection) {
44989
+ pushToCache(this.cacheKey, {
44990
+ data: [],
44991
+ params: {},
44992
+ });
44993
+ }
44994
+ }
44995
+ async persistModel(queryPayload) {
44996
+ await this.queryStreamController.saveToMainDB(queryPayload);
44997
+ }
44998
+ persistQueryStream({ response, direction, refresh, }) {
44999
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
45000
+ }
45001
+ startSubscription() {
45002
+ return this.queryStreamController.subscribeRTE([
45003
+ { fn: onRoomEndBroadcasting, action: EnumPostActions.OnPostUpdated },
45004
+ ]);
45005
+ }
45006
+ notifyChange({ origin, loading, error }) {
45007
+ var _a, _b;
45008
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
45009
+ if (!collection)
45010
+ return;
45011
+ const data = this.applyFilter((_b = collection.data
45012
+ .map(id => pullFromCache(['post', 'get', id]))
45013
+ .filter(isNonNullable)
45014
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
45015
+ if (!this.shouldNotify(data) && origin === 'event')
45016
+ return;
45017
+ this.callback({
45018
+ data,
45019
+ loading,
45020
+ error,
45021
+ });
45022
+ }
45023
+ // eslint-disable-next-line class-methods-use-this
45024
+ applyFilter(data) {
45025
+ // No additional filtering needed for live room posts
45026
+ // API handles all filtering based on targetId and targetType
45027
+ return data;
45028
+ }
45029
+ }
45030
+
45031
+ /* begin_public_function
45032
+ id: post.liveRoom.query
45033
+ */
45034
+ /**
45035
+ * ```js
45036
+ * import { PostRepository } from '@amityco/ts-sdk'
45037
+ *
45038
+ * let posts = []
45039
+ * const unsub = PostRepository.getLiveRoomPosts({
45040
+ * targetType: Amity.PostTargetType,
45041
+ * targetId: Amity.Post['targetId'],
45042
+ * }, response => merge(posts, response.data))
45043
+ * ```
45044
+ *
45045
+ * Observe all mutations on a list of {@link Amity.Post} for a given live room
45046
+ *
45047
+ * @param params.targetType the type of the target
45048
+ * @param params.targetId the ID of the target
45049
+ * @param callback the function to call when new data are available
45050
+ * @param config
45051
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the posts
45052
+ *
45053
+ * @category Posts Live Collection
45054
+ */
45055
+ const getLiveRoomPosts = (callback) => {
45056
+ const { log, cache } = getActiveClient();
45057
+ if (!cache) {
45058
+ console.log(ENABLE_CACHE_MESSAGE);
45059
+ }
45060
+ const timestamp = Date.now();
45061
+ log(`getLiveRoomPosts(tmpid: ${timestamp}) > listen`);
45062
+ const liveRoomPostsLiveCollection = new LiveRoomPostLiveCollectionController(callback);
45063
+ const disposers = liveRoomPostsLiveCollection.startSubscription();
45064
+ const cacheKey = liveRoomPostsLiveCollection.getCacheKey();
45065
+ disposers.push(() => dropFromCache(cacheKey));
45066
+ return () => {
45067
+ log(`getLiveRoomPosts(tmpid: ${timestamp}) > dispose`);
45068
+ disposers.forEach(fn => fn());
44928
45069
  };
44929
- return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCohostInviteAccept', filter);
44930
45070
  };
45071
+ /* end_public_function */
45072
+
45073
+ class CommunityLiveRoomPostPaginationController extends PaginationNoPageController {
45074
+ async getRequest(queryParams) {
45075
+ const { limit = 100, communityIds } = queryParams;
45076
+ const { data: queryResponse } = await this.http.get(`/api/v1/rooms/lives`, {
45077
+ params: {
45078
+ targetTypes: ['community'],
45079
+ targetIds: communityIds,
45080
+ options: {
45081
+ limit,
45082
+ sortBy: 'lastCreated',
45083
+ },
45084
+ },
45085
+ });
45086
+ return queryResponse;
45087
+ }
45088
+ }
44931
45089
 
45090
+ class CommunityLiveRoomPostQueryStreamController extends QueryStreamController {
45091
+ constructor(query, cacheKey, notifyChange, preparePayload) {
45092
+ super(query, cacheKey);
45093
+ this.notifyChange = notifyChange;
45094
+ this.preparePayload = preparePayload;
45095
+ }
45096
+ async saveToMainDB(response) {
45097
+ const processedPayload = await this.preparePayload(response);
45098
+ const client = getActiveClient();
45099
+ const cachedAt = client.cache && Date.now();
45100
+ if (client.cache) {
45101
+ ingestInCache(processedPayload, { cachedAt });
45102
+ }
45103
+ }
45104
+ appendToQueryStream(response, direction, refresh = false) {
45105
+ var _a, _b;
45106
+ if (refresh) {
45107
+ pushToCache(this.cacheKey, {
45108
+ data: resolvePostIdsFromRooms(response.rooms, response.posts),
45109
+ });
45110
+ }
45111
+ else {
45112
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
45113
+ const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
45114
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...resolvePostIdsFromRooms(response.rooms, response.posts)])] }));
45115
+ }
45116
+ }
45117
+ reactor(action) {
45118
+ return (room) => {
45119
+ var _a;
45120
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
45121
+ if (!collection)
45122
+ return;
45123
+ if (room.status === 'ended') {
45124
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: collection.data.filter(postId => room.referenceId !== postId) }));
45125
+ }
45126
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
45127
+ };
45128
+ }
45129
+ subscribeRTE(createSubscriber) {
45130
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
45131
+ }
45132
+ }
45133
+
45134
+ class CommunityLiveRoomPostLiveCollectionController extends LiveCollectionController {
45135
+ constructor(query, callback) {
45136
+ const queryStreamId = hash(query);
45137
+ const cacheKey = ['communityLiveRoomPosts', 'collection', queryStreamId];
45138
+ const paginationController = new CommunityLiveRoomPostPaginationController(query);
45139
+ super(paginationController, queryStreamId, cacheKey, callback);
45140
+ this.query = query;
45141
+ this.queryStreamController = new CommunityLiveRoomPostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
45142
+ this.callback = callback.bind(this);
45143
+ this.loadPage({ initial: true });
45144
+ }
45145
+ setup() {
45146
+ var _a;
45147
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
45148
+ if (!collection) {
45149
+ pushToCache(this.cacheKey, {
45150
+ data: [],
45151
+ params: {},
45152
+ });
45153
+ }
45154
+ }
45155
+ async persistModel(queryPayload) {
45156
+ await this.queryStreamController.saveToMainDB(queryPayload);
45157
+ }
45158
+ persistQueryStream({ response, direction, refresh, }) {
45159
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
45160
+ }
45161
+ startSubscription() {
45162
+ return this.queryStreamController.subscribeRTE([
45163
+ { fn: onRoomEndBroadcasting, action: EnumPostActions.OnPostUpdated },
45164
+ ]);
45165
+ }
45166
+ notifyChange({ origin, loading, error }) {
45167
+ var _a, _b;
45168
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
45169
+ if (!collection)
45170
+ return;
45171
+ const data = this.applyFilter((_b = collection.data
45172
+ .map((id) => pullFromCache(['post', 'get', id]))
45173
+ .filter(isNonNullable)
45174
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
45175
+ if (!this.shouldNotify(data) && origin === 'event')
45176
+ return;
45177
+ this.callback({
45178
+ data,
45179
+ loading,
45180
+ error,
45181
+ });
45182
+ }
45183
+ // eslint-disable-next-line class-methods-use-this
45184
+ applyFilter(data) {
45185
+ // No additional filtering needed for live room posts
45186
+ // API handles all filtering based on targetId and targetType
45187
+ return data;
45188
+ }
45189
+ }
45190
+
45191
+ /* begin_public_function
45192
+ id: post.communityLiveRoom.query
45193
+ */
44932
45194
  /**
44933
45195
  * ```js
44934
- * import { onRoomCoHostInviteRejected } from '@amityco/ts-sdk'
44935
- * const dispose = onRoomCoHostInviteRejected(room => {
44936
- * // ...
44937
- * })
45196
+ * import { PostRepository } from '@amityco/ts-sdk'
45197
+ *
45198
+ * let posts = []
45199
+ * const unsub = PostRepository.getCommunityLiveRoomPosts({
45200
+ * targetId: 'communityId',
45201
+ * }, response => merge(posts, response.data))
44938
45202
  * ```
44939
45203
  *
44940
- * Fired when a co-host invitation is rejected for a {@link Amity.Room}
45204
+ * Observe all mutations on a list of {@link Amity.Post} for live rooms in a specific community
44941
45205
  *
44942
- * @param callback The function to call when the event was fired
44943
- * @returns an {@link Amity.Unsubscriber} function to stop listening
45206
+ * @param params.targetId the ID of the community
45207
+ * @param params.limit optional limit for the number of posts to fetch
45208
+ * @param callback the function to call when new data are available
45209
+ * @param config
45210
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the posts
44944
45211
  *
44945
- * @category Room Events
45212
+ * @category Posts Live Collection
44946
45213
  */
44947
- const onRoomCoHostInviteRejected = (callback) => {
45214
+ const getCommunityLiveRoomPosts = (params, callback, config) => {
45215
+ const { log, cache } = getActiveClient();
45216
+ if (!cache) {
45217
+ console.log(ENABLE_CACHE_MESSAGE);
45218
+ }
45219
+ const timestamp = Date.now();
45220
+ log(`getCommunityLiveRoomPosts(tmpid: ${timestamp}) > listen`);
45221
+ const communityLiveRoomPostsLiveCollection = new CommunityLiveRoomPostLiveCollectionController(params, callback);
45222
+ const disposers = communityLiveRoomPostsLiveCollection.startSubscription();
45223
+ const cacheKey = communityLiveRoomPostsLiveCollection.getCacheKey();
45224
+ disposers.push(() => dropFromCache(cacheKey));
45225
+ return () => {
45226
+ log(`getCommunityLiveRoomPosts(tmpid: ${timestamp}) > dispose`);
45227
+ disposers.forEach(fn => fn());
45228
+ };
45229
+ };
45230
+ /* end_public_function */
45231
+
45232
+ var index$a = /*#__PURE__*/Object.freeze({
45233
+ __proto__: null,
45234
+ getPostByIds: getPostByIds,
45235
+ createPost: createPost,
45236
+ editPost: editPost,
45237
+ deletePost: deletePost,
45238
+ softDeletePost: softDeletePost,
45239
+ hardDeletePost: hardDeletePost,
45240
+ approvePost: approvePost,
45241
+ declinePost: declinePost,
45242
+ flagPost: flagPost,
45243
+ unflagPost: unflagPost,
45244
+ isPostFlaggedByMe: isPostFlaggedByMe,
45245
+ createClipPost: createClipPost,
45246
+ createAudioPost: createAudioPost,
45247
+ createMixedMediaPost: createMixedMediaPost,
45248
+ onPostCreated: onPostCreated,
45249
+ onPostUpdated: onPostUpdated,
45250
+ onPostDeleted: onPostDeleted,
45251
+ onPostApproved: onPostApproved,
45252
+ onPostDeclined: onPostDeclined,
45253
+ onPostFlagged: onPostFlagged,
45254
+ onPostUnflagged: onPostUnflagged,
45255
+ onPostReactionAdded: onPostReactionAdded,
45256
+ onPostReactionRemoved: onPostReactionRemoved,
45257
+ getPost: getPost,
45258
+ getPosts: getPosts,
45259
+ getPinnedPosts: getPinnedPosts,
45260
+ getGlobalPinnedPosts: getGlobalPinnedPosts,
45261
+ semanticSearchPosts: semanticSearchPosts,
45262
+ searchPostsByHashtag: searchPostsByHashtag,
45263
+ getLiveRoomPosts: getLiveRoomPosts,
45264
+ getCommunityLiveRoomPosts: getCommunityLiveRoomPosts
45265
+ });
45266
+
45267
+ /* begin_public_function
45268
+ id: stream.create
45269
+ */
45270
+ /**
45271
+ * ```js
45272
+ * import { createStream } from '@amityco/ts-sdk'
45273
+ * const created = await createStream({ title: 'my stream', 'thumbnailFileId': fileId })
45274
+ * ```
45275
+ *
45276
+ * Creates an {@link Amity.InternalStream}
45277
+ *
45278
+ * @param bundle The data necessary to create a new {@link Amity.InternalStream}
45279
+ * @returns The newly created {@link Amity.InternalStream}
45280
+ *
45281
+ * @category Stream API
45282
+ * @async
45283
+ */
45284
+ const createStream = async (bundle) => {
44948
45285
  const client = getActiveClient();
44949
- const filter = (payload) => {
44950
- const data = prepareMyInvitationsPayload(payload);
44951
- ingestInCache(data);
44952
- callback(data.invitations);
45286
+ client.log('stream/createStream', bundle);
45287
+ const { data } = await client.http.post('/api/v3/video-streaming', bundle);
45288
+ const cachedAt = client.cache && Date.now();
45289
+ if (client.cache)
45290
+ ingestInCache(data, { cachedAt });
45291
+ const { videoStreamings } = data;
45292
+ return {
45293
+ data: LinkedObject.stream(videoStreamings[0]),
45294
+ cachedAt,
44953
45295
  };
44954
- return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCohostInviteReject', filter);
44955
45296
  };
45297
+ /* end_public_function */
45298
+
45299
+ /* begin_public_function
45300
+ id: stream.update
45301
+ */
45302
+ /**
45303
+ * @deprecated this function is deprecated,
45304
+ * please use {@link Amity.StreamRepository.editStream} instead.
45305
+ *
45306
+ * ```js
45307
+ * import { updateStream } from '@amityco/ts-sdk'
45308
+ * const updated = await updateStream(streamId, { title: 'foobar' })
45309
+ * ```
45310
+ *
45311
+ * Updates an {@link Amity.Stream}
45312
+ *
45313
+ * @param streamId The ID of the {@link Amity.Stream} to edit
45314
+ * @param patch The patch data to apply
45315
+ * @returns the updated {@link Amity.Stream} object
45316
+ *
45317
+ * @category Stream API
45318
+ * @async
45319
+ */
45320
+ const updateStream = async (streamId, patch) => {
45321
+ const client = getActiveClient();
45322
+ client.log('stream/updateStream', streamId, patch);
45323
+ const { data } = await client.http.put(`/api/v3/video-streaming/${streamId}`, patch);
45324
+ const cachedAt = client.cache && Date.now();
45325
+ if (client.cache)
45326
+ ingestInCache(data, { cachedAt });
45327
+ const { videoStreamings } = data;
45328
+ return {
45329
+ data: LinkedObject.stream(videoStreamings.find(stream => stream.streamId === streamId)),
45330
+ cachedAt,
45331
+ };
45332
+ };
45333
+ /* end_public_function */
45334
+
45335
+ /* begin_public_function
45336
+ id: stream.get
45337
+ */
45338
+ /**
45339
+ * ```js
45340
+ * import { getStream } from '@amityco/ts-sdk'
45341
+ * const stream = await getStream('foobar')
45342
+ * ```
45343
+ *
45344
+ * Fetches a {@link Amity.Stream} object
45345
+ *
45346
+ * @param streamId the ID of the {@link Amity.Stream} to fetch
45347
+ * @returns the associated {@link Amity.Stream} object
45348
+ *
45349
+ * @category Stream API
45350
+ * @async
45351
+ */
45352
+ const getStream = async (streamId) => {
45353
+ const client = getActiveClient();
45354
+ client.log('stream/getStream', streamId);
45355
+ const { data } = await client.http.get(`/api/v3/video-streaming/${streamId}`);
45356
+ const cachedAt = client.cache && Date.now();
45357
+ if (client.cache)
45358
+ ingestInCache(data, { cachedAt });
45359
+ const { videoStreamings } = data;
45360
+ return {
45361
+ data: videoStreamings.find(stream => stream.streamId === streamId),
45362
+ cachedAt,
45363
+ };
45364
+ };
45365
+ /* end_public_function */
45366
+ /**
45367
+ * ```js
45368
+ * import { getStream } from '@amityco/ts-sdk'
45369
+ * const stream = getStream.locally('foobar')
45370
+ * ```
45371
+ *
45372
+ * Fetches a {@link Amity.Stream} object
45373
+ *
45374
+ * @param streamId the ID of the {@link Amity.Stream} to fetch
45375
+ * @returns the associated {@link Amity.Stream} object
45376
+ *
45377
+ * @category Stream API
45378
+ */
45379
+ getStream.locally = (streamId) => {
45380
+ const client = getActiveClient();
45381
+ client.log('stream/getStream', streamId);
45382
+ if (!client.cache)
45383
+ return;
45384
+ const cached = pullFromCache(['stream', 'get', streamId]);
45385
+ if (!cached)
45386
+ return;
45387
+ return {
45388
+ data: cached.data,
45389
+ cachedAt: cached.cachedAt,
45390
+ };
45391
+ };
45392
+
45393
+ // import { unwrapPayload } from '~/core/transports'
45394
+ /* begin_public_function
45395
+ id: stream.delete
45396
+ */
45397
+ /**
45398
+ * ```js
45399
+ * import { deleteStream } from '@amityco/ts-sdk'
45400
+ * const success = await deleteStream(streamId)
45401
+ * ```
45402
+ *
45403
+ * Deletes a {@link Amity.InternalStream}
45404
+ *
45405
+ * @param streamId The {@link Amity.InternalStream} ID to delete
45406
+ * @return A success boolean if the {@link Amity.InternalStream} was deleted
45407
+ *
45408
+ * @category Stream API
45409
+ * @async
45410
+ */
45411
+ const deleteStream = async (streamId) => {
45412
+ const client = getActiveClient();
45413
+ client.log('stream/deleteStream', streamId);
45414
+ const stream = await getStream(streamId);
45415
+ // API-FIX: it returns { success: boolean } but seems it should be Amity.Response<{ success: boolean }
45416
+ // API-FIX: swagger docs are wrong!
45417
+ const { data } = await client.http.delete(`/api/v3/video-streaming/${streamId}`);
45418
+ const { success } = data; // unwrapPayload(data)
45419
+ const deleted = Object.assign(Object.assign({}, stream.data), { isDeleted: true });
45420
+ upsertInCache(['stream', 'get', streamId], deleted);
45421
+ return success;
45422
+ };
45423
+ /* end_public_function */
44956
45424
 
44957
45425
  /**
44958
45426
  * ```js
44959
- * import { onRoomCoHostInviteCanceled } from '@amityco/ts-sdk'
44960
- * const dispose = onRoomCoHostInviteCanceled(room => {
44961
- * // ...
44962
- * })
45427
+ * import { disposeStream } from '@amityco/ts-sdk'
45428
+ * const stream = await disposeStream(streamId)
44963
45429
  * ```
44964
45430
  *
44965
- * Fired when a co-host invitation is canceled for a {@link Amity.Room}
45431
+ * Dispose a {@link Amity.InternalStream}.
45432
+ * Streaming status will be updated to "ended" and streaming url will be invalidated
44966
45433
  *
44967
- * @param callback The function to call when the event was fired
44968
- * @returns an {@link Amity.Unsubscriber} function to stop listening
45434
+ * @param streamId The {@link Amity.InternalStream} ID to dispose
45435
+ * @returns the associated {@link Amity.InternalStream} object
44969
45436
  *
44970
- * @category Room Events
45437
+ * @category Stream API
45438
+ * @async
44971
45439
  */
44972
- const onRoomCoHostInviteCanceled = (callback) => {
45440
+ const disposeStream = async (streamId) => {
44973
45441
  const client = getActiveClient();
44974
- const filter = (payload) => {
44975
- const data = prepareMyInvitationsPayload(payload);
44976
- ingestInCache(data);
44977
- callback(data.invitations);
45442
+ client.log('stream/disposeStream', streamId);
45443
+ const { data } = await client.http.delete(`/api/v3/video-streaming/${streamId}/streaming-url`);
45444
+ const cachedAt = client.cache && Date.now();
45445
+ if (client.cache)
45446
+ ingestInCache(data, { cachedAt });
45447
+ const { videoStreamings } = data;
45448
+ return {
45449
+ data: videoStreamings.find(stream => stream.streamId === streamId),
45450
+ cachedAt,
44978
45451
  };
44979
- return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCohostInviteCancel', filter);
44980
45452
  };
45453
+ /* end_public_function */
44981
45454
 
45455
+ /* begin_public_function
45456
+ id: stream.update
45457
+ */
44982
45458
  /**
45459
+ *
44983
45460
  * ```js
44984
- * import { onRoomParticipantJoined } from '@amityco/ts-sdk'
44985
- * const dispose = onRoomParticipantJoined(room => {
44986
- * // ...
44987
- * })
45461
+ * import { StreamRepository } from '@amityco/ts-sdk'
45462
+ * const updated = await StreamRepository.editStream(streamId, { title: 'foobar' })
44988
45463
  * ```
44989
45464
  *
44990
- * Fired when a participant has joined a {@link Amity.Room}
45465
+ * Updates an {@link Amity.Stream}
44991
45466
  *
44992
- * @param callback The function to call when the event was fired
44993
- * @returns an {@link Amity.Unsubscriber} function to stop listening
45467
+ * @param streamId The ID of the {@link Amity.Stream} to edit
45468
+ * @param patch The patch data to apply
45469
+ * @returns the updated {@link Amity.Stream} object
44994
45470
  *
44995
- * @category Room Events
45471
+ * @category Stream API
45472
+ * @async
44996
45473
  */
44997
- const onRoomParticipantJoined = (callback) => {
45474
+ const editStream = async (streamId, patch) => {
44998
45475
  const client = getActiveClient();
44999
- const filter = (payload) => {
45000
- ingestInCache(payload);
45001
- callback(payload.rooms[0]);
45476
+ client.log('stream/updateStream', streamId, patch);
45477
+ const { data } = await client.http.put(`/api/v3/video-streaming/${streamId}`, patch);
45478
+ const cachedAt = client.cache && Date.now();
45479
+ if (client.cache)
45480
+ ingestInCache(data, { cachedAt });
45481
+ const { videoStreamings } = data;
45482
+ return {
45483
+ data: LinkedObject.stream(videoStreamings.find(stream => stream.streamId === streamId)),
45484
+ cachedAt,
45002
45485
  };
45003
- return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
45004
45486
  };
45487
+ /* end_public_function */
45005
45488
 
45006
45489
  /**
45007
45490
  * ```js
45008
- * import { onRoomParticipantLeft } from '@amityco/ts-sdk'
45009
- * const dispose = onRoomParticipantLeft(room => {
45491
+ * import { onStreamStarted } from '@amityco/ts-sdk'
45492
+ * const dispose = onStreamStarted(stream => {
45010
45493
  * // ...
45011
45494
  * })
45012
45495
  * ```
45013
45496
  *
45014
- * Fired when a participant has left a {@link Amity.Room}
45497
+ * Fired when a {@link Amity.InternalStream} has started airing
45015
45498
  *
45016
45499
  * @param callback The function to call when the event was fired
45017
45500
  * @returns an {@link Amity.Unsubscriber} function to stop listening
45018
45501
  *
45019
- * @category Room Events
45502
+ * @category Stream Events
45020
45503
  */
45021
- const onRoomParticipantLeft = (callback) => {
45504
+ const onStreamStarted = (callback) => {
45022
45505
  const client = getActiveClient();
45023
45506
  const filter = (payload) => {
45024
45507
  ingestInCache(payload);
45025
- callback(payload.rooms[0]);
45508
+ callback(payload.videoStreamings[0]);
45026
45509
  };
45027
- return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
45510
+ return createEventSubscriber(client, 'stream/onStreamStarted', 'video-streaming.didStart', filter);
45028
45511
  };
45029
45512
 
45030
45513
  /**
45031
45514
  * ```js
45032
- * import { onRoomCreated } from '@amityco/ts-sdk'
45033
- * const dispose = onRoomCreated(room => {
45515
+ * import { onStreamStopped } from '@amityco/ts-sdk'
45516
+ * const dispose = onStreamStopped(stream => {
45034
45517
  * // ...
45035
45518
  * })
45036
45519
  * ```
45037
45520
  *
45038
- * Fired when a {@link Amity.Room} has been created locally
45521
+ * Fired when a {@link Amity.InternalStream} has stopped airing
45039
45522
  *
45040
45523
  * @param callback The function to call when the event was fired
45041
45524
  * @returns an {@link Amity.Unsubscriber} function to stop listening
45042
45525
  *
45043
- * @category Room Events
45526
+ * @category Stream Events
45044
45527
  */
45045
- const onRoomCreated = (callback) => {
45528
+ const onStreamStopped = (callback) => {
45046
45529
  const client = getActiveClient();
45047
45530
  const filter = (payload) => {
45048
45531
  ingestInCache(payload);
45049
- callback(payload.rooms[0]);
45532
+ callback(payload.videoStreamings[0]);
45050
45533
  };
45051
- return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
45534
+ return createEventSubscriber(client, 'stream/onStreamStropped', 'video-streaming.didStop', filter);
45052
45535
  };
45053
45536
 
45054
45537
  /**
45055
45538
  * ```js
45056
- * import { onRoomUpdated } from '@amityco/ts-sdk'
45057
- * const dispose = onRoomUpdated(room => {
45539
+ * import { onStreamRecorded } from '@amityco/ts-sdk'
45540
+ * const dispose = onStreamRecorded(stream => {
45058
45541
  * // ...
45059
45542
  * })
45060
45543
  * ```
45061
45544
  *
45062
- * Fired when a {@link Amity.Room} has been updated locally
45545
+ * Fired when the recordings of a {@link Amity.InternalStream} are available
45063
45546
  *
45064
45547
  * @param callback The function to call when the event was fired
45065
45548
  * @returns an {@link Amity.Unsubscriber} function to stop listening
45066
45549
  *
45067
- * @category Room Events
45550
+ * @category Stream Events
45068
45551
  */
45069
- const onRoomUpdated = (callback) => {
45552
+ const onStreamRecorded = (callback) => {
45070
45553
  const client = getActiveClient();
45071
45554
  const filter = (payload) => {
45072
45555
  ingestInCache(payload);
45073
- callback(payload.rooms[0]);
45556
+ callback(payload.videoStreamings[0]);
45074
45557
  };
45075
- return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
45558
+ return createEventSubscriber(client, 'stream/onStreamRecorded', 'video-streaming.didRecord', filter);
45076
45559
  };
45077
45560
 
45078
45561
  /**
45079
45562
  * ```js
45080
- * import { onRoomDeleted } from '@amityco/ts-sdk'
45081
- * const dispose = onRoomDeleted(room => {
45563
+ * import { onStreamFlagged } from '@amityco/ts-sdk'
45564
+ * const dispose = onStreamFlagged(stream => {
45082
45565
  * // ...
45083
45566
  * })
45084
45567
  * ```
45085
45568
  *
45086
- * Fired when a {@link Amity.Room} has been deleted locally
45569
+ * Fired when a {@link Amity.InternalStream} has started airing
45087
45570
  *
45088
45571
  * @param callback The function to call when the event was fired
45089
45572
  * @returns an {@link Amity.Unsubscriber} function to stop listening
45090
45573
  *
45091
- * @category Room Events
45574
+ * @category Stream Events
45092
45575
  */
45093
- const onRoomDeleted = (callback) => {
45576
+ const onStreamFlagged = (callback) => {
45094
45577
  const client = getActiveClient();
45095
45578
  const filter = (payload) => {
45096
45579
  ingestInCache(payload);
45097
- callback(payload.rooms[0]);
45580
+ callback(payload.videoStreamings[0]);
45098
45581
  };
45099
- return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
45582
+ return createEventSubscriber(client, 'stream/onStreamFlagged', 'video-streaming.didFlag', filter);
45100
45583
  };
45101
45584
 
45102
45585
  /**
45103
45586
  * ```js
45104
- * import { onRoomStopped } from '@amityco/ts-sdk'
45105
- * const dispose = onRoomStopped(room => {
45587
+ * import { onStreamTerminated } from '@amityco/ts-sdk'
45588
+ * const dispose = onStreamTerminated(stream => {
45106
45589
  * // ...
45107
45590
  * })
45108
45591
  * ```
45109
45592
  *
45110
- * Fired when a {@link Amity.Room} has been stopped locally
45593
+ * Fired when a {@link Amity.InternalStream} has started airing
45111
45594
  *
45112
45595
  * @param callback The function to call when the event was fired
45113
45596
  * @returns an {@link Amity.Unsubscriber} function to stop listening
45114
45597
  *
45115
- * @category Room Events
45598
+ * @category Stream Events
45116
45599
  */
45117
- const onRoomStopped = (callback) => {
45600
+ const onStreamTerminated = (callback) => {
45118
45601
  const client = getActiveClient();
45119
45602
  const filter = (payload) => {
45120
45603
  ingestInCache(payload);
45121
- callback(payload.rooms[0]);
45604
+ callback(payload.videoStreamings[0]);
45122
45605
  };
45123
- return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
45606
+ return createEventSubscriber(client, 'stream/onStreamTerminated', 'video-streaming.didTerminate', filter);
45124
45607
  };
45125
45608
 
45126
45609
  /**
45127
45610
  * ```js
45128
- * import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
45129
- * const dispose = onRoomParticipantRemoved(room => {
45611
+ * import { onStreamViewerUnbanned } from '@amityco/ts-sdk'
45612
+ * const dispose = onStreamViewerBanned(stream => {
45130
45613
  * // ...
45131
45614
  * })
45132
45615
  * ```
45133
45616
  *
45134
- * Fired when a participant has been removed from a {@link Amity.Room} locally
45617
+ * Fired when a user in channel linked to stream has been unbanned
45135
45618
  *
45136
45619
  * @param callback The function to call when the event was fired
45137
45620
  * @returns an {@link Amity.Unsubscriber} function to stop listening
45138
45621
  *
45139
- * @category Room Events
45622
+ * @category Stream Events
45140
45623
  */
45141
- const onRoomParticipantRemoved = (callback) => {
45624
+ const onStreamViewerUnbanned = (callback) => {
45142
45625
  const client = getActiveClient();
45143
- const filter = (payload) => {
45144
- ingestInCache(payload);
45145
- callback(payload.rooms[0]);
45626
+ const filter = async (payloads) => {
45627
+ var _a;
45628
+ // Get new stream object to restore stream watcherUrl in cache
45629
+ const { list } = payloads;
45630
+ await Promise.all(list.map(({ streamId }) => getStream(streamId)));
45631
+ const stream = (_a = pullFromCache(['stream', 'get', list[0].streamId])) === null || _a === void 0 ? void 0 : _a.data;
45632
+ if (!stream)
45633
+ return;
45634
+ callback(stream);
45146
45635
  };
45147
- return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'room.participantRemoved', filter);
45636
+ return createEventSubscriber(client, 'stream/onStreamViewerDidUnban', 'video-streaming.viewerDidUnban', filter);
45148
45637
  };
45149
45638
 
45639
+ /* eslint-disable no-use-before-define */
45640
+ /* begin_public_function
45641
+ id: stream.get
45642
+ */
45150
45643
  /**
45151
45644
  * ```js
45152
- * import { onRoomLeft } from '@amityco/ts-sdk'
45153
- * const dispose = onRoomLeft(room => {
45154
- * // ...
45155
- * })
45645
+ * import { StreamRepository } from '@amityco/ts-sdk'
45646
+ * const unsub = StreamRepository.getStreamById('foobar')
45647
+ * unsub()
45156
45648
  * ```
45157
45649
  *
45158
- * Fired when a user has left a {@link Amity.Room} locally
45650
+ * Fetches a {@link Amity.Stream} object
45159
45651
  *
45160
- * @param callback The function to call when the event was fired
45161
- * @returns an {@link Amity.Unsubscriber} function to stop listening
45652
+ * @param streamId the ID of the {@link Amity.Stream} to get
45653
+ * @param callback
45654
+ * @returns the associated {@link Amity.Stream} object
45162
45655
  *
45163
- * @category Room Events
45656
+ * @category Stream Live Object
45164
45657
  */
45165
- const onRoomLeft = (callback) => {
45166
- const client = getActiveClient();
45167
- const filter = (payload) => {
45168
- ingestInCache(payload);
45169
- callback(payload.rooms[0]);
45658
+ const getStreamById = (streamId, callback) => {
45659
+ const reactor = (snapshot) => {
45660
+ const { data } = snapshot;
45661
+ callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.stream(snapshot.data) : data }));
45170
45662
  };
45171
- return createEventSubscriber(client, 'room/onRoomLeft', 'local.room.left', filter);
45663
+ return liveObject(streamId, reactor, 'streamId', getStream, [
45664
+ onStreamRecorded,
45665
+ onStreamStarted,
45666
+ onStreamStopped,
45667
+ onStreamFlagged,
45668
+ onStreamTerminated,
45669
+ onStreamViewerBanned,
45670
+ ]);
45172
45671
  };
45173
-
45672
+ /* end_public_function */
45174
45673
  /**
45175
45674
  * ```js
45176
- * import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
45177
- * const dispose = onRoomParticipantRemoved(room => {
45178
- * // ...
45179
- * })
45675
+ * import { StreamRepository } from '@amityco/ts-sdk'
45676
+ * const stream = StreamRepository.getStreamById.locally('foobar')
45180
45677
  * ```
45181
45678
  *
45182
- * Fired when a participant has been removed from a {@link Amity.Room} locally
45679
+ * Fetches a {@link Amity.Stream} live object
45183
45680
  *
45184
- * @param callback The function to call when the event was fired
45185
- * @returns an {@link Amity.Unsubscriber} function to stop listening
45681
+ * @param streamId the ID of the {@link Amity.Stream} to fetch
45682
+ * @returns the associated {@link Amity.Stream} live object
45186
45683
  *
45187
- * @category Room Events
45684
+ * @category Stream API
45188
45685
  */
45189
- const onRoomParticipantRemovedLocal = (callback) => {
45686
+ getStreamById.locally = (streamId) => {
45190
45687
  const client = getActiveClient();
45191
- const filter = (payload) => {
45192
- ingestInCache(payload);
45193
- callback(payload.rooms[0]);
45688
+ client.log('stream/getStreamById', streamId);
45689
+ if (!client.cache)
45690
+ return;
45691
+ const cached = pullFromCache(['stream', 'get', streamId]);
45692
+ if (!cached)
45693
+ return;
45694
+ return {
45695
+ data: LinkedObject.stream(cached.data),
45696
+ cachedAt: cached.cachedAt,
45194
45697
  };
45195
- return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
45196
- };
45197
-
45198
- const getRoom = (roomId, callback) => {
45199
- // TODO: add callbackDataSelector if there are linked object fields
45200
- return liveObject(roomId, callback, '_id', getRoomById, [
45201
- onRoomEndBroadcasting,
45202
- onRoomStartBroadcasting,
45203
- onRoomWaitingReconnect,
45204
- onRoomRecordedAvailable,
45205
- onRoomParticipantJoined,
45206
- onRoomParticipantLeft,
45207
- onRoomParticipantRemoved,
45208
- onRoomParticipantRemovedLocal,
45209
- convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
45210
- ], {
45211
- callbackDataSelector: (data) => {
45212
- if (!data)
45213
- return data;
45214
- return LinkedObject.room(data);
45215
- },
45216
- });
45217
45698
  };
45218
45699
 
45219
- class RoomPaginationController extends PaginationController {
45700
+ class GetStreamsPageController extends PaginationController {
45220
45701
  async getRequest(queryParams, token) {
45221
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
45222
- const baseOptions = {
45223
- type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
45224
- };
45225
- const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
45226
- const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
45227
- params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
45702
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
45703
+ const options = token ? { token } : { limit };
45704
+ const { data: queryResponse } = await this.http.get(`/api/v3/video-streaming`, {
45705
+ params: Object.assign(Object.assign({}, params), { options }),
45228
45706
  });
45229
- return queryResponse;
45707
+ return Object.assign(Object.assign({}, queryResponse.results), { paging: queryResponse.paging });
45230
45708
  }
45231
45709
  }
45232
45710
 
45233
- var EnumRoomActions;
45234
- (function (EnumRoomActions) {
45235
- EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
45236
- EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
45237
- EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
45238
- EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
45239
- EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
45240
- EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
45241
- EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
45242
- })(EnumRoomActions || (EnumRoomActions = {}));
45243
-
45244
- class RoomQueryStreamController extends QueryStreamController {
45245
- constructor(query, cacheKey, notifyChange, preparePayload) {
45711
+ class GetStreamsQueryStreamController extends QueryStreamController {
45712
+ constructor(query, cacheKey, notifyChange, paginationController) {
45246
45713
  super(query, cacheKey);
45247
45714
  this.notifyChange = notifyChange;
45248
- this.preparePayload = preparePayload;
45715
+ this.paginationController = paginationController;
45249
45716
  }
45250
- async saveToMainDB(response) {
45251
- const processedPayload = await this.preparePayload(response);
45717
+ // eslint-disable-next-line class-methods-use-this
45718
+ saveToMainDB(response) {
45252
45719
  const client = getActiveClient();
45253
45720
  const cachedAt = client.cache && Date.now();
45254
45721
  if (client.cache) {
45255
- ingestInCache(processedPayload, { cachedAt });
45722
+ ingestInCache(response, { cachedAt });
45256
45723
  }
45257
45724
  }
45258
45725
  appendToQueryStream(response, direction, refresh = false) {
45259
45726
  var _a, _b;
45260
45727
  if (refresh) {
45261
45728
  pushToCache(this.cacheKey, {
45262
- data: response.rooms.map(getResolver('room')),
45729
+ data: response.videoStreamings.map(getResolver('stream')),
45730
+ query: this.query,
45263
45731
  });
45264
45732
  }
45265
45733
  else {
45266
45734
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
45267
- const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
45268
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
45735
+ const messages = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
45736
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === 'next'
45737
+ ? [...new Set([...messages, ...response.videoStreamings.map(getResolver('stream'))])]
45738
+ : [...new Set([...response.videoStreamings.map(getResolver('stream')), ...messages])] }));
45269
45739
  }
45270
45740
  }
45271
45741
  reactor(action) {
45272
- return (room) => {
45742
+ return (payload) => {
45273
45743
  var _a;
45274
45744
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
45275
45745
  if (!collection)
45276
45746
  return;
45277
- if (action === EnumRoomActions.OnRoomDeleted) {
45278
- collection.data = collection.data.filter(roomId => roomId !== room._id);
45279
- }
45280
- if (action === EnumRoomActions.OnRoomCreated) {
45281
- collection.data = [...new Set([room._id, ...collection.data])];
45282
- }
45747
+ collection.data = [...new Set([payload.streamId, ...collection.data])];
45283
45748
  pushToCache(this.cacheKey, collection);
45284
45749
  this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
45285
45750
  };
@@ -45289,171 +45754,107 @@ class RoomQueryStreamController extends QueryStreamController {
45289
45754
  }
45290
45755
  }
45291
45756
 
45292
- // TODO: confirm related events
45293
- const getRoomSubscription = () => [
45294
- {
45295
- fn: onRoomStartBroadcasting,
45296
- action: EnumRoomActions.OnRoomStartBroadcasting,
45297
- },
45298
- {
45299
- fn: onRoomEndBroadcasting,
45300
- action: EnumRoomActions.OnRoomEndBroadcasting,
45301
- },
45302
- {
45303
- fn: onRoomRecordedAvailable,
45304
- action: EnumRoomActions.OnRoomUpdated,
45305
- },
45306
- ];
45307
-
45308
- class RoomLiveCollectionController extends LiveCollectionController {
45757
+ class GetStreamsLiveCollectionController extends LiveCollectionController {
45309
45758
  constructor(query, callback) {
45310
45759
  const queryStreamId = hash(query);
45311
- const cacheKey = ['rooms', 'collection', queryStreamId];
45312
- const paginationController = new RoomPaginationController(query);
45760
+ const cacheKey = ['streams', 'collection', queryStreamId];
45761
+ const paginationController = new GetStreamsPageController(query);
45313
45762
  super(paginationController, queryStreamId, cacheKey, callback);
45763
+ this.applyFilter = (data) => {
45764
+ let streams = filterByPropEquality(data, 'isDeleted', this.query.isDeleted);
45765
+ streams = streams.sort(this.query.sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
45766
+ return streams;
45767
+ };
45314
45768
  this.query = query;
45315
- this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
45769
+ this.queryStreamController = new GetStreamsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), paginationController);
45770
+ this.paginationController = paginationController;
45316
45771
  this.callback = callback.bind(this);
45317
45772
  this.loadPage({ initial: true });
45318
45773
  }
45319
- setup() {
45320
- var _a;
45321
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
45322
- if (!collection) {
45323
- pushToCache(this.cacheKey, {
45324
- data: [],
45325
- params: {},
45326
- });
45327
- }
45328
- }
45329
- async persistModel(queryPayload) {
45330
- await this.queryStreamController.saveToMainDB(queryPayload);
45331
- }
45332
- persistQueryStream({ response, direction, refresh, }) {
45333
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
45334
- }
45335
- startSubscription() {
45336
- return this.queryStreamController.subscribeRTE(getRoomSubscription());
45337
- }
45338
45774
  notifyChange({ origin, loading, error }) {
45339
- var _a, _b;
45775
+ var _a;
45340
45776
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
45341
45777
  if (!collection)
45342
45778
  return;
45343
- const data = this.applyFilter((_b = collection.data
45344
- .map(id => pullFromCache(['room', 'get', id]))
45345
- .filter(isNonNullable)
45346
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
45779
+ let data = collection.data
45780
+ .map(streamId => pullFromCache(['stream', 'get', streamId]))
45781
+ .filter(Boolean)
45782
+ .map(stream => LinkedObject.stream(stream.data));
45347
45783
  if (!this.shouldNotify(data) && origin === 'event')
45348
45784
  return;
45785
+ data = this.applyFilter(data);
45349
45786
  this.callback({
45350
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
45787
+ onNextPage: () => this.loadPage({ initial: false, direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
45351
45788
  data,
45352
45789
  hasNextPage: !!this.paginationController.getNextToken(),
45353
45790
  loading,
45354
45791
  error,
45355
45792
  });
45356
45793
  }
45357
- applyFilter(data) {
45358
- let rooms = data;
45359
- if (!this.query.includeDeleted) {
45360
- rooms = filterByPropEquality(rooms, 'isDeleted', false);
45361
- }
45362
- if (this.query.statuses && this.query.statuses.length > 0) {
45363
- rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
45364
- }
45365
- if (this.query.type) {
45366
- rooms = filterByPropEquality(rooms, 'type', this.query.type);
45367
- }
45368
- switch (this.query.sortBy) {
45369
- case 'firstCreated':
45370
- rooms = rooms.sort(sortByFirstCreated);
45371
- break;
45372
- case 'lastCreated':
45373
- default:
45374
- rooms = rooms.sort(sortByLastCreated);
45375
- break;
45794
+ startSubscription() {
45795
+ return this.queryStreamController.subscribeRTE([
45796
+ { fn: onStreamRecorded, action: 'onStreamRecorded' },
45797
+ { fn: onStreamStarted, action: 'onStreamStarted' },
45798
+ { fn: onStreamStopped, action: 'onStreamStopped' },
45799
+ { fn: onStreamFlagged, action: 'onStreamFlagged' },
45800
+ { fn: onStreamTerminated, action: 'onStreamTerminated' },
45801
+ { fn: onStreamViewerBanned, action: 'onStreamViewerBanned' },
45802
+ { fn: onStreamViewerUnbanned, action: 'onStreamViewerUnbanned' },
45803
+ ]);
45804
+ }
45805
+ setup() {
45806
+ var _a;
45807
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
45808
+ if (!collection) {
45809
+ pushToCache(this.cacheKey, {
45810
+ data: [],
45811
+ params: {},
45812
+ });
45376
45813
  }
45377
- return rooms;
45814
+ }
45815
+ persistModel(response) {
45816
+ this.queryStreamController.saveToMainDB(response);
45817
+ }
45818
+ persistQueryStream({ response, direction, refresh, }) {
45819
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
45378
45820
  }
45379
45821
  }
45380
45822
 
45381
- /* begin_public_function
45382
- id: room.get_rooms
45383
- */
45384
- /**
45385
- * ```js
45386
- * import { RoomRepository } from '@amityco/ts-sdk'
45387
- *
45388
- * let rooms = []
45389
- * const unsub = RoomRepository.getRooms({
45390
- * type: 'direct_streaming',
45391
- * statuses: ['live', 'idle'],
45392
- * sortBy: 'lastCreated',
45393
- * limit: 20,
45394
- * includeDeleted: false
45395
- * }, response => merge(rooms, response.data))
45396
- * ```
45397
- *
45398
- * Observe all mutations on a list of {@link Amity.Room} for a given query
45399
- *
45400
- * @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
45401
- * @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
45402
- * @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
45403
- * @param params.limit maximum number of rooms to retrieve per page
45404
- * @param params.includeDeleted whether to include deleted rooms in the results
45405
- * @param callback the function to call when new data are available
45406
- * @param config optional configuration for the live collection
45407
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
45408
- *
45409
- * @category Rooms Live Collection
45410
- */
45411
- const getRooms = (params, callback, config) => {
45412
- const { log, cache } = getActiveClient();
45823
+ const getStreams = (params, callback, config) => {
45824
+ const { log, cache, userId } = getActiveClient();
45413
45825
  if (!cache) {
45414
45826
  console.log(ENABLE_CACHE_MESSAGE);
45415
45827
  }
45416
45828
  const timestamp = Date.now();
45417
- log(`getRooms(tmpid: ${timestamp}) > listen`);
45418
- const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
45419
- const disposers = roomsLiveCollection.startSubscription();
45420
- const cacheKey = roomsLiveCollection.getCacheKey();
45421
- disposers.push(() => dropFromCache(cacheKey));
45829
+ log(`getStreams(tmpid: ${timestamp}) > listen`);
45830
+ const liveCollection = new GetStreamsLiveCollectionController(params, callback);
45831
+ const disposers = liveCollection.startSubscription();
45832
+ const cacheKey = liveCollection.getCacheKey();
45833
+ disposers.push(() => {
45834
+ dropFromCache(cacheKey);
45835
+ });
45422
45836
  return () => {
45423
- log(`getRooms(tmpid: ${timestamp}) > dispose`);
45837
+ log(`getStreams(tmpid: ${timestamp}) > dispose`);
45424
45838
  disposers.forEach(fn => fn());
45425
45839
  };
45426
45840
  };
45427
- /* end_public_function */
45428
45841
 
45429
45842
  var index$9 = /*#__PURE__*/Object.freeze({
45430
45843
  __proto__: null,
45431
- createRoom: createRoom,
45432
- updateRoom: updateRoom,
45433
- deleteRoom: deleteRoom,
45434
- stopRoom: stopRoom,
45435
- getBroadcasterData: getBroadcasterData,
45436
- getRecordedUrl: getRecordedUrl,
45437
- removeParticipant: removeParticipant,
45438
- leaveRoom: leaveRoom,
45439
- onRoomStartBroadcasting: onRoomStartBroadcasting,
45440
- onRoomWaitingReconnect: onRoomWaitingReconnect,
45441
- onRoomEndBroadcasting: onRoomEndBroadcasting,
45442
- onRoomRecordedAvailable: onRoomRecordedAvailable,
45443
- onRoomCoHostInvited: onRoomCoHostInvited,
45444
- onRoomCoHostInviteAccepted: onRoomCoHostInviteAccepted,
45445
- onRoomCoHostInviteRejected: onRoomCoHostInviteRejected,
45446
- onRoomCoHostInviteCanceled: onRoomCoHostInviteCanceled,
45447
- onRoomParticipantJoined: onRoomParticipantJoined,
45448
- onRoomParticipantLeft: onRoomParticipantLeft,
45449
- onRoomCreated: onRoomCreated,
45450
- onRoomUpdated: onRoomUpdated,
45451
- onRoomDeleted: onRoomDeleted,
45452
- onRoomStopped: onRoomStopped,
45453
- onRoomParticipantRemoved: onRoomParticipantRemoved,
45454
- onRoomLeft: onRoomLeft,
45455
- getRoom: getRoom,
45456
- getRooms: getRooms
45844
+ createStream: createStream,
45845
+ updateStream: updateStream,
45846
+ deleteStream: deleteStream,
45847
+ disposeStream: disposeStream,
45848
+ editStream: editStream,
45849
+ onStreamStarted: onStreamStarted,
45850
+ onStreamStopped: onStreamStopped,
45851
+ onStreamRecorded: onStreamRecorded,
45852
+ onStreamFlagged: onStreamFlagged,
45853
+ onStreamTerminated: onStreamTerminated,
45854
+ onStreamViewerBanned: onStreamViewerBanned,
45855
+ onStreamViewerUnbanned: onStreamViewerUnbanned,
45856
+ getStreamById: getStreamById,
45857
+ getStreams: getStreams
45457
45858
  });
45458
45859
 
45459
45860
  /* begin_public_function
@@ -45528,7 +45929,6 @@ const getRoomUserCount = async (roomId) => {
45528
45929
  client.log('roomPresence/getRoomUserCount', { roomId });
45529
45930
  const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users/count`);
45530
45931
  pushToCache(['get', 'watchingCount', roomId], data);
45531
- fireEvent('local.room.watchingCountUpdated', data);
45532
45932
  return data;
45533
45933
  };
45534
45934
  /* end_public_function */
@@ -48962,4 +49362,4 @@ var index = /*#__PURE__*/Object.freeze({
48962
49362
  getRSVPs: getRSVPs
48963
49363
  });
48964
49364
 
48965
- export { API_REGIONS, index$4 as AdRepository, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, index$e as CategoryRepository, index$i as ChannelRepository, index$r as Client, index$d as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$f as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$c as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$o as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$m as MessageRepository, index$7 as PollRepository, PostContentType, index$b as PostRepository, PostStructureType, index$n as ReactionRepository, index$8 as RoomPresenceRepository, index$9 as RoomRepository, index$5 as StoryRepository, index$a as StreamRepository, index$l as SubChannelRepository, SubscriptionLevels, index$p as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$3 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
49365
+ export { API_REGIONS, index$4 as AdRepository, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, index$e as CategoryRepository, index$i as ChannelRepository, index$r as Client, index$d as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$f as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$c as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$o as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$m as MessageRepository, index$7 as PollRepository, PostContentType, index$a as PostRepository, PostStructureType, index$n as ReactionRepository, index$8 as RoomPresenceRepository, index$b as RoomRepository, index$5 as StoryRepository, index$9 as StreamRepository, index$l as SubChannelRepository, SubscriptionLevels, index$p as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$3 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };